Merge "Add sound related B&R function for Onboarding" into main

This commit is contained in:
XingHai Lu
2023-11-22 10:12:53 +00:00
committed by Android (Google) Code Review
3 changed files with 23 additions and 1 deletions

View File

@@ -26,17 +26,21 @@ import android.app.backup.SharedPreferencesBackupHelper;
import android.os.ParcelFileDescriptor;
import com.android.settings.fuelgauge.BatteryBackupHelper;
import com.android.settings.onboarding.OnboardingFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.shortcut.CreateShortcutPreferenceController;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import com.android.settings.flags.Flags;
/**
* 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() {
@@ -45,6 +49,14 @@ public class SettingsBackupHelper extends BackupAgentHelper {
addHelper(BatteryBackupHelper.TAG, new BatteryBackupHelper(this));
addHelper(PREF_LOCALE_NOTIFICATION,
new SharedPreferencesBackupHelper(this, LOCALE_NOTIFICATION));
if (Flags.enableSoundBackup()) {
OnboardingFeatureProvider onboardingFeatureProvider =
FeatureFactory.getFeatureFactory().getOnboardingFeatureProvider();
if (onboardingFeatureProvider != null) {
addHelper(SOUND_BACKUP_HELPER, onboardingFeatureProvider.
getSoundBackupHelper(this, this.getBackupRestoreEventLogger()));
}
}
}
@Override

View File

@@ -15,6 +15,8 @@
*/
package com.android.settings.onboarding
import android.app.backup.BackupHelper
import android.app.backup.BackupRestoreEventLogger
import android.content.Context
/**
@@ -29,4 +31,12 @@ interface OnboardingFeatureProvider {
* @param preferenceKey The key to distinguish which preference has been changed.
*/
fun markPreferenceHasChanged(context: Context, preferenceKey: String)
/**
* Return a BackupHelper for backup sound related settings.
*
* @param context App context
* @param logger To log B&R stats.
*/
fun getSoundBackupHelper(context: Context, logger: BackupRestoreEventLogger): BackupHelper
}

View File

@@ -162,7 +162,7 @@ abstract class FeatureFactory {
abstract val stylusFeatureProvider: StylusFeatureProvider
/**
* Retrieves implementation for TogglePreference feature.
* Retrieves implementation for Onboarding related feature.
*/
open val onboardingFeatureProvider: OnboardingFeatureProvider? = null