Merge "Deep link to detail UI when mainline module version is clicked."
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 521d709..b8bd424 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -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>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index c333edb..ff040ee 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -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 -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9b23ca9..e51734c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -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 -->
@@ -5662,12 +5660,6 @@
<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>
<!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
@@ -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] -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index da103c5..1efe2c2 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -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"
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index 9dd5fea..2996afa 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -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"
diff --git a/res/xml/app_default_settings.xml b/res/xml/app_default_settings.xml
index c26c069..1f1b24a 100644
--- a/res/xml/app_default_settings.xml
+++ b/res/xml/app_default_settings.xml
@@ -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"
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index ae9d14d..c8d1d63 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -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"/>
diff --git a/res/xml/dark_ui_settings.xml b/res/xml/dark_ui_settings.xml
new file mode 100644
index 0000000..1f11eba
--- /dev/null
+++ b/res/xml/dark_ui_settings.xml
@@ -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 >
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index f98ce3d..2d5b24d 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -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"/>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 91fe656..940e6de 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -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
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index 57bee1f..c3161d5 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -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
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index c4bd11d..63ce90b 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -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"
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 15ab1aa..c621466 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -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"
diff --git a/res/xml/wifi_display_settings.xml b/res/xml/wifi_display_settings.xml
index 7ad214e..769e9ce 100644
--- a/res/xml/wifi_display_settings.xml
+++ b/res/xml/wifi_display_settings.xml
@@ -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>
diff --git a/res/xml/wifi_network_details_fragment.xml b/res/xml/wifi_network_details_fragment.xml
index 8979efc..782a7cf 100644
--- a/res/xml/wifi_network_details_fragment.xml
+++ b/res/xml/wifi_network_details_fragment.xml
@@ -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"
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 921af04..b9b9538 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -136,6 +136,8 @@
"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 @@
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 @@
(context, HEARING_AID_PREFERENCE);
mHearingAidPreferenceController.setFragmentManager(getFragmentManager());
getLifecycle().addObserver(mHearingAidPreferenceController);
+
+ mLiveCaptionPreferenceController = new LiveCaptionPreferenceController(context,
+ LIVE_CAPTION_PREFERENCE_KEY);
}
@Override
@@ -487,6 +494,10 @@
// 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 @@
mHearingAidPreferenceController.updateState(mHearingAidPreference);
+ mLiveCaptionPreferenceController.updateState(mLiveCaptionPreference);
+
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
mCaptioningPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
@@ -752,7 +765,6 @@
}
void updateAccessibilityTimeoutSummary(ContentResolver resolver, Preference pref) {
-
String[] timeoutSummarys = getResources().getStringArray(
R.array.accessibility_timeout_summaries);
int[] timeoutValues = getResources().getIntArray(
@@ -821,7 +833,7 @@
pref.setSummary(entries[index]);
}
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ @VisibleForTesting
void updateVibrationSummary(Preference pref) {
final Context context = getContext();
final Vibrator vibrator = context.getSystemService(Vibrator.class);
diff --git a/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java b/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java
new file mode 100644
index 0000000..2d12f67
--- /dev/null
+++ b/src/com/android/settings/accessibility/LiveCaptionPreferenceController.java
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 9839934..4faa158 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -625,12 +625,32 @@
@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;
}
}
diff --git a/src/com/android/settings/core/HideNonSystemOverlayMixin.java b/src/com/android/settings/core/HideNonSystemOverlayMixin.java
index 59cef3b..4b8975d 100644
--- a/src/com/android/settings/core/HideNonSystemOverlayMixin.java
+++ b/src/com/android/settings/core/HideNonSystemOverlayMixin.java
@@ -22,9 +22,11 @@
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 @@
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 @@
@OnLifecycleEvent(ON_STOP)
public void onStop() {
- if (mActivity == null) {
+ if (mActivity == null || !isEnabled()) {
return;
}
final Window window = mActivity.getWindow();
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
index 638c7c1..94636e9 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
@@ -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 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return Build.IS_DEBUGGABLE ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/display/DarkUIPreferenceController.java b/src/com/android/settings/display/DarkUIPreferenceController.java
index 21af603..7d8fd56 100644
--- a/src/com/android/settings/display/DarkUIPreferenceController.java
+++ b/src/com/android/settings/display/DarkUIPreferenceController.java
@@ -27,8 +27,7 @@
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;
@@ -48,58 +47,8 @@
}
@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());
}
}
diff --git a/src/com/android/settings/display/DarkUISettings.java b/src/com/android/settings/display/DarkUISettings.java
new file mode 100644
index 0000000..50fd386
--- /dev/null
+++ b/src/com/android/settings/display/DarkUISettings.java
@@ -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);
+ }
+ };
+}
diff --git a/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java b/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java
new file mode 100644
index 0000000..0fca306
--- /dev/null
+++ b/src/com/android/settings/display/DarkUISettingsRadioButtonsController.java
@@ -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];
+ }
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
index 7a1f7f5..7d4bdac 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -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
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
index 664707d..341e061 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
@@ -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 @@
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 @@
mAppContext = appContext;
mConditionManager = conditionManager;
mColorDisplayManager = mAppContext.getSystemService(ColorDisplayManager.class);
+ mReceiver = new Receiver();
}
@Override
@@ -72,6 +81,7 @@
public void onActionClick() {
// Turn off grayscale
mColorDisplayManager.setSaturationLevel(100 /* staturationLevel */);
+ sendBroadcast();
mConditionManager.onConditionChanged();
}
@@ -93,11 +103,27 @@
@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();
+ }
+ }
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index b9170a9..006734f 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -98,8 +98,6 @@
@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 @@
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);
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
index c510294..161c218 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceController.java
@@ -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 @@
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 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());
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 891d171..4f3b9bc 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -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 @@
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
diff --git a/src/com/android/settings/widget/RadioButtonPickerFragment.java b/src/com/android/settings/widget/RadioButtonPickerFragment.java
index 591cd21..8861c94 100644
--- a/src/com/android/settings/widget/RadioButtonPickerFragment.java
+++ b/src/com/android/settings/widget/RadioButtonPickerFragment.java
@@ -58,6 +58,9 @@
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 @@
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
+ if (mIllustrationId != 0) {
+ addIllustration(screen);
+ }
if (!mAppendStaticPreferences) {
addStaticPreferences(screen);
}
@@ -241,6 +247,23 @@
}
}
+ /**
+ * 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();
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index fd215d8..2d88673 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -55,22 +55,41 @@
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 @@
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 @@
});
}
+ @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 @@
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);
diff --git a/src/com/android/settings/wifi/AddWifiNetworkPreference.java b/src/com/android/settings/wifi/AddWifiNetworkPreference.java
index cd2e4a8..e49f2ab 100644
--- a/src/com/android/settings/wifi/AddWifiNetworkPreference.java
+++ b/src/com/android/settings/wifi/AddWifiNetworkPreference.java
@@ -20,7 +20,6 @@
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 @@
getContext().startActivity(
WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
});
-
- final View divider = (View) holder.findViewById(
- com.android.settingslib.R.id.two_target_divider);
- divider.setVisibility(View.INVISIBLE);
}
}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 0adbd8d..0887fc5 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -637,7 +637,7 @@
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();
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index a22bdba..9b3c1b3 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -198,7 +198,7 @@
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)) {
diff --git a/src/com/android/settings/wifi/details/AddDevicePreferenceController.java b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
new file mode 100644
index 0000000..61804a2
--- /dev/null
+++ b/src/com/android/settings/wifi/details/AddDevicePreferenceController.java
@@ -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);
+ }
+ }
+}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index cf59dbd..5fc350b 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -342,7 +342,7 @@
.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 @@
* 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);
}
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 66587ed..ee4cc29 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -134,6 +134,7 @@
mMetricsFeatureProvider);
controllers.add(mWifiDetailPreferenceController);
+ controllers.add(new AddDevicePreferenceController(context).init(mAccessPoint));
controllers.add(new WifiMeteredPreferenceController(context, mAccessPoint.getConfig()));
WifiPrivacyPreferenceController privacyController = new WifiPrivacyPreferenceController(
context);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
index 4e6a0d6..d388931 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
@@ -95,35 +95,15 @@
@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) {
return inflater.inflate(R.layout.wifi_dpp_qrcode_generator_fragment, container,
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index bf78b3f..6c6444c 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -165,9 +165,8 @@
}
/**
- * 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 @@
* @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;
@@ -259,18 +280,6 @@
}
/**
- * 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 @@
}
}
- private static boolean isSupportConfiguratorQrCodeScanner(Context context,
+ public static boolean isSupportConfiguratorQrCodeScanner(Context context,
AccessPoint accessPoint) {
if (!isWifiDppEnabled(context)) {
return false;
@@ -329,7 +338,7 @@
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();
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java b/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java
index 64014d9..7d4ebec 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSsidPreference.java
@@ -39,6 +39,7 @@
private ImageButton mImageButton;
private Drawable mButtonIcon;
+ private View mDivider;
private View.OnClickListener mClickListener;
private boolean mVisible;
@@ -68,6 +69,8 @@
}
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 @@
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);
}
}
diff --git a/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor b/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor
index 675108d..a723842 100644
--- a/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor
+++ b/tests/robotests/assets/grandfather_invalid_base_preference_controller_constructor
@@ -10,5 +10,8 @@
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
\ No newline at end of file
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 015502b..8ca65ff 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -19,6 +19,7 @@
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
diff --git a/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
new file mode 100644
index 0000000..9e0ce9c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/LiveCaptionPreferenceControllerTest.java
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
index f3d85d3..59aea3d 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
@@ -324,7 +324,7 @@
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 @@
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 @@
final boolean controllable = mController.handleDisableable();
- verify(mButtonPrefs).setButton2Text(R.string.install_text);
+ verify(mButtonPrefs).setButton2Text(R.string.enable_text);
assertThat(controllable).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
index ca99361..fdbf8b9 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DrawOverlayDetailsTest.java
@@ -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 @@
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);
- }
}
diff --git a/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
index 5f2a514..5e5239d 100644
--- a/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceControllerTest.java
@@ -18,17 +18,9 @@
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 @@
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";
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index 139ef41..5538155 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -55,6 +55,7 @@
private static final int BATTERY_LEVEL_LEFT = 25;
private static final int BATTERY_LEVEL_RIGHT = 45;
private static final String ICON_URI = "content://test.provider/icon.png";
+ private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
private Context mContext;
@@ -83,6 +84,7 @@
mController.mLayoutPreference = mLayoutPreference;
mController.mBluetoothAdapter = mBluetoothAdapter;
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
+ when(mCachedDevice.getAddress()).thenReturn(MAC_ADDRESS);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index e57d5aa..29640d6 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -52,6 +52,8 @@
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
ShadowCachedBluetoothDeviceManager.class})
public class AvailableMediaBluetoothDeviceUpdaterTest {
+ private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
+
@Mock
private DashboardFragment mDashboardFragment;
@Mock
@@ -84,6 +86,7 @@
doReturn(mContext).when(mDashboardFragment).getContext();
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
+ when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
mBluetoothDeviceUpdater = spy(new AvailableMediaBluetoothDeviceUpdater(mContext,
mDashboardFragment, mDevicePreferenceCallback));
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index f6969ec..56d17f4 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -52,6 +52,7 @@
@Config(shadows = {ShadowAlertDialogCompat.class})
public class BluetoothDevicePreferenceTest {
private static final boolean SHOW_DEVICES_WITHOUT_NAMES = true;
+ private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
private Context mContext;
@Mock
@@ -68,6 +69,7 @@
mContext = new ContextThemeWrapper(context, R.style.Theme_Settings);
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
+ when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
SHOW_DEVICES_WITHOUT_NAMES);
}
@@ -164,18 +166,6 @@
}
@Test
- public void imagingDeviceIcon_isICSettingsPrint() {
- when(mCachedBluetoothDevice.getBatteryLevel())
- .thenReturn(BluetoothDevice.BATTERY_LEVEL_UNKNOWN);
- when(mCachedBluetoothDevice.getBtClass())
- .thenReturn(new BluetoothClass(BluetoothClass.Device.Major.IMAGING));
-
- mPreference.onDeviceAttributesChanged();
- DrawableTestHelper.assertDrawableResId(mPreference.getIcon(),
- com.android.internal.R.drawable.ic_settings_print);
- }
-
- @Test
public void testVisible_showDeviceWithoutNames_visible() {
doReturn(false).when(mCachedBluetoothDevice).hasHumanReadableName();
BluetoothDevicePreference preference =
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
index b320500..24aae85 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
@@ -56,6 +56,9 @@
@Config(shadows = {ShadowBluetoothAdapter.class})
public class BluetoothDeviceUpdaterTest {
+ private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
+ private static final String SUB_MAC_ADDRESS = "05:52:C7:0B:D8:3C";
+
@Mock
private DashboardFragment mDashboardFragment;
@Mock
@@ -93,6 +96,8 @@
when(mSubCachedBluetoothDevice.getDevice()).thenReturn(mSubBluetoothDevice);
when(mLocalManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
+ when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
+ when(mSubBluetoothDevice.getAddress()).thenReturn(SUB_MAC_ADDRESS);
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
mBluetoothDeviceUpdater =
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
index db4da4f..615f67a 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
@@ -54,6 +54,9 @@
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
ShadowCachedBluetoothDeviceManager.class})
public class ConnectedBluetoothDeviceUpdaterTest {
+
+ private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
+
@Mock
private DashboardFragment mDashboardFragment;
@Mock
@@ -84,6 +87,7 @@
mCachedDevices = new ArrayList<>();
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
+ when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
mDashboardFragment, mDevicePreferenceCallback));
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index 03c7136..ac7692d 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -44,6 +44,8 @@
@Config(shadows = {ShadowBluetoothAdapter.class})
public class SavedBluetoothDeviceUpdaterTest {
+ private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
+
@Mock
private DashboardFragment mDashboardFragment;
@Mock
@@ -64,6 +66,7 @@
mContext = RuntimeEnvironment.application;
doReturn(mContext).when(mDashboardFragment).getContext();
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
+ when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mContext, mDashboardFragment,
diff --git a/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java b/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
index 579cba0..d4f43e2 100644
--- a/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
+++ b/tests/robotests/src/com/android/settings/core/HideNonSystemOverlayMixinTest.java
@@ -20,6 +20,7 @@
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.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 @@
@Before
public void setUp() {
- RuntimeEnvironment.application.setTheme(R.style.Theme_AppCompat);
mActivityController = Robolectric.buildActivity(TestActivity.class);
}
@@ -68,10 +68,25 @@
.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));
}
}
diff --git a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
index 2e15967..cf97544 100644
--- a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java
@@ -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.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.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class FeatureFlagPreferenceControllerTest {
@@ -59,10 +63,18 @@
}
@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();
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
deleted file mode 100644
index c8f847b..0000000
--- a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
+++ /dev/null
@@ -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();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java
new file mode 100644
index 0000000..76142a4
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/DarkUISettingsRadioButtonsControllerTest.java
@@ -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();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
index 0ee9cfc..0e7c312 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
@@ -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 @@
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);
+ public void testOnPreferenceChange_turnOnAutoOff_autoDisableOn() {
+ mController.setChecked(true);
final int isOn = getAutoDisableSetting();
- assertThat(isOn).isEqualTo(0);
+ assertThat(isOn).isEqualTo(1);
}
@Test
- public void testOnPreferenceChange_TurnOffKeepActive_autoDisableOff() {
- mController.onPreferenceChange(null, false);
+ public void testOnPreferenceChange_TurnOffAutoOff_autoDisableOff() {
+ mController.setChecked(false);
final int isOn = getAutoDisableSetting();
- assertThat(isOn).isEqualTo(1);
+ assertThat(isOn).isEqualTo(0);
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
index 8c24735..2fe4697 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
@@ -18,11 +18,13 @@
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 @@
verify(mConditionManager).onConditionChanged();
}
+
+ @Test
+ public void onActionClick_shouldSendBroadcast() {
+ mController.onActionClick();
+
+ verify(mContext).sendBroadcast(any(Intent.class), any(String.class));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
index ab3f4de..c551960 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorSliceTest.java
@@ -45,6 +45,7 @@
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 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowBluetoothAdapter.class})
+@Ignore("b/129292771")
public class MediaOutputIndicatorSliceTest {
private static final String TEST_DEVICE_NAME = "test_device_name";
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
index 4a5662e..ed93258 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
@@ -37,6 +37,7 @@
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 @@
@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";
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
index 78ed4b5..9957cde 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLtePreferenceControllerTest.java
@@ -102,13 +102,27 @@
}
@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
diff --git a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
deleted file mode 100644
index 9555a56..0000000
--- a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
+++ /dev/null
@@ -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.
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index 3509d75..4bc8374 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -32,6 +32,7 @@
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 @@
@Config(qualifiers = "sw400dp")
@Test
+ @Ignore("b/129342100")
public void fingerprintExtraSet_shouldDisplayFingerprintIcon() {
ChooseLockPattern activity = createActivity(true);
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
diff --git a/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
index 57c6e01..6340b16 100644
--- a/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/AppCheckBoxPreferenceTest.java
@@ -35,8 +35,6 @@
@RunWith(RobolectricTestRunner.class)
public class AppCheckBoxPreferenceTest {
- private static final String SUMMARY = "summary info";
-
private Context mContext;
private AppCheckBoxPreference mPreference;
private AppCheckBoxPreference mAttrPreference;
@@ -58,26 +56,6 @@
}
@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);
diff --git a/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
deleted file mode 100644
index aa5e3e7..0000000
--- a/tests/robotests/src/com/android/settings/widget/AppSwitchPreferenceTest.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 4cd6be4..b53f364 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -18,6 +18,10 @@
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.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 @@
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 @@
(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 @@
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());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
index 6c221e7..25fa737 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingDisclaimerFragmentTest.java
@@ -35,6 +35,7 @@
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 @@
public class WifiCallingDisclaimerFragmentTest {
@Mock
- private Activity mActivity;
+ private FragmentActivity mActivity;
@Mock
private DisclaimerItem mDisclaimerItem;
@Mock
@@ -89,7 +90,7 @@
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();
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 574d0d6..947d618 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -77,6 +77,7 @@
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 @@
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowDevicePolicyManager.class, ShadowEntityHeaderController.class})
+@Ignore("b/129292549")
public class WifiDetailPreferenceControllerTest {
private static final int LEVEL = 1;
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index 75a9e11..e9f35d8 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -139,7 +139,7 @@
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) {