Merge "Misc fixes for User page and my device info page"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1963830..2e51108 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2686,8 +2686,6 @@
<intent-filter android:priority="150">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.notifications" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.applications.NotificationApps" />
</activity>
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 066dab9..f3050c4 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -1661,7 +1661,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_accessibility.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1677,7 +1677,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_accounts.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1693,7 +1693,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_apps.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1709,7 +1709,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_battery.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1725,7 +1725,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_connected_device.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1741,7 +1741,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_display.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1753,11 +1753,27 @@
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:color="@color/homepage_generic_icon_background" />"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/drawable/ic_homepage_generic_background.xml"
+ line="20"
+ column="9"/>
+ </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:color="@color/homepage_network_background" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_network.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1773,7 +1789,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_security.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1789,7 +1805,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_sound.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1805,7 +1821,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_storage.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1821,7 +1837,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_support.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -1837,7 +1853,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_homepage_system_dashboard.xml"
- line="24"
+ line="23"
column="17"/>
</issue>
@@ -2557,7 +2573,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="5637"
+ line="5651"
column="36"/>
</issue>
@@ -2589,7 +2605,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="437"
+ line="442"
column="44"/>
</issue>
@@ -2605,7 +2621,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="443"
+ line="448"
column="44"/>
</issue>
@@ -2621,7 +2637,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="444"
+ line="449"
column="44"/>
</issue>
@@ -2637,7 +2653,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="467"
+ line="472"
column="41"/>
</issue>
diff --git a/res/drawable/ic_homepage_accessibility.xml b/res/drawable/ic_homepage_accessibility.xml
index 6cfb124..07c9ef2 100644
--- a/res/drawable/ic_homepage_accessibility.xml
+++ b/res/drawable/ic_homepage_accessibility.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_accessibility_background" />
<size
diff --git a/res/drawable/ic_homepage_accounts.xml b/res/drawable/ic_homepage_accounts.xml
index 4cfccc2..ee33505 100644
--- a/res/drawable/ic_homepage_accounts.xml
+++ b/res/drawable/ic_homepage_accounts.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_accounts_background" />
<size
diff --git a/res/drawable/ic_homepage_apps.xml b/res/drawable/ic_homepage_apps.xml
index d494799..3d18d09 100644
--- a/res/drawable/ic_homepage_apps.xml
+++ b/res/drawable/ic_homepage_apps.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_app_and_notification_background" />
<size
diff --git a/res/drawable/ic_homepage_battery.xml b/res/drawable/ic_homepage_battery.xml
index d9ad3d3..abafdcb 100644
--- a/res/drawable/ic_homepage_battery.xml
+++ b/res/drawable/ic_homepage_battery.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_battery_background" />
<size
diff --git a/res/drawable/ic_homepage_connected_device.xml b/res/drawable/ic_homepage_connected_device.xml
index 20707fb..483427c 100644
--- a/res/drawable/ic_homepage_connected_device.xml
+++ b/res/drawable/ic_homepage_connected_device.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_connected_device_background" />
<size
diff --git a/res/drawable/ic_homepage_display.xml b/res/drawable/ic_homepage_display.xml
index ec5e54f..893a583 100644
--- a/res/drawable/ic_homepage_display.xml
+++ b/res/drawable/ic_homepage_display.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_display_background" />
<size
diff --git a/res/drawable/ic_homepage_generic_background.xml b/res/drawable/ic_homepage_generic_background.xml
new file mode 100644
index 0000000..37273a0
--- /dev/null
+++ b/res/drawable/ic_homepage_generic_background.xml
@@ -0,0 +1,24 @@
+<?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.
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="oval">
+ <solid
+ android:color="@color/homepage_generic_icon_background" />
+ <size
+ android:width="@dimen/dashboard_tile_image_size"
+ android:height="@dimen/dashboard_tile_image_size" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/ic_homepage_network.xml b/res/drawable/ic_homepage_network.xml
index c72e152..5ed023a 100644
--- a/res/drawable/ic_homepage_network.xml
+++ b/res/drawable/ic_homepage_network.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_network_background" />
<size
diff --git a/res/drawable/ic_homepage_security.xml b/res/drawable/ic_homepage_security.xml
index 52dedfb..5a6ed97 100644
--- a/res/drawable/ic_homepage_security.xml
+++ b/res/drawable/ic_homepage_security.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_security_background" />
<size
diff --git a/res/drawable/ic_homepage_sound.xml b/res/drawable/ic_homepage_sound.xml
index 7210889..4991656 100644
--- a/res/drawable/ic_homepage_sound.xml
+++ b/res/drawable/ic_homepage_sound.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_sound_background" />
<size
diff --git a/res/drawable/ic_homepage_storage.xml b/res/drawable/ic_homepage_storage.xml
index e7f5819..4922844 100644
--- a/res/drawable/ic_homepage_storage.xml
+++ b/res/drawable/ic_homepage_storage.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_storage_background" />
<size
diff --git a/res/drawable/ic_homepage_support.xml b/res/drawable/ic_homepage_support.xml
index 31d51bf..0936304 100644
--- a/res/drawable/ic_homepage_support.xml
+++ b/res/drawable/ic_homepage_support.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_support_background" />
<size
diff --git a/res/drawable/ic_homepage_system_dashboard.xml b/res/drawable/ic_homepage_system_dashboard.xml
index bf3d0eb..60f0476 100644
--- a/res/drawable/ic_homepage_system_dashboard.xml
+++ b/res/drawable/ic_homepage_system_dashboard.xml
@@ -18,8 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
+ <shape android:shape="oval">
<solid
android:color="@color/homepage_system_background" />
<size
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fe05e6f..711d720 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3391,16 +3391,6 @@
<string name="location_title">My Location</string>
<!-- [CHAR LIMIT=30] Title for managed profile location switch -->
<string name="managed_profile_location_switch_title">Location for work profile</string>
- <!-- [CHAR LIMIT=30] Location settings screen, setting preference screen box label for location mode -->
- <string name="location_mode_title">Mode</string>
- <!-- [CHAR LIMIT=30] Location settings screen, high accuracy location mode -->
- <string name="location_mode_high_accuracy_title">High accuracy</string>
- <!-- [CHAR LIMIT=30] Location settings screen, battery saving location mode -->
- <string name="location_mode_battery_saving_title">Battery saving</string>
- <!-- [CHAR LIMIT=30] Location settings screen, device only location mode -->
- <string name="location_mode_sensors_only_title">Device only</string>
- <!-- [CHAR LIMIT=30] Location settings screen, location off mode -->
- <string name="location_mode_location_off_title">Location off</string>
<!-- [CHAR LIMIT=30] Location settings screen. It's a link that directs the user to a page that
shows the location permission setting for each installed app -->
<string name="location_app_level_permissions">App-level permissions</string>
@@ -3414,14 +3404,6 @@
<string name="location_high_battery_use">High battery use</string>
<!-- [CHAR LIMIT=30] Location settings screen, recent location requests low battery use-->
<string name="location_low_battery_use">Low battery use</string>
- <!-- [CHAR LIMIT=30] Location mode screen, screen title -->
- <string name="location_mode_screen_title">Location mode</string>
- <!-- [CHAR LIMIT=130] Location mode screen, description for high accuracy mode -->
- <string name="location_mode_high_accuracy_description">Use GPS, Wi\u2011Fi, Bluetooth, or mobile networks to determine location </string>
- <!-- [CHAR LIMIT=130] Location mode screen, description for battery saving mode -->
- <string name="location_mode_battery_saving_description">Use Wi\u2011Fi, Bluetooth, or mobile networks to determine location</string>
- <!-- [CHAR LIMIT=130] Location mode screen, description for sensors only mode -->
- <string name="location_mode_sensors_only_description">Use GPS and device sensors to determine location</string>
<!-- [CHAR LIMIT=30] Wireless background scanning settings screen, screen title -->
<string name="location_scanning_screen_title">Scanning</string>
<!-- [CHAR LIMIT=130] Preference title for Wi-Fi always scanning -->
@@ -6709,7 +6691,6 @@
<string name="keywords_sounds_and_notifications_interruptions">dont don\u2019t disturb, interrupt, interruption, break</string>
<string name="keywords_app">RAM</string>
<string name="keywords_location">nearby, location, history, reporting</string>
- <string name="keywords_location_mode">accuracy</string>
<string name="keywords_accounts">account</string>
<string name="keywords_users">restriction, restrict, restricted</string>
<string name="keywords_keyboard_and_ime">text correction, correct, sound, vibrate, auto, language, gesture, suggest, suggestion, theme, offensive, word, type, emoji, international</string>
@@ -8346,8 +8327,8 @@
<!-- Summary of payment screen [CHAR LIMIT=NONE] -->
<string name="payment_summary"><xliff:g id="app_name" example="Payment App">%1$s</xliff:g> is default</string>
- <!-- Summary of location screen [CHAR LIMIT=NONE] -->
- <string name="location_on_summary">ON / <xliff:g id="location_mode" example="High accuracy">%1$s</xliff:g></string>
+ <!-- Summary of location on screen [CHAR LIMIT=NONE] -->
+ <string name="location_on_summary">ON</string>
<!-- Location off [CHAR LIMIT=NONE] -->
<string name="location_off_summary">OFF</string>
@@ -9230,12 +9211,20 @@
<!-- Keywords for Directory Access settings -->
<string name="keywords_directory_access">directory access</string>
+ <!-- String used to describe the name of a directory in a volume; it must
+ show both names, with the directory name wrapped in parenthesis -->
+ <string name="directory_on_volume"><xliff:g id="volume" example="SD Card">%1$s</xliff:g> (<xliff:g id="directory" example="Movies">%2$s</xliff:g>)</string>
+
<!-- Account type associated with the backup account. Empty for AOSP. [DO NOT TRANSLATE] -->
- <string name="account_type"></string>
+ <string name="account_type" translatable="false"></string>
<!-- Package to target for Account credential confirmation. This will allow users to
remind/rediscover their backup account password prior to a reset. Empty for AOSP.
[DO NOT TRANSLATE] -->
- <string name="account_confirmation_package"></string>
+ <string name="account_confirmation_package" translatable="false"></string>
+ <!-- Class to target for Account credential confirmation. This will allow users to
+ remind/rediscover their backup account password prior to a reset. Empty for AOSP.
+ [DO NOT TRANSLATE] -->
+ <string name="account_confirmation_class" translatable="false"></string>
<!-- Title for the new About Phone screen [CHAR LIMIT=40] -->
<string name="my_device_info_title" product="default">My Phone</string>
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index c799c8b..6d20571 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -53,7 +53,7 @@
settings:useAdditionalSummary="true" />
<!-- Visibility Override -->
- <com.android.settings.notification.RestrictedDropDownPreference
+ <com.android.settings.RestrictedListPreference
android:key="visibility_override"
android:title="@string/app_notification_visibility_override_title"/>
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 520ebaa..e080be4 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -15,39 +15,27 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/configure_notification_settings"
android:key="configure_notification_settings">
- <PreferenceCategory
- android:key="recent_notifications_category"
- android:title="@string/recent_notifications"
- android:order="-200">
- <!-- Placeholder for a list of recent apps -->
-
- <!-- See all apps button -->
- <Preference
- android:title="@string/notifications_title"
- android:key="all_notifications"
- android:order="20">
- <intent
- android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.settings"
- android:targetClass="com.android.settings.Settings$NotificationAppListActivity">
- </intent>
- </Preference>
- </PreferenceCategory>
-
- <!-- Empty category to draw divider -->
- <PreferenceCategory
- android:key="all_notifications_divider"
- android:order="-190"/>
-
<!-- When device is locked -->
- <com.android.settings.notification.RestrictedDropDownPreference
+ <com.android.settings.RestrictedListPreference
android:key="lock_screen_notifications"
android:title="@string/lock_screen_notifications_title"
android:summary="@string/summary_placeholder"/>
+ <PreferenceCategory
+ android:key="lock_screen_notifications_profile_header"
+ android:title="@string/profile_section_header">
+
+ <com.android.settings.RestrictedListPreference
+ android:key="lock_screen_notifications_profile"
+ android:title="@string/lock_screen_notifications_title"
+ android:summary="@string/summary_placeholder"/>
+
+ </PreferenceCategory>
+
<!-- Notification badging -->
<SwitchPreference
android:key="notification_badging"
@@ -71,14 +59,30 @@
android:title="@string/fingerprint_swipe_for_notifications_title"
android:fragment="com.android.settings.gestures.SwipeToNotificationSettings" />
+ <!-- Empty category to draw divider -->
<PreferenceCategory
- android:key="lock_screen_notifications_profile_header"
- android:title="@string/profile_section_header">
+ android:key="all_notifications_divider"
+ android:order="20"/>
- <com.android.settings.notification.RestrictedDropDownPreference
- android:key="lock_screen_notifications_profile"
- android:title="@string/lock_screen_notifications_title"
- android:summary="@string/summary_placeholder"/>
+ <PreferenceCategory
+ android:key="recent_notifications_category"
+ android:title="@string/recent_notifications"
+ settings:allowDividerAbove="false"
+ android:order="21">
+ <!-- Placeholder for a list of recent apps -->
+ <!-- See all apps button -->
+ <Preference
+ android:title="@string/notifications_title"
+ android:key="all_notifications"
+ android:order="22">
+ <intent
+ android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.settings"
+ android:targetClass="com.android.settings.Settings$NotificationAppListActivity">
+ </intent>
+ </Preference>
</PreferenceCategory>
+
+
</PreferenceScreen>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 04644f5..5a0d249 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -15,109 +15,116 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="development_prefs_screen"
- android:title="@string/development_settings_title">
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="development_prefs_screen"
+ android:title="@string/development_settings_title">
- <Preference
- android:key="memory"
- android:icon="@drawable/ic_settings_memory"
- android:title="@string/memory_settings_title"
- android:summary="@string/summary_placeholder"
- android:fragment="com.android.settings.applications.ProcessStatsSummary" />
+ <PreferenceCategory
+ android:key="debug_misc_category"
+ android:order="100">
- <com.android.settings.BugreportPreference
+ <Preference
+ android:key="memory"
+ android:icon="@drawable/ic_settings_memory"
+ android:title="@string/memory_settings_title"
+ android:summary="@string/summary_placeholder"
+ android:fragment="com.android.settings.applications.ProcessStatsSummary" />
+
+ <com.android.settings.BugreportPreference
android:key="bugreport"
android:title="@*android:string/bugreport_title"
android:dialogTitle="@*android:string/bugreport_title" />
- <Preference
+ <Preference
android:key="local_backup_password"
android:title="@string/local_backup_password_title"
android:summary="@string/local_backup_password_summary_none"
- android:persistent="false" >
- <intent
+ android:persistent="false">
+ <intent
android:action="android.settings.privacy.SET_FULL_BACKUP_PASSWORD"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.SetFullBackupPassword" />
- </Preference>
+ </Preference>
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="keep_screen_on"
- android:title="@string/keep_screen_on"
- android:summary="@string/keep_screen_on_summary"
- settings:useAdditionalSummary="true" />
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="keep_screen_on"
+ android:title="@string/keep_screen_on"
+ android:summary="@string/keep_screen_on_summary"
+ settings:useAdditionalSummary="true" />
- <ListPreference
- android:key="hdcp_checking"
- android:title="@string/hdcp_checking_title"
- android:dialogTitle="@string/hdcp_checking_dialog_title"
- android:entries="@array/hdcp_checking_titles"
- android:entryValues="@array/hdcp_checking_values" />
+ <ListPreference
+ android:key="hdcp_checking"
+ android:title="@string/hdcp_checking_title"
+ android:dialogTitle="@string/hdcp_checking_dialog_title"
+ android:entries="@array/hdcp_checking_titles"
+ android:entryValues="@array/hdcp_checking_values" />
- <SwitchPreference
- android:key="bt_hci_snoop_log"
- android:title="@string/bt_hci_snoop_log"
- android:summary="@string/bt_hci_snoop_log_summary"/>
+ <SwitchPreference
+ android:key="bt_hci_snoop_log"
+ android:title="@string/bt_hci_snoop_log"
+ android:summary="@string/bt_hci_snoop_log_summary" />
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="oem_unlock_enable"
- android:title="@string/oem_unlock_enable"
- android:summary="@string/oem_unlock_enable_summary"
- settings:useAdditionalSummary="true"/>
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="oem_unlock_enable"
+ android:title="@string/oem_unlock_enable"
+ android:summary="@string/oem_unlock_enable_summary"
+ settings:useAdditionalSummary="true" />
- <Preference
- android:key="running_apps"
- android:title="@string/runningservices_settings_title"
- android:summary="@string/runningservices_settings_summary"
- android:fragment="com.android.settings.applications.RunningServices" />
+ <Preference
+ android:key="running_apps"
+ android:title="@string/runningservices_settings_title"
+ android:summary="@string/runningservices_settings_summary"
+ android:fragment="com.android.settings.applications.RunningServices" />
- <Preference
- android:key="convert_to_file_encryption"
- android:title="@string/convert_to_file_encryption"
- android:summary="@string/convert_to_file_encryption_enabled"
- android:fragment="com.android.settings.applications.ConvertToFbe" />
+ <Preference
+ android:key="convert_to_file_encryption"
+ android:title="@string/convert_to_file_encryption"
+ android:summary="@string/convert_to_file_encryption_enabled"
+ android:fragment="com.android.settings.applications.ConvertToFbe" />
- <com.android.settings.development.ColorModePreference
- android:key="picture_color_mode"
- android:title="@string/picture_color_mode"
- android:summary="@string/picture_color_mode_desc" />
+ <com.android.settings.development.ColorModePreference
+ android:key="picture_color_mode"
+ android:title="@string/picture_color_mode"
+ android:summary="@string/picture_color_mode_desc" />
- <Preference android:key="select_webview_provider"
- android:title="@string/select_webview_provider_title"
- android:dialogTitle="@string/select_webview_provider_dialog_title"
- android:fragment="com.android.settings.webview.WebViewAppPicker" />
+ <Preference android:key="select_webview_provider"
+ android:title="@string/select_webview_provider_title"
+ android:dialogTitle="@string/select_webview_provider_dialog_title"
+ android:fragment="com.android.settings.webview.WebViewAppPicker" />
- <SwitchPreference
- android:key="color_temperature"
- android:title="@string/color_temperature"
- android:summary="@string/color_temperature_desc" />
+ <SwitchPreference
+ android:key="color_temperature"
+ android:title="@string/color_temperature"
+ android:summary="@string/color_temperature_desc" />
- <SwitchPreference
- android:key="ota_disable_automatic_update"
- android:title="@string/ota_disable_automatic_update" />
+ <SwitchPreference
+ android:key="ota_disable_automatic_update"
+ android:title="@string/ota_disable_automatic_update" />
- <Preference
- android:key="demo_mode"
- android:title="@string/demo_mode">
- <intent android:action="com.android.settings.action.DEMO_MODE" />
- </Preference>
+ <Preference
+ android:key="demo_mode"
+ android:title="@string/demo_mode">
+ <intent android:action="com.android.settings.action.DEMO_MODE" />
+ </Preference>
- <Preference
- android:key="quick_settings_tiles"
- android:title="@string/quick_settings_developer_tiles"
- android:fragment="com.android.settings.development.qstile.DevelopmentTileConfigFragment" />
+ <Preference
+ android:key="quick_settings_tiles"
+ android:title="@string/quick_settings_developer_tiles"
+ android:fragment="com.android.settings.development.qstile.DevelopmentTileConfigFragment" />
+ </PreferenceCategory>
- <PreferenceCategory android:key="debug_debugging_category"
- android:title="@string/debug_debugging_category">
+ <PreferenceCategory
+ android:key="debug_debugging_category"
+ android:title="@string/debug_debugging_category"
+ android:order="200">
<SwitchPreference
android:key="enable_adb"
android:title="@string/enable_adb"
- android:summary="@string/enable_adb_summary"/>
+ android:summary="@string/enable_adb_summary" />
<Preference android:key="clear_adb_keys"
- android:title="@string/clear_adb_keys" />
+ android:title="@string/clear_adb_keys" />
<SwitchPreference
android:key="enable_terminal"
@@ -127,32 +134,32 @@
<SwitchPreference
android:key="bugreport_in_power"
android:title="@string/bugreport_in_power"
- android:summary="@string/bugreport_in_power_summary"/>
+ android:summary="@string/bugreport_in_power_summary" />
<Preference android:key="mock_location_app"
- android:title="@string/mock_location_app" />
+ android:title="@string/mock_location_app" />
<SwitchPreference
android:key="enable_gnss_raw_meas_full_tracking"
android:title="@string/enable_gnss_raw_meas_full_tracking"
- android:summary="@string/enable_gnss_raw_meas_full_tracking_summary"/>
+ android:summary="@string/enable_gnss_raw_meas_full_tracking_summary" />
<SwitchPreference
- android:key="debug_view_attributes"
- android:title="@string/debug_view_attributes" />
+ android:key="debug_view_attributes"
+ android:title="@string/debug_view_attributes" />
<Preference android:key="debug_app"
- android:title="@string/debug_app" />
+ android:title="@string/debug_app" />
<SwitchPreference
android:key="wait_for_debugger"
android:title="@string/wait_for_debugger"
- android:summary="@string/wait_for_debugger_summary"/>
+ android:summary="@string/wait_for_debugger_summary" />
<com.android.settingslib.RestrictedSwitchPreference
android:key="verify_apps_over_usb"
android:title="@string/verify_apps_over_usb_title"
- android:summary="@string/verify_apps_over_usb_summary"/>
+ android:summary="@string/verify_apps_over_usb_summary" />
<ListPreference
android:key="select_logd_size"
@@ -171,7 +178,7 @@
<SwitchPreference
android:key="connectivity_monitor_switch"
android:title="@string/connectivity_monitor_switch"
- android:summary="@string/connectivity_monitor_switch_summary"/>
+ android:summary="@string/connectivity_monitor_switch_summary" />
<SwitchPreference
android:key="camera_laser_sensor_switch"
@@ -180,42 +187,48 @@
<Preference
android:key="feature_flags_dashboard"
android:title="@string/feature_flags_dashboard_title"
- android:fragment="com.android.settings.development.featureflags.FeatureFlagsDashboard"/>
+ android:fragment="com.android.settings.development.featureflags.FeatureFlagsDashboard" />
<SwitchPreference
android:key="enable_gpu_debug_layers"
android:title="@string/enable_gpu_debug_layers"
- android:summary="@string/enable_gpu_debug_layers_summary"/>
+ android:summary="@string/enable_gpu_debug_layers_summary" />
</PreferenceCategory>
- <PreferenceCategory android:key="debug_networking_category"
- android:title="@string/debug_networking_category">
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="300" />
+
+ <PreferenceCategory
+ android:key="debug_networking_category"
+ android:title="@string/debug_networking_category"
+ android:order="400">
<SwitchPreference
android:key="wifi_display_certification"
android:title="@string/wifi_display_certification"
- android:summary="@string/wifi_display_certification_summary"/>
+ android:summary="@string/wifi_display_certification_summary" />
<SwitchPreference
android:key="wifi_verbose_logging"
android:title="@string/wifi_verbose_logging"
- android:summary="@string/wifi_verbose_logging_summary"/>
+ android:summary="@string/wifi_verbose_logging_summary" />
<SwitchPreference
android:key="wifi_connected_mac_randomization"
android:title="@string/wifi_connected_mac_randomization"
- android:summary="@string/wifi_connected_mac_randomization_summary"/>
+ android:summary="@string/wifi_connected_mac_randomization_summary" />
<SwitchPreference
android:key="mobile_data_always_on"
android:title="@string/mobile_data_always_on"
- android:summary="@string/mobile_data_always_on_summary"/>
+ android:summary="@string/mobile_data_always_on_summary" />
<SwitchPreference
android:key="tethering_hardware_offload"
android:title="@string/tethering_hardware_offload"
- android:summary="@string/tethering_hardware_offload_summary"/>
+ android:summary="@string/tethering_hardware_offload_summary" />
<ListPreference
android:key="select_usb_configuration"
@@ -227,17 +240,17 @@
<SwitchPreference
android:key="bluetooth_show_devices_without_names"
android:title="@string/bluetooth_show_devices_without_names"
- android:summary="@string/bluetooth_show_devices_without_names_summary"/>
+ android:summary="@string/bluetooth_show_devices_without_names_summary" />
<SwitchPreference
android:key="bluetooth_disable_absolute_volume"
android:title="@string/bluetooth_disable_absolute_volume"
- android:summary="@string/bluetooth_disable_absolute_volume_summary"/>
+ android:summary="@string/bluetooth_disable_absolute_volume_summary" />
<SwitchPreference
android:key="bluetooth_disable_inband_ringing"
android:title="@string/bluetooth_disable_inband_ringing"
- android:summary="@string/bluetooth_disable_inband_ringing_summary"/>
+ android:summary="@string/bluetooth_disable_inband_ringing_summary" />
<ListPreference
android:key="bluetooth_select_avrcp_version"
@@ -282,46 +295,50 @@
android:entryValues="@array/bluetooth_a2dp_codec_ldac_playback_quality_values" />
<ListPreference
- android:key="bluetooth_max_connected_audio_devices"
- android:title="@string/bluetooth_max_connected_audio_devices_string"
- android:dialogTitle="@string/bluetooth_max_connected_audio_devices_dialog_title"
- android:entries="@array/bluetooth_max_connected_audio_devices"
- android:entryValues="@array/bluetooth_max_connected_audio_devices_values" />
+ android:key="bluetooth_max_connected_audio_devices"
+ android:title="@string/bluetooth_max_connected_audio_devices_string"
+ android:dialogTitle="@string/bluetooth_max_connected_audio_devices_dialog_title"
+ android:entries="@array/bluetooth_max_connected_audio_devices"
+ android:entryValues="@array/bluetooth_max_connected_audio_devices_values" />
</PreferenceCategory>
- <PreferenceCategory android:key="debug_input_category"
- android:title="@string/debug_input_category">
+ <PreferenceCategory
+ android:key="debug_input_category"
+ android:title="@string/debug_input_category"
+ android:order="500">
<SwitchPreference
android:key="show_touches"
android:title="@string/show_touches"
- android:summary="@string/show_touches_summary"/>
+ android:summary="@string/show_touches_summary" />
<SwitchPreference
android:key="pointer_location"
android:title="@string/pointer_location"
- android:summary="@string/pointer_location_summary"/>
+ android:summary="@string/pointer_location_summary" />
</PreferenceCategory>
- <PreferenceCategory android:key="debug_drawing_category"
- android:title="@string/debug_drawing_category">
+ <PreferenceCategory
+ android:key="debug_drawing_category"
+ android:title="@string/debug_drawing_category"
+ android:order="600">
<SwitchPreference
android:key="show_screen_updates"
android:title="@string/show_screen_updates"
- android:summary="@string/show_screen_updates_summary"/>
+ android:summary="@string/show_screen_updates_summary" />
<SwitchPreference
android:key="debug_layout"
android:title="@string/debug_layout"
- android:summary="@string/debug_layout_summary"/>
+ android:summary="@string/debug_layout_summary" />
<SwitchPreference
android:key="force_rtl_layout_all_locales"
android:title="@string/force_rtl_layout_all_locales"
- android:summary="@string/force_rtl_layout_all_locales_summary"/>
+ android:summary="@string/force_rtl_layout_all_locales_summary" />
<ListPreference
android:key="window_animation_scale"
@@ -357,78 +374,78 @@
</PreferenceCategory>
- <PreferenceCategory android:key="debug_hw_drawing_category"
- android:title="@string/debug_hw_drawing_category">
+ <PreferenceCategory
+ android:key="debug_hw_drawing_category"
+ android:title="@string/debug_hw_drawing_category"
+ android:order="700">
<SwitchPreference
- android:key="force_hw_ui"
- android:title="@string/force_hw_ui"
- android:summary="@string/force_hw_ui_summary"/>
+ android:key="force_hw_ui"
+ android:title="@string/force_hw_ui"
+ android:summary="@string/force_hw_ui_summary" />
<SwitchPreference
- android:key="show_hw_screen_updates"
- android:title="@string/show_hw_screen_updates"
- android:summary="@string/show_hw_screen_updates_summary"/>
+ android:key="show_hw_screen_updates"
+ android:title="@string/show_hw_screen_updates"
+ android:summary="@string/show_hw_screen_updates_summary" />
<SwitchPreference
- android:key="show_hw_layers_updates"
- android:title="@string/show_hw_layers_updates"
- android:summary="@string/show_hw_layers_updates_summary"/>
+ android:key="show_hw_layers_updates"
+ android:title="@string/show_hw_layers_updates"
+ android:summary="@string/show_hw_layers_updates_summary" />
<ListPreference
- android:key="debug_hw_overdraw"
- android:title="@string/debug_hw_overdraw"
- android:entries="@array/debug_hw_overdraw_entries"
- android:entryValues="@array/debug_hw_overdraw_values" />
+ android:key="debug_hw_overdraw"
+ android:title="@string/debug_hw_overdraw"
+ android:entries="@array/debug_hw_overdraw_entries"
+ android:entryValues="@array/debug_hw_overdraw_values" />
<ListPreference
- android:key="show_non_rect_clip"
- android:title="@string/show_non_rect_clip"
- android:entries="@array/show_non_rect_clip_entries"
- android:entryValues="@array/show_non_rect_clip_values" />
+ android:key="show_non_rect_clip"
+ android:title="@string/show_non_rect_clip"
+ android:entries="@array/show_non_rect_clip_entries"
+ android:entryValues="@array/show_non_rect_clip_values" />
<SwitchPreference
- android:key="force_msaa"
- android:title="@string/force_msaa"
- android:summary="@string/force_msaa_summary"/>
+ android:key="force_msaa"
+ android:title="@string/force_msaa"
+ android:summary="@string/force_msaa_summary" />
<SwitchPreference
- android:key="disable_overlays"
- android:title="@string/disable_overlays"
- android:summary="@string/disable_overlays_summary"/>
+ android:key="disable_overlays"
+ android:title="@string/disable_overlays"
+ android:summary="@string/disable_overlays_summary" />
<ListPreference
- android:entries="@array/simulate_color_space_entries"
- android:entryValues="@array/simulate_color_space_values"
- android:key="simulate_color_space"
- android:summary="%s"
- android:title="@string/simulate_color_space" />
-
- <ListPreference
- android:key="debug_hw_renderer"
- android:title="@string/debug_hw_renderer"
- android:entries="@array/debug_hw_renderer_entries"
- android:entryValues="@array/debug_hw_renderer_values" />
+ android:entries="@array/simulate_color_space_entries"
+ android:entryValues="@array/simulate_color_space_values"
+ android:key="simulate_color_space"
+ android:summary="%s"
+ android:title="@string/simulate_color_space" />
</PreferenceCategory>
- <PreferenceCategory android:key="media_category"
- android:title="@string/media_category">
+ <PreferenceCategory
+ android:key="media_category"
+ android:title="@string/media_category"
+ android:order="800">
<SwitchPreference
- android:key="usb_audio"
- android:title="@string/usb_audio_disable_routing"
- android:summary="@string/usb_audio_disable_routing_summary" />
+ android:key="usb_audio"
+ android:title="@string/usb_audio_disable_routing"
+ android:summary="@string/usb_audio_disable_routing_summary" />
</PreferenceCategory>
- <PreferenceCategory android:key="debug_monitoring_category"
- android:title="@string/debug_monitoring_category">
+ <PreferenceCategory
+ android:key="debug_monitoring_category"
+ android:title="@string/debug_monitoring_category"
+ android:order="900">
<SwitchPreference
android:key="strict_mode"
android:title="@string/strict_mode"
- android:summary="@string/strict_mode_summary"/>
+ android:summary="@string/strict_mode_summary" />
<ListPreference
android:key="track_frame_time"
@@ -438,13 +455,15 @@
</PreferenceCategory>
- <PreferenceCategory android:key="debug_applications_category"
- android:title="@string/debug_applications_category">
+ <PreferenceCategory
+ android:key="debug_applications_category"
+ android:title="@string/debug_applications_category"
+ android:order="1000">
<SwitchPreference
android:key="immediately_destroy_activities"
android:title="@string/immediately_destroy_activities"
- android:summary="@string/immediately_destroy_activities_summary"/>
+ android:summary="@string/immediately_destroy_activities_summary" />
<ListPreference
android:key="app_process_limit"
@@ -454,52 +473,48 @@
<Preference
- android:key="background_check"
- android:fragment="com.android.settings.applications.appops.BackgroundCheckSummary"
- android:title="@string/background_check_pref" />
+ android:key="background_check"
+ android:fragment="com.android.settings.applications.appops.BackgroundCheckSummary"
+ android:title="@string/background_check_pref" />
<SwitchPreference
android:key="show_first_crash_dialog"
android:title="@string/show_first_crash_dialog"
- android:summary="@string/show_first_crash_dialog_summary"/>
+ android:summary="@string/show_first_crash_dialog_summary" />
<SwitchPreference
android:key="show_all_anrs"
android:title="@string/show_all_anrs"
- android:summary="@string/show_all_anrs_summary"/>
+ android:summary="@string/show_all_anrs_summary" />
<SwitchPreference
android:key="show_notification_channel_warnings"
android:title="@string/show_notification_channel_warnings"
- android:summary="@string/show_notification_channel_warnings_summary"/>
+ android:summary="@string/show_notification_channel_warnings_summary" />
<Preference
- android:key="inactive_apps"
- android:title="@string/inactive_apps_title"
- android:fragment="com.android.settings.fuelgauge.InactiveApps"/>
+ android:key="inactive_apps"
+ android:title="@string/inactive_apps_title"
+ android:fragment="com.android.settings.fuelgauge.InactiveApps" />
<SwitchPreference
android:key="force_allow_on_external"
android:title="@string/force_allow_on_external"
- android:summary="@string/force_allow_on_external_summary"/>
+ android:summary="@string/force_allow_on_external_summary" />
<SwitchPreference
android:key="force_resizable_activities"
android:title="@string/force_resizable_activities"
- android:summary="@string/force_resizable_activities_summary"/>
+ android:summary="@string/force_resizable_activities_summary" />
<SwitchPreference
- android:key="enable_freeform_support"
- android:title="@string/enable_freeform_support"
- android:summary="@string/enable_freeform_support_summary"/>
+ android:key="enable_freeform_support"
+ android:title="@string/enable_freeform_support"
+ android:summary="@string/enable_freeform_support_summary" />
<Preference
android:key="reset_shortcut_manager_throttling"
android:title="@string/reset_shortcut_manager_throttling" />
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="200"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/location_mode.xml b/res/xml/location_mode.xml
deleted file mode 100644
index ac8e584..0000000
--- a/res/xml/location_mode.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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:key="location_mode_settings"
- android:title="@string/location_mode_screen_title">
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="high_accuracy"
- android:title="@string/location_mode_high_accuracy_title"
- android:summary="@string/location_mode_high_accuracy_description" />
- <com.android.settings.widget.RadioButtonPreference
- android:key="battery_saving"
- android:title="@string/location_mode_battery_saving_title"
- android:summary="@string/location_mode_battery_saving_description" />
- <com.android.settings.widget.RadioButtonPreference
- android:key="sensors_only"
- android:title="@string/location_mode_sensors_only_title"
- android:summary="@string/location_mode_sensors_only_description" />
-
-</PreferenceScreen>
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 0414f20..267fce9 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -50,10 +50,4 @@
<PreferenceCategory
android:key="location_services"
android:title="@string/location_category_location_services" />
-
- <Preference
- android:key="location_mode"
- android:title="@string/location_mode_title"
- settings:keywords="@string/keywords_location_mode"
- android:summary="@string/summary_placeholder" />
</PreferenceScreen>
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 6faedd7..1da1de5 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -19,7 +19,7 @@
android:key="security_lockscreen_settings_screen"
android:title="@string/lockscreen_settings_title">
- <com.android.settings.notification.RestrictedDropDownPreference
+ <com.android.settings.RestrictedListPreference
android:key="security_setting_lock_screen_notif"
android:title="@string/lock_screen_notifications_title"
android:summary="@string/summary_placeholder" />
@@ -42,7 +42,7 @@
android:key="security_setting_lock_screen_notif_work_header"
android:title="@string/profile_section_header">
- <com.android.settings.notification.RestrictedDropDownPreference
+ <com.android.settings.RestrictedListPreference
android:key="security_setting_lock_screen_notif_work"
android:title="@string/lock_screen_notifications_title"
android:summary="@string/summary_placeholder" />
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index b7fb694..687e645 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -123,17 +123,21 @@
return !((requestCode != KEYGUARD_REQUEST) && (requestCode != CREDENTIAL_CONFIRM_REQUEST));
}
+ @VisibleForTesting
+ boolean isShowFinalConfirmation(int requestCode, int resultCode) {
+ return (resultCode == Activity.RESULT_OK) || (requestCode == CREDENTIAL_CONFIRM_REQUEST);
+ }
+
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
-
if (!isValidRequestCode(requestCode)) {
return;
}
// If the user entered a valid keyguard trace, present the final
// confirmation prompt; otherwise, go back to the initial state.
- if (resultCode == Activity.RESULT_OK) {
+ if (isShowFinalConfirmation(requestCode, resultCode)) {
showFinalConfirmation();
} else {
establishInitialState();
@@ -155,7 +159,10 @@
final Context context = getActivity();
final String accountType = context.getString(R.string.account_type);
final String packageName = context.getString(R.string.account_confirmation_package);
- if (TextUtils.isEmpty(accountType) || TextUtils.isEmpty(packageName)) {
+ final String className = context.getString(R.string.account_confirmation_class);
+ if (TextUtils.isEmpty(accountType)
+ || TextUtils.isEmpty(packageName)
+ || TextUtils.isEmpty(className)) {
return false;
}
final AccountManager am = AccountManager.get(context);
@@ -163,7 +170,7 @@
if (accounts != null && accounts.length > 0) {
final Intent requestAccountConfirmation = new Intent()
.setPackage(packageName)
- .setAction("android.accounts.action.PRE_FACTORY_RESET");
+ .setComponent(new ComponentName(packageName, className));
// Check to make sure that the intent is supported.
final PackageManager pm = context.getPackageManager();
final ResolveInfo resolution = pm.resolveActivity(requestAccountConfirmation, 0);
@@ -172,7 +179,7 @@
&& packageName.equals(resolution.activityInfo.packageName)) {
// Note that we need to check the packagename to make sure that an Activity resolver
// wasn't returned.
- getActivity().startActivityForResult(
+ startActivityForResult(
requestAccountConfirmation, CREDENTIAL_CONFIRM_REQUEST);
return true;
}
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index 78a5050..ff036bb 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -22,6 +22,7 @@
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AppGlobals;
+import android.app.GrantedUriPermission;
import android.app.LoaderManager;
import android.content.Context;
import android.content.DialogInterface;
@@ -399,7 +400,7 @@
// Gets all URI permissions from am.
ActivityManager am = (ActivityManager) getActivity().getSystemService(
Context.ACTIVITY_SERVICE);
- List<UriPermission> perms =
+ List<GrantedUriPermission> perms =
am.getGrantedUriPermissions(mAppEntry.info.packageName).getList();
if (perms.isEmpty()) {
@@ -411,8 +412,8 @@
// Group number of URIs by app.
Map<CharSequence, MutableInt> uriCounters = new TreeMap<>();
- for (UriPermission perm : perms) {
- String authority = perm.getUri().getAuthority();
+ for (GrantedUriPermission perm : perms) {
+ String authority = perm.uri.getAuthority();
ProviderInfo provider = pm.resolveContentProvider(authority, 0);
CharSequence app = provider.applicationInfo.loadLabel(pm);
MutableInt count = uriCounters.get(app);
diff --git a/src/com/android/settings/applications/DirectoryAccessDetails.java b/src/com/android/settings/applications/DirectoryAccessDetails.java
index 43422d0..3e9bf47 100644
--- a/src/com/android/settings/applications/DirectoryAccessDetails.java
+++ b/src/com/android/settings/applications/DirectoryAccessDetails.java
@@ -24,6 +24,7 @@
import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS;
import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS_COLUMNS;
import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS_COL_DIRECTORY;
+import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS_COL_GRANTED;
import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS_COL_PACKAGE;
import static android.os.storage.StorageVolume.ScopedAccessProviderContract.TABLE_PERMISSIONS_COL_VOLUME_UUID;
@@ -120,8 +121,7 @@
addPreferencesFromResource(R.xml.directory_access_details);
final PreferenceScreen prefsGroup = getPreferenceScreen();
- // Set external directory UUIDs.
- ArraySet<String> externalDirectoryUuids = null;
+ final Map<String, ExternalVolume> externalVolumes = new HashMap<>();
final Uri providerUri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
.authority(AUTHORITY).appendPath(TABLE_PERMISSIONS).appendPath("*")
@@ -146,8 +146,10 @@
final String pkg = cursor.getString(TABLE_PERMISSIONS_COL_PACKAGE);
final String uuid = cursor.getString(TABLE_PERMISSIONS_COL_VOLUME_UUID);
final String dir = cursor.getString(TABLE_PERMISSIONS_COL_DIRECTORY);
+ final boolean granted = cursor.getInt(TABLE_PERMISSIONS_COL_GRANTED) == 1;
if (VERBOSE) {
- Log.v(TAG, "Pkg:" + pkg + " uuid: " + uuid + " dir: " + dir);
+ Log.v(TAG, "Pkg:" + pkg + " uuid: " + uuid + " dir: " + dir
+ + " granted:" + granted);
}
if (!mPackageName.equals(pkg)) {
@@ -159,64 +161,92 @@
if (uuid == null) {
// Primary storage entry: add right away
- prefsGroup.addPreference(
- newPreference(context, dir, providerUri, /* uuid= */ null, dir));
+ prefsGroup.addPreference(newPreference(context, dir, providerUri,
+ /* uuid= */ null, dir, granted));
} else {
// External volume entry: save it for later.
- if (externalDirectoryUuids == null) {
- externalDirectoryUuids = new ArraySet<>(1);
+ ExternalVolume externalVolume = externalVolumes.get(uuid);
+ if (externalVolume == null) {
+ externalVolume = new ExternalVolume(uuid);
+ externalVolumes.put(uuid, externalVolume);
}
- externalDirectoryUuids.add(uuid);
+ if (dir == null) {
+ // Whole volume
+ externalVolume.granted = granted;
+ } else {
+ // Directory only
+ externalVolume.children.add(new Pair<>(dir, granted));
+ }
}
}
}
+ if (VERBOSE) {
+ Log.v(TAG, "external volumes: " + externalVolumes);
+ }
+
+ if (externalVolumes.isEmpty()) {
+ // We're done!
+ return;
+ }
+
// Add entries from external volumes
- if (externalDirectoryUuids != null) {
- if (VERBOSE) {
- Log.v(TAG, "adding external directories: " + externalDirectoryUuids);
- }
- // Query StorageManager to get the user-friendly volume names.
- final StorageManager sm = context.getSystemService(StorageManager.class);
- final List<VolumeInfo> volumes = sm.getVolumes();
- if (volumes.isEmpty()) {
- Log.w(TAG, "StorageManager returned no secondary volumes");
- return;
- }
- final Map<String, String> volumeNames = new HashMap<>(volumes.size());
- for (VolumeInfo volume : volumes) {
- final String uuid = volume.getFsUuid();
- if (uuid == null) continue; // Primary storage; not used.
+ // Query StorageManager to get the user-friendly volume names.
+ final StorageManager sm = context.getSystemService(StorageManager.class);
+ final List<VolumeInfo> volumes = sm.getVolumes();
+ if (volumes.isEmpty()) {
+ Log.w(TAG, "StorageManager returned no secondary volumes");
+ return;
+ }
+ final Map<String, String> volumeNames = new HashMap<>(volumes.size());
+ for (VolumeInfo volume : volumes) {
+ final String uuid = volume.getFsUuid();
+ if (uuid == null) continue; // Primary storage; not used.
- String name = sm.getBestVolumeDescription(volume);
- if (name == null) {
- Log.w(TAG, "No description for " + volume + "; using uuid instead: " + uuid);
- name = uuid;
- }
- volumeNames.put(uuid, name);
+ String name = sm.getBestVolumeDescription(volume);
+ if (name == null) {
+ Log.w(TAG, "No description for " + volume + "; using uuid instead: " + uuid);
+ name = uuid;
}
- if (VERBOSE) {
- Log.v(TAG, "UUID -> name mapping: " + volumeNames);
- }
+ volumeNames.put(uuid, name);
+ }
+ if (VERBOSE) {
+ Log.v(TAG, "UUID -> name mapping: " + volumeNames);
+ }
- externalDirectoryUuids.forEach((uuid) ->{
- final String name = volumeNames.get(uuid);
- // TODO(b/72055774): add separator
- prefsGroup.addPreference(
- newPreference(context, name, providerUri, uuid, /* dir= */ null));
+ for (ExternalVolume volume : externalVolumes.values()) {
+ final String volumeName = volumeNames.get(volume.uuid);
+ if (volumeName == null) {
+ Log.w(TAG, "Ignoring entry for invalid UUID: " + volume.uuid);
+ continue;
+ }
+ // First add the pref for the whole volume...
+ // TODO(b/72055774): add separator
+ prefsGroup.addPreference(newPreference(context, volumeName, providerUri, volume.uuid,
+ /* dir= */ null, volume.granted));
+ // TODO(b/72055774): make sure children are gone when parent is toggled on - should be
+ // handled automatically if we're refreshing the activity on change, otherwise we'll
+ // need to explicitly remove them
+
+ // ... then the children prefs
+ volume.children.forEach((pair) -> {
+ final String dir = pair.first;
+ final String name = context.getResources()
+ .getString(R.string.directory_on_volume, volumeName, dir);
+ prefsGroup
+ .addPreference(newPreference(context, name, providerUri, volume.uuid,
+ dir, pair.second));
});
}
- return;
}
-
private SwitchPreference newPreference(Context context, String title, Uri providerUri,
- String uuid, String dir) {
+ String uuid, String dir, boolean granted) {
final SwitchPreference pref = new SwitchPreference(context);
pref.setKey(String.format("%s:%s", uuid, dir));
pref.setTitle(title);
- pref.setChecked(false);
+ pref.setChecked(granted);
pref.setOnPreferenceChangeListener((unused, value) -> {
resetDoNotAskAgain(context, value, providerUri, uuid, dir);
return true;
@@ -259,4 +289,20 @@
public int getMetricsCategory() {
return MetricsEvent.APPLICATIONS_DIRECTORY_ACCESS_DETAIL;
}
+
+ private static class ExternalVolume {
+ final String uuid;
+ final List<Pair<String, Boolean>> children = new ArrayList<>();
+ boolean granted;
+
+ ExternalVolume(String uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public String toString() {
+ return "ExternalVolume: [uuid=" + uuid + ", granted=" + granted +
+ ", children=" + children + "]";
+ }
+ }
}
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 20c5581..3859081 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -325,7 +325,7 @@
// Not visible on launcher -> likely not a user visible app, skip if non-instant.
final ApplicationsState.AppEntry appEntry =
mApplicationsState.getEntry(pkgName, mUserId);
- if (!AppUtils.isInstant(appEntry.info)) {
+ if (appEntry == null || appEntry.info == null || !AppUtils.isInstant(appEntry.info)) {
Log.d(TAG, "Not a user visible or instant app, skipping " + pkgName);
return false;
}
diff --git a/src/com/android/settings/dashboard/DashboardAdapter.java b/src/com/android/settings/dashboard/DashboardAdapter.java
index 2d35ea7..9b23417 100644
--- a/src/com/android/settings/dashboard/DashboardAdapter.java
+++ b/src/com/android/settings/dashboard/DashboardAdapter.java
@@ -45,13 +45,13 @@
import com.android.settings.dashboard.conditional.Condition;
import com.android.settings.dashboard.conditional.ConditionAdapter;
import com.android.settings.dashboard.suggestions.SuggestionAdapter;
-import com.android.settings.dashboard.suggestions.SuggestionControllerMixin;
import com.android.settings.dashboard.suggestions.SuggestionDismissController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.Utils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/com/android/settings/dashboard/DashboardAdapterV2.java b/src/com/android/settings/dashboard/DashboardAdapterV2.java
index ad93e4c..7cd4f38 100644
--- a/src/com/android/settings/dashboard/DashboardAdapterV2.java
+++ b/src/com/android/settings/dashboard/DashboardAdapterV2.java
@@ -17,7 +17,6 @@
import android.app.Activity;
import android.content.Context;
-import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Bundle;
@@ -43,7 +42,6 @@
import com.android.settings.dashboard.conditional.Condition;
import com.android.settings.dashboard.conditional.ConditionAdapterV2;
import com.android.settings.dashboard.suggestions.SuggestionAdapterV2;
-import com.android.settings.dashboard.suggestions.SuggestionControllerMixin;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -51,6 +49,7 @@
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import java.util.List;
@@ -95,7 +94,7 @@
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(context);
mCache = new IconCache(context);
mSuggestionAdapter = new SuggestionAdapterV2(mContext, suggestionControllerMixin,
- savedInstanceState, this /* callback */, lifecycle);
+ savedInstanceState, this /* callback */, lifecycle);
setHasStableIds(true);
@@ -110,11 +109,11 @@
}
mDashboardData = new DashboardDataV2.Builder()
- .setConditions(conditions)
- .setSuggestions(mSuggestionAdapter.getSuggestions())
- .setCategory(category)
- .setConditionExpanded(conditionExpanded)
- .build();
+ .setConditions(conditions)
+ .setSuggestions(mSuggestionAdapter.getSuggestions())
+ .setCategory(category)
+ .setConditionExpanded(conditionExpanded)
+ .build();
}
public void setSuggestions(List<Suggestion> data) {
@@ -126,7 +125,6 @@
}
public void setCategory(DashboardCategory category) {
- tintIcons(category);
final DashboardDataV2 prevData = mDashboardData;
Log.d(TAG, "adapter setCategory called");
mDashboardData = new DashboardDataV2.Builder(prevData)
@@ -155,8 +153,8 @@
// remain as the dashboard item. Need to refresh the dashboard list.
final DashboardDataV2 prevData = mDashboardData;
mDashboardData = new DashboardDataV2.Builder(prevData)
- .setSuggestions(null)
- .build();
+ .setSuggestions(null)
+ .build();
notifyDashboardDataChanged(prevData);
} else {
mSuggestionAdapter.removeSuggestion(suggestion);
@@ -194,7 +192,7 @@
switch (type) {
case R.layout.dashboard_tile:
final Tile tile = (Tile) mDashboardData.getItemEntityByPosition(position);
- onBindTile((DashboardItemHolder) holder, tile);
+ onBindTile(holder, tile);
holder.itemView.setTag(tile);
holder.itemView.setOnClickListener(mTileClickListener);
break;
@@ -214,7 +212,7 @@
MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, false);
DashboardDataV2 prevData = mDashboardData;
mDashboardData = new DashboardDataV2.Builder(prevData).
- setConditionExpanded(false).build();
+ setConditionExpanded(false).build();
notifyDashboardDataChanged(prevData);
scrollToTopOfConditions();
});
@@ -275,14 +273,14 @@
} else {
holder.title.setText(null);
holder.summary.setText(
- mContext.getString(R.string.condition_summary, data.conditionCount));
+ mContext.getString(R.string.condition_summary, data.conditionCount));
updateConditionIcons(data.conditionIcons, holder.icons);
holder.icons.setVisibility(View.VISIBLE);
}
holder.itemView.setOnClickListener(v -> {
mMetricsFeatureProvider.action(mContext,
- MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
+ MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
final DashboardDataV2 prevData = mDashboardData;
mDashboardData = new DashboardDataV2.Builder(prevData)
.setConditionExpanded(true).build();
@@ -294,8 +292,8 @@
@VisibleForTesting
void onBindCondition(final ConditionContainerHolder holder, int position) {
final ConditionAdapterV2 adapter = new ConditionAdapterV2(mContext,
- (List<Condition>) mDashboardData.getItemEntityByPosition(position),
- mDashboardData.isConditionExpanded());
+ (List<Condition>) mDashboardData.getItemEntityByPosition(position),
+ mDashboardData.isConditionExpanded());
adapter.addDismissHandling(holder.data);
holder.data.setAdapter(adapter);
holder.data.setLayoutManager(new LinearLayoutManager(mContext));
@@ -306,10 +304,10 @@
// If there is suggestions to show, it will be at position 0 as we don't show the suggestion
// header anymore.
final List<Suggestion> suggestions =
- (List<Suggestion>) mDashboardData.getItemEntityByPosition(position);
+ (List<Suggestion>) mDashboardData.getItemEntityByPosition(position);
final int suggestionCount = suggestions.size();
if (suggestions != null && suggestionCount > 0) {
- holder.summary.setText(""+suggestionCount);
+ holder.summary.setText("" + suggestionCount);
mSuggestionAdapter.setSuggestions(suggestions);
holder.data.setAdapter(mSuggestionAdapter);
}
@@ -318,8 +316,14 @@
holder.data.setLayoutManager(layoutManager);
}
- private void onBindTile(DashboardItemHolder holder, Tile tile) {
- holder.icon.setImageDrawable(mCache.getIcon(tile.icon));
+ @VisibleForTesting
+ void onBindTile(DashboardItemHolder holder, Tile tile) {
+ Drawable icon = mCache.getIcon(tile.icon);
+ if (!TextUtils.equals(tile.icon.getResPackage(), mContext.getPackageName())) {
+ icon = new RoundedHomepageIcon(mContext, icon);
+ mCache.updateIcon(tile.icon, icon);
+ }
+ holder.icon.setImageDrawable(icon);
holder.title.setText(tile.title);
if (!TextUtils.isEmpty(tile.summary)) {
holder.summary.setText(tile.summary);
@@ -329,25 +333,6 @@
}
}
- private void tintIcons(DashboardCategory category) {
- if (!mDashboardFeatureProvider.shouldTintIcon()) {
- return;
- }
- // TODO: Better place for tinting?
- final TypedArray a = mContext.obtainStyledAttributes(new int[]{
- android.R.attr.colorControlNormal});
- final int tintColor = a.getColor(0, mContext.getColor(R.color.fallback_tintColor));
- a.recycle();
- if (category != null) {
- for (Tile tile : category.getTiles()) {
- if (tile.isIconTintable) {
- // If this drawable is tintable, tint it to match the color.
- tile.icon.setTint(tintColor);
- }
- }
- }
- }
-
@Override
public void onSaveInstanceState(Bundle outState) {
final DashboardCategory category = mDashboardData.getCategory();
@@ -392,10 +377,14 @@
Drawable drawable = mMap.get(icon);
if (drawable == null) {
drawable = icon.loadDrawable(mContext);
- mMap.put(icon, drawable);
+ updateIcon(icon, drawable);
}
return drawable;
}
+
+ public void updateIcon(Icon icon, Drawable drawable) {
+ mMap.put(icon, drawable);
+ }
}
public static class DashboardItemHolder extends RecyclerView.ViewHolder {
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProvider.java b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
index c493e672..e0873f5 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProvider.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
@@ -56,7 +56,9 @@
/**
* Whether or not we should tint icons in setting pages.
+ * @deprecated in favor of color icons in homepage
*/
+ @Deprecated
boolean shouldTintIcon();
/**
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index 15b407b..fc82d41 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -38,7 +38,6 @@
import com.android.settings.dashboard.conditional.ConditionManager.ConditionListener;
import com.android.settings.dashboard.conditional.FocusRecyclerView;
import com.android.settings.dashboard.conditional.FocusRecyclerView.FocusListener;
-import com.android.settings.dashboard.suggestions.SuggestionControllerMixin;
import com.android.settings.dashboard.suggestions.SuggestionDismissController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.ActionBarShadowController;
@@ -46,6 +45,7 @@
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.SettingsDrawerActivity;
import com.android.settingslib.drawer.SettingsDrawerActivity.CategoryListener;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import com.android.settingslib.utils.ThreadUtils;
import java.util.List;
@@ -87,7 +87,9 @@
super.onAttach(context);
Log.d(TAG, "Creating SuggestionControllerMixin");
mSuggestionControllerMixin = new SuggestionControllerMixin(context, this /* host */,
- getLifecycle());
+ getLifecycle(), FeatureFactory.getFactory(context)
+ .getSuggestionFeatureProvider(context)
+ .getSuggestionServiceComponent());
}
@Override
diff --git a/src/com/android/settings/dashboard/RoundedHomepageIcon.java b/src/com/android/settings/dashboard/RoundedHomepageIcon.java
new file mode 100644
index 0000000..19749b9
--- /dev/null
+++ b/src/com/android/settings/dashboard/RoundedHomepageIcon.java
@@ -0,0 +1,36 @@
+/*
+ * 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.dashboard;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
+
+import com.android.settings.R;
+
+public class RoundedHomepageIcon extends LayerDrawable {
+
+ public RoundedHomepageIcon(Context context, Drawable foreground) {
+ super(new Drawable[] {
+ context.getDrawable(R.drawable.ic_homepage_generic_background),
+ foreground
+ });
+ final int insetPx = context.getResources()
+ .getDimensionPixelSize(R.dimen.dashboard_tile_foreground_image_inset);
+ setLayerInset(1 /* index */, insetPx, insetPx, insetPx, insetPx);
+ }
+}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
index 2b79a9b..d1d7db2 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
@@ -31,6 +31,7 @@
import com.android.settings.dashboard.DashboardAdapter.IconCache;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import java.util.List;
import java.util.Objects;
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2.java b/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2.java
index e04ae93..483af92 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2.java
@@ -38,6 +38,7 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionController.java b/src/com/android/settings/dashboard/suggestions/SuggestionController.java
deleted file mode 100644
index 8fe1a47..0000000
--- a/src/com/android/settings/dashboard/suggestions/SuggestionController.java
+++ /dev/null
@@ -1,174 +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.dashboard.suggestions;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.service.settings.suggestions.ISuggestionService;
-import android.service.settings.suggestions.Suggestion;
-import android.support.annotation.Nullable;
-import android.support.annotation.WorkerThread;
-import android.util.Log;
-
-import java.util.List;
-
-/**
- * A controller class to access suggestion data.
- */
-public class SuggestionController {
-
- /**
- * Callback interface when service is connected/disconnected.
- */
- public interface ServiceConnectionListener {
- /**
- * Called when service is connected.
- */
- void onServiceConnected();
-
- /**
- * Called when service is disconnected.
- */
- void onServiceDisconnected();
- }
-
- private static final String TAG = "SuggestionController";
- private static final boolean DEBUG = false;
-
- private final Context mContext;
- private final Intent mServiceIntent;
-
- private ServiceConnection mServiceConnection;
- private ISuggestionService mRemoteService;
- private ServiceConnectionListener mConnectionListener;
-
- /**
- * Create a new controller instance.
- *
- * @param context caller context
- * @param service The component name for service.
- * @param listener listener to receive service connected/disconnected event.
- */
- public SuggestionController(Context context, ComponentName service,
- ServiceConnectionListener listener) {
- mContext = context.getApplicationContext();
- mConnectionListener = listener;
- mServiceIntent = new Intent().setComponent(service);
- mServiceConnection = createServiceConnection();
- }
-
- /**
- * Start the controller.
- */
- public void start() {
- mContext.bindServiceAsUser(mServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE,
- android.os.Process.myUserHandle());
- }
-
- /**
- * Stop the controller.
- */
- public void stop() {
- if (mRemoteService != null) {
- mRemoteService = null;
- mContext.unbindService(mServiceConnection);
- }
- }
-
- /**
- * Get setting suggestions.
- */
- @Nullable
- @WorkerThread
- public List<Suggestion> getSuggestions() {
- if (!isReady()) {
- return null;
- }
- try {
- return mRemoteService.getSuggestions();
- } catch (NullPointerException e) {
- Log.w(TAG, "mRemote service detached before able to query", e);
- return null;
- } catch (RemoteException e) {
- Log.w(TAG, "Error when calling getSuggestion()", e);
- return null;
- }
- }
-
- public void dismissSuggestions(Suggestion suggestion) {
- if (!isReady()) {
- Log.w(TAG, "SuggestionController not ready, cannot dismiss " + suggestion.getId());
- return;
- }
- try {
- mRemoteService.dismissSuggestion(suggestion);
- } catch (RemoteException e) {
- Log.w(TAG, "Error when calling dismissSuggestion()", e);
- }
- }
-
- public void launchSuggestion(Suggestion suggestion) {
- if (!isReady()) {
- Log.w(TAG, "SuggestionController not ready, cannot launch " + suggestion.getId());
- return;
- }
-
- try {
- mRemoteService.launchSuggestion(suggestion);
- } catch (RemoteException e) {
- Log.w(TAG, "Error when calling launchSuggestion()", e);
- }
- }
-
- /**
- * Whether or not the manager is ready
- */
- private boolean isReady() {
- return mRemoteService != null;
- }
-
- /**
- * Create a new {@link ServiceConnection} object to handle service connect/disconnect event.
- */
- private ServiceConnection createServiceConnection() {
- return new ServiceConnection() {
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- if (DEBUG) {
- Log.d(TAG, "Service is connected");
- }
- mRemoteService = ISuggestionService.Stub.asInterface(service);
- if (mConnectionListener != null) {
- mConnectionListener.onServiceConnected();
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- if (mConnectionListener != null) {
- mRemoteService = null;
- mConnectionListener.onServiceDisconnected();
- }
- }
- };
- }
-}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixin.java b/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixin.java
deleted file mode 100644
index 81496ee..0000000
--- a/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixin.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.dashboard.suggestions;
-
-import android.app.LoaderManager;
-import android.content.Context;
-import android.content.Loader;
-import android.os.Bundle;
-import android.service.settings.suggestions.Suggestion;
-import android.support.annotation.Nullable;
-import android.util.Log;
-
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.core.lifecycle.events.OnStop;
-
-import java.util.List;
-
-/**
- * Manages IPC communication to SettingsIntelligence for suggestion related services.
- */
-public class SuggestionControllerMixin implements SuggestionController.ServiceConnectionListener,
- LifecycleObserver, OnStart, OnStop, LoaderManager.LoaderCallbacks<List<Suggestion>> {
-
- public interface SuggestionControllerHost {
- /**
- * Called when suggestion data fetching is ready.
- */
- void onSuggestionReady(List<Suggestion> data);
-
- /**
- * Returns {@link LoaderManager} associated with the host. If host is not attached to
- * activity then return null.
- */
- @Nullable
- LoaderManager getLoaderManager();
- }
-
- private static final String TAG = "SuggestionCtrlMixin";
- private static final boolean DEBUG = false;
-
- private final Context mContext;
- private final SuggestionController mSuggestionController;
- private final SuggestionControllerHost mHost;
-
- private boolean mSuggestionLoaded;
-
- public SuggestionControllerMixin(Context context, SuggestionControllerHost host,
- Lifecycle lifecycle) {
- mContext = context.getApplicationContext();
- mHost = host;
- mSuggestionController = new SuggestionController(mContext,
- FeatureFactory.getFactory(mContext)
- .getSuggestionFeatureProvider(mContext)
- .getSuggestionServiceComponent(),
- this /* serviceConnectionListener */);
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
- }
-
- @Override
- public void onStart() {
- mSuggestionController.start();
- }
-
- @Override
- public void onStop() {
- mSuggestionController.stop();
- }
-
- @Override
- public void onServiceConnected() {
- final LoaderManager loaderManager = mHost.getLoaderManager();
- if (loaderManager != null) {
- loaderManager.restartLoader(SuggestionLoader.LOADER_ID_SUGGESTIONS,
- null /* args */, this /* callback */);
- }
- }
-
- @Override
- public void onServiceDisconnected() {
- if (DEBUG) {
- Log.d(TAG, "SuggestionService disconnected");
- }
- final LoaderManager loaderManager = mHost.getLoaderManager();
- if (loaderManager != null) {
- loaderManager.destroyLoader(SuggestionLoader.LOADER_ID_SUGGESTIONS);
- }
- }
-
- @Override
- public Loader<List<Suggestion>> onCreateLoader(int id, Bundle args) {
- if (id == SuggestionLoader.LOADER_ID_SUGGESTIONS) {
- mSuggestionLoaded = false;
- return new SuggestionLoader(mContext, mSuggestionController);
- }
- throw new IllegalArgumentException("This loader id is not supported " + id);
- }
-
- @Override
- public void onLoadFinished(Loader<List<Suggestion>> loader, List<Suggestion> data) {
- mSuggestionLoaded = true;
- mHost.onSuggestionReady(data);
- }
-
- @Override
- public void onLoaderReset(Loader<List<Suggestion>> loader) {
- mSuggestionLoaded = false;
- }
-
- public boolean isSuggestionLoaded() {
- return mSuggestionLoaded;
- }
-
- public void dismissSuggestion(Suggestion suggestion) {
- mSuggestionController.dismissSuggestions(suggestion);
- }
-
- public void launchSuggestion(Suggestion suggestion) {
- mSuggestionController.launchSuggestion(suggestion);
- }
-}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionDismissController.java b/src/com/android/settings/dashboard/suggestions/SuggestionDismissController.java
index db2d0bb..6a8db89 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionDismissController.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionDismissController.java
@@ -23,6 +23,7 @@
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
/**
* Deprecated as a close button is provided to dismiss the suggestion.
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
index bdc29e7..b700049 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
@@ -24,6 +24,7 @@
import android.util.Pair;
import com.android.settingslib.drawer.Tile;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import java.util.List;
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
index 60b20e0..4e5f688 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
@@ -40,6 +40,7 @@
import com.android.settings.wifi.WifiCallingSuggestionActivity;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.drawer.Tile;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import java.util.List;
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionLoader.java b/src/com/android/settings/dashboard/suggestions/SuggestionLoader.java
deleted file mode 100644
index 8c5b46d..0000000
--- a/src/com/android/settings/dashboard/suggestions/SuggestionLoader.java
+++ /dev/null
@@ -1,54 +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.dashboard.suggestions;
-
-import android.content.Context;
-import android.service.settings.suggestions.Suggestion;
-import android.util.Log;
-
-import com.android.settingslib.utils.AsyncLoader;
-
-import java.util.List;
-
-public class SuggestionLoader extends AsyncLoader<List<Suggestion>> {
-
- public static final int LOADER_ID_SUGGESTIONS = 42;
- private static final String TAG = "SuggestionLoader";
-
- private final SuggestionController mSuggestionController;
-
- public SuggestionLoader(Context context, SuggestionController controller) {
- super(context);
- mSuggestionController = controller;
- }
-
- @Override
- protected void onDiscardResult(List<Suggestion> result) {
-
- }
-
- @Override
- public List<Suggestion> loadInBackground() {
- final List<Suggestion> data = mSuggestionController.getSuggestions();
- if (data == null) {
- Log.d(TAG, "data is null");
- } else {
- Log.d(TAG, "data size " + data.size());
- }
- return data;
- }
-}
diff --git a/src/com/android/settings/datausage/DataPlanUsageSummary.java b/src/com/android/settings/datausage/DataPlanUsageSummary.java
index a56bfa1..9489322 100644
--- a/src/com/android/settings/datausage/DataPlanUsageSummary.java
+++ b/src/com/android/settings/datausage/DataPlanUsageSummary.java
@@ -48,6 +48,11 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * @deprecated This fragment was supposed to be new version of {@link DataUsageSummary} however
+ * unfinished and used nowhere. Keep it in case we may bring it back someday.
+ */
+@Deprecated
public class DataPlanUsageSummary extends DataUsageBase {
public static final String KEY_DATA_PLAN_USAGE = "data_plan_usage";
diff --git a/src/com/android/settings/datausage/DataUsageBase.java b/src/com/android/settings/datausage/DataUsageBase.java
index f08d534..b889a2f 100644
--- a/src/com/android/settings/datausage/DataUsageBase.java
+++ b/src/com/android/settings/datausage/DataUsageBase.java
@@ -36,6 +36,10 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settingslib.NetworkPolicyEditor;
+/**
+ * @deprecated please use {@link DataUsageBaseFragment} instead.
+ */
+@Deprecated
public abstract class DataUsageBase extends SettingsPreferenceFragment {
private static final String TAG = "DataUsageBase";
private static final String ETHERNET = "ethernet";
diff --git a/src/com/android/settings/datausage/DataUsageBaseFragment.java b/src/com/android/settings/datausage/DataUsageBaseFragment.java
new file mode 100644
index 0000000..344f2b8
--- /dev/null
+++ b/src/com/android/settings/datausage/DataUsageBaseFragment.java
@@ -0,0 +1,130 @@
+/*
+ * 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.datausage;
+
+import static android.net.ConnectivityManager.TYPE_ETHERNET;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.INetworkStatsService;
+import android.net.INetworkStatsSession;
+import android.net.NetworkPolicy;
+import android.net.NetworkPolicyManager;
+import android.net.NetworkTemplate;
+import android.net.TrafficStats;
+import android.os.Bundle;
+import android.os.INetworkManagementService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemProperties;
+import android.os.UserManager;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.NetworkPolicyEditor;
+
+public abstract class DataUsageBaseFragment extends DashboardFragment {
+ private static final String TAG = "DataUsageBase";
+ private static final String ETHERNET = "ethernet";
+
+ protected final TemplatePreference.NetworkServices services =
+ new TemplatePreference.NetworkServices();
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ final Context context = getActivity();
+
+ services.mNetworkService = INetworkManagementService.Stub.asInterface(
+ ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
+ services.mStatsService = INetworkStatsService.Stub.asInterface(
+ ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
+ services.mPolicyManager = NetworkPolicyManager.from(context);
+
+ services.mPolicyEditor = new NetworkPolicyEditor(services.mPolicyManager);
+
+ services.mTelephonyManager = TelephonyManager.from(context);
+ services.mSubscriptionManager = SubscriptionManager.from(context);
+ services.mUserManager = UserManager.get(context);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ services.mPolicyEditor.read();
+ }
+
+ protected boolean isAdmin() {
+ return services.mUserManager.isAdminUser();
+ }
+
+ protected boolean isMobileDataAvailable(int subId) {
+ return services.mSubscriptionManager.getActiveSubscriptionInfo(subId) != null;
+ }
+
+ protected boolean isNetworkPolicyModifiable(NetworkPolicy policy, int subId) {
+ return policy != null && isBandwidthControlEnabled() && services.mUserManager.isAdminUser()
+ && isDataEnabled(subId);
+ }
+
+ private boolean isDataEnabled(int subId) {
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return true;
+ }
+ return services.mTelephonyManager.getDataEnabled(subId);
+ }
+
+ protected boolean isBandwidthControlEnabled() {
+ try {
+ return services.mNetworkService.isBandwidthControlEnabled();
+ } catch (RemoteException e) {
+ Log.w(TAG, "problem talking with INetworkManagementService: ", e);
+ return false;
+ }
+ }
+
+ /**
+ * Test if device has an ethernet network connection.
+ */
+ public boolean hasEthernet(Context context) {
+ if (DataUsageUtils.TEST_RADIOS) {
+ return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains(ETHERNET);
+ }
+
+ final ConnectivityManager conn = ConnectivityManager.from(context);
+ final boolean hasEthernet = conn.isNetworkSupported(TYPE_ETHERNET);
+
+ final long ethernetBytes;
+ try {
+ INetworkStatsSession statsSession = services.mStatsService.openSession();
+ if (statsSession != null) {
+ ethernetBytes = statsSession.getSummaryForNetwork(
+ NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
+ .getTotalBytes();
+ TrafficStats.closeQuietly(statsSession);
+ } else {
+ ethernetBytes = 0;
+ }
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+
+ // only show ethernet when both hardware present and traffic has occurred
+ return hasEthernet && ethernetBytes > 0;
+ }
+}
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index e626c3a..b63cee3 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -46,6 +46,7 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.NetworkPolicyEditor;
+import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.net.DataUsageController;
import java.util.ArrayList;
@@ -53,11 +54,11 @@
/**
* Settings preference fragment that displays data usage summary.
- *
- * This class in deprecated use {@link DataPlanUsageSummary}.
*/
-@Deprecated
-public class DataUsageSummary extends DataUsageBase implements Indexable, DataUsageEditController {
+public class DataUsageSummary extends DataUsageBaseFragment implements Indexable,
+ DataUsageEditController {
+
+ private static final String TAG = "DataUsageSummary";
static final boolean LOGD = false;
@@ -100,7 +101,6 @@
boolean hasMobileData = DataUsageUtils.hasMobileData(context);
mDataUsageController = new DataUsageController(context);
mDataInfoController = new DataUsageInfoController();
- addPreferencesFromResource(R.xml.data_usage);
int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
@@ -177,6 +177,21 @@
return super.onPreferenceTreeClick(preference);
}
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.data_usage;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+ return null;
+ }
+
private void addMobileSection(int subId) {
addMobileSection(subId, null);
}
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index e4e6493..171dd6a 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -18,6 +18,8 @@
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothCodecConfig;
+import android.bluetooth.BluetoothCodecStatus;
+import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference;
@@ -80,7 +82,7 @@
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
synchronized (mBluetoothA2dpConfigStore) {
if (mBluetoothA2dp != null) {
- setCodecConfigPreference(codecConfig);
+ setCodecConfigPreference(null, codecConfig); // Use current active device
}
}
// Because the setting is not persisted into permanent storage, we cannot call update state
@@ -99,13 +101,13 @@
@Override
public void updateState(Preference preference) {
- if (getCodecConfig() == null || mPreference == null) {
+ if (getCodecConfig(null) == null || mPreference == null) { // Use current active device
return;
}
BluetoothCodecConfig codecConfig;
synchronized (mBluetoothA2dpConfigStore) {
- codecConfig = getCodecConfig();
+ codecConfig = getCodecConfig(null); // Use current active device
}
final int index = getCurrentA2dpSettingIndex(codecConfig);
@@ -183,16 +185,19 @@
protected abstract int getDefaultIndex();
@VisibleForTesting
- void setCodecConfigPreference(BluetoothCodecConfig config) {
- mBluetoothA2dp.setCodecConfigPreference(config);
+ void setCodecConfigPreference(BluetoothDevice device,
+ BluetoothCodecConfig config) {
+ mBluetoothA2dp.setCodecConfigPreference(device, config);
}
@VisibleForTesting
- BluetoothCodecConfig getCodecConfig() {
- if (mBluetoothA2dp == null || mBluetoothA2dp.getCodecStatus() == null) {
- return null;
+ BluetoothCodecConfig getCodecConfig(BluetoothDevice device) {
+ if (mBluetoothA2dp != null) {
+ BluetoothCodecStatus codecStatus = mBluetoothA2dp.getCodecStatus(device);
+ if (codecStatus != null) {
+ return codecStatus.getCodecConfig();
+ }
}
-
- return mBluetoothA2dp.getCodecStatus().getCodecConfig();
+ return null;
}
}
diff --git a/src/com/android/settings/development/BluetoothAudioCodecPreferenceController.java b/src/com/android/settings/development/BluetoothAudioCodecPreferenceController.java
index 2163a70..b5c40a3 100644
--- a/src/com/android/settings/development/BluetoothAudioCodecPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothAudioCodecPreferenceController.java
@@ -109,14 +109,14 @@
case 6:
synchronized (mBluetoothA2dpConfigStore) {
if (mBluetoothA2dp != null) {
- mBluetoothA2dp.enableOptionalCodecs();
+ mBluetoothA2dp.enableOptionalCodecs(null); // Use current active device
}
}
return;
case 7:
synchronized (mBluetoothA2dpConfigStore) {
if (mBluetoothA2dp != null) {
- mBluetoothA2dp.disableOptionalCodecs();
+ mBluetoothA2dp.disableOptionalCodecs(null); // Use current active device
}
}
return;
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index ce4b7bf..395d230 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -435,7 +435,6 @@
controllers.add(new ForceMSAAPreferenceController(context));
controllers.add(new HardwareOverlaysPreferenceController(context));
controllers.add(new SimulateColorSpacePreferenceController(context));
- controllers.add(new SetGpuRendererPreferenceController(context));
controllers.add(new UsbAudioRoutingPreferenceController(context));
controllers.add(new StrictModePreferenceController(context));
controllers.add(new ProfileGpuRenderingPreferenceController(context));
diff --git a/src/com/android/settings/development/SetGpuRendererPreferenceController.java b/src/com/android/settings/development/SetGpuRendererPreferenceController.java
deleted file mode 100644
index b19344c..0000000
--- a/src/com/android/settings/development/SetGpuRendererPreferenceController.java
+++ /dev/null
@@ -1,102 +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.development;
-
-import android.content.Context;
-import android.os.SystemProperties;
-import android.support.v7.preference.ListPreference;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-import android.text.TextUtils;
-import android.view.ThreadedRenderer;
-
-import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.development.DeveloperOptionsPreferenceController;
-import com.android.settingslib.development.SystemPropPoker;
-
-public class SetGpuRendererPreferenceController extends
- DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
- PreferenceControllerMixin {
-
- private static final String DEBUG_HW_RENDERER_KEY = "debug_hw_renderer";
-
- private final String[] mListValues;
- private final String[] mListSummaries;
- private ListPreference mPreference;
-
- public SetGpuRendererPreferenceController(Context context) {
- super(context);
-
- mListValues = context.getResources().getStringArray(R.array.debug_hw_renderer_values);
- mListSummaries = context.getResources().getStringArray(R.array.debug_hw_renderer_entries);
- }
-
- @Override
- public String getPreferenceKey() {
- return DEBUG_HW_RENDERER_KEY;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
-
- mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- writeDebugHwRendererOptions(newValue);
- updateDebugHwRendererOptions();
- return true;
- }
-
- @Override
- public void updateState(Preference preference) {
- updateDebugHwRendererOptions();
- }
-
- @Override
- protected void onDeveloperOptionsSwitchEnabled() {
- mPreference.setEnabled(true);
- }
-
- @Override
- protected void onDeveloperOptionsSwitchDisabled() {
- mPreference.setEnabled(false);
- }
-
- private void writeDebugHwRendererOptions(Object newValue) {
- SystemProperties.set(ThreadedRenderer.DEBUG_RENDERER_PROPERTY,
- newValue == null ? "" : newValue.toString());
- SystemPropPoker.getInstance().poke();
- }
-
- private void updateDebugHwRendererOptions() {
- final String value = SystemProperties.get(
- ThreadedRenderer.DEBUG_RENDERER_PROPERTY, "" /* default */);
- int index = 0; // default
- for (int i = 0; i < mListValues.length; i++) {
- if (TextUtils.equals(value, mListValues[i])) {
- index = i;
- break;
- }
- }
- mPreference.setValue(mListValues[index]);
- mPreference.setSummary(mListSummaries[index]);
- }
-}
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index c4c795b..6384130 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -171,18 +171,20 @@
if (discharging && provider != null
&& provider.isEnhancedBatteryPredictionEnabled(context)) {
Estimate estimate = provider.getEnhancedBatteryPrediction(context);
- BatteryUtils.logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
- return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
- elapsedRealtimeUs, shortString,
- BatteryUtils.convertMsToUs(estimate.estimateMillis),
- estimate.isBasedOnUsage);
- } else {
- long prediction = discharging
- ? stats.computeBatteryTimeRemaining(elapsedRealtimeUs) : 0;
- BatteryUtils.logRuntime(LOG_TAG, "time for regular BatteryInfo", startTime);
- return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
- elapsedRealtimeUs, shortString, prediction, false);
+ if(estimate != null) {
+ BatteryUtils
+ .logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
+ return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
+ elapsedRealtimeUs, shortString,
+ BatteryUtils.convertMsToUs(estimate.estimateMillis),
+ estimate.isBasedOnUsage);
+ }
}
+ long prediction = discharging
+ ? stats.computeBatteryTimeRemaining(elapsedRealtimeUs) : 0;
+ BatteryUtils.logRuntime(LOG_TAG, "time for regular BatteryInfo", startTime);
+ return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
+ elapsedRealtimeUs, shortString, prediction, false);
}
@Override
diff --git a/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java b/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
index a080e2b..e58ccd3 100644
--- a/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
+++ b/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
@@ -55,6 +55,9 @@
stats, elapsedRealtimeUs, false);
Estimate estimate = powerUsageFeatureProvider.getEnhancedBatteryPrediction(context);
+ if (estimate == null) {
+ estimate = new Estimate(0, false);
+ }
BatteryInfo newInfo = BatteryInfo.getBatteryInfo(getContext(), batteryBroadcast, stats,
elapsedRealtimeUs, false,
BatteryUtils.convertMsToUs(estimate.estimateMillis),
diff --git a/src/com/android/settings/location/LocationEnabler.java b/src/com/android/settings/location/LocationEnabler.java
index 28ee213..30ecf2e 100644
--- a/src/com/android/settings/location/LocationEnabler.java
+++ b/src/com/android/settings/location/LocationEnabler.java
@@ -123,7 +123,8 @@
}
return;
}
- updateLocationEnabled(mContext, enabled, UserHandle.myUserId());
+ updateLocationEnabled(mContext, enabled, UserHandle.myUserId(),
+ Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
refreshLocationMode();
}
@@ -142,7 +143,8 @@
return;
}
- updateLocationMode(mContext, currentMode, mode, ActivityManager.getCurrentUser());
+ updateLocationMode(mContext, currentMode, mode, ActivityManager.getCurrentUser(),
+ Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
refreshLocationMode();
}
diff --git a/src/com/android/settings/location/LocationMode.java b/src/com/android/settings/location/LocationMode.java
deleted file mode 100644
index 5931f9e..0000000
--- a/src/com/android/settings/location/LocationMode.java
+++ /dev/null
@@ -1,108 +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.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A page with 3 radio buttons to choose the location mode.
- *
- * There are 3 location modes when location access is enabled:
- *
- * High accuracy: use both GPS and network location.
- *
- * Battery saving: use network location only to reduce the power consumption.
- *
- * Sensors only: use GPS location only.
- */
-public class LocationMode extends DashboardFragment {
-
- private static final String TAG = "LocationMode";
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.LOCATION_MODE;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.location_mode;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, getLifecycle());
- }
-
- @Override
- public int getHelpResource() {
- return R.string.help_url_location_access;
- }
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(
- Context context, Lifecycle lifecycle) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new LocationModeHighAccuracyPreferenceController(context, lifecycle));
- controllers.add(
- new LocationModeBatterySavingPreferenceController(context, lifecycle));
- controllers.add(new LocationModeSensorsOnlyPreferenceController(context, lifecycle));
- return controllers;
- }
-
- /**
- * For Search.
- */
- public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.location_mode;
- return Arrays.asList(sir);
- }
-
- @Override
- protected boolean isPageSearchEnabled(Context context) {
- return context.getResources().getBoolean(R.bool.config_location_mode_available);
- }
-
- @Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context
- context) {
- return buildPreferenceControllers(context, null /* lifecycle */);
- }
- };
-}
diff --git a/src/com/android/settings/location/LocationModeBatterySavingPreferenceController.java b/src/com/android/settings/location/LocationModeBatterySavingPreferenceController.java
deleted file mode 100644
index 70c7013..0000000
--- a/src/com/android/settings/location/LocationModeBatterySavingPreferenceController.java
+++ /dev/null
@@ -1,40 +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.location;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class LocationModeBatterySavingPreferenceController
- extends LocationModeRadioButtonPreferenceController {
-
- private static final String KEY_BATTERY_SAVING = "battery_saving";
-
- public LocationModeBatterySavingPreferenceController(Context context,
- Lifecycle lifecycle) {
- super(context, lifecycle);
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_BATTERY_SAVING;
- }
-
- @Override
- protected int getLocationMode() {
- return Settings.Secure.LOCATION_MODE_BATTERY_SAVING;
- }
-}
diff --git a/src/com/android/settings/location/LocationModeHighAccuracyPreferenceController.java b/src/com/android/settings/location/LocationModeHighAccuracyPreferenceController.java
deleted file mode 100644
index bd2d07e..0000000
--- a/src/com/android/settings/location/LocationModeHighAccuracyPreferenceController.java
+++ /dev/null
@@ -1,40 +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.location;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class LocationModeHighAccuracyPreferenceController
- extends LocationModeRadioButtonPreferenceController {
-
- private static final String KEY_HIGH_ACCURACY = "high_accuracy";
-
- public LocationModeHighAccuracyPreferenceController(Context context,
- Lifecycle lifecycle) {
- super(context, lifecycle);
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_HIGH_ACCURACY;
- }
-
- @Override
- protected int getLocationMode() {
- return Settings.Secure.LOCATION_MODE_HIGH_ACCURACY;
- }
-}
diff --git a/src/com/android/settings/location/LocationModePreferenceController.java b/src/com/android/settings/location/LocationModePreferenceController.java
deleted file mode 100644
index 265a9df..0000000
--- a/src/com/android/settings/location/LocationModePreferenceController.java
+++ /dev/null
@@ -1,76 +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.location;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class LocationModePreferenceController extends LocationBasePreferenceController {
-
- /** Key for preference screen "Mode" */
- private static final String KEY_LOCATION_MODE = "location_mode";
-
- private final LocationSettings mParentFragment;
- private Preference mPreference;
-
- public LocationModePreferenceController(Context context, LocationSettings parent,
- Lifecycle lifecycle) {
- super(context, lifecycle);
- mParentFragment = parent;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_LOCATION_MODE;
- }
-
- @Override
- public boolean isAvailable() {
- return mContext.getResources().getBoolean(R.bool.config_location_mode_available);
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mPreference = screen.findPreference(KEY_LOCATION_MODE);
- }
-
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (KEY_LOCATION_MODE.equals(preference.getKey())) {
- final SettingsActivity activity = (SettingsActivity) mParentFragment.getActivity();
- activity.startPreferencePanel(mParentFragment, LocationMode.class.getName(), null,
- R.string.location_mode_screen_title, null, mParentFragment, 0);
- return true;
- }
- return false;
- }
-
- @Override
- public void onLocationModeChanged(int mode, boolean restricted) {
- final int modeDescription = LocationPreferenceController.getLocationString(mode);
- if (modeDescription != 0) {
- mPreference.setSummary(modeDescription);
- }
- // Restricted user can't change the location mode, so disable the master switch. But in some
- // corner cases, the location might still be enabled. In such case the master switch should
- // be disabled but checked.
- mPreference.setEnabled(mLocationEnabler.isEnabled(mode));
- }
-}
diff --git a/src/com/android/settings/location/LocationModeRadioButtonPreferenceController.java b/src/com/android/settings/location/LocationModeRadioButtonPreferenceController.java
deleted file mode 100644
index bdf7c8f..0000000
--- a/src/com/android/settings/location/LocationModeRadioButtonPreferenceController.java
+++ /dev/null
@@ -1,53 +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.location;
-
-import android.content.Context;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.settings.widget.RadioButtonPreference;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public abstract class LocationModeRadioButtonPreferenceController
- extends LocationBasePreferenceController
- implements RadioButtonPreference.OnClickListener {
-
- protected RadioButtonPreference mPreference;
-
- public LocationModeRadioButtonPreferenceController(Context context, Lifecycle lifecycle) {
- super(context, lifecycle);
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mPreference = (RadioButtonPreference) screen.findPreference(getPreferenceKey());
- mPreference.setOnClickListener(this);
- }
-
- @Override
- public void onRadioButtonClicked(RadioButtonPreference emiter) {
- mLocationEnabler.setLocationMode(getLocationMode());
- }
-
- @Override
- public void onLocationModeChanged(int mode, boolean restricted) {
- mPreference.setChecked(mode == getLocationMode());
- mPreference.setEnabled(mLocationEnabler.isEnabled(mode));
- }
-
- /** Gets the location mode that this controller monitors. */
- protected abstract int getLocationMode();
-
-}
diff --git a/src/com/android/settings/location/LocationModeSensorsOnlyPreferenceController.java b/src/com/android/settings/location/LocationModeSensorsOnlyPreferenceController.java
deleted file mode 100644
index b79dbf2..0000000
--- a/src/com/android/settings/location/LocationModeSensorsOnlyPreferenceController.java
+++ /dev/null
@@ -1,40 +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.location;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class LocationModeSensorsOnlyPreferenceController
- extends LocationModeRadioButtonPreferenceController {
-
- private static final String KEY_SENSORS_ONLY = "sensors_only";
-
- public LocationModeSensorsOnlyPreferenceController(Context context,
- Lifecycle lifecycle) {
- super(context, lifecycle);
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_SENSORS_ONLY;
- }
-
- @Override
- protected int getLocationMode() {
- return Settings.Secure.LOCATION_MODE_SENSORS_ONLY;
- }
-}
diff --git a/src/com/android/settings/location/LocationPreferenceController.java b/src/com/android/settings/location/LocationPreferenceController.java
index 9b68848..5760ab7 100644
--- a/src/com/android/settings/location/LocationPreferenceController.java
+++ b/src/com/android/settings/location/LocationPreferenceController.java
@@ -105,26 +105,11 @@
int mode = Secure.getInt(context.getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF);
if (mode != Secure.LOCATION_MODE_OFF) {
- return context.getString(R.string.location_on_summary,
- context.getString(getLocationString(mode)));
+ return context.getString(R.string.location_on_summary);
}
return context.getString(R.string.location_off_summary);
}
- public static int getLocationString(int mode) {
- switch (mode) {
- case Secure.LOCATION_MODE_OFF:
- return R.string.location_mode_location_off_title;
- case Secure.LOCATION_MODE_SENSORS_ONLY:
- return R.string.location_mode_sensors_only_title;
- case Secure.LOCATION_MODE_BATTERY_SAVING:
- return R.string.location_mode_battery_saving_title;
- case Secure.LOCATION_MODE_HIGH_ACCURACY:
- return R.string.location_mode_high_accuracy_title;
- }
- return 0;
- }
-
@Override
public ResultPayload getResultPayload() {
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 85c049d..3cc5b84 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -127,7 +127,6 @@
private static List<AbstractPreferenceController> buildPreferenceControllers(
Context context, LocationSettings fragment, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new LocationModePreferenceController(context, fragment, lifecycle));
controllers.add(new AppLocationPermissionPreferenceController(context));
controllers.add(new LocationForWorkPreferenceController(context, lifecycle));
controllers.add(
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index d56febb..bf821db 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -34,6 +34,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
+import com.android.settings.RestrictedListPreference;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.overlay.FeatureFactory;
@@ -55,8 +56,8 @@
private final String mWorkSettingCategoryKey;
private final String mWorkSettingKey;
- private RestrictedDropDownPreference mLockscreen;
- private RestrictedDropDownPreference mLockscreenProfile;
+ private RestrictedListPreference mLockscreen;
+ private RestrictedListPreference mLockscreenProfile;
private final int mProfileChallengeUserId;
private final boolean mSecure;
@@ -92,13 +93,13 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mLockscreen =
- (RestrictedDropDownPreference) screen.findPreference(mSettingKey);
+ (RestrictedListPreference) screen.findPreference(mSettingKey);
if (mLockscreen == null) {
Log.i(TAG, "Preference not found: " + mSettingKey);
return;
}
if (mProfileChallengeUserId != UserHandle.USER_NULL) {
- mLockscreenProfile = (RestrictedDropDownPreference) screen.findPreference(
+ mLockscreenProfile = (RestrictedListPreference) screen.findPreference(
mWorkSettingKey);
} else {
setVisible(screen, mWorkSettingKey, false /* visible */);
@@ -180,11 +181,6 @@
entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable_profile));
values.add(Integer.toString(R.string.lock_screen_notifications_summary_disable_profile));
- mLockscreenProfile.setOnPreClickListener(
- (Preference p) -> Utils.startQuietModeDialogIfNecessary(mContext,
- UserManager.get(mContext), mProfileChallengeUserId)
- );
-
mLockscreenProfile.setEntries(entries.toArray(new CharSequence[entries.size()]));
mLockscreenProfile.setEntryValues(values.toArray(new CharSequence[values.size()]));
updateLockscreenNotificationsForProfile();
@@ -224,36 +220,40 @@
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String key = preference.getKey();
if (TextUtils.equals(mWorkSettingKey, key)) {
- final int val = Integer.parseInt((String) newValue);
- if (val == mLockscreenSelectedValueProfile) {
- return false;
- }
- final boolean enabled =
- val != R.string.lock_screen_notifications_summary_disable_profile;
- final boolean show =
- val == R.string.lock_screen_notifications_summary_show_profile;
- Settings.Secure.putIntForUser(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- show ? 1 : 0, mProfileChallengeUserId);
- Settings.Secure.putIntForUser(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- enabled ? 1 : 0, mProfileChallengeUserId);
- mLockscreenSelectedValueProfile = val;
- return true;
+ if (Utils.startQuietModeDialogIfNecessary(mContext, UserManager.get(mContext),
+ mProfileChallengeUserId)) {
+ return false;
+ }
+ final int val = Integer.parseInt((String) newValue);
+ if (val == mLockscreenSelectedValueProfile) {
+ return false;
+ }
+ final boolean enabled =
+ val != R.string.lock_screen_notifications_summary_disable_profile;
+ final boolean show =
+ val == R.string.lock_screen_notifications_summary_show_profile;
+ Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
+ show ? 1 : 0, mProfileChallengeUserId);
+ Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
+ enabled ? 1 : 0, mProfileChallengeUserId);
+ mLockscreenSelectedValueProfile = val;
+ return true;
} else if (TextUtils.equals(mSettingKey, key)) {
- final int val = Integer.parseInt((String) newValue);
- if (val == mLockscreenSelectedValue) {
- return false;
- }
- final boolean enabled =
- val != R.string.lock_screen_notifications_summary_disable;
- final boolean show = val == R.string.lock_screen_notifications_summary_show;
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
- mLockscreenSelectedValue = val;
- return true;
+ final int val = Integer.parseInt((String) newValue);
+ if (val == mLockscreenSelectedValue) {
+ return false;
+ }
+ final boolean enabled =
+ val != R.string.lock_screen_notifications_summary_disable;
+ final boolean show = val == R.string.lock_screen_notifications_summary_show;
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
+ mLockscreenSelectedValue = val;
+ return true;
}
return false;
}
@@ -264,8 +264,8 @@
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
mContext, keyguardNotificationFeatures, UserHandle.myUserId());
if (admin != null && mLockscreen != null) {
- RestrictedDropDownPreference.RestrictedItem item =
- new RestrictedDropDownPreference.RestrictedItem(entry, entryValue, admin);
+ RestrictedListPreference.RestrictedItem item =
+ new RestrictedListPreference.RestrictedItem(entry, entryValue, admin);
mLockscreen.addRestrictedItem(item);
}
if (mProfileChallengeUserId != UserHandle.USER_NULL) {
@@ -273,8 +273,8 @@
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
mContext, keyguardNotificationFeatures, mProfileChallengeUserId);
if (profileAdmin != null && mLockscreenProfile != null) {
- RestrictedDropDownPreference.RestrictedItem item =
- new RestrictedDropDownPreference.RestrictedItem(
+ RestrictedListPreference.RestrictedItem item =
+ new RestrictedListPreference.RestrictedItem(
entry, entryValue, profileAdmin);
mLockscreenProfile.addRestrictedItem(item);
}
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 8b0ed46..18b77bc 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -30,6 +30,7 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
+import com.android.settings.widget.MasterCheckBoxPreference;
import com.android.settings.widget.MasterSwitchPreference;
import com.android.settings.widget.SwitchBar;
import com.android.settings.wrapper.NotificationChannelGroupWrapper;
@@ -277,9 +278,9 @@
protected Preference populateSingleChannelPrefs(PreferenceGroup parent,
final NotificationChannel channel, final boolean groupBlocked) {
- MasterSwitchPreference channelPref = new MasterSwitchPreference(
+ MasterCheckBoxPreference channelPref = new MasterCheckBoxPreference(
getPrefContext());
- channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null
+ channelPref.setCheckBoxEnabled(mSuspendedAppsAdmin == null
&& isChannelBlockable(channel)
&& isChannelConfigurable(channel)
&& !groupBlocked);
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index ef34a9b..dbffc55 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -283,7 +283,7 @@
// Not visible on launcher -> likely not a user visible app, skip if non-instant.
final ApplicationsState.AppEntry appEntry =
mApplicationsState.getEntry(pkgName, mUserId);
- if (!AppUtils.isInstant(appEntry.info)) {
+ if (appEntry == null || appEntry.info == null || !AppUtils.isInstant(appEntry.info)) {
Log.d(TAG, "Not a user visible or instant app, skipping " + pkgName);
return false;
}
diff --git a/src/com/android/settings/notification/RestrictedDropDownPreference.java b/src/com/android/settings/notification/RestrictedDropDownPreference.java
deleted file mode 100644
index d19cf8d..0000000
--- a/src/com/android/settings/notification/RestrictedDropDownPreference.java
+++ /dev/null
@@ -1,262 +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.
- */
-
-package com.android.settings.notification;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.support.v7.preference.DropDownPreference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.ArrayAdapter;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import com.android.settings.R;
-import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import com.android.settingslib.RestrictedPreferenceHelper;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class RestrictedDropDownPreference extends DropDownPreference {
- private final RestrictedPreferenceHelper mHelper;
- private ReselectionSpinner mSpinner;
- private List<RestrictedItem> mRestrictedItems = new ArrayList<>();
- private boolean mUserClicked = false;
- private OnPreferenceClickListener mPreClickListener;
-
- public RestrictedDropDownPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- setLayoutResource(R.layout.restricted_preference_dropdown);
- setWidgetLayoutResource(R.layout.restricted_icon);
- mHelper = new RestrictedPreferenceHelper(context, this, attrs);
- }
-
- @Override
- protected ArrayAdapter createAdapter() {
- return new RestrictedArrayItemAdapter(getContext());
- }
-
- @Override
- public void setValue(String value) {
- if (getRestrictedItemForEntryValue(value) != null) {
- return;
- }
- super.setValue(value);
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder view) {
- mSpinner = (ReselectionSpinner) view.itemView.findViewById(R.id.spinner);
- mSpinner.setPreference(this);
- super.onBindViewHolder(view);
- mHelper.onBindViewHolder(view);
- mSpinner.setOnItemSelectedListener(mItemSelectedListener);
- final View restrictedIcon = view.findViewById(R.id.restricted_icon);
- if (restrictedIcon != null) {
- restrictedIcon.setVisibility(isDisabledByAdmin() ? View.VISIBLE : View.GONE);
- }
- }
-
- private boolean isRestrictedForEntry(CharSequence entry) {
- if (entry == null) {
- return false;
- }
- for (RestrictedItem item : mRestrictedItems) {
- if (entry.equals(item.entry)) {
- return true;
- }
- }
- return false;
- }
-
- private RestrictedItem getRestrictedItemForEntryValue(CharSequence entryValue) {
- if (entryValue == null) {
- return null;
- }
- for (RestrictedItem item : mRestrictedItems) {
- if (entryValue.equals(item.entryValue)) {
- return item;
- }
- }
- return null;
- }
-
- private RestrictedItem getRestrictedItemForPosition(int position) {
- if (position < 0 || position >= getEntryValues().length) {
- return null;
- }
- CharSequence entryValue = getEntryValues()[position];
- return getRestrictedItemForEntryValue(entryValue);
- }
-
- public void addRestrictedItem(RestrictedItem item) {
- mRestrictedItems.add(item);
- }
-
- public void clearRestrictedItems() {
- mRestrictedItems.clear();
- }
-
- @Override
- public void performClick() {
- if (mPreClickListener != null && mPreClickListener.onPreferenceClick(this)) {
- return;
- }
- if (!mHelper.performClick()) {
- mUserClicked = true;
- super.performClick();
- }
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- if (enabled && isDisabledByAdmin()) {
- mHelper.setDisabledByAdmin(null);
- return;
- }
- super.setEnabled(enabled);
- }
-
- public void setDisabledByAdmin(EnforcedAdmin admin) {
- if (mHelper.setDisabledByAdmin(admin)) {
- notifyChanged();
- }
- }
-
- /**
- * Similar to {@link #setOnPreferenceClickListener(OnPreferenceClickListener)}, but can
- * preempt {@link #onClick()}.
- */
- public void setOnPreClickListener(OnPreferenceClickListener l) {
- mPreClickListener = l;
- }
-
- public boolean isDisabledByAdmin() {
- return mHelper.isDisabledByAdmin();
- }
-
- private void setUserClicked(boolean userClicked) {
- mUserClicked = userClicked;
- }
-
- private boolean isUserClicked() {
- return mUserClicked;
- }
-
- private final OnItemSelectedListener mItemSelectedListener = new OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
- if (mUserClicked) {
- mUserClicked = false;
- } else {
- return;
- }
- if (position >= 0 && position < getEntryValues().length) {
- String value = getEntryValues()[position].toString();
- RestrictedItem item = getRestrictedItemForEntryValue(value);
- if (item != null) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
- item.enforcedAdmin);
- mSpinner.setSelection(findIndexOfValue(getValue()));
- } else if (!value.equals(getValue()) && callChangeListener(value)) {
- setValue(value);
- }
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- // noop
- }
- };
-
- /**
- * Extension of {@link ArrayAdapter} which updates the state of the dropdown item
- * depending on whether it is restricted by the admin.
- */
- private class RestrictedArrayItemAdapter extends ArrayAdapter<String> {
- private static final int TEXT_RES_ID = android.R.id.text1;
- public RestrictedArrayItemAdapter(Context context) {
- super(context, R.layout.spinner_dropdown_restricted_item, TEXT_RES_ID);
- }
-
- @Override
- public View getDropDownView(int position, View convertView, ViewGroup parent) {
- View rootView = super.getView(position, convertView, parent);
- CharSequence entry = getItem(position);
- boolean isEntryRestricted = isRestrictedForEntry(entry);
- TextView text = (TextView) rootView.findViewById(TEXT_RES_ID);
- if (text != null) {
- text.setEnabled(!isEntryRestricted);
- }
- View restrictedIcon = rootView.findViewById(R.id.restricted_icon);
- if (restrictedIcon != null) {
- restrictedIcon.setVisibility(isEntryRestricted ? View.VISIBLE : View.GONE);
- }
- return rootView;
- }
- }
-
- /**
- * Extension of {@link Spinner} which triggers the admin support dialog on user clicking a
- * restricted item even if was already selected.
- */
- public static class ReselectionSpinner extends Spinner {
- private RestrictedDropDownPreference pref;
-
- public ReselectionSpinner(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void setPreference(RestrictedDropDownPreference pref) {
- this.pref = pref;
- }
-
- @Override
- public void setSelection(int position) {
- int previousSelectedPosition = getSelectedItemPosition();
- super.setSelection(position);
- if (position == previousSelectedPosition && pref.isUserClicked()) {
- pref.setUserClicked(false);
- RestrictedItem item = pref.getRestrictedItemForPosition(position);
- if (item != null) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
- item.enforcedAdmin);
- }
- }
- }
- }
-
- public static class RestrictedItem {
- public final CharSequence entry;
- public final CharSequence entryValue;
- public final EnforcedAdmin enforcedAdmin;
-
- public RestrictedItem(CharSequence entry, CharSequence entryValue,
- EnforcedAdmin enforcedAdmin) {
- this.entry = entry;
- this.entryValue = entryValue;
- this.enforcedAdmin = enforcedAdmin;
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/notification/VisibilityPreferenceController.java b/src/com/android/settings/notification/VisibilityPreferenceController.java
index 76caac0..62ca183 100644
--- a/src/com/android/settings/notification/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/VisibilityPreferenceController.java
@@ -29,6 +29,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
+import com.android.settings.RestrictedListPreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.RestrictedLockUtils;
@@ -65,7 +66,7 @@
public void updateState(Preference preference) {
if (mChannel != null && mAppRow != null) {
- RestrictedDropDownPreference pref = (RestrictedDropDownPreference) preference;
+ RestrictedListPreference pref = (RestrictedListPreference) preference;
ArrayList<CharSequence> entries = new ArrayList<>();
ArrayList<CharSequence> values = new ArrayList<>();
@@ -120,14 +121,14 @@
return true;
}
- private void setRestrictedIfNotificationFeaturesDisabled(RestrictedDropDownPreference pref,
+ private void setRestrictedIfNotificationFeaturesDisabled(RestrictedListPreference pref,
CharSequence entry, CharSequence entryValue, int keyguardNotificationFeatures) {
RestrictedLockUtils.EnforcedAdmin admin =
RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
mContext, keyguardNotificationFeatures, mAppRow.userId);
if (admin != null) {
- RestrictedDropDownPreference.RestrictedItem item =
- new RestrictedDropDownPreference.RestrictedItem(entry, entryValue, admin);
+ RestrictedListPreference.RestrictedItem item =
+ new RestrictedListPreference.RestrictedItem(entry, entryValue, admin);
pref.addRestrictedItem(item);
}
}
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index 9d0dce1..faa4b8c 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -62,7 +62,6 @@
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
import com.android.settings.inputmethod.VirtualKeyboardFragment;
import com.android.settings.language.LanguageAndInputSettings;
-import com.android.settings.location.LocationMode;
import com.android.settings.location.LocationSettings;
import com.android.settings.location.ScanningSettings;
import com.android.settings.network.NetworkDashboardFragment;
@@ -132,7 +131,6 @@
addIndex(GestureSettings.class);
addIndex(LanguageAndInputSettings.class);
addIndex(LocationSettings.class);
- addIndex(LocationMode.class);
addIndex(ScanningSettings.class);
addIndex(SecuritySettingsV2.class);
addIndex(ScreenLockSettings.class);
diff --git a/src/com/android/settings/widget/MasterCheckBoxPreference.java b/src/com/android/settings/widget/MasterCheckBoxPreference.java
index 333c9aa..552f51c 100644
--- a/src/com/android/settings/widget/MasterCheckBoxPreference.java
+++ b/src/com/android/settings/widget/MasterCheckBoxPreference.java
@@ -34,6 +34,7 @@
private CheckBox mCheckBox;
private boolean mChecked;
+ private boolean mEnableCheckBox = true;
public MasterCheckBoxPreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
@@ -88,9 +89,7 @@
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
- if (mCheckBox != null) {
- mCheckBox.setEnabled(enabled);
- }
+ setCheckBoxEnabled(enabled);
}
public boolean isChecked() {
@@ -104,6 +103,13 @@
}
}
+ public void setCheckBoxEnabled(boolean enabled) {
+ mEnableCheckBox = enabled;
+ if (mCheckBox != null) {
+ mCheckBox.setEnabled(enabled);
+ }
+ }
+
public CheckBox getCheckBox() {
return mCheckBox;
}
diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java
index 9bf3310..776025f 100644
--- a/tests/robotests/src/com/android/settings/MasterClearTest.java
+++ b/tests/robotests/src/com/android/settings/MasterClearTest.java
@@ -66,7 +66,8 @@
)
public class MasterClearTest {
private static final String TEST_ACCOUNT_TYPE = "android.test.account.type";
- private static final String TEST_CONFIRMATION_PACKAGE = "android.test.confirmation.pkg";
+ private static final String TEST_CONFIRMATION_PACKAGE = "android.test.conf.pkg";
+ private static final String TEST_CONFIRMATION_CLASS = "android.test.conf.pkg.ConfActivity";
private static final String TEST_ACCOUNT_NAME = "test@example.com";
@Mock
@@ -223,6 +224,7 @@
when(mMasterClear.getActivity()).thenReturn(mMockActivity);
when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
when(mMockActivity.getString(R.string.account_confirmation_package)).thenReturn(TEST_CONFIRMATION_PACKAGE);
+ when(mMockActivity.getString(R.string.account_confirmation_class)).thenReturn(TEST_CONFIRMATION_CLASS);
Account[] accounts = new Account[0];
when(mMockActivity.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
@@ -235,6 +237,7 @@
when(mMasterClear.getActivity()).thenReturn(mMockActivity);
when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
when(mMockActivity.getString(R.string.account_confirmation_package)).thenReturn(TEST_CONFIRMATION_PACKAGE);
+ when(mMockActivity.getString(R.string.account_confirmation_class)).thenReturn(TEST_CONFIRMATION_CLASS);
Account[] accounts = new Account[] { new Account(TEST_ACCOUNT_NAME, TEST_ACCOUNT_TYPE) };
when(mMockActivity.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
when(mAccountManager.getAccountsByType(TEST_ACCOUNT_TYPE)).thenReturn(accounts);
@@ -250,6 +253,7 @@
// Only try to show account confirmation if the appropriate resource overlays are available.
when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
when(mMockActivity.getString(R.string.account_confirmation_package)).thenReturn(TEST_CONFIRMATION_PACKAGE);
+ when(mMockActivity.getString(R.string.account_confirmation_class)).thenReturn(TEST_CONFIRMATION_CLASS);
// Add accounts to trigger the search for a resolving intent.
Account[] accounts = new Account[] { new Account(TEST_ACCOUNT_NAME, TEST_ACCOUNT_TYPE) };
when(mMockActivity.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
@@ -265,7 +269,7 @@
when(mPackageManager.resolveActivity(any(), eq(0))).thenReturn(resolveInfo);
// Finally mock out the startActivityForResultCall
- doNothing().when(mMockActivity).startActivityForResult(any(), eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
+ doNothing().when(mMasterClear).startActivityForResult(any(), eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
assertThat(mMasterClear.tryShowAccountConfirmation()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
index bd57211..ed97fe7 100644
--- a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
@@ -248,6 +248,33 @@
}
@Test
+ public void display_showRecentsWithNullAppEntryOrInfo() {
+ final List<UsageStats> stats = new ArrayList<>();
+ final UsageStats stat1 = new UsageStats();
+ final UsageStats stat2 = new UsageStats();
+ stat1.mLastTimeUsed = System.currentTimeMillis();
+ stat1.mPackageName = "pkg.class";
+ stats.add(stat1);
+
+ stat2.mLastTimeUsed = System.currentTimeMillis();
+ stat2.mPackageName = "pkg.class2";
+ stats.add(stat2);
+
+ // app1 has AppEntry with null info, app2 has null AppEntry.
+ mAppEntry.info = null;
+ when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
+ .thenReturn(mAppEntry);
+ when(mAppState.getEntry(stat2.mPackageName, UserHandle.myUserId()))
+ .thenReturn(null);
+
+ when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
+ .thenReturn(stats);
+
+ // We should not crash here.
+ mController.displayPreference(mScreen);
+ }
+
+ @Test
public void display_hasRecentButNoneDisplayable_showAppInfo() {
final List<UsageStats> stats = new ArrayList<>();
final UsageStats stat1 = new UsageStats();
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterV2Test.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterV2Test.java
index 801a8e4..40150cb 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterV2Test.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterV2Test.java
@@ -16,11 +16,8 @@
package com.android.settings.dashboard;
import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
@@ -31,11 +28,12 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.res.Resources;
-import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.service.settings.suggestions.Suggestion;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
+import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
@@ -47,7 +45,6 @@
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import org.junit.Before;
@@ -58,6 +55,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
@@ -97,7 +95,7 @@
mConditionList.add(mCondition);
when(mCondition.shouldShow()).thenReturn(true);
mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- mConditionList, null /* suggestionControllerMixin */, null /* lifecycle */);
+ mConditionList, null /* suggestionControllerMixin */, null /* lifecycle */);
when(mView.getTag()).thenReturn(mCondition);
}
@@ -105,7 +103,8 @@
public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
final DashboardAdapterV2 adapter =
spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */));
+ null /* conditions */, null /* suggestionControllerMixin */, null /*
+ lifecycle */));
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3");
adapter.setSuggestions(suggestions);
@@ -143,8 +142,9 @@
new DashboardAdapterV2.SuggestionContainerHolder(itemView);
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4");
final DashboardAdapterV2 adapter = spy(new DashboardAdapterV2(mContext,
- null /*savedInstance */, null /* conditions */, null /* suggestionControllerMixin */,
- null /* lifecycle */));
+ null /*savedInstance */, null /* conditions */,
+ null /* suggestionControllerMixin */,
+ null /* lifecycle */));
adapter.setSuggestions(suggestions);
adapter.onBindSuggestion(holder, 0);
@@ -160,7 +160,8 @@
public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
DashboardAdapterV2 adapter =
spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */));
+ null /* conditions */, null /* suggestionControllerMixin */, null /*
+ lifecycle */));
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
adapter.setSuggestions(suggestions);
final DashboardDataV2 dashboardData = adapter.mDashboardData;
@@ -173,27 +174,9 @@
}
@Test
- public void testSetCategories_iconTinted() {
- TypedArray mockTypedArray = mock(TypedArray.class);
- doReturn(mockTypedArray).when(mContext).obtainStyledAttributes(any(int[].class));
- doReturn(0x89000000).when(mockTypedArray).getColor(anyInt(), anyInt());
-
- final DashboardCategory category = new DashboardCategory();
- final Icon mockIcon = mock(Icon.class);
- final Tile tile = new Tile();
- tile.isIconTintable = true;
- tile.icon = mockIcon;
- category.addTile(tile);
-
- mDashboardAdapter.setCategory(category);
-
- verify(mockIcon).setTint(eq(0x89000000));
- }
-
- @Test
public void testBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
mDashboardAdapter.setSuggestions(suggestions);
@@ -217,7 +200,7 @@
@Test
public void testBindSuggestion_shouldSetSummary() {
mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
mDashboardAdapter.setSuggestions(suggestions);
@@ -231,7 +214,7 @@
final TextView summary = mock(TextView.class);
when(itemView.findViewById(android.R.id.summary)).thenReturn(summary);
final DashboardAdapterV2.SuggestionContainerHolder holder =
- new DashboardAdapterV2.SuggestionContainerHolder(itemView);
+ new DashboardAdapterV2.SuggestionContainerHolder(itemView);
mDashboardAdapter.onBindSuggestion(holder, 0);
@@ -245,6 +228,46 @@
verify(summary).setText("4");
}
+ @Test
+ public void onBindTile_internalTile_shouldNotUseGenericBackgroundIcon() {
+ final Context context = RuntimeEnvironment.application;
+ final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
+ final DashboardAdapterV2.DashboardItemHolder holder =
+ new DashboardAdapterV2.DashboardItemHolder(view);
+ final Tile tile = new Tile();
+ tile.icon = Icon.createWithResource(context, R.drawable.ic_settings);
+ final DashboardAdapterV2.IconCache iconCache = mock(DashboardAdapterV2.IconCache.class);
+ when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
+
+ mDashboardAdapter = new DashboardAdapterV2(context, null /* savedInstanceState */,
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
+ mDashboardAdapter.onBindTile(holder, tile);
+
+ verify(iconCache, never()).updateIcon(any(Icon.class), any(Drawable.class));
+ }
+
+ @Test
+ public void onBindTile_externalTile_shouldNotUseGenericBackgroundIcon() {
+ final Context context = RuntimeEnvironment.application;
+ final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
+ final DashboardAdapterV2.DashboardItemHolder holder =
+ new DashboardAdapterV2.DashboardItemHolder(view);
+ final Tile tile = new Tile();
+ tile.icon = mock(Icon.class);
+ when(tile.icon.getResPackage()).thenReturn("another.package");
+
+ final DashboardAdapterV2.IconCache iconCache = mock(DashboardAdapterV2.IconCache.class);
+ when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
+
+ mDashboardAdapter = new DashboardAdapterV2(context, null /* savedInstanceState */,
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
+ mDashboardAdapter.onBindTile(holder, tile);
+
+ verify(iconCache).updateIcon(eq(tile.icon), any(RoundedHomepageIcon.class));
+ }
+
private List<Suggestion> makeSuggestionsV2(String... pkgNames) {
final List<Suggestion> suggestions = new ArrayList<>();
for (String pkgName : pkgNames) {
diff --git a/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java b/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
new file mode 100644
index 0000000..4c62a6f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.dashboard;
+
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+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.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class RoundedHomepageIconTest {
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ }
+
+ @Test
+ public void createIcon_shouldSetBackgroundAndInset() {
+ final RoundedHomepageIcon icon = new RoundedHomepageIcon(
+ mContext, new ColorDrawable(Color.BLACK));
+
+ assertThat(icon.getNumberOfLayers()).isEqualTo(2);
+ assertThat(icon.getDrawable(0))
+ .isEqualTo(mContext.getDrawable(R.drawable.ic_homepage_generic_background));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/ShadowSuggestionController.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/ShadowSuggestionController.java
deleted file mode 100644
index b720f83..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/ShadowSuggestionController.java
+++ /dev/null
@@ -1,61 +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.dashboard.suggestions;
-
-import android.service.settings.suggestions.Suggestion;
-
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-
-import java.util.List;
-
-@Implements(SuggestionController.class)
-public class ShadowSuggestionController {
-
- public static boolean sStartCalled;
- public static boolean sStopCalled;
- public static boolean sGetSuggestionCalled;
-
- public static List<Suggestion> sSuggestions;
-
- public static void reset() {
- sStartCalled = false;
- sStopCalled = false;
- sGetSuggestionCalled = false;
- sSuggestions = null;
- }
-
- @Implementation
- public void start() {
- sStartCalled = true;
- }
-
- @Implementation
- public void stop() {
- sStopCalled = true;
- }
-
- public static void setSuggestion(List<Suggestion> suggestions) {
- sSuggestions = suggestions;
- }
-
- @Implementation
- public List<Suggestion> getSuggestions() {
- sGetSuggestionCalled = true;
- return sSuggestions;
- }
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index 2ecab8d..49e82e4 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -36,6 +36,7 @@
import com.android.settings.dashboard.DashboardAdapter;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java
index 2297f07..1e76e2d 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java
@@ -36,6 +36,7 @@
import com.android.settings.dashboard.DashboardAdapterV2;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixinTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixinTest.java
deleted file mode 100644
index 822cb10..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionControllerMixinTest.java
+++ /dev/null
@@ -1,128 +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.dashboard.suggestions;
-
-import static android.arch.lifecycle.Lifecycle.Event.ON_START;
-import static android.arch.lifecycle.Lifecycle.Event.ON_STOP;
-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;
-
-import android.app.LoaderManager;
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.Context;
-
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.After;
-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;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
- shadows = {
- ShadowSuggestionController.class
- })
-public class SuggestionControllerMixinTest {
-
- @Mock
- private SuggestionControllerMixin.SuggestionControllerHost mHost;
-
- private Context mContext;
- private LifecycleOwner mLifecycleOwner;
- private Lifecycle mLifecycle;
- private SuggestionControllerMixin mMixin;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- FakeFeatureFactory.setupForTest();
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- }
-
- @After
- public void tearDown() {
- ShadowSuggestionController.reset();
- }
-
- @Test
- public void goThroughLifecycle_onStartStop_shouldStartStopController() {
- mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
-
- mLifecycle.handleLifecycleEvent(ON_START);
- assertThat(ShadowSuggestionController.sStartCalled).isTrue();
-
- mLifecycle.handleLifecycleEvent(ON_STOP);
- assertThat(ShadowSuggestionController.sStopCalled).isTrue();
- }
-
- @Test
- public void onServiceConnected_shouldGetSuggestion() {
- final LoaderManager loaderManager = mock(LoaderManager.class);
- when(mHost.getLoaderManager()).thenReturn(loaderManager);
-
- mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
- mMixin.onServiceConnected();
-
- verify(loaderManager).restartLoader(SuggestionLoader.LOADER_ID_SUGGESTIONS,
- null /* args */, mMixin /* callback */);
- }
-
- @Test
- public void onServiceConnected_hostNotAttached_shouldDoNothing() {
- when(mHost.getLoaderManager()).thenReturn(null);
-
- mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
- mMixin.onServiceConnected();
-
- verify(mHost).getLoaderManager();
- }
-
- @Test
- public void onServiceDisconnected_hostNotAttached_shouldDoNothing() {
- when(mHost.getLoaderManager()).thenReturn(null);
-
- mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
- mMixin.onServiceDisconnected();
-
- verify(mHost).getLoaderManager();
- }
-
- @Test
- public void doneLoadingg_shouldSetSuggestionLoaded() {
- mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
-
- mMixin.onLoadFinished(mock(SuggestionLoader.class), null);
-
- assertThat(mMixin.isSuggestionLoaded()).isTrue();
-
- mMixin.onLoaderReset(mock(SuggestionLoader.class));
-
- assertThat(mMixin.isSuggestionLoaded()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
index a437cb4..f10f5ec 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
@@ -33,6 +33,7 @@
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
index 8ed885f..54af308 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
@@ -44,6 +44,7 @@
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowSecureSettings;
import com.android.settingslib.drawer.Tile;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
import org.junit.After;
import org.junit.Before;
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
index 8b3c770..54fbe71 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
@@ -18,6 +18,7 @@
import android.content.Context;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settingslib.NetworkPolicyEditor;
@@ -47,9 +48,12 @@
private Context mContext;
private DataUsageList mDataUsageList;
+ private FakeFeatureFactory mFactory;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mFactory = FakeFeatureFactory.setupForTest();
mNetworkServices.mPolicyEditor = mock(NetworkPolicyEditor.class);
mDataUsageList = spy(DataUsageList.class);
diff --git a/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
index a7ae938..15df916 100644
--- a/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
@@ -74,8 +74,8 @@
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = spy(new AbstractBluetoothA2dpPreferenceControllerImpl(mContext, mLifecycle,
mBluetoothA2dpConfigStore));
- doReturn(mBluetoothCodecConfig).when(mController).getCodecConfig();
- doNothing().when(mController).setCodecConfigPreference(any());
+ doReturn(mBluetoothCodecConfig).when(mController).getCodecConfig(null);
+ doNothing().when(mController).setCodecConfigPreference(any(), any());
when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mBluetoothCodecConfig);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
@@ -87,7 +87,7 @@
mController.onPreferenceChange(mPreference, "" /* new value */);
- verify(mController).setCodecConfigPreference(any());
+ verify(mController).setCodecConfigPreference(any(), any());
}
@Test
@@ -96,7 +96,7 @@
mController.onPreferenceChange(mPreference, "" /* new value */);
- verify(mController, never()).setCodecConfigPreference(any());
+ verify(mController, never()).setCodecConfigPreference(any(), any());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/development/SetGpuRendererPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SetGpuRendererPreferenceControllerTest.java
deleted file mode 100644
index 7b3097b..0000000
--- a/tests/robotests/src/com/android/settings/development/SetGpuRendererPreferenceControllerTest.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.development;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.os.SystemProperties;
-import android.support.v7.preference.ListPreference;
-import android.support.v7.preference.PreferenceScreen;
-import android.view.ThreadedRenderer;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
-
-import org.junit.After;
-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;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
- shadows = {SettingsShadowSystemProperties.class})
-public class SetGpuRendererPreferenceControllerTest {
-
- @Mock
- private ListPreference mPreference;
- @Mock
- private PreferenceScreen mScreen;
-
- /**
- * 0: OpenGl (Default)
- * 1: OpenGl (Skia)
- */
- private String[] mListValues;
- private String[] mListSummaries;
- private Context mContext;
- private SetGpuRendererPreferenceController mController;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mListValues = mContext.getResources().getStringArray(R.array.debug_hw_renderer_values);
- mListSummaries = mContext.getResources().getStringArray(R.array.debug_hw_renderer_entries);
- mController = new SetGpuRendererPreferenceController(mContext);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
- mController.displayPreference(mScreen);
- }
-
- @After
- public void teardown() {
- SettingsShadowSystemProperties.clear();
- }
-
- @Test
- public void onPreferenceChange_noValueSet_shouldSetEmptyString() {
- mController.onPreferenceChange(mPreference, null /* new value */);
-
- String mode = SystemProperties.get(
- ThreadedRenderer.DEBUG_RENDERER_PROPERTY);
- assertThat(mode).isEqualTo("");
- }
-
- @Test
- public void onPreferenceChange_option1Selected_shouldSetOption1() {
- mController.onPreferenceChange(mPreference, mListValues[1]);
-
- String mode = SystemProperties.get(
- ThreadedRenderer.DEBUG_RENDERER_PROPERTY);
- assertThat(mode).isEqualTo(mListValues[1]);
- }
-
- @Test
- public void updateState_option1Set_shouldUpdatePreferenceToOption1() {
- SystemProperties.set(ThreadedRenderer.DEBUG_RENDERER_PROPERTY,
- mListValues[1]);
-
- mController.updateState(mPreference);
-
- verify(mPreference).setValue(mListValues[1]);
- verify(mPreference).setSummary(mListSummaries[1]);
- }
-
- @Test
- public void updateState_option0Set_shouldUpdatePreferenceToOption0() {
- SystemProperties.set(ThreadedRenderer.DEBUG_RENDERER_PROPERTY,
- mListValues[0]);
-
- mController.updateState(mPreference);
-
- verify(mPreference).setValue(mListValues[0]);
- verify(mPreference).setSummary(mListSummaries[0]);
- }
-
- @Test
- public void updateState_noOptionSet_shouldDefaultToOption0() {
- SystemProperties.set(ThreadedRenderer.DEBUG_RENDERER_PROPERTY, null);
-
- mController.updateState(mPreference);
-
- verify(mPreference).setValue(mListValues[0]);
- verify(mPreference).setSummary(mListSummaries[0]);
- }
-
- @Test
- public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
- mController.onDeveloperOptionsSwitchDisabled();
-
- verify(mPreference).setEnabled(false);
- }
-
- @Test
- public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
- mController.onDeveloperOptionsSwitchEnabled();
-
- verify(mPreference).setEnabled(true);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java b/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
index 8cc92cd..1bae729 100644
--- a/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
@@ -179,7 +179,7 @@
}
@Test
- public void setLocationMode_notRestricted_shouldBroadcastUpdate() {
+ public void setLocationMode_notRestricted_shouldBroadcastUpdateAndSetChanger() {
when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
@@ -189,6 +189,9 @@
argThat(actionMatches(LocationManager.MODE_CHANGING_ACTION)),
eq(UserHandle.of(ActivityManager.getCurrentUser())),
eq(WRITE_SECURE_SETTINGS));
+ assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_CHANGER_UNKNOWN))
+ .isEqualTo(Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
}
@Test
@@ -202,7 +205,7 @@
}
@Test
- public void setLocationEnabled_notRestricted_shouldBroadcastUpdate() {
+ public void setLocationEnabled_notRestricted_shouldBroadcastUpdateAndSetChanger() {
when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
@@ -212,6 +215,9 @@
argThat(actionMatches(LocationManager.MODE_CHANGING_ACTION)),
eq(UserHandle.of(ActivityManager.getCurrentUser())),
eq(WRITE_SECURE_SETTINGS));
+ assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_CHANGER_UNKNOWN))
+ .isEqualTo(Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/location/LocationModeBatterySavingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationModeBatterySavingPreferenceControllerTest.java
deleted file mode 100644
index 41e9f1e..0000000
--- a/tests/robotests/src/com/android/settings/location/LocationModeBatterySavingPreferenceControllerTest.java
+++ /dev/null
@@ -1,57 +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.location;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class LocationModeBatterySavingPreferenceControllerTest {
-
- private LifecycleOwner mLifecycleOwner;
- private Lifecycle mLifecycle;
-
- @Before
- public void setUp() {
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- }
-
- @Test
- public void getLocationMode_shouldReturnModeBatterySaving() {
- final LocationModeBatterySavingPreferenceController controller =
- new LocationModeBatterySavingPreferenceController(mock(Context.class), mLifecycle);
-
- assertThat(controller.getLocationMode())
- .isEqualTo(Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
- }
-
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationModeHighAccuracyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationModeHighAccuracyPreferenceControllerTest.java
deleted file mode 100644
index 9c8bac6..0000000
--- a/tests/robotests/src/com/android/settings/location/LocationModeHighAccuracyPreferenceControllerTest.java
+++ /dev/null
@@ -1,57 +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.location;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class LocationModeHighAccuracyPreferenceControllerTest {
-
- private LifecycleOwner mLifecycleOwner;
- private Lifecycle mLifecycle;
-
- @Before
- public void setUp() {
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- }
-
- @Test
- public void getLocationMode_shouldReturnModeHighAccuracy() {
- final LocationModeHighAccuracyPreferenceController controller =
- new LocationModeHighAccuracyPreferenceController(mock(Context.class), mLifecycle);
-
- assertThat(controller.getLocationMode())
- .isEqualTo(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
- }
-
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationModePreferenceControllerTest.java
deleted file mode 100644
index a28cb20..0000000
--- a/tests/robotests/src/com/android/settings/location/LocationModePreferenceControllerTest.java
+++ /dev/null
@@ -1,141 +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.location;
-
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.Context;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-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;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class LocationModePreferenceControllerTest {
-
- @Mock
- private LocationSettings mFragment;
- @Mock
- private SettingsActivity mActivity;
- @Mock
- private Preference mPreference;
- @Mock
- private PreferenceScreen mScreen;
- @Mock
- private UserManager mUserManager;
-
- private Context mContext;
- private LocationModePreferenceController mController;
- private LifecycleOwner mLifecycleOwner;
- private Lifecycle mLifecycle;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- mController = new LocationModePreferenceController(mContext, mFragment, mLifecycle);
- when(mFragment.getActivity()).thenReturn(mActivity);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
- }
-
- @Test
- @Config(qualifiers = "mcc999")
- public void locationModePreference_ifXmlSetToFalse_shouldNotBeAvailable() {
- assertFalse(mController.isAvailable());
- }
-
- @Test
- public void locationModePreference_ifXmlSetToTrue_shouldBeAvailable() {
- assertTrue(mController.isAvailable());
- }
-
- @Test
- public void onLocationModeChanged_locationOff_shouldDisablePreference() {
- when(mUserManager.hasUserRestriction(any())).thenReturn(false);
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_OFF, false);
-
- verify(mPreference).setEnabled(false);
- }
-
- @Test
- public void onLocationModeChanged_restricted_shouldDisablePreference() {
- when(mUserManager.hasUserRestriction(any())).thenReturn(true);
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
-
- verify(mPreference).setEnabled(false);
- }
-
- @Test
- public void onLocationModeChanged_locationOnNotRestricted_shouldEnablePreference() {
- when(mUserManager.hasUserRestriction(any())).thenReturn(false);
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
-
- verify(mPreference).setEnabled(true);
- }
-
- @Test
- public void onLocationModeChanged_shouldUpdateSummary() {
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
-
- verify(mPreference).setSummary(anyInt());
- }
-
- @Test
- public void handlePreferenceTreeClick_shouldStartLocationModeFragment() {
- final Preference preference = new Preference(mContext);
- preference.setKey(mController.getPreferenceKey());
-
- mController.handlePreferenceTreeClick(preference);
-
- verify(mActivity).startPreferencePanel(any(), eq(LocationMode.class.getName()), any(),
- eq(R.string.location_mode_screen_title), any(), any(), anyInt());
- }
-
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationModeRadioButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationModeRadioButtonPreferenceControllerTest.java
deleted file mode 100644
index 2766788..0000000
--- a/tests/robotests/src/com/android/settings/location/LocationModeRadioButtonPreferenceControllerTest.java
+++ /dev/null
@@ -1,140 +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.location;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.Context;
-import android.provider.Settings;
-import android.support.v7.preference.PreferenceScreen;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowSecureSettings;
-import com.android.settings.widget.RadioButtonPreference;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-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;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(
- manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
- shadows = {ShadowSecureSettings.class})
-public class LocationModeRadioButtonPreferenceControllerTest {
-
- @Mock
- private RadioButtonPreference mPreference;
- @Mock
- private PreferenceScreen mScreen;
-
- private Context mContext;
- private LocationModeRadioButtonPreferenceController mController;
- private LifecycleOwner mLifecycleOwner;
- private Lifecycle mLifecycle;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- mController = new LocationModeRadioButtonPreferenceControllerTestable(mContext, mLifecycle);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
- }
-
- @Test
- public void displayPreference_shouldAddClickListener() {
- mController.displayPreference(mScreen);
-
- verify(mPreference).setOnClickListener(mController);
- }
-
- @Test
- public void onRadioButtonClicked_shouldSetLocationModeToOwnMode() {
- mController.displayPreference(mScreen);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
-
- mController.onRadioButtonClicked(mPreference);
-
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF))
- .isEqualTo(mController.getLocationMode());
- }
-
- @Test
- public void onLocationModeChanged_otherModeSelected_shouldUncheckPreference() {
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
-
- verify(mPreference).setChecked(false);
- }
-
- @Test
- public void onLocationModeChanged_ownModeSelected_shouldCheckPreference() {
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(mController.getLocationMode(), false);
-
- verify(mPreference).setChecked(true);
- }
-
- @Test
- public void onLocationModeChanged_locationOff_shouldDisablePreference() {
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_OFF, false);
-
- verify(mPreference).setEnabled(false);
- }
-
- @Test
- public void onLocationModeChanged_locationOn_shouldDisablePreference() {
- mController.displayPreference(mScreen);
-
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
-
- verify(mPreference).setEnabled(true);
- }
-
- private class LocationModeRadioButtonPreferenceControllerTestable
- extends LocationModeRadioButtonPreferenceController {
-
- public LocationModeRadioButtonPreferenceControllerTestable(Context context,
- Lifecycle lifecycle) {
- super(context, lifecycle);
- }
-
- @Override
- public String getPreferenceKey() {
- return "test";
- }
-
- @Override
- protected int getLocationMode() {
- return Settings.Secure.LOCATION_MODE_HIGH_ACCURACY;
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationModeSensorsOnlyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationModeSensorsOnlyPreferenceControllerTest.java
deleted file mode 100644
index 4ed75d2..0000000
--- a/tests/robotests/src/com/android/settings/location/LocationModeSensorsOnlyPreferenceControllerTest.java
+++ /dev/null
@@ -1,57 +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.location;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.Context;
-import android.provider.Settings;
-
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class LocationModeSensorsOnlyPreferenceControllerTest {
-
- private LifecycleOwner mLifecycleOwner;
- private Lifecycle mLifecycle;
-
- @Before
- public void setUp() {
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- }
-
- @Test
- public void getLocationMode_shouldReturnModeSensorsOnly() {
- final LocationModeSensorsOnlyPreferenceController controller =
- new LocationModeSensorsOnlyPreferenceController(mock(Context.class), mLifecycle);
-
- assertThat(controller.getLocationMode())
- .isEqualTo(Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
- }
-
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationModeTest.java b/tests/robotests/src/com/android/settings/location/LocationModeTest.java
deleted file mode 100644
index 0e7a9d7..0000000
--- a/tests/robotests/src/com/android/settings/location/LocationModeTest.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.location;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.spy;
-
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.XmlTestUtils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class LocationModeTest {
-
- private Context mContext;
- private LocationMode mFragment;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- mFragment = new LocationMode();
- }
-
- @Test
- public void testSearchIndexProvider_shouldIndexResource() {
- final List<SearchIndexableResource> indexRes =
- mFragment.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(mContext,
- true /* enabled */);
-
- assertThat(indexRes).isNotNull();
- assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
- }
-
- @Test
- @Config(qualifiers = "mcc999")
- public void testSearchIndexProvider_ifPageDisabled_shouldNotIndexResource() {
- final List<String> niks = LocationMode.SEARCH_INDEX_DATA_PROVIDER
- .getNonIndexableKeys(mContext);
- final int xmlId = mFragment.getPreferenceScreenResId();
-
- final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(mContext, xmlId);
- assertThat(niks).containsAllIn(keys);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java
index 2c92b44..e4aa075 100644
--- a/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationPreferenceControllerTest.java
@@ -109,45 +109,30 @@
}
@Test
- public void getLocationSummary_sensorsOnly_shouldSetSummarySensorsOnly() {
+ public void getLocationSummary_sensorsOnly_shouldSetSummaryOn() {
Secure.putInt(mContext.getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_SENSORS_ONLY);
assertThat(mController.getLocationSummary(mContext)).isEqualTo(
- mContext.getString(R.string.location_on_summary,
- mContext.getString(R.string.location_mode_sensors_only_title)));
+ mContext.getString(R.string.location_on_summary));
}
@Test
- public void getLocationSummary_highAccuracy_shouldSetSummarHighAccuracy() {
+ public void getLocationSummary_highAccuracy_shouldSetSummaryOn() {
Secure.putInt(mContext.getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_HIGH_ACCURACY);
assertThat(mController.getLocationSummary(mContext)).isEqualTo(
- mContext.getString(R.string.location_on_summary,
- mContext.getString(R.string.location_mode_high_accuracy_title)));
+ mContext.getString(R.string.location_on_summary));
}
@Test
- public void getLocationSummary_batterySaving_shouldSetSummaryBatterySaving() {
+ public void getLocationSummary_batterySaving_shouldSetSummaryOn() {
Secure.putInt(mContext.getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_BATTERY_SAVING);
assertThat(mController.getLocationSummary(mContext)).isEqualTo(
- mContext.getString(R.string.location_on_summary,
- mContext.getString(R.string.location_mode_battery_saving_title)));
- }
-
- @Test
- public void getLocationString_shouldCorrectString() {
- assertThat(mController.getLocationString(Secure.LOCATION_MODE_OFF)).isEqualTo(
- R.string.location_mode_location_off_title);
- assertThat(mController.getLocationString(Secure.LOCATION_MODE_SENSORS_ONLY)).isEqualTo(
- R.string.location_mode_sensors_only_title);
- assertThat(mController.getLocationString(Secure.LOCATION_MODE_BATTERY_SAVING)).isEqualTo(
- R.string.location_mode_battery_saving_title);
- assertThat(mController.getLocationString(Secure.LOCATION_MODE_HIGH_ACCURACY)).isEqualTo(
- R.string.location_mode_high_accuracy_title);
+ mContext.getString(R.string.location_on_summary));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
index c18372c..25dba80 100644
--- a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
@@ -47,6 +47,7 @@
import android.support.v7.preference.PreferenceScreen;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.RestrictedListPreference;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowRestrictionUtils;
@@ -115,8 +116,8 @@
@Test
public void testNoCrashIfNoOnResume() throws Exception {
mController.isAvailable();
- mController.updateState(mock(RestrictedDropDownPreference.class));
- mController.onPreferenceChange(mock(RestrictedDropDownPreference.class), true);
+ mController.updateState(mock(RestrictedListPreference.class));
+ mController.onPreferenceChange(mock(RestrictedListPreference.class), true);
}
@Test
@@ -165,7 +166,7 @@
mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
verify(pref, times(2)).addRestrictedItem(any());
@@ -187,7 +188,7 @@
mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
verify(pref, times(1)).addRestrictedItem(any());
@@ -202,7 +203,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
mController.onResume(appRow, channel, null, null);
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
ArgumentCaptor<CharSequence[]> argumentCaptor =
@@ -221,7 +222,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
mController.onResume(appRow, channel, null, null);
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
ArgumentCaptor<CharSequence[]> argumentCaptor =
@@ -237,7 +238,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
mController.onResume(appRow, channel, null, null);
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
ArgumentCaptor<CharSequence[]> argumentCaptor =
@@ -268,7 +269,7 @@
when(channel.getLockscreenVisibility()).thenReturn(VISIBILITY_NO_OVERRIDE);
mController.onResume(appRow, channel, null, null);
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
@@ -287,7 +288,7 @@
when(channel.getLockscreenVisibility()).thenReturn(Notification.VISIBILITY_SECRET);
mController.onResume(appRow, channel, null, null);
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
@@ -306,7 +307,7 @@
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
mController.onResume(appRow, channel, null, null);
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
mController.onPreferenceChange(pref, String.valueOf(Notification.VISIBILITY_PRIVATE));
@@ -325,7 +326,7 @@
channel.setLockscreenVisibility(VISIBILITY_NO_OVERRIDE);
mController.onResume(appRow, channel, null, null);
- RestrictedDropDownPreference pref = mock(RestrictedDropDownPreference.class);
+ RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
mController.onPreferenceChange(pref, String.valueOf(Notification.VISIBILITY_SECRET));
diff --git a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
index e6530d5..ac3e0b6 100644
--- a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
@@ -89,6 +89,23 @@
}
@Test
+ public void setCheckboxEnabled_shouldOnlyUpdateCheckBoxEnabledState() {
+ final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
+ LayoutInflater.from(mContext).inflate(
+ R.layout.preference_widget_master_checkbox, null));
+ final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget);
+ mPreference.onBindViewHolder(holder);
+
+ mPreference.setCheckBoxEnabled(false);
+ assertThat(mPreference.isEnabled()).isTrue();
+ assertThat(checkBox.isEnabled()).isFalse();
+
+ mPreference.setCheckBoxEnabled(true);
+ assertThat(mPreference.isEnabled()).isTrue();
+ assertThat(checkBox.isEnabled()).isTrue();
+ }
+
+ @Test
public void clickWidgetView_shouldToggleCheckBox() {
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
diff --git a/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java b/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java
index 8fe2358..3daecce 100644
--- a/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java
+++ b/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java
@@ -74,7 +74,24 @@
"toggle_bluetooth",
"toggle_nfc",
"android_beam_settings",
- "sms_mirroring"
+ "sms_mirroring",
+ // Dup keys from About Phone v2 experiment.
+ "ims_reg_state",
+ "bt_address",
+ "device_model",
+ "firmware_version",
+ "regulatory_info",
+ "manual",
+ "legal_container",
+ "device_feedback",
+ "fcc_equipment_id",
+ "sim_status",
+ "build_number",
+ "phone_number",
+ "imei_info",
+ "wifi_ip_address",
+ "wifi_mac_address",
+ "safety_info"
);
private Context mContext;