Merge "Move users to system dashboard"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4a4275f..6eb52ef 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/res/values/strings.xml b/res/values/strings.xml
index 65d7b0f..8295a4a 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..42e5c54 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,84 @@
</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" />
+ 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:key="debug_hw_renderer"
+ android:title="@string/debug_hw_renderer"
+ android:entries="@array/debug_hw_renderer_entries"
+ android:entryValues="@array/debug_hw_renderer_values" />
</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 +461,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 +479,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/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/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/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 034cbd0..75f64d3 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/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/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/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/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;