Merge "Update R accessibility assets and strings (4/n)" into rvc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 12075a2..17b498e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3196,7 +3196,6 @@
<activity-alias
android:name="MediaOutputSlice"
android:label="@string/media_output_panel_title"
- android:permission="android.permission.BLUETOOTH_PRIVILEGED"
android:targetActivity=".panel.SettingsPanelActivity">
<intent-filter>
<action android:name="com.android.settings.panel.action.MEDIA_OUTPUT" />
diff --git a/res/layout/dialog_back_gesture_sensitivity.xml b/res/layout/dialog_back_gesture_sensitivity.xml
deleted file mode 100644
index 37ef771..0000000
--- a/res/layout/dialog_back_gesture_sensitivity.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2019 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:padding="12dp">
-
- <SeekBar
- android:id="@+id/back_sensitivity_seekbar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:min="0"
- android:max="3"
- style="@android:style/Widget.Material.SeekBar.Discrete"
- android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_marginTop="2dp"
- android:layout_marginBottom="8dp">
-
- <TextView android:id="@+id/low_tick"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_marginBottom="2dp"
- android:layout_marginStart="12dp"
- android:gravity="start"
- android:text="@string/low_label"
- android:textAppearance="?android:attr/textAppearance"
- android:singleLine="true"
- android:ellipsize="marquee" />
-
- <TextView android:id="@+id/high_tick"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_marginBottom="2dp"
- android:layout_marginEnd="12dp"
- android:gravity="end"
- android:text="@string/high_label"
- android:textAppearance="?android:attr/textAppearance"
- android:singleLine="true"
- android:ellipsize="marquee" />
-
- </LinearLayout>
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/notification_history_app_layout.xml b/res/layout/notification_history_app_layout.xml
index 4c899e6..5d8ff3f 100644
--- a/res/layout/notification_history_app_layout.xml
+++ b/res/layout/notification_history_app_layout.xml
@@ -82,10 +82,8 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notification_list"
android:layout_width="match_parent"
- android:layout_height="0dp"
+ android:layout_height="wrap_content"
android:clipChildren="true"
- settings:layout_constraintHeight_max="300dp"
- settings:layout_constrainedHeight="true"
settings:fastScrollEnabled="true"
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index f67d0bd..4ce02ee 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -37,5 +37,6 @@
<color name="palette_list_color_cyan">@color/palette_list_dark_mode_color_cyan</color>
<color name="palette_list_color_blue">@color/palette_list_dark_mode_color_blue</color>
<color name="palette_list_color_purple">@color/palette_list_dark_mode_color_purple</color>
+ <color name="gestures_setting_background_color">@android:color/black</color>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5dcab3e..b789907 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2742,7 +2742,7 @@
<!-- Display settings screen, display white balance settings summary [CHAR LIMIT=NONE] -->
<string name="display_white_balance_summary"></string>
<!-- Display settings screen, setting option name to enable adaptive sleep [CHAR LIMIT=30] -->
- <string name="adaptive_sleep_title">Screen attention</string>
+ <string name="adaptive_sleep_title">Turn on screen attention</string>
<!-- Setting option summary when adaptive sleep is on [CHAR LIMIT=NONE] -->
<string name="adaptive_sleep_summary_on">On / Screen won\u2019t turn off if you\u2019re looking at it</string>
<!-- Setting option summary when adaptive sleep is off [CHAR LIMIT=NONE] -->
@@ -2756,7 +2756,7 @@
<!-- Description feature's privacy sensitive details to make sure users understand what feature users, what it saves/sends etc [CHAR LIMIT=NONE]-->
<string name="adaptive_sleep_privacy">Screen attention uses the front camera to see if someone is looking at the screen. It works on device, and images are never stored or sent to Google.</string>
<!-- Description about the contextual adaptive sleep card [CHAR LIMIT=NONE]-->
- <string name="adaptive_sleep_contextual_slice_summary">Keep screen on when viewing it</string>
+ <string name="adaptive_sleep_contextual_slice_summary">Keep screen on when looking at it</string>
<!-- Night display screen, setting option name to enable night display (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
<string name="night_display_title">Night Light</string>
@@ -7221,7 +7221,7 @@
contacts support advanced calling features, such as video calling. [CHAR LIMIT=50]-->
<string name="contact_discovery_opt_in_title">Contact discovery</string>
<!-- Summary of a preference determining whether or not the user has enabled contact discovery.
- [CHAR LIMIT=100] -->
+ [CHAR LIMIT=110] -->
<string name="contact_discovery_opt_in_summary">Allows your carrier to discover which calling features your contacts support.</string>
<!-- Title of the dialog shown when the user tries to enable Contact Discovery.
[CHAR LIMIT=50] -->
@@ -8448,7 +8448,7 @@
<string name="notification_assistant_security_warning_summary">
<xliff:g id="notification_assistant_name" example="Notification Assistant">%1$s</xliff:g> will be able to read all notifications,
including personal information such as contact names and the text of messages you receive.
- It will also be able to modify or dismiss notifications or trigger action buttons they contain.
+ This app will also be able to dismiss notifications or take action on buttons in notifications, including answering phone calls.
\n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings.
</string>
@@ -8461,7 +8461,7 @@
<string name="notification_listener_security_warning_summary">
<xliff:g id="notification_listener_name">%1$s</xliff:g> will be able to read all notifications,
including personal information such as contact names and the text of messages you receive.
- It will also be able to dismiss notifications or trigger action buttons they contain.
+ This app will also be able to dismiss notifications or take action on buttons in notifications, including answering phone calls.
\n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings.
</string>
<string name="notification_listener_disable_warning_summary">
@@ -11584,6 +11584,11 @@
<!-- UI debug setting: Force enable "smart dark" UI rendering feature summary [CHAR LIMIT=NONE] -->
<string name="hwui_force_dark_summary">Overrides the force-dark feature to be always-on</string>
+ <!-- If blurs are supported on SurfaceFlinger. [CHAR LIMIT=60] -->
+ <string name="enable_blurs_on_windows_title">Enable blurs</string>
+ <!-- If blurs are supported on SurfaceFlinger, summary. [CHAR LIMIT=NONE] -->
+ <string name="enable_blurs_on_windows_summary">Enables window blurs at compositor level. Requires device reboot.</string>
+
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
<string name="privacy_dashboard_title">Privacy</string>
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 7ff68aa..1802060 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -139,6 +139,7 @@
android:key="gesture_system_navigation_input_summary_accessibility"
android:persistent="false"
android:title="@string/system_navigation_title"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.SystemNavigationPreferenceController"/>
</PreferenceCategory>
diff --git a/res/xml/billing_cycle.xml b/res/xml/billing_cycle.xml
index e9a34f1..77f8bc3 100644
--- a/res/xml/billing_cycle.xml
+++ b/res/xml/billing_cycle.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="billing_cycle_settings"
android:title="@string/billing_cycle">
<Preference
diff --git a/res/xml/bluetooth_screen.xml b/res/xml/bluetooth_screen.xml
index cce114b..86dc8a1 100644
--- a/res/xml/bluetooth_screen.xml
+++ b/res/xml/bluetooth_screen.xml
@@ -33,6 +33,7 @@
settings:allowDividerAbove="true"
settings:userRestriction="no_config_bluetooth"
settings:useAdminDisabledSummary="true"
+ settings:searchable="false"
settings:controller="com.android.settings.connecteddevice.AddDevicePreferenceController"/>
<com.android.settingslib.widget.FooterPreference
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index f0977e8..4078e82 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -42,7 +42,8 @@
android:key="all_notifications"
android:title="@string/notifications_title"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
- android:order="4">
+ android:order="4"
+ settings:searchable="false">
<extra
android:name="classname"
android:value="com.android.settings.Settings$NotificationAppListActivity"/>
@@ -136,7 +137,8 @@
android:title="@string/notification_ringtone_title"
android:dialogTitle="@string/notification_ringtone_title"
android:summary="@string/summary_placeholder"
- android:ringtoneType="notification"/>
+ android:ringtoneType="notification"
+ settings:searchable="false"/>
<SwitchPreference
android:key="notification_people_strip"
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index bd8f1dd..958af7f 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -32,6 +32,7 @@
android:title="@string/nfc_quick_toggle_title"
android:icon="@drawable/ic_nfc"
android:order="-7"
+ settings:searchable="false"
settings:controller="com.android.settings.connecteddevice.NfcAndPaymentFragmentController"/>
<Preference
diff --git a/res/xml/conversation_list_settings.xml b/res/xml/conversation_list_settings.xml
index 1d6b13c..5b9f0c4 100644
--- a/res/xml/conversation_list_settings.xml
+++ b/res/xml/conversation_list_settings.xml
@@ -27,11 +27,6 @@
<Preference
android:key="behavior"
android:summary="@string/important_conversation_behavior_summary"/>
- <SwitchPreference
- android:key="important_bubble"
- android:title="@string/important_bubble"
- android:icon="@drawable/ic_create_bubble"
- settings:controller="com.android.settings.notification.app.ImportantConversationBubblePreferenceController"/>
<!-- Important conversations added here -->
<PreferenceCategory
android:key="important_conversations_list"
diff --git a/res/xml/data_saver.xml b/res/xml/data_saver.xml
index 4a917f6..3816f26 100644
--- a/res/xml/data_saver.xml
+++ b/res/xml/data_saver.xml
@@ -24,6 +24,7 @@
android:title="@string/unrestricted_data_saver"
android:summary="@string/summary_two_lines_placeholder"
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess"
+ settings:searchable="false"
settings:controller="com.android.settings.applications.specialaccess.DataSaverController" />
<com.android.settingslib.widget.FooterPreference
diff --git a/res/xml/default_autofill_picker_settings.xml b/res/xml/default_autofill_picker_settings.xml
index da72b43..2aa39e4 100644
--- a/res/xml/default_autofill_picker_settings.xml
+++ b/res/xml/default_autofill_picker_settings.xml
@@ -26,6 +26,7 @@
android:key="default_autofill_main"
android:title="@string/autofill_app"
android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ settings:searchable="false"
settings:keywords="@string/autofill_keywords">
<extra android:name="for_work" android:value="false" />
</com.android.settings.widget.GearPreference>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 834fb48..b4d0bba 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -482,6 +482,11 @@
android:summary="@string/hwui_force_dark_summary" />
<SwitchPreference
+ android:key="enable_blurs_on_windows"
+ android:title="@string/enable_blurs_on_windows_title"
+ android:summary="@string/enable_blurs_on_windows_summary" />
+
+ <SwitchPreference
android:key="force_msaa"
android:title="@string/force_msaa"
android:summary="@string/force_msaa_summary" />
diff --git a/res/xml/firmware_version.xml b/res/xml/firmware_version.xml
index 41396f0..41f7733 100644
--- a/res/xml/firmware_version.xml
+++ b/res/xml/firmware_version.xml
@@ -27,6 +27,7 @@
android:title="@string/firmware_version"
android:summary="@string/summary_placeholder"
settings:enableCopying="true"
+ settings:searchable="false"
settings:controller="com.android.settings.deviceinfo.firmwareversion.FirmwareVersionDetailPreferenceController"/>
<!-- Security patch -->
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index 5ac27e0..a523ec6 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -30,18 +30,21 @@
android:key="gesture_swipe_down_fingerprint_input_summary"
android:title="@string/fingerprint_swipe_for_notifications_title"
android:fragment="com.android.settings.gestures.SwipeToNotificationSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController" />
<Preference
android:key="gesture_double_tap_power_input_summary"
android:title="@string/double_tap_power_for_camera_title"
android:fragment="com.android.settings.gestures.DoubleTapPowerSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.DoubleTapPowerPreferenceController" />
<Preference
android:key="gesture_double_twist_input_summary"
android:title="@string/double_twist_for_camera_mode_title"
android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.DoubleTwistPreferenceController" />
<Preference
@@ -54,18 +57,21 @@
android:key="gesture_tap_screen_input_summary"
android:title="@string/ambient_display_tap_screen_title"
android:fragment="com.android.settings.gestures.TapScreenGestureSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.TapScreenGesturePreferenceController" />
<Preference
android:key="gesture_double_tap_screen_input_summary"
android:title="@string/ambient_display_title"
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
<Preference
android:key="gesture_pick_up_input_summary"
android:title="@string/ambient_display_pickup_title"
android:fragment="com.android.settings.gestures.PickupGestureSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
<Preference
diff --git a/res/xml/mobile_network_list.xml b/res/xml/mobile_network_list.xml
index 01ddb28..6bf9ad2 100644
--- a/res/xml/mobile_network_list.xml
+++ b/res/xml/mobile_network_list.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="mobile_network_list_screen"
android:title="@string/network_settings_title">
<com.android.settingslib.RestrictedPreference
@@ -25,6 +24,7 @@
settings:isPreferenceVisible="false"
settings:userRestriction="no_config_mobile_networks"
settings:useAdminDisabledSummary="true"
+ settings:searchable="false"
android:title="@string/mobile_network_list_add_more"
android:icon="@drawable/ic_menu_add_activated_tint"
android:order="100" >
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 623460c..7899963 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -46,7 +46,7 @@
android:title="@string/app_permissions"
android:summary="@string/summary_placeholder"
settings:allowDividerAbove="true"
- settings:keywords="@string/keywords_app_permissions"
+ settings:searchable="false"
settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
</Preference>
diff --git a/res/xml/privacy_settings.xml b/res/xml/privacy_settings.xml
index 2e09dbd..2fc3ca4 100644
--- a/res/xml/privacy_settings.xml
+++ b/res/xml/privacy_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="privacy_settings_screen"
android:title="@string/privacy_settings_title">
<!-- Backup settings -->
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index dfc5ce7..8962fc2 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -69,18 +69,21 @@
android:key="ambient_display_tap"
android:title="@string/ambient_display_tap_screen_title"
android:fragment="com.android.settings.gestures.TapScreenGestureSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.TapScreenGesturePreferenceController" />
<Preference
android:key="ambient_display_double_tap"
android:title="@string/ambient_display_title"
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
<Preference
android:key="ambient_display_pick_up"
android:title="@string/ambient_display_pickup_title"
android:fragment="com.android.settings.gestures.PickupGestureSettings"
+ settings:searchable="false"
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
<SwitchPreference
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index cc45a96..858911d 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -18,7 +18,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_face_settings_page"
android:title="@string/security_settings_face_preference_title">
<com.android.settings.widget.VideoPreference
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index b0498f8..6ee87f4 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -51,6 +51,7 @@
android:title="@string/manage_device_admin"
android:fragment="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminSettings"
android:summary="@string/summary_placeholder"
+ settings:searchable="false"
settings:controller="com.android.settings.enterprise.ManageDeviceAdminPreferenceController" />
<Preference
diff --git a/res/xml/zen_mode_restrict_notifications_settings.xml b/res/xml/zen_mode_restrict_notifications_settings.xml
index ad574d8..0bf8c26 100644
--- a/res/xml/zen_mode_restrict_notifications_settings.xml
+++ b/res/xml/zen_mode_restrict_notifications_settings.xml
@@ -17,6 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/zen_mode_restrict_notifications_title">
<PreferenceCategory
@@ -25,16 +26,19 @@
<com.android.settings.notification.zen.ZenCustomRadioButtonPreference
android:key="zen_mute_notifications"
android:title="@string/zen_mode_restrict_notifications_mute"
- android:summary="@string/zen_mode_restrict_notifications_mute_summary"/>
+ android:summary="@string/zen_mode_restrict_notifications_mute_summary"
+ settings:searchable="false"/>
<com.android.settings.notification.zen.ZenCustomRadioButtonPreference
android:key="zen_hide_notifications"
android:title="@string/zen_mode_restrict_notifications_hide"
- android:summary="@string/zen_mode_restrict_notifications_hide_summary"/>
+ android:summary="@string/zen_mode_restrict_notifications_hide_summary"
+ settings:searchable="false"/>
<com.android.settings.notification.zen.ZenCustomRadioButtonPreference
android:key="zen_custom"
- android:title="@string/zen_mode_restrict_notifications_custom" />
+ android:title="@string/zen_mode_restrict_notifications_custom"
+ settings:searchable="false"/>
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference />
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index f8a3aa5..ce2d132 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -43,7 +43,6 @@
<Preference
android:key="zen_mode_behavior_apps"
android:title="@string/zen_category_apps"
- settings:controller="com.android.settings.notification.zen.ZenModeBypassingAppsPreferenceController"
android:fragment="com.android.settings.notification.zen.ZenModeBypassingAppsSettings" />
<!-- All sounds -->
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 315cba1..e8eb8ba 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -888,6 +888,27 @@
}
/**
+ * Return {@code true} if the supplied package is the device owner or profile owner of a
+ * given user.
+ *
+ * @param devicePolicyManager used to check whether it is device owner and profile owner app
+ * @param packageName package to check about
+ * @param userId the if of the relevant user
+ */
+ public static boolean isProfileOrDeviceOwner(DevicePolicyManager devicePolicyManager,
+ String packageName, int userId) {
+ if ((devicePolicyManager.getDeviceOwnerUserId() == userId)
+ && devicePolicyManager.isDeviceOwnerApp(packageName)) {
+ return true;
+ }
+ final ComponentName cn = devicePolicyManager.getProfileOwnerAsUser(userId);
+ if (cn != null && cn.getPackageName().equals(packageName)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Return the resource id to represent the install status for an app
*/
@StringRes
diff --git a/src/com/android/settings/applications/AppStateManageExternalStorageBridge.java b/src/com/android/settings/applications/AppStateManageExternalStorageBridge.java
index 7933062..1132137 100644
--- a/src/com/android/settings/applications/AppStateManageExternalStorageBridge.java
+++ b/src/com/android/settings/applications/AppStateManageExternalStorageBridge.java
@@ -69,7 +69,7 @@
/**
* Returns the MANAGE_EXTERNAL_STORAGE {@link AppStateAppOpsBridge.PermissionState} object
- * associated with the given package and user.
+ * associated with the given package and UID.
*/
public PermissionState getManageExternalStoragePermState(String pkg, int uid) {
return getPermissionInfo(pkg, uid);
diff --git a/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java b/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java
index 1b14402..590384c 100644
--- a/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java
@@ -25,8 +25,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.om.OverlayManager;
import android.content.om.OverlayInfo;
+import android.content.om.OverlayManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -393,11 +393,19 @@
enabled = false;
}
- // We don't allow uninstalling DO/PO on *any* users, because if it's a system app,
+ // We don't allow uninstalling DO/PO on *any* users if it's a system app, because
// "uninstall" is actually "downgrade to the system version + disable", and "downgrade"
// will clear data on all users.
- if (Utils.isProfileOrDeviceOwner(mUserManager, mDpm, mPackageInfo.packageName)) {
- enabled = false;
+ if (isSystemPackage(mActivity.getResources(), mPm, mPackageInfo)) {
+ if (Utils.isProfileOrDeviceOwner(mUserManager, mDpm, mPackageInfo.packageName)) {
+ enabled = false;
+ }
+ // We allow uninstalling if the calling user is not a DO/PO and if it's not a system app,
+ // because this will not have device-wide consequences.
+ } else {
+ if (Utils.isProfileOrDeviceOwner(mDpm, mPackageInfo.packageName, mUserId)) {
+ enabled = false;
+ }
}
// Don't allow uninstalling the device provisioning package.
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 54af16f..8a37473 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -38,6 +38,7 @@
import android.app.settings.SettingsEnums;
import android.app.usage.IUsageStatsManager;
import android.compat.annotation.ChangeId;
+import android.compat.annotation.LoggingOnly;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -186,6 +187,7 @@
* requested such permission.
*/
@ChangeId
+ @LoggingOnly
private static final long CHANGE_RESTRICT_SAW_INTENT = 135920175L;
// sort order
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index 3e534b3..9afb2b4 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -457,12 +457,20 @@
private void showPolicyTransparencyDialogIfRequired() {
if (isManagedProfile(mDeviceAdmin)
&& mDeviceAdmin.getComponent().equals(mDPM.getProfileOwner())) {
- if (hasBaseCantRemoveProfileRestriction()) {
- // If DISALLOW_REMOVE_MANAGED_PROFILE is set by the system, there's no
- // point showing a dialog saying it's disabled by an admin.
- return;
+ EnforcedAdmin enforcedAdmin;
+ ComponentName adminComponent = mDPM.getProfileOwnerAsUser(getUserId());
+ if (adminComponent != null && mDPM.isOrganizationOwnedDeviceWithManagedProfile()) {
+ enforcedAdmin = new EnforcedAdmin(adminComponent,
+ UserManager.DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.of(getUserId()));
+ } else {
+ // Todo (b/151061366): Investigate this case to check if it is still viable.
+ if (hasBaseCantRemoveProfileRestriction()) {
+ // If DISALLOW_REMOVE_MANAGED_PROFILE is set by the system, there's no
+ // point showing a dialog saying it's disabled by an admin.
+ return;
+ }
+ enforcedAdmin = getAdminEnforcingCantRemoveProfile();
}
- EnforcedAdmin enforcedAdmin = getAdminEnforcingCantRemoveProfile();
if (enforcedAdmin != null) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
DeviceAdminAdd.this,
@@ -640,7 +648,8 @@
final EnforcedAdmin admin = getAdminEnforcingCantRemoveProfile();
final boolean hasBaseRestriction = hasBaseCantRemoveProfileRestriction();
- if (admin != null && !hasBaseRestriction) {
+ if ((hasBaseRestriction && mDPM.isOrganizationOwnedDeviceWithManagedProfile())
+ || (admin != null && !hasBaseRestriction)) {
findViewById(R.id.restricted_icon).setVisibility(View.VISIBLE);
}
mActionButton.setEnabled(admin == null && !hasBaseRestriction);
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index a0aa6db..4179ea3 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -68,11 +68,13 @@
final int result = bm.canAuthenticate(authenticators);
- if (result == BiometricManager.BIOMETRIC_SUCCESS
- || result == BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE) {
- Log.e(TAG, "Unexpected result: " + result);
- finish();
- return;
+ if (!WizardManagerHelper.isAnySetupWizard(getIntent())) {
+ if (result == BiometricManager.BIOMETRIC_SUCCESS
+ || result == BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE) {
+ Log.e(TAG, "Unexpected result: " + result);
+ finish();
+ return;
+ }
}
if (authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) {
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 08cfa70..c1ee545 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -336,7 +336,22 @@
keys.add(hasEnrolled ? PREF_KEY_ENROLL_FACE_UNLOCK
: PREF_KEY_DELETE_FACE_DATA);
}
+
+ if (!isAttentionSupported(context)) {
+ keys.add(FaceSettingsAttentionPreferenceController.KEY);
+ }
+
return keys;
}
+
+ private boolean isAttentionSupported(Context context) {
+ FaceFeatureProvider featureProvider = FeatureFactory.getFactory(
+ context).getFaceFeatureProvider();
+ boolean isAttentionSupported = false;
+ if (featureProvider != null) {
+ isAttentionSupported = featureProvider.isAttentionSupported(context);
+ }
+ return isAttentionSupported;
+ }
};
}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index f3f2a3a..8c79f2a 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -487,6 +487,7 @@
controllers.add(new DebugGpuOverdrawPreferenceController(context));
controllers.add(new DebugNonRectClipOperationsPreferenceController(context));
controllers.add(new ForceDarkPreferenceController(context));
+ controllers.add(new EnableBlursPreferenceController(context));
controllers.add(new ForceMSAAPreferenceController(context));
controllers.add(new HardwareOverlaysPreferenceController(context));
controllers.add(new SimulateColorSpacePreferenceController(context));
diff --git a/src/com/android/settings/development/EnableBlursPreferenceController.java b/src/com/android/settings/development/EnableBlursPreferenceController.java
new file mode 100644
index 0000000..88e0db1
--- /dev/null
+++ b/src/com/android/settings/development/EnableBlursPreferenceController.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.os.SystemProperties;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+import com.android.settingslib.development.SystemPropPoker;
+
+/**
+ * Controller that toggles window blurs on SurfaceFlinger on devices that support it.
+ */
+public final class EnableBlursPreferenceController extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ @VisibleForTesting
+ static final String DISABLE_BLURS_SYSPROP = "persist.sys.sf.disable_blurs";
+ private static final String ENABLE_BLURS_ON_WINDOWS = "enable_blurs_on_windows";
+ private final boolean mBlurSupported;
+
+ public EnableBlursPreferenceController(Context context) {
+ this(context, SystemProperties
+ .getBoolean("ro.surface_flinger.supports_background_blur", false));
+ }
+
+ @VisibleForTesting
+ public EnableBlursPreferenceController(Context context, boolean blurSupported) {
+ super(context);
+ mBlurSupported = blurSupported;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return ENABLE_BLURS_ON_WINDOWS;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean isDisabled = !(Boolean) newValue;
+ SystemProperties.set(DISABLE_BLURS_SYSPROP, isDisabled ? "1" : "0");
+ SystemPropPoker.getInstance().poke();
+ return true;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mBlurSupported;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ boolean isEnabled = !SystemProperties.getBoolean(
+ DISABLE_BLURS_SYSPROP, false /* default */);
+ ((SwitchPreference) mPreference).setChecked(isEnabled);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ SystemProperties.set(DISABLE_BLURS_SYSPROP, null);
+ updateState(null);
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index 38626ca..7f2c645 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -587,12 +587,6 @@
result.add(data);
data = new SearchIndexableRaw(context);
- data.title = context.getString(R.string.memory_apps_usage);
- data.key = "storage_settings_apps_space";
- data.screenTitle = context.getString(R.string.storage_settings);
- result.add(data);
-
- data = new SearchIndexableRaw(context);
data.title = context.getString(R.string.memory_dcim_usage);
data.key = "storage_settings_dcim_space";
data.screenTitle = context.getString(R.string.storage_settings);
diff --git a/src/com/android/settings/gestures/GestureNavigationBackSensitivityDialog.java b/src/com/android/settings/gestures/GestureNavigationBackSensitivityDialog.java
deleted file mode 100644
index e4f25eb..0000000
--- a/src/com/android/settings/gestures/GestureNavigationBackSensitivityDialog.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.gestures;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.os.Bundle;
-import android.os.ServiceManager;
-import android.view.View;
-import android.widget.SeekBar;
-
-import com.android.settings.R;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-
-/**
- * Dialog to set the back gesture's sensitivity in Gesture navigation mode.
- */
-public class GestureNavigationBackSensitivityDialog extends InstrumentedDialogFragment {
- private static final String TAG = "GestureNavigationBackSensitivityDialog";
- private static final String KEY_BACK_SENSITIVITY = "back_sensitivity";
-
- public static void show(SystemNavigationGestureSettings parent, int sensitivity) {
- if (!parent.isAdded()) {
- return;
- }
-
- final GestureNavigationBackSensitivityDialog dialog =
- new GestureNavigationBackSensitivityDialog();
- final Bundle bundle = new Bundle();
- bundle.putInt(KEY_BACK_SENSITIVITY, sensitivity);
- dialog.setArguments(bundle);
- dialog.setTargetFragment(parent, 0);
- dialog.show(parent.getFragmentManager(), TAG);
- }
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.SETTINGS_GESTURE_NAV_BACK_SENSITIVITY_DLG;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final View view = getActivity().getLayoutInflater().inflate(
- R.layout.dialog_back_gesture_sensitivity, null);
- final SeekBar seekBar = view.findViewById(R.id.back_sensitivity_seekbar);
- seekBar.setProgress(getArguments().getInt(KEY_BACK_SENSITIVITY));
- return new AlertDialog.Builder(getContext())
- .setTitle(R.string.back_sensitivity_dialog_title)
- .setMessage(R.string.back_sensitivity_dialog_message)
- .setView(view)
- .setPositiveButton(R.string.okay, (dialog, which) -> {
- int sensitivity = seekBar.getProgress();
- getArguments().putInt(KEY_BACK_SENSITIVITY, sensitivity);
- SystemNavigationGestureSettings.setBackSensitivity(getActivity(),
- getOverlayManager(), sensitivity);
- })
- .create();
- }
-
- private IOverlayManager getOverlayManager() {
- return IOverlayManager.Stub.asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE));
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
index 9e78388..728343e 100644
--- a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
+++ b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
@@ -66,11 +66,6 @@
private static final String TAG = "SystemNavigationGesture";
@VisibleForTesting
- static final String SHARED_PREFERENCES_NAME = "system_navigation_settings_preferences";
- @VisibleForTesting
- static final String PREFS_BACK_SENSITIVITY_KEY = "system_navigation_back_sensitivity";
-
- @VisibleForTesting
static final String KEY_SYSTEM_NAV_3BUTTONS = "system_nav_3buttons";
@VisibleForTesting
static final String KEY_SYSTEM_NAV_2BUTTONS = "system_nav_2buttons";
@@ -80,25 +75,6 @@
public static final String PREF_KEY_SUGGESTION_COMPLETE =
"pref_system_navigation_suggestion_complete";
- @VisibleForTesting
- static final String NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK
- = "com.android.internal.systemui.navbar.gestural_narrow_back";
- @VisibleForTesting
- static final String NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK
- = "com.android.internal.systemui.navbar.gestural_wide_back";
- @VisibleForTesting
- static final String NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK
- = "com.android.internal.systemui.navbar.gestural_extra_wide_back";
- @VisibleForTesting
- static final String[] BACK_GESTURE_INSET_OVERLAYS = {
- NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK,
- NAV_BAR_MODE_GESTURAL_OVERLAY,
- NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK,
- NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK
- };
- @VisibleForTesting
- static int BACK_GESTURE_INSET_DEFAULT_OVERLAY = 1;
-
private IOverlayManager mOverlayManager;
private VideoPreference mVideoPreference;
@@ -122,6 +98,8 @@
mVideoPreference.setHeight( /* Illustration height in dp */
getResources().getDimension(R.dimen.system_navigation_illustration_height)
/ getResources().getDisplayMetrics().density);
+
+ migrateOverlaySensitivityToSettings(context, mOverlayManager);
}
@Override
@@ -164,8 +142,8 @@
RadioButtonPreferenceWithExtraWidget p = (RadioButtonPreferenceWithExtraWidget) pref;
if (info.getKey() == KEY_SYSTEM_NAV_GESTURAL) {
p.setExtraWidgetVisibility(EXTRA_WIDGET_VISIBILITY_SETTING);
- p.setExtraWidgetOnClickListener((v) -> GestureNavigationBackSensitivityDialog
- .show(this, getBackSensitivity(getContext(), mOverlayManager)));
+ p.setExtraWidgetOnClickListener((v) -> startActivity(new Intent(
+ GestureNavigationSettingsFragment.GESTURE_NAVIGATION_SETTINGS)));
} else {
p.setExtraWidgetVisibility(EXTRA_WIDGET_VISIBILITY_GONE);
}
@@ -213,8 +191,7 @@
@Override
protected boolean setDefaultKey(String key) {
- final Context c = getContext();
- setCurrentSystemNavigationMode(c, mOverlayManager, key);
+ setCurrentSystemNavigationMode(mOverlayManager, key);
setIllustrationVideo(mVideoPreference, key);
if (TextUtils.equals(KEY_SYSTEM_NAV_GESTURAL, key) && (
isAnyServiceSupportAccessibilityButton() || isNavBarMagnificationEnabled())) {
@@ -225,38 +202,28 @@
return true;
}
- @VisibleForTesting
- static void setBackSensitivity(Context context, IOverlayManager overlayManager,
- int sensitivity) {
- if (sensitivity < 0 || sensitivity >= BACK_GESTURE_INSET_OVERLAYS.length) {
- throw new IllegalArgumentException("Sensitivity out of range.");
+ static void migrateOverlaySensitivityToSettings(Context context,
+ IOverlayManager overlayManager) {
+ if (!SystemNavigationPreferenceController.isGestureNavigationEnabled(context)) {
+ return;
}
- // Store the sensitivity level, to be able to restore when user returns to Gesture Nav mode
- context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).edit()
- .putInt(PREFS_BACK_SENSITIVITY_KEY, sensitivity).apply();
- if (getCurrentSystemNavigationMode(context) == KEY_SYSTEM_NAV_GESTURAL) {
- setNavBarInteractionMode(overlayManager, BACK_GESTURE_INSET_OVERLAYS[sensitivity]);
+ OverlayInfo info = null;
+ try {
+ info = overlayManager.getOverlayInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, USER_CURRENT);
+ } catch (RemoteException e) { /* Do nothing */ }
+ if (info != null && !info.isEnabled()) {
+ // Enable the default gesture nav overlay. Back sensitivity for left and right are
+ // stored as separate settings values, and other gesture nav overlays are deprecated.
+ setCurrentSystemNavigationMode(overlayManager, KEY_SYSTEM_NAV_GESTURAL);
+ Settings.Secure.putFloat(context.getContentResolver(),
+ Settings.Secure.BACK_GESTURE_INSET_SCALE_LEFT, 1.0f);
+ Settings.Secure.putFloat(context.getContentResolver(),
+ Settings.Secure.BACK_GESTURE_INSET_SCALE_RIGHT, 1.0f);
}
}
@VisibleForTesting
- static int getBackSensitivity(Context context, IOverlayManager overlayManager) {
- for (int i = 0; i < BACK_GESTURE_INSET_OVERLAYS.length; i++) {
- OverlayInfo info = null;
- try {
- info = overlayManager.getOverlayInfo(BACK_GESTURE_INSET_OVERLAYS[i], USER_CURRENT);
- } catch (RemoteException e) { /* Do nothing */ }
- if (info != null && info.isEnabled()) {
- return i;
- }
- }
- // If Gesture nav is not selected, read the value from shared preferences.
- return context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
- .getInt(PREFS_BACK_SENSITIVITY_KEY, BACK_GESTURE_INSET_DEFAULT_OVERLAY);
- }
-
- @VisibleForTesting
static String getCurrentSystemNavigationMode(Context context) {
if (SystemNavigationPreferenceController.isGestureNavigationEnabled(context)) {
return KEY_SYSTEM_NAV_GESTURAL;
@@ -268,24 +235,20 @@
}
@VisibleForTesting
- static void setCurrentSystemNavigationMode(Context context, IOverlayManager overlayManager,
- String key) {
+ static void setCurrentSystemNavigationMode(IOverlayManager overlayManager, String key) {
+ String overlayPackage = NAV_BAR_MODE_GESTURAL_OVERLAY;
switch (key) {
case KEY_SYSTEM_NAV_GESTURAL:
- int sensitivity = getBackSensitivity(context, overlayManager);
- setNavBarInteractionMode(overlayManager, BACK_GESTURE_INSET_OVERLAYS[sensitivity]);
+ overlayPackage = NAV_BAR_MODE_GESTURAL_OVERLAY;
break;
case KEY_SYSTEM_NAV_2BUTTONS:
- setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
+ overlayPackage = NAV_BAR_MODE_2BUTTON_OVERLAY;
break;
case KEY_SYSTEM_NAV_3BUTTONS:
- setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
+ overlayPackage = NAV_BAR_MODE_3BUTTON_OVERLAY;
break;
}
- }
- private static void setNavBarInteractionMode(IOverlayManager overlayManager,
- String overlayPackage) {
try {
overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);
} catch (RemoteException e) {
diff --git a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
index a06c77e..ab9110d 100644
--- a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
+++ b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
@@ -251,6 +251,10 @@
return result;
}
+ boolean isFirstLocaleChecked() {
+ return mFeedItemList != null && mFeedItemList.get(0).getChecked();
+ }
+
void addLocale(LocaleStore.LocaleInfo li) {
mFeedItemList.add(li);
notifyItemInserted(mFeedItemList.size() - 1);
diff --git a/src/com/android/settings/localepicker/LocaleListEditor.java b/src/com/android/settings/localepicker/LocaleListEditor.java
index 0666e0b..3165d09 100644
--- a/src/com/android/settings/localepicker/LocaleListEditor.java
+++ b/src/com/android/settings/localepicker/LocaleListEditor.java
@@ -34,6 +34,7 @@
import android.view.ViewGroup;
import android.widget.TextView;
+import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;
@@ -184,7 +185,8 @@
// Shows no warning if there is no locale checked, shows a warning
// about removing all the locales if all of them are checked, and
// a "regular" warning otherwise.
- private void showRemoveLocaleWarningDialog() {
+ @VisibleForTesting
+ void showRemoveLocaleWarningDialog() {
int checkedCount = mAdapter.getCheckedCount();
// Nothing checked, just exit remove mode without a warning dialog
@@ -218,33 +220,41 @@
final String title = getResources().getQuantityString(R.plurals.dlg_remove_locales_title,
checkedCount);
mShowingRemoveDialog = true;
- new AlertDialog.Builder(getActivity())
- .setTitle(title)
- .setMessage(R.string.dlg_remove_locales_message)
+
+ final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ if (mAdapter.isFirstLocaleChecked()) {
+ builder.setMessage(R.string.dlg_remove_locales_message);
+ }
+
+ builder.setTitle(title)
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setRemoveMode(false);
}
})
- .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- // This is a sensitive area to change.
- // removeChecked() triggers a system update and "kills" the frame.
- // This means that saveState + restoreState are called before
- // setRemoveMode is called.
- // So we want that mRemoveMode and dialog status have the right values
- // before that save.
- // We can't just call setRemoveMode(false) before calling removeCheched
- // because that unchecks all items and removeChecked would have nothing
- // to remove.
- mRemoveMode = false;
- mShowingRemoveDialog = false;
- mAdapter.removeChecked();
- setRemoveMode(false);
- }
- })
+ .setPositiveButton(R.string.locale_remove_menu,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // This is a sensitive area to change.
+ // removeChecked() triggers a system update and "kills" the frame.
+ // This means that saveState + restoreState are called before
+ // setRemoveMode is called.
+ // So we want that mRemoveMode and dialog status have the right
+ // values
+ // before that save.
+ // We can't just call setRemoveMode(false) before calling
+ // removeCheched
+ // because that unchecks all items and removeChecked would have
+ // nothing
+ // to remove.
+ mRemoveMode = false;
+ mShowingRemoveDialog = false;
+ mAdapter.removeChecked();
+ setRemoveMode(false);
+ }
+ })
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
index 7557fd9..281d23e 100644
--- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java
+++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
@@ -112,6 +112,11 @@
notifySliceChange();
}
+ @Override
+ public void onRequestFailed(int reason) {
+ notifySliceChange();
+ }
+
public Collection<MediaDevice> getMediaDevices() {
return mMediaDevices;
}
@@ -119,6 +124,9 @@
public void connectDevice(MediaDevice device) {
ThreadUtils.postOnBackgroundThread(() -> {
mLocalMediaManager.connectDevice(device);
+ ThreadUtils.postOnMainThread(() -> {
+ notifySliceChange();
+ });
});
}
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 318a50d..785d1df 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -42,6 +42,7 @@
import com.android.settings.slices.CustomSliceable;
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settings.slices.SliceBroadcastReceiver;
+import com.android.settingslib.media.LocalMediaManager;
import com.android.settingslib.media.MediaDevice;
import com.android.settingslib.media.MediaOutputSliceConstants;
@@ -246,6 +247,15 @@
rowBuilder.setTitle(deviceName);
rowBuilder.setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
ListBuilder.ICON_IMAGE, deviceName));
+ switch (device.getState()) {
+ case LocalMediaManager.MediaDeviceState.STATE_CONNECTING:
+ rowBuilder.setSubtitle(mContext.getText(R.string.media_output_switching));
+ break;
+ case LocalMediaManager.MediaDeviceState.STATE_CONNECTING_FAILED:
+ rowBuilder.setSubtitle(mContext.getText(
+ R.string.media_output_switch_error_text));
+ break;
+ }
}
return rowBuilder;
diff --git a/src/com/android/settings/notification/app/ImportantConversationBubblePreferenceController.java b/src/com/android/settings/notification/app/ImportantConversationBubblePreferenceController.java
deleted file mode 100644
index f6f14aa..0000000
--- a/src/com/android/settings/notification/app/ImportantConversationBubblePreferenceController.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification.app;
-
-import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
-import static android.provider.Settings.Secure.BUBBLE_IMPORTANT_CONVERSATIONS;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.TogglePreferenceController;
-
-public class ImportantConversationBubblePreferenceController extends TogglePreferenceController
- implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
-
- private static final String TAG = "ImpConvBubPrefContr";
- @VisibleForTesting
- static final int ON = 1;
- @VisibleForTesting
- static final int OFF = 0;
-
-
- public ImportantConversationBubblePreferenceController(Context context, String preferenceKey) {
- super(context, preferenceKey);
- }
-
- private boolean isGloballyEnabled() {
- return Settings.Global.getInt(mContext.getContentResolver(),
- NOTIFICATION_BUBBLES, OFF) == ON;
- }
-
- @Override
- public int getAvailabilityStatus() {
- return isGloballyEnabled() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
- }
-
- @Override
- public boolean isSliceable() {
- return false;
- }
-
- @Override
- public boolean isChecked() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- BUBBLE_IMPORTANT_CONVERSATIONS, ON) == ON;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- return Settings.Secure.putInt(mContext.getContentResolver(),
- BUBBLE_IMPORTANT_CONVERSATIONS, isChecked ? ON : OFF);
- }
-}
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index 6356378..fe91669 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -39,17 +39,12 @@
public class VideoPreference extends Preference {
private static final String TAG = "VideoPreference";
- private static final int DEFAULT_BACKGROUND_RESOURCE_ID = -1;
private final Context mContext;
@VisibleForTesting
AnimationController mAnimationController;
@VisibleForTesting
boolean mAnimationAvailable;
- @VisibleForTesting
- LinearLayout mAnimationView;
- @VisibleForTesting
- int mBackgroundResId = DEFAULT_BACKGROUND_RESOURCE_ID;
private float mAspectRatio = 1.0f;
private int mPreviewId;
@@ -120,7 +115,6 @@
mVideo = (TextureView) holder.findViewById(R.id.video_texture_view);
mPreviewImage = (ImageView) holder.findViewById(R.id.video_preview_image);
mPlayButton = (ImageView) holder.findViewById(R.id.video_play_button);
- mAnimationView = (LinearLayout) holder.itemView;
final AspectRatioFrameLayout layout = (AspectRatioFrameLayout) holder.findViewById(
R.id.video_container);
@@ -130,9 +124,6 @@
layout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, mHeight));
}
- if (mBackgroundResId != DEFAULT_BACKGROUND_RESOURCE_ID) {
- mAnimationView.setBackgroundResource(mBackgroundResId);
- }
if (mAnimationController != null) {
mAnimationController.attachView(mVideo, mPreviewImage, mPlayButton);
}
@@ -213,14 +204,6 @@
}
/**
- * Set the background color of the video preference
- * @param resId resource id of color
- */
- public void setBackgroundColor(int resId) {
- mBackgroundResId = resId;
- }
-
- /**
* Handle animation operations.
*/
interface AnimationController {
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
index 03ea121..a4a51dc 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
@@ -18,18 +18,22 @@
import static com.android.settings.AllInOneTetherSettings.DEDUP_POSTFIX;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.net.wifi.SoftApConfiguration;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.ValidatedEditTextPreference;
import com.android.settings.wifi.WifiUtils;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import java.util.UUID;
@@ -40,9 +44,19 @@
private String mPassword;
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
+
+ @VisibleForTesting
+ WifiTetherPasswordPreferenceController(Context context, OnTetherConfigUpdateListener listener,
+ MetricsFeatureProvider provider) {
+ super(context, listener);
+ mMetricsFeatureProvider = provider;
+ }
+
public WifiTetherPasswordPreferenceController(Context context,
OnTetherConfigUpdateListener listener) {
super(context, listener);
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
@@ -69,6 +83,10 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (!TextUtils.equals(mPassword, (String) newValue)) {
+ mMetricsFeatureProvider.action(mContext,
+ SettingsEnums.ACTION_SETTINGS_CHANGE_WIFI_HOTSPOT_PASSWORD);
+ }
mPassword = (String) newValue;
updatePasswordDisplay((EditTextPreference) mPreference);
mListener.onTetherConfigUpdated(this);
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
index a4289a6..9070d44 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.Intent;
import android.net.wifi.SoftApConfiguration;
+import android.text.TextUtils;
import android.util.FeatureFlagUtils;
import android.util.Log;
@@ -48,6 +49,15 @@
private final MetricsFeatureProvider mMetricsFeatureProvider;
+ // This constructor is used for testing.
+ @VisibleForTesting
+ WifiTetherSSIDPreferenceController(Context context, OnTetherConfigUpdateListener listener,
+ MetricsFeatureProvider provider) {
+ super(context, listener);
+ mWifiDeviceNameTextValidator = new WifiDeviceNameTextValidator();
+ mMetricsFeatureProvider = provider;
+ }
+
public WifiTetherSSIDPreferenceController(Context context,
OnTetherConfigUpdateListener listener) {
super(context, listener);
@@ -93,6 +103,10 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (!TextUtils.equals(mSSID, (String) newValue)) {
+ mMetricsFeatureProvider.action(mContext,
+ SettingsEnums.ACTION_SETTINGS_CHANGE_WIFI_HOTSPOT_NAME);
+ }
mSSID = (String) newValue;
updateSsidDisplay((EditTextPreference) preference);
mListener.onTetherConfigUpdated(this);
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 ca2a800..7304fc2 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java
@@ -36,7 +36,6 @@
import static org.mockito.Mockito.when;
import android.app.ActivityManager;
-import android.app.Application;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -51,8 +50,6 @@
import android.util.ArraySet;
import android.view.View;
-import androidx.preference.PreferenceScreen;
-
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedPreferenceFragment;
@@ -277,7 +274,8 @@
}
@Test
- public void updateUninstallButton_isProfileOrDeviceOwner_setButtonDisable() {
+ public void updateUninstallButton_isSystemAndIsProfileOrDeviceOwner_setButtonDisable() {
+ doReturn(true).when(mController).isSystemPackage(any(), any(), any());
doReturn(true).when(mDpm).isDeviceOwnerAppOnAnyUser(anyString());
mController.updateUninstallButton();
@@ -286,6 +284,38 @@
}
@Test
+ public void updateUninstallButton_isSystemAndIsNotProfileOrDeviceOwner_setButtonEnabled() {
+ doReturn(true).when(mController).isSystemPackage(any(), any(), any());
+ doReturn(false).when(mDpm).isDeviceOwnerAppOnAnyUser(anyString());
+
+ mController.updateUninstallButton();
+
+ verify(mButtonPrefs).setButton2Enabled(true);
+ }
+
+ @Test
+ public void updateUninstallButton_isNotSystemAndIsProfileOrDeviceOwner_setButtonDisable() {
+ doReturn(false).when(mController).isSystemPackage(any(), any(), any());
+ doReturn(0).when(mDpm).getDeviceOwnerUserId();
+ doReturn(true).when(mDpm).isDeviceOwnerApp(anyString());
+
+ mController.updateUninstallButton();
+
+ verify(mButtonPrefs).setButton2Enabled(false);
+ }
+
+ @Test
+ public void updateUninstallButton_isNotSystemAndIsNotProfileOrDeviceOwner_setButtonEnabled() {
+ doReturn(false).when(mController).isSystemPackage(any(), any(), any());
+ doReturn(10).when(mDpm).getDeviceOwnerUserId();
+ doReturn(false).when(mDpm).isDeviceOwnerApp(anyString());
+
+ mController.updateUninstallButton();
+
+ verify(mButtonPrefs).setButton2Enabled(true);
+ }
+
+ @Test
public void updateUninstallButton_isDeviceProvisioningApp_setButtonDisable() {
doReturn(true).when(mDpm).isDeviceOwnerAppOnAnyUser(anyString());
when(mSettingsActivity.getResources().getString(anyInt())).thenReturn(PACKAGE_NAME);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ManageExternalStorageDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ManageExternalStorageDetailsTest.java
index ed85c01..88c2471 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/ManageExternalStorageDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/ManageExternalStorageDetailsTest.java
@@ -64,13 +64,11 @@
private ManageExternalStorageDetails mFragment;
- private final HashMap<String, Integer> mPkgToOpModeMap = new HashMap<>();
private final HashMap<Integer, Integer> mUidToOpModeMap = new HashMap<>();
@Before
public void setUp() {
// Reset the global trackers
- mPkgToOpModeMap.clear();
mUidToOpModeMap.clear();
//Start the mockin'
@@ -106,8 +104,7 @@
// Verify that mAppOpsManager was called to allow the app-op
verify(mAppOpsManager, times(1))
- .setMode(anyInt(), anyInt(), nullable(String.class), anyInt());
- assertThat(mPkgToOpModeMap).containsExactly(mockPkgName, AppOpsManager.MODE_ALLOWED);
+ .setUidMode(anyInt(), anyInt(), anyInt());
assertThat(mUidToOpModeMap).containsExactly(mockUid, AppOpsManager.MODE_ALLOWED);
// Verify the mSwitchPref was enabled
@@ -141,8 +138,7 @@
// Verify that mAppOpsManager was called to deny the app-op
verify(mAppOpsManager, times(1))
- .setMode(anyInt(), anyInt(), nullable(String.class), anyInt());
- assertThat(mPkgToOpModeMap).containsExactly(mockPkgName, AppOpsManager.MODE_ERRORED);
+ .setUidMode(anyInt(), anyInt(), anyInt());
assertThat(mUidToOpModeMap).containsExactly(mockUid, AppOpsManager.MODE_ERRORED);
// Verify the mSwitchPref was enabled
@@ -164,33 +160,32 @@
}
private void mockAppOpsOperations() {
- Answer<Void> answerSetMode = invocation -> {
+ Answer<Void> answerSetUidMode = invocation -> {
int code = invocation.getArgument(0);
int uid = invocation.getArgument(1);
- String packageName = invocation.getArgument(2);
- int mode = invocation.getArgument(3);
+ int mode = invocation.getArgument(2);
if (code != AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE) {
return null;
}
- mPkgToOpModeMap.put(packageName, mode);
mUidToOpModeMap.put(uid, mode);
return null;
};
- doAnswer(answerSetMode).when(mAppOpsManager)
- .setMode(anyInt(), anyInt(), nullable(String.class), anyInt());
+ doAnswer(answerSetUidMode).when(mAppOpsManager)
+ .setUidMode(anyInt(), anyInt(), anyInt());
Answer<PermissionState> answerPermState = invocation -> {
String packageName = invocation.getArgument(0);
+ int uid = invocation.getArgument(1);
PermissionState res = new PermissionState(packageName, null);
res.permissionDeclared = false;
- if (mPkgToOpModeMap.containsKey(packageName)) {
+ if (mUidToOpModeMap.containsKey(uid)) {
res.permissionDeclared = true;
- res.appOpMode = mPkgToOpModeMap.get(packageName);
+ res.appOpMode = mUidToOpModeMap.get(uid);
}
return res;
};
diff --git a/tests/robotests/src/com/android/settings/applications/assist/AssistFlashScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/assist/AssistFlashScreenPreferenceControllerTest.java
index 8392ac1..1e6faa1 100644
--- a/tests/robotests/src/com/android/settings/applications/assist/AssistFlashScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/assist/AssistFlashScreenPreferenceControllerTest.java
@@ -41,7 +41,6 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -81,7 +80,6 @@
}
@Test
- @Ignore
@Config(shadows = {ShadowSecureSettings.class})
public void isAvailable_hasAssistantAndAllowDisclosure_shouldReturnTrue() {
ReflectionHelpers.setField(mController, "mContext", mMockContext);
@@ -93,7 +91,6 @@
}
@Test
- @Ignore
@Config(shadows = {ShadowSecureSettings.class})
public void isAvailable_hasAssistantAndDisallowDisclosure_shouldReturnTrue() {
ReflectionHelpers.setField(mController, "mContext", mMockContext);
@@ -112,7 +109,6 @@
}
@Test
- @Ignore
@Config(shadows = {ShadowSecureSettings.class})
public void onResume_shouldUpdatePreference() {
Settings.Secure.putString(mContext.getContentResolver(),
diff --git a/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java
index 7de830c..3e46027 100644
--- a/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/assist/DefaultAssistPreferenceControllerTest.java
@@ -44,7 +44,6 @@
import com.android.settingslib.applications.DefaultAppInfo;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -95,7 +94,6 @@
}
@Test
- @Ignore
@Config(shadows = {ShadowSecureSettings.class})
public void getDefaultAppInfo_hasDefaultAssist_shouldReturnKey() {
final String flattenKey = "com.android.settings/assist";
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
index dfacd81..9ec7f0b 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
@@ -45,7 +45,6 @@
import com.android.settingslib.applications.DefaultAppInfo;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
@@ -107,7 +106,6 @@
}
@Test
- @Ignore
public void setAndGetDefaultAppKey_shouldUpdateDefaultAutoFill() {
mPicker.onAttach((Context) mActivity);
diff --git a/tests/robotests/src/com/android/settings/development/EnableBlursPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/EnableBlursPreferenceControllerTest.java
new file mode 100644
index 0000000..d943cb1
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/EnableBlursPreferenceControllerTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.SystemProperties;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public final class EnableBlursPreferenceControllerTest {
+
+ @Mock
+ private SwitchPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ @Rule
+ public MockitoRule mockitoRule = MockitoJUnit.rule();
+
+ private Context mContext;
+ private EnableBlursPreferenceController mController;
+
+ @Before
+ public void setup() {
+ mContext = RuntimeEnvironment.application;
+ mController = new EnableBlursPreferenceController(mContext, true);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+ mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onPreferenceChanged_settingEnabled_enableBlurs() {
+ mController.onPreferenceChange(mPreference, true /* new value */);
+
+ final boolean mode = SystemProperties
+ .getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP,
+ false /* default */);
+ assertThat(mode).isFalse();
+ }
+
+ @Test
+ public void onPreferenceChanged_settingDisabled_disableBlurs() {
+ mController.onPreferenceChange(mPreference, false /* new value */);
+
+ final boolean mode = SystemProperties
+ .getBoolean(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP,
+ false /* default */);
+
+ assertThat(mode).isTrue();
+ }
+
+ @Test
+ public void updateState_settingEnabled_preferenceShouldNotBeChecked() {
+ SystemProperties.set(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, "1");
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void updateState_settingDisabled_preferenceShouldBeChecked() {
+ SystemProperties.set(EnableBlursPreferenceController.DISABLE_BLURS_SYSPROP, "0");
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Test
+ public void onDeveloperOptionsDisabled_shouldResetPreference() {
+ mController.onDeveloperOptionsDisabled();
+ // Can predict true or false, depends on device config.
+ verify(mPreference).setChecked(anyBoolean());
+ }
+
+ @Test
+ public void isAvailable_whenSupported() {
+ assertThat(mController.isAvailable()).isTrue();
+
+ mController = new EnableBlursPreferenceController(mContext, false);
+ assertThat(mController.isAvailable()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java
index 24cb9ed..78424da 100644
--- a/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SystemNavigationGestureSettingsTest.java
@@ -24,14 +24,9 @@
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
-import static com.android.settings.gestures.SystemNavigationGestureSettings.BACK_GESTURE_INSET_DEFAULT_OVERLAY;
-import static com.android.settings.gestures.SystemNavigationGestureSettings.BACK_GESTURE_INSET_OVERLAYS;
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_2BUTTONS;
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_3BUTTONS;
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_GESTURAL;
-import static com.android.settings.gestures.SystemNavigationGestureSettings.NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK;
-import static com.android.settings.gestures.SystemNavigationGestureSettings.NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK;
-import static com.android.settings.gestures.SystemNavigationGestureSettings.NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK;
import static com.google.common.truth.Truth.assertThat;
@@ -39,7 +34,6 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -116,96 +110,16 @@
@Test
public void testSetCurrentSystemNavigationMode() throws Exception {
- mSettings.setBackSensitivity(mContext, mOverlayManager, 0);
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_GESTURAL);
- verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
- NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK, USER_CURRENT);
-
- mSettings.setBackSensitivity(mContext, mOverlayManager, 1);
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_GESTURAL);
+ mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_GESTURAL);
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
NAV_BAR_MODE_GESTURAL_OVERLAY, USER_CURRENT);
- mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_GESTURAL);
- verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
- NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK, USER_CURRENT);
-
- mSettings.setBackSensitivity(mContext, mOverlayManager, 3);
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_GESTURAL);
- verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
- NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK, USER_CURRENT);
-
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_2BUTTONS);
+ mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_2BUTTONS);
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
NAV_BAR_MODE_2BUTTON_OVERLAY, USER_CURRENT);
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_3BUTTONS);
+ mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_3BUTTONS);
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
}
-
- @Test
- public void testSetCurrentSystemNavigationMode_backSensitivityValuePersists() throws Exception {
- SettingsShadowResources.overrideResource(
- R.integer.config_navBarInteractionMode, NAV_BAR_MODE_3BUTTON);
-
- mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_3BUTTONS);
- verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
- NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
-
- // Return to Gesture navigation, without setting the sensitivity value.
- mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
- KEY_SYSTEM_NAV_GESTURAL);
- verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
- NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK, USER_CURRENT);
- }
-
- @Test
- public void testGetBackSensitivity_default() {
- assertEquals(BACK_GESTURE_INSET_DEFAULT_OVERLAY,
- mSettings.getBackSensitivity(mContext, mOverlayManager));
- }
-
- @Test
- public void testBackSensitivitySetterAndGetter_currentNavModeNotGestural() throws Exception {
- SettingsShadowResources.overrideResource(
- R.integer.config_navBarInteractionMode, NAV_BAR_MODE_3BUTTON);
-
- mSettings.setBackSensitivity(mContext, mOverlayManager, 3);
- assertEquals(3, mSettings.getBackSensitivity(mContext, mOverlayManager));
- mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
- assertEquals(2, mSettings.getBackSensitivity(mContext, mOverlayManager));
-
- verify(mOverlayManager, never()).setEnabledExclusiveInCategory(any(), anyInt());
- }
-
- @Test
- public void testBackSensitivitySetterAndGetter_currentNavModeIsGestural() throws Exception {
- SettingsShadowResources.overrideResource(
- R.integer.config_navBarInteractionMode, NAV_BAR_MODE_GESTURAL);
-
- when(mOverlayManager.getOverlayInfo(BACK_GESTURE_INSET_OVERLAYS[3], USER_CURRENT))
- .thenReturn(mOverlayInfoEnabled);
- mSettings.setBackSensitivity(mContext, mOverlayManager, 3);
- assertEquals(3, mSettings.getBackSensitivity(mContext, mOverlayManager));
-
- when(mOverlayManager.getOverlayInfo(BACK_GESTURE_INSET_OVERLAYS[2], USER_CURRENT))
- .thenReturn(mOverlayInfoEnabled);
- mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
- assertEquals(2, mSettings.getBackSensitivity(mContext, mOverlayManager));
-
- verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
- NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK, USER_CURRENT);
- verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
- NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK, USER_CURRENT);
- }
}
diff --git a/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java b/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java
index d84d779..f9b1543 100644
--- a/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java
+++ b/tests/robotests/src/com/android/settings/localepicker/LocaleListEditorTest.java
@@ -18,40 +18,68 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.view.View;
import android.widget.TextView;
-import com.android.settings.testutils.FakeFeatureFactory;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
+import com.android.settings.R;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowAlertDialogCompat.class)
public class LocaleListEditorTest {
private LocaleListEditor mLocaleListEditor;
- @Mock
private Context mContext;
+ private FragmentActivity mActivity;
+
+ @Mock
+ private LocaleDragAndDropAdapter mAdapter;
@Before
public void setUp() {
- mLocaleListEditor = new LocaleListEditor();
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mLocaleListEditor = spy(new LocaleListEditor());
+ when(mLocaleListEditor.getContext()).thenReturn(mContext);
+ mActivity = Robolectric.buildActivity(FragmentActivity.class).get();
+ when(mLocaleListEditor.getActivity()).thenReturn(mActivity);
ReflectionHelpers.setField(mLocaleListEditor, "mEmptyTextView",
new TextView(RuntimeEnvironment.application));
ReflectionHelpers.setField(mLocaleListEditor, "mRestrictionsManager",
RuntimeEnvironment.application.getSystemService(Context.RESTRICTIONS_SERVICE));
ReflectionHelpers.setField(mLocaleListEditor, "mUserManager",
RuntimeEnvironment.application.getSystemService(Context.USER_SERVICE));
+ ReflectionHelpers.setField(mLocaleListEditor, "mAdapter", mAdapter);
FakeFeatureFactory.setupForTest();
}
+ @After
+ public void tearDown() {
+ ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", false);
+ ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", false);
+ }
+
@Test
public void testDisallowConfigLocale_unrestrict() {
ReflectionHelpers.setField(mLocaleListEditor, "mIsUiRestricted", true);
@@ -67,4 +95,69 @@
mLocaleListEditor.onResume();
assertThat(mLocaleListEditor.getEmptyTextView().getVisibility()).isEqualTo(View.VISIBLE);
}
+
+ @Test
+ public void showRemoveLocaleWarningDialog_allLocaleSelected_shouldShowErrorDialog() {
+ //pre-condition
+ when(mAdapter.getCheckedCount()).thenReturn(1);
+ when(mAdapter.getItemCount()).thenReturn(1);
+ when(mAdapter.isFirstLocaleChecked()).thenReturn(true);
+ ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
+ ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", true);
+
+ //launch dialog
+ mLocaleListEditor.showRemoveLocaleWarningDialog();
+
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ assertThat(dialog).isNotNull();
+
+ final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
+
+ assertThat(shadowDialog.getTitle()).isEqualTo(
+ mContext.getString(R.string.dlg_remove_locales_error_title));
+ }
+
+ @Test
+ public void showRemoveLocaleWarningDialog_mainLocaleSelected_shouldShowLocaleChangeDialog() {
+ //pre-condition
+ when(mAdapter.getCheckedCount()).thenReturn(1);
+ when(mAdapter.getItemCount()).thenReturn(2);
+ when(mAdapter.isFirstLocaleChecked()).thenReturn(true);
+ ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
+ ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", true);
+
+ //launch dialog
+ mLocaleListEditor.showRemoveLocaleWarningDialog();
+
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ assertThat(dialog).isNotNull();
+
+ final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
+
+ assertThat(shadowDialog.getMessage()).isEqualTo(
+ mContext.getString(R.string.dlg_remove_locales_message));
+ }
+
+ @Test
+ public void showRemoveLocaleWarningDialog_mainLocaleNotSelected_shouldShowConfirmDialog() {
+ //pre-condition
+ when(mAdapter.getCheckedCount()).thenReturn(1);
+ when(mAdapter.getItemCount()).thenReturn(2);
+ when(mAdapter.isFirstLocaleChecked()).thenReturn(false);
+ ReflectionHelpers.setField(mLocaleListEditor, "mRemoveMode", true);
+ ReflectionHelpers.setField(mLocaleListEditor, "mShowingRemoveDialog", true);
+
+ //launch dialog
+ mLocaleListEditor.showRemoveLocaleWarningDialog();
+
+ final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+
+ assertThat(dialog).isNotNull();
+
+ final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
+
+ assertThat(shadowDialog.getMessage()).isNull();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java
index f92b012..8014e56 100644
--- a/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java
@@ -30,6 +30,7 @@
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
+import android.media.MediaRoute2ProviderService;
import android.net.Uri;
import com.android.settings.testutils.shadow.ShadowAudioManager;
@@ -95,7 +96,8 @@
@Test
public void onSelectedDeviceStateChanged_shouldNotifyChange() {
- mMediaDeviceUpdateWorker.onSelectedDeviceStateChanged(null, 0);
+ mMediaDeviceUpdateWorker.onSelectedDeviceStateChanged(mMediaDevice1,
+ LocalMediaManager.MediaDeviceState.STATE_CONNECTED);
verify(mResolver).notifyChange(URI, null);
}
@@ -156,6 +158,13 @@
}
@Test
+ public void onRequestFailed_shouldNotifyChange() {
+ mMediaDeviceUpdateWorker.onRequestFailed(MediaRoute2ProviderService.REASON_UNKNOWN_ERROR);
+
+ verify(mResolver).notifyChange(URI, null /* observer */);
+ }
+
+ @Test
public void onReceive_inCallState_shouldNotifyChange() {
mMediaDeviceUpdateWorker.mLocalMediaManager = mock(LocalMediaManager.class);
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
index 03d85b2..426eacc 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
@@ -336,6 +336,81 @@
}
@Test
+ public void getSlice_onTransferring_containTransferringSubtitle() {
+ final List<MediaDevice> mSelectedDevices = new ArrayList<>();
+ final List<MediaDevice> mSelectableDevices = new ArrayList<>();
+ mDevices.clear();
+ final MediaDevice device = mock(MediaDevice.class);
+ when(device.getName()).thenReturn(TEST_DEVICE_1_NAME);
+ when(device.getIcon()).thenReturn(mTestDrawable);
+ when(device.getMaxVolume()).thenReturn(100);
+ when(device.isConnected()).thenReturn(true);
+ when(device.getDeviceType()).thenReturn(MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE);
+ when(device.getId()).thenReturn(TEST_DEVICE_1_ID);
+ final MediaDevice device2 = mock(MediaDevice.class);
+ when(device2.getName()).thenReturn(TEST_DEVICE_2_NAME);
+ when(device2.getIcon()).thenReturn(mTestDrawable);
+ when(device2.getMaxVolume()).thenReturn(100);
+ when(device2.isConnected()).thenReturn(false);
+ when(device2.getState()).thenReturn(LocalMediaManager.MediaDeviceState.STATE_CONNECTING);
+ when(device2.getDeviceType()).thenReturn(MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE);
+ when(device2.getId()).thenReturn(TEST_DEVICE_2_ID);
+ mSelectedDevices.add(device);
+ mSelectableDevices.add(device2);
+ when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(device);
+ mDevices.add(device);
+ mDevices.add(device2);
+ when(mLocalMediaManager.getSelectedMediaDevice()).thenReturn(mSelectedDevices);
+ when(mLocalMediaManager.getSelectableMediaDevice()).thenReturn(mSelectableDevices);
+ mMediaDeviceUpdateWorker.onDeviceListUpdate(mDevices);
+
+ final Slice mediaSlice = mMediaOutputSlice.getSlice();
+ final String sliceInfo = SliceQuery.findAll(mediaSlice, FORMAT_SLICE, HINT_LIST_ITEM,
+ null).toString();
+
+ assertThat(TextUtils.indexOf(sliceInfo, mContext.getText(R.string.media_output_switching)))
+ .isNotEqualTo(-1);
+ }
+
+ @Test
+ public void getSlice_onTransferringFailed_containFailedSubtitle() {
+ final List<MediaDevice> mSelectedDevices = new ArrayList<>();
+ final List<MediaDevice> mSelectableDevices = new ArrayList<>();
+ mDevices.clear();
+ final MediaDevice device = mock(MediaDevice.class);
+ when(device.getName()).thenReturn(TEST_DEVICE_1_NAME);
+ when(device.getIcon()).thenReturn(mTestDrawable);
+ when(device.getMaxVolume()).thenReturn(100);
+ when(device.isConnected()).thenReturn(true);
+ when(device.getDeviceType()).thenReturn(MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE);
+ when(device.getId()).thenReturn(TEST_DEVICE_1_ID);
+ final MediaDevice device2 = mock(MediaDevice.class);
+ when(device2.getName()).thenReturn(TEST_DEVICE_2_NAME);
+ when(device2.getIcon()).thenReturn(mTestDrawable);
+ when(device2.getMaxVolume()).thenReturn(100);
+ when(device2.isConnected()).thenReturn(false);
+ when(device2.getState()).thenReturn(LocalMediaManager.MediaDeviceState
+ .STATE_CONNECTING_FAILED);
+ when(device2.getDeviceType()).thenReturn(MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE);
+ when(device2.getId()).thenReturn(TEST_DEVICE_2_ID);
+ mSelectedDevices.add(device);
+ mSelectableDevices.add(device2);
+ when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(device);
+ mDevices.add(device);
+ mDevices.add(device2);
+ when(mLocalMediaManager.getSelectedMediaDevice()).thenReturn(mSelectedDevices);
+ when(mLocalMediaManager.getSelectableMediaDevice()).thenReturn(mSelectableDevices);
+ mMediaDeviceUpdateWorker.onDeviceListUpdate(mDevices);
+
+ final Slice mediaSlice = mMediaOutputSlice.getSlice();
+ final String sliceInfo = SliceQuery.findAll(mediaSlice, FORMAT_SLICE, HINT_LIST_ITEM,
+ null).toString();
+
+ assertThat(TextUtils.indexOf(sliceInfo, mContext.getText(
+ R.string.media_output_switch_error_text))).isNotEqualTo(-1);
+ }
+
+ @Test
public void onNotifyChange_foundMediaDevice_connect() {
mDevices.clear();
final MediaDevice device = mock(MediaDevice.class);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index 3641a97..eaa0011 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -42,7 +42,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -121,7 +120,6 @@
}
@Test
- @Ignore
public void updateBottomNavigationView_oneSubscription_shouldNotCrash() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1);
@@ -131,7 +129,6 @@
}
@Test
- @Ignore
public void updateBottomNavigationView_twoSubscription_shouldNotCrash() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
@@ -141,7 +138,6 @@
}
@Test
- @Ignore
public void switchFragment_switchBetweenTwoSubscriptions() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
@@ -152,12 +148,12 @@
mMobileNetworkActivity.onActivity(activity -> {
final MockMobileNetworkActivity mockActivity = (MockMobileNetworkActivity) activity;
+ mockActivity.switchFragment(mSubscriptionInfo1);
assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo1);
});
}
@Test
- @Ignore
public void switchFragment_subscriptionsUpdate_notifyByIntent() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
@@ -168,24 +164,24 @@
mMobileNetworkActivity.onActivity(activity -> {
final MockMobileNetworkActivity mockActivity = (MockMobileNetworkActivity) activity;
+ mockActivity.switchFragment(mSubscriptionInfo1);
assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo1);
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo2);
mContext.sendBroadcast(new Intent(
CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED), null);
+ mockActivity.switchFragment(mSubscriptionInfo2);
assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo2);
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1);
mContext.sendBroadcast(new Intent(
TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED), null);
+ mockActivity.switchFragment(mSubscriptionInfo1);
assertThat(mockActivity.mSubscriptionInFragment).isEqualTo(mSubscriptionInfo1);
});
}
@Test
- @Ignore
public void onSaveInstanceState_saveCurrentSubId() {
mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo1, mSubscriptionInfo2);
diff --git a/tests/robotests/src/com/android/settings/notification/app/ImportantConversationBubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ImportantConversationBubblePreferenceControllerTest.java
deleted file mode 100644
index c99e095..0000000
--- a/tests/robotests/src/com/android/settings/notification/app/ImportantConversationBubblePreferenceControllerTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification.app;
-
-import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
-import static android.provider.Settings.Secure.BUBBLE_IMPORTANT_CONVERSATIONS;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
-import static com.android.settings.notification.app.ImportantConversationBubblePreferenceController.OFF;
-import static com.android.settings.notification.app.ImportantConversationBubblePreferenceController.ON;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-
-@RunWith(RobolectricTestRunner.class)
-public class ImportantConversationBubblePreferenceControllerTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private PreferenceScreen mScreen;
-
- private ImportantConversationBubblePreferenceController mController;
- @Mock
- private TwoStatePreference mPreference;
-
- private static final String KEY = "important_bubble";
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mController = new ImportantConversationBubblePreferenceController(mContext, KEY);
- when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
- when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
- }
-
- @Test
- public void testGetAvailabilityStatus_globallyOn() {
- Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void testGetAvailabilityStatus_globallyOff() {
- Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
- }
-
- @Test
- public void updateState_preferenceSetCheckedWhenSettingIsOn() {
- Settings.Secure.putInt(mContext.getContentResolver(), BUBBLE_IMPORTANT_CONVERSATIONS, ON);
-
- mController.updateState(mPreference);
-
- verify(mPreference).setChecked(true);
- }
-
- @Test
- public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
- Settings.Secure.putInt(mContext.getContentResolver(), BUBBLE_IMPORTANT_CONVERSATIONS, OFF);
-
- mController.updateState(mPreference);
-
- verify(mPreference).setChecked(false);
- }
-
- @Test
- public void isChecked_settingIsOff_shouldReturnFalse() {
- Settings.Secure.putInt(mContext.getContentResolver(), BUBBLE_IMPORTANT_CONVERSATIONS, OFF);
-
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void isChecked_settingIsOn_shouldReturnTrue() {
- Settings.Secure.putInt(mContext.getContentResolver(), BUBBLE_IMPORTANT_CONVERSATIONS, ON);
-
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void setChecked_setFalse_disablesSetting() {
- Settings.Secure.putInt(mContext.getContentResolver(), BUBBLE_IMPORTANT_CONVERSATIONS, ON);
-
- mController.setChecked(false);
- int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
- BUBBLE_IMPORTANT_CONVERSATIONS, -1);
-
- assertThat(updatedValue).isEqualTo(OFF);
- }
-
- @Test
- public void setChecked_setTrue_enablesSetting() {
- Settings.Secure.putInt(mContext.getContentResolver(), BUBBLE_IMPORTANT_CONVERSATIONS, OFF);
-
- mController.setChecked(true);
- int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
- BUBBLE_IMPORTANT_CONVERSATIONS, -1);
-
- assertThat(updatedValue).isEqualTo(ON);
- }
-
- @Test
- public void isSliceable_returnsFalse() {
- assertThat(mController.isSliceable()).isFalse();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/wallpaper/StyleSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/wallpaper/StyleSuggestionActivityTest.java
index 72f9c62..120c780 100644
--- a/tests/robotests/src/com/android/settings/wallpaper/StyleSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wallpaper/StyleSuggestionActivityTest.java
@@ -28,7 +28,6 @@
import com.android.settings.testutils.shadow.ShadowSecureSettings;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -61,7 +60,6 @@
}
@Test
- @Ignore
@Config(shadows = ShadowSecureSettings.class)
public void hasStyleSet_yes_shouldReturnTrue() {
when(mResources.getBoolean(com.android.internal.R.bool.config_enableWallpaperService))
@@ -73,7 +71,6 @@
}
@Test
- @Ignore
@Config(shadows = ShadowSecureSettings.class)
public void hasStyleSet_no_shouldReturnFalse() {
when(mResources.getBoolean(com.android.internal.R.bool.config_enableWallpaperService))
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 720ad20..46b582f 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -32,7 +32,6 @@
import android.view.TextureView;
import android.view.View;
import android.widget.ImageView;
-import android.widget.LinearLayout;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceViewHolder;
@@ -61,8 +60,6 @@
private ImageView fakePreview;
@Mock
private ImageView fakePlayButton;
- @Mock
- private LinearLayout mAnimationView;
private Context mContext;
private VideoPreference mVideoPreference;
@@ -77,7 +74,6 @@
new MediaAnimationController(mContext, R.raw.accessibility_screen_magnification));
mVideoPreference = new VideoPreference(mContext, null /* attrs */);
mVideoPreference.mAnimationController = mAnimationController;
- mVideoPreference.mAnimationView = mAnimationView;
when(mAnimationController.getVideoWidth()).thenReturn(VIDEO_WIDTH);
when(mAnimationController.getVideoHeight()).thenReturn(VIDEO_HEIGHT);
@@ -162,13 +158,6 @@
assertThat(vp2.mAnimationController instanceof VectorAnimationController).isTrue();
}
- @Test
- public void setBackgroundColor_shouldBeCalled() {
- mVideoPreference.setBackgroundColor(1111);
-
- assertThat(mVideoPreference.mBackgroundResId).isEqualTo(1111);
- }
-
public static class TestFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
index bf2261a..7835f7e 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
@@ -19,10 +19,12 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.wifi.SoftApConfiguration;
@@ -31,6 +33,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.widget.ValidatedEditTextPreference;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import org.junit.Before;
import org.junit.Test;
@@ -46,6 +49,7 @@
private static final String VALID_PASS = "12345678";
private static final String VALID_PASS2 = "23456789";
+ private static final String INITIAL_PASSWORD = "test_password";
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock
@@ -56,6 +60,8 @@
private WifiTetherBasePreferenceController.OnTetherConfigUpdateListener mListener;
@Mock
private PreferenceScreen mScreen;
+ @Mock
+ private MetricsFeatureProvider mMetricsFeatureProvider;
private WifiTetherPasswordPreferenceController mController;
private ValidatedEditTextPreference mPreference;
@@ -66,7 +72,8 @@
MockitoAnnotations.initMocks(this);
mPreference = new ValidatedEditTextPreference(RuntimeEnvironment.application);
mConfig = new SoftApConfiguration.Builder().setSsid("test_1234")
- .setPassphrase("test_password", SoftApConfiguration.SECURITY_TYPE_WPA2_PSK).build();
+ .setPassphrase(INITIAL_PASSWORD, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)
+ .build();
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
@@ -76,7 +83,8 @@
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
- mController = new WifiTetherPasswordPreferenceController(mContext, mListener);
+ mController = new WifiTetherPasswordPreferenceController(mContext, mListener,
+ mMetricsFeatureProvider);
}
@Test
@@ -102,6 +110,22 @@
}
@Test
+ public void changePreference_shouldLogActionWhenChanged() {
+ mController.displayPreference(mScreen);
+ mController.onPreferenceChange(mPreference, VALID_PASS);
+ verify(mMetricsFeatureProvider).action(mContext,
+ SettingsEnums.ACTION_SETTINGS_CHANGE_WIFI_HOTSPOT_PASSWORD);
+ }
+
+ @Test
+ public void changePreference_shouldNotLogActionWhenNotChanged() {
+ mController.displayPreference(mScreen);
+ mController.onPreferenceChange(mPreference, INITIAL_PASSWORD);
+ verify(mMetricsFeatureProvider, never()).action(mContext,
+ SettingsEnums.ACTION_SETTINGS_CHANGE_WIFI_HOTSPOT_PASSWORD);
+ }
+
+ @Test
public void updateDisplay_shouldUpdateValue() {
// Set controller password to anything and verify is set.
mController.displayPreference(mScreen);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
index fc38088..a6a9dda 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
@@ -19,10 +19,12 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.wifi.SoftApConfiguration;
@@ -30,6 +32,8 @@
import androidx.preference.PreferenceScreen;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -52,6 +56,8 @@
private WifiTetherBasePreferenceController.OnTetherConfigUpdateListener mListener;
@Mock
private PreferenceScreen mScreen;
+ @Mock
+ private MetricsFeatureProvider mMetricsFeatureProvider;
private WifiTetherSSIDPreferenceController mController;
private WifiTetherSsidPreference mPreference;
@@ -67,8 +73,8 @@
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
-
- mController = new WifiTetherSSIDPreferenceController(mContext, mListener);
+ mController = new WifiTetherSSIDPreferenceController(mContext, mListener,
+ mMetricsFeatureProvider);
}
@Test
@@ -103,6 +109,23 @@
}
@Test
+ public void changePreference_shouldLogActionWhenChanged() {
+ mController.displayPreference(mScreen);
+ mController.onPreferenceChange(mPreference, "1");
+ verify(mMetricsFeatureProvider).action(mContext,
+ SettingsEnums.ACTION_SETTINGS_CHANGE_WIFI_HOTSPOT_NAME);
+ }
+
+ @Test
+ public void changePreference_shouldNotLogActionWhenNotChanged() {
+ mController.displayPreference(mScreen);
+ mController.onPreferenceChange(mPreference,
+ WifiTetherSSIDPreferenceController.DEFAULT_SSID);
+ verify(mMetricsFeatureProvider, never()).action(mContext,
+ SettingsEnums.ACTION_SETTINGS_CHANGE_WIFI_HOTSPOT_NAME);
+ }
+
+ @Test
public void updateDisplay_shouldUpdateValue() {
// Set controller ssid to anything and verify is set.
mController.displayPreference(mScreen);