Loading api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3883,6 +3883,7 @@ package android.app { method public android.app.PendingIntent getRunningServiceControlPanel(android.content.ComponentName) throws java.lang.SecurityException; method public android.app.PendingIntent getRunningServiceControlPanel(android.content.ComponentName) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningServiceInfo> getRunningServices(int) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningServiceInfo> getRunningServices(int) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningTaskInfo> getRunningTasks(int) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningTaskInfo> getRunningTasks(int) throws java.lang.SecurityException; method public boolean isBackgroundRestricted(); method public deprecated boolean isInLockTaskMode(); method public deprecated boolean isInLockTaskMode(); method public boolean isLowRamDevice(); method public boolean isLowRamDevice(); method public static boolean isRunningInTestHarness(); method public static boolean isRunningInTestHarness(); core/java/android/app/ActivityManager.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -3334,6 +3334,28 @@ public class ActivityManager { } } } } /** * Query whether the user has enabled background restrictions for this app. * * <p> The user may chose to do this, if they see that an app is consuming an unreasonable * amount of battery while in the background. </p> * * <p> If true, any work that the app tries to do will be aggressively restricted while it is in * the background. At a minimum, jobs and alarms will not execute and foreground services * cannot be started unless an app activity is in the foreground. </p> * * <p><b> Note that these restrictions stay in effect even when the device is charging.</b></p> * * @return true if user has enforced background restrictions for this app, false otherwise. */ public boolean isBackgroundRestricted() { try { return getService().isBackgroundRestricted(mContext.getOpPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * Sets the memory trim mode for a process and schedules a memory trim operation. * Sets the memory trim mode for a process and schedules a memory trim operation. * * Loading core/java/android/app/IActivityManager.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -614,7 +614,7 @@ interface IActivityManager { int sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code, int sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code, in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver, in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver, in String requiredPermission, in Bundle options); in String requiredPermission, in Bundle options); boolean isBackgroundRestricted(in String packageName); // Start of N MR1 transactions // Start of N MR1 transactions void setVrThread(int tid); void setVrThread(int tid); Loading services/core/java/com/android/server/am/ActivityManagerService.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -12878,6 +12878,25 @@ public class ActivityManagerService extends IActivityManager.Stub return false; return false; } } @Override public boolean isBackgroundRestricted(String packageName) { final int callingUid = Binder.getCallingUid(); final IPackageManager pm = AppGlobals.getPackageManager(); try { final int packageUid = pm.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING, UserHandle.getUserId(callingUid)); if (packageUid != callingUid) { throw new IllegalArgumentException("Uid " + callingUid + " cannot query restriction state for package " + packageName); } } catch (RemoteException exc) { // Ignore. } final int mode = mAppOpsService.checkOperation(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, callingUid, packageName); return (mode != AppOpsManager.MODE_ALLOWED); } @Override @Override public void backgroundWhitelistUid(final int uid) { public void backgroundWhitelistUid(final int uid) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { Loading
api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3883,6 +3883,7 @@ package android.app { method public android.app.PendingIntent getRunningServiceControlPanel(android.content.ComponentName) throws java.lang.SecurityException; method public android.app.PendingIntent getRunningServiceControlPanel(android.content.ComponentName) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningServiceInfo> getRunningServices(int) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningServiceInfo> getRunningServices(int) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningTaskInfo> getRunningTasks(int) throws java.lang.SecurityException; method public deprecated java.util.List<android.app.ActivityManager.RunningTaskInfo> getRunningTasks(int) throws java.lang.SecurityException; method public boolean isBackgroundRestricted(); method public deprecated boolean isInLockTaskMode(); method public deprecated boolean isInLockTaskMode(); method public boolean isLowRamDevice(); method public boolean isLowRamDevice(); method public static boolean isRunningInTestHarness(); method public static boolean isRunningInTestHarness();
core/java/android/app/ActivityManager.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -3334,6 +3334,28 @@ public class ActivityManager { } } } } /** * Query whether the user has enabled background restrictions for this app. * * <p> The user may chose to do this, if they see that an app is consuming an unreasonable * amount of battery while in the background. </p> * * <p> If true, any work that the app tries to do will be aggressively restricted while it is in * the background. At a minimum, jobs and alarms will not execute and foreground services * cannot be started unless an app activity is in the foreground. </p> * * <p><b> Note that these restrictions stay in effect even when the device is charging.</b></p> * * @return true if user has enforced background restrictions for this app, false otherwise. */ public boolean isBackgroundRestricted() { try { return getService().isBackgroundRestricted(mContext.getOpPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * Sets the memory trim mode for a process and schedules a memory trim operation. * Sets the memory trim mode for a process and schedules a memory trim operation. * * Loading
core/java/android/app/IActivityManager.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -614,7 +614,7 @@ interface IActivityManager { int sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code, int sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code, in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver, in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver, in String requiredPermission, in Bundle options); in String requiredPermission, in Bundle options); boolean isBackgroundRestricted(in String packageName); // Start of N MR1 transactions // Start of N MR1 transactions void setVrThread(int tid); void setVrThread(int tid); Loading
services/core/java/com/android/server/am/ActivityManagerService.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -12878,6 +12878,25 @@ public class ActivityManagerService extends IActivityManager.Stub return false; return false; } } @Override public boolean isBackgroundRestricted(String packageName) { final int callingUid = Binder.getCallingUid(); final IPackageManager pm = AppGlobals.getPackageManager(); try { final int packageUid = pm.getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING, UserHandle.getUserId(callingUid)); if (packageUid != callingUid) { throw new IllegalArgumentException("Uid " + callingUid + " cannot query restriction state for package " + packageName); } } catch (RemoteException exc) { // Ignore. } final int mode = mAppOpsService.checkOperation(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, callingUid, packageName); return (mode != AppOpsManager.MODE_ALLOWED); } @Override @Override public void backgroundWhitelistUid(final int uid) { public void backgroundWhitelistUid(final int uid) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { if (Binder.getCallingUid() != Process.SYSTEM_UID) {