Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7c886b4 authored by Christopher Tate's avatar Christopher Tate
Browse files

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.
parent bd1e8aa5
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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) {