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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user