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

Commit 4ee7ff80 authored by Alex Johnston's avatar Alex Johnston Committed by Android (Google) Code Review
Browse files

Merge "Add forced app standby and app standby exemption app-ops to AppOpsManager"

parents 2f1db9ec cb1bb0f3
Loading
Loading
Loading
Loading
+52 −2
Original line number Original line Diff line number Diff line
@@ -1368,9 +1368,31 @@ public class AppOpsManager {
    public static final int OP_READ_MEDIA_VISUAL_USER_SELECTED =
    public static final int OP_READ_MEDIA_VISUAL_USER_SELECTED =
            AppProtoEnums.APP_OP_READ_MEDIA_VISUAL_USER_SELECTED;
            AppProtoEnums.APP_OP_READ_MEDIA_VISUAL_USER_SELECTED;


    /**
     * Prevent an app from being placed into app standby buckets.
     *
     * Only to be used by the system.
     *
     * @hide
     */
    public static final int OP_SYSTEM_EXEMPT_FROM_APP_STANDBY =
            AppProtoEnums.APP_OP_SYSTEM_EXEMPT_FROM_APP_STANDBY;

    /**
     * Prevent an app from being placed into forced app standby.
     * {@link ActivityManager#isBackgroundRestricted()}
     * {@link #OP_RUN_ANY_IN_BACKGROUND}
     *
     * Only to be used by the system.
     *
     * @hide
     */
    public static final int OP_SYSTEM_EXEMPT_FROM_FORCED_APP_STANDBY =
            AppProtoEnums.APP_OP_SYSTEM_EXEMPT_FROM_FORCED_APP_STANDBY;

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


    /** Access to coarse location information. */
    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -1869,6 +1891,28 @@ public class AppOpsManager {
     */
     */
    public static final String OPSTR_RUN_LONG_JOBS = "android:run_long_jobs";
    public static final String OPSTR_RUN_LONG_JOBS = "android:run_long_jobs";


    /**
     * Prevent an app from being placed into app standby buckets.
     *
     * Only to be used by the system.
     *
     * @hide
     */
    public static final String OPSTR_SYSTEM_EXEMPT_FROM_APP_STANDBY =
            "android:system_exempt_from_app_standby";

    /**
     * Prevent an app from being placed into forced app standby.
     * {@link ActivityManager#isBackgroundRestricted()}
     * {@link #OP_RUN_ANY_IN_BACKGROUND}
     *
     * Only to be used by the system.
     *
     * @hide
     */
    public static final String OPSTR_SYSTEM_EXEMPT_FROM_FORCED_APP_STANDBY =
            "android:system_exempt_from_forced_app_standby";

    /** {@link #sAppOpsToNote} not initialized yet for this op */
    /** {@link #sAppOpsToNote} not initialized yet for this op */
    private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0;
    private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0;
    /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */
    /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */
@@ -2350,7 +2394,13 @@ public class AppOpsManager {
            new AppOpInfo.Builder(OP_READ_MEDIA_VISUAL_USER_SELECTED,
            new AppOpInfo.Builder(OP_READ_MEDIA_VISUAL_USER_SELECTED,
                    OPSTR_READ_MEDIA_VISUAL_USER_SELECTED, "READ_MEDIA_VISUAL_USER_SELECTED")
                    OPSTR_READ_MEDIA_VISUAL_USER_SELECTED, "READ_MEDIA_VISUAL_USER_SELECTED")
                    .setPermission(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)
                    .setPermission(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)
                    .setDefaultMode(AppOpsManager.MODE_ALLOWED).build()
                    .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(),
        new AppOpInfo.Builder(OP_SYSTEM_EXEMPT_FROM_APP_STANDBY,
                OPSTR_SYSTEM_EXEMPT_FROM_APP_STANDBY,
                "SYSTEM_EXEMPT_FROM_APP_STANDBY").build(),
        new AppOpInfo.Builder(OP_SYSTEM_EXEMPT_FROM_FORCED_APP_STANDBY,
                OPSTR_SYSTEM_EXEMPT_FROM_FORCED_APP_STANDBY,
                "SYSTEM_EXEMPT_FROM_FORCED_APP_STANDBY").build()
    };
    };


    /**
    /**