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

Commit 26d71a68 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

[PM] Keep the value of isPendingRestore in share user changed

When the value of isPendingRestore is true, even if we create the
new PackageSettings in share user changed case, we still need to
set the value of isPendingRestore to true in new PackageSettings.

Bug: 334996345
Test: manual. 1. Create the backup and factory reset the device
              2. Enable archive install in store app
              3. Restore the app (share user changed) in setupwizard
	      4. Unarchive the app. Check the permission is restored
Change-Id: I45c410193377add028bcd0ffaa1d85444ba20f5b
parent d725ff4f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ final class ScanPackageUtils {
            }
        }

        boolean isPendingRestoreBefore = false;
        if (pkgSetting != null && oldSharedUserSetting != sharedUserSetting) {
            PackageManagerService.reportSettingsProblem(Log.WARN,
                    "Package " + parsedPackage.getPackageName() + " shared user changed from "
@@ -178,6 +179,9 @@ final class ScanPackageUtils {
                            + " to "
                            + (sharedUserSetting != null ? sharedUserSetting.name : "<nothing>")
                            + "; replacing with new");
            // Preserve the value of isPendingRestore. We need to set it to the new PackageSetting
            // if the value is true to restore the app
            isPendingRestoreBefore = pkgSetting.isPendingRestore();
            pkgSetting = null;
        }

@@ -224,6 +228,11 @@ final class ScanPackageUtils {
                    parsedPackage.getUsesStaticLibrariesVersions(), parsedPackage.getMimeGroups(),
                    newDomainSetId,
                    parsedPackage.getTargetSdkVersion(), parsedPackage.getRestrictUpdateHash());

            // If isPendingRestore is true before, set the value true to the PackageSetting
            if (isPendingRestoreBefore) {
                pkgSetting.setPendingRestore(true);
            }
        } else {
            // make a deep copy to avoid modifying any existing system state.
            pkgSetting = new PackageSetting(pkgSetting);