diff --git a/core/api/system-current.txt b/core/api/system-current.txt index fde95bd3fb1e4..22b73cc15e2e0 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -626,6 +626,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"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 8263a4e3d81fb..8a671be0673bd 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -1462,9 +1462,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"; @@ -2058,6 +2066,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} */ @@ -2580,7 +2597,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