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

Commit b74f796d authored by Edward Cunningham's avatar Edward Cunningham
Browse files

Fix to allow self-updates without user action.

Check if the *current* installer package (ie. the session owner) is
allowed to install packages when deciding if user action is needed. We
were mistakenly checking the *existing* installer package (ie. installer
of record) instead, which prevented self-updates.

Bug: 184741940
Test: Manual with local test app.
Change-Id: Ie0aec7a34ead94788af462002d6dccf420f9f50b
parent 53bdb4b8
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -948,14 +948,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                == PackageManager.PERMISSION_GRANTED);
        final int targetPackageUid = mPm.getPackageUid(packageName, 0, userId);
        final boolean isUpdate = targetPackageUid != -1;
        final InstallSourceInfo installSourceInfo = isUpdate
        final InstallSourceInfo existingInstallSourceInfo = isUpdate
                ? mPm.getInstallSourceInfo(packageName)
                : null;
        final String installerPackageName = installSourceInfo != null
                ? installSourceInfo.getInstallingPackageName()
        final String existingInstallerPackageName = existingInstallSourceInfo != null
                ? existingInstallSourceInfo.getInstallingPackageName()
                : null;
        final boolean isInstallerOfRecord = isUpdate
                && Objects.equals(installerPackageName, getInstallerPackageName());
                && Objects.equals(existingInstallerPackageName, getInstallerPackageName());
        final boolean isSelfUpdate = targetPackageUid == mInstallerUid;
        final boolean isPermissionGranted = isInstallPermissionGranted
                || (isUpdatePermissionGranted && isUpdate)
@@ -972,7 +972,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            return USER_ACTION_NOT_NEEDED;
        }

        if (mPm.isInstallDisabledForPackage(installerPackageName, mInstallerUid, userId)) {
        if (mPm.isInstallDisabledForPackage(getInstallerPackageName(), mInstallerUid, userId)) {
            // show the installer to account for device poslicy or unknown sources use cases
            return USER_ACTION_REQUIRED;
        }