From 5bc871d58107223ee18228477c067b5a6a2f00e6 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Thu, 26 May 2022 20:16:25 +0600 Subject: [PATCH 1/2] App lounge: handled app update for paid and anonymous user --- .../e/apps/updates/manager/UpdatesWorker.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt index bd2dc6fd3..ea7964f9a 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt @@ -117,13 +117,8 @@ class UpdatesWorker @AssistedInject constructor( authData: AuthData ) { appsNeededToUpdate.forEach { fusedApp -> - if (!fusedApp.isFree) { - val purchaseHelper = PurchaseHelper(authData) - purchaseHelper.purchase( - fusedApp.package_name, - fusedApp.latest_version_code, - fusedApp.offer_type - ) + if (!fusedApp.isFree && authData.isAnonymous) { + return@forEach } val iconBase64 = getIconImageToBase64(fusedApp) @@ -144,7 +139,12 @@ class UpdatesWorker @AssistedInject constructor( fusedApp.originalSize ) - updateFusedDownloadWithAppDownloadLink(fusedApp, authData, fusedDownload) + try { + updateFusedDownloadWithAppDownloadLink(fusedApp, authData, fusedDownload) + } catch (e: Exception) { + e.printStackTrace() + return@forEach + } fusedManagerRepository.addDownload(fusedDownload) fusedManagerRepository.updateAwaiting(fusedDownload) -- GitLab From 07fc7b2114a2e33a4bc1ef84de148acb982a1505 Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Fri, 27 May 2022 10:08:14 +0600 Subject: [PATCH 2/2] App Lounge: DB creation is synchronized --- .../e/apps/api/fused/FusedAPIImpl.kt | 1 - .../e/apps/manager/database/DatabaseModule.kt | 10 +-------- .../e/apps/manager/database/FusedDatabase.kt | 21 ++++++++++++++++++- .../e/apps/updates/manager/UpdatesWorker.kt | 1 - 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt index aaeaab818..44a8fa60e 100644 --- a/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +++ b/app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt @@ -215,7 +215,6 @@ class FusedAPIImpl @Inject constructor( } } } - } suspend fun getSearchSuggestions(query: String, authData: AuthData): List { diff --git a/app/src/main/java/foundation/e/apps/manager/database/DatabaseModule.kt b/app/src/main/java/foundation/e/apps/manager/database/DatabaseModule.kt index 678c91003..d2cf3fd03 100644 --- a/app/src/main/java/foundation/e/apps/manager/database/DatabaseModule.kt +++ b/app/src/main/java/foundation/e/apps/manager/database/DatabaseModule.kt @@ -1,7 +1,6 @@ package foundation.e.apps.manager.database import android.content.Context -import androidx.room.Room import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -13,17 +12,10 @@ import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) object DatabaseModule { - - private const val DATABASE_NAME = "fused_database" - @Singleton @Provides fun provideDatabaseInstance(@ApplicationContext context: Context): FusedDatabase { - return Room.databaseBuilder( - context, - FusedDatabase::class.java, - DATABASE_NAME - ).fallbackToDestructiveMigration().build() + return FusedDatabase.getInstance(context) } @Singleton diff --git a/app/src/main/java/foundation/e/apps/manager/database/FusedDatabase.kt b/app/src/main/java/foundation/e/apps/manager/database/FusedDatabase.kt index 51f106117..c8b4c080c 100644 --- a/app/src/main/java/foundation/e/apps/manager/database/FusedDatabase.kt +++ b/app/src/main/java/foundation/e/apps/manager/database/FusedDatabase.kt @@ -1,14 +1,33 @@ package foundation.e.apps.manager.database +import android.content.Context import androidx.room.Database +import androidx.room.Room import androidx.room.RoomDatabase import androidx.room.TypeConverters +import foundation.e.apps.api.database.AppDatabase import foundation.e.apps.manager.database.fusedDownload.FusedDownload import foundation.e.apps.manager.database.fusedDownload.FusedDownloadDAO @Database(entities = [FusedDownload::class], version = 2, exportSchema = false) @TypeConverters(FusedConverter::class) abstract class FusedDatabase : RoomDatabase() { - abstract fun fusedDownloadDao(): FusedDownloadDAO + + companion object { + private lateinit var INSTANCE: FusedDatabase + private const val DATABASE_NAME = "fused_database" + + fun getInstance(context: Context): FusedDatabase { + if (!Companion::INSTANCE.isInitialized) { + synchronized(AppDatabase::class) { + INSTANCE = + Room.databaseBuilder(context, FusedDatabase::class.java, DATABASE_NAME) + .fallbackToDestructiveMigration() + .build() + } + } + return INSTANCE + } + } } diff --git a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt index ea7964f9a..70ead846c 100644 --- a/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt +++ b/app/src/main/java/foundation/e/apps/updates/manager/UpdatesWorker.kt @@ -14,7 +14,6 @@ import androidx.preference.PreferenceManager import androidx.work.CoroutineWorker import androidx.work.WorkerParameters import com.aurora.gplayapi.data.models.AuthData -import com.aurora.gplayapi.helpers.PurchaseHelper import com.google.gson.Gson import dagger.assisted.Assisted import dagger.assisted.AssistedInject -- GitLab