Merge "Add title and icon in output switcher panel header"
diff --git a/res/layout/accessibility_shortcut_secondary_action.xml b/res/layout/accessibility_shortcut_secondary_action.xml
index 1b575da..84c8e6b 100644
--- a/res/layout/accessibility_shortcut_secondary_action.xml
+++ b/res/layout/accessibility_shortcut_secondary_action.xml
@@ -94,8 +94,9 @@
android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:minWidth="58dp"
+ android:contentDescription="@string/accessibility_shortcut_settings"
android:gravity="end|center_vertical"
+ android:minWidth="58dp"
android:orientation="vertical" />
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/daltonizer_preview.xml b/res/layout/daltonizer_preview.xml
index 24c0f76..bdf1070 100644
--- a/res/layout/daltonizer_preview.xml
+++ b/res/layout/daltonizer_preview.xml
@@ -24,6 +24,6 @@
android:id="@+id/palette_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:contentDescription="@null" />
+ android:importantForAccessibility="noHideDescendants" />
</FrameLayout>
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index a3ad4207..18ad3b5 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -470,7 +470,7 @@
<EditText android:id="@+id/proxy_pac"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/wifi_item_content"
+ style="@style/wifi_item_edit_content"
android:hint="@string/proxy_url_hint"
android:inputType="textNoSuggestions"
android:singleLine="true"/>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 9c3a622..bfffce0 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1175,6 +1175,19 @@
<item>zen_mode_from_none</item>
</string-array>
+ <string-array name="zen_mode_conversations_entries" translatable="false">
+ <item>@string/zen_mode_from_all_conversations</item>
+ <item>@string/zen_mode_from_important_conversations</item>
+ <item>@string/zen_mode_from_no_conversations</item>
+ </string-array>
+
+ <!-- these values correspond with ZenPolicy.ConversationSenders -->
+ <string-array name="zen_mode_conversations_values" translatable="false">
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+
<!--String arrays for notification swipe direction -->
<string-array name="swipe_direction_titles">
<item>@string/swipe_direction_rtl</item>
diff --git a/res/values/config.xml b/res/values/config.xml
index fc2ca1f..42bc0d6 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -416,9 +416,11 @@
<string-array name="config_suppress_injected_tile_keys" translatable="false"/>
<!-- Reset application package name -->
- <string-array name="config_reset_app_package_name" translatable="false">
- <item>com.android.systemui</item>
+ <string-array name="config_skip_reset_apps_package_name" translatable="false">
<item>android</item>
+ <item>com.android.providers.downloads</item>
+ <item>com.android.systemui</item>
+ <item>com.android.vending</item>
</string-array>
<!-- Settings panel keeps observe this uri -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0ddc62a..bf5b34d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4877,6 +4877,8 @@
<string name="accessibility_global_gesture_preference_title">Volume key shortcut</string>
<!-- Title for the preference to choose the service that is turned on and off by the accessibility shortcut. [CHAR LIMIT=35] -->
<string name="accessibility_shortcut_service_title">Shortcut service</string>
+ <!-- Label for shortcut settings button. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_shortcut_settings">Shortcut settings</string>
<!-- Title for the switch preference that controls whether or not the accessibility shortcut works on the lock screen. [CHAR LIMIT=35] -->
<string name="accessibility_shortcut_service_on_lock_screen_title">Allow from lock screen</string>
<!-- Description of accessibility shortcut. [CHAR LIMIT=NONE] -->
@@ -5079,9 +5081,12 @@
<!-- Label describing a high intensity vibration option. [CHAR LIMIT=15] -->
<string name="accessibility_vibration_intensity_high">High</string>
- <!-- Title for accessibility menu item to lauch a settings activity. [CHAR LIMIT=15] -->
+ <!-- Title for accessibility menu item to launch a settings activity. [CHAR LIMIT=15] -->
<string name="accessibility_menu_item_settings">Settings</string>
+ <!-- Title for accessibility menu item to launch a settings activity with app name. [CHAR LIMIT=30] -->
+ <string name="accessibility_service_menu_item_settings"><xliff:g example="TalkBack" id="accessibility_app_name">%1$s</xliff:g> settings</string>
+
<!-- Summary for the enabled state of an accessibility feature. [CHAR LIMIT=10] -->
<string name="accessibility_feature_state_on">On</string>
<!-- Summary for the disabled state of an accessibility feature. [CHAR LIMIT=10] -->
@@ -5532,13 +5537,9 @@
<!-- Title for the smart battery toggle [CHAR LIMIT=NONE] -->
<string name="smart_battery_title">Manage apps automatically</string>
<!-- Summary for the smart battery toggle [CHAR LIMIT=NONE] -->
- <string name="smart_battery_summary">Limit battery for apps that you don\u2019t use often</string>
+ <string name="smart_battery_summary" product="default">Limit battery for apps that you don\u2019t use often</string>
<!-- Footer for the aosp smart battery page -->
- <string name="smart_battery_footer" product="default">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
- <!-- Footer for the aosp smart battery page -->
- <string name="smart_battery_footer" product="tablet">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
- <!-- Footer for the aosp smart battery page -->
- <string name="smart_battery_footer" product="device">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
+ <string name="smart_battery_footer">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
<!-- Title for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
<string name="restricted_app_title">Restricted apps</string>
<!-- Summary for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
@@ -5559,7 +5560,8 @@
<string name="battery_auto_restriction_summary">Detect when apps drain battery</string>
<!-- Summary for battery manager when it is on -->
- <string name="battery_manager_on">On / Detecting when apps drain battery</string>
+ <string name="battery_manager_on" product="default">On / Detecting when apps drain battery</string>
+
<!-- Summary for battery manager when it is off -->
<string name="battery_manager_off">Off</string>
<!-- Summary for battery manager, showing app restricted -->
@@ -7108,6 +7110,8 @@
<string name="help_uri_bluetooth_screen" translatable="false"></string>
<!-- url for the SIM combination warning required dialog help page -->
<string name="help_uri_sim_combination_warning" translatable="false"></string>
+ <!-- url for the NFC and payment settings page -->
+ <string name="help_uri_nfc_and_payment_settings" translatable="false"></string>
<!-- User account title [CHAR LIMIT=30] -->
<string name="user_account_title">Account for content</string>
@@ -7338,6 +7342,8 @@
<string name="connected_devices_dashboard_no_driving_mode_summary">Bluetooth, NFC</string>
<!-- Summary for Connected devices settings, explaning a few important settings under it [CHAR LIMIT=NONE]-->
<string name="connected_devices_dashboard_no_driving_mode_no_nfc_summary">Bluetooth</string>
+ <!-- Summary for Tap & pay settings, explaning a few important settings under it [CHAR LIMIT=NONE]-->
+ <string name="nfc_and_payment_settings_payment_off_nfc_off_summary">Unavailable because NFC is off</string>
<!-- Title for setting tile leading to Apps & Notification settings [CHAR LIMIT=40]-->
<string name="app_and_notification_dashboard_title">Apps & notifications</string>
<!-- Summary for Apps & Notification settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
@@ -7574,6 +7580,15 @@
<!-- Sound: Title for the option managing whether or not to vibrate when ringing. [CHAR LIMIT=30] -->
<string name="vibrate_when_ringing_title">Vibrate for calls</string>
+ <!-- Sound: Option for vibrate when ringing setting: Never vibrate. [CHAR LIMIT=40] -->
+ <string name="vibrate_when_ringing_option_never_vibrate">Never vibrate</string>
+
+ <!-- Sound: Option for vibrate when ringing setting: Always vibrate. [CHAR LIMIT=40] -->
+ <string name="vibrate_when_ringing_option_always_vibrate">Always vibrate</string>
+
+ <!-- Sound: Option for vibrate when ringing setting: Ramping ringer. [CHAR LIMIT=80] -->
+ <string name="vibrate_when_ringing_option_ramping_ringer">Vibrate first then ring gradually</string>
+
<!-- Sound: Title for the other sounds option and associated settings page. [CHAR LIMIT=30] -->
<string name="other_sound_settings">Other sounds</string>
@@ -7784,7 +7799,7 @@
<!-- Do not disturb: what to block summary, all effects -->
<string name="zen_mode_block_effect_summary_all">Sound, vibration, and visual signs of notifications</string>
- <string name="zen_mode_blocked_effects_footer">Notifications needed for basic phone activity and status will never be hidden</string>
+ <string name="zen_mode_blocked_effects_footer">Notifications needed for basic phone activity and status will never be hidden.</string>
<!-- Do not disturb: Zen mode no sounds are exceptions to bypass do not disturb-->
<string name="zen_mode_no_exceptions">None</string>
@@ -8639,6 +8654,9 @@
</plurals>
<string name="zen_mode_conversations_title">Conversations</string>
+ <string name="zen_mode_from_all_conversations">From all conversations</string>
+ <string name="zen_mode_from_important_conversations">From important conversations</string>
+ <string name="zen_mode_from_no_conversations">Don\u2019t allow any conversations</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Messages option -->
<string name="zen_mode_messages">Allow messages</string>
@@ -10795,34 +10813,34 @@
<!-- UI debug setting: ANGLE enabled app has been set [CHAR LIMIT=NONE] -->
<string name="angle_enabled_app_set">ANGLE enabled application: <xliff:g id="app_name" example="com.company.app">%1$s</xliff:g></string>
- <!-- Title for Game Driver dashboard where developers can configure apps to use game driver or not [CHAR LIMIT=50] -->
- <string name="game_driver_dashboard_title">Game Driver Preferences</string>
- <!-- Summary for Game Driver dashboard [CHAR LIMIT=50] -->
- <string name="game_driver_dashboard_summary">Modify Game Driver settings</string>
- <!-- Footer text for Game Driver dashboard [CHAR LIMIT=NONE] -->
- <string name="game_driver_footer_text">When Game Driver is turned on, you can pick to use the updated graphics driver for Apps installed on the device.</string>
- <!-- Title for Game Driver all apps preference [CHAR LIMIT=50] -->
- <string name="game_driver_all_apps_preference_title">Enable for all apps</string>
- <!-- Title for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_title">Select Graphics Driver</string>
- <!-- The default value for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_default">Default</string>
+ <!-- Title for graphics driver dashboard where developers can configure apps to choose graphics driver [CHAR LIMIT=50] -->
+ <string name="graphics_driver_dashboard_title">Graphics Driver Preferences</string>
+ <!-- Summary for graphics driver dashboard [CHAR LIMIT=50] -->
+ <string name="graphics_driver_dashboard_summary">Modify graphics driver settings</string>
+ <!-- Footer text for graphics driver dashboard [CHAR LIMIT=NONE] -->
+ <string name="graphics_driver_footer_text">When there are multiple graphics drivers, you can pick to use the updated graphics driver for Apps installed on the device.</string>
+ <!-- Title for graphics Driver all apps preference [CHAR LIMIT=50] -->
+ <string name="graphics_driver_all_apps_preference_title">Enable for all apps</string>
+ <!-- Title for graphics driver preference for app [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_title">Select Graphics Driver</string>
+ <!-- The default value of graphics driver preference for app [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_default">Default</string>
<!-- The game driver value for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_game_driver">Game Driver</string>
- <!-- The game driver value for Prerelease Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_prerelease_driver">Prerelease Driver</string>
- <!-- The system value for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_system">System Graphics Driver</string>
- <!-- All the values for Game Driver all apps preference [CHAR LIMIT=50] -->
- <string-array name="game_driver_all_apps_preference_values">
- <item>@string/game_driver_app_preference_default</item>
- <item>@string/game_driver_app_preference_game_driver</item>
+ <string name="graphics_driver_app_preference_game_driver">Game Driver</string>
+ <!-- The prerelase driver value for Prerelease Driver app preference [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_prerelease_driver">Prerelease Driver</string>
+ <!-- The system driver value for system graphics driver app preference [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_system">System Graphics Driver</string>
+ <!-- All the graphics driver preference values for all apps globally [CHAR LIMIT=50] -->
+ <string-array name="graphics_driver_all_apps_preference_values">
+ <item>@string/graphics_driver_app_preference_default</item>
+ <item>@string/graphics_driver_app_preference_game_driver</item>
</string-array>
- <!-- All the values for Game Driver app preference [CHAR LIMIT=50] -->
- <string-array name="game_driver_app_preference_values">
- <item>@string/game_driver_app_preference_default</item>
- <item>@string/game_driver_app_preference_game_driver</item>
- <item>@string/game_driver_app_preference_system</item>
+ <!-- All the values of graphics driver for app preference [CHAR LIMIT=50] -->
+ <string-array name="graphics_driver_app_preference_values">
+ <item>@string/graphics_driver_app_preference_default</item>
+ <item>@string/graphics_driver_app_preference_game_driver</item>
+ <item>@string/graphics_driver_app_preference_system</item>
</string-array>
<!-- Title for App Compatibility Changes dashboard where developers can configure per-app overrides for compatibility changes [CHAR LIMIT=50] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index a4c82b2..33a2022 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -141,7 +141,7 @@
<item name="android:textSize">14sp</item>
</style>
- <style name="wifi_item_edit_content">
+ <style name="wifi_item_edit_content" parent="@android:style/TextAppearance.Widget.EditText">
<item name="android:paddingStart">4dip</item>
<item name="android:layout_marginStart">4dip</item>
<item name="android:textSize">18sp</item>
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index 7c50bcc..f5cef7e 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -28,21 +28,13 @@
android:order="-9"
settings:searchable="false"/>
- <SwitchPreference
- android:key="toggle_nfc"
+ <Preference
+ android:fragment="com.android.settings.connecteddevice.NfcAndPaymentFragment"
+ android:key="nfc_and_payment_settings"
android:title="@string/nfc_quick_toggle_title"
android:icon="@drawable/ic_nfc"
- android:summary="@string/nfc_quick_toggle_summary"
- settings:controller="com.android.settings.nfc.NfcPreferenceController"
- android:order="-7"/>
-
- <SwitchPreference
- android:key="nfc_secure_settings"
- android:title="@string/nfc_secure_settings_title"
- settings:controller="com.android.settings.nfc.SecureNfcPreferenceController"
- android:icon="@drawable/ic_nfc"
- android:summary="@string/nfc_secure_toggle_summary"
- android:order="-7"/>
+ android:order="-7"
+ settings:controller="com.android.settings.connecteddevice.NfcAndPaymentFragmentController"/>
<Preference
android:fragment="com.android.settings.wfd.WifiDisplaySettings"
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index acd50ad..ff6640c 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -217,9 +217,9 @@
android:summary="@string/enable_gpu_debug_layers_summary" />
<Preference
- android:key="game_driver_dashboard"
- android:title="@string/game_driver_dashboard_title"
- android:summary="@string/game_driver_dashboard_summary"
+ android:key="graphics_driver_dashboard"
+ android:title="@string/graphics_driver_dashboard_title"
+ android:summary="@string/graphics_driver_dashboard_summary"
android:fragment="com.android.settings.development.gamedriver.GameDriverDashboard"
settings:searchable="false" />
diff --git a/res/xml/game_driver_settings.xml b/res/xml/graphics_driver_settings.xml
similarity index 67%
rename from res/xml/game_driver_settings.xml
rename to res/xml/graphics_driver_settings.xml
index e467320..e4aa04e 100644
--- a/res/xml/game_driver_settings.xml
+++ b/res/xml/graphics_driver_settings.xml
@@ -18,27 +18,27 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="game_driver_settings"
- android:title="@string/game_driver_dashboard_title">
+ android:key="graphics_driver_settings"
+ android:title="@string/graphics_driver_dashboard_title">
<ListPreference
- android:key="game_driver_all_apps_preference"
- android:title="@string/game_driver_all_apps_preference_title"
- android:dialogTitle="@string/game_driver_all_apps_preference_title"
- android:entries="@array/game_driver_all_apps_preference_values"
- android:entryValues="@array/game_driver_all_apps_preference_values"
+ android:key="graphics_driver_all_apps_preference"
+ android:title="@string/graphics_driver_all_apps_preference_title"
+ android:dialogTitle="@string/graphics_driver_all_apps_preference_title"
+ android:entries="@array/graphics_driver_all_apps_preference_values"
+ android:entryValues="@array/graphics_driver_all_apps_preference_values"
settings:controller="com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController">
</ListPreference>
<PreferenceCategory
- android:key="game_driver_category"
- android:title="@string/game_driver_app_preference_title"
+ android:key="graphics_driver_category"
+ android:title="@string/graphics_driver_app_preference_title"
settings:controller="com.android.settings.development.gamedriver.GameDriverAppPreferenceController">
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
- android:key="game_driver_footer"
- android:title="@string/game_driver_footer_text"
+ android:key="graphics_driver_footer"
+ android:title="@string/graphics_driver_footer_text"
android:selectable="false"
settings:controller="com.android.settings.development.gamedriver.GameDriverFooterPreferenceController">
</com.android.settingslib.widget.FooterPreference>
diff --git a/res/xml/nfc_and_payment_settings.xml b/res/xml/nfc_and_payment_settings.xml
new file mode 100644
index 0000000..f240388
--- /dev/null
+++ b/res/xml/nfc_and_payment_settings.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/nfc_quick_toggle_title">
+
+ <SwitchPreference
+ android:key="toggle_nfc"
+ android:title="@string/nfc_quick_toggle_title"
+ android:summary="@string/nfc_quick_toggle_summary"
+ settings:controller="com.android.settings.nfc.NfcPreferenceController"/>
+
+ <SwitchPreference
+ android:key="nfc_secure_settings"
+ android:title="@string/nfc_secure_settings_title"
+ settings:controller="com.android.settings.nfc.SecureNfcPreferenceController"
+ android:summary="@string/nfc_secure_toggle_summary"/>
+
+ <Preference
+ android:key="default_payment_app"
+ android:title="@string/nfc_payment_settings_title"
+ android:fragment="com.android.settings.nfc.PaymentSettings"
+ settings:keywords="@string/keywords_default_payment_app"
+ settings:controller="com.android.settings.applications.specialaccess.DefaultPaymentSettingsPreferenceController"/>
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index d82a324..a24a95f 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -88,11 +88,12 @@
settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>
<!-- Also vibrate for calls -->
- <SwitchPreference
- android:key="vibrate_when_ringing"
+ <Preference
+ android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
+ android:key="vibrate_for_calls"
android:title="@string/vibrate_when_ringing_title"
- settings:controller="com.android.settings.notification.VibrateWhenRingPreferenceController"
- android:order="-130"/>
+ android:order="-130"
+ settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"/>
<!-- Interruptions -->
<com.android.settingslib.RestrictedPreference
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index e511d17..200f896 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -101,13 +101,6 @@
settings:controller="com.android.settings.applications.specialaccess.premiumsms.PremiumSmsController" />
<Preference
- android:key="default_payment_app"
- android:title="@string/nfc_payment_settings_title"
- android:fragment="com.android.settings.nfc.PaymentSettings"
- settings:keywords="@string/keywords_default_payment_app"
- settings:controller="com.android.settings.applications.specialaccess.DefaultPaymentSettingsPreferenceController" />
-
- <Preference
android:key="data_saver"
android:title="@string/unrestricted_data_saver"
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess"
diff --git a/res/xml/vibrate_for_calls_settings.xml b/res/xml/vibrate_for_calls_settings.xml
new file mode 100644
index 0000000..5b6d217
--- /dev/null
+++ b/res/xml/vibrate_for_calls_settings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/vibrate_when_ringing_title" />
diff --git a/res/xml/zen_mode_people_settings.xml b/res/xml/zen_mode_people_settings.xml
index 5456f6f..140d1cd 100644
--- a/res/xml/zen_mode_people_settings.xml
+++ b/res/xml/zen_mode_people_settings.xml
@@ -59,6 +59,13 @@
<PreferenceCategory
android:title="@string/zen_mode_conversations_title"
android:key="zen_mode_settings_category_conversations">
+
+ <!-- Conversations -->
+ <ListPreference
+ android:key="zen_mode_conversations"
+ android:title="@string/zen_mode_conversations_title"
+ android:entries="@array/zen_mode_conversations_entries"
+ android:entryValues="@array/zen_mode_conversations_values"/>
</PreferenceCategory>
<!-- Footer that shows if user is put into alarms only or total silence mode by an app -->
diff --git a/src/com/android/settings/AllInOneTetherSettings.java b/src/com/android/settings/AllInOneTetherSettings.java
index 098e6fb..996c434 100644
--- a/src/com/android/settings/AllInOneTetherSettings.java
+++ b/src/com/android/settings/AllInOneTetherSettings.java
@@ -20,7 +20,7 @@
import static android.net.ConnectivityManager.TETHERING_WIFI;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_CHANGED_ACTION;
-import static com.android.settings.network.WifiTetherDisablePreferenceController.KEY_ENABLE_WIFI_TETHERING;
+import static com.android.settings.network.TetherEnabler.KEY_ENABLE_WIFI_TETHERING;
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothAdapter;
diff --git a/src/com/android/settings/LinkifyUtils.java b/src/com/android/settings/LinkifyUtils.java
index 5550db5..7da7ed2 100644
--- a/src/com/android/settings/LinkifyUtils.java
+++ b/src/com/android/settings/LinkifyUtils.java
@@ -74,7 +74,7 @@
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(false);
+ ds.setUnderlineText(true);
}
};
spannableContent.setSpan(spannableLink, beginIndex, endIndex,
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 8a96484..315cba1 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -688,6 +688,15 @@
return um.getCredentialOwnerProfile(userId);
}
+ /**
+ * Returns the credential type of the given user id.
+ */
+ public static @LockPatternUtils.CredentialType int getCredentialType(Context context,
+ int userId) {
+ final LockPatternUtils lpu = new LockPatternUtils(context);
+ return lpu.getCredentialTypeForUser(userId);
+ }
+
private static final StringBuilder sBuilder = new StringBuilder(50);
private static final java.util.Formatter sFormatter = new java.util.Formatter(
sBuilder, Locale.getDefault());
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1722c99..6f51fd3 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -437,7 +437,8 @@
final String settingsClassName = info.getSettingsActivityName();
if (!TextUtils.isEmpty(settingsClassName)) {
extras.putString(EXTRA_SETTINGS_TITLE,
- getString(R.string.accessibility_menu_item_settings));
+ getString(R.string.accessibility_service_menu_item_settings,
+ resolveInfo.loadLabel(getPackageManager())));
extras.putString(EXTRA_SETTINGS_COMPONENT_NAME,
new ComponentName(packageName, settingsClassName).flattenToString());
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index 159e609..2bcb5b3 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -16,6 +16,8 @@
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType.LEGACY;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
@@ -99,9 +101,11 @@
public void onResume() {
super.onResume();
updateAccessibilityServicePreference(mScreenReaderPreference,
- findService(SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME));
+ SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME,
+ LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.class.getName());
updateAccessibilityServicePreference(mSelectToSpeakPreference,
- findService(SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME));
+ SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME,
+ LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.class.getName());
configureMagnificationPreferenceIfNeeded(mDisplayMagnificationPreference);
}
@@ -143,7 +147,8 @@
}
private void updateAccessibilityServicePreference(Preference preference,
- AccessibilityServiceInfo info) {
+ String packageName, String serviceName, String targetLegacyFragment) {
+ final AccessibilityServiceInfo info = findService(packageName, serviceName);
if (info == null) {
getPreferenceScreen().removePreference(preference);
return;
@@ -154,6 +159,9 @@
preference.setTitle(title);
ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
preference.setKey(componentName.flattenToString());
+ if (AccessibilityUtil.getAccessibilityServiceFragmentType(info) == LEGACY) {
+ preference.setFragment(targetLegacyFragment);
+ }
// Update the extras.
Bundle extras = preference.getExtras();
diff --git a/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
new file mode 100644
index 0000000..c9257a9
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 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.accessibility;
+
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleScreenReaderPreferenceFragmentForSetupWizard
+ extends LegacyAccessibilityServicePreferenceFragment {
+
+ private boolean mToggleSwitchWasInitiallyChecked;
+
+ @Override
+ protected void onProcessArguments(Bundle arguments) {
+ super.onProcessArguments(arguments);
+ mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+ }
+
+ @Override
+ public void onStop() {
+ // Log the final choice in value if it's different from the previous value.
+ if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ mMetricsFeatureProvider.action(getContext(),
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
+ mToggleSwitch.isChecked());
+ }
+
+ super.onStop();
+ }
+}
diff --git a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
new file mode 100644
index 0000000..2c8485b
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 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.accessibility;
+
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard
+ extends LegacyAccessibilityServicePreferenceFragment {
+
+ private boolean mToggleSwitchWasInitiallyChecked;
+
+ @Override
+ protected void onProcessArguments(Bundle arguments) {
+ super.onProcessArguments(arguments);
+ mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+ }
+
+ @Override
+ public void onStop() {
+ // Log the final choice in value if it's different from the previous value.
+ if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ mMetricsFeatureProvider.action(getContext(),
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
+ mToggleSwitch.isChecked());
+ }
+
+ super.onStop();
+ }
+}
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 36b2da1..6d64a23 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -89,10 +89,8 @@
@Override
public void onResume() {
super.onResume();
-
- mSettingsContentObserver.register(getContentResolver());
-
updateSwitchBarToggleSwitch();
+ mSettingsContentObserver.register(getContentResolver());
}
@Override
@@ -199,6 +197,9 @@
private void updateSwitchBarToggleSwitch() {
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getPrefContext())
.contains(mComponentName);
+ if (mSwitchBar.isChecked() == checked) {
+ return;
+ }
mSwitchBar.setCheckedInternal(checked);
}
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index 283fa90..d25be83 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -17,6 +17,8 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import android.app.settings.SettingsEnums;
import android.net.Uri;
@@ -26,13 +28,11 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Switch;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.State;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable;
@@ -42,8 +42,7 @@
/** Settings page for color inversion. */
@SearchIndexable
-public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements SwitchBar.OnSwitchChangeListener {
+public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
private static final String CATEGORY_FOOTER_KEY = "color_inversion_footer_category";
@@ -58,7 +57,7 @@
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? State.OFF : State.ON);
+ Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
}
@Override
@@ -69,7 +68,7 @@
@Override
protected void onRemoveSwitchBarToggleSwitch() {
super.onRemoveSwitchBarToggleSwitch();
- mSwitchBar.removeOnSwitchChangeListener(this);
+ mToggleSwitch.setOnBeforeCheckedChangeListener(null);
}
@Override
@@ -79,16 +78,13 @@
}
@Override
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
- }
-
- @Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF) == State.ON);
- mSwitchBar.addOnSwitchChangeListener(this);
+ updateSwitchBarToggleSwitch();
+ mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
+ });
}
@Override
@@ -101,9 +97,7 @@
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF)
- == State.ON);
+ updateSwitchBarToggleSwitch();
}
};
return super.onCreateView(inflater, container, savedInstanceState);
@@ -123,6 +117,7 @@
@Override
public void onResume() {
super.onResume();
+ updateSwitchBarToggleSwitch();
mSettingsContentObserver.register(getContentResolver());
}
@@ -138,6 +133,14 @@
showDialog(DIALOG_ID_EDIT_SHORTCUT);
}
+ private void updateSwitchBarToggleSwitch() {
+ final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
+ if (mSwitchBar.isChecked() == checked) {
+ return;
+ }
+ mSwitchBar.setCheckedInternal(checked);
+ }
+
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_color_inversion_settings);
}
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 493140c..9a6aefd 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -17,6 +17,8 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -28,14 +30,12 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Switch;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.State;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -47,8 +47,7 @@
@SearchIndexable
public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements DaltonizerRadioButtonPreferenceController.OnChangeListener,
- SwitchBar.OnSwitchChangeListener{
+ implements DaltonizerRadioButtonPreferenceController.OnChangeListener {
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
private static final String CATEGORY_FOOTER_KEY = "daltonizer_footer_category";
@@ -88,9 +87,7 @@
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF)
- == State.ON);
+ updateSwitchBarToggleSwitch();
}
};
return super.onCreateView(inflater, container, savedInstanceState);
@@ -109,7 +106,9 @@
@Override
public void onResume() {
super.onResume();
+ updateSwitchBarToggleSwitch();
mSettingsContentObserver.register(getContentResolver());
+
for (AbstractPreferenceController controller :
buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
((DaltonizerRadioButtonPreferenceController) controller).setOnChangeListener(this);
@@ -145,13 +144,13 @@
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? State.OFF : State.ON);
+ Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
}
@Override
protected void onRemoveSwitchBarToggleSwitch() {
super.onRemoveSwitchBarToggleSwitch();
- mSwitchBar.removeOnSwitchChangeListener(this);
+ mToggleSwitch.setOnBeforeCheckedChangeListener(null);
}
@Override
@@ -161,16 +160,13 @@
}
@Override
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
- }
-
- @Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF) == State.ON);
- mSwitchBar.addOnSwitchChangeListener(this);
+ updateSwitchBarToggleSwitch();
+ mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
+ });
}
@Override
@@ -179,6 +175,14 @@
showDialog(DialogEnums.EDIT_SHORTCUT);
}
+ private void updateSwitchBarToggleSwitch() {
+ final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
+ if (mSwitchBar.isChecked() == checked) {
+ return;
+ }
+ mSwitchBar.setCheckedInternal(checked);
+ }
+
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_daltonizer_settings);
}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index b82a344..401ca5e 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -188,12 +188,6 @@
initShortcutPreference();
- mSettingsPreference = new Preference(getPrefContext());
- mSettingsPreference.setTitle(R.string.accessibility_magnification_service_settings_title);
- mSettingsPreference.setKey(SETTINGS_KEY);
- mSettingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
- mSettingsPreference.setPersistent(false);
-
super.onViewCreated(view, savedInstanceState);
mConfigWarningPreference = new Preference(getPrefContext());
diff --git a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
index fc68e03..29c031d 100644
--- a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -46,4 +46,3 @@
super.onStop();
}
}
-
diff --git a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
index 5f01e4b..da94abc 100644
--- a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -47,4 +47,3 @@
super.onStop();
}
}
-
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 7e02065..28a88a2 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -22,7 +22,6 @@
import android.content.Context;
import android.icu.text.RelativeDateTimeFormatter;
import android.os.UserHandle;
-import android.util.IconDrawableFactory;
import android.view.View;
import androidx.annotation.NonNull;
@@ -37,6 +36,7 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.Utils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.utils.StringUtil;
@@ -65,7 +65,6 @@
private final ApplicationsState mApplicationsState;
private final int mUserId;
- private final IconDrawableFactory mIconDrawableFactory;
private final MetricsFeatureProvider mMetricsFeatureProvider;
private Fragment mHost;
@@ -76,7 +75,6 @@
mApplicationsState = ApplicationsState.getInstance(
(Application) mContext.getApplicationContext());
mUserId = UserHandle.myUserId();
- mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
mMetricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
}
@@ -161,7 +159,7 @@
}
return new AppEntityInfo.Builder()
- .setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info))
+ .setIcon(Utils.getBadgedIcon(mContext, appEntry.info))
.setTitle(appEntry.label)
.setSummary(StringUtil.formatRelativeTime(mContext,
System.currentTimeMillis() - stat.getLastTimeUsed(), false,
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 2597665..0f7a8c2 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -1460,7 +1460,7 @@
ApplicationsState.AppEntry entry = mEntries.get(position);
synchronized (entry) {
holder.setTitle(entry.label);
- holder.setIcon(mIconDrawableFactory.getBadgedIcon(entry.info));
+ holder.setIcon(Utils.getBadgedIcon(mContext, entry.info));
updateSummary(holder, entry);
updateSwitch(holder, entry);
holder.updateDisableView(entry.info);
diff --git a/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java b/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
index 1fe0d01..270a5c8 100644
--- a/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
+++ b/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
@@ -114,7 +114,7 @@
PackageManager.GET_DISABLED_COMPONENTS);
final List<String> whiteList = Arrays.asList(
mContext.getResources().getStringArray(
- R.array.config_reset_app_package_name));
+ R.array.config_skip_reset_apps_package_name));
for (int i = 0; i < apps.size(); i++) {
ApplicationInfo app = apps.get(i);
diff --git a/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java b/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java
index dbdc9fe..2f03c3d 100644
--- a/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java
@@ -21,11 +21,23 @@
import android.nfc.NfcAdapter;
import android.os.UserManager;
-import com.android.settings.core.BasePreferenceController;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
-public class DefaultPaymentSettingsPreferenceController extends BasePreferenceController {
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+/**
+ * This Controller works with PaymentSettingsEnabler to control payment features availability
+ * based on NFC status
+ */
+public class DefaultPaymentSettingsPreferenceController extends BasePreferenceController
+ implements LifecycleObserver, OnResume, OnPause {
private final NfcAdapter mNfcAdapter;
+ private PaymentSettingsEnabler mPaymentSettingsEnabler;
private final PackageManager mPackageManager;
private final UserManager mUserManager;
@@ -38,6 +50,32 @@
}
@Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ if (!isAvailable()) {
+ mPaymentSettingsEnabler = null;
+ return;
+ }
+
+ final Preference preference = screen.findPreference(getPreferenceKey());
+ mPaymentSettingsEnabler = new PaymentSettingsEnabler(mContext, preference);
+ }
+
+ @Override
+ public void onResume() {
+ if (mPaymentSettingsEnabler != null) {
+ mPaymentSettingsEnabler.resume();
+ }
+ }
+
+ @Override
+ public void onPause() {
+ if (mPaymentSettingsEnabler != null) {
+ mPaymentSettingsEnabler.pause();
+ }
+ }
+
+ @Override
public int getAvailabilityStatus() {
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)
|| !mPackageManager.hasSystemFeature(
@@ -47,9 +85,12 @@
if (!mUserManager.isAdminUser()) {
return DISABLED_FOR_USER;
}
- if (mNfcAdapter == null || !mNfcAdapter.isEnabled()) {
+ if (mNfcAdapter == null) {
return CONDITIONALLY_UNAVAILABLE;
}
+ if (!mNfcAdapter.isEnabled()) {
+ return DISABLED_DEPENDENT_SETTING;
+ }
return AVAILABLE;
}
}
diff --git a/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java b/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java
new file mode 100644
index 0000000..6c5227d
--- /dev/null
+++ b/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2020 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.applications.specialaccess;
+
+import android.content.Context;
+import android.nfc.NfcAdapter;
+
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.nfc.BaseNfcEnabler;
+
+/**
+ * PaymentSettingsEnabler is a helper to manage the payment feature enable / disable state.
+ * It enables / disables payment features based on NFC state, and ensures the summary of the
+ * preference is updated.
+ */
+public class PaymentSettingsEnabler extends BaseNfcEnabler {
+ private final Preference mPreference;
+
+ public PaymentSettingsEnabler(Context context, Preference preference) {
+ super(context);
+ mPreference = preference;
+ }
+
+ @Override
+ protected void handleNfcStateChanged(int newState) {
+ switch (newState) {
+ case NfcAdapter.STATE_OFF:
+ mPreference.setSummary(
+ R.string.nfc_and_payment_settings_payment_off_nfc_off_summary);
+ mPreference.setEnabled(false);
+ break;
+ case NfcAdapter.STATE_ON:
+ mPreference.setSummary(null);
+ mPreference.setEnabled(true);
+ break;
+ }
+ }
+}
diff --git a/src/com/android/settings/biometrics/OWNERS b/src/com/android/settings/biometrics/OWNERS
index 6332a46..021e89d 100644
--- a/src/com/android/settings/biometrics/OWNERS
+++ b/src/com/android/settings/biometrics/OWNERS
@@ -1,6 +1,7 @@
# Default reviewers for this and subdirectories.
+curtislb@google.com
jaggies@google.com
kchyn@google.com
yukl@google.com
-# Emergency approvers in case the above are not available
\ No newline at end of file
+# Emergency approvers in case the above are not available
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
index 749a38f..aa12409 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
@@ -109,7 +109,7 @@
profilePref.setChecked(profile.getConnectionStatus(device) ==
BluetoothProfile.STATE_CONNECTED);
} else {
- profilePref.setChecked(profile.isPreferred(device));
+ profilePref.setChecked(profile.isEnabled(device));
}
if (profile instanceof A2dpProfile) {
@@ -117,7 +117,7 @@
SwitchPreference highQualityPref = (SwitchPreference) mProfilesContainer.findPreference(
HIGH_QUALITY_AUDIO_PREF_TAG);
if (highQualityPref != null) {
- if (a2dp.isPreferred(device) && a2dp.supportsHighQualityAudio(device)) {
+ if (a2dp.isEnabled(device) && a2dp.supportsHighQualityAudio(device)) {
highQualityPref.setVisible(true);
highQualityPref.setTitle(a2dp.getHighQualityAudioOptionLabel(device));
highQualityPref.setChecked(a2dp.isHighQualityAudioEnabled(device));
@@ -142,8 +142,7 @@
if (profile instanceof MapProfile) {
bluetoothDevice.setMessageAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
}
- profile.setPreferred(bluetoothDevice, true);
- mCachedDevice.connectProfile(profile);
+ profile.setEnabled(bluetoothDevice, true);
}
/**
@@ -151,8 +150,7 @@
*/
private void disableProfile(LocalBluetoothProfile profile) {
final BluetoothDevice bluetoothDevice = mCachedDevice.getDevice();
- mCachedDevice.disconnect(profile);
- profile.setPreferred(bluetoothDevice, false);
+ profile.setEnabled(bluetoothDevice, false);
if (profile instanceof MapProfile) {
bluetoothDevice.setMessageAccessPermission(BluetoothDevice.ACCESS_REJECTED);
} else if (profile instanceof PbapServerProfile) {
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 4226720..86b72ec 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -60,10 +60,12 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef({SortType.TYPE_DEFAULT,
- SortType.TYPE_FIFO})
+ SortType.TYPE_FIFO,
+ SortType.TYPE_NO_SORT})
public @interface SortType {
int TYPE_DEFAULT = 1;
int TYPE_FIFO = 2;
+ int TYPE_NO_SORT = 3;
}
private final CachedBluetoothDevice mCachedDevice;
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index e2715d3..3778862 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -232,12 +232,21 @@
* Add the {@link Preference} that represents the {@code cachedDevice}
*/
protected void addPreference(CachedBluetoothDevice cachedDevice) {
+ addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+ }
+
+ /**
+ * Add the {@link Preference} with {@link BluetoothDevicePreference.SortType} that
+ * represents the {@code cachedDevice}
+ */
+ protected void addPreference(CachedBluetoothDevice cachedDevice,
+ @BluetoothDevicePreference.SortType int type) {
final BluetoothDevice device = cachedDevice.getDevice();
if (!mPreferenceMap.containsKey(device)) {
BluetoothDevicePreference btPreference =
new BluetoothDevicePreference(mPrefContext, cachedDevice,
true /* showDeviceWithoutNames */,
- BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+ type);
btPreference.setKey(getPreferenceKey());
btPreference.setOnGearClickListener(mDeviceProfilesListener);
if (this instanceof Preference.OnPreferenceClickListener) {
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index fdd7a1e..6893c25 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -15,6 +15,7 @@
*/
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.util.Log;
@@ -24,6 +25,7 @@
import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
/**
* Maintain and update saved bluetooth devices(bonded but not connected)
@@ -42,6 +44,26 @@
}
@Override
+ public void forceUpdate() {
+ if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
+ final CachedBluetoothDeviceManager cachedManager =
+ mLocalManager.getCachedDeviceManager();
+ for (BluetoothDevice device
+ : BluetoothAdapter.getDefaultAdapter().getMostRecentlyConnectedDevices()) {
+ final CachedBluetoothDevice cachedDevice = cachedManager.findDevice(device);
+ if (isFilterMatched(cachedDevice)) {
+ // Add the preference if it is new one
+ addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_NO_SORT);
+ } else {
+ removePreference(cachedDevice);
+ }
+ }
+ } else {
+ removeAllDevicesFromPreference();
+ }
+ }
+
+ @Override
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
if (DBG) {
diff --git a/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java b/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java
index 94ab5c2..23459d6 100644
--- a/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java
+++ b/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java
@@ -176,6 +176,9 @@
if (BugReportHandlerUtil.SHELL_APP_PACKAGE.equals(handlerApp)) {
return context.getString(R.string.system_default_app_subtext);
}
+ if (mUserManager.getUserProfiles().size() < 2) {
+ return "";
+ }
final UserInfo userInfo = mUserManager.getUserInfo(handlerUser);
if (userInfo != null && userInfo.isManagedProfile()) {
return context.getString(R.string.work_profile_app_subtext);
diff --git a/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java b/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java
new file mode 100644
index 0000000..4ebc0cd
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2020 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.connecteddevice;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.search.SearchIndexable;
+
+/**
+ * This fragment contains NFC and payment specific settings.
+ */
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class NfcAndPaymentFragment extends DashboardFragment {
+ private static final String TAG = "NfcAndPaymentFragment";
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.nfc_and_payment_settings;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.CONNECTION_DEVICE_ADVANCED_NFC;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_uri_nfc_and_payment_settings;
+ }
+
+ /**
+ * For Search.
+ */
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.nfc_and_payment_settings);
+}
diff --git a/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentController.java b/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentController.java
new file mode 100644
index 0000000..fef1922
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentController.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2020 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.connecteddevice;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.nfc.NfcAdapter;
+import android.os.UserManager;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * Controller that used to show NFC and payment features
+ */
+public class NfcAndPaymentFragmentController extends BasePreferenceController {
+ private final NfcAdapter mNfcAdapter;
+ private final PackageManager mPackageManager;
+ private final UserManager mUserManager;
+
+ public NfcAndPaymentFragmentController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+
+ mPackageManager = context.getPackageManager();
+ mUserManager = context.getSystemService(UserManager.class);
+ mNfcAdapter = NfcAdapter.getDefaultAdapter(context);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)
+ || !mPackageManager.hasSystemFeature(
+ PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ if (!mUserManager.isAdminUser()) {
+ return DISABLED_FOR_USER;
+ }
+ return AVAILABLE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (mNfcAdapter != null) {
+ if (mNfcAdapter.isEnabled()) {
+ return mContext.getText(R.string.switch_on_text);
+ } else {
+ return mContext.getText(R.string.switch_off_text);
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
index 489408d..d6bdb54 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
@@ -85,14 +85,14 @@
new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this);
final Resources resources = context.getResources();
- mEntryList = resources.getStringArray(R.array.game_driver_app_preference_values);
- mPreferenceTitle = resources.getString(R.string.game_driver_app_preference_title);
- mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
+ mEntryList = resources.getStringArray(R.array.graphics_driver_app_preference_values);
+ mPreferenceTitle = resources.getString(R.string.graphics_driver_app_preference_title);
+ mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
- resources.getString(R.string.game_driver_app_preference_game_driver);
+ resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferencePrereleaseDriver =
- resources.getString(R.string.game_driver_app_preference_prerelease_driver);
- mPreferenceSystem = resources.getString(R.string.game_driver_app_preference_system);
+ resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
+ mPreferenceSystem = resources.getString(R.string.graphics_driver_app_preference_system);
// TODO: Move this task to background if there's potential ANR/Jank.
// Update the UI when all the app infos are ready.
diff --git a/src/com/android/settings/development/gamedriver/GameDriverDashboard.java b/src/com/android/settings/development/gamedriver/GameDriverDashboard.java
index f67c029..4ef0a87 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverDashboard.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverDashboard.java
@@ -49,7 +49,7 @@
@Override
protected int getPreferenceScreenResId() {
- return R.xml.game_driver_settings;
+ return R.xml.graphics_driver_settings;
}
@Override
@@ -71,7 +71,7 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.game_driver_settings) {
+ new BaseSearchIndexProvider(R.xml.graphics_driver_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
diff --git a/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java b/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java
index 290e4b2..9c816c5 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java
@@ -64,11 +64,11 @@
mContentResolver = context.getContentResolver();
final Resources resources = context.getResources();
- mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
+ mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
- resources.getString(R.string.game_driver_app_preference_game_driver);
+ resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferencePrereleaseDriver =
- resources.getString(R.string.game_driver_app_preference_prerelease_driver);
+ resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
mGameDriverContentObserver =
new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this);
}
diff --git a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
index 0266689..99510a2 100644
--- a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
+++ b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
@@ -102,7 +102,7 @@
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
final String batteryLevel = Utils.getBatteryPercentage(intent);
final String batteryStatus = Utils.getBatteryStatus(
- mContext.getResources(), intent);
+ mContext, intent);
if (forceUpdate) {
mBatteryListener.onBatteryChanged(BatteryUpdateType.MANUAL);
} else if(!batteryLevel.equals(mBatteryLevel)) {
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index ab03b65..1935c35 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -133,7 +133,7 @@
remaining = context.getString(R.string.remaining_length_format,
Formatter.formatShortElapsedTime(context, remainingTimeUs / 1000));
}
- view.setBottomLabels(new CharSequence[] {timeString, remaining});
+ view.setBottomLabels(new CharSequence[]{timeString, remaining});
}
public static void getBatteryInfo(final Context context, final Callback callback) {
@@ -232,9 +232,8 @@
info.batteryPercentString = Utils.formatPercentage(info.batteryLevel);
info.mCharging = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
info.averageTimeToDischarge = estimate.getAverageDischargeTime();
- final Resources resources = context.getResources();
- info.statusLabel = Utils.getBatteryStatus(resources, batteryBroadcast);
+ info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
if (!info.mCharging) {
updateBatteryInfoDischarging(context, shortString, estimate, info);
} else {
@@ -261,12 +260,11 @@
R.string.power_remaining_charging_duration_only, timeString);
info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
} else {
- final String chargeStatusLabel = resources.getString(
- R.string.battery_info_status_charging_lower);
+ final String chargeStatusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
info.remainingLabel = null;
info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
resources.getString(R.string.power_charging, info.batteryPercentString,
- chargeStatusLabel);
+ chargeStatusLabel.toLowerCase());
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
index c4765c3..3c88eb2 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
@@ -162,11 +162,10 @@
@VisibleForTesting
boolean isAvailable(Context context) {
- // checking dark theme mode.
- if (isDarkThemeMode(context)) {
+ // check if dark theme mode is enabled or if dark theme scheduling is on.
+ if (isDarkThemeMode(context) || isNightModeScheduled()) {
return false;
}
-
// checking the current battery level
final BatteryManager batteryManager = context.getSystemService(BatteryManager.class);
final int level = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
@@ -186,6 +185,18 @@
sSliceClicked = clicked;
}
+ private boolean isNightModeScheduled() {
+ final int mode = mUiModeManager.getNightMode();
+ if (DEBUG) {
+ Log.d(TAG, "night mode : " + mode);
+ }
+ // Turn on from sunset to sunrise or turn on at custom time
+ if (mode == UiModeManager.MODE_NIGHT_AUTO || mode == UiModeManager.MODE_NIGHT_CUSTOM) {
+ return true;
+ }
+ return false;
+ }
+
public static class DarkThemeWorker extends SliceBackgroundWorker<Void> {
private final Context mContext;
private final ContentObserver mContentObserver =
diff --git a/src/com/android/settings/network/BluetoothTetherPreferenceController.java b/src/com/android/settings/network/BluetoothTetherPreferenceController.java
index 327b6ac..d41c5af 100644
--- a/src/com/android/settings/network/BluetoothTetherPreferenceController.java
+++ b/src/com/android/settings/network/BluetoothTetherPreferenceController.java
@@ -33,34 +33,29 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
import com.google.common.annotations.VisibleForTesting;
/**
* This controller helps to manage the switch state and visibility of bluetooth tether switch
* preference. It stores preference value when preference changed.
- * TODO(b/147272749): Extend BasePreferenceController.java instead.
*/
-public final class BluetoothTetherPreferenceController extends AbstractPreferenceController
+public final class BluetoothTetherPreferenceController extends BasePreferenceController
implements LifecycleObserver, Preference.OnPreferenceChangeListener {
private static final String TAG = "BluetoothTetherPreferenceController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- public static final String PREF_KEY = "enable_bluetooth_tethering";
private final ConnectivityManager mCm;
private int mBluetoothState;
private Preference mPreference;
private final SharedPreferences mSharedPreferences;
- public BluetoothTetherPreferenceController(Context context, Lifecycle lifecycle) {
- super(context);
+ public BluetoothTetherPreferenceController(Context context, String prefKey) {
+ super(context, prefKey);
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mSharedPreferences =
context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
@@ -76,18 +71,12 @@
}
@Override
- public boolean isAvailable() {
- final String[] bluetoothRegexs = mCm.getTetherableBluetoothRegexs();
- return bluetoothRegexs != null && bluetoothRegexs.length > 0;
- }
-
- @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = screen.findPreference(PREF_KEY);
+ mPreference = screen.findPreference(mPreferenceKey);
if (mPreference != null && mPreference instanceof SwitchPreference) {
((SwitchPreference) mPreference)
- .setChecked(mSharedPreferences.getBoolean(PREF_KEY, false));
+ .setChecked(mSharedPreferences.getBoolean(mPreferenceKey, false));
}
}
@@ -110,8 +99,13 @@
}
@Override
- public String getPreferenceKey() {
- return PREF_KEY;
+ public int getAvailabilityStatus() {
+ final String[] bluetoothRegexs = mCm.getTetherableBluetoothRegexs();
+ if (bluetoothRegexs == null || bluetoothRegexs.length == 0) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
}
@VisibleForTesting
@@ -133,7 +127,7 @@
Log.d(TAG, "preference changing to " + o);
}
final SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(PREF_KEY, (Boolean) o);
+ editor.putBoolean(mPreferenceKey, (Boolean) o);
editor.apply();
return true;
}
diff --git a/src/com/android/settings/network/TetherEnabler.java b/src/com/android/settings/network/TetherEnabler.java
index e2b4c68..2ea3c04 100644
--- a/src/com/android/settings/network/TetherEnabler.java
+++ b/src/com/android/settings/network/TetherEnabler.java
@@ -61,13 +61,14 @@
public static final String SHARED_PREF = "tether_options";
+ // This KEY is used for a shared preference value, not for any displayed preferences.
+ public static final String KEY_ENABLE_WIFI_TETHERING = "enable_wifi_tethering";
@VisibleForTesting
- static final String WIFI_TETHER_KEY =
- WifiTetherDisablePreferenceController.KEY_ENABLE_WIFI_TETHERING;
+ static final String WIFI_TETHER_DISABLE_KEY = "disable_wifi_tethering";
@VisibleForTesting
- static final String USB_TETHER_KEY = UsbTetherPreferenceController.PREF_KEY;
+ static final String USB_TETHER_KEY = "enable_usb_tethering";
@VisibleForTesting
- static final String BLUETOOTH_TETHER_KEY = BluetoothTetherPreferenceController.PREF_KEY;
+ static final String BLUETOOTH_TETHER_KEY = "enable_bluetooth_tethering";
private final SwitchWidgetController mSwitchWidgetController;
private final WifiManager mWifiManager;
@@ -176,7 +177,7 @@
private void stopTether() {
// Wi-Fi tether is selected by default.
- if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
+ if (mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true)) {
stopTethering(TETHERING_WIFI);
}
@@ -202,7 +203,7 @@
void startTether() {
// Wi-Fi tether is selected by default.
- if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
+ if (mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true)) {
startTethering(TETHERING_WIFI);
}
@@ -328,7 +329,7 @@
if (!mSwitchWidgetController.isChecked()) {
return;
}
- if (TextUtils.equals(WIFI_TETHER_KEY, key)) {
+ if (TextUtils.equals(KEY_ENABLE_WIFI_TETHERING, key)) {
if (sharedPreferences.getBoolean(key, true)) {
startTethering(TETHERING_WIFI);
} else {
diff --git a/src/com/android/settings/network/UsbTetherPreferenceController.java b/src/com/android/settings/network/UsbTetherPreferenceController.java
index 5722480..c1d3be2 100644
--- a/src/com/android/settings/network/UsbTetherPreferenceController.java
+++ b/src/com/android/settings/network/UsbTetherPreferenceController.java
@@ -36,20 +36,18 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.Utils;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
/**
* This controller helps to manage the switch state and visibility of USB tether switch
* preference. It stores preference values when preference changed.
- * TODO(b/147272749): Extend BasePreferenceController.java instead.
*
*/
-public final class UsbTetherPreferenceController extends AbstractPreferenceController implements
+public final class UsbTetherPreferenceController extends BasePreferenceController implements
LifecycleObserver, Preference.OnPreferenceChangeListener {
private static final String TAG = "UsbTetherPrefController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- public static final String PREF_KEY = "enable_usb_tethering";
private final ConnectivityManager mCm;
private boolean mUsbConnected;
@@ -57,14 +55,11 @@
private Preference mPreference;
private final SharedPreferences mSharedPreferences;
- public UsbTetherPreferenceController(Context context, Lifecycle lifecycle) {
- super(context);
+ public UsbTetherPreferenceController(Context context, String prefKey) {
+ super(context, prefKey);
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mSharedPreferences =
context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
@@ -82,23 +77,22 @@
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
String[] usbRegexs = mCm.getTetherableUsbRegexs();
- return usbRegexs != null && usbRegexs.length > 0 && !Utils.isMonkeyRunning();
- }
-
- @Override
- public String getPreferenceKey() {
- return PREF_KEY;
+ if (usbRegexs == null || usbRegexs.length == 0 || Utils.isMonkeyRunning()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = screen.findPreference(PREF_KEY);
+ mPreference = screen.findPreference(mPreferenceKey);
if (mPreference != null && mPreference instanceof SwitchPreference) {
((SwitchPreference) mPreference)
- .setChecked(mSharedPreferences.getBoolean(PREF_KEY, false));
+ .setChecked(mSharedPreferences.getBoolean(mPreferenceKey, false));
}
}
@@ -136,7 +130,7 @@
Log.d(TAG, "preference changing to " + o);
}
final SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(PREF_KEY, (Boolean) o);
+ editor.putBoolean(mPreferenceKey, (Boolean) o);
editor.apply();
return true;
}
diff --git a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
index 99fcfcd..ddc2bf7 100644
--- a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
+++ b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
@@ -30,7 +30,7 @@
import androidx.preference.SwitchPreference;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
/**
* This controller helps to manage the switch state and visibility of wifi tether disable switch
@@ -40,19 +40,13 @@
*
* @see BluetoothTetherPreferenceController
* @see UsbTetherPreferenceController
- * TODO(b/147272749): Extend BasePreferenceController.java instead.
- *
*/
-public final class WifiTetherDisablePreferenceController extends AbstractPreferenceController
+public final class WifiTetherDisablePreferenceController extends BasePreferenceController
implements LifecycleObserver, Preference.OnPreferenceChangeListener,
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "WifiTetherDisablePreferenceController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- public static final String PREF_KEY = "disable_wifi_tethering";
-
- // This KEY is used for a shared preference value, not for any displayed preferences.
- public static final String KEY_ENABLE_WIFI_TETHERING = "enable_wifi_tethering";
private final ConnectivityManager mCm;
private boolean mBluetoothTetherEnabled;
@@ -61,8 +55,8 @@
private Preference mPreference;
private final SharedPreferences mSharedPreferences;
- public WifiTetherDisablePreferenceController(Context context, Lifecycle lifecycle) {
- super(context);
+ public WifiTetherDisablePreferenceController(Context context, String prefKey) {
+ super(context, prefKey);
mSharedPreferences =
context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -70,9 +64,6 @@
TetherEnabler.USB_TETHER_KEY, false);
mBluetoothTetherEnabled = mSharedPreferences.getBoolean(
TetherEnabler.BLUETOOTH_TETHER_KEY, false);
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@@ -85,20 +76,19 @@
mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
}
- @Override
- public boolean isAvailable() {
- final String[] wifiRegexs = mCm.getTetherableWifiRegexs();
- return wifiRegexs != null && wifiRegexs.length > 0 && shouldShow();
- }
-
@VisibleForTesting
boolean shouldShow() {
return mBluetoothTetherEnabled || mUSBTetherEnabled;
}
@Override
- public String getPreferenceKey() {
- return PREF_KEY;
+ public int getAvailabilityStatus() {
+ final String[] wifiRegexs = mCm.getTetherableWifiRegexs();
+ if (wifiRegexs == null || wifiRegexs.length == 0 || !shouldShow()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
}
@Override
@@ -111,10 +101,11 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mScreen = screen;
- mPreference = screen.findPreference(PREF_KEY);
+ mPreference = screen.findPreference(mPreferenceKey);
if (mPreference != null && mPreference instanceof SwitchPreference) {
((SwitchPreference) mPreference)
- .setChecked(!mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true));
+ .setChecked(!mSharedPreferences.getBoolean(
+ TetherEnabler.KEY_ENABLE_WIFI_TETHERING, true));
mPreference.setOnPreferenceChangeListener(this);
}
updateState(mPreference);
@@ -123,7 +114,7 @@
@Override
public void updateState(Preference preference) {
super.updateState(preference);
- setVisible(mScreen, PREF_KEY, shouldShow());
+ setVisible(mScreen, mPreferenceKey, shouldShow());
}
@Override
@@ -162,7 +153,7 @@
Log.d(TAG, "check state changing to " + o);
}
final SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(KEY_ENABLE_WIFI_TETHERING, enableWifi);
+ editor.putBoolean(TetherEnabler.KEY_ENABLE_WIFI_TETHERING, enableWifi);
editor.apply();
return true;
}
diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java
index 83d6578..5519ddd 100644
--- a/src/com/android/settings/network/ims/ImsQueryController.java
+++ b/src/com/android/settings/network/ims/ImsQueryController.java
@@ -16,6 +16,10 @@
package com.android.settings.network.ims;
+import android.telephony.AccessNetworkConstants;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
+
import androidx.annotation.VisibleForTesting;
/**
@@ -23,8 +27,38 @@
*/
abstract class ImsQueryController {
+ private volatile int mCapability;
+ private volatile int mTech;
+ private volatile int mTransportType;
+
+ /**
+ * Constructor for query IMS status
+ */
+ ImsQueryController() {}
+
+ /**
+ * Constructor for query IMS status
+ *
+ * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+ * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
+ * @param transportType {@link AccessNetworkConstants#TransportType}
+ */
+ ImsQueryController(
+ @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
+ @ImsRegistrationImplBase.ImsRegistrationTech int tech,
+ @AccessNetworkConstants.TransportType int transportType) {
+ mCapability = capability;
+ mTech = tech;
+ mTransportType = transportType;
+ }
+
@VisibleForTesting
ImsQuery isTtyOnVolteEnabled(int subId) {
return new ImsQueryTtyOnVolteStat(subId);
}
+
+ @VisibleForTesting
+ ImsQuery isProvisionedOnDevice(int subId) {
+ return new ImsQueryProvisioningStat(subId, mCapability, mTech);
+ }
}
diff --git a/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java b/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java
new file mode 100644
index 0000000..c00f1df
--- /dev/null
+++ b/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 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.network.ims;
+
+import android.telephony.ims.ImsMmTelManager;
+
+
+/**
+ * An {@link ImsQuery} for accessing IMS user setting for enhanced 4G LTE
+ */
+public class ImsQueryEnhanced4gLteModeUserSetting implements ImsQuery {
+
+ /**
+ * Constructor
+ * @param subId subscription id
+ */
+ public ImsQueryEnhanced4gLteModeUserSetting(int subId) {
+ mSubId = subId;
+ }
+
+ private volatile int mSubId;
+
+ /**
+ * Implementation of interface {@link ImsQuery#query()}
+ *
+ * @return result of query
+ */
+ public boolean query() {
+ final ImsMmTelManager imsMmTelManager =
+ ImsMmTelManager.createForSubscriptionId(mSubId);
+ return imsMmTelManager.isAdvancedCallingSettingEnabled();
+ }
+}
diff --git a/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
new file mode 100644
index 0000000..34f232d
--- /dev/null
+++ b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2020 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.network.ims;
+
+import android.telephony.ims.ProvisioningManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
+
+
+/**
+ * An {@link ImsQuery} for accessing IMS provision stat
+ */
+public class ImsQueryProvisioningStat implements ImsQuery {
+
+ private volatile int mSubId;
+ private volatile int mCapability;
+ private volatile int mTech;
+
+ /**
+ * Constructor
+ * @param subId subscription id
+ * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+ * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
+ */
+ public ImsQueryProvisioningStat(int subId,
+ @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
+ @ImsRegistrationImplBase.ImsRegistrationTech int tech) {
+ mSubId = subId;
+ mCapability = capability;
+ mTech = tech;
+ }
+
+ /**
+ * Implementation of interface {@link ImsQuery}
+ *
+ * @return result of query
+ */
+ public boolean query() {
+ final ProvisioningManager privisionManager =
+ ProvisioningManager.createForSubscriptionId(mSubId);
+ return privisionManager.getProvisioningStatusForCapability(mCapability, mTech);
+ }
+}
diff --git a/src/com/android/settings/network/ims/VolteQueryImsState.java b/src/com/android/settings/network/ims/VolteQueryImsState.java
index 320aa26..608768a 100644
--- a/src/com/android/settings/network/ims/VolteQueryImsState.java
+++ b/src/com/android/settings/network/ims/VolteQueryImsState.java
@@ -18,13 +18,16 @@
import android.content.Context;
import android.telecom.TelecomManager;
+import android.telephony.AccessNetworkConstants;
import android.telephony.SubscriptionManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.annotation.VisibleForTesting;
import com.android.ims.ImsManager;
import com.android.settings.network.SubscriptionUtil;
-
+import com.android.settings.network.telephony.MobileNetworkUtils;
/**
* Controller class for querying Volte status
@@ -41,11 +44,53 @@
* @param subId subscription's id
*/
public VolteQueryImsState(Context context, int subId) {
+ super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
+ ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
+ AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
mContext = context;
mSubId = subId;
}
/**
+ * Implementation of ImsQueryController#isEnabledByUser(int subId)
+ */
+ @VisibleForTesting
+ ImsQuery isEnabledByUser(int subId) {
+ return new ImsQueryEnhanced4gLteModeUserSetting(subId);
+ }
+
+ @VisibleForTesting
+ ImsManager getImsManager(int subId) {
+ return ImsManager.getInstance(mContext,
+ SubscriptionUtil.getPhoneId(mContext, subId));
+ }
+
+ /**
+ * Check whether VoLTE has been provisioned or not on this subscription
+ *
+ * @return true when VoLTE has been enabled, otherwise false
+ */
+ public boolean isVoLteProvisioned() {
+ final ImsManager imsManager = getImsManager(mSubId);
+ if (imsManager == null) {
+ return false;
+ }
+
+ return imsManager.isVolteEnabledByPlatform()
+ && isProvisionedOnDevice(mSubId).query();
+ }
+
+ /**
+ * Check whether VoLTE can be perform or not on this subscription
+ *
+ * @return true when VoLTE can be performed, otherwise false
+ */
+ public boolean isReadyToVoLte() {
+ return isVoLteProvisioned()
+ && MobileNetworkUtils.isImsServiceStateReady(getImsManager(mSubId));
+ }
+
+ /**
* Get allowance status for user to alter configuration
*
* @return true when changing configuration by user is allowed.
@@ -74,8 +119,6 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
- mContext, mSubId));
- return imsManager.isEnhanced4gLteModeSettingEnabledByUser();
+ return isEnabledByUser(mSubId).query();
}
}
diff --git a/src/com/android/settings/network/ims/VtQueryImsState.java b/src/com/android/settings/network/ims/VtQueryImsState.java
index 5ac07a3..a9003b1 100644
--- a/src/com/android/settings/network/ims/VtQueryImsState.java
+++ b/src/com/android/settings/network/ims/VtQueryImsState.java
@@ -18,10 +18,17 @@
import android.content.Context;
import android.telecom.TelecomManager;
+import android.telephony.AccessNetworkConstants;
import android.telephony.SubscriptionManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.annotation.VisibleForTesting;
+import com.android.ims.ImsManager;
+import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.telephony.MobileNetworkUtils;
+
/**
* Controller class for querying VT status
*/
@@ -37,6 +44,9 @@
* @param subId subscription's id
*/
public VtQueryImsState(Context context, int subId) {
+ super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
+ ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
+ AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
mContext = context;
mSubId = subId;
}
@@ -49,6 +59,28 @@
return new ImsQueryVtUserSetting(subId);
}
+ @VisibleForTesting
+ ImsManager getImsManager(int subId) {
+ return ImsManager.getInstance(mContext,
+ SubscriptionUtil.getPhoneId(mContext, subId));
+ }
+
+ /**
+ * Check whether Video Call can be perform or not on this subscription
+ *
+ * @return true when Video Call can be performed, otherwise false
+ */
+ public boolean isReadyToVideoCall() {
+ final ImsManager imsManager = getImsManager(mSubId);
+ if (imsManager == null) {
+ return false;
+ }
+
+ return imsManager.isVtEnabledByPlatform()
+ && isProvisionedOnDevice(mSubId).query()
+ && MobileNetworkUtils.isImsServiceStateReady(imsManager);
+ }
+
/**
* Get allowance status for user to alter configuration
*
diff --git a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
index e1b3bbf..d6703d1 100644
--- a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
+++ b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
@@ -37,6 +37,7 @@
* @param subId subscription's id
*/
public WifiCallingQueryImsState(Context context, int subId) {
+ super();
mContext = context;
mSubId = subId;
}
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index 123e100..efbbbf8 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -23,9 +23,6 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -33,8 +30,6 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.ims.ImsManager;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
@@ -55,8 +50,6 @@
Preference mPreference;
private CarrierConfigManager mCarrierConfigManager;
private PersistableBundle mCarrierConfig;
- @VisibleForTesting
- ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
@VisibleForTesting
Integer mCallState;
@@ -81,10 +74,6 @@
}
mSubId = subId;
mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
- if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
- mImsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
- mContext, mSubId));
- }
final boolean show4GForLTE = mCarrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
@@ -96,29 +85,26 @@
return this;
}
- @VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
@Override
public int getAvailabilityStatus(int subId) {
init(subId);
if (!isModeMatched()) {
return CONDITIONALLY_UNAVAILABLE;
}
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ if ((carrierConfig == null)
+ || carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
final VolteQueryImsState queryState = queryImsState(subId);
- final boolean isVisible = SubscriptionManager.isValidSubscriptionId(subId)
- && mImsManager != null && carrierConfig != null
- && mImsManager.isVolteEnabledByPlatform()
- && isVolteProvisionedOnDevice(mSubId)
- && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
- && !carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL);
- return isVisible
- ? (isUserControlAllowed() && queryState.isAllowUserControl()
- ? AVAILABLE : AVAILABLE_UNSEARCHABLE)
- : CONDITIONALLY_UNAVAILABLE;
+ if (!queryState.isReadyToVoLte()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ return (isUserControlAllowed() && queryState.isAllowUserControl())
+ ? AVAILABLE : AVAILABLE_UNSEARCHABLE;
}
@Override
@@ -200,19 +186,6 @@
CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL);
}
- private boolean isVolteProvisionedOnDevice(int subId) {
- if (!SubscriptionManager.isValidSubscriptionId(subId)) {
- return true;
- }
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
private class PhoneCallStateListener extends PhoneStateListener {
PhoneCallStateListener() {
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index 3cad316..31e8239 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -28,9 +28,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -40,10 +37,8 @@
import androidx.slice.builders.ListBuilder.RowBuilder;
import androidx.slice.builders.SliceAction;
-import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBroadcastReceiver;
@@ -112,14 +107,6 @@
return null;
}
- final ImsManager imsManager = getImsManager(subId);
-
- if (!imsManager.isVolteEnabledByPlatform()
- || !isVolteProvisionedOnDevice(subId)) {
- Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
- return null;
- }
-
if (isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL, subId, false)
|| !isCarrierConfigManagerKeyEnabled(
@@ -130,6 +117,11 @@
}
final VolteQueryImsState queryState = queryImsState(subId);
+ if (!queryState.isVoLteProvisioned()) {
+ Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
+ return null;
+ }
+
try {
return getEnhanced4gLteSlice(sliceUri,
queryState.isEnabledByUser(), subId);
@@ -164,15 +156,6 @@
.build();
}
- protected ImsManager getImsManager(int subId) {
- return ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId));
- }
-
- @VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
/**
* Handles Enhanced 4G LTE mode setting change from Enhanced 4G LTE slice and posts
* notification. Should be called when intent action is ACTION_ENHANCED_4G_LTE_CHANGED
@@ -183,9 +166,8 @@
final int subId = getDefaultVoiceSubId();
if (SubscriptionManager.isValidSubscriptionId(subId)) {
- final ImsManager imsManager = getImsManager(subId);
- if (imsManager.isVolteEnabledByPlatform() && isVolteProvisionedOnDevice(subId)) {
- final VolteQueryImsState queryState = queryImsState(subId);
+ final VolteQueryImsState queryState = queryImsState(subId);
+ if (queryState.isVoLteProvisioned()) {
final boolean currentValue = queryState.isEnabledByUser()
&& queryState.isAllowUserControl();
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
@@ -285,16 +267,6 @@
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
}
- private boolean isVolteProvisionedOnDevice(int subId) {
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
@VisibleForTesting
VolteQueryImsState queryImsState(int subId) {
return new VolteQueryImsState(mContext, subId);
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index e0ecccc..cdfbff8 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -85,6 +85,8 @@
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + mSubId,
newPreferredNetworkMode);
+ final ListPreference listPreference = (ListPreference) preference;
+ listPreference.setSummary(getPreferredNetworkModeSummaryResId(newPreferredNetworkMode));
return true;
}
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index fa5deab..ab8327c 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -48,8 +48,6 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.DeviceInfoUtils;
-import java.util.List;
-
/**
* A dialog allowing the display name of a mobile network subscription to be changed
*/
@@ -117,9 +115,9 @@
.setPositiveButton(R.string.mobile_network_sim_name_rename, (dialog, which) -> {
mSubscriptionManager.setDisplayName(mNameView.getText().toString(), mSubId,
SubscriptionManager.NAME_SOURCE_USER_INPUT);
- final Color color = (mColorSpinner == null) ? mColors[0]
- : mColors[mColorSpinner.getSelectedItemPosition()];
- mSubscriptionManager.setIconTint(color.getColor(), mSubId);
+ mSubscriptionManager.setIconTint(
+ mColors[mColorSpinner.getSelectedItemPosition()].getColor(),
+ mSubId);
})
.setNegativeButton(android.R.string.cancel, null);
return builder.create();
@@ -128,17 +126,7 @@
@VisibleForTesting
protected void populateView(View view) {
mNameView = view.findViewById(R.id.name_edittext);
- SubscriptionInfo info = null;
- final List<SubscriptionInfo> infoList = mSubscriptionManager
- .getAvailableSubscriptionInfoList();
- if (infoList != null) {
- for (SubscriptionInfo subInfo : infoList) {
- if (subInfo.getSubscriptionId() == mSubId) {
- info = subInfo;
- break;
- }
- }
- }
+ final SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
if (info == null) {
Log.w(TAG, "got null SubscriptionInfo for mSubId:" + mSubId);
return;
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index 6fba161..eed4046 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -23,9 +23,6 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -33,9 +30,7 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.ims.ImsManager;
import com.android.settings.network.MobileDataEnabledListener;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settings.network.ims.VtQueryImsState;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -54,8 +49,6 @@
private Preference mPreference;
private CarrierConfigManager mCarrierConfigManager;
- @VisibleForTesting
- ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
@VisibleForTesting
Integer mCallState;
@@ -101,7 +94,7 @@
return;
}
final SwitchPreference switchPreference = (SwitchPreference) preference;
- final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
+ final boolean videoCallEnabled = isVideoCallEnabled(mSubId);
switchPreference.setVisible(videoCallEnabled);
if (videoCallEnabled) {
final boolean videoCallEditable = queryVoLteState(mSubId).isEnabledByUser()
@@ -138,53 +131,29 @@
public VideoCallingPreferenceController init(int subId) {
mSubId = subId;
- if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
- mImsManager = ImsManager.getInstance(mContext,
- SubscriptionUtil.getPhoneId(mContext, mSubId));
- }
return this;
}
- private boolean isVideoCallEnabled(int subId) {
- final ImsManager imsManager = SubscriptionManager.isValidSubscriptionId(subId)
- ? ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId))
- : null;
- return isVideoCallEnabled(subId, imsManager);
- }
-
@VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
- private boolean isVtProvisionedOnDevice(int subId) {
- if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- return true;
+ boolean isVideoCallEnabled(int subId) {
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ return false;
}
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
- @VisibleForTesting
- boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
- TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
- if (SubscriptionManager.isValidSubscriptionId(subId)) {
- telephonyManager = telephonyManager.createForSubscriptionId(subId);
+ if (carrierConfig == null) {
+ return false;
}
- return carrierConfig != null && imsManager != null
- && imsManager.isVtEnabledByPlatform()
- && isVtProvisionedOnDevice(subId)
- && MobileNetworkUtils.isImsServiceStateReady(imsManager)
- && (carrierConfig.getBoolean(
+
+ if (!carrierConfig.getBoolean(
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
- || telephonyManager.isDataEnabled());
+ && (!mContext.getSystemService(TelephonyManager.class)
+ .createForSubscriptionId(subId).isDataEnabled())) {
+ return false;
+ }
+
+ return queryImsState(subId).isReadyToVideoCall();
}
@Override
diff --git a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
deleted file mode 100644
index 503b5bc..0000000
--- a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
+++ /dev/null
@@ -1,144 +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 static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.Utils;
-import com.android.settings.core.TogglePreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
-
-public class VibrateWhenRingPreferenceController extends TogglePreferenceController
- implements LifecycleObserver, OnResume, OnPause {
-
- /** Flag for whether or not to apply ramping ringer on incoming phone calls. */
- private static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
- private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
- private final int DEFAULT_VALUE = 0;
- private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
- private SettingObserver mSettingObserver;
-
- public VibrateWhenRingPreferenceController(Context context, String key) {
- super(context, key);
- }
-
- @Override
- public boolean isChecked() {
- return Settings.System.getInt(mContext.getContentResolver(),
- VIBRATE_WHEN_RINGING, DEFAULT_VALUE) != DEFAULT_VALUE;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- return Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
- isChecked ? NOTIFICATION_VIBRATE_WHEN_RINGING : DEFAULT_VALUE);
- }
-
- @Override
- @AvailabilityStatus
- public int getAvailabilityStatus() {
- // If ramping ringer is enabled then this setting will be injected
- // with additional options.
- return Utils.isVoiceCapable(mContext) && !isRampingRingerEnabled()
- ? AVAILABLE
- : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- public boolean isSliceable() {
- return TextUtils.equals(getPreferenceKey(), "vibrate_when_ringing");
- }
-
- @Override
- public boolean isPublicSlice() {
- return true;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- Preference preference = screen.findPreference(KEY_VIBRATE_WHEN_RINGING);
- if (preference != null) {
- mSettingObserver = new SettingObserver(preference);
- preference.setPersistent(false);
- }
- }
-
- @Override
- public void onResume() {
- if (mSettingObserver != null) {
- mSettingObserver.register(true /* register */);
- }
- }
-
- @Override
- public void onPause() {
- if (mSettingObserver != null) {
- mSettingObserver.register(false /* register */);
- }
- }
-
- private final class SettingObserver extends ContentObserver {
-
- private final Uri VIBRATE_WHEN_RINGING_URI =
- Settings.System.getUriFor(VIBRATE_WHEN_RINGING);
-
- private final Preference mPreference;
-
- public SettingObserver(Preference preference) {
- super(new Handler());
- mPreference = preference;
- }
-
- public void register(boolean register) {
- final ContentResolver cr = mContext.getContentResolver();
- if (register) {
- cr.registerContentObserver(VIBRATE_WHEN_RINGING_URI, false, this);
- } else {
- cr.unregisterContentObserver(this);
- }
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- super.onChange(selfChange, uri);
- if (VIBRATE_WHEN_RINGING_URI.equals(uri)) {
- updateState(mPreference);
- }
- }
- }
-
- private boolean isRampingRingerEnabled() {
- return DeviceConfig.getBoolean(
- DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
- }
-
-}
diff --git a/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java
deleted file mode 100644
index 309cd42..0000000
--- a/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2020 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.zen;
-
-import android.app.Application;
-import android.app.NotificationChannel;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.core.text.BidiFormatter;
-import androidx.fragment.app.Fragment;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
-import com.android.settings.applications.AppInfoBase;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.ChannelNotificationSettings;
-import com.android.settingslib.applications.ApplicationsState;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.widget.apppreference.AppPreference;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Adds a preference to the PreferenceScreen for each conversation notification channel that can
- * bypass DND.
- */
-public class ZenModeAllBypassingConversationsPreferenceController extends
- AbstractPreferenceController implements PreferenceControllerMixin {
-
- private final String KEY = "zen_mode_settings_category_conversations";
-
- @VisibleForTesting ApplicationsState mApplicationsState;
- @VisibleForTesting PreferenceCategory mCategory;
- @VisibleForTesting Context mPrefContext;
-
- private ApplicationsState.Session mAppSession;
- private NotificationBackend mNotificationBackend = new NotificationBackend();
- private Fragment mHostFragment;
-
- public ZenModeAllBypassingConversationsPreferenceController(Context context, Application app,
- Fragment host) {
-
- this(context, app == null ? null : ApplicationsState.getInstance(app), host);
- }
-
- private ZenModeAllBypassingConversationsPreferenceController(Context context,
- ApplicationsState appState, Fragment host) {
- super(context);
- mApplicationsState = appState;
- mHostFragment = host;
-
- if (mApplicationsState != null && host != null) {
- mAppSession = mApplicationsState.newSession(mAppSessionCallbacks, host.getLifecycle());
- }
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- mCategory = screen.findPreference(KEY);
- mPrefContext = screen.getContext();
- updateNotificationChannelList();
- super.displayPreference(screen);
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY;
- }
-
- /**
- * Call this method to trigger the notification channels list to refresh.
- */
- public void updateNotificationChannelList() {
- if (mAppSession == null) {
- return;
- }
-
- ApplicationsState.AppFilter filter = ApplicationsState.FILTER_ALL_ENABLED;
- List<ApplicationsState.AppEntry> apps = mAppSession.rebuild(filter,
- ApplicationsState.ALPHA_COMPARATOR);
- if (apps != null) {
- updateNotificationChannelList(apps);
- }
- }
-
- @VisibleForTesting
- void updateNotificationChannelList(List<ApplicationsState.AppEntry> apps) {
- if (mCategory == null || apps == null) {
- return;
- }
-
- List<Preference> channelsBypassingDnd = new ArrayList<>();
- for (ApplicationsState.AppEntry entry : apps) {
- String pkg = entry.info.packageName;
- mApplicationsState.ensureIcon(entry);
- for (NotificationChannel channel : mNotificationBackend
- .getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList()) {
- if (TextUtils.isEmpty(channel.getConversationId())) {
- // only conversation channels
- continue;
- }
- Preference pref = new AppPreference(mPrefContext);
- pref.setKey(pkg + "|" + channel.getId());
- pref.setTitle(BidiFormatter.getInstance().unicodeWrap(entry.label));
- // TODO: use badged shortcut icon instead of app icon
- pref.setIcon(entry.icon);
- pref.setSummary(BidiFormatter.getInstance().unicodeWrap(channel.getName()));
-
- pref.setOnPreferenceClickListener(preference -> {
- Bundle args = new Bundle();
- args.putString(AppInfoBase.ARG_PACKAGE_NAME, entry.info.packageName);
- args.putInt(AppInfoBase.ARG_PACKAGE_UID, entry.info.uid);
- args.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
- new SubSettingLauncher(mContext)
- .setDestination(ChannelNotificationSettings.class.getName())
- .setArguments(args)
- .setTitleRes(R.string.notification_channel_title)
- .setResultListener(mHostFragment, 0)
- .setSourceMetricsCategory(
- SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP)
- .launch();
- return true;
- });
- channelsBypassingDnd.add(pref);
- }
-
- mCategory.removeAll();
- if (channelsBypassingDnd.size() > 0) {
- mCategory.setVisible(true);
- for (Preference prefToAdd : channelsBypassingDnd) {
- mCategory.addPreference(prefToAdd);
- }
- } else {
- mCategory.setVisible(false);
- }
- }
- }
-
- private final ApplicationsState.Callbacks mAppSessionCallbacks =
- new ApplicationsState.Callbacks() {
-
- @Override
- public void onRunningStateChanged(boolean running) {
- updateNotificationChannelList();
- }
-
- @Override
- public void onPackageListChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onRebuildComplete(ArrayList<ApplicationsState.AppEntry> apps) {
- updateNotificationChannelList(apps);
- }
-
- @Override
- public void onPackageIconChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onPackageSizeChanged(String packageName) {
- updateNotificationChannelList();
- }
-
- @Override
- public void onAllSizesComputed() { }
-
- @Override
- public void onLauncherInfoChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onLoadEntriesCompleted() {
- // Add shortcut info
- updateNotificationChannelList();
- }
- };
-}
diff --git a/src/com/android/settings/notification/zen/ZenModeBackend.java b/src/com/android/settings/notification/zen/ZenModeBackend.java
index ac49466..836f435 100644
--- a/src/com/android/settings/notification/zen/ZenModeBackend.java
+++ b/src/com/android/settings/notification/zen/ZenModeBackend.java
@@ -16,8 +16,12 @@
package com.android.settings.notification.zen;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_NONE;
import android.app.ActivityManager;
import android.app.AutomaticZenRule;
@@ -147,25 +151,35 @@
return SOURCE_NONE;
}
+ protected int getPriorityConversationSenders() {
+ if (isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)) {
+ return mPolicy.priorityConversationSenders;
+ }
+ return CONVERSATION_SENDERS_NONE;
+ }
+
protected void saveVisualEffectsPolicy(int category, boolean suppress) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
int suppressedEffects = getNewSuppressedEffects(suppress, category);
savePolicy(mPolicy.priorityCategories, mPolicy.priorityCallSenders,
- mPolicy.priorityMessageSenders, suppressedEffects);
+ mPolicy.priorityMessageSenders, suppressedEffects,
+ mPolicy.priorityConversationSenders);
}
protected void saveSoundPolicy(int category, boolean allow) {
int priorityCategories = getNewDefaultPriorityCategories(allow, category);
savePolicy(priorityCategories, mPolicy.priorityCallSenders,
- mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
+ mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects,
+ mPolicy.priorityConversationSenders);
}
protected void savePolicy(int priorityCategories, int priorityCallSenders,
- int priorityMessageSenders, int suppressedVisualEffects) {
+ int priorityMessageSenders, int suppressedVisualEffects,
+ int priorityConversationSenders) {
mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders,
- priorityMessageSenders, suppressedVisualEffects);
+ priorityMessageSenders, suppressedVisualEffects, priorityConversationSenders);
mNotificationManager.setNotificationPolicy(mPolicy);
}
@@ -210,23 +224,21 @@
}
savePolicy(getNewDefaultPriorityCategories(allowSenders, category),
- priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects);
+ priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects,
+ mPolicy.priorityConversationSenders);
if (ZenModeSettingsBase.DEBUG) Log.d(TAG, "onPrefChange allow" +
stringCategory + "=" + allowSenders + " allow" + stringCategory + "From="
+ ZenModeConfig.sourceToString(allowSendersFrom));
}
- protected String getSendersKey(int category) {
- switch (getZenMode()) {
- case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
- case Settings.Global.ZEN_MODE_ALARMS:
- return getKeyFromSetting(SOURCE_NONE);
- default:
- int prioritySenders = getPrioritySenders(category);
- return getKeyFromSetting(isPriorityCategoryEnabled(category)
- ? prioritySenders : SOURCE_NONE);
- }
+ protected void saveConversationSenders(int val) {
+ final boolean allowSenders = val != CONVERSATION_SENDERS_NONE;
+
+ savePolicy(getNewDefaultPriorityCategories(allowSenders, PRIORITY_CATEGORY_CONVERSATIONS),
+ mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders,
+ mPolicy.suppressedVisualEffects, val);
+
}
private int getPrioritySenders(int category) {
@@ -240,6 +252,10 @@
return getPriorityMessageSenders();
}
+ if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS) {
+ return getPriorityConversationSenders();
+ }
+
return categorySenders;
}
@@ -271,11 +287,13 @@
}
}
- protected int getAlarmsTotalSilenceCallsMessagesSummary(int category) {
+ protected int getAlarmsTotalSilencePeopleSummary(int category) {
if (category == NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES) {
return R.string.zen_mode_from_none_messages;
} else if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CALLS){
return R.string.zen_mode_from_none_calls;
+ } else if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS) {
+ return R.string.zen_mode_from_no_conversations;
}
return R.string.zen_mode_from_none;
}
@@ -309,6 +327,21 @@
}
}
+ protected int getConversationSummary() {
+ int conversationType = getPriorityConversationSenders();
+
+ switch (conversationType) {
+ case NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE:
+ return R.string.zen_mode_from_all_conversations;
+ case NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT:
+ return R.string.zen_mode_from_important_conversations;
+ case NotificationManager.Policy.CONVERSATION_SENDERS_NONE:
+ return R.string.zen_mode_from_no_conversations;
+ default:
+ return R.string.zen_mode_from_no_conversations;
+ }
+ }
+
protected int getContactsCallsSummary(ZenPolicy policy) {
int peopleType = policy.getPriorityCallSenders();
switch (peopleType) {
@@ -398,12 +431,21 @@
messages = ZenPolicy.PEOPLE_TYPE_NONE;
}
+ int conversations;
+ if (mPolicy.allowConversations()) {
+ // unlike the above, no mapping is needed because the values are the same
+ conversations = mPolicy.allowConversationsFrom();
+ } else {
+ conversations = CONVERSATION_SENDERS_NONE;
+ }
+
return new ZenPolicy.Builder(zenPolicy)
.allowAlarms(mPolicy.allowAlarms())
.allowCalls(calls)
.allowEvents(mPolicy.allowEvents())
.allowMedia(mPolicy.allowMedia())
.allowMessages(messages)
+ .allowConversations(conversations)
.allowReminders(mPolicy.allowReminders())
.allowRepeatCallers(mPolicy.allowRepeatCallers())
.allowSystem(mPolicy.allowSystem())
diff --git a/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
index 7b97fb1..0930db2 100644
--- a/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
@@ -56,7 +56,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
index ba91f56..de169ed 100644
--- a/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
@@ -55,7 +55,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java b/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
index a06f023..a48c93d 100644
--- a/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
@@ -55,7 +55,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePeopleSettings.java b/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
index af3c26b..ff768db 100644
--- a/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
+++ b/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
@@ -65,8 +65,7 @@
controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
context.getResources().getInteger(com.android.internal.R.integer
.config_zen_repeat_callers_threshold)));
- controllers.add(
- new ZenModeAllBypassingConversationsPreferenceController(context, app, host));
+ controllers.add(new ZenModePriorityConversationsPreferenceController(context, lifecycle));
controllers.add(new ZenModeSettingsFooterPreferenceController(context, lifecycle,
fragmentManager));
return controllers;
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
index 780cf84..6b538dc 100644
--- a/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
@@ -80,7 +80,7 @@
case Settings.Global.ZEN_MODE_ALARMS:
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java
new file mode 100644
index 0000000..afd17ad
--- /dev/null
+++ b/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2020 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.zen;
+
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_ANYONE;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_NONE;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+public class ZenModePriorityConversationsPreferenceController
+ extends AbstractZenModePreferenceController
+ implements Preference.OnPreferenceChangeListener {
+
+ protected static final String KEY = "zen_mode_conversations";
+ private final ZenModeBackend mBackend;
+ private ListPreference mPreference;
+
+ public ZenModePriorityConversationsPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, KEY, lifecycle);
+ mBackend = ZenModeBackend.getInstance(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(KEY);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ updateValue(preference);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
+ mBackend.saveConversationSenders(Integer.parseInt(selectedContactsFrom.toString()));
+ updateValue(preference);
+ return true;
+ }
+
+ private void updateValue(Preference preference) {
+ mPreference = (ListPreference) preference;
+ switch (getZenMode()) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Settings.Global.ZEN_MODE_ALARMS:
+ mPreference.setEnabled(false);
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
+ NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS));
+ break;
+ default:
+ preference.setEnabled(true);
+ preference.setSummary(mBackend.getConversationSummary());
+ int senders = mBackend.getPriorityConversationSenders();
+
+ switch (senders) {
+ case CONVERSATION_SENDERS_NONE:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ break;
+ case CONVERSATION_SENDERS_IMPORTANT:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+ break;
+ default:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_ANYONE));
+ break;
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
index f54179e..6476c63 100644
--- a/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
@@ -80,7 +80,7 @@
case Settings.Global.ZEN_MODE_ALARMS:
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 8947f8f..6f505bd 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -182,6 +182,15 @@
if ((mTitle == null) && isManagedProfile) {
mTitle = getTitleFromOrganizationName(mUserId);
}
+ final @LockPatternUtils.CredentialType int credentialType = Utils.getCredentialType(
+ mContext, effectiveUserId);
+ if (mTitle == null) {
+ mTitle = getTitleFromCredentialType(credentialType, isManagedProfile);
+ }
+ if (mDetails == null) {
+ mDetails = getDetailsFromCredentialType(credentialType, isManagedProfile);
+ }
+
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
@@ -233,6 +242,44 @@
}
}
+ private String getTitleFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
+ boolean isManagedProfile) {
+ switch (credentialType) {
+ case LockPatternUtils.CREDENTIAL_TYPE_PIN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_work_pin_header)
+ : getString(R.string.lockpassword_confirm_your_pin_header);
+ case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_work_pattern_header)
+ : getString(R.string.lockpassword_confirm_your_pattern_header);
+ case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_work_password_header)
+ : getString(R.string.lockpassword_confirm_your_password_header);
+ }
+ return null;
+ }
+
+ private String getDetailsFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
+ boolean isManagedProfile) {
+ switch (credentialType) {
+ case LockPatternUtils.CREDENTIAL_TYPE_PIN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_pin_generic_profile)
+ : getString(R.string.lockpassword_confirm_your_pin_generic);
+ case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_pattern_generic_profile)
+ : getString(R.string.lockpassword_confirm_your_pattern_generic);
+ case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_password_generic_profile)
+ : getString(R.string.lockpassword_confirm_your_password_generic);
+ }
+ return null;
+ }
+
@Override
protected void onStart() {
super.onStart();
diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceController.java b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java
new file mode 100644
index 0000000..31abd8a
--- /dev/null
+++ b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2020 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.sound;
+
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * Controller for vibrate for calls settings.
+ */
+public class VibrateForCallsPreferenceController extends BasePreferenceController {
+
+ private static final int ON = 1;
+ private static final int OFF = 0;
+ @VisibleForTesting
+ static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
+
+ public VibrateForCallsPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ @AvailabilityStatus
+ public int getAvailabilityStatus() {
+ return Utils.isVoiceCapable(mContext) && !DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false)
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (Settings.Global.getInt(
+ mContext.getContentResolver(),
+ Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
+ return mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer);
+ } else if (Settings.System.getInt(
+ mContext.getContentResolver(),
+ Settings.System.VIBRATE_WHEN_RINGING, OFF) == ON) {
+ return mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate);
+ } else {
+ return mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate);
+ }
+ }
+}
diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java
new file mode 100644
index 0000000..73b9f2f
--- /dev/null
+++ b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2019 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.sound;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPickerFragment;
+import com.android.settingslib.widget.CandidateInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Fragment for changing vibrate for calls options.
+ */
+public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment {
+ private static final String TAG = "VibrateForCallsPreferenceFragment";
+
+ @VisibleForTesting
+ static final String KEY_NEVER_VIBRATE = "never_vibrate";
+ @VisibleForTesting
+ static final String KEY_ALWAYS_VIBRATE = "always_vibrate";
+ @VisibleForTesting
+ static final String KEY_RAMPING_RINGER = "ramping_ringer";
+
+ private static final int ON = 1;
+ private static final int OFF = 0;
+
+ private final Map<String, VibrateForCallsCandidateInfo> mCandidates;
+
+ public VibrateForCallsPreferenceFragment() {
+ mCandidates = new ArrayMap<>();
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ loadCandidates(context);
+ }
+
+ private void loadCandidates(Context context) {
+ mCandidates.put(KEY_NEVER_VIBRATE,
+ new VibrateForCallsCandidateInfo(
+ KEY_NEVER_VIBRATE, R.string.vibrate_when_ringing_option_never_vibrate));
+ mCandidates.put(KEY_ALWAYS_VIBRATE,
+ new VibrateForCallsCandidateInfo(
+ KEY_ALWAYS_VIBRATE, R.string.vibrate_when_ringing_option_always_vibrate));
+ mCandidates.put(KEY_RAMPING_RINGER,
+ new VibrateForCallsCandidateInfo(
+ KEY_RAMPING_RINGER, R.string.vibrate_when_ringing_option_ramping_ringer));
+ }
+
+ private void updateSettings(VibrateForCallsCandidateInfo candidate) {
+ final String key = candidate.getKey();
+ if (TextUtils.equals(key, KEY_ALWAYS_VIBRATE)) {
+ Settings.System.putInt(
+ getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, ON);
+ Settings.Global.putInt(
+ getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
+ } else if (TextUtils.equals(key, KEY_RAMPING_RINGER)) {
+ Settings.System.putInt(
+ getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(
+ getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON);
+ } else {
+ Settings.System.putInt(
+ getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(
+ getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
+ }
+ }
+
+ @Override
+ protected List<? extends CandidateInfo> getCandidates() {
+ final List<VibrateForCallsCandidateInfo> candidates = new ArrayList<>();
+ candidates.add(mCandidates.get(KEY_NEVER_VIBRATE));
+ candidates.add(mCandidates.get(KEY_ALWAYS_VIBRATE));
+ candidates.add(mCandidates.get(KEY_RAMPING_RINGER));
+ return candidates;
+ }
+
+ @Override
+ protected String getDefaultKey() {
+ if (Settings.Global.getInt(
+ getContext().getContentResolver(),
+ Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
+ return KEY_RAMPING_RINGER;
+ } else if (Settings.System.getInt(
+ getContext().getContentResolver(),
+ Settings.System.VIBRATE_WHEN_RINGING, OFF) == ON) {
+ return KEY_ALWAYS_VIBRATE;
+ } else {
+ return KEY_NEVER_VIBRATE;
+ }
+ }
+
+ @Override
+ protected boolean setDefaultKey(String key) {
+ final VibrateForCallsCandidateInfo candidate = mCandidates.get(key);
+ if (candidate == null) {
+ Log.e(TAG, "Unknown vibrate for calls candidate (key = " + key + ")!");
+ return false;
+ }
+ updateSettings(candidate);
+ return true;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.vibrate_for_calls_settings;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.VIBRATE_FOR_CALLS;
+ }
+
+ @VisibleForTesting
+ class VibrateForCallsCandidateInfo extends CandidateInfo {
+ private final String mKey;
+ private final int mLabelId;
+
+ VibrateForCallsCandidateInfo(String key, int labelId) {
+ super(true /* enabled */);
+ mKey = key;
+ mLabelId = labelId;
+ }
+
+ @Override
+ public CharSequence loadLabel() {
+ return getContext().getString(mLabelId);
+ }
+
+ @Override
+ public Drawable loadIcon() {
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ return mKey;
+ }
+ }
+}
diff --git a/src/com/android/settings/utils/AnnotationSpan.java b/src/com/android/settings/utils/AnnotationSpan.java
index e6457da..1b8179d 100644
--- a/src/com/android/settings/utils/AnnotationSpan.java
+++ b/src/com/android/settings/utils/AnnotationSpan.java
@@ -50,7 +50,7 @@
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(false);
+ ds.setUnderlineText(true);
}
public static CharSequence linkify(CharSequence rawText, LinkInfo... linkInfos) {
diff --git a/src/com/android/settings/vpn2/AppDialogFragment.java b/src/com/android/settings/vpn2/AppDialogFragment.java
index 2f9cd7a..ea9e546 100644
--- a/src/com/android/settings/vpn2/AppDialogFragment.java
+++ b/src/com/android/settings/vpn2/AppDialogFragment.java
@@ -22,6 +22,7 @@
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.net.IConnectivityManager;
+import android.net.VpnManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -145,7 +146,8 @@
}
final int userId = getUserId();
try {
- mService.setVpnPackageAuthorization(mPackageInfo.packageName, userId, false);
+ mService.setVpnPackageAuthorization(
+ mPackageInfo.packageName, userId, VpnManager.TYPE_VPN_NONE);
onDisconnect(dialog);
} catch (RemoteException e) {
Log.e(TAG, "Failed to forget authorization of " + mPackageInfo.packageName +
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 5f46446..8e3d9bb 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -15,6 +15,7 @@
*/
package com.android.settings.vpn2;
+import static android.app.AppOpsManager.OP_ACTIVATE_PLATFORM_VPN;
import static android.app.AppOpsManager.OP_ACTIVATE_VPN;
import android.annotation.NonNull;
@@ -312,7 +313,7 @@
final AppOpsManager service =
(AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
- application.packageName, new int[]{OP_ACTIVATE_VPN});
+ application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
return !ArrayUtils.isEmpty(ops);
}
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 83cdf71..8a2b465 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -16,6 +16,7 @@
package com.android.settings.vpn2;
+import static android.app.AppOpsManager.OP_ACTIVATE_PLATFORM_VPN;
import static android.app.AppOpsManager.OP_ACTIVATE_VPN;
import android.annotation.UiThread;
@@ -522,7 +523,8 @@
// Fetch VPN-enabled apps from AppOps.
AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- List<AppOpsManager.PackageOps> apps = aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN});
+ List<AppOpsManager.PackageOps> apps =
+ aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
if (apps != null) {
for (AppOpsManager.PackageOps pkg : apps) {
int userId = UserHandle.getUserId(pkg.getUid());
@@ -533,8 +535,8 @@
// Look for a MODE_ALLOWED permission to activate VPN.
boolean allowed = false;
for (AppOpsManager.OpEntry op : pkg.getOps()) {
- if (op.getOp() == OP_ACTIVATE_VPN &&
- op.getMode() == AppOpsManager.MODE_ALLOWED) {
+ if ((op.getOp() == OP_ACTIVATE_VPN || op.getOp() == OP_ACTIVATE_PLATFORM_VPN)
+ && op.getMode() == AppOpsManager.MODE_ALLOWED) {
allowed = true;
}
}
diff --git a/src/com/android/settings/widget/MasterSwitchPreference.java b/src/com/android/settings/widget/MasterSwitchPreference.java
index b34b162..9fe077e 100644
--- a/src/com/android/settings/widget/MasterSwitchPreference.java
+++ b/src/com/android/settings/widget/MasterSwitchPreference.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Switch;
@@ -81,6 +82,11 @@
}
}
});
+
+ // Consumes move events to ignore drag actions.
+ switchWidget.setOnTouchListener((v, event) -> {
+ return event.getActionMasked() == MotionEvent.ACTION_MOVE;
+ });
}
mSwitch = (Switch) holder.findViewById(R.id.switchWidget);
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 488aadb..00df051 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -17,6 +17,7 @@
package com.android.settings.wifi;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
import android.annotation.NonNull;
@@ -730,7 +731,8 @@
}
WifiConfiguration.NetworkSelectionStatus networkStatus =
config.getNetworkSelectionStatus();
- if (networkStatus == null || networkStatus.isNetworkEnabled()) {
+ if (networkStatus == null
+ || networkStatus.getNetworkSelectionStatus() == NETWORK_SELECTION_ENABLED) {
return false;
}
int reason = networkStatus.getNetworkSelectionDisableReason();
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index 932f5d9..36e9d98 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -16,6 +16,7 @@
package com.android.settings.wifi;
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
import android.app.Activity;
@@ -1100,7 +1101,8 @@
}
WifiConfiguration.NetworkSelectionStatus networkStatus =
config.getNetworkSelectionStatus();
- if (networkStatus == null || networkStatus.isNetworkEnabled()) {
+ if (networkStatus == null
+ || networkStatus.getNetworkSelectionStatus() == NETWORK_SELECTION_ENABLED) {
return false;
}
int reason = networkStatus.getNetworkSelectionDisableReason();
diff --git a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
index b584ea1..05c7b4e 100644
--- a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
+++ b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
@@ -715,7 +715,7 @@
}
@VisibleForTesting
- void updateScanResults(List<AccessPoint> allAccessPoints) {
+ void updateScanResultsToUi(List<AccessPoint> allAccessPoints) {
if (mUiToRequestedList == null) {
// Nothing need to be updated.
return;
@@ -723,13 +723,16 @@
// Update the signal level of the UI networks.
for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
- final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
- .stream()
- .filter(accesspoint -> accesspoint.matches(
- uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
- .findFirst();
- uiConfigurationItem.mLevel =
- matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+ uiConfigurationItem.mLevel = 0;
+ if (allAccessPoints != null) {
+ final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
+ .stream()
+ .filter(accesspoint -> accesspoint.matches(
+ uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
+ .findFirst();
+ uiConfigurationItem.mLevel =
+ matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+ }
}
if (mIsSingleNetwork) {
@@ -742,7 +745,17 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ onAccessPointsChanged();
+ }
+
+ /**
+ * Update the results when data changes
+ */
+ @Override
public void onAccessPointsChanged() {
- updateScanResults(mWifiTracker.getAccessPoints());
+ updateScanResultsToUi(
+ mWifiTracker.getManager().isWifiEnabled() ? mWifiTracker.getAccessPoints() : null);
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 3d864cc..074df76 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -366,6 +366,7 @@
appEntry.extraInfo = mock(AppFilterItem.class);
appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
+ ReflectionHelpers.setField(adapter, "mContext", mContext);
adapter.onBindViewHolder(holder, 0);
// no crash? yay!
@@ -387,6 +388,7 @@
appEntry.info = mock(ApplicationInfo.class);
appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
+ ReflectionHelpers.setField(adapter, "mContext", mContext);
adapter.onBindViewHolder(holder, 0);
verify(holder).updateSwitch(any(), anyBoolean(), anyBoolean());
@@ -406,6 +408,7 @@
appEntry.info = mock(ApplicationInfo.class);
appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
+ ReflectionHelpers.setField(adapter, "mContext", mContext);
adapter.onBindViewHolder(holder, 0);
verify(holder, never()).updateSwitch(any(), anyBoolean(), anyBoolean());
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java
index a287ea6..cc960d7 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java
@@ -76,4 +76,14 @@
assertThat(mController.isAvailable()).isFalse();
}
+
+ @Test
+ public void getAvailabilityStatus_NfcIsDisabled_shouldReturnDisabled() {
+ when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
+ when(mUserManager.isAdminUser()).thenReturn(true);
+ when(mNfcAdapter.isEnabled()).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ DefaultPaymentSettingsPreferenceController.DISABLED_DEPENDENT_SETTING);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/PaymentSettingsEnablerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/PaymentSettingsEnablerTest.java
new file mode 100644
index 0000000..f1d8952
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/PaymentSettingsEnablerTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2020 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.applications.specialaccess;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.nfc.NfcAdapter;
+
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class PaymentSettingsEnablerTest {
+ private Context mContext;
+ private Preference mPreference;
+ private PaymentSettingsEnabler mEnabler;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mPreference = new Preference(mContext);
+ mEnabler = spy(new PaymentSettingsEnabler(mContext, mPreference));
+ }
+
+ @Test
+ public void handleNfcStateChanged_stateOff_shouldChangeSummaryAndDisablePreference() {
+ mEnabler.handleNfcStateChanged(NfcAdapter.STATE_OFF);
+
+ assertThat(mPreference.getSummary().toString()).contains(
+ mContext.getString(R.string.nfc_and_payment_settings_payment_off_nfc_off_summary));
+ assertThat(mPreference.isEnabled()).isFalse();
+ }
+
+ @Test
+ public void handleNfcStateChanged_stateOn_shouldClearSummaryAndEnablePreference() {
+ mEnabler.handleNfcStateChanged(NfcAdapter.STATE_ON);
+
+ assertThat(mPreference.getSummary()).isNull();
+ assertThat(mPreference.isEnabled()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
index 9637884..5fc45a6 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
@@ -115,18 +115,6 @@
}
@Override
- public boolean connect(BluetoothDevice device) {
- mConnectedDevices.add(device);
- return true;
- }
-
- @Override
- public boolean disconnect(BluetoothDevice device) {
- mConnectedDevices.remove(device);
- return false;
- }
-
- @Override
public int getConnectionStatus(BluetoothDevice device) {
if (mConnectedDevices.contains(device)) {
return BluetoothProfile.STATE_CONNECTED;
@@ -136,20 +124,21 @@
}
@Override
- public boolean isPreferred(BluetoothDevice device) {
+ public boolean isEnabled(BluetoothDevice device) {
return mPreferred.getOrDefault(device, false);
}
@Override
- public int getPreferred(BluetoothDevice device) {
- return isPreferred(device) ?
- BluetoothProfile.CONNECTION_POLICY_ALLOWED
+ public int getConnectionPolicy(BluetoothDevice device) {
+ return isEnabled(device)
+ ? BluetoothProfile.CONNECTION_POLICY_ALLOWED
: BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
}
@Override
- public void setPreferred(BluetoothDevice device, boolean preferred) {
- mPreferred.put(device, preferred);
+ public boolean setEnabled(BluetoothDevice device, boolean enabled) {
+ mPreferred.put(device, enabled);
+ return true;
}
@Override
@@ -192,7 +181,7 @@
private LocalBluetoothProfile addFakeProfile(int profileNameResId,
boolean deviceIsPreferred) {
LocalBluetoothProfile profile = new FakeBluetoothProfile(mContext, profileNameResId);
- profile.setPreferred(mDevice, deviceIsPreferred);
+ profile.setEnabled(mDevice, deviceIsPreferred);
mConnectableProfiles.add(profile);
when(mProfileManager.getProfileByName(eq(profile.toString()))).thenReturn(profile);
return profile;
@@ -266,7 +255,7 @@
assertThat(pref.isChecked()).isTrue();
pref.performClick();
assertThat(pref.isChecked()).isFalse();
- assertThat(mConnectableProfiles.get(0).isPreferred(mDevice)).isFalse();
+ assertThat(mConnectableProfiles.get(0).isEnabled(mDevice)).isFalse();
// Make sure no new preferences were added.
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
@@ -274,7 +263,7 @@
// Clicking the pref again should make the profile once again preferred.
pref.performClick();
assertThat(pref.isChecked()).isTrue();
- assertThat(mConnectableProfiles.get(0).isPreferred(mDevice)).isTrue();
+ assertThat(mConnectableProfiles.get(0).isEnabled(mDevice)).isTrue();
// Make sure we still haven't gotten any new preferences added.
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
@@ -364,7 +353,7 @@
mContext.getString(R.string.bluetooth_profile_a2dp_high_quality_unknown_codec));
when(profile.supportsHighQualityAudio(mDevice)).thenReturn(supportsHighQualityAudio);
when(profile.isHighQualityAudioEnabled(mDevice)).thenReturn(highQualityAudioEnabled);
- when(profile.isPreferred(mDevice)).thenReturn(preferred);
+ when(profile.isEnabled(mDevice)).thenReturn(preferred);
when(profile.isProfileReady()).thenReturn(true);
mConnectableProfiles.add(profile);
return profile;
@@ -426,8 +415,8 @@
SwitchPreference audioPref =
(SwitchPreference) mScreen.findPreference(audioProfile.toString());
audioPref.performClick();
- verify(audioProfile).setPreferred(mDevice, false);
- when(audioProfile.isPreferred(mDevice)).thenReturn(false);
+ verify(audioProfile).setEnabled(mDevice, false);
+ when(audioProfile.isEnabled(mDevice)).thenReturn(false);
mController.onDeviceAttributesChanged();
assertThat(audioPref.isVisible()).isTrue();
SwitchPreference highQualityAudioPref = getHighQualityAudioPref();
@@ -435,8 +424,8 @@
// And re-enabling media audio should make high quality switch to reappear.
audioPref.performClick();
- verify(audioProfile).setPreferred(mDevice, true);
- when(audioProfile.isPreferred(mDevice)).thenReturn(true);
+ verify(audioProfile).setEnabled(mDevice, true);
+ when(audioProfile.isEnabled(mDevice)).thenReturn(true);
mController.onDeviceAttributesChanged();
highQualityAudioPref = getHighQualityAudioPref();
assertThat(highQualityAudioPref.isVisible()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentControllerTest.java
new file mode 100644
index 0000000..fdedc88
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentControllerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2020 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.connecteddevice;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.nfc.NfcAdapter;
+import android.nfc.NfcManager;
+import android.os.UserManager;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class NfcAndPaymentFragmentControllerTest {
+ private NfcAndPaymentFragmentController mController;
+ private Context mContext;
+
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private UserManager mUserManager;
+ @Mock
+ private NfcManager mNfcManager;
+ @Mock
+ private NfcAdapter mNfcAdapter;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+
+ when(mContext.getApplicationContext()).thenReturn(mContext);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+ when(mContext.getSystemService(Context.NFC_SERVICE)).thenReturn(mNfcManager);
+ when(NfcAdapter.getDefaultAdapter(mContext)).thenReturn(mNfcAdapter);
+
+ mController = new NfcAndPaymentFragmentController(mContext, "fakeKey");
+ ReflectionHelpers.setField(mController, "mNfcAdapter", mNfcAdapter);
+ }
+
+ @Test
+ public void getAvailabilityStatus_hasNfc_shouldReturnAvailable() {
+ when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
+ when(mUserManager.isAdminUser()).thenReturn(true);
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(NfcAndPaymentFragmentController.AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noNfcAdapter_shouldReturnUnsupported() {
+ ReflectionHelpers.setField(mController, "mNfcAdapter", null);
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(NfcAndPaymentFragmentController.UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notAdminUser_shouldReturnDisabled() {
+ when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
+ when(mUserManager.isAdminUser()).thenReturn(false);
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(NfcAndPaymentFragmentController.DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getSummary_nfcOn_shouldProvideOnSummary() {
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+ assertThat(mController.getSummary().toString()).contains(
+ mContext.getString(R.string.switch_on_text));
+ }
+
+ @Test
+ public void getSummary_nfcOff_shouldProvideOffSummary() {
+ when(mNfcAdapter.isEnabled()).thenReturn(false);
+ assertThat(mController.getSummary().toString()).contains(
+ mContext.getString(R.string.switch_off_text));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java
new file mode 100644
index 0000000..af68784
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2020 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.connecteddevice;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.nfc.NfcAdapter;
+import android.provider.SearchIndexableResource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class NfcAndPaymentFragmentTest {
+ private NfcAndPaymentFragment mFragment;
+ private Context mContext;
+
+ @Mock
+ private NfcAdapter mNfcAdapter;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mFragment = new NfcAndPaymentFragment();
+ mContext = spy(RuntimeEnvironment.application);
+ }
+
+ @Test
+ public void searchIndexProvider_shouldIndexResource() {
+ final List<SearchIndexableResource> indexRes =
+ NfcAndPaymentFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getXmlResourcesToIndex(mContext, true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
+ }
+
+ @Test
+ public void searchIndexProvider_shouldIndexAllItems() {
+ when(mContext.getApplicationContext()).thenReturn(mContext);
+ when(NfcAdapter.getDefaultAdapter(mContext)).thenReturn(mNfcAdapter);
+ when(mNfcAdapter.isSecureNfcSupported()).thenReturn(true);
+
+ final List<String> niks = NfcAndPaymentFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(mContext);
+
+ assertThat(niks).isNotNull();
+ assertThat(niks).isEmpty();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
index dd5af2b..de4be1d 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
@@ -21,6 +21,7 @@
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
@@ -41,8 +42,6 @@
import com.android.settings.R;
-import java.util.Arrays;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,6 +50,8 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.Arrays;
+
@RunWith(RobolectricTestRunner.class)
public class GameDriverAppPreferenceControllerTest {
@@ -87,10 +88,13 @@
mContext = spy(RuntimeEnvironment.application);
mResolver = mContext.getContentResolver();
mValueList =
- mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
- mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
+ mContext.getResources().getStringArray(
+ R.array.graphics_driver_app_preference_values);
+ mDialogTitle = mContext.getResources().getString(
+ R.string.graphics_driver_app_preference_title);
mPreferencePrereleaseDriver =
- mContext.getResources().getString(R.string.game_driver_app_preference_prerelease_driver);
+ mContext.getResources().getString(
+ R.string.graphics_driver_app_preference_prerelease_driver);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java
index f8f8add..eb5c3b3 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java
@@ -50,6 +50,6 @@
@Test
public void getPreferenceScreen_shouldReturnGameDriverSettings() {
- assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.game_driver_settings);
+ assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.graphics_driver_settings);
}
}
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java
index df59971..8495f60 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java
@@ -71,11 +71,11 @@
mResolver = mContext.getContentResolver();
final Resources resources = mContext.getResources();
- mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
+ mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
- resources.getString(R.string.game_driver_app_preference_game_driver);
+ resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferencePrereleaseDriver =
- resources.getString(R.string.game_driver_app_preference_prerelease_driver);
+ resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
Settings.Global.putInt(
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
index cdbbf7e..4d5f1a0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
@@ -42,7 +42,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@@ -73,7 +72,7 @@
mChargingIntent.putExtra(BatteryManager.EXTRA_LEVEL, BATTERY_INTENT_LEVEL);
mChargingIntent.putExtra(BatteryManager.EXTRA_SCALE, BATTERY_INTENT_SCALE);
mChargingIntent
- .putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_CHARGING);
+ .putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_CHARGING);
}
@Test
@@ -85,9 +84,9 @@
mBatteryBroadcastReceiver.onReceive(mContext, mChargingIntent);
assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
- .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
+ .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
- .isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
+ .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent));
verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL);
}
@@ -111,7 +110,7 @@
public void testOnReceive_batteryDataNotChanged_listenerNotInvoked() {
final String batteryLevel = Utils.getBatteryPercentage(mChargingIntent);
final String batteryStatus =
- Utils.getBatteryStatus(mContext.getResources(), mChargingIntent);
+ Utils.getBatteryStatus(mContext, mChargingIntent);
mBatteryBroadcastReceiver.mBatteryLevel = batteryLevel;
mBatteryBroadcastReceiver.mBatteryStatus = batteryStatus;
@@ -134,9 +133,9 @@
mBatteryBroadcastReceiver.register();
assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
- .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
+ .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
- .isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
+ .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent));
// 2 times because register will force update the battery
verify(mBatteryListener, times(2)).onBatteryChanged(BatteryUpdateType.MANUAL);
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
index 06f9b98..ad2930d 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
@@ -23,8 +23,11 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import com.android.settings.homepage.contextualcards.ContextualCard;
import com.android.settings.homepage.contextualcards.ContextualCard.CardType;
@@ -37,6 +40,8 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -45,6 +50,7 @@
@RunWith(RobolectricTestRunner.class)
public class ConditionContextualCardControllerTest {
+ private static final int SUB_ID = 2;
@Mock
private ConditionManager mConditionManager;
@@ -57,6 +63,17 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+
+ // parameters required by CellularDataConditionController
+ final ShadowSubscriptionManager shadowSubscriptionMgr = shadowOf(
+ mContext.getSystemService(SubscriptionManager.class));
+ shadowSubscriptionMgr.setDefaultDataSubscriptionId(SUB_ID);
+
+ final TelephonyManager telephonyManager =
+ spy(mContext.getSystemService(TelephonyManager.class));
+ final ShadowTelephonyManager shadowTelephonyMgr = shadowOf(telephonyManager);
+ shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
+
mController = spy(new ConditionContextualCardController(mContext));
ReflectionHelpers.setField(mController, "mConditionManager", mConditionManager);
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
index 7170bdd..3be65dc 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
@@ -25,6 +25,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import android.app.UiModeManager;
import android.content.Context;
import android.net.Uri;
import android.os.BatteryManager;
@@ -54,6 +55,8 @@
private BatteryManager mBatteryManager;
@Mock
private PowerManager mPowerManager;
+ @Mock
+ private UiModeManager mUiModeManager;
private Context mContext;
private DarkThemeSlice mDarkThemeSlice;
@@ -68,6 +71,7 @@
mFeatureFactory.slicesFeatureProvider.newUiSession();
doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
+ doReturn(mUiModeManager).when(mContext).getSystemService(UiModeManager.class);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -90,8 +94,25 @@
}
@Test
+ public void isAvailable_nonDarkTheme_autoNightMode_returnFalse() {
+ mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
+ setNightMode(UiModeManager.MODE_NIGHT_AUTO);
+
+ assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
+ }
+
+ @Test
+ public void isAvailable_nonDarkTheme_customNightMode_returnFalse() {
+ mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
+ setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
+
+ assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
+ }
+
+ @Test
public void isAvailable_nonDarkThemeBatteryCapacityEq100_returnFalse() {
setBatteryCapacityLevel(100);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
}
@@ -99,6 +120,7 @@
@Test
public void isAvailable_nonDarkThemeBatteryCapacityLt50_returnTrue() {
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.isAvailable(mContext)).isTrue();
}
@@ -142,6 +164,7 @@
mFeatureFactory.slicesFeatureProvider.getUiSessionToken();
mDarkThemeSlice.sKeepSliceShow = true;
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.getSlice()).isNotNull();
}
@@ -162,6 +185,7 @@
mDarkThemeSlice.sSliceClicked = true;
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.getSlice()).isNotNull();
}
@@ -169,6 +193,7 @@
@Test
public void getSlice_isAvailable_returnSlice() {
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.getSlice()).isNotNull();
}
@@ -176,6 +201,7 @@
@Test
public void getSlice_isAvailable_showTitleSubtitle() {
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
final Slice slice = mDarkThemeSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
@@ -191,4 +217,8 @@
when(mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY))
.thenReturn(power_level);
}
+
+ private void setNightMode(int mode) {
+ when(mUiModeManager.getNightMode()).thenReturn(mode);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
index 4b0df98..b4bda14 100644
--- a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
@@ -38,7 +38,6 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -114,7 +113,6 @@
}
@Test
- @Ignore
public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() {
mController.displayPreference(mScreen);
final EnforcedAdmin admin = mock(EnforcedAdmin.class);
@@ -124,11 +122,9 @@
mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
verify(mPreference).setDisabledByAdmin(any());
- verify(mPreference).setChecked(false);
}
@Test
- @Ignore
public void onLocationModeChanged_locationOff_shouldDisablePreference() {
mController.displayPreference(mScreen);
doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
@@ -138,7 +134,7 @@
verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false);
- verify(mPreference).setSummary(R.string.switch_off_text);
+ verify(mPreference).setSummary(R.string.location_app_permission_summary_location_off);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
index c76e234..ec4087a 100644
--- a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
@@ -16,11 +16,12 @@
package com.android.settings.network;
+import static com.android.settings.network.TetherEnabler.BLUETOOTH_TETHER_KEY;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -28,7 +29,6 @@
import android.content.Context;
import android.net.ConnectivityManager;
-import androidx.lifecycle.Lifecycle;
import androidx.test.core.app.ApplicationProvider;
import org.junit.Before;
@@ -55,7 +55,7 @@
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
mConnectivityManager);
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
- mController = new BluetoothTetherPreferenceController(mContext, mock(Lifecycle.class));
+ mController = new BluetoothTetherPreferenceController(mContext, BLUETOOTH_TETHER_KEY);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index a18e49d..4ae829f 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -16,9 +16,6 @@
package com.android.settings.network;
-import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_ABSENT;
-import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
@@ -29,10 +26,8 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import android.telephony.UiccSlotInfo;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -88,43 +83,6 @@
}
@Test
- @Ignore
- public void getAvailableSubscriptions_oneSelectableTwoDisabledPSimsOneAbsent_twoResults() {
- final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
-
- when(info1.getSubscriptionId()).thenReturn(111);
- when(info1.getSimSlotIndex()).thenReturn(-1);
-
- when(info2.getSubscriptionId()).thenReturn(222);
- when(info2.getSimSlotIndex()).thenReturn(-1);
-
- when(info3.getSubscriptionId()).thenReturn(333);
- when(info3.getSimSlotIndex()).thenReturn(0);
-
- when(mSubMgr.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1));
- when(mSubMgr.getAllSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2, info3));
-
- final UiccSlotInfo info2slot = mock(UiccSlotInfo.class);
- final UiccSlotInfo info3slot = mock(UiccSlotInfo.class);
-
- when(info2slot.getLogicalSlotIdx()).thenReturn(-1);
- when(info2slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_ABSENT);
-
- when(info3slot.getLogicalSlotIdx()).thenReturn(0);
- when(info3slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_PRESENT);
-
- final UiccSlotInfo[] slotInfos = {info2slot, info3slot};
- when(mTelMgr.getUiccSlotsInfo()).thenReturn(slotInfos);
-
- final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
- assertThat(subs).hasSize(2);
- assertThat(subs.get(0).getSubscriptionId()).isEqualTo(111);
- assertThat(subs.get(1).getSubscriptionId()).isEqualTo(333);
- }
-
- @Test
public void getActiveSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
when(mSubMgr.getActiveSubscriptionInfoList()).thenReturn(null);
final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mSubMgr);
diff --git a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
index a2d55dc..6fa2251 100644
--- a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
@@ -136,7 +136,8 @@
@Test
public void onSwitchToggled_onlyStartsWifiTetherWhenNeeded() {
- when(mSharedPreferences.getBoolean(TetherEnabler.WIFI_TETHER_KEY, true)).thenReturn(true);
+ when(mSharedPreferences.getBoolean(TetherEnabler.KEY_ENABLE_WIFI_TETHERING, true))
+ .thenReturn(true);
when(mWifiManager.isWifiApEnabled()).thenReturn(true);
mEnabler.onSwitchToggled(true);
verify(mConnectivityManager, never()).startTethering(anyInt(), anyBoolean(), any(), any());
@@ -150,7 +151,8 @@
public void onSwitchToggled_shouldStartUSBTetherWhenSelected() {
SharedPreferences preference = mock(SharedPreferences.class);
ReflectionHelpers.setField(mEnabler, "mSharedPreferences", preference);
- when(preference.getBoolean(TetherEnabler.WIFI_TETHER_KEY, true)).thenReturn(false);
+ when(preference.getBoolean(TetherEnabler.KEY_ENABLE_WIFI_TETHERING, true))
+ .thenReturn(false);
when(preference.getBoolean(TetherEnabler.USB_TETHER_KEY, false)).thenReturn(true);
when(preference.getBoolean(TetherEnabler.BLUETOOTH_TETHER_KEY, true)).thenReturn(false);
diff --git a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
index 9127e4b..c150222 100644
--- a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
@@ -16,11 +16,12 @@
package com.android.settings.network;
+import static com.android.settings.network.TetherEnabler.USB_TETHER_KEY;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -28,7 +29,6 @@
import android.content.Context;
import android.net.ConnectivityManager;
-import androidx.lifecycle.Lifecycle;
import androidx.test.core.app.ApplicationProvider;
import org.junit.Before;
@@ -54,8 +54,8 @@
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
mConnectivityManager);
- when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[] {""});
- mController = new UsbTetherPreferenceController(mContext, mock(Lifecycle.class));
+ when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
+ mController = new UsbTetherPreferenceController(mContext, USB_TETHER_KEY);
}
@Test
@@ -75,7 +75,7 @@
@Test
public void display_availableChangedCorrectly() {
- when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[] {""});
+ when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
assertThat(mController.isAvailable()).isTrue();
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
diff --git a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
index e42c477..ebb9902 100644
--- a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
@@ -16,7 +16,9 @@
package com.android.settings.network;
-import static com.android.settings.network.WifiTetherDisablePreferenceController.PREF_KEY;
+import static com.android.settings.network.TetherEnabler.BLUETOOTH_TETHER_KEY;
+import static com.android.settings.network.TetherEnabler.USB_TETHER_KEY;
+import static com.android.settings.network.TetherEnabler.WIFI_TETHER_DISABLE_KEY;
import static com.google.common.truth.Truth.assertThat;
@@ -30,7 +32,6 @@
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
-import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import androidx.test.core.app.ApplicationProvider;
@@ -68,10 +69,10 @@
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
when(mContext.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE))
.thenReturn(mSharedPreferences);
- mController = new WifiTetherDisablePreferenceController(mContext, mock(Lifecycle.class));
+ mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
ReflectionHelpers.setField(mController, "mScreen", mPreferenceScreen);
ReflectionHelpers.setField(mController, "mPreference", mPreference);
- when(mPreferenceScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
+ when(mPreferenceScreen.findPreference(WIFI_TETHER_DISABLE_KEY)).thenReturn(mPreference);
}
@Test
@@ -103,30 +104,22 @@
@Test
public void switch_shouldListenToUsbAndBluetooth() {
- when(mSharedPreferences.getBoolean(
- BluetoothTetherPreferenceController.PREF_KEY, false)).thenReturn(true);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- BluetoothTetherPreferenceController.PREF_KEY);
+ when(mSharedPreferences.getBoolean(BLUETOOTH_TETHER_KEY, false)).thenReturn(true);
+ mController.onSharedPreferenceChanged(mSharedPreferences, BLUETOOTH_TETHER_KEY);
verify(mPreference).setVisible(eq(true));
- when(mSharedPreferences.getBoolean(
- UsbTetherPreferenceController.PREF_KEY, false)).thenReturn(true);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- UsbTetherPreferenceController.PREF_KEY);
+ when(mSharedPreferences.getBoolean(USB_TETHER_KEY, false)).thenReturn(true);
+ mController.onSharedPreferenceChanged(mSharedPreferences, USB_TETHER_KEY);
assertThat(mController.shouldShow()).isTrue();
- when(mSharedPreferences.getBoolean(
- UsbTetherPreferenceController.PREF_KEY, false)).thenReturn(false);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- UsbTetherPreferenceController.PREF_KEY);
+ when(mSharedPreferences.getBoolean(USB_TETHER_KEY, false)).thenReturn(false);
+ mController.onSharedPreferenceChanged(mSharedPreferences, USB_TETHER_KEY);
assertThat(mController.shouldShow()).isTrue();
- when(mSharedPreferences.getBoolean(
- BluetoothTetherPreferenceController.PREF_KEY, false)).thenReturn(false);
+ when(mSharedPreferences.getBoolean(BLUETOOTH_TETHER_KEY, false)).thenReturn(false);
when(mSharedPreferences.edit()).thenReturn(mock(SharedPreferences.Editor.class));
when(mPreference.isChecked()).thenReturn(true);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- BluetoothTetherPreferenceController.PREF_KEY);
+ mController.onSharedPreferenceChanged(mSharedPreferences, BLUETOOTH_TETHER_KEY);
verify(mPreference).setChecked(eq(false));
verify(mPreference).setVisible(eq(false));
}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java b/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
new file mode 100644
index 0000000..d2a7129
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2020 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.network.ims;
+
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class MockImsQueryResult {
+
+ public static class BooleanResult implements ImsQuery {
+ private boolean mResult;
+
+ public BooleanResult(boolean result) {
+ super();
+ mResult = result;
+ }
+
+ public boolean query() {
+ return mResult;
+ }
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
new file mode 100644
index 0000000..42ddd70
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2020 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+
+/**
+ * Controller class for mock VoLte status
+ */
+public class MockVolteQueryImsState extends VolteQueryImsState {
+
+ private ImsQuery mIsTtyOnVolteEnabled;
+ private ImsQuery mIsProvisionedOnDevice;
+ private ImsQuery mIsEnabledByUser;
+
+ /**
+ * Constructor
+ *
+ * @param context {@link Context}
+ * @param subId subscription's id
+ */
+ public MockVolteQueryImsState(Context context, int subId) {
+ super(context, subId);
+ }
+
+ public ImsManager getImsManager(int subId) {
+ return super.getImsManager(subId);
+ }
+
+ public void setIsTtyOnVolteEnabled(boolean enabled) {
+ mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isTtyOnVolteEnabled(int subId) {
+ if (mIsTtyOnVolteEnabled != null) {
+ return mIsTtyOnVolteEnabled;
+ }
+ return super.isTtyOnVolteEnabled(subId);
+ }
+
+ public void setIsProvisionedOnDevice(boolean isProvisioned) {
+ mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ }
+
+ @Override
+ ImsQuery isProvisionedOnDevice(int subId) {
+ if (mIsProvisionedOnDevice != null) {
+ return mIsProvisionedOnDevice;
+ }
+ return super.isProvisionedOnDevice(subId);
+ }
+
+ public void setIsEnabledByUser(boolean enabled) {
+ mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isEnabledByUser(int subId) {
+ if (mIsEnabledByUser != null) {
+ return mIsEnabledByUser;
+ }
+ return super.isEnabledByUser(subId);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
new file mode 100644
index 0000000..b5971e9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2020 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+/**
+ * Controller class for mock VT status
+ */
+public class MockVtQueryImsState extends VtQueryImsState {
+
+ private ImsQuery mIsTtyOnVolteEnabled;
+ private ImsQuery mIsProvisionedOnDevice;
+ private ImsQuery mIsEnabledByUser;
+
+ /**
+ * Constructor
+ *
+ * @param context {@link Context}
+ * @param subId subscription's id
+ */
+ public MockVtQueryImsState(Context context, int subId) {
+ super(context, subId);
+ }
+
+ public ImsManager getImsManager(int subId) {
+ return super.getImsManager(subId);
+ }
+
+ public void setIsTtyOnVolteEnabled(boolean enabled) {
+ mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isTtyOnVolteEnabled(int subId) {
+ if (mIsTtyOnVolteEnabled != null) {
+ return mIsTtyOnVolteEnabled;
+ }
+ return super.isTtyOnVolteEnabled(subId);
+ }
+
+ public void setIsProvisionedOnDevice(boolean isProvisioned) {
+ mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ }
+
+ @Override
+ ImsQuery isProvisionedOnDevice(int subId) {
+ if (mIsProvisionedOnDevice != null) {
+ return mIsProvisionedOnDevice;
+ }
+ return super.isProvisionedOnDevice(subId);
+ }
+
+ public void setIsEnabledByUser(boolean enabled) {
+ mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isEnabledByUser(int subId) {
+ if (mIsEnabledByUser != null) {
+ return mIsEnabledByUser;
+ }
+ return super.isEnabledByUser(subId);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
index 3e0bfa3..d7db984 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
@@ -35,7 +35,7 @@
import com.android.ims.ImsManager;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
import com.android.settingslib.RestrictedSwitchPreference;
import org.junit.Before;
@@ -63,7 +63,7 @@
@Mock
private ProvisioningManager mProvisioningManager;
- private VolteQueryImsState mQueryImsState;
+ private MockVolteQueryImsState mQueryImsState;
private Enhanced4gLtePreferenceController mController;
private SwitchPreference mPreference;
@@ -85,17 +85,13 @@
mCarrierConfig = new PersistableBundle();
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
- mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+ doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
mPreference = new RestrictedSwitchPreference(mContext);
- mController = spy(new Enhanced4gLtePreferenceController(mContext, "roaming") {
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
- });
+ mController = spy(new Enhanced4gLtePreferenceController(mContext, "VoLTE"));
mController.init(SUB_ID);
- mController.mImsManager = mImsManager;
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
mPreference.setKey(mController.getPreferenceKey());
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
index c9abe23..a89a7aa 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
@@ -34,8 +34,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.slice.Slice;
import androidx.slice.SliceItem;
@@ -47,7 +45,7 @@
import com.android.ims.ImsManager;
import com.android.settings.R;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBroadcastReceiver;
@@ -81,7 +79,7 @@
private ProvisioningManager mProvisioningManager;
private ShadowSubscriptionManager mShadowSubscriptionManager;
- private VolteQueryImsState mQueryImsState;
+ private MockVolteQueryImsState mQueryImsState;
private Context mContext;
private FakeEnhanced4gLteSliceHelper mEnhanced4gLteSliceHelper;
@@ -110,7 +108,9 @@
//setup for SliceBroadcastReceiver test
mReceiver = spy(new SliceBroadcastReceiver());
- mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+ doReturn(mMockImsManager).when(mQueryImsState).getImsManager(anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
mEnhanced4gLteSliceHelper = spy(new FakeEnhanced4gLteSliceHelper(mContext));
doReturn(mQueryImsState).when(mEnhanced4gLteSliceHelper).queryImsState(anyInt());
@@ -143,9 +143,7 @@
@Test
public void test_CreateEnhanced4gLteSlice_success() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -160,9 +158,7 @@
@Test
public void test_SettingSliceProvider_getsRightSliceEnhanced4gLte() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -179,9 +175,7 @@
@Ignore
public void test_SliceBroadcastReceiver_toggleOffEnhanced4gLte() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(false).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mSlicesFeatureProvider.getNewEnhanced4gLteSliceHelper(mContext))
@@ -278,7 +272,7 @@
}
private class FakeEnhanced4gLteSliceHelper extends Enhanced4gLteSliceHelper {
- int mSubId = 1;
+ int mSubId = SUB_ID;
FakeEnhanced4gLteSliceHelper(Context context) {
super(context);
@@ -289,16 +283,6 @@
return mMockCarrierConfigManager;
}
- @Override
- protected ImsManager getImsManager(int subId) {
- return mMockImsManager;
- }
-
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
-
protected int getDefaultVoiceSubId() {
return mSubId;
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
index b406986..2d5f47b 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
@@ -23,12 +23,12 @@
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.telephony.ServiceState;
@@ -48,6 +48,7 @@
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -55,13 +56,7 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowTelephonyManager;
-
-import java.util.ArrayList;
-import java.util.List;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowAlertDialogCompat.class)
@@ -70,8 +65,6 @@
@Mock
private TelephonyManager mTelephonyMgr;
@Mock
- private ServiceState mServiceState;
- @Mock
private SubscriptionManager mSubscriptionMgr;
@Mock
private SubscriptionInfo mSubscriptionInfo;
@@ -79,38 +72,27 @@
private FragmentActivity mActivity;
private RenameMobileNetworkDialogFragment mFragment;
private int mSubscriptionId = 1234;
- private List<SubscriptionInfo> mSubscriptionInfoList;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
-
- Context context = spy(RuntimeEnvironment.application);
-
- final ShadowTelephonyManager stm = Shadow.extract(context.getSystemService(
- TelephonyManager.class));
- stm.setTelephonyManagerForSubscriptionId(mSubscriptionId, mTelephonyMgr);
- when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
-
- when(mTelephonyMgr.getServiceState()).thenReturn(mServiceState);
- when(mServiceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
+ mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(mSubscriptionId);
when(mSubscriptionInfo.getDisplayName()).thenReturn("test");
- when(mSubscriptionMgr.setDisplayName(any(), anyInt(), anyInt())).thenReturn(0);
-
- mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
mFragment = spy(RenameMobileNetworkDialogFragment.newInstance(mSubscriptionId));
+ doReturn(mTelephonyMgr).when(mFragment).getTelephonyManager(any());
doReturn(mSubscriptionMgr).when(mFragment).getSubscriptionManager(any());
- mSubscriptionInfoList = new ArrayList<SubscriptionInfo>();
- mSubscriptionInfoList.add(mSubscriptionInfo);
- when(mSubscriptionMgr.getAvailableSubscriptionInfoList()).thenReturn(
- mSubscriptionInfoList);
+ final ServiceState serviceState = mock(ServiceState.class);
+ when(serviceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
+ when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
+ when(mTelephonyMgr.getServiceState()).thenReturn(serviceState);
}
@Test
+ @Ignore
public void dialog_subscriptionMissing_noCrash() {
final AlertDialog dialog = startDialog();
final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
@@ -119,7 +101,10 @@
}
@Test
+ @Ignore
public void dialog_cancelButtonClicked_setDisplayNameAndIconTintNotCalled() {
+ when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
+ mSubscriptionInfo);
final AlertDialog dialog = startDialog();
final EditText nameView = mFragment.getNameView();
nameView.setText("test2");
@@ -132,7 +117,11 @@
}
@Test
+ @Ignore
public void dialog_saveButtonClicked_setDisplayNameAndIconTint() {
+ when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
+ mSubscriptionInfo);
+
final AlertDialog dialog = startDialog();
final EditText nameView = mFragment.getNameView();
nameView.setText("test2");
@@ -152,9 +141,12 @@
}
@Test
+ @Ignore
public void populateView_infoIsOpportunistic_hideNumberLabel() {
final View view = LayoutInflater.from(mActivity).inflate(
R.layout.dialog_mobile_network_rename, null);
+ when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
+ mSubscriptionInfo);
when(mSubscriptionInfo.isOpportunistic()).thenReturn(true);
startDialog();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index e68a0f4..c766289 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -20,7 +20,6 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.spy;
import android.content.Context;
@@ -29,14 +28,13 @@
import android.telephony.TelephonyManager;
import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.feature.ImsFeature;
-import android.telephony.ims.feature.MmTelFeature;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.ims.ImsManager;
+import com.android.settings.network.ims.MockVtQueryImsState;
import com.android.settings.network.ims.VolteQueryImsState;
-import com.android.settings.network.ims.VtQueryImsState;
import org.junit.Before;
import org.junit.Test;
@@ -61,7 +59,7 @@
@Mock
private PreferenceScreen mPreferenceScreen;
- private VtQueryImsState mQueryImsState;
+ private MockVtQueryImsState mQueryImsState;
private VolteQueryImsState mQueryVoLteState;
private VideoCallingPreferenceController mController;
@@ -74,7 +72,6 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
doReturn(mCarrierConfigManager).when(mContext)
.getSystemService(CarrierConfigManager.class);
@@ -85,29 +82,22 @@
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
- mQueryImsState = spy(new VtQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVtQueryImsState(mContext, SUB_ID));
doReturn(true).when(mQueryImsState).isEnabledByUser();
+ doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
mQueryVoLteState = spy(new VolteQueryImsState(mContext, SUB_ID));
doReturn(true).when(mQueryVoLteState).isEnabledByUser();
mPreference = new SwitchPreference(mContext);
- mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling") {
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
- });
+ mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling"));
mController.init(SUB_ID);
- mController.mImsManager = mImsManager;
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
mPreference.setKey(mController.getPreferenceKey());
doReturn(true).when(mImsManager).isVtEnabledByPlatform();
- doReturn(true).when(mProvisioningManager)
- .getProvisioningStatusForCapability(
- eq(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO), anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
doReturn(true).when(mTelephonyManager).isDataEnabled();
@@ -116,14 +106,15 @@
@Test
public void isVideoCallEnabled_allFlagsOn_returnTrue() {
- assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
+ assertThat(mController.isVideoCallEnabled(SUB_ID)).isTrue();
}
@Test
public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
+ mQueryImsState.setIsProvisionedOnDevice(false);
doReturn(false).when(mImsManager).isVtEnabledByPlatform();
- assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
}
@Test
@@ -132,7 +123,7 @@
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
doReturn(false).when(mTelephonyManager).isDataEnabled();
- assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
deleted file mode 100644
index ec275c1..0000000
--- a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
+++ /dev/null
@@ -1,232 +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 static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
-import android.telephony.TelephonyManager;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
-import com.android.settings.testutils.shadow.ShadowDeviceConfig;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowContentResolver;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows={ShadowDeviceConfig.class})
-public class VibrateWhenRingPreferenceControllerTest {
-
- private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
- private final int DEFAULT_VALUE = 0;
- private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
- private Context mContext;
- private ContentResolver mContentResolver;
- @Mock
- private PreferenceScreen mScreen;
- @Mock
- private TelephonyManager mTelephonyManager;
- private VibrateWhenRingPreferenceController mController;
- private Preference mPreference;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- mContentResolver = mContext.getContentResolver();
- when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
- mController = new VibrateWhenRingPreferenceController(mContext, KEY_VIBRATE_WHEN_RINGING);
- mPreference = new Preference(mContext);
- mPreference.setKey(mController.getPreferenceKey());
- when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
- }
-
- @Test
- public void display_shouldDisplay() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isTrue();
- }
-
- @Test
- public void display_shouldNotDisplay_notVoiceCapable() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void display_shouldNotDisplay_RampingRingerEnabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void display_shouldNotDisplay_VoiceEnabled_RampingRingerEnabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void display_shouldNotDisplay_VoiceDisabled_RampingRingerEnabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void testOnPreferenceChange_turnOn_returnOn() {
- mController.onPreferenceChange(null, true);
- final int mode = Settings.System.getInt(mContext.getContentResolver(),
- VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
-
- assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
- }
-
- @Test
- public void testOnPreferenceChange_turnOff_returnOff() {
- mController.onPreferenceChange(null, false);
- final int mode = Settings.System.getInt(mContext.getContentResolver(),
- VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
-
- assertThat(mode).isEqualTo(DEFAULT_VALUE);
- }
-
- @Test
- public void voiceCapable_availabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void voiceCapable_notAvailabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
- }
-
- @Test
- public void updateState_settingIsOn_preferenceShouldBeChecked() {
- final TwoStatePreference preference = mock(TwoStatePreference.class);
- Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 1);
-
- mController.updateState(preference);
-
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
- final TwoStatePreference preference = mock(TwoStatePreference.class);
- Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
-
- mController.updateState(preference);
-
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void setChecked_settingsIsOn() {
- mController.setChecked(true);
- final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
- -1);
-
- assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
- }
-
- @Test
- public void setChecked_settingsIsOff() {
- mController.setChecked(false);
- final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
- -1);
-
- assertThat(mode).isEqualTo(DEFAULT_VALUE);
- }
-
- @Test
- public void testObserver_onResume_shouldRegisterObserver() {
- final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
- mController.displayPreference(mScreen);
-
- mController.onResume();
-
- assertThat(shadowContentResolver.getContentObservers(
- Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isNotEmpty();
- }
-
- @Test
- public void testObserver_onPause_shouldUnregisterObserver() {
- final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
- mController.displayPreference(mScreen);
-
- mController.onResume();
- mController.onPause();
-
- assertThat(shadowContentResolver.getContentObservers(
- Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isEmpty();
- }
-
- @Test
- public void isSliceableCorrectKey_returnsTrue() {
- final VibrateWhenRingPreferenceController controller =
- new VibrateWhenRingPreferenceController(mContext, "vibrate_when_ringing");
- assertThat(controller.isSliceable()).isTrue();
- }
-
- @Test
- public void isSliceableIncorrectKey_returnsFalse() {
- final VibrateWhenRingPreferenceController controller =
- new VibrateWhenRingPreferenceController(mContext, "bad_key");
- assertThat(controller.isSliceable()).isFalse();
- }
-
- @Test
- public void isPublicSlice_returnTrue() {
- assertThat(mController.isPublicSlice()).isTrue();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
index c4ece5a..247d68e 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
@@ -1,25 +1,41 @@
package com.android.settings.notification.zen;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CALLS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_STARRED;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
+
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
+import android.app.NotificationManager.Policy;
import android.content.Context;
import android.database.Cursor;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
-import com.android.settings.notification.zen.ZenModeBackend;
+import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
@@ -55,60 +71,6 @@
mBackend = new ZenModeBackend(mContext);
}
- @Test
- public void updateState_checkRuleOrderingDescending() {
- final int NUM_RULES = 4;
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(
- NUM_RULES, false);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- // check ordering, most recent should be at the end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i].getKey());
- }
- }
-
- @Test
- public void updateState_checkRuleOrderingAscending() {
- final int NUM_RULES = 4;
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesAscendingCreationTime(
- NUM_RULES, false);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- // check ordering, most recent should be at the end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + i, rules[i].getKey());
- }
- }
-
- @Test
- public void updateState_checkRuleOrderingDescending_withDefaultRules() {
- final int NUM_RULES = 4;
-
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(NUM_RULES,
- true);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- assertEquals(rules[0].getKey(), DEFAULT_ID_1);
- assertEquals(rules[1].getKey(), DEFAULT_ID_2);
- // NON-DEFAULT RULES check ordering, most recent at the bottom/end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i + 2].getKey());
- }
- }
-
- @Test
- public void updateSummary_nullCursorValues() {
- Cursor testCursorWithNullValues = createMockCursor(3);
- when(testCursorWithNullValues.getString(0)).thenReturn(null);
-
- // expected - no null values
- List<String> contacts = mBackend.getStarredContacts(testCursorWithNullValues);
- for (String contact : contacts) {
- assertThat(contact).isNotNull();
- }
- }
-
private Cursor createMockCursor(int size) {
Cursor mockCursor = mock(Cursor.class);
when(mockCursor.moveToFirst()).thenReturn(true);
@@ -173,4 +135,133 @@
ruleMap.entrySet().toArray(toReturn);
return toReturn;
}
+
+ @Test
+ public void updateState_checkRuleOrderingDescending() {
+ final int NUM_RULES = 4;
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(
+ NUM_RULES, false);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ // check ordering, most recent should be at the end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i].getKey());
+ }
+ }
+
+ @Test
+ public void updateState_checkRuleOrderingAscending() {
+ final int NUM_RULES = 4;
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesAscendingCreationTime(
+ NUM_RULES, false);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ // check ordering, most recent should be at the end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + i, rules[i].getKey());
+ }
+ }
+
+ @Test
+ public void updateState_checkRuleOrderingDescending_withDefaultRules() {
+ final int NUM_RULES = 4;
+
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(NUM_RULES,
+ true);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ assertEquals(rules[0].getKey(), DEFAULT_ID_1);
+ assertEquals(rules[1].getKey(), DEFAULT_ID_2);
+ // NON-DEFAULT RULES check ordering, most recent at the bottom/end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i + 2].getKey());
+ }
+ }
+
+ @Test
+ public void updateSummary_nullCursorValues() {
+ Cursor testCursorWithNullValues = createMockCursor(3);
+ when(testCursorWithNullValues.getString(0)).thenReturn(null);
+
+ // expected - no null values
+ List<String> contacts = mBackend.getStarredContacts(testCursorWithNullValues);
+ for (String contact : contacts) {
+ assertThat(contact).isNotNull();
+ }
+ }
+
+ @Test
+ public void saveConversationSenders_importantToNone() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(
+ new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_IMPORTANT));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(
+ PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_NONE);
+ assertEquals(expected, captor.getValue());
+ }
+
+ @Test
+ public void saveConversationSenders_noneToAll() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(new Policy(
+ PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_NONE));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE);
+ assertEquals(expected, captor.getValue());
+ }
+
+ @Test
+ public void saveSenders_doesNotChangeConversations() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(
+ new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_ANY,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE);
+ assertEquals(expected, captor.getValue());
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
index e4490d5..d1f80b8 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
@@ -34,8 +34,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.notification.zen.ZenModeBackend;
-import com.android.settings.notification.zen.ZenModePriorityCallsPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -88,7 +86,7 @@
when(mBackend.getPriorityCallSenders())
.thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS)).thenCallRealMethod();
when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
.thenCallRealMethod();
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java
new file mode 100644
index 0000000..1583b91
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2020 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.zen;
+
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
+import static android.provider.Settings.Global.ZEN_MODE;
+import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
+import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+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.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class ZenModePriorityConversationsPreferenceControllerTest {
+
+ private ZenModePriorityConversationsPreferenceController mController;
+
+ @Mock
+ private ZenModeBackend mBackend;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private ListPreference mockPref;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private ContentResolver mContentResolver;
+ private Context mContext;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ mContentResolver = RuntimeEnvironment.application.getContentResolver();
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ when(mBackend.getPriorityConversationSenders())
+ .thenReturn(CONVERSATION_SENDERS_IMPORTANT);
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(PRIORITY_CATEGORY_CONVERSATIONS))
+ .thenCallRealMethod();
+ when(mBackend.getConversationSummary()).thenCallRealMethod();
+
+ mController = new ZenModePriorityConversationsPreferenceController(
+ mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(mockPref);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void updateState_TotalSilence() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
+
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ }
+
+ @Test
+ public void updateState_AlarmsOnly() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
+
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ }
+
+ @Test
+ public void updateState_Priority_important() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_important_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+ }
+
+ @Test
+ public void updateState_Priority_all() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_ANYONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_all_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_ANYONE));
+ }
+
+ @Test
+ public void updateState_Priority_none() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_NONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(false);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ }
+
+ @Test
+ public void onPreferenceChange_noneToImportant() {
+ // start with none
+
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_NONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(false);
+
+ mController.updateState(mockPref);
+ reset(mBackend);
+
+ mController.onPreferenceChange(mockPref, String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+
+ verify(mBackend).saveConversationSenders(CONVERSATION_SENDERS_IMPORTANT);
+ verify(mBackend).getPriorityConversationSenders();
+ }
+
+ @Test
+ public void onPreferenceChange_allToNone() {
+ // start with none
+
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_ANYONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+ mController.updateState(mockPref);
+ reset(mBackend);
+
+ mController.onPreferenceChange(mockPref, String.valueOf(CONVERSATION_SENDERS_NONE));
+
+ verify(mBackend).saveConversationSenders(CONVERSATION_SENDERS_NONE);
+ verify(mBackend).getPriorityConversationSenders();
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
index 3ecd22a..7af2211 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
@@ -34,8 +34,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.notification.zen.ZenModeBackend;
-import com.android.settings.notification.zen.ZenModePriorityMessagesPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -88,7 +86,7 @@
when(mBackend.getPriorityMessageSenders())
.thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES)).thenCallRealMethod();
when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
.thenCallRealMethod();
diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java
new file mode 100644
index 0000000..bf2b0f3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2020 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.sound;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+import android.telephony.TelephonyManager;
+
+import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowDeviceConfig.class})
+public class VibrateForCallsPreferenceControllerTest {
+
+ private static final int OFF = 0;
+ private static final int ON = 1;
+ private Context mContext;
+ private ContentResolver mContentResolver;
+ @Mock
+ private TelephonyManager mTelephonyManager;
+ private VibrateForCallsPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mContentResolver = mContext.getContentResolver();
+ when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
+ mController = new VibrateForCallsPreferenceController(
+ mContext, VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notVoiceCapable_returnUnsupportedOnDevice() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "false", false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_rampingRingerEnabled_returnUnsupportedOnDevice() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "true", false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_voiceCapableAndRampingRingerDisabled_returnAvailable() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "false", false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getSummary_applyRampingRinger_rampingRingerSummary() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer));
+ }
+
+ @Test
+ public void getSummary_enableVibrateWhenRinging_alwaysVibrateSummary() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate));
+ }
+
+ @Test
+ public void getSummary_notApplyRampingRingerDisableVibrateWhenRinging_neverVibrateSummary() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java
new file mode 100644
index 0000000..0a766d6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2020 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.sound;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class VibrateForCallsPreferenceFragmentTest {
+
+ private static final int OFF = 0;
+ private static final int ON = 1;
+ private Context mContext;
+ private ContentResolver mContentResolver;
+ private VibrateForCallsPreferenceFragment mFragment;
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+ mContentResolver = mContext.getContentResolver();
+ mFragment = spy(new VibrateForCallsPreferenceFragment());
+ doReturn(mContext).when(mFragment).getContext();
+ mFragment.onAttach(mContext);
+ }
+
+ @Test
+ public void getDefaultKey_applyRampingRinger_keyRampingRinger() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
+
+ assertThat(mFragment.getDefaultKey()).isEqualTo(
+ VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
+ }
+
+ @Test
+ public void getDefaultKey_enableVibrateWhenRinging_keyAlwaysVibrate() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mFragment.getDefaultKey()).isEqualTo(
+ VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
+ }
+
+ @Test
+ public void getDefaultKey_notApplyRampingRingerDisableVibrateWhenRinging_keyNeverVibrate() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mFragment.getDefaultKey()).isEqualTo(
+ VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
+ }
+
+ @Test
+ public void setDefaultKey_keyRampingRinger_applyRampingRingerDisableVibrateWhenRinging() {
+ mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
+
+ assertThat(Settings.Global.getInt(
+ mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON);
+ assertThat(Settings.System.getInt(
+ mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
+ }
+
+ @Test
+ public void setDefaultKey_keyAlwaysVibrate_notApplyRampingRingerEnableVibrateWhenRinging() {
+ mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
+
+ assertThat(Settings.Global.getInt(
+ mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
+ assertThat(Settings.System.getInt(
+ mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(ON);
+ }
+
+ @Test
+ public void setDefaultKey_keyNeverVibrate_notApplyRampingRingerDisableVibrateWhenRinging() {
+ mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
+
+ assertThat(Settings.Global.getInt(
+ mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
+ assertThat(Settings.System.getInt(
+ mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
index ae236bf..955b721 100644
--- a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
@@ -26,6 +26,7 @@
import android.app.settings.SettingsEnums;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkSuggestion;
import android.os.Bundle;
import android.os.Parcelable;
@@ -59,7 +60,8 @@
private static final String FAKE_NEW_SAVED_WPA_SSID = "\"fake_new_wpa_ssid\"";
private static final String KEY_SSID = "key_ssid";
private static final String KEY_SECURITY = "key_security";
- private static final int SCANED_LEVEL = 4;
+ private static final int SCANED_LEVEL0 = 0;
+ private static final int SCANED_LEVEL4 = 4;
private AddAppNetworksFragment mAddAppNetworksFragment;
private List<WifiNetworkSuggestion> mFakedSpecifiedNetworksList;
@@ -76,6 +78,9 @@
@Mock
private WifiTracker mMockWifiTracker;
+ @Mock
+ private WifiManager mMockWifiManager;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -86,10 +91,13 @@
WifiConfiguration.KeyMgmt.NONE, null);
mSavedWpaConfigurationEntry = generateRegularWifiConfiguration(FAKE_NEW_SAVED_WPA_SSID,
WifiConfiguration.KeyMgmt.WPA_PSK, "\"1234567890\"");
+ when(mMockWifiTracker.getManager()).thenReturn(mMockWifiManager);
+ when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
+
mAddAppNetworksFragment.mWifiTracker = mMockWifiTracker;
WifiTrackerFactory.setTestingWifiTracker(mMockWifiTracker);
- setUpOneScannedNetworkWithScanedLevel();
+ setUpOneScannedNetworkWithScanedLevel4();
}
@Test
@@ -208,6 +216,7 @@
@Test
public void withOneSuggestion_whenScanResultChanged_uiListShouldHaveNewLevel() {
// Arrange
+ when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(true);
// Setup a fake saved network list and assign to fragment.
addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
// Setup one specified networks and its results and assign to fragment.
@@ -221,16 +230,36 @@
// Assert
assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
- SCANED_LEVEL);
+ SCANED_LEVEL4);
}
- private void setUpOneScannedNetworkWithScanedLevel() {
+ @Test
+ public void withOneSuggestion_whenScanResultChangedButWifiOff_uiListShouldHaveZeroLevel() {
+ // Arrange
+ when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(false);
+ // Setup a fake saved network list and assign to fragment.
+ addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
+ // Setup one specified networks and its results and assign to fragment.
+ addOneSpecifiedRegularNetworkSuggestion(mNewOpenSuggestionEntry);
+ mAddAppNetworksFragment.mAllSpecifiedNetworksList = mFakedSpecifiedNetworksList;
+ // Call filterSavedNetworks to generate necessary objects.
+ mAddAppNetworksFragment.filterSavedNetworks(mFakeSavedNetworksList);
+
+ // Act
+ mAddAppNetworksFragment.onAccessPointsChanged();
+
+ // Assert
+ assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
+ SCANED_LEVEL0);
+ }
+
+ private void setUpOneScannedNetworkWithScanedLevel4() {
final ArrayList list = new ArrayList<>();
list.add(mMockAccessPoint);
when(mMockWifiTracker.getAccessPoints()).thenReturn(list);
when(mMockAccessPoint.getSsidStr()).thenReturn(FAKE_NEW_OPEN_SSID);
when(mMockAccessPoint.matches(any(WifiConfiguration.class))).thenReturn(true);
- when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL);
+ when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL4);
}
private void addOneSavedNetworkConfiguration(@NonNull WifiConfiguration wifiConfiguration) {
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
index b4ad167..e864ce3 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
@@ -28,14 +28,13 @@
import com.android.settings.R;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowLooper;
@RunWith(RobolectricTestRunner.class)
-@Ignore
public class ListWithEntrySummaryPreferenceTest {
private Context mContext;
@@ -55,6 +54,7 @@
public void setUp() {
mContext = RuntimeEnvironment.application;
mContext.setTheme(R.style.Theme_Settings_Home);
+ ShadowLooper.pauseMainLooper();
mPreference = new ListWithEntrySummaryPreference(mContext, null);
mPreference.setEntries(mDefaultEntries);
mPreference.setEntryValues(mDefaultEntryValues);
@@ -62,7 +62,7 @@
}
@Test
- public void initialize_defaultEntries_shouldDisplayDefalutEntries() {
+ public void initialize_defaultEntries_shouldDisplayDefaultEntries() {
AlertDialog dialog = showDialog(mPreference);
ListAdapter adapter = dialog.getListView().getAdapter();
diff --git a/tests/uitests/assets/search_results_list b/tests/uitests/assets/search_results_list
index f2536ef..a6dafe2 100644
--- a/tests/uitests/assets/search_results_list
+++ b/tests/uitests/assets/search_results_list
@@ -224,7 +224,7 @@
Enable Bluetooth HCI snoop log;bt_hci_snoop_log
Enable GPU debug layers;enable_gpu_debug_layers
Enable Wi-Fi Verbose Logging;wifi_verbose_logging
-Enable for all apps;game_driver_all_apps_preference
+Enable for all apps;graphics_driver_all_apps_preference
Enable freeform windows;enable_freeform_support
Enable view attribute inspection;debug_view_attributes
Encrypt phone;encryption_and_credentials_encryption_status
@@ -256,7 +256,7 @@
Force desktop mode;force_desktop_mode_on_external_displays
Force full GNSS measurements;enable_gnss_raw_meas_full_tracking
Free up space;storage_settings_free_space
-Game Driver Preferences;game_driver_settings
+Graphics Driver Preferences;graphics_driver_settings
Games;pref_games
Gestures;gesture_settings
Gestures;gesture_settings_screen
@@ -612,7 +612,7 @@
Wallpaper;wallpaper
Wallpapers;wallpaper_attributions
WebView implementation;select_webview_provider
-When Game Driver is turned on, you can pick to use the updated graphics driver for Apps installed on the device.;game_driver_footer
+When there are multiple graphics drivers, you can pick to use the updated graphics driver for Apps installed on the device.;graphics_driver_footer
When device is in VR;vr_display_pref
When to start;when_to_start
Wi-Fi;main_toggle_wifi
diff --git a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
index 4ebfef7..bc8a52a 100644
--- a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
+++ b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
@@ -316,7 +316,8 @@
assertThat(accessPoint.getConfig()).isNotNull();
NetworkSelectionStatus networkStatus = accessPoint.getConfig().getNetworkSelectionStatus();
assertThat(networkStatus).isNotNull();
- assertThat(networkStatus.isNetworkEnabled()).isFalse();
+ assertThat(networkStatus.getNetworkSelectionStatus())
+ .isEqualTo(NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED);
assertThat(networkStatus.getNetworkSelectionDisableReason()).isEqualTo(
NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);