summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-02-28 22:28:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-02-28 22:28:30 +0000
commit379374b1d3d777924689fea0cf7ea6eccff77f2a (patch)
treebc443fd1f31267ea5be40338875f46ce62d1641e /core/java
parentd5a2e636c0147fd71572f43d5cf73c7ba16a6e64 (diff)
parent4d64c093cd785e7a53fafe1aaf796ed734d61a02 (diff)
Merge "Added an api to query ForcedAppStandby state"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ActivityManager.java22
-rw-r--r--core/java/android/app/IActivityManager.aidl2
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);