[DataStore] Migrate LocaleNotification SharedPreferences to BackupRestoreStorage
Bug: 325144964 Test: Manual tests Change-Id: I195ee91f29030fcfe7176ed0c18fb2e2d0d40257
This commit is contained in:
@@ -30,6 +30,7 @@ import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||
import com.android.settings.core.instrumentation.ElapsedTimeUtils;
|
||||
import com.android.settings.fuelgauge.BatterySettingsStorage;
|
||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||
import com.android.settings.localepicker.LocaleNotificationDataManager;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.overlay.FeatureFactoryImpl;
|
||||
import com.android.settings.spa.SettingsSpaEnvironment;
|
||||
@@ -56,7 +57,10 @@ public class SettingsApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
BackupRestoreStorageManager.getInstance(this).add(new BatterySettingsStorage(this));
|
||||
BackupRestoreStorageManager.getInstance(this)
|
||||
.add(
|
||||
new BatterySettingsStorage(this),
|
||||
LocaleNotificationDataManager.getSharedPreferencesStorage(this));
|
||||
|
||||
// Add null checking to avoid test case failed.
|
||||
if (getApplicationContext() != null) {
|
||||
|
@@ -16,10 +16,8 @@
|
||||
|
||||
package com.android.settings.backup;
|
||||
|
||||
import static com.android.settings.localepicker.LocaleNotificationDataManager.LOCALE_NOTIFICATION;
|
||||
|
||||
import android.app.backup.BackupAgentHelper;
|
||||
import android.app.backup.SharedPreferencesBackupHelper;
|
||||
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.onboarding.OnboardingFeatureProvider;
|
||||
@@ -29,15 +27,12 @@ import com.android.settingslib.datastore.BackupRestoreStorageManager;
|
||||
|
||||
/** Backup agent for Settings APK */
|
||||
public class SettingsBackupHelper extends BackupAgentHelper {
|
||||
private static final String PREF_LOCALE_NOTIFICATION = "localeNotificationSharedPref";
|
||||
public static final String SOUND_BACKUP_HELPER = "SoundSettingsBackup";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
BackupRestoreStorageManager.getInstance(this).addBackupAgentHelpers(this);
|
||||
addHelper(PREF_LOCALE_NOTIFICATION,
|
||||
new SharedPreferencesBackupHelper(this, LOCALE_NOTIFICATION));
|
||||
if (Flags.enableSoundBackup()) {
|
||||
OnboardingFeatureProvider onboardingFeatureProvider =
|
||||
FeatureFactory.getFeatureFactory().getOnboardingFeatureProvider();
|
||||
|
@@ -19,8 +19,11 @@ package com.android.settings.localepicker;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settingslib.datastore.SharedPreferencesStorage;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -43,6 +46,12 @@ public class LocaleNotificationDataManager {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
/** Returns the underlying {@link SharedPreferences} storage. */
|
||||
@NonNull
|
||||
public static SharedPreferencesStorage getSharedPreferencesStorage(@NonNull Context context) {
|
||||
return new SharedPreferencesStorage(context, LOCALE_NOTIFICATION, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
private static SharedPreferences getSharedPreferences(Context context) {
|
||||
return context.getSharedPreferences(LOCALE_NOTIFICATION, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user