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

Commit 56a3c70d authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Exempting privileged apps from permission check in package installer

If a privileged app does want to be treated as a trusted source, it can
pass in the extra EXTRA_NOT_UNKNOWN_SOURCE and does not need to declare
the permission REQUEST_INSTALL_PACKAGES. In such a case it will not be
shown in the list under settings to the user.

Test: Manually tested that sync auth successfully installs dpc during
profile provisioning flow

Bug: 37623444
Change-Id: I70083980f3b8e43de78d2f1a781d55e19fdc00ee
parent ef54ec21
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -64,10 +64,15 @@ public class InstallStart extends Activity {
            callingPackage = (sessionInfo != null) ? sessionInfo.getInstallerPackageName() : null;
        }

        ApplicationInfo sourceInfo = getSourceInfo(callingPackage);
        final ApplicationInfo sourceInfo = getSourceInfo(callingPackage);
        final int originatingUid = getOriginatingUid(sourceInfo);
        boolean isTrustedSource = false;
        if (sourceInfo != null
                && (sourceInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) {
            isTrustedSource = intent.getBooleanExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false);
        }

        if (originatingUid != PackageInstaller.SessionParams.UID_UNKNOWN) {
        if (!isTrustedSource && originatingUid != PackageInstaller.SessionParams.UID_UNKNOWN) {
            final int targetSdkVersion = getMaxTargetSdkVersionForUid(originatingUid);
            if (targetSdkVersion < 0) {
                Log.w(LOG_TAG, "Cannot get target sdk version for uid " + originatingUid);