From f7c886b4fe27cd9ab4a9991958ff931054556a24 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Fri, 26 Jun 2009 15:34:09 -0700 Subject: [PATCH] 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. --- .../com/android/server/BackupManagerService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 8297aa210ac13..c0f0d749eb95f 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -529,6 +529,19 @@ class BackupManagerService extends IBackupManager.Stub { // 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) {