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

Commit e0097f50 authored by Ilyas Sung's avatar Ilyas Sung
Browse files

Add exemption that prevents apps from being placed in hibernation

Bug: 246330879
Test: atest AppOpsTests
Change-Id: I61d1a7b092b9b0a41c60ca6ef14aad48122f9221
parent 4f69147f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -623,6 +623,7 @@ package android.app {
    field public static final String OPSTR_RUN_ANY_IN_BACKGROUND = "android:run_any_in_background";
    field public static final String OPSTR_RUN_IN_BACKGROUND = "android:run_in_background";
    field public static final String OPSTR_START_FOREGROUND = "android:start_foreground";
    field public static final String OPSTR_SYSTEM_EXEMPT_FROM_HIBERNATION = "android:system_exempt_from_hibernation";
    field public static final String OPSTR_TAKE_AUDIO_FOCUS = "android:take_audio_focus";
    field public static final String OPSTR_TAKE_MEDIA_BUTTONS = "android:take_media_buttons";
    field public static final String OPSTR_TOAST_WINDOW = "android:toast_window";
+22 −2
Original line number Diff line number Diff line
@@ -1461,9 +1461,17 @@ public class AppOpsManager {
     */
    public static final int OP_USE_FULL_SCREEN_INTENT = AppProtoEnums.APP_OP_USE_FULL_SCREEN_INTENT;

    /**
     * Prevent an app from being placed into hibernation.
     *
     * @hide
     */
    public static final int OP_SYSTEM_EXEMPT_FROM_HIBERNATION =
            AppProtoEnums.APP_OP_SYSTEM_EXEMPT_FROM_HIBERNATION;

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

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -2057,6 +2065,15 @@ public class AppOpsManager {
     */
    public static final String OPSTR_USE_FULL_SCREEN_INTENT = "android:use_full_screen_intent";

    /**
     *  Prevent an app from being placed into hibernation.
     *
     * @hide
     */
    @SystemApi
    public static final String OPSTR_SYSTEM_EXEMPT_FROM_HIBERNATION =
            "android:system_exempt_from_hibernation";

    /** {@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} */
@@ -2578,7 +2595,10 @@ public class AppOpsManager {
                .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(),
        new AppOpInfo.Builder(OP_USE_FULL_SCREEN_INTENT, OPSTR_USE_FULL_SCREEN_INTENT,
                "USE_FULL_SCREEN_INTENT").setPermission(Manifest.permission.USE_FULL_SCREEN_INTENT)
                .build()
                .build(),
        new AppOpInfo.Builder(OP_SYSTEM_EXEMPT_FROM_HIBERNATION,
                OPSTR_SYSTEM_EXEMPT_FROM_HIBERNATION,
                "SYSTEM_EXEMPT_FROM_HIBERNATION").build()
    };

    // The number of longs needed to form a full bitmask of app ops