summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-08-10 14:52:52 -0700
committerDianne Hackborn <hackbod@google.com>2015-08-10 14:52:52 -0700
commitc7b57b1e65b487defad4967cf42cf076b499cbee (patch)
tree72964f743c15cb729c024e0b92ccefbada726064 /core
parentc52839277b8714d150a9fe276b6ba3fa8a0cbf38 (diff)
downloadframeworks_base-c7b57b1e65b487defad4967cf42cf076b499cbee.zip
frameworks_base-c7b57b1e65b487defad4967cf42cf076b499cbee.tar.gz
frameworks_base-c7b57b1e65b487defad4967cf42cf076b499cbee.tar.bz2
Fix issue #23037899: Support for Battery Optimization permission + Dialog
New permission, new Intent action. Change-Id: I1d9ba55be8f72074e29d33ad7a0a12a820bbac39
Diffstat (limited to 'core')
-rw-r--r--core/java/android/provider/Settings.java32
-rw-r--r--core/res/AndroidManifest.xml7
2 files changed, 36 insertions, 3 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 6e178a4..fe95864 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -616,20 +616,46 @@ public final class Settings {
/**
* Activity Action: Show screen for controlling which apps can ignore battery optimizations.
* <p>
- * Input: Optionally, the Intent's data URI specifies the application package name
- * to be shown, with the "package" scheme. That is "package:com.my.app".
+ * Input: Nothing.
* <p>
* Output: Nothing.
* <p>
* You can use {@link android.os.PowerManager#isIgnoringBatteryOptimizations
* PowerManager.isIgnoringBatteryOptimizations()} to determine if an application is
- * already ignoring optimizations.
+ * already ignoring optimizations. You can use
+ * {@link #ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS} to ask the user to put you
+ * on this list.
*/
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS =
"android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS";
/**
+ * Activity Action: Ask the user to allow an to ignore battery optimizations (that is,
+ * put them on the whitelist of apps shown by
+ * {@link #ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}). For an app to use this, it also
+ * must hold the {@link android.Manifest.permission#REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}
+ * permission.
+ * <p><b>Note:</b> most applications should <em>not</em> use this; there are many facilities
+ * provided by the platform for applications to operate correctly in the various power
+ * saving mode. This is only for unusual applications that need to deeply control their own
+ * execution, at the potential expense of the user's battery life. Note that these applications
+ * greatly run the risk of showing to the user has how power consumers on their device.</p>
+ * <p>
+ * Input: The Intent's data URI must specify the application package name
+ * to be shown, with the "package" scheme. That is "package:com.my.app".
+ * <p>
+ * Output: Nothing.
+ * <p>
+ * You can use {@link android.os.PowerManager#isIgnoringBatteryOptimizations
+ * PowerManager.isIgnoringBatteryOptimizations()} to determine if an application is
+ * already ignoring optimizations.
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS =
+ "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
+
+ /**
* @hide
* Activity Action: Show the "app ops" settings screen.
* <p>
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 53b553e8..629d14b 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2257,6 +2257,13 @@
<permission android:name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"
android:protectionLevel="system|signature" />
+ <!-- Permission an application must hold in order to use
+ {@link android.provider.Settings#ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}.
+ This is a normal permission: an app requesting it will always be granted the
+ permission, without the user needing to approve or see it. -->
+ <permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"
+ android:protectionLevel="normal" />
+
<!-- @SystemApi Allows an application to collect battery statistics -->
<permission android:name="android.permission.BATTERY_STATS"
android:protectionLevel="signature|privileged|development" />