Loading core/java/android/provider/Settings.java +8 −0 Original line number Diff line number Diff line Loading @@ -7808,6 +7808,14 @@ public final class Settings { public static final String SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION = "suppress_auto_battery_saver_suggestion"; /** * List of packages, which data need to be unconditionally cleared before full restore. * Type: string * @hide */ public static final String PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE = "packages_to_clear_data_before_full_restore"; /** * This are the settings to be backed up. * Loading core/proto/android/providers/settings/secure.proto +1 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ message SecureSettingsProto { optional SettingProto transport = 4 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto manager_constants = 5; optional SettingProto local_transport_parameters = 6; optional SettingProto packages_to_clear_data_before_full_restore = 7; } optional Backup backup = 10; Loading core/tests/coretests/src/android/provider/SettingsBackupTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -587,7 +587,8 @@ public class SettingsBackupTest { Settings.Secure.BLUETOOTH_ON_WHILE_DRIVING, Settings.Secure.LOW_POWER_MANUAL_ACTIVATION_COUNT, Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED, Settings.Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION); Settings.Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE); @Test public void systemSettingsBackedUpOrBlacklisted() { Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +3 −0 Original line number Diff line number Diff line Loading @@ -1724,6 +1724,9 @@ class SettingsProtoDumpUtil { dumpSetting(s, p, Settings.Secure.BACKUP_LOCAL_TRANSPORT_PARAMETERS, SecureSettingsProto.Backup.LOCAL_TRANSPORT_PARAMETERS); dumpSetting(s, p, Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE, SecureSettingsProto.Backup.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE); p.end(backupToken); // Settings.Secure.BLUETOOTH_ON intentionally excluded since it's deprecated. Loading services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java +33 −5 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import android.content.pm.PackageManagerInternal; import android.content.pm.Signature; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.provider.Settings; import android.text.TextUtils; import android.util.Slog; import com.android.internal.util.Preconditions; Loading @@ -55,8 +57,11 @@ import com.android.server.backup.utils.TarBackupReader; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; /** * Full restore engine, used by both adb restore and transport-based full restore. Loading Loading @@ -326,10 +331,15 @@ public class FullRestoreEngine extends RestoreEngine { // If we haven't sent any data to this app yet, we probably // need to clear it first. Check that. if (!mClearedPackages.contains(pkg)) { // apps with their own backup agents are // responsible for coherently managing a full // restore. if (mTargetApp.backupAgentName == null) { // Apps with their own backup agents are responsible for coherently // managing a full restore. // In some rare cases they can't, especially in case of deferred // restore. In this case check whether this app should be forced to // clear up. // TODO: Fix this properly with manifest parameter. boolean forceClear = shouldForceClearAppDataOnFullRestore( mTargetApp.packageName); if (mTargetApp.backupAgentName == null || forceClear) { if (DEBUG) { Slog.d(TAG, "Clearing app data preparatory to full restore"); Loading Loading @@ -627,6 +637,24 @@ public class FullRestoreEngine extends RestoreEngine { return true; } /** * Returns whether the package is in the list of the packages for which clear app data should * be called despite the fact that they have backup agent. * * <p>The list is read from {@link Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE}. */ private boolean shouldForceClearAppDataOnFullRestore(String packageName) { String packageListString = Settings.Secure.getString( mBackupManagerService.getContext().getContentResolver(), Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE); if (TextUtils.isEmpty(packageListString)) { return false; } List<String> packages = Arrays.asList(packageListString.split(";")); return packages.contains(packageName); } void sendOnRestorePackage(String name) { if (mObserver != null) { try { Loading Loading
core/java/android/provider/Settings.java +8 −0 Original line number Diff line number Diff line Loading @@ -7808,6 +7808,14 @@ public final class Settings { public static final String SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION = "suppress_auto_battery_saver_suggestion"; /** * List of packages, which data need to be unconditionally cleared before full restore. * Type: string * @hide */ public static final String PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE = "packages_to_clear_data_before_full_restore"; /** * This are the settings to be backed up. * Loading
core/proto/android/providers/settings/secure.proto +1 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ message SecureSettingsProto { optional SettingProto transport = 4 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto manager_constants = 5; optional SettingProto local_transport_parameters = 6; optional SettingProto packages_to_clear_data_before_full_restore = 7; } optional Backup backup = 10; Loading
core/tests/coretests/src/android/provider/SettingsBackupTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -587,7 +587,8 @@ public class SettingsBackupTest { Settings.Secure.BLUETOOTH_ON_WHILE_DRIVING, Settings.Secure.LOW_POWER_MANUAL_ACTIVATION_COUNT, Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED, Settings.Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION); Settings.Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE); @Test public void systemSettingsBackedUpOrBlacklisted() { Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +3 −0 Original line number Diff line number Diff line Loading @@ -1724,6 +1724,9 @@ class SettingsProtoDumpUtil { dumpSetting(s, p, Settings.Secure.BACKUP_LOCAL_TRANSPORT_PARAMETERS, SecureSettingsProto.Backup.LOCAL_TRANSPORT_PARAMETERS); dumpSetting(s, p, Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE, SecureSettingsProto.Backup.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE); p.end(backupToken); // Settings.Secure.BLUETOOTH_ON intentionally excluded since it's deprecated. Loading
services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java +33 −5 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import android.content.pm.PackageManagerInternal; import android.content.pm.Signature; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.provider.Settings; import android.text.TextUtils; import android.util.Slog; import com.android.internal.util.Preconditions; Loading @@ -55,8 +57,11 @@ import com.android.server.backup.utils.TarBackupReader; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; /** * Full restore engine, used by both adb restore and transport-based full restore. Loading Loading @@ -326,10 +331,15 @@ public class FullRestoreEngine extends RestoreEngine { // If we haven't sent any data to this app yet, we probably // need to clear it first. Check that. if (!mClearedPackages.contains(pkg)) { // apps with their own backup agents are // responsible for coherently managing a full // restore. if (mTargetApp.backupAgentName == null) { // Apps with their own backup agents are responsible for coherently // managing a full restore. // In some rare cases they can't, especially in case of deferred // restore. In this case check whether this app should be forced to // clear up. // TODO: Fix this properly with manifest parameter. boolean forceClear = shouldForceClearAppDataOnFullRestore( mTargetApp.packageName); if (mTargetApp.backupAgentName == null || forceClear) { if (DEBUG) { Slog.d(TAG, "Clearing app data preparatory to full restore"); Loading Loading @@ -627,6 +637,24 @@ public class FullRestoreEngine extends RestoreEngine { return true; } /** * Returns whether the package is in the list of the packages for which clear app data should * be called despite the fact that they have backup agent. * * <p>The list is read from {@link Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE}. */ private boolean shouldForceClearAppDataOnFullRestore(String packageName) { String packageListString = Settings.Secure.getString( mBackupManagerService.getContext().getContentResolver(), Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE); if (TextUtils.isEmpty(packageListString)) { return false; } List<String> packages = Arrays.asList(packageListString.split(";")); return packages.contains(packageName); } void sendOnRestorePackage(String name) { if (mObserver != null) { try { Loading