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

Commit 2f34b1a6 authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Adding app op and intent action for external sources

Added an app op to control which package and uid can install apps on the
device and an intent action to launch the settings fragment.

Test: Will include in follow up CL, tracked in b/33792674

Bug: 31002700
Change-Id: Ic073495759d9867f8001a6c712e402398c53dfc9
parent bcd68cf5
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -243,8 +243,10 @@ public class AppOpsManager {
    public static final int OP_AUDIO_ACCESSIBILITY_VOLUME = 64;
    /** @hide Read the phone number. */
    public static final int OP_READ_PHONE_NUMBER = 65;
    /** @hide Request package installs through package installer */
    public static final int OP_REQUEST_INSTALL_PACKAGES = 66;
    /** @hide */
    public static final int _NUM_OP = 66;
    public static final int _NUM_OP = 67;

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -461,6 +463,7 @@ public class AppOpsManager {
            OP_RUN_IN_BACKGROUND,
            OP_AUDIO_ACCESSIBILITY_VOLUME,
            OP_READ_PHONE_NUMBER,
            OP_REQUEST_INSTALL_PACKAGES,
    };

    /**
@@ -534,6 +537,7 @@ public class AppOpsManager {
            null,
            null, // OP_AUDIO_ACCESSIBILITY_VOLUME
            OPSTR_READ_PHONE_NUMBER,
            null, // OP_REQUEST_INSTALL_PACKAGES
    };

    /**
@@ -607,6 +611,7 @@ public class AppOpsManager {
            "RUN_IN_BACKGROUND",
            "AUDIO_ACCESSIBILITY_VOLUME",
            "READ_PHONE_NUMBER",
            "REQUEST_INSTALL_PACKAGES",
    };

    /**
@@ -680,6 +685,7 @@ public class AppOpsManager {
            null, // no permission for running in background
            null, // no permission for changing accessibility volume
            Manifest.permission.READ_PHONE_NUMBER,
            Manifest.permission.REQUEST_INSTALL_PACKAGES,
    };

    /**
@@ -754,6 +760,7 @@ public class AppOpsManager {
            null, // RUN_IN_BACKGROUND
            UserManager.DISALLOW_ADJUST_VOLUME, //AUDIO_ACCESSIBILITY_VOLUME
            null, // READ_PHONE_NUMBER
            null, // REQUEST_INSTALL_PACKAGES
    };

    /**
@@ -827,6 +834,7 @@ public class AppOpsManager {
            false, // RUN_IN_BACKGROUND
            false, // AUDIO_ACCESSIBILITY_VOLUME
            false, // READ_PHONE_NUMBER
            false, // REQUEST_INSTALL_PACKAGES
    };

    /**
@@ -899,6 +907,7 @@ public class AppOpsManager {
            AppOpsManager.MODE_ALLOWED,  // OP_RUN_IN_BACKGROUND
            AppOpsManager.MODE_ALLOWED,  // OP_AUDIO_ACCESSIBILITY_VOLUME
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_DEFAULT, // OP_REQUEST_INSTALL_PACKAGES
    };

    /**
@@ -975,6 +984,7 @@ public class AppOpsManager {
            false,
            false, // OP_AUDIO_ACCESSIBILITY_VOLUME
            false,
            false, // OP_REQUEST_INSTALL_PACKAGES
    };

    /**
+15 −0
Original line number Diff line number Diff line
@@ -285,6 +285,21 @@ public final class Settings {
    public static final String ACTION_SECURITY_SETTINGS =
            "android.settings.SECURITY_SETTINGS";

    /**
     * Activity Action: Show settings to allow configuration of trusted external sources
     * <p>
     * In some cases, a matching Activity may not exist, so ensure you
     * safeguard against this.
     * <p>
     * Input: Nothing.
     * <p>
     * Output: Nothing.
     * @hide
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_MANAGE_EXTERNAL_SOURCES =
            "android.settings.action.MANAGE_EXTERNAL_SOURCES";

    /**
     * Activity Action: Show trusted credentials settings, opening to the user tab,
     * to allow management of installed credentials.
+2 −2
Original line number Diff line number Diff line
@@ -2480,14 +2480,14 @@
        android:protectionLevel="signature" />

    <!-- Allows an application to request installing packages. Apps
         targeting APIs greater than 22 must hold this permission in
         targeting APIs greater than 25 must hold this permission in
         order to use {@link android.content.Intent#ACTION_INSTALL_PACKAGE}.
         <p>Protection level: normal
    -->
    <permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"
        android:label="@string/permlab_requestInstallPackages"
        android:description="@string/permdesc_requestInstallPackages"
        android:protectionLevel="normal" />
        android:protectionLevel="signature|appop" />

    <!-- @SystemApi Allows an application to install packages.
    <p>Not for use by third-party applications. -->
+5 −0
Original line number Diff line number Diff line
@@ -3306,6 +3306,11 @@ message MetricsEvent {
    // ACTION: "Force stop" action on an app
    ACTION_APP_FORCE_STOP = 807;

    // OPEN: Settings > Apps > Gear > Special Access > Install other apps
    // CATEGORY: SETTINGS
    // OS: 8.0
    MANAGE_EXTERNAL_SOURCES = 808;

    // ---- End O Constants, all O constants go above this line ----

    // Add new aosp constants above this line.