Merge "Fix tapping magnification crash in vision settings setup screen"
diff --git a/res/drawable/ic_cellular_1_bar.xml b/res/drawable/ic_cellular_1_bar.xml
index 23caacc2..a07e257 100644
--- a/res/drawable/ic_cellular_1_bar.xml
+++ b/res/drawable/ic_cellular_1_bar.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2019 The Android Open Source Project
+ Copyright (C) 2022 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.
@@ -19,11 +19,11 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
- android:tint="?android:attr/colorControlNormal">
+ android:tint="@color/battery_usage_system_icon_color">
<path
- android:fillColor="#000000"
+ android:fillColor="@android:color/white"
android:pathData="M20,7v13H7L20,7 M22,2L2,22h20V2L22,2z" />
<path
- android:fillColor="#000000"
+ android:fillColor="@android:color/white"
android:pathData="M 11 13 L 2 22 L 11 22 Z" />
-</vector>
\ No newline at end of file
+</vector>
diff --git a/res/drawable/ic_power_system.xml b/res/drawable/ic_power_system.xml
index 3b84f59..cdebc0e 100644
--- a/res/drawable/ic_power_system.xml
+++ b/res/drawable/ic_power_system.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2019 The Android Open Source Project
+ Copyright (C) 2022 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.
@@ -19,8 +19,8 @@
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
+ android:tint="@color/battery_usage_system_icon_color">
<path
- android:fillColor="#000000"
+ android:fillColor="@android:color/white"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
</vector>
diff --git a/res/drawable/ic_settings_aod.xml b/res/drawable/ic_settings_aod.xml
index b238e3a..89affdc 100644
--- a/res/drawable/ic_settings_aod.xml
+++ b/res/drawable/ic_settings_aod.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2018 The Android Open Source Project
+ Copyright (C) 2022 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.
@@ -19,17 +19,17 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
- android:tint="?android:attr/colorControlNormal">
+ android:tint="@color/battery_usage_system_icon_color">
<path
- android:fillColor="#000000"
- android:pathData="M17,1.01L7,1C5.9,1,5,1.9,5,3v18c0,1.1,0.9,2,2,2h10c1.1,0,2-0.9,2-2V3C19,1.9,18.1,1.01,17,1.01z M17,21H7l0-1h10V21z M17,18H7V6h10V18z M17,4H7V3h10V4z" />
+ android:fillColor="@android:color/white"
+ android:pathData="M17,1.01L7,1C5.9,1,5,1.9,5,3v18c0,1.1,0.9,2,2,2h10c1.1,0,2-0.9,2-2V3C19,1.9,18.1,1.01,17,1.01z M17,21H7l0-1h10V21z M17,18H7V6h10V18z M17,4H7V3h10V4z"/>
<path
- android:fillColor="#000000"
- android:pathData="M 8 10 H 16 V 11.5 H 8 V 10 Z" />
+ android:fillColor="@android:color/white"
+ android:pathData="M 8 10 H 16 V 11.5 H 8 V 10 Z"/>
<path
- android:fillColor="#000000"
- android:pathData="M 9 13 H 15 V 14.5 H 9 V 13 Z" />
+ android:fillColor="@android:color/white"
+ android:pathData="M 9 13 H 15 V 14.5 H 9 V 13 Z"/>
<path
- android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
-</vector>
\ No newline at end of file
+ android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z"/>
+</vector>
diff --git a/res/drawable/ic_settings_bluetooth.xml b/res/drawable/ic_settings_bluetooth.xml
new file mode 100644
index 0000000..a8666ac
--- /dev/null
+++ b/res/drawable/ic_settings_bluetooth.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="@color/battery_usage_system_icon_color">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M17.71,7.71L12,2h-1v7.59L6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 11,14.41L11,22h1l5.71,-5.71 -4.3,-4.29 4.3,-4.29zM13,5.83l1.88,1.88L13,9.59L13,5.83zM14.88,16.29L13,18.17v-3.76l1.88,1.88z"/>
+</vector>
diff --git a/res/drawable/ic_settings_camera.xml b/res/drawable/ic_settings_camera.xml
index 3c85532..278d295 100644
--- a/res/drawable/ic_settings_camera.xml
+++ b/res/drawable/ic_settings_camera.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2015 The Android Open Source Project
+ Copyright (C) 2022 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.
@@ -21,9 +21,9 @@
android:viewportWidth="48"
android:viewportHeight="48"
android:autoMirrored="true"
- android:tint="?android:attr/colorControlNormal">
+ android:tint="@color/battery_usage_system_icon_color">
- <path android:fillColor="#000000"
+ <path android:fillColor="@android:color/white"
android:pathData="M18.8 21l9.53-16.51C26.94 4.18 25.49 4 24 4c-4.8 0-9.19 1.69-12.64
4.51l7.33 12.69.11-.2zm24.28-3c-1.84-5.85-6.3-10.52-11.99-12.68L23.77
18h19.31zm.52 2H28.62l.58 1 9.53 16.5C41.99 33.94 44 29.21 44
diff --git a/res/drawable/ic_settings_display.xml b/res/drawable/ic_settings_display.xml
index 7f0aacd..61d1aeb 100644
--- a/res/drawable/ic_settings_display.xml
+++ b/res/drawable/ic_settings_display.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2016 The Android Open Source Project
+ Copyright (C) 2022 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.
@@ -18,8 +18,8 @@
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
- android:tint="?android:attr/colorControlNormal">
+ android:tint="@color/battery_usage_system_icon_color">
<path
- android:fillColor="#FFFFFFFF"
+ android:fillColor="@android:color/white"
android:pathData="M20,8.69V4h-4.69L12,0.69L8.69,4H4v4.69L0.69,12L4,15.31V20h4.69L12,23.31L15.31,20H20v-4.69L23.31,12L20,8.69zM18,14.48V18h-3.52L12,20.48L9.52,18H6v-3.52L3.52,12L6,9.52V6h3.52L12,3.52L14.48,6H18v3.52L20.48,12L18,14.48zM12,17c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5V17z"/>
</vector>
diff --git a/res/drawable/ic_settings_phone_idle.xml b/res/drawable/ic_settings_phone_idle.xml
index 7bb6c31..fd304e7 100644
--- a/res/drawable/ic_settings_phone_idle.xml
+++ b/res/drawable/ic_settings_phone_idle.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2019 The Android Open Source Project
+ Copyright (C) 2022 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.
@@ -18,8 +18,8 @@
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:pathData="M14,48h4v-4h-4v4zM22,48h4v-4h-4v4zM26,4h-4v20h4L26,4zM33.13,8.87l-2.89,2.89C33.69,13.87 36,17.66 36,22c0,6.63 -5.37,12 -12,12s-12,-5.37 -12,-12c0,-4.34 2.31,-8.13 5.76,-10.24l-2.89,-2.89C10.72,11.76 8,16.56 8,22c0,8.84 7.16,16 16,16s16,-7.16 16,-16c0,-5.44 -2.72,-10.24 -6.87,-13.13zM30,48h4v-4h-4v4z"
- android:fillColor="#000000"/>
+ android:tint="@color/battery_usage_system_icon_color">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M14,48h4v-4h-4v4zM22,48h4v-4h-4v4zM26,4h-4v20h4L26,4zM33.13,8.87l-2.89,2.89C33.69,13.87 36,17.66 36,22c0,6.63 -5.37,12 -12,12s-12,-5.37 -12,-12c0,-4.34 2.31,-8.13 5.76,-10.24l-2.89,-2.89C10.72,11.76 8,16.56 8,22c0,8.84 7.16,16 16,16s16,-7.16 16,-16c0,-5.44 -2.72,-10.24 -6.87,-13.13zM30,48h4v-4h-4v4z"/>
</vector>
diff --git a/res/drawable/ic_settings_voice_calls.xml b/res/drawable/ic_settings_voice_calls.xml
index b455f0a..c8817a8 100644
--- a/res/drawable/ic_settings_voice_calls.xml
+++ b/res/drawable/ic_settings_voice_calls.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2019 The Android Open Source Project
+ Copyright (C) 2022 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.
@@ -18,8 +18,8 @@
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:pathData="M40,31c-2.49,0 -4.89,-0.4 -7.14,-1.14 -0.69,-0.22 -1.48,-0.06 -2.03,0.49l-4.4,4.41c-5.67,-2.88 -10.29,-7.51 -13.18,-13.17l4.4,-4.41c0.55,-0.55 0.71,-1.34 0.49,-2.03C17.4,12.9 17,10.49 17,8c0,-1.11 -0.89,-2 -2,-2L8,6c-1.11,0 -2,0.89 -2,2 0,18.78 15.22,34 34,34 1.11,0 2,-0.89 2,-2v-7c0,-1.11 -0.89,-2 -2,-2zM38,24h4c0,-9.94 -8.06,-18 -18,-18v4c7.73,0 14,6.27 14,14zM30,24h4c0,-5.52 -4.48,-10 -10,-10v4c3.31,0 6,2.69 6,6z"
- android:fillColor="#000000"/>
+ android:tint="@color/battery_usage_system_icon_color">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M40,31c-2.49,0 -4.89,-0.4 -7.14,-1.14 -0.69,-0.22 -1.48,-0.06 -2.03,0.49l-4.4,4.41c-5.67,-2.88 -10.29,-7.51 -13.18,-13.17l4.4,-4.41c0.55,-0.55 0.71,-1.34 0.49,-2.03C17.4,12.9 17,10.49 17,8c0,-1.11 -0.89,-2 -2,-2L8,6c-1.11,0 -2,0.89 -2,2 0,18.78 15.22,34 34,34 1.11,0 2,-0.89 2,-2v-7c0,-1.11 -0.89,-2 -2,-2zM38,24h4c0,-9.94 -8.06,-18 -18,-18v4c7.73,0 14,6.27 14,14zM30,24h4c0,-5.52 -4.48,-10 -10,-10v4c3.31,0 6,2.69 6,6z"/>
</vector>
diff --git a/res/drawable/ic_settings_wireless_no_theme.xml b/res/drawable/ic_settings_wireless_no_theme.xml
new file mode 100644
index 0000000..5e18b89a
--- /dev/null
+++ b/res/drawable/ic_settings_wireless_no_theme.xml
@@ -0,0 +1,30 @@
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="@color/battery_usage_system_icon_color">
+ <path
+ android:pathData="M1.003,9L3.003,11C7.973,6.03 16.033,6.03 21.003,11L23.003,9C16.933,2.93 7.083,2.93 1.003,9ZM9.003,17L12.003,20L15.003,17C13.353,15.34 10.663,15.34 9.003,17ZM7.005,15L5.005,13C8.875,9.14 15.145,9.14 19.005,13L17.005,15C14.245,12.241 9.765,12.241 7.005,15Z"
+ android:fillType="evenOdd"
+ android:fillColor="@android:color/white"/>
+ <path
+ android:pathData="M0,0H24V24H0V0ZM0,0H24V24H0V0Z"
+ android:fillType="evenOdd"
+ android:fillColor="@android:color/white"/>
+</vector>
diff --git a/res/layout/battery_chart_graph.xml b/res/layout/battery_chart_graph.xml
index 6e86aec..f116c8e 100644
--- a/res/layout/battery_chart_graph.xml
+++ b/res/layout/battery_chart_graph.xml
@@ -31,25 +31,33 @@
android:textColor="?android:attr/textColorSecondary"
android:text="@string/battery_usage_chart_graph_hint_last_full_charge" />
- <com.android.settings.fuelgauge.batteryusage.BatteryChartView
- android:id="@+id/daily_battery_chart"
+ <LinearLayout
+ android:id="@+id/battery_chart_group"
android:layout_width="match_parent"
- android:layout_height="170dp"
- android:layout_marginBottom="16dp"
- android:visibility="gone"
- android:contentDescription="@string/daily_battery_usage_chart"
- android:textAppearance="?android:attr/textAppearanceSmall"
- settings:textColor="?android:attr/textColorSecondary" />
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:alpha="0">
+ <com.android.settings.fuelgauge.batteryusage.BatteryChartView
+ android:id="@+id/daily_battery_chart"
+ android:layout_width="match_parent"
+ android:layout_height="170dp"
+ android:layout_marginBottom="16dp"
+ android:visibility="gone"
+ android:contentDescription="@string/daily_battery_usage_chart"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ settings:textColor="?android:attr/textColorSecondary" />
- <com.android.settings.fuelgauge.batteryusage.BatteryChartView
- android:id="@+id/hourly_battery_chart"
- android:layout_width="match_parent"
- android:layout_height="170dp"
- android:layout_marginBottom="16dp"
- android:visibility="visible"
- android:contentDescription="@string/hourly_battery_usage_chart"
- android:textAppearance="?android:attr/textAppearanceSmall"
- settings:textColor="?android:attr/textColorSecondary" />
+ <com.android.settings.fuelgauge.batteryusage.BatteryChartView
+ android:id="@+id/hourly_battery_chart"
+ android:layout_width="match_parent"
+ android:layout_height="170dp"
+ android:layout_marginBottom="16dp"
+ android:visibility="visible"
+ android:contentDescription="@string/hourly_battery_usage_chart"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ settings:textColor="?android:attr/textColorSecondary" />
+ </LinearLayout>
+
<!-- Use non-scalable text size from text_size_small_material -->
<TextView
android:id="@+id/companion_text"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 4e4ee5d..0017c2c 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -52,5 +52,8 @@
<!-- Material inverse ripple color, useful for inverted backgrounds. -->
<color name="ripple_material_inverse">@*android:color/ripple_material_light</color>
+
+ <!-- Icon tint color for battery usage system icon -->
+ <color name="battery_usage_system_icon_color">@android:color/white</color>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e818a28..7ca1ab2 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -209,4 +209,7 @@
<!-- Background for multiple user settings page avatars -->
<color name="user_avatar_color_bg">?androidprv:attr/colorSurface</color>
+
+ <!-- Icon tint color for battery usage system icon -->
+ <color name="battery_usage_system_icon_color">?android:attr/textColorPrimary</color>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b039c61..2aae74a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4668,8 +4668,6 @@
<string name="reset_app_preferences_desc">This will reset all preferences for:\n\n<li>Disabled apps</li>\n<li>Disabled app notifications</li>\n<li>Default applications for actions</li>\n<li>Background data restrictions for apps</li>\n<li>Any permission restrictions</li>\n<li>Battery usage settings</li>\n\nYou will not lose any app data.</string>
<!-- [CHAR LIMIT=25] Manage applications screen, menu item. Confirmation button of dialog to confirm resetting user's app preferences. -->
<string name="reset_app_preferences_button">Reset apps</string>
- <!-- Manage applications screen, individual app screen, button label when the user wants to manage the space taken up by an app. -->
- <string name="manage_space_text">Manage space</string>
<!-- Text for menu option in ManageApps screen to present various menu options -->
<string name="filter">Filter</string>
<!-- Title of dialog for presenting filter options -->
@@ -13165,6 +13163,10 @@
<string name="media_controls_resume_title">Pin media player</string>
<!-- Description of toggle to enable or disable the media resumption feature in quick settings [CHAR LIMIT=NONE]-->
<string name="media_controls_resume_description">To quickly resume playback, media player stays open in Quick Settings</string>
+ <!-- Title of toggle to enable or disable the media resumption on lockscreen [CHAR LIMIT=NONE]-->
+ <string name="media_controls_lockscreen_title">Show media on lock screen</string>
+ <!-- Description of toggle to enable or disable the media resumption on lockscreen [CHAR LIMIT=NONE]-->
+ <string name="media_controls_lockscreen_description">To quickly resume playback, media player stays open on lock screen</string>
<!-- Title of toggle to enable or disable media recommendations in quick settings [CHAR LIMIT=NONE] -->
<string name="media_controls_recommendations_title">Show media recommendations</string>
<!-- Description of toggle to enable or disable media recommendations based on user's activity [CHAR LIMIT=NONE] -->
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 4e58e66..96a3f85 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -156,7 +156,7 @@
android:title="@string/notification_pulse_title"
settings:controller="com.android.settings.notification.PulseNotificationPreferenceController"/>
- <SwitchPreference
+ <com.android.settingslib.PrimarySwitchPreference
android:key="notification_assistant"
android:order="23"
android:title="@string/notification_assistant_title"
diff --git a/res/xml/media_controls_settings.xml b/res/xml/media_controls_settings.xml
index 0318097..822639a 100644
--- a/res/xml/media_controls_settings.xml
+++ b/res/xml/media_controls_settings.xml
@@ -28,6 +28,12 @@
app:controller="com.android.settings.sound.MediaControlsPreferenceController" />
<SwitchPreference
+ android:key="media_controls_lockscreen"
+ android:title="@string/media_controls_lockscreen_title"
+ android:summary="@string/media_controls_lockscreen_description"
+ app:controller="com.android.settings.sound.MediaControlsLockScreenPreferenceController" />
+
+ <SwitchPreference
android:key="media_controls_recommendations"
android:title="@string/media_controls_recommendations_title"
android:summary="@string/media_controls_recommendations_description"
diff --git a/res/xml/privacy_advanced_settings.xml b/res/xml/privacy_advanced_settings.xml
index 9f465d4..b028008 100644
--- a/res/xml/privacy_advanced_settings.xml
+++ b/res/xml/privacy_advanced_settings.xml
@@ -51,6 +51,14 @@
android:summary="@string/summary_placeholder"
settings:searchable="false"/>
+ <!-- Show media on lock screen -->
+ <SwitchPreference
+ android:key="privacy_media_controls_lockscreen"
+ android:title="@string/media_controls_lockscreen_title"
+ android:summary="@string/media_controls_lockscreen_description"
+ settings:controller=
+ "com.android.settings.sound.MediaControlsLockScreenPreferenceController" />
+
<!-- Privacy Service -->
<PreferenceCategory
android:key="privacy_services"
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 0a7cab5..f8f916e 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -89,6 +89,14 @@
android:summary="@string/summary_placeholder"
settings:searchable="false"/>
+ <!-- Show media on lock screen -->
+ <SwitchPreference
+ android:key="privacy_media_controls_lockscreen"
+ android:title="@string/media_controls_lockscreen_title"
+ android:summary="@string/media_controls_lockscreen_description"
+ settings:controller=
+ "com.android.settings.sound.MediaControlsLockScreenPreferenceController" />
+
<!-- Privacy Service -->
<PreferenceCategory
android:key="privacy_services"
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index c3dc306..5a1d11b 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -309,11 +309,7 @@
.setButton1Enabled(false);
mCanClearData = false;
} else {
- if (appHasSpaceManagementUI) {
- mButtonsPref.setButton1Text(R.string.manage_space_text);
- } else {
- mButtonsPref.setButton1Text(R.string.clear_user_data_text);
- }
+ mButtonsPref.setButton1Text(R.string.clear_user_data_text);
mButtonsPref.setButton1Icon(R.drawable.ic_settings_delete)
.setButton1OnClickListener(v -> handleClearDataClick());
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 94dfe96..e50973b 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -98,9 +98,9 @@
import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.applications.AppStateAlarmsAndRemindersBridge;
+import com.android.settings.applications.AppStateAppBatteryUsageBridge;
import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
import com.android.settings.applications.AppStateBaseBridge;
-import com.android.settings.applications.AppStateAppBatteryUsageBridge;
import com.android.settings.applications.AppStateInstallAppsBridge;
import com.android.settings.applications.AppStateLocaleBridge;
import com.android.settings.applications.AppStateManageExternalStorageBridge;
@@ -321,7 +321,7 @@
mListType = LIST_TYPE_ALARMS_AND_REMINDERS;
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())
|| className.equals(
- Settings.NotificationReviewPermissionsActivity.class.getName())) {
+ Settings.NotificationReviewPermissionsActivity.class.getName())) {
mListType = LIST_TYPE_NOTIFICATION;
mUsageStatsManager = IUsageStatsManager.Stub.asInterface(
ServiceManager.getService(Context.USAGE_STATS_SERVICE));
@@ -924,8 +924,9 @@
/**
* Returns a resource ID of title based on what type of app list is
+ *
* @param intent the intent of the activity that might include a specified title
- * @param args the args that includes a class name of app list
+ * @param args the args that includes a class name of app list
*/
public static int getTitleResId(@NonNull Intent intent, Bundle args) {
int screenTitle = intent.getIntExtra(
@@ -948,13 +949,13 @@
screenTitle = R.string.change_wifi_state_title;
} else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) {
screenTitle = R.string.manage_external_storage_title;
- } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) {
+ } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) {
screenTitle = R.string.media_management_apps_title;
} else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) {
screenTitle = R.string.alarms_and_reminders_title;
} else if (className.equals(Settings.NotificationAppListActivity.class.getName())
|| className.equals(
- Settings.NotificationReviewPermissionsActivity.class.getName())) {
+ Settings.NotificationReviewPermissionsActivity.class.getName())) {
screenTitle = R.string.app_notifications_title;
} else if (className.equals(AppLocaleDetails.class.getName())) {
screenTitle = R.string.app_locales_picker_menu_title;
@@ -1198,11 +1199,11 @@
} else {
rebuild(R.id.sort_order_alpha, true);
}
+ return;
} else if (mManageApplications.mListType == LIST_TYPE_BATTERY_OPTIMIZATION) {
logAppBatteryUsage(filterType);
- } else {
- rebuild();
}
+ rebuild();
}
public void resume(int sort) {
@@ -1337,7 +1338,7 @@
}
private void logAppBatteryUsage(int filterType) {
- switch(filterType) {
+ switch (filterType) {
case FILTER_APPS_BATTERY_UNRESTRICTED:
logAction(SettingsEnums.ACTION_BATTERY_OPTIMIZED_APPS_FILTER_UNRESTRICTED);
break;
@@ -1562,6 +1563,7 @@
/**
* Check item in the list shall enable or disable.
+ *
* @param position The item position in the list
*/
public boolean isEnabled(int position) {
@@ -1726,7 +1728,7 @@
public OnScrollListener(ApplicationsAdapter adapter) {
mAdapter = adapter;
mInputMethodManager = mAdapter.mContext.getSystemService(
- InputMethodManager.class);
+ InputMethodManager.class);
}
@Override
diff --git a/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java b/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
index bd79cc2..404fe6d 100644
--- a/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
+++ b/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
@@ -127,13 +127,14 @@
@Override
public boolean onPreferenceTreeClick(Preference preference) {
final String key = preference.getKey();
+ final Context context = requireActivity().getApplicationContext();
// Generate challenge (and request LSS to create a HAT) each time the preference is clicked,
// since FingerprintSettings and FaceSettings revoke the challenge when finishing.
if (getFacePreferenceKey().equals(key)) {
mDoNotFinishActivity = true;
mFaceManager.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
- final byte[] token = BiometricUtils.requestGatekeeperHat(getActivity(), mGkPwHandle,
+ final byte[] token = BiometricUtils.requestGatekeeperHat(context, mGkPwHandle,
mUserId, challenge);
final Bundle extras = preference.getExtras();
extras.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
@@ -146,7 +147,7 @@
} else if (getFingerprintPreferenceKey().equals(key)) {
mDoNotFinishActivity = true;
mFingerprintManager.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
- final byte[] token = BiometricUtils.requestGatekeeperHat(getActivity(), mGkPwHandle,
+ final byte[] token = BiometricUtils.requestGatekeeperHat(context, mGkPwHandle,
mUserId, challenge);
final Bundle extras = preference.getExtras();
extras.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
diff --git a/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java b/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java
index ba09e5f..978fb0d 100644
--- a/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java
@@ -40,6 +40,7 @@
@VisibleForTesting
RestrictedPreference mPreference;
protected final CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
+ private PreferenceScreen mPreferenceScreen;
public CombinedBiometricStatusPreferenceController(Context context) {
this(context, KEY_BIOMETRIC_SETTINGS, null /* lifecycle */);
@@ -66,11 +67,15 @@
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
updateStateInternal();
+ if (mPreferenceScreen != null) {
+ displayPreference(mPreferenceScreen);
+ }
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
+ mPreferenceScreen = screen;
mPreference = screen.findPreference(mPreferenceKey);
}
diff --git a/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java b/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
index 9b4b433..7c41957 100644
--- a/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
@@ -40,6 +40,7 @@
protected final FaceManager mFaceManager;
@VisibleForTesting
RestrictedPreference mPreference;
+ private PreferenceScreen mPreferenceScreen;
private final FaceStatusUtils mFaceStatusUtils;
public FaceStatusPreferenceController(Context context) {
@@ -67,11 +68,15 @@
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
updateStateInternal();
+ if (mPreferenceScreen != null) {
+ displayPreference(mPreferenceScreen);
+ }
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
+ mPreferenceScreen = screen;
mPreference = screen.findPreference(mPreferenceKey);
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 427b50a..fd589f4 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -67,7 +67,7 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- final FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
+ final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(this);
final List<FingerprintSensorPropertiesInternal> props =
fingerprintManager.getSensorPropertiesInternal();
mCanAssumeUdfps = props != null && props.size() == 1 && props.get(0).isAnyUdfpsType();
@@ -138,8 +138,7 @@
// This is an entry point for SetNewPasswordController, e.g.
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
- final FingerprintManager fpm = getSystemService(FingerprintManager.class);
- fpm.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
+ fingerprintManager.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
mChallenge = challenge;
mSensorId = sensorId;
mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
@@ -278,6 +277,7 @@
}
private void onStartButtonClick(View view) {
+ mNextClicked = true;
startActivityForResult(getFingerprintEnrollingIntent(), ENROLL_REQUEST);
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index e1acec7..bf18ed5 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -364,10 +364,16 @@
mHasFirstEnrolled);
}
- // Need to authenticate a session token if none
- if (mToken == null && mLaunchedConfirm == false) {
- mLaunchedConfirm = true;
- launchChooseOrConfirmLock();
+ // (mLaunchedConfirm or mIsEnrolling) means that we are waiting an activity result.
+ if (!mLaunchedConfirm && !mIsEnrolling) {
+ // Need to authenticate a session token if none
+ if (mToken == null) {
+ mLaunchedConfirm = true;
+ launchChooseOrConfirmLock();
+ } else if (!mHasFirstEnrolled) {
+ mIsEnrolling = true;
+ addFirstFingerprint();
+ }
}
updateFooterColumns(activity);
}
@@ -674,8 +680,7 @@
updateAddPreference();
if (!mHasFirstEnrolled && !mIsEnrolling) {
mIsEnrolling = true;
- addFirstFingerprint(
- BiometricUtils.getGatekeeperPasswordHandle(data));
+ addFirstFingerprint();
}
});
} else {
@@ -695,7 +700,7 @@
}
} else if (requestCode == AUTO_ADD_FIRST_FINGERPRINT_REQUEST) {
mIsEnrolling = false;
- mHasFirstEnrolled = false;
+ mHasFirstEnrolled = true;
if (resultCode != RESULT_FINISHED) {
Log.d(TAG, "Add first fingerprint fail, result:" + resultCode);
finish();
@@ -771,7 +776,7 @@
}
}
- private void addFirstFingerprint(@Nullable Long gkPwHandle) {
+ private void addFirstFingerprint() {
Intent intent = new Intent();
intent.setClassName(SETTINGS_PACKAGE_NAME,
FingerprintEnrollIntroductionInternal.class.getName());
@@ -782,9 +787,6 @@
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
- if (gkPwHandle != null) {
- intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, (long) gkPwHandle);
- }
startActivityForResult(intent, AUTO_ADD_FIRST_FINGERPRINT_REQUEST);
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceController.java b/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceController.java
index 62edcf0..1ed0688 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceController.java
@@ -41,6 +41,7 @@
@VisibleForTesting
RestrictedPreference mPreference;
private final FingerprintStatusUtils mFingerprintStatusUtils;
+ private PreferenceScreen mPreferenceScreen;
public FingerprintStatusPreferenceController(Context context) {
this(context, KEY_FINGERPRINT_SETTINGS);
@@ -68,11 +69,15 @@
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
updateStateInternal();
+ if (mPreferenceScreen != null) {
+ displayPreference(mPreferenceScreen);
+ }
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
+ mPreferenceScreen = screen;
mPreference = screen.findPreference(mPreferenceKey);
}
diff --git a/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java b/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java
index dd06b67..62a66cf 100644
--- a/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java
+++ b/src/com/android/settings/bluetooth/BluetoothBroadcastDialog.java
@@ -74,12 +74,12 @@
TextView title = layout.findViewById(com.android.settingslib.R.id.dialog_title);
TextView subTitle = layout.findViewById(com.android.settingslib.R.id.dialog_subtitle);
- title.setText(mContext.getString(R.string.bluetooth_broadcast_dialog_title));
- subTitle.setText(
- mContext.getString(R.string.bluetooth_broadcast_dialog_broadcast_message));
Button broadcastBtn = layout.findViewById(com.android.settingslib.R.id.positive_btn);
if (isBroadcastSupported() && mIsMediaStreaming) {
+ title.setText(mContext.getString(R.string.bluetooth_broadcast_dialog_title));
+ subTitle.setText(
+ mContext.getString(R.string.bluetooth_broadcast_dialog_broadcast_message));
broadcastBtn.setVisibility(View.VISIBLE);
if (TextUtils.isEmpty(mCurrentAppLabel)) {
broadcastBtn.setText(mContext.getString(R.string.bluetooth_broadcast_dialog_title));
@@ -92,6 +92,9 @@
launchMediaOutputBroadcastDialog();
});
} else {
+ title.setText(mContext.getString(R.string.bluetooth_find_broadcast));
+ subTitle.setText(
+ mContext.getString(R.string.bluetooth_broadcast_dialog_find_message));
broadcastBtn.setVisibility(View.GONE);
}
diff --git a/src/com/android/settings/development/MockLocationAppPreferenceController.java b/src/com/android/settings/development/MockLocationAppPreferenceController.java
index 4803843..6b0ed03 100644
--- a/src/com/android/settings/development/MockLocationAppPreferenceController.java
+++ b/src/com/android/settings/development/MockLocationAppPreferenceController.java
@@ -165,7 +165,7 @@
if (packageOps != null) {
for (AppOpsManager.PackageOps packageOp : packageOps) {
if (packageOp.getOps().get(0).getMode() == AppOpsManager.MODE_ALLOWED) {
- return packageOps.get(0).getPackageName();
+ return packageOp.getPackageName();
}
}
}
diff --git a/src/com/android/settings/development/tare/TareHomePage.java b/src/com/android/settings/development/tare/TareHomePage.java
index d0567f7..edaeba2 100644
--- a/src/com/android/settings/development/tare/TareHomePage.java
+++ b/src/com/android/settings/development/tare/TareHomePage.java
@@ -27,6 +27,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
+import android.provider.DeviceConfig;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
@@ -66,7 +67,7 @@
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mConfigObserver.mEnableTareSetting == SETTING_VALUE_DEFAULT
- && isChecked == (Settings.Global.DEFAULT_ENABLE_TARE == SETTING_VALUE_ON)) {
+ && isChecked == mConfigObserver.getDefaultEnabledStatus()) {
// Don't bother writing something that's not new information. It would make
// it hard to use DeviceConfig if we did.
return;
@@ -93,12 +94,19 @@
/** Reverts the TARE settings to the original default settings */
public void revertSettings(View v) {
Toast.makeText(this, R.string.tare_settings_reverted_toast, Toast.LENGTH_LONG).show();
+ final boolean wasSettingsDefault =
+ mConfigObserver.mEnableTareSetting == SETTING_VALUE_DEFAULT;
Settings.Global.putString(getApplicationContext().getContentResolver(),
Settings.Global.ENABLE_TARE, null);
Settings.Global.putString(getApplicationContext().getContentResolver(),
Settings.Global.TARE_ALARM_MANAGER_CONSTANTS, null);
Settings.Global.putString(getApplicationContext().getContentResolver(),
Settings.Global.TARE_JOB_SCHEDULER_CONSTANTS, null);
+ if (wasSettingsDefault) {
+ // Only do this manually here to force a DeviceConfig check if the settings value isn't
+ // actually changing.
+ setEnabled(mConfigObserver.getDefaultEnabledStatus());
+ }
}
/** Opens up the AlarmManager TARE policy page with its factors to view and edit */
@@ -117,13 +125,14 @@
/** Changes the enabled state of the TARE homepage buttons based on global toggle */
private void setEnabled(boolean tareStatus) {
- mRevButton.setEnabled(tareStatus);
mAlarmManagerView.setEnabled(tareStatus);
mJobSchedulerView.setEnabled(tareStatus);
mOnSwitch.setChecked(tareStatus);
}
private class ConfigObserver extends ContentObserver {
+ private static final String KEY_DC_ENABLE_TARE = "enable_tare";
+
private int mEnableTareSetting;
ConfigObserver(Handler handler) {
@@ -148,7 +157,7 @@
private void processEnableTareChange() {
final String setting =
Settings.Global.getString(getContentResolver(), Settings.Global.ENABLE_TARE);
- if (setting == null ) {
+ if (setting == null) {
mEnableTareSetting = SETTING_VALUE_DEFAULT;
} else {
try {
@@ -157,7 +166,21 @@
mEnableTareSetting = Settings.Global.DEFAULT_ENABLE_TARE;
}
}
- setEnabled(mEnableTareSetting == SETTING_VALUE_ON);
+ final boolean enabled;
+ if (mEnableTareSetting == SETTING_VALUE_ON) {
+ enabled = true;
+ } else if (mEnableTareSetting == SETTING_VALUE_OFF) {
+ enabled = false;
+ } else {
+ enabled = getDefaultEnabledStatus();
+ }
+ setEnabled(enabled);
}
+
+ private boolean getDefaultEnabledStatus() {
+ return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_TARE, KEY_DC_ENABLE_TARE,
+ Settings.Global.DEFAULT_ENABLE_TARE == SETTING_VALUE_ON);
+ }
+
}
}
diff --git a/src/com/android/settings/dream/DreamComplicationPreferenceController.java b/src/com/android/settings/dream/DreamComplicationPreferenceController.java
index d9c4fb3..596fe20 100644
--- a/src/com/android/settings/dream/DreamComplicationPreferenceController.java
+++ b/src/com/android/settings/dream/DreamComplicationPreferenceController.java
@@ -42,14 +42,12 @@
@Override
public boolean isChecked() {
- return mBackend.getEnabledComplications().containsAll(mBackend.getSupportedComplications());
+ return mBackend.getComplicationsEnabled();
}
@Override
public boolean setChecked(boolean isChecked) {
- for (int complication : mBackend.getSupportedComplications()) {
- mBackend.setComplicationEnabled(complication, isChecked);
- }
+ mBackend.setComplicationsEnabled(isChecked);
return true;
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
index ea493a3..95145ba 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
@@ -31,7 +31,6 @@
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.fuelgauge.EstimateKt;
import com.android.settingslib.utils.AsyncLoaderCompat;
@@ -67,16 +66,14 @@
final BatteryTipPolicy policy = new BatteryTipPolicy(getContext());
final BatteryInfo batteryInfo = mBatteryUtils.getBatteryInfo(TAG);
final Context context = getContext();
- final boolean extraDefend = FeatureFactory.getFactory(context)
- .getPowerUsageFeatureProvider(context)
- .isExtraDefend();
tips.add(new LowBatteryDetector(context, policy, batteryInfo).detect());
tips.add(new HighUsageDetector(context, policy, mBatteryUsageStats, batteryInfo).detect());
tips.add(new SmartBatteryDetector(
context, policy, batteryInfo, context.getContentResolver()).detect());
tips.add(new EarlyWarningDetector(policy, context).detect());
- tips.add(new BatteryDefenderDetector(batteryInfo, extraDefend).detect());
+ tips.add(new BatteryDefenderDetector(
+ batteryInfo, context.getApplicationContext()).detect());
Collections.sort(tips);
return tips;
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java
index 367b2b1..87d4a0b 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java
@@ -16,28 +16,33 @@
package com.android.settings.fuelgauge.batterytip.detectors;
+import android.content.Context;
+
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.batterytip.tips.BatteryDefenderTip;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
+import com.android.settings.overlay.FeatureFactory;
/**
* Detect whether the battery is overheated
*/
public class BatteryDefenderDetector implements BatteryTipDetector {
private final BatteryInfo mBatteryInfo;
- private final boolean mExtraDefend;
+ private final Context mContext;
- public BatteryDefenderDetector(BatteryInfo batteryInfo, boolean extraDefend) {
+ public BatteryDefenderDetector(BatteryInfo batteryInfo, Context context) {
mBatteryInfo = batteryInfo;
- mExtraDefend = extraDefend;
+ mContext = context;
}
@Override
public BatteryTip detect() {
- final int state =
- mBatteryInfo.isOverheated
- ? BatteryTip.StateType.NEW
- : BatteryTip.StateType.INVISIBLE;
- return new BatteryDefenderTip(state, mExtraDefend);
+ if (mBatteryInfo.isOverheated) {
+ final boolean extraDefend = FeatureFactory.getFactory(mContext)
+ .getPowerUsageFeatureProvider(mContext)
+ .isExtraDefend();
+ return new BatteryDefenderTip(BatteryTip.StateType.NEW, extraDefend);
+ }
+ return new BatteryDefenderTip(BatteryTip.StateType.INVISIBLE);
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
index 0a133bb..5c0fc58 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
@@ -108,7 +108,7 @@
});
cardPreference.setPrimaryButtonVisible(isPluggedIn(context));
- cardPreference.setSecondaryButtonText(context.getString(R.string.see_more));
+ cardPreference.setSecondaryButtonText(context.getString(R.string.learn_more));
cardPreference.setSecondaryButtonClickListener(unused -> cardPreference.performClick());
cardPreference.setSecondaryButtonVisible(true);
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
index e2553ad..45ae8c5 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
@@ -65,7 +65,10 @@
private static final String TAG = "BatteryChartPreferenceController";
private static final String KEY_FOOTER_PREF = "battery_graph_footer";
private static final String PACKAGE_NAME_NONE = "none";
+ private static final int ENABLED_ICON_ALPHA = 255;
+ private static final int DISABLED_ICON_ALPHA = 255 / 3;
+ private static final long FADE_ANIMATION_DURATION = 350L;
private static final long VALID_USAGE_TIME_DURATION = DateUtils.HOUR_IN_MILLIS * 2;
private static final long VALID_DIFF_DURATION = DateUtils.MINUTE_IN_MILLIS * 3;
@@ -102,6 +105,7 @@
private boolean mIs24HourFormat;
private boolean mIsFooterPrefAdded = false;
+ private View mBatteryChartViewGroup;
private PreferenceScreen mPreferenceScreen;
private FooterPreference mFooterPreference;
// Daily view model only saves abbreviated day of week texts (e.g. MON). This field saves the
@@ -202,7 +206,7 @@
mPrefContext = screen.getContext();
mAppListPrefGroup = screen.findPreference(mPreferenceKey);
mAppListPrefGroup.setOrderingAsAdded(false);
- mAppListPrefGroup.setTitle(mPrefContext.getString(R.string.battery_app_usage));
+ mAppListPrefGroup.setTitle("");
mFooterPreference = screen.findPreference(KEY_FOOTER_PREF);
// Removes footer first until usage data is loaded to avoid flashing.
if (mFooterPreference != null) {
@@ -260,6 +264,8 @@
final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
Log.d(TAG, "setBatteryHistoryMap() " + (batteryHistoryMap == null ? "null"
: ("size=" + batteryHistoryMap.size())));
+ // Ensure the battery chart group is visible for users.
+ animateBatteryChartViewGroup();
final BatteryLevelData batteryLevelData =
DataProcessor.getBatteryLevelData(mContext, mHandler, batteryHistoryMap,
batteryUsageMap -> {
@@ -302,8 +308,13 @@
void setBatteryChartView(@NonNull final BatteryChartView dailyChartView,
@NonNull final BatteryChartView hourlyChartView) {
+ final View parentView = (View) dailyChartView.getParent();
+ if (parentView != null && parentView.getId() == R.id.battery_chart_group) {
+ mBatteryChartViewGroup = (View) dailyChartView.getParent();
+ }
if (mDailyChartView != dailyChartView || mHourlyChartView != hourlyChartView) {
mHandler.post(() -> setBatteryChartViewInner(dailyChartView, hourlyChartView));
+ animateBatteryChartViewGroup();
}
}
@@ -463,6 +474,7 @@
if (!isAdded) {
mAppListPrefGroup.addPreference(pref);
}
+ appIcon.setAlpha(pref.isEnabled() ? ENABLED_ICON_ALPHA : DISABLED_ICON_ALPHA);
prefIndex++;
}
}
@@ -612,6 +624,13 @@
return !DataProcessor.contains(packageName, mNotAllowShowSummaryPackages);
}
+ private void animateBatteryChartViewGroup() {
+ if (mBatteryChartViewGroup != null && mBatteryChartViewGroup.getAlpha() == 0) {
+ mBatteryChartViewGroup.animate().alpha(1f).setDuration(FADE_ANIMATION_DURATION)
+ .start();
+ }
+ }
+
private void addFooterPreferenceIfNeeded(boolean containAppItems) {
if (mIsFooterPrefAdded || mFooterPreference == null) {
return;
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java
index 24d6dad..ccb2fb7 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java
@@ -574,7 +574,7 @@
break;
case BatteryConsumer.POWER_COMPONENT_BLUETOOTH:
name = context.getResources().getString(R.string.power_bluetooth);
- iconId = com.android.internal.R.drawable.ic_settings_bluetooth;
+ iconId = R.drawable.ic_settings_bluetooth;
break;
case BatteryConsumer.POWER_COMPONENT_CAMERA:
name = context.getResources().getString(R.string.power_camera);
@@ -598,7 +598,7 @@
break;
case BatteryConsumer.POWER_COMPONENT_WIFI:
name = context.getResources().getString(R.string.power_wifi);
- iconId = R.drawable.ic_settings_wireless;
+ iconId = R.drawable.ic_settings_wireless_no_theme;
break;
case BatteryConsumer.POWER_COMPONENT_IDLE:
case BatteryConsumer.POWER_COMPONENT_MEMORY:
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryHistoryPreference.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryHistoryPreference.java
index 71fd26c..6748223 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryHistoryPreference.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryHistoryPreference.java
@@ -106,12 +106,11 @@
return;
}
if (mIsChartGraphEnabled) {
+ final TextView companionTextView = (TextView) view.findViewById(R.id.companion_text);
mDailyChartView = (BatteryChartView) view.findViewById(R.id.daily_battery_chart);
- mDailyChartView.setCompanionTextView(
- (TextView) view.findViewById(R.id.companion_text));
+ mDailyChartView.setCompanionTextView(companionTextView);
mHourlyChartView = (BatteryChartView) view.findViewById(R.id.hourly_battery_chart);
- mHourlyChartView.setCompanionTextView(
- (TextView) view.findViewById(R.id.companion_text));
+ mHourlyChartView.setCompanionTextView(companionTextView);
if (mChartPreferenceController != null) {
mChartPreferenceController.setBatteryChartView(mDailyChartView, mHourlyChartView);
}
diff --git a/src/com/android/settings/notification/NotificationAssistantPreferenceController.java b/src/com/android/settings/notification/NotificationAssistantPreferenceController.java
index e8a66b6..e17d71f 100644
--- a/src/com/android/settings/notification/NotificationAssistantPreferenceController.java
+++ b/src/com/android/settings/notification/NotificationAssistantPreferenceController.java
@@ -18,34 +18,48 @@
import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
+import android.service.notification.NotificationAssistantService;
import androidx.fragment.app.Fragment;
+import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
+import com.android.settingslib.PrimarySwitchPreference;
import com.google.common.annotations.VisibleForTesting;
+import java.util.List;
+
public class NotificationAssistantPreferenceController extends TogglePreferenceController {
private static final String TAG = "NASPreferenceController";
- private static final String KEY_NAS = "notification_assistant";
+ static final String KEY_NAS = "notification_assistant";
private final UserManager mUserManager;
+ private final PackageManager mPackageManager;
private Fragment mFragment;
private int mUserId = UserHandle.myUserId();
@VisibleForTesting
protected NotificationBackend mNotificationBackend;
+ private ComponentName mDefaultNASComponent;
+ private Intent mNASSettingIntent;
public NotificationAssistantPreferenceController(Context context) {
super(context, KEY_NAS);
mUserManager = UserManager.get(context);
mNotificationBackend = new NotificationBackend();
+ mPackageManager = context.getPackageManager();
+ getDefaultNASIntent();
}
+
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
@@ -54,14 +68,13 @@
@Override
public boolean isChecked() {
ComponentName acn = mNotificationBackend.getAllowedNotificationAssistant();
- ComponentName dcn = mNotificationBackend.getDefaultNotificationAssistant();
- return (acn != null && acn.equals(dcn));
+ return (acn != null && acn.equals(mDefaultNASComponent));
}
@Override
public boolean setChecked(boolean isChecked) {
ComponentName cn = isChecked
- ? mNotificationBackend.getDefaultNotificationAssistant() : null;
+ ? mDefaultNASComponent : null;
if (isChecked) {
if (mFragment == null) {
throw new IllegalStateException("No fragment to start activity");
@@ -102,8 +115,43 @@
mNotificationBackend = backend;
}
+ @VisibleForTesting
+ void getDefaultNASIntent() {
+ mDefaultNASComponent = mNotificationBackend.getDefaultNotificationAssistant();
+ if (mDefaultNASComponent != null) {
+ mNASSettingIntent = new Intent(
+ NotificationAssistantService.ACTION_NOTIFICATION_ASSISTANT_DETAIL_SETTINGS);
+ mNASSettingIntent.setPackage(mDefaultNASComponent.getPackageName());
+ mNASSettingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ }
+ }
+
@Override
public boolean isSliceable() {
return (mFragment != null && mFragment instanceof ConfigureNotificationSettings);
}
+
+ private boolean isNASSettingActivityAvailable() {
+ final List<ResolveInfo> resolved = mPackageManager.queryIntentActivities(mNASSettingIntent,
+ PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_ALL));
+ return (resolved != null && !resolved.isEmpty());
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ if (isNASSettingActivityAvailable()) {
+ preference.setIntent(mNASSettingIntent);
+ } else {
+ // Cannot find settings activity from the default NAS app
+ preference.setIntent(null);
+ preference.setOnPreferenceClickListener(
+ preference1 -> {
+ onPreferenceChange(preference1, !isChecked());
+ ((PrimarySwitchPreference) preference1).setChecked(isChecked());
+ return true;
+ }
+ );
+ }
+ }
}
diff --git a/src/com/android/settings/overlay/SurveyFeatureProvider.java b/src/com/android/settings/overlay/SurveyFeatureProvider.java
index 44ee525..ce5be98 100644
--- a/src/com/android/settings/overlay/SurveyFeatureProvider.java
+++ b/src/com/android/settings/overlay/SurveyFeatureProvider.java
@@ -26,14 +26,15 @@
* An interface for classes wishing to provide the ability to serve surveys to implement.
*/
public interface SurveyFeatureProvider {
-
/**
* Downloads a survey asynchronously to shared preferences to be served at a later date.
*
* @param activity A valid context.
* @param surveyId A unique Id representing a survey to download.
- * @param data a text blob to be attached to the survey results.
+ * @param data a text blob to be attached to the survey results.
+ * @deprecated This is not used after T.
*/
+ @Deprecated
void downloadSurvey(Activity activity, String surveyId, @Nullable String data);
/**
@@ -42,17 +43,21 @@
* @param activity The host activity to show the survey in.
* @param surveyId A unique Id representing a survey to download.
* @return A boolean indicating if a survey was shown or not.
+ * @deprecated This is not used after T.
*/
+ @Deprecated
boolean showSurveyIfAvailable(Activity activity, String surveyId);
/**
* A helper method to get the surveyId. Implementers should create a mapping of
* keys to surveyIds and provide them via this function.
*
- * @param context A valid context.
+ * @param context A valid context.
* @param simpleKey The simple name of the key to get the surveyId for.
* @return The unique Id as a string or null on error.
+ * @deprecated This is not used after T.
*/
+ @Deprecated
String getSurveyId(Context context, String simpleKey);
/**
@@ -60,28 +65,36 @@
* unix timestamp) for the remaining survey should it exist and be ready to show. Returns -1 if
* no valid survey exists after removing the potentially expired one.
*
- * @param context the calling context.
+ * @param context the calling context.
* @param surveyId the site ID.
* @return the unix timestamp for the available survey for the given {@coe siteId} or -1 if
* there is none available.
+ * @deprecated This is not used after T.
*/
+ @Deprecated
long getSurveyExpirationDate(Context context, String surveyId);
/**
* Registers an activity to show surveys/prompts as soon as they are downloaded. The receiver
* should be unregistered prior to destroying the activity to avoid undefined behavior by
* calling {@link #unregisterReceiver(Activity, BroadcastReceiver)}.
+ *
* @param activity The activity that should show surveys once they are downloaded.
* @return the broadcast receiver listening for survey downloads. Must be unregistered before
* leaving the activity.
+ * @deprecated This is not used after T.
*/
+ @Deprecated
BroadcastReceiver createAndRegisterReceiver(Activity activity);
/**
* Unregisters the broadcast receiver for this activity. Should only be called once per activity
* after a call to {@link #createAndRegisterReceiver(Activity)}.
+ *
* @param activity The activity that was used to register the BroadcastReceiver.
+ * @deprecated This is not used after T.
*/
+ @Deprecated
static void unregisterReceiver(Activity activity, BroadcastReceiver receiver) {
if (activity == null) {
throw new IllegalStateException("Cannot unregister receiver if activity is null");
@@ -89,4 +102,11 @@
LocalBroadcastManager.getInstance(activity).unregisterReceiver(receiver);
}
+
+ /**
+ * Send the visited activity to the place where it will trigger a survey if possible.
+ *
+ * @param simpleKey The simple name of the key to get the surveyId for.
+ */
+ void sendActivityIfAvailable(String simpleKey);
}
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index 732277b..9c4f8f1 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -65,6 +65,8 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ SimDialogProhibitService.supportDismiss(this);
+
getWindow().addSystemFlags(
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
showOrUpdateDialog();
@@ -225,4 +227,15 @@
}
return null;
}
+
+ /*
+ * Force dismiss this Activity.
+ */
+ protected void forceClose() {
+ if (isFinishing() || isDestroyed()) {
+ return;
+ }
+ Log.d(TAG, "Dismissed by Service");
+ finishAndRemoveTask();
+ }
}
diff --git a/src/com/android/settings/sim/SimDialogProhibitService.java b/src/com/android/settings/sim/SimDialogProhibitService.java
new file mode 100644
index 0000000..1558fb3
--- /dev/null
+++ b/src/com/android/settings/sim/SimDialogProhibitService.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2022 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.sim;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import java.lang.ref.WeakReference;
+import java.util.concurrent.RejectedExecutionException;
+
+/**
+ * A class for routing dismiss dialog request to SimDialogActivity.
+ */
+public class SimDialogProhibitService {
+
+ private static final String TAG = "SimDialogProhibitService";
+
+ private static WeakReference<SimDialogActivity> sSimDialogActivity;
+
+ /**
+ * Support the dismiss of {@link SimDialogActivity} (singletone.)
+ *
+ * @param activity {@link SimDialogActivity}
+ */
+ public static void supportDismiss(SimDialogActivity activity) {
+ sSimDialogActivity = new WeakReference<SimDialogActivity>(activity);
+ }
+
+ /**
+ * Dismiss SimDialogActivity dialog.
+ *
+ * @param context is a {@link Context}
+ */
+ public static void dismissDialog(Context context) {
+ // Dismiss existing dialog.
+ if (!dismissDialogThroughRunnable()) {
+ dismissDialogThroughIntent(context);
+ }
+ }
+
+ /**
+ * Dismiss dialog (if there's any).
+ *
+ * @return {@code true} when success, {@code false} when failure.
+ */
+ protected static boolean dismissDialogThroughRunnable() {
+ final SimDialogActivity activity = (sSimDialogActivity == null) ?
+ null : sSimDialogActivity.get();
+ if (activity == null) {
+ Log.i(TAG, "No SimDialogActivity for dismiss.");
+ return true;
+ }
+
+ try {
+ activity.getMainExecutor().execute(() -> activity.forceClose());
+ return true;
+ } catch (RejectedExecutionException exception) {
+ Log.w(TAG, "Fail to close SimDialogActivity through executor", exception);
+ }
+ return false;
+ }
+
+ /**
+ * Dismiss dialog through {@link Intent}.
+ *
+ * @param uiContext is {@link Context} for start SimDialogActivity.
+ */
+ protected static void dismissDialogThroughIntent(Context uiContext) {
+ Intent newIntent = new Intent(uiContext, SimDialogActivity.class);
+ newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ newIntent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.PICK_DISMISS);
+ uiContext.startActivity(newIntent);
+ }
+}
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 5902b92..9d3f860 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -164,10 +164,7 @@
// If the dialog type is to dismiss.
if (dialogType == EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS) {
- Intent newIntent = new Intent(context, SimDialogActivity.class);
- newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- newIntent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, PICK_DISMISS);
- context.startActivity(newIntent);
+ SimDialogProhibitService.dismissDialog(context);
return;
}
diff --git a/src/com/android/settings/sound/MediaControlsLockScreenPreferenceController.java b/src/com/android/settings/sound/MediaControlsLockScreenPreferenceController.java
new file mode 100644
index 0000000..009ab2e
--- /dev/null
+++ b/src/com/android/settings/sound/MediaControlsLockScreenPreferenceController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.sound;
+
+import static android.provider.Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Toggle for media control resumption on lock screen.
+ */
+public class MediaControlsLockScreenPreferenceController extends TogglePreferenceController {
+ public MediaControlsLockScreenPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ int val = Settings.Secure.getInt(mContext.getContentResolver(),
+ MEDIA_CONTROLS_LOCK_SCREEN, 1);
+ return val == 1;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ int val = isChecked ? 1 : 0;
+ return Settings.Secure.putInt(mContext.getContentResolver(),
+ MEDIA_CONTROLS_LOCK_SCREEN, val);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_sound;
+ }
+}
diff --git a/src/com/android/settings/survey/SurveyMixin.java b/src/com/android/settings/survey/SurveyMixin.java
index 5de2653..2f68de6 100644
--- a/src/com/android/settings/survey/SurveyMixin.java
+++ b/src/com/android/settings/survey/SurveyMixin.java
@@ -16,14 +16,12 @@
package com.android.settings.survey;
import android.app.Activity;
-import android.content.BroadcastReceiver;
import androidx.fragment.app.Fragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SurveyFeatureProvider;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume;
/**
@@ -31,17 +29,17 @@
* in settings. This allows new classes to automatically support settings provided the extend
* one of the relevant classes in com.android.settings.lifecycle.
*/
-public class SurveyMixin implements LifecycleObserver, OnResume, OnPause {
+public class SurveyMixin implements LifecycleObserver, OnResume {
private String mName;
private Fragment mFragment;
- private BroadcastReceiver mReceiver;
/**
* A mixin that attempts to perform survey related tasks right before onResume is called
* in a Settings PreferenceFragment. This will allow for remote updating and creation of
* surveys.
- * @param fragment The fragment that this mixin will be attached to.
+ *
+ * @param fragment The fragment that this mixin will be attached to.
* @param fragmentName The simple name of the fragment.
*/
public SurveyMixin(Fragment fragment, String fragmentName) {
@@ -53,31 +51,13 @@
public void onResume() {
Activity activity = mFragment.getActivity();
- // guard against the activity not existing yet or the feature being disabled
+ // guard against the activity not existing yet
if (activity != null) {
SurveyFeatureProvider provider =
FeatureFactory.getFactory(activity).getSurveyFeatureProvider(activity);
if (provider != null) {
-
- // Try to download a survey if there is none available, show the survey otherwise
- String id = provider.getSurveyId(activity, mName);
- if (provider.getSurveyExpirationDate(activity, id) <= -1) {
- // register the receiver to show the survey on completion.
- mReceiver = provider.createAndRegisterReceiver(activity);
- provider.downloadSurvey(activity, id, null /* data */);
- } else {
- provider.showSurveyIfAvailable(activity, id);
- }
+ provider.sendActivityIfAvailable(mName);
}
}
}
-
- @Override
- public void onPause() {
- Activity activity = mFragment.getActivity();
- if (mReceiver != null && activity != null) {
- SurveyFeatureProvider.unregisterReceiver(activity, mReceiver);
- mReceiver = null;
- }
- }
}
diff --git a/src/com/android/settings/users/RemoveGuestOnExitPreferenceController.java b/src/com/android/settings/users/RemoveGuestOnExitPreferenceController.java
index 182494c..01df5fd 100644
--- a/src/com/android/settings/users/RemoveGuestOnExitPreferenceController.java
+++ b/src/com/android/settings/users/RemoveGuestOnExitPreferenceController.java
@@ -24,7 +24,6 @@
import android.os.Handler;
import android.os.UserManager;
import android.provider.Settings;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
@@ -87,9 +86,7 @@
|| !UserManager.isGuestUserAllowEphemeralStateChange()
|| !mUserCaps.isAdmin()
|| mUserCaps.disallowAddUser()
- || mUserCaps.disallowAddUserSetByAdmin()
- || !FeatureFlagUtils.isEnabled(mContext,
- FeatureFlagUtils.SETTINGS_GUEST_MODE_UX_CHANGES)) {
+ || mUserCaps.disallowAddUserSetByAdmin()) {
return DISABLED_FOR_USER;
} else {
return mUserCaps.mUserSwitcherEnabled ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 5b2729a..274d40a 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -49,7 +49,6 @@
import android.provider.ContactsContract;
import android.provider.Settings;
import android.text.TextUtils;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
@@ -490,11 +489,6 @@
updateUserList();
}
- private boolean isEnableGuestModeUxChanges() {
- return FeatureFlagUtils.isEnabled(getContext(),
- FeatureFlagUtils.SETTINGS_GUEST_MODE_UX_CHANGES);
- }
-
/**
* Loads profile information for the current user.
*/
@@ -1362,33 +1356,25 @@
}
mGuestCategory.setVisible(true);
mGuestExitPreference.setVisible(true);
- if (isEnableGuestModeUxChanges()) {
- mGuestResetPreference.setVisible(true);
+ mGuestResetPreference.setVisible(true);
- boolean isGuestFirstLogin = Settings.Secure.getIntForUser(
- getContext().getContentResolver(),
- SETTING_GUEST_HAS_LOGGED_IN,
- 0,
- UserHandle.myUserId()) <= 1;
- String guestExitSummary;
- if (mUserCaps.mIsEphemeral) {
- guestExitSummary = getContext().getString(
- R.string.guest_notification_ephemeral);
- } else if (isGuestFirstLogin) {
- guestExitSummary = getContext().getString(
- R.string.guest_notification_non_ephemeral);
- } else {
- guestExitSummary = getContext().getString(
- R.string.guest_notification_non_ephemeral_non_first_login);
- }
- mGuestExitPreference.setSummary(guestExitSummary);
+ boolean isGuestFirstLogin = Settings.Secure.getIntForUser(
+ getContext().getContentResolver(),
+ SETTING_GUEST_HAS_LOGGED_IN,
+ 0,
+ UserHandle.myUserId()) <= 1;
+ String guestExitSummary;
+ if (mUserCaps.mIsEphemeral) {
+ guestExitSummary = getContext().getString(
+ R.string.guest_notification_ephemeral);
+ } else if (isGuestFirstLogin) {
+ guestExitSummary = getContext().getString(
+ R.string.guest_notification_non_ephemeral);
} else {
- mGuestExitPreference.setIcon(getEncircledDefaultIcon());
- mGuestExitPreference.setTitle(
- mGuestUserAutoCreated
- ? com.android.settingslib.R.string.guest_reset_guest
- : com.android.settingslib.R.string.guest_exit_guest);
+ guestExitSummary = getContext().getString(
+ R.string.guest_notification_non_ephemeral_non_first_login);
}
+ mGuestExitPreference.setSummary(guestExitSummary);
}
private void updateGuestCategory(Context context, List<UserInfo> users) {
@@ -1417,16 +1403,12 @@
pref.setOnPreferenceClickListener(this);
pref.setEnabled(canOpenUserDetails);
pref.setSelectable(true);
- if (isEnableGuestModeUxChanges()) {
- Drawable icon = getContext().getDrawable(R.drawable.ic_account_circle_outline);
- icon.setTint(
- getColorAttrDefaultColor(getContext(), android.R.attr.colorControlNormal));
- pref.setIcon(encircleUserIcon(
- UserIcons.convertToBitmapAtUserIconSize(
- getContext().getResources(), icon)));
- } else {
- pref.setIcon(getEncircledDefaultIcon());
- }
+ Drawable icon = getContext().getDrawable(R.drawable.ic_account_circle_outline);
+ icon.setTint(
+ getColorAttrDefaultColor(getContext(), android.R.attr.colorControlNormal));
+ pref.setIcon(encircleUserIcon(
+ UserIcons.convertToBitmapAtUserIconSize(
+ getContext().getResources(), icon)));
pref.setKey(KEY_USER_GUEST);
pref.setOrder(Preference.DEFAULT_ORDER);
if (mUserCaps.mDisallowSwitchUser) {
@@ -1468,13 +1450,6 @@
&& mUserCaps.mUserSwitcherEnabled) {
isVisible = true;
mAddGuest.setVisible(true);
- // when isEnableGuestModeUxChanges() is true, the icon is set via the layout xml
- // In com.android.settings.users.UserSettingsTest
- // we disable the check for setIcon being called
- if (!isEnableGuestModeUxChanges()) {
- Drawable icon = context.getDrawable(R.drawable.ic_account_circle);
- mAddGuest.setIcon(centerAndTint(icon));
- }
mAddGuest.setSelectable(true);
if (mGuestUserAutoCreated && mGuestCreationScheduled.get()) {
mAddGuest.setTitle(com.android.internal.R.string.guest_name);
@@ -1492,21 +1467,11 @@
private void updateAddUser(Context context) {
updateAddUserCommon(context, mAddUser, mUserCaps.mCanAddRestrictedProfile);
- // when isEnableGuestModeUxChanges() is true, the icon is set via the layout xml
- if (!isEnableGuestModeUxChanges()) {
- Drawable icon = context.getDrawable(R.drawable.ic_account_circle_filled);
- mAddUser.setIcon(centerAndTint(icon));
- }
}
private void updateAddSupervisedUser(Context context) {
if (!TextUtils.isEmpty(mConfigSupervisedUserCreationPackage)) {
updateAddUserCommon(context, mAddSupervisedUser, false);
- // when isEnableGuestModeUxChanges() is true, the icon is set via the layout xml
- if (!isEnableGuestModeUxChanges()) {
- Drawable icon = context.getDrawable(R.drawable.ic_add_supervised_user);
- mAddSupervisedUser.setIcon(centerAndTint(icon));
- }
} else {
mAddSupervisedUser.setVisible(false);
}
@@ -1603,28 +1568,17 @@
@Override
public boolean onPreferenceClick(Preference pref) {
if (isCurrentUserGuest()) {
- if (isEnableGuestModeUxChanges()) {
- if (mGuestResetPreference != null && pref == mGuestResetPreference) {
- showDialog(DIALOG_CONFIRM_RESET_AND_RESTART_GUEST);
- return true;
+ if (mGuestResetPreference != null && pref == mGuestResetPreference) {
+ showDialog(DIALOG_CONFIRM_RESET_AND_RESTART_GUEST);
+ return true;
+ }
+ if (mGuestExitPreference != null && pref == mGuestExitPreference) {
+ if (mUserCaps.mIsEphemeral) {
+ showDialog(DIALOG_CONFIRM_EXIT_GUEST_EPHEMERAL);
+ } else {
+ showDialog(DIALOG_CONFIRM_EXIT_GUEST_NON_EPHEMERAL);
}
- if (mGuestExitPreference != null && pref == mGuestExitPreference) {
- if (mUserCaps.mIsEphemeral) {
- showDialog(DIALOG_CONFIRM_EXIT_GUEST_EPHEMERAL);
- } else {
- showDialog(DIALOG_CONFIRM_EXIT_GUEST_NON_EPHEMERAL);
- }
- return true;
- }
- } else {
- if (mGuestExitPreference != null && pref == mGuestExitPreference) {
- if (mGuestUserAutoCreated) {
- showDialog(DIALOG_CONFIRM_REMOVE_GUEST_WITH_AUTO_CREATE);
- } else {
- showDialog(DIALOG_CONFIRM_REMOVE_GUEST);
- }
- return true;
- }
+ return true;
}
}
if (pref == mMePreference) {
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
index a78dbb1..49a16cb 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensorTest.java
@@ -16,11 +16,15 @@
package com.android.settings.biometrics.fingerprint;
+import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_REAR;
+import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
+
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.robolectric.RuntimeEnvironment.application;
@@ -28,9 +32,14 @@
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
+import android.hardware.biometrics.ComponentInfoInternal;
+import android.hardware.biometrics.SensorProperties;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintManager.EnrollmentCallback;
+import android.hardware.fingerprint.FingerprintSensorProperties;
+import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.os.CancellationSignal;
+import android.view.View;
import com.android.settings.R;
import com.android.settings.biometrics.BiometricEnrollBase;
@@ -40,6 +49,8 @@
import com.google.android.setupcompat.PartnerCustomizationLayout;
import com.google.android.setupcompat.template.FooterBarMixin;
+import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupdesign.GlifLayout;
import org.junit.After;
import org.junit.Before;
@@ -51,17 +62,24 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
+import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowActivity;
import org.robolectric.shadows.ShadowActivity.IntentForResult;
+import java.util.ArrayList;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowUtils.class)
public class FingerprintEnrollFindSensorTest {
+ private static final int DEFAULT_ACTIVITY_RESULT = Activity.RESULT_CANCELED;
+
@Mock
private FingerprintManager mFingerprintManager;
+ private ActivityController<FingerprintEnrollFindSensor> mActivityController;
+
private FingerprintEnrollFindSensor mActivity;
@Before
@@ -70,12 +88,40 @@
ShadowUtils.setFingerprintManager(mFingerprintManager);
FakeFeatureFactory.setupForTest();
- mActivity = Robolectric.buildActivity(
+ mActivityController = Robolectric.buildActivity(
FingerprintEnrollFindSensor.class,
new Intent()
// Set the challenge token so the confirm screen will not be shown
- .putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]))
- .setup().get();
+ .putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0])
+ );
+ mActivity = mActivityController.get();
+ }
+
+ private void setupActivity_onRearDevice() {
+ final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
+ props.add(newFingerprintSensorPropertiesInternal(TYPE_REAR));
+ doReturn(props).when(mFingerprintManager).getSensorPropertiesInternal();
+
+ mActivityController.setup();
+ }
+
+ private void setupActivity_onUdfpsDevice() {
+ final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
+ props.add(newFingerprintSensorPropertiesInternal(TYPE_UDFPS_OPTICAL));
+ doReturn(props).when(mFingerprintManager).getSensorPropertiesInternal();
+
+ mActivityController.setup();
+ }
+
+ private FingerprintSensorPropertiesInternal newFingerprintSensorPropertiesInternal(
+ @FingerprintSensorProperties.SensorType int sensorType) {
+ return new FingerprintSensorPropertiesInternal(
+ 0 /* sensorId */,
+ SensorProperties.STRENGTH_STRONG,
+ 1 /* maxEnrollmentsPerUser */,
+ new ArrayList<ComponentInfoInternal>(),
+ sensorType,
+ true /* resetLockoutRequiresHardwareAuthToken */);
}
@After
@@ -83,13 +129,7 @@
ShadowUtils.reset();
}
- @Test
- public void enrollFingerprint_shouldProceed() {
- EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
-
- enrollmentCallback.onEnrollmentProgress(123);
- enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
-
+ private void verifyStartEnrollingActivity() {
ShadowActivity shadowActivity = Shadows.shadowOf(mActivity);
IntentForResult startedActivity =
shadowActivity.getNextStartedActivityForResult();
@@ -100,6 +140,7 @@
@Test
public void enrollFingerprintTwice_shouldStartOneEnrolling() {
+ setupActivity_onRearDevice();
EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
enrollmentCallback.onEnrollmentProgress(123);
@@ -123,6 +164,8 @@
@Config(qualifiers = "mcc999")
@Test
public void layoutWithoutAnimation_shouldNotCrash() {
+ setupActivity_onRearDevice();
+
EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
enrollmentCallback.onEnrollmentProgress(123);
enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
@@ -137,6 +180,8 @@
@Test
public void clickSkip_shouldReturnResultSkip() {
+ setupActivity_onRearDevice();
+
PartnerCustomizationLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
layout.getMixin(FooterBarMixin.class).getSecondaryButtonView().performClick();
@@ -160,6 +205,8 @@
@Test
public void onActivityResult_withNullIntentShouldNotCrash() {
+ setupActivity_onRearDevice();
+
// this should not crash
mActivity.onActivityResult(BiometricEnrollBase.CONFIRM_REQUEST, Activity.RESULT_OK,
null);
@@ -167,74 +214,159 @@
}
@Test
- public void onActivityResult_EnrollRequestResultFinishShallBeSentBack() {
- final int defaultActivityResult = Shadows.shadowOf(mActivity).getResultCode();
-
- // Start enrolling
- EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
- enrollmentCallback.onEnrollmentProgress(123);
- enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
+ public void enrollingFinishResultShallSentBack_onRearDevice() {
+ setupActivity_onRearDevice();
+ triggerEnrollProgressAndError_onRearDevice();
+ verifyStartEnrollingActivity();
// onStop shall not change default activity result
- mActivity.onStop();
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(defaultActivityResult);
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
- // onActivityResult from Enrolling activity shall be sent back
- final int testResult = BiometricEnrollBase.RESULT_FINISHED;
- mActivity.onActivityResult(BiometricEnrollBase.ENROLL_REQUEST, testResult, null);
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testResult);
- assertThat(mActivity.isFinishing()).isEqualTo(true);
-
- // onStop shall not change last activity result
- mActivity.onStop();
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testResult);
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_FINISHED);
}
@Test
- public void onActivityResult_EnrollRequestResultSkipShallBeSentBack() {
- final int defaultActivityResult = Shadows.shadowOf(mActivity).getResultCode();
-
- // Start enrolling
- EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
- enrollmentCallback.onEnrollmentProgress(123);
- enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
+ public void enrollingSkipResultShallSentBack_onRearDevice() {
+ setupActivity_onRearDevice();
+ triggerEnrollProgressAndError_onRearDevice();
+ verifyStartEnrollingActivity();
// onStop shall not change default activity result
- mActivity.onStop();
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(defaultActivityResult);
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
- // onActivityResult from Enrolling activity shall be sent back
- final int testResult = BiometricEnrollBase.RESULT_SKIP;
- mActivity.onActivityResult(BiometricEnrollBase.ENROLL_REQUEST, testResult, null);
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testResult);
- assertThat(mActivity.isFinishing()).isEqualTo(true);
-
- // onStop shall not change last activity result
- mActivity.onStop();
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testResult);
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_SKIP);
}
@Test
- public void onActivityResult_EnrollRequestResultTimeoutShallBeSentBack() {
- final int defaultActivityResult = Shadows.shadowOf(mActivity).getResultCode();
+ public void enrollingTimeoutResultShallSentBack_onRearDevice() {
+ setupActivity_onRearDevice();
+ triggerEnrollProgressAndError_onRearDevice();
+ verifyStartEnrollingActivity();
- // Start enrolling
+ // onStop shall not change default activity result
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_TIMEOUT);
+ }
+
+ @Test
+ public void enrollingFinishResultShallSentBack_onUdfpsDevice_triggeredByLottieClick() {
+ setupActivity_onUdfpsDevice();
+ clickLottieView_onUdfpsDevice();
+ verifyStartEnrollingActivity();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ // onStop shall not change default activity result
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_FINISHED);
+ }
+
+ @Test
+ public void enrollingSkipResultShallSentBack_onUdfpsDevice_triggeredByLottieClick() {
+ setupActivity_onUdfpsDevice();
+ clickLottieView_onUdfpsDevice();
+ verifyStartEnrollingActivity();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ // onStop shall not change default activity result
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_SKIP);
+ }
+
+ @Test
+ public void enrollingTimeoutResultShallSentBack_onUdfpsDevice_triggeredByLottieClick() {
+ setupActivity_onUdfpsDevice();
+ clickLottieView_onUdfpsDevice();
+ verifyStartEnrollingActivity();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ // onStop shall not change default activity result
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_TIMEOUT);
+ }
+
+ @Test
+ public void enrollingFinishResultShallSentBack_onUdfpsDevice_triggeredByPrimaryButtonClick() {
+ setupActivity_onUdfpsDevice();
+ clickPrimaryButton_onUdfpsDevice();
+ verifyStartEnrollingActivity();
+
+ // onStop shall not change default activity result
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_FINISHED);
+ }
+
+ @Test
+ public void enrollingSkipResultShallSentBack_onUdfpsDevice_triggeredByPrimaryButtonClick() {
+ setupActivity_onUdfpsDevice();
+ clickPrimaryButton_onUdfpsDevice();
+ verifyStartEnrollingActivity();
+
+ // onStop shall not change default activity result
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_SKIP);
+ }
+
+ @Test
+ public void enrollingTimeoutResultShallSentBack_onUdfpsDevice_triggeredByPrimaryButtonClick() {
+ setupActivity_onUdfpsDevice();
+ clickPrimaryButton_onUdfpsDevice();
+ verifyStartEnrollingActivity();
+
+ // onStop shall not change default activity result
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(DEFAULT_ACTIVITY_RESULT);
+
+ gotEnrollingResult_verifyResultSentBack(BiometricEnrollBase.RESULT_TIMEOUT);
+ }
+
+ private void triggerEnrollProgressAndError_onRearDevice() {
EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
enrollmentCallback.onEnrollmentProgress(123);
enrollmentCallback.onEnrollmentError(FingerprintManager.FINGERPRINT_ERROR_CANCELED, "test");
+ }
- // onStop shall not change default activity result
- mActivity.onStop();
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(defaultActivityResult);
+ private void clickPrimaryButton_onUdfpsDevice() {
+ final FooterBarMixin footerBarMixin =
+ ((GlifLayout) mActivity.findViewById(R.id.setup_wizard_layout))
+ .getMixin(FooterBarMixin.class);
+ final FooterButton primaryButton = footerBarMixin.getPrimaryButton();
+ assertThat(primaryButton).isNotNull();
+ assertThat(primaryButton.getVisibility()).isEqualTo(View.VISIBLE);
+ primaryButton.onClick(null);
+ }
+ private void clickLottieView_onUdfpsDevice() {
+ final View lottieView = mActivity.findViewById(R.id.illustration_lottie);
+ assertThat(lottieView).isNotNull();
+ lottieView.performClick();
+ }
+
+ private void gotEnrollingResult_verifyResultSentBack(int testActivityResult) {
// onActivityResult from Enrolling activity shall be sent back
- final int testResult = BiometricEnrollBase.RESULT_TIMEOUT;
- mActivity.onActivityResult(BiometricEnrollBase.ENROLL_REQUEST, testResult, null);
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testResult);
+ mActivityController.start().resume().visible();
+ Shadows.shadowOf(mActivity).receiveResult(
+ new Intent(mActivity, FingerprintEnrollEnrolling.class),
+ testActivityResult,
+ null);
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testActivityResult);
assertThat(mActivity.isFinishing()).isEqualTo(true);
// onStop shall not change last activity result
- mActivity.onStop();
- assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testResult);
+ mActivityController.pause().stop();
+ assertThat(Shadows.shadowOf(mActivity).getResultCode()).isEqualTo(testActivityResult);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetectorTest.java
index 3309f59..90e7ad7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetectorTest.java
@@ -18,6 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.core.app.ApplicationProvider;
+
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
@@ -42,7 +44,7 @@
mBatteryInfo.discharging = false;
mBatteryDefenderDetector = new BatteryDefenderDetector(
- mBatteryInfo, /* extraDefend= */ false);
+ mBatteryInfo, ApplicationProvider.getApplicationContext());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
index c1ec7c6..6bd6b26 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
@@ -125,7 +125,7 @@
@Test
public void updatePreference_shouldSetSecondaryButtonText() {
- String expected = mContext.getString(R.string.see_more);
+ String expected = mContext.getString(R.string.learn_more);
mBatteryDefenderTip.updatePreference(mCardPreference);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java
index 5ca3aca..ffc6d9a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java
@@ -307,7 +307,7 @@
R.drawable.ic_settings_aod);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_BLUETOOTH,
R.string.power_bluetooth,
- com.android.internal.R.drawable.ic_settings_bluetooth);
+ R.drawable.ic_settings_bluetooth);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_CAMERA,
R.string.power_camera,
R.drawable.ic_settings_camera);
@@ -325,7 +325,7 @@
R.drawable.ic_settings_display);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_WIFI,
R.string.power_wifi,
- R.drawable.ic_settings_wireless);
+ R.drawable.ic_settings_wireless_no_theme);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_IDLE,
R.string.power_idle,
R.drawable.ic_settings_phone_idle);
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java
index d130711..b594667 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java
@@ -16,7 +16,12 @@
package com.android.settings.notification;
+import static android.service.notification.NotificationAssistantService.ACTION_NOTIFICATION_ASSISTANT_DETAIL_SETTINGS;
+
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -29,16 +34,24 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.os.UserManager;
import android.provider.Settings;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.testutils.shadow.ShadowSecureSettings;
+import com.android.settingslib.PrimarySwitchPreference;
import org.junit.Before;
import org.junit.Test;
@@ -47,9 +60,13 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
+import java.util.ArrayList;
+import java.util.List;
+
@RunWith(RobolectricTestRunner.class)
public class NotificationAssistantPreferenceControllerTest {
@@ -67,23 +84,48 @@
private NotificationBackend mBackend;
@Mock
private UserManager mUserManager;
+ @Mock
+ private PackageManager mPackageManager;
private NotificationAssistantPreferenceController mPreferenceController;
- ComponentName mNASComponent = new ComponentName("a", "b");
+ ComponentName mNASComponent = new ComponentName("pkgname", "clsname");
+ private PrimarySwitchPreference mPreference;
+ private ShadowApplication mShadowApplication;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
- ShadowApplication.getInstance().setSystemService(Context.USER_SERVICE, mUserManager);
+ mPreference = spy(new PrimarySwitchPreference(mContext));
+ mShadowApplication = ShadowApplication.getInstance();
+ mShadowApplication.setSystemService(Context.USER_SERVICE, mUserManager);
doReturn(mContext).when(mFragment).getContext();
when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
when(mBackend.getDefaultNotificationAssistant()).thenReturn(mNASComponent);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
mPreferenceController = new NotificationAssistantPreferenceController(mContext);
mPreferenceController.setBackend(mBackend);
mPreferenceController.setFragment(mFragment);
+ mPreferenceController.getDefaultNASIntent();
+
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
+ mPreference.setKey(NotificationAssistantPreferenceController.KEY_NAS);
+ screen.addPreference(mPreference);
+ mPreferenceController.displayPreference(screen);
+
when(mUserManager.getProfileIds(eq(0), anyBoolean())).thenReturn(new int[] {0, 10});
when(mUserManager.getProfileIds(eq(20), anyBoolean())).thenReturn(new int[] {20});
+
+ ActivityInfo activityInfo1 = new ActivityInfo();
+ activityInfo1.packageName = "pkgname";
+ activityInfo1.name = "name";
+ ResolveInfo resolveInfo1 = new ResolveInfo();
+ resolveInfo1.activityInfo = activityInfo1;
+ List<ResolveInfo> resolvers1 = new ArrayList<>();
+ resolvers1.add(resolveInfo1);
+ when(mPackageManager.queryIntentActivities(any(Intent.class), any()))
+ .thenReturn(resolvers1);
}
@Test
@@ -109,6 +151,34 @@
}
@Test
+ public void testUpdateState_SettingActivityAvailable() throws Exception {
+ mPreferenceController.updateState(mPreference);
+ assertNotNull(mPreference.getIntent());
+
+ mPreference.performClick();
+ Intent nextIntent = Shadows.shadowOf(
+ (Application) ApplicationProvider.getApplicationContext()).getNextStartedActivity();
+ assertEquals(nextIntent.getAction(), ACTION_NOTIFICATION_ASSISTANT_DETAIL_SETTINGS);
+ }
+
+ @Test
+ public void testUpdateState_SettingActivityUnavailable() throws Exception {
+ when(mPackageManager.queryIntentActivities(any(Intent.class), any()))
+ .thenReturn(null);
+ mPreferenceController.updateState(mPreference);
+ assertNull(mPreference.getIntent());
+
+ mPreference.performClick();
+ Intent nextIntent = Shadows.shadowOf(
+ (Application) ApplicationProvider.getApplicationContext()).getNextStartedActivity();
+ assertNull(nextIntent);
+ // Verify a dialog is shown
+ verify(mFragmentTransaction).add(
+ any(NotificationAssistantDialogFragment.class), anyString());
+ verify(mBackend, times(0)).setNotificationAssistantGranted(any());
+ }
+
+ @Test
@Config(shadows = ShadowSecureSettings.class)
public void testMigrationFromSetting_userEnable_multiProfile() throws Exception {
Settings.Secure.putIntForUser(mContext.getContentResolver(),
diff --git a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
index 10e291c..b33e94b 100644
--- a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
+++ b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
@@ -42,6 +42,7 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -74,6 +75,7 @@
import org.robolectric.annotation.Config;
import java.util.Arrays;
+import java.util.concurrent.Executor;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowAlertDialogCompat.class)
@@ -81,6 +83,8 @@
@Mock
private Context mContext;
@Mock
+ private Executor mExecutor;
+ @Mock
private NotificationManager mNotificationManager;
@Mock
private TelephonyManager mTelephonyManager;
@@ -94,6 +98,8 @@
private SubscriptionInfo mSubInfo;
@Mock
private DisplayMetrics mDisplayMetrics;
+ @Mock
+ private SimDialogActivity mActivity;
private final String mFakeDisplayName = "fake_display_name";
private final CharSequence mFakeNotificationChannelTitle = "fake_notification_channel_title";
@@ -236,27 +242,18 @@
@Test
public void onReceivePrimarySubListChange_WithDismissExtra_shouldDismiss() {
+ doReturn(mExecutor).when(mActivity).getMainExecutor();
+ SimDialogProhibitService.supportDismiss(mActivity);
+
Intent intent = new Intent(TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED);
intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
- EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA);
+ EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS);
mSimSelectNotification.onReceive(mContext, intent);
clearInvocations(mContext);
// Dismiss.
- intent.putExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
- EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DISMISS);
- mSimSelectNotification.onReceive(mContext, intent);
- ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mContext).startActivity(intentCaptor.capture());
- Intent capturedIntent = intentCaptor.getValue();
- assertThat(capturedIntent).isNotNull();
- assertThat(capturedIntent.getComponent().getClassName()).isEqualTo(
- SimDialogActivity.class.getName());
- assertThat(capturedIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK)
- .isNotEqualTo(0);
- assertThat(capturedIntent.getIntExtra(SimDialogActivity.DIALOG_TYPE_KEY, INVALID_PICK))
- .isEqualTo(PICK_DISMISS);
+ verify(mExecutor).execute(any());
}
@Test
public void onReceivePrimarySubListChange_DualCdmaWarning_notificationShouldSend() {
diff --git a/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java b/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
index 0962d29..8f43268 100644
--- a/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
+++ b/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
@@ -1,20 +1,12 @@
package com.android.settings.survey;
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.IntentFilter;
import androidx.fragment.app.FragmentActivity;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.overlay.SurveyFeatureProvider;
@@ -28,22 +20,15 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.ArrayList;
-import java.util.HashMap;
@RunWith(RobolectricTestRunner.class)
public class SurveyMixinTest {
private static final String FAKE_KEY = "fake_key";
- private static final String FAKE_SURVEY_ID = "fake_id";
private Context mContext;
private SurveyFeatureProvider mProvider;
@Mock
- private BroadcastReceiver mReceiver;
- @Mock
private InstrumentedPreferenceFragment mFragment;
@Before
@@ -52,99 +37,16 @@
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mProvider = FakeFeatureFactory.setupForTest().getSurveyFeatureProvider(mContext);
- when(mProvider.getSurveyId(any(), eq(FAKE_KEY))).thenReturn(FAKE_SURVEY_ID);
}
@Test
- public void onResume_triesRegisteringReceiverAndDownloadingWhenNoSurveyDetected() {
- // Pretend there is no survey in memory
- when(mProvider.getSurveyExpirationDate(any(), any())).thenReturn(-1L);
-
+ public void onResume_noActionIfActivityDoesNotExist() {
// Pretend we are an activity that is starting up
FragmentActivity temp = Robolectric.setupActivity(FragmentActivity.class);
- when(mFragment.getActivity()).thenReturn(temp);
- SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
- mixin.onResume();
-
- // Verify that a download was attempted
- verify(mProvider, times(1)).downloadSurvey(any(), any(), any());
- // Verify that we registered a receiver for download completion broadcasts
- verify(mProvider, times(1)).createAndRegisterReceiver(any());
- // Verify we did not try to show a survey
- verify(mProvider, never()).showSurveyIfAvailable(any(), any());
- }
-
- @Test
- public void onResume_triesShowingSurveyWhenOneIsPresent() {
- // Pretend there is a survey in memory
- when(mProvider.getSurveyExpirationDate(any(), any())).thenReturn(0L);
-
- // Pretend we are an activity that is starting up
- FragmentActivity temp = Robolectric.setupActivity(FragmentActivity.class);
- when(mFragment.getActivity()).thenReturn(temp);
- SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
- mixin.onResume();
-
- // Verify that a download was not attempted
- verify(mProvider, never()).downloadSurvey(any(), any(), any());
- // Verify that we did not register a receiver
- verify(mProvider, never()).createAndRegisterReceiver(any());
- // Verify we tried to show a survey
- verify(mProvider, times(1)).showSurveyIfAvailable(any(), any());
- }
-
- @Test
- public void onResume_doesNothingWhenActivityIsNull() {
- // Pretend the activity died somewhere in the process
when(mFragment.getActivity()).thenReturn(null);
SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
mixin.onResume();
- // Verify we don't try showing or downloading a survey
- verify(mProvider, never()).showSurveyIfAvailable(any(), any());
- verify(mProvider, never()).downloadSurvey(any(), any(), any());
- }
-
- @Test
- public void onPause_removesReceiverIfPreviouslySet() {
- // Pretend there is a survey in memory
- when(mProvider.getSurveyExpirationDate(any(), any())).thenReturn(-1L);
-
- // Pretend we are an activity that starts and stops
- FragmentActivity temp = Robolectric.setupActivity(FragmentActivity.class);
- when(mFragment.getActivity()).thenReturn(temp);
- when(mProvider.createAndRegisterReceiver(any())).thenReturn(mReceiver);
- LocalBroadcastManager manager = LocalBroadcastManager.getInstance(temp);
- SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
- mixin.onResume();
- manager.registerReceiver(mReceiver, new IntentFilter());
- mixin.onPause();
-
- // Verify we remove the receiver
- HashMap<BroadcastReceiver, ArrayList<IntentFilter>> map =
- ReflectionHelpers.getField(manager, "mReceivers");
- assertThat(map.containsKey(mReceiver)).isFalse();
- }
-
- @Test
- public void onPause_doesNothingWhenActivityOrReceiverNull() {
- // Pretend there is a survey in memory
- when(mProvider.getSurveyExpirationDate(any(), any())).thenReturn(-1L);
-
- // Pretend we are an activity that fails to create a receiver properly
- FragmentActivity temp = Robolectric.setupActivity(FragmentActivity.class);
- when(mFragment.getActivity()).thenReturn(temp);
- SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
- mixin.onPause();
-
- // Verify we do nothing;
- verify(mProvider, never()).showSurveyIfAvailable(any(), any());
-
- // pretend the activity died before onPause
- when(mFragment.getActivity()).thenReturn(null);
- mixin.onPause();
-
- // Verify we do nothing
- verify(mProvider, never()).showSurveyIfAvailable(any(), any());
+ verify(mProvider, times(0)).sendActivityIfAvailable(FAKE_KEY);
}
}
diff --git a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
index f85e104..0c297f4 100644
--- a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
+++ b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
@@ -71,7 +71,7 @@
@Test
public void cycleChecked_customLabel_shouldUpdateTextAndBackground() {
final int onText = R.string.main_clear_progress_text;
- final int offText = R.string.manage_space_text;
+ final int offText = R.string.clear_user_data_text;
mBar.setSwitchBarText(onText, offText);
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
diff --git a/tests/unit/src/com/android/settings/datausage/BillingCyclePreferenceTest.java b/tests/unit/src/com/android/settings/datausage/BillingCyclePreferenceTest.java
new file mode 100644
index 0000000..f74768f
--- /dev/null
+++ b/tests/unit/src/com/android/settings/datausage/BillingCyclePreferenceTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2022 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.datausage;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.os.INetworkManagementService;
+import android.os.RemoteException;
+import android.os.UserManager;
+import android.telephony.TelephonyManager;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class BillingCyclePreferenceTest {
+
+ private Context mContext;
+ private BillingCyclePreference mPreference;
+ private TemplatePreference.NetworkServices mServices;
+ @Mock
+ private INetworkManagementService mNetManageSerice;
+ @Mock
+ private TelephonyManager mTelephonyManager;
+ @Mock
+ private UserManager mUserManager;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(ApplicationProvider.getApplicationContext());
+
+ mServices = new TemplatePreference.NetworkServices();
+ mServices.mNetworkService = mNetManageSerice;
+ mServices.mTelephonyManager = mTelephonyManager;
+ mServices.mUserManager = mUserManager;
+
+ doReturn(mTelephonyManager).when(mTelephonyManager)
+ .createForSubscriptionId(anyInt());
+
+ mPreference = spy(new BillingCyclePreference(mContext, null /* attrs */));
+ mPreference.setTemplate(null, 0, mServices);
+ }
+
+ @Test
+ public void testPreferenceUpdate_onMobileDataEnabledChange_accessDataEnabledApi() {
+ try {
+ doReturn(true).when(mNetManageSerice).isBandwidthControlEnabled();
+ } catch (RemoteException exception) {}
+ doReturn(true).when(mUserManager).isAdminUser();
+ mPreference.onMobileDataEnabledChange();
+
+ verify(mTelephonyManager)
+ .isDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER);
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/src/com/android/settings/sound/MediaControlsLockScreenPreferenceControllerTest.java b/tests/unit/src/com/android/settings/sound/MediaControlsLockScreenPreferenceControllerTest.java
new file mode 100644
index 0000000..6c1aede
--- /dev/null
+++ b/tests/unit/src/com/android/settings/sound/MediaControlsLockScreenPreferenceControllerTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.sound;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class MediaControlsLockScreenPreferenceControllerTest {
+
+ private static final String KEY = "media_controls_lockscreen";
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+
+ private int mOriginalPreference;
+ private ContentResolver mContentResolver;
+ private MediaControlsLockScreenPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContentResolver = mContext.getContentResolver();
+ mOriginalPreference = Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, 1);
+ mController = new MediaControlsLockScreenPreferenceController(mContext, KEY);
+ }
+
+ @After
+ public void tearDown() {
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN,
+ mOriginalPreference);
+ }
+
+ @Test
+ public void getAvailability_returnAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void setChecked_disable_shouldTurnOff() {
+ Settings.Secure.putInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, 1);
+
+ assertThat(mController.isChecked()).isTrue();
+
+ mController.setChecked(false);
+
+ assertThat(Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, -1)).isEqualTo(0);
+ }
+
+ @Test
+ public void setChecked_enable_shouldTurnOn() {
+ Settings.Secure.putInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, 0);
+
+ assertThat(mController.isChecked()).isFalse();
+
+ mController.setChecked(true);
+
+ assertThat(Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, -1)).isEqualTo(1);
+ }
+}