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

Commit 295068d3 authored by Gavin Corkery's avatar Gavin Corkery Committed by Android (Google) Code Review
Browse files

Merge "Check eligibility before calling snapshotAndRestoreUserData"

parents 0383ea90 fd42d3c9
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -13852,7 +13852,7 @@ public class PackageManagerService extends IPackageManager.Stub
        // If this is an update to a package that might be potentially downgraded, then we
        // need to check with the rollback manager whether there's any userdata that might
        // need to be restored for the package.
        // need to be snapshotted or restored for the package.
        //
        // TODO(narayan): Get this working for cases where userId == UserHandle.USER_ALL.
        if (res.returnCode == PackageManager.INSTALL_SUCCEEDED && !doRestore && update) {
@@ -13879,12 +13879,16 @@ public class PackageManagerService extends IPackageManager.Stub
                installedUsers = ps.queryInstalledUsers(allUsers, true);
            }
            if (ps != null) {
            boolean doSnapshotOrRestore = data != null && data.args != null
                    && ((data.args.installFlags & PackageManager.INSTALL_ENABLE_ROLLBACK) != 0
                    || (data.args.installFlags & PackageManager.INSTALL_REQUEST_DOWNGRADE) != 0);
            if (ps != null && doSnapshotOrRestore) {
                try {
                    rm.snapshotAndRestoreUserData(packageName, installedUsers, appId, ceDataInode,
                            seInfo, token);
                } catch (RemoteException re) {
                    // Cannot happen, the RollbackManager is hosted in the same process.
                    Log.e(TAG, "Error snapshotting/restoring user data: " + re);
                }
                doRestore = true;
            }