Snap for 5409551 from b93e55f05e to qt-release
Change-Id: I04a3ffe03cfa387b75bd569368ad306640ef95bd
This commit is contained in:
@@ -1378,6 +1378,26 @@
|
||||
<item>@string/wifi_calling_mode_cellular_preferred_summary</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Carrier variant of Enhaced 4G LTE Mode title. [CHAR LIMIT=NONE] -->
|
||||
<string-array name="enhanced_4g_lte_mode_title_variant">
|
||||
<!-- 0: Default -->
|
||||
<item>@string/enhanced_4g_lte_mode_title</item>
|
||||
<!-- 1: Verizon -->
|
||||
<item>@string/enhanced_4g_lte_mode_title_advanced_calling</item>
|
||||
<!-- 2: All carriers who want 4G -->
|
||||
<item>@string/enhanced_4g_lte_mode_title_4g_calling</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Carrier variant of Enhaced 4G LTE Mode summary. [CHAR LIMIT=NONE] -->
|
||||
<string-array name="enhanced_4g_lte_mode_sumary_variant">
|
||||
<!-- 0: Default -->
|
||||
<item>@string/enhanced_4g_lte_mode_summary</item>
|
||||
<!-- 1: Verizon -->
|
||||
<item>@string/enhanced_4g_lte_mode_summary</item>
|
||||
<!-- 2: All carriers who want 4G -->
|
||||
<item>@string/enhanced_4g_lte_mode_summary_4g_calling</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Bluetooth icon foreground colors -->
|
||||
<integer-array name="bt_icon_fg_colors">
|
||||
<item>@color/bt_color_icon_1</item>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<color name="homepage_privacy_background">#5E97F6</color>
|
||||
|
||||
<color name="homepage_card_stroke_color">#1f000000</color>
|
||||
<color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
|
||||
<color name="homepage_card_dismissal_background">@*android:color/material_grey_100</color>
|
||||
<color name="contextual_card_background">@*android:color/background_device_default_light</color>
|
||||
<!-- End of dashboard/homepage icon background colors -->
|
||||
|
||||
|
||||
@@ -2620,8 +2620,6 @@
|
||||
<string name="sound_effects_enable_title">Tap sounds</string>
|
||||
<!-- Sound settings screen, setting check box label -->
|
||||
<string name="lock_sounds_enable_title">Screen lock sound</string>
|
||||
<!-- Sound settings screen, setting check box label -->
|
||||
<string name="haptic_feedback_enable_title">Vibrate on tap</string>
|
||||
<!-- Sound settings screen, setting option name checkbox to enable/disable audio recording features that improve audio recording in noisy environments -->
|
||||
<string name="audio_record_proc_title">Noise cancellation</string>
|
||||
<!-- Volume description for media volume -->
|
||||
@@ -5661,12 +5659,6 @@
|
||||
<!-- Battery saver: Title for battery saver schedule screen [CHAR_LIMIT=40] -->
|
||||
<string name="battery_saver_schedule_settings_title">Set a schedule</string>
|
||||
|
||||
<!-- Battery Saver: Title for sticky battery saver preference [CHAR_LIMIT=60] -->
|
||||
<string name="battery_saver_sticky_title">Keep battery saver on</string>
|
||||
|
||||
<!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
|
||||
<string name="battery_saver_sticky_description">Battery saver will stay on even after device is fully charged</string>
|
||||
|
||||
<!-- Battery Saver: Title for sticky battery saver preference [CHAR_LIMIT=60] -->
|
||||
<string name="battery_saver_sticky_title_new">Turn off when fully charged</string>
|
||||
|
||||
@@ -6781,6 +6773,24 @@
|
||||
<string name="help_uri_notifications" translatable="false"></string>
|
||||
<!-- Help URI, Apps [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps" translatable="false"></string>
|
||||
<!-- Help URI, manage apps storage [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_storage" translatable="false"></string>
|
||||
<!-- Help URI, manage apps power [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_high_power" translatable="false"></string>
|
||||
<!-- Help URI, manage apps overlay [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_overlay" translatable="false"></string>
|
||||
<!-- Help URI, manage apps write settings [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_write_settings" translatable="false"></string>
|
||||
<!-- Help URI, manage apps manage sources [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_manage_sources" translatable="false"></string>
|
||||
<!-- Help URI, manage apps games [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_games" translatable="false"></string>
|
||||
<!-- Help URI, manage apps movies [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_movies" translatable="false"></string>
|
||||
<!-- Help URI, manage apps photography [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_photography" translatable="false"></string>
|
||||
<!-- Help URI, manage apps wifi access [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_apps_wifi_access" translatable="false"></string>
|
||||
<!-- Help URI, Storage [DO NOT TRANSLATE] -->
|
||||
<string name="help_uri_storage" translatable="false"></string>
|
||||
<!-- Help URI, Accessibility [DO NOT TRANSLATE] -->
|
||||
@@ -6921,9 +6931,15 @@
|
||||
<!-- Access point names title. [CHAR LIMIT=50] -->
|
||||
<string name="access_point_names">Access point names</string>
|
||||
<!-- Enhaced 4G LTE Mode title. [CHAR LIMIT=50] -->
|
||||
<string name="enhanced_4g_lte_mode_title">Enhanced 4G LTE Mode</string>
|
||||
<string name="enhanced_4g_lte_mode_title">VoLTE</string>
|
||||
<!-- Enhaced 4G LTE Mode title for carriers who want to show Advanced Calling. [CHAR LIMIT=50] -->
|
||||
<string name="enhanced_4g_lte_mode_title_advanced_calling">Advanced Calling</string>
|
||||
<!-- Enhaced 4G LTE Mode title for carriers who want to show 4G Calling. [CHAR LIMIT=50] -->
|
||||
<string name="enhanced_4g_lte_mode_title_4g_calling">4G Calling</string>
|
||||
<!-- Enhaced 4G LTE Mode summary. [CHAR LIMIT=100] -->
|
||||
<string name="enhanced_4g_lte_mode_summary">Use LTE data to enhance voice and communications (Recommended)</string>
|
||||
<string name="enhanced_4g_lte_mode_summary">Use LTE services to improve voice and other communications (recommended)</string>
|
||||
<!-- Enhaced 4G LTE Mode summary for 4g calling. [CHAR LIMIT=100] -->
|
||||
<string name="enhanced_4g_lte_mode_summary_4g_calling">Use 4G services to improve voice and other communications (recommended)</string>
|
||||
<!-- Preferred network type title. [CHAR LIMIT=50] -->
|
||||
<string name="preferred_network_type_title">Preferred network type</string>
|
||||
<!-- Preferred network type summary. [CHAR LIMIT=100] -->
|
||||
@@ -7118,6 +7134,24 @@
|
||||
|
||||
<!--Search Keywords [CHAR LIMIT=NONE]-->
|
||||
<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]-->
|
||||
<string name="keywords_time_format">Use 24-hour format</string>
|
||||
<!-- Search keyword for "Files" settings under Settings > Storage. [CHAR_LIMIT=NONE]-->
|
||||
<string name="keywords_storage_files">Download</string>
|
||||
<!-- Search keyword for "Default Apps" settings [CHAR_LIMIT=NONE]-->
|
||||
<string name="keywords_app_default">Open with</string>
|
||||
<!-- Search keyword for "App info" settings [CHAR_LIMIT=NONE]-->
|
||||
<string name="keywords_applications_settings">Applications</string>
|
||||
<!-- Search keyword for "Time zone" settings [CHAR_LIMIT=NONE]-->
|
||||
<string name="keywords_time_zone">timezone</string>
|
||||
<!-- Search keyword for "Display over other apps" settings [CHAR_LIMIT=NONE]-->
|
||||
<string name="keywords_draw_overlay">Chat head</string>
|
||||
<string name="keywords_change_wifi_state">wifi, wi-fi, toggle, control</string>
|
||||
<string name="keywords_more_default_sms_app">text message, texting, messages, messaging, default</string>
|
||||
<string name="keywords_more_mobile_networks">cellular, mobile, cell carrier, wireless, data, 4g,3g, 2g, lte</string>
|
||||
@@ -7128,7 +7162,8 @@
|
||||
<string name="keywords_display_night_display">dim screen, night, tint, night shift, brightness, screen color, colour, color</string>
|
||||
<string name="keywords_display_wallpaper">background, personalize, customize display</string>
|
||||
<string name="keywords_display_font_size">text size</string>
|
||||
<string name="keywords_display_cast_screen">project, cast</string>
|
||||
<!-- Search keyword for "Cast" settings [CHAR_LIMIT=NONE]-->
|
||||
<string name="keywords_display_cast_screen">project, cast, Screen mirroring, Screen sharing, mirroring, share screen, screen casting</string>
|
||||
<string name="keywords_storage">space, disk, hard drive, device usage</string>
|
||||
<string name="keywords_battery">power usage, charge</string>
|
||||
<string name="keywords_spell_checker">spelling, dictionary, spellcheck, auto-correct</string>
|
||||
@@ -7181,7 +7216,7 @@
|
||||
<string name="keywords_ambient_display_screen">Ambient display, Lock screen display</string>
|
||||
|
||||
<!-- Search keyword for lock screen notification setting [CHAR_LIMIT=NONE] -->
|
||||
<string name="keywords_lock_screen_notif">lock screen notification</string>
|
||||
<string name="keywords_lock_screen_notif">lock screen notification, notifications</string>
|
||||
|
||||
<!-- Search keyword for face settings. -->
|
||||
<string name="keywords_face_settings">face</string>
|
||||
@@ -7368,6 +7403,12 @@
|
||||
<!-- Sound: Other sounds: Title for the option enabling boot sounds. [CHAR LIMIT=30] -->
|
||||
<string name="boot_sounds_title">Power on sounds</string>
|
||||
|
||||
<!-- Setting title for controlling how caption text display in real time [CHAR LIMIT=40]-->
|
||||
<string name="live_caption_title">Live Caption</string>
|
||||
|
||||
<!-- Setting summary for controlling how caption text display in real time [CHAR LIMIT=NONE]-->
|
||||
<string name="live_caption_summary">Automatically caption media</string>
|
||||
|
||||
<!-- Sound: Summary for the Do not Disturb option when there is no automatic rules turned on. [CHAR LIMIT=NONE]-->
|
||||
<string name="zen_mode_settings_summary_off">Never</string>
|
||||
|
||||
@@ -7387,7 +7428,7 @@
|
||||
<string name="zen_mode_behavior_settings_title">Exceptions</string>
|
||||
|
||||
<!-- Do not disturb: Title for the dnd duration setting (user can specify how long dnd will last when toggling dnd on from qs or settings) [CHAR LIMIT=30] -->
|
||||
<string name="zen_mode_duration_settings_title">Duration</string>
|
||||
<string name="zen_mode_duration_settings_title">Default duration</string>
|
||||
|
||||
<!-- Do not disturb: Instructions indicating what types of sounds can bypass DND. [CHAR LIMIT=52] -->
|
||||
<string name="zen_mode_behavior_allow_title">Allow sounds and vibrations from</string>
|
||||
@@ -10534,8 +10575,6 @@
|
||||
<!-- Message informs the user that has no SIM card in personalized Settings [CHAR LIMIT=30] -->
|
||||
<string name="no_sim_card">No SIM card</string>
|
||||
|
||||
<!-- Carrier variant of Enhaced 4G LTE Mode title. [CHAR LIMIT=50] -->
|
||||
<string name="enhanced_4g_lte_mode_title_variant">Advanced Calling</string>
|
||||
<!-- The following strings are summaries for preferred network modes in Mobile network settings,
|
||||
and have a character limit of 100 -->
|
||||
<!-- WCDMA preferred [CHAR LIMIT=NONE] -->
|
||||
|
||||
@@ -132,6 +132,12 @@
|
||||
android:key="audio_and_captions_category"
|
||||
android:title="@string/audio_and_captions_category_title">
|
||||
|
||||
<Preference
|
||||
android:key="live_caption"
|
||||
android:title="@string/live_caption_title"
|
||||
android:summary="@string/live_caption_summary"
|
||||
settings:controller="com.android.settings.accessibility.LiveCaptionPreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="toggle_master_mono"
|
||||
android:title="@string/accessibility_toggle_master_mono_title"
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
android:title="@string/applications_settings"
|
||||
android:order="-999"
|
||||
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
|
||||
settings:controller="com.android.settings.applications.AllAppsInfoPreferenceController"/>
|
||||
settings:controller="com.android.settings.applications.AllAppsInfoPreferenceController"
|
||||
settings:keywords="@string/keywords_applications_settings"/>
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="recent_open_apps"
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="app_default_settings_screen"
|
||||
android:title="@string/app_default_dashboard_title">
|
||||
android:title="@string/app_default_dashboard_title"
|
||||
settings:keywords="@string/keywords_app_default">
|
||||
|
||||
<com.android.settingslib.widget.apppreference.AppPreference
|
||||
android:key="assist_and_voice_input"
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
<SwitchPreference
|
||||
android:key="battery_saver_sticky"
|
||||
android:title="@string/battery_saver_sticky_title"
|
||||
android:summary="@string/battery_saver_sticky_description"
|
||||
android:title="@string/battery_saver_sticky_title_new"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:keywords="@string/keywords_battery_saver_sticky"
|
||||
settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController"/>
|
||||
|
||||
|
||||
24
res/xml/dark_ui_settings.xml
Normal file
24
res/xml/dark_ui_settings.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/dark_ui_mode"
|
||||
android:key="dark_ui_mode_screen"
|
||||
settings:staticPreferenceLocation="append"
|
||||
settings:keywords="@string/keywords_dark_ui_mode">
|
||||
</PreferenceScreen >
|
||||
@@ -56,12 +56,14 @@
|
||||
android:title="@string/date_time_set_timezone_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
|
||||
settings:userRestriction="no_config_date_time" />
|
||||
settings:userRestriction="no_config_date_time"
|
||||
settings:keywords="@string/keywords_time_zone"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="time_format_preference_category"
|
||||
android:title="@string/time_format_category_title">
|
||||
android:title="@string/time_format_category_title"
|
||||
settings:keywords="@string/keywords_time_format">
|
||||
<SwitchPreference
|
||||
android:key="auto_24hour"
|
||||
android:title="@string/date_time_24hour_auto"/>
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
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:controller="com.android.settings.display.AutoBrightnessPreferenceController"
|
||||
settings:keywords="@string/keywords_auto_brightness"/>
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="wallpaper"
|
||||
@@ -57,14 +58,13 @@
|
||||
android:targetClass="@string/config_wallpaper_picker_class" />
|
||||
</com.android.settingslib.RestrictedPreference>
|
||||
|
||||
<ListPreference
|
||||
|
||||
<Preference
|
||||
android:key="dark_ui_mode"
|
||||
android:fragment="com.android.settings.display.DarkUISettings"
|
||||
android:title="@string/dark_ui_mode"
|
||||
android:dialogTitle="@string/dark_ui_mode_title"
|
||||
android:entries="@array/dark_ui_mode_entries"
|
||||
android:entryValues="@array/dark_ui_mode_values"
|
||||
settings:keywords="@string/keywords_dark_ui_mode"
|
||||
settings:controller="com.android.settings.display.DarkUIPreferenceController" />
|
||||
settings:searchable="false"
|
||||
settings:controller="com.android.settings.display.DarkUIPreferenceController"/>
|
||||
|
||||
<!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
|
||||
<com.android.settings.display.TimeoutListPreference
|
||||
|
||||
@@ -124,7 +124,8 @@
|
||||
android:dialogTitle="@string/ringtone_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:ringtoneType="ringtone"
|
||||
android:order="-100"/>
|
||||
android:order="-100"
|
||||
settings:keywords="@string/sound_settings"/>
|
||||
|
||||
<!-- Default notification ringtone -->
|
||||
<com.android.settings.DefaultRingtonePreference
|
||||
@@ -180,7 +181,8 @@
|
||||
<SwitchPreference
|
||||
android:key="vibrate_on_touch"
|
||||
android:title="@string/vibrate_on_touch_title"
|
||||
android:summary="@string/vibrate_on_touch_summary" />
|
||||
android:summary="@string/vibrate_on_touch_summary"
|
||||
settings:keywords="@string/keywords_vibrate_on_touch"/>
|
||||
|
||||
<!-- Dock speaker plays -->
|
||||
<DropDownPreference
|
||||
|
||||
@@ -62,7 +62,8 @@
|
||||
android:key="pref_files"
|
||||
android:title="@string/storage_files"
|
||||
android:icon="@drawable/ic_folder_vd_theme_24"
|
||||
android:order="7" />
|
||||
android:order="7"
|
||||
settings:keywords="@string/keywords_storage_files"/>
|
||||
<com.android.settings.deviceinfo.StorageItemPreference
|
||||
android:key="pref_system"
|
||||
android:title="@string/storage_detail_system"
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
android:key="notify_open_networks"
|
||||
android:title="@string/wifi_notify_open_networks"
|
||||
android:icon="@drawable/ic_open_wifi_notifications"
|
||||
android:summary="@string/wifi_notify_open_networks_summary" />
|
||||
android:summary="@string/wifi_notify_open_networks_summary"
|
||||
settings:keywords="@string/keywords_wifi_notify_open_networks"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="wifi_cellular_data_fallback"
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="wifi_display_settings_screen"
|
||||
android:title="@string/wifi_display_settings_title">
|
||||
android:title="@string/wifi_display_settings_title"
|
||||
settings:keywords="@string/keywords_display_cast_screen">
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -71,6 +71,15 @@
|
||||
android:entryValues="@array/wifi_privacy_values"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- Add device Category -->
|
||||
<PreferenceCategory
|
||||
android:key="add_device_category" >
|
||||
<Preference
|
||||
android:key="add_device_to_network"
|
||||
android:title="@string/wifi_dpp_add_device"
|
||||
android:summary="@string/wifi_dpp_connect_network_using_qr_code"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- Network Details -->
|
||||
<PreferenceCategory
|
||||
android:key="ip_details_category"
|
||||
|
||||
@@ -136,6 +136,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
"accessibility_control_timeout_preference_fragment";
|
||||
private static final String DARK_UI_MODE_PREFERENCE =
|
||||
"dark_ui_mode_accessibility";
|
||||
private static final String LIVE_CAPTION_PREFERENCE_KEY =
|
||||
"live_caption";
|
||||
|
||||
|
||||
// Extras passed to sub-fragments.
|
||||
@@ -236,11 +238,13 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
private Preference mDisplayDaltonizerPreferenceScreen;
|
||||
private Preference mHearingAidPreference;
|
||||
private Preference mVibrationPreferenceScreen;
|
||||
private Preference mLiveCaptionPreference;
|
||||
private SwitchPreference mToggleInversionPreference;
|
||||
private ColorInversionPreferenceController mInversionPreferenceController;
|
||||
private AccessibilityHearingAidPreferenceController mHearingAidPreferenceController;
|
||||
private ListPreference mDarkUIModePreference;
|
||||
private DarkUIPreferenceController mDarkUIPreferenceController;
|
||||
private LiveCaptionPreferenceController mLiveCaptionPreferenceController;
|
||||
|
||||
private int mLongPressTimeoutDefault;
|
||||
|
||||
@@ -299,6 +303,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
(context, HEARING_AID_PREFERENCE);
|
||||
mHearingAidPreferenceController.setFragmentManager(getFragmentManager());
|
||||
getLifecycle().addObserver(mHearingAidPreferenceController);
|
||||
|
||||
mLiveCaptionPreferenceController = new LiveCaptionPreferenceController(context,
|
||||
LIVE_CAPTION_PREFERENCE_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -487,6 +494,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
// Captioning.
|
||||
mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
|
||||
|
||||
// Live caption
|
||||
mLiveCaptionPreference = findPreference(LIVE_CAPTION_PREFERENCE_KEY);
|
||||
mLiveCaptionPreferenceController.displayPreference(getPreferenceScreen());
|
||||
|
||||
// Display magnification.
|
||||
mDisplayMagnificationPreferenceScreen = findPreference(
|
||||
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
|
||||
@@ -732,6 +743,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
|
||||
mHearingAidPreferenceController.updateState(mHearingAidPreference);
|
||||
|
||||
mLiveCaptionPreferenceController.updateState(mLiveCaptionPreference);
|
||||
|
||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
|
||||
mCaptioningPreferenceScreen);
|
||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
|
||||
@@ -752,7 +765,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
|
||||
void updateAccessibilityTimeoutSummary(ContentResolver resolver, Preference pref) {
|
||||
|
||||
String[] timeoutSummarys = getResources().getStringArray(
|
||||
R.array.accessibility_timeout_summaries);
|
||||
int[] timeoutValues = getResources().getIntArray(
|
||||
@@ -821,7 +833,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
pref.setSummary(entries[index]);
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
@VisibleForTesting
|
||||
void updateVibrationSummary(Preference pref) {
|
||||
final Context context = getContext();
|
||||
final Vibrator vibrator = context.getSystemService(Vibrator.class);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LiveCaptionPreferenceController extends BasePreferenceController {
|
||||
|
||||
@VisibleForTesting
|
||||
static final Intent LIVE_CAPTION_INTENT = new Intent(
|
||||
"com.android.settings.action.live_caption");
|
||||
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
public LiveCaptionPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
final List<ResolveInfo> resolved =
|
||||
mPackageManager.queryIntentActivities(LIVE_CAPTION_INTENT, 0 /* flags */);
|
||||
return resolved != null && !resolved.isEmpty()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
preference.setIntent(LIVE_CAPTION_INTENT);
|
||||
}
|
||||
}
|
||||
@@ -625,12 +625,32 @@ public class ManageApplications extends InstrumentedFragment
|
||||
|
||||
@StringRes
|
||||
int getHelpResource() {
|
||||
if (mListType == LIST_TYPE_MAIN) {
|
||||
return R.string.help_uri_apps;
|
||||
} else if (mListType == LIST_TYPE_USAGE_ACCESS) {
|
||||
return R.string.help_url_usage_access;
|
||||
} else {
|
||||
return R.string.help_uri_notifications;
|
||||
switch (mListType) {
|
||||
case LIST_TYPE_NOTIFICATION:
|
||||
return R.string.help_uri_notifications;
|
||||
case LIST_TYPE_USAGE_ACCESS:
|
||||
return R.string.help_url_usage_access;
|
||||
case LIST_TYPE_STORAGE:
|
||||
return R.string.help_uri_apps_storage;
|
||||
case LIST_TYPE_HIGH_POWER:
|
||||
return R.string.help_uri_apps_high_power;
|
||||
case LIST_TYPE_OVERLAY:
|
||||
return R.string.help_uri_apps_overlay;
|
||||
case LIST_TYPE_WRITE_SETTINGS:
|
||||
return R.string.help_uri_apps_write_settings;
|
||||
case LIST_TYPE_MANAGE_SOURCES:
|
||||
return R.string.help_uri_apps_manage_sources;
|
||||
case LIST_TYPE_GAMES:
|
||||
return R.string.help_uri_apps_overlay;
|
||||
case LIST_TYPE_MOVIES:
|
||||
return R.string.help_uri_apps_movies;
|
||||
case LIST_TYPE_PHOTOGRAPHY:
|
||||
return R.string.help_uri_apps_photography;
|
||||
case LIST_TYPE_WIFI_ACCESS:
|
||||
return R.string.help_uri_apps_wifi_access;
|
||||
default:
|
||||
case LIST_TYPE_MAIN:
|
||||
return R.string.help_uri_apps;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,11 @@ import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
@@ -41,9 +43,14 @@ public class HideNonSystemOverlayMixin implements LifecycleObserver {
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isEnabled() {
|
||||
return !Build.IS_DEBUGGABLE;
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_START)
|
||||
public void onStart() {
|
||||
if (mActivity == null) {
|
||||
if (mActivity == null || !isEnabled()) {
|
||||
return;
|
||||
}
|
||||
mActivity.getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
@@ -53,7 +60,7 @@ public class HideNonSystemOverlayMixin implements LifecycleObserver {
|
||||
|
||||
@OnLifecycleEvent(ON_STOP)
|
||||
public void onStop() {
|
||||
if (mActivity == null) {
|
||||
if (mActivity == null || !isEnabled()) {
|
||||
return;
|
||||
}
|
||||
final Window window = mActivity.getWindow();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.development.featureflags;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.preference.PreferenceGroup;
|
||||
@@ -39,7 +40,7 @@ public class FeatureFlagsPreferenceController extends BasePreferenceController
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
return Build.IS_DEBUGGABLE ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,11 +17,16 @@
|
||||
package com.android.settings.deviceinfo.firmwareversion;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
|
||||
@@ -29,6 +34,9 @@ public class MainlineModuleVersionPreferenceController extends BasePreferenceCon
|
||||
|
||||
private static final String TAG = "MainlineModuleControl";
|
||||
|
||||
@VisibleForTesting
|
||||
static final Intent MODULE_UPDATE_INTENT =
|
||||
new Intent("android.settings.MODULE_UPDATE_SETTINGS");
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
private String mModuleVersion;
|
||||
@@ -65,6 +73,20 @@ public class MainlineModuleVersionPreferenceController extends BasePreferenceCon
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
// Confirm MODULE_UPDATE_INTENT is handleable, and set it to Preference.
|
||||
final ResolveInfo resolved =
|
||||
mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0 /* flags */);
|
||||
if (resolved != null) {
|
||||
preference.setIntent(MODULE_UPDATE_INTENT);
|
||||
} else {
|
||||
preference.setIntent(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mModuleVersion;
|
||||
|
||||
@@ -27,8 +27,7 @@ import androidx.preference.PreferenceScreen;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class DarkUIPreferenceController extends BasePreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
public class DarkUIPreferenceController extends BasePreferenceController {
|
||||
|
||||
private UiModeManager mUiModeManager;
|
||||
|
||||
@@ -47,59 +46,9 @@ public class DarkUIPreferenceController extends BasePreferenceController
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
int value = mUiModeManager.getNightMode();
|
||||
ListPreference preference = screen.findPreference(getPreferenceKey());
|
||||
preference.setValue(modeToString(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mUiModeManager.setNightMode(modeToInt((String) newValue));
|
||||
refreshSummary(preference);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return modeToDescription(mUiModeManager.getNightMode());
|
||||
}
|
||||
|
||||
private String modeToDescription(int mode) {
|
||||
String[] values = mContext.getResources().getStringArray(R.array.dark_ui_mode_entries);
|
||||
switch (mode) {
|
||||
case UiModeManager.MODE_NIGHT_YES:
|
||||
return values[0];
|
||||
case UiModeManager.MODE_NIGHT_NO:
|
||||
case UiModeManager.MODE_NIGHT_AUTO:
|
||||
default:
|
||||
return values[1];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String modeToString(int mode) {
|
||||
switch (mode) {
|
||||
case UiModeManager.MODE_NIGHT_YES:
|
||||
return "yes";
|
||||
case UiModeManager.MODE_NIGHT_NO:
|
||||
case UiModeManager.MODE_NIGHT_AUTO:
|
||||
default:
|
||||
return "no";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int modeToInt(String mode) {
|
||||
switch (mode) {
|
||||
case "yes":
|
||||
return UiModeManager.MODE_NIGHT_YES;
|
||||
case "no":
|
||||
case "auto":
|
||||
default:
|
||||
return UiModeManager.MODE_NIGHT_NO;
|
||||
}
|
||||
return DarkUISettingsRadioButtonsController.modeToDescription(
|
||||
mContext, mUiModeManager.getNightMode());
|
||||
}
|
||||
}
|
||||
|
||||
145
src/com/android/settings/display/DarkUISettings.java
Normal file
145
src/com/android/settings/display/DarkUISettings.java
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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.app.UiModeManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The screen for selecting the dark theme preference for this device. Automatically updates
|
||||
* the associated footer view with any needed information.
|
||||
*/
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class DarkUISettings extends RadioButtonPickerFragment implements Indexable {
|
||||
|
||||
private DarkUISettingsRadioButtonsController mController;
|
||||
private Preference mFooter;
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.dark_ui_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
// TODO(b/128686189): add illustration once it is ready
|
||||
setIllustration(0, 0);
|
||||
mFooter = new FooterPreference(context);
|
||||
mFooter.setIcon(android.R.color.transparent);
|
||||
mController = new DarkUISettingsRadioButtonsController(context, mFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends CandidateInfo> getCandidates() {
|
||||
final Context context = getContext();
|
||||
final List<CandidateInfo> candidates = new ArrayList<>();
|
||||
candidates.add(new DarkUISettingsCandidateInfo(
|
||||
DarkUISettingsRadioButtonsController.modeToDescription(
|
||||
context, UiModeManager.MODE_NIGHT_YES),
|
||||
/* summary */ null,
|
||||
DarkUISettingsRadioButtonsController.KEY_DARK,
|
||||
/* enabled */ true));
|
||||
candidates.add(new DarkUISettingsCandidateInfo(
|
||||
DarkUISettingsRadioButtonsController.modeToDescription(
|
||||
context, UiModeManager.MODE_NIGHT_NO),
|
||||
/* summary */ null,
|
||||
DarkUISettingsRadioButtonsController.KEY_LIGHT,
|
||||
/* enabled */ true));
|
||||
return candidates;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addStaticPreferences(PreferenceScreen screen) {
|
||||
screen.addPreference(mFooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultKey() {
|
||||
return mController.getDefaultKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean setDefaultKey(String key) {
|
||||
return mController.setDefaultKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.DARK_UI_SETTINGS;
|
||||
}
|
||||
|
||||
static class DarkUISettingsCandidateInfo extends CandidateInfo {
|
||||
|
||||
private final CharSequence mLabel;
|
||||
private final CharSequence mSummary;
|
||||
private final String mKey;
|
||||
|
||||
DarkUISettingsCandidateInfo(CharSequence label, CharSequence summary, String key,
|
||||
boolean enabled) {
|
||||
super(enabled);
|
||||
mLabel = label;
|
||||
mKey = key;
|
||||
mSummary = summary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence loadLabel() {
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable loadIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return mKey;
|
||||
}
|
||||
|
||||
public CharSequence getSummary() {
|
||||
return mSummary;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.dark_ui_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.app.UiModeManager;
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
import com.android.settings.R;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
public class DarkUISettingsRadioButtonsController {
|
||||
|
||||
public static final String KEY_DARK = "key_dark_ui_settings_dark";
|
||||
public static final String KEY_LIGHT = "key_dark_ui_settings_light";
|
||||
|
||||
@VisibleForTesting
|
||||
UiModeManager mManager;
|
||||
|
||||
private Preference mFooter;
|
||||
|
||||
public DarkUISettingsRadioButtonsController(Context context, Preference footer) {
|
||||
mManager = context.getSystemService(UiModeManager.class);
|
||||
mFooter = footer;
|
||||
}
|
||||
|
||||
public String getDefaultKey() {
|
||||
final int mode = mManager.getNightMode();
|
||||
updateFooter();
|
||||
return mode == UiModeManager.MODE_NIGHT_YES ? KEY_DARK : KEY_LIGHT;
|
||||
}
|
||||
|
||||
public boolean setDefaultKey(String key) {
|
||||
switch(key) {
|
||||
case KEY_DARK:
|
||||
mManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
|
||||
break;
|
||||
case KEY_LIGHT:
|
||||
mManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException(
|
||||
"Not a valid key for " + this.getClass().getSimpleName() + ": " + key);
|
||||
}
|
||||
updateFooter();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateFooter() {
|
||||
final int mode = mManager.getNightMode();
|
||||
switch (mode) {
|
||||
case UiModeManager.MODE_NIGHT_YES:
|
||||
mFooter.setSummary(R.string.dark_ui_settings_dark_summary);
|
||||
break;
|
||||
case UiModeManager.MODE_NIGHT_NO:
|
||||
case UiModeManager.MODE_NIGHT_AUTO:
|
||||
default:
|
||||
mFooter.setSummary(R.string.dark_ui_settings_light_summary);
|
||||
}
|
||||
}
|
||||
|
||||
public static String modeToDescription(Context context, int mode) {
|
||||
final String[] values = context.getResources().getStringArray(R.array.dark_ui_mode_entries);
|
||||
switch (mode) {
|
||||
case UiModeManager.MODE_NIGHT_YES:
|
||||
return values[0];
|
||||
case UiModeManager.MODE_NIGHT_NO:
|
||||
case UiModeManager.MODE_NIGHT_AUTO:
|
||||
default:
|
||||
return values[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,58 @@
|
||||
package com.android.settings.fuelgauge.batterysaver;
|
||||
|
||||
import android.content.Context;
|
||||
import android.icu.text.NumberFormat;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
public class BatterySaverStickyPreferenceController extends BasePreferenceController implements
|
||||
public class BatterySaverStickyPreferenceController extends TogglePreferenceController implements
|
||||
PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
public static final String LOW_POWER_STICKY_AUTO_DISABLE_ENABLED =
|
||||
"low_power_sticky_auto_disable_enabled";
|
||||
private Context mContext;
|
||||
|
||||
public BatterySaverStickyPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, 1) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
|
||||
isChecked ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshSummary(Preference preference) {
|
||||
super.refreshSummary(preference);
|
||||
final double stickyShutoffLevel = Settings.Global.getInt(
|
||||
mContext.getContentResolver(), Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, 90);
|
||||
final String percentage = NumberFormat
|
||||
.getPercentInstance()
|
||||
.format(stickyShutoffLevel / 100.0);
|
||||
preference.setSummary(
|
||||
mContext.getString(R.string.battery_saver_sticky_description_new, percentage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
int setting = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
LOW_POWER_STICKY_AUTO_DISABLE_ENABLED, 1);
|
||||
Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED, 1);
|
||||
|
||||
((SwitchPreference) preference).setChecked(setting == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean keepActive = (Boolean) newValue;
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
|
||||
keepActive ? 0 : 1);
|
||||
return true;
|
||||
((SwitchPreference) preference).setChecked(setting == 1);
|
||||
refreshSummary(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards.conditional;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -32,10 +35,15 @@ public class GrayscaleConditionController implements ConditionalCardController {
|
||||
static final int ID = Objects.hash("GrayscaleConditionController");
|
||||
|
||||
private static final String TAG = "GrayscaleCondition";
|
||||
private static final String ACTION_GRAYSCALE_CHANGED =
|
||||
"android.settings.action.GRAYSCALE_CHANGED";
|
||||
private static final IntentFilter GRAYSCALE_CHANGED_FILTER = new IntentFilter(
|
||||
ACTION_GRAYSCALE_CHANGED);
|
||||
|
||||
private final Context mAppContext;
|
||||
private final ConditionManager mConditionManager;
|
||||
private final ColorDisplayManager mColorDisplayManager;
|
||||
private final Receiver mReceiver;
|
||||
|
||||
private Intent mIntent;
|
||||
|
||||
@@ -43,6 +51,7 @@ public class GrayscaleConditionController implements ConditionalCardController {
|
||||
mAppContext = appContext;
|
||||
mConditionManager = conditionManager;
|
||||
mColorDisplayManager = mAppContext.getSystemService(ColorDisplayManager.class);
|
||||
mReceiver = new Receiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +81,7 @@ public class GrayscaleConditionController implements ConditionalCardController {
|
||||
public void onActionClick() {
|
||||
// Turn off grayscale
|
||||
mColorDisplayManager.setSaturationLevel(100 /* staturationLevel */);
|
||||
sendBroadcast();
|
||||
mConditionManager.onConditionChanged();
|
||||
}
|
||||
|
||||
@@ -93,11 +103,27 @@ public class GrayscaleConditionController implements ConditionalCardController {
|
||||
|
||||
@Override
|
||||
public void startMonitoringStateChange() {
|
||||
|
||||
mAppContext.registerReceiver(mReceiver, GRAYSCALE_CHANGED_FILTER,
|
||||
Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS, null /* scheduler */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopMonitoringStateChange() {
|
||||
mAppContext.unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
private void sendBroadcast() {
|
||||
final Intent intent = new Intent();
|
||||
intent.setAction(ACTION_GRAYSCALE_CHANGED);
|
||||
mAppContext.sendBroadcast(intent, Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS);
|
||||
}
|
||||
|
||||
public class Receiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (ACTION_GRAYSCALE_CHANGED.equals(intent.getAction())) {
|
||||
mConditionManager.onConditionChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,6 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
@Override
|
||||
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
|
||||
final Uri uri = card.getSliceUri();
|
||||
//TODO(b/120629936): Take this out once blank card issue is fixed.
|
||||
Log.d(TAG, "bindView - uri = " + uri);
|
||||
|
||||
if (!ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
||||
Log.w(TAG, "Invalid uri, skipping slice: " + uri);
|
||||
@@ -121,10 +119,8 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
mContext.getContentResolver().notifyChange(CardContentProvider.REFRESH_CARD_URI,
|
||||
null);
|
||||
return;
|
||||
} else {
|
||||
//TODO(b/120629936): Take this out once blank card issue is fixed.
|
||||
Log.d(TAG, "Slice callback - uri = " + slice.getUri());
|
||||
}
|
||||
|
||||
switch (holder.getItemViewType()) {
|
||||
case VIEW_TYPE_DEFERRED_SETUP:
|
||||
mDeferredSetupCardHelper.bindView(holder, card, slice);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Looper;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
@@ -52,12 +53,18 @@ public class Enhanced4gLtePreferenceController extends TelephonyTogglePreference
|
||||
ImsManager mImsManager;
|
||||
private PhoneCallStateListener mPhoneStateListener;
|
||||
private final List<On4gLteUpdateListener> m4gLteListeners;
|
||||
private final CharSequence[] mVariantTitles;
|
||||
private final CharSequence[] mVariantSumaries;
|
||||
|
||||
public Enhanced4gLtePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
m4gLteListeners = new ArrayList<>();
|
||||
mPhoneStateListener = new PhoneCallStateListener(Looper.getMainLooper());
|
||||
mVariantTitles = context.getResources()
|
||||
.getTextArray(R.array.enhanced_4g_lte_mode_title_variant);
|
||||
mVariantSumaries = context.getResources()
|
||||
.getTextArray(R.array.enhanced_4g_lte_mode_sumary_variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,12 +101,20 @@ public class Enhanced4gLtePreferenceController extends TelephonyTogglePreference
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
final SwitchPreference switchPreference = (SwitchPreference) preference;
|
||||
final boolean useVariant4glteTitle = mCarrierConfig.getInt(
|
||||
CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT) != 0;
|
||||
int enhanced4glteModeTitleId = useVariant4glteTitle ?
|
||||
R.string.enhanced_4g_lte_mode_title_variant :
|
||||
R.string.enhanced_4g_lte_mode_title;
|
||||
switchPreference.setTitle(enhanced4glteModeTitleId);
|
||||
final int variant4glteTitleIndex = mCarrierConfig.getInt(
|
||||
CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT);
|
||||
|
||||
// Default index 0 indicates the default title/sumary string
|
||||
CharSequence enhanced4glteModeTitle = mVariantTitles[0];
|
||||
CharSequence enhanced4glteModeSummary = mVariantSumaries[0];
|
||||
if (variant4glteTitleIndex >= 0 && variant4glteTitleIndex < mVariantTitles.length) {
|
||||
enhanced4glteModeTitle = mVariantTitles[variant4glteTitleIndex];
|
||||
}
|
||||
if (variant4glteTitleIndex >= 0 && variant4glteTitleIndex < mVariantSumaries.length) {
|
||||
enhanced4glteModeSummary = mVariantSumaries[variant4glteTitleIndex];
|
||||
}
|
||||
switchPreference.setTitle(enhanced4glteModeTitle);
|
||||
switchPreference.setSummary(enhanced4glteModeSummary);
|
||||
switchPreference.setEnabled(is4gLtePrefEnabled());
|
||||
switchPreference.setChecked(mImsManager.isEnhanced4gLteModeSettingEnabledByUser()
|
||||
&& mImsManager.isNonTtyOrTtyOnVolteEnabled());
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.android.settings.sim;
|
||||
|
||||
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_ID;
|
||||
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES;
|
||||
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE;
|
||||
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL;
|
||||
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA;
|
||||
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE;
|
||||
import static android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
@@ -52,8 +52,8 @@ public class SimSelectNotification extends BroadcastReceiver {
|
||||
|
||||
int dialogType = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
|
||||
EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE);
|
||||
if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_FOR_ALL_TYPES) {
|
||||
int subId = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_ID,
|
||||
if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL) {
|
||||
int subId = intent.getIntExtra(EXTRA_SUBSCRIPTION_ID,
|
||||
SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
|
||||
int slotIndex = SubscriptionManager.getSlotIndex(subId);
|
||||
// If there is only one subscription, ask if user wants to use if for everything
|
||||
|
||||
@@ -58,6 +58,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
|
||||
protected UserManager mUserManager;
|
||||
protected int mUserId;
|
||||
private int mIllustrationId;
|
||||
private int mIllustrationPreviewId;
|
||||
private VideoPreference mVideoPreference;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -164,6 +167,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
final String systemDefaultKey = getSystemDefaultKey();
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
screen.removeAll();
|
||||
if (mIllustrationId != 0) {
|
||||
addIllustration(screen);
|
||||
}
|
||||
if (!mAppendStaticPreferences) {
|
||||
addStaticPreferences(screen);
|
||||
}
|
||||
@@ -241,6 +247,23 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to set an illustration at the top of this screen. Set the illustration id to 0
|
||||
* if you want to remove the illustration.
|
||||
* @param illustrationId The res id for the raw of the illustration.
|
||||
* @param previewId The res id for the drawable of the illustration
|
||||
*/
|
||||
protected void setIllustration(int illustrationId, int previewId) {
|
||||
mIllustrationId = illustrationId;
|
||||
mIllustrationPreviewId = previewId;
|
||||
}
|
||||
|
||||
private void addIllustration(PreferenceScreen screen) {
|
||||
mVideoPreference = new VideoPreference(getContext());
|
||||
mVideoPreference.setVideo(mIllustrationId, mIllustrationPreviewId);
|
||||
screen.addPreference(mVideoPreference);
|
||||
}
|
||||
|
||||
protected abstract List<? extends CandidateInfo> getCandidates();
|
||||
|
||||
protected abstract String getDefaultKey();
|
||||
|
||||
@@ -55,22 +55,41 @@ public class VideoPreference extends Preference {
|
||||
private int mPreviewResource;
|
||||
private boolean mViewVisible;
|
||||
private Surface mSurface;
|
||||
private int mAnimationId;
|
||||
|
||||
public VideoPreference(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
initialize(context, null);
|
||||
}
|
||||
|
||||
public VideoPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
initialize(context, attrs);
|
||||
}
|
||||
|
||||
private void initialize(Context context, AttributeSet attrs) {
|
||||
TypedArray attributes = context.getTheme().obtainStyledAttributes(
|
||||
attrs,
|
||||
com.android.settings.R.styleable.VideoPreference,
|
||||
R.styleable.VideoPreference,
|
||||
0, 0);
|
||||
try {
|
||||
int animation = attributes.getResourceId(R.styleable.VideoPreference_animation, 0);
|
||||
// if these are already set that means they were set dynamically and don't need
|
||||
// to be loaded from xml
|
||||
mAnimationId = mAnimationId == 0
|
||||
? attributes.getResourceId(R.styleable.VideoPreference_animation, 0)
|
||||
: mAnimationId;
|
||||
mVideoPath = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||
.authority(context.getPackageName())
|
||||
.appendPath(String.valueOf(animation))
|
||||
.appendPath(String.valueOf(mAnimationId))
|
||||
.build();
|
||||
mPreviewResource = attributes.getResourceId(
|
||||
R.styleable.VideoPreference_preview, 0);
|
||||
mPreviewResource = mPreviewResource == 0
|
||||
? attributes.getResourceId(R.styleable.VideoPreference_preview, 0)
|
||||
: mPreviewResource;
|
||||
if (mPreviewResource == 0 && mAnimationId == 0) {
|
||||
return;
|
||||
}
|
||||
initMediaPlayer();
|
||||
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
|
||||
setVisible(true);
|
||||
@@ -103,20 +122,9 @@ public class VideoPreference extends Preference {
|
||||
|
||||
imageView.setImageResource(mPreviewResource);
|
||||
layout.setAspectRatio(mAspectRadio);
|
||||
updateViewStates(imageView, playButton);
|
||||
|
||||
video.setOnClickListener(v -> {
|
||||
if (mMediaPlayer != null) {
|
||||
if (mMediaPlayer.isPlaying()) {
|
||||
mMediaPlayer.pause();
|
||||
playButton.setVisibility(View.VISIBLE);
|
||||
mVideoPaused = true;
|
||||
} else {
|
||||
mMediaPlayer.start();
|
||||
playButton.setVisibility(View.GONE);
|
||||
mVideoPaused = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
video.setOnClickListener(v -> updateViewStates(imageView, playButton));
|
||||
|
||||
video.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
|
||||
@Override
|
||||
@@ -161,6 +169,23 @@ public class VideoPreference extends Preference {
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateViewStates(ImageView imageView, ImageView playButton) {
|
||||
if (mMediaPlayer != null) {
|
||||
if (mMediaPlayer.isPlaying()) {
|
||||
mMediaPlayer.pause();
|
||||
playButton.setVisibility(View.VISIBLE);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
mVideoPaused = true;
|
||||
} else {
|
||||
imageView.setVisibility(View.GONE);
|
||||
playButton.setVisibility(View.GONE);
|
||||
mMediaPlayer.start();
|
||||
mVideoPaused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetached() {
|
||||
releaseMediaPlayer();
|
||||
@@ -178,6 +203,20 @@ public class VideoPreference extends Preference {
|
||||
releaseMediaPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the video for this preference. If a previous video was set this one will override it
|
||||
* and properly release any resources and re-initialize the preference to play the new video.
|
||||
*
|
||||
* @param videoId The raw res id of the video
|
||||
* @param previewId The drawable res id of the preview image to use if the video fails to load.
|
||||
*/
|
||||
public void setVideo(int videoId, int previewId) {
|
||||
mAnimationId = videoId;
|
||||
mPreviewResource = previewId;
|
||||
releaseMediaPlayer();
|
||||
initialize(mContext, null);
|
||||
}
|
||||
|
||||
private void initMediaPlayer() {
|
||||
if (mMediaPlayer == null) {
|
||||
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
@@ -63,10 +62,6 @@ public class AddWifiNetworkPreference extends Preference {
|
||||
getContext().startActivity(
|
||||
WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
|
||||
});
|
||||
|
||||
final View divider = (View) holder.findViewById(
|
||||
com.android.settingslib.R.id.two_target_divider);
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -637,7 +637,7 @@ public class WifiConfigController implements TextWatcher,
|
||||
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
|
||||
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
|
||||
.BIP_GMAC_256);
|
||||
config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
|
||||
// allowedSuiteBCiphers will be set according to certificate type
|
||||
}
|
||||
config.enterpriseConfig = new WifiEnterpriseConfig();
|
||||
int eapMethod = mEapMethodSpinner.getSelectedItemPosition();
|
||||
|
||||
@@ -198,7 +198,7 @@ public class WifiUtils {
|
||||
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
|
||||
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
|
||||
.BIP_GMAC_256);
|
||||
config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
|
||||
// allowedSuiteBCiphers will be set according to certificate type
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.wifi.details;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.wifi.dpp.WifiDppUtils;
|
||||
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
/**
|
||||
* {@link AbstractPreferenceController} that launches Wi-Fi Easy Connect configurator flow
|
||||
*/
|
||||
public class AddDevicePreferenceController extends BasePreferenceController {
|
||||
|
||||
private static final String TAG = "AddDevicePreferenceController";
|
||||
|
||||
private static final String KEY_ADD_DEVICE_CATEGORY = "add_device_category";
|
||||
private static final String KEY_ADD_DEVICE = "add_device_to_network";
|
||||
|
||||
private AccessPoint mAccessPoint;
|
||||
private WifiManager mWifiManager;
|
||||
|
||||
public AddDevicePreferenceController(Context context) {
|
||||
super(context, KEY_ADD_DEVICE_CATEGORY);
|
||||
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
}
|
||||
|
||||
public AddDevicePreferenceController init(AccessPoint accessPoint) {
|
||||
mAccessPoint = accessPoint;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (WifiDppUtils.isSupportConfiguratorQrCodeScanner(mContext, mAccessPoint)) {
|
||||
return AVAILABLE;
|
||||
} else {
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_ADD_DEVICE.equals(preference.getKey())) {
|
||||
WifiDppUtils.showLockScreen(mContext, () -> launchWifiDppConfiguratorQrCodeScanner());
|
||||
return true; /* click is handled */
|
||||
}
|
||||
|
||||
return false; /* click is not handled */
|
||||
}
|
||||
|
||||
private void launchWifiDppConfiguratorQrCodeScanner() {
|
||||
final Intent intent = WifiDppUtils.getConfiguratorQrCodeScannerIntentOrNull(mContext,
|
||||
mWifiManager, mAccessPoint);
|
||||
|
||||
if (intent == null) {
|
||||
Log.e(TAG, "Launch Wi-Fi QR code scanner with a wrong Wi-Fi network!");
|
||||
} else {
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
.setButton3Text(R.string.share)
|
||||
.setButton3Icon(R.drawable.ic_qrcode_24dp)
|
||||
.setButton3OnClickListener(view -> shareNetwork())
|
||||
.setButton3Visible(WifiDppUtils.isSuportConfigurator(mContext, mAccessPoint));
|
||||
.setButton3Visible(WifiDppUtils.isSupportConfiguratorQrCodeGenerator(mAccessPoint));
|
||||
|
||||
mSignalStrengthPref = screen.findPreference(KEY_SIGNAL_STRENGTH_PREF);
|
||||
mTxLinkSpeedPref = screen.findPreference(KEY_TX_LINK_SPEED);
|
||||
@@ -757,11 +757,11 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
|
||||
* Show QR code to share the network represented by this preference.
|
||||
*/
|
||||
public void launchWifiDppConfiguratorActivity() {
|
||||
final Intent intent = WifiDppUtils.getConfiguratorIntentOrNull(mContext, mWifiManager,
|
||||
mAccessPoint);
|
||||
final Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntentOrNull(mContext,
|
||||
mWifiManager, mAccessPoint);
|
||||
|
||||
if (intent == null) {
|
||||
Log.e(TAG, "Launch Wi-Fi DPP configurator with a wrong Wi-Fi network!");
|
||||
Log.e(TAG, "Launch Wi-Fi DPP QR code generator with a wrong Wi-Fi network!");
|
||||
} else {
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ public class WifiNetworkDetailsFragment extends DashboardFragment {
|
||||
mMetricsFeatureProvider);
|
||||
|
||||
controllers.add(mWifiDetailPreferenceController);
|
||||
controllers.add(new AddDevicePreferenceController(context).init(mAccessPoint));
|
||||
controllers.add(new WifiMeteredPreferenceController(context, mAccessPoint.getConfig()));
|
||||
WifiPrivacyPreferenceController privacyController = new WifiPrivacyPreferenceController(
|
||||
context);
|
||||
|
||||
@@ -95,34 +95,14 @@ public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
final WifiNetworkConfig wifiNetworkConfig = getWifiNetworkConfigFromHostActivity();
|
||||
MenuItem menuItem;
|
||||
if (!wifiNetworkConfig.isHotspot() &&
|
||||
wifiNetworkConfig.isSupportWifiDpp(getActivity())) {
|
||||
menuItem = menu.add(0, Menu.FIRST, 0, R.string.next_label);
|
||||
menuItem.setIcon(R.drawable.ic_scan_24dp);
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
} else {
|
||||
menuItem = menu.findItem(Menu.FIRST);
|
||||
if (menuItem != null) {
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
}
|
||||
final MenuItem menuItem = menu.findItem(Menu.FIRST);
|
||||
if (menuItem != null) {
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
}
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case Menu.FIRST:
|
||||
mListener.onQrCodeGeneratorFragmentAddButtonClicked();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
@@ -165,9 +165,8 @@ public class WifiDppUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an intent to launch QR code generator or scanner according to the Wi-Fi network
|
||||
* security. It may return null if the security is not supported by QR code generator nor
|
||||
* scanner.
|
||||
* Returns an intent to launch QR code generator. It may return null if the security is not
|
||||
* supported by QR code generator.
|
||||
*
|
||||
* Do not use this method for Wi-Fi hotspot network, use
|
||||
* {@code getHotspotConfiguratorIntentOrNull} instead.
|
||||
@@ -177,12 +176,34 @@ public class WifiDppUtils {
|
||||
* @param accessPoint An instance of {@link AccessPoint}
|
||||
* @return Intent for launching QR code generator
|
||||
*/
|
||||
public static Intent getConfiguratorIntentOrNull(Context context,
|
||||
public static Intent getConfiguratorQrCodeGeneratorIntentOrNull(Context context,
|
||||
WifiManager wifiManager, AccessPoint accessPoint) {
|
||||
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
|
||||
if (isSupportConfiguratorQrCodeGenerator(accessPoint)) {
|
||||
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
||||
} else if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
final WifiConfiguration wifiConfiguration = accessPoint.getConfig();
|
||||
setConfiguratorIntentExtra(intent, wifiManager, wifiConfiguration);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an intent to launch QR code scanner. It may return null if the security is not
|
||||
* supported by QR code scanner.
|
||||
*
|
||||
* @param context The context to use for the content resolver
|
||||
* @param wifiManager An instance of {@link WifiManager}
|
||||
* @param accessPoint An instance of {@link AccessPoint}
|
||||
* @return Intent for launching QR code scanner
|
||||
*/
|
||||
public static Intent getConfiguratorQrCodeScannerIntentOrNull(Context context,
|
||||
WifiManager wifiManager, AccessPoint accessPoint) {
|
||||
final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
|
||||
if (isSupportConfiguratorQrCodeScanner(context, accessPoint)) {
|
||||
intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||
} else {
|
||||
return null;
|
||||
@@ -258,18 +279,6 @@ public class WifiDppUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Android Q supports Wi-Fi configurator by:
|
||||
*
|
||||
* 1. QR code generator of ZXing's Wi-Fi network config format.
|
||||
* and
|
||||
* 2. QR code scanner of Wi-Fi DPP QR code format.
|
||||
*/
|
||||
public static boolean isSuportConfigurator(Context context, AccessPoint accessPoint) {
|
||||
return isSupportConfiguratorQrCodeScanner(context, accessPoint) ||
|
||||
isSupportConfiguratorQrCodeGenerator(accessPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows authentication screen to confirm credentials (pin, pattern or password) for the current
|
||||
* user of the device.
|
||||
@@ -314,7 +323,7 @@ public class WifiDppUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSupportConfiguratorQrCodeScanner(Context context,
|
||||
public static boolean isSupportConfiguratorQrCodeScanner(Context context,
|
||||
AccessPoint accessPoint) {
|
||||
if (!isWifiDppEnabled(context)) {
|
||||
return false;
|
||||
@@ -329,7 +338,7 @@ public class WifiDppUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
|
||||
public static boolean isSupportConfiguratorQrCodeGenerator(AccessPoint accessPoint) {
|
||||
// QR code generator produces QR code with ZXing's Wi-Fi network config format,
|
||||
// it supports PSK and WEP and non security
|
||||
final int security = accessPoint.getSecurity();
|
||||
|
||||
@@ -39,6 +39,7 @@ public class WifiTetherSsidPreference extends ValidatedEditTextPreference {
|
||||
|
||||
private ImageButton mImageButton;
|
||||
private Drawable mButtonIcon;
|
||||
private View mDivider;
|
||||
private View.OnClickListener mClickListener;
|
||||
private boolean mVisible;
|
||||
|
||||
@@ -68,6 +69,8 @@ public class WifiTetherSsidPreference extends ValidatedEditTextPreference {
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
// TODO(b/129019971): use methods of divider line in parent object
|
||||
setLayoutResource(com.android.settingslib.R.layout.preference_two_target);
|
||||
setWidgetLayoutResource(R.layout.wifi_button_preference_widget);
|
||||
}
|
||||
|
||||
@@ -82,13 +85,17 @@ public class WifiTetherSsidPreference extends ValidatedEditTextPreference {
|
||||
getContext().getString(R.string.wifi_dpp_share_hotspot));
|
||||
setButtonIcon(R.drawable.ic_qrcode_24dp);
|
||||
mImageButton.setImageDrawable(mButtonIcon);
|
||||
|
||||
mDivider = holder.findViewById(R.id.two_target_divider);
|
||||
}
|
||||
|
||||
if (mVisible) {
|
||||
mImageButton.setOnClickListener(mClickListener);
|
||||
mImageButton.setVisibility(View.VISIBLE);
|
||||
mDivider.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mImageButton.setVisibility(View.GONE);
|
||||
mDivider.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,8 @@ com.android.settings.datausage.WifiDataUsageSummaryPreferenceController
|
||||
com.android.settings.fuelgauge.RestrictAppPreferenceController
|
||||
com.android.settings.fuelgauge.batterysaver.BatterySaverButtonPreferenceController
|
||||
com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController
|
||||
com.android.settings.gestures.SystemNavigationEdgeToEdgePreferenceController
|
||||
com.android.settings.gestures.SystemNavigationLegacyPreferenceController
|
||||
com.android.settings.gestures.SystemNavigationSwipeUpPreferenceController
|
||||
com.android.settings.security.VisiblePatternProfilePreferenceController
|
||||
com.android.settings.wifi.details.WifiMeteredPreferenceController
|
||||
@@ -19,6 +19,7 @@ com.android.settings.applications.ProcessStatsSummary
|
||||
com.android.settings.applications.ProcessStatsUi
|
||||
com.android.settings.applications.RunningServices
|
||||
com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails
|
||||
com.android.settings.applications.specialaccess.zenaccess.ZenAccessDetails
|
||||
com.android.settings.applications.UsageAccessDetails
|
||||
com.android.settings.backup.ToggleBackupSettingFragment
|
||||
com.android.settings.biometrics.fingerprint.FingerprintSettings$FingerprintSettingsFragment
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.accessibility;
|
||||
|
||||
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 android.content.pm.ResolveInfo;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.shadows.ShadowPackageManager;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class LiveCaptionPreferenceControllerTest {
|
||||
|
||||
private LiveCaptionPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mController = new LiveCaptionPreferenceController(RuntimeEnvironment.application,
|
||||
"test_key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_canResolveIntent_shouldReturnAvailable() {
|
||||
final ShadowPackageManager pm = Shadows.shadowOf(
|
||||
RuntimeEnvironment.application.getPackageManager());
|
||||
pm.addResolveInfoForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
|
||||
new ResolveInfo());
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_noResolveIntent_shouldReturnUnavailable() {
|
||||
final ShadowPackageManager pm = Shadows.shadowOf(
|
||||
RuntimeEnvironment.application.getPackageManager());
|
||||
pm.setResolveInfosForIntent(LiveCaptionPreferenceController.LIVE_CAPTION_INTENT,
|
||||
Collections.emptyList());
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
}
|
||||
@@ -324,7 +324,7 @@ public class AppButtonsPreferenceControllerTest {
|
||||
|
||||
final boolean controllable = mController.handleDisableable();
|
||||
|
||||
verify(mButtonPrefs).setButton2Text(R.string.uninstall_text);
|
||||
verify(mButtonPrefs).setButton2Text(R.string.disable_text);
|
||||
assertThat(controllable).isFalse();
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class AppButtonsPreferenceControllerTest {
|
||||
|
||||
final boolean controllable = mController.handleDisableable();
|
||||
|
||||
verify(mButtonPrefs).setButton2Text(R.string.uninstall_text);
|
||||
verify(mButtonPrefs).setButton2Text(R.string.disable_text);
|
||||
assertThat(controllable).isTrue();
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public class AppButtonsPreferenceControllerTest {
|
||||
|
||||
final boolean controllable = mController.handleDisableable();
|
||||
|
||||
verify(mButtonPrefs).setButton2Text(R.string.install_text);
|
||||
verify(mButtonPrefs).setButton2Text(R.string.enable_text);
|
||||
assertThat(controllable).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,43 +16,26 @@
|
||||
|
||||
package com.android.settings.applications.appinfo;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowAppInfoBase;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.Spy;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class DrawOverlayDetailsTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private FragmentActivity mActivity;
|
||||
|
||||
@Mock
|
||||
private Window mWindow;
|
||||
|
||||
private LayoutParams layoutParams;
|
||||
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
@@ -82,23 +65,4 @@ public class DrawOverlayDetailsTest {
|
||||
MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_APPDRAW_DENY,
|
||||
mFragment.getMetricsCategory(), "app", 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowAppInfoBase.class})
|
||||
public void hideNonSystemOverlaysWhenResumed() {
|
||||
when(mFragment.getActivity()).thenReturn(mActivity);
|
||||
when(mActivity.getWindow()).thenReturn(mWindow);
|
||||
when(mWindow.getAttributes()).thenReturn(layoutParams);
|
||||
|
||||
mFragment.onResume();
|
||||
verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
|
||||
mFragment.onPause();
|
||||
|
||||
// There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
|
||||
ArgumentCaptor<LayoutParams> paramCaptor = ArgumentCaptor.forClass(LayoutParams.class);
|
||||
verify(mWindow).setAttributes(paramCaptor.capture());
|
||||
assertEquals(0,
|
||||
paramCaptor.getValue().privateFlags & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,9 @@ package com.android.settings.applications.managedomainurls;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
@@ -64,21 +56,6 @@ public class DomainAppPreferenceControllerTest {
|
||||
assertThat(pref.getLayoutResource()).isEqualTo(R.layout.preference_app);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_shouldSetAppendixViewToGone() {
|
||||
final DomainAppPreference pref = new DomainAppPreference(
|
||||
mContext, mIconDrawableFactory, mAppEntry);
|
||||
final View holderView = mock(View.class);
|
||||
final View appendixView = mock(View.class);
|
||||
when(holderView.findViewById(R.id.summary_container)).thenReturn(mock(View.class));
|
||||
when(holderView.findViewById(android.R.id.progress)).thenReturn(mock(ProgressBar.class));
|
||||
when(holderView.findViewById(R.id.appendix)).thenReturn(appendixView);
|
||||
|
||||
pref.onBindViewHolder(PreferenceViewHolder.createInstanceForTests(holderView));
|
||||
|
||||
verify(appendixView).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private ApplicationInfo createApplicationInfo(String packageName) {
|
||||
ApplicationInfo appInfo = new ApplicationInfo();
|
||||
appInfo.sourceDir = "foo";
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTE
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -33,8 +34,8 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.android.controller.ActivityController;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class HideNonSystemOverlayMixinTest {
|
||||
@@ -43,7 +44,6 @@ public class HideNonSystemOverlayMixinTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
RuntimeEnvironment.application.setTheme(R.style.Theme_AppCompat);
|
||||
mActivityController = Robolectric.buildActivity(TestActivity.class);
|
||||
}
|
||||
|
||||
@@ -68,10 +68,25 @@ public class HideNonSystemOverlayMixinTest {
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isEnabled_debug_false() {
|
||||
ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
|
||||
|
||||
assertThat(new HideNonSystemOverlayMixin(null).isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isEnabled_user_true() {
|
||||
ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
|
||||
|
||||
assertThat(new HideNonSystemOverlayMixin(null).isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
public static class TestActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTheme(R.style.Theme_AppCompat);
|
||||
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.development.featureflags;
|
||||
|
||||
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;
|
||||
|
||||
@@ -26,6 +27,8 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -37,6 +40,7 @@ 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 FeatureFlagPreferenceControllerTest {
|
||||
@@ -59,10 +63,18 @@ public class FeatureFlagPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_available() {
|
||||
public void getAvailability_debug_available() {
|
||||
ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getAvailability_user_unavailable() {
|
||||
ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_shouldRefreshFeatureFlags() {
|
||||
mController.onStart();
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.deviceinfo.firmwareversion;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.android.settings.deviceinfo.firmwareversion.MainlineModuleVersionPreferenceController.MODULE_UPDATE_INTENT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -29,8 +30,11 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -48,11 +52,13 @@ public class MainlineModuleVersionPreferenceControllerTest {
|
||||
private PackageManager mPackageManager;
|
||||
|
||||
private Context mContext;
|
||||
private Preference mPreference;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mPreference = new Preference(mContext);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.MAINLINE_MODULE, true);
|
||||
@@ -82,7 +88,6 @@ public class MainlineModuleVersionPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_noMainlineModulePackageInfo_unavailable() throws Exception {
|
||||
|
||||
final String provider = "test.provider";
|
||||
when(mContext.getString(
|
||||
com.android.internal.R.string.config_defaultModuleMetadataProvider))
|
||||
@@ -98,6 +103,43 @@ public class MainlineModuleVersionPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_hasMainlineModulePackageInfo_available() throws Exception {
|
||||
setupModulePackage();
|
||||
|
||||
final MainlineModuleVersionPreferenceController controller =
|
||||
new MainlineModuleVersionPreferenceController(mContext, "key");
|
||||
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateStates_canHandleIntent_setIntentToPreference() throws Exception {
|
||||
setupModulePackage();
|
||||
when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
|
||||
.thenReturn(new ResolveInfo());
|
||||
|
||||
final MainlineModuleVersionPreferenceController controller =
|
||||
new MainlineModuleVersionPreferenceController(mContext, "key");
|
||||
|
||||
controller.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getIntent()).isEqualTo(MODULE_UPDATE_INTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateStates_cannotHandleIntent_setNullToPreference() throws Exception {
|
||||
setupModulePackage();
|
||||
when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
|
||||
.thenReturn(null);
|
||||
|
||||
final MainlineModuleVersionPreferenceController controller =
|
||||
new MainlineModuleVersionPreferenceController(mContext, "key");
|
||||
|
||||
controller.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getIntent()).isNull();
|
||||
}
|
||||
|
||||
private void setupModulePackage() throws Exception {
|
||||
final String provider = "test.provider";
|
||||
final String version = "test version 123";
|
||||
final PackageInfo info = new PackageInfo();
|
||||
@@ -106,11 +148,5 @@ public class MainlineModuleVersionPreferenceControllerTest {
|
||||
com.android.internal.R.string.config_defaultModuleMetadataProvider))
|
||||
.thenReturn(provider);
|
||||
when(mPackageManager.getPackageInfo(eq(provider), anyInt())).thenReturn(info);
|
||||
|
||||
final MainlineModuleVersionPreferenceController controller =
|
||||
new MainlineModuleVersionPreferenceController(mContext, "key");
|
||||
|
||||
assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings.display;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.UiModeManager;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
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 DarkUIPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ListPreference mPreference;
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
@Mock
|
||||
private UiModeManager mUiModeManager;
|
||||
private DarkUIPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new DarkUIPreferenceController(mContext, "dark_ui_mode");
|
||||
mController.setUiModeManager(mUiModeManager);
|
||||
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
|
||||
.thenReturn(mPreference);
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChanged_setAuto() {
|
||||
// Auto was deprecated, it should default to NO.
|
||||
mController.onPreferenceChange(mPreference, "auto");
|
||||
verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_NO));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChanged_setNightMode() {
|
||||
mController.onPreferenceChange(mPreference, "yes");
|
||||
verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_YES));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChanged_setDayMode() {
|
||||
mController.onPreferenceChange(mPreference, "no");
|
||||
verify(mUiModeManager).setNightMode(eq(UiModeManager.MODE_NIGHT_NO));
|
||||
}
|
||||
|
||||
public int getCurrentMode() {
|
||||
final UiModeManager uiModeManager = mContext.getSystemService(UiModeManager.class);
|
||||
return uiModeManager.getNightMode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.UiModeManager;
|
||||
import android.content.Context;
|
||||
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.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class DarkUISettingsRadioButtonsControllerTest {
|
||||
|
||||
@Mock
|
||||
private UiModeManager mUiModeManager;
|
||||
@Mock
|
||||
private Preference mFooter;
|
||||
private Context mContext;
|
||||
private DarkUISettingsRadioButtonsController mController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new DarkUISettingsRadioButtonsController(mContext, mFooter);
|
||||
mController.mManager = mUiModeManager;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void footerUpdatesCorrectly() {
|
||||
doReturn(UiModeManager.MODE_NIGHT_YES).when(mUiModeManager).getNightMode();
|
||||
mController.updateFooter();
|
||||
verify(mFooter).setSummary(eq(R.string.dark_ui_settings_dark_summary));
|
||||
|
||||
doReturn(UiModeManager.MODE_NIGHT_NO).when(mUiModeManager).getNightMode();
|
||||
mController.updateFooter();
|
||||
verify(mFooter).setSummary(eq(R.string.dark_ui_settings_light_summary));
|
||||
}
|
||||
|
||||
public int getCurrentMode() {
|
||||
final UiModeManager uiModeManager = mContext.getSystemService(UiModeManager.class);
|
||||
return uiModeManager.getNightMode();
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.android.settings.fuelgauge.batterysaver;
|
||||
|
||||
import static com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController.LOW_POWER_STICKY_AUTO_DISABLE_ENABLED;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -43,21 +43,21 @@ public class BatterySaverStickyPreferenceControllerTest {
|
||||
|
||||
private int getAutoDisableSetting() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
|
||||
Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED,
|
||||
1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnPreferenceChange_turnOnKeepActive_autoDisableOff() {
|
||||
mController.onPreferenceChange(null, true);
|
||||
final int isOn = getAutoDisableSetting();
|
||||
assertThat(isOn).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnPreferenceChange_TurnOffKeepActive_autoDisableOff() {
|
||||
mController.onPreferenceChange(null, false);
|
||||
public void testOnPreferenceChange_turnOnAutoOff_autoDisableOn() {
|
||||
mController.setChecked(true);
|
||||
final int isOn = getAutoDisableSetting();
|
||||
assertThat(isOn).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnPreferenceChange_TurnOffAutoOff_autoDisableOff() {
|
||||
mController.setChecked(false);
|
||||
final int isOn = getAutoDisableSetting();
|
||||
assertThat(isOn).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@ package com.android.settings.homepage.contextualcards.conditional;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -80,4 +82,11 @@ public class GrayscaleConditionControllerTest {
|
||||
|
||||
verify(mConditionManager).onConditionChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActionClick_shouldSendBroadcast() {
|
||||
mController.onActionClick();
|
||||
|
||||
verify(mContext).sendBroadcast(any(Intent.class), any(String.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.android.settingslib.media.MediaDevice;
|
||||
import com.android.settingslib.media.MediaOutputSliceConstants;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -59,6 +60,7 @@ import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowBluetoothAdapter.class})
|
||||
@Ignore("b/129292771")
|
||||
public class MediaOutputIndicatorSliceTest {
|
||||
|
||||
private static final String TEST_DEVICE_NAME = "test_device_name";
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -52,6 +53,7 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowBluetoothUtils.class,
|
||||
ShadowBluetoothDevice.class})
|
||||
@Ignore("b/129292771")
|
||||
public class MediaOutputIndicatorWorkerTest {
|
||||
|
||||
private static final String TEST_A2DP_DEVICE_NAME = "Test_A2DP_BT_Device_NAME";
|
||||
|
||||
@@ -102,13 +102,27 @@ public class Enhanced4gLtePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_variant4gLte_useVariantTitle() {
|
||||
mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 1);
|
||||
|
||||
public void updateState_variant4gLte_useVariantTitleAndSummary() {
|
||||
mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 0);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getTitle()).isEqualTo(
|
||||
mContext.getString(R.string.enhanced_4g_lte_mode_title_variant));
|
||||
mContext.getString(R.string.enhanced_4g_lte_mode_title));
|
||||
assertThat(mPreference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.enhanced_4g_lte_mode_summary));
|
||||
|
||||
mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 1);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.getTitle()).isEqualTo(
|
||||
mContext.getString(R.string.enhanced_4g_lte_mode_title_advanced_calling));
|
||||
assertThat(mPreference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.enhanced_4g_lte_mode_summary));
|
||||
|
||||
mCarrierConfig.putInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT, 2);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.getTitle()).isEqualTo(
|
||||
mContext.getString(R.string.enhanced_4g_lte_mode_title_4g_calling));
|
||||
assertThat(mPreference.getSummary()).isEqualTo(
|
||||
mContext.getString(R.string.enhanced_4g_lte_mode_summary_4g_calling));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AppNotificationSettingsTest {
|
||||
|
||||
private WindowManager.LayoutParams mLayoutParams;
|
||||
private AppNotificationSettings mFragment;
|
||||
private FragmentActivity mActivity;
|
||||
@Mock
|
||||
private Window mWindow;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mLayoutParams = new WindowManager.LayoutParams();
|
||||
mActivity = spy(Robolectric.setupActivity(FragmentActivity.class));
|
||||
mFragment = spy(new AppNotificationSettings());
|
||||
when(mFragment.getActivity()).thenReturn(mActivity);
|
||||
when(mFragment.getFragmentManager()).thenReturn(mock(FragmentManager.class));
|
||||
when(mActivity.getWindow()).thenReturn(mWindow);
|
||||
when(mWindow.getAttributes()).thenReturn(mLayoutParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowNotificationSettingsBase.class})
|
||||
public void onResume_shouldHideSystemOverlay() {
|
||||
mFragment.onResume();
|
||||
|
||||
verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowNotificationSettingsBase.class})
|
||||
public void onPause_shouldRemoveHideSystemOverlay() {
|
||||
mFragment.onResume();
|
||||
|
||||
verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
|
||||
mFragment.onPause();
|
||||
|
||||
// There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
|
||||
ArgumentCaptor<WindowManager.LayoutParams> paramCaptor = ArgumentCaptor.forClass(
|
||||
WindowManager.LayoutParams.class);
|
||||
verify(mWindow).setAttributes(paramCaptor.capture());
|
||||
assertEquals(0,
|
||||
paramCaptor.getValue().privateFlags
|
||||
& SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
}
|
||||
|
||||
@Implements(NotificationSettingsBase.class)
|
||||
public static class ShadowNotificationSettingsBase {
|
||||
|
||||
protected void __constructor__() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected void onResume() {
|
||||
// No-op.
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected void onPause() {
|
||||
// No-op.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.android.settingslib.testutils.DrawableTestHelper;
|
||||
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
@@ -92,6 +93,7 @@ public class ChooseLockPatternTest {
|
||||
|
||||
@Config(qualifiers = "sw400dp")
|
||||
@Test
|
||||
@Ignore("b/129342100")
|
||||
public void fingerprintExtraSet_shouldDisplayFingerprintIcon() {
|
||||
ChooseLockPattern activity = createActivity(true);
|
||||
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
|
||||
|
||||
@@ -35,8 +35,6 @@ import org.robolectric.RuntimeEnvironment;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AppCheckBoxPreferenceTest {
|
||||
|
||||
private static final String SUMMARY = "summary info";
|
||||
|
||||
private Context mContext;
|
||||
private AppCheckBoxPreference mPreference;
|
||||
private AppCheckBoxPreference mAttrPreference;
|
||||
@@ -57,26 +55,6 @@ public class AppCheckBoxPreferenceTest {
|
||||
assertThat(mAttrPreference.getLayoutResource()).isEqualTo(R.layout.preference_app);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_noSummary_layoutGone() {
|
||||
mPreference.setSummary("");
|
||||
|
||||
mPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
|
||||
assertThat(mPreferenceViewHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_hasSummary_layoutVisible() {
|
||||
mPreference.setSummary(SUMMARY);
|
||||
|
||||
mPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
|
||||
assertThat(mPreferenceViewHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_appendixGone() {
|
||||
mPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.widget;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AppSwitchPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
private View mRootView;
|
||||
private AppSwitchPreference mPref;
|
||||
private PreferenceViewHolder mHolder;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
|
||||
mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
|
||||
mPref = new AppSwitchPreference(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSummary_showSummaryContainer() {
|
||||
mPref.setSummary("test");
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSummary_hideSummaryContainer() {
|
||||
mPref.setSummary(null);
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
|
||||
.isEqualTo(View.GONE);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,10 @@ package com.android.settings.widget;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
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.verify;
|
||||
@@ -29,6 +33,8 @@ import android.media.MediaPlayer;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.TextureView;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -45,8 +51,13 @@ import org.robolectric.RuntimeEnvironment;
|
||||
public class VideoPreferenceTest {
|
||||
private static final int VIDEO_WIDTH = 100;
|
||||
private static final int VIDEO_HEIGHT = 150;
|
||||
|
||||
@Mock
|
||||
private MediaPlayer mMediaPlayer;
|
||||
@Mock
|
||||
private ImageView fakePreview;
|
||||
@Mock
|
||||
private ImageView fakePlayButton;
|
||||
private Context mContext;
|
||||
private VideoPreference mVideoPreference;
|
||||
private PreferenceViewHolder mPreferenceViewHolder;
|
||||
@@ -83,8 +94,8 @@ public class VideoPreferenceTest {
|
||||
(TextureView) mPreferenceViewHolder.findViewById(R.id.video_texture_view);
|
||||
mVideoPreference.mAnimationAvailable = true;
|
||||
mVideoPreference.mVideoReady = true;
|
||||
mVideoPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
mVideoPreference.onViewInvisible();
|
||||
mVideoPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||
when(mMediaPlayer.isPlaying()).thenReturn(false);
|
||||
final TextureView.SurfaceTextureListener listener = video.getSurfaceTextureListener();
|
||||
|
||||
@@ -101,4 +112,30 @@ public class VideoPreferenceTest {
|
||||
|
||||
verify(mMediaPlayer).release();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateViewStates_paused_updatesViews() {
|
||||
when(mMediaPlayer.isPlaying()).thenReturn(true);
|
||||
mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
|
||||
verify(fakePlayButton).setVisibility(eq(View.VISIBLE));
|
||||
verify(fakePreview).setVisibility(eq(View.VISIBLE));
|
||||
verify(mMediaPlayer).pause();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateViewStates_playing_updatesViews() {
|
||||
when(mMediaPlayer.isPlaying()).thenReturn(false);
|
||||
mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
|
||||
verify(fakePlayButton).setVisibility(eq(View.GONE));
|
||||
verify(fakePreview).setVisibility(eq(View.GONE));
|
||||
verify(mMediaPlayer).start();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateViewStates_noMediaPlayer_skips() {
|
||||
mVideoPreference.mMediaPlayer = null;
|
||||
mVideoPreference.updateViewStates(fakePreview, fakePlayButton);
|
||||
verify(fakePlayButton, never()).setVisibility(anyInt());
|
||||
verify(fakePreview, never()).setVisibility(anyInt());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.RecyclerView.OnScrollListener;
|
||||
|
||||
@@ -60,7 +61,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
public class WifiCallingDisclaimerFragmentTest {
|
||||
|
||||
@Mock
|
||||
private Activity mActivity;
|
||||
private FragmentActivity mActivity;
|
||||
@Mock
|
||||
private DisclaimerItem mDisclaimerItem;
|
||||
@Mock
|
||||
@@ -89,7 +90,7 @@ public class WifiCallingDisclaimerFragmentTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mActivity = Robolectric.setupActivity(Activity.class);
|
||||
mActivity = Robolectric.setupActivity(FragmentActivity.class);
|
||||
mFragment = spy(new WifiCallingDisclaimerFragment());
|
||||
|
||||
doReturn(mActivity).when(mFragment).getActivity();
|
||||
|
||||
@@ -77,6 +77,7 @@ import com.android.settingslib.widget.LayoutPreference;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
@@ -98,6 +99,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowDevicePolicyManager.class, ShadowEntityHeaderController.class})
|
||||
@Ignore("b/129292549")
|
||||
public class WifiDetailPreferenceControllerTest {
|
||||
|
||||
private static final int LEVEL = 1;
|
||||
|
||||
@@ -139,7 +139,7 @@ public class WifiSliceTest {
|
||||
|
||||
private AccessPoint createAccessPoint(String name, boolean active, boolean reachable) {
|
||||
final AccessPoint accessPoint = mock(AccessPoint.class);
|
||||
doReturn(name).when(accessPoint).getConfigName();
|
||||
doReturn(name).when(accessPoint).getTitle();
|
||||
doReturn(active).when(accessPoint).isActive();
|
||||
doReturn(reachable).when(accessPoint).isReachable();
|
||||
if (active) {
|
||||
|
||||
Reference in New Issue
Block a user