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

Commit 414f5c6c authored by Varun Shah's avatar Varun Shah
Browse files

Introduce a new permission for LRJ.

Add a new permission "RUN_LONG_JOBS" for apps which lets them schedule
long running jobs.

Since this will be a "normal|appop" permission, add the AppOps logic as
well.

Bug: 255038128
Test: build/manual
Change-Id: I27637f2a502bbd615df2d6fb0e558bece60ddaf0
parent 7d9ac5fc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@ package android {
    field public static final String REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE = "android.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE";
    field public static final String REQUEST_PASSWORD_COMPLEXITY = "android.permission.REQUEST_PASSWORD_COMPLEXITY";
    field @Deprecated public static final String RESTART_PACKAGES = "android.permission.RESTART_PACKAGES";
    field public static final String RUN_LONG_JOBS = "android.permission.RUN_LONG_JOBS";
    field public static final String SCHEDULE_EXACT_ALARM = "android.permission.SCHEDULE_EXACT_ALARM";
    field public static final String SEND_RESPOND_VIA_MESSAGE = "android.permission.SEND_RESPOND_VIA_MESSAGE";
    field public static final String SEND_SMS = "android.permission.SEND_SMS";
+19 −2
Original line number Diff line number Diff line
@@ -1353,9 +1353,16 @@ public class AppOpsManager {
    public static final int OP_RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO =
            AppProtoEnums.APP_OP_RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO;

    /**
     * App can schedule long running jobs.
     *
     * @hide
     */
    public static final int OP_RUN_LONG_JOBS = AppProtoEnums.APP_OP_RUN_LONG_JOBS;

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public static final int _NUM_OP = 122;
    public static final int _NUM_OP = 123;

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -1839,6 +1846,13 @@ public class AppOpsManager {
    public static final String OPSTR_RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO =
            "android:receive_explicit_user_interaction_audio";

    /**
     * App can schedule long running jobs.
     *
     * @hide
     */
    public static final String OPSTR_RUN_LONG_JOBS = "android:run_long_jobs";

    /** {@link #sAppOpsToNote} not initialized yet for this op */
    private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0;
    /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */
@@ -1933,6 +1947,7 @@ public class AppOpsManager {
            OP_SCHEDULE_EXACT_ALARM,
            OP_MANAGE_MEDIA,
            OP_TURN_SCREEN_ON,
            OP_RUN_LONG_JOBS,
    };

    static final AppOpInfo[] sAppOpInfos = new AppOpInfo[]{
@@ -2312,7 +2327,9 @@ public class AppOpsManager {
        new AppOpInfo.Builder(OP_RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO,
                OPSTR_RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO,
                "RECEIVE_EXPLICIT_USER_INTERACTION_AUDIO").setDefaultMode(
                AppOpsManager.MODE_ALLOWED).build()
                AppOpsManager.MODE_ALLOWED).build(),
        new AppOpInfo.Builder(OP_RUN_LONG_JOBS, OPSTR_RUN_LONG_JOBS, "RUN_LONG_JOBS")
                .setPermission(Manifest.permission.RUN_LONG_JOBS).build()
    };

    /**
+9 −0
Original line number Diff line number Diff line
@@ -6622,6 +6622,15 @@
    <permission android:name="android.permission.MANAGE_DEVICE_LOCK_STATE"
                android:protectionLevel="internal|role" />

    <!-- Allows applications to use the long running jobs APIs.
         <p>This is a special access permission that can be revoked by the system or the user.
         <p>Apps need to target API {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE} or above
         to be able to request this permission.
         <p>Protection level: appop
     -->
    <permission android:name="android.permission.RUN_LONG_JOBS"
                android:protectionLevel="normal|appop"/>

    <!-- Attribution for Geofencing service. -->
    <attribution android:tag="GeofencingService" android:label="@string/geofencing_service"/>
    <!-- Attribution for Country Detector. -->