summaryrefslogtreecommitdiffstats
path: root/tests/ActivityTests
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 /tests/ActivityTests
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 'tests/ActivityTests')
-rw-r--r--tests/ActivityTests/AndroidManifest.xml1
-rw-r--r--tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java5
2 files changed, 5 insertions, 1 deletions
diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml
index 73cb432..7b9c9f1 100644
--- a/tests/ActivityTests/AndroidManifest.xml
+++ b/tests/ActivityTests/AndroidManifest.xml
@@ -24,6 +24,7 @@
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.MANAGE_USERS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
+ <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-sdk android:targetSdkVersion="22" />
<application android:label="ActivityTest">
<activity android:name="ActivityTestMain">
diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java
index 2f0bf39..5fbfe8a 100644
--- a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java
+++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java
@@ -465,9 +465,12 @@ public class ActivityTestMain extends Activity {
menu.add("Ignore battery optimizations").setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
+ Intent intent;
if (!mPower.isIgnoringBatteryOptimizations(getPackageName())) {
+ intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.fromParts("package", getPackageName(), null));
+ } else {
+ intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
}
startActivity(intent);
return true;