Merge "Fix settings crash after androidx refactoring"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b666881..c1e0c60 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -307,7 +307,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.wifi.SavedAccessPointsWifiSettings" />
+ android:value="com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
@@ -574,6 +574,12 @@
android:value="true" />
</activity>
+ <activity android:name=".localepicker.LocalePickerWithRegionActivity"
+ android:excludeFromRecents="true"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:exported="false">
+ </activity>
+
<activity
android:name=".Settings$LanguageAndInputSettingsActivity"
android:label="@string/language_settings"
@@ -1923,7 +1929,7 @@
<activity android:name=".bluetooth.RequestPermissionActivity"
android:excludeFromRecents="true"
android:permission="android.permission.BLUETOOTH"
- android:theme="@style/BluetoothPermission">
+ android:theme="@style/Theme.BluetoothPermission">
<intent-filter android:priority="1">
<action android:name="android.bluetooth.adapter.action.REQUEST_DISCOVERABLE" />
<action android:name="android.bluetooth.adapter.action.REQUEST_ENABLE" />
@@ -2520,9 +2526,6 @@
<action android:name="android.settings.ALL_APPS_NOTIFICATION_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
- <intent-filter android:priority="150">
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.applications.manageapplications.ManageApplications" />
</activity>
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 623f537..c2b8ed5 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -1353,22 +1353,6 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" android:textColor="@color/red""
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/layout/credentials_dialog.xml"
- line="36"
- column="17"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:textColor="#FFFFFF""
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -2121,102 +2105,6 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" android:textColor="#ffffb060""
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/layout/permission_settings.xml"
- line="46"
- column="17"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" android:background="#000000" />"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/layout/radio_info.xml"
- line="116"
- column="13"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" android:background="#000000" />"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/layout/radio_info.xml"
- line="135"
- column="13"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" android:background="#000000" />"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/layout/radio_info.xml"
- line="165"
- column="13"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" android:background="#000000" />"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/layout/radio_info.xml"
- line="303"
- column="13"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" android:background="#000000" />"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/layout/radio_info.xml"
- line="303"
- column="13"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:src="@color/running_processes_system_ram""
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -2445,7 +2333,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rXC/strings.xml"
- line="2531"
+ line="2559"
column="168"/>
</issue>
@@ -2461,7 +2349,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rAU/strings.xml"
- line="2532"
+ line="2560"
column="64"/>
</issue>
@@ -2477,7 +2365,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rCA/strings.xml"
- line="2532"
+ line="2560"
column="64"/>
</issue>
@@ -2493,7 +2381,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rGB/strings.xml"
- line="2532"
+ line="2560"
column="64"/>
</issue>
@@ -2509,7 +2397,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rIN/strings.xml"
- line="2532"
+ line="2560"
column="64"/>
</issue>
@@ -2525,7 +2413,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="5920"
+ line="5902"
column="36"/>
</issue>
@@ -2541,7 +2429,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="248"
+ line="171"
column="41"/>
</issue>
@@ -2557,7 +2445,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="465"
+ line="425"
column="44"/>
</issue>
@@ -2573,7 +2461,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="471"
+ line="431"
column="44"/>
</issue>
@@ -2589,7 +2477,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="472"
+ line="432"
column="44"/>
</issue>
@@ -2601,155 +2489,11 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="31"
- column="40"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="49"
- column="40"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="67"
- column="40"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="85"
- column="40"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="103"
- column="40"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="121"
- column="40"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="android:colorPrimary">@color/material_grey_100</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="197"
- column="43"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="android:colorAccent">@color/material_blue_700</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="198"
- column="42"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="android:titleTextColor">@color/material_blue_700</item>"
- errorLine2=" ^">
- <location
- file="res/values/themes.xml"
- line="199"
- column="45"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <item name="batteryGoodColor">@color/battery_good_color_light</item>"
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="240"
+ line="54"
column="39"/>
</issue>
@@ -2765,7 +2509,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="241"
+ line="55"
column="40"/>
</issue>
@@ -2781,7 +2525,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="242"
+ line="56"
column="38"/>
</issue>
@@ -2797,7 +2541,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="280"
+ line="86"
column="47"/>
</issue>
@@ -2813,7 +2557,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="349"
+ line="147"
column="45"/>
</issue>
@@ -2829,7 +2573,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="350"
+ line="148"
column="49"/>
</issue>
@@ -2845,7 +2589,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="358"
+ line="156"
column="45"/>
</issue>
@@ -2861,7 +2605,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="359"
+ line="157"
column="49"/>
</issue>
@@ -2873,6 +2617,150 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="29"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="48"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="67"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="86"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="105"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="124"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="android:colorPrimary">@color/material_grey_100</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="187"
+ column="43"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="android:colorAccent">@color/material_blue_700</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="188"
+ column="42"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="android:titleTextColor">@color/material_blue_700</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="189"
+ column="45"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:background="@color/divider_color" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
diff --git a/res/drawable-hdpi/appwidget_item_bg_normal.9.png b/res/drawable-hdpi/appwidget_item_bg_normal.9.png
deleted file mode 100644
index 8dd4479..0000000
--- a/res/drawable-hdpi/appwidget_item_bg_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/appwidget_item_bg_pressed.9.png b/res/drawable-hdpi/appwidget_item_bg_pressed.9.png
deleted file mode 100644
index fb64dfc..0000000
--- a/res/drawable-hdpi/appwidget_item_bg_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/bg_header_horizontal_tile.png b/res/drawable-hdpi/bg_header_horizontal_tile.png
deleted file mode 100644
index 4270099..0000000
--- a/res/drawable-hdpi/bg_header_horizontal_tile.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/bg_internal_storage_header.png b/res/drawable-hdpi/bg_internal_storage_header.png
deleted file mode 100644
index 1c297d9..0000000
--- a/res/drawable-hdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/bg_portable_storage_header.png b/res/drawable-hdpi/bg_portable_storage_header.png
deleted file mode 100644
index 42fe2c1..0000000
--- a/res/drawable-hdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/bg_setup_header.png b/res/drawable-hdpi/bg_setup_header.png
deleted file mode 100644
index 0d30849..0000000
--- a/res/drawable-hdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/bg_tile_teal.png b/res/drawable-hdpi/bg_tile_teal.png
deleted file mode 100644
index 26538ec..0000000
--- a/res/drawable-hdpi/bg_tile_teal.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_sync_grey.png b/res/drawable-hdpi/ic_sync_grey.png
deleted file mode 100644
index 3e9995a..0000000
--- a/res/drawable-hdpi/ic_sync_grey.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_sync_red.png b/res/drawable-hdpi/ic_sync_red.png
deleted file mode 100644
index 5abb707..0000000
--- a/res/drawable-hdpi/ic_sync_red.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_selected_all.png b/res/drawable-hdpi/ic_tab_selected_all.png
deleted file mode 100644
index c168869..0000000
--- a/res/drawable-hdpi/ic_tab_selected_all.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_selected_download.png b/res/drawable-hdpi/ic_tab_selected_download.png
deleted file mode 100644
index dd3f5f9..0000000
--- a/res/drawable-hdpi/ic_tab_selected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_selected_running.png b/res/drawable-hdpi/ic_tab_selected_running.png
deleted file mode 100644
index 17b71b4..0000000
--- a/res/drawable-hdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_selected_sdcard.png b/res/drawable-hdpi/ic_tab_selected_sdcard.png
deleted file mode 100644
index 752c35d..0000000
--- a/res/drawable-hdpi/ic_tab_selected_sdcard.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_unselected_all.png b/res/drawable-hdpi/ic_tab_unselected_all.png
deleted file mode 100644
index c168869..0000000
--- a/res/drawable-hdpi/ic_tab_unselected_all.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_unselected_download.png b/res/drawable-hdpi/ic_tab_unselected_download.png
deleted file mode 100644
index 1e71efb..0000000
--- a/res/drawable-hdpi/ic_tab_unselected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_unselected_running.png b/res/drawable-hdpi/ic_tab_unselected_running.png
deleted file mode 100644
index a73d078..0000000
--- a/res/drawable-hdpi/ic_tab_unselected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_unselected_sdcard.png b/res/drawable-hdpi/ic_tab_unselected_sdcard.png
deleted file mode 100644
index 752c35d..0000000
--- a/res/drawable-hdpi/ic_tab_unselected_sdcard.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/illustration_horizontal.jpg b/res/drawable-hdpi/illustration_horizontal.jpg
deleted file mode 100644
index 428b2f4..0000000
--- a/res/drawable-hdpi/illustration_horizontal.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/illustration_tile.jpg b/res/drawable-hdpi/illustration_tile.jpg
deleted file mode 100644
index 9931a23..0000000
--- a/res/drawable-hdpi/illustration_tile.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_0.png b/res/drawable-hdpi/lock_anim_0.png
deleted file mode 100644
index 08732e4..0000000
--- a/res/drawable-hdpi/lock_anim_0.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_1.png b/res/drawable-hdpi/lock_anim_1.png
deleted file mode 100644
index 74a0628..0000000
--- a/res/drawable-hdpi/lock_anim_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_10.png b/res/drawable-hdpi/lock_anim_10.png
deleted file mode 100644
index adb981d..0000000
--- a/res/drawable-hdpi/lock_anim_10.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_11.png b/res/drawable-hdpi/lock_anim_11.png
deleted file mode 100644
index f8976a2..0000000
--- a/res/drawable-hdpi/lock_anim_11.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_12.png b/res/drawable-hdpi/lock_anim_12.png
deleted file mode 100644
index 3ccdc85..0000000
--- a/res/drawable-hdpi/lock_anim_12.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_13.png b/res/drawable-hdpi/lock_anim_13.png
deleted file mode 100644
index ccd38d5..0000000
--- a/res/drawable-hdpi/lock_anim_13.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_14.png b/res/drawable-hdpi/lock_anim_14.png
deleted file mode 100644
index 2f40d9e..0000000
--- a/res/drawable-hdpi/lock_anim_14.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_2.png b/res/drawable-hdpi/lock_anim_2.png
deleted file mode 100644
index 495b2da..0000000
--- a/res/drawable-hdpi/lock_anim_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_3.png b/res/drawable-hdpi/lock_anim_3.png
deleted file mode 100644
index fa37813..0000000
--- a/res/drawable-hdpi/lock_anim_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_4.png b/res/drawable-hdpi/lock_anim_4.png
deleted file mode 100644
index 8201fd9..0000000
--- a/res/drawable-hdpi/lock_anim_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_5.png b/res/drawable-hdpi/lock_anim_5.png
deleted file mode 100644
index b08932d..0000000
--- a/res/drawable-hdpi/lock_anim_5.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_6.png b/res/drawable-hdpi/lock_anim_6.png
deleted file mode 100644
index dac09e1..0000000
--- a/res/drawable-hdpi/lock_anim_6.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_7.png b/res/drawable-hdpi/lock_anim_7.png
deleted file mode 100644
index f06c9d6..0000000
--- a/res/drawable-hdpi/lock_anim_7.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_8.png b/res/drawable-hdpi/lock_anim_8.png
deleted file mode 100644
index 07f7e34..0000000
--- a/res/drawable-hdpi/lock_anim_8.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/lock_anim_9.png b/res/drawable-hdpi/lock_anim_9.png
deleted file mode 100644
index 551bafa..0000000
--- a/res/drawable-hdpi/lock_anim_9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/nfc_payment_empty_state.png b/res/drawable-hdpi/nfc_payment_empty_state.png
deleted file mode 100644
index 7d20bc8..0000000
--- a/res/drawable-hdpi/nfc_payment_empty_state.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/spinner_default_holo_dark_am_no_underline.9.png b/res/drawable-hdpi/spinner_default_holo_dark_am_no_underline.9.png
deleted file mode 100644
index 267e7ba..0000000
--- a/res/drawable-hdpi/spinner_default_holo_dark_am_no_underline.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/ic_tab_selected_running.png b/res/drawable-ldrtl-hdpi/ic_tab_selected_running.png
deleted file mode 100644
index 1cb9c8d..0000000
--- a/res/drawable-ldrtl-hdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/ic_tab_unselected_running.png b/res/drawable-ldrtl-hdpi/ic_tab_unselected_running.png
deleted file mode 100644
index 1cb9c8d..0000000
--- a/res/drawable-ldrtl-hdpi/ic_tab_unselected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/ic_tab_selected_running.png b/res/drawable-ldrtl-mdpi/ic_tab_selected_running.png
deleted file mode 100644
index 740e709..0000000
--- a/res/drawable-ldrtl-mdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/ic_tab_unselected_running.png b/res/drawable-ldrtl-mdpi/ic_tab_unselected_running.png
deleted file mode 100644
index 740e709..0000000
--- a/res/drawable-ldrtl-mdpi/ic_tab_unselected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/ic_tab_selected_running.png b/res/drawable-ldrtl-xhdpi/ic_tab_selected_running.png
deleted file mode 100644
index fcd6ab1..0000000
--- a/res/drawable-ldrtl-xhdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/ic_tab_unselected_running.png b/res/drawable-ldrtl-xhdpi/ic_tab_unselected_running.png
deleted file mode 100644
index fcd6ab1..0000000
--- a/res/drawable-ldrtl-xhdpi/ic_tab_unselected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_item_bg_normal.9.png b/res/drawable-mdpi/appwidget_item_bg_normal.9.png
deleted file mode 100644
index 6af3493..0000000
--- a/res/drawable-mdpi/appwidget_item_bg_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/appwidget_item_bg_pressed.9.png b/res/drawable-mdpi/appwidget_item_bg_pressed.9.png
deleted file mode 100644
index ebb7a99..0000000
--- a/res/drawable-mdpi/appwidget_item_bg_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/bg_header_horizontal_tile.png b/res/drawable-mdpi/bg_header_horizontal_tile.png
deleted file mode 100644
index be8512d..0000000
--- a/res/drawable-mdpi/bg_header_horizontal_tile.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/bg_internal_storage_header.png b/res/drawable-mdpi/bg_internal_storage_header.png
deleted file mode 100644
index d93c6a2..0000000
--- a/res/drawable-mdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/bg_portable_storage_header.png b/res/drawable-mdpi/bg_portable_storage_header.png
deleted file mode 100644
index a39df23..0000000
--- a/res/drawable-mdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/bg_setup_header.png b/res/drawable-mdpi/bg_setup_header.png
deleted file mode 100644
index f07d3fa..0000000
--- a/res/drawable-mdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/bg_tile_teal.png b/res/drawable-mdpi/bg_tile_teal.png
deleted file mode 100644
index 01abedb..0000000
--- a/res/drawable-mdpi/bg_tile_teal.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_sync_grey.png b/res/drawable-mdpi/ic_sync_grey.png
deleted file mode 100644
index 8f168d4..0000000
--- a/res/drawable-mdpi/ic_sync_grey.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_sync_red.png b/res/drawable-mdpi/ic_sync_red.png
deleted file mode 100644
index 5e38136..0000000
--- a/res/drawable-mdpi/ic_sync_red.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_selected_all.png b/res/drawable-mdpi/ic_tab_selected_all.png
deleted file mode 100644
index 3cc0dde..0000000
--- a/res/drawable-mdpi/ic_tab_selected_all.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_selected_download.png b/res/drawable-mdpi/ic_tab_selected_download.png
deleted file mode 100644
index a9d71ae..0000000
--- a/res/drawable-mdpi/ic_tab_selected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_selected_running.png b/res/drawable-mdpi/ic_tab_selected_running.png
deleted file mode 100644
index 714c5a4..0000000
--- a/res/drawable-mdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_selected_sdcard.png b/res/drawable-mdpi/ic_tab_selected_sdcard.png
deleted file mode 100644
index 731aad5..0000000
--- a/res/drawable-mdpi/ic_tab_selected_sdcard.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_unselected_all.png b/res/drawable-mdpi/ic_tab_unselected_all.png
deleted file mode 100644
index 3cc0dde..0000000
--- a/res/drawable-mdpi/ic_tab_unselected_all.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_unselected_download.png b/res/drawable-mdpi/ic_tab_unselected_download.png
deleted file mode 100644
index 59930fe..0000000
--- a/res/drawable-mdpi/ic_tab_unselected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_unselected_running.png b/res/drawable-mdpi/ic_tab_unselected_running.png
deleted file mode 100644
index b76a1d3..0000000
--- a/res/drawable-mdpi/ic_tab_unselected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_tab_unselected_sdcard.png b/res/drawable-mdpi/ic_tab_unselected_sdcard.png
deleted file mode 100644
index 731aad5..0000000
--- a/res/drawable-mdpi/ic_tab_unselected_sdcard.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/illustration_horizontal.jpg b/res/drawable-mdpi/illustration_horizontal.jpg
deleted file mode 100644
index 52e7993..0000000
--- a/res/drawable-mdpi/illustration_horizontal.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/illustration_tile.jpg b/res/drawable-mdpi/illustration_tile.jpg
deleted file mode 100644
index 7923fb4..0000000
--- a/res/drawable-mdpi/illustration_tile.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_0.png b/res/drawable-mdpi/lock_anim_0.png
deleted file mode 100644
index afdda8b..0000000
--- a/res/drawable-mdpi/lock_anim_0.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_1.png b/res/drawable-mdpi/lock_anim_1.png
deleted file mode 100644
index 6cae8e5..0000000
--- a/res/drawable-mdpi/lock_anim_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_10.png b/res/drawable-mdpi/lock_anim_10.png
deleted file mode 100644
index 5de840e..0000000
--- a/res/drawable-mdpi/lock_anim_10.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_11.png b/res/drawable-mdpi/lock_anim_11.png
deleted file mode 100644
index 35db815..0000000
--- a/res/drawable-mdpi/lock_anim_11.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_12.png b/res/drawable-mdpi/lock_anim_12.png
deleted file mode 100644
index 8778d98..0000000
--- a/res/drawable-mdpi/lock_anim_12.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_13.png b/res/drawable-mdpi/lock_anim_13.png
deleted file mode 100644
index d0b8cf0..0000000
--- a/res/drawable-mdpi/lock_anim_13.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_14.png b/res/drawable-mdpi/lock_anim_14.png
deleted file mode 100644
index ea1aa31..0000000
--- a/res/drawable-mdpi/lock_anim_14.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_2.png b/res/drawable-mdpi/lock_anim_2.png
deleted file mode 100644
index 0542b1d..0000000
--- a/res/drawable-mdpi/lock_anim_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_3.png b/res/drawable-mdpi/lock_anim_3.png
deleted file mode 100644
index 7e2ba9a..0000000
--- a/res/drawable-mdpi/lock_anim_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_4.png b/res/drawable-mdpi/lock_anim_4.png
deleted file mode 100644
index a3ca629..0000000
--- a/res/drawable-mdpi/lock_anim_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_5.png b/res/drawable-mdpi/lock_anim_5.png
deleted file mode 100644
index 17e3839..0000000
--- a/res/drawable-mdpi/lock_anim_5.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_6.png b/res/drawable-mdpi/lock_anim_6.png
deleted file mode 100644
index 90205a6..0000000
--- a/res/drawable-mdpi/lock_anim_6.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_7.png b/res/drawable-mdpi/lock_anim_7.png
deleted file mode 100644
index 1d94a47..0000000
--- a/res/drawable-mdpi/lock_anim_7.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_8.png b/res/drawable-mdpi/lock_anim_8.png
deleted file mode 100644
index af7cd28..0000000
--- a/res/drawable-mdpi/lock_anim_8.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/lock_anim_9.png b/res/drawable-mdpi/lock_anim_9.png
deleted file mode 100644
index d401624..0000000
--- a/res/drawable-mdpi/lock_anim_9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/nfc_payment_empty_state.png b/res/drawable-mdpi/nfc_payment_empty_state.png
deleted file mode 100644
index 67ea0b7..0000000
--- a/res/drawable-mdpi/nfc_payment_empty_state.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/spinner_default_holo_dark_am_no_underline.9.png b/res/drawable-mdpi/spinner_default_holo_dark_am_no_underline.9.png
deleted file mode 100644
index db51f6b..0000000
--- a/res/drawable-mdpi/spinner_default_holo_dark_am_no_underline.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-hdpi/bg_internal_storage_header.png b/res/drawable-sw600dp-hdpi/bg_internal_storage_header.png
deleted file mode 100644
index 5102e54..0000000
--- a/res/drawable-sw600dp-hdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-hdpi/bg_portable_storage_header.png b/res/drawable-sw600dp-hdpi/bg_portable_storage_header.png
deleted file mode 100644
index 26fd248..0000000
--- a/res/drawable-sw600dp-hdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-hdpi/bg_setup_header.png b/res/drawable-sw600dp-hdpi/bg_setup_header.png
deleted file mode 100644
index 2178602..0000000
--- a/res/drawable-sw600dp-hdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-mdpi/bg_internal_storage_header.png b/res/drawable-sw600dp-mdpi/bg_internal_storage_header.png
deleted file mode 100644
index b39c652..0000000
--- a/res/drawable-sw600dp-mdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-mdpi/bg_portable_storage_header.png b/res/drawable-sw600dp-mdpi/bg_portable_storage_header.png
deleted file mode 100644
index 1f5d10b..0000000
--- a/res/drawable-sw600dp-mdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-mdpi/bg_setup_header.png b/res/drawable-sw600dp-mdpi/bg_setup_header.png
deleted file mode 100644
index 157b8aa..0000000
--- a/res/drawable-sw600dp-mdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xhdpi/bg_internal_storage_header.png b/res/drawable-sw600dp-xhdpi/bg_internal_storage_header.png
deleted file mode 100644
index 38ea2a3..0000000
--- a/res/drawable-sw600dp-xhdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xhdpi/bg_portable_storage_header.png b/res/drawable-sw600dp-xhdpi/bg_portable_storage_header.png
deleted file mode 100644
index 169ac25..0000000
--- a/res/drawable-sw600dp-xhdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xhdpi/bg_setup_header.png b/res/drawable-sw600dp-xhdpi/bg_setup_header.png
deleted file mode 100644
index a4e1eb3..0000000
--- a/res/drawable-sw600dp-xhdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xxhdpi/bg_internal_storage_header.png b/res/drawable-sw600dp-xxhdpi/bg_internal_storage_header.png
deleted file mode 100644
index 8920af3..0000000
--- a/res/drawable-sw600dp-xxhdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xxhdpi/bg_portable_storage_header.png b/res/drawable-sw600dp-xxhdpi/bg_portable_storage_header.png
deleted file mode 100644
index 9190f38..0000000
--- a/res/drawable-sw600dp-xxhdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xxhdpi/bg_setup_header.png b/res/drawable-sw600dp-xxhdpi/bg_setup_header.png
deleted file mode 100644
index 6fce3df..0000000
--- a/res/drawable-sw600dp-xxhdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xxxhdpi/bg_internal_storage_header.png b/res/drawable-sw600dp-xxxhdpi/bg_internal_storage_header.png
deleted file mode 100644
index a99ed1c..0000000
--- a/res/drawable-sw600dp-xxxhdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xxxhdpi/bg_portable_storage_header.png b/res/drawable-sw600dp-xxxhdpi/bg_portable_storage_header.png
deleted file mode 100644
index d979bfb..0000000
--- a/res/drawable-sw600dp-xxxhdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw600dp-xxxhdpi/bg_setup_header.png b/res/drawable-sw600dp-xxxhdpi/bg_setup_header.png
deleted file mode 100644
index 7276b4e..0000000
--- a/res/drawable-sw600dp-xxxhdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_item_bg_normal.9.png b/res/drawable-xhdpi/appwidget_item_bg_normal.9.png
deleted file mode 100644
index d752d5e..0000000
--- a/res/drawable-xhdpi/appwidget_item_bg_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/appwidget_item_bg_pressed.9.png b/res/drawable-xhdpi/appwidget_item_bg_pressed.9.png
deleted file mode 100644
index e5941a6..0000000
--- a/res/drawable-xhdpi/appwidget_item_bg_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/bg_header_horizontal_tile.png b/res/drawable-xhdpi/bg_header_horizontal_tile.png
deleted file mode 100644
index 3b36902..0000000
--- a/res/drawable-xhdpi/bg_header_horizontal_tile.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/bg_internal_storage_header.png b/res/drawable-xhdpi/bg_internal_storage_header.png
deleted file mode 100644
index f8b64e0..0000000
--- a/res/drawable-xhdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/bg_portable_storage_header.png b/res/drawable-xhdpi/bg_portable_storage_header.png
deleted file mode 100644
index 12c432d..0000000
--- a/res/drawable-xhdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/bg_setup_header.png b/res/drawable-xhdpi/bg_setup_header.png
deleted file mode 100644
index d7c4401..0000000
--- a/res/drawable-xhdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/bg_tile_teal.png b/res/drawable-xhdpi/bg_tile_teal.png
deleted file mode 100644
index e6f2f06..0000000
--- a/res/drawable-xhdpi/bg_tile_teal.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sync_grey.png b/res/drawable-xhdpi/ic_sync_grey.png
deleted file mode 100644
index 8a17f37..0000000
--- a/res/drawable-xhdpi/ic_sync_grey.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_sync_red.png b/res/drawable-xhdpi/ic_sync_red.png
deleted file mode 100644
index 92d02e1..0000000
--- a/res/drawable-xhdpi/ic_sync_red.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_selected_all.png b/res/drawable-xhdpi/ic_tab_selected_all.png
deleted file mode 100644
index b59933b..0000000
--- a/res/drawable-xhdpi/ic_tab_selected_all.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_selected_download.png b/res/drawable-xhdpi/ic_tab_selected_download.png
deleted file mode 100644
index 6c6d26b..0000000
--- a/res/drawable-xhdpi/ic_tab_selected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_selected_running.png b/res/drawable-xhdpi/ic_tab_selected_running.png
deleted file mode 100644
index 37084d2..0000000
--- a/res/drawable-xhdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_selected_sdcard.png b/res/drawable-xhdpi/ic_tab_selected_sdcard.png
deleted file mode 100644
index 536326c..0000000
--- a/res/drawable-xhdpi/ic_tab_selected_sdcard.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_unselected_all.png b/res/drawable-xhdpi/ic_tab_unselected_all.png
deleted file mode 100644
index b59933b..0000000
--- a/res/drawable-xhdpi/ic_tab_unselected_all.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_unselected_download.png b/res/drawable-xhdpi/ic_tab_unselected_download.png
deleted file mode 100644
index e8084c2..0000000
--- a/res/drawable-xhdpi/ic_tab_unselected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_unselected_running.png b/res/drawable-xhdpi/ic_tab_unselected_running.png
deleted file mode 100644
index 8eda83f..0000000
--- a/res/drawable-xhdpi/ic_tab_unselected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_tab_unselected_sdcard.png b/res/drawable-xhdpi/ic_tab_unselected_sdcard.png
deleted file mode 100644
index 536326c..0000000
--- a/res/drawable-xhdpi/ic_tab_unselected_sdcard.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/illustration_horizontal.jpg b/res/drawable-xhdpi/illustration_horizontal.jpg
deleted file mode 100644
index 2733f8e..0000000
--- a/res/drawable-xhdpi/illustration_horizontal.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/illustration_tile.jpg b/res/drawable-xhdpi/illustration_tile.jpg
deleted file mode 100644
index 57bccca..0000000
--- a/res/drawable-xhdpi/illustration_tile.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_0.png b/res/drawable-xhdpi/lock_anim_0.png
deleted file mode 100644
index 5e8e6dc..0000000
--- a/res/drawable-xhdpi/lock_anim_0.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_1.png b/res/drawable-xhdpi/lock_anim_1.png
deleted file mode 100644
index 96fbd03..0000000
--- a/res/drawable-xhdpi/lock_anim_1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_10.png b/res/drawable-xhdpi/lock_anim_10.png
deleted file mode 100644
index e2e83b1..0000000
--- a/res/drawable-xhdpi/lock_anim_10.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_11.png b/res/drawable-xhdpi/lock_anim_11.png
deleted file mode 100644
index 68de396..0000000
--- a/res/drawable-xhdpi/lock_anim_11.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_12.png b/res/drawable-xhdpi/lock_anim_12.png
deleted file mode 100644
index 11e51c7..0000000
--- a/res/drawable-xhdpi/lock_anim_12.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_13.png b/res/drawable-xhdpi/lock_anim_13.png
deleted file mode 100644
index 86a6115..0000000
--- a/res/drawable-xhdpi/lock_anim_13.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_14.png b/res/drawable-xhdpi/lock_anim_14.png
deleted file mode 100644
index 5bff2fa..0000000
--- a/res/drawable-xhdpi/lock_anim_14.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_2.png b/res/drawable-xhdpi/lock_anim_2.png
deleted file mode 100644
index 68e59c8..0000000
--- a/res/drawable-xhdpi/lock_anim_2.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_3.png b/res/drawable-xhdpi/lock_anim_3.png
deleted file mode 100644
index 16272ed..0000000
--- a/res/drawable-xhdpi/lock_anim_3.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_4.png b/res/drawable-xhdpi/lock_anim_4.png
deleted file mode 100644
index af6fbc4..0000000
--- a/res/drawable-xhdpi/lock_anim_4.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_5.png b/res/drawable-xhdpi/lock_anim_5.png
deleted file mode 100644
index 1e631b5..0000000
--- a/res/drawable-xhdpi/lock_anim_5.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_6.png b/res/drawable-xhdpi/lock_anim_6.png
deleted file mode 100644
index 93fcf39..0000000
--- a/res/drawable-xhdpi/lock_anim_6.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_7.png b/res/drawable-xhdpi/lock_anim_7.png
deleted file mode 100644
index b5c5277..0000000
--- a/res/drawable-xhdpi/lock_anim_7.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_8.png b/res/drawable-xhdpi/lock_anim_8.png
deleted file mode 100644
index bcaec0d..0000000
--- a/res/drawable-xhdpi/lock_anim_8.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/lock_anim_9.png b/res/drawable-xhdpi/lock_anim_9.png
deleted file mode 100644
index c481d1a..0000000
--- a/res/drawable-xhdpi/lock_anim_9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/nfc_payment_empty_state.png b/res/drawable-xhdpi/nfc_payment_empty_state.png
deleted file mode 100644
index 5291c22..0000000
--- a/res/drawable-xhdpi/nfc_payment_empty_state.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/spinner_default_holo_dark_am_no_underline.9.png b/res/drawable-xhdpi/spinner_default_holo_dark_am_no_underline.9.png
deleted file mode 100644
index 8d22ce2..0000000
--- a/res/drawable-xhdpi/spinner_default_holo_dark_am_no_underline.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_item_bg_normal.9.png b/res/drawable-xxhdpi/appwidget_item_bg_normal.9.png
deleted file mode 100644
index 0d887c8..0000000
--- a/res/drawable-xxhdpi/appwidget_item_bg_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/appwidget_item_bg_pressed.9.png b/res/drawable-xxhdpi/appwidget_item_bg_pressed.9.png
deleted file mode 100644
index d14eb23..0000000
--- a/res/drawable-xxhdpi/appwidget_item_bg_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_header_horizontal_tile.png b/res/drawable-xxhdpi/bg_header_horizontal_tile.png
deleted file mode 100644
index a879fe2..0000000
--- a/res/drawable-xxhdpi/bg_header_horizontal_tile.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_internal_storage_header.png b/res/drawable-xxhdpi/bg_internal_storage_header.png
deleted file mode 100644
index 01fe761..0000000
--- a/res/drawable-xxhdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_portable_storage_header.png b/res/drawable-xxhdpi/bg_portable_storage_header.png
deleted file mode 100644
index 4bacf7c..0000000
--- a/res/drawable-xxhdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_setup_header.png b/res/drawable-xxhdpi/bg_setup_header.png
deleted file mode 100644
index 566cc5f..0000000
--- a/res/drawable-xxhdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_tile_teal.png b/res/drawable-xxhdpi/bg_tile_teal.png
deleted file mode 100644
index 29d268a..0000000
--- a/res/drawable-xxhdpi/bg_tile_teal.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_tab_selected_download.png b/res/drawable-xxhdpi/ic_tab_selected_download.png
deleted file mode 100644
index 3abb0f0..0000000
--- a/res/drawable-xxhdpi/ic_tab_selected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_tab_selected_running.png b/res/drawable-xxhdpi/ic_tab_selected_running.png
deleted file mode 100644
index bfc9b5c..0000000
--- a/res/drawable-xxhdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_tab_unselected_download.png b/res/drawable-xxhdpi/ic_tab_unselected_download.png
deleted file mode 100644
index 7030f3e..0000000
--- a/res/drawable-xxhdpi/ic_tab_unselected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/illustration_horizontal.jpg b/res/drawable-xxhdpi/illustration_horizontal.jpg
deleted file mode 100644
index aec8d0f..0000000
--- a/res/drawable-xxhdpi/illustration_horizontal.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/illustration_tile.jpg b/res/drawable-xxhdpi/illustration_tile.jpg
deleted file mode 100644
index 2ba33fa..0000000
--- a/res/drawable-xxhdpi/illustration_tile.jpg
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/nfc_payment_empty_state.png b/res/drawable-xxhdpi/nfc_payment_empty_state.png
deleted file mode 100644
index e23b0a7..0000000
--- a/res/drawable-xxhdpi/nfc_payment_empty_state.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/spinner_default_holo_dark_am_no_underline.9.png b/res/drawable-xxhdpi/spinner_default_holo_dark_am_no_underline.9.png
deleted file mode 100644
index 29fb50f..0000000
--- a/res/drawable-xxhdpi/spinner_default_holo_dark_am_no_underline.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_item_bg_normal.9.png b/res/drawable-xxxhdpi/appwidget_item_bg_normal.9.png
deleted file mode 100644
index a656a67..0000000
--- a/res/drawable-xxxhdpi/appwidget_item_bg_normal.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/appwidget_item_bg_pressed.9.png b/res/drawable-xxxhdpi/appwidget_item_bg_pressed.9.png
deleted file mode 100644
index 58e64be..0000000
--- a/res/drawable-xxxhdpi/appwidget_item_bg_pressed.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/bg_header_horizontal_tile.png b/res/drawable-xxxhdpi/bg_header_horizontal_tile.png
deleted file mode 100644
index f19306a..0000000
--- a/res/drawable-xxxhdpi/bg_header_horizontal_tile.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/bg_internal_storage_header.png b/res/drawable-xxxhdpi/bg_internal_storage_header.png
deleted file mode 100644
index eb9f268..0000000
--- a/res/drawable-xxxhdpi/bg_internal_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/bg_portable_storage_header.png b/res/drawable-xxxhdpi/bg_portable_storage_header.png
deleted file mode 100644
index 311544a..0000000
--- a/res/drawable-xxxhdpi/bg_portable_storage_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/bg_setup_header.png b/res/drawable-xxxhdpi/bg_setup_header.png
deleted file mode 100644
index 0df665e..0000000
--- a/res/drawable-xxxhdpi/bg_setup_header.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/bg_tile_teal.png b/res/drawable-xxxhdpi/bg_tile_teal.png
deleted file mode 100644
index 3d1a97a..0000000
--- a/res/drawable-xxxhdpi/bg_tile_teal.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_tab_selected_download.png b/res/drawable-xxxhdpi/ic_tab_selected_download.png
deleted file mode 100644
index a024704..0000000
--- a/res/drawable-xxxhdpi/ic_tab_selected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_tab_selected_running.png b/res/drawable-xxxhdpi/ic_tab_selected_running.png
deleted file mode 100644
index f7a329f..0000000
--- a/res/drawable-xxxhdpi/ic_tab_selected_running.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_tab_unselected_download.png b/res/drawable-xxxhdpi/ic_tab_unselected_download.png
deleted file mode 100644
index 1aa5f2e..0000000
--- a/res/drawable-xxxhdpi/ic_tab_unselected_download.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/nfc_payment_empty_state.png b/res/drawable-xxxhdpi/nfc_payment_empty_state.png
deleted file mode 100644
index 569bb07..0000000
--- a/res/drawable-xxxhdpi/nfc_payment_empty_state.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/appwidget_item_bg.xml b/res/drawable/appwidget_item_bg.xml
deleted file mode 100644
index b9de6d4..0000000
--- a/res/drawable/appwidget_item_bg.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:state_pressed="true"
- android:drawable="@drawable/appwidget_item_bg_pressed" />
-
- <item android:drawable="@drawable/appwidget_item_bg_normal" />
-</selector>
diff --git a/res/drawable/ic_menu_add_inset.xml b/res/drawable/ic_menu_add_inset.xml
deleted file mode 100644
index a4f0a65..0000000
--- a/res/drawable/ic_menu_add_inset.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!--
- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<inset
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:insetLeft="5dp">
- <vector
- android:width="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/colorAccent">
- <path
- android:fillColor="#FF000000"
- android:pathData="M19.0,13.0l-6.0,0.0l0.0,6.0l-2.0,0.0l0.0,-6.0L5.0,13.0l0.0,-2.0l6.0,0.0L11.0,5.0l2.0,0.0l0.0,6.0l6.0,0.0l0.0,2.0z"/>
- </vector>
-</inset>
diff --git a/res/drawable/lock_anim.xml b/res/drawable/lock_anim.xml
deleted file mode 100644
index 8ec31a6..0000000
--- a/res/drawable/lock_anim.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2008, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-<animation-list
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:oneshot="false">
- <item android:drawable="@drawable/lock_anim_0" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_1" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_2" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_3" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_4" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_5" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_6" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_7" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_8" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_9" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_10" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_11" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_12" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_13" android:duration="200" />
- <item android:drawable="@drawable/lock_anim_14" android:duration="200" />
-</animation-list>
diff --git a/res/layout/dream_start_button.xml b/res/layout/dream_start_button.xml
index 7d5e0c9..a45e56f 100644
--- a/res/layout/dream_start_button.xml
+++ b/res/layout/dream_start_button.xml
@@ -27,7 +27,7 @@
<Button
android:id="@+id/dream_start_now_button"
- style="@style/DreamStartButton"
+ style="@style/ActionSecondaryButton"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
diff --git a/res/layout/fallback_home_finishing_boot.xml b/res/layout/fallback_home_finishing_boot.xml
index 2714409..333eb5e 100644
--- a/res/layout/fallback_home_finishing_boot.xml
+++ b/res/layout/fallback_home_finishing_boot.xml
@@ -38,11 +38,11 @@
android:text="@*android:string/android_start_title"/>
<ProgressBar
- android:theme="@style/FallbackHomeProgressBar"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12.75dp"
+ android:colorControlActivated="?android:attr/textColorPrimary"
android:indeterminate="true"/>
</LinearLayout>
diff --git a/res/layout/keyguard_appwidget_item.xml b/res/layout/keyguard_appwidget_item.xml
deleted file mode 100755
index de0c855..0000000
--- a/res/layout/keyguard_appwidget_item.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:background="@drawable/appwidget_item_bg"
- android:layout_marginTop="2dip"
- android:layout_marginBottom="2dip"
- android:layout_marginLeft="2dip"
- android:layout_marginRight="2dip"
- android:paddingLeft="16dip"
- android:paddingRight="16dip"
- android:paddingTop="16dip"
- android:paddingBottom="16dip" >
- <ImageView
- android:id="@+id/icon"
- android:layout_width="@dimen/appwidget_preview_width"
- android:layout_height="@dimen/appwidget_preview_height"
- android:scaleType="center" />
- <TextView
- android:id="@+id/label"
- style="@style/KeyguardAppWidgetItem"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingLeft="24dip"
- android:paddingBottom="8dip"
- android:gravity="left|bottom" />
- </LinearLayout>
-</FrameLayout>
diff --git a/res/layout/keyguard_appwidget_picker_layout.xml b/res/layout/keyguard_appwidget_picker_layout.xml
deleted file mode 100644
index e533672..0000000
--- a/res/layout/keyguard_appwidget_picker_layout.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/layout_root"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingLeft="@dimen/keyguard_appwidget_picker_margin_left"
- android:paddingRight="@dimen/keyguard_appwidget_picker_margin_right"
- android:paddingTop="2dip"
- android:paddingBottom="2dip"
- android:orientation="vertical" >
- <GridView android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:numColumns="@integer/keyguard_appwidget_picker_cols"
- android:layout_gravity="center_horizontal"
- android:listSelector="@android:color/transparent"
- android:id="@+id/widget_list" />
-</LinearLayout>
diff --git a/res/layout/nfc_payment.xml b/res/layout/nfc_payment.xml
index f56d2a4..c7039cf 100644
--- a/res/layout/nfc_payment.xml
+++ b/res/layout/nfc_payment.xml
@@ -48,15 +48,6 @@
android:drawSelectorOnTop="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:clipToPadding="false"
- android:scrollbarStyle="@integer/preference_scrollbar_style" />
-<!--
- <ListView
- android:id="@android:id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipToPadding="false"
- android:scrollbarStyle="@integer/preference_scrollbar_style" />
--->
+ android:clipToPadding="false" />
</FrameLayout>
</LinearLayout>
diff --git a/res/layout/ownerinfo.xml b/res/layout/ownerinfo.xml
index 29e0840..18ac461 100644
--- a/res/layout/ownerinfo.xml
+++ b/res/layout/ownerinfo.xml
@@ -28,8 +28,9 @@
android:minHeight="@dimen/min_tap_target_size"
android:gravity="top"
android:hint="@string/owner_info_settings_edit_text_hint"
- android:inputType="textMultiLine|textCapSentences"
- />
+ android:inputType="textMultiLine|textCapSentences">
+ <requestFocus />
+ </EditText>
</LinearLayout>
diff --git a/res/layout/permission_settings.xml b/res/layout/permission_settings.xml
deleted file mode 100644
index f08b9d6..0000000
--- a/res/layout/permission_settings.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipToPadding="false"
- android:scrollbarStyle="@integer/preference_scrollbar_style">
-
- <LinearLayout
- android:id="@+id/all_details"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingBottom="5dip"
- android:orientation="vertical">
-
- <!-- Permissions section -->
- <LinearLayout
- android:id="@+id/permissions_section"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TextView
- style="?android:attr/listSeparatorTextViewStyle"
- android:layout_marginTop="8dip"
- android:text="@string/permissions_label" />
- <TextView android:id="@+id/security_settings_billing_desc"
- android:text="@string/security_settings_billing_desc"
- android:textColor="#ffffb060"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingTop="6dip"
- android:paddingBottom="6dip"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
- <LinearLayout
- android:id="@+id/security_settings_billing_list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_premium_sms_desc" />
- <Spinner
- android:id="@+id/security_settings_premium_sms_list"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:spinnerMode="dropdown" />
- </LinearLayout>
- <TextView android:id="@+id/security_settings_desc"
- android:text="@string/security_settings_desc"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingTop="6dip"
- android:paddingBottom="6dip"
- android:paddingStart="?android:attr/listPreferredItemPaddingStart"
- android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
- <LinearLayout
- android:id="@+id/security_settings_list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"/>
- </LinearLayout>
-
-
- </LinearLayout>
-</ScrollView>
diff --git a/res/layout/preference_list_fragment.xml b/res/layout/preference_list_fragment.xml
index eeea9c4..852ef6d 100644
--- a/res/layout/preference_list_fragment.xml
+++ b/res/layout/preference_list_fragment.xml
@@ -37,19 +37,6 @@
android:paddingStart="@dimen/settings_side_margin"
android:paddingEnd="@dimen/settings_side_margin">
- <ListView android:id="@+id/backup_list"
- style="@style/PreferenceFragmentListSinglePane"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="@dimen/dashboard_padding_top"
- android:paddingBottom="@dimen/dashboard_padding_bottom"
- android:scrollbarStyle="@*android:integer/preference_fragment_scrollbarStyle"
- android:clipToPadding="false"
- android:drawSelectorOnTop="false"
- android:elevation="@dimen/dashboard_category_elevation"
- android:visibility="gone"
- android:scrollbarAlwaysDrawVerticalTrack="true" />
-
<include layout="@layout/loading_container" />
</FrameLayout>
@@ -74,8 +61,7 @@
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentStart="true"
- android:text="@*android:string/back_button_label"
- />
+ android:text="@*android:string/back_button_label" />
<LinearLayout
android:orientation="horizontal"
@@ -89,16 +75,14 @@
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:text="@*android:string/skip_button_label"
- android:visibility="gone"
- />
+ android:visibility="gone" />
<Button android:id="@+id/next_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dip"
- android:text="@*android:string/next_button_label"
- />
+ android:text="@*android:string/next_button_label" />
</LinearLayout>
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index aaad941..641905d 100644
--- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml
@@ -14,61 +14,68 @@
limitations under the License.
-->
-<LinearLayout
+<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="8dp">
+ android:layout_height="wrap_content">
- <RadioGroup
- android:id="@+id/private_dns_radio_group"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <RadioButton
- android:id="@+id/private_dns_mode_off"
- android:text="@string/private_dns_mode_off"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:minHeight="48dp"/>
-
- <RadioButton
- android:id="@+id/private_dns_mode_opportunistic"
- android:text="@string/private_dns_mode_opportunistic"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:minHeight="48dp"/>
-
- <RadioButton
- android:id="@+id/private_dns_mode_provider"
- android:text="@string/private_dns_mode_provider"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:minHeight="48dp"/>
-
- <EditText
- android:id="@+id/private_dns_mode_provider_hostname"
- android:hint="@string/private_dns_mode_provider_hostname_hint"
- style="@android:style/Widget.CompoundButton.RadioButton"
- android:imeOptions="actionDone"
- android:inputType="textFilter|textUri"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginStart="40dp"
- android:layout_marginEnd="8dp"
- android:minHeight="48dp"/>
- </RadioGroup>
-
- <TextView
- android:id="@+id/private_dns_help_info"
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:minHeight="48dp"
- android:paddingStart="16dp"
- android:textAppearance="?android:attr/textAppearanceSmall"/>
-</LinearLayout>
+ android:orientation="vertical"
+ android:padding="8dp">
+
+ <RadioGroup
+ android:id="@+id/private_dns_radio_group"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_off"
+ android:text="@string/private_dns_mode_off"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_opportunistic"
+ android:text="@string/private_dns_mode_opportunistic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_provider"
+ android:text="@string/private_dns_mode_provider"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <EditText
+ android:id="@+id/private_dns_mode_provider_hostname"
+ android:hint="@string/private_dns_mode_provider_hostname_hint"
+ style="@android:style/Widget.CompoundButton.RadioButton"
+ android:imeOptions="actionDone"
+ android:inputType="textFilter|textUri"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="40dp"
+ android:layout_marginEnd="8dp"
+ android:minHeight="48dp"/>
+ </RadioGroup>
+
+ <TextView
+ android:id="@+id/private_dns_help_info"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:minHeight="48dp"
+ android:paddingStart="16dp"
+ android:textAppearance="?android:attr/textAppearanceSmall"/>
+ </LinearLayout>
+
+</ScrollView>
+
diff --git a/res/layout/running_service_details.xml b/res/layout/running_service_details.xml
index f618bdd..68ddb1c 100644
--- a/res/layout/running_service_details.xml
+++ b/res/layout/running_service_details.xml
@@ -20,8 +20,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:clipToPadding="false"
- android:scrollbarStyle="@integer/preference_scrollbar_style">
+ android:clipToPadding="false">
<LinearLayout
android:id="@+id/all_details"
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 9569ae4..37e71e2 100755
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -17,11 +17,6 @@
<resources>
<dimen name="appwidget_width">421dip</dimen>
<dimen name="appwidget_height">68dip</dimen>
- <dimen name="appwidget_preview_width">120dip</dimen>
- <dimen name="appwidget_preview_height">70dip</dimen>
- <dimen name="keyguard_appwidget_picker_margin_left">2dip</dimen>
- <dimen name="keyguard_appwidget_picker_margin_right">2dip</dimen>
- <integer name="keyguard_appwidget_picker_cols">2</integer>
<dimen name="captioning_preview_height">100dp</dimen>
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
deleted file mode 100644
index 0903167..0000000
--- a/res/values-land/styles.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <style name="KeyguardAppWidgetItem">
- <item name="android:textSize">16sp</item>
- </style>
-</resources>
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index f6b4ad8..d5ea762 100755
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -18,8 +18,6 @@
<dimen name="screen_margin_sides">128dip</dimen>
<dimen name="screen_margin_top">72dip</dimen>
<dimen name="screen_margin_bottom">48dip</dimen>
- <dimen name="appwidget_preview_height">80dip</dimen>
- <dimen name="keyguard_appwidget_picker_width">720dip</dimen>
<!-- CryptKeeper top margin for password/pin screen -->
<dimen name="crypt_keeper_password_top_margin">116dip</dimen>
diff --git a/res/values-sw600dp-land/styles.xml b/res/values-sw600dp-land/styles.xml
deleted file mode 100644
index 645d1fe..0000000
--- a/res/values-sw600dp-land/styles.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <style name="KeyguardAppWidgetItem">
- <item name="android:textSize">18sp</item>
- </style>
-</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 8e47a62..58b05d8 100755
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -27,14 +27,6 @@
<dimen name="appwidget_min_width">325dip</dimen>
<dimen name="appwidget_min_height">50dip</dimen>
- <dimen name="appwidget_preview_width">120dip</dimen>
- <dimen name="appwidget_preview_height">70dip</dimen>
- <dimen name="keyguard_appwidget_picker_margin_left">2dip</dimen>
- <dimen name="keyguard_appwidget_picker_margin_right">2dip</dimen>
- <integer name="keyguard_appwidget_picker_cols">2</integer>
-
- <dimen name="settings_side_margin">0dip</dimen>
-
<!-- ActionBar contentInsetStart -->
<dimen name="actionbar_contentInsetStart">24dp</dimen>
<dimen name="actionbar_subsettings_contentInsetStart">80dp</dimen>
diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml
index d428288..b132f9f 100644
--- a/res/values-sw600dp/styles.xml
+++ b/res/values-sw600dp/styles.xml
@@ -28,7 +28,4 @@
<item name="android:textSize">20sp</item>
</style>
- <style name="KeyguardAppWidgetItem">
- <item name="android:textSize">16sp</item>
- </style>
</resources>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 981c936..ec4e22f 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -16,9 +16,6 @@
<resources>
<dimen name="pager_tabs_padding">0dp</dimen>
- <dimen name="appwidget_preview_height">80dip</dimen>
- <integer name="keyguard_appwidget_picker_cols">2</integer>
- <dimen name="keyguard_appwidget_picker_width">720dip</dimen>
<dimen name="settings_side_margin">64dp</dimen>
diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml
deleted file mode 100644
index 645d1fe..0000000
--- a/res/values-sw720dp/styles.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <style name="KeyguardAppWidgetItem">
- <item name="android:textSize">18sp</item>
- </style>
-</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 33573ac..7bdbe6d 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -179,4 +179,10 @@
<attr name="batteryBadColor" format="color" />
<attr name="batteryMaybeColor" format="color" />
+ <attr name="fingerprint_layout_theme" format="reference" />
+ <attr name="face_layout_theme" format="reference" />
+ <attr name="ic_menu_moreoverflow" format="reference" />
+ <attr name="side_margin" format="reference|dimension" />
+ <attr name="wifi_signal_color" format="reference" />
+
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 02d3182..2341728 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -97,9 +97,6 @@
<dimen name="dashboard_category_padding_start">0dp</dimen>
<dimen name="dashboard_category_padding_end">0dp</dimen>
- <!-- Dashboard category panel elevation -->
- <dimen name="dashboard_category_elevation">2dp</dimen>
-
<!-- Dashboard tile minimum height -->
<dimen name="dashboard_tile_minimum_height">72dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 82ae090..41b3a80 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -27,10 +27,7 @@
<!-- Strings for Dialog close button [CHAR LIMIT=20] -->
<string name="dlg_close">Close</string>
- <!-- Strings for Dialog switch button [CHAR LIMIT=20] -->
- <string name="dlg_switch">Switch</string>
- <!-- Device Info --> <skip />
<!-- Device Info screen. Used for a status item's value when the proper value is not known -->
<string name="device_info_default">Unknown</string>
<!-- [CHAR LIMIT=NONE] Device Info screen. Countdown for user taps to enable development settings -->
@@ -49,14 +46,6 @@
<!-- Category headings in left-pane header menu --> <skip />
<!-- Settings main menu category heading. Wireless and networks (Wi-Fi, Bluetooth, data usage...). [CHAR LIMIT=40] -->
<string name="header_category_wireless_networks">Wireless & networks</string>
- <!-- Settings main menu category heading. Wireless and networks (Wi-Fi, Bluetooth, data usage...). [CHAR LIMIT=40] -->
- <string name="header_category_connections">Connections</string>
- <!-- Settings main menu category heading. Device (Sound, display, battery, applications...). [CHAR LIMIT=40] -->
- <string name="header_category_device">Device</string>
- <!-- Settings main menu category heading. Personal (Accounts, security, language, backup...). [CHAR LIMIT=40] -->
- <string name="header_category_personal">Personal</string>
- <!-- Settings main menu category heading. Personal (Accounts, security, language, backup...). [CHAR LIMIT=40] -->
- <string name="header_category_access">Access</string>
<!-- Settings main menu category heading. System (Updates, data, accessibility, about phone). [CHAR LIMIT=40] -->
<string name="header_category_system">System</string>
@@ -269,8 +258,6 @@
<!-- Bluetooth broadcasting settings, option to enable/disable broadcasting -->
<string name="bluetooth_broadcasting">Broadcasting</string>
- <!-- Bluetooth settings. Message when the device state is unknown -->
- <string name="bluetooth_unknown" />
<!--Bluetooth settings screen, summary text for Bluetooth device with no name -->
<string name="bluetooth_device">Unnamed Bluetooth device</string>
<!--Bluetooth settings screen, text that appears in heading bar when scanning for devices -->
@@ -347,9 +334,6 @@
<!-- Strings for msg to display to user while bluetooth is turning off [CHAR LIMIT=60] -->
<string name="bluetooth_turning_off">"Turning Bluetooth off\u2026"</string>
- <!-- Strings for device profile auto connect setting -->
- <string name="bluetooth_auto_connect">Auto-connect</string>
-
<!-- Activity label of BluetoothPermissionActivity [CHAR LIMIT=none]-->
<string name="bluetooth_connection_permission_request">"Bluetooth connection request"</string>
@@ -419,8 +403,6 @@
<string name="connected_device_connected_title">Currently connected</string>
<!-- Title for connected device group [CHAR LIMIT=none]-->
<string name="connected_device_saved_title">Saved devices</string>
- <!-- Title for preference to add a device [CHAR LIMIT=none] [BACKUP_MESSAGE_ID=7803521577708810621] -->
- <string name="connected_device_add_device_title">Add device</string>
<!-- Summary for preference to add a device [CHAR LIMIT=none]-->
<string name="connected_device_add_device_summary">Bluetooth will turn on to pair</string>
<!-- Title for other connection preferences [CHAR LIMIT=none]-->
@@ -606,9 +588,6 @@
<!-- Title for the locale picker activity -->
<string name="language_picker_title">Languages</string>
- <!-- Title for the language selection screen [CHAR LIMIT=25] -->
- <string name="pref_title_lang_selection">Language preferences</string>
-
<!-- Menu item in the locale menu. Will remove the selected locales. [CHAR LIMIT=30] -->
<string name="locale_remove_menu">Remove</string>
@@ -662,10 +641,6 @@
<!-- The title of the activity to adjust proxy settings -->
<string name="proxy_settings_label">Proxy settings</string>
- <!-- ======================================================================================= -->
- <!-- NEW STUFF -->
- <!-- ======================================================================================= -->
-
<!-- Button label for generic cancel action [CHAR LIMIT=20] -->
<string name="cancel">Cancel</string>
<!-- Button label for generic OK action [CHAR LIMIT=20] -->
@@ -687,8 +662,6 @@
<string name="settings_shortcut">Settings shortcut</string>
<!-- Wireless controls settings screen, setting check box label -->
<string name="airplane_mode">Airplane mode</string>
- <!-- Main Settings screen settings title for things like airplane mode, tethering, NFC, VPN. This will take you to another screen with those settings. [CHAR LIMIT=30] -->
- <string name="radio_controls_title">More</string>
<!-- Wireless Settings screen title for things like Wi-Fi, bluetooth, airplane mode. -->
<string name="wireless_networks_settings_title">Wireless & networks</string>
<!-- Main Settings screen settings summary text for the "Wireless controls" setting -->
@@ -727,7 +700,6 @@
<!-- mobile network settings screen, setting option summary text -->
<string name="sum_carrier_select">Choose a network operator</string>
- <!-- Date and time settings --><skip />
<!-- Main Settings screen setting option name to go into the date and time settings-->
<string name="date_and_time_settings_title">Date & time</string>
<!-- Title for Date & Time settings screen in SetupWizard [CHAR LIMIT=40] -->
@@ -2140,8 +2112,6 @@
<string name="wifi_forget_dialog_message">All passwords for this network will be deleted</string>
<!-- Wi-Fi Advanced Settings --> <skip />
- <!-- Wi-Fi settings screen, Saved networks, settings section. This is a header shown above Saved networks wifi settings. [CHAR LIMIT=30] -->
- <string name="wifi_saved_access_points_titlebar">Saved networks</string>
<!-- Wi-Fi settings screen, Saved networks summary. This shows below the "Saved networks" item and indicates the number of networks a user has saved. -->
<plurals name="wifi_saved_access_points_summary">
<item quantity="one">1 network</item>
@@ -4089,12 +4059,6 @@
<string name="no_applications">No apps.</string>
<!-- [CHAR LIMIT=15] Manage applications, label for chart showing internal storage use. -->
<string name="internal_storage">Internal storage</string>
- <!-- [CHAR LIMIT=30] Title for internal device storage that is capitalized for placement as a phrase into another sentence -->
- <string name="internal_storage_sentence">internal storage</string>
- <!-- [CHAR LIMIT=15] Manage applications, label for chart showing SD card storage use. -->
- <string name="sd_card_storage" product="nosdcard">USB storage</string>
- <!-- [CHAR LIMIT=15] Manage applications, label for chart showing SD card storage use. -->
- <string name="sd_card_storage" product="default">SD card storage</string>
<!-- Manage app screen, shown when the activity is busy recomputing the size of each app -->
<string name="recompute_size">Recomputing size\u2026</string>
<!-- Manage applications, individual application screen, confirmation dialog title. Displays when user selects to "Clear data". -->
@@ -4111,36 +4075,12 @@
<string name="app_not_found_dlg_text"> The app wasn\u2019t found in the list of installed apps.</string>
<!-- Manage applications, text for dialog if clear data fails-->
<string name="clear_failed_dlg_text">Couldn\u2019t clear storage for app.</string>
- <!-- Manage applications, individual application info screen, text that appears under the "Permissions" heading. This describes the permissions that the application has. -->
- <string name="security_settings_desc" product="tablet">This app can access the following on your tablet:</string>
- <!-- Manage applications, individual application info screen, text that appears under the "Permissions" heading. This describes the permissions that the application has. -->
- <string name="security_settings_desc" product="default">This app can access the following on your phone:</string>
- <!-- [CHAR_LIMIT=NONE] Manage applications, individual application info screen, text that appears under the "Permissions" heading.
- This describes the permissions that the application has. It is used when multiple packages are contributing
- to the permissions and need to be listed here. -->
- <string name="security_settings_desc_multi" product="tablet">This app can access the following on your tablet.
- In order to improve performance and reduce memory usage, some of these permissions
- are available to <xliff:g id="base_app_name">%1$s</xliff:g>
- because it runs in the same process as <xliff:g id="additional_apps_list">%2$s</xliff:g>:</string>
- <!-- [CHAR_LIMIT=NONE] Manage applications, individual application info screen, text that appears under the "Permissions" heading.
- This describes the permissions that the application has. It is used when multiple packages are contributing
- to the permissions and need to be listed here. -->
- <string name="security_settings_desc_multi" product="default">This app can access the following on your phone.
- In order to improve performance and reduce memory usage, some of these permissions
- are available to <xliff:g id="base_app_name">%1$s</xliff:g>
- because it runs in the same process as <xliff:g id="additional_apps_list">%2$s</xliff:g>:</string>
<!-- [CHAR_LIMIT=NONE] Format to put together two items in a list. -->
<string name="join_two_items"><xliff:g id="first_item">%1$s</xliff:g> and <xliff:g id="second_item">%2$s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] Format to put together two unrelated items in a list when "and" is not an appropriate conjunction for these 2 items -->
<string name="join_two_unrelated_items"><xliff:g id="first_item">%1$s</xliff:g>, <xliff:g id="second_item">%2$s</xliff:g></string>
- <!-- Manage applications, individual application info screen, text that appears under the "Permissions" heading after the app has tried to send to a premium SMS. [CHAR LIMIT=50] -->
- <string name="security_settings_billing_desc">This app may charge you money:</string>
- <!-- Manage applications, text for permission to send to premium SMS short codes. [CHAR LIMIT=40] -->
- <string name="security_settings_premium_sms_desc">Send premium SMS</string>
<string name="computing_size">Computing\u2026</string>
<string name="invalid_size_value">Couldn\u2019t compute package size.</string>
- <!-- String displayed when list is empty -->
- <string name="empty_list_msg">You don\u2019t have any third-party apps installed.</string>
<!-- Manage applications, version string displayed in app snippet -->
<string name="version_text">version <xliff:g id="version_num">%1$s</xliff:g></string>
<!-- Manage applications, text for Move button -->
@@ -4153,9 +4093,6 @@
<string name="move_app_to_sdcard" product="nosdcard">Move to USB storage</string>
<!-- Manage applications, text for Move button to move app to sdcard -->
<string name="move_app_to_sdcard" product="default">Move to SD card</string>
- <!-- Manage applications, title for dialog when killing persistent apps-->
- <!-- Manage applications, text for Move button when move is in progress -->
- <string name="moving">Moving</string>
<!-- Text of pop up message if the request for a "migrate primary storage" operation
(see storage_menu_migrate) is denied as another is already in progress. [CHAR LIMIT=75] -->
@@ -4173,16 +4110,10 @@
<string name="force_stop_dlg_title">Force stop?</string>
<!-- [CHAR LIMIT=200] Manage applications, text for dialog when killing persistent apps-->
<string name="force_stop_dlg_text">If you force stop an app, it may misbehave.</string>
- <!-- Manage applications, text for dialog when moving an app -->
- <string name="move_app_failed_dlg_title"></string>
- <!-- Manage applications, text for dialog moving an app -->
- <string name="move_app_failed_dlg_text">Couldn\u2019t move app. <xliff:g id="reason">%1$s</xliff:g></string>
<!-- Manage applications, application installation location title -->
<string name="app_install_location_title">Preferred install location</string>
<!-- Manage applications. application installation location summary -->
<string name="app_install_location_summary">Change the preferred installation location for new apps</string>
- <!-- [CHAR LIMIT=30] Manage applications, title for dialog when disabling apps -->
- <string name="app_disable_dlg_title">Disable built-in app?</string>
<!-- [CHAR LIMIT=30] Manage applications, label for option to disable app -->
<string name="app_disable_dlg_positive">Disable app</string>
<!-- [CHAR LIMIT=200] Manage applications, text for dialog when disabling apps -->
@@ -4193,11 +4124,6 @@
<string name="app_special_disable_dlg_text">If you disable this app, Android and other apps may no longer function as intended. Your data will also be deleted.</string>
<!-- [CHAR LIMIT=30] Manage applications, title for dialog when disabling notifications for an app -->
<string name="app_disable_notifications_dlg_title">Turn off notifications?</string>
- <!-- [CHAR LIMIT=200] Manage applications, text for dialog when disabling notifications for an app -->
- <string name="app_disable_notifications_dlg_text">
- If you turn off notifications for this app, you may miss important alerts and updates.
- </string>
-
<!-- Manage applications, individual application info screen, section heading for information about the app installer [CHAR_LIMIT=25] -->
<string name="app_install_details_group_title">Store</string>
<!-- Manage applications, individual application info screen, title for the option which will trigger application info in it's installer [CHAR_LIMIT=25] -->
@@ -4994,11 +4920,6 @@
<!-- Title for the screen usage in power use UI [CHAR_LIMIT=60] -->
<string name="device_screen_usage">Screen usage since full charge</string>
- <!-- Title for the screen consumption in power use UI(i.e. Screen consumption: 30% of battery usage) [CHAR_LIMIT=40] -->
- <string name="device_screen_consumption">Screen consumption</string>
- <!-- Title for the cellular network in power use UI(i.e. Mobile network scanning: 30% of battery usage) [CHAR_LIMIT=40] -->
- <string name="device_cellular_network">Mobile network scanning</string>
-
<!-- Label for list of apps using battery in power use UI. Note: ^1 should be used in all translations[CHAR_LIMIT=120] -->
<string name="power_usage_list_summary">Battery usage since full charge</string>
<!-- Temp string used to debug new battery estimates [DO NOT TRANSLATE] -->
@@ -5056,18 +4977,6 @@
<!-- Subtitle for list of packages -->
<string name="packages_subtitle">Included packages</string>
- <!-- Activity title for battery abnormal details page [CHAR LIMIT=60] -->
- <string name="battery_abnormal_details_title">Apps draining battery</string>
-
- <!-- Summary for wakelock anomaly, means device been kept awake [CHAR LIMIT=60] -->
- <string name="battery_abnormal_wakelock_summary">Keeping device awake</string>
- <!-- Summary for wakeup alarm anomaly, meaning device been wakeup in the background [CHAR LIMIT=60] -->
- <string name="battery_abnormal_wakeup_alarm_summary">Waking up device in background</string>
- <!-- Summary for location anomaly, meaning device is requesting location too frequently [CHAR LIMIT=60] -->
- <string name="battery_abnormal_location_summary">Requesting location frequently</string>
- <!-- Summary for anomalies, meaning some apps behaving abnormally [CHAR LIMIT=80] -->
- <string name="battery_abnormal_apps_summary"><xliff:g id="number">%1$d</xliff:g> apps misbehaving</string>
-
<!-- Title for the battery summary tip [CHAR LIMIT=NONE] -->
<string name="battery_tip_summary_title">Apps are running normally</string>
<!-- Summary for the battery summary tip [CHAR LIMIT=NONE] -->
@@ -6034,8 +5943,8 @@
<!-- Activity title for network data usage summary. [CHAR LIMIT=25] -->
<string name="data_usage_summary_title">Data usage</string>
- <!-- Activity title for Appk data usage summary. [CHAR LIMIT=25] -->
- <string name="data_usage_app_summary_title">App data usage</string>
+ <!-- Activity title Mobile data & WI-FI summary. [CHAR LIMIT=25] -->
+ <string name="data_usage_app_summary_title">Mobile data & Wi\u2011Fi</string>
<!-- Message about carrier data accounting. [CHAR LIMIT=100] -->
<string name="data_usage_accounting">Carrier data accounting may differ from your device.</string>
<!-- Title for app usage. [CHAR LIMIT=40] -->
@@ -6986,6 +6895,8 @@
<string name="app_and_notification_dashboard_title">Apps & notifications</string>
<!-- Summary for Apps & Notification settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
<string name="app_and_notification_dashboard_summary">Permissions, default apps</string>
+ <!-- Toast text for notification settings in the work profile. This is shown when an app in the work profile attempts to open notification settings. [CHAR LIMIT=NONE] -->
+ <string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string>
<!-- Title for setting tile leading to account settings [CHAR LIMIT=40]-->
<string name="account_dashboard_title">Accounts</string>
<!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]-->
@@ -8578,9 +8489,6 @@
<!-- Label for menu to show app usage [CHAR LIMIT=30] -->
<string name="hide_extra_apps">Show app usage</string>
- <!-- Title for high usage item, which means power high usage [CHAR LIMIT=30] -->
- <string name="power_high_usage_title">High usage</string>
-
<!-- Summary for high usage item, showing app/apps are behaving abnormally [CHAR LIMIT=80] -->
<plurals name="power_high_usage_summary">
<item quantity="one"><xliff:g id="app">%1$s</xliff:g> behaving abnormally</item>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 2210904..88ff2bb 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -16,6 +16,14 @@
<resources>
+ <style name="Theme.ActionBar" parent="@android:style/Widget.DeviceDefault.Light.ActionBar.Solid">
+ <item name="android:contentInsetStart">@dimen/actionbar_contentInsetStart</item>
+ </style>
+
+ <style name="Theme.ActionBar.SubSettings" parent="Theme.ActionBar">
+ <item name="android:contentInsetStart">@dimen/actionbar_subsettings_contentInsetStart</item>
+ </style>
+
<style name="info_label">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
@@ -56,71 +64,6 @@
<item name="android:layout_width">match_parent</item>
</style>
-
- <style name="TextAppearance" parent="android:TextAppearance.Material">
- </style>
-
- <style name="TextAppearance.info_label">
- <item name="android:textSize">14sp</item>
- <item name="android:textStyle">bold</item>
- </style>
-
- <style name="TextAppearance.info_small">
- <item name="android:textSize">12sp</item>
- <item name="android:textStyle">normal</item>
- </style>
-
- <style name="TextAppearance.info_value">
- <item name="android:textSize">14sp</item>
- <item name="android:textStyle">normal</item>
- </style>
-
- <style name="TextAppearance.PasswordEntry" parent="android:TextAppearance.Material">
- <item name="android:gravity">center</item>
- <item name="android:singleLine">true</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- <item name="android:textSize">24sp</item>
- </style>
-
- <style name="TextAppearance.CryptKeeper_PasswordEntry" parent="android:TextAppearance.Material">
- <item name="android:gravity">center_horizontal</item>
- <item name="android:background">@null</item>
- <item name="android:textCursorDrawable">@null</item>
- <item name="android:singleLine">true</item>
- <item name="android:imeOptions">flagForceAscii|actionDone</item>
- </style>
-
- <style name="TallTitleBarTheme" parent="android:Theme.NoTitleBar">
- <item name="android:windowContentOverlay">@null</item>
- </style>
-
- <style name="PreferenceHeaderPanelSinglePane">
- <item name="android:layout_marginStart">0dp</item>
- <item name="android:layout_marginEnd">0dp</item>
- <item name="android:background">@null</item>
- </style>
-
- <style name="PreferencePanelSinglePane" parent="@*android:style/PreferencePanel">
- <item name="android:layout_marginStart">0dp</item>
- <item name="android:layout_marginEnd">0dp</item>
- <item name="android:paddingStart">0dp</item>
- <item name="android:paddingEnd">0dp</item>
- <item name="android:background">@null</item>
- <item name="android:scrollbarStyle">outsideOverlay</item>
- </style>
-
- <style name="PreferenceHeaderListSinglePane" parent="@*android:style/PreferenceHeaderList">
- <item name="android:paddingStart">@dimen/settings_side_margin</item>
- <item name="android:paddingEnd">@dimen/settings_side_margin</item>
- <item name="android:paddingTop">0dp</item>
- <item name="android:paddingBottom">0dp</item>
- <item name="android:layout_marginStart">0dp</item>
- <item name="android:layout_marginEnd">0dp</item>
- <item name="android:layout_marginTop">0dp</item>
- <item name="android:layout_marginBottom">0dp</item>
- <item name="android:scrollbarStyle">outsideOverlay</item>
- </style>
-
<style name="PreferenceFragmentListSinglePane" parent="@*android:style/PreferenceFragmentList">
<item name="android:paddingStart">@dimen/settings_side_margin</item>
<item name="android:paddingEnd">@dimen/settings_side_margin</item>
@@ -224,13 +167,6 @@
<item name="android:activityOpenExitAnimation">@anim/confirm_credential_open_exit</item>
</style>
- <style name="Transparent">
- <item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsFloating">true</item>
- </style>
-
<style name="CryptKeeperBlankTheme" parent="@android:style/Theme.Material.NoActionBar">
<item name="android:background">#ff000000</item>
</style>
@@ -284,14 +220,37 @@
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
</style>
- <style name="TextAppearance.PagerTabs" parent="@android:style/TextAppearance.Material.Widget.TabWidget" />
+ <style name="TextAppearance" parent="android:TextAppearance.Material"/>
- <style name="KeyguardAppWidgetItem">
- <item name="android:textSize">18sp</item>
+ <style name="TextAppearance.info_label">
+ <item name="android:textSize">14sp</item>
+ <item name="android:textStyle">bold</item>
</style>
- <!-- Scrollbar style OUTSIDE_OVERLAY -->
- <integer name="preference_scrollbar_style">33554432</integer>
+ <style name="TextAppearance.info_small">
+ <item name="android:textSize">12sp</item>
+ <item name="android:textStyle">normal</item>
+ </style>
+
+ <style name="TextAppearance.info_value">
+ <item name="android:textSize">14sp</item>
+ <item name="android:textStyle">normal</item>
+ </style>
+
+ <style name="TextAppearance.PasswordEntry" parent="android:TextAppearance.Material">
+ <item name="android:gravity">center</item>
+ <item name="android:singleLine">true</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:textSize">24sp</item>
+ </style>
+
+ <style name="TextAppearance.CryptKeeper_PasswordEntry" parent="android:TextAppearance.Material">
+ <item name="android:gravity">center_horizontal</item>
+ <item name="android:background">@null</item>
+ <item name="android:textCursorDrawable">@null</item>
+ <item name="android:singleLine">true</item>
+ <item name="android:imeOptions">flagForceAscii|actionDone</item>
+ </style>
<style name="TextAppearance.Medium" parent="@android:style/TextAppearance.Material.Medium" />
<style name="TextAppearance.Small" parent="@android:style/TextAppearance.Material.Small" />
@@ -304,9 +263,44 @@
</style>
<style name="TextAppearance.TileTitle" parent="@android:style/TextAppearance.Material.Subhead" />
- <style name="TextAppearance.TileSubTitle" parent="@android:style/TextAppearance.Material.Body1" />
- <style name="TextAppearance.RecentsTitle" parent="TextAppearance.CategoryTitle" />
- <style name="TextAppearance.ResultTitle" parent="TextAppearance.CategoryTitle" />
+
+ <style name="TextAppearance.SuggestionTitle"
+ parent="@android:style/TextAppearance.Material.Subhead">
+ <item name="android:textSize">16sp</item>
+ </style>
+
+ <style name="TextAppearance.SuggestionSummary" parent="TextAppearance.Small">
+ <item name="android:textColor">?android:attr/textColorSecondary</item>
+ </style>
+
+ <style name="TextAppearance.FingerprintErrorText"
+ parent="android:TextAppearance.Material.Body1">
+ <item name="android:textColor">?android:attr/colorError</item>
+ </style>
+
+ <style name="TextAppearance.FaceErrorText"
+ parent="android:TextAppearance.Material.Body1">
+ <item name="android:textColor">?android:attr/colorError</item>
+ </style>
+
+ <style name="TextAppearance.ConfirmDeviceCredentialsErrorText"
+ parent="android:TextAppearance.Material.Body1">
+ <item name="android:textColor">?android:attr/colorError</item>
+ </style>
+
+ <style name="TextAppearance.Small.SwitchBar">
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:textStyle">normal</item>
+ </style>
+
+ <style name="TextAppearance.RemoveDialogContent" parent="@android:style/TextAppearance.Material">
+ <item name="android:textSize">16sp</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ </style>
+
+ <style name="TextAppearance.SearchBar" parent="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle">
+ <item name="android:textSize">@dimen/search_bar_text_size</item>
+ </style>
<style name="TextAppearance.SuggestionHeader"
parent="@android:style/TextAppearance.Material.Subhead">
@@ -314,6 +308,35 @@
<item name="android:textColor">?android:attr/colorAccent</item>
</style>
+ <style name="TextAppearance.EntityHeaderTitle"
+ parent="@android:style/TextAppearance.Material.Subhead">
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:textSize">16sp</item>
+ </style>
+
+ <style name="TextAppearance.EntityHeaderSummary"
+ parent="@android:style/TextAppearance.Material.Body1">
+ <item name="android:textAlignment">viewStart</item>
+ <item name="android:textColor">?android:attr/textColorSecondary</item>
+ <item name="android:gravity">start</item>
+ <item name="android:singleLine">true</item>
+ <item name="android:ellipsize">marquee</item>
+ </style>
+
+ <style name="TextAppearance.ZenOnboardingButton">
+ <item name="android:fontFamily">sans-serif-medium</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:textColor">?android:attr/colorAccent</item>
+ <item name="android:background">@drawable/btn_borderless_rect</item>
+ <item name="android:gravity">center</item>
+ <item name="android:focusable">true</item>
+ <item name="android:padding">8dp</item>
+ </style>
+
+ <style name="SuggestionConditionStyle">
+ <item name="android:background">?android:attr/colorPrimary</item>
+ </style>
+
<style name="SuggestionCardText">
<item name="android:textAlignment">viewStart</item>
</style>
@@ -333,48 +356,14 @@
<item name="android:layout_marginBottom">@dimen/suggestion_card_button_bottom_margin</item>
</style>
- <style name="TextAppearance.SuggestionTitle"
- parent="@android:style/TextAppearance.Material.Subhead">
- <item name="android:textSize">16sp</item>
- </style>
-
- <style name="TextAppearance.SuggestionSummary" parent="TextAppearance.Small">
- <item name="android:textColor">?android:attr/textColorSecondary</item>
- </style>
-
- <style name="TextAppearance.FingerprintErrorText"
- parent="android:TextAppearance.Material.Body1">
- <item name="android:textColor">?android:attr/colorError</item>
- </style>
-
<style name="FingerprintLayoutTheme">
<item name="android:icon">@drawable/ic_fingerprint_header</item>
</style>
- <style name="TextAppearance.FaceErrorText"
- parent="android:TextAppearance.Material.Body1">
- <item name="android:textColor">?android:attr/colorError</item>
- </style>
-
<style name="FaceLayoutTheme">
<item name="android:icon">@drawable/ic_face_header</item>
</style>
- <style name="TextAppearance.ConfirmDeviceCredentialsErrorText"
- parent="android:TextAppearance.Material.Body1">
- <item name="android:textColor">?android:attr/colorError</item>
- </style>
-
- <style name="TextAppearance.Small.SwitchBar">
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- <item name="android:textStyle">normal</item>
- </style>
-
- <style name="TextAppearance.RemoveDialogContent" parent="@android:style/TextAppearance.Material">
- <item name="android:textSize">16sp</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- </style>
-
<style name="PreviewPagerPageIndicator">
<item name="dotGap">8dp</item>
<item name="pageIndicatorColor">?android:attr/colorControlNormal</item>
@@ -390,12 +379,6 @@
<item name="android:gravity">center_vertical</item>
</style>
- <style name="RedactionItemAndLabel">
- <item name="android:layout_marginTop">@dimen/redaction_vertical_margins</item>
- <item name="android:paddingStart">@dimen/redaction_padding_start</item>
- <item name="android:textAppearance">@android:style/TextAppearance.Material.Subhead</item>
- </style>
-
<style name="FingerprintHeaderStyle" parent="android:style/TextAppearance.Material.Subhead">
<item name="android:paddingTop">16dp</item>
<item name="android:textColor">@color/primary_dark_material_light</item>
@@ -424,37 +407,10 @@
<item name="android:paddingBottom">8dp</item>
</style>
- <style name="TextAppearance.EntityHeaderTitle"
- parent="@android:style/TextAppearance.Material.Subhead">
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- <item name="android:textSize">16sp</item>
- </style>
-
- <style name="TextAppearance.EntityHeaderSummary"
- parent="@android:style/TextAppearance.Material.Body1">
- <item name="android:textAlignment">viewStart</item>
- <item name="android:textColor">?android:attr/textColorSecondary</item>
- <item name="android:gravity">start</item>
- <item name="android:singleLine">true</item>
- <item name="android:ellipsize">marquee</item>
- </style>
-
- <style name="TextAppearance.ZenOnboardingButton">
- <item name="android:fontFamily">sans-serif-medium</item>
- <item name="android:textSize">14sp</item>
- <item name="android:textColor">?android:attr/colorAccent</item>
- <item name="android:background">@drawable/btn_borderless_rect</item>
- <item name="android:gravity">center</item>
- <item name="android:focusable">true</item>
- <item name="android:padding">8dp</item>
- </style>
-
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
- <style name="DreamStartButton" parent="android:Widget.DeviceDefault.Button" />
-
<style name="LockPatternContainerStyle">
<item name="android:maxHeight">400dp</item>
<item name="android:maxWidth">420dp</item>
@@ -490,14 +446,6 @@
<item name="*android:successColor">@color/setup_lock_pattern_view_success_color_light</item>
</style>
- <style name="SuggestionConditionStyle">
- <item name="android:background">?android:attr/colorPrimary</item>
- </style>
-
- <style name="TextAppearance.SearchBar" parent="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle">
- <item name="android:textSize">@dimen/search_bar_text_size</item>
- </style>
-
<style name="device_info_dialog_label">
<item name="android:textAlignment">viewStart</item>
<item name="android:textAppearance">@android:style/TextAppearance.Material.Body1</item>
diff --git a/res/values/styles_preference.xml b/res/values/styles_preference.xml
index 8fd38d6..0f7ecab 100644
--- a/res/values/styles_preference.xml
+++ b/res/values/styles_preference.xml
@@ -19,6 +19,17 @@
<!-- Things unrelated to preference framework UI customization should go to other styles files -->
<resources>
+ <style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.SettingsBase">
+ <item name="apnPreferenceStyle">@style/ApnPreference</item>
+ <item name="seekBarPreferenceStyle">@style/SettingsSeekBarPreference</item>
+ <item name="twoStateButtonPreferenceStyle">@style/TwoStateButtonPreference</item>
+ </style>
+
+ <style name="PreferenceTheme.SetupWizard">
+ <item name="preferenceFragmentCompatStyle">@style/SetupWizardPreferenceFragmentStyle</item>
+ <item name="preferenceStyle">@style/Preference.Material</item>
+ </style>
+
<style name="ApnPreference" parent="@style/Preference.Material">
<item name="android:layout">@layout/apn_preference_layout</item>
</style>
@@ -40,4 +51,8 @@
<item name="android:negativeButtonText">@android:string/cancel</item>
</style>
+ <style name="SetupWizardPreferenceFragmentStyle" parent="PreferenceFragment.Material">
+ <item name="android:layout">@layout/setup_preference</item>
+ </style>
+
</resources>
\ No newline at end of file
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 70cffa3..3bf36ba9 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -15,212 +15,19 @@
-->
<resources>
- <attr name="fingerprint_layout_theme" format="reference" />
- <attr name="face_layout_theme" format="reference" />
- <attr name="ic_menu_moreoverflow" format="reference" />
- <attr name="side_margin" format="reference|dimension" />
- <attr name="wifi_signal_color" format="reference" />
- <style name="GlifTheme" parent="SuwThemeGlif">
- <!-- For all Alert Dialogs -->
- <item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
- <item name="android:windowBackground">?android:attr/colorBackground</item>
- <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
- <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
- <item name="face_layout_theme">@style/FaceLayoutTheme</item>
- <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="side_margin">0dip</item>
- <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
- <item name="wifi_signal">@drawable/wifi_signal</item>
- <item name="wifi_friction">@drawable/wifi_friction</item>
- <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
- <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
-
- <!-- LockPatternView colors -->
- <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
- </style>
-
- <style name="GlifTheme.Light" parent="SuwThemeGlif.Light">
- <!-- For all Alert Dialogs -->
- <item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
- <item name="android:windowBackground">?android:attr/colorBackground</item>
- <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
- <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
- <item name="face_layout_theme">@style/FaceLayoutTheme</item>
- <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="side_margin">0dip</item>
- <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
- <item name="wifi_signal">@drawable/wifi_signal</item>
- <item name="wifi_friction">@drawable/wifi_friction</item>
- <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
- <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
-
- <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
- <item name="*android:colorError">@color/glif_error_color</item>
- </style>
-
- <style name="GlifV2Theme" parent="SuwThemeGlifV2">
- <!-- For all Alert Dialogs -->
- <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
- <item name="android:windowBackground">?android:attr/colorBackground</item>
- <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
- <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
- <item name="face_layout_theme">@style/FaceLayoutTheme</item>
- <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="side_margin">0dip</item>
- <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
- <item name="wifi_signal">@drawable/wifi_signal</item>
- <item name="wifi_friction">@drawable/wifi_friction</item>
- <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
- <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
-
- <!-- LockPatternView colors -->
- <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
- </style>
-
- <style name="GlifV2Theme.Light" parent="SuwThemeGlifV2.Light">
- <!-- For all Alert Dialogs -->
- <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
- <item name="android:windowBackground">?android:attr/colorBackground</item>
- <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
- <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
- <item name="face_layout_theme">@style/FaceLayoutTheme</item>
- <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="side_margin">0dip</item>
- <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
- <item name="wifi_signal">@drawable/wifi_signal</item>
- <item name="wifi_friction">@drawable/wifi_friction</item>
- <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
- <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
-
- <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
- <item name="*android:colorError">@color/glif_error_color</item>
- </style>
-
- <style name="GlifV3Theme" parent="SuwThemeGlifV3">
- <!-- For all Alert Dialogs -->
- <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
- <item name="android:windowBackground">?android:attr/colorBackground</item>
- <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
- <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
- <item name="face_layout_theme">@style/FaceLayoutTheme</item>
- <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="side_margin">0dip</item>
- <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
- <item name="wifi_signal">@drawable/wifi_signal</item>
- <item name="wifi_friction">@drawable/wifi_friction</item>
- <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
- <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
-
- <!-- LockPatternView colors -->
- <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
- </style>
-
- <style name="GlifV3Theme.Light" parent="SuwThemeGlifV3.Light">
- <!-- For all Alert Dialogs -->
- <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
- <item name="android:windowBackground">?android:attr/colorBackground</item>
- <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
- <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
- <item name="face_layout_theme">@style/FaceLayoutTheme</item>
- <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
- <item name="side_margin">0dip</item>
- <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
- <item name="wifi_signal">@drawable/wifi_signal</item>
- <item name="wifi_friction">@drawable/wifi_friction</item>
- <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
- <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
-
- <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
- <item name="*android:colorError">@color/glif_error_color</item>
- </style>
-
- <style name="SetupWizardTheme.Transparent" parent="GlifTheme">
+ <style name="Transparent">
+ <item name="alertDialogTheme">@style/Theme.AlertDialog</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
- <item name="android:windowAnimationStyle">@null</item>
</style>
- <style name="SetupWizardTheme.Light.Transparent" parent="GlifTheme.Light">
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsFloating">true</item>
- <item name="android:windowAnimationStyle">@null</item>
- </style>
-
- <style name="GlifV2Theme.Transparent">
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsFloating">true</item>
- <item name="android:windowAnimationStyle">@null</item>
- </style>
-
- <style name="GlifV2Theme.Light.Transparent">
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsFloating">true</item>
- <item name="android:windowAnimationStyle">@null</item>
- </style>
-
- <style name="GlifV3Theme.Transparent">
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsFloating">true</item>
- <item name="android:windowAnimationStyle">@null</item>
- </style>
-
- <style name="GlifV3Theme.Light.Transparent">
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsFloating">true</item>
- <item name="android:windowAnimationStyle">@null</item>
- </style>
-
-
- <style name="SuwSuggestionThemeGlif.Light" parent="SuwThemeGlif.Light">
- <item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>
- </style>
-
- <style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.SettingsBase">
- <item name="apnPreferenceStyle">@style/ApnPreference</item>
- <item name="seekBarPreferenceStyle">@style/SettingsSeekBarPreference</item>
- <item name="twoStateButtonPreferenceStyle">@style/TwoStateButtonPreference</item>
- </style>
-
- <style name="PreferenceTheme.SetupWizard" parent="PreferenceTheme">
- <item name="preferenceFragmentCompatStyle">@style/SetupWizardPreferenceFragmentStyle</item>
- <item name="preferenceStyle">@style/Preference.Material</item>
- </style>
-
- <style name="SetupWizardPreferenceFragmentStyle" parent="PreferenceFragment.Material">
- <item name="android:layout">@layout/setup_preference</item>
- </style>
-
- <!-- Accessibility portion of Setup Wizard -->
- <style name="SetupWizardAccessibilityTheme" parent="Theme.SettingsBase">
- <item name="android:windowLightStatusBar">false</item>
- <item name="android:colorPrimary">@color/material_grey_100</item>
- <item name="android:colorAccent">@color/material_blue_700</item>
- <item name="android:titleTextColor">@color/material_blue_700</item>
- <item name="preferenceTheme">@style/PreferenceTheme</item>
- <item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.Settings</item>
- </style>
-
- <!-- Theme with no local references, used by AccountPreferenceBase where we have to inflate
- layouts against a remote context using our local theme colors. Due to the implementation
- details of Theme, we can't reference any local resources and MUST instead use the values
- directly. So use #ff263238 instead of @color/theme_primary and so on. -->
<style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings" />
<style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="android:listPreferredItemHeight">72dip</item>
- <item name="*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
- <item name="*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
- <item name="*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item>
- <item name="*android:preferenceFragmentListStyle">@style/PreferenceFragmentListSinglePane</item>
- <item name="*android:preferenceFragmentPaddingSide">@dimen/settings_side_margin</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="face_layout_theme">@style/FaceLayoutTheme</item>
@@ -238,8 +45,8 @@
<item name="preferenceBackgroundColor">@drawable/preference_background</item>
- <!-- For all androidx version of AlertDialogs -->
- <item name="alertDialogTheme">@style/Theme.AppCompat.Light.Dialog.Alert</item>
+ <!-- For AndroidX AlertDialog -->
+ <item name="alertDialogTheme">@style/Theme.AlertDialog</item>
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
@@ -249,6 +56,12 @@
<item name="batteryBadColor">@color/battery_bad_color_light</item>
</style>
+ <!-- Variant of the settings theme with no action bar. -->
+ <style name="Theme.Settings.NoActionBar">
+ <item name="android:windowActionBar">false</item>
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
<style name="Theme.SubSettings" parent="Theme.Settings">
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Theme.ActionBar.SubSettings</item>
@@ -256,12 +69,6 @@
<item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.Settings</item>
</style>
- <!-- Variant of the settings theme with no action bar. -->
- <style name="Theme.Settings.NoActionBar">
- <item name="android:windowActionBar">false</item>
- <item name="android:windowNoTitle">true</item>
- </style>
-
<style name="Theme.ProvisioningActivity" parent="@android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowIsTranslucent">true</item>
@@ -272,14 +79,6 @@
<item name="android:backgroundDimEnabled">false</item>
</style>
- <style name="Theme.ActionBar" parent="@android:style/Widget.DeviceDefault.Light.ActionBar.Solid">
- <item name="android:contentInsetStart">@dimen/actionbar_contentInsetStart</item>
- </style>
-
- <style name="Theme.ActionBar.SubSettings" parent="Theme.ActionBar">
- <item name="android:contentInsetStart">@dimen/actionbar_subsettings_contentInsetStart</item>
- </style>
-
<style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.ActionBar">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
@@ -307,19 +106,15 @@
<item name="android:windowSoftInputMode">adjustResize</item>
</style>
- <style name="GlifV2ThemeAlertDialog" parent="SuwAlertDialogTheme">
- <item name="android:windowSoftInputMode">adjustResize</item>
- </style>
-
- <style name="GlifV2ThemeAlertDialog.Light" parent="SuwAlertDialogTheme.Light">
- <item name="android:windowSoftInputMode">adjustResize</item>
- </style>
-
- <style name="Theme.AlertDialog" parent="@*android:style/Theme.DeviceDefault.Settings.Dialog.Alert">
+ <style name="Theme.AlertDialog" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
<item name="android:windowSoftInputMode">adjustResize</item>
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Theme.ActionBar</item>
+
+ <!-- copied from Theme.DeviceDefault.Light.Dialog.Alert -->
+ <item name="colorAccent">@*android:color/accent_device_default_light</item>
+ <item name="dialogCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
</style>
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
@@ -366,19 +161,16 @@
<item name="android:navigationBarColor">#00000000</item>
</style>
- <style name="FallbackHomeProgressBar" parent="FallbackHome">
- <item name="android:colorControlActivated">?android:attr/textColorPrimary</item>
- </style>
-
- <style name="BluetoothPermission" parent="@android:style/Theme.Material.Light.Dialog.Alert">
+ <style name="Theme.BluetoothPermission" parent="@android:style/Theme.Material.Light.Dialog.Alert">
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.Settings.Home" parent="Theme.AppCompat.Light.NoActionBar">
- <!-- copied from frameworks/base/core/res/res/values/themes_device_defaults.xml -->
+ <!-- Color names copied from frameworks/base/core/res/res/values/themes_device_defaults.xml -->
<item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
<item name="colorPrimaryDark">@*android:color/primary_dark_device_default_settings_light</item>
<item name="android:colorAccent">@*android:color/accent_device_default_light</item>
+ <item name="android:windowLightStatusBar">true</item>
</style>
</resources>
diff --git a/res/values/themes_suw.xml b/res/values/themes_suw.xml
new file mode 100644
index 0000000..11ef373
--- /dev/null
+++ b/res/values/themes_suw.xml
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<!-- SUW related themes -->
+<resources>
+ <style name="GlifTheme" parent="SuwThemeGlif">
+ <!-- For all Alert Dialogs -->
+ <item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
+ <item name="android:windowBackground">?android:attr/colorBackground</item>
+ <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+ <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
+ <item name="face_layout_theme">@style/FaceLayoutTheme</item>
+ <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
+ <item name="side_margin">0dip</item>
+ <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
+ <item name="wifi_signal">@drawable/wifi_signal</item>
+ <item name="wifi_friction">@drawable/wifi_friction</item>
+ <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
+ <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
+
+ <!-- LockPatternView colors -->
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
+ </style>
+
+ <style name="GlifTheme.Light" parent="SuwThemeGlif.Light">
+ <!-- For all Alert Dialogs -->
+ <item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
+ <item name="android:windowBackground">?android:attr/colorBackground</item>
+ <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+ <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
+ <item name="face_layout_theme">@style/FaceLayoutTheme</item>
+ <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
+ <item name="side_margin">0dip</item>
+ <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
+ <item name="wifi_signal">@drawable/wifi_signal</item>
+ <item name="wifi_friction">@drawable/wifi_friction</item>
+ <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
+ <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
+
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
+ <item name="*android:colorError">@color/glif_error_color</item>
+ </style>
+
+ <style name="GlifV2Theme" parent="SuwThemeGlifV2">
+ <!-- For all Alert Dialogs -->
+ <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
+ <item name="android:windowBackground">?android:attr/colorBackground</item>
+ <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+ <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
+ <item name="face_layout_theme">@style/FaceLayoutTheme</item>
+ <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
+ <item name="side_margin">0dip</item>
+ <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
+ <item name="wifi_signal">@drawable/wifi_signal</item>
+ <item name="wifi_friction">@drawable/wifi_friction</item>
+ <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
+ <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
+
+ <!-- LockPatternView colors -->
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
+ </style>
+
+ <style name="GlifV2Theme.Light" parent="SuwThemeGlifV2.Light">
+ <!-- For all Alert Dialogs -->
+ <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
+ <item name="android:windowBackground">?android:attr/colorBackground</item>
+ <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+ <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
+ <item name="face_layout_theme">@style/FaceLayoutTheme</item>
+ <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
+ <item name="side_margin">0dip</item>
+ <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
+ <item name="wifi_signal">@drawable/wifi_signal</item>
+ <item name="wifi_friction">@drawable/wifi_friction</item>
+ <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
+ <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
+
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
+ <item name="*android:colorError">@color/glif_error_color</item>
+ </style>
+
+ <style name="GlifV3Theme" parent="SuwThemeGlifV3">
+ <!-- For all Alert Dialogs -->
+ <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
+ <item name="android:windowBackground">?android:attr/colorBackground</item>
+ <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+ <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
+ <item name="face_layout_theme">@style/FaceLayoutTheme</item>
+ <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
+ <item name="side_margin">0dip</item>
+ <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
+ <item name="wifi_signal">@drawable/wifi_signal</item>
+ <item name="wifi_friction">@drawable/wifi_friction</item>
+ <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
+ <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
+
+ <!-- LockPatternView colors -->
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
+ </style>
+
+ <style name="GlifV3Theme.Light" parent="SuwThemeGlifV3.Light">
+ <!-- For all Alert Dialogs -->
+ <item name="android:alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
+ <item name="android:windowBackground">?android:attr/colorBackground</item>
+ <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
+ <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
+ <item name="face_layout_theme">@style/FaceLayoutTheme</item>
+ <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
+ <item name="side_margin">0dip</item>
+ <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
+ <item name="wifi_signal">@drawable/wifi_signal</item>
+ <item name="wifi_friction">@drawable/wifi_friction</item>
+ <item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
+ <item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
+
+ <item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
+ <item name="*android:colorError">@color/glif_error_color</item>
+ </style>
+
+ <style name="GlifV2Theme.Transparent">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowIsFloating">true</item>
+ <item name="android:windowAnimationStyle">@null</item>
+ </style>
+
+ <style name="GlifV2Theme.Light.Transparent">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowIsFloating">true</item>
+ <item name="android:windowAnimationStyle">@null</item>
+ </style>
+
+ <style name="GlifV2ThemeAlertDialog" parent="SuwAlertDialogTheme">
+ <item name="android:windowSoftInputMode">adjustResize</item>
+ </style>
+
+ <style name="GlifV2ThemeAlertDialog.Light" parent="SuwAlertDialogTheme.Light">
+ <item name="android:windowSoftInputMode">adjustResize</item>
+ </style>
+
+ <style name="GlifV3Theme.Transparent">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowIsFloating">true</item>
+ <item name="android:windowAnimationStyle">@null</item>
+ </style>
+
+ <style name="GlifV3Theme.Light.Transparent">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowIsFloating">true</item>
+ <item name="android:windowAnimationStyle">@null</item>
+ </style>
+
+ <style name="SetupWizardTheme.Transparent" parent="GlifTheme">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowIsFloating">true</item>
+ <item name="android:windowAnimationStyle">@null</item>
+ </style>
+
+ <style name="SetupWizardTheme.Light.Transparent" parent="GlifTheme.Light">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowNoTitle">true</item>
+ <item name="android:windowIsFloating">true</item>
+ <item name="android:windowAnimationStyle">@null</item>
+ </style>
+
+ <!-- Accessibility portion of Setup Wizard -->
+ <style name="SetupWizardAccessibilityTheme" parent="Theme.SettingsBase">
+ <item name="android:windowLightStatusBar">false</item>
+ <item name="android:colorPrimary">@color/material_grey_100</item>
+ <item name="android:colorAccent">@color/material_blue_700</item>
+ <item name="android:titleTextColor">@color/material_blue_700</item>
+ <item name="preferenceTheme">@style/PreferenceTheme</item>
+ <item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.Settings</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml
index 9d77e86..684d032 100644
--- a/res/xml/app_info_settings.xml
+++ b/res/xml/app_info_settings.xml
@@ -63,7 +63,7 @@
<Preference
android:key="data_settings"
- android:title="@string/data_usage_summary_title"
+ android:title="@string/data_usage_app_summary_title"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.applications.appinfo.AppDataUsagePreferenceController" />
diff --git a/res/xml/auto_brightness_detail.xml b/res/xml/auto_brightness_detail.xml
index 8b683f1..b10f1ad 100644
--- a/res/xml/auto_brightness_detail.xml
+++ b/res/xml/auto_brightness_detail.xml
@@ -23,8 +23,10 @@
<com.android.settings.widget.VideoPreference
android:key="auto_brightness_video"
+ android:title="@string/summary_placeholder"
settings:animation="@raw/aab_brightness"
- settings:preview="@drawable/aab_brightness"/>
+ settings:preview="@drawable/aab_brightness"
+ settings:controller="com.android.settings.widget.VideoPreferenceController"/>
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
<com.android.settingslib.RestrictedSwitchPreference
diff --git a/res/xml/power_abnormal_detail.xml b/res/xml/power_abnormal_detail.xml
deleted file mode 100644
index de918a9..0000000
--- a/res/xml/power_abnormal_detail.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/battery_abnormal_details_title">
-
- <PreferenceCategory
- android:key="app_abnormal_list"/>
-
-</PreferenceScreen>
diff --git a/res/xml/power_usage_detail.xml b/res/xml/power_usage_detail.xml
index 2be2a52..0493a51 100644
--- a/res/xml/power_usage_detail.xml
+++ b/res/xml/power_usage_detail.xml
@@ -43,11 +43,6 @@
</PreferenceCategory>
- <Preference
- android:key="high_usage"
- android:icon="@drawable/ic_battery_alert_24dp"
- android:title="@string/power_high_usage_title"/>
-
<PreferenceCategory
android:title="@string/battery_detail_info_title">
diff --git a/res/xml/smart_battery_detail.xml b/res/xml/smart_battery_detail.xml
index 8af3e96..abf5e43 100644
--- a/res/xml/smart_battery_detail.xml
+++ b/res/xml/smart_battery_detail.xml
@@ -23,8 +23,10 @@
<com.android.settings.widget.VideoPreference
android:key="auto_awesome_battery"
+ android:title="@string/summary_placeholder"
settings:animation="@raw/auto_awesome_battery"
- settings:preview="@drawable/auto_awesome_battery"/>
+ settings:preview="@drawable/auto_awesome_battery"
+ settings:controller="com.android.settings.widget.VideoPreferenceController"/>
<SwitchPreference
android:key="smart_battery"
diff --git a/res/xml/wifi_display_saved_access_points.xml b/res/xml/wifi_display_saved_access_points.xml
index 81fb701..98b4dec 100644
--- a/res/xml/wifi_display_saved_access_points.xml
+++ b/res/xml/wifi_display_saved_access_points.xml
@@ -14,7 +14,15 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/wifi_saved_access_points_titlebar">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="saved_access_points"
+ android:title="@string/wifi_saved_access_points_label">
+
+ <PreferenceCategory
+ android:key="saved_access_points_category"
+ android:layout="@layout/preference_category_no_label"
+ settings:controller="com.android.settings.wifi.savedaccesspoints.SavedAccessPointsPreferenceController"/>
</PreferenceScreen>
diff --git a/res/xml/wifi_settings.xml b/res/xml/wifi_settings.xml
index 52aadcf..4ca9284 100644
--- a/res/xml/wifi_settings.xml
+++ b/res/xml/wifi_settings.xml
@@ -39,6 +39,6 @@
<Preference
android:key="saved_networks"
android:title="@string/wifi_saved_access_points_label"
- android:fragment="com.android.settings.wifi.SavedAccessPointsWifiSettings" />
+ android:fragment="com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings" />
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/settings/AllowBindAppWidgetActivity.java b/src/com/android/settings/AllowBindAppWidgetActivity.java
index 52e7870..7557d97 100644
--- a/src/com/android/settings/AllowBindAppWidgetActivity.java
+++ b/src/com/android/settings/AllowBindAppWidgetActivity.java
@@ -16,7 +16,6 @@
package com.android.settings;
-import android.app.AlertDialog;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
@@ -33,6 +32,8 @@
import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;
+import androidx.appcompat.app.AlertDialog;
+
/**
* This activity is displayed when an app launches the BIND_APPWIDGET intent. This allows apps
* that don't have the BIND_APPWIDGET permission to bind specific widgets.
diff --git a/src/com/android/settings/BandMode.java b/src/com/android/settings/BandMode.java
index b130295..9728a5f 100644
--- a/src/com/android/settings/BandMode.java
+++ b/src/com/android/settings/BandMode.java
@@ -1,7 +1,6 @@
package com.android.settings;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.AsyncResult;
import android.os.Bundle;
@@ -18,6 +17,7 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
+import androidx.appcompat.app.AlertDialog;
/**
* Radio Band Mode Selection Class
diff --git a/src/com/android/settings/CredentialStorage.java b/src/com/android/settings/CredentialStorage.java
index 7b39e4f..03a9203 100644
--- a/src/com/android/settings/CredentialStorage.java
+++ b/src/com/android/settings/CredentialStorage.java
@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.DialogInterface;
@@ -49,6 +48,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import sun.security.util.ObjectIdentifier;
import sun.security.x509.AlgorithmId;
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index 9558d75..f710852 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -18,7 +18,6 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -42,6 +41,8 @@
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
+
public class EncryptionInterstitial extends SettingsActivity {
private static final String TAG = EncryptionInterstitial.class.getSimpleName();
diff --git a/src/com/android/settings/MonitoringCertInfoActivity.java b/src/com/android/settings/MonitoringCertInfoActivity.java
index aea2a37..d181f7a 100644
--- a/src/com/android/settings/MonitoringCertInfoActivity.java
+++ b/src/com/android/settings/MonitoringCertInfoActivity.java
@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -29,6 +28,8 @@
import com.android.settingslib.RestrictedLockUtils;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Activity that shows a dialog explaining that a CA cert is allowing someone to monitor network
* traffic. This activity should be launched for the user into which the CA cert is installed
diff --git a/src/com/android/settings/ProxySelector.java b/src/com/android/settings/ProxySelector.java
index 1c51a98..a681b94 100644
--- a/src/com/android/settings/ProxySelector.java
+++ b/src/com/android/settings/ProxySelector.java
@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -43,6 +42,8 @@
import com.android.settings.SettingsPreferenceFragment.SettingsDialogFragment;
import com.android.settings.core.InstrumentedFragment;
+import androidx.appcompat.app.AlertDialog;
+
public class ProxySelector extends InstrumentedFragment implements DialogCreatable {
private static final String TAG = "ProxySelector";
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index ee20c58..3db9935 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -20,7 +20,6 @@
import static android.provider.Settings.Global.PREFERRED_NETWORK_MODE;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.QueuedWork;
import android.content.ComponentName;
import android.content.Context;
@@ -91,6 +90,8 @@
import java.net.URL;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
+
public class RadioInfo extends Activity {
private static final String TAG = "RadioInfo";
diff --git a/src/com/android/settings/RegulatoryInfoDisplayActivity.java b/src/com/android/settings/RegulatoryInfoDisplayActivity.java
index 2b47c86..6430a13 100644
--- a/src/com/android/settings/RegulatoryInfoDisplayActivity.java
+++ b/src/com/android/settings/RegulatoryInfoDisplayActivity.java
@@ -17,7 +17,6 @@
package com.android.settings;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -34,6 +33,7 @@
import java.util.Locale;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* {@link Activity} that displays regulatory information for the "Regulatory information"
diff --git a/src/com/android/settings/RemoteBugreportActivity.java b/src/com/android/settings/RemoteBugreportActivity.java
index 7069175..2c88ec3 100644
--- a/src/com/android/settings/RemoteBugreportActivity.java
+++ b/src/com/android/settings/RemoteBugreportActivity.java
@@ -17,7 +17,6 @@
import android.annotation.Nullable;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
import android.content.Intent;
@@ -25,6 +24,8 @@
import android.os.UserHandle;
import android.util.Log;
+import androidx.appcompat.app.AlertDialog;
+
/**
* UI for the remote bugreport dialog. Shows one of 3 possible dialogs:
* <ul>
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index 1ecc8d7..88a7049 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -18,7 +18,6 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.content.ContentResolver;
@@ -50,6 +49,7 @@
import com.android.settingslib.RestrictedLockUtils;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* Confirm and execute a reset of the network settings to a clean "just out of the box"
@@ -150,7 +150,8 @@
}
}
- ImsManager.factoryReset(context);
+ ImsManager.getInstance(context,
+ SubscriptionManager.getPhoneId(mSubId)).factoryReset();
restoreDefaultApn(context);
esimFactoryReset(context, context.getPackageName());
// There has been issues when Sms raw table somehow stores orphan
diff --git a/src/com/android/settings/RestrictedListPreference.java b/src/com/android/settings/RestrictedListPreference.java
index a5d241c..e79f03e 100644
--- a/src/com/android/settings/RestrictedListPreference.java
+++ b/src/com/android/settings/RestrictedListPreference.java
@@ -18,7 +18,6 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import android.app.AlertDialog;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
@@ -41,6 +40,7 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AlertDialog.Builder;
import androidx.preference.ListPreferenceDialogFragmentCompat;
import androidx.preference.PreferenceViewHolder;
diff --git a/src/com/android/settings/RestrictedSettingsFragment.java b/src/com/android/settings/RestrictedSettingsFragment.java
index 3bf9f85..2894366 100644
--- a/src/com/android/settings/RestrictedSettingsFragment.java
+++ b/src/com/android/settings/RestrictedSettingsFragment.java
@@ -19,7 +19,6 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,6 +36,7 @@
import com.android.settingslib.RestrictedLockUtils;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* Base class for settings screens that should be pin protected when in restricted mode or
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index cafe5cf..cacd04e 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -46,6 +46,7 @@
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.backup.BackupSettingsActivity;
+import com.android.settings.core.OnActivityResultListener;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.gateway.SettingsGateway;
@@ -64,6 +65,7 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -375,6 +377,19 @@
}
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ final List<Fragment> fragments = getSupportFragmentManager().getFragments();
+ if (fragments != null) {
+ for (Fragment fragment : fragments) {
+ if (fragment instanceof OnActivityResultListener) {
+ fragment.onActivityResult(requestCode, resultCode, data);
+ }
+ }
+ }
+ }
+
@VisibleForTesting
void launchSettingFragment(String initialFragmentName, boolean isSubSettings, Intent intent) {
if (!mIsShowingDashboard && initialFragmentName != null) {
diff --git a/src/com/android/settings/TrustedCredentialsDialogBuilder.java b/src/com/android/settings/TrustedCredentialsDialogBuilder.java
index 03414bd..76bf861 100644
--- a/src/com/android/settings/TrustedCredentialsDialogBuilder.java
+++ b/src/com/android/settings/TrustedCredentialsDialogBuilder.java
@@ -17,7 +17,6 @@
import android.annotation.NonNull;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
import android.content.pm.UserInfo;
@@ -41,6 +40,8 @@
import java.util.List;
import java.util.function.IntConsumer;
+import androidx.appcompat.app.AlertDialog;
+
class TrustedCredentialsDialogBuilder extends AlertDialog.Builder {
public interface DelegateInterface {
List<X509Certificate> getX509CertsFromCertHolder(CertHolder certHolder);
diff --git a/src/com/android/settings/UserCredentialsSettings.java b/src/com/android/settings/UserCredentialsSettings.java
index 20defb3..06d0be6 100644
--- a/src/com/android/settings/UserCredentialsSettings.java
+++ b/src/com/android/settings/UserCredentialsSettings.java
@@ -18,7 +18,6 @@
import android.annotation.LayoutRes;
import android.annotation.Nullable;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -57,6 +56,7 @@
import java.util.SortedMap;
import java.util.TreeMap;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 55ec159..9d5f96f 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -389,9 +389,7 @@
*/
public static UserHandle getManagedProfile(UserManager userManager) {
List<UserHandle> userProfiles = userManager.getUserProfiles();
- final int count = userProfiles.size();
- for (int i = 0; i < count; i++) {
- final UserHandle profile = userProfiles.get(i);
+ for (UserHandle profile : userProfiles) {
if (profile.getIdentifier() == userManager.getUserHandle()) {
continue;
}
diff --git a/src/com/android/settings/accessibility/AccessibilityServiceWarning.java b/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
index 4890011..95e1643 100644
--- a/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
+++ b/src/com/android/settings/accessibility/AccessibilityServiceWarning.java
@@ -20,7 +20,6 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -41,6 +40,8 @@
import java.util.List;
import java.util.Locale;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Utility class for creating the dialog that asks users for explicit permission to grant
* all of the requested capabilities to an accessibility service before the service is enabled
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index b910130..22cff3e 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -633,8 +633,14 @@
mCategoryToPrefCategoryMap.get(CATEGORY_DISPLAY);
experimentalCategory.removePreference(mToggleInversionPreference);
experimentalCategory.removePreference(mDisplayDaltonizerPreferenceScreen);
- mToggleInversionPreference.setOrder(mToggleLargePointerIconPreference.getOrder());
- mDisplayDaltonizerPreferenceScreen.setOrder(mToggleInversionPreference.getOrder());
+ mDisplayDaltonizerPreferenceScreen.setOrder(
+ mDisplayMagnificationPreferenceScreen.getOrder() + 1);
+ mToggleInversionPreference.setOrder(
+ mDisplayDaltonizerPreferenceScreen.getOrder() + 1);
+ mToggleLargePointerIconPreference.setOrder(
+ mToggleInversionPreference.getOrder() + 1);
+ mToggleDisableAnimationsPreference.setOrder(
+ mToggleLargePointerIconPreference.getOrder() + 1);
mToggleInversionPreference.setSummary(R.string.summary_empty);
displayCategory.addPreference(mToggleInversionPreference);
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index b345e05..6738736 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -18,7 +18,6 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -46,6 +45,8 @@
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
+
public class ToggleAccessibilityServicePreferenceFragment
extends ToggleFeaturePreferenceFragment implements DialogInterface.OnClickListener {
diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java
index f90c3c6..58624cd 100644
--- a/src/com/android/settings/accounts/AccountSyncSettings.java
+++ b/src/com/android/settings/accounts/AccountSyncSettings.java
@@ -19,7 +19,6 @@
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
@@ -53,6 +52,7 @@
import java.util.Date;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
public class AccountSyncSettings extends AccountPreferenceBase {
diff --git a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
index 8df485c..3520116 100644
--- a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
+++ b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
@@ -22,7 +22,6 @@
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -45,6 +44,7 @@
import java.io.IOException;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceScreen;
diff --git a/src/com/android/settings/applications/AppInfoBase.java b/src/com/android/settings/applications/AppInfoBase.java
index 4ee2fd8..0acb046 100644
--- a/src/com/android/settings/applications/AppInfoBase.java
+++ b/src/com/android/settings/applications/AppInfoBase.java
@@ -19,7 +19,6 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
@@ -51,6 +50,7 @@
import java.util.ArrayList;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
diff --git a/src/com/android/settings/applications/AppLaunchSettings.java b/src/com/android/settings/applications/AppLaunchSettings.java
index 6b527a7..82ac1b0 100644
--- a/src/com/android/settings/applications/AppLaunchSettings.java
+++ b/src/com/android/settings/applications/AppLaunchSettings.java
@@ -21,7 +21,6 @@
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
-import android.app.AlertDialog;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
@@ -42,6 +41,7 @@
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.DropDownPreference;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index 897cbc7..ed5397a 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -22,7 +22,6 @@
import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.GrantedUriPermission;
import android.content.ContentResolver;
@@ -64,6 +63,7 @@
import java.util.TreeMap;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
import androidx.preference.Preference;
diff --git a/src/com/android/settings/applications/DirectoryAccessDetails.java b/src/com/android/settings/applications/DirectoryAccessDetails.java
index 02c33c0..8325f0d 100644
--- a/src/com/android/settings/applications/DirectoryAccessDetails.java
+++ b/src/com/android/settings/applications/DirectoryAccessDetails.java
@@ -34,7 +34,6 @@
import android.annotation.Nullable;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@@ -60,6 +59,7 @@
import java.util.Map;
import java.util.Set;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
diff --git a/src/com/android/settings/applications/ProcessStatsDetail.java b/src/com/android/settings/applications/ProcessStatsDetail.java
index 3331b1c..e57808f 100644
--- a/src/com/android/settings/applications/ProcessStatsDetail.java
+++ b/src/com/android/settings/applications/ProcessStatsDetail.java
@@ -21,7 +21,6 @@
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
-import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
@@ -59,6 +58,7 @@
import java.util.HashMap;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
diff --git a/src/com/android/settings/applications/RunningServiceDetails.java b/src/com/android/settings/applications/RunningServiceDetails.java
index 0461343..66fdb08 100644
--- a/src/com/android/settings/applications/RunningServiceDetails.java
+++ b/src/com/android/settings/applications/RunningServiceDetails.java
@@ -2,7 +2,6 @@
import android.app.Activity;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.ApplicationErrorReport;
import android.app.Dialog;
import android.app.PendingIntent;
@@ -44,6 +43,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
public class RunningServiceDetails extends InstrumentedFragment
diff --git a/src/com/android/settings/applications/UsageAccessDetails.java b/src/com/android/settings/applications/UsageAccessDetails.java
index 8c76e71..c14ddbc 100644
--- a/src/com/android/settings/applications/UsageAccessDetails.java
+++ b/src/com/android/settings/applications/UsageAccessDetails.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.applications;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -32,6 +31,7 @@
import com.android.settings.overlay.FeatureFactory;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;
diff --git a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
index 32fcef5..4dab72b 100644
--- a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java
@@ -99,13 +99,11 @@
(UserManager) mContext.getSystemService(Context.USER_SERVICE);
final BatteryEntry entry = new BatteryEntry(mContext, null, userManager, mSipper);
entry.defaultPackageName = mPackageName;
- AdvancedPowerUsageDetail.startBatteryDetailPage(
- (SettingsActivity) mParent.getActivity(), mParent, mBatteryHelper,
- BatteryStats.STATS_SINCE_CHARGED, entry, mBatteryPercent,
- null /* mAnomalies */);
+ AdvancedPowerUsageDetail.startBatteryDetailPage(mParent.getActivity(), mParent,
+ mBatteryHelper, BatteryStats.STATS_SINCE_CHARGED, entry, mBatteryPercent);
} else {
- AdvancedPowerUsageDetail.startBatteryDetailPage(
- (SettingsActivity) mParent.getActivity(), mParent, mPackageName);
+ AdvancedPowerUsageDetail.startBatteryDetailPage(mParent.getActivity(), mParent,
+ mPackageName);
}
return true;
}
diff --git a/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java b/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java
index f6e0472..eeeb205 100644
--- a/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java
+++ b/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.applications.appinfo;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -30,6 +29,7 @@
import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* Fragment to show the dialog for uninstall or forcestop. This fragment uses function in
diff --git a/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java b/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
index 94111cf..8c572af 100644
--- a/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
+++ b/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
@@ -17,7 +17,6 @@
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
@@ -38,6 +37,7 @@
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;
diff --git a/src/com/android/settings/applications/appinfo/ExternalSourcesDetails.java b/src/com/android/settings/applications/appinfo/ExternalSourcesDetails.java
index dc9ab7e..224072c 100644
--- a/src/com/android/settings/applications/appinfo/ExternalSourcesDetails.java
+++ b/src/com/android/settings/applications/appinfo/ExternalSourcesDetails.java
@@ -18,7 +18,6 @@
import static android.app.Activity.RESULT_CANCELED;
import static android.app.Activity.RESULT_OK;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.os.Bundle;
@@ -34,6 +33,7 @@
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
diff --git a/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragment.java b/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragment.java
index 2e668ef..683a764 100644
--- a/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragment.java
+++ b/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragment.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.applications.appinfo;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -28,6 +27,8 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.overlay.FeatureFactory;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Fragment to show the dialog for clearing the instant app.
*/
diff --git a/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java b/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java
index 7f9f359..aed263f 100644
--- a/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java
+++ b/src/com/android/settings/applications/appinfo/WriteSettingsDetails.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.applications.appinfo;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
@@ -33,6 +32,7 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;
diff --git a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
index d0493e9..395ea64 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.applications.defaultapps;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -28,11 +27,13 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settings.widget.RadioButtonPreference;
import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.widget.CandidateInfo;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -43,11 +44,13 @@
public abstract class DefaultAppPickerFragment extends RadioButtonPickerFragment {
protected PackageManager mPm;
+ protected BatteryUtils mBatteryUtils;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mPm = context.getPackageManager();
+ mBatteryUtils = BatteryUtils.getInstance(context);
}
@Override
diff --git a/src/com/android/settings/applications/defaultapps/DefaultPhonePicker.java b/src/com/android/settings/applications/defaultapps/DefaultPhonePicker.java
index e462ab8..0bda2ec 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultPhonePicker.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultPhonePicker.java
@@ -80,6 +80,7 @@
@Override
protected boolean setDefaultKey(String key) {
if (!TextUtils.isEmpty(key) && !TextUtils.equals(key, getDefaultKey())) {
+ mBatteryUtils.clearForceAppStandby(key);
return mDefaultKeyUpdater.setDefaultDialerApplication(getContext(), key, mUserId);
}
return false;
diff --git a/src/com/android/settings/applications/defaultapps/DefaultSmsPicker.java b/src/com/android/settings/applications/defaultapps/DefaultSmsPicker.java
index 91f9caf..b5a2880 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultSmsPicker.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultSmsPicker.java
@@ -16,6 +16,7 @@
package com.android.settings.applications.defaultapps;
+import android.app.AppOpsManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -25,6 +26,7 @@
import com.android.internal.telephony.SmsApplication;
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.widget.CandidateInfo;
@@ -74,6 +76,7 @@
protected boolean setDefaultKey(String key) {
if (!TextUtils.isEmpty(key) && !TextUtils.equals(key, getDefaultKey())) {
mDefaultKeyUpdater.setDefaultApplication(getContext(), key);
+ mBatteryUtils.clearForceAppStandby(key);
return true;
}
return false;
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index de4558e..a64f461 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -54,6 +54,7 @@
import android.preference.PreferenceFrameLayout;
import android.text.TextUtils;
import android.util.ArraySet;
+import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -862,6 +863,7 @@
private final Context mContext;
private final AppStateBaseBridge mExtraInfoBridge;
private final LoadingViewController mLoadingViewController;
+ private final IconDrawableFactory mIconDrawableFactory;
private AppFilterItem mAppFilter;
private ArrayList<ApplicationsState.AppEntry> mEntries;
@@ -894,6 +896,7 @@
mManageApplications.mListContainer
);
mContext = manageApplications.getActivity();
+ mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
mAppFilter = appFilter;
if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
mExtraInfoBridge = new AppStateNotificationBridge(mContext, mState, this,
@@ -1318,8 +1321,7 @@
ApplicationsState.AppEntry entry = mEntries.get(position);
synchronized (entry) {
holder.setTitle(entry.label);
- mState.ensureIcon(entry);
- holder.setIcon(entry.icon);
+ holder.setIcon(mIconDrawableFactory.getBadgedIcon(entry.info));
updateSummary(holder, entry);
updateSwitch(holder, entry);
holder.updateDisableView(entry.info);
diff --git a/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java b/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
index 686e027..4e38f4e 100644
--- a/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
+++ b/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
@@ -19,7 +19,6 @@
import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.INotificationManager;
import android.content.Context;
@@ -39,6 +38,8 @@
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
+
public class ResetAppsHelper implements DialogInterface.OnClickListener,
DialogInterface.OnDismissListener {
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index 6e0f915..c7e93b8 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -18,7 +18,6 @@
import android.app.Activity;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.app.admin.DeviceAdminInfo;
@@ -74,6 +73,8 @@
import java.util.List;
import java.util.Optional;
+import androidx.appcompat.app.AlertDialog;
+
public class DeviceAdminAdd extends Activity {
static final String TAG = "DeviceAdminAdd";
@@ -455,10 +456,7 @@
void unrestrictAppIfPossible(BatteryUtils batteryUtils) {
// Unrestrict admin app if it is already been restricted
final String packageName = mDeviceAdmin.getComponent().getPackageName();
- final int uid = batteryUtils.getPackageUid(packageName);
- if (batteryUtils.isForceAppStandbyEnabled(uid, packageName)) {
- batteryUtils.setForceAppStandby(uid, packageName, AppOpsManager.MODE_ALLOWED);
- }
+ batteryUtils.clearForceAppStandby(packageName);
}
void continueRemoveAction(CharSequence msg) {
diff --git a/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureDetails.java b/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureDetails.java
index 6af4f81..79606ee 100644
--- a/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureDetails.java
+++ b/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureDetails.java
@@ -19,7 +19,6 @@
import static android.app.AppOpsManager.MODE_ERRORED;
import static android.app.AppOpsManager.OP_PICTURE_IN_PICTURE;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.os.Bundle;
@@ -30,6 +29,7 @@
import com.android.settings.overlay.FeatureFactory;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.SwitchPreference;
diff --git a/src/com/android/settings/backup/ToggleBackupSettingFragment.java b/src/com/android/settings/backup/ToggleBackupSettingFragment.java
index 0d1c33e..fb24542 100644
--- a/src/com/android/settings/backup/ToggleBackupSettingFragment.java
+++ b/src/com/android/settings/backup/ToggleBackupSettingFragment.java
@@ -1,6 +1,5 @@
package com.android.settings.backup;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.backup.IBackupManager;
import android.content.Context;
@@ -20,6 +19,7 @@
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.ToggleSwitch;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceViewHolder;
diff --git a/src/com/android/settings/biometrics/BiometricErrorDialog.java b/src/com/android/settings/biometrics/BiometricErrorDialog.java
index 4e073f1..5c4e891 100644
--- a/src/com/android/settings/biometrics/BiometricErrorDialog.java
+++ b/src/com/android/settings/biometrics/BiometricErrorDialog.java
@@ -20,7 +20,6 @@
import static com.android.settings.biometrics.BiometricSettings.RESULT_TIMEOUT;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.hardware.biometrics.BiometricConstants;
@@ -28,6 +27,8 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Abstract dialog, shown when an error occurs during biometric enrollment.
*/
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 56d96ce..38ef2c1 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -18,7 +18,6 @@
import android.animation.Animator;
import android.animation.ObjectAnimator;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -47,6 +46,8 @@
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Activity which handles the actual enrolling for fingerprint.
*/
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 76ee78b..d318fef 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -18,7 +18,6 @@
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -57,6 +56,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceGroup;
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
index 4529277..febffa6 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
@@ -17,7 +17,6 @@
package com.android.settings.biometrics.fingerprint;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -32,6 +31,7 @@
import com.android.settings.password.ChooseLockSettingsHelper;
import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 8590392..eb1cd52 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -18,7 +18,6 @@
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
-import android.app.AlertDialog;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.DialogInterface;
@@ -39,6 +38,7 @@
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
diff --git a/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
index 0eb9746..6f737e0 100644
--- a/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.bluetooth;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -38,6 +37,8 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Dialog fragment for renaming a Bluetooth device.
*/
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
index 580a26f..e5d2aa7 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.bluetooth;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -40,6 +39,7 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* A dialogFragment used by {@link BluetoothPairingDialog} to create an appropriately styled dialog
diff --git a/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java b/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java
index 32edb23..e660691 100644
--- a/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java
+++ b/src/com/android/settings/bluetooth/ForgetDeviceDialogFragment.java
@@ -17,7 +17,6 @@
package com.android.settings.bluetooth;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
@@ -31,6 +30,7 @@
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/** Implements an AlertDialog for confirming that a user wishes to unpair or "forget" a paired
* device*/
diff --git a/src/com/android/settings/bluetooth/RequestPermissionActivity.java b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
index 0c9ab37..5f6fc39 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
@@ -18,7 +18,6 @@
import android.annotation.NonNull;
import android.app.Activity;
-import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
@@ -38,6 +37,8 @@
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import androidx.appcompat.app.AlertDialog;
+
/**
* RequestPermissionActivity asks the user whether to enable discovery. This is
* usually started by an application wanted to start bluetooth and or discovery
@@ -49,7 +50,7 @@
// adb shell am start -a android.bluetooth.adapter.action.REQUEST_DISCOVERABLE
// adb shell am start -a android.bluetooth.adapter.action.REQUEST_DISABLE
- private static final String TAG = "RequestPermissionActivity";
+ private static final String TAG = "BtRequestPermission";
private static final int MAX_DISCOVERABLE_TIMEOUT = 3600; // 1 hr
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index 96f5da5..567aa93 100755
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -16,7 +16,6 @@
package com.android.settings.bluetooth;
-import android.app.AlertDialog;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
@@ -34,6 +33,7 @@
import com.android.settingslib.bluetooth.LocalBluetoothManager.BluetoothManagerCallback;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* Utils is a helper class that contains constants for various
diff --git a/src/com/android/settings/core/OnActivityResultListener.java b/src/com/android/settings/core/OnActivityResultListener.java
new file mode 100644
index 0000000..5832c7f
--- /dev/null
+++ b/src/com/android/settings/core/OnActivityResultListener.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.core;
+
+import android.app.Activity;
+import android.content.Intent;
+
+/**
+ * This interface marks a class that it wants to listen to
+ * {@link Activity#onActivityResult(int, int, Intent)}.
+ *
+ * Whenever {@link com.android.settings.SettingsActivity} receives an activity result, it will
+ * propagate the data to this interface so it has a chance to inspect and handle activity results.
+ */
+public interface OnActivityResultListener {
+}
diff --git a/src/com/android/settings/core/SettingsBaseActivity.java b/src/com/android/settings/core/SettingsBaseActivity.java
index 2cce467..9672694 100644
--- a/src/com/android/settings/core/SettingsBaseActivity.java
+++ b/src/com/android/settings/core/SettingsBaseActivity.java
@@ -35,15 +35,14 @@
import android.view.WindowManager.LayoutParams;
import android.widget.Toolbar;
+import androidx.fragment.app.FragmentActivity;
+
import com.android.settings.R;
import com.android.settingslib.drawer.CategoryManager;
-import com.android.settingslib.drawer.TileUtils;
import java.util.ArrayList;
import java.util.List;
-import androidx.fragment.app.FragmentActivity;
-
public class SettingsBaseActivity extends FragmentActivity {
protected static final boolean DEBUG_TIMING = false;
@@ -174,7 +173,7 @@
}
public String getSettingPkg() {
- return TileUtils.SETTING_PKG;
+ return CategoryManager.SETTING_PKG;
}
public interface CategoryListener {
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 1569ff0..219c92c 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -38,7 +38,6 @@
import com.android.settings.applications.ProcessStatsSummary;
import com.android.settings.applications.ProcessStatsUi;
import com.android.settings.applications.UsageAccessDetails;
-import com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings;
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
import com.android.settings.applications.appinfo.DrawOverlayDetails;
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
@@ -50,6 +49,7 @@
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminSettings;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureSettings;
+import com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings;
import com.android.settings.backup.PrivacySettings;
import com.android.settings.backup.ToggleBackupSettingFragment;
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
@@ -127,12 +127,12 @@
import com.android.settings.webview.WebViewAppPicker;
import com.android.settings.wfd.WifiDisplaySettings;
import com.android.settings.wifi.ConfigureWifiSettings;
-import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiAPITest;
import com.android.settings.wifi.WifiInfo;
import com.android.settings.wifi.WifiSettings;
import com.android.settings.wifi.calling.WifiCallingSettings;
import com.android.settings.wifi.p2p.WifiP2pSettings;
+import com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.tether.WifiTetherSettings;
public class SettingsGateway {
diff --git a/src/com/android/settings/dashboard/DashboardData.java b/src/com/android/settings/dashboard/DashboardData.java
index 9f66731..182d79b 100644
--- a/src/com/android/settings/dashboard/DashboardData.java
+++ b/src/com/android/settings/dashboard/DashboardData.java
@@ -20,6 +20,9 @@
import android.service.settings.suggestions.Suggestion;
import android.text.TextUtils;
+import androidx.annotation.VisibleForTesting;
+import androidx.recyclerview.widget.DiffUtil;
+
import com.android.settings.R;
import com.android.settings.dashboard.conditional.Condition;
import com.android.settingslib.drawer.DashboardCategory;
@@ -31,9 +34,6 @@
import java.util.List;
import java.util.Objects;
-import androidx.annotation.VisibleForTesting;
-import androidx.recyclerview.widget.DiffUtil;
-
/**
* Description about data list used in the DashboardAdapter. In the data list each item can be
* Condition, suggestion or category tile.
@@ -411,16 +411,7 @@
&& TextUtils.equals(localTile.summary, targetTile.summary);
case TYPE_SUGGESTION_CONTAINER:
case TYPE_CONDITION_CONTAINER:
- // If entity is suggestion and contains remote view, force refresh
- final List entities = (List) entity;
- if (!entities.isEmpty()) {
- Object firstEntity = entities.get(0);
- if (firstEntity instanceof Tile
- && ((Tile) firstEntity).remoteViews != null) {
- return false;
- }
- }
- // Otherwise Fall through to default
+ // Fall through to default
default:
return entity == null ? targetItem.entity == null
: entity.equals(targetItem.entity);
diff --git a/src/com/android/settings/dashboard/RestrictedDashboardFragment.java b/src/com/android/settings/dashboard/RestrictedDashboardFragment.java
index 8258678..927385b 100644
--- a/src/com/android/settings/dashboard/RestrictedDashboardFragment.java
+++ b/src/com/android/settings/dashboard/RestrictedDashboardFragment.java
@@ -19,7 +19,6 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -37,6 +36,8 @@
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settingslib.RestrictedLockUtils;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Base class for settings screens that should be pin protected when in restricted mode or
* that will display an admin support message in case an admin has disabled the options.
diff --git a/src/com/android/settings/datausage/BillingCycleSettings.java b/src/com/android/settings/datausage/BillingCycleSettings.java
index 2e89e59..1d1ec6d 100644
--- a/src/com/android/settings/datausage/BillingCycleSettings.java
+++ b/src/com/android/settings/datausage/BillingCycleSettings.java
@@ -17,7 +17,6 @@
import static android.net.NetworkPolicy.LIMIT_DISABLED;
import static android.net.NetworkPolicy.WARNING_DISABLED;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -47,6 +46,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
diff --git a/src/com/android/settings/deletionhelper/ActivationWarningFragment.java b/src/com/android/settings/deletionhelper/ActivationWarningFragment.java
index 1618e2a..9bfe032 100644
--- a/src/com/android/settings/deletionhelper/ActivationWarningFragment.java
+++ b/src/com/android/settings/deletionhelper/ActivationWarningFragment.java
@@ -16,12 +16,12 @@
package com.android.settings.deletionhelper;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import com.android.settings.R;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
/**
diff --git a/src/com/android/settings/development/BluetoothA2dpHwOffloadRebootDialog.java b/src/com/android/settings/development/BluetoothA2dpHwOffloadRebootDialog.java
index 03e1143..ba05910 100644
--- a/src/com/android/settings/development/BluetoothA2dpHwOffloadRebootDialog.java
+++ b/src/com/android/settings/development/BluetoothA2dpHwOffloadRebootDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.development;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -26,6 +25,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class BluetoothA2dpHwOffloadRebootDialog extends InstrumentedDialogFragment
diff --git a/src/com/android/settings/development/ClearAdbKeysWarningDialog.java b/src/com/android/settings/development/ClearAdbKeysWarningDialog.java
index e930759..3d81f1a 100644
--- a/src/com/android/settings/development/ClearAdbKeysWarningDialog.java
+++ b/src/com/android/settings/development/ClearAdbKeysWarningDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.development;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/development/DisableLogPersistWarningDialog.java b/src/com/android/settings/development/DisableLogPersistWarningDialog.java
index fbe2b05..b25e5ff 100644
--- a/src/com/android/settings/development/DisableLogPersistWarningDialog.java
+++ b/src/com/android/settings/development/DisableLogPersistWarningDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.development;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/development/EnableAdbWarningDialog.java b/src/com/android/settings/development/EnableAdbWarningDialog.java
index e1354ce..e191f30 100644
--- a/src/com/android/settings/development/EnableAdbWarningDialog.java
+++ b/src/com/android/settings/development/EnableAdbWarningDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.development;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/development/EnableDevelopmentSettingWarningDialog.java b/src/com/android/settings/development/EnableDevelopmentSettingWarningDialog.java
index 51532f3..ebc195e 100644
--- a/src/com/android/settings/development/EnableDevelopmentSettingWarningDialog.java
+++ b/src/com/android/settings/development/EnableDevelopmentSettingWarningDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.development;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class EnableDevelopmentSettingWarningDialog extends InstrumentedDialogFragment
diff --git a/src/com/android/settings/development/EnableOemUnlockSettingWarningDialog.java b/src/com/android/settings/development/EnableOemUnlockSettingWarningDialog.java
index 09d2ffe..cf077ca 100644
--- a/src/com/android/settings/development/EnableOemUnlockSettingWarningDialog.java
+++ b/src/com/android/settings/development/EnableOemUnlockSettingWarningDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.development;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/development/OemLockInfoDialog.java b/src/com/android/settings/development/OemLockInfoDialog.java
index 74babf2..f197c6a 100644
--- a/src/com/android/settings/development/OemLockInfoDialog.java
+++ b/src/com/android/settings/development/OemLockInfoDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.development;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
@@ -24,6 +23,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java b/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java
index 51964a9..3057fa0 100644
--- a/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java
+++ b/src/com/android/settings/deviceinfo/HardwareInfoDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;
@@ -31,6 +30,7 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
public class HardwareInfoDialogFragment extends InstrumentedDialogFragment {
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeForget.java b/src/com/android/settings/deviceinfo/PrivateVolumeForget.java
index 8c7fa09..ebd976b 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeForget.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeForget.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -38,6 +37,7 @@
import com.android.settings.search.actionbar.SearchMenuController;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class PrivateVolumeForget extends InstrumentedFragment {
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index 8d6714d..997f0d2 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -65,6 +64,7 @@
import java.util.List;
import java.util.Objects;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index 90da85c..f4ea580 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -18,7 +18,6 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -61,6 +60,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
index 85e5929..e09e89d 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
@@ -20,7 +20,6 @@
import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_FORGET_UUID;
import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_PRIVATE;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
@@ -33,6 +32,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
public class StorageWizardFormatConfirm extends InstrumentedDialogFragment {
diff --git a/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java b/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java
index 45f39d9..0224040 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/DeviceNameWarningDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.aboutphone;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
/**
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDialogFragment.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDialogFragment.java
index 17a9692..9c6075e 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDialogFragment.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.firmwareversion;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -27,6 +26,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogFragment.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogFragment.java
index 01fb04a..808edd4 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogFragment.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.imei;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.text.TextUtils;
@@ -30,6 +29,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java
index ef51185..2dd3785 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo.simstatus;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.text.TextUtils;
@@ -28,6 +27,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
index 6de3a92..6a4ca92 100644
--- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
+++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
@@ -17,7 +17,6 @@
package com.android.settings.enterprise;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
@@ -43,6 +42,7 @@
import java.util.Objects;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* Helper class for {@link ActionDisabledByAdminDialog} which sets up the dialog.
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index c71468b..2c48c3d 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -42,11 +42,6 @@
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment;
-import com.android.settings.fuelgauge.anomaly.AnomalyLoader;
-import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
-import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.widget.EntityHeaderController;
@@ -71,8 +66,6 @@
*/
public class AdvancedPowerUsageDetail extends DashboardFragment implements
ButtonActionDialogFragment.AppButtonsDialogListener,
- AnomalyDialogFragment.AnomalyDialogListener,
- LoaderManager.LoaderCallbacks<List<Anomaly>>,
BatteryTipPreferenceController.BatteryTipListener {
public static final String TAG = "AdvancedPowerDetail";
@@ -84,7 +77,6 @@
public static final String EXTRA_ICON_ID = "extra_icon_id";
public static final String EXTRA_POWER_USAGE_PERCENT = "extra_power_usage_percent";
public static final String EXTRA_POWER_USAGE_AMOUNT = "extra_power_usage_amount";
- public static final String EXTRA_ANOMALY_LIST = "extra_anomaly_list";
private static final String KEY_PREF_FOREGROUND = "app_usage_foreground";
private static final String KEY_PREF_BACKGROUND = "app_usage_background";
@@ -93,8 +85,6 @@
private static final int REQUEST_UNINSTALL = 0;
private static final int REQUEST_REMOVE_DEVICE_ADMIN = 1;
- private static final int ANOMALY_LOADER = 0;
-
@VisibleForTesting
LayoutPreference mHeaderPreference;
@VisibleForTesting
@@ -108,18 +98,15 @@
Preference mForegroundPreference;
@VisibleForTesting
Preference mBackgroundPreference;
- @VisibleForTesting
- AnomalySummaryPreferenceController mAnomalySummaryPreferenceController;
private AppButtonsPreferenceController mAppButtonsPreferenceController;
private BackgroundActivityPreferenceController mBackgroundActivityPreferenceController;
- private List<Anomaly> mAnomalies;
private String mPackageName;
@VisibleForTesting
static void startBatteryDetailPage(Activity caller, BatteryUtils batteryUtils,
InstrumentedPreferenceFragment fragment, BatteryStatsHelper helper, int which,
- BatteryEntry entry, String usagePercent, List<Anomaly> anomalies) {
+ BatteryEntry entry, String usagePercent) {
// Initialize mStats if necessary.
helper.getStats();
@@ -150,7 +137,6 @@
args.putLong(EXTRA_FOREGROUND_TIME, foregroundTimeMs);
args.putString(EXTRA_POWER_USAGE_PERCENT, usagePercent);
args.putInt(EXTRA_POWER_USAGE_AMOUNT, (int) sipper.totalPowerMah);
- args.putParcelableList(EXTRA_ANOMALY_LIST, anomalies);
new SubSettingLauncher(caller)
.setDestination(AdvancedPowerUsageDetail.class.getName())
@@ -171,9 +157,9 @@
public static void startBatteryDetailPage(Activity caller,
InstrumentedPreferenceFragment fragment, BatteryStatsHelper helper, int which,
- BatteryEntry entry, String usagePercent, List<Anomaly> anomalies) {
+ BatteryEntry entry, String usagePercent) {
startBatteryDetailPage(caller, BatteryUtils.getInstance(caller), fragment, helper, which,
- entry, usagePercent, anomalies);
+ entry, usagePercent);
}
public static void startBatteryDetailPage(Activity caller,
@@ -209,15 +195,12 @@
super.onCreate(icicle);
mPackageName = getArguments().getString(EXTRA_PACKAGE_NAME);
- mAnomalySummaryPreferenceController = new AnomalySummaryPreferenceController(
- (SettingsActivity) getActivity(), this);
mForegroundPreference = findPreference(KEY_PREF_FOREGROUND);
mBackgroundPreference = findPreference(KEY_PREF_BACKGROUND);
mHeaderPreference = (LayoutPreference) findPreference(KEY_PREF_HEADER);
if (mPackageName != null) {
mAppEntry = mState.getEntry(mPackageName, UserHandle.myUserId());
- initAnomalyInfo();
}
}
@@ -230,16 +213,6 @@
}
@VisibleForTesting
- void initAnomalyInfo() {
- mAnomalies = getArguments().getParcelableArrayList(EXTRA_ANOMALY_LIST);
- if (mAnomalies == null) {
- getLoaderManager().initLoader(ANOMALY_LOADER, Bundle.EMPTY, this);
- } else if (mAnomalies != null) {
- mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(mAnomalies);
- }
- }
-
- @VisibleForTesting
void initHeader() {
final View appSnippet = mHeaderPreference.findViewById(R.id.entity_header);
final Activity context = getActivity();
@@ -280,8 +253,6 @@
final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
- final String usagePercent = bundle.getString(EXTRA_POWER_USAGE_PERCENT);
- final int powerMah = bundle.getInt(EXTRA_POWER_USAGE_AMOUNT);
mForegroundPreference.setSummary(
TextUtils.expandTemplate(getText(R.string.battery_used_for),
StringUtil.formatElapsedTime(context, foregroundTimeMs, false)));
@@ -291,15 +262,6 @@
}
@Override
- public boolean onPreferenceTreeClick(Preference preference) {
- if (TextUtils.equals(preference.getKey(), AnomalySummaryPreferenceController.ANOMALY_KEY)) {
- mAnomalySummaryPreferenceController.onPreferenceTreeClick(preference);
- return true;
- }
- return super.onPreferenceTreeClick(preference);
- }
-
- @Override
public int getMetricsCategory() {
return MetricsEvent.FUELGAUGE_POWER_USAGE_DETAIL;
}
@@ -350,29 +312,6 @@
}
@Override
- public void onAnomalyHandled(Anomaly anomaly) {
- mAnomalySummaryPreferenceController.hideHighUsagePreference();
- }
-
- @Override
- public Loader<List<Anomaly>> onCreateLoader(int id, Bundle args) {
- return new AnomalyLoader(getContext(), mPackageName);
- }
-
- @Override
- public void onLoadFinished(Loader<List<Anomaly>> loader, List<Anomaly> data) {
- final AnomalyUtils anomalyUtils = AnomalyUtils.getInstance(getContext());
- anomalyUtils.logAnomalies(mMetricsFeatureProvider, data,
- MetricsEvent.FUELGAUGE_POWER_USAGE_DETAIL);
- mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(data);
- }
-
- @Override
- public void onLoaderReset(Loader<List<Anomaly>> loader) {
-
- }
-
- @Override
public void onBatteryTipHandled(BatteryTip batteryTip) {
mBackgroundActivityPreferenceController.updateSummary(
findPreference(mBackgroundActivityPreferenceController.getPreferenceKey()));
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index f14b1c9..7f0cb88 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -41,7 +41,6 @@
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -79,7 +78,6 @@
private SettingsActivity mActivity;
private InstrumentedPreferenceFragment mFragment;
private Context mPrefContext;
- SparseArray<List<Anomaly>> mAnomalySparseArray;
private Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
@@ -162,30 +160,13 @@
if (preference instanceof PowerGaugePreference) {
PowerGaugePreference pgp = (PowerGaugePreference) preference;
BatteryEntry entry = pgp.getInfo();
- AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity,
- mFragment, mBatteryStatsHelper, STATS_TYPE, entry, pgp.getPercent(),
- mAnomalySparseArray != null ? mAnomalySparseArray.get(entry.sipper.getUid())
- : null);
+ AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils,
+ mFragment, mBatteryStatsHelper, STATS_TYPE, entry, pgp.getPercent());
return true;
}
return false;
}
- public void refreshAnomalyIcon(final SparseArray<List<Anomaly>> anomalySparseArray) {
- if (!isAvailable()) {
- return;
- }
- mAnomalySparseArray = anomalySparseArray;
- for (int i = 0, size = anomalySparseArray.size(); i < size; i++) {
- final String key = extractKeyFromUid(anomalySparseArray.keyAt(i));
- final PowerGaugePreference pref = (PowerGaugePreference) mAppListGroup.findPreference(
- key);
- if (pref != null) {
- pref.shouldShowAnomalyIcon(true);
- }
- }
- }
-
public void refreshAppListGroup(BatteryStatsHelper statsHelper, boolean showAllApps) {
if (!isAvailable()) {
return;
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 83b0e1b..9e920c4 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -38,7 +38,6 @@
import com.android.internal.os.BatteryStatsHelper;
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.fuelgauge.batterytip.AnomalyInfo;
import com.android.settings.fuelgauge.batterytip.StatsManagerConfig;
import com.android.settings.overlay.FeatureFactory;
@@ -392,20 +391,6 @@
}
}
- @StringRes
- public int getSummaryResIdFromAnomalyType(@Anomaly.AnomalyType int type) {
- switch (type) {
- case Anomaly.AnomalyType.WAKE_LOCK:
- return R.string.battery_abnormal_wakelock_summary;
- case Anomaly.AnomalyType.WAKEUP_ALARM:
- return R.string.battery_abnormal_wakeup_alarm_summary;
- case Anomaly.AnomalyType.BLUETOOTH_SCAN:
- return R.string.battery_abnormal_location_summary;
- default:
- throw new IllegalArgumentException("Incorrect anomaly type: " + type);
- }
- }
-
public void setForceAppStandby(int uid, String packageName,
int mode) {
final boolean isPreOApp = isPreOApp(packageName);
@@ -422,6 +407,16 @@
packageName) == AppOpsManager.MODE_IGNORED;
}
+ public boolean clearForceAppStandby(String packageName) {
+ final int uid = getPackageUid(packageName);
+ if (uid != UID_NULL && isForceAppStandbyEnabled(uid, packageName)) {
+ setForceAppStandby(uid, packageName, AppOpsManager.MODE_ALLOWED);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public void initBatteryStatsHelper(BatteryStatsHelper statsHelper, Bundle bundle,
UserManager userManager) {
statsHelper.create(bundle);
diff --git a/src/com/android/settings/fuelgauge/HighPowerDetail.java b/src/com/android/settings/fuelgauge/HighPowerDetail.java
index 84120d7..f5df452 100644
--- a/src/com/android/settings/fuelgauge/HighPowerDetail.java
+++ b/src/com/android/settings/fuelgauge/HighPowerDetail.java
@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.content.Context;
@@ -38,6 +37,7 @@
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class HighPowerDetail extends InstrumentedDialogFragment implements OnClickListener,
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetails.java b/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetails.java
deleted file mode 100644
index 68412c7..0000000
--- a/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetails.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.os.UserHandle;
-import android.util.IconDrawableFactory;
-
-import androidx.annotation.VisibleForTesting;
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.Utils;
-import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment;
-import com.android.settings.fuelgauge.anomaly.AnomalyPreference;
-import com.android.settingslib.core.AbstractPreferenceController;
-
-import java.util.List;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceGroup;
-
-/**
- * Fragment to show a list of anomaly apps, where user could handle these anomalies
- */
-public class PowerUsageAnomalyDetails extends DashboardFragment implements
- AnomalyDialogFragment.AnomalyDialogListener {
-
- public static final String TAG = "PowerAbnormalUsageDetail";
- @VisibleForTesting
- static final String EXTRA_ANOMALY_LIST = "anomaly_list";
- private static final int REQUEST_ANOMALY_ACTION = 0;
- private static final String KEY_PREF_ANOMALY_LIST = "app_abnormal_list";
-
- @VisibleForTesting
- List<Anomaly> mAnomalies;
- @VisibleForTesting
- PreferenceGroup mAbnormalListGroup;
- @VisibleForTesting
- PackageManager mPackageManager;
- @VisibleForTesting
- BatteryUtils mBatteryUtils;
- @VisibleForTesting
- IconDrawableFactory mIconDrawableFactory;
-
- public static void startBatteryAbnormalPage(SettingsActivity caller,
- InstrumentedPreferenceFragment fragment, List<Anomaly> anomalies) {
- Bundle args = new Bundle();
- args.putParcelableList(EXTRA_ANOMALY_LIST, anomalies);
-
- new SubSettingLauncher(caller)
- .setDestination(PowerUsageAnomalyDetails.class.getName())
- .setTitleRes(R.string.battery_abnormal_details_title)
- .setArguments(args)
- .setSourceMetricsCategory(fragment.getMetricsCategory())
- .launch();
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- final Context context = getContext();
-
- mAnomalies = getArguments().getParcelableArrayList(EXTRA_ANOMALY_LIST);
- mAbnormalListGroup = (PreferenceGroup) findPreference(KEY_PREF_ANOMALY_LIST);
- mPackageManager = context.getPackageManager();
- mIconDrawableFactory = IconDrawableFactory.newInstance(context);
- mBatteryUtils = BatteryUtils.getInstance(context);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- refreshUi();
- }
-
- @Override
- public boolean onPreferenceTreeClick(Preference preference) {
- if (preference instanceof AnomalyPreference) {
- AnomalyPreference anomalyPreference = (AnomalyPreference) preference;
- final Anomaly anomaly = anomalyPreference.getAnomaly();
-
- AnomalyDialogFragment dialogFragment = AnomalyDialogFragment.newInstance(anomaly,
- MetricsProto.MetricsEvent.FUELGAUGE_ANOMALY_DETAIL);
- dialogFragment.setTargetFragment(this, REQUEST_ANOMALY_ACTION);
- dialogFragment.show(getFragmentManager(), TAG);
-
- return true;
- }
-
- return super.onPreferenceTreeClick(preference);
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.power_abnormal_detail;
- }
-
- @Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return null;
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.FUELGAUGE_ANOMALY_DETAIL;
- }
-
- void refreshUi() {
- mAbnormalListGroup.removeAll();
- for (int i = 0, size = mAnomalies.size(); i < size; i++) {
- final Anomaly anomaly = mAnomalies.get(i);
- Preference pref = new AnomalyPreference(getPrefContext(), anomaly);
- pref.setSummary(mBatteryUtils.getSummaryResIdFromAnomalyType(anomaly.type));
- Drawable icon = getBadgedIcon(anomaly.packageName, UserHandle.getUserId(anomaly.uid));
- if (icon != null) {
- pref.setIcon(icon);
- }
-
- mAbnormalListGroup.addPreference(pref);
- }
- }
-
- @Override
- public void onAnomalyHandled(Anomaly anomaly) {
- mAnomalies.remove(anomaly);
- refreshUi();
- }
-
- @VisibleForTesting
- Drawable getBadgedIcon(String packageName, int userId) {
- return Utils.getBadgedIcon(mIconDrawableFactory, mPackageManager, packageName, userId);
- }
-}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 3d13d04..843aeec 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -41,8 +41,6 @@
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.display.BatteryPercentagePreferenceController;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
import com.android.settings.fuelgauge.batterytip.BatteryTipLoader;
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
@@ -104,11 +102,6 @@
@VisibleForTesting
BatteryInfo mBatteryInfo;
- /**
- * SparseArray that maps uid to {@link Anomaly}, so we could find {@link Anomaly} by uid
- */
- @VisibleForTesting
- SparseArray<List<Anomaly>> mAnomalySparseArray;
@VisibleForTesting
BatteryHeaderPreferenceController mBatteryHeaderPreferenceController;
@VisibleForTesting
@@ -217,7 +210,6 @@
KEY_TIME_SINCE_LAST_FULL_CHARGE);
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.battery_footer_summary);
mBatteryUtils = BatteryUtils.getInstance(getContext());
- mAnomalySparseArray = new SparseArray<>();
restartBatteryInfoLoader();
mBatteryTipPreferenceController.restoreInstanceState(icicle);
@@ -328,11 +320,6 @@
}
@VisibleForTesting
- AnomalyDetectionPolicy getAnomalyDetectionPolicy() {
- return new AnomalyDetectionPolicy(getContext());
- }
-
- @VisibleForTesting
void updateLastFullChargePreference() {
if (mBatteryInfo != null && mBatteryInfo.averageTimeToDischarge
!= Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN) {
@@ -369,17 +356,6 @@
}
@VisibleForTesting
- void updateAnomalySparseArray(List<Anomaly> anomalies) {
- mAnomalySparseArray.clear();
- for (final Anomaly anomaly : anomalies) {
- if (mAnomalySparseArray.get(anomaly.uid) == null) {
- mAnomalySparseArray.append(anomaly.uid, new ArrayList<>());
- }
- mAnomalySparseArray.get(anomaly.uid).add(anomaly);
- }
- }
-
- @VisibleForTesting
void restartBatteryInfoLoader() {
getLoaderManager().restartLoader(BATTERY_INFO_LOADER, Bundle.EMPTY,
mBatteryInfoLoaderCallbacks);
diff --git a/src/com/android/settings/fuelgauge/anomaly/Anomaly.java b/src/com/android/settings/fuelgauge/anomaly/Anomaly.java
deleted file mode 100644
index 5ff21cb..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/Anomaly.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.TextUtils;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.Objects;
-
-import androidx.annotation.IntDef;
-
-/**
- * Data that represents an app has been detected as anomaly. It contains
- *
- * 1. Basic information of the app(i.e. uid, package name)
- * 2. Type of anomaly
- * 3. Data that has been detected as anomaly(i.e wakelock time)
- */
-public class Anomaly implements Parcelable {
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({AnomalyType.WAKE_LOCK,
- AnomalyType.WAKEUP_ALARM,
- AnomalyType.BLUETOOTH_SCAN})
- public @interface AnomalyType {
- int WAKE_LOCK = 0;
- int WAKEUP_ALARM = 1;
- int BLUETOOTH_SCAN = 2;
- }
-
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({AnomalyActionType.FORCE_STOP,
- AnomalyActionType.BACKGROUND_CHECK,
- AnomalyActionType.LOCATION_CHECK,
- AnomalyActionType.STOP_AND_BACKGROUND_CHECK})
- public @interface AnomalyActionType {
- int FORCE_STOP = 0;
- int BACKGROUND_CHECK = 1;
- int LOCATION_CHECK = 2;
- int STOP_AND_BACKGROUND_CHECK = 3;
- }
-
- @AnomalyType
- public static final int[] ANOMALY_TYPE_LIST = {
- AnomalyType.WAKE_LOCK,
- AnomalyType.WAKEUP_ALARM,
- AnomalyType.BLUETOOTH_SCAN};
-
- /**
- * Type of this this anomaly
- */
- public final int type;
- public final int uid;
- public final int targetSdkVersion;
- public final long wakelockTimeMs;
- public final long bluetoothScanningTimeMs;
- public final int wakeupAlarmCount;
- /**
- * {@code true} if background restriction is enabled
- *
- * @see android.app.AppOpsManager.OP_RUN_IN_BACKGROUND
- */
- public final boolean backgroundRestrictionEnabled;
- /**
- * Display name of this anomaly, usually it is the app name
- */
- public final CharSequence displayName;
- public final String packageName;
-
- private Anomaly(Builder builder) {
- type = builder.mType;
- uid = builder.mUid;
- displayName = builder.mDisplayName;
- packageName = builder.mPackageName;
- wakelockTimeMs = builder.mWakeLockTimeMs;
- targetSdkVersion = builder.mTargetSdkVersion;
- backgroundRestrictionEnabled = builder.mBgRestrictionEnabled;
- bluetoothScanningTimeMs = builder.mBluetoothScanningTimeMs;
- wakeupAlarmCount = builder.mWakeupAlarmCount;
- }
-
- private Anomaly(Parcel in) {
- type = in.readInt();
- uid = in.readInt();
- displayName = in.readCharSequence();
- packageName = in.readString();
- wakelockTimeMs = in.readLong();
- targetSdkVersion = in.readInt();
- backgroundRestrictionEnabled = in.readBoolean();
- wakeupAlarmCount = in.readInt();
- bluetoothScanningTimeMs = in.readLong();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(type);
- dest.writeInt(uid);
- dest.writeCharSequence(displayName);
- dest.writeString(packageName);
- dest.writeLong(wakelockTimeMs);
- dest.writeInt(targetSdkVersion);
- dest.writeBoolean(backgroundRestrictionEnabled);
- dest.writeInt(wakeupAlarmCount);
- dest.writeLong(bluetoothScanningTimeMs);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Anomaly)) {
- return false;
- }
-
- Anomaly other = (Anomaly) obj;
- return type == other.type
- && uid == other.uid
- && wakelockTimeMs == other.wakelockTimeMs
- && TextUtils.equals(displayName, other.displayName)
- && TextUtils.equals(packageName, other.packageName)
- && targetSdkVersion == other.targetSdkVersion
- && backgroundRestrictionEnabled == other.backgroundRestrictionEnabled
- && wakeupAlarmCount == other.wakeupAlarmCount
- && bluetoothScanningTimeMs == other.bluetoothScanningTimeMs;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, uid, displayName, packageName, wakelockTimeMs, targetSdkVersion,
- backgroundRestrictionEnabled, wakeupAlarmCount, bluetoothScanningTimeMs);
- }
-
- @Override
- public String toString() {
- return "type=" + toAnomalyTypeText(type) + " uid=" + uid + " package=" + packageName +
- " displayName=" + displayName + " wakelockTimeMs=" + wakelockTimeMs +
- " wakeupAlarmCount=" + wakeupAlarmCount + " bluetoothTimeMs="
- + bluetoothScanningTimeMs;
- }
-
- private String toAnomalyTypeText(@AnomalyType int type) {
- switch (type) {
- case AnomalyType.WAKEUP_ALARM:
- return "wakeupAlarm";
- case AnomalyType.WAKE_LOCK:
- return "wakelock";
- case AnomalyType.BLUETOOTH_SCAN:
- return "unoptimizedBluetoothScan";
- }
-
- return "";
- }
-
- public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public Anomaly createFromParcel(Parcel in) {
- return new Anomaly(in);
- }
-
- public Anomaly[] newArray(int size) {
- return new Anomaly[size];
- }
- };
-
- public static final class Builder {
- @AnomalyType
- private int mType;
- private int mUid;
- private int mTargetSdkVersion;
- private CharSequence mDisplayName;
- private String mPackageName;
- private long mWakeLockTimeMs;
- private boolean mBgRestrictionEnabled;
- private int mWakeupAlarmCount;
- private long mBluetoothScanningTimeMs;
-
- public Builder setType(@AnomalyType int type) {
- mType = type;
- return this;
- }
-
- public Builder setUid(int uid) {
- mUid = uid;
- return this;
- }
-
- public Builder setDisplayName(CharSequence displayName) {
- mDisplayName = displayName;
- return this;
- }
-
- public Builder setPackageName(String packageName) {
- mPackageName = packageName;
- return this;
- }
-
- public Builder setWakeLockTimeMs(long wakeLockTimeMs) {
- mWakeLockTimeMs = wakeLockTimeMs;
- return this;
- }
-
- public Builder setTargetSdkVersion(int targetSdkVersion) {
- mTargetSdkVersion = targetSdkVersion;
- return this;
- }
-
- public Builder setBackgroundRestrictionEnabled(boolean bgRestrictionEnabled) {
- mBgRestrictionEnabled = bgRestrictionEnabled;
- return this;
- }
-
- public Builder setWakeupAlarmCount(int wakeupAlarmCount) {
- mWakeupAlarmCount = wakeupAlarmCount;
- return this;
- }
-
- public Builder setBluetoothScanningTimeMs(long bluetoothScanningTimeMs) {
- mBluetoothScanningTimeMs = bluetoothScanningTimeMs;
- return this;
- }
-
- public Anomaly build() {
- return new Anomaly(this);
- }
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java
deleted file mode 100644
index 712fe93..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicy.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import android.content.Context;
-import android.net.Uri;
-import android.provider.Settings;
-import android.text.format.DateUtils;
-import android.util.KeyValueListParser;
-import android.util.Log;
-
-import java.util.Arrays;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Class to store the policy for anomaly detection, which comes from
- * {@link android.provider.Settings.Global}
- */
-public class AnomalyDetectionPolicy {
- public static final String TAG = "AnomalyDetectionPolicy";
-
- @VisibleForTesting
- static final String KEY_ANOMALY_DETECTION_ENABLED = "anomaly_detection_enabled";
- @VisibleForTesting
- static final String KEY_WAKELOCK_DETECTION_ENABLED = "wakelock_enabled";
- @VisibleForTesting
- static final String KEY_WAKEUP_ALARM_DETECTION_ENABLED = "wakeup_alarm_enabled";
- @VisibleForTesting
- static final String KEY_BLUETOOTH_SCAN_DETECTION_ENABLED = "bluetooth_scan_enabled";
- @VisibleForTesting
- static final String KEY_WAKELOCK_THRESHOLD = "wakelock_threshold";
- @VisibleForTesting
- static final String KEY_WAKEUP_ALARM_THRESHOLD = "wakeup_alarm_threshold";
- @VisibleForTesting
- static final String KEY_WAKEUP_BLACKLISTED_TAGS = "wakeup_blacklisted_tags";
- @VisibleForTesting
- static final String KEY_BLUETOOTH_SCAN_THRESHOLD = "bluetooth_scan_threshold";
-
- /**
- * {@code true} if general anomaly detection is enabled
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_ANOMALY_DETECTION_ENABLED
- */
- final boolean anomalyDetectionEnabled;
-
- /**
- * {@code true} if wakelock anomaly detection is enabled
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_WAKELOCK_DETECTION_ENABLED
- */
- final boolean wakeLockDetectionEnabled;
-
- /**
- * {@code true} if wakeup alarm detection is enabled
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_WAKEUP_ALARM_DETECTION_ENABLED
- */
- final boolean wakeupAlarmDetectionEnabled;
-
- /**
- * {@code true} if bluetooth scanning detection is enabled
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_BLUETOOTH_SCAN_THRESHOLD
- */
- final boolean bluetoothScanDetectionEnabled;
-
- /**
- * Threshold for wakelock time in milli seconds
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_WAKELOCK_THRESHOLD
- */
- public final long wakeLockThreshold;
-
- /**
- * Threshold for wakeup alarm count per hour
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_WAKEUP_ALARM_THRESHOLD
- */
- public final long wakeupAlarmThreshold;
-
- /**
- * Array of blacklisted wakeups, by tag.
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_WAKEUP_BLACKLISTED_TAGS
- */
- public final Set<String> wakeupBlacklistedTags;
-
- /**
- * Threshold for bluetooth unoptimized scanning time in milli seconds
- *
- * @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
- * @see #KEY_BLUETOOTH_SCAN_THRESHOLD
- */
- public final long bluetoothScanThreshold;
-
- private final KeyValueListParser mParser;
-
- public AnomalyDetectionPolicy(Context context) {
- mParser = new KeyValueListParser(',');
- final String value = Settings.Global.getString(context.getContentResolver(),
- Settings.Global.ANOMALY_DETECTION_CONSTANTS);
-
- try {
- mParser.setString(value);
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Bad anomaly detection constants");
- }
-
- anomalyDetectionEnabled =
- mParser.getBoolean(KEY_ANOMALY_DETECTION_ENABLED, false);
- wakeLockDetectionEnabled =
- mParser.getBoolean(KEY_WAKELOCK_DETECTION_ENABLED,false);
- wakeupAlarmDetectionEnabled =
- mParser.getBoolean(KEY_WAKEUP_ALARM_DETECTION_ENABLED,false);
- bluetoothScanDetectionEnabled = mParser.getBoolean(
- KEY_BLUETOOTH_SCAN_DETECTION_ENABLED, false);
- wakeLockThreshold = mParser.getLong(KEY_WAKELOCK_THRESHOLD,
- DateUtils.HOUR_IN_MILLIS);
- wakeupAlarmThreshold = mParser.getLong(KEY_WAKEUP_ALARM_THRESHOLD, 10);
- wakeupBlacklistedTags = parseStringSet(KEY_WAKEUP_BLACKLISTED_TAGS, null);
- bluetoothScanThreshold = mParser.getLong(KEY_BLUETOOTH_SCAN_THRESHOLD,
- 30 * DateUtils.MINUTE_IN_MILLIS);
- }
-
- public boolean isAnomalyDetectionEnabled() {
- return anomalyDetectionEnabled;
- }
-
- public boolean isAnomalyDetectorEnabled(@Anomaly.AnomalyType int type) {
- switch (type) {
- case Anomaly.AnomalyType.WAKE_LOCK:
- return wakeLockDetectionEnabled;
- case Anomaly.AnomalyType.WAKEUP_ALARM:
- return wakeupAlarmDetectionEnabled;
- case Anomaly.AnomalyType.BLUETOOTH_SCAN:
- return bluetoothScanDetectionEnabled;
- default:
- return false; // Disabled when no this type
- }
- }
-
- private Set<String> parseStringSet(final String key, final Set<String> defaultSet) {
- final String value = mParser.getString(key, null);
- if (value != null) {
- return Arrays.stream(value.split(":"))
- .map(String::trim).map(Uri::decode).collect(Collectors.toSet());
- } else {
- return defaultSet;
- }
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragment.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragment.java
deleted file mode 100644
index d1d14b5..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragment.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.os.Bundle;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Dialog Fragment to show action dialog for each anomaly
- */
-public class AnomalyDialogFragment extends InstrumentedDialogFragment implements
- DialogInterface.OnClickListener {
-
- private static final String ARG_ANOMALY = "anomaly";
- private static final String ARG_METRICS_KEY = "metrics_key";
-
- @VisibleForTesting
- Anomaly mAnomaly;
- @VisibleForTesting
- AnomalyUtils mAnomalyUtils;
-
- /**
- * Listener to give the control back to target fragment
- */
- public interface AnomalyDialogListener {
- /**
- * This method is invoked once anomaly is handled, then target fragment could do
- * extra work. One example is that fragment could remove the anomaly preference
- * since it has been handled
- *
- * @param anomaly that has been handled
- */
- void onAnomalyHandled(Anomaly anomaly);
- }
-
- public static AnomalyDialogFragment newInstance(Anomaly anomaly, int metricsKey) {
- AnomalyDialogFragment dialogFragment = new AnomalyDialogFragment();
-
- Bundle args = new Bundle(2);
- args.putParcelable(ARG_ANOMALY, anomaly);
- args.putInt(ARG_METRICS_KEY, metricsKey);
- dialogFragment.setArguments(args);
-
- return dialogFragment;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- initAnomalyUtils();
- }
-
- @VisibleForTesting
- void initAnomalyUtils() {
- mAnomalyUtils = AnomalyUtils.getInstance(getContext());
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.DIALOG_HANDLE_ANOMALY;
- }
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- final AnomalyDialogListener lsn = (AnomalyDialogListener) getTargetFragment();
- if (lsn == null) {
- return;
- }
-
- final AnomalyAction anomalyAction = mAnomalyUtils.getAnomalyAction(mAnomaly);
- final int metricsKey = getArguments().getInt(ARG_METRICS_KEY);
-
- anomalyAction.handlePositiveAction(mAnomaly, metricsKey);
- lsn.onAnomalyHandled(mAnomaly);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final Bundle bundle = getArguments();
- final Context context = getContext();
- final AnomalyUtils anomalyUtils = AnomalyUtils.getInstance(context);
-
- mAnomaly = bundle.getParcelable(ARG_ANOMALY);
- anomalyUtils.logAnomaly(mMetricsFeatureProvider, mAnomaly,
- MetricsProto.MetricsEvent.DIALOG_HANDLE_ANOMALY);
-
- final AnomalyAction anomalyAction = mAnomalyUtils.getAnomalyAction(mAnomaly);
- switch (anomalyAction.getActionType()) {
- case Anomaly.AnomalyActionType.FORCE_STOP:
- return new AlertDialog.Builder(context)
- .setTitle(R.string.dialog_stop_title)
- .setMessage(getString(mAnomaly.type == Anomaly.AnomalyType.WAKE_LOCK
- ? R.string.dialog_stop_message
- : R.string.dialog_stop_message_wakeup_alarm, mAnomaly.displayName))
- .setPositiveButton(R.string.dialog_stop_ok, this)
- .setNegativeButton(R.string.dlg_cancel, null)
- .create();
- case Anomaly.AnomalyActionType.STOP_AND_BACKGROUND_CHECK:
- return new AlertDialog.Builder(context)
- .setTitle(R.string.dialog_background_check_title)
- .setMessage(getString(R.string.dialog_background_check_message,
- mAnomaly.displayName))
- .setPositiveButton(R.string.dialog_background_check_ok, this)
- .setNegativeButton(R.string.dlg_cancel, null)
- .create();
- case Anomaly.AnomalyActionType.LOCATION_CHECK:
- return new AlertDialog.Builder(context)
- .setTitle(R.string.dialog_location_title)
- .setMessage(getString(R.string.dialog_location_message,
- mAnomaly.displayName))
- .setPositiveButton(R.string.dialog_location_ok, this)
- .setNegativeButton(R.string.dlg_cancel, null)
- .create();
- default:
- throw new IllegalArgumentException("unknown type " + mAnomaly.type);
- }
- }
-
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyLoader.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyLoader.java
deleted file mode 100644
index c7d6ba4..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyLoader.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.BatteryStats;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.util.Log;
-
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settingslib.utils.AsyncLoaderCompat;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Loader to compute which apps are anomaly and return a anomaly list. It will return
- * an empty list if there is no anomaly.
- */
-public class AnomalyLoader extends AsyncLoaderCompat<List<Anomaly>> {
- private static final String TAG = "AnomalyLoader";
-
- private static final boolean USE_FAKE_DATA = false;
- private BatteryStatsHelper mBatteryStatsHelper;
- private String mPackageName;
- private UserManager mUserManager;
- @VisibleForTesting
- AnomalyUtils mAnomalyUtils;
- @VisibleForTesting
- AnomalyDetectionPolicy mPolicy;
-
- /**
- * Create {@link AnomalyLoader} that runs anomaly check for all apps.
- */
- public AnomalyLoader(Context context, BatteryStatsHelper batteryStatsHelper) {
- this(context, batteryStatsHelper, null, new AnomalyDetectionPolicy(context));
-
- }
-
- /**
- * Create {@link AnomalyLoader} with {@code packageName}, so this loader will only
- * detect anomalies related to {@code packageName}, or check all apps if {@code packageName}
- * is {@code null}.
- *
- * This constructor will create {@link BatteryStatsHelper} in background thread.
- *
- * @param packageName if set, only finds anomalies for this package. If {@code null},
- * detects all anomalies of this type.
- */
- public AnomalyLoader(Context context, String packageName) {
- this(context, null, packageName, new AnomalyDetectionPolicy(context));
- }
-
- @VisibleForTesting
- AnomalyLoader(Context context, BatteryStatsHelper batteryStatsHelper,
- String packageName, AnomalyDetectionPolicy policy) {
- super(context);
- mBatteryStatsHelper = batteryStatsHelper;
- mPackageName = packageName;
- mAnomalyUtils = AnomalyUtils.getInstance(context);
- mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- mPolicy = policy;
- }
-
- @Override
- protected void onDiscardResult(List<Anomaly> result) {
- }
-
- @Override
- public List<Anomaly> loadInBackground() {
- if (USE_FAKE_DATA) {
- return generateFakeData();
- }
- if (mBatteryStatsHelper == null) {
- mBatteryStatsHelper = new BatteryStatsHelper(getContext());
- mBatteryStatsHelper.create((Bundle) null);
- mBatteryStatsHelper.refreshStats(BatteryStats.STATS_SINCE_CHARGED,
- mUserManager.getUserProfiles());
- }
-
- return mAnomalyUtils.detectAnomalies(mBatteryStatsHelper, mPolicy, mPackageName);
- }
-
- @VisibleForTesting
- List<Anomaly> generateFakeData() {
- final List<Anomaly> anomalies = new ArrayList<>();
- final Context context = getContext();
- final String packageName = "com.android.settings";
- final CharSequence displayName = "Settings";
- try {
- final int uid = context.getPackageManager().getPackageUid(packageName, 0);
-
- anomalies.add(new Anomaly.Builder()
- .setUid(uid)
- .setType(Anomaly.AnomalyType.WAKE_LOCK)
- .setPackageName(packageName)
- .setDisplayName(displayName)
- .build());
- anomalies.add(new Anomaly.Builder()
- .setUid(uid)
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setPackageName(packageName)
- .setDisplayName(displayName)
- .build());
- anomalies.add(new Anomaly.Builder()
- .setUid(uid)
- .setType(Anomaly.AnomalyType.BLUETOOTH_SCAN)
- .setPackageName(packageName)
- .setDisplayName(displayName)
- .build());
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "Cannot find package by name: " + packageName, e);
- }
- return anomalies;
- }
-
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyPreference.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyPreference.java
deleted file mode 100644
index ba06147..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyPreference.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.android.settings.fuelgauge.anomaly;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-/**
- * Preference that stores {@link Anomaly}
- */
-public class AnomalyPreference extends Preference {
- private Anomaly mAnomaly;
-
- public AnomalyPreference(Context context, Anomaly anomaly) {
- super(context);
- mAnomaly = anomaly;
-
- if (anomaly != null) {
- setTitle(anomaly.displayName);
- }
- }
-
- public Anomaly getAnomaly() {
- return mAnomaly;
- }
-
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceController.java b/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceController.java
deleted file mode 100644
index 70c83bc..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceController.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import android.content.Context;
-
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.PowerUsageAnomalyDetails;
-
-import java.util.List;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-
-/**
- * Manager that responsible for updating high usage preference and handling preference click.
- */
-public class AnomalySummaryPreferenceController {
- private static final String TAG = "HighUsagePreferenceController";
-
- public static final String ANOMALY_KEY = "high_usage";
-
- private static final int REQUEST_ANOMALY_ACTION = 0;
- private InstrumentedPreferenceFragment mFragment;
- @VisibleForTesting
- Preference mAnomalyPreference;
- @VisibleForTesting
- List<Anomaly> mAnomalies;
- @VisibleForTesting
- BatteryUtils mBatteryUtils;
- private SettingsActivity mSettingsActivity;
-
- /**
- * Metrics key about fragment that create this controller
- *
- * @see com.android.internal.logging.nano.MetricsProto.MetricsEvent
- */
- private int mMetricsKey;
-
- public AnomalySummaryPreferenceController(SettingsActivity activity,
- InstrumentedPreferenceFragment fragment) {
- mFragment = fragment;
- mSettingsActivity = activity;
- mAnomalyPreference = mFragment.getPreferenceScreen().findPreference(ANOMALY_KEY);
- mMetricsKey = fragment.getMetricsCategory();
- mBatteryUtils = BatteryUtils.getInstance(activity.getApplicationContext());
- hideHighUsagePreference();
- }
-
- public boolean onPreferenceTreeClick(Preference preference) {
- if (mAnomalies != null && ANOMALY_KEY.equals(preference.getKey())) {
- if (mAnomalies.size() == 1) {
- final Anomaly anomaly = mAnomalies.get(0);
- AnomalyDialogFragment dialogFragment = AnomalyDialogFragment.newInstance(anomaly,
- mMetricsKey);
- dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
- dialogFragment.show(mFragment.getFragmentManager(), TAG);
- } else {
- PowerUsageAnomalyDetails.startBatteryAbnormalPage(mSettingsActivity, mFragment,
- mAnomalies);
- }
- return true;
- }
- return false;
- }
-
- /**
- * Update anomaly preference based on {@code anomalies}, also store a reference
- * of {@paramref anomalies}, which would be used in {@link #onPreferenceTreeClick(Preference)}
- *
- * @param anomalies used to update the summary, this method will store a reference of it
- */
- public void updateAnomalySummaryPreference(List<Anomaly> anomalies) {
- final Context context = mFragment.getContext();
- mAnomalies = anomalies;
-
- if (!mAnomalies.isEmpty()) {
- mAnomalyPreference.setVisible(true);
- final int count = mAnomalies.size();
- final String title = context.getResources().getQuantityString(
- R.plurals.power_high_usage_title, count, mAnomalies.get(0).displayName);
- final String summary = count > 1 ?
- context.getString(R.string.battery_abnormal_apps_summary, count)
- : context.getString(
- mBatteryUtils.getSummaryResIdFromAnomalyType(mAnomalies.get(0).type));
-
- mAnomalyPreference.setTitle(title);
- mAnomalyPreference.setSummary(summary);
- } else {
- mAnomalyPreference.setVisible(false);
- }
- }
-
- public void hideHighUsagePreference() {
- mAnomalyPreference.setVisible(false);
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java b/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
deleted file mode 100644
index dc4bee0..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/AnomalyUtils.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import android.content.Context;
-import android.os.Build;
-import android.util.Pair;
-import android.util.SparseIntArray;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
-import com.android.settings.fuelgauge.anomaly.action.ForceStopAction;
-import com.android.settings.fuelgauge.anomaly.action.LocationCheckAction;
-import com.android.settings.fuelgauge.anomaly.action.StopAndBackgroundCheckAction;
-import com.android.settings.fuelgauge.anomaly.checker.AnomalyDetector;
-import com.android.settings.fuelgauge.anomaly.checker.BluetoothScanAnomalyDetector;
-import com.android.settings.fuelgauge.anomaly.checker.WakeLockAnomalyDetector;
-import com.android.settings.fuelgauge.anomaly.checker.WakeupAlarmAnomalyDetector;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Utility class for anomaly detection
- */
-public class AnomalyUtils {
- private Context mContext;
- private static AnomalyUtils sInstance;
-
- private static final SparseIntArray mMetricArray;
- static {
- mMetricArray = new SparseIntArray();
- mMetricArray.append(Anomaly.AnomalyType.WAKE_LOCK,
- MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKELOCK);
- mMetricArray.append(Anomaly.AnomalyType.WAKEUP_ALARM,
- MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKEUP_ALARM);
- mMetricArray.append(Anomaly.AnomalyType.BLUETOOTH_SCAN,
- MetricsProto.MetricsEvent.ANOMALY_TYPE_UNOPTIMIZED_BT);
- }
-
- @VisibleForTesting
- AnomalyUtils(Context context) {
- mContext = context.getApplicationContext();
- }
-
- public static AnomalyUtils getInstance(Context context) {
- if (sInstance == null) {
- sInstance = new AnomalyUtils(context);
- }
- return sInstance;
- }
-
- /**
- * Return the corresponding {@link AnomalyAction} according to
- * {@link com.android.settings.fuelgauge.anomaly.Anomaly}
- *
- * @return corresponding {@link AnomalyAction}, or null if cannot find it.
- */
- public AnomalyAction getAnomalyAction(Anomaly anomaly) {
- switch (anomaly.type) {
- case Anomaly.AnomalyType.WAKE_LOCK:
- return new ForceStopAction(mContext);
- case Anomaly.AnomalyType.WAKEUP_ALARM:
- if (anomaly.targetSdkVersion >= Build.VERSION_CODES.O
- || (anomaly.targetSdkVersion < Build.VERSION_CODES.O
- && anomaly.backgroundRestrictionEnabled)) {
- return new ForceStopAction(mContext);
- } else {
- return new StopAndBackgroundCheckAction(mContext);
- }
- case Anomaly.AnomalyType.BLUETOOTH_SCAN:
- return new LocationCheckAction(mContext);
- default:
- return null;
- }
- }
-
- /**
- * Return the corresponding {@link AnomalyDetector} according to
- * {@link com.android.settings.fuelgauge.anomaly.Anomaly.AnomalyType}
- *
- * @return corresponding {@link AnomalyDetector}, or null if cannot find it.
- */
- public AnomalyDetector getAnomalyDetector(@Anomaly.AnomalyType int anomalyType) {
- switch (anomalyType) {
- case Anomaly.AnomalyType.WAKE_LOCK:
- return new WakeLockAnomalyDetector(mContext);
- case Anomaly.AnomalyType.WAKEUP_ALARM:
- return new WakeupAlarmAnomalyDetector(mContext);
- case Anomaly.AnomalyType.BLUETOOTH_SCAN:
- return new BluetoothScanAnomalyDetector(mContext);
- default:
- return null;
- }
- }
-
- /**
- * Detect whether application with {@code targetPackageName} has anomaly. When
- * {@code targetPackageName} is null, start detection among all the applications.
- *
- * @param batteryStatsHelper contains battery stats, used to detect anomaly
- * @param policy contains configuration about anomaly check
- * @param targetPackageName represents the app need to be detected
- * @return the list of anomalies
- */
- public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper,
- AnomalyDetectionPolicy policy, String targetPackageName) {
- final List<Anomaly> anomalies = new ArrayList<>();
- for (@Anomaly.AnomalyType int type : Anomaly.ANOMALY_TYPE_LIST) {
- if (policy.isAnomalyDetectorEnabled(type)) {
- anomalies.addAll(getAnomalyDetector(type).detectAnomalies(
- batteryStatsHelper, targetPackageName));
- }
- }
-
- return anomalies;
- }
-
- /**
- * Log the list of {@link Anomaly} using {@link MetricsFeatureProvider}, which contains
- * anomaly type, package name, field_context, field_action_type
- *
- * @param provider provider to do the logging
- * @param anomalies contains the data to log
- * @param contextId which page invoke this logging
- * @see #logAnomaly(MetricsFeatureProvider, Anomaly, int)
- */
- public void logAnomalies(MetricsFeatureProvider provider, List<Anomaly> anomalies,
- int contextId) {
- for (int i = 0, size = anomalies.size(); i < size; i++) {
- logAnomaly(provider, anomalies.get(i), contextId);
- }
- }
-
- /**
- * Log the {@link Anomaly} using {@link MetricsFeatureProvider}, which contains
- * anomaly type, package name, field_context, field_action_type
- *
- * @param provider provider to do the logging
- * @param anomaly contains the data to log
- * @param contextId which page invoke this logging
- * @see #logAnomalies(MetricsFeatureProvider, List, int)
- */
- public void logAnomaly(MetricsFeatureProvider provider, Anomaly anomaly, int contextId) {
- provider.action(
- mContext,
- mMetricArray.get(anomaly.type, MetricsProto.MetricsEvent.VIEW_UNKNOWN),
- anomaly.packageName,
- Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, contextId),
- Pair.create(MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
- getAnomalyAction(anomaly).getActionType()));
- }
-
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/action/AnomalyAction.java b/src/com/android/settings/fuelgauge/anomaly/action/AnomalyAction.java
deleted file mode 100644
index d7de5a7..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/action/AnomalyAction.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import android.content.Context;
-import android.util.Pair;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-
-/**
- * Abstract class for anomaly action, which is triggered if we need to handle the anomaly
- */
-public abstract class AnomalyAction {
- protected Context mContext;
- protected int mActionMetricKey;
-
- private MetricsFeatureProvider mMetricsFeatureProvider;
-
- public AnomalyAction(Context context) {
- mContext = context;
- mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
- }
-
- /**
- * handle the action when user clicks positive button
- *
- * @param anomaly about the app that we need to handle
- * @param contextMetricsKey key for the page that invokes the action
- * @see com.android.internal.logging.nano.MetricsProto
- */
- public void handlePositiveAction(Anomaly anomaly, int contextMetricsKey) {
- mMetricsFeatureProvider.action(mContext, mActionMetricKey, anomaly.packageName,
- Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, contextMetricsKey));
- }
-
- /**
- * Check whether the action is active for {@code anomaly}
- *
- * @param anomaly about the app that we need to handle
- * @return {@code true} if action is active, otherwise return {@code false}
- */
- public abstract boolean isActionActive(Anomaly anomaly);
-
- @Anomaly.AnomalyActionType
- public abstract int getActionType();
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckAction.java b/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckAction.java
deleted file mode 100644
index ed2387c..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import android.app.AppOpsManager;
-import android.content.Context;
-import android.os.Build;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Background check action for anomaly app, which means to stop app running in the background
- */
-public class BackgroundCheckAction extends AnomalyAction {
-
- private AppOpsManager mAppOpsManager;
- @VisibleForTesting
- BatteryUtils mBatteryUtils;
-
- public BackgroundCheckAction(Context context) {
- super(context);
- mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- mActionMetricKey = MetricsProto.MetricsEvent.ACTION_APP_BACKGROUND_CHECK;
- mBatteryUtils = BatteryUtils.getInstance(context);
- }
-
- @Override
- public void handlePositiveAction(Anomaly anomaly, int contextMetricsKey) {
- super.handlePositiveAction(anomaly, contextMetricsKey);
- if (anomaly.targetSdkVersion < Build.VERSION_CODES.O) {
- mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, anomaly.uid,
- anomaly.packageName,
- AppOpsManager.MODE_IGNORED);
- }
- }
-
- @Override
- public boolean isActionActive(Anomaly anomaly) {
- return !mBatteryUtils.isBackgroundRestrictionEnabled(anomaly.targetSdkVersion, anomaly.uid,
- anomaly.packageName);
- }
-
- @Override
- public int getActionType() {
- return Anomaly.AnomalyActionType.BACKGROUND_CHECK;
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/action/ForceStopAction.java b/src/com/android/settings/fuelgauge/anomaly/action/ForceStopAction.java
deleted file mode 100644
index fb7306a..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/action/ForceStopAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.util.Log;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
-/**
- * Force stop action for anomaly app, which means to stop the app which causes anomaly
- */
-public class ForceStopAction extends AnomalyAction {
- private static final String TAG = "ForceStopAction";
-
- private ActivityManager mActivityManager;
- private PackageManager mPackageManager;
-
- public ForceStopAction(Context context) {
- super(context);
- mActivityManager = (ActivityManager) context.getSystemService(
- Context.ACTIVITY_SERVICE);
- mPackageManager = context.getPackageManager();
- mActionMetricKey = MetricsProto.MetricsEvent.ACTION_APP_FORCE_STOP;
- }
-
- @Override
- public void handlePositiveAction(Anomaly anomaly, int contextMetricsKey) {
- super.handlePositiveAction(anomaly, contextMetricsKey);
-
- mActivityManager.forceStopPackage(anomaly.packageName);
- }
-
- @Override
- public boolean isActionActive(Anomaly anomaly) {
- try {
- ApplicationInfo info = mPackageManager.getApplicationInfo(anomaly.packageName,
- PackageManager.GET_META_DATA);
- return (info.flags & ApplicationInfo.FLAG_STOPPED) == 0;
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "Cannot find info for app: " + anomaly.packageName);
- }
- return false;
- }
-
- @Override
- public int getActionType() {
- return Anomaly.AnomalyActionType.FORCE_STOP;
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckAction.java b/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckAction.java
deleted file mode 100644
index cdeab5d..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckAction.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.pm.permission.RuntimePermissionPresenter;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.core.content.PermissionChecker;
-
-/**
- * Location action for anomaly app, which means to turn off location permission for this app
- */
-public class LocationCheckAction extends AnomalyAction {
-
- private static final String TAG = "LocationCheckAction";
-
- private final RuntimePermissionPresenter mRuntimePermissionPresenter;
-
- public LocationCheckAction(Context context) {
- this(context, RuntimePermissionPresenter.getInstance(context));
- }
-
- @VisibleForTesting
- LocationCheckAction(Context context, RuntimePermissionPresenter runtimePermissionPresenter) {
- super(context);
- mRuntimePermissionPresenter = runtimePermissionPresenter;
- mActionMetricKey = MetricsProto.MetricsEvent.ACTION_APP_LOCATION_CHECK;
- }
-
- @Override
- public void handlePositiveAction(Anomaly anomaly, int contextMetricsKey) {
- super.handlePositiveAction(anomaly, contextMetricsKey);
- mRuntimePermissionPresenter.revokeRuntimePermission(anomaly.packageName,
- Manifest.permission.ACCESS_COARSE_LOCATION);
- mRuntimePermissionPresenter.revokeRuntimePermission(anomaly.packageName,
- Manifest.permission.ACCESS_FINE_LOCATION);
- }
-
- @Override
- public boolean isActionActive(Anomaly anomaly) {
- return isPermissionGranted(anomaly, Manifest.permission.ACCESS_COARSE_LOCATION)
- || isPermissionGranted(anomaly, Manifest.permission.ACCESS_FINE_LOCATION);
- }
-
- @Override
- public int getActionType() {
- return Anomaly.AnomalyActionType.LOCATION_CHECK;
- }
-
- private boolean isPermissionGranted(Anomaly anomaly, String permission) {
- return PermissionChecker.checkPermission(mContext, permission, -1, anomaly.uid,
- anomaly.packageName) == PermissionChecker.PERMISSION_GRANTED;
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundCheckAction.java b/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundCheckAction.java
deleted file mode 100644
index a89e128..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundCheckAction.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import android.content.Context;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Force stop and background check action for anomaly app, this action will
- * 1. Force stop the app
- * 2. Turn on background check
- */
-public class StopAndBackgroundCheckAction extends AnomalyAction {
- @VisibleForTesting
- ForceStopAction mForceStopAction;
- @VisibleForTesting
- BackgroundCheckAction mBackgroundCheckAction;
-
- public StopAndBackgroundCheckAction(Context context) {
- this(context, new ForceStopAction(context), new BackgroundCheckAction(context));
- mActionMetricKey = MetricsProto.MetricsEvent.ACTION_APP_STOP_AND_BACKGROUND_CHECK;
- }
-
- @VisibleForTesting
- StopAndBackgroundCheckAction(Context context, ForceStopAction forceStopAction,
- BackgroundCheckAction backgroundCheckAction) {
- super(context);
- mForceStopAction = forceStopAction;
- mBackgroundCheckAction = backgroundCheckAction;
- }
-
- @Override
- public void handlePositiveAction(Anomaly anomaly, int metricsKey) {
- super.handlePositiveAction(anomaly, metricsKey);
- mForceStopAction.handlePositiveAction(anomaly, metricsKey);
- mBackgroundCheckAction.handlePositiveAction(anomaly, metricsKey);
- }
-
- @Override
- public boolean isActionActive(Anomaly anomaly) {
- return mForceStopAction.isActionActive(anomaly)
- && mBackgroundCheckAction.isActionActive(anomaly);
- }
-
- @Override
- public int getActionType() {
- return Anomaly.AnomalyActionType.STOP_AND_BACKGROUND_CHECK;
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/checker/AnomalyDetector.java b/src/com/android/settings/fuelgauge/anomaly/checker/AnomalyDetector.java
deleted file mode 100644
index 1921bef..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/checker/AnomalyDetector.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package com.android.settings.fuelgauge.anomaly.checker;
-
-import android.annotation.Nullable;
-
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
-import java.util.List;
-
-public interface AnomalyDetector {
- /**
- * Detect whether there is anomaly among all the applications in the device
- *
- * @param batteryStatsHelper used to detect the anomaly
- * @return anomaly list
- */
- List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper);
-
- /**
- * Detect whether application with {@code targetPackageName} has anomaly. When
- * {@code targetPackageName} is null, start detection among all the applications.
- *
- * @param batteryStatsHelper used to detect the anomaly
- * @param targetPackageName represents the app need to be detected
- * @return anomaly list
- */
- List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper,
- @Nullable String targetPackageName);
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetector.java b/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetector.java
deleted file mode 100644
index 0641a85..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetector.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.checker;
-
-import android.content.Context;
-import android.os.BatteryStats;
-import android.os.SystemClock;
-
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.Utils;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
-import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Check whether apps have unoptimized bluetooth scanning in the background
- */
-public class BluetoothScanAnomalyDetector implements AnomalyDetector {
- private static final String TAG = "BluetoothScanAnomalyDetector";
- @VisibleForTesting
- BatteryUtils mBatteryUtils;
- private long mBluetoothScanningThreshold;
- private Context mContext;
- private AnomalyUtils mAnomalyUtils;
-
- public BluetoothScanAnomalyDetector(Context context) {
- this(context, new AnomalyDetectionPolicy(context), AnomalyUtils.getInstance(context));
- }
-
- @VisibleForTesting
- BluetoothScanAnomalyDetector(Context context, AnomalyDetectionPolicy policy,
- AnomalyUtils anomalyUtils) {
- mContext = context;
- mBatteryUtils = BatteryUtils.getInstance(context);
- mBluetoothScanningThreshold = policy.bluetoothScanThreshold;
- mAnomalyUtils = anomalyUtils;
- }
-
- @Override
- public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper) {
- // Detect all apps if targetPackageName is null
- return detectAnomalies(batteryStatsHelper, null /* targetPackageName */);
- }
-
- @Override
- public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper,
- String targetPackageName) {
- final List<BatterySipper> batterySippers = batteryStatsHelper.getUsageList();
- final List<Anomaly> anomalies = new ArrayList<>();
- final int targetUid = mBatteryUtils.getPackageUid(targetPackageName);
- final long elapsedRealtimeMs = SystemClock.elapsedRealtime();
-
- for (int i = 0, size = batterySippers.size(); i < size; i++) {
- final BatterySipper sipper = batterySippers.get(i);
- final BatteryStats.Uid uid = sipper.uidObj;
- if (uid == null
- || mBatteryUtils.shouldHideSipper(sipper)
- || (targetUid != BatteryUtils.UID_NULL && targetUid != uid.getUid())) {
- continue;
- }
-
- final long bluetoothTimeMs = getBluetoothUnoptimizedBgTimeMs(uid, elapsedRealtimeMs);
- if (bluetoothTimeMs > mBluetoothScanningThreshold) {
- final String packageName = mBatteryUtils.getPackageName(uid.getUid());
- final CharSequence displayName = Utils.getApplicationLabel(mContext,
- packageName);
-
- Anomaly anomaly = new Anomaly.Builder()
- .setUid(uid.getUid())
- .setType(Anomaly.AnomalyType.BLUETOOTH_SCAN)
- .setDisplayName(displayName)
- .setPackageName(packageName)
- .setBluetoothScanningTimeMs(bluetoothTimeMs)
- .build();
-
- if (mAnomalyUtils.getAnomalyAction(anomaly).isActionActive(anomaly)) {
- anomalies.add(anomaly);
- }
- }
- }
-
- return anomalies;
- }
-
- @VisibleForTesting
- public long getBluetoothUnoptimizedBgTimeMs(BatteryStats.Uid uid, long elapsedRealtimeMs) {
- BatteryStats.Timer timer = uid.getBluetoothUnoptimizedScanBackgroundTimer();
-
- return timer != null ? timer.getTotalDurationMsLocked(elapsedRealtimeMs) : 0;
- }
-
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetector.java b/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetector.java
deleted file mode 100644
index ffed1e8..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetector.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.checker;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.BatteryStats;
-import android.os.SystemClock;
-
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.Utils;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
-import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Check whether apps holding wakelock too long
- */
-public class WakeLockAnomalyDetector implements AnomalyDetector {
- private static final String TAG = "WakeLockAnomalyChecker";
- @VisibleForTesting
- BatteryUtils mBatteryUtils;
- @VisibleForTesting
- long mWakeLockThresholdMs;
- private PackageManager mPackageManager;
- private Context mContext;
- private AnomalyUtils mAnomalyUtils;
-
- public WakeLockAnomalyDetector(Context context) {
- this(context, new AnomalyDetectionPolicy(context), AnomalyUtils.getInstance(context));
- }
-
- @VisibleForTesting
- WakeLockAnomalyDetector(Context context, AnomalyDetectionPolicy policy,
- AnomalyUtils anomalyUtils) {
- mContext = context;
- mPackageManager = context.getPackageManager();
- mBatteryUtils = BatteryUtils.getInstance(context);
- mAnomalyUtils = anomalyUtils;
- mWakeLockThresholdMs = policy.wakeLockThreshold;
- }
-
- @Override
- public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper) {
- // Detect all apps if targetPackageName is null
- return detectAnomalies(batteryStatsHelper, null /* targetPackageName */);
- }
-
- @Override
- public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper,
- String targetPackageName) {
- final List<BatterySipper> batterySippers = batteryStatsHelper.getUsageList();
- final List<Anomaly> anomalies = new ArrayList<>();
- final long rawRealtime = SystemClock.elapsedRealtime();
- final int targetUid = mBatteryUtils.getPackageUid(targetPackageName);
-
- // Check the app one by one
- for (int i = 0, size = batterySippers.size(); i < size; i++) {
- final BatterySipper sipper = batterySippers.get(i);
- final BatteryStats.Uid uid = sipper.uidObj;
- if (uid == null
- || mBatteryUtils.shouldHideSipper(sipper)
- || (targetUid != BatteryUtils.UID_NULL && targetUid != uid.getUid())) {
- continue;
- }
-
- final long currentDurationMs = getCurrentDurationMs(uid, rawRealtime);
- final long backgroundDurationMs = getBackgroundTotalDurationMs(uid, rawRealtime);
-
- if (backgroundDurationMs > mWakeLockThresholdMs && currentDurationMs != 0) {
- final String packageName = mBatteryUtils.getPackageName(uid.getUid());
- final CharSequence displayName = Utils.getApplicationLabel(mContext,
- packageName);
-
- Anomaly anomaly = new Anomaly.Builder()
- .setUid(uid.getUid())
- .setType(Anomaly.AnomalyType.WAKE_LOCK)
- .setDisplayName(displayName)
- .setPackageName(packageName)
- .setWakeLockTimeMs(backgroundDurationMs)
- .build();
-
- if (mAnomalyUtils.getAnomalyAction(anomaly).isActionActive(anomaly)) {
- anomalies.add(anomaly);
- }
- }
- }
- return anomalies;
- }
-
- @VisibleForTesting
- long getCurrentDurationMs(BatteryStats.Uid uid, long elapsedRealtimeMs) {
- BatteryStats.Timer timer = uid.getAggregatedPartialWakelockTimer();
-
- return timer != null ? timer.getCurrentDurationMsLocked(elapsedRealtimeMs) : 0;
- }
-
- @VisibleForTesting
- long getBackgroundTotalDurationMs(BatteryStats.Uid uid, long elapsedRealtimeMs) {
- BatteryStats.Timer timer = uid.getAggregatedPartialWakelockTimer();
- BatteryStats.Timer subTimer = timer != null ? timer.getSubTimer() : null;
-
- return subTimer != null ? subTimer.getTotalDurationMsLocked(elapsedRealtimeMs) : 0;
- }
-}
diff --git a/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java b/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java
deleted file mode 100644
index f6c3aff..0000000
--- a/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetector.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.checker;
-
-import android.content.Context;
-import android.os.BatteryStats;
-import android.text.format.DateUtils;
-import android.util.ArrayMap;
-
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.Utils;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
-import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import androidx.annotation.VisibleForTesting;
-
-/**
- * Check whether apps has too many wakeup alarms
- */
-public class WakeupAlarmAnomalyDetector implements AnomalyDetector {
- private static final String TAG = "WakeupAlarmAnomalyDetector";
- @VisibleForTesting
- BatteryUtils mBatteryUtils;
- private long mWakeupAlarmThreshold;
- private Set<String> mWakeupBlacklistedTags;
- private Context mContext;
- private AnomalyUtils mAnomalyUtils;
-
- public WakeupAlarmAnomalyDetector(Context context) {
- this(context, new AnomalyDetectionPolicy(context), AnomalyUtils.getInstance(context));
- }
-
- @VisibleForTesting
- WakeupAlarmAnomalyDetector(Context context, AnomalyDetectionPolicy policy,
- AnomalyUtils anomalyUtils) {
- mContext = context;
- mBatteryUtils = BatteryUtils.getInstance(context);
- mAnomalyUtils = anomalyUtils;
- mWakeupAlarmThreshold = policy.wakeupAlarmThreshold;
- mWakeupBlacklistedTags = policy.wakeupBlacklistedTags;
- }
-
- @Override
- public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper) {
- // Detect all apps if targetPackageName is null
- return detectAnomalies(batteryStatsHelper, null /* targetPackageName */);
- }
-
- @Override
- public List<Anomaly> detectAnomalies(BatteryStatsHelper batteryStatsHelper,
- String targetPackageName) {
- final List<BatterySipper> batterySippers = batteryStatsHelper.getUsageList();
- final List<Anomaly> anomalies = new ArrayList<>();
- final double totalRunningHours = mBatteryUtils.calculateRunningTimeBasedOnStatsType(
- batteryStatsHelper, BatteryStats.STATS_SINCE_CHARGED)
- / (double) DateUtils.HOUR_IN_MILLIS;
- final int targetUid = mBatteryUtils.getPackageUid(targetPackageName);
-
- if (totalRunningHours >= 1) {
- for (int i = 0, size = batterySippers.size(); i < size; i++) {
- final BatterySipper sipper = batterySippers.get(i);
- final BatteryStats.Uid uid = sipper.uidObj;
- if (uid == null
- || mBatteryUtils.shouldHideSipper(sipper)
- || (targetUid != BatteryUtils.UID_NULL && targetUid != uid.getUid())) {
- continue;
- }
-
- final int wakeupAlarmCount = (int) (getWakeupAlarmCountFromUid(uid)
- / totalRunningHours);
- if (wakeupAlarmCount > mWakeupAlarmThreshold) {
- final String packageName = mBatteryUtils.getPackageName(uid.getUid());
- final CharSequence displayName = Utils.getApplicationLabel(mContext,
- packageName);
- final int targetSdkVersion = mBatteryUtils.getTargetSdkVersion(packageName);
-
- Anomaly anomaly = new Anomaly.Builder()
- .setUid(uid.getUid())
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setDisplayName(displayName)
- .setPackageName(packageName)
- .setTargetSdkVersion(targetSdkVersion)
- .setBackgroundRestrictionEnabled(
- mBatteryUtils.isBackgroundRestrictionEnabled(targetSdkVersion,
- uid.getUid(), packageName))
- .setWakeupAlarmCount(wakeupAlarmCount)
- .build();
-
- if (mAnomalyUtils.getAnomalyAction(anomaly).isActionActive(anomaly)) {
- anomalies.add(anomaly);
- }
- }
- }
- }
-
- return anomalies;
- }
-
- @VisibleForTesting
- int getWakeupAlarmCountFromUid(BatteryStats.Uid uid) {
- int wakeups = 0;
- final ArrayMap<String, ? extends BatteryStats.Uid.Pkg> packageStats
- = uid.getPackageStats();
- for (int ipkg = packageStats.size() - 1; ipkg >= 0; ipkg--) {
- final BatteryStats.Uid.Pkg ps = packageStats.valueAt(ipkg);
- final ArrayMap<String, ? extends BatteryStats.Counter> alarms =
- ps.getWakeupAlarmStats();
- for (Map.Entry<String, ? extends BatteryStats.Counter> alarm : alarms.entrySet()) {
- if (mWakeupBlacklistedTags != null
- && mWakeupBlacklistedTags.contains(alarm.getKey())) {
- continue;
- }
- int count = alarm.getValue().getCountLocked(BatteryStats.STATS_SINCE_CHARGED);
- wakeups += count;
- }
- }
-
- return wakeups;
- }
-
-}
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java
index d5f8794..bc332b6 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java
@@ -21,8 +21,6 @@
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -62,7 +60,7 @@
String UID = "uid";
/**
* The type of the anomaly app
- * @see Anomaly.AnomalyType
+ * @see StatsManagerConfig.AnomalyType
*/
String ANOMALY_TYPE = "anomaly_type";
/**
diff --git a/src/com/android/settings/fuelgauge/batterytip/AppInfo.java b/src/com/android/settings/fuelgauge/batterytip/AppInfo.java
index 34aefd6..73d3b86 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AppInfo.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AppInfo.java
@@ -21,8 +21,6 @@
import android.text.TextUtils;
import android.util.ArraySet;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
import java.util.Objects;
import androidx.annotation.VisibleForTesting;
@@ -34,7 +32,7 @@
public final String packageName;
/**
* Anomaly type of the app
- * @see Anomaly.AnomalyType
+ * @see StatsManagerConfig.AnomalyType
*/
public final ArraySet<Integer> anomalyTypes;
public final long screenOnTimeMs;
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java b/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java
index 2411db4..910b368 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java
@@ -40,6 +40,8 @@
import java.util.List;
import java.util.Map;
+import androidx.annotation.VisibleForTesting;
+
/**
* Database manager for battery data. Now it only contains anomaly data stored in {@link AppInfo}.
*
@@ -62,6 +64,11 @@
return sSingleton;
}
+ @VisibleForTesting(otherwise = VisibleForTesting.NONE)
+ public static void setUpForTest(BatteryDatabaseManager batteryDatabaseManager) {
+ sSingleton = batteryDatabaseManager;
+ }
+
/**
* Insert an anomaly log to database.
*
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
index 4b08626..66d9f2c 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge.batterytip;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -39,6 +38,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java
index 22c90e3..4bd8cd7 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicy.java
@@ -40,6 +40,7 @@
private static final String KEY_HIGH_USAGE_PERIOD_MS = "high_usage_period_ms";
private static final String KEY_HIGH_USAGE_BATTERY_DRAINING = "high_usage_battery_draining";
private static final String KEY_APP_RESTRICTION_ENABLED = "app_restriction_enabled";
+ private static final String KEY_APP_RESTRICTION_ACTIVE_HOUR = "app_restriction_active_hour";
private static final String KEY_REDUCED_BATTERY_ENABLED = "reduced_battery_enabled";
private static final String KEY_REDUCED_BATTERY_PERCENT = "reduced_battery_percent";
private static final String KEY_LOW_BATTERY_ENABLED = "low_battery_enabled";
@@ -119,6 +120,15 @@
public final boolean appRestrictionEnabled;
/**
+ * Period(hour) to show anomaly apps. If it is 24 hours, it means only show anomaly apps
+ * happened in last 24 hours.
+ *
+ * @see Settings.Global#BATTERY_TIP_CONSTANTS
+ * @see #KEY_APP_RESTRICTION_ACTIVE_HOUR
+ */
+ public final int appRestrictionActiveHour;
+
+ /**
* {@code true} if reduced battery tip is enabled
*
* @see Settings.Global#BATTERY_TIP_CONSTANTS
@@ -228,6 +238,7 @@
Duration.ofHours(2).toMillis());
highUsageBatteryDraining = mParser.getInt(KEY_HIGH_USAGE_BATTERY_DRAINING, 25);
appRestrictionEnabled = mParser.getBoolean(KEY_APP_RESTRICTION_ENABLED, true);
+ appRestrictionActiveHour = mParser.getInt(KEY_APP_RESTRICTION_ACTIVE_HOUR, 24);
reducedBatteryEnabled = mParser.getBoolean(KEY_REDUCED_BATTERY_ENABLED, false);
reducedBatteryPercent = mParser.getInt(KEY_REDUCED_BATTERY_PERCENT, 50);
lowBatteryEnabled = mParser.getBoolean(KEY_LOW_BATTERY_ENABLED, true);
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
index df6fa5a..8debf6b 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
@@ -34,6 +34,8 @@
import com.android.settings.fuelgauge.batterytip.actions.RestrictAppAction;
import com.android.settings.fuelgauge.batterytip.actions.SmartBatteryAction;
import com.android.settings.fuelgauge.batterytip.actions.UnrestrictAppAction;
+import com.android.settings.fuelgauge.batterytip.tips.AppLabelPredicate;
+import com.android.settings.fuelgauge.batterytip.tips.AppRestrictionPredicate;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
@@ -126,4 +128,17 @@
statsManager.setBroadcastSubscriber(pendingIntent,
StatsManagerConfig.ANOMALY_CONFIG_KEY, StatsManagerConfig.SUBSCRIBER_ID);
}
+
+ /**
+ * Detect and return anomaly apps after {@code timeAfterMs}
+ */
+ public static List<AppInfo> detectAnomalies(Context context, long timeAfterMs) {
+ final List<AppInfo> highUsageApps = BatteryDatabaseManager.getInstance(context)
+ .queryAllAnomalies(timeAfterMs, AnomalyDatabaseHelper.State.NEW);
+ // Remove it if it doesn't have label or been restricted
+ highUsageApps.removeIf(AppLabelPredicate.getInstance(context)
+ .or(AppRestrictionPredicate.getInstance(context)));
+
+ return highUsageApps;
+ }
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java
index 312eeb8..e6c0837 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java
@@ -23,6 +23,7 @@
import com.android.settings.fuelgauge.batterytip.AppInfo;
import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
+import com.android.settings.fuelgauge.batterytip.BatteryTipUtils;
import com.android.settings.fuelgauge.batterytip.tips.AppLabelPredicate;
import com.android.settings.fuelgauge.batterytip.tips.AppRestrictionPredicate;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
@@ -30,6 +31,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import androidx.annotation.VisibleForTesting;
@@ -52,8 +54,8 @@
mContext = context;
mPolicy = policy;
mBatteryDatabaseManager = BatteryDatabaseManager.getInstance(context);
- mAppRestrictionPredicate = new AppRestrictionPredicate(context);
- mAppLabelPredicate = new AppLabelPredicate(context);
+ mAppRestrictionPredicate = AppRestrictionPredicate.getInstance(context);
+ mAppLabelPredicate = AppLabelPredicate.getInstance(context);
}
@Override
@@ -62,12 +64,10 @@
return getFakeData();
}
if (mPolicy.appRestrictionEnabled) {
- // TODO(b/72385333): hook up the query timestamp to server side
- final long oneDayBeforeMs = System.currentTimeMillis() - DateUtils.DAY_IN_MILLIS;
- final List<AppInfo> highUsageApps = mBatteryDatabaseManager.queryAllAnomalies(
- oneDayBeforeMs, AnomalyDatabaseHelper.State.NEW);
- // Remove it if it doesn't have label or been restricted
- highUsageApps.removeIf(mAppLabelPredicate.or(mAppRestrictionPredicate));
+ final long oneDayBeforeMs = System.currentTimeMillis()
+ - TimeUnit.HOURS.toMillis(mPolicy.appRestrictionActiveHour);
+ final List<AppInfo> highUsageApps = BatteryTipUtils.detectAnomalies(mContext,
+ oneDayBeforeMs);
if (!highUsageApps.isEmpty()) {
// If there are new anomalies, show them
return new RestrictAppTip(BatteryTip.StateType.NEW, highUsageApps);
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/AppLabelPredicate.java b/src/com/android/settings/fuelgauge/batterytip/tips/AppLabelPredicate.java
index 13a2452..1444b12 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/AppLabelPredicate.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/AppLabelPredicate.java
@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge.batterytip.tips;
-import android.app.AppOpsManager;
import android.content.Context;
import com.android.settings.Utils;
@@ -28,12 +27,20 @@
* {@link Predicate} for {@link AppInfo} to check whether it has label
*/
public class AppLabelPredicate implements Predicate<AppInfo> {
- private Context mContext;
- private AppOpsManager mAppOpsManager;
- public AppLabelPredicate(Context context) {
+ private static AppLabelPredicate sInstance;
+ private Context mContext;
+
+ public static AppLabelPredicate getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new AppLabelPredicate(context.getApplicationContext());
+ }
+
+ return sInstance;
+ }
+
+ private AppLabelPredicate(Context context) {
mContext = context;
- mAppOpsManager = context.getSystemService(AppOpsManager.class);
}
@Override
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/AppRestrictionPredicate.java b/src/com/android/settings/fuelgauge/batterytip/tips/AppRestrictionPredicate.java
index 3650fe3..43a4d90 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/AppRestrictionPredicate.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/AppRestrictionPredicate.java
@@ -27,9 +27,19 @@
* {@link Predicate} for {@link AppInfo} to check whether it is restricted.
*/
public class AppRestrictionPredicate implements Predicate<AppInfo> {
+
+ private static AppRestrictionPredicate sInstance;
private AppOpsManager mAppOpsManager;
- public AppRestrictionPredicate(Context context) {
+ public static AppRestrictionPredicate getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new AppRestrictionPredicate(context.getApplicationContext());
+ }
+
+ return sInstance;
+ }
+
+ private AppRestrictionPredicate(Context context) {
mAppOpsManager = context.getSystemService(AppOpsManager.class);
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java
index 61a1157..1d5143f 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTip.java
@@ -16,7 +16,6 @@
package com.android.settings.fuelgauge.batterytip.tips;
-import android.content.ContentResolver;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
index 8a2d86d..0d91c74 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
@@ -112,7 +112,7 @@
super.sanityCheck(context);
// Set it invisible if there is no valid app
- mRestrictAppList.removeIf(new AppLabelPredicate(context));
+ mRestrictAppList.removeIf(AppLabelPredicate.getInstance(context));
if (mRestrictAppList.isEmpty()) {
mState = StateType.INVISIBLE;
}
diff --git a/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java b/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
index 1a7fe22..388e16c 100644
--- a/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
+++ b/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
@@ -17,7 +17,6 @@
package com.android.settings.inputmethod;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -43,6 +42,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import androidx.appcompat.app.AlertDialog;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.AsyncTaskLoader;
import androidx.loader.content.Loader;
diff --git a/src/com/android/settings/inputmethod/SpellCheckersSettings.java b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
index 1a828ce..c8eb109 100644
--- a/src/com/android/settings/inputmethod/SpellCheckersSettings.java
+++ b/src/com/android/settings/inputmethod/SpellCheckersSettings.java
@@ -16,7 +16,6 @@
package com.android.settings.inputmethod;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ApplicationInfo;
@@ -35,6 +34,7 @@
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.SwitchBar.OnSwitchChangeListener;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.Preference.OnPreferenceClickListener;
diff --git a/src/com/android/settings/language/PhoneLanguagePreferenceController.java b/src/com/android/settings/language/PhoneLanguagePreferenceController.java
index 0f9b419..8045fc0 100644
--- a/src/com/android/settings/language/PhoneLanguagePreferenceController.java
+++ b/src/com/android/settings/language/PhoneLanguagePreferenceController.java
@@ -75,7 +75,7 @@
new SubSettingLauncher(mContext)
.setDestination(LocaleListEditor.class.getName())
.setSourceMetricsCategory(MetricsProto.MetricsEvent.SETTINGS_LANGUAGE_CATEGORY)
- .setTitleRes(R.string.pref_title_lang_selection)
+ .setTitleRes(R.string.language_picker_title)
.launch();
return true;
}
diff --git a/src/com/android/settings/localepicker/LocaleListEditor.java b/src/com/android/settings/localepicker/LocaleListEditor.java
index 87c19dd..dada1c8 100644
--- a/src/com/android/settings/localepicker/LocaleListEditor.java
+++ b/src/com/android/settings/localepicker/LocaleListEditor.java
@@ -18,8 +18,9 @@
import static android.os.UserManager.DISALLOW_CONFIG_LOCALE;
-import android.app.AlertDialog;
+import android.app.Activity;
import android.content.DialogInterface;
+import android.content.Intent;
import android.os.Bundle;
import android.os.LocaleList;
import android.view.LayoutInflater;
@@ -40,18 +41,19 @@
import java.util.List;
import java.util.Locale;
-import androidx.fragment.app.FragmentTransaction;
+import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;
/**
* Drag-and-drop editor for the user-ordered locale lists.
*/
-public class LocaleListEditor extends RestrictedSettingsFragment
- implements LocalePickerWithRegion.LocaleSelectedListener {
+public class LocaleListEditor extends RestrictedSettingsFragment {
+ protected static final String INTENT_LOCALE_KEY = "localeInfo";
private static final String CFGKEY_REMOVE_MODE = "localeRemoveMode";
private static final String CFGKEY_REMOVE_DIALOG = "showingLocaleRemoveDialog";
private static final int MENU_ID_REMOVE = Menu.FIRST + 1;
+ private static final int REQUEST_LOCALE_PICKER = 0;
private LocaleDragAndDropAdapter mAdapter;
private Menu mMenu;
@@ -150,6 +152,19 @@
return super.onOptionsItemSelected(menuItem);
}
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_LOCALE_PICKER && resultCode == Activity.RESULT_OK
+ && data != null) {
+ final LocaleStore.LocaleInfo locale =
+ (LocaleStore.LocaleInfo) data.getSerializableExtra(
+ INTENT_LOCALE_KEY);
+ mAdapter.addLocale(locale);
+ updateVisibilityOfRemoveMenu();
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
private void setRemoveMode(boolean mRemoveMode) {
this.mRemoveMode = mRemoveMode;
mAdapter.setRemoveMode(mRemoveMode);
@@ -267,24 +282,13 @@
mAddLanguage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- final LocalePickerWithRegion selector = LocalePickerWithRegion.createLanguagePicker(
- getContext(), LocaleListEditor.this, false /* translate only */);
- getFragmentManager()
- .beginTransaction()
- .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
- .replace(getId(), selector)
- .addToBackStack("localeListEditor")
- .commit();
+ final Intent intent = new Intent(getActivity(),
+ LocalePickerWithRegionActivity.class);
+ startActivityForResult(intent, REQUEST_LOCALE_PICKER);
}
});
}
- @Override
- public void onLocaleSelected(LocaleStore.LocaleInfo locale) {
- mAdapter.addLocale(locale);
- updateVisibilityOfRemoveMenu();
- }
-
// Hide the "Remove" menu if there is only one locale in the list, show it otherwise
// This is called when the menu is first created, and then one add / remove locale
private void updateVisibilityOfRemoveMenu() {
diff --git a/src/com/android/settings/localepicker/LocalePickerWithRegion.java b/src/com/android/settings/localepicker/LocalePickerWithRegion.java
deleted file mode 100644
index e8a91bc..0000000
--- a/src/com/android/settings/localepicker/LocalePickerWithRegion.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.localepicker;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.os.LocaleList;
-import android.text.TextUtils;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.SearchView;
-
-import com.android.internal.R;
-import com.android.internal.app.LocaleHelper;
-import com.android.internal.app.LocalePicker;
-import com.android.internal.app.LocaleStore;
-import com.android.internal.app.SuggestedLocaleAdapter;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.fragment.app.ListFragment;
-
-/**
- * A two-step locale picker. It shows a language, then a country.
- *
- * <p>It shows suggestions at the top, then the rest of the locales.
- * Allows the user to search for locales using both their native name and their name in the
- * default locale.</p>
- */
-public class LocalePickerWithRegion extends ListFragment implements SearchView.OnQueryTextListener {
- private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
-
- private SuggestedLocaleAdapter mAdapter;
- private LocaleSelectedListener mListener;
- private Set<LocaleStore.LocaleInfo> mLocaleList;
- private LocaleStore.LocaleInfo mParentLocale;
- private boolean mTranslatedOnly = false;
- private SearchView mSearchView = null;
- private CharSequence mPreviousSearch = null;
- private boolean mPreviousSearchHadFocus = false;
- private int mFirstVisiblePosition = 0;
- private int mTopDistance = 0;
-
- /**
- * Other classes can register to be notified when a locale was selected.
- *
- * <p>This is the mechanism to "return" the result of the selection.</p>
- */
- public interface LocaleSelectedListener {
- /**
- * The classes that want to retrieve the locale picked should implement this method.
- * @param locale the locale picked.
- */
- void onLocaleSelected(LocaleStore.LocaleInfo locale);
- }
-
- private static LocalePickerWithRegion createCountryPicker(Context context,
- LocaleSelectedListener listener, LocaleStore.LocaleInfo parent,
- boolean translatedOnly) {
- LocalePickerWithRegion
- localePicker = new LocalePickerWithRegion();
- boolean shouldShowTheList = localePicker.setListener(context, listener, parent,
- translatedOnly);
- return shouldShowTheList ? localePicker : null;
- }
-
- public static LocalePickerWithRegion createLanguagePicker(Context context,
- LocaleSelectedListener listener, boolean translatedOnly) {
- LocalePickerWithRegion
- localePicker = new LocalePickerWithRegion();
- localePicker.setListener(context, listener, /* parent */ null, translatedOnly);
- return localePicker;
- }
-
- /**
- * Sets the listener and initializes the locale list.
- *
- * <p>Returns true if we need to show the list, false if not.</p>
- *
- * <p>Can return false because of an error, trying to show a list of countries,
- * but no parent locale was provided.</p>
- *
- * <p>It can also return false if the caller tries to show the list in country mode and
- * there is only one country available (i.e. Japanese => Japan).
- * In this case we don't even show the list, we call the listener with that locale,
- * "pretending" it was selected, and return false.</p>
- */
- private boolean setListener(Context context, LocaleSelectedListener listener,
- LocaleStore.LocaleInfo parent, boolean translatedOnly) {
- this.mParentLocale = parent;
- this.mListener = listener;
- this.mTranslatedOnly = translatedOnly;
- setRetainInstance(true);
-
- final HashSet<String> langTagsToIgnore = new HashSet<>();
- if (!translatedOnly) {
- final LocaleList userLocales = LocalePicker.getLocales();
- final String[] langTags = userLocales.toLanguageTags().split(",");
- Collections.addAll(langTagsToIgnore, langTags);
- }
-
- if (parent != null) {
- mLocaleList = LocaleStore.getLevelLocales(context,
- langTagsToIgnore, parent, translatedOnly);
- if (mLocaleList.size() <= 1) {
- if (listener != null && (mLocaleList.size() == 1)) {
- listener.onLocaleSelected(mLocaleList.iterator().next());
- }
- return false;
- }
- } else {
- mLocaleList = LocaleStore.getLevelLocales(context, langTagsToIgnore,
- null /* no parent */, translatedOnly);
- }
-
- return true;
- }
-
- private void returnToParentFrame() {
- getFragmentManager().popBackStack(PARENT_FRAGMENT_NAME,
- FragmentManager.POP_BACK_STACK_INCLUSIVE);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setHasOptionsMenu(true);
-
- if (mLocaleList == null) {
- // The fragment was killed and restored by the FragmentManager.
- // At this point we have no data, no listener. Just return, to prevend a NPE.
- // Fixes b/28748150. Created b/29400003 for a cleaner solution.
- returnToParentFrame();
- return;
- }
-
- final boolean countryMode = mParentLocale != null;
- final Locale sortingLocale = countryMode ? mParentLocale.getLocale() : Locale.getDefault();
- mAdapter = new SuggestedLocaleAdapter(mLocaleList, countryMode);
- final LocaleHelper.LocaleInfoComparator comp =
- new LocaleHelper.LocaleInfoComparator(sortingLocale, countryMode);
- mAdapter.sort(comp);
- setListAdapter(mAdapter);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- int id = menuItem.getItemId();
- switch (id) {
- case android.R.id.home:
- getFragmentManager().popBackStack();
- return true;
- }
- return super.onOptionsItemSelected(menuItem);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- if (mParentLocale != null) {
- getActivity().setTitle(mParentLocale.getFullNameNative());
- } else {
- getActivity().setTitle(R.string.language_selection_title);
- }
-
- getListView().requestFocus();
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- // Save search status
- if (mSearchView != null) {
- mPreviousSearchHadFocus = mSearchView.hasFocus();
- mPreviousSearch = mSearchView.getQuery();
- } else {
- mPreviousSearchHadFocus = false;
- mPreviousSearch = null;
- }
-
- // Save scroll position
- final ListView list = getListView();
- final View firstChild = list.getChildAt(0);
- mFirstVisiblePosition = list.getFirstVisiblePosition();
- mTopDistance = (firstChild == null) ? 0 : (firstChild.getTop() - list.getPaddingTop());
- }
-
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
- final LocaleStore.LocaleInfo locale =
- (LocaleStore.LocaleInfo) getListAdapter().getItem(position);
-
- if (locale.getParent() != null) {
- if (mListener != null) {
- mListener.onLocaleSelected(locale);
- }
- returnToParentFrame();
- } else {
- LocalePickerWithRegion
- selector = LocalePickerWithRegion.createCountryPicker(
- getContext(), mListener, locale, mTranslatedOnly /* translate only */);
- if (selector != null) {
- getFragmentManager().beginTransaction()
- .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
- .replace(getId(), selector).addToBackStack(null)
- .commit();
- } else {
- returnToParentFrame();
- }
- }
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (mParentLocale == null) {
- inflater.inflate(R.menu.language_selection_list, menu);
-
- final MenuItem searchMenuItem = menu.findItem(R.id.locale_search_menu);
- mSearchView = (SearchView) searchMenuItem.getActionView();
-
- mSearchView.setQueryHint(getText(R.string.search_language_hint));
- mSearchView.setOnQueryTextListener(this);
-
- // Restore previous search status
- if (!TextUtils.isEmpty(mPreviousSearch)) {
- searchMenuItem.expandActionView();
- mSearchView.setIconified(false);
- mSearchView.setActivated(true);
- if (mPreviousSearchHadFocus) {
- mSearchView.requestFocus();
- }
- mSearchView.setQuery(mPreviousSearch, true /* submit */);
- } else {
- mSearchView.setQuery(null, false /* submit */);
- }
-
- // Restore previous scroll position
- getListView().setSelectionFromTop(mFirstVisiblePosition, mTopDistance);
- }
- }
-
- @Override
- public boolean onQueryTextSubmit(String query) {
- return false;
- }
-
- @Override
- public boolean onQueryTextChange(String newText) {
- if (mAdapter != null) {
- mAdapter.getFilter().filter(newText);
- }
- return false;
- }
-}
diff --git a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
new file mode 100644
index 0000000..6ddcf23
--- /dev/null
+++ b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.localepicker;
+
+import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.MenuItem;
+
+import com.android.internal.app.LocalePickerWithRegion;
+import com.android.internal.app.LocaleStore;
+
+public class LocalePickerWithRegionActivity extends Activity
+ implements LocalePickerWithRegion.LocaleSelectedListener {
+
+ private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ final LocalePickerWithRegion selector = LocalePickerWithRegion.createLanguagePicker(
+ this, LocalePickerWithRegionActivity.this, false /* translate only */);
+ getFragmentManager()
+ .beginTransaction()
+ .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
+ .replace(android.R.id.content, selector)
+ .addToBackStack(PARENT_FRAGMENT_NAME)
+ .commit();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ handleBackPressed();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onLocaleSelected(LocaleStore.LocaleInfo locale) {
+ final Intent intent = new Intent();
+ intent.putExtra(LocaleListEditor.INTENT_LOCALE_KEY, locale);
+ setResult(RESULT_OK, intent);
+ finish();
+ }
+
+ @Override
+ public void onBackPressed() {
+ handleBackPressed();
+ }
+
+ private void handleBackPressed() {
+ if (getFragmentManager().getBackStackEntryCount() > 1) {
+ super.onBackPressed();
+ } else {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ }
+}
+
diff --git a/src/com/android/settings/location/AppSettingsInjector.java b/src/com/android/settings/location/AppSettingsInjector.java
new file mode 100644
index 0000000..6b79a7e
--- /dev/null
+++ b/src/com/android/settings/location/AppSettingsInjector.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.location;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import androidx.preference.Preference;
+
+import com.android.settings.widget.AppPreference;
+import com.android.settings.widget.RestrictedAppPreference;
+import com.android.settingslib.location.InjectedSetting;
+import com.android.settingslib.location.SettingsInjector;
+
+import java.util.List;
+
+/**
+ * Adds the preferences specified by the {@link InjectedSetting} objects to a preference group.
+ */
+public class AppSettingsInjector extends SettingsInjector {
+
+ public AppSettingsInjector(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected Preference createPreference(Context prefContext, InjectedSetting setting) {
+ return TextUtils.isEmpty(setting.userRestriction)
+ ? new AppPreference(prefContext)
+ : new RestrictedAppPreference(prefContext, setting.userRestriction);
+ }
+}
diff --git a/src/com/android/settings/location/InjectedSetting.java b/src/com/android/settings/location/InjectedSetting.java
deleted file mode 100644
index 4877cb4..0000000
--- a/src/com/android/settings/location/InjectedSetting.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.location;
-
-import android.content.Intent;
-import android.os.UserHandle;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.internal.annotations.Immutable;
-
-import java.util.Objects;
-
-/**
- * Specifies a setting that is being injected into Settings > Location > Location services.
- *
- * @see android.location.SettingInjectorService
- */
-@Immutable
-class InjectedSetting {
-
- /**
- * Package for the subclass of {@link android.location.SettingInjectorService} and for the
- * settings activity.
- */
- public final String packageName;
-
- /**
- * Class name for the subclass of {@link android.location.SettingInjectorService} that
- * specifies dynamic values for the location setting.
- */
- public final String className;
-
- /**
- * The {@link androidx.preference.Preference#getTitle()} value.
- */
- public final String title;
-
- /**
- * The {@link androidx.preference.Preference#getIcon()} value.
- */
- public final int iconId;
-
- /**
- * The user/profile associated with this setting (e.g. managed profile)
- */
- public final UserHandle mUserHandle;
-
- /**
- * The activity to launch to allow the user to modify the settings value. Assumed to be in the
- * {@link #packageName} package.
- */
- public final String settingsActivity;
-
- /**
- * The user restriction associated with this setting.
- */
- public final String userRestriction;
-
- private InjectedSetting(Builder builder) {
- this.packageName = builder.mPackageName;
- this.className = builder.mClassName;
- this.title = builder.mTitle;
- this.iconId = builder.mIconId;
- this.mUserHandle = builder.mUserHandle;
- this.settingsActivity = builder.mSettingsActivity;
- this.userRestriction = builder.mUserRestriction;
- }
-
- @Override
- public String toString() {
- return "InjectedSetting{" +
- "mPackageName='" + packageName + '\'' +
- ", mClassName='" + className + '\'' +
- ", label=" + title +
- ", iconId=" + iconId +
- ", userId=" + mUserHandle.getIdentifier() +
- ", settingsActivity='" + settingsActivity + '\'' +
- ", userRestriction='" + userRestriction +
- '}';
- }
-
- /**
- * Returns the intent to start the {@link #className} service.
- */
- public Intent getServiceIntent() {
- Intent intent = new Intent();
- intent.setClassName(packageName, className);
- return intent;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof InjectedSetting)) return false;
-
- InjectedSetting that = (InjectedSetting) o;
-
- return Objects.equals(packageName, that.packageName)
- && Objects.equals(className, that.className)
- && Objects.equals(title, that.title)
- && Objects.equals(iconId, that.iconId)
- && Objects.equals(mUserHandle, that.mUserHandle)
- && Objects.equals(settingsActivity, that.settingsActivity)
- && Objects.equals(userRestriction, that.userRestriction);
- }
-
- @Override
- public int hashCode() {
- int result = packageName.hashCode();
- result = 31 * result + className.hashCode();
- result = 31 * result + title.hashCode();
- result = 31 * result + iconId;
- result = 31 * result + (mUserHandle == null ? 0 : mUserHandle.hashCode());
- result = 31 * result + settingsActivity.hashCode();
- result = 31 * result + (userRestriction == null ? 0 : userRestriction.hashCode());
- return result;
- }
-
- public static class Builder {
- private String mPackageName;
- private String mClassName;
- private String mTitle;
- private int mIconId;
- private UserHandle mUserHandle;
- private String mSettingsActivity;
- private String mUserRestriction;
-
- public Builder setPackageName(String packageName) {
- mPackageName = packageName;
- return this;
- }
-
- public Builder setClassName(String className) {
- mClassName = className;
- return this;
- }
-
- public Builder setTitle(String title) {
- mTitle = title;
- return this;
- }
-
- public Builder setIconId(int iconId) {
- mIconId = iconId;
- return this;
- }
-
- public Builder setUserHandle(UserHandle userHandle) {
- mUserHandle = userHandle;
- return this;
- }
-
- public Builder setSettingsActivity(String settingsActivity) {
- mSettingsActivity = settingsActivity;
- return this;
- }
-
- public Builder setUserRestriction(String userRestriction) {
- mUserRestriction = userRestriction;
- return this;
- }
-
- public InjectedSetting build() {
- if (mPackageName == null || mClassName == null || TextUtils.isEmpty(mTitle)
- || TextUtils.isEmpty(mSettingsActivity)) {
- if (Log.isLoggable(SettingsInjector.TAG, Log.WARN)) {
- Log.w(SettingsInjector.TAG, "Illegal setting specification: package="
- + mPackageName + ", class=" + mClassName
- + ", title=" + mTitle + ", settingsActivity=" + mSettingsActivity);
- }
- return null;
- }
- return new InjectedSetting(this);
- }
- }
-}
diff --git a/src/com/android/settings/location/LocationServicePreferenceController.java b/src/com/android/settings/location/LocationServicePreferenceController.java
index 67ec152..035faad 100644
--- a/src/com/android/settings/location/LocationServicePreferenceController.java
+++ b/src/com/android/settings/location/LocationServicePreferenceController.java
@@ -47,19 +47,19 @@
private PreferenceCategory mCategoryLocationServices;
private final LocationSettings mFragment;
- private final SettingsInjector mInjector;
+ private final AppSettingsInjector mInjector;
/** Receives UPDATE_INTENT */
@VisibleForTesting
BroadcastReceiver mInjectedSettingsReceiver;
public LocationServicePreferenceController(Context context, LocationSettings fragment,
Lifecycle lifecycle) {
- this(context, fragment, lifecycle, new SettingsInjector(context));
+ this(context, fragment, lifecycle, new AppSettingsInjector(context));
}
@VisibleForTesting
LocationServicePreferenceController(Context context, LocationSettings fragment,
- Lifecycle lifecycle, SettingsInjector injector) {
+ Lifecycle lifecycle, AppSettingsInjector injector) {
super(context, lifecycle);
mFragment = fragment;
mInjector = injector;
diff --git a/src/com/android/settings/location/SettingsInjector.java b/src/com/android/settings/location/SettingsInjector.java
deleted file mode 100644
index 1206e85..0000000
--- a/src/com/android/settings/location/SettingsInjector.java
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.location;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageItemInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
-import android.graphics.drawable.Drawable;
-import android.location.SettingInjectorService;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.SystemClock;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.util.IconDrawableFactory;
-import android.util.Log;
-import android.util.Xml;
-
-import com.android.settings.widget.AppPreference;
-import com.android.settings.widget.RestrictedAppPreference;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import androidx.preference.Preference;
-
-/**
- * Adds the preferences specified by the {@link InjectedSetting} objects to a preference group.
- *
- * Duplicates some code from {@link android.content.pm.RegisteredServicesCache}. We do not use that
- * class directly because it is not a good match for our use case: we do not need the caching, and
- * so do not want the additional resource hit at app install/upgrade time; and we would have to
- * suppress the tie-breaking between multiple services reporting settings with the same name.
- * Code-sharing would require extracting {@link
- * android.content.pm.RegisteredServicesCache#parseServiceAttributes(android.content.res.Resources,
- * String, android.util.AttributeSet)} into an interface, which didn't seem worth it.
- */
-class SettingsInjector {
- static final String TAG = "SettingsInjector";
-
- /**
- * If reading the status of a setting takes longer than this, we go ahead and start reading
- * the next setting.
- */
- private static final long INJECTED_STATUS_UPDATE_TIMEOUT_MILLIS = 1000;
-
- /**
- * {@link Message#what} value for starting to load status values
- * in case we aren't already in the process of loading them.
- */
- private static final int WHAT_RELOAD = 1;
-
- /**
- * {@link Message#what} value sent after receiving a status message.
- */
- private static final int WHAT_RECEIVED_STATUS = 2;
-
- /**
- * {@link Message#what} value sent after the timeout waiting for a status message.
- */
- private static final int WHAT_TIMEOUT = 3;
-
- private final Context mContext;
-
- /**
- * The settings that were injected
- */
- private final Set<Setting> mSettings;
-
- private final Handler mHandler;
-
- public SettingsInjector(Context context) {
- mContext = context;
- mSettings = new HashSet<Setting>();
- mHandler = new StatusLoadingHandler();
- }
-
- /**
- * Returns a list for a profile with one {@link InjectedSetting} object for each
- * {@link android.app.Service} that responds to
- * {@link SettingInjectorService#ACTION_SERVICE_INTENT} and provides the expected setting
- * metadata.
- *
- * Duplicates some code from {@link android.content.pm.RegisteredServicesCache}.
- *
- * TODO: unit test
- */
- private List<InjectedSetting> getSettings(final UserHandle userHandle) {
- PackageManager pm = mContext.getPackageManager();
- Intent intent = new Intent(SettingInjectorService.ACTION_SERVICE_INTENT);
-
- final int profileId = userHandle.getIdentifier();
- List<ResolveInfo> resolveInfos =
- pm.queryIntentServicesAsUser(intent, PackageManager.GET_META_DATA, profileId);
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Found services for profile id " + profileId + ": " + resolveInfos);
- }
- List<InjectedSetting> settings = new ArrayList<InjectedSetting>(resolveInfos.size());
- for (ResolveInfo resolveInfo : resolveInfos) {
- try {
- InjectedSetting setting = parseServiceInfo(resolveInfo, userHandle, pm);
- if (setting == null) {
- Log.w(TAG, "Unable to load service info " + resolveInfo);
- } else {
- settings.add(setting);
- }
- } catch (XmlPullParserException e) {
- Log.w(TAG, "Unable to load service info " + resolveInfo, e);
- } catch (IOException e) {
- Log.w(TAG, "Unable to load service info " + resolveInfo, e);
- }
- }
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Loaded settings for profile id " + profileId + ": " + settings);
- }
-
- return settings;
- }
-
- /**
- * Returns the settings parsed from the attributes of the
- * {@link SettingInjectorService#META_DATA_NAME} tag, or null.
- *
- * Duplicates some code from {@link android.content.pm.RegisteredServicesCache}.
- */
- private static InjectedSetting parseServiceInfo(ResolveInfo service, UserHandle userHandle,
- PackageManager pm) throws XmlPullParserException, IOException {
-
- ServiceInfo si = service.serviceInfo;
- ApplicationInfo ai = si.applicationInfo;
-
- if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "Ignoring attempt to inject setting from app not in system image: "
- + service);
- return null;
- }
- }
-
- XmlResourceParser parser = null;
- try {
- parser = si.loadXmlMetaData(pm, SettingInjectorService.META_DATA_NAME);
- if (parser == null) {
- throw new XmlPullParserException("No " + SettingInjectorService.META_DATA_NAME
- + " meta-data for " + service + ": " + si);
- }
-
- AttributeSet attrs = Xml.asAttributeSet(parser);
-
- int type;
- while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
- && type != XmlPullParser.START_TAG) {
- }
-
- String nodeName = parser.getName();
- if (!SettingInjectorService.ATTRIBUTES_NAME.equals(nodeName)) {
- throw new XmlPullParserException("Meta-data does not start with "
- + SettingInjectorService.ATTRIBUTES_NAME + " tag");
- }
-
- Resources res = pm.getResourcesForApplicationAsUser(si.packageName,
- userHandle.getIdentifier());
- return parseAttributes(si.packageName, si.name, userHandle, res, attrs);
- } catch (PackageManager.NameNotFoundException e) {
- throw new XmlPullParserException(
- "Unable to load resources for package " + si.packageName);
- } finally {
- if (parser != null) {
- parser.close();
- }
- }
- }
-
- /**
- * Returns an immutable representation of the static attributes for the setting, or null.
- */
- private static InjectedSetting parseAttributes(String packageName, String className,
- UserHandle userHandle, Resources res, AttributeSet attrs) {
-
- TypedArray sa = res.obtainAttributes(attrs, android.R.styleable.SettingInjectorService);
- try {
- // Note that to help guard against malicious string injection, we do not allow dynamic
- // specification of the label (setting title)
- final String title = sa.getString(android.R.styleable.SettingInjectorService_title);
- final int iconId =
- sa.getResourceId(android.R.styleable.SettingInjectorService_icon, 0);
- final String settingsActivity =
- sa.getString(android.R.styleable.SettingInjectorService_settingsActivity);
- final String userRestriction = sa.getString(
- android.R.styleable.SettingInjectorService_userRestriction);
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "parsed title: " + title + ", iconId: " + iconId
- + ", settingsActivity: " + settingsActivity);
- }
- return new InjectedSetting.Builder()
- .setPackageName(packageName)
- .setClassName(className)
- .setTitle(title)
- .setIconId(iconId)
- .setUserHandle(userHandle)
- .setSettingsActivity(settingsActivity)
- .setUserRestriction(userRestriction)
- .build();
- } finally {
- sa.recycle();
- }
- }
-
- /**
- * Gets a list of preferences that other apps have injected.
- *
- * @param profileId Identifier of the user/profile to obtain the injected settings for or
- * UserHandle.USER_CURRENT for all profiles associated with current user.
- */
- public List<Preference> getInjectedSettings(Context prefContext, final int profileId) {
- final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- final List<UserHandle> profiles = um.getUserProfiles();
- ArrayList<Preference> prefs = new ArrayList<>();
- final int profileCount = profiles.size();
- for (int i = 0; i < profileCount; ++i) {
- final UserHandle userHandle = profiles.get(i);
- if (profileId == UserHandle.USER_CURRENT || profileId == userHandle.getIdentifier()) {
- Iterable<InjectedSetting> settings = getSettings(userHandle);
- for (InjectedSetting setting : settings) {
- Preference pref = addServiceSetting(prefContext, prefs, setting);
- mSettings.add(new Setting(setting, pref));
- }
- }
- }
-
- reloadStatusMessages();
-
- return prefs;
- }
-
- /**
- * Checks wheteher there is any preference that other apps have injected.
- *
- * @param profileId Identifier of the user/profile to obtain the injected settings for or
- * UserHandle.USER_CURRENT for all profiles associated with current user.
- */
- public boolean hasInjectedSettings(final int profileId) {
- final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- final List<UserHandle> profiles = um.getUserProfiles();
- final int profileCount = profiles.size();
- for (int i = 0; i < profileCount; ++i) {
- final UserHandle userHandle = profiles.get(i);
- if (profileId == UserHandle.USER_CURRENT || profileId == userHandle.getIdentifier()) {
- Iterable<InjectedSetting> settings = getSettings(userHandle);
- for (InjectedSetting setting : settings) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Reloads the status messages for all the preference items.
- */
- public void reloadStatusMessages() {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "reloadingStatusMessages: " + mSettings);
- }
- mHandler.sendMessage(mHandler.obtainMessage(WHAT_RELOAD));
- }
-
- /**
- * Adds an injected setting to the root.
- */
- private Preference addServiceSetting(Context prefContext, List<Preference> prefs,
- InjectedSetting info) {
- final PackageManager pm = mContext.getPackageManager();
- Drawable appIcon = null;
- try {
- final PackageItemInfo itemInfo = new PackageItemInfo();
- itemInfo.icon = info.iconId;
- itemInfo.packageName = info.packageName;
- final ApplicationInfo appInfo = pm.getApplicationInfo(info.packageName,
- PackageManager.GET_META_DATA);
- appIcon = IconDrawableFactory.newInstance(mContext)
- .getBadgedIcon(itemInfo, appInfo, info.mUserHandle.getIdentifier());
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "Can't get ApplicationInfo for " + info.packageName, e);
- }
- Preference pref = TextUtils.isEmpty(info.userRestriction)
- ? new AppPreference(prefContext)
- : new RestrictedAppPreference(prefContext, info.userRestriction);
- pref.setTitle(info.title);
- pref.setSummary(null);
- pref.setIcon(appIcon);
- pref.setOnPreferenceClickListener(new ServiceSettingClickedListener(info));
- prefs.add(pref);
- return pref;
- }
-
- private class ServiceSettingClickedListener
- implements Preference.OnPreferenceClickListener {
- private InjectedSetting mInfo;
-
- public ServiceSettingClickedListener(InjectedSetting info) {
- mInfo = info;
- }
-
- @Override
- public boolean onPreferenceClick(Preference preference) {
- // Activity to start if they click on the preference. Must start in new task to ensure
- // that "android.settings.LOCATION_SOURCE_SETTINGS" brings user back to
- // Settings > Location.
- Intent settingIntent = new Intent();
- settingIntent.setClassName(mInfo.packageName, mInfo.settingsActivity);
- // Sometimes the user may navigate back to "Settings" and launch another different
- // injected setting after one injected setting has been launched.
- //
- // FLAG_ACTIVITY_CLEAR_TOP allows multiple Activities to stack on each other. When
- // "back" button is clicked, the user will navigate through all the injected settings
- // launched before. Such behavior could be quite confusing sometimes.
- //
- // In order to avoid such confusion, we use FLAG_ACTIVITY_CLEAR_TASK, which always clear
- // up all existing injected settings and make sure that "back" button always brings the
- // user back to "Settings" directly.
- settingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- mContext.startActivityAsUser(settingIntent, mInfo.mUserHandle);
- return true;
- }
- }
-
- /**
- * Loads the setting status values one at a time. Each load starts a subclass of {@link
- * SettingInjectorService}, so to reduce memory pressure we don't want to load too many at
- * once.
- */
- private final class StatusLoadingHandler extends Handler {
-
- /**
- * Settings whose status values need to be loaded. A set is used to prevent redundant loads.
- */
- private Set<Setting> mSettingsToLoad = new HashSet<Setting>();
-
- /**
- * Settings that are being loaded now and haven't timed out. In practice this should have
- * zero or one elements.
- */
- private Set<Setting> mSettingsBeingLoaded = new HashSet<Setting>();
-
- /**
- * Settings that are being loaded but have timed out. If only one setting has timed out, we
- * will go ahead and start loading the next setting so that one slow load won't delay the
- * load of the other settings.
- */
- private Set<Setting> mTimedOutSettings = new HashSet<Setting>();
-
- private boolean mReloadRequested;
-
- private StatusLoadingHandler() {
- super(Looper.getMainLooper());
- }
- @Override
- public void handleMessage(Message msg) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "handleMessage start: " + msg + ", " + this);
- }
-
- // Update state in response to message
- switch (msg.what) {
- case WHAT_RELOAD:
- mReloadRequested = true;
- break;
- case WHAT_RECEIVED_STATUS:
- final Setting receivedSetting = (Setting) msg.obj;
- receivedSetting.maybeLogElapsedTime();
- mSettingsBeingLoaded.remove(receivedSetting);
- mTimedOutSettings.remove(receivedSetting);
- removeMessages(WHAT_TIMEOUT, receivedSetting);
- break;
- case WHAT_TIMEOUT:
- final Setting timedOutSetting = (Setting) msg.obj;
- mSettingsBeingLoaded.remove(timedOutSetting);
- mTimedOutSettings.add(timedOutSetting);
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "Timed out after " + timedOutSetting.getElapsedTime()
- + " millis trying to get status for: " + timedOutSetting);
- }
- break;
- default:
- Log.wtf(TAG, "Unexpected what: " + msg);
- }
-
- // Decide whether to load additional settings based on the new state. Start by seeing
- // if we have headroom to load another setting.
- if (mSettingsBeingLoaded.size() > 0 || mTimedOutSettings.size() > 1) {
- // Don't load any more settings until one of the pending settings has completed.
- // To reduce memory pressure, we want to be loading at most one setting (plus at
- // most one timed-out setting) at a time. This means we'll be responsible for
- // bringing in at most two services.
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "too many services already live for " + msg + ", " + this);
- }
- return;
- }
-
- if (mReloadRequested && mSettingsToLoad.isEmpty() && mSettingsBeingLoaded.isEmpty()
- && mTimedOutSettings.isEmpty()) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "reloading because idle and reload requesteed " + msg + ", " + this);
- }
- // Reload requested, so must reload all settings
- mSettingsToLoad.addAll(mSettings);
- mReloadRequested = false;
- }
-
- // Remove the next setting to load from the queue, if any
- Iterator<Setting> iter = mSettingsToLoad.iterator();
- if (!iter.hasNext()) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "nothing left to do for " + msg + ", " + this);
- }
- return;
- }
- Setting setting = iter.next();
- iter.remove();
-
- // Request the status value
- setting.startService();
- mSettingsBeingLoaded.add(setting);
-
- // Ensure that if receiving the status value takes too long, we start loading the
- // next value anyway
- Message timeoutMsg = obtainMessage(WHAT_TIMEOUT, setting);
- sendMessageDelayed(timeoutMsg, INJECTED_STATUS_UPDATE_TIMEOUT_MILLIS);
-
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "handleMessage end " + msg + ", " + this
- + ", started loading " + setting);
- }
- }
-
- @Override
- public String toString() {
- return "StatusLoadingHandler{" +
- "mSettingsToLoad=" + mSettingsToLoad +
- ", mSettingsBeingLoaded=" + mSettingsBeingLoaded +
- ", mTimedOutSettings=" + mTimedOutSettings +
- ", mReloadRequested=" + mReloadRequested +
- '}';
- }
- }
-
- /**
- * Represents an injected setting and the corresponding preference.
- */
- private final class Setting {
-
- public final InjectedSetting setting;
- public final Preference preference;
- public long startMillis;
-
- private Setting(InjectedSetting setting, Preference preference) {
- this.setting = setting;
- this.preference = preference;
- }
-
- @Override
- public String toString() {
- return "Setting{" +
- "setting=" + setting +
- ", preference=" + preference +
- '}';
- }
-
- /**
- * Returns true if they both have the same {@link #setting} value. Ignores mutable
- * {@link #preference} and {@link #startMillis} so that it's safe to use in sets.
- */
- @Override
- public boolean equals(Object o) {
- return this == o || o instanceof Setting && setting.equals(((Setting) o).setting);
- }
-
- @Override
- public int hashCode() {
- return setting.hashCode();
- }
-
- /**
- * Starts the service to fetch for the current status for the setting, and updates the
- * preference when the service replies.
- */
- public void startService() {
- final ActivityManager am = (ActivityManager)
- mContext.getSystemService(Context.ACTIVITY_SERVICE);
- if (!am.isUserRunning(setting.mUserHandle.getIdentifier())) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "Cannot start service as user "
- + setting.mUserHandle.getIdentifier() + " is not running");
- }
- return;
- }
- Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- Bundle bundle = msg.getData();
- boolean enabled = bundle.getBoolean(SettingInjectorService.ENABLED_KEY, true);
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, setting + ": received " + msg + ", bundle: " + bundle);
- }
- preference.setSummary(null);
- preference.setEnabled(enabled);
- mHandler.sendMessage(
- mHandler.obtainMessage(WHAT_RECEIVED_STATUS, Setting.this));
- }
- };
- Messenger messenger = new Messenger(handler);
-
- Intent intent = setting.getServiceIntent();
- intent.putExtra(SettingInjectorService.MESSENGER_KEY, messenger);
-
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, setting + ": sending update intent: " + intent
- + ", handler: " + handler);
- startMillis = SystemClock.elapsedRealtime();
- } else {
- startMillis = 0;
- }
-
- // Start the service, making sure that this is attributed to the user associated with
- // the setting rather than the system user.
- mContext.startServiceAsUser(intent, setting.mUserHandle);
- }
-
- public long getElapsedTime() {
- long end = SystemClock.elapsedRealtime();
- return end - startMillis;
- }
-
- public void maybeLogElapsedTime() {
- if (Log.isLoggable(TAG, Log.DEBUG) && startMillis != 0) {
- long elapsed = getElapsedTime();
- Log.d(TAG, this + " update took " + elapsed + " millis");
- }
- }
- }
-}
diff --git a/src/com/android/settings/network/ApnEditor.java b/src/com/android/settings/network/ApnEditor.java
index 3b4189b..91a094f 100644
--- a/src/com/android/settings/network/ApnEditor.java
+++ b/src/com/android/settings/network/ApnEditor.java
@@ -18,7 +18,6 @@
import static android.content.Context.TELEPHONY_SERVICE;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.Context;
@@ -55,6 +54,7 @@
import java.util.Set;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.MultiSelectListPreference;
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 31a8435..27e1a98 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -19,7 +19,6 @@
.MANAGE_MOBILE_PLAN_DIALOG_ID;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.icu.text.ListFormatter;
@@ -44,6 +43,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
@SearchIndexable
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 3a04ade..ad90e72 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -22,7 +22,6 @@
import static android.system.OsConstants.AF_INET;
import static android.system.OsConstants.AF_INET6;
-import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
@@ -52,6 +51,7 @@
import java.util.Map;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* Dialog to set the Private DNS
@@ -72,7 +72,7 @@
PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME, R.id.private_dns_mode_provider);
}
- private static final int[] ADDRESS_FAMILIES = new int[]{AF_INET, AF_INET6};
+ private static final int[] ADDRESS_FAMILIES = new int[] {AF_INET, AF_INET6};
@VisibleForTesting
static final String MODE_KEY = Settings.Global.PRIVATE_DNS_MODE;
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 2b5a8ab..7120cf6 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -27,6 +27,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.RingtonePreference;
+import com.android.settings.core.OnActivityResultListener;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -44,7 +45,8 @@
import androidx.preference.Preference;
@SearchIndexable
-public class ConfigureNotificationSettings extends DashboardFragment {
+public class ConfigureNotificationSettings extends DashboardFragment implements
+ OnActivityResultListener {
private static final String TAG = "ConfigNotiSettings";
@VisibleForTesting
diff --git a/src/com/android/settings/notification/NotificationAccessSettings.java b/src/com/android/settings/notification/NotificationAccessSettings.java
index 17739f9..9bfbd2c 100644
--- a/src/com/android/settings/notification/NotificationAccessSettings.java
+++ b/src/com/android/settings/notification/NotificationAccessSettings.java
@@ -16,17 +16,18 @@
package com.android.settings.notification;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
+import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
@@ -40,6 +41,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
/**
@@ -62,6 +64,18 @@
private NotificationManager mNm;
@Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ final Context ctx = getContext();
+ if (UserManager.get(ctx).isManagedProfile()) {
+ // Apps in the work profile do not support notification listeners.
+ Toast.makeText(ctx, R.string.notification_settings_work_profile, Toast.LENGTH_SHORT)
+ .show();
+ finish();
+ }
+ }
+
+ @Override
public int getMetricsCategory() {
return MetricsEvent.NOTIFICATION_ACCESS;
}
diff --git a/src/com/android/settings/notification/NotificationLockscreenPreference.java b/src/com/android/settings/notification/NotificationLockscreenPreference.java
index af912af..3370f3e 100644
--- a/src/com/android/settings/notification/NotificationLockscreenPreference.java
+++ b/src/com/android/settings/notification/NotificationLockscreenPreference.java
@@ -16,7 +16,6 @@
package com.android.settings.notification;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -36,6 +35,7 @@
import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
+import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AlertDialog.Builder;
public class NotificationLockscreenPreference extends RestrictedListPreference {
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index dafc538..cc3b7c9 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -31,6 +31,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.RingtonePreference;
+import com.android.settings.core.OnActivityResultListener;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.sound.HandsFreeProfileOutputPreferenceController;
@@ -51,7 +52,7 @@
import androidx.preference.Preference;
@SearchIndexable
-public class SoundSettings extends DashboardFragment {
+public class SoundSettings extends DashboardFragment implements OnActivityResultListener {
private static final String TAG = "SoundSettings";
private static final String SELECTED_PREFERENCE_KEY = "selected_preference";
diff --git a/src/com/android/settings/notification/WorkSoundPreferenceController.java b/src/com/android/settings/notification/WorkSoundPreferenceController.java
index 44796f8..26cd8aa 100644
--- a/src/com/android/settings/notification/WorkSoundPreferenceController.java
+++ b/src/com/android/settings/notification/WorkSoundPreferenceController.java
@@ -17,7 +17,6 @@
package com.android.settings.notification;
import android.annotation.UserIdInt;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -47,6 +46,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
diff --git a/src/com/android/settings/notification/ZenAccessSettings.java b/src/com/android/settings/notification/ZenAccessSettings.java
index 4af8158..2e4bb4e 100644
--- a/src/com/android/settings/notification/ZenAccessSettings.java
+++ b/src/com/android/settings/notification/ZenAccessSettings.java
@@ -18,7 +18,6 @@
import android.annotation.Nullable;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.AppGlobals;
import android.app.Dialog;
import android.app.NotificationManager;
@@ -58,6 +57,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceScreen;
diff --git a/src/com/android/settings/notification/ZenDeleteRuleDialog.java b/src/com/android/settings/notification/ZenDeleteRuleDialog.java
index 2783e3b..c460d84 100644
--- a/src/com/android/settings/notification/ZenDeleteRuleDialog.java
+++ b/src/com/android/settings/notification/ZenDeleteRuleDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.notification;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -26,6 +25,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class ZenDeleteRuleDialog extends InstrumentedDialogFragment {
diff --git a/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java b/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java
index 56f9081..3cfd13d 100644
--- a/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java
+++ b/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java
@@ -16,7 +16,6 @@
package com.android.settings.notification;
-import android.app.AlertDialog;
import android.app.AutomaticZenRule;
import android.app.Dialog;
import android.app.TimePickerDialog;
@@ -42,6 +41,7 @@
import java.util.Calendar;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceClickListener;
diff --git a/src/com/android/settings/notification/ZenRuleNameDialog.java b/src/com/android/settings/notification/ZenRuleNameDialog.java
index 4314454..62c83cd 100644
--- a/src/com/android/settings/notification/ZenRuleNameDialog.java
+++ b/src/com/android/settings/notification/ZenRuleNameDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.notification;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -32,6 +31,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class ZenRuleNameDialog extends InstrumentedDialogFragment {
diff --git a/src/com/android/settings/notification/ZenRuleSelectionDialog.java b/src/com/android/settings/notification/ZenRuleSelectionDialog.java
index 40b79f7..b1a3939 100644
--- a/src/com/android/settings/notification/ZenRuleSelectionDialog.java
+++ b/src/com/android/settings/notification/ZenRuleSelectionDialog.java
@@ -18,7 +18,6 @@
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.NotificationManager;
import android.content.Context;
@@ -47,6 +46,7 @@
import java.util.Set;
import java.util.TreeSet;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class ZenRuleSelectionDialog extends InstrumentedDialogFragment {
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index 3e478d1..3dc4068 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -23,7 +23,6 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -63,6 +62,7 @@
import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
index fc1fab0..0f6eeb3 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
@@ -20,7 +20,6 @@
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityOptions;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.IActivityManager;
import android.app.KeyguardManager;
@@ -53,6 +52,7 @@
import com.android.settings.biometrics.fingerprint.FingerprintUiHelper;
import com.android.settings.core.InstrumentedFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
diff --git a/src/com/android/settings/password/SetupSkipDialog.java b/src/com/android/settings/password/SetupSkipDialog.java
index 98a2482..c93d12d 100644
--- a/src/com/android/settings/password/SetupSkipDialog.java
+++ b/src/com/android/settings/password/SetupSkipDialog.java
@@ -17,7 +17,6 @@
package com.android.settings.password;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -27,6 +26,7 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class SetupSkipDialog extends InstrumentedDialogFragment
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index 4629360..1311be0 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -22,9 +22,6 @@
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.content.pm.ResolveInfo;
-import android.database.DataSetObserver;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.print.PrintManager;
@@ -44,13 +41,10 @@
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.ListView;
import android.widget.SearchView;
import android.widget.Switch;
import android.widget.TextView;
@@ -67,8 +61,11 @@
import java.util.List;
import java.util.Map;
+import androidx.annotation.NonNull;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
/**
* Fragment with print service settings.
@@ -77,23 +74,18 @@
implements SwitchBar.OnSwitchChangeListener,
LoaderManager.LoaderCallbacks<List<PrintServiceInfo>> {
- private static final String LOG_TAG = "PrintServiceSettingsFragment";
+ private static final String LOG_TAG = "PrintServiceSettings";
private static final int LOADER_ID_PRINTERS_LOADER = 1;
private static final int LOADER_ID_PRINT_SERVICE_LOADER = 2;
- private final DataSetObserver mDataObserver = new DataSetObserver() {
+ private final AdapterDataObserver mDataObserver = new AdapterDataObserver() {
@Override
public void onChanged() {
invalidateOptionsMenuIfNeeded();
updateEmptyView();
}
- @Override
- public void onInvalidated() {
- invalidateOptionsMenuIfNeeded();
- }
-
private void invalidateOptionsMenuIfNeeded() {
final int unfilteredItemCount = mPrintersAdapter.getUnfilteredCount();
if ((mLastUnfilteredItemCount <= 0 && unfilteredItemCount > 0)
@@ -173,8 +165,6 @@
super.onViewCreated(view, savedInstanceState);
initComponents();
updateUiForArguments();
- getListView().setVisibility(View.GONE);
- getBackupListView().setVisibility(View.VISIBLE);
}
@Override
@@ -189,15 +179,11 @@
.setPrintServiceEnabled(mComponentName, enabled);
}
- private ListView getBackupListView() {
- return (ListView) getView().findViewById(R.id.backup_list);
- }
-
private void updateEmptyView() {
ViewGroup contentRoot = (ViewGroup) getListView().getParent();
- View emptyView = getBackupListView().getEmptyView();
+ View emptyView = getEmptyView();
if (!mToggleSwitch.isChecked()) {
- if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
+ if (emptyView != null) {
contentRoot.removeView(emptyView);
emptyView = null;
}
@@ -209,11 +195,10 @@
TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_service_disabled);
contentRoot.addView(emptyView);
- getBackupListView().setEmptyView(emptyView);
+ setEmptyView(emptyView);
}
} else if (mPrintersAdapter.getUnfilteredCount() <= 0) {
- if (emptyView != null
- && emptyView.getId() != R.id.empty_printers_list_service_enabled) {
+ if (emptyView != null) {
contentRoot.removeView(emptyView);
emptyView = null;
}
@@ -221,10 +206,10 @@
emptyView = getActivity().getLayoutInflater().inflate(
R.layout.empty_printers_list_service_enabled, contentRoot, false);
contentRoot.addView(emptyView);
- getBackupListView().setEmptyView(emptyView);
+ setEmptyView(emptyView);
}
- } else if (mPrintersAdapter.getCount() <= 0) {
- if (emptyView != null && emptyView.getId() != R.id.empty_print_state) {
+ } else if (mPrintersAdapter.getItemCount() <= 0) {
+ if (emptyView != null) {
contentRoot.removeView(emptyView);
emptyView = null;
}
@@ -236,7 +221,11 @@
TextView textView = (TextView) emptyView.findViewById(R.id.message);
textView.setText(R.string.print_no_printers_found);
contentRoot.addView(emptyView);
- getBackupListView().setEmptyView(emptyView);
+ setEmptyView(emptyView);
+ }
+ } else if (mPrintersAdapter.getItemCount() > 0) {
+ if (emptyView != null) {
+ contentRoot.removeView(emptyView);
}
}
}
@@ -254,7 +243,7 @@
private void initComponents() {
mPrintersAdapter = new PrintersAdapter();
- mPrintersAdapter.registerDataSetObserver(mDataObserver);
+ mPrintersAdapter.registerAdapterDataObserver(mDataObserver);
final SettingsActivity activity = (SettingsActivity) getActivity();
@@ -263,31 +252,12 @@
mSwitchBar.show();
mToggleSwitch = mSwitchBar.getSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(new ToggleSwitch.OnBeforeCheckedChangeListener() {
- @Override
- public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
- onPreferenceToggled(mPreferenceKey, checked);
- return false;
- }
+ mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
});
- getBackupListView().setSelector(new ColorDrawable(Color.TRANSPARENT));
- getBackupListView().setAdapter(mPrintersAdapter);
- getBackupListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- PrinterInfo printer = (PrinterInfo) mPrintersAdapter.getItem(position);
-
- if (printer.getInfoIntent() != null) {
- try {
- getActivity().startIntentSender(printer.getInfoIntent().getIntentSender(),
- null, 0, 0, 0);
- } catch (SendIntentException e) {
- Log.e(LOG_TAG, "Could not execute info intent: %s", e);
- }
- }
- }
- });
+ getListView().setAdapter(mPrintersAdapter);
}
@@ -446,8 +416,17 @@
}
}
- private final class PrintersAdapter extends BaseAdapter
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+
+ public ViewHolder(@NonNull View itemView) {
+ super(itemView);
+ }
+ }
+
+
+ private final class PrintersAdapter extends RecyclerView.Adapter<ViewHolder>
implements LoaderManager.LoaderCallbacks<List<PrinterInfo>>, Filterable {
+
private final Object mLock = new Object();
private final List<PrinterInfo> mPrinters = new ArrayList<PrinterInfo>();
@@ -509,19 +488,19 @@
}
}
notifyDataSetChanged();
+
}
};
}
@Override
- public int getCount() {
+ public int getItemCount() {
synchronized (mLock) {
return mFilteredPrinters.size();
}
}
- @Override
- public Object getItem(int position) {
+ private Object getItem(int position) {
synchronized (mLock) {
return mFilteredPrinters.get(position);
}
@@ -543,24 +522,27 @@
return printer.getStatus() != PrinterInfo.STATUS_UNAVAILABLE;
}
+ @NonNull
@Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = getActivity().getLayoutInflater().inflate(
- R.layout.printer_dropdown_item, parent, false);
- }
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ final View view = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.printer_dropdown_item, parent, false);
+ return new ViewHolder(view);
+ }
- convertView.setEnabled(isActionable(position));
+ @Override
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
+ holder.itemView.setEnabled(isActionable(position));
final PrinterInfo printer = (PrinterInfo) getItem(position);
CharSequence title = printer.getName();
CharSequence subtitle = printer.getDescription();
Drawable icon = printer.loadIcon(getActivity());
- TextView titleView = (TextView) convertView.findViewById(R.id.title);
+ TextView titleView = holder.itemView.findViewById(R.id.title);
titleView.setText(title);
- TextView subtitleView = (TextView) convertView.findViewById(R.id.subtitle);
+ TextView subtitleView = holder.itemView.findViewById(R.id.subtitle);
if (!TextUtils.isEmpty(subtitle)) {
subtitleView.setText(subtitle);
subtitleView.setVisibility(View.VISIBLE);
@@ -569,7 +551,7 @@
subtitleView.setVisibility(View.GONE);
}
- LinearLayout moreInfoView = (LinearLayout) convertView.findViewById(R.id.more_info);
+ LinearLayout moreInfoView = holder.itemView.findViewById(R.id.more_info);
if (printer.getInfoIntent() != null) {
moreInfoView.setVisibility(View.VISIBLE);
moreInfoView.setOnClickListener(new OnClickListener() {
@@ -587,7 +569,7 @@
moreInfoView.setVisibility(View.GONE);
}
- ImageView iconView = (ImageView) convertView.findViewById(R.id.icon);
+ ImageView iconView = holder.itemView.findViewById(R.id.icon);
if (icon != null) {
iconView.setVisibility(View.VISIBLE);
if (!isActionable(position)) {
@@ -603,7 +585,18 @@
iconView.setVisibility(View.GONE);
}
- return convertView;
+ holder.itemView.setOnClickListener(v -> {
+ PrinterInfo pi = (PrinterInfo) getItem(position);
+
+ if (pi.getInfoIntent() != null) {
+ try {
+ getActivity().startIntentSender(pi.getInfoIntent().getIntentSender(),
+ null, 0, 0, 0);
+ } catch (SendIntentException e) {
+ Log.e(LOG_TAG, "Could not execute info intent: %s", e);
+ }
+ }
+ });
}
@Override
@@ -642,7 +635,7 @@
mFilteredPrinters.clear();
mLastSearchString = null;
}
- notifyDataSetInvalidated();
+ notifyDataSetChanged();
}
}
diff --git a/src/com/android/settings/security/ConfigureKeyGuardDialog.java b/src/com/android/settings/security/ConfigureKeyGuardDialog.java
index 3bcfb89..f09e077 100644
--- a/src/com/android/settings/security/ConfigureKeyGuardDialog.java
+++ b/src/com/android/settings/security/ConfigureKeyGuardDialog.java
@@ -17,7 +17,6 @@
package com.android.settings.security;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.DialogInterface;
@@ -31,6 +30,7 @@
import com.android.settings.password.ChooseLockGeneric;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
/**
* Prompt for key guard configuration confirmation.
diff --git a/src/com/android/settings/security/CryptKeeperSettings.java b/src/com/android/settings/security/CryptKeeperSettings.java
index 9766911..b7c5db7 100644
--- a/src/com/android/settings/security/CryptKeeperSettings.java
+++ b/src/com/android/settings/security/CryptKeeperSettings.java
@@ -17,7 +17,6 @@
package com.android.settings.security;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -42,6 +41,7 @@
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.password.ConfirmLockPattern;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java
index e214720..71130ea 100644
--- a/src/com/android/settings/security/LockscreenDashboardFragment.java
+++ b/src/com/android/settings/security/LockscreenDashboardFragment.java
@@ -19,6 +19,8 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import androidx.annotation.VisibleForTesting;
+
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -29,6 +31,7 @@
import com.android.settings.gestures.PickupGesturePreferenceController;
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.security.screenlock.LockScreenPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
@@ -37,8 +40,6 @@
import java.util.Arrays;
import java.util.List;
-import androidx.annotation.VisibleForTesting;
-
/**
* Settings screen for lock screen preference
*/
@@ -157,5 +158,11 @@
niks.add(KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER);
return niks;
}
+
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ return new LockScreenPreferenceController(context, "anykey")
+ .isAvailable();
+ }
};
}
diff --git a/src/com/android/settings/security/UnificationConfirmationDialog.java b/src/com/android/settings/security/UnificationConfirmationDialog.java
index f82ece6..e862bd0 100644
--- a/src/com/android/settings/security/UnificationConfirmationDialog.java
+++ b/src/com/android/settings/security/UnificationConfirmationDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.security;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -25,6 +24,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
public class UnificationConfirmationDialog extends InstrumentedDialogFragment {
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index 853f80d..803e1cf 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -17,7 +17,6 @@
package com.android.settings.sim;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -45,6 +44,8 @@
import java.util.Iterator;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
+
public class SimDialogActivity extends Activity {
private static String TAG = "SimDialogActivity";
diff --git a/src/com/android/settings/sim/SimPreferenceDialog.java b/src/com/android/settings/sim/SimPreferenceDialog.java
index 2b6ebe3..a657a6b 100644
--- a/src/com/android/settings/sim/SimPreferenceDialog.java
+++ b/src/com/android/settings/sim/SimPreferenceDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.sim;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
@@ -42,6 +41,8 @@
import com.android.settings.R;
import com.android.settings.Utils;
+import androidx.appcompat.app.AlertDialog;
+
public class SimPreferenceDialog extends Activity {
private Context mContext;
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index da705c9..f6c08ce 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -32,15 +32,15 @@
import android.util.Log;
import android.util.Pair;
+import com.android.settings.bluetooth.BluetoothSliceBuilder;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.flashlight.FlashlightSliceBuilder;
import com.android.settings.location.LocationSliceBuilder;
import com.android.settings.mobilenetwork.Enhanced4gLteSliceHelper;
import com.android.settings.notification.ZenModeSliceBuilder;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.core.BasePreferenceController;
import com.android.settings.wifi.WifiSliceBuilder;
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
-import com.android.settings.bluetooth.BluetoothSliceBuilder;
import com.android.settingslib.SliceBroadcastRelay;
import com.android.settingslib.utils.ThreadUtils;
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index a56a290..c1c3b8e8 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -49,6 +49,7 @@
import java.util.List;
import java.util.stream.Collectors;
+import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
import androidx.slice.builders.ListBuilder;
@@ -242,7 +243,7 @@
private static Slice buildToggleSlice(Context context, SliceData sliceData,
BasePreferenceController controller) {
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
- final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
+ final IconCompat icon = getSafeIcon(context, sliceData);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final TogglePreferenceController toggleController =
@@ -266,7 +267,7 @@
private static Slice buildIntentSlice(Context context, SliceData sliceData,
BasePreferenceController controller) {
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
- final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
+ final IconCompat icon = getSafeIcon(context, sliceData);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final List<String> keywords = buildSliceKeywords(sliceData);
@@ -287,7 +288,7 @@
final SliderPreferenceController sliderController = (SliderPreferenceController) controller;
final PendingIntent actionIntent = getSliderAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
- final IconCompat icon = IconCompat.createWithResource(context, sliceData.getIconResource());
+ final IconCompat icon = getSafeIcon(context, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
final SliceAction primaryAction = new SliceAction(contentIntent, icon,
@@ -382,4 +383,14 @@
.setKeywords(keywords)
.build();
}
+
+ @VisibleForTesting
+ static IconCompat getSafeIcon(Context context, SliceData data) {
+ int iconResource = data.getIconResource();
+
+ if (iconResource == 0) {
+ iconResource = R.drawable.ic_settings;
+ }
+ return IconCompat.createWithResource(context, iconResource);
+ }
}
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index c13d12c..d21d0c8 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -20,7 +20,6 @@
import static android.provider.Settings.Secure.TTS_DEFAULT_RATE;
import static android.provider.Settings.Secure.TTS_DEFAULT_SYNTH;
-import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
@@ -57,6 +56,7 @@
import java.util.Objects;
import java.util.Set;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
diff --git a/src/com/android/settings/tts/TtsEnginePreference.java b/src/com/android/settings/tts/TtsEnginePreference.java
index 84f5b7e..41684c5 100644
--- a/src/com/android/settings/tts/TtsEnginePreference.java
+++ b/src/com/android/settings/tts/TtsEnginePreference.java
@@ -16,7 +16,6 @@
package com.android.settings.tts;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -29,6 +28,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
diff --git a/src/com/android/settings/users/AutoSyncDataPreferenceController.java b/src/com/android/settings/users/AutoSyncDataPreferenceController.java
index 7d840ca..5856f71 100644
--- a/src/com/android/settings/users/AutoSyncDataPreferenceController.java
+++ b/src/com/android/settings/users/AutoSyncDataPreferenceController.java
@@ -16,7 +16,6 @@
package com.android.settings.users;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
@@ -33,6 +32,7 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.core.AbstractPreferenceController;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
diff --git a/src/com/android/settings/users/EditUserInfoController.java b/src/com/android/settings/users/EditUserInfoController.java
index 072c8cd..6045516 100644
--- a/src/com/android/settings/users/EditUserInfoController.java
+++ b/src/com/android/settings/users/EditUserInfoController.java
@@ -17,7 +17,6 @@
package com.android.settings.users;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -41,6 +40,7 @@
import java.io.File;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
/**
diff --git a/src/com/android/settings/users/OwnerInfoSettings.java b/src/com/android/settings/users/OwnerInfoSettings.java
index 0f99360..7576917 100644
--- a/src/com/android/settings/users/OwnerInfoSettings.java
+++ b/src/com/android/settings/users/OwnerInfoSettings.java
@@ -16,7 +16,6 @@
package com.android.settings.users;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -33,6 +32,7 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.security.OwnerInfoPreferenceController.OwnerInfoCallback;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class OwnerInfoSettings extends InstrumentedDialogFragment implements OnClickListener {
diff --git a/src/com/android/settings/users/UserDialogs.java b/src/com/android/settings/users/UserDialogs.java
index 3ed383a..137c938 100644
--- a/src/com/android/settings/users/UserDialogs.java
+++ b/src/com/android/settings/users/UserDialogs.java
@@ -16,7 +16,6 @@
package com.android.settings.users;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -34,6 +33,8 @@
import com.android.settings.R;
import com.android.settings.Utils;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Helper class for displaying dialogs related to user settings.
*/
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 7d84d99..9aa56c2 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -18,7 +18,6 @@
import android.app.Activity;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
@@ -79,6 +78,7 @@
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
diff --git a/src/com/android/settings/utils/ManagedServiceSettings.java b/src/com/android/settings/utils/ManagedServiceSettings.java
index 87c6b8e..e222e56 100644
--- a/src/com/android/settings/utils/ManagedServiceSettings.java
+++ b/src/com/android/settings/utils/ManagedServiceSettings.java
@@ -18,7 +18,6 @@
import android.annotation.Nullable;
import android.app.ActivityManager;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@@ -43,6 +42,7 @@
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
diff --git a/src/com/android/settings/utils/PreferenceGroupChildrenCache.java b/src/com/android/settings/utils/PreferenceGroupChildrenCache.java
new file mode 100644
index 0000000..dcbf4fd
--- /dev/null
+++ b/src/com/android/settings/utils/PreferenceGroupChildrenCache.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.utils;
+
+import android.text.TextUtils;
+import android.util.ArrayMap;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+
+/**
+ * Class that helps track which {@link Preference}s in a {@link PreferenceGroup} are still being
+ * used, and remove unused ones.
+ */
+public class PreferenceGroupChildrenCache {
+
+ private ArrayMap<String, Preference> mPreferenceCache;
+
+ public void cacheRemoveAllPrefs(PreferenceGroup group) {
+ mPreferenceCache = new ArrayMap<>();
+ final int N = group.getPreferenceCount();
+ for (int i = 0; i < N; i++) {
+ Preference p = group.getPreference(i);
+ if (TextUtils.isEmpty(p.getKey())) {
+ continue;
+ }
+ mPreferenceCache.put(p.getKey(), p);
+ }
+ }
+
+ public void removeCachedPrefs(PreferenceGroup group) {
+ for (Preference p : mPreferenceCache.values()) {
+ group.removePreference(p);
+ }
+ mPreferenceCache = null;
+ }
+
+ public Preference getCachedPreference(String key) {
+ return mPreferenceCache != null ? mPreferenceCache.remove(key) : null;
+ }
+
+ public int getCachedCount() {
+ return mPreferenceCache != null ? mPreferenceCache.size() : 0;
+ }
+}
diff --git a/src/com/android/settings/vpn2/AppDialog.java b/src/com/android/settings/vpn2/AppDialog.java
index e41ffef..6641bf3 100644
--- a/src/com/android/settings/vpn2/AppDialog.java
+++ b/src/com/android/settings/vpn2/AppDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.vpn2;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
@@ -24,6 +23,8 @@
import com.android.settings.R;
+import androidx.appcompat.app.AlertDialog;
+
/**
* UI for managing the connection controlled by an app.
*
diff --git a/src/com/android/settings/vpn2/AppDialogFragment.java b/src/com/android/settings/vpn2/AppDialogFragment.java
index 2f7a6bb..759adbf 100644
--- a/src/com/android/settings/vpn2/AppDialogFragment.java
+++ b/src/com/android/settings/vpn2/AppDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.vpn2;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -34,6 +33,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
/**
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 145e86f..a141919 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -18,7 +18,6 @@
import static android.app.AppOpsManager.OP_ACTIVATE_VPN;
import android.annotation.NonNull;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.content.Context;
@@ -49,6 +48,7 @@
import java.util.List;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.preference.Preference;
diff --git a/src/com/android/settings/vpn2/ConfigDialog.java b/src/com/android/settings/vpn2/ConfigDialog.java
index 4eecd28..376dba7 100644
--- a/src/com/android/settings/vpn2/ConfigDialog.java
+++ b/src/com/android/settings/vpn2/ConfigDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.vpn2;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -39,6 +38,8 @@
import java.net.InetAddress;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Dialog showing information about a VPN configuration. The dialog
* can be launched to either edit or prompt for credentials to connect
diff --git a/src/com/android/settings/vpn2/ConfigDialogFragment.java b/src/com/android/settings/vpn2/ConfigDialogFragment.java
index 00b22bb..1517bf7 100644
--- a/src/com/android/settings/vpn2/ConfigDialogFragment.java
+++ b/src/com/android/settings/vpn2/ConfigDialogFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.vpn2;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -38,6 +37,8 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
+
/**
* Fragment wrapper around a {@link ConfigDialog}.
*/
diff --git a/src/com/android/settings/vpn2/ConfirmLockdownFragment.java b/src/com/android/settings/vpn2/ConfirmLockdownFragment.java
index 5c2c9d7..d73e928 100644
--- a/src/com/android/settings/vpn2/ConfirmLockdownFragment.java
+++ b/src/com/android/settings/vpn2/ConfirmLockdownFragment.java
@@ -15,7 +15,6 @@
*/
package com.android.settings.vpn2;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -24,6 +23,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
public class ConfirmLockdownFragment extends InstrumentedDialogFragment
diff --git a/src/com/android/settings/wfd/WifiDisplaySettings.java b/src/com/android/settings/wfd/WifiDisplaySettings.java
index 3d8dbde..dbb4e21 100755
--- a/src/com/android/settings/wfd/WifiDisplaySettings.java
+++ b/src/com/android/settings/wfd/WifiDisplaySettings.java
@@ -16,7 +16,6 @@
package com.android.settings.wfd;
-import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -63,6 +62,7 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
diff --git a/src/com/android/settings/widget/SingleTargetGearPreference.java b/src/com/android/settings/widget/SingleTargetGearPreference.java
index 8def647..b770b6d 100644
--- a/src/com/android/settings/widget/SingleTargetGearPreference.java
+++ b/src/com/android/settings/widget/SingleTargetGearPreference.java
@@ -17,13 +17,13 @@
package com.android.settings.widget;
import android.content.Context;
-
-import androidx.core.content.res.TypedArrayUtils;
-import androidx.preference.Preference;
import android.util.AttributeSet;
import com.android.settings.R;
+import androidx.core.content.res.TypedArrayUtils;
+import androidx.preference.Preference;
+
/**
* A preference with single target and a gear icon on the side.
*/
diff --git a/src/com/android/settings/widget/ValidatedEditTextPreference.java b/src/com/android/settings/widget/ValidatedEditTextPreference.java
index aec362f..76d8bcc 100644
--- a/src/com/android/settings/widget/ValidatedEditTextPreference.java
+++ b/src/com/android/settings/widget/ValidatedEditTextPreference.java
@@ -16,7 +16,6 @@
package com.android.settings.widget;
-import android.app.AlertDialog;
import android.content.Context;
import android.text.Editable;
import android.text.InputType;
@@ -30,6 +29,7 @@
import com.android.settingslib.CustomEditTextPreferenceCompat;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceViewHolder;
/**
diff --git a/src/com/android/settings/widget/VideoPreferenceController.java b/src/com/android/settings/widget/VideoPreferenceController.java
new file mode 100644
index 0000000..457c6df
--- /dev/null
+++ b/src/com/android/settings/widget/VideoPreferenceController.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+import androidx.preference.PreferenceScreen;
+
+public class VideoPreferenceController extends BasePreferenceController implements
+ LifecycleObserver, OnResume, OnPause {
+
+ private VideoPreference mVideoPreference;
+ private boolean mVideoPaused;
+
+ public VideoPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mVideoPreference = (VideoPreference) screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public void onPause() {
+ if (mVideoPreference != null) {
+ mVideoPaused = mVideoPreference.isVideoPaused();
+ mVideoPreference.onViewInvisible();
+ }
+ }
+
+ @Override
+ public void onResume() {
+ if (mVideoPreference != null) {
+ mVideoPreference.onViewVisible(mVideoPaused);
+ }
+ }
+
+}
diff --git a/src/com/android/settings/wifi/ChangeWifiStateDetails.java b/src/com/android/settings/wifi/ChangeWifiStateDetails.java
index fbf0d63..899b35d 100644
--- a/src/com/android/settings/wifi/ChangeWifiStateDetails.java
+++ b/src/com/android/settings/wifi/ChangeWifiStateDetails.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi;
-import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.content.Context;
import android.os.Bundle;
@@ -29,6 +28,7 @@
import com.android.settings.wifi.AppStateChangeWifiStateBridge.WifiSettingsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.SwitchPreference;
diff --git a/src/com/android/settings/wifi/LongPressAccessPointPreference.java b/src/com/android/settings/wifi/LongPressAccessPointPreference.java
index 579d848..85fd800 100644
--- a/src/com/android/settings/wifi/LongPressAccessPointPreference.java
+++ b/src/com/android/settings/wifi/LongPressAccessPointPreference.java
@@ -28,12 +28,6 @@
private final Fragment mFragment;
public LongPressAccessPointPreference(AccessPoint accessPoint, Context context,
- UserBadgeCache cache, boolean forSavedNetworks, Fragment fragment) {
- super(accessPoint, context, cache, forSavedNetworks);
- mFragment = fragment;
- }
-
- public LongPressAccessPointPreference(AccessPoint accessPoint, Context context,
UserBadgeCache cache, boolean forSavedNetworks, int iconResId, Fragment fragment) {
super(accessPoint, context, cache, iconResId, forSavedNetworks);
mFragment = fragment;
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
deleted file mode 100644
index ebb493c..0000000
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.wifi;
-
-import android.annotation.Nullable;
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.Context;
-import android.icu.text.Collator;
-import android.net.wifi.WifiManager;
-import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
-import android.widget.Toast;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.search.Indexable;
-import com.android.settingslib.wifi.AccessPoint;
-import com.android.settingslib.wifi.AccessPointPreference;
-import com.android.settingslib.wifi.WifiSavedConfigUtils;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-/**
- * UI to manage saved networks/access points.
- * TODO(b/64806699): convert to {@link DashboardFragment} with {@link PreferenceController}s
- */
-public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
- implements Indexable, WifiDialog.WifiDialogListener {
- private static final String TAG = "SavedAccessPoints";
- @VisibleForTesting
- static final int MSG_UPDATE_PREFERENCES = 1;
- private static final Comparator<AccessPoint> SAVED_NETWORK_COMPARATOR =
- new Comparator<AccessPoint>() {
- final Collator mCollator = Collator.getInstance();
- @Override
- public int compare(AccessPoint ap1, AccessPoint ap2) {
- return mCollator.compare(
- nullToEmpty(ap1.getConfigName()), nullToEmpty(ap2.getConfigName()));
- }
-
- private String nullToEmpty(String string) {
- return (string == null) ? "" : string;
- }
- };
-
- @VisibleForTesting
- final WifiManager.ActionListener mForgetListener = new WifiManager.ActionListener() {
- @Override
- public void onSuccess() {
- postUpdatePreference();
- }
-
- @Override
- public void onFailure(int reason) {
- postUpdatePreference();
- }
- };
-
- @VisibleForTesting
- final Handler mHandler = new Handler() {
- @Override
- public void handleMessage(android.os.Message msg) {
- if (msg.what == MSG_UPDATE_PREFERENCES) {
- initPreferences();
- }
- }
- };
-
- private final WifiManager.ActionListener mSaveListener = new WifiManager.ActionListener() {
- @Override
- public void onSuccess() {
- postUpdatePreference();
- }
- @Override
- public void onFailure(int reason) {
- Activity activity = getActivity();
- if (activity != null) {
- Toast.makeText(activity,
- R.string.wifi_failed_save_message,
- Toast.LENGTH_SHORT).show();
- }
- }
- };
-
- private WifiDialog mDialog;
- private WifiManager mWifiManager;
- private AccessPoint mDlgAccessPoint;
- private Bundle mAccessPointSavedState;
- private AccessPoint mSelectedAccessPoint;
- private Preference mAddNetworkPreference;
-
- private AccessPointPreference.UserBadgeCache mUserBadgeCache;
-
- // Instance state key
- private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.WIFI_SAVED_ACCESS_POINTS;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.wifi_display_saved_access_points);
- mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
- }
-
- @Override
- public void onResume() {
- super.onResume();
- initPreferences();
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
-
- if (savedInstanceState != null) {
- if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
- mAccessPointSavedState =
- savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
- }
- }
- }
-
- private void initPreferences() {
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- final Context context = getPrefContext();
-
- final List<AccessPoint> accessPoints =
- WifiSavedConfigUtils.getAllConfigs(context, mWifiManager);
- Collections.sort(accessPoints, SAVED_NETWORK_COMPARATOR);
- cacheRemoveAllPrefs(preferenceScreen);
-
- final int accessPointsSize = accessPoints.size();
- for (int i = 0; i < accessPointsSize; ++i) {
- AccessPoint ap = accessPoints.get(i);
- String key = ap.getKey();
- LongPressAccessPointPreference preference =
- (LongPressAccessPointPreference) getCachedPreference(key);
- if (preference == null) {
- preference = new LongPressAccessPointPreference(
- ap, context, mUserBadgeCache, true, this);
- preference.setKey(key);
- preference.setIcon(null);
- preferenceScreen.addPreference(preference);
- }
- preference.setOrder(i);
- }
-
- removeCachedPrefs(preferenceScreen);
-
- if (mAddNetworkPreference == null) {
- mAddNetworkPreference = new Preference(getPrefContext());
- mAddNetworkPreference.setIcon(R.drawable.ic_menu_add_inset);
- mAddNetworkPreference.setTitle(R.string.wifi_add_network);
- }
- mAddNetworkPreference.setOrder(accessPointsSize);
- preferenceScreen.addPreference(mAddNetworkPreference);
-
- if(getPreferenceScreen().getPreferenceCount() < 1) {
- Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
- }
- }
-
- private void postUpdatePreference() {
- if (!mHandler.hasMessages(MSG_UPDATE_PREFERENCES)) {
- mHandler.sendEmptyMessage(MSG_UPDATE_PREFERENCES);
- }
- }
-
- private void showWifiDialog(@Nullable LongPressAccessPointPreference accessPoint) {
- if (mDialog != null) {
- removeDialog(WifiSettings.WIFI_DIALOG_ID);
- mDialog = null;
- }
-
- if (accessPoint != null) {
- // Save the access point and edit mode
- mDlgAccessPoint = accessPoint.getAccessPoint();
- } else {
- // No access point is selected. Clear saved state.
- mDlgAccessPoint = null;
- mAccessPointSavedState = null;
- }
-
- showDialog(WifiSettings.WIFI_DIALOG_ID);
- }
-
- @Override
- public Dialog onCreateDialog(int dialogId) {
- switch (dialogId) {
- case WifiSettings.WIFI_DIALOG_ID:
- if (mDlgAccessPoint == null && mAccessPointSavedState == null) {
- // Add new network
- mDialog = WifiDialog.createFullscreen(getActivity(), this, null,
- WifiConfigUiBase.MODE_CONNECT);
- } else {
- // Modify network
- if (mDlgAccessPoint == null) {
- // Restore AP from save state
- mDlgAccessPoint = new AccessPoint(getActivity(), mAccessPointSavedState);
- // Reset the saved access point data
- mAccessPointSavedState = null;
- }
- mDialog = WifiDialog.createModal(getActivity(), this, mDlgAccessPoint,
- WifiConfigUiBase.MODE_VIEW);
- }
- mSelectedAccessPoint = mDlgAccessPoint;
-
- return mDialog;
- }
- return super.onCreateDialog(dialogId);
- }
-
- @Override
- public int getDialogMetricsCategory(int dialogId) {
- switch (dialogId) {
- case WifiSettings.WIFI_DIALOG_ID:
- return MetricsProto.MetricsEvent.DIALOG_WIFI_SAVED_AP_EDIT;
- default:
- return 0;
- }
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
-
- // If the dialog is showing, save its state.
- if (mDialog != null && mDialog.isShowing()) {
- if (mDlgAccessPoint != null) {
- mAccessPointSavedState = new Bundle();
- mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
- outState.putBundle(SAVE_DIALOG_ACCESS_POINT_STATE, mAccessPointSavedState);
- }
- }
- }
-
- @Override
- public void onForget(WifiDialog dialog) {
- if (mSelectedAccessPoint != null) {
- if (mSelectedAccessPoint.isPasspointConfig()) {
- try {
- mWifiManager.removePasspointConfiguration(
- mSelectedAccessPoint.getPasspointFqdn());
- } catch (RuntimeException e) {
- Log.e(TAG, "Failed to remove Passpoint configuration for "
- + mSelectedAccessPoint.getConfigName());
- }
- postUpdatePreference();
- } else {
- // mForgetListener will call initPreferences upon completion
- mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId, mForgetListener);
- }
- mSelectedAccessPoint = null;
- }
- }
-
- @Override
- public void onSubmit(WifiDialog dialog) {
- mWifiManager.save(dialog.getController().getConfig(), mSaveListener);
- }
-
- @Override
- public boolean onPreferenceTreeClick(Preference preference) {
- if (preference instanceof LongPressAccessPointPreference) {
- showWifiDialog((LongPressAccessPointPreference) preference);
- return true;
- } else if (preference == mAddNetworkPreference) {
- showWifiDialog(null);
- return true;
- } else {
- return super.onPreferenceTreeClick(preference);
- }
- }
-}
diff --git a/src/com/android/settings/wifi/WifiAPITest.java b/src/com/android/settings/wifi/WifiAPITest.java
index 9fc5ec4..52a54b7 100644
--- a/src/com/android/settings/wifi/WifiAPITest.java
+++ b/src/com/android/settings/wifi/WifiAPITest.java
@@ -18,7 +18,6 @@
import static android.content.Context.WIFI_SERVICE;
-import android.app.AlertDialog;
import android.content.DialogInterface;
import android.net.wifi.WifiManager;
import android.os.Bundle;
@@ -29,6 +28,7 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index 79500e0..a487017 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -27,11 +26,17 @@
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.wifi.AccessPoint;
-public class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterface.OnClickListener {
+import androidx.appcompat.app.AlertDialog;
+
+public class WifiDialog extends AlertDialog implements WifiConfigUiBase,
+ DialogInterface.OnClickListener {
public interface WifiDialogListener {
- void onForget(WifiDialog dialog);
- void onSubmit(WifiDialog dialog);
+ default void onForget(WifiDialog dialog) {
+ }
+
+ default void onSubmit(WifiDialog dialog) {
+ }
}
private static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;
@@ -64,7 +69,7 @@
}
/* package */ WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
- int mode, int style, boolean hideSubmitButton) {
+ int mode, int style, boolean hideSubmitButton) {
super(context, style);
mMode = mode;
mListener = listener;
@@ -81,7 +86,6 @@
protected void onCreate(Bundle savedInstanceState) {
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
setView(mView);
- setInverseBackgroundForced(true);
mController = new WifiConfigController(this, mView, mAccessPoint, mMode);
super.onCreate(savedInstanceState);
@@ -99,8 +103,8 @@
}
public void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- mController.updatePassword();
+ super.onRestoreInstanceState(savedInstanceState);
+ mController.updatePassword();
}
@Override
diff --git a/src/com/android/settings/wifi/WifiPickerActivity.java b/src/com/android/settings/wifi/WifiPickerActivity.java
index ca392ce..f7c4f79 100644
--- a/src/com/android/settings/wifi/WifiPickerActivity.java
+++ b/src/com/android/settings/wifi/WifiPickerActivity.java
@@ -21,6 +21,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.wifi.p2p.WifiP2pSettings;
+import com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings;
import androidx.preference.PreferenceFragmentCompat;
diff --git a/src/com/android/settings/wifi/WifiScanModeActivity.java b/src/com/android/settings/wifi/WifiScanModeActivity.java
index 4742f63..cdd4f5f 100644
--- a/src/com/android/settings/wifi/WifiScanModeActivity.java
+++ b/src/com/android/settings/wifi/WifiScanModeActivity.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -30,6 +29,7 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
diff --git a/src/com/android/settings/wifi/WifiScanningRequiredFragment.java b/src/com/android/settings/wifi/WifiScanningRequiredFragment.java
index 77636ae..a2e8b0e 100644
--- a/src/com/android/settings/wifi/WifiScanningRequiredFragment.java
+++ b/src/com/android/settings/wifi/WifiScanningRequiredFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
@@ -35,6 +34,7 @@
import com.android.settingslib.HelpUtils;
import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
public class WifiScanningRequiredFragment extends InstrumentedDialogFragment implements
DialogInterface.OnClickListener {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index e5ff3d9..28e10b2 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -231,7 +231,7 @@
Context prefContext = getPrefContext();
mAddPreference = new Preference(prefContext);
- mAddPreference.setIcon(R.drawable.ic_menu_add_inset);
+ mAddPreference.setIcon(R.drawable.ic_menu_add);
mAddPreference.setTitle(R.string.wifi_add_network);
mStatusMessagePreference = new LinkablePreference(prefContext);
diff --git a/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java b/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java
index 3fe22c2..55ad183 100644
--- a/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java
+++ b/src/com/android/settings/wifi/WriteWifiConfigToNfcDialog.java
@@ -17,7 +17,6 @@
package com.android.settings.wifi;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.wifi.WifiManager;
@@ -46,6 +45,8 @@
import java.io.IOException;
+import androidx.appcompat.app.AlertDialog;
+
class WriteWifiConfigToNfcDialog extends AlertDialog
implements TextWatcher, View.OnClickListener, CompoundButton.OnCheckedChangeListener {
@@ -96,7 +97,6 @@
mView = getLayoutInflater().inflate(R.layout.write_wifi_config_to_nfc, null);
setView(mView);
- setInverseBackgroundForced(true);
setTitle(R.string.setup_wifi_nfc_tag);
setCancelable(true);
setButton(DialogInterface.BUTTON_NEUTRAL,
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index e0868c7..6d34029 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -17,7 +17,6 @@
package com.android.settings.wifi.calling;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -47,6 +46,7 @@
import com.android.settings.Utils;
import com.android.settings.widget.SwitchBar;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceClickListener;
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index d291f9c..bda3b76 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -542,11 +542,6 @@
}
@Override
- public void onForget(WifiDialog dialog) {
- // can't forget network from a 'modify' dialog
- }
-
- @Override
public void onSubmit(WifiDialog dialog) {
if (dialog.getController() != null) {
mWifiManager.save(dialog.getController().getConfig(), new WifiManager.ActionListener() {
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
index 7ab43c7..3c2fa08 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
@@ -17,7 +17,6 @@
package com.android.settings.wifi.p2p;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -55,6 +54,7 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
new file mode 100644
index 0000000..dea4443
--- /dev/null
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.savedaccesspoints;
+
+
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.utils.PreferenceGroupChildrenCache;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.utils.ThreadUtils;
+import com.android.settingslib.wifi.AccessPoint;
+import com.android.settingslib.wifi.AccessPointPreference;
+import com.android.settingslib.wifi.AccessPointPreference.UserBadgeCache;
+import com.android.settingslib.wifi.WifiSavedConfigUtils;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Controller that manages a PreferenceGroup, which contains a list of saved access points.
+ */
+public class SavedAccessPointsPreferenceController extends BasePreferenceController implements
+ LifecycleObserver, OnStart, Preference.OnPreferenceClickListener,
+ WifiManager.ActionListener {
+
+ private static final String TAG = "SavedAPPrefCtrl";
+
+ private final WifiManager mWifiManager;
+ private final PreferenceGroupChildrenCache mChildrenCache;
+
+ private final UserBadgeCache mUserBadgeCache;
+ private PreferenceGroup mPreferenceGroup;
+ private SavedAccessPointsWifiSettings mHost;
+
+ public SavedAccessPointsPreferenceController(Context context,
+ String preferenceKey) {
+ super(context, preferenceKey);
+ mUserBadgeCache = new AccessPointPreference.UserBadgeCache(context.getPackageManager());
+ mWifiManager = context.getSystemService(WifiManager.class);
+ mChildrenCache = new PreferenceGroupChildrenCache();
+ }
+
+ public SavedAccessPointsPreferenceController setHost(SavedAccessPointsWifiSettings host) {
+ mHost = host;
+ return this;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public void onStart() {
+ refreshSavedAccessPoints();
+ }
+
+ public void postRefreshSavedAccessPoints() {
+ ThreadUtils.postOnMainThread(() -> refreshSavedAccessPoints());
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (mHost != null) {
+ mHost.showWifiDialog((AccessPointPreference) preference);
+ }
+ return false;
+ }
+
+ @Override
+ public void onSuccess() {
+ postRefreshSavedAccessPoints();
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ postRefreshSavedAccessPoints();
+ }
+
+ @VisibleForTesting
+ void refreshSavedAccessPoints() {
+ if (mPreferenceGroup == null) {
+ Log.w(TAG, "PreferenceGroup is null, skipping.");
+ return;
+ }
+ final Context prefContext = mPreferenceGroup.getContext();
+
+ final List<AccessPoint> accessPoints =
+ WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
+ Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
+ mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
+
+ final int accessPointsSize = accessPoints.size();
+ for (int i = 0; i < accessPointsSize; ++i) {
+ AccessPoint ap = accessPoints.get(i);
+ String key = ap.getKey();
+ AccessPointPreference preference =
+ (AccessPointPreference) mChildrenCache.getCachedPreference(key);
+ if (preference == null) {
+ preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
+ preference.setKey(key);
+ preference.setIcon(null);
+ preference.setOnPreferenceClickListener(this);
+ mPreferenceGroup.addPreference(preference);
+ }
+ preference.setOrder(i);
+ }
+
+ mChildrenCache.removeCachedPrefs(mPreferenceGroup);
+
+ if (mPreferenceGroup.getPreferenceCount() < 1) {
+ Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
+ }
+ }
+}
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
new file mode 100644
index 0000000..8f14ec2
--- /dev/null
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.savedaccesspoints;
+
+import android.annotation.Nullable;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.util.Log;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.wifi.WifiConfigUiBase;
+import com.android.settings.wifi.WifiDialog;
+import com.android.settings.wifi.WifiSettings;
+import com.android.settingslib.wifi.AccessPoint;
+import com.android.settingslib.wifi.AccessPointPreference;
+
+/**
+ * UI to manage saved networks/access points.
+ */
+public class SavedAccessPointsWifiSettings extends DashboardFragment
+ implements WifiDialog.WifiDialogListener, DialogInterface.OnCancelListener {
+
+ private static final String TAG = "SavedAccessPoints";
+
+ private WifiManager mWifiManager;
+ private Bundle mAccessPointSavedState;
+ private AccessPoint mSelectedAccessPoint;
+
+ // Instance state key
+ private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.WIFI_SAVED_ACCESS_POINTS;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.wifi_display_saved_access_points;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ mWifiManager = (WifiManager) getContext()
+ .getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ use(SavedAccessPointsPreferenceController.class)
+ .setHost(this);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (savedInstanceState != null) {
+ if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
+ mAccessPointSavedState =
+ savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
+ }
+ }
+ }
+
+ public void showWifiDialog(@Nullable AccessPointPreference accessPoint) {
+ removeDialog(WifiSettings.WIFI_DIALOG_ID);
+
+ if (accessPoint != null) {
+ // Save the access point and edit mode
+ mSelectedAccessPoint = accessPoint.getAccessPoint();
+ } else {
+ // No access point is selected. Clear saved state.
+ mSelectedAccessPoint = null;
+ mAccessPointSavedState = null;
+ }
+
+ showDialog(WifiSettings.WIFI_DIALOG_ID);
+ }
+
+ @Override
+ public Dialog onCreateDialog(int dialogId) {
+ switch (dialogId) {
+ case WifiSettings.WIFI_DIALOG_ID:
+ // Modify network
+ if (mSelectedAccessPoint == null) {
+ // Restore AP from save state
+ mSelectedAccessPoint = new AccessPoint(getActivity(), mAccessPointSavedState);
+ // Reset the saved access point data
+ mAccessPointSavedState = null;
+ }
+ final WifiDialog dialog = WifiDialog.createModal(
+ getActivity(), this, mSelectedAccessPoint, WifiConfigUiBase.MODE_VIEW);
+ dialog.setOnCancelListener(this);
+
+ return dialog;
+ }
+ return super.onCreateDialog(dialogId);
+ }
+
+ @Override
+ public int getDialogMetricsCategory(int dialogId) {
+ switch (dialogId) {
+ case WifiSettings.WIFI_DIALOG_ID:
+ return MetricsProto.MetricsEvent.DIALOG_WIFI_SAVED_AP_EDIT;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ // If the dialog is showing (indicated by the existence of mSelectedAccessPoint), then we
+ // save its state.
+ if (mSelectedAccessPoint != null) {
+ mAccessPointSavedState = new Bundle();
+ mSelectedAccessPoint.saveWifiState(mAccessPointSavedState);
+ outState.putBundle(SAVE_DIALOG_ACCESS_POINT_STATE, mAccessPointSavedState);
+ }
+ }
+
+ @Override
+ public void onForget(WifiDialog dialog) {
+ if (mSelectedAccessPoint != null) {
+ if (mSelectedAccessPoint.isPasspointConfig()) {
+ try {
+ mWifiManager.removePasspointConfiguration(
+ mSelectedAccessPoint.getPasspointFqdn());
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to remove Passpoint configuration for "
+ + mSelectedAccessPoint.getConfigName());
+ }
+ use(SavedAccessPointsPreferenceController.class)
+ .postRefreshSavedAccessPoints();
+ } else {
+ // mForgetListener will call initPreferences upon completion
+ mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId,
+ use(SavedAccessPointsPreferenceController.class));
+ }
+ mSelectedAccessPoint = null;
+ }
+ }
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ mSelectedAccessPoint = null;
+ }
+}
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedNetworkComparator.java b/src/com/android/settings/wifi/savedaccesspoints/SavedNetworkComparator.java
new file mode 100644
index 0000000..cff4387
--- /dev/null
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedNetworkComparator.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.savedaccesspoints;
+
+import android.icu.text.Collator;
+
+import com.android.settingslib.wifi.AccessPoint;
+
+import java.util.Comparator;
+
+public final class SavedNetworkComparator {
+ public static final Comparator<AccessPoint> INSTANCE =
+ new Comparator<AccessPoint>() {
+ final Collator mCollator = Collator.getInstance();
+
+ @Override
+ public int compare(AccessPoint ap1, AccessPoint ap2) {
+ return mCollator.compare(
+ nullToEmpty(ap1.getConfigName()), nullToEmpty(ap2.getConfigName()));
+ }
+
+ private String nullToEmpty(String string) {
+ return (string == null) ? "" : string;
+ }
+ };
+}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index a662f2f..37869e9 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -41,7 +41,6 @@
com.android.settings.fuelgauge.AdvancedPowerUsageDetail
com.android.settings.fuelgauge.BatteryHistoryDetail
com.android.settings.fuelgauge.InactiveApps
-com.android.settings.fuelgauge.PowerUsageAnomalyDetails
com.android.settings.fuelgauge.RestrictedAppDetails
com.android.settings.IccLockSettings
com.android.settings.inputmethod.InputMethodAndSubtypeEnabler
@@ -74,5 +73,5 @@
com.android.settings.wifi.ChangeWifiStateDetails
com.android.settings.wifi.details.WifiNetworkDetailsFragment
com.android.settings.wifi.p2p.WifiP2pSettings
-com.android.settings.wifi.SavedAccessPointsWifiSettings
+com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings
com.android.settings.wifi.WifiInfo
diff --git a/tests/robotests/assets/grandfather_not_implementing_instrumentable b/tests/robotests/assets/grandfather_not_implementing_instrumentable
index 27ab65c..2c8ae5d 100644
--- a/tests/robotests/assets/grandfather_not_implementing_instrumentable
+++ b/tests/robotests/assets/grandfather_not_implementing_instrumentable
@@ -5,5 +5,4 @@
com.android.settings.password.ChooseLockPattern$SaveAndFinishWorker
com.android.settings.RestrictedListPreference$RestrictedListPreferenceDialogFragment
com.android.settings.password.ConfirmDeviceCredentialBaseFragment$LastTryDialog
-com.android.settings.password.CredentialCheckResultTracker
-com.android.settings.localepicker.LocalePickerWithRegion
+com.android.settings.password.CredentialCheckResultTracker
\ No newline at end of file
diff --git a/tests/robotests/res/values/themes.xml b/tests/robotests/res/values/themes.xml
index 74bdd9b..9a247f6 100644
--- a/tests/robotests/res/values/themes.xml
+++ b/tests/robotests/res/values/themes.xml
@@ -1,5 +1,8 @@
<resources>
- <style name="Theme.Settings" parent="@android:style/Theme.DeviceDefault.Settings" />
+ <style name="Theme.Settings" parent="@android:style/Theme.DeviceDefault.Settings">
+ <!-- For AndroidX AlertDialogs -->
+ <item name="alertDialogTheme">@style/Theme.AppCompat.DayNight.Dialog.Alert</item>
+ </style>
<!-- Override the main app's style for ActionPrimaryButton to get around lack of new style
support in robolectric -->
diff --git a/tests/robotests/src/com/android/settings/RestrictedSettingsFragmentTest.java b/tests/robotests/src/com/android/settings/RestrictedSettingsFragmentTest.java
index 35f9e28..73be107 100644
--- a/tests/robotests/src/com/android/settings/RestrictedSettingsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/RestrictedSettingsFragmentTest.java
@@ -21,7 +21,6 @@
import static org.mockito.Mockito.verify;
import android.app.Activity;
-import android.app.AlertDialog;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -31,6 +30,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import androidx.appcompat.app.AlertDialog;
+
@RunWith(SettingsRobolectricTestRunner.class)
public class RestrictedSettingsFragmentTest {
diff --git a/tests/robotests/src/com/android/settings/SettingsActivityTest.java b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
index 1966467..d1033ea 100644
--- a/tests/robotests/src/com/android/settings/SettingsActivityTest.java
+++ b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
@@ -16,6 +16,7 @@
package com.android.settings;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -26,6 +27,7 @@
import android.app.ActivityManager;
import android.content.Intent;
+import com.android.settings.core.OnActivityResultListener;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
@@ -35,6 +37,10 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
+import java.util.List;
+
+import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
@@ -65,9 +71,34 @@
}
@Test
- public void testSetTaskDescription_IconChanged() {
+ public void setTaskDescription_shouldUpdateIcon() {
mActivity.setTaskDescription(mTaskDescription);
verify(mTaskDescription).setIcon(anyInt());
}
+
+ @Test
+ public void onActivityResult_shouldDelegateToListener() {
+ final List<Fragment> fragments = new ArrayList<>();
+ fragments.add(new Fragment());
+ fragments.add(new ListenerFragment());
+
+ final FragmentManager manager = mock(FragmentManager.class);
+ when(mActivity.getSupportFragmentManager()).thenReturn(manager);
+ when(manager.getFragments()).thenReturn(fragments);
+
+ mActivity.onActivityResult(0, 0, new Intent());
+
+ assertThat(((ListenerFragment) fragments.get(1)).mOnActivityResultCalled).isTrue();
+ }
+
+ public static class ListenerFragment extends Fragment implements OnActivityResultListener {
+
+ public boolean mOnActivityResultCalled;
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ mOnActivityResultCalled = true;
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java b/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java
index 3b3a287..281a6c9 100644
--- a/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java
+++ b/tests/robotests/src/com/android/settings/SettingsLicenseActivityTest.java
@@ -18,7 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -30,7 +29,6 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -84,9 +82,7 @@
}
@Test
- @Ignore("b/111194177")
public void testOnCreateWithGeneratedHtmlFile() {
- doReturn(null).when(mActivity).onCreateLoader(anyInt(), any());
doReturn(Uri.parse("content://com.android.settings.files/my_cache/generated_test.html"))
.when(mActivity).getUriFromGeneratedHtmlFile(any());
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
index afbf532..40dcf7a 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
@@ -31,6 +31,7 @@
import com.android.settings.R;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.testutils.Robolectric;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.accounts.AuthenticatorHelper;
import com.android.settingslib.drawer.CategoryKey;
@@ -38,7 +39,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
@@ -49,7 +49,7 @@
import androidx.fragment.app.FragmentActivity;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class AccountDashboardFragmentTest {
private AccountDashboardFragment mFragment;
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index 035d74e..0d905aa 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -22,7 +22,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -52,6 +51,7 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
index de2479a..dac9409 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.applications.appinfo;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
@@ -44,6 +45,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.widget.ActionButtonPreference;
import com.android.settings.widget.ActionButtonPreferenceTest;
import com.android.settingslib.applications.AppUtils;
@@ -59,12 +61,11 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.util.ReflectionHelpers;
import androidx.fragment.app.Fragment;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class AppButtonsPreferenceControllerTest {
private static final String PACKAGE_NAME = "com.android.settings";
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java
index 98bfcd5..80a696a 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java
@@ -21,12 +21,13 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
@@ -35,13 +36,13 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowAlertDialog;
-import org.robolectric.shadows.ShadowDialog;
+import org.robolectric.annotation.Config;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowAlertDialogCompat.class, SettingsShadowResourcesImpl.class})
public class ButtonActionDialogFragmentTest {
private static final int FORCE_STOP_ID = ButtonActionDialogFragment.DialogType.FORCE_STOP;
@@ -73,12 +74,12 @@
@Test
public void testOnCreateDialog_forceStopDialog() {
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(FORCE_STOP_ID);
-
FragmentTestUtils.startFragment(fragment);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
assertThat(dialog).isNotNull();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
mShadowContext.getString(R.string.force_stop_dlg_text));
@@ -93,12 +94,12 @@
@Test
public void testOnCreateDialog_disableDialog() {
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(DISABLE_ID);
-
FragmentTestUtils.startFragment(fragment);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
assertThat(dialog).isNotNull();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
mShadowContext.getString(R.string.app_disable_dlg_text));
@@ -111,13 +112,13 @@
@Test
public void testOnCreateDialog_specialDisableDialog() {
ButtonActionDialogFragment fragment =
- ButtonActionDialogFragment.newInstance(SPECIAL_DISABLE_ID);
-
+ ButtonActionDialogFragment.newInstance(SPECIAL_DISABLE_ID);
FragmentTestUtils.startFragment(fragment);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
assertThat(dialog).isNotNull();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
mShadowContext.getString(R.string.app_disable_dlg_text));
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragmentTest.java
index 1281b74..6b4a641 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/InstantAppButtonDialogFragmentTest.java
@@ -25,24 +25,27 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.testutils.FragmentTestUtils;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowAlertDialog;
-import org.robolectric.shadows.ShadowDialog;
+import org.robolectric.annotation.Config;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowAlertDialogCompat.class, SettingsShadowResourcesImpl.class})
public class InstantAppButtonDialogFragmentTest {
private static final String TEST_PACKAGE = "testPackage";
@@ -52,8 +55,10 @@
@Before
public void setUp() {
+ final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
mContext = spy(RuntimeEnvironment.application);
mFragment = spy(InstantAppButtonDialogFragment.newInstance(TEST_PACKAGE));
+ mFragment.show(activity.getSupportFragmentManager(), "InstantAppButtonDialogFragment");
doReturn(mContext).when(mFragment).getContext();
}
@@ -61,7 +66,6 @@
public void onClick_shouldDeleteApp() {
final PackageManager packageManager = mock(PackageManager.class);
when(mContext.getPackageManager()).thenReturn(packageManager);
- FragmentTestUtils.startFragment(mFragment);
mFragment.onClick(null /* dialog */, 0 /* which */);
@@ -71,11 +75,11 @@
@Test
public void onCreateDialog_clearAppDialog_shouldShowClearAppDataConfirmation() {
- FragmentTestUtils.startFragment(mFragment);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
assertThat(dialog).isNotNull();
- final ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+
+ final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
mContext.getString(R.string.clear_instant_app_confirmation));
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java
index f304b49..57d31cf 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultPhonePickerTest.java
@@ -29,6 +29,7 @@
import android.content.pm.PackageManager;
import android.os.UserManager;
+import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
@@ -53,6 +54,8 @@
private DefaultPhonePicker.DefaultKeyUpdater mDefaultKeyUpdater;
@Mock
private PackageManager mPackageManager;
+ @Mock
+ private BatteryUtils mBatteryUtils;
private DefaultPhonePicker mPicker;
@@ -66,6 +69,7 @@
ReflectionHelpers.setField(mPicker, "mPm", mPackageManager);
ReflectionHelpers.setField(mPicker, "mDefaultKeyUpdater", mDefaultKeyUpdater);
+ ReflectionHelpers.setField(mPicker, "mBatteryUtils", mBatteryUtils);
doReturn(RuntimeEnvironment.application).when(mPicker).getContext();
}
@@ -87,6 +91,14 @@
@Test
public void getDefaultAppKey_shouldReturnDefault() {
mPicker.getDefaultKey();
+
verify(mDefaultKeyUpdater).getDefaultDialerApplication(any(Context.class), anyInt());
}
+
+ @Test
+ public void setDefaultKey_shouldUnrestrictApp() {
+ mPicker.setDefaultKey(TEST_APP_KEY);
+
+ verify(mBatteryUtils).clearForceAppStandby(TEST_APP_KEY);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java
index 18bb60e..ade62a1 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultSmsPickerTest.java
@@ -28,6 +28,7 @@
import android.content.pm.PackageManager;
import android.os.UserManager;
+import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
@@ -52,6 +53,8 @@
private DefaultSmsPicker.DefaultKeyUpdater mDefaultKeyUpdater;
@Mock
private PackageManager mPackageManager;
+ @Mock
+ private BatteryUtils mBatteryUtils;
private DefaultSmsPicker mPicker;
@@ -64,6 +67,7 @@
ReflectionHelpers.setField(mPicker, "mPm", mPackageManager);
ReflectionHelpers.setField(mPicker, "mDefaultKeyUpdater", mDefaultKeyUpdater);
+ ReflectionHelpers.setField(mPicker, "mBatteryUtils", mBatteryUtils);
doReturn(RuntimeEnvironment.application).when(mPicker).getContext();
}
@@ -80,4 +84,11 @@
verify(mDefaultKeyUpdater).getDefaultApplication(any(Context.class));
}
+
+ @Test
+ public void setDefaultKey_shouldUnrestrictApp() {
+ mPicker.setDefaultKey(TEST_APP_KEY);
+
+ verify(mBatteryUtils).clearForceAppStandby(TEST_APP_KEY);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index d31e3e0..cc0308c 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -37,6 +37,9 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.os.Bundle;
import android.os.Looper;
import android.os.UserManager;
@@ -74,6 +77,14 @@
private ApplicationsState.Session mSession;
@Mock
private Menu mMenu;
+ @Mock
+ private FragmentActivity mActivity;
+ @Mock
+ private Resources mResources;
+ @Mock
+ private UserManager mUserManager;
+ @Mock
+ private PackageManager mPackageManager;
private MenuItem mAppReset;
private MenuItem mSortRecent;
private MenuItem mSortFrequent;
@@ -89,7 +100,11 @@
when(mState.newSession(any())).thenReturn(mSession);
when(mState.getBackgroundLooper()).thenReturn(Looper.myLooper());
- mFragment = new ManageApplications();
+ mFragment = spy(new ManageApplications());
+ when(mFragment.getActivity()).thenReturn(mActivity);
+ when(mActivity.getResources()).thenReturn(mResources);
+ when(mActivity.getSystemService(UserManager.class)).thenReturn(mUserManager);
+ when(mActivity.getPackageManager()).thenReturn(mPackageManager);
}
@Test
@@ -126,10 +141,8 @@
@Test
public void onCreateView_shouldNotShowLoadingContainer() {
- final ManageApplications fragment = spy(new ManageApplications());
- ReflectionHelpers.setField(fragment, "mResetAppsHelper",
- mock(ResetAppsHelper.class));
- doNothing().when(fragment).createHeader();
+ ReflectionHelpers.setField(mFragment, "mResetAppsHelper", mock(ResetAppsHelper.class));
+ doNothing().when(mFragment).createHeader();
final LayoutInflater layoutInflater = mock(LayoutInflater.class);
final View view = mock(View.class);
@@ -137,19 +150,17 @@
when(layoutInflater.inflate(anyInt(), eq(null))).thenReturn(view);
when(view.findViewById(R.id.loading_container)).thenReturn(loadingContainer);
- fragment.onCreateView(layoutInflater, mock(ViewGroup.class), null);
+ mFragment.onCreateView(layoutInflater, mock(ViewGroup.class), null);
verify(loadingContainer, never()).setVisibility(View.VISIBLE);
}
@Test
public void updateLoading_appLoaded_shouldNotDelayCallToHandleLoadingContainer() {
- final ManageApplications fragment = mock(ManageApplications.class);
- ReflectionHelpers.setField(fragment, "mLoadingContainer", mock(View.class));
- ReflectionHelpers.setField(fragment, "mListContainer", mock(View.class));
- when(fragment.getActivity()).thenReturn(mock(FragmentActivity.class));
+ ReflectionHelpers.setField(mFragment, "mLoadingContainer", mock(View.class));
+ ReflectionHelpers.setField(mFragment, "mListContainer", mock(View.class));
final ManageApplications.ApplicationsAdapter adapter =
- spy(new ManageApplications.ApplicationsAdapter(mState, fragment,
+ spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
final LoadingViewController loadingViewController =
mock(LoadingViewController.class);
@@ -168,12 +179,10 @@
@Test
public void updateLoading_appNotLoaded_shouldDelayCallToHandleLoadingContainer() {
- final ManageApplications fragment = mock(ManageApplications.class);
- ReflectionHelpers.setField(fragment, "mLoadingContainer", mock(View.class));
- ReflectionHelpers.setField(fragment, "mListContainer", mock(View.class));
- when(fragment.getActivity()).thenReturn(mock(FragmentActivity.class));
+ ReflectionHelpers.setField(mFragment, "mLoadingContainer", mock(View.class));
+ ReflectionHelpers.setField(mFragment, "mListContainer", mock(View.class));
final ManageApplications.ApplicationsAdapter adapter =
- spy(new ManageApplications.ApplicationsAdapter(mState, fragment,
+ spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
final LoadingViewController loadingViewController =
mock(LoadingViewController.class);
@@ -200,21 +209,19 @@
@Test
public void onRebuildComplete_shouldHideLoadingView() {
final Context context = RuntimeEnvironment.application;
- final ManageApplications fragment = mock(ManageApplications.class);
final RecyclerView recyclerView = mock(RecyclerView.class);
final View emptyView = mock(View.class);
- ReflectionHelpers.setField(fragment, "mRecyclerView", recyclerView);
- ReflectionHelpers.setField(fragment, "mEmptyView", emptyView);
+ ReflectionHelpers.setField(mFragment, "mRecyclerView", recyclerView);
+ ReflectionHelpers.setField(mFragment, "mEmptyView", emptyView);
final View loadingContainer = mock(View.class);
when(loadingContainer.getContext()).thenReturn(context);
final View listContainer = mock(View.class);
when(listContainer.getVisibility()).thenReturn(View.INVISIBLE);
when(listContainer.getContext()).thenReturn(context);
- ReflectionHelpers.setField(fragment, "mLoadingContainer", loadingContainer);
- ReflectionHelpers.setField(fragment, "mListContainer", listContainer);
- when(fragment.getActivity()).thenReturn(mock(FragmentActivity.class));
+ ReflectionHelpers.setField(mFragment, "mLoadingContainer", loadingContainer);
+ ReflectionHelpers.setField(mFragment, "mListContainer", listContainer);
final ManageApplications.ApplicationsAdapter adapter =
- spy(new ManageApplications.ApplicationsAdapter(mState, fragment,
+ spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
final LoadingViewController loadingViewController =
mock(LoadingViewController.class);
@@ -231,6 +238,8 @@
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
appList.add(mock(ApplicationsState.AppEntry.class));
when(mSession.getAllApps()).thenReturn(appList);
+ ReflectionHelpers.setField(
+ mFragment, "mFilterAdapter", mock(ManageApplications.FilterSpinnerAdapter.class));
adapter.onRebuildComplete(null);
@@ -241,8 +250,7 @@
public void notifyItemChange_recyclerViewIdle_shouldNotify() {
final RecyclerView recyclerView = mock(RecyclerView.class);
final ManageApplications.ApplicationsAdapter adapter =
- spy(new ManageApplications.ApplicationsAdapter(mState,
- mock(ManageApplications.class),
+ spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
adapter.onAttachedToRecyclerView(recyclerView);
@@ -256,8 +264,7 @@
public void notifyItemChange_recyclerViewScrolling_shouldNotifyWhenIdle() {
final RecyclerView recyclerView = mock(RecyclerView.class);
final ManageApplications.ApplicationsAdapter adapter =
- spy(new ManageApplications.ApplicationsAdapter(mState,
- mock(ManageApplications.class),
+ spy(new ManageApplications.ApplicationsAdapter(mState, mFragment,
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
adapter.onAttachedToRecyclerView(recyclerView);
@@ -273,20 +280,19 @@
@Test
public void applicationsAdapter_onBindViewHolder_updateSwitch_notifications() {
- ManageApplications manageApplications = mock(ManageApplications.class);
- when(manageApplications.getActivity()).thenReturn(mock(FragmentActivity.class));
- UserManager um = mock(UserManager.class);
- when(um.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
- ReflectionHelpers.setField(manageApplications, "mUserManager", um);
- manageApplications.mListType = LIST_TYPE_NOTIFICATION;
+ when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
+ ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
+ mFragment.mListType = LIST_TYPE_NOTIFICATION;
ApplicationViewHolder holder = mock(ApplicationViewHolder.class);
ReflectionHelpers.setField(holder, "itemView", mock(View.class));
ManageApplications.ApplicationsAdapter adapter =
new ManageApplications.ApplicationsAdapter(mState,
- manageApplications, mock(AppFilterItem.class),
+ mFragment, mock(AppFilterItem.class),
mock(Bundle.class));
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
- appList.add(mock(ApplicationsState.AppEntry.class));
+ final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
+ appEntry.info = mock(ApplicationInfo.class);
+ appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
adapter.onBindViewHolder(holder, 0);
@@ -295,19 +301,17 @@
@Test
public void applicationsAdapter_onBindViewHolder_updateSwitch_notNotifications() {
- ManageApplications manageApplications = mock(ManageApplications.class);
- manageApplications.mListType = LIST_TYPE_MAIN;
+ mFragment.mListType = LIST_TYPE_MAIN;
ApplicationViewHolder holder = mock(ApplicationViewHolder.class);
ReflectionHelpers.setField(holder, "itemView", mock(View.class));
- UserManager um = mock(UserManager.class);
- when(um.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
- ReflectionHelpers.setField(manageApplications, "mUserManager", um);
- ManageApplications.ApplicationsAdapter adapter =
- new ManageApplications.ApplicationsAdapter(mState,
- manageApplications, mock(AppFilterItem.class),
- mock(Bundle.class));
+ when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
+ ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
+ ManageApplications.ApplicationsAdapter adapter = new ManageApplications.ApplicationsAdapter(
+ mState, mFragment, mock(AppFilterItem.class), mock(Bundle.class));
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
- appList.add(mock(ApplicationsState.AppEntry.class));
+ final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
+ appEntry.info = mock(ApplicationInfo.class);
+ appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
adapter.onBindViewHolder(holder, 0);
@@ -316,23 +320,18 @@
@Test
public void sortOrderSavedOnRebuild() {
- ManageApplications manageApplications = mock(ManageApplications.class);
- when(manageApplications.getActivity()).thenReturn(mock(FragmentActivity.class));
- UserManager um = mock(UserManager.class);
- when(um.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
- ReflectionHelpers.setField(manageApplications, "mUserManager", um);
- manageApplications.mListType = LIST_TYPE_NOTIFICATION;
- manageApplications.mSortOrder = -1;
- ManageApplications.ApplicationsAdapter adapter =
- new ManageApplications.ApplicationsAdapter(mState,
- manageApplications, mock(AppFilterItem.class),
- mock(Bundle.class));
+ when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[]{});
+ ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
+ mFragment.mListType = LIST_TYPE_NOTIFICATION;
+ mFragment.mSortOrder = -1;
+ ManageApplications.ApplicationsAdapter adapter = new ManageApplications.ApplicationsAdapter(
+ mState, mFragment, mock(AppFilterItem.class), mock(Bundle.class));
adapter.rebuild(mSortRecent.getItemId());
- assertThat(manageApplications.mSortOrder).isEqualTo(mSortRecent.getItemId());
+ assertThat(mFragment.mSortOrder).isEqualTo(mSortRecent.getItemId());
adapter.rebuild(mSortFrequent.getItemId());
- assertThat(manageApplications.mSortOrder).isEqualTo(mSortFrequent.getItemId());
+ assertThat(mFragment.mSortOrder).isEqualTo(mSortFrequent.getItemId());
}
private void setUpOptionMenus() {
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAddTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAddTest.java
index e85f3f6..6bc143c 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAddTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAddTest.java
@@ -17,9 +17,13 @@
package com.android.settings.applications.specialaccess.deviceadmin;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -39,6 +43,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
public class DeviceAdminAddTest {
@@ -47,7 +52,6 @@
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private DeviceAdminInfo mDeviceAdmin;
- @Mock
private BatteryUtils mBatteryUtils;
private FakeFeatureFactory mFeatureFactory;
private DeviceAdminAdd mDeviceAdminAdd;
@@ -56,6 +60,8 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mBatteryUtils = spy(BatteryUtils.getInstance(RuntimeEnvironment.application));
+ doNothing().when(mBatteryUtils).setForceAppStandby(anyInt(), anyString(), anyInt());
mFeatureFactory = FakeFeatureFactory.setupForTest();
mDeviceAdminAdd = Robolectric.buildActivity(DeviceAdminAdd.class).get();
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java
index cf416d8..9479771 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/DeleteFingerprintDialogTest.java
@@ -26,6 +26,7 @@
import com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment;
import com.android.settings.biometrics.fingerprint.FingerprintSettings.FingerprintSettingsFragment.DeleteFingerprintDialog;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowFragment;
import com.android.settingslib.testutils.FragmentTestUtils;
@@ -37,7 +38,7 @@
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowFragment.class)
+@Config(shadows = {ShadowFragment.class, SettingsShadowResourcesImpl.class})
public class DeleteFingerprintDialogTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
index 38127ef..797a202 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensorTest.java
@@ -16,11 +16,9 @@
package com.android.settings.biometrics.fingerprint;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.RuntimeEnvironment.application;
-import android.app.AlertDialog;
import android.content.Intent;
import android.hardware.fingerprint.FingerprintManager;
import android.widget.Button;
@@ -30,6 +28,8 @@
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
import org.junit.After;
@@ -39,12 +39,17 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
-import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowAlertDialog;
+
+import androidx.appcompat.app.AlertDialog;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class, ShadowUtils.class})
+@Config(shadows = {
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowUtils.class,
+ ShadowAlertDialogCompat.class,
+ SettingsShadowResourcesImpl.class
+})
public class SetupFingerprintEnrollFindSensorTest {
@Mock
@@ -75,11 +80,12 @@
final Button skipButton = activity.findViewById(R.id.skip_button);
skipButton.performClick();
- final AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
- assertNotNull(alertDialog);
+ final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ assertThat(alertDialog).isNotNull();
- final ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog);
+ final ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(
+ alertDialog);
final int titleRes = R.string.setup_fingerprint_enroll_skip_title;
- assertEquals(application.getString(titleRes), shadowAlertDialog.getTitle());
+ assertThat(application.getString(titleRes)).isEqualTo(shadowAlertDialog.getTitle());
}
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index 1162f8e..6256a3d 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -27,11 +27,14 @@
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.os.UserManager;
+import android.view.ContextThemeWrapper;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -41,9 +44,11 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {SettingsShadowResourcesImpl.class, ShadowAlertDialogCompat.class})
public class BluetoothDevicePreferenceTest {
private static final boolean SHOW_DEVICES_WITHOUT_NAMES = true;
@@ -58,7 +63,8 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application.getApplicationContext());
+ Context context = spy(RuntimeEnvironment.application.getApplicationContext());
+ mContext = new ContextThemeWrapper(context, R.style.Theme_Settings);
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
index ede0b04..6cd924a 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java
@@ -26,7 +26,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.text.SpannableStringBuilder;
@@ -38,6 +37,8 @@
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
@@ -46,9 +47,12 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowAlertDialog;
+import org.robolectric.annotation.Config;
+
+import androidx.appcompat.app.AlertDialog;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowAlertDialogCompat.class, SettingsShadowResourcesImpl.class})
public class BluetoothPairingDialogTest {
private static final String FILLER = "text that goes in a view";
@@ -434,7 +438,7 @@
BluetoothPairingDialogFragment fragment = spy(new BluetoothPairingDialogFragment());
when(fragment.getPairingViewText()).thenReturn(existingText);
setupFragment(fragment);
- AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
+ AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
boolean expected = !TextUtils.isEmpty(existingText);
assertThat(dialog.getButton(Dialog.BUTTON_POSITIVE).isEnabled()).isEqualTo(expected);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
index 37abdcc..8532cc1 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
@@ -24,10 +24,9 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
-
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import org.junit.Before;
@@ -37,11 +36,14 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowDialog;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResourcesImpl.class)
public class ForgetDeviceDialogFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
index d41475f..2533341 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
@@ -22,13 +22,14 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.testutils.FragmentTestUtils;
@@ -40,11 +41,15 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowAlertDialog;
+import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
+import androidx.appcompat.app.AlertDialog;
+
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowAlertDialogCompat.class, SettingsShadowResourcesImpl.class})
public class LocalDeviceNameDialogFragmentTest {
+
@Mock
private LocalBluetoothManager mManager;
@Mock
@@ -75,7 +80,7 @@
@Test
public void diaglogTriggersShowSoftInput() {
FragmentTestUtils.startFragment(mFragment);
- AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
+ AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
View view = dialog.findViewById(R.id.edittext);
verify(mInputMethodManager).showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
index e257a88..0ecd295 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
@@ -25,7 +25,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.Button;
import android.widget.EditText;
@@ -33,6 +32,7 @@
import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.testutils.FragmentTestUtils;
@@ -42,9 +42,13 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowDialog;
+import androidx.appcompat.app.AlertDialog;
+
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResourcesImpl.class)
public class RemoteDeviceNameDialogFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
index a4cbc9d..3d7eb13 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
@@ -20,7 +20,9 @@
import static com.android.settings.dashboard.DashboardData.STABLE_ID_CONDITION_FOOTER;
import static com.android.settings.dashboard.DashboardData.STABLE_ID_SUGGESTION_CONDITION_DIVIDER;
import static com.android.settings.dashboard.DashboardData.STABLE_ID_SUGGESTION_CONTAINER;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -29,6 +31,7 @@
import com.android.settings.dashboard.conditional.AirplaneModeCondition;
import com.android.settings.dashboard.conditional.Condition;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
@@ -37,7 +40,6 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import java.util.ArrayList;
import java.util.Collections;
@@ -48,7 +50,7 @@
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListUpdateCallback;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class DashboardDataTest {
private static final String TEST_SUGGESTION_TITLE = "Use fingerprint";
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/HardwareInfoDialogFragmentTest.java b/tests/robotests/src/com/android/settings/deviceinfo/HardwareInfoDialogFragmentTest.java
index e17f6be..23ca244 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/HardwareInfoDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/HardwareInfoDialogFragmentTest.java
@@ -29,14 +29,17 @@
import com.android.settings.R;
import com.android.settings.testutils.Robolectric;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
import androidx.fragment.app.FragmentActivity;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = SettingsShadowResourcesImpl.class)
public class HardwareInfoDialogFragmentTest {
private FragmentActivity mActivity;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java
index d1215ec..49025a8 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeForgetTest.java
@@ -18,7 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
-import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.storage.VolumeRecord;
@@ -28,6 +27,7 @@
import com.android.settings.deviceinfo.PrivateVolumeForget.ForgetConfirmFragment;
import com.android.settings.testutils.Robolectric;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowStorageManager;
import org.junit.After;
@@ -36,10 +36,11 @@
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowStorageManager.class)
+@Config(shadows = {ShadowStorageManager.class, SettingsShadowResourcesImpl.class})
public class PrivateVolumeForgetTest {
private PrivateVolumeForget mFragment;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index e6b3499..e486807 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -45,8 +45,6 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.applications.LayoutPreference;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowActivityManager;
@@ -70,9 +68,6 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
-import java.util.ArrayList;
-import java.util.List;
-
import androidx.fragment.app.FragmentActivity;
import androidx.loader.app.LoaderManager;
import androidx.preference.Preference;
@@ -129,8 +124,6 @@
@Mock
private LoaderManager mLoaderManager;
@Mock
- private AnomalySummaryPreferenceController mAnomalySummaryPreferenceController;
- @Mock
private BatteryStats.Timer mForegroundActivityTimer;
@Mock
private BatteryUtils mBatteryUtils;
@@ -139,7 +132,6 @@
private Preference mBackgroundPreference;
private AdvancedPowerUsageDetail mFragment;
private SettingsActivity mTestActivity;
- private List<Anomaly> mAnomalies;
@Before
public void setUp() {
@@ -216,11 +208,6 @@
mBackgroundPreference = new Preference(mContext);
mFragment.mForegroundPreference = mForegroundPreference;
mFragment.mBackgroundPreference = mBackgroundPreference;
- mFragment.mAnomalySummaryPreferenceController = mAnomalySummaryPreferenceController;
-
- mAnomalies = new ArrayList<>();
- mAnomalies.add(new Anomaly.Builder().setUid(UID).setType(
- Anomaly.AnomalyType.WAKE_LOCK).build());
}
@After
@@ -275,7 +262,7 @@
@Test
public void testStartBatteryDetailPage_hasBasicData() {
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils, mFragment,
- mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, mAnomalies);
+ mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT);
assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_UID)).isEqualTo(UID);
assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME))
@@ -284,8 +271,6 @@
.isEqualTo(FOREGROUND_TIME_MS);
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT))
.isEqualTo(USAGE_PERCENT);
- assertThat(mBundle.getParcelableArrayList(
- AdvancedPowerUsageDetail.EXTRA_ANOMALY_LIST)).isEqualTo(mAnomalies);
}
@Test
@@ -294,7 +279,7 @@
mBatterySipper.usageTimeMs = PHONE_FOREGROUND_TIME_MS;
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils, mFragment,
- mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, null);
+ mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT);
assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_UID)).isEqualTo(UID);
assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME))
@@ -303,8 +288,6 @@
.isEqualTo(PHONE_BACKGROUND_TIME_MS);
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT))
.isEqualTo(USAGE_PERCENT);
- assertThat(mBundle.getParcelableArrayList(
- AdvancedPowerUsageDetail.EXTRA_ANOMALY_LIST)).isNull();
}
@Test
@@ -312,25 +295,21 @@
mBatterySipper.mPackages = PACKAGE_NAME;
mBatteryEntry.defaultPackageName = PACKAGE_NAME[0];
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils, mFragment,
- mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, mAnomalies);
+ mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT);
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME)).isEqualTo(
PACKAGE_NAME[0]);
- assertThat(mBundle.getParcelableArrayList(
- AdvancedPowerUsageDetail.EXTRA_ANOMALY_LIST)).isEqualTo(mAnomalies);
}
@Test
public void testStartBatteryDetailPage_SystemApp() {
mBatterySipper.mPackages = null;
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils, mFragment,
- mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, null);
+ mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT);
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_LABEL)).isEqualTo(APP_LABEL);
assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_ICON_ID)).isEqualTo(ICON_ID);
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME)).isNull();
- assertThat(mBundle.getParcelableArrayList(
- AdvancedPowerUsageDetail.EXTRA_ANOMALY_LIST)).isNull();
}
@Test
@@ -339,8 +318,7 @@
mBatterySipper.mPackages = PACKAGE_NAME;
doReturn(appUid).when(mBatterySipper).getUid();
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils, mFragment,
- mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, null);
-
+ mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT);
verify(mActivity).startActivityAsUser(any(Intent.class), eq(new UserHandle(10)));
}
@@ -353,7 +331,7 @@
final int currentUser = 20;
ShadowActivityManager.setCurrentUser(currentUser);
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils, mFragment,
- mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, null);
+ mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT);
verify(mActivity).startActivityAsUser(any(Intent.class), eq(new UserHandle(currentUser)));
}
@@ -391,7 +369,7 @@
mBatteryEntry.sipper.mPackages = PACKAGE_NAME;
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mBatteryUtils, mFragment,
- mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, null);
+ mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT);
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME))
.isEqualTo(PACKAGE_NAME[0]);
@@ -416,24 +394,4 @@
assertThat(mForegroundPreference.getSummary().toString()).isEqualTo("Used for 0 min");
assertThat(mBackgroundPreference.getSummary().toString()).isEqualTo("Active for 0 min");
}
-
- @Test
- public void testInitAnomalyInfo_anomalyNull_startAnomalyLoader() {
- doReturn(null).when(mBundle)
- .getParcelableArrayList(AdvancedPowerUsageDetail.EXTRA_ANOMALY_LIST);
-
- mFragment.initAnomalyInfo();
-
- verify(mLoaderManager).initLoader(eq(0), eq(Bundle.EMPTY), any());
- }
-
- @Test
- public void testInitAnomalyInfo_anomalyExisted_updateAnomaly() {
- doReturn(mAnomalies).when(mBundle)
- .getParcelableArrayList(AdvancedPowerUsageDetail.EXTRA_ANOMALY_LIST);
-
- mFragment.initAnomalyInfo();
-
- verify(mAnomalySummaryPreferenceController).updateAnomalySummaryPreference(mAnomalies);
- }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AutoRestrictionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AutoRestrictionPreferenceControllerTest.java
index a6790fd..406ed77 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AutoRestrictionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AutoRestrictionPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.doReturn;
import android.content.Context;
@@ -24,17 +25,17 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.SwitchPreference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class AutoRestrictionPreferenceControllerTest {
private static final int ON = 1;
private static final int OFF = 0;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
index 3dee0a6..1a3155d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BackgroundActivityPreferenceControllerTest.java
@@ -35,6 +35,7 @@
import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowFragment;
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
@@ -45,13 +46,12 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import androidx.preference.Preference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class, ShadowFragment.class})
public class BackgroundActivityPreferenceControllerTest {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
index dc7c205..c29a012 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -24,31 +25,25 @@
import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateUtils;
-import android.util.FeatureFlagUtils;
-import android.util.SparseArray;
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatteryStatsImpl;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import java.util.List;
-
import androidx.preference.PreferenceGroup;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class BatteryAppListPreferenceControllerTest {
private static final String[] PACKAGE_NAMES = {"com.app1", "com.app2"};
@@ -168,21 +163,6 @@
}
@Test
- public void testRefreshAnomalyIcon_containsAnomaly_showAnomalyIcon() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlags.BATTERY_DISPLAY_APP_LIST, true);
- PowerGaugePreference preference = new PowerGaugePreference(mContext);
- final String key = mPreferenceController.extractKeyFromUid(UID);
- final SparseArray<List<Anomaly>> anomalySparseArray = new SparseArray<>();
- anomalySparseArray.append(UID, null);
- preference.setKey(key);
- doReturn(preference).when(mAppListGroup).findPreference(key);
-
- mPreferenceController.refreshAnomalyIcon(anomalySparseArray);
-
- assertThat(preference.showAnomalyIcon()).isTrue();
- }
-
- @Test
public void testShouldHideSipper_typeOvercounted_returnTrue() {
mNormalBatterySipper.drainType = BatterySipper.DrainType.OVERCOUNTED;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
index 30999cb..58bfe0e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.spy;
import android.content.Context;
@@ -26,19 +27,19 @@
import com.android.settings.fuelgauge.batterytip.AppInfo;
import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
import java.util.List;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class BatteryDatabaseManagerTest {
private static String PACKAGE_NAME_NEW = "com.android.app1";
private static int UID_NEW = 345;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
index b89a3f0..7bb0848 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
@@ -16,6 +16,7 @@
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -30,6 +31,7 @@
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatterySipper.DrainType;
import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Rule;
@@ -38,12 +40,11 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.util.Locale;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class BatteryEntryTest {
private static final int APP_UID = 123;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
index abf05af..d8ee8f6 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryOptimizationPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
@@ -29,6 +30,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
import org.junit.Before;
@@ -36,13 +38,12 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class BatteryOptimizationPreferenceControllerTest {
private static final String PKG_IN_WHITELIST = "com.pkg.in.whitelist";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
index 801a5e5..df34b78 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -51,8 +51,6 @@
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.R;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.fuelgauge.batterytip.AnomalyInfo;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -429,16 +427,6 @@
}
@Test
- public void testGetSummaryResIdFromAnomalyType() {
- assertThat(mBatteryUtils.getSummaryResIdFromAnomalyType(Anomaly.AnomalyType.WAKE_LOCK))
- .isEqualTo(R.string.battery_abnormal_wakelock_summary);
- assertThat(mBatteryUtils.getSummaryResIdFromAnomalyType(Anomaly.AnomalyType.WAKEUP_ALARM))
- .isEqualTo(R.string.battery_abnormal_wakeup_alarm_summary);
- assertThat(mBatteryUtils.getSummaryResIdFromAnomalyType(Anomaly.AnomalyType.BLUETOOTH_SCAN))
- .isEqualTo(R.string.battery_abnormal_location_summary);
- }
-
- @Test
public void testGetForegroundActivityTotalTimeMs_returnMilliseconds() {
final long rawRealtimeUs = SystemClock.elapsedRealtime() * 1000;
doReturn(mTimer).when(mUid).getForegroundActivityTimer();
@@ -665,4 +653,35 @@
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, UID,
mAnomalyInfo)).isTrue();
}
+
+ @Test
+ public void clearForceAppStandby_appRestricted_clearAndReturnTrue() {
+ when(mBatteryUtils.getPackageUid(HIGH_SDK_PACKAGE)).thenReturn(UID);
+ when(mAppOpsManager.checkOpNoThrow(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UID,
+ HIGH_SDK_PACKAGE)).thenReturn(AppOpsManager.MODE_IGNORED);
+
+ assertThat(mBatteryUtils.clearForceAppStandby(HIGH_SDK_PACKAGE)).isTrue();
+ verify(mAppOpsManager).setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UID,
+ HIGH_SDK_PACKAGE, AppOpsManager.MODE_ALLOWED);
+ }
+
+ @Test
+ public void clearForceAppStandby_appInvalid_returnFalse() {
+ when(mBatteryUtils.getPackageUid(PACKAGE_NAME)).thenReturn(BatteryUtils.UID_NULL);
+
+ assertThat(mBatteryUtils.clearForceAppStandby(PACKAGE_NAME)).isFalse();
+ verify(mAppOpsManager, never()).setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UID,
+ PACKAGE_NAME, AppOpsManager.MODE_ALLOWED);
+ }
+
+ @Test
+ public void clearForceAppStandby_appUnrestricted_returnFalse() {
+ when(mBatteryUtils.getPackageUid(PACKAGE_NAME)).thenReturn(UID);
+ when(mAppOpsManager.checkOpNoThrow(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UID,
+ PACKAGE_NAME)).thenReturn(AppOpsManager.MODE_ALLOWED);
+
+ assertThat(mBatteryUtils.clearForceAppStandby(PACKAGE_NAME)).isFalse();
+ verify(mAppOpsManager, never()).setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UID,
+ PACKAGE_NAME, AppOpsManager.MODE_ALLOWED);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetailsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetailsTest.java
deleted file mode 100644
index 0fb004c..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAnomalyDetailsTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge;
-
-import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-import android.util.IconDrawableFactory;
-
-import com.android.settings.SettingsActivity;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceManager;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class PowerUsageAnomalyDetailsTest {
-
- private static final String NAME_APP_1 = "app1";
- private static final String NAME_APP_2 = "app2";
- private static final String NAME_APP_3 = "app3";
- private static final String PACKAGE_NAME_1 = "com.android.app1";
- private static final String PACKAGE_NAME_2 = "com.android.app2";
- private static final String PACKAGE_NAME_3 = "com.android.app3";
-
- @Mock
- private SettingsActivity mSettingsActivity;
- @Mock
- private PreferenceManager mPreferenceManager;
- @Mock
- private Drawable mDrawable1;
- @Mock
- private Drawable mDrawable2;
- @Mock
- private Drawable mDrawable3;
- @Mock
- private PackageManager mPackageManager;
- @Mock
- private IconDrawableFactory mIconDrawableFactory;
-
- private PowerUsageAnomalyDetails mFragment;
- private PreferenceGroup mAbnormalListGroup;
- private List<Anomaly> mAnomalyList;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mAbnormalListGroup = spy(new PreferenceCategory(RuntimeEnvironment.application));
-
- mAnomalyList = new ArrayList<>();
- Anomaly anomaly1 = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKE_LOCK)
- .setPackageName(PACKAGE_NAME_1)
- .setDisplayName(NAME_APP_1)
- .build();
- mAnomalyList.add(anomaly1);
- Anomaly anomaly2 = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setPackageName(PACKAGE_NAME_2)
- .setDisplayName(NAME_APP_2)
- .build();
- mAnomalyList.add(anomaly2);
- Anomaly anomaly3 = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.BLUETOOTH_SCAN)
- .setPackageName(PACKAGE_NAME_3)
- .setDisplayName(NAME_APP_3)
- .build();
- mAnomalyList.add(anomaly3);
-
- mFragment = spy(new PowerUsageAnomalyDetails());
- mFragment.mAbnormalListGroup = mAbnormalListGroup;
- mFragment.mAnomalies = mAnomalyList;
- mFragment.mBatteryUtils = new BatteryUtils(RuntimeEnvironment.application);
- mFragment.mPackageManager = mPackageManager;
- mFragment.mIconDrawableFactory = mIconDrawableFactory;
- when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
- when(mPreferenceManager.getContext()).thenReturn(RuntimeEnvironment.application);
- }
-
- @Test
- public void testRefreshUi_displayCorrectTitleAndSummary() {
- final List<Preference> testPreferences = new ArrayList<>();
- final ArgumentCaptor<Preference> preferenceCaptor =
- ArgumentCaptor.forClass(Preference.class);
- Answer<Void> prefCallable = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- testPreferences.add(preferenceCaptor.getValue());
- return null;
- }
- };
- doAnswer(prefCallable).when(mAbnormalListGroup).addPreference(preferenceCaptor.capture());
-
- mFragment.refreshUi();
-
- final Preference wakelockPreference = testPreferences.get(0);
- assertThat(wakelockPreference.getTitle()).isEqualTo(NAME_APP_1);
- assertThat(wakelockPreference.getSummary()).isEqualTo("Keeping device awake");
- final Preference wakeupPreference = testPreferences.get(1);
- assertThat(wakeupPreference.getTitle()).isEqualTo(NAME_APP_2);
- assertThat(wakeupPreference.getSummary()).isEqualTo("Waking up device in background");
- final Preference bluetoothPreference = testPreferences.get(2);
- assertThat(bluetoothPreference.getTitle()).isEqualTo(NAME_APP_3);
- assertThat(bluetoothPreference.getSummary()).isEqualTo("Requesting location frequently");
- }
-
- @Test
- public void testRefreshUi_iconCorrect() {
- doReturn(mDrawable1).when(mFragment).getBadgedIcon(eq(PACKAGE_NAME_1), anyInt());
- doReturn(mDrawable2).when(mFragment).getBadgedIcon(eq(PACKAGE_NAME_2), anyInt());
- doReturn(mDrawable3).when(mFragment).getBadgedIcon(eq(PACKAGE_NAME_3), anyInt());
-
- final List<Drawable> testIcons = new ArrayList<>();
- final ArgumentCaptor<Preference> preferenceCaptor = ArgumentCaptor.forClass(
- Preference.class);
- Answer<Void> prefCallable = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- testIcons.add(preferenceCaptor.getValue().getIcon());
- return null;
- }
- };
- doAnswer(prefCallable).when(mAbnormalListGroup).addPreference(preferenceCaptor.capture());
-
- mFragment.refreshUi();
-
- assertThat(testIcons).containsExactly(mDrawable1, mDrawable2, mDrawable3);
- }
-
- @Test
- public void testStartBatteryAbnormalPage_dataCorrect() {
- final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
-
- PowerUsageAnomalyDetails.startBatteryAbnormalPage(mSettingsActivity, mFragment,
- mAnomalyList);
-
- verify(mSettingsActivity).startActivity(intent.capture());
- assertThat(intent.getValue().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS)
- .getParcelableArrayList(PowerUsageAnomalyDetails.EXTRA_ANOMALY_LIST))
- .isEqualTo(mAnomalyList);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 22b042e..97e272b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -34,7 +34,6 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.util.SparseArray;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -46,7 +45,6 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.applications.LayoutPreference;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -240,23 +238,6 @@
}
@Test
- public void updateAnomalySparseArray() {
- mFragment.mAnomalySparseArray = new SparseArray<>();
- final List<Anomaly> anomalies = new ArrayList<>();
- final Anomaly anomaly1 = new Anomaly.Builder().setUid(UID).build();
- final Anomaly anomaly2 = new Anomaly.Builder().setUid(UID).build();
- final Anomaly anomaly3 = new Anomaly.Builder().setUid(UID_2).build();
- anomalies.add(anomaly1);
- anomalies.add(anomaly2);
- anomalies.add(anomaly3);
-
- mFragment.updateAnomalySparseArray(anomalies);
-
- assertThat(mFragment.mAnomalySparseArray.get(UID)).containsExactly(anomaly1, anomaly2);
- assertThat(mFragment.mAnomalySparseArray.get(UID_2)).containsExactly(anomaly3);
- }
-
- @Test
public void restartBatteryTipLoader() {
//TODO: add policy logic here when BatteryTipPolicy is implemented
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
index 81cf652..267f263 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
@@ -18,7 +18,9 @@
import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT;
import static com.android.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -33,6 +35,7 @@
import com.android.settings.R;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -40,7 +43,6 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
@@ -48,7 +50,7 @@
import androidx.preference.Preference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class RestrictAppPreferenceControllerTest {
private static final int ALLOWED_UID = 111;
private static final String ALLOWED_PACKAGE_NAME = "com.android.allowed.package";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
index 1cc027f..b9ed509 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedAppDetailsTest.java
@@ -21,7 +21,6 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -38,6 +37,8 @@
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
@@ -47,18 +48,18 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowAlertDialog;
-import org.robolectric.shadows.ShadowDialog;
+import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.CheckBoxPreference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowAlertDialogCompat.class, SettingsShadowResourcesImpl.class})
public class RestrictedAppDetailsTest {
private static final String PACKAGE_NAME = "com.android.app";
@@ -154,8 +155,8 @@
FragmentTestUtils.startFragment(dialogFragment);
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict app?");
}
@@ -166,8 +167,8 @@
FragmentTestUtils.startFragment(dialogFragment);
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Remove restriction?");
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
index d7db331..971de7a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.doReturn;
import android.content.ContentResolver;
@@ -25,17 +26,17 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.SwitchPreference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class SmartBatteryPreferenceControllerTest {
private static final int ON = 1;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
deleted file mode 100644
index f209fd7..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDetectionPolicyTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-
-import android.content.Context;
-import android.provider.Settings;
-import android.text.format.DateUtils;
-import android.util.KeyValueListParser;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class AnomalyDetectionPolicyTest {
-
- private static final String ANOMALY_DETECTION_CONSTANTS_VALUE =
- "anomaly_detection_enabled=true"
- + ",wakelock_enabled=false"
- + ",wakelock_threshold=3000"
- + ",wakeup_alarm_enabled=true"
- + ",wakeup_alarm_threshold=100"
- + ",wakeup_blacklisted_tags=tag1:tag2:with%2Ccomma:with%3Acolon"
- + ",bluetooth_scan_enabled=true"
- + ",bluetooth_scan_threshold=2000";
- private Context mContext;
- private KeyValueListParser mKeyValueListParser;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mKeyValueListParser = spy((new KeyValueListParser(',')));
- }
-
- @Test
- public void testInit_usesConfigValues() {
- AnomalyDetectionPolicy anomalyDetectionPolicy = createAnomalyPolicyWithConfig();
-
- assertThat(anomalyDetectionPolicy.anomalyDetectionEnabled).isTrue();
- assertThat(anomalyDetectionPolicy.wakeLockDetectionEnabled).isFalse();
- assertThat(anomalyDetectionPolicy.wakeLockThreshold).isEqualTo(3000);
- assertThat(anomalyDetectionPolicy.wakeupAlarmDetectionEnabled).isTrue();
- assertThat(anomalyDetectionPolicy.wakeupAlarmThreshold).isEqualTo(100);
- assertThat(anomalyDetectionPolicy.wakeupBlacklistedTags)
- .containsExactly("tag1", "tag2", "with,comma", "with:colon");
- assertThat(anomalyDetectionPolicy.bluetoothScanDetectionEnabled).isTrue();
- assertThat(anomalyDetectionPolicy.bluetoothScanThreshold).isEqualTo(2000);
- }
-
- @Test
- public void testInit_defaultValues() {
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.ANOMALY_DETECTION_CONSTANTS, "");
- // Mock it to avoid noSuchMethodError
- doReturn(true).when(mKeyValueListParser).getBoolean(anyString(), eq(true));
- doReturn(false).when(mKeyValueListParser).getBoolean(anyString(), eq(false));
-
- AnomalyDetectionPolicy anomalyDetectionPolicy = new AnomalyDetectionPolicy(mContext);
- ReflectionHelpers.setField(anomalyDetectionPolicy, "mParser", mKeyValueListParser);
-
- assertThat(anomalyDetectionPolicy.anomalyDetectionEnabled).isFalse();
- assertThat(anomalyDetectionPolicy.wakeLockDetectionEnabled).isFalse();
- assertThat(anomalyDetectionPolicy.wakeLockThreshold).isEqualTo(DateUtils.HOUR_IN_MILLIS);
- assertThat(anomalyDetectionPolicy.wakeupAlarmDetectionEnabled).isFalse();
- assertThat(anomalyDetectionPolicy.wakeupAlarmThreshold).isEqualTo(10);
- assertThat(anomalyDetectionPolicy.wakeupBlacklistedTags).isNull();
- assertThat(anomalyDetectionPolicy.bluetoothScanDetectionEnabled).isFalse();
- assertThat(anomalyDetectionPolicy.bluetoothScanThreshold)
- .isEqualTo(30 * DateUtils.MINUTE_IN_MILLIS);
- }
-
- @Test
- public void testIsAnomalyDetectorEnabled_usesConfigValues() {
- AnomalyDetectionPolicy policy = createAnomalyPolicyWithConfig();
-
- assertThat(policy.isAnomalyDetectorEnabled(Anomaly.AnomalyType.WAKE_LOCK)).isFalse();
- assertThat(policy.isAnomalyDetectorEnabled(Anomaly.AnomalyType.WAKEUP_ALARM)).isTrue();
- assertThat(policy.isAnomalyDetectorEnabled(Anomaly.AnomalyType.BLUETOOTH_SCAN)).isTrue();
- }
-
- @Test
- public void testIsAnomalyDetectorEnabled_usesDefaultValues() {
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.ANOMALY_DETECTION_CONSTANTS, "");
- // Mock it to avoid noSuchMethodError
- doReturn(true).when(mKeyValueListParser).getBoolean(anyString(), eq(true));
- doReturn(false).when(mKeyValueListParser).getBoolean(anyString(), eq(false));
-
- AnomalyDetectionPolicy policy = new AnomalyDetectionPolicy(mContext);
- ReflectionHelpers.setField(policy, "mParser", mKeyValueListParser);
-
- assertThat(policy.isAnomalyDetectorEnabled(Anomaly.AnomalyType.WAKE_LOCK)).isFalse();
- assertThat(policy.isAnomalyDetectorEnabled(Anomaly.AnomalyType.WAKEUP_ALARM)).isFalse();
- assertThat(policy.isAnomalyDetectorEnabled(Anomaly.AnomalyType.BLUETOOTH_SCAN)).isFalse();
- }
-
- private AnomalyDetectionPolicy createAnomalyPolicyWithConfig() {
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.ANOMALY_DETECTION_CONSTANTS, ANOMALY_DETECTION_CONSTANTS_VALUE);
- // Mock it to avoid noSuchMethodError
- doReturn(true).when(mKeyValueListParser)
- .getBoolean(AnomalyDetectionPolicy.KEY_ANOMALY_DETECTION_ENABLED, false);
- doReturn(false).when(mKeyValueListParser)
- .getBoolean(AnomalyDetectionPolicy.KEY_WAKELOCK_DETECTION_ENABLED, false);
- doReturn(true).when(mKeyValueListParser)
- .getBoolean(AnomalyDetectionPolicy.KEY_WAKEUP_ALARM_DETECTION_ENABLED, false);
- doReturn(true).when(mKeyValueListParser)
- .getBoolean(AnomalyDetectionPolicy.KEY_BLUETOOTH_SCAN_DETECTION_ENABLED, false);
-
- final AnomalyDetectionPolicy policy = new AnomalyDetectionPolicy(mContext);
- ReflectionHelpers.setField(policy, "mParser", mKeyValueListParser);
- return policy;
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
deleted file mode 100644
index c68b438..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.pm.permission.RuntimePermissionPresenter;
-import android.os.Build;
-
-import com.android.settings.R;
-import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowRuntimePermissionPresenter;
-import com.android.settingslib.testutils.FragmentTestUtils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowAlertDialog;
-import org.robolectric.shadows.ShadowDialog;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowRuntimePermissionPresenter.class)
-public class AnomalyDialogFragmentTest {
-
- private static final String PACKAGE_NAME = "com.android.app";
- private static final String DISPLAY_NAME = "app";
- private static final int UID = 111;
-
- @Mock
- private AnomalyUtils mAnomalyUtils;
- @Mock
- private AnomalyAction mAnomalyAction;
- @Mock
- private RuntimePermissionPresenter mRuntimePermissionPresenter;
- private Anomaly mWakeLockAnomaly;
- private Anomaly mWakeupAlarmAnomaly;
- private Anomaly mWakeupAlarmAnomaly2;
- private Anomaly mBluetoothAnomaly;
- private AnomalyDialogFragment mAnomalyDialogFragment;
- private Context mContext;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = spy(RuntimeEnvironment.application);
- mWakeLockAnomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKE_LOCK)
- .setUid(UID)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .build();
- mWakeupAlarmAnomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setUid(UID)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .build();
- mWakeupAlarmAnomaly2 = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setUid(UID)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .setTargetSdkVersion(Build.VERSION_CODES.O)
- .build();
- mBluetoothAnomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.BLUETOOTH_SCAN)
- .setUid(UID)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .build();
- FakeFeatureFactory.setupForTest();
- ShadowRuntimePermissionPresenter.setRuntimePermissionPresenter(mRuntimePermissionPresenter);
- }
-
- @Test
- public void testOnCreateDialog_hasCorrectData() {
- mAnomalyDialogFragment =
- AnomalyDialogFragment.newInstance(mWakeLockAnomaly, 0 /* metricskey */);
- FragmentTestUtils.startFragment(mAnomalyDialogFragment);
-
- assertThat(mAnomalyDialogFragment.mAnomaly).isEqualTo(mWakeLockAnomaly);
- }
-
- @Test
- public void testOnCreateDialog_wakelockAnomaly_fireForceStopDialog() {
- mAnomalyDialogFragment =
- AnomalyDialogFragment.newInstance(mWakeLockAnomaly, 0 /* metricskey */);
-
- FragmentTestUtils.startFragment(mAnomalyDialogFragment);
-
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- assertThat(dialog).isNotNull();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
-
- assertThat(shadowDialog.getMessage()).isEqualTo(
- mContext.getString(R.string.dialog_stop_message, mWakeLockAnomaly.displayName));
- assertThat(shadowDialog.getTitle()).isEqualTo(
- mContext.getString(R.string.dialog_stop_title));
- assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(
- mContext.getString(R.string.dialog_stop_ok));
- assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(
- mContext.getString(R.string.dlg_cancel));
- }
-
- @Test
- public void testOnCreateDialog_wakeupAlarmAnomalyPriorO_fireStopAndBackgroundCheckDialog() {
- mAnomalyDialogFragment =
- AnomalyDialogFragment.newInstance(mWakeupAlarmAnomaly, 0 /* metricskey */);
-
- FragmentTestUtils.startFragment(mAnomalyDialogFragment);
-
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- assertThat(dialog).isNotNull();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
-
- assertThat(shadowDialog.getMessage()).isEqualTo(
- mContext.getString(R.string.dialog_background_check_message,
- mWakeLockAnomaly.displayName));
- assertThat(shadowDialog.getTitle()).isEqualTo(
- mContext.getString(R.string.dialog_background_check_title));
- assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(
- mContext.getString(R.string.dialog_background_check_ok));
- assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(
- mContext.getString(R.string.dlg_cancel));
- }
-
- @Test
- public void testOnCreateDialog_wakeupAlarmAnomalyTargetingO_fireForceStopDialog() {
- mAnomalyDialogFragment =
- AnomalyDialogFragment.newInstance(mWakeupAlarmAnomaly2, 0 /* metricskey */);
-
- FragmentTestUtils.startFragment(mAnomalyDialogFragment);
-
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- assertThat(dialog).isNotNull();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
-
- assertThat(shadowDialog.getMessage()).isEqualTo(
- mContext.getString(R.string.dialog_stop_message_wakeup_alarm,
- mWakeLockAnomaly.displayName));
- assertThat(shadowDialog.getTitle()).isEqualTo(
- mContext.getString(R.string.dialog_stop_title));
- assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(
- mContext.getString(R.string.dialog_stop_ok));
- assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(
- mContext.getString(R.string.dlg_cancel));
- }
-
- @Test
- public void testOnCreateDialog_bluetoothAnomaly_fireLocationCheckDialog() {
- mAnomalyDialogFragment = spy(AnomalyDialogFragment.newInstance(mBluetoothAnomaly,
- 0 /* metricskey */));
- mAnomalyDialogFragment.mAnomalyUtils = mAnomalyUtils;
- doReturn(mAnomalyAction).when(mAnomalyUtils).getAnomalyAction(any());
- doNothing().when(mAnomalyDialogFragment).initAnomalyUtils();
- doReturn(Anomaly.AnomalyActionType.LOCATION_CHECK).when(mAnomalyAction).getActionType();
-
- FragmentTestUtils.startFragment(mAnomalyDialogFragment);
-
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- assertThat(dialog).isNotNull();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
-
- assertThat(shadowDialog.getMessage()).isEqualTo(
- mContext.getString(R.string.dialog_location_message,
- mWakeLockAnomaly.displayName));
- assertThat(shadowDialog.getTitle()).isEqualTo(
- mContext.getString(R.string.dialog_location_title));
- assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(
- mContext.getString(R.string.dialog_location_ok));
- assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(
- mContext.getString(R.string.dlg_cancel));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
deleted file mode 100644
index e2febc1..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.UserManager;
-
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.fuelgauge.anomaly.checker.BluetoothScanAnomalyDetector;
-import com.android.settings.fuelgauge.anomaly.checker.WakeLockAnomalyDetector;
-import com.android.settings.fuelgauge.anomaly.checker.WakeupAlarmAnomalyDetector;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class AnomalyLoaderTest {
-
- private static final String PACKAGE_NAME = "com.android.settings";
- private static final CharSequence DISPLAY_NAME = "Settings";
- private static final int UID = 0;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock
- private BatteryStatsHelper mBatteryStatsHelper;
- @Mock
- private WakeLockAnomalyDetector mWakeLockAnomalyDetector;
- @Mock
- private WakeupAlarmAnomalyDetector mWakeupAlarmAnomalyDetector;
- @Mock
- private BluetoothScanAnomalyDetector mBluetoothScanAnomalyDetector;
- @Mock
- private AnomalyDetectionPolicy mAnomalyDetectionPolicy;
- @Mock
- private UserManager mUserManager;
- private Anomaly mWakeLockAnomaly;
- private Anomaly mWakeupAlarmAnomaly;
- private Anomaly mBluetoothScanAnomaly;
- private List<Anomaly> mWakeLockAnomalies;
- private List<Anomaly> mWakeupAlarmAnomalies;
- private List<Anomaly> mBluetoothScanAnomalies;
- private AnomalyLoader mAnomalyLoader;
-
- @Before
- public void setUp() throws PackageManager.NameNotFoundException {
- MockitoAnnotations.initMocks(this);
-
- FakeFeatureFactory.setupForTest();
- doReturn(true).when(mAnomalyDetectionPolicy).isAnomalyDetectorEnabled(anyInt());
- doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
- when(mContext.getPackageManager().getPackageUid(anyString(), anyInt())).thenReturn(UID);
-
- mWakeLockAnomalies = new ArrayList<>();
- mWakeLockAnomaly = createAnomaly(Anomaly.AnomalyType.WAKE_LOCK);
- mWakeLockAnomalies.add(mWakeLockAnomaly);
- doReturn(mWakeLockAnomalies).when(mWakeLockAnomalyDetector).detectAnomalies(any(), any());
-
- mWakeupAlarmAnomalies = new ArrayList<>();
- mWakeupAlarmAnomaly = createAnomaly(Anomaly.AnomalyType.WAKEUP_ALARM);
- mWakeupAlarmAnomalies.add(mWakeupAlarmAnomaly);
- doReturn(mWakeupAlarmAnomalies)
- .when(mWakeupAlarmAnomalyDetector).detectAnomalies(any(), any());
-
- mBluetoothScanAnomalies = new ArrayList<>();
- mBluetoothScanAnomaly = createAnomaly(Anomaly.AnomalyType.BLUETOOTH_SCAN);
- mBluetoothScanAnomalies.add(mBluetoothScanAnomaly);
- doReturn(mBluetoothScanAnomalies)
- .when(mBluetoothScanAnomalyDetector).detectAnomalies(any(), any());
-
- mAnomalyLoader = new AnomalyLoader(mContext, mBatteryStatsHelper, null,
- mAnomalyDetectionPolicy);
- mAnomalyLoader.mAnomalyUtils = spy(new AnomalyUtils(mContext));
- }
-
- @Test
- public void testLoadInBackground_containsValidAnomalies() {
- doReturn(mWakeLockAnomalyDetector).when(mAnomalyLoader.mAnomalyUtils).getAnomalyDetector(
- Anomaly.AnomalyType.WAKE_LOCK);
- doReturn(mWakeupAlarmAnomalyDetector).when(mAnomalyLoader.mAnomalyUtils).getAnomalyDetector(
- Anomaly.AnomalyType.WAKEUP_ALARM);
- doReturn(mBluetoothScanAnomalyDetector).when(
- mAnomalyLoader.mAnomalyUtils).getAnomalyDetector(
- Anomaly.AnomalyType.BLUETOOTH_SCAN);
-
- List<Anomaly> anomalies = mAnomalyLoader.loadInBackground();
-
- assertThat(anomalies)
- .containsExactly(mWakeLockAnomaly, mWakeupAlarmAnomaly, mBluetoothScanAnomaly);
- }
-
- private Anomaly createAnomaly(@Anomaly.AnomalyType int type) {
- return new Anomaly.Builder()
- .setType(type)
- .setUid(UID)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .build();
- }
-
- @Test
- public void testGenerateFakeData() {
- List<Anomaly> anomalies = mAnomalyLoader.generateFakeData();
-
- assertThat(anomalies)
- .containsExactly(mWakeLockAnomaly, mWakeupAlarmAnomaly, mBluetoothScanAnomaly);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyPreferenceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyPreferenceTest.java
deleted file mode 100644
index 9b85981..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyPreferenceTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class AnomalyPreferenceTest {
-
- @Anomaly.AnomalyType
- private static final int ANOMALY_TYPE = Anomaly.AnomalyType.WAKE_LOCK;
- private static final String PACKAGE_NAME = "com.android.app";
- private static final String DISPLAY_NAME = "app";
- private static final int UID = 111;
-
- private Context mContext;
- private Anomaly mAnomaly;
- private AnomalyPreference mAnomalyPreference;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = RuntimeEnvironment.application;
-
- mAnomaly = new Anomaly.Builder()
- .setType(ANOMALY_TYPE)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .setUid(UID)
- .build();
- }
-
- @Test
- public void testAnomalyPreference_containsCorrectData() {
- mAnomalyPreference = new AnomalyPreference(mContext, mAnomaly);
-
- assertThat(mAnomalyPreference.getTitle()).isEqualTo(DISPLAY_NAME);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceControllerTest.java
deleted file mode 100644
index e6dea88..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalySummaryPreferenceControllerTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-
-import com.android.settings.SettingsActivity;
-import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class AnomalySummaryPreferenceControllerTest {
-
- @Anomaly.AnomalyType
- private static final int ANOMALY_TYPE = Anomaly.AnomalyType.WAKE_LOCK;
- private static final String PACKAGE_NAME = "com.android.app";
- private static final String DISPLAY_NAME = "appName";
- private static final int UID = 111;
-
- @Mock
- private InstrumentedPreferenceFragment mFragment;
- @Mock
- private FragmentManager mFragmentManager;
- @Mock
- private FragmentTransaction mFragmentTransaction;
- @Mock
- private SettingsActivity mSettingsActivity;
- @Mock
- private PreferenceScreen mPreferenceScreen;
-
- private AnomalySummaryPreferenceController mAnomalySummaryPreferenceController;
- private Preference mPreference;
- private Context mContext;
- private List<Anomaly> mAnomalyList;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = RuntimeEnvironment.application;
- mPreference = new Preference(mContext);
- mPreference.setKey(AnomalySummaryPreferenceController.ANOMALY_KEY);
- when(mFragment.getPreferenceScreen()).thenReturn(mPreferenceScreen);
- when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
- when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
- when(mFragment.getContext()).thenReturn(mContext);
- when(mSettingsActivity.getApplicationContext()).thenReturn(mContext);
- when(mPreferenceScreen.findPreference(any())).thenReturn(mPreference);
-
- mAnomalyList = new ArrayList<>();
-
- mAnomalySummaryPreferenceController = new AnomalySummaryPreferenceController(
- mSettingsActivity, mFragment);
- }
-
- @Test
- public void testUpdateHighUsageSummaryPreference_hasCorrectData() {
- mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(mAnomalyList);
-
- assertThat(mAnomalySummaryPreferenceController.mAnomalies).isEqualTo(mAnomalyList);
- }
-
- @Test
- public void testUpdateAnomalySummaryPreference_oneAnomaly_showCorrectSummary() {
- mAnomalyList.add(createTestAnomaly());
-
- mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(mAnomalyList);
-
- assertThat(mPreference.getTitle()).isEqualTo("appName draining battery");
- assertThat(mPreference.getSummary()).isEqualTo("Keeping device awake");
- }
-
- @Test
- public void testUpdateAnomalySummaryPreference_emptyAnomaly_preferenceInvisible() {
- mPreference.setVisible(true);
- mAnomalyList.clear();
-
- mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(mAnomalyList);
-
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void testUpdateAnomalySummaryPreference_multipleAnomalies_showCorrectSummary() {
- mAnomalyList.add(createTestAnomaly());
- mAnomalyList.add(createTestAnomaly());
-
- mAnomalySummaryPreferenceController.updateAnomalySummaryPreference(mAnomalyList);
-
- assertThat(mPreference.getTitle()).isEqualTo("Apps draining battery");
- assertThat(mPreference.getSummary()).isEqualTo("2 apps misbehaving");
- }
-
- @Test
- public void testOnPreferenceTreeClick_oneAnomaly_showDialog() {
-
- mAnomalyList.add(createTestAnomaly());
- mAnomalySummaryPreferenceController.mAnomalies = mAnomalyList;
-
- mAnomalySummaryPreferenceController.onPreferenceTreeClick(mPreference);
-
- verify(mFragmentManager).beginTransaction();
- verify(mFragmentTransaction).add(any(), anyString());
- verify(mFragmentTransaction).commit();
- }
-
- private Anomaly createTestAnomaly() {
- return new Anomaly.Builder()
- .setType(ANOMALY_TYPE)
- .setUid(UID)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .build();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyTest.java
deleted file mode 100644
index be09c24..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.os.Build;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class AnomalyTest {
-
- private static int TYPE = Anomaly.AnomalyType.WAKE_LOCK;
- private static int UID = 111;
- private static int SDK_VERSION = Build.VERSION_CODES.L;
- private static long WAKE_LOCK_TIME_MS = 1500;
- private static String PACKAGE_NAME = "com.android.settings";
- private static String DISPLAY_NAME = "settings";
- private static long BLUETOOTH_TIME_MS = 2555555;
- private static int WAKEUP_ALARM_COUNT = 100;
-
- private Anomaly mAnomaly;
-
- @Before
- public void setUp() {
- mAnomaly = new Anomaly.Builder()
- .setType(TYPE)
- .setUid(UID)
- .setWakeLockTimeMs(WAKE_LOCK_TIME_MS)
- .setPackageName(PACKAGE_NAME)
- .setDisplayName(DISPLAY_NAME)
- .setTargetSdkVersion(SDK_VERSION)
- .setBackgroundRestrictionEnabled(true)
- .setBluetoothScanningTimeMs(BLUETOOTH_TIME_MS)
- .setWakeupAlarmCount(WAKEUP_ALARM_COUNT)
- .build();
- }
-
- @Test
- public void testBuilder_buildCorrectly() {
- assertThat(mAnomaly.type).isEqualTo(TYPE);
- assertThat(mAnomaly.uid).isEqualTo(UID);
- assertThat(mAnomaly.wakelockTimeMs).isEqualTo(WAKE_LOCK_TIME_MS);
- assertThat(mAnomaly.packageName).isEqualTo(PACKAGE_NAME);
- assertThat(mAnomaly.displayName).isEqualTo(DISPLAY_NAME);
- assertThat(mAnomaly.targetSdkVersion).isEqualTo(SDK_VERSION);
- assertThat(mAnomaly.backgroundRestrictionEnabled).isTrue();
- assertThat(mAnomaly.wakeupAlarmCount).isEqualTo(WAKEUP_ALARM_COUNT);
- assertThat(mAnomaly.bluetoothScanningTimeMs).isEqualTo(BLUETOOTH_TIME_MS);
- }
-
- @Test
- public void testToString() {
- assertThat(mAnomaly.toString()).isEqualTo(
- "type=wakelock uid=111 package=com.android.settings displayName=settings"
- + " wakelockTimeMs=1500 wakeupAlarmCount=100 bluetoothTimeMs=2555555");
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
deleted file mode 100644
index 72abc18..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyUtilsTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.verify;
-
-import android.os.Build;
-import android.util.Pair;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.fuelgauge.anomaly.action.ForceStopAction;
-import com.android.settings.fuelgauge.anomaly.action.StopAndBackgroundCheckAction;
-import com.android.settings.fuelgauge.anomaly.checker.WakeLockAnomalyDetector;
-import com.android.settings.fuelgauge.anomaly.checker.WakeupAlarmAnomalyDetector;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowKeyValueListParser;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowKeyValueListParser.class)
-public class AnomalyUtilsTest {
-
- private static final String PACKAGE_NAME_WAKEUP = "com.android.app1";
- private static final String PACKAGE_NAME_WAKELOCK = "com.android.app2";
- private static final int CONTEXT_ID = 55;
-
- @Mock
- private MetricsFeatureProvider mMetricsFeatureProvider;
- private AnomalyUtils mAnomalyUtils;
- private Anomaly mWakeupAnomaly;
- private Anomaly mWakeLockAnomaly;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mAnomalyUtils = new AnomalyUtils(RuntimeEnvironment.application);
-
- mWakeLockAnomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKE_LOCK)
- .setPackageName(PACKAGE_NAME_WAKELOCK)
- .build();
- mWakeupAnomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setPackageName(PACKAGE_NAME_WAKEUP)
- .build();
- }
-
- @Test
- public void testGetAnomalyAction_typeWakeLock_returnForceStop() {
- Anomaly anomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKE_LOCK)
- .build();
- assertThat(mAnomalyUtils.getAnomalyAction(anomaly)).isInstanceOf(
- ForceStopAction.class);
- }
-
- @Test
- public void testGetAnomalyDetector_typeWakeLock_returnWakeLockDetector() {
- assertThat(mAnomalyUtils.getAnomalyDetector(Anomaly.AnomalyType.WAKE_LOCK)).isInstanceOf(
- WakeLockAnomalyDetector.class);
- }
-
- @Test
- public void testGetAnomalyAction_typeWakeUpAlarmTargetO_returnForceStop() {
- Anomaly anomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setTargetSdkVersion(Build.VERSION_CODES.O)
- .build();
- assertThat(mAnomalyUtils.getAnomalyAction(anomaly)).isInstanceOf(
- ForceStopAction.class);
- }
-
- @Test
- public void testGetAnomalyAction_typeWakeUpAlarmTargetPriorOAndBgOff_returnStopAndBackground() {
- Anomaly anomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setTargetSdkVersion(Build.VERSION_CODES.L)
- .setBackgroundRestrictionEnabled(false)
- .build();
- assertThat(mAnomalyUtils.getAnomalyAction(anomaly)).isInstanceOf(
- StopAndBackgroundCheckAction.class);
- }
-
- @Test
- public void testGetAnomalyAction_typeWakeUpAlarmTargetPriorOAndBgOn_returnForceStop() {
- Anomaly anomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setTargetSdkVersion(Build.VERSION_CODES.L)
- .setBackgroundRestrictionEnabled(true)
- .build();
- assertThat(mAnomalyUtils.getAnomalyAction(anomaly)).isInstanceOf(
- ForceStopAction.class);
- }
-
- @Test
- public void testGetAnomalyDetector_typeWakeUpAlarm_returnWakeUpAlarmDetector() {
- assertThat(mAnomalyUtils.getAnomalyDetector(Anomaly.AnomalyType.WAKEUP_ALARM)).isInstanceOf(
- WakeupAlarmAnomalyDetector.class);
- }
-
- @Test
- public void testLogAnomaly() {
- mAnomalyUtils.logAnomaly(mMetricsFeatureProvider, mWakeLockAnomaly, CONTEXT_ID);
-
- verify(mMetricsFeatureProvider).action(RuntimeEnvironment.application,
- MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKELOCK,
- PACKAGE_NAME_WAKELOCK,
- Pair.create(
- MetricsProto.MetricsEvent.FIELD_CONTEXT,
- CONTEXT_ID),
- Pair.create(
- MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
- Anomaly.AnomalyActionType.FORCE_STOP));
- }
-
- @Test
- public void testLogAnomalies() {
- final List<Anomaly> anomalies = new ArrayList<>();
- anomalies.add(mWakeLockAnomaly);
- anomalies.add(mWakeupAnomaly);
-
- mAnomalyUtils.logAnomalies(mMetricsFeatureProvider, anomalies, CONTEXT_ID);
-
- verify(mMetricsFeatureProvider).action(RuntimeEnvironment.application,
- MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKELOCK,
- PACKAGE_NAME_WAKELOCK,
- Pair.create(
- MetricsProto.MetricsEvent.FIELD_CONTEXT,
- CONTEXT_ID),
- Pair.create(
- MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
- Anomaly.AnomalyActionType.FORCE_STOP));
- verify(mMetricsFeatureProvider).action(RuntimeEnvironment.application,
- MetricsProto.MetricsEvent.ANOMALY_TYPE_WAKEUP_ALARM,
- PACKAGE_NAME_WAKEUP,
- Pair.create(
- MetricsProto.MetricsEvent.FIELD_CONTEXT,
- CONTEXT_ID),
- Pair.create(
- MetricsProto.MetricsEvent.FIELD_ANOMALY_ACTION_TYPE,
- Anomaly.AnomalyActionType.STOP_AND_BACKGROUND_CHECK));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
deleted file mode 100644
index 226be10..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import android.app.AppOpsManager;
-import android.content.Context;
-import android.util.Pair;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class AnomalyActionTest {
-
- private static final String PACKAGE_NAME = "com.android.app";
- private static final int UID = 111;
- private static final int ACTION_KEY = 2;
- private static final int METRIC_KEY = 3;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock
- private AppOpsManager mAppOpsManager;
- private Anomaly mAnomaly;
- private TestAnomalyAction mTestAnomalyAction;
- private FakeFeatureFactory mFeatureFactory;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mFeatureFactory = FakeFeatureFactory.setupForTest();
- doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
-
- mAnomaly = new Anomaly.Builder().setUid(UID).setPackageName(PACKAGE_NAME).build();
- mTestAnomalyAction = new TestAnomalyAction(mContext);
- }
-
- @Test
- public void testHandlePositiveAction_logAction() {
- mTestAnomalyAction.handlePositiveAction(mAnomaly, METRIC_KEY);
-
- verify(mFeatureFactory.metricsFeatureProvider).action(mContext, ACTION_KEY, PACKAGE_NAME,
- Pair.create(MetricsProto.MetricsEvent.FIELD_CONTEXT, METRIC_KEY));
- }
-
- private class TestAnomalyAction extends AnomalyAction {
- private TestAnomalyAction(Context context) {
- super(context);
- mActionMetricKey = ACTION_KEY;
- }
-
- @Override
- public boolean isActionActive(Anomaly anomaly) {
- return false;
- }
-
- @Override
- public int getActionType() {
- return 0;
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
deleted file mode 100644
index 20b5486..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import android.app.AppOpsManager;
-import android.content.Context;
-import android.os.Build;
-
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class BackgroundCheckActionTest {
-
- private static final String PACKAGE_NAME = "com.android.app";
- private static final int UID = 111;
- private static final int SDK_VERSION = Build.VERSION_CODES.L;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock
- private AppOpsManager mAppOpsManager;
- @Mock
- private BatteryUtils mBatteryUtils;
- private Anomaly mAnomaly;
- private BackgroundCheckAction mBackgroundCheckAction;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- FakeFeatureFactory.setupForTest();
- doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
-
- mAnomaly = new Anomaly.Builder()
- .setUid(UID)
- .setPackageName(PACKAGE_NAME)
- .setTargetSdkVersion(SDK_VERSION)
- .build();
- mBackgroundCheckAction = new BackgroundCheckAction(mContext);
- mBackgroundCheckAction.mBatteryUtils = mBatteryUtils;
- }
-
- @Test
- public void testHandlePositiveAction_forceStopPackage() {
- mBackgroundCheckAction.handlePositiveAction(mAnomaly, 0 /* metricskey */);
-
- verify(mAppOpsManager).setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, UID, PACKAGE_NAME,
- AppOpsManager.MODE_IGNORED);
- }
-
- @Test
- public void testIsActionActive_modeAllowed_returnTrue() {
- doReturn(false).when(mBatteryUtils)
- .isBackgroundRestrictionEnabled(SDK_VERSION, UID, PACKAGE_NAME);
-
- assertThat(mBackgroundCheckAction.isActionActive(mAnomaly)).isTrue();
- }
-
- @Test
- public void testIsActionActive_modeIgnored_returnFalse() {
- doReturn(true).when(mBatteryUtils)
- .isBackgroundRestrictionEnabled(SDK_VERSION, UID, PACKAGE_NAME);
-
- assertThat(mBackgroundCheckAction.isActionActive(mAnomaly)).isFalse();
- }
-
- @Test
- public void testConstructor_batteryUtilsNotNull() {
- mBackgroundCheckAction = new BackgroundCheckAction(mContext);
-
- assertThat(mBackgroundCheckAction.mBatteryUtils).isNotNull();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
deleted file mode 100644
index 49c679b..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import android.app.ActivityManager;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class ForceStopActionTest {
-
- private static final String PACKAGE_NAME = "com.android.app";
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock
- private ActivityManager mActivityManager;
- @Mock
- private ApplicationInfo mApplicationInfo;
- @Mock
- private PackageManager mPackageManager;
- private Anomaly mAnomaly;
- private ForceStopAction mForceStopAction;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- FakeFeatureFactory.setupForTest();
- doReturn(mActivityManager).when(mContext).getSystemService(Context.ACTIVITY_SERVICE);
- doReturn(mPackageManager).when(mContext).getPackageManager();
- doReturn(mApplicationInfo).when(mPackageManager)
- .getApplicationInfo(PACKAGE_NAME, PackageManager.GET_META_DATA);
-
- mAnomaly = new Anomaly.Builder().setPackageName(PACKAGE_NAME).build();
- mForceStopAction = new ForceStopAction(mContext);
- }
-
- @Test
- public void testHandlePositiveAction_forceStopPackage() {
- mForceStopAction.handlePositiveAction(mAnomaly, 0 /* metricskey */);
-
- verify(mActivityManager).forceStopPackage(PACKAGE_NAME);
- }
-
- @Test
- public void testIsActionActive_appStopped_returnFalse() {
- mApplicationInfo.flags = ApplicationInfo.FLAG_STOPPED;
-
- assertThat(mForceStopAction.isActionActive(mAnomaly)).isFalse();
- }
-
- @Test
- public void testIsActionActive_appRunning_returnTrue() {
- mApplicationInfo.flags = 0;
-
- assertThat(mForceStopAction.isActionActive(mAnomaly)).isTrue();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
deleted file mode 100644
index 711fa11..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.pm.PackageManager;
-
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowPermissionChecker;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowPermissionChecker.class)
-public class LocationCheckActionTest {
-
- private static final String PACKAGE_NAME = "com.android.app";
- private static final int UID = 12345;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- private Anomaly mAnomaly;
- private LocationCheckAction mLocationCheckAction;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest();
- mLocationCheckAction = new LocationCheckAction(mContext, null);
- mAnomaly = new Anomaly.Builder()
- .setType(Anomaly.AnomalyType.BLUETOOTH_SCAN)
- .setPackageName(PACKAGE_NAME)
- .setUid(UID)
- .build();
- ShadowPermissionChecker.clear();
- }
-
- @Test
- public void testIsActionActive_coarseLocationGranted_returnTrue() {
- ShadowPermissionChecker.addPermission(Manifest.permission.ACCESS_COARSE_LOCATION, -1, UID,
- PACKAGE_NAME, PackageManager.PERMISSION_GRANTED);
-
- assertThat(mLocationCheckAction.isActionActive(mAnomaly)).isTrue();
- }
-
- @Test
- public void testIsActionActive_fineLocationGranted_returnTrue() {
- ShadowPermissionChecker.addPermission(Manifest.permission.ACCESS_FINE_LOCATION, -1, UID,
- PACKAGE_NAME, PackageManager.PERMISSION_GRANTED);
-
- assertThat(mLocationCheckAction.isActionActive(mAnomaly)).isTrue();
- }
-
- @Test
- public void testIsActionActive_noLocationGranted_returnFalse() {
- assertThat(mLocationCheckAction.isActionActive(mAnomaly)).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
deleted file mode 100644
index f49395b..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.action;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class StopAndBackgroundActionTest {
-
- private static final String PACKAGE_NAME = "com.android.app";
- private static final int UID = 111;
- private static final int METRICS_KEY = 3;
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock
- private BackgroundCheckAction mBackgroundCheckAction;
- @Mock
- private ForceStopAction mForceStopAction;
- private StopAndBackgroundCheckAction mStopAndBackgroundCheckAction;
- private Anomaly mAnomaly;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- mAnomaly = new Anomaly.Builder().setUid(UID).setPackageName(PACKAGE_NAME).build();
-
- FakeFeatureFactory.setupForTest();
- mStopAndBackgroundCheckAction = new StopAndBackgroundCheckAction(mContext, mForceStopAction,
- mBackgroundCheckAction);
- }
-
- @Test
- public void testHandlePositiveAction_stopAndBackgroundCheck() {
- mStopAndBackgroundCheckAction.handlePositiveAction(mAnomaly, METRICS_KEY);
-
- verify(mBackgroundCheckAction).handlePositiveAction(mAnomaly, METRICS_KEY);
- verify(mForceStopAction).handlePositiveAction(mAnomaly, METRICS_KEY);
- }
-
- @Test
- public void testIsActionActive_restrictionEnabled_returnFalse() {
- doReturn(true).when(mForceStopAction).isActionActive(mAnomaly);
-
- assertThat(mStopAndBackgroundCheckAction.isActionActive(mAnomaly)).isFalse();
- }
-
- @Test
- public void testIsActionActive_appNotRunning_returnFalse() {
- doReturn(true).when(mBackgroundCheckAction).isActionActive(mAnomaly);
-
- assertThat(mStopAndBackgroundCheckAction.isActionActive(mAnomaly)).isFalse();
- }
-
- @Test
- public void testIsActionActive_appStoppedAndRestrictionOn_returnFalse() {
- assertThat(mStopAndBackgroundCheckAction.isActionActive(mAnomaly)).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetectorTest.java
deleted file mode 100644
index 61cf694..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/BluetoothScanAnomalyDetectorTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.checker;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.os.BatteryStats;
-import android.text.format.DateUtils;
-
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
-import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
-import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class BluetoothScanAnomalyDetectorTest {
-
- private static final String TARGET_PACKAGE_NAME = "com.android.app";
- private static final int ANOMALY_UID = 111;
- private static final int NORMAL_UID = 222;
- private static final int TARGET_UID = 333;
- private static final long ANOMALY_BLUETOOTH_SCANNING_TIME = DateUtils.HOUR_IN_MILLIS;
- private static final long NORMAL_BLUETOOTH_SCANNING_TIME = DateUtils.MINUTE_IN_MILLIS;
- @Mock
- private BatteryStatsHelper mBatteryStatsHelper;
- @Mock
- private BatterySipper mAnomalySipper;
- @Mock
- private BatterySipper mNormalSipper;
- @Mock
- private BatterySipper mTargetSipper;
- @Mock
- private BatteryStats.Uid mAnomalyUid;
- @Mock
- private BatteryStats.Uid mNormalUid;
- @Mock
- private BatteryStats.Uid mTargetUid;
- @Mock
- private BatteryUtils mBatteryUtils;
- @Mock
- private AnomalyDetectionPolicy mPolicy;
- @Mock
- private AnomalyAction mAnomalyAction;
- @Mock
- private AnomalyUtils mAnomalyUtils;
-
- private BluetoothScanAnomalyDetector mBluetoothScanAnomalyDetector;
- private Context mContext;
- private List<BatterySipper> mUsageList;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = spy(RuntimeEnvironment.application);
- ReflectionHelpers.setField(mPolicy, "bluetoothScanThreshold",
- 30 * DateUtils.MINUTE_IN_MILLIS);
- doReturn(mAnomalyAction).when(mAnomalyUtils).getAnomalyAction(any());
-
- mAnomalySipper.uidObj = mAnomalyUid;
- doReturn(ANOMALY_UID).when(mAnomalyUid).getUid();
- mNormalSipper.uidObj = mNormalUid;
- doReturn(NORMAL_UID).when(mNormalUid).getUid();
- mTargetSipper.uidObj = mTargetUid;
- doReturn(TARGET_UID).when(mTargetUid).getUid();
-
- mUsageList = new ArrayList<>();
- mUsageList.add(mAnomalySipper);
- mUsageList.add(mNormalSipper);
- mUsageList.add(mTargetSipper);
- when(mBatteryStatsHelper.getUsageList()).thenReturn(mUsageList);
-
- mBluetoothScanAnomalyDetector = spy(new BluetoothScanAnomalyDetector(mContext, mPolicy,
- mAnomalyUtils));
- mBluetoothScanAnomalyDetector.mBatteryUtils = mBatteryUtils;
- doReturn(false).when(mBatteryUtils).shouldHideSipper(any());
- doReturn(true).when(mAnomalyAction).isActionActive(any());
-
- doReturn(ANOMALY_BLUETOOTH_SCANNING_TIME).when(
- mBluetoothScanAnomalyDetector).getBluetoothUnoptimizedBgTimeMs(eq(mAnomalyUid),
- anyLong());
- doReturn(ANOMALY_BLUETOOTH_SCANNING_TIME).when(
- mBluetoothScanAnomalyDetector).getBluetoothUnoptimizedBgTimeMs(eq(mTargetUid),
- anyLong());
- doReturn(NORMAL_BLUETOOTH_SCANNING_TIME).when(
- mBluetoothScanAnomalyDetector).getBluetoothUnoptimizedBgTimeMs(eq(mNormalUid),
- anyLong());
- }
-
- @Test
- public void testDetectAnomalies_containsAnomaly_detectIt() {
- doReturn(-1).when(mBatteryUtils).getPackageUid(nullable(String.class));
- final Anomaly anomaly = createBluetoothAnomaly(ANOMALY_UID);
- final Anomaly targetAnomaly = createBluetoothAnomaly(TARGET_UID);
-
- List<Anomaly> mAnomalies =
- mBluetoothScanAnomalyDetector.detectAnomalies(mBatteryStatsHelper);
-
- assertThat(mAnomalies).containsExactly(anomaly, targetAnomaly);
- }
-
- @Test
- public void testDetectAnomalies_detectTargetAnomaly_detectIt() {
- doReturn(TARGET_UID).when(mBatteryUtils).getPackageUid(TARGET_PACKAGE_NAME);
- final Anomaly targetAnomaly = createBluetoothAnomaly(TARGET_UID);
-
- List<Anomaly> mAnomalies =
- mBluetoothScanAnomalyDetector.detectAnomalies(mBatteryStatsHelper, TARGET_PACKAGE_NAME);
-
- assertThat(mAnomalies).containsExactly(targetAnomaly);
- }
-
- private Anomaly createBluetoothAnomaly(int uid) {
- return new Anomaly.Builder()
- .setUid(uid)
- .setType(Anomaly.AnomalyType.BLUETOOTH_SCAN)
- .setBluetoothScanningTimeMs(ANOMALY_BLUETOOTH_SCANNING_TIME)
- .build();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetectorTest.java
deleted file mode 100644
index b70dcaf..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeLockAnomalyDetectorTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.checker;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.os.BatteryStats;
-import android.text.format.DateUtils;
-
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
-import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
-import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class WakeLockAnomalyDetectorTest {
-
- private static final String TARGET_PACKAGE_NAME = "com.android.app";
- private static final long ANOMALY_WAKELOCK_TIME_MS = 2 * DateUtils.HOUR_IN_MILLIS;
- private static final long NORMAL_WAKELOCK_TIME_MS = DateUtils.SECOND_IN_MILLIS;
- private static final long WAKELOCK_THRESHOLD_MS = DateUtils.HOUR_IN_MILLIS;
- private static final int ANOMALY_UID = 111;
- private static final int NORMAL_UID = 222;
- private static final int TARGET_UID = 333;
- private static final int INACTIVE_UID = 444;
- @Mock
- private BatteryStatsHelper mBatteryStatsHelper;
- @Mock
- private BatterySipper mAnomalySipper;
- @Mock
- private BatterySipper mTargetSipper;
- @Mock
- private BatterySipper mNormalSipper;
- @Mock
- private BatterySipper mInactiveSipper;
- @Mock
- private BatteryStats.Uid mAnomalyUid;
- @Mock
- private BatteryStats.Uid mNormalUid;
- @Mock
- private BatteryStats.Uid mTargetUid;
- @Mock
- private BatteryStats.Uid mInactiveUid;
- @Mock
- private BatteryUtils mBatteryUtils;
- @Mock
- private PackageManager mPackageManager;
- @Mock
- private ApplicationInfo mApplicationInfo;
- @Mock
- private AnomalyDetectionPolicy mPolicy;
- @Mock
- private AnomalyAction mAnomalyAction;
- @Mock
- private AnomalyUtils mAnomalyUtils;
-
- private WakeLockAnomalyDetector mWakelockAnomalyDetector;
- private Context mContext;
- private List<BatterySipper> mUsageList;
- private Anomaly mAnomaly;
- private Anomaly mTargetAnomaly;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- mContext = spy(RuntimeEnvironment.application);
- ReflectionHelpers.setField(mPolicy, "wakeLockThreshold", WAKELOCK_THRESHOLD_MS);
-
- doReturn(false).when(mBatteryUtils).shouldHideSipper(nullable(BatterySipper.class));
- doReturn(mPackageManager).when(mContext).getPackageManager();
- doReturn(mApplicationInfo).when(mPackageManager)
- .getApplicationInfo(nullable(String.class), anyInt());
- doReturn(true).when(mAnomalyAction).isActionActive(any());
- doReturn(mAnomalyAction).when(mAnomalyUtils).getAnomalyAction(any());
-
- mWakelockAnomalyDetector =
- spy(new WakeLockAnomalyDetector(mContext, mPolicy, mAnomalyUtils));
- mWakelockAnomalyDetector.mBatteryUtils = mBatteryUtils;
-
- mAnomalySipper.uidObj = mAnomalyUid;
- doReturn(ANOMALY_WAKELOCK_TIME_MS).when(mWakelockAnomalyDetector)
- .getBackgroundTotalDurationMs(eq(mAnomalyUid), anyLong());
- doReturn(ANOMALY_WAKELOCK_TIME_MS).when(mWakelockAnomalyDetector)
- .getCurrentDurationMs(eq(mAnomalyUid), anyLong());
- doReturn(ANOMALY_UID).when(mAnomalyUid).getUid();
-
- mNormalSipper.uidObj = mNormalUid;
- doReturn(NORMAL_WAKELOCK_TIME_MS).when(mWakelockAnomalyDetector)
- .getBackgroundTotalDurationMs(eq(mNormalUid), anyLong());
- doReturn(0L).when(mWakelockAnomalyDetector)
- .getCurrentDurationMs(eq(mNormalUid), anyLong());
- doReturn(NORMAL_UID).when(mNormalUid).getUid();
-
- mTargetSipper.uidObj = mTargetUid;
- doReturn(ANOMALY_WAKELOCK_TIME_MS).when(mWakelockAnomalyDetector)
- .getBackgroundTotalDurationMs(eq(mTargetUid), anyLong());
- doReturn(ANOMALY_WAKELOCK_TIME_MS).when(mWakelockAnomalyDetector)
- .getCurrentDurationMs(eq(mTargetUid), anyLong());
- doReturn(TARGET_UID).when(mTargetUid).getUid();
-
- mInactiveSipper.uidObj = mInactiveUid;
- doReturn(ANOMALY_WAKELOCK_TIME_MS).when(mWakelockAnomalyDetector)
- .getBackgroundTotalDurationMs(eq(mInactiveUid), anyLong());
- doReturn(0L).when(mWakelockAnomalyDetector)
- .getCurrentDurationMs(eq(mInactiveUid), anyLong());
- doReturn(INACTIVE_UID).when(mInactiveUid).getUid();
-
- mUsageList = new ArrayList<>();
- mUsageList.add(mAnomalySipper);
- mUsageList.add(mNormalSipper);
- mUsageList.add(mTargetSipper);
- mUsageList.add(mInactiveSipper);
- when(mBatteryStatsHelper.getUsageList()).thenReturn(mUsageList);
-
- mAnomaly = createWakeLockAnomaly(ANOMALY_UID);
- mTargetAnomaly = createWakeLockAnomaly(TARGET_UID);
- }
-
- @Test
- public void testDetectAnomalies_containsAnomaly_detectIt() {
- doReturn(BatteryUtils.UID_NULL).when(mBatteryUtils).getPackageUid(nullable(String.class));
-
- List<Anomaly> mAnomalies = mWakelockAnomalyDetector.detectAnomalies(mBatteryStatsHelper);
-
- assertThat(mAnomalies).containsExactly(mAnomaly, mTargetAnomaly);
- }
-
- @Test
- public void testDetectAnomalies_containsTargetPackage_detectIt() {
- doReturn(TARGET_UID).when(mBatteryUtils).getPackageUid(TARGET_PACKAGE_NAME);
-
- List<Anomaly> mAnomalies =
- mWakelockAnomalyDetector.detectAnomalies(mBatteryStatsHelper, TARGET_PACKAGE_NAME);
-
- assertThat(mAnomalies).containsExactly(mTargetAnomaly);
- }
-
- @Test
- public void testContainsThresholdFromPolicy() {
- assertThat(mWakelockAnomalyDetector.mWakeLockThresholdMs).isEqualTo(WAKELOCK_THRESHOLD_MS);
- }
-
- private Anomaly createWakeLockAnomaly(int uid) {
- return new Anomaly.Builder()
- .setUid(uid)
- .setType(Anomaly.AnomalyType.WAKE_LOCK)
- .setWakeLockTimeMs(ANOMALY_WAKELOCK_TIME_MS)
- .build();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
deleted file mode 100644
index 789b80b..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/checker/WakeupAlarmAnomalyDetectorTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.fuelgauge.anomaly.checker;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.os.BatteryStats;
-import android.os.Build;
-import android.text.format.DateUtils;
-import android.util.ArrayMap;
-import android.util.ArraySet;
-
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
-import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
-import com.android.settings.fuelgauge.anomaly.action.AnomalyAction;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class WakeupAlarmAnomalyDetectorTest {
-
- private static final String TARGET_PACKAGE_NAME = "com.android.target";
- private static final String ANOMALY_PACKAGE_NAME = "com.android.anomaly";
- private static final boolean TARGET_BACKGROUND_RESTRICTION_ON = false;
- private static final boolean ANOMALY_BACKGROUND_RESTRICTION_ON = true;
- private static final int TARGET_SDK = Build.VERSION_CODES.L;
- private static final int ANOMALY_SDK = Build.VERSION_CODES.O;
- private static final int ANOMALY_UID = 111;
- private static final int NORMAL_UID = 222;
- private static final int TARGET_UID = 333;
- private static final long RUNNING_TIME_MS =
- 1 * DateUtils.HOUR_IN_MILLIS + 10 * DateUtils.MINUTE_IN_MILLIS;
- private static final int ANOMALY_WAKEUP_COUNT = 500;
- private static final int NORMAL_WAKEUP_COUNT = 61;
- private static final int BLACKLISTED_WAKEUP_COUNT = 37;
- private static final int ANOMALY_WAKEUP_FREQUENCY = 428; // count per hour
- @Mock
- private BatteryStatsHelper mBatteryStatsHelper;
- @Mock
- private BatterySipper mAnomalySipper;
- @Mock
- private BatterySipper mNormalSipper;
- @Mock
- private BatterySipper mTargetSipper;
- @Mock
- private BatteryStats.Uid mAnomalyUid;
- @Mock
- private BatteryStats.Uid mNormalUid;
- @Mock
- private BatteryStats.Uid mTargetUid;
- @Mock
- private BatteryUtils mBatteryUtils;
- @Mock
- private BatteryStats.Uid.Pkg mPkg;
- @Mock
- private BatteryStats.Counter mCounter;
- @Mock
- private BatteryStats.Counter mCounter2;
- @Mock
- private AnomalyDetectionPolicy mPolicy;
- @Mock
- private AnomalyAction mAnomalyAction;
- @Mock
- private AnomalyUtils mAnomalyUtils;
-
- private WakeupAlarmAnomalyDetector mWakeupAlarmAnomalyDetector;
- private Context mContext;
- private List<BatterySipper> mUsageList;
- private Anomaly mAnomaly;
- private Anomaly mTargetAnomaly;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- mContext = spy(RuntimeEnvironment.application);
- ReflectionHelpers.setField(mPolicy, "wakeupAlarmThreshold", 60);
- final Set<String> blacklistedTags = new ArraySet<>();
- blacklistedTags.add("blacklistedTag");
- ReflectionHelpers.setField(mPolicy, "wakeupBlacklistedTags", blacklistedTags);
-
- doReturn(false).when(mBatteryUtils).shouldHideSipper(any());
- doReturn(RUNNING_TIME_MS).when(mBatteryUtils)
- .calculateRunningTimeBasedOnStatsType(any(), anyInt());
- doReturn(true).when(mAnomalyAction).isActionActive(any());
- doReturn(mAnomalyAction).when(mAnomalyUtils).getAnomalyAction(any());
-
- mAnomalySipper.uidObj = mAnomalyUid;
- doReturn(ANOMALY_UID).when(mAnomalyUid).getUid();
- mNormalSipper.uidObj = mNormalUid;
- doReturn(NORMAL_UID).when(mNormalUid).getUid();
- mTargetSipper.uidObj = mTargetUid;
- doReturn(TARGET_UID).when(mTargetUid).getUid();
-
- mUsageList = new ArrayList<>();
- mUsageList.add(mAnomalySipper);
- mUsageList.add(mNormalSipper);
- mUsageList.add(mTargetSipper);
- when(mBatteryStatsHelper.getUsageList()).thenReturn(mUsageList);
-
- doReturn(TARGET_PACKAGE_NAME).when(mBatteryUtils).getPackageName(TARGET_UID);
- doReturn(ANOMALY_PACKAGE_NAME).when(mBatteryUtils).getPackageName(ANOMALY_UID);
- doReturn(TARGET_SDK).when(mBatteryUtils).getTargetSdkVersion(TARGET_PACKAGE_NAME);
- doReturn(ANOMALY_SDK).when(mBatteryUtils).getTargetSdkVersion(ANOMALY_PACKAGE_NAME);
- doReturn(TARGET_BACKGROUND_RESTRICTION_ON).when(mBatteryUtils)
- .isBackgroundRestrictionEnabled(TARGET_SDK, TARGET_UID, TARGET_PACKAGE_NAME);
- doReturn(ANOMALY_BACKGROUND_RESTRICTION_ON).when(mBatteryUtils)
- .isBackgroundRestrictionEnabled(ANOMALY_SDK, ANOMALY_UID, ANOMALY_PACKAGE_NAME);
-
- mAnomaly = new Anomaly.Builder()
- .setUid(ANOMALY_UID)
- .setPackageName(ANOMALY_PACKAGE_NAME)
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setTargetSdkVersion(ANOMALY_SDK)
- .setBackgroundRestrictionEnabled(ANOMALY_BACKGROUND_RESTRICTION_ON)
- .setWakeupAlarmCount(ANOMALY_WAKEUP_FREQUENCY)
- .build();
- mTargetAnomaly = new Anomaly.Builder()
- .setUid(TARGET_UID)
- .setPackageName(TARGET_PACKAGE_NAME)
- .setType(Anomaly.AnomalyType.WAKEUP_ALARM)
- .setTargetSdkVersion(TARGET_SDK)
- .setBackgroundRestrictionEnabled(TARGET_BACKGROUND_RESTRICTION_ON)
- .setWakeupAlarmCount(ANOMALY_WAKEUP_FREQUENCY)
- .build();
-
- mWakeupAlarmAnomalyDetector =
- spy(new WakeupAlarmAnomalyDetector(mContext, mPolicy, mAnomalyUtils));
- mWakeupAlarmAnomalyDetector.mBatteryUtils = mBatteryUtils;
- }
-
- @Test
- public void testDetectAnomalies_containsAnomaly_detectIt() {
- doReturn(-1).when(mBatteryUtils).getPackageUid(nullable(String.class));
- doReturn(ANOMALY_WAKEUP_COUNT).when(mWakeupAlarmAnomalyDetector)
- .getWakeupAlarmCountFromUid(mAnomalyUid);
- doReturn(ANOMALY_WAKEUP_COUNT).when(mWakeupAlarmAnomalyDetector)
- .getWakeupAlarmCountFromUid(mTargetUid);
- doReturn(NORMAL_WAKEUP_COUNT).when(mWakeupAlarmAnomalyDetector)
- .getWakeupAlarmCountFromUid(mNormalUid);
-
- List<Anomaly> mAnomalies = mWakeupAlarmAnomalyDetector.detectAnomalies(mBatteryStatsHelper);
-
- assertThat(mAnomalies).containsExactly(mAnomaly, mTargetAnomaly);
- }
-
- @Test
- public void testDetectAnomalies_detectTargetAnomaly_detectIt() {
- doReturn(TARGET_UID).when(mBatteryUtils).getPackageUid(TARGET_PACKAGE_NAME);
- doReturn(ANOMALY_WAKEUP_COUNT).when(mWakeupAlarmAnomalyDetector)
- .getWakeupAlarmCountFromUid(mAnomalyUid);
- doReturn(ANOMALY_WAKEUP_COUNT).when(mWakeupAlarmAnomalyDetector)
- .getWakeupAlarmCountFromUid(mTargetUid);
- doReturn(NORMAL_WAKEUP_COUNT).when(mWakeupAlarmAnomalyDetector)
- .getWakeupAlarmCountFromUid(mNormalUid);
-
- List<Anomaly> mAnomalies = mWakeupAlarmAnomalyDetector
- .detectAnomalies(mBatteryStatsHelper, TARGET_PACKAGE_NAME);
-
- assertThat(mAnomalies).containsExactly(mTargetAnomaly);
- }
-
- @Test
- public void testGetWakeupAlarmCountFromUid_countCorrect() {
- final ArrayMap<String, BatteryStats.Uid.Pkg> packageStats = new ArrayMap<>();
- final ArrayMap<String, BatteryStats.Counter> alarms = new ArrayMap<>();
- doReturn(alarms).when(mPkg).getWakeupAlarmStats();
- doReturn(NORMAL_WAKEUP_COUNT).when(mCounter).getCountLocked(anyInt());
- doReturn(packageStats).when(mAnomalyUid).getPackageStats();
- packageStats.put("", mPkg);
- alarms.put("1", mCounter);
- alarms.put("2", mCounter);
-
- assertThat(mWakeupAlarmAnomalyDetector.getWakeupAlarmCountFromUid(mAnomalyUid))
- .isEqualTo(2 * NORMAL_WAKEUP_COUNT);
- }
-
- @Test
- public void testGetWakeupAlarmCountFromUid_filterOutBlacklistedTags() {
- final ArrayMap<String, BatteryStats.Uid.Pkg> packageStats = new ArrayMap<>();
- final ArrayMap<String, BatteryStats.Counter> alarms = new ArrayMap<>();
- doReturn(alarms).when(mPkg).getWakeupAlarmStats();
- doReturn(NORMAL_WAKEUP_COUNT).when(mCounter).getCountLocked(anyInt());
- doReturn(BLACKLISTED_WAKEUP_COUNT).when(mCounter2).getCountLocked(anyInt());
- doReturn(packageStats).when(mAnomalyUid).getPackageStats();
- packageStats.put("", mPkg);
- alarms.put("allowedTag", mCounter);
- alarms.put("blacklistedTag", mCounter2);
-
- assertThat(mWakeupAlarmAnomalyDetector.getWakeupAlarmCountFromUid(mAnomalyUid))
- .isEqualTo(NORMAL_WAKEUP_COUNT);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AppInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AppInfoTest.java
index 74e8fe6..ef12673 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AppInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AppInfoTest.java
@@ -21,7 +21,6 @@
import android.os.Parcel;
import android.text.format.DateUtils;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
@@ -36,8 +35,10 @@
public class AppInfoTest {
private static final String PACKAGE_NAME = "com.android.app";
- private static final int TYPE_WAKELOCK = Anomaly.AnomalyType.WAKE_LOCK;
- private static final int TYPE_WAKEUP = Anomaly.AnomalyType.WAKEUP_ALARM;
+ private static final int TYPE_WAKELOCK =
+ StatsManagerConfig.AnomalyType.EXCESSIVE_WAKELOCK_ALL_SCREEN_OFF;
+ private static final int TYPE_WAKEUP =
+ StatsManagerConfig.AnomalyType.EXCESSIVE_WAKEUPS_IN_BACKGROUND;
private static final long SCREEN_TIME_MS = DateUtils.HOUR_IN_MILLIS;
private static final int UID = 3452;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index e9c9978..8882101 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -20,7 +20,6 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import android.app.AlertDialog;
import android.content.Context;
import android.text.format.DateUtils;
@@ -33,6 +32,8 @@
import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settingslib.testutils.FragmentTestUtils;
@@ -42,16 +43,16 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowAlertDialog;
-import org.robolectric.shadows.ShadowDialog;
import java.util.ArrayList;
import java.util.List;
+import androidx.appcompat.app.AlertDialog;
+
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowUtils.class)
+@Config(shadows = {ShadowUtils.class, ShadowAlertDialogCompat.class,
+ SettingsShadowResourcesImpl.class})
public class BatteryTipDialogFragmentTest {
private static final String PACKAGE_NAME = "com.android.app";
@@ -108,8 +109,8 @@
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
mContext.getString(R.string.battery_tip_dialog_message, 1));
@@ -121,8 +122,8 @@
FragmentTestUtils.startFragment(mDialogFragment);
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict app?");
assertThat(shadowDialog.getMessage())
@@ -142,8 +143,8 @@
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict 2 apps?");
assertThat(shadowDialog.getMessage())
@@ -171,8 +172,8 @@
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict 6 apps?");
assertThat(shadowDialog.getMessage())
@@ -189,8 +190,8 @@
FragmentTestUtils.startFragment(mDialogFragment);
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Remove restriction?");
assertThat(shadowDialog.getMessage())
@@ -204,8 +205,8 @@
FragmentTestUtils.startFragment(mDialogFragment);
- final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
- ShadowAlertDialog shadowDialog = Shadows.shadowOf(dialog);
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(
"Your apps are using a normal amount of battery. If apps use too much battery, "
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java
index b0d6a7d..3ada030 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoaderTest.java
@@ -28,9 +28,13 @@
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.fuelgauge.batterytip.tips.AppLabelPredicate;
+import com.android.settings.fuelgauge.batterytip.tips.AppRestrictionPredicate;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
+import com.android.settings.testutils.BatteryTestUtils;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -77,6 +81,12 @@
mBatteryTipLoader.mBatteryUtils = mBatteryUtils;
}
+ @After
+ public void tearDown() {
+ BatteryTestUtils.clearStaticInstance(AppLabelPredicate.class, "sInstance");
+ BatteryTestUtils.clearStaticInstance(AppRestrictionPredicate.class, "sInstance");
+ }
+
@Test
public void testLoadBackground_containsAllTipsWithOrder() {
final List<BatteryTip> batteryTips = mBatteryTipLoader.loadInBackground();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java
index 547e0eb..053a716 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipPolicyTest.java
@@ -49,7 +49,8 @@
+ ",test_battery_saver_tip=true"
+ ",test_high_usage_tip=false"
+ ",test_smart_battery_tip=true"
- + ",test_low_battery_tip=true";
+ + ",test_low_battery_tip=true"
+ + ",app_restriction_active_hour=6";
private Context mContext;
@Before
@@ -72,6 +73,7 @@
assertThat(batteryTipPolicy.highUsagePeriodMs).isEqualTo(2000);
assertThat(batteryTipPolicy.highUsageBatteryDraining).isEqualTo(30);
assertThat(batteryTipPolicy.appRestrictionEnabled).isTrue();
+ assertThat(batteryTipPolicy.appRestrictionActiveHour).isEqualTo(6);
assertThat(batteryTipPolicy.reducedBatteryEnabled).isTrue();
assertThat(batteryTipPolicy.reducedBatteryPercent).isEqualTo(30);
assertThat(batteryTipPolicy.lowBatteryEnabled).isFalse();
@@ -99,6 +101,7 @@
assertThat(batteryTipPolicy.highUsagePeriodMs).isEqualTo(2 * DateUtils.HOUR_IN_MILLIS);
assertThat(batteryTipPolicy.highUsageBatteryDraining).isEqualTo(25);
assertThat(batteryTipPolicy.appRestrictionEnabled).isTrue();
+ assertThat(batteryTipPolicy.appRestrictionActiveHour).isEqualTo(24);
assertThat(batteryTipPolicy.reducedBatteryEnabled).isFalse();
assertThat(batteryTipPolicy.reducedBatteryPercent).isEqualTo(50);
assertThat(batteryTipPolicy.lowBatteryEnabled).isTrue();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java
index 459c4e2..3882e8c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java
@@ -17,6 +17,7 @@
package com.android.settings.fuelgauge.batterytip;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetectorTest.java
index 6ef4c74..179f2a1 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetectorTest.java
@@ -34,8 +34,11 @@
import com.android.settings.fuelgauge.batterytip.AppInfo;
import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
+import com.android.settings.fuelgauge.batterytip.tips.AppLabelPredicate;
+import com.android.settings.fuelgauge.batterytip.tips.AppRestrictionPredicate;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
+import com.android.settings.testutils.BatteryTestUtils;
import com.android.settings.testutils.DatabaseTestUtils;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -86,6 +89,7 @@
mContext = spy(RuntimeEnvironment.application);
mPolicy = spy(new BatteryTipPolicy(mContext));
+ doReturn(mContext).when(mContext).getApplicationContext();
doReturn(mAppOpsManager).when(mContext).getSystemService(AppOpsManager.class);
doReturn(AppOpsManager.MODE_IGNORED).when(mAppOpsManager).checkOpNoThrow(
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, RESTRICTED_UID, RESTRICTED_PACKAGE_NAME);
@@ -93,6 +97,7 @@
AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UNRESTRICTED_UID,
UNRESTRICTED_PACKAGE_NAME);
+ BatteryDatabaseManager.setUpForTest(mBatteryDatabaseManager);
doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(any(),
anyInt());
@@ -102,7 +107,12 @@
mRestrictAppDetector = new RestrictAppDetector(mContext, mPolicy);
mRestrictAppDetector.mBatteryDatabaseManager = mBatteryDatabaseManager;
+ }
+ @After
+ public void tearDown() {
+ BatteryTestUtils.clearStaticInstance(AppLabelPredicate.class, "sInstance");
+ BatteryTestUtils.clearStaticInstance(AppRestrictionPredicate.class, "sInstance");
}
@After
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java
index 5c8b7d9..dd3e281 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java
@@ -34,9 +34,11 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.testutils.BatteryTestUtils;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -74,6 +76,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ doReturn(mContext).when(mContext).getApplicationContext();
doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(PACKAGE_NAME,
PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.MATCH_ANY_USER);
@@ -98,6 +101,12 @@
mInvisibleBatteryTip = new RestrictAppTip(BatteryTip.StateType.INVISIBLE, new ArrayList<>());
}
+ @After
+ public void tearDown() {
+ BatteryTestUtils.clearStaticInstance(AppLabelPredicate.class, "sInstance");
+ BatteryTestUtils.clearStaticInstance(AppRestrictionPredicate.class, "sInstance");
+ }
+
@Test
public void parcelable() {
Parcel parcel = Parcel.obtain();
diff --git a/tests/robotests/src/com/android/settings/localepicker/LocalePickerWithRegionActivityTest.java b/tests/robotests/src/com/android/settings/localepicker/LocalePickerWithRegionActivityTest.java
new file mode 100644
index 0000000..bad3dbd
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/localepicker/LocalePickerWithRegionActivityTest.java
@@ -0,0 +1,51 @@
+package com.android.settings.localepicker;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+
+import android.app.Activity;
+
+import com.android.internal.app.LocaleStore;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
+import org.robolectric.Shadows;
+import org.robolectric.android.controller.ActivityController;
+import org.robolectric.shadows.ShadowActivity;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class LocalePickerWithRegionActivityTest {
+
+ private LocalePickerWithRegionActivity mActivity;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final ActivityController<LocalePickerWithRegionActivity> mActivityController =
+ Robolectric.buildActivity(LocalePickerWithRegionActivity.class);
+ mActivity = spy(mActivityController.get());
+ }
+
+ @Test
+ public void onLocaleSelected_resultShouldBeOK() {
+ final ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
+ mActivity.onLocaleSelected(mock(LocaleStore.LocaleInfo.class));
+
+ assertEquals(Activity.RESULT_OK, shadowActivity.getResultCode());
+ }
+
+ @Test
+ public void onLocaleSelected_localeInfoShouldBeSentBack() {
+ final ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
+ mActivity.onLocaleSelected(mock(LocaleStore.LocaleInfo.class));
+
+ assertNotNull(shadowActivity.getResultIntent().getSerializableExtra(
+ LocaleListEditor.INTENT_LOCALE_KEY));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/location/InjectedSettingTest.java b/tests/robotests/src/com/android/settings/location/InjectedSettingTest.java
deleted file mode 100644
index 5045837..0000000
--- a/tests/robotests/src/com/android/settings/location/InjectedSettingTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.location;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public final class InjectedSettingTest {
-
- private static final String TEST_STRING = "test";
-
- @Test
- public void buildWithoutPackageName_ShouldReturnNull() {
- assertThat(((new InjectedSetting.Builder())
- .setClassName(TEST_STRING)
- .setTitle(TEST_STRING)
- .setSettingsActivity(TEST_STRING).build())).isNull();
- }
-
- private InjectedSetting getTestSetting() {
- return new InjectedSetting.Builder()
- .setPackageName(TEST_STRING)
- .setClassName(TEST_STRING)
- .setTitle(TEST_STRING)
- .setSettingsActivity(TEST_STRING).build();
- }
-
- @Test
- public void testEquals() {
- InjectedSetting setting1 = getTestSetting();
- InjectedSetting setting2 = getTestSetting();
- assertThat(setting1).isEqualTo(setting2);
- }
-
- @Test
- public void testHashCode() {
- InjectedSetting setting = getTestSetting();
- assertThat(setting.hashCode()).isEqualTo(1225314048);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
index ba5decc..f0904d0 100644
--- a/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
@@ -67,7 +67,7 @@
@Mock
private PreferenceScreen mScreen;
@Mock
- private SettingsInjector mSettingsInjector;
+ private AppSettingsInjector mSettingsInjector;
@Mock
private DevicePolicyManager mDevicePolicyManager;
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
index 3e1cde1..cb26fb6 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
@@ -25,7 +25,6 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -49,6 +48,8 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
+import androidx.appcompat.app.AlertDialog;
+
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = ShadowOs.class)
public class PrivateDnsModeDialogPreferenceTest {
@@ -132,9 +133,9 @@
@Test
public void testOnCheckedChanged_switchMode_saveButtonHasCorrectState() {
final String[] INVALID_HOST_NAMES = new String[] {
- INVALID_HOST_NAME,
- "2001:db8::53", // IPv6 string literal
- "192.168.1.1", // IPv4 string literal
+ INVALID_HOST_NAME,
+ "2001:db8::53", // IPv6 string literal
+ "192.168.1.1", // IPv4 string literal
};
for (String invalid : INVALID_HOST_NAMES) {
diff --git a/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
index 3d33ec2..150a89f 100644
--- a/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
@@ -17,9 +17,12 @@
package com.android.settings.notification;
import static android.provider.Settings.Secure.NOTIFICATION_BADGING;
+
import static com.android.settings.notification.BadgingNotificationPreferenceController.OFF;
import static com.android.settings.notification.BadgingNotificationPreferenceController.ON;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -27,20 +30,21 @@
import android.content.Context;
import android.provider.Settings;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.TwoStatePreference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class BadgingNotificationPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
index 5aecadc..c1428a4 100644
--- a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
@@ -18,6 +18,7 @@
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
+
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
@@ -31,18 +32,19 @@
import android.content.Context;
import android.os.UserManager;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowApplication;
import androidx.preference.Preference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class DeletedChannelsPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java
index 71ca554..b4f86a7 100644
--- a/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java
@@ -17,7 +17,9 @@
package com.android.settings.notification;
import static android.provider.Settings.System.NOTIFICATION_LIGHT_PULSE;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -28,6 +30,7 @@
import android.provider.Settings;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -35,14 +38,13 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.TwoStatePreference;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class PulseNotificationPreferenceControllerTest {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java
index f76a5ca..5068f85 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockTypeDialogFragmentTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Google Inc.
+ * Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,38 +16,33 @@
package com.android.settings.password;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import android.app.AlertDialog;
import android.content.Context;
import com.android.settings.R;
import com.android.settings.password.ChooseLockTypeDialogFragment.OnLockTypeSelectedListener;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowUserManager;
-import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.testutils.FragmentTestUtils;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowAlertDialog;
-import org.robolectric.shadows.ShadowDialog;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowUserManager.class, ShadowUtils.class})
+@Config(shadows = {SettingsShadowResourcesImpl.class, ShadowAlertDialogCompat.class})
public class ChooseLockTypeDialogFragmentTest {
private Context mContext;
@@ -61,32 +56,36 @@
}
@Test
- @Ignore("b/111247403")
public void testThatDialog_IsShown() {
AlertDialog latestDialog = startLockFragment();
- assertNotNull(latestDialog);
- ShadowDialog shadowDialog = Shadows.shadowOf(latestDialog);
+ ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(
+ latestDialog);
+
+ assertThat(latestDialog).isNotNull();
+ assertThat(latestDialog.isShowing()).isTrue();
// verify that we are looking at the expected dialog.
- assertEquals(shadowDialog.getTitle(),
+ assertThat(shadowAlertDialog.getTitle()).isEqualTo(
mContext.getString(R.string.setup_lock_settings_options_dialog_title));
}
@Test
- @Ignore("b/111247403")
public void testThat_OnClickListener_IsCalled() {
mFragment.mDelegate = mock(OnLockTypeSelectedListener.class);
AlertDialog lockDialog = startLockFragment();
- ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(lockDialog);
+ ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(lockDialog);
+
shadowAlertDialog.clickOnItem(0);
+
verify(mFragment.mDelegate, times(1)).onLockTypeSelected(any(ScreenLockType.class));
}
@Test
- @Ignore("b/111247403")
public void testThat_OnClickListener_IsNotCalledWhenCancelled() {
mFragment.mDelegate = mock(OnLockTypeSelectedListener.class);
AlertDialog lockDialog = startLockFragment();
+
lockDialog.dismiss();
+
verify(mFragment.mDelegate, never()).onLockTypeSelected(any(ScreenLockType.class));
}
@@ -94,7 +93,7 @@
ChooseLockTypeDialogFragment chooseLockTypeDialogFragment =
ChooseLockTypeDialogFragment.newInstance(1234);
chooseLockTypeDialogFragment.show(mFragment.getChildFragmentManager(), null);
- return ShadowAlertDialog.getLatestAlertDialog();
+ return ShadowAlertDialogCompat.getLatestAlertDialog();
}
public static class TestFragment extends Fragment implements OnLockTypeSelectedListener {
diff --git a/tests/robotests/src/com/android/settings/password/ConfirmCredentialTest.java b/tests/robotests/src/com/android/settings/password/ConfirmCredentialTest.java
index 636248a..1d0b71f 100644
--- a/tests/robotests/src/com/android/settings/password/ConfirmCredentialTest.java
+++ b/tests/robotests/src/com/android/settings/password/ConfirmCredentialTest.java
@@ -20,9 +20,8 @@
import com.android.settings.password.ConfirmDeviceCredentialBaseFragment.LastTryDialog;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -32,13 +31,12 @@
import androidx.fragment.app.FragmentManager;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
+@Config(shadows = SettingsShadowResourcesImpl.class)
public class ConfirmCredentialTest {
@Test
- @Ignore("b/111193572")
public void testLastTryDialogShownExactlyOnce() {
FragmentManager fm = Robolectric.buildActivity(FragmentActivity.class).
- get().getSupportFragmentManager();
+ setup().get().getSupportFragmentManager();
// Launch only one instance at a time.
assertThat(LastTryDialog.show(
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
index 627a4a0..d2ec785 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPatternTest.java
@@ -19,7 +19,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.RuntimeEnvironment.application;
-import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.os.UserHandle;
@@ -37,28 +36,29 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowAlertDialog;
import org.robolectric.shadows.ShadowPackageManager;
import org.robolectric.util.ReflectionHelpers;
import org.robolectric.util.ReflectionHelpers.ClassParameter;
import java.util.Arrays;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {
- SettingsShadowResourcesImpl.class,
- SettingsShadowResources.SettingsShadowTheme.class,
- ShadowUtils.class
+ SettingsShadowResourcesImpl.class,
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowUtils.class,
+ ShadowAlertDialogCompat.class
})
public class SetupChooseLockPatternTest {
@@ -88,7 +88,7 @@
ShadowPackageManager spm = Shadows.shadowOf(application.getPackageManager());
ComponentName cname = new ComponentName(application, SetupRedactionInterstitial.class);
final int componentEnabled = spm.getComponentEnabledSettingFlags(cname)
- & PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+ & PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
assertThat(componentEnabled).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
@@ -111,22 +111,20 @@
assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
button.performClick();
- AlertDialog chooserDialog = ShadowAlertDialog.getLatestAlertDialog();
+ AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(chooserDialog).isNotNull();
- int count = Shadows.shadowOf(chooserDialog).getAdapter().getCount();
+ int count = chooserDialog.getListView().getCount();
assertThat(count).named("List items shown").isEqualTo(3);
}
@Config(qualifiers = "sw400dp")
@Test
- @Ignore("b/111194289")
public void sw400dp_shouldShowScreenLockOptions() {
verifyScreenLockOptionsShown();
}
@Config(qualifiers = "sw400dp-land")
@Test
- @Ignore("b/111194289")
public void sw400dpLandscape_shouldShowScreenLockOptions() {
verifyScreenLockOptionsShown();
}
@@ -156,7 +154,7 @@
assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
skipButton.performClick();
- AlertDialog chooserDialog = ShadowAlertDialog.getLatestAlertDialog();
+ AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(chooserDialog).isNotNull();
}
diff --git a/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java b/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
index 57cf7cd..aa36b33 100644
--- a/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupSkipDialogTest.java
@@ -16,30 +16,30 @@
package com.android.settings.password;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import android.app.AlertDialog;
+import static com.google.common.truth.Truth.assertThat;
import com.android.settings.R;
import com.android.settings.testutils.Robolectric;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowAlertDialog;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {
- SettingsShadowResources.SettingsShadowTheme.class,
- ShadowUtils.class
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowUtils.class,
+ ShadowAlertDialogCompat.class,
+ SettingsShadowResourcesImpl.class
})
public class SetupSkipDialogTest {
@@ -55,12 +55,12 @@
SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(false);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
- assertNotNull(alertDialog);
- ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog);
- assertEquals(mActivity.getString(R.string.lock_screen_intro_skip_title),
+ AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ assertThat(alertDialog).isNotNull();
+ ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
+ assertThat(mActivity.getString(R.string.lock_screen_intro_skip_title)).isEqualTo(
shadowAlertDialog.getTitle());
- assertEquals(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text),
+ assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text)).isEqualTo(
shadowAlertDialog.getMessage());
}
@@ -69,12 +69,12 @@
SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true);
setupSkipDialog.show(mActivity.getSupportFragmentManager());
- AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
- assertNotNull(alertDialog);
- ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog);
- assertEquals(mActivity.getString(R.string.lock_screen_intro_skip_title),
+ AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+ assertThat(alertDialog).isNotNull();
+ ShadowAlertDialogCompat shadowAlertDialog = ShadowAlertDialogCompat.shadowOf(alertDialog);
+ assertThat(mActivity.getString(R.string.lock_screen_intro_skip_title)).isEqualTo(
shadowAlertDialog.getTitle());
- assertEquals(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text_frp),
+ assertThat(mActivity.getString(R.string.lock_screen_intro_skip_dialog_text_frp)).isEqualTo(
shadowAlertDialog.getMessage());
}
}
diff --git a/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
index 173f56b..7e8c0d5 100644
--- a/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
@@ -17,17 +17,22 @@
package com.android.settings.security;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
+import com.android.internal.widget.LockPatternUtils;
import com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController;
import com.android.settings.display.AmbientDisplayNotificationsPreferenceController;
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
import com.android.settings.gestures.PickupGesturePreferenceController;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.XmlTestUtils;
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
@@ -37,6 +42,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@@ -49,12 +55,18 @@
})
public class LockscreenDashboardFragmentTest {
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+ private FakeFeatureFactory mFeatureFactory;
private TestFragment mTestFragment;
private Context mContext;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ when(mFeatureFactory.securityFeatureProvider.getLockPatternUtils(any(Context.class)))
+ .thenReturn(mLockPatternUtils);
mContext = RuntimeEnvironment.application;
mTestFragment = spy(new TestFragment());
}
@@ -112,6 +124,16 @@
verify(controller).setConfig(any());
}
+ @Test
+ public void isPageSearchable_notLocked_shouldNotBeSearchable() {
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
+ when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(true);
+
+ assertThat(LockscreenDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(mContext))
+ .contains("security_lockscreen_settings_screen");
+ }
+
public static class TestFragment extends LockscreenDashboardFragment {
@Override
protected <T extends AbstractPreferenceController> T use(Class<T> clazz) {
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index ed33a80..b96c128 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -48,8 +48,11 @@
import org.mockito.ArgumentCaptor;
import org.robolectric.RuntimeEnvironment;
+import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
+import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
+import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -406,27 +409,92 @@
assertThat(intentData).isEqualTo(expectedUri);
}
+ @Test
+ public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
+ final int expectedIconResource = IconCompat.createWithResource(mContext,
+ R.drawable.ic_settings).toIcon().getResId();
+ final SliceData sliceData = getDummyData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT,
+ 0x0);
+
+ final Slice slice = SliceBuilderUtils.buildSlice(mContext, sliceData);
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ final SliceAction primaryAction = metadata.getPrimaryAction();
+ final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
+ assertThat(actualIconResource).isEqualTo(expectedIconResource);
+ }
+
+ @Test
+ public void buildToggleSlice_noIconPassed_returnsSliceWithIcon() {
+ final int expectedIconResource = IconCompat.createWithResource(mContext,
+ R.drawable.ic_settings).toIcon().getResId();
+ final SliceData dummyData = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
+ 0x0);
+
+ final Slice slice = SliceBuilderUtils.buildSlice(mContext, dummyData);
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ final SliceAction primaryAction = metadata.getPrimaryAction();
+ final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
+ assertThat(actualIconResource).isEqualTo(expectedIconResource);
+ }
+
+ @Test
+ public void buildSliderSlice_noIconPassed_returnsSliceWithIcon() {
+ final int expectedIconResource = IconCompat.createWithResource(mContext,
+ R.drawable.ic_settings).toIcon().getResId();
+ final SliceData data = getDummyData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER, 0x0);
+
+ final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ final SliceAction primaryAction = metadata.getPrimaryAction();
+ final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
+ assertThat(actualIconResource).isEqualTo(expectedIconResource);
+ }
+
+ @Test
+ public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
+ final int settingsIcon = R.drawable.ic_settings;
+ final int zeroIcon = 0x0;
+ final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
+ zeroIcon);
+
+ final IconCompat actualIcon = SliceBuilderUtils.getSafeIcon(mContext, data);
+
+ final int actualIconResource = actualIcon.toIcon().getResId();
+ assertThat(actualIconResource).isNotEqualTo(zeroIcon);
+ assertThat(actualIconResource).isEqualTo(settingsIcon);
+ }
+
private SliceData getDummyData() {
- return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE);
+ return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
+ ICON);
+ }
+
+ private SliceData getDummyData(Class prefController, int sliceType, int icon) {
+ return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
+ icon);
}
private SliceData getDummyData(String summary, String screenTitle) {
- return getDummyData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH, screenTitle);
+ return getDummyData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH, screenTitle,
+ ICON);
}
private SliceData getDummyData(Class prefController, int sliceType) {
- return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE);
+ return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE, ICON);
}
private SliceData getDummyData(Class prefController, String summary, int sliceType,
- String screenTitle) {
+ String screenTitle, int icon) {
return new SliceData.Builder()
.setKey(KEY)
.setTitle(TITLE)
.setSummary(summary)
.setScreenTitle(screenTitle)
.setKeywords(KEYWORDS)
- .setIcon(ICON)
+ .setIcon(icon)
.setFragmentName(FRAGMENT_NAME)
.setUri(URI)
.setPreferenceControllerClassName(prefController.getName())
diff --git a/tests/robotests/src/com/android/settings/testutils/BatteryTestUtils.java b/tests/robotests/src/com/android/settings/testutils/BatteryTestUtils.java
index 2bdab27..eed2009 100644
--- a/tests/robotests/src/com/android/settings/testutils/BatteryTestUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/BatteryTestUtils.java
@@ -19,6 +19,8 @@
import android.content.Intent;
import android.os.BatteryManager;
+import java.lang.reflect.Field;
+
public class BatteryTestUtils {
public static Intent getChargingIntent() {
@@ -47,4 +49,15 @@
return intent;
}
+ public static void clearStaticInstance(Class clazz, String fieldName) {
+ Field instance;
+ try {
+ instance = clazz.getDeclaredField(fieldName);
+ instance.setAccessible(true);
+ instance.set(null, null);
+ } catch (Exception e) {
+ throw new RuntimeException();
+ }
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
index 9fb69a3..dd51687 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
@@ -43,7 +43,8 @@
// that Robolectric isn't yet aware of.
// TODO: Remove this once Robolectric is updated.
if (id == R.drawable.switchbar_background
- || id == R.color.ripple_material_light) {
+ || id == R.color.ripple_material_light
+ || id == R.color.ripple_material_dark) {
return new ColorDrawable();
} else if (id == R.drawable.ic_launcher_settings) {
// ic_launcher_settings uses adaptive-icon, which is not supported by robolectric,
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowTypedArray.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowTypedArray.java
new file mode 100644
index 0000000..fc3ff0c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowTypedArray.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.testutils.shadow;
+
+import static org.robolectric.shadow.api.Shadow.directlyOn;
+
+import android.content.res.ColorStateList;
+import android.content.res.TypedArray;
+import android.graphics.Color;
+
+import androidx.annotation.Nullable;
+import androidx.annotation.StyleableRes;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.RealObject;
+import org.robolectric.shadows.ShadowTypedArray;
+
+@Implements(value = TypedArray.class, inheritImplementationMethods = true)
+public class SettingsShadowTypedArray extends ShadowTypedArray {
+
+ @RealObject
+ TypedArray realTypedArray;
+
+ @Implementation
+ @Nullable
+ public ColorStateList getColorStateList(@StyleableRes int index) {
+ if (index == com.android.internal.R.styleable.TextView_textColorLink) {
+ return ColorStateList.valueOf(Color.WHITE);
+ }
+ return directlyOn(realTypedArray, TypedArray.class).getColorStateList(index);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessPoint.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessPoint.java
new file mode 100644
index 0000000..2cb6964
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessPoint.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.testutils.shadow;
+
+import com.android.settingslib.wifi.AccessPoint;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@Implements(AccessPoint.class)
+public class ShadowAccessPoint {
+
+ @Implementation
+ public String getSavedNetworkSummary() {
+ return "saved";
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java
new file mode 100644
index 0000000..a682d85
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.testutils.shadow;
+
+import android.annotation.SuppressLint;
+import android.view.View;
+
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.RealObject;
+import org.robolectric.annotation.Resetter;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowDialog;
+import org.robolectric.util.ReflectionHelpers;
+
+import javax.annotation.Nullable;
+
+import androidx.appcompat.app.AlertDialog;
+
+/* Robolectric shadow for the androidx alert dialog. */
+@Implements(AlertDialog.class)
+public class ShadowAlertDialogCompat extends ShadowDialog {
+
+ @SuppressLint("StaticFieldLeak")
+ @Nullable
+ private static ShadowAlertDialogCompat latestSupportAlertDialog;
+ @RealObject
+ private AlertDialog realAlertDialog;
+
+ @Implementation
+ public void show() {
+ super.show();
+ latestSupportAlertDialog = this;
+ }
+
+ public CharSequence getMessage() {
+ final Object alertController = ReflectionHelpers.getField(realAlertDialog, "mAlert");
+ return ReflectionHelpers.getField(alertController, "mMessage");
+ }
+
+ public CharSequence getTitle() {
+ final Object alertController = ReflectionHelpers.getField(realAlertDialog, "mAlert");
+ return ReflectionHelpers.getField(alertController, "mTitle");
+ }
+
+ public View getView() {
+ final Object alertController = ReflectionHelpers.getField(realAlertDialog, "mAlert");
+ return ReflectionHelpers.getField(alertController, "mView");
+ }
+
+ @Nullable
+ public static AlertDialog getLatestAlertDialog() {
+ return latestSupportAlertDialog == null ? null : latestSupportAlertDialog.realAlertDialog;
+ }
+
+ @Resetter
+ public static void reset() {
+ latestSupportAlertDialog = null;
+ }
+
+ public static ShadowAlertDialogCompat shadowOf(AlertDialog alertDialog) {
+ return (ShadowAlertDialogCompat) Shadow.extract(alertDialog);
+ }
+
+ public void clickOnItem(int index) {
+ Shadows.shadowOf(realAlertDialog.getListView()).performItemClick(index);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
index e5304da..65f92a3 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
@@ -20,13 +20,17 @@
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
+import android.net.wifi.hotspot2.PasspointConfiguration;
import org.robolectric.annotation.HiddenApi;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
-@Implements(WifiManager.class)
+import java.util.Collections;
+import java.util.List;
+
+@Implements(value = WifiManager.class, inheritImplementationMethods = true)
public class ShadowWifiManager extends org.robolectric.shadows.ShadowWifiManager {
public WifiConfiguration savedWifiConfig;
@@ -43,6 +47,11 @@
savedWifiConfig = config;
}
+ @Implementation
+ public List<PasspointConfiguration> getPasspointConfigurations() {
+ return Collections.emptyList();
+ }
+
public static ShadowWifiManager get() {
return Shadow.extract(application.getSystemService(WifiManager.class));
}
diff --git a/tests/robotests/src/com/android/settings/widget/BottomLabelLayoutTest.java b/tests/robotests/src/com/android/settings/widget/BottomLabelLayoutTest.java
index ea0d89a..7b7bcfa 100644
--- a/tests/robotests/src/com/android/settings/widget/BottomLabelLayoutTest.java
+++ b/tests/robotests/src/com/android/settings/widget/BottomLabelLayoutTest.java
@@ -23,14 +23,14 @@
import android.widget.Space;
import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class BottomLabelLayoutTest {
private BottomLabelLayout mBottomLabelLayout;
diff --git a/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
index 15658d5..4b23e7f 100644
--- a/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
+++ b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
@@ -17,6 +17,7 @@
package com.android.settings.widget;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -25,15 +26,15 @@
import android.content.res.Resources;
import android.util.SparseIntArray;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-@RunWith(RobolectricTestRunner.class)
+@RunWith(SettingsRobolectricTestRunner.class)
public class UsageGraphTest {
private UsageGraph mGraph;
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceControllerTest.java
new file mode 100644
index 0000000..ad56fe6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceControllerTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.anyBoolean;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import androidx.preference.PreferenceScreen;
+
+@RunWith(RobolectricTestRunner.class)
+public class VideoPreferenceControllerTest {
+
+ @Mock
+ private VideoPreference mPreference;
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private VideoPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = new VideoPreferenceController(RuntimeEnvironment.application, "test_pref");
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ }
+
+ @Test
+ public void getAvailabilityStatus_isAlwaysAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ }
+
+ @Test
+ public void onPause_shouldCallOnViewInvisibleOnPrefernece() {
+ mController.displayPreference(mScreen);
+
+ mController.onPause();
+
+ verify(mPreference).onViewInvisible();
+ }
+
+ @Test
+ public void onResume_shouldCallOnViewVisibleOnPrefernece() {
+ mController.displayPreference(mScreen);
+
+ mController.onResume();
+
+ verify(mPreference).onViewVisible(anyBoolean());
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/SavedAccessPointsWifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/SavedAccessPointsWifiSettingsTest.java
deleted file mode 100644
index b4fc4cd..0000000
--- a/tests/robotests/src/com/android/settings/wifi/SavedAccessPointsWifiSettingsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.wifi;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WifiManager.ActionListener;
-import android.os.Handler;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.wifi.AccessPoint;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class SavedAccessPointsWifiSettingsTest {
-
- @Mock
- private WifiManager mockWifiManager;
- @Mock
- private WifiDialog mockWifiDialog;
- @Mock
- private WifiConfigController mockConfigController;
- @Mock
- private WifiConfiguration mockWifiConfiguration;
- @Mock
- private AccessPoint mockAccessPoint;
- @Mock
- private Handler mHandler;
-
- private SavedAccessPointsWifiSettings mSettings;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mSettings = new SavedAccessPointsWifiSettings();
- ReflectionHelpers.setField(mSettings, "mHandler", mHandler);
- ReflectionHelpers.setField(mSettings, "mWifiManager", mockWifiManager);
-
- when(mockWifiDialog.getController()).thenReturn(mockConfigController);
- when(mockConfigController.getConfig()).thenReturn(mockWifiConfiguration);
- }
-
- @Test
- public void onForget_isPasspointConfig_shouldSendMessageToHandler() {
- final AccessPoint accessPoint = mock(AccessPoint.class);
- when(accessPoint.isPasspointConfig()).thenReturn(true);
- ReflectionHelpers.setField(mSettings, "mSelectedAccessPoint", accessPoint);
-
- mSettings.onForget(null);
-
- verify(mHandler).sendEmptyMessage(SavedAccessPointsWifiSettings.MSG_UPDATE_PREFERENCES);
- }
-
- @Test
- public void onForget_onSuccess_shouldSendMessageToHandler() {
- mSettings.mForgetListener.onSuccess();
-
- verify(mHandler).sendEmptyMessage(SavedAccessPointsWifiSettings.MSG_UPDATE_PREFERENCES);
- }
-
- @Test
- public void onForget_onFailure_shouldSendMessageToHandler() {
- mSettings.mForgetListener.onFailure(0);
-
- verify(mHandler).sendEmptyMessage(SavedAccessPointsWifiSettings.MSG_UPDATE_PREFERENCES);
- }
-
- @Test
- public void onSubmit_shouldInvokeSaveApi() {
- mSettings.onSubmit(mockWifiDialog);
- verify(mockWifiManager).save(eq(mockWifiConfiguration), any(ActionListener.class));
- }
-
- @Test
- public void onForget_shouldInvokeForgetApi() {
- ReflectionHelpers.setField(mSettings, "mSelectedAccessPoint", mockAccessPoint);
- when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfiguration);
- mSettings.onForget(mockWifiDialog);
- verify(mockWifiManager)
- .forget(eq(mockWifiConfiguration.networkId), any(ActionListener.class));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java b/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
index 8cdecff..e80edba 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
@@ -24,6 +24,9 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.SettingsShadowTypedArray;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
import com.android.settings.testutils.shadow.ShadowWifiManager;
@@ -34,16 +37,17 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowAlertDialog;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {
- SettingsShadowResources.SettingsShadowTheme.class,
- ShadowConnectivityManager.class,
- ShadowWifiManager.class
-}
-)
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowConnectivityManager.class,
+ SettingsShadowTypedArray.class,
+ ShadowWifiManager.class,
+ ShadowAlertDialogCompat.class,
+ SettingsShadowResourcesImpl.class
+})
public class WifiDialogActivityTest {
private static final String AP1_SSID = "\"ap1\"";
@@ -62,7 +66,7 @@
@Test
public void onSubmit_shouldConnectToNetwork() {
WifiDialogActivity activity = Robolectric.setupActivity(WifiDialogActivity.class);
- WifiDialog dialog = (WifiDialog) ShadowAlertDialog.getLatestAlertDialog();
+ WifiDialog dialog = (WifiDialog) ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
ReflectionHelpers.setField(dialog, "mController", mController);
@@ -78,8 +82,9 @@
Robolectric.buildActivity(
WifiDialogActivity.class,
new Intent().putExtra(WifiDialogActivity.KEY_CONNECT_FOR_CALLER, false))
- .setup().get();
- WifiDialog dialog = (WifiDialog) ShadowAlertDialog.getLatestAlertDialog();
+ .setup().get();
+ WifiDialog dialog = (WifiDialog) ShadowAlertDialogCompat.getLatestAlertDialog();
+
assertThat(dialog).isNotNull();
ReflectionHelpers.setField(dialog, "mController", mController);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiDialogTest.java b/tests/robotests/src/com/android/settings/wifi/WifiDialogTest.java
index 7025100..7a88131 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiDialogTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiDialogTest.java
@@ -25,15 +25,7 @@
private Context mContext = RuntimeEnvironment.application;
- private WifiDialogListener mListener = new WifiDialogListener() {
- @Override
- public void onForget(WifiDialog dialog) {
- }
-
- @Override
- public void onSubmit(WifiDialog dialog) {
- }
- };
+ private WifiDialogListener mListener = new WifiDialogListener() {};
@Before
public void setUp() {
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiScanningRequiredFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/WifiScanningRequiredFragmentTest.java
index 995ad17..d37b667 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiScanningRequiredFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiScanningRequiredFragmentTest.java
@@ -27,7 +27,6 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -45,6 +44,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
@RunWith(SettingsRobolectricTestRunner.class)
diff --git a/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java b/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java
index 252e7ed..7e3ce6f 100644
--- a/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WriteWifiConfigToNfcDialogTest.java
@@ -20,11 +20,10 @@
import static org.mockito.Mockito.when;
import android.app.Activity;
-import android.content.Context;
import android.net.wifi.WifiManager;
-import android.view.inputmethod.InputMethodManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
import com.android.settings.testutils.shadow.ShadowNfcAdapter;
import org.junit.After;
@@ -33,17 +32,15 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowNfcAdapter.class)
+@Config(shadows = {ShadowNfcAdapter.class, SettingsShadowResourcesImpl.class})
public class WriteWifiConfigToNfcDialogTest {
@Mock
- private Activity mActivity;
- @Mock
private WifiManager mWifiManager;
private WriteWifiConfigToNfcDialog mWriteWifiConfigToNfcDialog;
@@ -51,13 +48,10 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- when(mActivity.getApplicationContext()).thenReturn(mActivity);
- when(mActivity.getSystemService(Context.INPUT_METHOD_SERVICE))
- .thenReturn(ReflectionHelpers.newInstance(InputMethodManager.class));
- mWriteWifiConfigToNfcDialog = new WriteWifiConfigToNfcDialog(RuntimeEnvironment.application,
- 0 /* security */);
+ final Activity activity = Robolectric.setupActivity(Activity.class);
+ mWriteWifiConfigToNfcDialog = new WriteWifiConfigToNfcDialog(activity, 0 /* security */);
ReflectionHelpers.setField(mWriteWifiConfigToNfcDialog, "mWifiManager", mWifiManager);
- mWriteWifiConfigToNfcDialog.setOwnerActivity(mActivity);
+ mWriteWifiConfigToNfcDialog.setOwnerActivity(activity);
mWriteWifiConfigToNfcDialog.onCreate(null /* savedInstanceState */);
}
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
new file mode 100644
index 0000000..790739a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.savedaccesspoints;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.net.wifi.WifiConfiguration;
+
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowAccessPoint;
+import com.android.settings.testutils.shadow.ShadowThreadUtils;
+import com.android.settings.testutils.shadow.ShadowWifiManager;
+import com.android.settingslib.wifi.AccessPointPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowThreadUtils.class, ShadowWifiManager.class})
+public class SavedAccessPointsPreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private PreferenceCategory mPreferenceCategory;
+
+ private Context mContext;
+ private ShadowWifiManager mWifiManager;
+ private SavedAccessPointsPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mWifiManager = ShadowWifiManager.get();
+ mController = spy(new SavedAccessPointsPreferenceController(mContext, "test_key"));
+
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreferenceCategory);
+ when(mPreferenceCategory.getContext()).thenReturn(mContext);
+ }
+
+ @Test
+ public void getAvailability_alwaysAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void onStart_shouldRefreshApList() {
+ doNothing().when(mController).refreshSavedAccessPoints();
+
+ mController.onStart();
+
+ verify(mController).refreshSavedAccessPoints();
+ }
+
+
+ @Test
+ public void postRefresh_shouldRefreshApList() {
+ doNothing().when(mController).refreshSavedAccessPoints();
+
+ mController.postRefreshSavedAccessPoints();
+
+ verify(mController).refreshSavedAccessPoints();
+ }
+
+ @Test
+ public void forget_onSuccess_shouldRefreshApList() {
+ doNothing().when(mController).refreshSavedAccessPoints();
+
+ mController.onSuccess();
+
+ verify(mController).refreshSavedAccessPoints();
+ }
+
+ @Test
+ public void forget_onFailure_shouldRefreshApList() {
+ doNothing().when(mController).refreshSavedAccessPoints();
+
+ mController.onFailure(0 /* reason */);
+
+ verify(mController).refreshSavedAccessPoints();
+ }
+
+ @Test
+ @Config(shadows = ShadowAccessPoint.class)
+ public void refreshSavedAccessPoints_shouldListAllAPs() {
+ final WifiConfiguration config = new WifiConfiguration();
+ config.SSID = "SSID";
+ config.BSSID = "BSSID";
+ config.networkId = 2;
+ mWifiManager.addNetwork(config);
+
+ final ArgumentCaptor<AccessPointPreference> captor =
+ ArgumentCaptor.forClass(AccessPointPreference.class);
+ mController.displayPreference(mPreferenceScreen);
+ mController.refreshSavedAccessPoints();
+
+ verify(mPreferenceCategory).addPreference(captor.capture());
+
+ final AccessPointPreference pref = captor.getValue();
+ assertThat(pref.getTitle()).isEqualTo(config.SSID);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
new file mode 100644
index 0000000..97ad7d9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.savedaccesspoints;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.wifi.WifiConfigController;
+import com.android.settings.wifi.WifiDialog;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.wifi.AccessPoint;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class SavedAccessPointsWifiSettingsTest {
+
+ @Mock
+ private WifiManager mWifiManager;
+ @Mock
+ private WifiDialog mWifiDialog;
+ @Mock
+ private WifiConfigController mConfigController;
+ @Mock
+ private WifiConfiguration mWifiConfiguration;
+ @Mock
+ private AccessPoint mAccessPoint;
+ @Mock
+ private SavedAccessPointsPreferenceController mSavedApController;
+
+ private TestFragment mSettings;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mSettings = spy(new TestFragment());
+
+ doReturn(mSavedApController).when(mSettings)
+ .use(SavedAccessPointsPreferenceController.class);
+
+ ReflectionHelpers.setField(mSettings, "mWifiManager", mWifiManager);
+
+ when(mWifiDialog.getController()).thenReturn(mConfigController);
+ when(mConfigController.getConfig()).thenReturn(mWifiConfiguration);
+ }
+
+ @Test
+ public void onForget_isPasspointConfig_shouldRefreshAPList() {
+ when(mAccessPoint.isPasspointConfig()).thenReturn(true);
+ ReflectionHelpers.setField(mSettings, "mSelectedAccessPoint", mAccessPoint);
+
+ mSettings.onForget(null);
+
+ verify(mSavedApController).postRefreshSavedAccessPoints();
+ }
+
+ @Test
+ public void onForget_shouldInvokeForgetApi() {
+ ReflectionHelpers.setField(mSettings, "mSelectedAccessPoint", mAccessPoint);
+ when(mAccessPoint.getConfig()).thenReturn(mWifiConfiguration);
+
+ mSettings.onForget(mWifiDialog);
+
+ verify(mWifiManager)
+ .forget(mWifiConfiguration.networkId, mSavedApController);
+ }
+
+ @Test
+ public void verifyConstants() {
+ assertThat(mSettings.getMetricsCategory()).isEqualTo(MetricsEvent.WIFI_SAVED_ACCESS_POINTS);
+ assertThat(mSettings.getPreferenceScreenResId())
+ .isEqualTo(R.xml.wifi_display_saved_access_points);
+ }
+
+ public static class TestFragment extends SavedAccessPointsWifiSettings {
+
+ public <T extends AbstractPreferenceController> T use(Class<T> clazz) {
+ return super.use(clazz);
+ }
+ }
+}
diff --git a/tests/unit/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java b/tests/unit/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
deleted file mode 100644
index 8be3320..0000000
--- a/tests/unit/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.fuelgauge.anomaly.action;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class LocationCheckActionTest {
- private static final String PACKAGE_NAME = "com.android.chrome";
-
- private Context mContext;
- private LocationCheckAction mLocationCheckAction;
- private Anomaly mAnomaly;
-
- @Before
- public void setUp() {
- mContext = InstrumentationRegistry.getTargetContext();
- mLocationCheckAction = new LocationCheckAction(mContext);
-
- mAnomaly = new Anomaly.Builder()
- .setUid(getPackageUid(mContext, PACKAGE_NAME))
- .setPackageName(PACKAGE_NAME)
- .build();
- }
-
- @Test
- public void testRevokeAndCheck() {
- mLocationCheckAction.handlePositiveAction(mAnomaly, 0 /* metric key */);
-
- assertThat(mLocationCheckAction.isActionActive(mAnomaly)).isFalse();
- }
-
- private int getPackageUid(Context context, String packageName) {
- try {
- return context.getPackageManager().getPackageUid(packageName,
- PackageManager.GET_META_DATA);
- } catch (PackageManager.NameNotFoundException e) {
- return -1;
- }
- }
-}
-
-
-
-