Snap for 5503058 from 703e6aa092 to qt-release

Change-Id: I50166996205f3b2f7c55855bdc671790ac578f13
This commit is contained in:
android-build-team Robot
2019-04-25 03:03:43 +00:00
53 changed files with 928 additions and 268 deletions

View File

@@ -1276,6 +1276,8 @@
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.privacy.PrivacyDashboardFragment" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
<activity android:name="SetFullBackupPassword"
@@ -1629,6 +1631,7 @@
android:resource="@string/suggestion_additional_fingerprints" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/suggestion_additional_fingerprints_summary" />
<meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity-alias>
<!-- Note this must not be exported since it returns the password in the intent -->

Binary file not shown.

Before

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 814 B

View File

@@ -0,0 +1,30 @@
<!--
~ 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
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M20,2H4C2.9,2 2.01,2.9 2.01,4L2,22l4,-4h14c1.1,0 2,-0.9 2,-2V4C22,2.9 21.1,2 20,2zM20,16H6H5.17l-0.59,0.59L4,17.17V4h16V16z"/>
<path
android:fillColor="#FF000000"
android:pathData="M11,12h2v2h-2z"/>
<path
android:fillColor="#FF000000"
android:pathData="M11,6h2v4h-2z"/>
</vector>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/security_settings_face_settings_enroll_button"
android:layout_marginStart="@dimen/screen_margin_sides"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/security_settings_face_settings_enroll"/>
</LinearLayout>

BIN
res/raw/bubbles.mp4 Normal file

Binary file not shown.

View File

@@ -24,5 +24,7 @@
<color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
<color name="contextual_card_background">@*android:color/material_grey_900</color>
<color name="search_bar_background">@*android:color/material_grey_800</color>
<!-- Dialog background color -->
<color name="dialog_background">@*android:color/material_grey_800</color>
</resources>

View File

@@ -33,6 +33,7 @@
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
<item name="colorAccent">@*android:color/accent_device_default_dark</item>
<item name="android:background">@color/dialog_background</item>
</style>
</resources>

View File

@@ -143,4 +143,7 @@
<!-- Search bar background color -->
<color name="search_bar_background">@android:color/white</color>
<!-- Dialog background color -->
<color name="dialog_background">@*android:color/background_device_default_light</color>
</resources>

View File

@@ -948,6 +948,8 @@
<string name="security_settings_face_settings_require_confirmation_details">When authenticating in apps, always require confirmation</string>
<!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] -->
<string name="security_settings_face_settings_remove_face_data">Remove face data</string>
<!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] -->
<string name="security_settings_face_settings_enroll">Set up face authentication</string>
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_settings_footer">Your face can be used to unlock your device and access apps.
<annotation id="url">Learn more</annotation></string>
@@ -2761,6 +2763,8 @@
<string name="brightness_summary">Adjust the brightness of the screen</string>
<!-- Sound & display settings screen, setting option name to enable adaptive brightness [CHAR LIMIT=30] -->
<string name="auto_brightness_title">Adaptive brightness</string>
<!-- Summary about the feature adaptive brightness [CHAR LIMIT=NONE] -->
<string name="auto_brightness_summary">Screen brightness adjusts to environment</string>
<!-- Setting option summary when adaptive brightness is on [CHAR LIMIT=NONE] -->
<string name="auto_brightness_summary_on">On</string>
<!-- Setting option summary when adaptive brightness is off [CHAR LIMIT=NONE] -->
@@ -7194,8 +7198,6 @@
<string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string>
<!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
<!-- Search keyword for "Adaptive brightness" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_auto_brightness">Auto brightness</string>
<!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
@@ -7282,7 +7284,7 @@
<string name="keywords_fingerprint_settings">fingerprint, add fingerprint</string>
<!-- Search keywords for adaptive brightness setting [CHAR LIMIT=NONE]-->
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness, Auto brightness</string>
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
<string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
@@ -7808,19 +7810,19 @@
<string name="asst_capability_prioritizer_title">Automatic Prioritization</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=200] -->
<string name="asst_capability_prioritizer_summary">Automatically de-prioritize less important notifications to the gentle section</string>
<string name="asst_capability_prioritizer_summary">Automatically set lower priority notifications to Gentle</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="asst_capabilities_actions_replies_title">Smart actions and replies</string>
<string name="asst_capabilities_actions_replies_title">Suggested actions and replies</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=200] -->
<string name="asst_capabilities_actions_replies_summary">Automatically add suggested actions and replies to notifications</string>
<string name="asst_capabilities_actions_replies_summary">Automatically show suggested actions &amp; replies</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="hide_silent_icons_title">Hide silent notification status icons</string>
<string name="hide_silent_icons_title">Hide icons from gentle notifications</string>
<!-- Configure Notifications: setting summary [CHAR LIMIT=NONE] -->
<string name="hide_silent_icons_summary">Hide icons for silent notifications in the status bar</string>
<string name="hide_silent_icons_summary">Icons from gentle notifications aren\'t shown in the status bar</string>
<!-- Configure Notifications: Title for the notification badging option. [CHAR LIMIT=30 BACKUP_MESSAGE_ID=5125022693565388760] -->
<string name="notification_badging_title">Allow notification dots</string>
@@ -7977,33 +7979,38 @@
<string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low">Gentle notifications will display in pull-down list</string>
<string name="notification_channel_summary_low">Always silent. Displays in pull-down shade.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low_status">Gentle notifications will display in pull-down list &amp; status bar</string>
<string name="notification_channel_summary_low_status">Always silent. Displays in pull-down shade &amp; status bar.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low_lock">Gentle notifications will display in pull-down list &amp; on lock screen</string>
<string name="notification_channel_summary_low_lock">Always silent. Displays in pull-down shade &amp; on lock screen.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
<string name="notification_channel_summary_low_status_lock">Gentle notifications will display in pull-down list, status bar &amp; on lock screen</string>
<string name="notification_channel_summary_low_status_lock">Always silent. Displays in pull-down shade, status bar &amp; on lock screen.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: normal importance level summary -->
<string name="notification_channel_summary_default">Prioritized notifications will alert and display in pull-down list, status bar &amp; on lock screen</string>
<string name="notification_channel_summary_default">Makes sound and displays in pull-down shade, status bar &amp; on lock screen.</string>
<!-- [CHAR LIMIT=100] Notification Importance title: high importance level summary -->
<string name="notification_channel_summary_high">When phone is unlocked, show notifications as a banner across top of screen</string>
<string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>
<!-- [CHAR LIMIT=100] Label for on/off toggle -->
<string name="notification_switch_label">Show notifications</string>
<!-- Default Apps > Default notification assistant -->
<string name="default_notification_assistant">Notification assistant</string>
<string name="default_notification_assistant">Adaptive Notifications</string>
<!-- app summary of notification app list screen [CHAR LIMIT=100] -->
<string name="notifications_sent_daily">~<xliff:g id="number">%1$s</xliff:g> per day</string>
<!-- app summary of notification app list screen [CHAR LIMIT=100] -->
<string name="notifications_sent_weekly">~<xliff:g id="number">%1$s</xliff:g> per week</string>
<plurals name="notifications_sent_daily">
<item quantity="one">~<xliff:g id="number">%d</xliff:g> notification per day</item>
<item quantity="other">~<xliff:g id="number">%d</xliff:g> notifications per day</item>
</plurals>
<plurals name="notifications_sent_weekly">
<item quantity="one">~<xliff:g id="number">%d</xliff:g> notification per week</item>
<item quantity="other">~<xliff:g id="number">%d</xliff:g> notifications per week</item>
</plurals>
<!-- app summary of notification app list screen [CHAR LIMIT=100] -->
<string name="notifications_sent_never">Never</string>
@@ -8025,10 +8032,10 @@
</plurals>
<!-- Title for Notification Assistant Picker screen [CHAR LIMIT=30]-->
<string name="notification_assistant_title">Notification Assistant</string>
<string name="notification_assistant_title">Adaptive Notifications</string>
<!-- Label for no NotificationAssistantService [CHAR_LIMIT=NONE] -->
<string name="no_notification_assistant">No assistant</string>
<string name="no_notification_assistant">None</string>
<!-- String to show in the list of notification listeners, when none is installed -->
<string name="no_notification_listeners">No installed apps have requested notification access.</string>

View File

@@ -117,6 +117,7 @@
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
<item name="colorAccent">@*android:color/accent_device_default_light</item>
<item name="android:background">@color/dialog_background</item>
</style>
<style name="Theme.AlertDialog" parent="Theme.AlertDialog.Base">

View File

@@ -32,8 +32,9 @@
<com.android.settingslib.RestrictedSwitchPreference
android:key="auto_brightness"
android:title="@string/auto_brightness_title"
android:summary="@string/auto_brightness_summary"
settings:keywords="@string/keywords_display_auto_brightness"
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
settings:controller="com.android.settings.display.AutoBrightnessDetailPreferenceController"
settings:useAdminDisabledSummary="true"
settings:userRestriction="no_config_brightness"
settings:allowDividerAbove="true" />

View File

@@ -18,6 +18,14 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/bubbles_app_toggle_title"
android:key="bubble_notification_settings">
<com.android.settings.widget.VideoPreference
android:key="bubbles_illustration"
android:title="@string/summary_placeholder"
settings:animation="@raw/bubbles"
settings:controller="com.android.settings.widget.VideoPreferenceController"
android:persistent="false" />
<!-- Notification bubbles -->
<SwitchPreference
android:key="global_notification_bubbles"

View File

@@ -44,8 +44,7 @@
android:title="@string/auto_brightness_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.display.AutoBrightnessSettings"
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
settings:keywords="@string/keywords_auto_brightness"/>
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"/>
<com.android.settingslib.RestrictedPreference
android:key="wallpaper"

View File

@@ -24,162 +24,170 @@
android:layout="@layout/styled_switch_bar"
settings:controller="com.android.settings.network.telephony.MobileNetworkSwitchController"/>
<com.android.settings.datausage.DataUsageSummaryPreference
android:key="status_header"
android:visibility="gone"
android:selectable="false" />
<ListPreference
android:key="calls_preference"
android:title="@string/calls_preference"
settings:controller="com.android.settings.network.telephony.CallsDefaultSubscriptionController"
settings:allowDividerAbove="true" />
<ListPreference
android:key="sms_preference"
android:title="@string/sms_preference"
settings:controller="com.android.settings.network.telephony.SmsDefaultSubscriptionController" />
<Preference
android:key="cdma_lte_data_service_key"
android:title="@string/cdma_lte_data_service"
settings:controller="com.android.settings.network.telephony.DataServiceSetupPreferenceController"
settings:allowDividerAbove="true"
settings:allowDividerBelow="false" />
<SwitchPreference
android:key="mobile_data_enable"
android:title="@string/mobile_data_settings_title"
android:summary="@string/mobile_data_settings_summary"
settings:controller="com.android.settings.network.telephony.MobileDataPreferenceController"
settings:allowDividerAbove="true"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="button_roaming_key"
android:title="@string/roaming"
android:persistent="false"
android:summaryOn="@string/roaming_enable"
android:summaryOff="@string/roaming_disable"
settings:userRestriction="no_data_roaming"
settings:controller="com.android.settings.network.telephony.RoamingPreferenceController"/>
<Preference
android:key="data_usage_summary"
android:title="@string/mobile_data_usage_title"
settings:controller="com.android.settings.network.telephony.DataUsagePreferenceController"/>
<com.android.settings.datausage.BillingCyclePreference
android:key="billing_preference"
android:title="@string/billing_cycle"
settings:controller="com.android.settings.datausage.BillingCyclePreferenceController" />
<SwitchPreference
android:key="mms_message"
android:title="@string/mms_message_title"
android:summary="@string/mms_message_summary"
settings:controller="com.android.settings.network.telephony.MmsMessagePreferenceController" />
<SwitchPreference
android:key="enhanced_4g_lte"
android:title="@string/enhanced_4g_lte_mode_title"
android:persistent="false"
android:summary="@string/enhanced_4g_lte_mode_summary"
settings:controller="com.android.settings.network.telephony.Enhanced4gLtePreferenceController"/>
<ListPreference
android:key="preferred_network_mode_key"
android:title="@string/preferred_network_mode_title"
android:summary="@string/preferred_network_mode_summary"
android:entries="@array/preferred_network_mode_choices"
android:entryValues="@array/preferred_network_mode_values"
android:dialogTitle="@string/preferred_network_mode_dialogtitle"
settings:controller="com.android.settings.network.telephony.PreferredNetworkModePreferenceController"/>
<ListPreference
android:key="enabled_networks_key"
android:title="@string/preferred_network_mode_title"
android:summary="@string/preferred_network_mode_summary"
android:entries="@array/enabled_networks_choices"
android:entryValues="@array/enabled_networks_values"
android:dialogTitle="@string/preferred_network_mode_dialogtitle"
settings:controller="com.android.settings.network.telephony.EnabledNetworkModePreferenceController"/>
<Preference
android:key="carrier_settings_version_key"
android:title="@string/carrier_settings_version"
settings:controller="com.android.settings.network.telephony.CarrierSettingsVersionPreferenceController"
settings:enableCopying="true" />
<PreferenceCategory
android:key="calling_category"
android:title="@string/call_category">
android:key="enabled_state_container"
android:title="@string/summary_placeholder"
settings:controller="com.android.settings.network.telephony.DisabledSubscriptionController"
android:layout="@layout/preference_category_no_label">
<PreferenceScreen
android:key="wifi_calling_key"
android:title="@string/wifi_calling_settings_title"
settings:controller="com.android.settings.network.telephony.WifiCallingPreferenceController" >
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.Settings$WifiCallingSettingsActivity">
<extra android:name="show_drawer_menu" android:value="true" />
</intent>
</PreferenceScreen>
<com.android.settings.datausage.DataUsageSummaryPreference
android:key="status_header"
android:visibility="gone"
android:selectable="false" />
<SwitchPreference
android:key="video_calling_key"
android:title="@string/video_calling_settings_title"
android:persistent="true"
settings:controller="com.android.settings.network.telephony.VideoCallingPreferenceController" />
<ListPreference
android:key="calls_preference"
android:title="@string/calls_preference"
settings:controller="com.android.settings.network.telephony.CallsDefaultSubscriptionController"
settings:allowDividerAbove="true"/>
</PreferenceCategory>
<com.android.settings.network.telephony.cdma.CdmaListPreference
android:key="cdma_system_select_key"
android:title="@string/cdma_system_select_title"
android:summary="@string/cdma_system_select_summary"
android:entries="@array/cdma_system_select_choices"
android:entryValues="@array/cdma_system_select_values"
android:dialogTitle="@string/cdma_system_select_dialogtitle"
settings:controller="com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController"/>
<com.android.settings.network.telephony.cdma.CdmaListPreference
android:key="cdma_subscription_key"
android:title="@string/cdma_subscription_title"
android:summary="@string/cdma_subscription_summary"
android:entries="@array/cdma_subscription_choices"
android:entryValues="@array/cdma_subscription_values"
android:dialogTitle="@string/cdma_subscription_dialogtitle"
settings:controller="com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController"/>
<PreferenceCategory
android:key="network_operators_category_key"
android:title="@string/network_operator_category"
settings:controller="com.android.settings.widget.PreferenceCategoryController">
<SwitchPreference
android:key="auto_select_key"
android:title="@string/select_automatically"
settings:controller="com.android.settings.network.telephony.gsm.AutoSelectPreferenceController"/>
<ListPreference
android:key="sms_preference"
android:title="@string/sms_preference"
settings:controller="com.android.settings.network.telephony.SmsDefaultSubscriptionController"/>
<Preference
android:key="choose_network_key"
android:title="@string/choose_network_title"
android:fragment="com.android.phone.NetworkSelectSetting"
settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
android:key="cdma_lte_data_service_key"
android:title="@string/cdma_lte_data_service"
settings:controller="com.android.settings.network.telephony.DataServiceSetupPreferenceController"
settings:allowDividerAbove="true"
settings:allowDividerBelow="false"/>
<SwitchPreference
android:key="mobile_data_enable"
android:title="@string/mobile_data_settings_title"
android:summary="@string/mobile_data_settings_summary"
settings:controller="com.android.settings.network.telephony.MobileDataPreferenceController"
settings:allowDividerAbove="true"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="button_roaming_key"
android:title="@string/roaming"
android:persistent="false"
android:summaryOn="@string/roaming_enable"
android:summaryOff="@string/roaming_disable"
settings:userRestriction="no_data_roaming"
settings:controller="com.android.settings.network.telephony.RoamingPreferenceController"/>
<Preference
android:key="data_usage_summary"
android:title="@string/mobile_data_usage_title"
settings:controller="com.android.settings.network.telephony.DataUsagePreferenceController"/>
<com.android.settings.datausage.BillingCyclePreference
android:key="billing_preference"
android:title="@string/billing_cycle"
settings:controller="com.android.settings.datausage.BillingCyclePreferenceController"/>
<SwitchPreference
android:key="mms_message"
android:title="@string/mms_message_title"
android:summary="@string/mms_message_summary"
settings:controller="com.android.settings.network.telephony.MmsMessagePreferenceController"/>
<SwitchPreference
android:key="enhanced_4g_lte"
android:title="@string/enhanced_4g_lte_mode_title"
android:persistent="false"
android:summary="@string/enhanced_4g_lte_mode_summary"
settings:controller="com.android.settings.network.telephony.Enhanced4gLtePreferenceController"/>
<ListPreference
android:key="preferred_network_mode_key"
android:title="@string/preferred_network_mode_title"
android:summary="@string/preferred_network_mode_summary"
android:entries="@array/preferred_network_mode_choices"
android:entryValues="@array/preferred_network_mode_values"
android:dialogTitle="@string/preferred_network_mode_dialogtitle"
settings:controller="com.android.settings.network.telephony.PreferredNetworkModePreferenceController"/>
<ListPreference
android:key="enabled_networks_key"
android:title="@string/preferred_network_mode_title"
android:summary="@string/preferred_network_mode_summary"
android:entries="@array/enabled_networks_choices"
android:entryValues="@array/enabled_networks_values"
android:dialogTitle="@string/preferred_network_mode_dialogtitle"
settings:controller="com.android.settings.network.telephony.EnabledNetworkModePreferenceController"/>
<Preference
android:key="carrier_settings_version_key"
android:title="@string/carrier_settings_version"
settings:controller="com.android.settings.network.telephony.CarrierSettingsVersionPreferenceController"
settings:enableCopying="true"/>
<PreferenceCategory
android:key="calling_category"
android:title="@string/call_category">
<PreferenceScreen
android:key="wifi_calling_key"
android:title="@string/wifi_calling_settings_title"
settings:controller="com.android.settings.network.telephony.WifiCallingPreferenceController">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.Settings$WifiCallingSettingsActivity">
<extra android:name="show_drawer_menu" android:value="true"/>
</intent>
</PreferenceScreen>
<SwitchPreference
android:key="video_calling_key"
android:title="@string/video_calling_settings_title"
android:persistent="true"
settings:controller="com.android.settings.network.telephony.VideoCallingPreferenceController"/>
</PreferenceCategory>
<com.android.settings.network.telephony.cdma.CdmaListPreference
android:key="cdma_system_select_key"
android:title="@string/cdma_system_select_title"
android:summary="@string/cdma_system_select_summary"
android:entries="@array/cdma_system_select_choices"
android:entryValues="@array/cdma_system_select_values"
android:dialogTitle="@string/cdma_system_select_dialogtitle"
settings:controller="com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController"/>
<com.android.settings.network.telephony.cdma.CdmaListPreference
android:key="cdma_subscription_key"
android:title="@string/cdma_subscription_title"
android:summary="@string/cdma_subscription_summary"
android:entries="@array/cdma_subscription_choices"
android:entryValues="@array/cdma_subscription_values"
android:dialogTitle="@string/cdma_subscription_dialogtitle"
settings:controller="com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController"/>
<PreferenceCategory
android:key="network_operators_category_key"
android:title="@string/network_operator_category"
settings:controller="com.android.settings.widget.PreferenceCategoryController">
<SwitchPreference
android:key="auto_select_key"
android:title="@string/select_automatically"
settings:controller="com.android.settings.network.telephony.gsm.AutoSelectPreferenceController"/>
<Preference
android:key="choose_network_key"
android:title="@string/choose_network_title"
android:fragment="com.android.phone.NetworkSelectSetting"
settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
</PreferenceCategory>
<!--We want separate APN setting from reset of settings because we want user to change it with caution-->
<com.android.settingslib.RestrictedPreference
android:key="telephony_apn_key"
android:persistent="false"
android:title="@string/mobile_network_apn_title"
settings:allowDividerAbove="true"
settings:controller="com.android.settings.network.telephony.ApnPreferenceController"/>
<Preference
android:key="carrier_settings_key"
android:title="@string/carrier_settings_title"
settings:controller="com.android.settings.network.telephony.CarrierPreferenceController">
</Preference>
</PreferenceCategory>
<!--We want separate APN setting from reset of settings because we want user to change it with caution-->
<com.android.settingslib.RestrictedPreference
android:key="telephony_apn_key"
android:persistent="false"
android:title="@string/mobile_network_apn_title"
settings:allowDividerAbove="true"
settings:controller="com.android.settings.network.telephony.ApnPreferenceController"/>
<Preference
android:key="carrier_settings_key"
android:title="@string/carrier_settings_title"
settings:controller="com.android.settings.network.telephony.CarrierPreferenceController">
</Preference>
</PreferenceScreen>

View File

@@ -61,6 +61,11 @@
android:key="security_settings_face_delete_faces_container"
android:selectable="false"
android:layout="@layout/face_remove_button" />
<com.android.settingslib.widget.LayoutPreference
android:key="security_settings_face_enroll_faces_container"
android:selectable="false"
android:layout="@layout/face_enroll_button " />
</PreferenceCategory>
<PreferenceCategory

View File

@@ -108,10 +108,12 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
return StringUtil.formatRelativeTime(
context, System.currentTimeMillis() - state.lastSent, true);
} else if (sortOrder == R.id.sort_order_frequent_notification) {
if (state.avgSentWeekly > 0) {
return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly);
if (state.avgSentDaily > 0) {
return context.getResources().getQuantityString(
R.plurals.notifications_sent_daily, state.avgSentDaily, state.avgSentDaily);
}
return context.getString(R.string.notifications_sent_daily, state.avgSentDaily);
return context.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
state.avgSentWeekly, state.avgSentWeekly);
} else {
return "";
}

View File

@@ -76,7 +76,7 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
public static final int BIOMETRIC_FIND_SENSOR_REQUEST = 2;
public static final int LEARN_MORE_REQUEST = 3;
public static final int CONFIRM_REQUEST = 4;
public static final int ENROLLING = 5;
public static final int ENROLL_REQUEST = 5;
protected boolean mLaunchedConfirmLock;
protected byte[] mToken;

View File

@@ -31,6 +31,8 @@ import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.util.Log;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
@@ -52,7 +54,7 @@ import java.util.List;
public class FaceSettings extends DashboardFragment {
private static final String TAG = "FaceSettings";
private static final String KEY_TOKEN = "key_token";
private static final String KEY_TOKEN = "hw_auth_token";
private UserManager mUserManager;
private FaceManager mFaceManager;
@@ -60,12 +62,23 @@ public class FaceSettings extends DashboardFragment {
private byte[] mToken;
private FaceSettingsAttentionPreferenceController mAttentionController;
private FaceSettingsRemoveButtonPreferenceController mRemoveController;
private FaceSettingsEnrollButtonPreferenceController mEnrollController;
private List<AbstractPreferenceController> mControllers;
private List<Preference> mTogglePreferences;
private Preference mRemoveButton;
private Preference mEnrollButton;
private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> {
if (getActivity() != null) {
getActivity().finish();
// Disable the toggles until the user re-enrolls
for (Preference preference : mTogglePreferences) {
preference.setEnabled(false);
}
// Hide the "remove" button and show the "set up face authentication" button.
mRemoveButton.setVisible(false);
mEnrollButton.setVisible(true);
};
public static boolean isAvailable(Context context) {
@@ -98,15 +111,28 @@ public class FaceSettings extends DashboardFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
mUserManager = getPrefContext().getSystemService(UserManager.class);
mFaceManager = getPrefContext().getSystemService(FaceManager.class);
mUserId = getActivity().getIntent().getIntExtra(
Intent.EXTRA_USER_ID, UserHandle.myUserId());
Preference keyguardPref = findPreference(FaceSettingsKeyguardPreferenceController.KEY);
Preference appPref = findPreference(FaceSettingsAppPreferenceController.KEY);
Preference attentionPref = findPreference(FaceSettingsAttentionPreferenceController.KEY);
Preference confirmPref = findPreference(FaceSettingsConfirmPreferenceController.KEY);
mTogglePreferences = new ArrayList<>(
Arrays.asList(keyguardPref, appPref, attentionPref, confirmPref));
mRemoveButton = findPreference(FaceSettingsRemoveButtonPreferenceController.KEY);
mEnrollButton = findPreference(FaceSettingsEnrollButtonPreferenceController.KEY);
// There is no better way to do this :/
for (AbstractPreferenceController controller : mControllers) {
if (controller instanceof FaceSettingsPreferenceController) {
((FaceSettingsPreferenceController) controller).setUserId(mUserId);
} else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) {
((FaceSettingsEnrollButtonPreferenceController) controller).setUserId(mUserId);
}
}
mRemoveController.setUserId(mUserId);
@@ -137,7 +163,12 @@ public class FaceSettings extends DashboardFragment {
super.onResume();
if (mToken != null) {
mAttentionController.setToken(mToken);
mEnrollController.setToken(mToken);
}
final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId);
mEnrollButton.setVisible(!hasEnrolled);
mRemoveButton.setVisible(hasEnrolled);
}
@Override
@@ -152,6 +183,7 @@ public class FaceSettings extends DashboardFragment {
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
if (mToken != null) {
mAttentionController.setToken(mToken);
mEnrollController.setToken(mToken);
}
}
}
@@ -188,6 +220,9 @@ public class FaceSettings extends DashboardFragment {
mRemoveController = (FaceSettingsRemoveButtonPreferenceController) controller;
mRemoveController.setListener(mRemovalListener);
mRemoveController.setActivity((SettingsActivity) getActivity());
} else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) {
mEnrollController = (FaceSettingsEnrollButtonPreferenceController) controller;
mEnrollController.setActivity((SettingsActivity) getActivity());
}
}
@@ -204,6 +239,7 @@ public class FaceSettings extends DashboardFragment {
controllers.add(new FaceSettingsRemoveButtonPreferenceController(context));
controllers.add(new FaceSettingsFooterPreferenceController(context));
controllers.add(new FaceSettingsConfirmPreferenceController(context));
controllers.add(new FaceSettingsEnrollButtonPreferenceController(context));
return controllers;
}

View File

@@ -19,22 +19,28 @@ package com.android.settings.biometrics.face;
import static android.provider.Settings.Secure.FACE_UNLOCK_APP_ENABLED;
import android.content.Context;
import android.hardware.face.FaceManager;
import android.provider.Settings;
import androidx.preference.Preference;
/**
* Preference controller for Face settings page controlling the ability to use
* Face authentication in apps (through BiometricPrompt).
*/
public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceController {
private static final String KEY = "security_settings_face_app";
static final String KEY = "security_settings_face_app";
private static final int ON = 1;
private static final int OFF = 0;
private static final int DEFAULT = ON; // face unlock is enabled for BiometricPrompt by default
private FaceManager mFaceManager;
public FaceSettingsAppPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mFaceManager = context.getSystemService(FaceManager.class);
}
public FaceSettingsAppPreferenceController(Context context) {
@@ -56,6 +62,18 @@ public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceC
isChecked ? ON : OFF, getUserId());
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (!FaceSettings.isAvailable(mContext)) {
preference.setEnabled(false);
} else if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
preference.setEnabled(false);
} else {
preference.setEnabled(true);
}
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;

View File

@@ -60,8 +60,12 @@ public class FaceSettingsAttentionPreferenceController extends FaceSettingsPrefe
@Override
public void onCompleted(boolean success, int feature, boolean value) {
if (feature == FaceManager.FEATURE_REQUIRE_ATTENTION && success) {
mPreference.setEnabled(true);
mPreference.setChecked(value);
if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
mPreference.setEnabled(false);
} else {
mPreference.setEnabled(true);
mPreference.setChecked(value);
}
}
}
};

View File

@@ -19,8 +19,11 @@ package com.android.settings.biometrics.face;
import static android.provider.Settings.Secure.FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION;
import android.content.Context;
import android.hardware.face.FaceManager;
import android.provider.Settings;
import androidx.preference.Preference;
import com.android.settings.core.TogglePreferenceController;
/**
@@ -28,12 +31,14 @@ import com.android.settings.core.TogglePreferenceController;
*/
public class FaceSettingsConfirmPreferenceController extends FaceSettingsPreferenceController {
private static final String KEY = "security_settings_face_require_confirmation";
static final String KEY = "security_settings_face_require_confirmation";
private static final int ON = 1;
private static final int OFF = 0;
private static final int DEFAULT = OFF;
private FaceManager mFaceManager;
public FaceSettingsConfirmPreferenceController(Context context) {
this(context, KEY);
}
@@ -41,6 +46,7 @@ public class FaceSettingsConfirmPreferenceController extends FaceSettingsPrefere
public FaceSettingsConfirmPreferenceController(Context context,
String preferenceKey) {
super(context, preferenceKey);
mFaceManager = context.getSystemService(FaceManager.class);
}
@Override
@@ -55,6 +61,18 @@ public class FaceSettingsConfirmPreferenceController extends FaceSettingsPrefere
FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION, isChecked ? ON : OFF, getUserId());
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (!FaceSettings.isAvailable(mContext)) {
preference.setEnabled(false);
} else if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
preference.setEnabled(false);
} else {
preference.setEnabled(true);
}
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;

View File

@@ -0,0 +1,89 @@
/*
* 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.biometrics.face;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.widget.LayoutPreference;
/**
* Preference controller that allows a user to enroll their face.
*/
public class FaceSettingsEnrollButtonPreferenceController extends BasePreferenceController
implements View.OnClickListener {
private static final String TAG = "FaceSettings/Remove";
static final String KEY = "security_settings_face_enroll_faces_container";
private int mUserId;
private byte[] mToken;
private SettingsActivity mActivity;
private Button mButton;
public FaceSettingsEnrollButtonPreferenceController(Context context) {
this(context, KEY);
}
public FaceSettingsEnrollButtonPreferenceController(Context context,
String preferenceKey) {
super(context, preferenceKey);
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
mButton = ((LayoutPreference) preference)
.findViewById(R.id.security_settings_face_settings_enroll_button);
mButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
final Intent intent = new Intent();
intent.setClassName("com.android.settings", FaceEnrollIntroduction.class.getName());
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
mContext.startActivity(intent);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
public void setUserId(int userId) {
mUserId = userId;
}
public void setToken(byte[] token) {
mToken = token;
}
public void setActivity(SettingsActivity activity) {
mActivity = activity;
}
}

View File

@@ -20,6 +20,7 @@ import static android.provider.Settings.Secure.FACE_UNLOCK_KEYGUARD_ENABLED;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.hardware.face.FaceManager;
import android.os.UserHandle;
import android.provider.Settings;
@@ -39,8 +40,11 @@ public class FaceSettingsKeyguardPreferenceController extends FaceSettingsPrefer
private static final int OFF = 0;
private static final int DEFAULT = ON; // face unlock is enabled on keyguard by default
private FaceManager mFaceManager;
public FaceSettingsKeyguardPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mFaceManager = context.getSystemService(FaceManager.class);
}
public FaceSettingsKeyguardPreferenceController(Context context) {
@@ -76,6 +80,8 @@ public class FaceSettingsKeyguardPreferenceController extends FaceSettingsPrefer
preference.setEnabled(false);
} else if (adminDisabled()) {
preference.setEnabled(false);
} else if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
preference.setEnabled(false);
} else {
preference.setEnabled(true);
}

View File

@@ -24,7 +24,6 @@ import android.content.DialogInterface;
import android.hardware.face.Face;
import android.hardware.face.FaceManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@@ -48,7 +47,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
implements View.OnClickListener {
private static final String TAG = "FaceSettings/Remove";
private static final String KEY = "security_settings_face_delete_faces_container";
static final String KEY = "security_settings_face_delete_faces_container";
public static class ConfirmRemoveDialog extends InstrumentedDialogFragment {
@@ -85,6 +84,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
private Listener mListener;
private SettingsActivity mActivity;
private int mUserId;
private boolean mRemoving;
private final Context mContext;
private final FaceManager mFaceManager;
@@ -103,6 +103,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
if (!faces.isEmpty()) {
mButton.setEnabled(true);
} else {
mRemoving = false;
mListener.onRemoved();
}
} else {
@@ -154,6 +155,12 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
mButton = ((LayoutPreference) preference)
.findViewById(R.id.security_settings_face_settings_remove_button);
mButton.setOnClickListener(this);
if (!FaceSettings.isAvailable(mContext)) {
mButton.setEnabled(false);
} else {
mButton.setEnabled(!mRemoving);
}
}
@Override
@@ -169,6 +176,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
@Override
public void onClick(View v) {
if (v == mButton) {
mRemoving = true;
mButton.setEnabled(false);
ConfirmRemoveDialog dialog = new ConfirmRemoveDialog();
dialog.setOnClickListener(mOnClickListener);

View File

@@ -147,7 +147,7 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase {
getSupportFragmentManager().beginTransaction().remove(mSidecar).
commitAllowingStateLoss();
mSidecar = null;
startActivityForResult(getFingerprintEnrollingIntent(), ENROLLING);
startActivityForResult(getFingerprintEnrollingIntent(), ENROLL_REQUEST);
}
}
@@ -162,7 +162,7 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase {
} else {
finish();
}
} else if (requestCode == ENROLLING) {
} else if (requestCode == ENROLL_REQUEST) {
if (resultCode == RESULT_FINISHED) {
setResult(RESULT_FINISHED);
finish();

View File

@@ -109,6 +109,10 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
* Force to update the list of bluetooth devices
*/
public void forceUpdate() {
if (mLocalManager == null) {
Log.e(TAG, "forceUpdate() Bluetooth is not supported on this device");
return;
}
if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
final Collection<CachedBluetoothDevice> cachedDevices =
mLocalManager.getCachedDeviceManager().getCachedDevicesCopy();
@@ -121,6 +125,10 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
}
public void removeAllDevicesFromPreference() {
if (mLocalManager == null) {
Log.e(TAG, "removeAllDevicesFromPreference() BT is not supported on this device");
return;
}
final Collection<CachedBluetoothDevice> cachedDevices =
mLocalManager.getCachedDeviceManager().getCachedDevicesCopy();
for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {

View File

@@ -83,9 +83,11 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
if (isAvailable()) {
mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
updateTitle();
mBluetoothDeviceUpdater.setPrefContext(screen.getContext());
mBluetoothDeviceUpdater.forceUpdate();

View File

@@ -73,10 +73,11 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
if (isAvailable()) {
final Context context = screen.getContext();
mBluetoothDeviceUpdater.setPrefContext(context);
mBluetoothDeviceUpdater.forceUpdate();
@@ -88,7 +89,11 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
@Override
public int getAvailabilityStatus() {
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
final PackageManager packageManager = mContext.getPackageManager();
return (packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|| packageManager.hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY)
|| packageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
|| mConnectedDockUpdater != null)
? AVAILABLE_UNSEARCHABLE
: UNSUPPORTED_ON_DEVICE;
}

View File

@@ -52,7 +52,8 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
@Override
public int getAvailabilityStatus() {
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
return (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|| mSavedDockUpdater != null)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -73,10 +73,10 @@ public class SavedDeviceGroupController extends BasePreferenceController
@Override
public void displayPreference(PreferenceScreen screen) {
if (isAvailable()) {
mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
mPreferenceGroup = screen.findPreference(KEY);
mPreferenceGroup.setVisible(false);
if (isAvailable()) {
final Context context = screen.getContext();
mBluetoothDeviceUpdater.setPrefContext(context);
mBluetoothDeviceUpdater.forceUpdate();
@@ -87,7 +87,8 @@ public class SavedDeviceGroupController extends BasePreferenceController
@Override
public int getAvailabilityStatus() {
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
return (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|| mSavedDockUpdater != null)
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}

View File

@@ -406,13 +406,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O
}
private SubscriptionInfo getPhoneSubscriptionInfo(int slotId) {
final List<SubscriptionInfo> subscriptionInfoList = SubscriptionManager.from(
mContext).getActiveSubscriptionInfoList(true);
if (subscriptionInfoList != null && subscriptionInfoList.size() > slotId) {
return subscriptionInfoList.get(slotId);
} else {
return null;
}
return SubscriptionManager.from(mContext).getActiveSubscriptionInfoForSimSlotIndex(slotId);
}
@VisibleForTesting

View File

@@ -0,0 +1,39 @@
/*
* 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.display;
import android.content.Context;
public class AutoBrightnessDetailPreferenceController extends AutoBrightnessPreferenceController {
public AutoBrightnessDetailPreferenceController(Context context, String key) {
super(context, key);
}
@Override
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available)
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
return true;
}
}

View File

@@ -19,7 +19,6 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
@@ -52,15 +51,10 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available)
? AVAILABLE
? AVAILABLE_UNSEARCHABLE
: UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
return TextUtils.equals(getPreferenceKey(), "auto_brightness");
}
@Override
public CharSequence getSummary() {
return mContext.getText(isChecked()

View File

@@ -0,0 +1,91 @@
/*
* 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.network.telephony;
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
import android.content.Context;
import android.telephony.SubscriptionManager;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.SubscriptionsChangeListener;
public class DisabledSubscriptionController extends BasePreferenceController implements
SubscriptionsChangeListener.SubscriptionsChangeListenerClient, LifecycleObserver {
private PreferenceCategory mCategory;
private int mSubId;
private SubscriptionsChangeListener mChangeListener;
private SubscriptionManager mSubscriptionManager;
public DisabledSubscriptionController(Context context, String preferenceKey) {
super(context, preferenceKey);
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
mChangeListener = new SubscriptionsChangeListener(context, this);
}
public void init(Lifecycle lifecycle, int subId) {
lifecycle.addObserver(this);
mSubId = subId;
}
@OnLifecycleEvent(ON_RESUME)
public void onResume() {
mChangeListener.start();
update();
}
@OnLifecycleEvent(ON_PAUSE)
public void onPause() {
mChangeListener.stop();
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mCategory = screen.findPreference(getPreferenceKey());
update();
}
private void update() {
if (mCategory == null || mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
return;
}
mCategory.setVisible(mSubscriptionManager.isSubscriptionEnabled(mSubId));
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE_UNSEARCHABLE;
}
@Override
public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
}
@Override
public void onSubscriptionsChanged() {
update();
}
}

View File

@@ -17,27 +17,24 @@
package com.android.settings.network.telephony;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.android.settings.network.MobileDataContentObserver;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.settings.network.MobileDataContentObserver;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
/**
* Preference controller for "Mobile data"
*/
@@ -60,7 +57,7 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
super(context, key);
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
mDataContentObserver = new MobileDataContentObserver(new Handler(Looper.getMainLooper()));
mDataContentObserver.setOnMobileDataChangedListener(()-> updateState(mPreference));
mDataContentObserver.setOnMobileDataChangedListener(() -> updateState(mPreference));
}
@Override
@@ -144,18 +141,10 @@ public class MobileDataPreferenceController extends TelephonyTogglePreferenceCon
final int defaultSubId = mSubscriptionManager.getDefaultDataSubscriptionId();
final boolean needToDisableOthers = mSubscriptionManager
.isActiveSubscriptionId(defaultSubId) && defaultSubId != mSubId;
if (enableData) {
if (isMultiSim && needToDisableOthers) {
mDialogType = MobileDataDialogFragment.TYPE_MULTI_SIM_DIALOG;
return true;
}
} else {
if (!isMultiSim) {
mDialogType = MobileDataDialogFragment.TYPE_DISABLE_DIALOG;
return true;
}
if (enableData && isMultiSim && needToDisableOthers) {
mDialogType = MobileDataDialogFragment.TYPE_MULTI_SIM_DIALOG;
return true;
}
return false;
}

View File

@@ -131,12 +131,13 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
super.onAttach(context);
if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
use(CallsDefaultSubscriptionController.class).init(getLifecycle());
use(SmsDefaultSubscriptionController.class).init(getLifecycle());
use(MobileNetworkSwitchController.class).init(getLifecycle(), mSubId);
use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
use(BillingCyclePreferenceController.class).init(mSubId);
use(MmsMessagePreferenceController.class).init(mSubId);
use(CallsDefaultSubscriptionController.class).init(getLifecycle());
use(SmsDefaultSubscriptionController.class).init(getLifecycle());
use(MobileNetworkSwitchController.class).init(getLifecycle(), mSubId);
use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
use(BillingCyclePreferenceController.class).init(mSubId);
use(MmsMessagePreferenceController.class).init(mSubId);
use(DisabledSubscriptionController.class).init(getLifecycle(), mSubId);
}
use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId);
use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId);

View File

@@ -91,6 +91,7 @@ public class ImportancePreference extends Preference {
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.itemView.setClickable(false);
TextView textView = (TextView) holder.findViewById(R.id.description);
mSilenceButton = (Button) holder.findViewById(R.id.silence);

View File

@@ -425,10 +425,12 @@ public class NotificationBackend {
return StringUtil.formatRelativeTime(
context, System.currentTimeMillis() - state.lastSent, true);
} else {
if (state.avgSentWeekly > 0) {
return context.getString(R.string.notifications_sent_weekly, state.avgSentWeekly);
if (state.avgSentDaily > 0) {
return context.getResources().getQuantityString(R.plurals.notifications_sent_daily,
state.avgSentDaily, state.avgSentDaily);
}
return context.getString(R.string.notifications_sent_daily, state.avgSentDaily);
return context.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
state.avgSentWeekly, state.avgSentWeekly);
}
}

View File

@@ -33,6 +33,7 @@ import androidx.slice.widget.SliceView;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.google.android.setupdesign.DividerItemDecoration;
import java.util.ArrayList;
@@ -128,7 +129,8 @@ public class PanelSlicesAdapter
.action(0 /* attribution */,
SettingsEnums.ACTION_PANEL_INTERACTION,
mMetricsCategory,
sliceLiveData.toString() /* log key */,
sliceLiveData.getValue().getUri().getLastPathSegment()
/* log key */,
eventInfo.actionType /* value */);
})
);

View File

@@ -174,7 +174,7 @@ public class SimListDialogFragment extends SimDialogFragment implements
if (sub == null) {
title.setText(R.string.sim_calls_ask_first_prefs_title);
summary.setText("");
icon.setImageDrawable(mContext.getDrawable(R.drawable.ic_help));
icon.setImageDrawable(mContext.getDrawable(R.drawable.ic_feedback_24dp));
icon.setImageTintList(
Utils.getColorAttr(mContext, android.R.attr.textColorSecondary));
} else {

View File

@@ -397,9 +397,21 @@ public class AppStateNotificationBridgeTest {
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentRarely, R.id.sort_order_frequent_notification).toString())
.contains("1");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentRarely, R.id.sort_order_frequent_notification).toString())
.contains("notification ");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentRarely, R.id.sort_order_frequent_notification).toString())
.contains("week");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentOften, R.id.sort_order_frequent_notification).toString())
.contains("8");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentOften, R.id.sort_order_frequent_notification).toString())
.contains("notifications");
assertThat(AppStateNotificationBridge.getSummary(
mContext, sentOften, R.id.sort_order_frequent_notification).toString())
.contains("day");
}
@Test

View File

@@ -88,6 +88,7 @@ public class ConnectedDeviceGroupControllerTest {
mPreferenceGroup = spy(new PreferenceScreen(mContext, null));
when(mPreferenceGroup.getPreferenceManager()).thenReturn(mPreferenceManager);
doReturn(mContext).when(mDashboardFragment).getContext();
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
mConnectedDeviceGroupController = new ConnectedDeviceGroupController(mContext);
mConnectedDeviceGroupController.init(mConnectedBluetoothDeviceUpdater,
@@ -153,8 +154,12 @@ public class ConnectedDeviceGroupControllerTest {
}
@Test
public void getAvailabilityStatus_noBluetoothFeature_returnUnSupported() {
public void getAvailabilityStatus_noBluetoothUsbDockFeature_returnUnSupported() {
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_ACCESSORY, false);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_HOST, false);
mConnectedDeviceGroupController.init(mConnectedBluetoothDeviceUpdater,
mConnectedUsbDeviceUpdater, null);
assertThat(mConnectedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
UNSUPPORTED_ON_DEVICE);
@@ -163,8 +168,37 @@ public class ConnectedDeviceGroupControllerTest {
@Test
public void getAvailabilityStatus_BluetoothFeature_returnSupported() {
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_ACCESSORY, false);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_HOST, false);
mConnectedDeviceGroupController.init(mConnectedBluetoothDeviceUpdater,
mConnectedUsbDeviceUpdater, null);
assertThat(mConnectedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
AVAILABLE_UNSEARCHABLE);
}
@Test
public void getAvailabilityStatus_haveUsbFeature_returnSupported() {
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_ACCESSORY, false);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_HOST, true);
mConnectedDeviceGroupController.init(mConnectedBluetoothDeviceUpdater,
mConnectedUsbDeviceUpdater, null);
assertThat(mConnectedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
AVAILABLE_UNSEARCHABLE);
}
@Test
public void getAvailabilityStatus_haveDockFeature_returnSupported() {
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_ACCESSORY, false);
mPackageManager.setSystemFeature(PackageManager.FEATURE_USB_HOST, false);
mConnectedDeviceGroupController.init(mConnectedBluetoothDeviceUpdater,
mConnectedUsbDeviceUpdater, mConnectedDockUpdater);
assertThat(mConnectedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
AVAILABLE_UNSEARCHABLE);
}
}

View File

@@ -95,18 +95,31 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
}
@Test
public void getAvailabilityStatus_noBluetoothFeature_returnUnSupported() {
public void getAvailabilityStatus_noBluetoothDockFeature_returnUnSupported() {
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
mPreConnectedDeviceController.setSavedDockUpdater(null);
assertThat(mPreConnectedDeviceController.getAvailabilityStatus()).isEqualTo(
CONDITIONALLY_UNAVAILABLE);
}
@Test
public void getAvailabilityStatus_hasBluetoothFeature_returnSupported() {
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
mPreConnectedDeviceController.setSavedDockUpdater(null);
assertThat(mPreConnectedDeviceController.getAvailabilityStatus()).isEqualTo(
AVAILABLE);
}
@Test
public void getAvailabilityStatus_haveDockFeature_returnSupported() {
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
assertThat(mPreConnectedDeviceController.getAvailabilityStatus()).isEqualTo(
AVAILABLE);
}
@Test
public void onDeviceAdded_addDevicePreference_displayIt() {
mPreConnectedDeviceController.onDeviceAdded(new Preference(mContext));

View File

@@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -81,6 +82,7 @@ public class SavedDeviceGroupControllerTest {
verify(mBluetoothDeviceUpdater).registerCallback();
verify(mSavedDockUpdater).registerCallback();
}
@Test
public void testUnregister() {
// unregister the callback in onStop()
@@ -88,16 +90,30 @@ public class SavedDeviceGroupControllerTest {
verify(mBluetoothDeviceUpdater).unregisterCallback();
verify(mSavedDockUpdater).unregisterCallback();
}
@Test
public void testGetAvailabilityStatus_noBluetoothFeature_returnUnSupported() {
public void testGetAvailabilityStatus_noBluetoothDockFeature_returnUnSupported() {
doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
mSavedDeviceGroupController.setSavedDockUpdater(null);
assertThat(mSavedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
UNSUPPORTED_ON_DEVICE);
}
@Test
public void testGetAvailabilityStatus_BluetoothFeature_returnSupported() {
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
mSavedDeviceGroupController.setSavedDockUpdater(null);
assertThat(mSavedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
AVAILABLE);
}
@Test
public void getAvailabilityStatus_haveDockFeature_returnSupported() {
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(false);
assertThat(mSavedDeviceGroupController.getAvailabilityStatus()).isEqualTo(
AVAILABLE);
}
}

View File

@@ -0,0 +1,69 @@
/*
* 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.display;
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 com.android.settings.testutils.shadow.SettingsShadowResources;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {SettingsShadowResources.class})
public class AutoBrightnessDetailPreferenceControllerTest {
private AutoBrightnessDetailPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new AutoBrightnessDetailPreferenceController(
RuntimeEnvironment.application, "test_key");
}
@Test
public void isSliceable_returnTrue() {
mController.onPreferenceChange(null, true);
assertThat(mController.isSliceable()).isTrue();
}
@Test
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailable() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void getAvailabilityStatus_configFalseSet_shouldReturnUnsupportedOnDevice() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
}

View File

@@ -20,6 +20,9 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import android.content.ContentResolver;
@@ -27,6 +30,7 @@ import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import org.junit.Before;
import org.junit.Test;
@@ -34,8 +38,10 @@ import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {SettingsShadowResources.class})
public class AutoBrightnessPreferenceControllerTest {
private static final String PREFERENCE_KEY = "auto_brightness";
@@ -115,17 +121,18 @@ public class AutoBrightnessPreferenceControllerTest {
}
@Test
public void isSliceable_correctKey_returnsTrue() {
final AutoBrightnessPreferenceController controller =
new AutoBrightnessPreferenceController(mContext,
"auto_brightness");
assertThat(controller.isSliceable()).isTrue();
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailableUnsearchable() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
@Test
public void isSliceable_incorrectKey_returnsFalse() {
final AutoBrightnessPreferenceController controller =
new AutoBrightnessPreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse();
public void getAvailabilityStatus_configFalseSet_shouldReturnUnsupportedOnDevice() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
}

View File

@@ -151,7 +151,8 @@ public class NotificationChannelSliceTest {
for (int i = 0; i < rowItems.size(); i++) {
// Assert the summary text is the same as expectation.
assertThat(getSummaryFromSliceItem(rowItems.get(i))).isEqualTo(
mContext.getString(R.string.notifications_sent_weekly, CHANNEL_COUNT - i));
mContext.getResources().getQuantityString(R.plurals.notifications_sent_weekly,
CHANNEL_COUNT - i, CHANNEL_COUNT - i));
}
}

View File

@@ -0,0 +1,101 @@
/*
* 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.network.telephony;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import android.content.Context;
import android.telephony.SubscriptionManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
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;
@RunWith(RobolectricTestRunner.class)
public class DisabledSubscriptionControllerTest {
private static final String KEY = "disabled_subscription_category";
private static final int SUB_ID = 111;
@Mock
private SubscriptionManager mSubscriptionManager;
@Mock
private PreferenceScreen mScreen;
private PreferenceCategory mCategory;
private Context mContext;
private Lifecycle mLifecycle;
private DisabledSubscriptionController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
LifecycleOwner lifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(lifecycleOwner);
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
mCategory = new PreferenceCategory(mContext);
doReturn(mCategory).when(mScreen).findPreference(KEY);
mController = new DisabledSubscriptionController(mContext, KEY);
mController.init(mLifecycle, SUB_ID);
}
@Test
public void displayPreference_subscriptionEnabled_categoryIsVisible() {
doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
mController.displayPreference(mScreen);
assertThat(mCategory.isVisible()).isTrue();
}
@Test
public void displayPreference_subscriptionDisabled_categoryIsNotVisible() {
doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
mController.displayPreference(mScreen);
assertThat(mCategory.isVisible()).isFalse();
}
@Test
public void onSubscriptionsChanged_subscriptionBecomesDisabled_categoryIsNotVisible() {
doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
mController.displayPreference(mScreen);
doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
mController.onSubscriptionsChanged();
assertThat(mCategory.isVisible()).isFalse();
}
@Test
public void onSubscriptionsChanged_subscriptionBecomesEnabled_categoryIsVisible() {
doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
mController.displayPreference(mScreen);
doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
mController.onSubscriptionsChanged();
assertThat(mCategory.isVisible()).isTrue();
}
}

View File

@@ -21,7 +21,6 @@ import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_U
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -30,6 +29,10 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.preference.SwitchPreference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,10 +43,6 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowSubscriptionManager;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.preference.SwitchPreference;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowSubscriptionManager.class)
public class MobileDataPreferenceControllerTest {
@@ -94,14 +93,13 @@ public class MobileDataPreferenceControllerTest {
}
@Test
public void isDialogNeeded_disableSingleSim_returnTrue() {
public void isDialogNeeded_disableSingleSim_returnFalse() {
doReturn(true).when(mTelephonyManager).isDataEnabled();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
doReturn(1).when(mTelephonyManager).getSimCount();
assertThat(mController.isDialogNeeded()).isTrue();
assertThat(mController.mDialogType).isEqualTo(MobileDataDialogFragment.TYPE_DISABLE_DIALOG);
assertThat(mController.isDialogNeeded()).isFalse();
}
@Test
@@ -127,7 +125,7 @@ public class MobileDataPreferenceControllerTest {
}
@Test
public void onPreferenceChange_needDialog_doNothing() {
public void onPreferenceChange_singleSim_On_shouldEnableData() {
doReturn(true).when(mTelephonyManager).isDataEnabled();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
@@ -135,11 +133,11 @@ public class MobileDataPreferenceControllerTest {
mController.onPreferenceChange(mPreference, true);
verify(mTelephonyManager, never()).setDataEnabled(true);
verify(mTelephonyManager).setDataEnabled(true);
}
@Test
public void onPreferenceChange_notNeedDialog_update() {
public void onPreferenceChange_multiSim_On_shouldEnableData() {
doReturn(true).when(mTelephonyManager).isDataEnabled();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();