Merge "Add metrics to Enable2gPreferenceController." into sc-dev
diff --git a/res/drawable/ic_fingerprint_introduction_shield_24dp.xml b/res/drawable/ic_fingerprint_introduction_shield_24dp.xml
new file mode 100644
index 0000000..28c9984
--- /dev/null
+++ b/res/drawable/ic_fingerprint_introduction_shield_24dp.xml
@@ -0,0 +1,45 @@
+<!--
+ Copyright (C) 2021 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.
+-->
+
+<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:aapt="http://schemas.android.com/aapt">
+ <aapt:attr name="android:drawable">
+ <vector android:height="24dp" android:width="24dp" android:viewportHeight="24"
+ android:viewportWidth="24"
+ android:tint="?android:attr/colorControlNormal">
+ <group android:name="_R_G">
+ <group android:name="_R_G_L_0_G">
+ <path android:name="_R_G_L_0_G_D_0_P_0" android:fillColor="#000000"
+ android:fillAlpha="1" android:fillType="nonZero"
+ android:pathData=" M12 2 C12,2 3.82,5.64 3.82,5.64 C3.82,5.64 3.82,11.09 3.82,11.09 C3.82,16.14 7.31,20.85 12,22 C16.69,20.85 20.18,16.14 20.18,11.09 C20.18,11.09 20.18,5.64 20.18,5.64 C20.18,5.64 12,2 12,2c M18.18 11.09 C18.18,12.64 17.77,14.14 17.08,15.47 C15.77,14.5 13.4,14 12,14 C10.6,14 8.23,14.5 6.92,15.47 C6.23,14.14 5.82,12.64 5.82,11.09 C5.82,11.09 5.82,6.94 5.82,6.94 C5.82,6.94 12,4.19 12,4.19 C12,4.19 18.18,6.94 18.18,6.94 C18.18,6.94 18.18,11.09 18.18,11.09c "/>
+ <path android:name="_R_G_L_0_G_D_1_P_0" android:fillColor="#000000"
+ android:fillAlpha="1" android:fillType="nonZero"
+ android:pathData=" M12 7.5 C13.66,7.5 15,8.84 15,10.5 C15,12.16 13.66,13.5 12,13.5 C10.34,13.5 9,12.16 9,10.5 C9,8.84 10.34,7.5 12,7.5c "/>
+ </group>
+ </group>
+ <group android:name="time_group"/>
+ </vector>
+ </aapt:attr>
+ <target android:name="time_group">
+ <aapt:attr name="android:animation">
+ <set android:ordering="together">
+ <objectAnimator android:propertyName="translateX" android:duration="2000"
+ android:startOffset="0" android:valueFrom="0" android:valueTo="1"
+ android:valueType="floatType"/>
+ </set>
+ </aapt:attr>
+ </target>
+</animated-vector>
\ No newline at end of file
diff --git a/res/drawable/ic_notification_silence.xml b/res/drawable/ic_notification_silence.xml
index 9da56dd..4b71d65 100644
--- a/res/drawable/ic_notification_silence.xml
+++ b/res/drawable/ic_notification_silence.xml
@@ -14,28 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:id="@+id/back">
- <shape android:shape="oval">
- <solid
- android:color="@color/notification_silence_color" />
- <size
- android:height="24dp"
- android:width="24dp"/>
- </shape>
- </item>
- <item
- android:id="@+id/fore"
- android:gravity="center">
- <vector
- android:width="13dp"
- android:height="13dp"
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
android:viewportWidth="24"
- android:viewportHeight="24">
- <path
- android:fillColor="#FFFFFFFF"
- android:pathData="M15,14.5c-1.38,0 -2.5,-1.12 -2.5,-2.5c0,-0.28 -0.22,-0.5 -0.5,-0.5s-0.5,0.22 -0.5,0.5c0,1.38 -1.12,2.5 -2.5,2.5S6.5,13.38 6.5,12c0,-0.28 -0.22,-0.5 -0.5,-0.5c-0.24,0 -0.46,0.18 -0.49,0.42C5.41,12.55 4.89,13 4.27,13H2v-2h1.71C4.1,10.11 5,9.5 6,9.5c1.38,0 2.5,1.12 2.5,2.5c0,0.28 0.22,0.5 0.5,0.5s0.5,-0.22 0.5,-0.5c0,-1.38 1.12,-2.5 2.5,-2.5s2.5,1.12 2.5,2.5c0,0.28 0.22,0.5 0.5,0.5s0.5,-0.22 0.5,-0.5c0,-1.38 1.12,-2.5 2.5,-2.5c1.02,0 1.91,0.6 2.29,1.5H22v2h-2.27c-0.62,0 -1.14,-0.45 -1.23,-1.08c-0.04,-0.24 -0.25,-0.42 -0.49,-0.42c-0.28,0 -0.5,0.22 -0.5,0.5C17.5,13.38 16.38,14.5 15,14.5z"/>
- </vector>
- </item>
-</layer-list>
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zM16,16L2.81,2.81 1.39,4.22l4.85,4.85C6.09,9.68 6,10.33 6,11v6L4,17v2h12.17l3.61,3.61 1.41,-1.41L16,16zM8,17l0.01,-6.16L14.17,17L8,17zM12,6.5c2.49,0 4,2.02 4,4.5v2.17l2,2L18,11c0,-3.07 -1.63,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68c-0.78,0.18 -1.45,0.52 -2.04,0.95L9.93,7.1c0.58,-0.37 1.27,-0.6 2.07,-0.6z"
+ android:fillColor="@android:color/white"/>
+</vector>
diff --git a/res/drawable/ic_ongoing_notification.xml b/res/drawable/ic_ongoing_notification.xml
new file mode 100644
index 0000000..238b517
--- /dev/null
+++ b/res/drawable/ic_ongoing_notification.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2021 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="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M12,18h0.17l-1.09,-1.09 1.41,-1.41L16,19l-3.5,3.5 -1.41,-1.41L12.17,20L12,20c-2.05,0 -4.09,-0.78 -5.66,-2.34 -3.12,-3.12 -3.12,-8.19 0,-11.31l1.41,1.41c-2.34,2.34 -2.34,6.15 0,8.49C8.89,17.38 10.4,18 12,18zM17.66,6.34c3.12,3.12 3.12,8.19 0,11.31l-1.41,-1.41c2.34,-2.34 2.34,-6.15 0,-8.49C15.11,6.62 13.6,6 12,6h-0.17l1.09,1.09L11.5,8.5 8,5l3.5,-3.5 1.41,1.41L11.83,4L12,4c2.05,0 4.09,0.78 5.66,2.34z"/>
+</vector>
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index 0aa18fb..8555f1a 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -31,22 +31,15 @@
android:orientation="vertical">
<com.google.android.setupdesign.view.RichTextView
- android:id="@+id/sud_layout_description"
- style="@style/SudDescription.Glif"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_fingerprint_enroll_introduction_message" />
-
- <com.google.android.setupdesign.view.RichTextView
android:id="@+id/error_text"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
- <com.google.android.setupdesign.view.FillContentLayout
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1">
+ android:layout_marginVertical="12dp">
<ImageView
style="@style/SudContentIllustration"
@@ -55,25 +48,89 @@
android:contentDescription="@null"
android:src="@drawable/fingerprint_enroll_introduction" />
- </com.google.android.setupdesign.view.FillContentLayout>
+ </FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:contentDescription="@null"
- android:src="@drawable/ic_info_outline_24dp"/>
+ android:orientation="vertical">
<com.google.android.setupdesign.view.RichTextView
- android:id="@+id/sud_layout_info"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/security_settings_fingerprint_enroll_introduction_bottom_message" />
+ android:textAlignment="viewStart"
+ android:paddingTop="12dp"
+ android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_1" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="12dp">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@null"
+ android:src="@drawable/ic_fingerprint_introduction_shield_24dp"/>
+ <Space
+ android:layout_width="24dp"
+ android:layout_height="wrap_content"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_fingerprint_enroll_introduction_footer_message_1" />
+ </LinearLayout>
+
+ <TextView
+ style="@style/SudDescription.Glif"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAlignment="viewStart"
+ android:paddingTop="24dp"
+ android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="12dp">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@null"
+ android:src="@drawable/ic_info_outline_24dp"/>
+ <Space
+ android:layout_width="24dp"
+ android:layout_height="wrap_content"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_fingerprint_enroll_introduction_footer_message_2" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="24dp">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@null"
+ android:src="@drawable/ic_fingerprint_24dp"/>
+ <Space
+ android:layout_width="24dp"
+ android:layout_height="wrap_content"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_fingerprint_enroll_introduction_footer_message_3" />
+ </LinearLayout>
+
</LinearLayout>
</LinearLayout>
diff --git a/res/layout/preference_labeled_continuous_slider.xml b/res/layout/preference_labeled_continuous_slider.xml
new file mode 100644
index 0000000..00e8796
--- /dev/null
+++ b/res/layout/preference_labeled_continuous_slider.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingStart="56dp"
+ android:paddingEnd="8dp"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp">
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingBottom="16dp"
+ android:layout_marginStart="16dp"
+ android:maxLines="1"
+ android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textColor="?android:attr/textColorPrimary" />
+
+ <SeekBar
+ android:id="@*android:id/seekbar"
+ android:layout_gravity="center_vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="8dp"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@android:id/text1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:textAlignment="viewStart"/>
+
+ <TextView
+ android:id="@android:id/text2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="16dp"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:textAlignment="viewEnd"/>
+ </LinearLayout>
+</LinearLayout>
diff --git a/res/values/config.xml b/res/values/config.xml
index e923fbd..984906f 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -506,4 +506,7 @@
<!-- whether use partner overlay theme for outside setupwizard flow -->
<bool name="config_suc_use_partner_resource">false</bool>
+
+ <!-- Cell broacast receiver package name -->
+ <string name="config_cell_broadcast_receiver_package" translatable="false">com.android.cellbroadcastreceiver.module</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5abba1f..68030bf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -884,13 +884,21 @@
<!-- message shown in summary field when no fingerprints are registered -->
<string name="security_settings_fingerprint_preference_summary_none"></string>
<!-- Introduction title shown in fingerprint enrollment to introduce the fingerprint feature[CHAR LIMIT=29] -->
- <string name="security_settings_fingerprint_enroll_introduction_title">Unlock with fingerprint</string>
- <!-- Introduction title shown in fingerprint enrollment to introduce the fingerprint feature, when fingerprint unlock is disabed by device admin [CHAR LIMIT=40] -->
+ <string name="security_settings_fingerprint_enroll_introduction_title">Set up your fingerprint</string>
+ <!-- Introduction title shown in fingerprint enrollment to introduce the fingerprint feature, when fingerprint unlock is disabled by device admin [CHAR LIMIT=40] -->
<string name="security_settings_fingerprint_enroll_introduction_title_unlock_disabled">Use your fingerprint</string>
<!-- Introduction detail message shown in fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_enroll_introduction_message">Just touch the fingerprint sensor to unlock your phone, authorize purchases, or sign in to apps. Be careful whose fingerprints you add. Even one added print can do any of these things.</string>
+ <!-- Introduction title shown in the bottom of fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
+ <string name="security_settings_fingerprint_enroll_introduction_footer_title_1">You\u2019re in control</string>
+ <!-- Introduction title shown in the bottom of fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
+ <string name="security_settings_fingerprint_enroll_introduction_footer_title_2">Keep in mind</string>
<!-- Introduction detail message shown in the bottom of fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
- <string name="security_settings_fingerprint_enroll_introduction_bottom_message">Your fingerprint may be less secure than a strong pattern or PIN.</string>
+ <string name="security_settings_fingerprint_enroll_introduction_footer_message_1">The data recorded by Fingerprint is stored securely and never leaves your phone. You can delete your data anytime in Settings.</string>
+ <!-- Introduction detail message shown in the bottom of fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
+ <string name="security_settings_fingerprint_enroll_introduction_footer_message_2">Your fingerprint may be less secure than a strong pattern or PIN.</string>
+ <!-- Introduction detail message shown in the bottom of fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
+ <string name="security_settings_fingerprint_enroll_introduction_footer_message_3" product="default">Your phone will occasionally use your recent fingerprint images to create improved fingerprint models.</string>
<!-- Introduction detail message shown in fingerprint enrollment dialog, when fingerprint unlock is disabled by device admin [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_enroll_introduction_message_unlock_disabled">Use your fingerprint to unlock your phone or approve purchases.\n\nNote: You can\u2019t use your fingerprint to unlock this device. For more information, contact your organization\u2019s admin.</string>
<!-- Introduction detail message shown in fingerprint enrollment screen in setup wizard. [CHAR LIMIT=NONE]-->
@@ -899,8 +907,12 @@
<string name="security_settings_fingerprint_enroll_introduction_cancel">Cancel</string>
<!-- Button text to cancel enrollment [CHAR LIMIT=30] -->
<string name="security_settings_fingerprint_enroll_introduction_no_thanks">No thanks</string>
+ <!-- Button text to skip enrollment [CHAR LIMIT=30] -->
+ <string name="security_settings_fingerprint_enroll_introduction_skip">Skip</string>
<!-- Button text to continue to the next screen from the introduction [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_enroll_introduction_continue">Continue</string>
+ <!-- Button text to agree the consent and continue to the next screen from the introduction [CHAR LIMIT=22] -->
+ <string name="security_settings_fingerprint_enroll_introduction_agree">Agree</string>
<!-- Button text to cancel enrollment from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_enroll_introduction_cancel_setup">Skip</string>
<!-- Button text to continue to the next screen from the introduction (this string variant is used while in setup wizard) [CHAR LIMIT=22] -->
@@ -2985,7 +2997,7 @@
<!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the always-on ambient display feature. -->
<string name="doze_always_on_summary">Increased battery usage</string>
<!-- [CHAR LIMIT=30] Display and accessibility settings screens, setting option name to force bold text. -->
- <string name="force_bold_text">Bold Text</string>
+ <string name="force_bold_text">Bold text</string>
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
<string name="title_font_size">Font size</string>
<!-- Summary for Font size. Lets the user know that this will make text larger or smaller. Appears in the accessibility portion of setup wizard. [CHAR LIMIT=NONE] -->
@@ -4037,7 +4049,7 @@
<string name="managed_profile_location_services">Location services for work</string>
<!-- [CHAR LIMIT=60] Location settings screen, screen title -->
- <string name="location_time_zone_detection_screen_title">Location time zone detection</string>
+ <string name="location_time_zone_detection_screen_title">Use location to set time zone</string>
<!-- [CHAR LIMIT=50] Location settings screen, title for the setting that control whether the
device can use its location for time zone detection. -->
<string name="location_time_zone_detection_enabled_title">Location time zone detection</string>
@@ -4051,7 +4063,7 @@
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
applicable due to other settings like the "automatic time zone detection enabled" setting
being set to "off". -->
- <string name="location_time_zone_detection_auto_is_off">Automatic time zone detection is disabled</string>
+ <string name="location_time_zone_detection_auto_is_off">Automatic time zone is off</string>
<!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
applicable for the user for unspecified reasons. More specific messages are used when there
is a clear reason. -->
@@ -4482,13 +4494,13 @@
<!-- Manage applications, restore updated system application to factory version -->
<string name="app_factory_reset">Uninstall updates</string>
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app is set as a default for some actions. -->
- <string name="auto_launch_enable_text">You\u2019ve chosen to launch this app by default for some actions.</string>
+ <string name="auto_launch_enable_text">Some activities you\u2019ve selected open in this app by default.</string>
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app was given user permission to create widgets. -->
<string name="always_allow_bind_appwidgets_text">You\u2019ve chosen to allow this app to create widgets and access their data.</string>
<!-- Manage applications, individual application screen, text under Launch by default heading if the app is NOT a default for actions -->
<string name="auto_launch_disable_text">No defaults set.</string>
<!-- Manage applications, individual application screen, button label under Launch by default heading. This is used to clear any default actions that may be assigned to this app. -->
- <string name="clear_activities">Clear defaults</string>
+ <string name="clear_activities">Clear default preferences</string>
<!-- Manage applications, individual application info screen, screen, message text under screen compatibility heading -->
<string name="screen_compatibility_text">This app may not be designed for your screen. You can control how it
adjusts to your screen here.</string>
@@ -7519,9 +7531,6 @@
<!-- Summary of multimedia messaging service settings. [CHAR LIMIT=100] -->
<string name="mms_message_summary">Send & receive when mobile data is off</string>
- <!-- Cell broacast receiver package name [DO NOT TRANSLATE] -->
- <string name="cell_broadcast_receiver_package">com.android.cellbroadcastreceiver.module</string>
-
<!-- Title of a preference for whether to allow data during calls that is shown when mobile
data is turned off. This is needed for some multi-SIM scenarios, because the SIM that is
default for data might not be available during a phone call. [CHAR LIMIT=60] -->
@@ -8776,8 +8785,10 @@
<!-- app summary of notification app list screen [CHAR LIMIT=100] -->
<string name="notifications_sent_never">Never</string>
- <!-- Sound & notification > Advanced section: Title for managing notification listeners option. [CHAR LIMIT=30] -->
- <string name="manage_notification_access_title">Notification access</string>
+ <!-- Sound & notification > Advanced section: Title for managing notification listeners option. [CHAR LIMIT=60] -->
+ <string name="manage_notification_access_title">Device & app notifications</string>
+
+ <string name="manage_notification_access_summary">Control which notifications show on your apps and devices</string>
<!-- Notification Access section: Indicates that the work profile admin doesn't allow this
notification listener to access work profile notifications [CHAR LIMIT=100] -->
@@ -8836,26 +8847,19 @@
<string name="notification_listener_disable_warning_confirm">Turn off</string>
<string name="notification_listener_disable_warning_cancel">Cancel</string>
<string name="notification_listener_type_title">Allowed notification types</string>
- <string name="notif_type_ongoing">Important ongoing notifications</string>
- <string name="notif_type_conversation">Conversation notifications</string>
- <string name="notif_type_alerting">Alerting notifications</string>
- <string name="notif_type_silent">Silent notifications</string>
-
- <!-- Per notification listener, launches a list of apps whose notifications this listener cannot see -->
- <string name="notif_listener_excluded_title">Apps that are not bridged to this listener</string>
-
- <!-- Per notification listener, when the listener can see notifications from all apps -->
- <string name="notif_listener_excluded_summary_zero">All apps are bridged</string>
-
- <!-- Per notification listener, a summary of how many apps this listener cannot see
- notifications from -->
- <plurals name="notif_listener_excluded_summary_nonzero">
- <item quantity="one">%d app is not bridged</item>
- <item quantity="other">%d apps are not bridged</item>
- </plurals>
+ <string name="notif_type_ongoing">Real-time</string>
+ <string name="notif_type_ongoing_summary">Real-time communication from apps in use, navigation, phone calls, and more</string>
+ <string name="notif_type_conversation">Conversations</string>
+ <string name="notif_type_conversation_summary">SMS and other communications</string>
+ <string name="notif_type_alerting">Default</string>
+ <string name="notif_type_alerting_summary">Notifications that may ring or vibrate based on settings</string>
+ <string name="notif_type_silent">Silent</string>
+ <string name="notif_type_silent_summary">Notifications that never make sound or vibrations</string>
<!-- Per notification listener, a list of apps whose notifications this listener cannot see -->
- <string name="notif_listener_excluded_app_title">Bridged apps</string>
+ <string name="notif_listener_excluded_app_title">See all apps</string>
+ <string name="notif_listener_excluded_app_summary">Change notification settings for each app that can send notifications</string>
+ <string name="notif_listener_excluded_app_screen_title">Apps shown on device</string>
<!-- Title for managing VR (virtual reality) helper services. [CHAR LIMIT=50] -->
<string name="vr_listeners_title">VR helper services</string>
@@ -9671,9 +9675,44 @@
<!-- Category name for App Launch -->
<string name="app_launch_domain_links_title">Opening links</string>
<string name="app_launch_open_domain_urls_title">Open supported links</string>
+ <!-- Preference title for Supported links open in this app. [CHAR LIMIT=60] -->
+ <string name="app_launch_top_intro_message">Supported links open in this app</string>
+ <!-- Preference title for Links to open in this app. [CHAR LIMIT=60] -->
+ <string name="app_launch_links_category">Links to open in this app</string>
+
<string name="app_launch_open_domain_urls_summary">Open without asking</string>
<string name="app_launch_supported_domain_urls_title">Supported links</string>
- <string name="app_launch_other_defaults_title">Other defaults</string>
+
+ <string name="app_launch_other_defaults_title">Other default preferences</string>
+ <!-- Preference title for Add link [CHAR LIMIT=60] -->
+ <string name="app_launch_add_link">Add link</string>
+ <!-- Footer for Open by default. [CHAR LIMIT=NONE] -->
+ <string name="app_launch_footer">An app can verify links to automatically open in the app. <annotation id="url">Learn more</annotation></string>
+
+ <!-- Title, message and button for verified links dialog. -->
+ <plurals name="app_launch_verified_links_title">
+ <item quantity="one"><xliff:g id="count">%d</xliff:g> verified link</item>
+ <item quantity="other"><xliff:g id="count">%d</xliff:g> verified links</item>
+ </plurals>
+ <plurals name="app_launch_verified_links_message">
+ <item quantity="one">This link is verified and automatically opens in this app.</item>
+ <item quantity="other">These links are verified and automatically open in this app.</item>
+ </plurals>
+ <!-- OK button for verified links dialog. [CHAR LIMIT=20] -->
+ <string name="app_launch_dialog_ok">OK</string>
+
+ <!-- Title for Checking other supported links dialog. [CHAR LIMIT=50] -->
+ <string name="app_launch_checking_links_title">Checking for other supported links\u2026</string>
+ <!-- Cancel button for Checking other supported links dialog. [CHAR LIMIT=20] -->
+ <string name="app_launch_dialog_cancel">Cancel</string>
+
+ <!-- Title and button for links found dialog. -->
+ <plurals name="app_launch_supported_links_title">
+ <item quantity="one"><xliff:g id="count">%d</xliff:g> supported link</item>
+ <item quantity="other"><xliff:g id="count">%d</xliff:g> supported links</item>
+ </plurals>
+ <!-- Add button for links found dialog. [CHAR LIMIT=20] -->
+ <string name="app_launch_supported_links_add">Add</string>
<!-- Summary for app storage preference -->
<string name="storage_summary_format"><xliff:g id="size" example="30.00MB">%1$s</xliff:g> used in <xliff:g id="storage_type" example="internal memory">%2$s</xliff:g></string>
@@ -11484,8 +11523,10 @@
<!-- AutoFill strings -->
<!-- Preference label for choosing auto-fill service. [CHAR LIMIT=60] -->
<string name="autofill_app">Autofill service</string>
+ <!-- Preference category for showing auto-fill services with saved passwords. [CHAR LIMIT=60] -->
+ <string name="autofill_passwords">Passwords</string>
<!-- Keywords for the auto-fill feature. [CHAR LIMIT=NONE] -->
- <string name="autofill_keywords">auto, fill, autofill</string>
+ <string name="autofill_keywords">auto, fill, autofill, password</string>
<!-- Message of the warning dialog for setting the auto-fill app. [CHAR_LIMIT=NONE] -->
<string name="autofill_confirmation_message">
@@ -12804,6 +12845,8 @@
<!-- Alert Dialog text when user didn't input the phone number [CHAR LIMIT=50]-->
<string name="smart_forwarding_missing_alert_dialog_text">OK</string>
- <!-- Enable 2G: Title for if user wants to enable 2G [CHAR LIMIT=40] -->
+ <!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=40] -->
<string name="enable_2g_title">Allow 2G</string>
+ <!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=NONE] -->
+ <string name="enable_2g_summary">Use 2G cellular connections. For emergency calls, 2G is always turned on.</string>
</resources>
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index bd2e85c..49d8e9b 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -90,7 +90,7 @@
settings:useAdminDisabledSummary="true">
<intent
android:action="android.intent.action.MAIN"
- android:targetPackage="@string/cell_broadcast_receiver_package"
+ android:targetPackage="@string/config_cell_broadcast_receiver_package"
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings"/>
</com.android.settingslib.RestrictedPreference>
diff --git a/res/xml/configure_notification_settings_v2.xml b/res/xml/configure_notification_settings_v2.xml
index 6c3ec52..b7cc2c8 100644
--- a/res/xml/configure_notification_settings_v2.xml
+++ b/res/xml/configure_notification_settings_v2.xml
@@ -23,12 +23,14 @@
android:title="@string/conversation_notifs_category">
<Preference
android:key="conversations"
+ android:order="1"
android:title="@string/conversations_category_title"
settings:controller="com.android.settings.notification.ConversationListSummaryPreferenceController"
android:fragment="com.android.settings.notification.app.ConversationListSettings"
/>
<Preference
android:key="notification_bubbles"
+ android:order="2"
android:title="@string/notification_bubbles_title"
android:summary="@string/notifications_bubble_setting_on_summary"
settings:controller="com.android.settings.notification.BubbleSummaryNotificationPreferenceController"
@@ -44,6 +46,7 @@
<!-- See all apps button -->
<Preference
android:key="all_notifications"
+ android:order="10"
android:title="@string/notifications_title"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
settings:searchable="false">
@@ -58,6 +61,7 @@
android:title="@string/lock_screen_notifications_title">
<Preference
android:key="notification_history"
+ android:order="11"
android:title="@string/notification_history"
android:summary="@string/notification_history_summary">
<intent
@@ -65,27 +69,38 @@
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.notification.history.NotificationHistoryActivity" />
</Preference>
+ <Preference
+ android:key="notification_access"
+ android:order="12"
+ android:title="@string/manage_notification_access_title"
+ android:summary="@string/manage_notification_access_summary"
+ android:fragment="com.android.settings.notification.NotificationAccessSettings"
+ settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessController" />
<!-- When device is locked -->
<com.android.settings.RestrictedListPreference
android:key="lock_screen_notifications"
+ android:order="13"
android:title="@string/lock_screen_notifs_title"
android:singleLineTitle="false"
android:summary="@string/summary_placeholder" />
<SwitchPreference
android:key="lock_screen_redact"
+ android:order="14"
android:title="@string/lock_screen_notifs_redact"
android:summary="@string/lock_screen_notifs_redact_summary"
settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />
<SwitchPreference
android:key="lock_screen_work_redact"
+ android:order="15"
android:title="@string/lock_screen_notifs_redact_work"
android:summary="@string/lock_screen_notifs_redact_work_summary"
settings:controller="com.android.settings.notification.RedactNotificationPreferenceController" />
<SwitchPreference
android:key="notification_lockscreen_bypass"
+ android:order="16"
android:title="@string/lockscreen_bypass_title"
android:summary="@string/lockscreen_bypass_summary"
settings:searchable="false"
@@ -98,6 +113,7 @@
android:title="@string/advanced_section_header">
<com.android.settingslib.RestrictedPreference
android:key="zen_mode_notifications"
+ android:order="17"
android:title="@string/zen_mode_settings_title"
settings:useAdminDisabledSummary="true"
android:fragment="com.android.settings.notification.zen.ZenModeSettings"
@@ -105,33 +121,38 @@
/>
<com.android.settingslib.RestrictedPreference
android:key="app_and_notif_cell_broadcast_settings"
+ android:order="18"
android:title="@string/cell_broadcast_settings"
settings:useAdminDisabledSummary="true">
<intent
android:action="android.intent.action.MAIN"
- android:targetPackage="@string/cell_broadcast_receiver_package"
+ android:targetPackage="@string/config_cell_broadcast_receiver_package"
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings"/>
</com.android.settingslib.RestrictedPreference>
<SwitchPreference
android:key="silent_icons"
+ android:order="19"
android:title="@string/silent_notifications_status_bar"
settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController"/>
<SwitchPreference
android:key="show_snooze_options"
+ android:order="20"
android:title="@string/snooze_options_title"
settings:controller="com.android.settings.notification.SnoozeNotificationPreferenceController" />
<!-- Notification badging -->
<SwitchPreference
android:key="notification_badging"
+ android:order="21"
android:title="@string/notification_badging_title"
settings:controller="com.android.settings.notification.BadgingNotificationPreferenceController"/>
<!-- Pulse notification light, on devices that support it -->
<SwitchPreference
android:key="notification_pulse"
+ android:order="22"
android:title="@string/notification_pulse_title"
settings:controller="com.android.settings.notification.PulseNotificationPreferenceController"/>
</PreferenceCategory>
diff --git a/res/xml/default_autofill_picker_settings.xml b/res/xml/default_autofill_picker_settings.xml
index bfc285b..392f733 100644
--- a/res/xml/default_autofill_picker_settings.xml
+++ b/res/xml/default_autofill_picker_settings.xml
@@ -22,14 +22,27 @@
android:title="@string/autofill_app"
settings:keywords="@string/autofill_keywords">
- <com.android.settings.widget.GearPreference
- android:key="default_autofill_main"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:searchable="false"
- settings:keywords="@string/autofill_keywords">
- <extra android:name="for_work" android:value="false" />
- </com.android.settings.widget.GearPreference>
+ <PreferenceCategory
+ android:key="passwords_category"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController" >
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="default_service_category"
+ android:title="@string/autofill_app">
+
+ <!-- TODO(b/169455298): Fix the redundant title. -->
+ <com.android.settings.widget.GearPreference
+ android:key="default_autofill_main"
+ android:title="@string/autofill_app"
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ settings:searchable="false"
+ settings:keywords="@string/autofill_keywords">
+ <extra android:name="for_work" android:value="false" />
+ </com.android.settings.widget.GearPreference>
+ </PreferenceCategory>
<com.android.settings.widget.WorkOnlyCategory
diff --git a/res/xml/emergency_settings.xml b/res/xml/emergency_settings.xml
index 774e328..28ae8b1 100644
--- a/res/xml/emergency_settings.xml
+++ b/res/xml/emergency_settings.xml
@@ -39,7 +39,7 @@
settings:useAdminDisabledSummary="true">
<intent
android:action="android.intent.action.MAIN"
- android:targetPackage="@string/cell_broadcast_receiver_package"
+ android:targetPackage="@string/config_cell_broadcast_receiver_package"
android:targetClass="com.android.cellbroadcastreceiver.CellBroadcastSettings"/>
</com.android.settingslib.RestrictedPreference>
</PreferenceScreen>
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index 86f5a83..7ab9893 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -258,5 +258,6 @@
<SwitchPreference
android:key="enable_2g"
android:title="@string/enable_2g_title"
+ android:summary="@string/enable_2g_summary"
settings:controller="com.android.settings.network.telephony.Enable2gPreferenceController" />
</PreferenceScreen>
diff --git a/res/xml/notification_access_bridged_apps_settings.xml b/res/xml/notification_access_bridged_apps_settings.xml
index 590a468..535a040 100644
--- a/res/xml/notification_access_bridged_apps_settings.xml
+++ b/res/xml/notification_access_bridged_apps_settings.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="nonbridged_apps"
- android:title="@string/notif_listener_excluded_app_title"
+ android:title="@string/notif_listener_excluded_app_screen_title"
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.BridgedAppsPreferenceController"
settings:searchable="false">
</PreferenceScreen>
diff --git a/res/xml/notification_access_permission_details.xml b/res/xml/notification_access_permission_details.xml
index 55a47f5..c4bb7f0 100644
--- a/res/xml/notification_access_permission_details.xml
+++ b/res/xml/notification_access_permission_details.xml
@@ -34,23 +34,32 @@
<CheckBoxPreference
android:key="type_filter_ongoing"
android:title="@string/notif_type_ongoing"
- settings:controller="com.android.settings.applications.specialaccess.notificationaccess.OngoingTypeFilterPreferenceController"/>/>
+ android:summary="@string/notif_type_ongoing_summary"
+ android:icon="@drawable/ic_ongoing_notification"
+ settings:controller="com.android.settings.applications.specialaccess.notificationaccess.OngoingTypeFilterPreferenceController"/>
<CheckBoxPreference
android:key="type_filter_conversation"
android:title="@string/notif_type_conversation"
- settings:controller="com.android.settings.applications.specialaccess.notificationaccess.ConversationTypeFilterPreferenceController"/>/>
+ android:summary="@string/notif_type_conversation_summary"
+ android:icon="@drawable/ic_promote_conversation"
+ settings:controller="com.android.settings.applications.specialaccess.notificationaccess.ConversationTypeFilterPreferenceController"/>
<CheckBoxPreference
android:key="type_filter_alerting"
android:title="@string/notif_type_alerting"
- settings:controller="com.android.settings.applications.specialaccess.notificationaccess.AlertingTypeFilterPreferenceController"/>/>
+ android:summary="@string/notif_type_alerting_summary"
+ android:icon="@drawable/ic_notification_alert"
+ settings:controller="com.android.settings.applications.specialaccess.notificationaccess.AlertingTypeFilterPreferenceController"/>
<CheckBoxPreference
android:key="type_filter_silent"
android:title="@string/notif_type_silent"
- settings:controller="com.android.settings.applications.specialaccess.notificationaccess.SilentTypeFilterPreferenceController"/>/>
+ android:summary="@string/notif_type_silent_summary"
+ android:icon="@drawable/ic_notification_silence"
+ settings:controller="com.android.settings.applications.specialaccess.notificationaccess.SilentTypeFilterPreferenceController"/>
<Preference
android:key="bridged_apps"
android:title="@string/notif_listener_excluded_app_title"
+ android:summary="@string/notif_listener_excluded_app_summary"
android:fragment="com.android.settings.applications.specialaccess.notificationaccess.BridgedAppsSettings"
settings:searchable="false"
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.BridgedAppsPreferenceController" />
diff --git a/res/xml/notification_access_settings.xml b/res/xml/notification_access_settings.xml
index 43f7c49..b523d7d 100644
--- a/res/xml/notification_access_settings.xml
+++ b/res/xml/notification_access_settings.xml
@@ -21,4 +21,13 @@
android:key="notification_access_screen"
android:title="@string/manage_notification_access_title"
settings:searchable="false"
- settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessScreenPreferenceController" />
+ settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessScreenPreferenceController">
+
+ <PreferenceCategory
+ android:key="allowed"
+ android:title="@string/app_permission_summary_allowed"/>
+
+ <PreferenceCategory
+ android:key="not_allowed"
+ android:title="@string/app_permission_summary_not_allowed"/>
+</PreferenceScreen>
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index b5e414b..75bbca0 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -17,6 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:key="power_usage_summary_screen"
android:title="@string/power_usage_summary_title"
settings:keywords="@string/keywords_battery">
@@ -31,6 +32,7 @@
android:fragment="com.android.settings.fuelgauge.PowerUsageAdvanced"
android:key="battery_usage_summary"
android:title="@string/advanced_battery_preference_title"
+ app:iconSpaceReserved="false"
settings:searchable="false" />
<com.android.settings.widget.CardPreference
@@ -38,23 +40,27 @@
android:title="@string/summary_placeholder"
settings:controller="com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController" />
- <com.android.settings.widget.PrimarySwitchPreference
- android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
- android:key="battery_saver_summary"
- android:title="@string/battery_saver"
- settings:controller="com.android.settings.fuelgauge.BatterySaverController" />
+ <PreferenceCategory>
+ <SwitchPreference
+ android:key="battery_percentage"
+ android:title="@string/battery_percentage"
+ android:summary="@string/battery_percentage_description"
+ settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />
+ </PreferenceCategory>
- <SwitchPreference
- android:key="battery_percentage"
- android:title="@string/battery_percentage"
- android:summary="@string/battery_percentage_description"
- settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />
+ <PreferenceCategory>
+ <Preference
+ android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
+ android:key="battery_saver_summary"
+ android:title="@string/battery_saver"
+ settings:controller="com.android.settings.fuelgauge.BatterySaverController" />
- <Preference
- android:fragment="com.android.settings.fuelgauge.SmartBatterySettings"
- android:key="smart_battery_manager"
- android:title="@string/smart_battery_manager_title"
- settings:controller="com.android.settings.fuelgauge.batterytip.BatteryManagerPreferenceController" />
+ <Preference
+ android:fragment="com.android.settings.fuelgauge.SmartBatterySettings"
+ android:key="smart_battery_manager"
+ android:title="@string/smart_battery_manager_title"
+ settings:controller="com.android.settings.fuelgauge.batterytip.BatteryManagerPreferenceController" />
+ </PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
android:key="power_usage_footer"
diff --git a/res/xml/reduce_bright_colors_settings.xml b/res/xml/reduce_bright_colors_settings.xml
index b9ca854..17e8b02 100644
--- a/res/xml/reduce_bright_colors_settings.xml
+++ b/res/xml/reduce_bright_colors_settings.xml
@@ -17,13 +17,16 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:persistent="false"
android:title="@string/reduce_bright_colors_preference_title">
- <com.android.settings.widget.SeekBarPreference
+ <com.android.settings.widget.LabeledContinuousSeekBarPreference
android:key="rbc_intensity"
android:persistent="false"
- android:title="@string/reduce_bright_colors_intensity_preference_title"/>
+ android:title="@string/reduce_bright_colors_intensity_preference_title"
+ settings:textStart="@string/reduce_bright_colors_intensity_preference_start_label"
+ settings:textEnd="@string/reduce_bright_colors_intensity_preference_end_label"/>
<SwitchPreference
android:key="rbc_persist"
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index d22a381..b672917 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -309,6 +309,7 @@
mMainSwitch = findViewById(R.id.switch_bar);
if (mMainSwitch != null) {
mMainSwitch.setMetricsTag(getMetricsTag());
+ mMainSwitch.setTranslationZ(findViewById(R.id.main_content).getTranslationZ() + 1);
}
// see if we should show Back/Next buttons
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index ff46722..dde5be1 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -128,8 +128,15 @@
@Override
protected void initSettingsPreference() {
+ // If the device doesn't support magnification area, it should hide the settings preference.
+ if (!getContext().getResources().getBoolean(
+ com.android.internal.R.bool.config_magnification_area)) {
+ return;
+ }
mSettingsPreference = new Preference(getPrefContext());
mSettingsPreference.setTitle(R.string.accessibility_menu_item_settings);
+ // TODO(b/177371954): "magnification area" should be brought up to the highest level of the
+ // settings UI so that it appears below "shortcut" to replace "settings.
mSettingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
mSettingsPreference.setPersistent(false);
diff --git a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
index 52b1a8d..5b74a88 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
@@ -180,6 +180,9 @@
// Keep Package Installer enabled.
keepEnabledPackages.add(mContext.getString(R.string.config_package_installer_package_name));
+ if (mPm.getWellbeingPackageName() != null) {
+ keepEnabledPackages.add(mPm.getWellbeingPackageName());
+ }
return keepEnabledPackages;
}
diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
new file mode 100644
index 0000000..792f2ee
--- /dev/null
+++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2021 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.applications.autofill;
+
+import android.annotation.UserIdInt;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ServiceInfo;
+import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
+import android.service.autofill.AutofillServiceInfo;
+import android.text.TextUtils;
+import android.util.IconDrawableFactory;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+
+import java.util.List;
+
+/**
+ * Queries available autofill services and adds preferences for those that declare passwords
+ * settings.
+ */
+public class PasswordsPreferenceController extends BasePreferenceController {
+
+ private final PackageManager mPm;
+ private final IconDrawableFactory mIconFactory;
+ private final List<AutofillServiceInfo> mServices;
+
+ public PasswordsPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ mPm = context.getPackageManager();
+ mIconFactory = IconDrawableFactory.newInstance(mContext);
+ mServices = AutofillServiceInfo.getAvailableServices(mContext, UserHandle.myUserId());
+ for (int i = mServices.size() - 1; i >= 0; i--) {
+ final String passwordsActivity = mServices.get(i).getPasswordsActivity();
+ if (TextUtils.isEmpty(passwordsActivity)) {
+ mServices.remove(i);
+ }
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return mServices.isEmpty() ? CONDITIONALLY_UNAVAILABLE : AVAILABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final PreferenceGroup group = screen.findPreference(getPreferenceKey());
+ // TODO(b/169455298): Show work profile passwords too.
+ addPasswordPreferences(screen.getContext(), UserHandle.myUserId(), group);
+ }
+
+ private void addPasswordPreferences(
+ Context prefContext, @UserIdInt int user, PreferenceGroup group) {
+ for (int i = 0; i < mServices.size(); i++) {
+ final AutofillServiceInfo service = mServices.get(i);
+ final Preference pref = new Preference(prefContext);
+ final ServiceInfo serviceInfo = service.getServiceInfo();
+ pref.setTitle(serviceInfo.loadLabel(mPm));
+ final Drawable icon =
+ mIconFactory.getBadgedIcon(
+ serviceInfo,
+ serviceInfo.applicationInfo,
+ user);
+ Utils.setSafeIcon(pref, icon);
+ pref.setIntent(
+ new Intent(Intent.ACTION_MAIN)
+ .setClassName(serviceInfo.packageName, service.getPasswordsActivity()));
+ group.addPreference(pref);
+ }
+ }
+}
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java b/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java
index 94736e4..1144f12 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java
@@ -16,6 +16,8 @@
package com.android.settings.applications.specialaccess.notificationaccess;
+import android.companion.ICompanionDeviceManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -30,8 +32,10 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.notification.NotificationBackend;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.LayoutPreference;
@@ -43,6 +47,10 @@
private PackageInfo mPackageInfo;
private PackageManager mPm;
private CharSequence mServiceName;
+ private ICompanionDeviceManager mCdm;
+ private LocalBluetoothManager mBm;
+ private ComponentName mCn;
+ private int mUserId;
public HeaderPreferenceController(Context context, String key) {
super(context, key);
@@ -68,6 +76,26 @@
return this;
}
+ public HeaderPreferenceController setCdm(ICompanionDeviceManager cdm) {
+ mCdm = cdm;
+ return this;
+ }
+
+ public HeaderPreferenceController setBluetoothManager(LocalBluetoothManager bm) {
+ mBm = bm;
+ return this;
+ }
+
+ public HeaderPreferenceController setCn(ComponentName cn) {
+ mCn = cn;
+ return this;
+ }
+
+ public HeaderPreferenceController setUserId(int userId) {
+ mUserId = userId;
+ return this;
+ }
+
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
@@ -88,6 +116,8 @@
.getBadgedIcon(mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mServiceName)
+ .setSecondSummary(new NotificationBackend().getDeviceList(
+ mCdm, mBm, mCn.getPackageName(), mUserId))
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
.setPackageName(mPackageInfo.packageName)
.setUid(mPackageInfo.applicationInfo.uid)
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java b/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java
index a205b57..1ac578d 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessDetails.java
@@ -21,7 +21,7 @@
import android.app.Activity;
import android.app.NotificationManager;
import android.app.settings.SettingsEnums;
-import android.bluetooth.BluetoothAdapter;
+import android.companion.ICompanionDeviceManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -30,6 +30,7 @@
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.os.Bundle;
+import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -45,14 +46,13 @@
import com.android.settings.SettingsActivity;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.applications.manageapplications.ManageApplications;
+import com.android.settings.bluetooth.Utils;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import java.util.Collection;
import java.util.List;
import java.util.Objects;
@@ -60,7 +60,6 @@
private static final String TAG = "NotifAccessDetails";
private NotificationBackend mNm = new NotificationBackend();
- private NotificationListenerFilter mNlf;
private ComponentName mComponentName;
private CharSequence mServiceName;
protected ServiceInfo mServiceInfo;
@@ -99,7 +98,12 @@
.setFragment(this)
.setPackageInfo(mPackageInfo)
.setPm(context.getPackageManager())
- .setServiceName(mServiceName);
+ .setServiceName(mServiceName)
+ .setBluetoothManager(Utils.getLocalBtManager(context))
+ .setCdm(ICompanionDeviceManager.Stub.asInterface(
+ ServiceManager.getService(Context.COMPANION_DEVICE_SERVICE)))
+ .setCn(mComponentName)
+ .setUserId(mUserId);
getPreferenceControllers().forEach(controllers -> {
controllers.forEach(controller -> {
if (controller instanceof TypeFilterPreferenceController) {
@@ -152,13 +156,6 @@
Preference apps = getPreferenceScreen().findPreference(
use(BridgedAppsPreferenceController.class).getPreferenceKey());
if (apps != null) {
- mNlf = mNm.getListenerFilter(mComponentName, mUserId);
- int nonBridgedCount = mNlf.getDisallowedPackages().size();
- apps.setSummary(nonBridgedCount == 0 ?
- getString(R.string.notif_listener_excluded_summary_zero)
- : getResources().getQuantityString(
- R.plurals.notif_listener_excluded_summary_nonzero,
- nonBridgedCount, nonBridgedCount));
apps.setOnPreferenceClickListener(preference -> {
final Bundle args = new Bundle();
@@ -169,7 +166,7 @@
new SubSettingLauncher(getContext())
.setDestination(BridgedAppsSettings.class.getName())
.setSourceMetricsCategory(getMetricsCategory())
- .setTitleRes(R.string.notif_listener_excluded_app_title)
+ .setTitleRes(R.string.notif_listener_excluded_app_screen_title)
.setArguments(args)
.setUserHandle(UserHandle.of(mUserId))
.launch();
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 7936f66..3fb8941 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -173,6 +173,10 @@
setHeaderText(resId, false /* force */);
}
+ protected void setDescriptionText(int resId) {
+ getLayout().setDescriptionText(resId);
+ }
+
protected FooterButton getNextButton() {
if (mFooterBarMixin != null) {
return mFooterBarMixin.getPrimaryButton();
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 26df474..09344b0 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -309,9 +309,8 @@
protected void initViews() {
super.initViews();
- TextView description = (TextView) findViewById(R.id.sud_layout_description);
if (mBiometricUnlockDisabledByAdmin) {
- description.setText(getDescriptionResDisabledByAdmin());
+ setDescriptionText(getDescriptionResDisabledByAdmin());
}
}
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 23a1133..0996a58 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -57,6 +57,8 @@
super.onCreate(savedInstanceState);
+ setDescriptionText(R.string.security_settings_fingerprint_enroll_introduction_message);
+
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
new FooterButton.Builder(this)
@@ -69,7 +71,7 @@
mFooterBarMixin.setPrimaryButton(
new FooterButton.Builder(this)
- .setText(R.string.wizard_next)
+ .setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
.setListener(this::onNextButtonClick)
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(R.style.SudGlifButton_Primary)
@@ -78,7 +80,7 @@
}
int getNegativeButtonTextId() {
- return R.string.security_settings_fingerprint_enroll_introduction_no_thanks;
+ return R.string.security_settings_fingerprint_enroll_introduction_skip;
}
@Override
diff --git a/src/com/android/settings/connecteddevice/usb/UsbBackend.java b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
index 4773aca..244818f 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbBackend.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
@@ -28,7 +28,7 @@
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPortStatus;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
import android.os.UserHandle;
import android.os.UserManager;
@@ -74,9 +74,8 @@
mIsAdminUser = userManager.isAdminUser();
mMidiSupported = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI);
- ConnectivityManager cm =
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- mTetheringSupported = cm.isTetheringSupported();
+ final TetheringManager tm = context.getSystemService(TetheringManager.class);
+ mTetheringSupported = tm.isTetheringSupported();
updatePorts();
}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java b/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
index 12e978f..de08f38 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
@@ -16,14 +16,17 @@
package com.android.settings.connecteddevice.usb;
-import static android.net.ConnectivityManager.TETHERING_USB;
+import static android.net.TetheringManager.TETHERING_USB;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerExecutor;
+import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen;
@@ -43,10 +46,13 @@
* Provides options for selecting the default USB mode.
*/
public class UsbDefaultFragment extends RadioButtonPickerFragment {
+
+ private static final String TAG = "UsbDefaultFragment";
+
@VisibleForTesting
UsbBackend mUsbBackend;
@VisibleForTesting
- ConnectivityManager mConnectivityManager;
+ TetheringManager mTetheringManager;
@VisibleForTesting
OnStartTetheringCallback mOnStartTetheringCallback = new OnStartTetheringCallback();
@VisibleForTesting
@@ -57,21 +63,32 @@
boolean mIsStartTethering = false;
private UsbConnectionBroadcastReceiver mUsbReceiver;
+ private Handler mHandler = new Handler();
+ private boolean mIsConnected = false;
@VisibleForTesting
UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
(connected, functions, powerRole, dataRole) -> {
+ final long defaultFunctions = mUsbBackend.getDefaultUsbFunctions();
+ Log.d(TAG, "UsbConnectionListener() connected : " + connected + ", functions : "
+ + functions + ", defaultFunctions : " + defaultFunctions);
+ if (connected && !mIsConnected && defaultFunctions == UsbManager.FUNCTION_RNDIS) {
+ startTethering();
+ }
+
if (mIsStartTethering) {
mCurrentFunctions = functions;
refresh(functions);
+ mIsStartTethering = false;
}
+ mIsConnected = connected;
};
@Override
public void onAttach(Context context) {
super.onAttach(context);
mUsbBackend = new UsbBackend(context);
- mConnectivityManager = context.getSystemService(ConnectivityManager.class);
+ mTetheringManager = context.getSystemService(TetheringManager.class);
mUsbReceiver = new UsbConnectionBroadcastReceiver(context, mUsbConnectionListener,
mUsbBackend);
getSettingsLifecycle().addObserver(mUsbReceiver);
@@ -138,10 +155,8 @@
if (!Utils.isMonkeyRunning()) {
if (functions == UsbManager.FUNCTION_RNDIS) {
// We need to have entitlement check for usb tethering, so use API in
- // ConnectivityManager.
- mIsStartTethering = true;
- mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
- mOnStartTetheringCallback);
+ // TetheringManager.
+ startTethering();
} else {
mIsStartTethering = false;
mCurrentFunctions = functions;
@@ -152,6 +167,13 @@
return true;
}
+ private void startTethering() {
+ Log.d(TAG, "startTethering()");
+ mIsStartTethering = true;
+ mTetheringManager.startTethering(TETHERING_USB, new HandlerExecutor(mHandler),
+ mOnStartTetheringCallback);
+ }
+
@Override
public void onPause() {
super.onPause();
@@ -159,20 +181,20 @@
}
@VisibleForTesting
- final class OnStartTetheringCallback extends
- ConnectivityManager.OnStartTetheringCallback {
+ final class OnStartTetheringCallback implements
+ TetheringManager.StartTetheringCallback {
@Override
public void onTetheringStarted() {
- super.onTetheringStarted();
+ Log.d(TAG, "onTetheringStarted()");
// Set default usb functions again to make internal data persistent
mCurrentFunctions = UsbManager.FUNCTION_RNDIS;
mUsbBackend.setDefaultUsbFunctions(UsbManager.FUNCTION_RNDIS);
}
@Override
- public void onTetheringFailed() {
- super.onTetheringFailed();
+ public void onTetheringFailed(int error) {
+ Log.w(TAG, "onTetheringFailed() error : " + error);
mUsbBackend.setDefaultUsbFunctions(mPreviousFunctions);
updateCandidates();
}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index 99e9d50..40626fb 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -17,11 +17,12 @@
package com.android.settings.connecteddevice.usb;
import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
-import static android.net.ConnectivityManager.TETHERING_USB;
import android.content.Context;
import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
+import android.os.Handler;
+import android.os.HandlerExecutor;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -55,7 +56,8 @@
}
private PreferenceCategory mProfilesContainer;
- private ConnectivityManager mConnectivityManager;
+ private TetheringManager mTetheringManager;
+ private Handler mHandler = new Handler();
@VisibleForTesting
OnStartTetheringCallback mOnStartTetheringCallback;
@VisibleForTesting
@@ -64,7 +66,7 @@
public UsbDetailsFunctionsController(Context context, UsbDetailsFragment fragment,
UsbBackend backend) {
super(context, fragment, backend);
- mConnectivityManager = context.getSystemService(ConnectivityManager.class);
+ mTetheringManager = context.getSystemService(TetheringManager.class);
mOnStartTetheringCallback = new OnStartTetheringCallback();
mPreviousFunction = mUsbBackend.getCurrentFunctions();
}
@@ -130,7 +132,7 @@
+ UsbManager.usbFunctionsToString(previousFunction));
}
if (function != previousFunction && !Utils.isMonkeyRunning()
- && !shouldIgnoreClickEvent(function, previousFunction)) {
+ && !isClickEventIgnored(function, previousFunction)) {
mPreviousFunction = previousFunction;
//Update the UI in advance to make it looks smooth
@@ -144,8 +146,9 @@
if (function == UsbManager.FUNCTION_RNDIS) {
// We need to have entitlement check for usb tethering, so use API in
- // ConnectivityManager.
- mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
+ // TetheringManager.
+ mTetheringManager.startTethering(
+ TetheringManager.TETHERING_USB, new HandlerExecutor(mHandler),
mOnStartTetheringCallback);
} else {
mUsbBackend.setCurrentFunctions(function);
@@ -153,7 +156,7 @@
}
}
- private boolean shouldIgnoreClickEvent(long function, long previousFunction) {
+ private boolean isClickEventIgnored(long function, long previousFunction) {
return isAccessoryMode(previousFunction) && function == UsbManager.FUNCTION_MTP;
}
@@ -172,12 +175,11 @@
}
@VisibleForTesting
- final class OnStartTetheringCallback extends
- ConnectivityManager.OnStartTetheringCallback {
+ final class OnStartTetheringCallback implements TetheringManager.StartTetheringCallback {
@Override
- public void onTetheringFailed() {
- super.onTetheringFailed();
+ public void onTetheringFailed(int error) {
+ Log.w(TAG, "onTetheringFailed() error : " + error);
mUsbBackend.setCurrentFunctions(mPreviousFunction);
}
}
diff --git a/src/com/android/settings/datausage/DataSaverBackend.java b/src/com/android/settings/datausage/DataSaverBackend.java
index f13e88e..e39e41a 100644
--- a/src/com/android/settings/datausage/DataSaverBackend.java
+++ b/src/com/android/settings/datausage/DataSaverBackend.java
@@ -20,10 +20,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.net.INetworkPolicyListener;
import android.net.NetworkPolicyManager;
-import android.os.RemoteException;
-import android.telephony.SubscriptionPlan;
import android.util.SparseIntArray;
import com.android.settings.overlay.FeatureFactory;
@@ -180,33 +177,17 @@
}
- private final INetworkPolicyListener mPolicyListener = new INetworkPolicyListener.Stub() {
- @Override
- public void onUidRulesChanged(int uid, int uidRules) throws RemoteException {
- }
-
+ private final NetworkPolicyManager.Listener mPolicyListener =
+ new NetworkPolicyManager.Listener() {
@Override
public void onUidPoliciesChanged(final int uid, final int uidPolicies) {
ThreadUtils.postOnMainThread(() -> handleUidPoliciesChanged(uid, uidPolicies));
}
@Override
- public void onMeteredIfacesChanged(String[] strings) throws RemoteException {
- }
-
- @Override
- public void onRestrictBackgroundChanged(final boolean isDataSaving) throws RemoteException {
+ public void onRestrictBackgroundChanged(final boolean isDataSaving) {
ThreadUtils.postOnMainThread(() -> handleRestrictBackgroundChanged(isDataSaving));
}
-
- @Override
- public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue,
- int[] networkTypes) {
- }
-
- @Override
- public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) {
- }
};
public interface Listener {
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 367e7c5..e34ae9b 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -200,8 +200,6 @@
mSwitchBar = ((SettingsActivity) getActivity()).getSwitchBar();
mSwitchBar.setTitle(getContext().getString(R.string.developer_options_main_switch_title));
mSwitchBar.show();
- mSwitchBar.setTranslationZ(
- getActivity().findViewById(R.id.main_content).getTranslationZ() + 1);
mSwitchBarController = new DevelopmentSwitchBarController(
this /* DevelopmentSettings */, mSwitchBar, mIsAvailable,
getSettingsLifecycle());
diff --git a/src/com/android/settings/display/AdaptiveSleepPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
index c0c5e63..e0527f9 100644
--- a/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
+++ b/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
@@ -20,6 +20,7 @@
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import android.Manifest;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -33,8 +34,10 @@
import com.android.settings.R;
import com.android.settings.bluetooth.RestrictionUtils;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.google.common.annotations.VisibleForTesting;
@@ -45,6 +48,7 @@
private RestrictionUtils mRestrictionUtils;
private PackageManager mPackageManager;
private Context mContext;
+ private MetricsFeatureProvider mMetricsFeatureProvider;
@VisibleForTesting
RestrictedSwitchPreference mPreference;
@@ -52,6 +56,7 @@
public AdaptiveSleepPreferenceController(Context context, RestrictionUtils restrictionUtils) {
mContext = context;
mRestrictionUtils = restrictionUtils;
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
mPreference = new RestrictedSwitchPreference(context);
mPreference.setTitle(R.string.adaptive_sleep_title);
mPreference.setSummary(R.string.adaptive_sleep_description);
@@ -60,6 +65,8 @@
mPreference.setKey(PREFERENCE_KEY);
mPreference.setOnPreferenceClickListener(preference -> {
final boolean isChecked = ((RestrictedSwitchPreference) preference).isChecked();
+ mMetricsFeatureProvider.action(context, SettingsEnums.ACTION_SCREEN_ATTENTION_CHANGED,
+ isChecked);
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ADAPTIVE_SLEEP, isChecked ? 1 : DEFAULT_VALUE);
return true;
diff --git a/src/com/android/settings/display/AutoRotateSwitchBarController.java b/src/com/android/settings/display/AutoRotateSwitchBarController.java
index 0931a10..e149ccb 100644
--- a/src/com/android/settings/display/AutoRotateSwitchBarController.java
+++ b/src/com/android/settings/display/AutoRotateSwitchBarController.java
@@ -93,7 +93,8 @@
private boolean setRotationLock(boolean isChecked) {
final boolean isLocked = !isChecked;
- mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_ROTATION_LOCK, isLocked);
+ mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_ROTATE_ROTATE_MASTER_TOGGLE,
+ isChecked);
RotationPolicy.setRotationLock(mContext, isLocked);
return true;
}
diff --git a/src/com/android/settings/display/ScreenTimeoutSettings.java b/src/com/android/settings/display/ScreenTimeoutSettings.java
index b518646..15b5466 100644
--- a/src/com/android/settings/display/ScreenTimeoutSettings.java
+++ b/src/com/android/settings/display/ScreenTimeoutSettings.java
@@ -26,12 +26,18 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.style.ClickableSpan;
import android.util.Log;
+import android.view.View;
+import androidx.annotation.NonNull;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpMenuController;
@@ -39,6 +45,7 @@
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.widget.CandidateInfo;
@@ -65,6 +72,7 @@
private CharSequence[] mInitialEntries;
private CharSequence[] mInitialValues;
private FooterPreference mPrivacyPreference;
+ private MetricsFeatureProvider mMetricsFeatureProvider;
@VisibleForTesting
RestrictedLockUtils.EnforcedAdmin mAdmin;
@@ -97,15 +105,7 @@
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
mPrivacyPreference.setSelectable(false);
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
-
- mDisableOptionsPreference = new FooterPreference(context);
- mDisableOptionsPreference.setLayoutResource(R.layout.preference_footer);
- mDisableOptionsPreference.setTitle(R.string.admin_disabled_other_options);
- mDisableOptionsPreference.setIcon(R.drawable.ic_info_outline_24dp);
-
- // The 'disabled by admin' preference should always be at the end of the setting page.
- mDisableOptionsPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE);
- mPrivacyPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE - 1);
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Override
@@ -138,14 +138,6 @@
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
- if (mAdmin != null) {
- mDisableOptionsPreference.setOnPreferenceClickListener(p -> {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
- return true;
- });
- screen.addPreference(mDisableOptionsPreference);
- }
-
final List<? extends CandidateInfo> candidateList = getCandidates();
if (candidateList == null) {
return;
@@ -165,14 +157,43 @@
}
if (mAdmin != null) {
- mDisableOptionsPreference.setOnPreferenceClickListener(p -> {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
- return true;
- });
+ setupDisabledFooterPreference();
screen.addPreference(mDisableOptionsPreference);
}
}
+ @VisibleForTesting
+ void setupDisabledFooterPreference() {
+ final String textDisabledByAdmin = getResources().getString(
+ R.string.admin_disabled_other_options);
+ final String textMoreDetails = getResources().getString(R.string.admin_more_details);
+
+ final SpannableString spannableString = new SpannableString(
+ textDisabledByAdmin + System.lineSeparator() + textMoreDetails);
+ final ClickableSpan clickableSpan = new ClickableSpan() {
+ @Override
+ public void onClick(@NonNull View widget) {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
+ }
+ };
+
+ if (textDisabledByAdmin != null && textMoreDetails != null) {
+ spannableString.setSpan(clickableSpan, textDisabledByAdmin.length() + 1,
+ textDisabledByAdmin.length() + textMoreDetails.length() + 1,
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+
+ mDisableOptionsPreference = new FooterPreference(getContext());
+ mDisableOptionsPreference.setLayoutResource(R.layout.preference_footer);
+ mDisableOptionsPreference.setTitle(spannableString);
+ mDisableOptionsPreference.setSelectable(false);
+ mDisableOptionsPreference.setIcon(R.drawable.ic_info_outline_24dp);
+
+ // The 'disabled by admin' preference should always be at the end of the setting page.
+ mDisableOptionsPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE);
+ mPrivacyPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE - 1);
+ }
+
@Override
protected String getDefaultKey() {
return getCurrentSystemScreenTimeout(getContext());
@@ -227,6 +248,8 @@
try {
if (context != null) {
final long value = Long.parseLong(key);
+ mMetricsFeatureProvider.action(context, SettingsEnums.ACTION_SCREEN_TIMEOUT_CHANGED,
+ (int) value);
Settings.System.putLong(context.getContentResolver(), SCREEN_OFF_TIMEOUT, value);
}
} catch (NumberFormatException e) {
diff --git a/src/com/android/settings/fuelgauge/BatterySaverController.java b/src/com/android/settings/fuelgauge/BatterySaverController.java
index a91f85c..fba163d 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverController.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverController.java
@@ -15,14 +15,21 @@
*/
package com.android.settings.fuelgauge;
+import android.content.ContentResolver;
import android.content.Context;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.os.Looper;
import android.os.PowerManager;
+import android.provider.Settings;
+import android.provider.Settings.Global;
-import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
-import com.android.settings.core.TogglePreferenceController;
-import com.android.settings.widget.PrimarySwitchPreference;
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -31,14 +38,19 @@
/**
* Controller to update the battery saver entry preference.
*/
-public class BatterySaverController extends TogglePreferenceController
+public class BatterySaverController extends BasePreferenceController
implements LifecycleObserver, OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
private static final String KEY_BATTERY_SAVER = "battery_saver_summary";
private final BatterySaverReceiver mBatteryStateChangeReceiver;
private final PowerManager mPowerManager;
-
- @VisibleForTesting
- PrimarySwitchPreference mBatterySaverPref;
+ private Preference mBatterySaverPref;
+ private final ContentObserver mObserver = new ContentObserver(
+ new Handler(Looper.getMainLooper())) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updateSummary();
+ }
+ };
public BatterySaverController(Context context) {
super(context, KEY_BATTERY_SAVER);
@@ -67,38 +79,54 @@
@Override
public void onStart() {
+ mContext.getContentResolver().registerContentObserver(
+ Settings.Global.getUriFor(Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL),
+ true /* notifyForDescendants */, mObserver);
mBatteryStateChangeReceiver.setListening(true);
+ updateSummary();
}
@Override
public void onStop() {
+ mContext.getContentResolver().unregisterContentObserver(mObserver);
mBatteryStateChangeReceiver.setListening(false);
}
@Override
- public void onPowerSaveModeChanged() {
- final boolean isChecked = isChecked();
- if (mBatterySaverPref != null && mBatterySaverPref.isChecked() != isChecked) {
- mBatterySaverPref.setChecked(isChecked);
+ public CharSequence getSummary() {
+ final boolean isPowerSaveOn = mPowerManager.isPowerSaveMode();
+ if (isPowerSaveOn) {
+ return mContext.getString(R.string.battery_saver_on_summary);
}
+
+ final ContentResolver resolver = mContext.getContentResolver();
+ final int mode = Settings.Global.getInt(resolver,
+ Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
+ if (mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) {
+ final int percent = Settings.Global.getInt(resolver,
+ Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+ return percent != 0 ?
+ mContext.getString(R.string.battery_saver_off_scheduled_summary,
+ Utils.formatPercentage(percent)) :
+ mContext.getString(R.string.battery_saver_off_summary);
+ } else {
+ return mContext.getString(R.string.battery_saver_auto_routine);
+ }
+ }
+
+ private void updateSummary() {
+ if (mBatterySaverPref != null) {
+ mBatterySaverPref.setSummary(getSummary());
+ }
+ }
+
+ @Override
+ public void onPowerSaveModeChanged() {
+ updateSummary();
}
@Override
public void onBatteryChanged(boolean pluggedIn) {
- if (mBatterySaverPref != null) {
- mBatterySaverPref.setSwitchEnabled(!pluggedIn);
- }
- }
-
- @Override
- public boolean isChecked() {
- return mPowerManager.isPowerSaveMode();
- }
-
- @Override
- public boolean setChecked(boolean stateOn) {
- return BatterySaverUtils.setPowerSaveMode(mContext, stateOn,
- false /* needFirstTimeWarning */);
}
}
diff --git a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
index 245118d..f4ef0eb 100644
--- a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
@@ -85,7 +85,8 @@
final Context prefContext = mCategoryRecentLocationRequests.getContext();
final List<RecentLocationAccesses.Access> recentLocationAccesses = new ArrayList<>();
final UserManager userManager = UserManager.get(mContext);
- for (RecentLocationAccesses.Access access : mRecentLocationApps.getAppListSorted()) {
+ for (RecentLocationAccesses.Access access : mRecentLocationApps.getAppListSorted(
+ /* showSystemApps= */ false)) {
if (isRequestMatchesProfileType(userManager, access, mType)) {
recentLocationAccesses.add(access);
}
diff --git a/src/com/android/settings/network/AllowedNetworkTypesListener.java b/src/com/android/settings/network/AllowedNetworkTypesListener.java
index a11f3b4..a9ed8be 100644
--- a/src/com/android/settings/network/AllowedNetworkTypesListener.java
+++ b/src/com/android/settings/network/AllowedNetworkTypesListener.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -28,14 +29,14 @@
/**
- * {@link PhoneStateListener} to listen to Allowed Network Types changed
+ * {@link TelephonyCallback} to listen to Allowed Network Types changed
*/
-public class AllowedNetworkTypesListener extends PhoneStateListener implements
- PhoneStateListener.AllowedNetworkTypesChangedListener {
+public class AllowedNetworkTypesListener extends TelephonyCallback implements
+ TelephonyCallback.AllowedNetworkTypesListener {
private static final String LOG_TAG = "NetworkModeListener";
@VisibleForTesting
- AllowedNetworkTypesListener.OnAllowedNetworkTypesChangedListener mListener;
+ OnAllowedNetworkTypesListener mListener;
private long mAllowedNetworkType = -1;
private Executor mExecutor;
@@ -44,7 +45,7 @@
mExecutor = executor;
}
- public void setAllowedNetworkTypesChangedListener(OnAllowedNetworkTypesChangedListener lsn) {
+ public void setAllowedNetworkTypesListener(OnAllowedNetworkTypesListener lsn) {
mListener = lsn;
}
@@ -56,7 +57,7 @@
public void register(Context context, int subId) {
TelephonyManager telephonyManager = context.getSystemService(
TelephonyManager.class).createForSubscriptionId(subId);
- telephonyManager.registerPhoneStateListener(mExecutor, this);
+ telephonyManager.registerTelephonyCallback(mExecutor, this);
}
/**
@@ -67,7 +68,7 @@
public void unregister(Context context, int subId) {
TelephonyManager telephonyManager = context.getSystemService(
TelephonyManager.class).createForSubscriptionId(subId);
- telephonyManager.unregisterPhoneStateListener(this);
+ telephonyManager.unregisterTelephonyCallback(this);
}
@Override
@@ -84,7 +85,7 @@
/**
* Listener for update of Preferred Network Mode change
*/
- public interface OnAllowedNetworkTypesChangedListener {
+ public interface OnAllowedNetworkTypesListener {
/**
* Notify the allowed network type changed.
*/
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index c020f06..a1fdb1c 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -83,8 +83,9 @@
// Second section: Add a carrier item.
// Third section: Add the Wi-Fi items which are not connected.
// Fourth section: If device has connection problem, this row show the message for user.
+ boolean hasEthernet = isEthernetConnected();
final ListBuilder listBuilder = mHelper.createListBuilder(getUri());
- if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled()) {
+ if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled() && !hasEthernet) {
log("Airplane mode is enabled.");
return listBuilder.build();
}
@@ -104,12 +105,12 @@
log("hasCarrier: " + hasCarrier);
// First section: Add a Ethernet or Wi-Fi item which state is connected.
- if (isEthernetConnected()) {
+ final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
+ if (hasEthernet) {
log("get Ethernet item which is connected");
listBuilder.addRow(createEthernetRow());
maxListSize--;
} else {
- final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
if (connectedWifiItem != null) {
log("get Wi-Fi item which is connected");
listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
@@ -126,7 +127,14 @@
maxListSize--;
}
- // Third section: Add the Wi-Fi items which are not connected.
+ // Third section: Add the connected Wi-Fi item to Wi-Fi list if the Ethernet is connected.
+ if (connectedWifiItem != null && hasEthernet) {
+ log("get Wi-Fi item which is connected");
+ listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
+ maxListSize--;
+ }
+
+ // Fourth section: Add the Wi-Fi items which are not connected.
if (wifiList != null && wifiList.size() > 0) {
log("get Wi-Fi items which are not connected. Wi-Fi items : " + wifiList.size());
@@ -140,7 +148,7 @@
}
}
- // Fourth section: If device has connection problem, this row show the message for user.
+ // Fifth section: If device has connection problem, this row show the message for user.
// 1) show non_carrier_network_unavailable:
// - while no wifi item
// 2) show all_network_unavailable:
@@ -154,7 +162,7 @@
resId = R.string.all_network_unavailable;
}
- if (!hasCarrier) {
+ if (!hasCarrier && !hasEthernet) {
// If there is no item in ProviderModelItem, slice needs a header.
listBuilder.setHeader(mHelper.createHeader(
NetworkProviderSettings.ACTION_NETWORK_PROVIDER_SETTINGS));
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index aa70459..be8f257 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -70,6 +70,9 @@
if (sActiveResultsForTesting != null) {
return sActiveResultsForTesting;
}
+ if (manager == null) {
+ return Collections.emptyList();
+ }
final List<SubscriptionInfo> subscriptions = manager.getActiveSubscriptionInfoList();
if (subscriptions == null) {
return new ArrayList<>();
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 392ccc6..f89ccfd 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -257,9 +257,10 @@
}
private CharSequence getMobilePreferenceSummary(int subId) {
+ TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId);
String result = mSubsPrefCtrlInjector.getNetworkType(
mContext, mConfig, mTelephonyDisplayInfo, subId);
- if (!mTelephonyManager.isDataEnabled()) {
+ if (!tm.isDataEnabled()) {
return mContext.getString(R.string.mobile_data_off_summary);
}
if (!result.isEmpty() && mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext)) {
diff --git a/src/com/android/settings/network/ims/VolteQueryImsState.java b/src/com/android/settings/network/ims/VolteQueryImsState.java
index 167b4b1..b09a130 100644
--- a/src/com/android/settings/network/ims/VolteQueryImsState.java
+++ b/src/com/android/settings/network/ims/VolteQueryImsState.java
@@ -16,11 +16,14 @@
package com.android.settings.network.ims;
+import static android.telephony.ims.ProvisioningManager.KEY_VOIMS_OPT_IN_STATUS;
+
import android.content.Context;
import android.telecom.TelecomManager;
import android.telephony.AccessNetworkConstants;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsException;
+import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.feature.MmTelFeature;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
@@ -133,4 +136,15 @@
}
return isEnabledByUser(mSubId);
}
+
+ /**
+ * Get VoIMS opt-in configuration.
+ *
+ * @return true when VoIMS opt-in has been enabled, otherwise false
+ */
+ public boolean isVoImsOptInEnabled() {
+ int voImsOptInStatus = ProvisioningManager.createForSubscriptionId(mSubId)
+ .getProvisioningIntValue(KEY_VOIMS_OPT_IN_STATUS);
+ return voImsOptInStatus == ProvisioningManager.PROVISIONING_VALUE_ENABLED;
+ }
}
diff --git a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
index 2c6c963..8d037fb 100644
--- a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
@@ -32,6 +32,7 @@
import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;
+import java.util.List;
import java.util.Objects;
/**
@@ -67,14 +68,22 @@
@Override
public int getAvailabilityStatus(int subId) {
- return hasBackupCallingFeature(subId) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ if (!hasBackupCallingFeature(subId)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ List<SubscriptionInfo> subIdList = getActiveSubscriptionList();
+ SubscriptionInfo subInfo = getSubscriptionInfoFromList(subIdList, subId);
+ if (subInfo == null) { // given subId is not actives
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ return (subIdList.size() > 1) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
/**
* Implementation of abstract methods
**/
public boolean setChecked(boolean isChecked) {
- ImsMmTelManager imsMmTelMgr = getImsMmTelManager();
+ ImsMmTelManager imsMmTelMgr = getImsMmTelManager(mSubId);
if (imsMmTelMgr == null) {
return false;
}
@@ -92,7 +101,7 @@
* Implementation of abstract methods
**/
public boolean isChecked() {
- ImsMmTelManager imsMmTelMgr = getImsMmTelManager();
+ ImsMmTelManager imsMmTelMgr = getImsMmTelManager(mSubId);
if (imsMmTelMgr == null) {
return false;
}
@@ -110,16 +119,17 @@
if ((preference == null) || (!(preference instanceof SwitchPreference))) {
return;
}
+ SubscriptionInfo subInfo = getSubscriptionInfoFromActiveList(mSubId);
+
mPreference = preference;
final SwitchPreference switchPreference = (SwitchPreference) preference;
- switchPreference.setChecked(isChecked());
+ switchPreference.setChecked((subInfo != null) ? isChecked() : false);
- updateSummary(getLatestSummary());
+ updateSummary(getLatestSummary(subInfo));
}
- private String getLatestSummary() {
- SubscriptionInfo subInfo = getSubscriptionInfo();
+ private String getLatestSummary(SubscriptionInfo subInfo) {
return Objects.toString((subInfo == null) ? null
: SubscriptionUtil.getUniqueSubscriptionDisplayName(subInfo, mContext), "");
}
@@ -144,19 +154,34 @@
CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, false);
}
- private ImsMmTelManager getImsMmTelManager() {
- if (!SubscriptionManager.isUsableSubscriptionId(mSubId)) {
+ private ImsMmTelManager getImsMmTelManager(int subId) {
+ if (!SubscriptionManager.isUsableSubscriptionId(subId)) {
return null;
}
ImsManager imsMgr = mContext.getSystemService(ImsManager.class);
- return (imsMgr == null) ? null : imsMgr.getImsMmTelManager(mSubId);
+ return (imsMgr == null) ? null : imsMgr.getImsMmTelManager(subId);
}
- private SubscriptionInfo getSubscriptionInfo() {
- SubscriptionManager subInfoMgr = mContext.getSystemService(SubscriptionManager.class);
- if (subInfoMgr == null) {
+ private List<SubscriptionInfo> getActiveSubscriptionList() {
+ SubscriptionManager subscriptionManager =
+ mContext.getSystemService(SubscriptionManager.class);
+ return SubscriptionUtil.getActiveSubscriptions(subscriptionManager);
+ }
+
+ private SubscriptionInfo getSubscriptionInfoFromList(
+ List<SubscriptionInfo> subInfoList, int subId) {
+ for (SubscriptionInfo subInfo : subInfoList) {
+ if ((subInfo != null) && (subInfo.getSubscriptionId() == subId)) {
+ return subInfo;
+ }
+ }
+ return null;
+ }
+
+ private SubscriptionInfo getSubscriptionInfoFromActiveList(int subId) {
+ if (!SubscriptionManager.isUsableSubscriptionId(subId)) {
return null;
}
- return subInfoMgr.getActiveSubscriptionInfo(mSubId);
+ return getSubscriptionInfoFromList(getActiveSubscriptionList(), subId);
}
}
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 5680bf6..f0d4a43 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -151,7 +151,7 @@
if (mAllowedNetworkTypesListener == null) {
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
mContext.getMainExecutor());
- mAllowedNetworkTypesListener.setAllowedNetworkTypesChangedListener(
+ mAllowedNetworkTypesListener.setAllowedNetworkTypesListener(
() -> updatePreference());
}
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index fbbdabc..c2b1fc4 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -107,12 +107,18 @@
if (!isModeMatched()) {
return CONDITIONALLY_UNAVAILABLE;
}
+ final VolteQueryImsState queryState = queryImsState(subId);
+ // Show VoLTE settings if VoIMS opt-in has been enabled irrespective of other VoLTE settings
+ if (queryState.isVoImsOptInEnabled()) {
+ return AVAILABLE;
+ }
+
final PersistableBundle carrierConfig = getCarrierConfigForSubId(subId);
if ((carrierConfig == null)
|| carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL)) {
return CONDITIONALLY_UNAVAILABLE;
}
- final VolteQueryImsState queryState = queryImsState(subId);
+
if (!queryState.isReadyToVoLte()) {
return CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/NetworkPreferenceCategoryController.java b/src/com/android/settings/network/telephony/NetworkPreferenceCategoryController.java
index 25651f5..4ebcb7a 100644
--- a/src/com/android/settings/network/telephony/NetworkPreferenceCategoryController.java
+++ b/src/com/android/settings/network/telephony/NetworkPreferenceCategoryController.java
@@ -45,7 +45,7 @@
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
context.getMainExecutor());
- mAllowedNetworkTypesListener.setAllowedNetworkTypesChangedListener(
+ mAllowedNetworkTypesListener.setAllowedNetworkTypesListener(
() -> updatePreference());
}
diff --git a/src/com/android/settings/network/telephony/NetworkProviderWorker.java b/src/com/android/settings/network/telephony/NetworkProviderWorker.java
index 9e23c7c..57f17b5 100644
--- a/src/com/android/settings/network/telephony/NetworkProviderWorker.java
+++ b/src/com/android/settings/network/telephony/NetworkProviderWorker.java
@@ -25,9 +25,9 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
-import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyCallback;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -62,7 +62,7 @@
private final Context mContext;
final Handler mHandler;
@VisibleForTesting
- final PhoneStateListener mPhoneStateListener;
+ final NetworkProviderTelephonyCallback mTelephonyCallback;
private TelephonyManager mTelephonyManager;
private Config mConfig = null;
private TelephonyDisplayInfo mTelephonyDisplayInfo =
@@ -82,7 +82,7 @@
mTelephonyManager = mContext.getSystemService(
TelephonyManager.class).createForSubscriptionId(mDefaultDataSubid);
- mPhoneStateListener = new NetworkProviderPhoneStateListener();
+ mTelephonyCallback = new NetworkProviderTelephonyCallback();
mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
mDataEnabledListener = new MobileDataEnabledListener(context, this);
mConnectivityListener = new DataConnectivityListener(context, this);
@@ -100,7 +100,7 @@
mDataEnabledListener.start(mDefaultDataSubid);
mConnectivityListener.start();
mSignalStrengthListener.resume();
- mTelephonyManager.registerPhoneStateListener(mHandler::post, mPhoneStateListener);
+ mTelephonyManager.registerTelephonyCallback(mHandler::post, mTelephonyCallback);
super.onSlicePinned();
}
@@ -111,7 +111,7 @@
mDataEnabledListener.stop();
mConnectivityListener.stop();
mSignalStrengthListener.pause();
- mTelephonyManager.unregisterPhoneStateListener(mPhoneStateListener);
+ mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
super.onSliceUnpinned();
}
@@ -141,12 +141,12 @@
return;
}
if (SubscriptionManager.isUsableSubscriptionId(defaultDataSubId)) {
- mTelephonyManager.unregisterPhoneStateListener(mPhoneStateListener);
+ mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
mMobileDataObserver.unregister(mContext);
mSignalStrengthListener.updateSubscriptionIds(Collections.singleton(defaultDataSubId));
mTelephonyManager = mTelephonyManager.createForSubscriptionId(defaultDataSubId);
- mTelephonyManager.registerPhoneStateListener(mHandler::post, mPhoneStateListener);
+ mTelephonyManager.registerTelephonyCallback(mHandler::post, mTelephonyCallback);
mMobileDataObserver.register(mContext, mDefaultDataSubid);
mConfig = getConfig(mContext);
} else {
@@ -216,10 +216,10 @@
}
}
- class NetworkProviderPhoneStateListener extends PhoneStateListener implements
- PhoneStateListener.DataConnectionStateChangedListener,
- PhoneStateListener.DisplayInfoChangedListener,
- PhoneStateListener.ServiceStateChangedListener {
+ class NetworkProviderTelephonyCallback extends TelephonyCallback implements
+ TelephonyCallback.DataConnectionStateListener,
+ TelephonyCallback.DisplayInfoListener,
+ TelephonyCallback.ServiceStateListener {
@Override
public void onServiceStateChanged(ServiceState state) {
Log.d(TAG, "onServiceStateChanged voiceState=" + state.getState()
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
index 06c3edb..4d1d319 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
@@ -77,7 +77,7 @@
if (mAllowedNetworkTypesListener == null) {
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
mContext.getMainExecutor());
- mAllowedNetworkTypesListener.setAllowedNetworkTypesChangedListener(
+ mAllowedNetworkTypesListener.setAllowedNetworkTypesListener(
() -> updatePreference());
}
}
diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index 19302da..997235c 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -81,7 +81,7 @@
mUiHandler = new Handler(Looper.getMainLooper());
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
new HandlerExecutor(mUiHandler));
- mAllowedNetworkTypesListener.setAllowedNetworkTypesChangedListener(
+ mAllowedNetworkTypesListener.setAllowedNetworkTypesListener(
() -> updatePreference());
}
diff --git a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
index 1b77c6d..cdeb1e5 100644
--- a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
@@ -60,7 +60,7 @@
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
mAllowedNetworkTypesListener = new AllowedNetworkTypesListener(
context.getMainExecutor());
- mAllowedNetworkTypesListener.setAllowedNetworkTypesChangedListener(
+ mAllowedNetworkTypesListener.setAllowedNetworkTypesListener(
() -> updatePreference());
}
diff --git a/src/com/android/settings/notification/NotificationAccessSettings.java b/src/com/android/settings/notification/NotificationAccessSettings.java
index 12d6295..a642d9c 100644
--- a/src/com/android/settings/notification/NotificationAccessSettings.java
+++ b/src/com/android/settings/notification/NotificationAccessSettings.java
@@ -20,12 +20,14 @@
import android.app.NotificationManager;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
+import android.companion.ICompanionDeviceManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.os.Bundle;
+import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -35,6 +37,7 @@
import android.view.View;
import android.widget.Toast;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -57,6 +60,9 @@
@SearchIndexable
public class NotificationAccessSettings extends EmptyTextSettings {
private static final String TAG = "NotifAccessSettings";
+ private static final String ALLOWED_KEY = "allowed";
+ private static final String NOT_ALLOWED_KEY = "not_allowed";
+
private static final ManagedServiceSettings.Config CONFIG =
new ManagedServiceSettings.Config.Builder()
.setTag(TAG)
@@ -76,6 +82,7 @@
private DevicePolicyManager mDpm;
private ServiceListing mServiceListing;
private IconDrawableFactory mIconDrawableFactory;
+ private NotificationBackend mBackend = new NotificationBackend();
@Override
public void onCreate(Bundle icicle) {
@@ -93,7 +100,6 @@
.setTag(CONFIG.tag)
.build();
mServiceListing.addCallback(this::updateList);
- setPreferenceScreen(getPreferenceManager().createPreferenceScreen(mContext));
if (UserManager.get(mContext).isManagedProfile()) {
// Apps in the work profile do not support notification listeners.
@@ -127,7 +133,11 @@
final int managedProfileId = Utils.getManagedProfileId(um, UserHandle.myUserId());
final PreferenceScreen screen = getPreferenceScreen();
- screen.removeAll();
+ final PreferenceCategory allowedCategory = screen.findPreference(ALLOWED_KEY);
+ allowedCategory.removeAll();
+ final PreferenceCategory notAllowedCategory = screen.findPreference(NOT_ALLOWED_KEY);
+ notAllowedCategory.removeAll();
+
services.sort(new PackageItemInfo.DisplayNameComparator(mPm));
for (ServiceInfo service : services) {
final ComponentName cn = new ComponentName(service.packageName, service.name);
@@ -145,9 +155,11 @@
pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo,
UserHandle.getUserId(service.applicationInfo.uid)));
pref.setKey(cn.flattenToString());
- pref.setSummary(mNm.isNotificationListenerAccessGranted(cn)
- ? R.string.app_permission_summary_allowed
- : R.string.app_permission_summary_not_allowed);
+ pref.setSummary(mBackend.getDeviceList(ICompanionDeviceManager.Stub.asInterface(
+ ServiceManager.getService(Context.COMPANION_DEVICE_SERVICE)),
+ com.android.settings.bluetooth.Utils.getLocalBtManager(mContext),
+ service.packageName,
+ UserHandle.myUserId()));
if (managedProfileId != UserHandle.USER_NULL
&& !mDpm.isNotificationListenerServicePermitted(
service.packageName, managedProfileId)) {
@@ -173,7 +185,11 @@
return true;
});
pref.setKey(cn.flattenToString());
- screen.addPreference(pref);
+ if (mNm.isNotificationListenerAccessGranted(cn)) {
+ allowedCategory.addPreference(pref);
+ } else {
+ notAllowedCategory.addPreference(pref);
+ }
}
highlightPreferenceIfNeeded();
}
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 8a7e737..4347ca5 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -30,6 +30,7 @@
import android.app.role.RoleManager;
import android.app.usage.IUsageStatsManager;
import android.app.usage.UsageEvents;
+import android.companion.ICompanionDeviceManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -55,14 +56,18 @@
import com.android.settingslib.R;
import com.android.settingslib.Utils;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.notification.ConversationIconFactory;
import com.android.settingslib.utils.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
public class NotificationBackend {
private static final String TAG = "NotificationBackend";
@@ -138,6 +143,35 @@
}
}
+ static public CharSequence getDeviceList(ICompanionDeviceManager cdm, LocalBluetoothManager lbm,
+ String pkg, int userId) {
+ boolean multiple = false;
+ StringBuilder sb = new StringBuilder();
+
+ try {
+ List<String> associatedMacAddrs = cdm.getAssociations(pkg, userId);
+ if (associatedMacAddrs != null) {
+ for (String assocMac : associatedMacAddrs) {
+ final Collection<CachedBluetoothDevice> cachedDevices =
+ lbm.getCachedDeviceManager().getCachedDevicesCopy();
+ for (CachedBluetoothDevice cachedBluetoothDevice : cachedDevices) {
+ if (Objects.equals(assocMac, cachedBluetoothDevice.getAddress())) {
+ if (multiple) {
+ sb.append(", ");
+ } else {
+ multiple = true;
+ }
+ sb.append(cachedBluetoothDevice.getName());
+ }
+ }
+ }
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "Error calling CDM", e);
+ }
+ return sb.toString();
+ }
+
public boolean isSystemApp(Context context, ApplicationInfo app) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
diff --git a/src/com/android/settings/security/RequestManageCredentials.java b/src/com/android/settings/security/RequestManageCredentials.java
index 4ee4fdf..eb7a7d8 100644
--- a/src/com/android/settings/security/RequestManageCredentials.java
+++ b/src/com/android/settings/security/RequestManageCredentials.java
@@ -208,7 +208,7 @@
.write();
finishWithResultCancelled();
});
- allowButton.setOnClickListener(b -> setOrUpdateCredentialManagementApp());
+ allowButton.setOnClickListener(b -> setOrUpdateCredentialManagementAppAndFinish());
}
private void loadExtendedFloatingActionButton() {
@@ -220,13 +220,14 @@
});
}
- private void setOrUpdateCredentialManagementApp() {
+ private void setOrUpdateCredentialManagementAppAndFinish() {
try {
mKeyChainConnection.getService().setCredentialManagementApp(
mCredentialManagerPackage, mAuthenticationPolicy);
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.CREDENTIAL_MANAGEMENT_APP_REQUEST_ACCEPTED)
.write();
+ setResult(RESULT_OK);
} catch (RemoteException e) {
Log.e(TAG, "Unable to set credential manager app", e);
logRequestFailure();
diff --git a/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java b/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
index 9c45ef4..e8eab68 100644
--- a/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
+++ b/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
@@ -28,6 +28,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
@@ -88,6 +89,10 @@
if (key != null) {
if (key instanceof PrivateKey) {
mKeyCertAliases.add(alias);
+ final Certificate[] cert = keyStore.getCertificateChain(alias);
+ if (cert != null && cert.length >= 2) {
+ mCaCertAliases.add(alias);
+ }
}
} else {
if (keyStore.getCertificate(alias) != null) {
diff --git a/src/com/android/settings/vpn2/ConfigDialog.java b/src/com/android/settings/vpn2/ConfigDialog.java
index a0c7a1e..42bc67d 100644
--- a/src/com/android/settings/vpn2/ConfigDialog.java
+++ b/src/com/android/settings/vpn2/ConfigDialog.java
@@ -24,8 +24,6 @@
import android.net.ProxyInfo;
import android.os.Bundle;
import android.os.SystemProperties;
-import android.security.Credentials;
-import android.security.KeyStore;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
@@ -42,10 +40,12 @@
import com.android.internal.net.VpnProfile;
import com.android.net.module.util.ProxyUtils;
import com.android.settings.R;
+import com.android.settings.utils.AndroidKeystoreAliasLoader;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
/**
@@ -58,7 +58,7 @@
class ConfigDialog extends AlertDialog implements TextWatcher,
View.OnClickListener, AdapterView.OnItemSelectedListener,
CompoundButton.OnCheckedChangeListener {
- private final KeyStore mKeyStore = KeyStore.getInstance();
+ private static final String TAG = "ConfigDialog";
private final DialogInterface.OnClickListener mListener;
private final VpnProfile mProfile;
@@ -153,10 +153,13 @@
mL2tpSecret.setTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
mIpsecIdentifier.setText(mProfile.ipsecIdentifier);
mIpsecSecret.setText(mProfile.ipsecSecret);
- loadCertificates(mIpsecUserCert, Credentials.USER_PRIVATE_KEY, 0, mProfile.ipsecUserCert);
- loadCertificates(mIpsecCaCert, Credentials.CA_CERTIFICATE,
+ AndroidKeystoreAliasLoader androidKeystoreAliasLoader =
+ new AndroidKeystoreAliasLoader(null);
+ loadCertificates(mIpsecUserCert, androidKeystoreAliasLoader.getKeyCertAliases(), 0,
+ mProfile.ipsecUserCert);
+ loadCertificates(mIpsecCaCert, androidKeystoreAliasLoader.getCaCertAliases(),
R.string.vpn_no_ca_cert, mProfile.ipsecCaCert);
- loadCertificates(mIpsecServerCert, Credentials.USER_CERTIFICATE,
+ loadCertificates(mIpsecServerCert, androidKeystoreAliasLoader.getKeyCertAliases(),
R.string.vpn_no_server_cert, mProfile.ipsecServerCert);
mSaveLogin.setChecked(mProfile.saveLogin);
mAlwaysOnVpn.setChecked(mProfile.key.equals(VpnUtils.getLockdownVpn()));
@@ -511,27 +514,30 @@
typeSpinner.setAdapter(adapter);
}
- private void loadCertificates(Spinner spinner, String prefix, int firstId, String selected) {
+ private void loadCertificates(Spinner spinner, Collection<String> choices, int firstId,
+ String selected) {
Context context = getContext();
String first = (firstId == 0) ? "" : context.getString(firstId);
- String[] certificates = mKeyStore.list(prefix);
+ String[] myChoices;
- if (certificates == null || certificates.length == 0) {
- certificates = new String[] {first};
+ if (choices == null || choices.size() == 0) {
+ myChoices = new String[] {first};
} else {
- String[] array = new String[certificates.length + 1];
- array[0] = first;
- System.arraycopy(certificates, 0, array, 1, certificates.length);
- certificates = array;
+ myChoices = new String[choices.size() + 1];
+ myChoices[0] = first;
+ int i = 1;
+ for (String c : choices) {
+ myChoices[i++] = c;
+ }
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
- context, android.R.layout.simple_spinner_item, certificates);
+ context, android.R.layout.simple_spinner_item, myChoices);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
- for (int i = 1; i < certificates.length; ++i) {
- if (certificates[i].equals(selected)) {
+ for (int i = 1; i < myChoices.length; ++i) {
+ if (myChoices[i].equals(selected)) {
spinner.setSelection(i);
break;
}
diff --git a/src/com/android/settings/vpn2/ConfigDialogFragment.java b/src/com/android/settings/vpn2/ConfigDialogFragment.java
index f339a69..b8825fe 100644
--- a/src/com/android/settings/vpn2/ConfigDialogFragment.java
+++ b/src/com/android/settings/vpn2/ConfigDialogFragment.java
@@ -25,7 +25,7 @@
import android.os.RemoteException;
import android.os.UserHandle;
import android.security.Credentials;
-import android.security.KeyStore;
+import android.security.LegacyVpnProfileStore;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
@@ -151,9 +151,8 @@
return;
}
- // Delete from KeyStore
- KeyStore keyStore = KeyStore.getInstance();
- keyStore.delete(Credentials.VPN + profile.key, KeyStore.UID_SELF);
+ // Delete from profile store.
+ LegacyVpnProfileStore.remove(Credentials.VPN + profile.key);
updateLockdownVpn(false, profile);
}
@@ -188,8 +187,7 @@
}
private void save(VpnProfile profile, boolean lockdown) {
- KeyStore.getInstance().put(Credentials.VPN + profile.key, profile.encode(),
- KeyStore.UID_SELF, /* flags */ 0);
+ LegacyVpnProfileStore.put(Credentials.VPN + profile.key, profile.encode());
// Flush out old version of profile
disconnect(profile);
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 0a3b2b0..7635733 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -41,7 +41,7 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.security.Credentials;
-import android.security.KeyStore;
+import android.security.LegacyVpnProfileStore;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
@@ -57,7 +57,6 @@
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnProfile;
-import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.widget.GearPreference;
@@ -94,8 +93,6 @@
private UserManager mUserManager;
private VpnManager mVpnManager;
- private final KeyStore mKeyStore = KeyStore.getInstance();
-
private Map<String, LegacyVpnPreference> mLegacyVpnPreferences = new ArrayMap<>();
private Map<AppVpnInfo, AppPreference> mAppPreferences = new ArrayMap<>();
@@ -222,7 +219,7 @@
final Context context = activity.getApplicationContext();
// Run heavy RPCs before switching to UI thread
- final List<VpnProfile> vpnProfiles = loadVpnProfiles(mKeyStore);
+ final List<VpnProfile> vpnProfiles = loadVpnProfiles();
final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */ true);
final Map<String, LegacyVpnInfo> connectedLegacyVpns = getConnectedLegacyVpns();
@@ -540,12 +537,13 @@
return result;
}
- static List<VpnProfile> loadVpnProfiles(KeyStore keyStore, int... excludeTypes) {
+ private static List<VpnProfile> loadVpnProfiles() {
final ArrayList<VpnProfile> result = Lists.newArrayList();
- for (String key : keyStore.list(Credentials.VPN)) {
- final VpnProfile profile = VpnProfile.decode(key, keyStore.get(Credentials.VPN + key));
- if (profile != null && !ArrayUtils.contains(excludeTypes, profile.type)) {
+ for (String key : LegacyVpnProfileStore.list(Credentials.VPN)) {
+ final VpnProfile profile = VpnProfile.decode(key,
+ LegacyVpnProfileStore.get(Credentials.VPN + key));
+ if (profile != null) {
result.add(profile);
}
}
diff --git a/src/com/android/settings/vpn2/VpnUtils.java b/src/com/android/settings/vpn2/VpnUtils.java
index 4c9338c..d6a5578 100644
--- a/src/com/android/settings/vpn2/VpnUtils.java
+++ b/src/com/android/settings/vpn2/VpnUtils.java
@@ -20,7 +20,7 @@
import android.os.RemoteException;
import android.provider.Settings;
import android.security.Credentials;
-import android.security.KeyStore;
+import android.security.LegacyVpnProfileStore;
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
@@ -28,27 +28,25 @@
/**
* Utility functions for vpn.
*
- * Keystore methods should only be called in system user
+ * LegacyVpnProfileStore methods should only be called in system user
*/
public class VpnUtils {
private static final String TAG = "VpnUtils";
public static String getLockdownVpn() {
- final byte[] value = KeyStore.getInstance().get(
- Credentials.LOCKDOWN_VPN, true /* suppressKeyNotFoundWarning */);
+ final byte[] value = LegacyVpnProfileStore.get(Credentials.LOCKDOWN_VPN);
return value == null ? null : new String(value);
}
public static void clearLockdownVpn(Context context) {
- KeyStore.getInstance().delete(Credentials.LOCKDOWN_VPN);
+ LegacyVpnProfileStore.remove(Credentials.LOCKDOWN_VPN);
// Always notify VpnManager after keystore update
getVpnManager(context).updateLockdownVpn();
}
public static void setLockdownVpn(Context context, String lockdownKey) {
- KeyStore.getInstance().put(Credentials.LOCKDOWN_VPN, lockdownKey.getBytes(),
- KeyStore.UID_SELF, /* flags */ 0);
+ LegacyVpnProfileStore.put(Credentials.LOCKDOWN_VPN, lockdownKey.getBytes());
// Always notify VpnManager after keystore update
getVpnManager(context).updateLockdownVpn();
}
diff --git a/src/com/android/settings/widget/LabeledContinuousSeekBarPreference.java b/src/com/android/settings/widget/LabeledContinuousSeekBarPreference.java
new file mode 100644
index 0000000..e269818
--- /dev/null
+++ b/src/com/android/settings/widget/LabeledContinuousSeekBarPreference.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import com.android.settings.R;
+
+/** A continuous labeled slider preference */
+public class LabeledContinuousSeekBarPreference extends LabeledSeekBarPreference {
+ public LabeledContinuousSeekBarPreference(Context context) {
+ this(context, null);
+ }
+
+ public LabeledContinuousSeekBarPreference(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public LabeledContinuousSeekBarPreference(Context context, AttributeSet attrs,
+ int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ public LabeledContinuousSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ setLayoutResource(R.layout.preference_labeled_continuous_slider);
+ }
+}
diff --git a/src/com/android/settings/widget/SettingsMainSwitchPreference.java b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
index 76f9b41..80a0021 100644
--- a/src/com/android/settings/widget/SettingsMainSwitchPreference.java
+++ b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
@@ -176,6 +176,7 @@
* Update the status of switch but doesn't notify the mOnBeforeListener.
*/
public void setCheckedInternal(boolean checked) {
+ super.setChecked(checked);
if (mMainSwitchBar != null) {
mMainSwitchBar.setCheckedInternal(checked);
}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index b2eca78..ee2abf8 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -536,8 +536,9 @@
} else {
enabled = ipAndProxyFieldsAreValid();
}
- if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP ||
- mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
+ if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP
+ || mAccessPointSecurity == AccessPoint.SECURITY_EAP_WPA3_ENTERPRISE
+ || mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
&& mEapCaCertSpinner != null
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
@@ -553,8 +554,9 @@
enabled = false;
}
}
- if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP ||
- mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
+ if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP
+ || mAccessPointSecurity == AccessPoint.SECURITY_EAP_WPA3_ENTERPRISE
+ || mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
&& mEapUserCertSpinner != null
&& mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
&& mEapUserCertSpinner.getSelectedItem().equals(mUnspecifiedCertString)) {
@@ -651,10 +653,13 @@
break;
case AccessPoint.SECURITY_EAP:
+ case AccessPoint.SECURITY_EAP_WPA3_ENTERPRISE:
case AccessPoint.SECURITY_EAP_SUITE_B:
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
// allowedSuiteBCiphers will be set according to certificate type
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B);
+ } else if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_WPA3_ENTERPRISE) {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_WPA3_ENTERPRISE);
} else {
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
}
@@ -1693,9 +1698,14 @@
if (mWifiManager.isWpa3SaeSupported()) {
spinnerAdapter.add(mContext.getString(R.string.wifi_security_sae));
mSecurityInPosition[idx++] = AccessPoint.SECURITY_SAE;
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_wpa_wpa2));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP;
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_wpa3));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP_WPA3_ENTERPRISE;
+ } else {
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
+ mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP;
}
- spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
- mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP;
if (mWifiManager.isWpa3SuiteBSupported()) {
spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_suiteb));
mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP_SUITE_B;
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index b4e26a6..32152de 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -500,6 +500,7 @@
enabled = ipAndProxyFieldsAreValid();
}
if ((mWifiEntrySecurity == WifiEntry.SECURITY_EAP
+ || mWifiEntrySecurity == WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE
|| mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B)
&& mEapCaCertSpinner != null
&& mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
@@ -517,6 +518,7 @@
}
}
if ((mWifiEntrySecurity == WifiEntry.SECURITY_EAP
+ || mWifiEntrySecurity == WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE
|| mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B)
&& mEapUserCertSpinner != null
&& mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
@@ -615,10 +617,13 @@
break;
case WifiEntry.SECURITY_EAP:
+ case WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE:
case WifiEntry.SECURITY_EAP_SUITE_B:
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
// allowedSuiteBCiphers will be set according to certificate type
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B);
+ } else if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE) {
+ config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP_WPA3_ENTERPRISE);
} else {
config.setSecurityParams(WifiConfiguration.SECURITY_TYPE_EAP);
}
@@ -942,6 +947,7 @@
}
if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP
+ && mWifiEntrySecurity != WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE
&& mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
mView.findViewById(R.id.eap).setVisibility(View.GONE);
return;
@@ -1660,9 +1666,14 @@
if (mWifiManager.isWpa3SaeSupported()) {
spinnerAdapter.add(mContext.getString(R.string.wifi_security_sae));
mSecurityInPosition[idx++] = WifiEntry.SECURITY_SAE;
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_wpa_wpa2));
+ mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP;
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_wpa3));
+ mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP_WPA3_ENTERPRISE;
+ } else {
+ spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
+ mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP;
}
- spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
- mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP;
if (mWifiManager.isWpa3SuiteBSupported()) {
spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_suiteb));
mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP_SUITE_B;
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 3df6221..0ed6747 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -31,6 +31,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.res.Resources;
import android.os.Bundle;
import android.provider.Settings;
import android.view.LayoutInflater;
@@ -75,7 +76,8 @@
"com.android.server.accessibility.MagnificationController";
private TestToggleScreenMagnificationPreferenceFragment mFragment;
- private Context mContext = ApplicationProvider.getApplicationContext();
+ private Context mContext;
+ private Resources mResources;
@Mock
private PreferenceManager mPreferenceManager;
@@ -86,10 +88,14 @@
public void setUpTestFragment() {
MockitoAnnotations.initMocks(this);
+ mContext = spy(ApplicationProvider.getApplicationContext());
mFragment = spy(new TestToggleScreenMagnificationPreferenceFragment());
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
when(mFragment.getContext()).thenReturn(mContext);
+ mResources = spy(mContext.getResources());
+ when(mContext.getResources()).thenReturn(mResources);
+ when(mFragment.getContext().getResources()).thenReturn(mResources);
doReturn(null).when(mFragment).getPreferenceScreen();
doReturn(mActivity).when(mFragment).getActivity();
}
@@ -250,6 +256,16 @@
assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
}
+ @Test
+ public void initSettingsPreference_notSupportsMagnificationArea_settingsPreferenceIsNull() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_magnification_area))
+ .thenReturn(false);
+ mFragment.initSettingsPreference();
+
+ assertThat(mFragment.mSettingsPreference).isNull();
+ }
+
private void putStringIntoSettings(String key, String componentName) {
Settings.Secure.putString(mContext.getContentResolver(), key, componentName);
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
index b816a18..b3f732f 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
@@ -34,7 +34,7 @@
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPortStatus;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
import android.os.UserHandle;
import android.os.UserManager;
@@ -57,7 +57,7 @@
@Mock
private UserManager mUserManager;
@Mock
- private ConnectivityManager mConnectivityManager;
+ private TetheringManager mTetheringManager;
@Mock
private UsbPort mUsbPort;
@Mock
@@ -69,8 +69,8 @@
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI))
.thenReturn(true);
when((Object) mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
- when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
- .thenReturn(mConnectivityManager);
+ when((Object) mContext.getSystemService(
+ TetheringManager.class)).thenReturn(mTetheringManager);
when(mUsbManager.getPorts()).thenReturn(Collections.singletonList(mUsbPort));
when(mUsbPortStatus.isConnected()).thenReturn(true);
when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
index 4afe22a..3108150 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
@@ -18,11 +18,12 @@
import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
-import static android.net.ConnectivityManager.TETHERING_USB;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -30,7 +31,7 @@
import static org.mockito.Mockito.when;
import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
import androidx.preference.PreferenceScreen;
@@ -50,7 +51,7 @@
@Mock
private UsbBackend mUsbBackend;
@Mock
- private ConnectivityManager mConnectivityManager;
+ private TetheringManager mTetheringManager;
private UsbDefaultFragment mFragment;
@@ -59,7 +60,7 @@
MockitoAnnotations.initMocks(this);
mFragment = new TestFragment();
mFragment.mUsbBackend = mUsbBackend;
- mFragment.mConnectivityManager = mConnectivityManager;
+ mFragment.mTetheringManager = mTetheringManager;
}
@Test
@@ -136,8 +137,9 @@
mFragment.setDefaultKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_RNDIS));
- verify(mConnectivityManager).startTethering(TETHERING_USB, true,
- mFragment.mOnStartTetheringCallback);
+ verify(mTetheringManager).startTethering(eq(TetheringManager.TETHERING_USB),
+ any(),
+ eq(mFragment.mOnStartTetheringCallback));
assertThat(mFragment.mPreviousFunctions).isEqualTo(
UsbManager.FUNCTION_MTP);
}
@@ -222,6 +224,32 @@
assertThat(mFragment.mCurrentFunctions).isEqualTo(UsbManager.FUNCTION_MIDI);
}
+ @Test
+ public void usbIsPluginAndUsbTetheringIsOn_startTetheringIsInvoked() {
+ when(mUsbBackend.getDefaultUsbFunctions()).thenReturn(UsbManager.FUNCTION_RNDIS);
+
+ mFragment.mUsbConnectionListener.onUsbConnectionChanged(false /* connected */,
+ UsbManager.FUNCTION_RNDIS, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
+ mFragment.mUsbConnectionListener.onUsbConnectionChanged(true /* connected */,
+ UsbManager.FUNCTION_RNDIS, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
+
+ verify(mTetheringManager).startTethering(eq(TetheringManager.TETHERING_USB),
+ any(),
+ eq(mFragment.mOnStartTetheringCallback));
+ }
+
+ @Test
+ public void usbIsNotPluginAndUsbTetheringIsOn_startTetheringIsNotInvoked() {
+ when(mUsbBackend.getDefaultUsbFunctions()).thenReturn(UsbManager.FUNCTION_RNDIS);
+
+ mFragment.mUsbConnectionListener.onUsbConnectionChanged(false /* connected */,
+ UsbManager.FUNCTION_RNDIS, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
+
+ verify(mTetheringManager, never()).startTethering(eq(TetheringManager.TETHERING_USB),
+ any(),
+ eq(mFragment.mOnStartTetheringCallback));
+ }
+
public static class TestFragment extends UsbDefaultFragment {
public final PreferenceScreen mScreen;
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
index 3ea2756..9118645 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
@@ -18,11 +18,12 @@
import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
-import static android.net.ConnectivityManager.TETHERING_USB;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -31,7 +32,7 @@
import android.content.Context;
import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceCategory;
@@ -73,7 +74,7 @@
@Mock
private FragmentActivity mActivity;
@Mock
- private ConnectivityManager mConnectivityManager;
+ private TetheringManager mTetheringManager;
@Before
public void setUp() {
@@ -89,7 +90,7 @@
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
- when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
+ when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
mDetailsFunctionsController = new UsbDetailsFunctionsController(mContext, mFragment,
mUsbBackend);
@@ -245,8 +246,9 @@
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
- verify(mConnectivityManager).startTethering(TETHERING_USB, true,
- mDetailsFunctionsController.mOnStartTetheringCallback);
+ verify(mTetheringManager).startTethering(eq(TetheringManager.TETHERING_USB),
+ any(),
+ eq(mDetailsFunctionsController.mOnStartTetheringCallback));
assertThat(mDetailsFunctionsController.mPreviousFunction).isEqualTo(
UsbManager.FUNCTION_MTP);
}
@@ -295,15 +297,16 @@
mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
verify(mUsbBackend, never()).setCurrentFunctions(UsbManager.FUNCTION_PTP);
- verify(mConnectivityManager, never()).startTethering(TETHERING_USB, true,
- mDetailsFunctionsController.mOnStartTetheringCallback);
+ verify(mTetheringManager, never()).startTethering(eq(TetheringManager.TETHERING_USB),
+ any(),
+ eq(mDetailsFunctionsController.mOnStartTetheringCallback));
}
@Test
public void onTetheringFailed_resetPreviousFunctions() {
mDetailsFunctionsController.mPreviousFunction = UsbManager.FUNCTION_PTP;
- mDetailsFunctionsController.mOnStartTetheringCallback.onTetheringFailed();
+ mDetailsFunctionsController.mOnStartTetheringCallback.onTetheringFailed(0);
verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_PTP);
}
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java
index 8a34930..323486e 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java
@@ -105,6 +105,7 @@
public void onBindDialogView_checkRadioButtonsText() {
when(mView.findViewById(ID1)).thenReturn(mRadioButton1);
when(mView.findViewById(ID2)).thenReturn(mRadioButton2);
+ when(mView.findViewById(TEXT_VIEW_ID)).thenReturn(mTextView);
assertThat(mRadioButton1.getText()).isNotEqualTo(BUTTON1);
assertThat(mRadioButton2.getText()).isNotEqualTo(BUTTON2);
@@ -118,6 +119,7 @@
public void onBindDialogView_checkRadioButtonsState() {
when(mView.findViewById(ID1)).thenReturn(mRadioButton1);
when(mView.findViewById(ID2)).thenReturn(mRadioButton2);
+ when(mView.findViewById(TEXT_VIEW_ID)).thenReturn(mTextView);
List<Integer> indexes = new ArrayList<>();
indexes.add(0);
when(mCallback.getSelectableIndex()).thenReturn(indexes);
diff --git a/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java b/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
index efc45e0..f0bf95c 100644
--- a/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
@@ -23,6 +23,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -138,6 +139,7 @@
public void updateCandidates_enforcedAdmin_showDisabledByAdminPreference() {
mSettings.mAdmin = new RestrictedLockUtils.EnforcedAdmin();
mSettings.mDisableOptionsPreference = mDisableOptionsPreference;
+ doNothing().when(mSettings).setupDisabledFooterPreference();
mSettings.updateCandidates();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
index 4d2910e..b3b8196 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverControllerTest.java
@@ -17,20 +17,15 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.PowerManager;
-import android.view.LayoutInflater;
-import android.widget.LinearLayout;
+import android.provider.Settings;
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-import com.android.settings.widget.PrimarySwitchPreference;
+import androidx.preference.Preference;
import org.junit.Before;
import org.junit.Test;
@@ -39,108 +34,84 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
public class BatterySaverControllerTest {
@Mock
+ private Preference mBatterySaverPref;
+ @Mock
private PowerManager mPowerManager;
private BatterySaverController mBatterySaverController;
- private PrimarySwitchPreference mBatterySaverPref;
+ private Context mContext;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- final Context mContext = spy(RuntimeEnvironment.application);
- mBatterySaverPref = new PrimarySwitchPreference(mContext);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- final PreferenceViewHolder mHolder =
- PreferenceViewHolder.createInstanceForTests(inflater.inflate(
- com.android.settingslib.R.layout.preference_two_target, null));
- final LinearLayout mWidgetView = mHolder.itemView.findViewById(android.R.id.widget_frame);
- inflater.inflate(R.layout.restricted_preference_widget_primary_switch, mWidgetView, true);
- mBatterySaverPref.onBindViewHolder(mHolder);
+ mContext = RuntimeEnvironment.application;
+ mBatterySaverController = spy(new BatterySaverController(mContext));
+ ReflectionHelpers.setField(mBatterySaverController, "mPowerManager", mPowerManager);
+ ReflectionHelpers.setField(mBatterySaverController, "mBatterySaverPref", mBatterySaverPref);
- doReturn(mPowerManager).when(mContext).getSystemService(Context.POWER_SERVICE);
-
- mBatterySaverController = new BatterySaverController(mContext);
- mBatterySaverController.mBatterySaverPref = mBatterySaverPref;
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
}
@Test
- public void onBatteryChanged_true_switchEnabled() {
- mBatterySaverController.onBatteryChanged(true);
-
- assertThat(mBatterySaverPref.getSwitch().isEnabled()).isFalse();
+ public void onPreferenceChange_onStart() {
+ mBatterySaverController.onStart();
+ verify(mBatterySaverPref).setSummary("Off");
}
@Test
- public void onBatteryChanged_false_switchDisabled() {
- mBatterySaverController.onBatteryChanged(false);
-
- assertThat(mBatterySaverPref.getSwitch().isEnabled()).isTrue();
+ public void onPreferenceChange_onPowerSaveModeChanged() {
+ mBatterySaverController.onPowerSaveModeChanged();
+ verify(mBatterySaverPref).setSummary("Off");
}
@Test
- public void onPowerSaveModeChanged_differentState_updateToIsChecked() {
+ public void getSummary_batterySaverOn_showSummaryOn() {
when(mPowerManager.isPowerSaveMode()).thenReturn(true);
- assertThat(mBatterySaverPref.isChecked()).isFalse();
-
- mBatterySaverController.onPowerSaveModeChanged();
-
- assertThat(mBatterySaverPref.isChecked()).isTrue();
+ assertThat(mBatterySaverController.getSummary()).isEqualTo("On");
}
@Test
- public void onPowerSaveModeChanged_differentState_updateToUnChecked() {
- mBatterySaverPref.setChecked(true);
-
+ public void getSummary_batterySaverOffButScheduled_showSummaryScheduled() {
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
- assertThat(mBatterySaverPref.isChecked()).isTrue();
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 15);
- mBatterySaverController.onPowerSaveModeChanged();
-
- assertThat(mBatterySaverPref.isChecked()).isFalse();
+ assertThat(mBatterySaverController.getSummary()).isEqualTo("Will turn on at 15%");
}
@Test
- public void onPowerSaveModeChanged_sameState_noUpdate() {
+ public void getSummary_batterySaverOffButScheduledZeroPercent_showSummaryOff() {
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
- assertThat(mBatterySaverPref.isChecked()).isFalse();
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
- mBatterySaverController.onPowerSaveModeChanged();
-
- assertThat(mBatterySaverPref.isChecked()).isFalse();
+ assertThat(mBatterySaverController.getSummary()).isEqualTo("Off");
}
@Test
- public void setChecked_on_setPowerSaveMode() {
- mBatterySaverController.setChecked(true);
+ public void getSummary_batterySaverOffButScheduledBasedOnRoutine_showSummaryBasedOnRoutine() {
+ when(mPowerManager.isPowerSaveMode()).thenReturn(false);
+ Settings.Global.putInt(
+ mContext.getContentResolver(),
+ Settings.Global.AUTOMATIC_POWER_SAVE_MODE,
+ PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
- verify(mPowerManager).setPowerSaveModeEnabled(true);
+ assertThat(mBatterySaverController.getSummary()).isEqualTo("Based on your routine");
}
@Test
- public void setChecked_off_unsetPowerSaveMode() {
- mBatterySaverController.setChecked(false);
-
- verify(mPowerManager).setPowerSaveModeEnabled(false);
- }
-
- @Test
- public void isChecked_on_powerSaveModeOn() {
- when(mPowerManager.isPowerSaveMode()).thenReturn(true);
-
- assertThat(mBatterySaverController.isChecked()).isTrue();
- }
-
- @Test
- public void isChecked_off_powerSaveModeOff() {
+ public void getSummary_batterySaverOff_showSummaryOff() {
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
- assertThat(mBatterySaverController.isChecked()).isFalse();
+ assertThat(mBatterySaverController.getSummary()).isEqualTo("Off");
}
}
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
index 5feee60..32c8627 100644
--- a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
@@ -98,7 +98,7 @@
@Test
@Ignore
public void updateState_whenAppListIsEmpty_shouldDisplayTitleTextAndDetailsText() {
- doReturn(new ArrayList<>()).when(mRecentLocationApps).getAppListSorted();
+ doReturn(new ArrayList<>()).when(mRecentLocationApps).getAppListSorted(false);
mController.displayPreference(mScreen);
mController.updateState(mLayoutPreference);
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java
index cb50609..17471b5 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java
@@ -26,24 +26,50 @@
import android.app.role.RoleManager;
import android.app.usage.UsageEvents;
+import android.bluetooth.BluetoothAdapter;
+import android.companion.ICompanionDeviceManager;
+import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Parcel;
import com.android.settings.notification.NotificationBackend.AppRow;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.google.common.collect.ImmutableList;
+
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class NotificationBackendTest {
+ @Mock
+ LocalBluetoothManager mBm;
+ @Mock
+ ICompanionDeviceManager mCdm;
+ @Mock
+ CachedBluetoothDeviceManager mCbm;
+ ComponentName mCn = new ComponentName("a", "b");
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(mBm.getCachedDeviceManager()).thenReturn(mCbm);
+ }
+
@Test
public void testMarkAppRow_unblockablePackage() {
AppRow appRow = new AppRow();
@@ -138,4 +164,69 @@
parcel.setDataPosition(0);
return UsageEvents.CREATOR.createFromParcel(parcel);
}
+
+ @Test
+ public void getDeviceList_noAssociations() throws Exception {
+ when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(null);
+
+ Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
+ CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class);
+ when(cbd1.getAddress()).thenReturn("00:00:00:00:00:10");
+ when(cbd1.getName()).thenReturn("Device 1");
+ cachedDevices.add(cbd1);
+ when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices);
+
+ BluetoothAdapter.getDefaultAdapter().enable();
+
+ assertThat(new NotificationBackend().getDeviceList(
+ mCdm, mBm, mCn.getPackageName(), 0).toString()).isEmpty();
+ }
+
+ @Test
+ public void getDeviceList_associationsButNoDevice() throws Exception {
+ List<String> macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20");
+ when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs);
+
+ when(mCbm.getCachedDevicesCopy()).thenReturn(new ArrayList<>());
+
+ assertThat(new NotificationBackend().getDeviceList(
+ mCdm, mBm, mCn.getPackageName(), 0).toString()).isEmpty();
+ }
+
+ @Test
+ public void getDeviceList_singleDevice() throws Exception {
+ List<String> macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20");
+ when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs);
+
+ Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
+ CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class);
+ when(cbd1.getAddress()).thenReturn(macs.get(0));
+ when(cbd1.getName()).thenReturn("Device 1");
+ cachedDevices.add(cbd1);
+ when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices);
+
+ assertThat(new NotificationBackend().getDeviceList(
+ mCdm, mBm, mCn.getPackageName(), 0).toString()).isEqualTo("Device 1");
+ }
+
+ @Test
+ public void getDeviceList_multipleDevices() throws Exception {
+ List<String> macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20");
+ when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs);
+
+ Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
+ CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class);
+ when(cbd1.getAddress()).thenReturn(macs.get(0));
+ when(cbd1.getName()).thenReturn("Device 1");
+ cachedDevices.add(cbd1);
+
+ CachedBluetoothDevice cbd2 = mock(CachedBluetoothDevice.class);
+ when(cbd2.getAddress()).thenReturn(macs.get(1));
+ when(cbd2.getName()).thenReturn("Device 2");
+ cachedDevices.add(cbd2);
+ when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices);
+
+ assertThat(new NotificationBackend().getDeviceList(
+ mCdm, mBm, mCn.getPackageName(), 0).toString()).isEqualTo("Device 1, Device 2");
+ }
}
diff --git a/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java b/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java
index 3387368..d8f3c78 100644
--- a/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java
+++ b/tests/unit/src/com/android/settings/network/AllowedNetworkTypesListenerTest.java
@@ -25,8 +25,8 @@
import android.content.Context;
import android.os.HandlerExecutor;
-import android.telephony.PhoneStateListener;
import android.telephony.RadioAccessFamily;
+import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.test.mock.MockContentResolver;
@@ -53,7 +53,7 @@
private AllowedNetworkTypesListener mAllowedNetworkTypesListener;
@Mock
- private AllowedNetworkTypesListener.OnAllowedNetworkTypesChangedListener mListener;
+ private AllowedNetworkTypesListener.OnAllowedNetworkTypesListener mListener;
@Mock
private TelephonyManager mTelephonyManager;
@@ -87,15 +87,15 @@
public void register_shouldRegisterContentObserver() {
mAllowedNetworkTypesListener.register(mContext, SUB_ID);
- verify(mTelephonyManager, times(1)).registerPhoneStateListener(any(HandlerExecutor.class),
- any(PhoneStateListener.class));
+ verify(mTelephonyManager, times(1)).registerTelephonyCallback(any(HandlerExecutor.class),
+ any(TelephonyCallback.class));
}
@Test
public void unregister_shouldUnregisterContentObserver() {
mAllowedNetworkTypesListener.unregister(mContext, SUB_ID);
- verify(mTelephonyManager).unregisterPhoneStateListener(
+ verify(mTelephonyManager).unregisterTelephonyCallback(
mAllowedNetworkTypesListener);
}
}
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
index 476d854..705f60e 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
@@ -264,7 +264,7 @@
@Test
@UiThreadTest
- public void getSlice_connectedEthernet_getOneEthernetAndOneCarrierAndTwoWiFi() {
+ public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getFourRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
@@ -273,9 +273,29 @@
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
mWifiList.add(mMockWifiSliceItem2);
mMockNetworkProviderWorker.updateSelfResults(mWifiList);
- when(mProviderModelSliceHelper.isAirplaneModeEnabled()).thenReturn(false);
- when(mProviderModelSliceHelper.hasCarrier()).thenReturn(true);
- when(mProviderModelSliceHelper.isDataSimActive()).thenReturn(true);
+ mockHelperCondition(false, true, true, null);
+ when(mMockNetworkProviderWorker.isEthernetConnected()).thenReturn(true);
+
+ final Slice slice = mMockProviderModelSlice.getSlice();
+
+ assertThat(slice).isNotNull();
+ assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
+ verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
+ verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
+ }
+
+ @Test
+ @UiThreadTest
+ public void getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getFourRow() {
+ mWifiList.clear();
+ mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
+ WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
+ mWifiList.add(mMockWifiSliceItem1);
+ mockWifiItemCondition(mMockWifiSliceItem2, "wifi2", "wifi2",
+ WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
+ mWifiList.add(mMockWifiSliceItem2);
+ mMockNetworkProviderWorker.updateSelfResults(mWifiList);
+ mockHelperCondition(false, true, true, mWifiList.get(0));
when(mMockNetworkProviderWorker.isEthernetConnected()).thenReturn(true);
final Slice slice = mMockProviderModelSlice.getSlice();
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index 6b31342..6997607 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -97,6 +97,7 @@
private LifecycleOwner mLifecycleOwner;
@Mock
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
+
private LifecycleRegistry mLifecycleRegistry;
private int mOnChildUpdatedCount;
private Context mContext;
@@ -428,7 +429,6 @@
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
@@ -447,7 +447,7 @@
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
- setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
+ setupGetIconConditions(sub.get(0).getSubscriptionId(), false, false,
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
doReturn(networkType)
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
@@ -534,7 +534,6 @@
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
- when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java
index 2ce9a51..97f8e11 100644
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java
@@ -207,22 +207,22 @@
@Test
@UiThreadTest
- public void onServiceStateChanged_notifyPhoneStateListener_callUpdateSlice() {
+ public void onServiceStateChanged_notifyTelephonyCallback_callUpdateSlice() {
mMockNetworkProviderWorker.onSlicePinned();
mMockNetworkProviderWorker.receiveNotification(false);
- mMockNetworkProviderWorker.mPhoneStateListener.onServiceStateChanged(new ServiceState());
+ mMockNetworkProviderWorker.mTelephonyCallback.onServiceStateChanged(new ServiceState());
assertThat(mMockNetworkProviderWorker.hasNotification()).isTrue();
}
@Test
@UiThreadTest
- public void onDisplayInfoChanged_notifyPhoneStateListener_callUpdateSlice() {
+ public void onDisplayInfoChanged_notifyTelephonyCallback_callUpdateSlice() {
mMockNetworkProviderWorker.onSlicePinned();
mMockNetworkProviderWorker.receiveNotification(false);
- mMockNetworkProviderWorker.mPhoneStateListener.onDisplayInfoChanged(
+ mMockNetworkProviderWorker.mTelephonyCallback.onDisplayInfoChanged(
new TelephonyDisplayInfo(14, 0));
assertThat(mMockNetworkProviderWorker.hasNotification()).isTrue();
@@ -230,11 +230,11 @@
@Test
@UiThreadTest
- public void onDataConnectionStateChanged_notifyPhoneStateListener_callUpdateSlice() {
+ public void onDataConnectionStateChanged_notifyTelephonyCallback_callUpdateSlice() {
mMockNetworkProviderWorker.onSlicePinned();
mMockNetworkProviderWorker.receiveNotification(false);
- mMockNetworkProviderWorker.mPhoneStateListener.onDataConnectionStateChanged(
+ mMockNetworkProviderWorker.mTelephonyCallback.onDataConnectionStateChanged(
TelephonyManager.DATA_DISCONNECTED, TelephonyManager.NETWORK_TYPE_LTE);
assertThat(mMockNetworkProviderWorker.hasNotification()).isTrue();