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 <aayushgupta219@gmail.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user