MigrationReceiver: Remove non-required general and alert notification channels

They have been renamed to downloads, install and export

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-10-07 15:28:21 +05:30
parent 376bdb3fbc
commit 1438cb9435

View File

@@ -1,10 +1,13 @@
package com.aurora.store.data.receiver package com.aurora.store.data.receiver
import android.app.NotificationManager
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.util.Log import android.util.Log
import androidx.core.content.getSystemService
import com.aurora.Constants import com.aurora.Constants
import com.aurora.extensions.isOAndAbove
import com.aurora.store.data.work.CacheWorker import com.aurora.store.data.work.CacheWorker
import com.aurora.store.util.CertUtil import com.aurora.store.util.CertUtil
import com.aurora.store.util.Preferences import com.aurora.store.util.Preferences
@@ -21,7 +24,7 @@ class MigrationReceiver : BroadcastReceiver() {
companion object { companion object {
private const val TAG = "MigrationReceiver" private const val TAG = "MigrationReceiver"
private const val PREF_VERSION = 2 // BUMP THIS MANUALLY ON ADDING NEW MIGRATION STEP private const val PREF_VERSION = 3 // BUMP THIS MANUALLY ON ADDING NEW MIGRATION STEP
fun runMigrationsIfRequired(context: Context) { fun runMigrationsIfRequired(context: Context) {
val oldVersion = Preferences.getInteger(context, PREFERENCE_MIGRATION_VERSION) val oldVersion = Preferences.getInteger(context, PREFERENCE_MIGRATION_VERSION)
@@ -65,6 +68,17 @@ class MigrationReceiver : BroadcastReceiver() {
currentVersion++ currentVersion++
} }
// 63 -> 64
if (currentVersion == 2) {
if (isOAndAbove()) {
with(context.getSystemService<NotificationManager>()!!) { // !1189
deleteNotificationChannel("NOTIFICATION_CHANNEL_GENERAL")
deleteNotificationChannel("NOTIFICATION_CHANNEL_ALERT")
}
}
currentVersion++
}
// Add new migrations / defaults above this point. // Add new migrations / defaults above this point.
if (currentVersion != PREF_VERSION) { if (currentVersion != PREF_VERSION) {
Log.e(TAG, "Upgrading to version $PREF_VERSION left it at $currentVersion instead") Log.e(TAG, "Upgrading to version $PREF_VERSION left it at $currentVersion instead")