diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-02-28 22:28:30 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-02-28 22:28:30 +0000 |
| commit | 379374b1d3d777924689fea0cf7ea6eccff77f2a (patch) | |
| tree | bc443fd1f31267ea5be40338875f46ce62d1641e /core/java | |
| parent | d5a2e636c0147fd71572f43d5cf73c7ba16a6e64 (diff) | |
| parent | 4d64c093cd785e7a53fafe1aaf796ed734d61a02 (diff) | |
Merge "Added an api to query ForcedAppStandby state"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityManager.java | 22 | ||||
| -rw-r--r-- | core/java/android/app/IActivityManager.aidl | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 03faeeeb91a1..66b9de56d03e 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -3335,6 +3335,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. * * <p><b>Note: this method is only intended for testing framework.</b></p> diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index ac301b3cc595..eaa23c6a9b61 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -614,7 +614,7 @@ interface IActivityManager { int sendIntentSender(in IIntentSender target, in IBinder whitelistToken, int code, in Intent intent, in String resolvedType, in IIntentReceiver finishedReceiver, in String requiredPermission, in Bundle options); - + boolean isBackgroundRestricted(in String packageName); // Start of N MR1 transactions void setVrThread(int tid); |
