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

Commit 13cd7b33 authored by Peter Visontay's avatar Peter Visontay
Browse files

Change the permission check of the REQUEST_INSTALL_PACKAGES App Op to the...

Change the permission check of the REQUEST_INSTALL_PACKAGES App Op to the semantically more correct noteOp*().

Also enable the logging of this operation via App Ops.

Bug: 63907873
Test: manually using the 3 install methods (intent and session-based) in ApiDemos.
Test: Ran GTS tests: GtsPackageInstallSessionTestCases, GtsExternalSourcesTestCases, GtsExternalSourcesNegativeTestCases
Test: Test command: run singleCommand gts-dev -m [gtsPackageName]
Change-Id: I3cf3603fec7eabcb902b401fef15561f6bb60697
parent 2fa59c32
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -290,8 +290,16 @@ public class PackageInstallerActivity extends OverlayTouchActivity implements On
    @Override
    public void onActivityResult(int request, int result, Intent data) {
        if (request == REQUEST_TRUST_EXTERNAL_SOURCE && result == RESULT_OK) {
            // The user has just allowed this package to install other packages (via Settings).
            mAllowUnknownSources = true;

            // Log the fact that the app is requesting an install, and is now allowed to do it
            // (before this point we could only log that it's requesting an install, but isn't
            // allowed to do it yet).
            int appOpCode =
                    AppOpsManager.permissionToOpCode(Manifest.permission.REQUEST_INSTALL_PACKAGES);
            mAppOpsManager.noteOpNoThrow(appOpCode, mOriginatingUid, mOriginatingPackage);

            Fragment currentDialog = getFragmentManager().findFragmentByTag("dialog");
            if (currentDialog != null) {
                getFragmentManager().beginTransaction().remove(currentDialog).commit();
@@ -522,7 +530,7 @@ public class PackageInstallerActivity extends OverlayTouchActivity implements On
        // Shouldn't use static constant directly, see b/65534401.
        final int appOpCode =
                AppOpsManager.permissionToOpCode(Manifest.permission.REQUEST_INSTALL_PACKAGES);
        final int appOpMode = mAppOpsManager.checkOpNoThrow(appOpCode,
        final int appOpMode = mAppOpsManager.noteOpNoThrow(appOpCode,
                mOriginatingUid, mOriginatingPackage);
        switch (appOpMode) {
            case AppOpsManager.MODE_DEFAULT: