From be42199d7645df9fa6b8ba5792a92ddec760b378 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Mon, 10 Jun 2024 10:53:14 +0530 Subject: [PATCH] MigrationReceiver: Remove default dispenser from App Gallery builds While default dispenser is not added for existing installs on App Gallery builds, existing installs still had default dispenser preseved which is not an intended behavior. Signed-off-by: Aayush Gupta --- .../store/data/receiver/MigrationReceiver.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/aurora/store/data/receiver/MigrationReceiver.kt b/app/src/main/java/com/aurora/store/data/receiver/MigrationReceiver.kt index d5265ab08..40513cea1 100644 --- a/app/src/main/java/com/aurora/store/data/receiver/MigrationReceiver.kt +++ b/app/src/main/java/com/aurora/store/data/receiver/MigrationReceiver.kt @@ -7,6 +7,7 @@ import android.util.Log import com.aurora.Constants import com.aurora.extensions.isSAndAbove import com.aurora.store.data.work.CacheWorker +import com.aurora.store.util.CertUtil import com.aurora.store.util.Preferences import com.aurora.store.util.Preferences.PREFERENCE_DISPENSER_URLS import com.aurora.store.util.Preferences.PREFERENCE_INTRO @@ -21,7 +22,7 @@ class MigrationReceiver: BroadcastReceiver() { private val TAG = MigrationReceiver::class.java.simpleName - private val prefVersion = 1 // BUMP THIS MANUALLY ON ADDING NEW MIGRATION STEP + private val prefVersion = 2 // BUMP THIS MANUALLY ON ADDING NEW MIGRATION STEP override fun onReceive(context: Context?, intent: Intent?) { if (context != null && intent?.action == Intent.ACTION_MY_PACKAGE_REPLACED) { @@ -53,6 +54,17 @@ class MigrationReceiver: BroadcastReceiver() { currentVersion++ } + // 59 -> 60 + if (currentVersion == 1) { + if (CertUtil.isAppGalleryApp(context, context.packageName)) { + val dispensers = Preferences.getStringSet(context, PREFERENCE_DISPENSER_URLS) + .toMutableSet() + .remove(Constants.URL_DISPENSER) + context.save(PREFERENCE_DISPENSER_URLS, dispensers) + } + currentVersion++ + } + // Add new migrations / defaults above this point. if (currentVersion != prefVersion) { Log.e(TAG, "Upgrading to version $prefVersion left it at $currentVersion instead")