Respect android:allowClearUserData=false during restore
Ordinarily we wipe the data of apps we are restoring. This is problematic for
packages that expect that their data can never be wiped back to nothing,
especially system packages, so we now respect the android:allowClearUserData
manifest attribute.
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 8297aa2..c0f0d74 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -529,6 +529,19 @@
// clear an application's data, blocking until the operation completes or times out
void clearApplicationDataSynchronous(String packageName) {
+ // Don't wipe packages marked allowClearUserData=false
+ try {
+ PackageInfo info = mPackageManager.getPackageInfo(packageName, 0);
+ if ((info.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA) == 0) {
+ if (DEBUG) Log.i(TAG, "allowClearUserData=false so not wiping "
+ + packageName);
+ return;
+ }
+ } catch (NameNotFoundException e) {
+ Log.w(TAG, "Tried to clear data for " + packageName + " but not found");
+ return;
+ }
+
ClearDataObserver observer = new ClearDataObserver();
synchronized(mClearDataLock) {