Merge "Fix UI problem in system language list" into udc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index dc519e9..ccf002a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -178,6 +178,7 @@
                   android:exported="true"
                   android:enabled="false"
                   android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|smallestScreenSize"
+                  android:knownActivityEmbeddingCerts="@array/config_known_host_certs"
                   android:permission="android.permission.LAUNCH_MULTI_PANE_SETTINGS_DEEP_LINK">
             <intent-filter>
                 <action android:name="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY" />
@@ -224,6 +225,7 @@
         <activity android:name=".SubSettings"
                   android:exported="false"
                   android:theme="@style/Theme.SubSettings"
+                  android:knownActivityEmbeddingCerts="@array/config_known_host_certs"
                   android:taskAffinity="com.android.settings.root" />
 
         <activity android:name=".Settings$CreateShortcutActivity"
@@ -333,6 +335,7 @@
         <activity android:name=".search.SearchResultTrampoline"
                   android:theme="@android:style/Theme.NoDisplay"
                   android:excludeFromRecents="true"
+                  android:knownActivityEmbeddingCerts="@array/config_known_host_certs"
                   android:exported="true">
             <intent-filter>
                 <action android:name="com.android.settings.SEARCH_RESULT_TRAMPOLINE" />
@@ -1628,6 +1631,7 @@
             android:excludeFromRecents="true"
             android:theme="@android:style/Theme.NoDisplay"
             android:exported="true"
+            android:knownActivityEmbeddingCerts="@array/config_known_host_certs"
             android:permission="android.permission.MODIFY_PHONE_STATE">
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
@@ -3115,8 +3119,6 @@
             android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED"/>
-                <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
-                <action android:name="android.intent.action.MY_PACKAGE_UNSUSPENDED"/>
                 <action android:name="com.google.android.setupwizard.SETUP_WIZARD_FINISHED"/>
                 <action android:name="com.android.settings.battery.action.PERIODIC_JOB_RECHECK"/>
             </intent-filter>
@@ -4200,6 +4202,12 @@
                 <action android:name="android.settings.SYNC_SETTINGS" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="package" />
+            </intent-filter>
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.CREDENTIAL_PROVIDER" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="package" />
             </intent-filter>
             <intent-filter android:priority="53">
                 <action android:name="android.intent.action.MAIN" />
diff --git a/res/drawable/flip_camera_for_selfie.xml b/res/drawable/flip_camera_for_selfie.xml
deleted file mode 100644
index dcbf9f4..0000000
--- a/res/drawable/flip_camera_for_selfie.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape>
-</shape>
diff --git a/res/drawable/screen_resolution_1440p.xml b/res/drawable/screen_resolution_1440p.xml
deleted file mode 100644
index a9d89ee..0000000
--- a/res/drawable/screen_resolution_1440p.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2022 The Android Open Source Project
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  -->
-
-<shape>
-</shape>
\ No newline at end of file
diff --git a/res/drawable/screen_resolution_1080p.xml b/res/drawable/screen_resolution_full.xml
similarity index 100%
rename from res/drawable/screen_resolution_1080p.xml
rename to res/drawable/screen_resolution_full.xml
diff --git a/res/drawable/screen_resolution_1080p.xml b/res/drawable/screen_resolution_high.xml
similarity index 100%
copy from res/drawable/screen_resolution_1080p.xml
copy to res/drawable/screen_resolution_high.xml
diff --git a/res/layout/locale_drag_cell.xml b/res/layout/locale_drag_cell.xml
index 247cfd2..f5a280b 100644
--- a/res/layout/locale_drag_cell.xml
+++ b/res/layout/locale_drag_cell.xml
@@ -15,21 +15,24 @@
 -->
 
 <com.android.settings.localepicker.LocaleDragCell
-              xmlns:android="http://schemas.android.com/apk/res/android"
-              android:layout_width="match_parent"
-              android:layout_height="wrap_content"
-              android:minHeight="?android:listPreferredItemHeight"
-              android:background="?android:colorBackground"
-              android:layout_marginTop="4dp"
-              android:layout_marginBottom="4dp"
-              android:layoutDirection="locale"
-              android:textDirection="locale">
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:minHeight="?android:listPreferredItemHeight"
+    android:background="?android:colorBackground"
+    android:layout_marginTop="12dp"
+    android:layout_marginBottom="12dp"
+    android:layoutDirection="locale"
+    android:textDirection="locale">
 
     <CheckBox
         android:id="@+id/checkbox"
         style="@style/LanguageCheckboxAndLabel"
         android:paddingStart="24dp"
-        android:layout_toStartOf="@+id/dragHandle"/>
+        android:layout_toStartOf="@+id/dragHandle"
+        android:layout_alignTop="@+id/miniLabel"
+        android:layout_alignBottom="@+id/miniLabel" />
 
     <TextView
         android:id="@+id/miniLabel"
@@ -38,37 +41,44 @@
         android:textColor="?android:attr/colorAccent"
         android:minWidth="24sp"
         android:gravity="center_vertical|center_horizontal"
-        android:layout_alignTop="@id/checkbox"
-        android:layout_alignBottom="@id/checkbox"/>
+        android:layout_centerVertical="true"/>
 
-    <LinearLayout
+    <androidx.constraintlayout.widget.ConstraintLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:orientation="vertical"
         android:minHeight="?android:listPreferredItemHeight"
         android:paddingStart="56dp"
         android:layout_toStartOf="@+id/dragHandle">
-        <TextView
-            android:id="@+id/label"
-            style="@style/LanguageCheckboxAndLabel"/>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent">
+            <TextView
+                android:id="@+id/label"
+                style="@style/LanguageCheckboxAndLabel" />
 
-        <TextView
-            android:id="@+id/l10nWarn"
-            style="@style/LanguageCheckboxAndLabel"
-            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
-            android:textColor="?android:textColorSecondary"
-            android:layout_marginBottom="4dp"
-            android:text="@string/locale_not_translated"/>
+            <TextView
+                android:id="@+id/l10nWarn"
+                style="@style/LanguageCheckboxAndLabel"
+                android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+                android:textColor="?android:textColorSecondary"
+                android:layout_marginTop="4dp"
+                android:text="@string/locale_not_translated"/>
 
-        <TextView
-            android:id="@+id/default_locale"
-            style="@style/LanguageCheckboxAndLabel"
-            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
-            android:textColor="?android:textColorSecondary"
-            android:layout_marginBottom="4dp"
-            android:text="@string/desc_current_default_language"/>
+            <TextView
+                android:id="@+id/default_locale"
+                style="@style/LanguageCheckboxAndLabel"
+                android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+                android:textColor="?android:textColorSecondary"
+                android:layout_marginTop="4dp"
+                android:text="@string/desc_current_default_language"/>
 
-    </LinearLayout>
+        </LinearLayout>
+    </androidx.constraintlayout.widget.ConstraintLayout>
 
     <ImageView
         android:id="@+id/dragHandle"
@@ -80,13 +90,6 @@
         android:src="@drawable/drag_handle"
         android:importantForAccessibility="no"
         android:layout_alignParentEnd="true"
-        android:layout_alignTop="@id/checkbox"
-        android:layout_alignBottom="@id/checkbox"/>
+        android:layout_centerVertical="true"/>
 
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="1dp"
-        android:background="?android:attr/listDivider"
-        android:layout_alignParentBottom="true"/>
-
-</com.android.settings.localepicker.LocaleDragCell>
+</com.android.settings.localepicker.LocaleDragCell>
\ No newline at end of file
diff --git a/res/layout/modifier_key_reset_dialog.xml b/res/layout/modifier_key_reset_dialog.xml
index fd38b11..11712bf 100644
--- a/res/layout/modifier_key_reset_dialog.xml
+++ b/res/layout/modifier_key_reset_dialog.xml
@@ -80,7 +80,7 @@
             android:drawablePadding="9dp"
             style="@style/ModifierKeyButtonCancel"
             android:textColor="?android:attr/textColorPrimary"
-            android:text="@string/modifier_keys_restore"/>
+            android:text="@string/modifier_keys_reset"/>
 
     </RelativeLayout>
 </LinearLayout>
\ No newline at end of file
diff --git a/res/raw/flip_camera_for_selfie_lottie.json b/res/raw/flip_camera_for_selfie_lottie.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/flip_camera_for_selfie_lottie.json
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 959bc17..aae7403 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -67,5 +67,9 @@
     <color name="udfps_enroll_progress">#7DA7F1</color>
     <color name="udfps_enroll_progress_help">#607DA7F1</color>
     <color name="udfps_enroll_progress_help_with_talkback">#FFEE675C</color>
+
+    <!-- Flash notifications colors -->
+    <!-- Screen flash notification color selected stroke in color selection dialog -->
+    <color name="screen_flash_color_button_outer_circle_stroke_color">#FFFFFF</color>
 </resources>
 
diff --git a/res/values/config.xml b/res/values/config.xml
index ef786be..28bf723 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -704,4 +704,15 @@
 
     <!-- Whether to display Cloned Apps page in Settings (Settings > Apps > Cloned Apps).-->
     <bool name="config_cloned_apps_page_enabled">false</bool>
+
+    <!-- Certificates of apps which are allowed to use activity embedding with Settings.-->
+    <string-array name="config_known_host_certs" translatable="false">
+        <item></item>
+    </string-array>
+
+    <!-- List of packages that should be hidden for MVNO. Do not translate -->
+    <string-array name="datausage_hiding_carrier_service_package_names" translatable="false"/>
+
+    <!-- List of MVNO. Do not translate -->
+    <integer-array name="datausage_hiding_carrier_service_carrier_id" translatable="false"/>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0d54cf4..de33ec7 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -412,10 +412,10 @@
     <dimen name="sfps_enroll_find_sensor_lottie_margin">0dp</dimen>
 
     <!-- Flash notifications dimensions -->
-    <dimen name="screen_flash_color_button_frame_size">38dp</dimen>
-    <dimen name="screen_flash_color_button_outer_circle_size">38dp</dimen>
+    <dimen name="screen_flash_color_button_frame_size">48dp</dimen>
+    <dimen name="screen_flash_color_button_outer_circle_size">48dp</dimen>
     <dimen name="screen_flash_color_button_outer_circle_stroke_width">2dp</dimen>
-    <dimen name="screen_flash_color_button_inner_circle_size">32dp</dimen>
+    <dimen name="screen_flash_color_button_inner_circle_size">42dp</dimen>
     <dimen name="screen_flash_color_button_inner_circle_padding">3dp</dimen>
     <dimen name="screen_flash_color_button_inner_circle_stroke">1dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5ab4a77..f23fb5f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -370,7 +370,7 @@
     <string name="desc_notice_of_language_picker">To select a language for each app, go to app language settings.</string>
 
     <!-- Title for locale helper page [CHAR LIMIT=NONE] -->
-    <string name="desc_locale_helper_footer_general">Learn more about languages</string>
+    <string name="desc_locale_helper_footer_general">Learn more about app languages</string>
 
     <!-- Link for Locale helper page. [CHAR LIMIT=NONE]-->
     <string name="link_locale_picker_footer_learn_more" translatable="false">https://support.google.com/android?p=per_language_app_settings</string>
@@ -1126,6 +1126,10 @@
     <string name="auto_pin_confirm_user_message">Auto-confirm correct PIN</string>
     <!-- Message shown to explain the security concern if a user opts-in to the auto-pin feature. [CHAR LIMIT=NONE] -->
     <string name="auto_pin_confirm_opt_in_security_message">Confirming your PIN by tapping Enter is more secure than using auto-confirm</string>
+    <!-- Description of pin confirmation screen when auto confirm setting is turned on. [CHAR LIMIT=NONE] -->
+    <string name="auto_confirm_on_pin_verify_description">Enter device PIN to enable auto-confirm</string>
+    <!-- Description of pin confirmation screen when auto confirm setting is turned off. [CHAR LIMIT=NONE] -->
+    <string name="auto_confirm_off_pin_verify_description">Enter device PIN to disable auto-confirm</string>
 
     <!--  Main Security lock settings --><skip />
     <!--  Title for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=22] -->
@@ -2020,13 +2024,37 @@
     <!-- Title for Wifi hotspot speed [CHAR LIMIT=NONE]-->
     <string name="wifi_hotspot_speed_title">Speed &amp; compatibility</string>
     <!-- Summary for Wifi hotspot speed to 2.4 GHz band [CHAR LIMIT=NONE]-->
-    <string name="wifi_hotspot_speed_2g_summary">2.4 GHz / Any device can connect</string>
+    <string name="wifi_hotspot_speed_summary_2g">2.4 GHz / Any device can connect</string>
     <!-- Summary for Wifi hotspot speed to 5 GHz band [CHAR LIMIT=NONE]-->
-    <string name="wifi_hotspot_speed_5g_summary">5 GHz / Most devices can connect</string>
+    <string name="wifi_hotspot_speed_summary_5g">5 GHz / Most devices can connect</string>
     <!-- Summary for Wifi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
-    <string name="wifi_hotspot_speed_6g_summary">6 GHz / Few devices can connect</string>
+    <string name="wifi_hotspot_speed_summary_6g">6 GHz / Few devices can connect</string>
     <!-- Summary for Wifi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
-    <string name="wifi_hotspot_speed_2g_and_5g_summary">2.4 and 5 GHz / Any device can connect</string>
+    <string name="wifi_hotspot_speed_summary_2g_and_5g">2.4 and 5 GHz / Any device can connect</string>
+    <!-- Top introduction on the Wi-Fi hotspot speed settings, summarizes options available for Wi-Fi hotspot bands. [CHAR LIMIT=NONE] -->
+    <string name="wifi_hotspot_speed_intro">Choose a frequency for your hotspot. The frequency affects the connection speed and what types of devices can find your hotspot.</string>
+    <!-- Category title on the radio button of the Wi-Fi hotspot speed. [CHAR LIMIT=NONE] -->
+    <string name="wifi_hotspot_speed_category">Preferred frequency</string>
+    <!-- Title for radio button of the Wi-Fi hotspot speed to 2.4 GHz band [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_2g">2.4 GHz</string>
+    <!-- Summary for radio button of the Wi-Fi hotspot speed to 2.4 GHz band [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_2g_summary">Slower speeds. Any device can connect.</string>
+    <!-- Title for radio button of the Wi-Fi hotspot speed to 5 GHz band [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_5g">5 GHz</string>
+    <!-- Summary for radio button of the Wi-Fi hotspot speed to 5 GHz band [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_5g_summary">Fast speeds. Most devices can connect.</string>
+    <!-- Title for radio button of the Wi-Fi hotspot speed to 2.4 GHz and 5 GHz bands [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_2g_5g">2.4 and 5 GHz</string>
+    <!-- Summary for radio button of the Wi-Fi hotspot speed to 2.4 GHz and 5 GHz bands [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_2g_5g_summary">Fast speeds. Any device can connect to this dual-band hotspot.</string>
+    <!-- Title for radio button of the Wi-Fi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_6g">6 GHz</string>
+    <!-- Summary for radio button of the Wi-Fi hotspot speed to 6 GHz band [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_6g_summary">Fastest speeds. Fewest devices can connect.</string>
+    <!-- Summary for the Wi-Fi hotspot speed unavailable [CHAR LIMIT=NONE]-->
+    <string name="wifi_hotspot_speed_summary_unavailable">Not available in your country or region</string>
+    <!-- The footer message for switch screen resolution [CHAR LIMIT=NONE] -->
+    <string name="wifi_hotspot_speed_footer">If your preferred frequency isn\u0027t available, your hotspot may use a different one. Hotspot security settings may change if you change the frequency.</string>
 
     <!-- Summary text when turning hotspot on -->
     <string name="wifi_tether_starting">Turning hotspot on\u2026</string>
@@ -3984,7 +4012,7 @@
     <!-- Text of the cancel button. [CHAR LIMIT=15] -->
     <string name="modifier_keys_cancel">Cancel</string>
     <!-- Text of the restore button. [CHAR LIMIT=15] -->
-    <string name="modifier_keys_restore">Restore</string>
+    <string name="modifier_keys_reset">Reset</string>
     <!-- Title for the modifier key picker dialog page [CHAR LIMIT=35] -->
     <string name="modifier_keys_picker_title">Choose modifier key</string>
     <!-- Summary for the modifier key picker dialog page [CHAR LIMIT=35] -->
@@ -4571,6 +4599,8 @@
     <string name="accessibility_one_handed_mode_auto_added_qs_tooltip_content">One-handed mode added to Quick Settings. Swipe down to turn it on or off anytime.</string>
     <!-- Used in the One-hand mode settings to show quick settings tooltip. [CHAR LIMIT=NONE] -->
     <string name="accessibility_one_handed_mode_qs_tooltip_content">You can also add one-handed mode to Quick Settings from the top of your screen</string>
+    <!-- Used in the font size settings to show quick settings tooltip for auto-added feature. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_font_scaling_auto_added_qs_tooltip_content">Font size added to Quick Settings. Swipe down to change the font size anytime.</string>
     <!-- Used in the accessibility action for accessibility quick settings tooltip to dismiss. [CHAR LIMIT=NONE] -->
     <string name="accessibility_quick_settings_tooltip_dismiss">Dismiss</string>
     <!-- Used in the Color correction settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
@@ -5272,7 +5302,7 @@
     <!-- Title for usage time that full charge lasts. [CHAR LIMIT=60] -->
     <string name="battery_full_charge_last">Full charge lasts about</string>
     <!-- Description for text in battery footer. [CHAR LIMIT=NONE] -->
-    <string name="battery_footer_summary">Battery usage data is approximate and can change based on usage.</string>
+    <string name="battery_footer_summary">Remaining battery life is approximate and can change based on usage</string>
     <!-- Title for battery usage amount by this app. [CHAR LIMIT=80] -->
     <string name="battery_detail_power_usage">Battery usage</string>
 
@@ -7611,8 +7641,8 @@
     <!-- Configure lock screen: Title for the option of unlocking directly to home. [CHAR LIMIT=30] -->
     <string name="lockscreen_bypass_title">Skip lock screen</string>
 
-    <!-- Configure lock screen: Summary for the option of unlocking directly to home. [CHAR LIMIT=100] -->
-    <string name="lockscreen_bypass_summary">After unlocking, go directly to last used screen</string>
+    <!-- Configure lock screen: Summary for the option of unlocking directly to home. [CHAR LIMIT=150] -->
+    <string name="lockscreen_bypass_summary">After unlocking, go directly to last used screen. Notifications won’t show on lock screen. Swipe down from top to see them.</string>
 
     <!-- Configure lock screen: Search keywords for the option of unlocking directly to home. [CHAR LIMIT=100] -->
     <string name="keywords_lockscreen_bypass">Lock screen, Lockscreen, Skip, Bypass</string>
@@ -10229,6 +10259,15 @@
     <!-- Message of the warning dialog for disabling the credential provider. [CHAR_LIMIT=NONE] -->
     <string name="credman_confirmation_message">Saved info like addresses or payment methods won\'t be filled in when you sign in. To keep your saved info filled in, set enable a password, passkey and data/or service.</string>
 
+    <!-- Title of the warning dialog for enabling the credential provider. [CHAR_LIMIT=NONE] -->
+    <string name="credman_enable_confirmation_message_title">Turn on %1$s\?</string>
+
+    <!-- Message of the warning dialog for enabling the credential provider. [CHAR_LIMIT=NONE] -->
+    <string name="credman_enable_confirmation_message">Saved info like addresses or payment methods will be shared with this provider.</string>
+
+    <!-- Positive button to turn on credential manager provider (confirmation). [CHAR LIMIT=60] -->
+    <string name="credman_enable_confirmation_message_positive_button">Turn on</string>
+
     <!-- Title of the error dialog when too many credential providers are selected. [CHAR_LIMIT=NONE] -->
     <string name="credman_error_message_title">Passwords, passkeys and data services limit</string>
 
@@ -11937,6 +11976,8 @@
     <string name="flash_notifications_summary_on_camera_and_screen">On / Camera and screen flash</string>
     <!-- Introduction in Flash Notification page to introduce flash notifications feature. [CHAR LIMIT=NONE]  -->
     <string name="flash_notifications_intro">Flash the camera light or the screen when you receive notifications or when alarms sound</string>
+    <!-- Introduction in Flash Notification page to introduce flash notifications feature without camera flash option. [CHAR LIMIT=NONE]  -->
+    <string name="flash_notifications_intro_without_camera_flash">Flash the screen when you receive notifications or when alarms sound</string>
     <!-- Notes in Flash Notification page footer for something should be aware. [CHAR LIMIT=NONE]  -->
     <string name="flash_notifications_note">Use flash notifications with caution if you\u0027re light sensitive</string>
     <!-- Label of the button to preview the selected Flash Notification effects. [CHAR LIMIT=20]-->
diff --git a/res/xml/accounts_work_dashboard_settings_credman.xml b/res/xml/accounts_work_dashboard_settings_credman.xml
index 1559476..2946a21 100644
--- a/res/xml/accounts_work_dashboard_settings_credman.xml
+++ b/res/xml/accounts_work_dashboard_settings_credman.xml
@@ -22,9 +22,9 @@
     android:title="@string/account_dashboard_title"
     settings:keywords="@string/keywords_accounts">
 
-    <com.android.settings.widget.WorkOnlyCategory
-        android:key="autofill_work_app_defaults"
-        android:order="30"
+    <PreferenceCategory
+        android:key="default_service_category"
+        android:order="10"
         android:title="@string/default_autofill_app">
 
         <com.android.settings.widget.GearPreference
@@ -36,11 +36,11 @@
                 android:name="for_work"
                 android:value="true" />
         </com.android.settings.widget.GearPreference>
-    </com.android.settings.widget.WorkOnlyCategory>
+    </PreferenceCategory>
 
     <PreferenceCategory
         android:key="credman_category"
-        android:order="20"
+        android:order="50"
         android:persistent="false"
         android:title="@string/credman_credentials"
         settings:controller="com.android.settings.applications.credentials.CredentialManagerPreferenceController"
diff --git a/res/xml/double_twist_gesture_settings.xml b/res/xml/double_twist_gesture_settings.xml
index b825a2c..674ba51 100644
--- a/res/xml/double_twist_gesture_settings.xml
+++ b/res/xml/double_twist_gesture_settings.xml
@@ -24,7 +24,8 @@
     <com.android.settingslib.widget.IllustrationPreference
         android:key="gesture_double_twist_video"
         settings:searchable="false"
-        app:lottie_rawRes="@drawable/flip_camera_for_selfie"/>
+        settings:lottie_rawRes="@raw/flip_camera_for_selfie_lottie"
+        settings:dynamicColor="true"/>
 
     <SwitchPreference
         android:key="gesture_double_twist"
diff --git a/res/xml/flash_notifications_settings.xml b/res/xml/flash_notifications_settings.xml
index 0017fa6..243fffc 100644
--- a/res/xml/flash_notifications_settings.xml
+++ b/res/xml/flash_notifications_settings.xml
@@ -21,12 +21,12 @@
 
     <com.android.settingslib.widget.TopIntroPreference
         android:key="flash_notifications_intro"
-        android:title="@string/flash_notifications_intro" />
+        settings:controller="com.android.settings.accessibility.FlashNotificationsIntroPreferenceController" />
 
     <com.android.settingslib.widget.IllustrationPreference
         android:key="flash_notifications_illustration"
         settings:searchable="false"
-        settings:lottie_rawRes="@drawable/flash_notifications_illustration"/>
+        settings:lottie_rawRes="@drawable/flash_notifications_illustration" />
 
     <SwitchPreference
         android:key="camera_flash_notification_preference"
diff --git a/res/xml/keyboard_settings.xml b/res/xml/keyboard_settings.xml
index 9a3ac1a..bb1c3da 100644
--- a/res/xml/keyboard_settings.xml
+++ b/res/xml/keyboard_settings.xml
@@ -30,8 +30,7 @@
         <Preference
             android:key="physical_keyboard_pref"
             android:title="@string/physical_keyboard_title"
-            android:summary="@string/summary_placeholder"
-            android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
+            android:summary="@string/summary_placeholder"/>
     </PreferenceCategory>
 
     <PreferenceCategory
diff --git a/res/xml/wifi_hotspot_speed.xml b/res/xml/wifi_hotspot_speed.xml
new file mode 100644
index 0000000..b19a5b9
--- /dev/null
+++ b/res/xml/wifi_hotspot_speed.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2023 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:title="@string/wifi_hotspot_speed_title"
+    settings:searchable="false">
+
+    <com.android.settingslib.widget.TopIntroPreference
+        android:key="wifi_hotspot_speed_intro"
+        android:title="@string/wifi_hotspot_speed_intro"/>
+
+    <PreferenceCategory
+        android:key="wifi_hotspot_speed"
+        android:title="@string/wifi_hotspot_speed_category">
+
+        <com.android.settingslib.widget.SelectorWithWidgetPreference
+            android:key="wifi_hotspot_speed_2g"
+            android:title="@string/wifi_hotspot_speed_2g"
+            android:summary="@string/wifi_hotspot_speed_2g_summary"
+            android:visibility="gone"/>
+
+        <com.android.settingslib.widget.SelectorWithWidgetPreference
+            android:key="wifi_hotspot_speed_5g"
+            android:title="@string/wifi_hotspot_speed_5g"
+            android:summary="@string/wifi_hotspot_speed_5g_summary"
+            android:visibility="gone"/>
+
+        <com.android.settingslib.widget.SelectorWithWidgetPreference
+            android:key="wifi_hotspot_speed_2g_5g"
+            android:title="@string/wifi_hotspot_speed_2g_5g"
+            android:summary="@string/wifi_hotspot_speed_2g_5g_summary"/>
+
+        <com.android.settingslib.widget.SelectorWithWidgetPreference
+            android:key="wifi_hotspot_speed_6g"
+            android:title="@string/wifi_hotspot_speed_6g"
+            android:summary="@string/wifi_hotspot_speed_6g_summary"/>
+    </PreferenceCategory>
+
+    <com.android.settingslib.widget.FooterPreference
+        android:key="wifi_hotspot_speed__footer"
+        android:title="@string/wifi_hotspot_speed_footer"
+        android:selectable="false"/>
+</PreferenceScreen>
+
+
+
diff --git a/res/xml/wifi_tether_settings.xml b/res/xml/wifi_tether_settings.xml
index 1cd5f48..3023a6e 100644
--- a/res/xml/wifi_tether_settings.xml
+++ b/res/xml/wifi_tether_settings.xml
@@ -50,5 +50,6 @@
         android:key="wifi_hotspot_speed"
         android:title="@string/wifi_hotspot_speed_title"
         android:summary="@string/summary_placeholder"
+        android:fragment="com.android.settings.wifi.tether.WifiHotspotSpeedSettings"
         settings:isPreferenceVisible="@bool/config_show_wifi_hotspot_speed"/>
 </PreferenceScreen>
diff --git a/src/com/android/settings/SettingsDumpService.java b/src/com/android/settings/SettingsDumpService.java
index 38987f5..4feb6b2 100644
--- a/src/com/android/settings/SettingsDumpService.java
+++ b/src/com/android/settings/SettingsDumpService.java
@@ -31,12 +31,15 @@
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
+import android.util.IndentingPrintWriter;
+import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 
 import com.android.settings.applications.ProcStatsData;
 import com.android.settings.datausage.lib.DataUsageLib;
 import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
+import com.android.settings.network.MobileNetworkRepository;
 import com.android.settingslib.net.DataUsageController;
 
 import org.json.JSONArray;
@@ -48,6 +51,10 @@
 import java.io.PrintWriter;
 
 public class SettingsDumpService extends Service {
+
+    public static final String EXTRA_KEY_SHOW_NETWORK_DUMP = "show_network_dump";
+
+    private static final String TAG = "SettingsDumpService";
     @VisibleForTesting
     static final String KEY_SERVICE = "service";
     @VisibleForTesting
@@ -64,6 +71,16 @@
     static final Intent BROWSER_INTENT =
             new Intent("android.intent.action.VIEW", Uri.parse("http://"));
 
+    private boolean mShouldShowNetworkDump = false;
+
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+        if (intent != null) {
+            mShouldShowNetworkDump = intent.getBooleanExtra(EXTRA_KEY_SHOW_NETWORK_DUMP, false);
+        }
+        return Service.START_REDELIVER_INTENT;
+    }
+
     @Override
     public IBinder onBind(Intent intent) {
         return null;
@@ -71,20 +88,27 @@
 
     @Override
     protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
-        JSONObject dump = new JSONObject();
-
-        try {
-            dump.put(KEY_SERVICE, "Settings State");
-            dump.put(KEY_STORAGE, dumpStorage());
-            dump.put(KEY_DATAUSAGE, dumpDataUsage());
-            dump.put(KEY_MEMORY, dumpMemory());
-            dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
-            dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
-        } catch (Exception e) {
-            e.printStackTrace();
+        IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
+        if (!mShouldShowNetworkDump) {
+            JSONObject dump = new JSONObject();
+            pw.println(TAG + ": ");
+            pw.increaseIndent();
+            try {
+                dump.put(KEY_SERVICE, "Settings State");
+                dump.put(KEY_STORAGE, dumpStorage());
+                dump.put(KEY_DATAUSAGE, dumpDataUsage());
+                dump.put(KEY_MEMORY, dumpMemory());
+                dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
+                dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
+            } catch (Exception e) {
+                Log.w(TAG, "exception in dump: ", e);
+            }
+            pw.println(dump);
+            pw.flush();
+            pw.decreaseIndent();
+        } else {
+            dumpMobileNetworkSettings(pw);
         }
-
-        writer.println(dump);
     }
 
     private JSONObject dumpMemory() throws JSONException {
@@ -186,4 +210,8 @@
 
         return obj;
     }
+
+    private void dumpMobileNetworkSettings(IndentingPrintWriter writer) {
+        MobileNetworkRepository.getInstance(this).dump(writer);
+    }
 }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index 8626c52..57047f9 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -30,7 +30,6 @@
 import com.android.settings.search.actionbar.SearchMenuController;
 import com.android.settings.support.actionbar.HelpResourceProvider;
 import com.android.settingslib.core.instrumentation.Instrumentable;
-import com.android.settingslib.transition.SettingsTransitionHelper;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
 import com.google.android.setupdesign.util.ThemeHelper;
@@ -84,7 +83,6 @@
                         : Instrumentable.METRICS_CATEGORY_UNKNOWN)
                 .setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(),
                         new Bundle()))
-                .setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_FADE)
                 .launch();
         return true;
     }
diff --git a/src/com/android/settings/accessibility/FlashNotificationsIntroPreferenceController.java b/src/com/android/settings/accessibility/FlashNotificationsIntroPreferenceController.java
new file mode 100644
index 0000000..44866f8
--- /dev/null
+++ b/src/com/android/settings/accessibility/FlashNotificationsIntroPreferenceController.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+/** Preference controller that controls the text content of Flash Notifications intro. */
+public class FlashNotificationsIntroPreferenceController extends BasePreferenceController {
+
+    public FlashNotificationsIntroPreferenceController(Context context,
+            String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        final int titleResource = FlashNotificationsUtil.isTorchAvailable(mContext)
+                ? R.string.flash_notifications_intro
+                : R.string.flash_notifications_intro_without_camera_flash;
+        final Preference preference = screen.findPreference(getPreferenceKey());
+        if (preference != null) {
+            preference.setTitle(titleResource);
+        }
+    }
+}
diff --git a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java
index 851797e..089dc7b 100644
--- a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java
+++ b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java
@@ -16,14 +16,22 @@
 
 package com.android.settings.accessibility;
 
+import android.content.ComponentName;
 import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
 import android.widget.SeekBar;
 
 import androidx.annotation.NonNull;
 import androidx.preference.PreferenceScreen;
 
+import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.widget.LabeledSeekBarPreference;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnCreate;
+import com.android.settingslib.core.lifecycle.events.OnDestroy;
+import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
 
 import java.util.Optional;
 
@@ -31,12 +39,19 @@
  * The controller of {@link LabeledSeekBarPreference} that listens to display size and font size
  * settings changes and updates preview size threshold smoothly.
  */
-class PreviewSizeSeekBarController extends BasePreferenceController implements
-        TextReadingResetController.ResetStateListener {
+abstract class PreviewSizeSeekBarController extends BasePreferenceController implements
+        TextReadingResetController.ResetStateListener, LifecycleObserver, OnCreate,
+        OnDestroy, OnSaveInstanceState {
     private final PreviewSizeData<? extends Number> mSizeData;
+    private static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
     private boolean mSeekByTouch;
     private Optional<ProgressInteractionListener> mInteractionListener = Optional.empty();
     private LabeledSeekBarPreference mSeekBarPreference;
+    private int mLastProgress;
+    private boolean mNeedsQSTooltipReshow = false;
+    private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
+    private final Handler mHandler;
+
 
     private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener =
             new SeekBar.OnSeekBarChangeListener() {
@@ -54,6 +69,7 @@
 
                     if (!mSeekByTouch) {
                         interactionListener.onProgressChanged();
+                        onProgressFinalized();
                     }
                 }
 
@@ -67,6 +83,7 @@
                     mSeekByTouch = false;
 
                     mInteractionListener.ifPresent(ProgressInteractionListener::onEndTrackingTouch);
+                    onProgressFinalized();
                 }
             };
 
@@ -74,6 +91,30 @@
             @NonNull PreviewSizeData<? extends Number> sizeData) {
         super(context, preferenceKey);
         mSizeData = sizeData;
+        mHandler = new Handler(context.getMainLooper());
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        // Restore the tooltip.
+        if (savedInstanceState != null
+                && savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) {
+            mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW);
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        // remove runnables in the queue.
+        mHandler.removeCallbacksAndMessages(null);
+    }
+
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing();
+        if (mNeedsQSTooltipReshow || isTooltipWindowShowing) {
+            outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
+        }
     }
 
     void setInteractionListener(ProgressInteractionListener interactionListener) {
@@ -91,11 +132,15 @@
 
         final int dataSize = mSizeData.getValues().size();
         final int initialIndex = mSizeData.getInitialIndex();
+        mLastProgress = initialIndex;
         mSeekBarPreference = screen.findPreference(getPreferenceKey());
         mSeekBarPreference.setMax(dataSize - 1);
         mSeekBarPreference.setProgress(initialIndex);
         mSeekBarPreference.setContinuousUpdates(true);
         mSeekBarPreference.setOnSeekBarChangeListener(mSeekBarChangeListener);
+        if (mNeedsQSTooltipReshow) {
+            mHandler.post(this::showQuickSettingsTooltipIfNeeded);
+        }
     }
 
     @Override
@@ -108,6 +153,44 @@
         mInteractionListener.ifPresent(ProgressInteractionListener::onProgressChanged);
     }
 
+    private void onProgressFinalized() {
+        // Using progress in SeekBarPreference since the progresses in
+        // SeekBarPreference and seekbar are not always the same.
+        // See {@link androidx.preference.Preference#callChangeListener(Object)}
+        int seekBarPreferenceProgress = mSeekBarPreference.getProgress();
+        if (seekBarPreferenceProgress != mLastProgress) {
+            showQuickSettingsTooltipIfNeeded();
+            mLastProgress = seekBarPreferenceProgress;
+        }
+    }
+
+    private void showQuickSettingsTooltipIfNeeded() {
+        final ComponentName tileComponentName = getTileComponentName();
+        if (tileComponentName == null) {
+            // Returns if no tile service assigned.
+            return;
+        }
+
+        if (!mNeedsQSTooltipReshow && AccessibilityQuickSettingUtils.hasValueInSharedPreferences(
+                mContext, tileComponentName)) {
+            // Returns if quick settings tooltip only show once.
+            return;
+        }
+
+        mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(mContext);
+        mTooltipWindow.setup(getTileTooltipContent(),
+                R.drawable.accessibility_auto_added_qs_tooltip_illustration);
+        mTooltipWindow.showAtTopCenter(mSeekBarPreference.getSeekbar());
+        AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext, tileComponentName);
+        mNeedsQSTooltipReshow = false;
+    }
+
+    /** Returns the accessibility Quick Settings tile component name. */
+    abstract ComponentName getTileComponentName();
+
+    /** Returns accessibility Quick Settings tile tooltip content. */
+    abstract CharSequence getTileTooltipContent();
+
 
     /**
      * Interface for callbacks when users interact with the seek bar.
diff --git a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java
index b35a5fe..97a9071 100644
--- a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java
@@ -16,11 +16,13 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.internal.accessibility.AccessibilityShortcutController.FONT_SIZE_COMPONENT_NAME;
 import static com.android.settings.accessibility.TextReadingResetController.ResetStateListener;
 
 import android.app.Activity;
 import android.app.Dialog;
 import android.app.settings.SettingsEnums;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.os.Bundle;
@@ -156,12 +158,34 @@
         controllers.add(mPreviewController);
 
         final PreviewSizeSeekBarController fontSizeController = new PreviewSizeSeekBarController(
-                context, FONT_SIZE_KEY, fontSizeData);
+                context, FONT_SIZE_KEY, fontSizeData) {
+            @Override
+            ComponentName getTileComponentName() {
+                return FONT_SIZE_COMPONENT_NAME;
+            }
+
+            @Override
+            CharSequence getTileTooltipContent() {
+                return context.getText(
+                        R.string.accessibility_font_scaling_auto_added_qs_tooltip_content);
+            }
+        };
         fontSizeController.setInteractionListener(mPreviewController);
+        getSettingsLifecycle().addObserver(fontSizeController);
         controllers.add(fontSizeController);
 
         final PreviewSizeSeekBarController displaySizeController = new PreviewSizeSeekBarController(
-                context, DISPLAY_SIZE_KEY, displaySizeData);
+                context, DISPLAY_SIZE_KEY, displaySizeData) {
+            @Override
+            ComponentName getTileComponentName() {
+                return null;
+            }
+
+            @Override
+            CharSequence getTileTooltipContent() {
+                return null;
+            }
+        };
         displaySizeController.setInteractionListener(mPreviewController);
         controllers.add(displaySizeController);
 
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index bba2826..f59de46 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -75,7 +75,9 @@
         if (CredentialManager.isServiceEnabled(context)) {
             CredentialManagerPreferenceController cmpp =
                     use(CredentialManagerPreferenceController.class);
-            cmpp.init(this, getFragmentManager());
+            CredentialManagerPreferenceController.Delegate delegate =
+                result -> getActivity().setResult(result);
+            cmpp.init(this, getFragmentManager(), getIntent(), delegate);
         } else {
             getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
         }
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index e0d49d2..a87eb7d 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -69,7 +69,9 @@
         if (CredentialManager.isServiceEnabled(context)) {
             CredentialManagerPreferenceController cmpp =
                     use(CredentialManagerPreferenceController.class);
-            cmpp.init(this, getFragmentManager());
+            CredentialManagerPreferenceController.Delegate delegate =
+                result -> getActivity().setResult(result);
+            cmpp.init(this, getFragmentManager(), getIntent(), delegate);
         } else {
             getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
         }
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index da380b3..445aced 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -69,7 +69,9 @@
         if (CredentialManager.isServiceEnabled(context)) {
             CredentialManagerPreferenceController cmpp =
                     use(CredentialManagerPreferenceController.class);
-            cmpp.init(this, getFragmentManager());
+            CredentialManagerPreferenceController.Delegate delegate =
+                result -> getActivity().setResult(result);
+            cmpp.init(this, getFragmentManager(), getIntent(), delegate);
         } else {
             getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
         }
diff --git a/src/com/android/settings/applications/AppStoreUtil.java b/src/com/android/settings/applications/AppStoreUtil.java
index b18a68f..b73b14a 100644
--- a/src/com/android/settings/applications/AppStoreUtil.java
+++ b/src/com/android/settings/applications/AppStoreUtil.java
@@ -53,7 +53,8 @@
             // so we choose to ignore this when supplied by a non-system app.
             String originatingPackageName = source.getOriginatingPackageName();
             String initiatingPackageName = source.getInitiatingPackageName();
-            if (originatingPackageName != null && initiatingPackageName != null) {
+            if (originatingPackageName != null && initiatingPackageName != null
+                    && !initiatingPackageName.equals("com.android.shell")) {
                 ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
                         initiatingPackageName, 0);
                 if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
diff --git a/src/com/android/settings/applications/InstalledAppDetailsTop.java b/src/com/android/settings/applications/InstalledAppDetailsTop.java
index 63e0451..a1bd720 100644
--- a/src/com/android/settings/applications/InstalledAppDetailsTop.java
+++ b/src/com/android/settings/applications/InstalledAppDetailsTop.java
@@ -17,6 +17,7 @@
 package com.android.settings.applications;
 
 import android.content.Intent;
+import android.net.Uri;
 import android.os.Bundle;
 import android.util.FeatureFlagUtils;
 
@@ -30,12 +31,16 @@
     @Override
     protected void onCreate(Bundle savedState) {
         super.onCreate(savedState);
-        if (!FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_ENABLE_SPA)) {
+        if (isFinishing() ||
+                !FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_ENABLE_SPA)) {
             return;
         }
-        String packageName = super.getIntent().getData().getSchemeSpecificPart();
-        SpaActivity.startSpaActivity(
-                this, AppInfoSettingsProvider.INSTANCE.getRoute(packageName, getUserId()));
+        Uri data = super.getIntent().getData();
+        if (data != null) {
+            String packageName = data.getSchemeSpecificPart();
+            String route = AppInfoSettingsProvider.INSTANCE.getRoute(packageName, getUserId());
+            SpaActivity.startSpaActivity(this, route);
+        }
         finish();
     }
 
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index 7ca3f90..eb0a5ec 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -20,20 +20,26 @@
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.app.Activity;
 import android.app.Dialog;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ServiceInfo;
+import android.content.res.Resources;
 import android.credentials.CredentialManager;
 import android.credentials.CredentialProviderInfo;
 import android.credentials.SetEnabledProvidersException;
 import android.graphics.drawable.Drawable;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.OutcomeReceiver;
 import android.os.UserHandle;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.IconDrawableFactory;
 import android.util.Log;
@@ -45,6 +51,7 @@
 import androidx.lifecycle.LifecycleObserver;
 import androidx.lifecycle.LifecycleOwner;
 import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
 import androidx.preference.PreferenceGroup;
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
@@ -66,7 +73,10 @@
 /** Queries available credential manager providers and adds preferences for them. */
 public class CredentialManagerPreferenceController extends BasePreferenceController
         implements LifecycleObserver {
+    public static final String ADD_SERVICE_DEVICE_CONFIG = "credential_manager_service_search_uri";
     private static final String TAG = "CredentialManagerPreferenceController";
+    private static final String ALTERNATE_INTENT = "android.settings.SYNC_SETTINGS";
+    private static final String PRIMARY_INTENT = "android.settings.CREDENTIAL_PROVIDER";
     private static final int MAX_SELECTABLE_PROVIDERS = 5;
 
     private final PackageManager mPm;
@@ -76,8 +86,11 @@
     private final @Nullable CredentialManager mCredentialManager;
     private final Executor mExecutor;
     private final Map<String, SwitchPreference> mPrefs = new HashMap<>(); // key is package name
+    private final List<ServiceInfo> mPendingServiceInfos = new ArrayList<>();
 
     private @Nullable FragmentManager mFragmentManager = null;
+    private @Nullable Delegate mDelegate = null;
+    private @Nullable String mFlagOverrideForTest = null;
 
     public CredentialManagerPreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
@@ -115,10 +128,110 @@
      *
      * @param fragment the fragment to use as the parent
      * @param fragmentManager the fragment manager to use
+     * @param intent the intent used to start the activity
+     * @param delegate the delegate to send results back to
      */
-    public void init(DashboardFragment fragment, FragmentManager fragmentManager) {
+    public void init(
+            DashboardFragment fragment,
+            FragmentManager fragmentManager,
+            @Nullable Intent launchIntent,
+            @NonNull Delegate delegate) {
         fragment.getSettingsLifecycle().addObserver(this);
         mFragmentManager = fragmentManager;
+        setDelegate(delegate);
+        verifyReceivedIntent(launchIntent);
+    }
+
+    /**
+     * Parses and sets the package component name. Returns a boolean as to whether this was
+     * successful.
+     */
+    @VisibleForTesting
+    boolean verifyReceivedIntent(Intent launchIntent) {
+        if (launchIntent == null || launchIntent.getAction() == null) {
+            return false;
+        }
+
+        final String action = launchIntent.getAction();
+        final boolean isCredProviderAction =
+                TextUtils.equals(action, PRIMARY_INTENT);
+        final boolean isExistingAction = TextUtils.equals(action, ALTERNATE_INTENT);
+        final boolean isValid = isCredProviderAction || isExistingAction;
+
+        if (!isValid) {
+            return false;
+        }
+
+        // After this point we have received a set credential manager provider intent
+        // so we should return a cancelled result if the data we got is no good.
+        if (launchIntent.getData() == null) {
+            setActivityResult(Activity.RESULT_CANCELED);
+            return false;
+        }
+
+        String packageName = launchIntent.getData().getSchemeSpecificPart();
+        if (packageName == null) {
+            setActivityResult(Activity.RESULT_CANCELED);
+            return false;
+        }
+
+        mPendingServiceInfos.clear();
+        for (CredentialProviderInfo cpi : mServices) {
+            final ServiceInfo serviceInfo = cpi.getServiceInfo();
+            if (serviceInfo.packageName.equals(packageName)) {
+                mPendingServiceInfos.add(serviceInfo);
+            }
+        }
+
+        // Don't set the result as RESULT_OK here because we should wait for the user to
+        // enable the provider.
+        if (!mPendingServiceInfos.isEmpty()) {
+            return true;
+        }
+
+        setActivityResult(Activity.RESULT_CANCELED);
+        return false;
+    }
+
+    @VisibleForTesting
+    void setDelegate(Delegate delegate) {
+        mDelegate = delegate;
+    }
+
+    private void setActivityResult(int resultCode) {
+        if (mDelegate == null) {
+            Log.e(TAG, "Missing delegate");
+            return;
+        }
+        mDelegate.setActivityResult(resultCode);
+    }
+
+    private void handleIntent() {
+        List<ServiceInfo> pendingServiceInfos = new ArrayList<>(mPendingServiceInfos);
+        mPendingServiceInfos.clear();
+        if (pendingServiceInfos.isEmpty()) {
+            return;
+        }
+
+        ServiceInfo serviceInfo = pendingServiceInfos.get(0);
+        ApplicationInfo appInfo = serviceInfo.applicationInfo;
+        CharSequence appName = "";
+        if (appInfo.nonLocalizedLabel != null) {
+            appName = appInfo.loadLabel(mPm);
+        }
+
+        // Stop if there is no name.
+        if (TextUtils.isEmpty(appName)) {
+            return;
+        }
+
+        NewProviderConfirmationDialogFragment fragment =
+                newNewProviderConfirmationDialogFragment(serviceInfo.packageName, appName);
+        if (fragment == null || mFragmentManager == null) {
+            return;
+        }
+
+        fragment.show(mFragmentManager, NewProviderConfirmationDialogFragment.TAG);
     }
 
     @OnLifecycleEvent(ON_CREATE)
@@ -130,15 +243,22 @@
         setAvailableServices(
                 lifecycleOwner,
                 mCredentialManager.getCredentialProviderServices(
-                        getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY));
+                        getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
+                null);
     }
 
     @VisibleForTesting
     void setAvailableServices(
-            LifecycleOwner lifecycleOwner, List<CredentialProviderInfo> availableServices) {
+            LifecycleOwner lifecycleOwner,
+            List<CredentialProviderInfo> availableServices,
+            String flagOverrideForTest) {
+        mFlagOverrideForTest = flagOverrideForTest;
         mServices.clear();
         mServices.addAll(availableServices);
 
+        // If there is a pending dialog then show it.
+        handleIntent();
+
         mEnabledPackageNames.clear();
         for (CredentialProviderInfo cpi : availableServices) {
             if (cpi.isEnabled()) {
@@ -166,6 +286,65 @@
         PreferenceGroup group = screen.findPreference(getPreferenceKey());
         Context context = screen.getContext();
         mPrefs.putAll(buildPreferenceList(context, group));
+
+        // Add the "add service" button only when there are no providers.
+        if (mPrefs.isEmpty()) {
+            String searchUri = getAddServiceUri(context);
+            if (!TextUtils.isEmpty(searchUri)) {
+                group.addPreference(newAddServicePreference(searchUri, context));
+            }
+        }
+    }
+
+    /**
+     * Returns the "add service" URI to show the play store. It will first try and use the
+     * credential manager specific search URI and if that is null it will fallback to the autofill
+     * one.
+     */
+    public @NonNull String getAddServiceUri(@NonNull Context context) {
+        // Check the credential manager gflag for a link.
+        String searchUri =
+                DeviceConfig.getString(
+                        DeviceConfig.NAMESPACE_CREDENTIAL,
+                        ADD_SERVICE_DEVICE_CONFIG,
+                        mFlagOverrideForTest);
+        if (!TextUtils.isEmpty(searchUri)) {
+            return searchUri;
+        }
+
+        // If not fall back on autofill.
+        return Settings.Secure.getStringForUser(
+                context.getContentResolver(),
+                Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
+                getUser());
+    }
+
+    /**
+     * Gets the preference that allows to add a new cred man service.
+     *
+     * @return the pref to be added
+     */
+    @VisibleForTesting
+    public Preference newAddServicePreference(String searchUri, Context context) {
+        final Intent addNewServiceIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(searchUri));
+        final Preference preference = new Preference(context);
+        preference.setOnPreferenceClickListener(
+                p -> {
+                    context.startActivityAsUser(addNewServiceIntent, UserHandle.of(getUser()));
+                    return true;
+                });
+        preference.setTitle(R.string.print_menu_item_add_service);
+        preference.setOrder(Integer.MAX_VALUE - 1);
+        preference.setPersistent(false);
+
+        // Try to set the icon this should fail in a test environment but work
+        // in the actual app.
+        try {
+            preference.setIcon(R.drawable.ic_add_24dp);
+        } catch (Resources.NotFoundException e) {
+            Log.e(TAG, "Failed to find icon for add services link", e);
+        }
+        return preference;
     }
 
     /** Aggregates the list of services and builds a list of UI prefs to show. */
@@ -207,7 +386,9 @@
             }
 
             // Build the pref and add it to the output & group.
-            SwitchPreference pref = addProviderPreference(context, title, icon, packageName, firstInfo.getSettingsSubtitle());
+            SwitchPreference pref =
+                    addProviderPreference(
+                            context, title, icon, packageName, firstInfo.getSettingsSubtitle());
             output.put(packageName, pref);
             group.addPreference(pref);
         }
@@ -362,6 +543,49 @@
                 });
     }
 
+    /** Create the new provider confirmation dialog. */
+    private @Nullable NewProviderConfirmationDialogFragment
+            newNewProviderConfirmationDialogFragment(
+                    @NonNull String packageName, @NonNull CharSequence appName) {
+        DialogHost host =
+                new DialogHost() {
+                    @Override
+                    public void onDialogClick(int whichButton) {
+                        completeEnableProviderDialogBox(whichButton, packageName);
+                    }
+                };
+
+        return new NewProviderConfirmationDialogFragment(host, packageName, appName);
+    }
+
+    @VisibleForTesting
+    void completeEnableProviderDialogBox(int whichButton, String packageName) {
+        if (whichButton == DialogInterface.BUTTON_POSITIVE) {
+            if (togglePackageNameEnabled(packageName)) {
+                // Enable all prefs.
+                if (mPrefs.containsKey(packageName)) {
+                    mPrefs.get(packageName).setChecked(true);
+                }
+                setActivityResult(Activity.RESULT_OK);
+            } else {
+                // There are too many providers so set the result as cancelled.
+                setActivityResult(Activity.RESULT_CANCELED);
+
+                // Show the error if too many enabled.
+                final DialogFragment fragment = newErrorDialogFragment();
+
+                if (fragment == null || mFragmentManager == null) {
+                    return;
+                }
+
+                fragment.show(mFragmentManager, ErrorDialogFragment.TAG);
+            }
+        } else {
+            // The user clicked the cancel button so send that result back.
+            setActivityResult(Activity.RESULT_CANCELED);
+        }
+    }
+
     private @Nullable ErrorDialogFragment newErrorDialogFragment() {
         DialogHost host =
                 new DialogHost() {
@@ -401,10 +625,15 @@
     }
 
     /** Called when the dialog button is clicked. */
-    private interface DialogHost {
+    private static interface DialogHost {
         void onDialogClick(int whichButton);
     }
 
+    /** Called to send messages back to the parent fragment. */
+    public static interface Delegate {
+        void setActivityResult(int resultCode);
+    }
+
     /** Dialog fragment parent class. */
     private abstract static class CredentialManagerDialogFragment extends DialogFragment
             implements DialogInterface.OnClickListener {
@@ -484,4 +713,45 @@
             getDialogHost().onDialogClick(which);
         }
     }
+
+    /**
+     * Confirmation dialog fragment shows a dialog to the user to confirm that they would like to
+     * enable the new provider.
+     */
+    public static class NewProviderConfirmationDialogFragment
+            extends CredentialManagerDialogFragment {
+
+        NewProviderConfirmationDialogFragment(
+                DialogHost dialogHost, @NonNull String packageName, @NonNull CharSequence appName) {
+            super(dialogHost);
+
+            final Bundle argument = new Bundle();
+            argument.putString(PACKAGE_NAME_KEY, packageName);
+            argument.putCharSequence(APP_NAME_KEY, appName);
+            setArguments(argument);
+        }
+
+        @Override
+        public Dialog onCreateDialog(Bundle savedInstanceState) {
+            final Bundle bundle = getArguments();
+            final Context context = getContext();
+            final String title =
+                    context.getString(
+                            R.string.credman_enable_confirmation_message_title,
+                            bundle.getCharSequence(CredentialManagerDialogFragment.APP_NAME_KEY));
+
+            return new AlertDialog.Builder(getActivity())
+                    .setTitle(title)
+                    .setMessage(context.getString(R.string.credman_enable_confirmation_message))
+                    .setPositiveButton(
+                            R.string.credman_enable_confirmation_message_positive_button, this)
+                    .setNegativeButton(android.R.string.cancel, this)
+                    .create();
+        }
+
+        @Override
+        public void onClick(DialogInterface dialog, int which) {
+            getDialogHost().onDialogClick(which);
+        }
+    }
 }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index e63a754..af581b8 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -22,6 +22,8 @@
 import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_CONSENT_DENIED;
 import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_CONSENT_GRANTED;
 
+import static com.google.android.setupdesign.transition.TransitionHelper.TRANSITION_FADE_THROUGH;
+
 import android.annotation.NonNull;
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
@@ -55,6 +57,7 @@
 import com.android.settings.password.ChooseLockSettingsHelper;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
+import com.google.android.setupdesign.transition.TransitionHelper;
 
 import java.util.List;
 
@@ -457,6 +460,9 @@
                 final boolean isOk =
                         isSuccessfulConfirmOrChooseCredential(requestCode, resultCode);
                 if (isOk && (mHasFeatureFace || mHasFeatureFingerprint)) {
+                    // Apply forward animation during the transition from ChooseLock/ConfirmLock to
+                    // SetupFingerprintEnrollIntroduction/FingerprintEnrollmentActivity
+                    TransitionHelper.applyForwardTransition(this, TRANSITION_FADE_THROUGH);
                     updateGatekeeperPasswordHandle(data);
                     if (mHasFeatureFingerprint) {
                         launchFingerprintOnlyEnroll();
@@ -473,6 +479,10 @@
                 mIsSingleEnrolling = false;
                 if ((resultCode == BiometricEnrollBase.RESULT_SKIP
                         || resultCode == BiometricEnrollBase.RESULT_FINISHED) && mHasFeatureFace) {
+                    // Apply forward animation during the transition from
+                    // SetupFingerprintEnroll*/FingerprintEnrollmentActivity to
+                    // SetupFaceEnrollIntroduction
+                    TransitionHelper.applyForwardTransition(this, TRANSITION_FADE_THROUGH);
                     launchFaceOnlyEnroll();
                 } else {
                     finishOrLaunchHandToParent(resultCode);
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 2a1d049..7051b70 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -21,7 +21,6 @@
 import android.os.UserHandle;
 import android.view.View;
 
-import com.android.settings.R;
 import com.android.settings.password.ChooseLockSettingsHelper;
 
 /**
@@ -120,7 +119,6 @@
             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
         }
         startActivity(intent);
-        overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
         finish();
     }
 
diff --git a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
index 7f69b91..62928af 100644
--- a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
+++ b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
@@ -267,9 +267,11 @@
         } else {
             getSupportFragmentManager().beginTransaction()
                     .setReorderingAllowed(true)
+                    .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_open_exit,
+                            R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_close_exit)
                     .replace(R.id.fragment_container_view, fragmentClass, null, tag)
-                    .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
-                            R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
                     .addToBackStack(tag)
                     .commit();
         }
@@ -373,20 +375,24 @@
             // Replace enrolling page
             getSupportFragmentManager().beginTransaction()
                     .setReorderingAllowed(true)
+                    .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_open_exit,
+                            R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_close_exit)
                     .replace(R.id.fragment_container_view, FingerprintEnrollFinishFragment.class,
                             null, FINISH_TAG)
-                    .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
-                            R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
                     .commit();
         } else {
             // Remove Enrolling page from backstack, and add Finish page. Latest backstack will
             // be changed from Intro->FindSensor->Enrolling to Intro->FindSensor->Finish
             getSupportFragmentManager().beginTransaction()
                     .setReorderingAllowed(true)
+                    .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_open_exit,
+                            R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_close_exit)
                     .replace(R.id.fragment_container_view, FingerprintEnrollFinishFragment.class,
                             null, FINISH_TAG)
-                    .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
-                            R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
                     .addToBackStack(FINISH_TAG)
                     .commit();
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
index a86b758..563c010 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
@@ -20,6 +20,7 @@
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
 import android.content.Context;
+import android.os.SystemProperties;
 import android.provider.DeviceConfig;
 import android.text.TextUtils;
 import android.util.Log;
@@ -66,6 +67,9 @@
     @VisibleForTesting
     static final String HIGH_QUALITY_AUDIO_PREF_TAG = "A2dpProfileHighQualityAudio";
 
+    private static final String ENABLE_DUAL_MODE_AUDIO =
+            "persist.bluetooth.enable_dual_mode_audio";
+
     private LocalBluetoothManager mManager;
     private LocalBluetoothProfileManager mProfileManager;
     private CachedBluetoothDevice mCachedDevice;
@@ -118,40 +122,17 @@
 
     /**
      * Refreshes the state for an existing SwitchPreference for a profile.
-     * If the LeAudio profile is enabled on the LeAudio devices, then the SwitchPreferences of
-     * A2dp profile and Headset profile are graied out.
      */
     private void refreshProfilePreference(SwitchPreference profilePref,
             LocalBluetoothProfile profile) {
         BluetoothDevice device = mCachedDevice.getDevice();
         boolean isLeAudioEnabled = isLeAudioEnabled();
-        if (profile instanceof A2dpProfile
-                || profile instanceof HeadsetProfile) {
-            if (isLeAudioEnabled) {
-                // If the LeAudio profile is enabled on the LeAudio devices, then the
-                // SwitchPreferences of A2dp profile and Headset profile are grayed out.
-                Log.d(TAG, "LE is enabled, gray out " + profile.toString());
-                profilePref.setEnabled(false);
-            } else {
-                List<CachedBluetoothDevice> deviceList = mProfileDeviceMap.get(
-                        profile.toString());
-                boolean isBusy = deviceList != null
-                        && deviceList.stream().anyMatch(item -> item.isBusy());
-                profilePref.setEnabled(!isBusy);
-            }
-        } else if (profile instanceof LeAudioProfile) {
-            List<CachedBluetoothDevice> leAudioDeviceList = mProfileDeviceMap.get(
+        if (profile instanceof A2dpProfile || profile instanceof HeadsetProfile
+                || profile instanceof LeAudioProfile) {
+            List<CachedBluetoothDevice> deviceList = mProfileDeviceMap.get(
                     profile.toString());
-            boolean isBusy = leAudioDeviceList != null
-                    && leAudioDeviceList.stream().anyMatch(item -> item.isBusy());
-            if (isLeAudioEnabled && !isBusy) {
-                LocalBluetoothProfile a2dp = mProfileManager.getA2dpProfile();
-                LocalBluetoothProfile headset = mProfileManager.getHeadsetProfile();
-                // If the LeAudio profile is enabled on the LeAudio devices, then the
-                // SwitchPreferences of A2dp profile and Headset profile are graied out.
-                grayOutPreferenceWhenLeAudioIsEnabled(a2dp);
-                grayOutPreferenceWhenLeAudioIsEnabled(headset);
-            }
+            boolean isBusy = deviceList != null
+                    && deviceList.stream().anyMatch(item -> item.isBusy());
             profilePref.setEnabled(!isBusy);
         } else if (profile instanceof PbapServerProfile
                 && isLeAudioEnabled
@@ -183,7 +164,7 @@
                     highQualityPref.setVisible(true);
                     highQualityPref.setTitle(a2dp.getHighQualityAudioOptionLabel(device));
                     highQualityPref.setChecked(a2dp.isHighQualityAudioEnabled(device));
-                    highQualityPref.setEnabled(!mCachedDevice.isBusy() && !isLeAudioEnabled);
+                    highQualityPref.setEnabled(!mCachedDevice.isBusy());
                 } else {
                     highQualityPref.setVisible(false);
                 }
@@ -205,16 +186,6 @@
         return false;
     }
 
-    private void grayOutPreferenceWhenLeAudioIsEnabled(LocalBluetoothProfile profile) {
-        if (profile != null) {
-            SwitchPreference pref = mProfilesContainer.findPreference(profile.toString());
-            if (pref != null) {
-                Log.d(TAG, "LE is enabled, gray out " + profile.toString());
-                pref.setEnabled(false);
-            }
-        }
-    }
-
     /**
      * Helper method to enable a profile for a device.
      */
@@ -321,6 +292,17 @@
         if (mapPermission != BluetoothDevice.ACCESS_UNKNOWN) {
             result.add(mapProfile);
         }
+
+        // Removes phone calls & media audio toggles for dual mode devices
+        boolean leAudioSupported = result.contains(
+                mManager.getProfileManager().getLeAudioProfile());
+        boolean classicAudioSupported = result.contains(
+                mManager.getProfileManager().getA2dpProfile()) || result.contains(
+                mManager.getProfileManager().getHeadsetProfile());
+        if (leAudioSupported && classicAudioSupported) {
+            result.remove(mManager.getProfileManager().getA2dpProfile());
+            result.remove(mManager.getProfileManager().getHeadsetProfile());
+        }
         Log.d(TAG, "getProfiles:result:" + result);
         return result;
     }
@@ -340,10 +322,7 @@
     }
 
     /**
-     * When user disable the Le Audio profile, the system needs to do two things.
-     * 1) Disable the Le Audio profile, VCP and CSIP for each of the Le Audio devices.
-     * 2) Enable the A2dp profile and Headset profile for the associated device. The system
-     * can't enable the A2dp profile and Headset profile if the Le Audio profile is enabled.
+     * Disable the Le Audio profile, VCP, and CSIP for each of the Le Audio devices.
      *
      * @param profile the LeAudio profile
      */
@@ -354,8 +333,6 @@
         }
         LocalBluetoothProfile vcp = mProfileManager.getVolumeControlProfile();
         LocalBluetoothProfile csip = mProfileManager.getCsipSetCoordinatorProfile();
-        LocalBluetoothProfile a2dp = mProfileManager.getA2dpProfile();
-        LocalBluetoothProfile headset = mProfileManager.getHeadsetProfile();
 
         for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
             Log.d(TAG,
@@ -369,15 +346,15 @@
             }
         }
 
-        enableProfileAfterUserDisablesLeAudio(a2dp);
-        enableProfileAfterUserDisablesLeAudio(headset);
+        if (!SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false)) {
+            Log.i(TAG, "Enabling classic audio profiles because dual mode is disabled");
+            enableProfileAfterUserDisablesLeAudio(mProfileManager.getA2dpProfile());
+            enableProfileAfterUserDisablesLeAudio(mProfileManager.getHeadsetProfile());
+        }
     }
 
     /**
-     * When user enable the Le Audio profile, the system needs to do two things.
-     * 1) Disable the A2dp profile and Headset profile for the associated device. The system
-     * can't enable the Le Audio if the A2dp profile and Headset profile are enabled.
-     * 2) Enable the Le Audio profile, VCP and CSIP for each of the Le Audio devices.
+     * Enable the Le Audio profile, VCP, and CSIP for each of the Le Audio devices.
      *
      * @param profile the LeAudio profile
      */
@@ -386,14 +363,15 @@
             Log.e(TAG, "There is no the LE profile or no device in mProfileDeviceMap. Do nothing.");
             return;
         }
-        LocalBluetoothProfile a2dp = mProfileManager.getA2dpProfile();
-        LocalBluetoothProfile headset = mProfileManager.getHeadsetProfile();
+
+        if (!SystemProperties.getBoolean(ENABLE_DUAL_MODE_AUDIO, false)) {
+            Log.i(TAG, "Disabling classic audio profiles because dual mode is disabled");
+            disableProfileBeforeUserEnablesLeAudio(mProfileManager.getA2dpProfile());
+            disableProfileBeforeUserEnablesLeAudio(mProfileManager.getHeadsetProfile());
+        }
+
         LocalBluetoothProfile vcp = mProfileManager.getVolumeControlProfile();
         LocalBluetoothProfile csip = mProfileManager.getCsipSetCoordinatorProfile();
-
-        disableProfileBeforeUserEnablesLeAudio(a2dp);
-        disableProfileBeforeUserEnablesLeAudio(headset);
-
         for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) {
             Log.d(TAG,
                     "User enable LE device: " + leAudioDevice.getDevice().getAnonymizedAddress());
@@ -474,6 +452,7 @@
             item.registerCallback(this);
         }
         mProfileManager.addServiceListener(this);
+        refresh();
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
index 3851753..182ada2 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
@@ -172,7 +172,7 @@
         }
         use(AdvancedBluetoothDetailsHeaderController.class).init(mCachedDevice);
         use(LeAudioBluetoothDetailsHeaderController.class).init(mCachedDevice, mManager);
-        use(KeyboardSettingsPreferenceController.class).init(mCachedDevice, getActivity());
+        use(KeyboardSettingsPreferenceController.class).init(mCachedDevice);
 
         final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(
                 context).getBluetoothFeatureProvider();
diff --git a/src/com/android/settings/bluetooth/HearingDeviceCallRoutingPreferenceController.java b/src/com/android/settings/bluetooth/HearingDeviceCallRoutingPreferenceController.java
index ea5ba8b..4e5e193 100644
--- a/src/com/android/settings/bluetooth/HearingDeviceCallRoutingPreferenceController.java
+++ b/src/com/android/settings/bluetooth/HearingDeviceCallRoutingPreferenceController.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.provider.Settings;
 
+import com.android.settings.Utils;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.bluetooth.HearingAidAudioRoutingConstants;
 
@@ -44,6 +45,11 @@
     }
 
     @Override
+    public int getAvailabilityStatus() {
+        return Utils.isVoiceCapable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+    }
+
+    @Override
     protected int[] getSupportedAttributeList() {
         return HearingAidAudioRoutingConstants.CALL_ROUTING_ATTRIBUTES;
     }
diff --git a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
index ac895df..c93a1c6 100644
--- a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
+++ b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
@@ -127,8 +127,9 @@
         pref.setTitle(mContext.getString(R.string.stylus_textfield_handwriting));
         pref.setIcon(R.drawable.ic_text_fields_alt);
         pref.setOnPreferenceClickListener(this);
-        pref.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 1);
+        pref.setChecked(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+                Secure.STYLUS_HANDWRITING_DEFAULT_VALUE) == 1);
         pref.setVisible(currentInputMethodSupportsHandwriting());
         return pref;
     }
@@ -157,8 +158,8 @@
                 mContext.startActivity(intent);
                 break;
             case KEY_HANDWRITING:
-                Settings.Global.putInt(mContext.getContentResolver(),
-                        Settings.Global.STYLUS_HANDWRITING_ENABLED,
+                Settings.Secure.putInt(mContext.getContentResolver(),
+                        Settings.Secure.STYLUS_HANDWRITING_ENABLED,
                         ((SwitchPreference) preference).isChecked() ? 1 : 0);
 
                 if (((SwitchPreference) preference).isChecked()) {
diff --git a/src/com/android/settings/core/SettingsBaseActivity.java b/src/com/android/settings/core/SettingsBaseActivity.java
index b4380ab..ff84a3f 100644
--- a/src/com/android/settings/core/SettingsBaseActivity.java
+++ b/src/com/android/settings/core/SettingsBaseActivity.java
@@ -50,6 +50,7 @@
 import com.google.android.material.appbar.CollapsingToolbarLayout;
 import com.google.android.material.resources.TextAppearanceConfig;
 import com.google.android.setupcompat.util.WizardManagerHelper;
+import com.google.android.setupdesign.transition.TransitionHelper;
 import com.google.android.setupdesign.util.ThemeHelper;
 
 /** Base activity for Settings pages */
@@ -77,6 +78,11 @@
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
+        final boolean isAnySetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
+        if (isAnySetupWizard) {
+            TransitionHelper.applyForwardTransition(this);
+            TransitionHelper.applyBackwardTransition(this);
+        }
         super.onCreate(savedInstanceState);
         if (isFinishing()) {
             return;
@@ -97,7 +103,6 @@
             requestWindowFeature(Window.FEATURE_NO_TITLE);
         }
         // Apply SetupWizard light theme during setup flow. This is for SubSettings pages.
-        final boolean isAnySetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
         if (isAnySetupWizard && this instanceof SubSettings) {
             setTheme(SetupWizardUtils.getTheme(this, getIntent()));
             setTheme(R.style.SettingsPreferenceTheme_SetupWizard);
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 68751e5..b1661e1 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -58,15 +58,20 @@
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.datausage.CycleAdapter.SpinnerInterface;
 import com.android.settings.network.MobileDataEnabledListener;
+import com.android.settings.network.MobileNetworkRepository;
 import com.android.settings.network.ProxySubscriptionManager;
 import com.android.settings.widget.LoadingViewController;
 import com.android.settingslib.AppItem;
+import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
 import com.android.settingslib.net.NetworkCycleChartData;
 import com.android.settingslib.net.NetworkCycleChartDataLoader;
 import com.android.settingslib.net.NetworkStatsSummaryLoader;
+import com.android.settingslib.net.UidDetail;
 import com.android.settingslib.net.UidDetailProvider;
+import com.android.settingslib.utils.ThreadUtils;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
@@ -118,6 +123,8 @@
     private Preference mUsageAmount;
     private PreferenceGroup mApps;
     private View mHeader;
+    private MobileNetworkRepository mMobileNetworkRepository;
+    private SubscriptionInfoEntity mSubscriptionInfoEntity;
 
     @Override
     public int getMetricsCategory() {
@@ -146,6 +153,11 @@
         }
 
         processArgument();
+        mMobileNetworkRepository = MobileNetworkRepository.getInstance(getContext());
+        ThreadUtils.postOnBackgroundThread(() -> {
+            mSubscriptionInfoEntity = mMobileNetworkRepository.getSubInfoById(
+                    String.valueOf(mSubId));
+        });
         mDataStateListener = new MobileDataEnabledListener(activity, this);
     }
 
@@ -451,7 +463,23 @@
         }
 
         Collections.sort(items);
+        final List<String> packageNames = Arrays.asList(getContext().getResources().getStringArray(
+                R.array.datausage_hiding_carrier_service_package_names));
+        boolean shouldHidePackageName = mSubscriptionInfoEntity != null
+                ? Arrays.stream(getContext().getResources().getIntArray(
+                        R.array.datausage_hiding_carrier_service_carrier_id))
+                .anyMatch(carrierId -> (carrierId == mSubscriptionInfoEntity.carrierId))
+                : false;
+
         for (int i = 0; i < items.size(); i++) {
+            UidDetail detail = mUidDetailProvider.getUidDetail(items.get(i).key, true);
+            // Do not show carrier service package in data usage list if it should be hidden for
+            // the carrier.
+            if (detail != null && shouldHidePackageName && packageNames.contains(
+                    detail.packageName)) {
+                continue;
+            }
+
             final int percentTotal = largest != 0 ? (int) (items.get(i).total * 100 / largest) : 0;
             final AppDataUsagePreference preference = new AppDataUsagePreference(getContext(),
                     items.get(i), percentTotal, mUidDetailProvider);
diff --git a/src/com/android/settings/development/StylusHandwritingPreferenceController.java b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
index 69b5bad..12cd781 100644
--- a/src/com/android/settings/development/StylusHandwritingPreferenceController.java
+++ b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
@@ -45,8 +45,8 @@
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         final boolean isEnabled = (Boolean) newValue;
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED,
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
                 isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
 
         return true;
@@ -54,16 +54,18 @@
 
     @Override
     public void updateState(Preference preference) {
-        final int enable = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+        final int enable = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+                Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
         ((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
     }
 
     @Override
     protected void onDeveloperOptionsSwitchDisabled() {
         super.onDeveloperOptionsSwitchDisabled();
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+                Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
         ((SwitchPreference) mPreference).setChecked(false);
     }
 }
diff --git a/src/com/android/settings/display/ScreenResolutionFragment.java b/src/com/android/settings/display/ScreenResolutionFragment.java
index b40b48f..de7d25f 100644
--- a/src/com/android/settings/display/ScreenResolutionFragment.java
+++ b/src/com/android/settings/display/ScreenResolutionFragment.java
@@ -251,10 +251,10 @@
 
         if (TextUtils.equals(
                 mScreenResolutionOptions[ScreenResolutionController.HIGHRESOLUTION_IDX], key)) {
-            preference.setLottieAnimationResId(R.drawable.screen_resolution_1080p);
+            preference.setLottieAnimationResId(R.drawable.screen_resolution_high);
         } else if (TextUtils.equals(
                 mScreenResolutionOptions[ScreenResolutionController.FULLRESOLUTION_IDX], key)) {
-            preference.setLottieAnimationResId(R.drawable.screen_resolution_1440p);
+            preference.setLottieAnimationResId(R.drawable.screen_resolution_full);
         }
     }
 
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryHistEntry.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryHistEntry.java
index 2cfb526..827f0fc 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryHistEntry.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryHistEntry.java
@@ -204,8 +204,7 @@
 
     @Override
     public String toString() {
-        final String recordAtDateTime =
-                ConvertUtils.utcToLocalTime(/*context=*/ null, mTimestamp);
+        final String recordAtDateTime = ConvertUtils.utcToLocalTimeForLogging(mTimestamp);
         final StringBuilder builder = new StringBuilder()
                 .append("\nBatteryHistEntry{")
                 .append(String.format("\n\tpackage=%s|label=%s|uid=%d|userId=%d|isHidden=%b",
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java
index 9c7ec35..a437877 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java
@@ -54,11 +54,13 @@
         if (intent == null || intent.getAction() == null) {
             return;
         }
-        Log.d(TAG, "onReceive:" + intent.getAction());
+        final String action = intent.getAction();
+        Log.d(TAG, "onReceive:" + action);
+        DatabaseUtils.recordDateTime(context, action);
         final String fullChargeIntentAction = FeatureFactory.getFactory(context)
                 .getPowerUsageFeatureProvider(context)
                 .getFullChargeIntentAction();
-        switch (intent.getAction()) {
+        switch (action) {
             case Intent.ACTION_BATTERY_LEVEL_CHANGED:
                 // Only when fullChargeIntentAction is ACTION_BATTERY_LEVEL_CHANGED,
                 // ACTION_BATTERY_LEVEL_CHANGED will be considered as the full charge event and then
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageDataLoader.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageDataLoader.java
index d446bb2..fb1be3e 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageDataLoader.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageDataLoader.java
@@ -57,6 +57,10 @@
         }
         final long elapsedTime = System.currentTimeMillis() - start;
         Log.d(TAG, String.format("getBatteryUsageStats() in %d/ms", elapsedTime));
+        if (isFullChargeStart) {
+            DatabaseUtils.recordDateTime(
+                    context, DatabaseUtils.KEY_LAST_LOAD_FULL_CHARGE_TIME);
+        }
 
         // Uploads the BatteryEntry data into database.
         DatabaseUtils.sendBatteryEntryData(
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageStatsLoader.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageStatsLoader.java
index d61b276..7f112ae 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageStatsLoader.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageStatsLoader.java
@@ -45,7 +45,8 @@
             builder.includeBatteryHistory();
         }
         try {
-            return mBatteryStatsManager.getBatteryUsageStats(builder.build());
+            return mBatteryStatsManager.getBatteryUsageStats(
+                    builder.includeProcessStateData().build());
         } catch (RuntimeException e) {
             Log.e(TAG, "loadInBackground() for getBatteryUsageStats()", e);
             // Use default BatteryUsageStats.
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiver.java b/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiver.java
index 8c9285e..64b5b77 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiver.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiver.java
@@ -61,8 +61,6 @@
 
         switch (action) {
             case Intent.ACTION_BOOT_COMPLETED:
-            case Intent.ACTION_MY_PACKAGE_REPLACED:
-            case Intent.ACTION_MY_PACKAGE_UNSUSPENDED:
             case ACTION_SETUP_WIZARD_FINISHED:
             case ACTION_PERIODIC_JOB_RECHECK:
                 Log.d(TAG, "refresh periodic job from action=" + action);
diff --git a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
index c1b7818..fcf934f 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
@@ -237,9 +237,10 @@
         return eventBuilder.build();
     }
 
-    /** Converts UTC timestamp to human readable local time string. */
-    public static String utcToLocalTime(Context context, long timestamp) {
-        final Locale locale = getLocale(context);
+    /** Converts UTC timestamp to local time string for logging only, so use the US locale for
+     *  better readability in debugging. */
+    public static String utcToLocalTimeForLogging(long timestamp) {
+        final Locale locale = Locale.US;
         final String pattern =
                 DateFormat.getBestDateTimePattern(locale, "MMM dd,yyyy HH:mm:ss");
         return DateFormat.format(pattern, timestamp).toString();
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
index 338cb11..38d4e69 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
@@ -17,7 +17,6 @@
 package com.android.settings.fuelgauge.batteryusage;
 
 import static com.android.settings.fuelgauge.batteryusage.ConvertUtils.getEffectivePackageName;
-import static com.android.settings.fuelgauge.batteryusage.ConvertUtils.utcToLocalTime;
 
 import android.app.usage.IUsageStatsManager;
 import android.app.usage.UsageEvents;
@@ -1357,7 +1356,7 @@
         final Map<String, BatteryHistEntry> entryMap = processedBatteryHistoryMap.get(timestamp);
         if (entryMap == null || entryMap.isEmpty()) {
             Log.e(TAG, "abnormal entry list in the timestamp:"
-                    + utcToLocalTime(context, timestamp));
+                    + ConvertUtils.utcToLocalTimeForLogging(timestamp));
             return null;
         }
         // The current time battery history hasn't been loaded yet, returns the current battery
@@ -1934,7 +1933,7 @@
             final BatteryHistEntry entry) {
         if (sDebug) {
             Log.d(TAG, String.format(entry != null ? "%s %s:\n%s" : "%s %s:%s",
-                    utcToLocalTime(context, timestamp), content, entry));
+                    ConvertUtils.utcToLocalTimeForLogging(timestamp), content, entry));
         }
     }
 }
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
index 655114f..ef1434c 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
@@ -19,6 +19,7 @@
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.database.Cursor;
 import android.net.Uri;
@@ -37,6 +38,7 @@
 import com.android.settings.fuelgauge.batteryusage.db.BatteryStateDatabase;
 import com.android.settingslib.fuelgauge.BatteryStatus;
 
+import java.io.PrintWriter;
 import java.time.Clock;
 import java.time.Duration;
 import java.util.ArrayList;
@@ -50,12 +52,15 @@
 /** A utility class to operate battery usage database. */
 public final class DatabaseUtils {
     private static final String TAG = "DatabaseUtils";
+    private static final String SHARED_PREFS_FILE = "battery_usage_shared_prefs";
+
     /** Clear memory threshold for device booting phase. **/
     private static final long CLEAR_MEMORY_THRESHOLD_MS = Duration.ofMinutes(5).toMillis();
     private static final long CLEAR_MEMORY_DELAYED_MS = Duration.ofSeconds(2).toMillis();
 
-    @VisibleForTesting
     static final int DATA_RETENTION_INTERVAL_DAY = 9;
+    static final String KEY_LAST_LOAD_FULL_CHARGE_TIME = "last_load_full_charge_time";
+    static final String KEY_LAST_UPLOAD_FULL_CHARGE_TIME = "last_upload_full_charge_time";
 
     /** An authority name of the battery content provider. */
     public static final String AUTHORITY = "com.android.settings.battery.usage.provider";
@@ -126,9 +131,10 @@
                         .build();
         final long latestTimestamp =
                 loadAppUsageLatestTimestampFromContentProvider(context, appUsageLatestTimestampUri);
+        final String latestTimestampString = ConvertUtils.utcToLocalTimeForLogging(latestTimestamp);
         Log.d(TAG, String.format(
-                "getAppUsageStartTimestampOfUser() userId=%d latestTimestamp=%d in %d/ms",
-                userId, latestTimestamp, (System.currentTimeMillis() - startTime)));
+                "getAppUsageStartTimestampOfUser() userId=%d latestTimestamp=%s in %d/ms",
+                userId, latestTimestampString, (System.currentTimeMillis() - startTime)));
         // Use (latestTimestamp + 1) here to avoid loading the events of the latestTimestamp
         // repeatedly.
         return Math.max(latestTimestamp + 1, earliestTimestamp);
@@ -146,7 +152,8 @@
         // sure the app usage calculation near the boundaries is correct.
         final long queryTimestamp =
                 Math.max(rawStartTimestamp, sixDaysAgoTimestamp) - USAGE_QUERY_BUFFER_HOURS;
-        Log.d(TAG, "sixDayAgoTimestamp: " + sixDaysAgoTimestamp);
+        Log.d(TAG, "sixDayAgoTimestamp: " + ConvertUtils.utcToLocalTimeForLogging(
+                sixDaysAgoTimestamp));
         final String queryUserIdString = userIds.stream()
                 .map(userId -> String.valueOf(userId))
                 .collect(Collectors.joining(","));
@@ -174,7 +181,8 @@
             Context context, Calendar calendar) {
         final long startTime = System.currentTimeMillis();
         final long sixDaysAgoTimestamp = getTimestampSixDaysAgo(calendar);
-        Log.d(TAG, "sixDayAgoTimestamp: " + sixDaysAgoTimestamp);
+        Log.d(TAG, "sixDayAgoTimestamp: " + ConvertUtils.utcToLocalTimeForLogging(
+                sixDaysAgoTimestamp));
         // Builds the content uri everytime to avoid cache.
         final Uri batteryStateUri =
                 new Uri.Builder()
@@ -373,10 +381,50 @@
         resolver.notifyChange(BATTERY_CONTENT_URI, /*observer=*/ null);
         Log.d(TAG, String.format("sendBatteryEntryData() size=%d in %d/ms",
                 size, (System.currentTimeMillis() - startTime)));
+        if (isFullChargeStart) {
+            recordDateTime(context, KEY_LAST_UPLOAD_FULL_CHARGE_TIME);
+        }
         clearMemory();
         return valuesList;
     }
 
+    /** Dump all required data into {@link PrintWriter}. */
+    public static void dump(Context context, PrintWriter writer) {
+        writeString(context, writer, "BatteryLevelChanged",
+                Intent.ACTION_BATTERY_LEVEL_CHANGED);
+        writeString(context, writer, "BatteryUnplugging",
+                BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING);
+        writeString(context, writer, "ClearBatteryCacheData",
+                BatteryUsageBroadcastReceiver.ACTION_CLEAR_BATTERY_CACHE_DATA);
+        writeString(context, writer, "LastLoadFullChargeTime",
+                KEY_LAST_LOAD_FULL_CHARGE_TIME);
+        writeString(context, writer, "LastUploadFullChargeTime",
+                KEY_LAST_UPLOAD_FULL_CHARGE_TIME);
+    }
+
+    static SharedPreferences getSharedPreferences(Context context) {
+        return context.getApplicationContext().getSharedPreferences(
+                SHARED_PREFS_FILE, Context.MODE_PRIVATE);
+    }
+
+    static void recordDateTime(Context context, String preferenceKey) {
+        final SharedPreferences sharedPreferences = getSharedPreferences(context);
+        if (sharedPreferences != null) {
+            final String currentTime = ConvertUtils.utcToLocalTimeForLogging(
+                    System.currentTimeMillis());
+            sharedPreferences.edit().putString(preferenceKey, currentTime).apply();
+        }
+    }
+
+    private static void writeString(
+            Context context, PrintWriter writer, String prefix, String key) {
+        final SharedPreferences sharedPreferences = getSharedPreferences(context);
+        if (sharedPreferences != null) {
+            final String content = sharedPreferences.getString(key, "");
+            writer.println(String.format("\t\t%s: %s", prefix, content));
+        }
+    }
+
     private static long loadAppUsageLatestTimestampFromContentProvider(
             Context context, final Uri appUsageLatestTimestampUri) {
         // We have already make sure the context here is with profile parent's user identity. Don't
diff --git a/src/com/android/settings/fuelgauge/batteryusage/PeriodicJobManager.java b/src/com/android/settings/fuelgauge/batteryusage/PeriodicJobManager.java
index 2b18e92..3d78c00 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/PeriodicJobManager.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/PeriodicJobManager.java
@@ -26,11 +26,8 @@
 
 import com.android.settings.overlay.FeatureFactory;
 
-import java.text.SimpleDateFormat;
 import java.time.Clock;
 import java.time.Duration;
-import java.util.Date;
-import java.util.Locale;
 
 /** Manages the periodic job to schedule or cancel the next job. */
 public final class PeriodicJobManager {
@@ -41,8 +38,6 @@
 
     private final Context mContext;
     private final AlarmManager mAlarmManager;
-    private final SimpleDateFormat mSimpleDateFormat =
-            new SimpleDateFormat("MMM dd,yyyy HH:mm:ss", Locale.ENGLISH);
 
     @VisibleForTesting
     static final int DATA_FETCH_INTERVAL_MINUTE = 60;
@@ -69,7 +64,6 @@
     }
 
     /** Schedules the next alarm job if it is available. */
-    @SuppressWarnings("JavaUtilDate")
     public void refreshJob(final boolean fromBoot) {
         if (mAlarmManager == null) {
             Log.e(TAG, "cannot schedule next alarm job");
@@ -83,7 +77,7 @@
         mAlarmManager.setExactAndAllowWhileIdle(
                 AlarmManager.RTC_WAKEUP, triggerAtMillis, pendingIntent);
         Log.d(TAG, "schedule next alarm job at "
-                + mSimpleDateFormat.format(new Date(triggerAtMillis)));
+                + ConvertUtils.utcToLocalTimeForLogging(triggerAtMillis));
     }
 
     void cancelJob(PendingIntent pendingIntent) {
diff --git a/src/com/android/settings/fuelgauge/batteryusage/bugreport/LogUtils.java b/src/com/android/settings/fuelgauge/batteryusage/bugreport/LogUtils.java
index 8215839..9be378b 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/bugreport/LogUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/bugreport/LogUtils.java
@@ -19,6 +19,8 @@
 import android.content.Context;
 import android.util.Log;
 
+import com.android.settings.fuelgauge.batteryusage.ConvertUtils;
+import com.android.settings.fuelgauge.batteryusage.DatabaseUtils;
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventDao;
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
 import com.android.settings.fuelgauge.batteryusage.db.BatteryState;
@@ -26,12 +28,9 @@
 import com.android.settings.fuelgauge.batteryusage.db.BatteryStateDatabase;
 
 import java.io.PrintWriter;
-import java.text.SimpleDateFormat;
 import java.time.Clock;
 import java.time.Duration;
-import java.util.Date;
 import java.util.List;
-import java.util.Locale;
 
 /** A utility class to aggregate and provide required log data. */
 public final class LogUtils {
@@ -39,8 +38,9 @@
     private static final Duration DUMP_TIME_OFFSET = Duration.ofHours(24);
     private static final Duration DUMP_TIME_OFFSET_FOR_ENTRY = Duration.ofHours(4);
 
-    @SuppressWarnings("JavaUtilDate")
     static void dumpBatteryUsageDatabaseHist(Context context, PrintWriter writer) {
+        DatabaseUtils.dump(context, writer);
+        writer.flush();
         final BatteryStateDao dao =
                 BatteryStateDatabase
                         .getInstance(context.getApplicationContext())
@@ -57,20 +57,18 @@
             return;
         }
         // Dumps all distinct timestamps.
-        final SimpleDateFormat formatter =
-                new SimpleDateFormat("MMM dd, HH:mm:ss", Locale.US);
         timestamps.forEach(timestamp -> {
-            final String formattedTimestamp = formatter.format(new Date(timestamp));
+            final String formattedTimestamp = ConvertUtils.utcToLocalTimeForLogging(timestamp);
             writer.println("\t" + formattedTimestamp);
             Log.w(TAG, "\t" + formattedTimestamp);
         });
+        writer.flush();
 
         final List<BatteryState> stateList = dao.getAllAfter(
                 Clock.systemUTC().millis() - DUMP_TIME_OFFSET_FOR_ENTRY.toMillis());
         stateList.stream().forEach(state -> writer.println(state));
     }
 
-    @SuppressWarnings("JavaUtilDate")
     static void dumpAppUsageDatabaseHist(Context context, PrintWriter writer) {
         final AppUsageEventDao dao =
                 BatteryStateDatabase
@@ -80,6 +78,7 @@
         final List<AppUsageEventEntity> eventList = dao.getAllAfter(
                 Clock.systemUTC().millis() - DUMP_TIME_OFFSET_FOR_ENTRY.toMillis());
         eventList.stream().forEach(event -> writer.println(event));
+        writer.flush();
     }
 
     private LogUtils() {}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventEntity.java b/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventEntity.java
index 9d62d07..c08c735 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventEntity.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/db/AppUsageEventEntity.java
@@ -21,19 +21,15 @@
 import androidx.room.Entity;
 import androidx.room.PrimaryKey;
 
+import com.android.settings.fuelgauge.batteryusage.ConvertUtils;
+
 import com.google.errorprone.annotations.CanIgnoreReturnValue;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.Locale;
-import java.util.TimeZone;
 
 /** A {@link Entity} class to save app usage events into database. */
 @Entity
 public class AppUsageEventEntity {
-    private static String sCacheZoneId;
-    private static SimpleDateFormat sCacheSimpleDateFormat;
-
     /** Keys for accessing {@link ContentValues}. */
     public static final String KEY_UID = "uid";
     public static final String KEY_USER_ID = "userId";
@@ -83,14 +79,8 @@
     }
 
     @Override
-    @SuppressWarnings("JavaUtilDate")
     public String toString() {
-        final String currentZoneId = TimeZone.getDefault().getID();
-        if (!currentZoneId.equals(sCacheZoneId) || sCacheSimpleDateFormat == null) {
-            sCacheZoneId = currentZoneId;
-            sCacheSimpleDateFormat = new SimpleDateFormat("MMM dd,yyyy HH:mm:ss", Locale.US);
-        }
-        final String recordAtDateTime = sCacheSimpleDateFormat.format(new Date(timestamp));
+        final String recordAtDateTime = ConvertUtils.utcToLocalTimeForLogging(timestamp);
         final StringBuilder builder = new StringBuilder()
                 .append("\nAppUsageEvent{")
                 .append(String.format(Locale.US,
diff --git a/src/com/android/settings/fuelgauge/batteryusage/db/BatteryState.java b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryState.java
index 9139c10..190c274 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/db/BatteryState.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryState.java
@@ -23,20 +23,15 @@
 
 import com.android.settings.fuelgauge.BatteryUtils;
 import com.android.settings.fuelgauge.batteryusage.BatteryInformation;
+import com.android.settings.fuelgauge.batteryusage.ConvertUtils;
 
 import com.google.errorprone.annotations.CanIgnoreReturnValue;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.Locale;
-import java.util.TimeZone;
 
 /** A {@link Entity} class to save battery states snapshot into database. */
 @Entity
 public class BatteryState {
-    private static String sCacheZoneId;
-    private static SimpleDateFormat sCacheSimpleDateFormat;
-
     @PrimaryKey(autoGenerate = true)
     private long mId;
 
@@ -91,14 +86,8 @@
     }
 
     @Override
-    @SuppressWarnings("JavaUtilDate")
     public String toString() {
-        final String currentZoneId = TimeZone.getDefault().getID();
-        if (!currentZoneId.equals(sCacheZoneId) || sCacheSimpleDateFormat == null) {
-            sCacheZoneId = currentZoneId;
-            sCacheSimpleDateFormat = new SimpleDateFormat("MMM dd,yyyy HH:mm:ss", Locale.US);
-        }
-        final String recordAtDateTime = sCacheSimpleDateFormat.format(new Date(timestamp));
+        final String recordAtDateTime = ConvertUtils.utcToLocalTimeForLogging(timestamp);
         final BatteryInformation batteryInformationInstance =
                 BatteryUtils.parseProtoFromString(
                         batteryInformation, BatteryInformation.getDefaultInstance());
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index fac3aaf..7713e27 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -29,11 +29,12 @@
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.ApplicationInfoFlags;
 import android.content.pm.UserInfo;
 import android.content.res.Configuration;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.Process;
-import android.os.RemoteException;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.text.TextUtils;
@@ -71,7 +72,6 @@
 import com.android.settings.core.FeatureFlags;
 import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.password.PasswordUtils;
 import com.android.settings.safetycenter.SafetyCenterManagerWrapper;
 import com.android.settingslib.Utils;
 import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
@@ -96,6 +96,10 @@
     public static final String EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA =
             "settings_large_screen_deep_link_intent_data";
 
+    // The referrer who fires the initial intent to start the homepage
+    @VisibleForTesting
+    static final String EXTRA_INITIAL_REFERRER = "initial_referrer";
+
     static final int DEFAULT_HIGHLIGHT_MENU_KEY = R.string.menu_key_network;
     private static final long HOMEPAGE_LOADING_TIMEOUT_MS = 300;
 
@@ -177,12 +181,16 @@
         mIsEmbeddingActivityEnabled = ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this);
         if (mIsEmbeddingActivityEnabled) {
             final UserManager um = getSystemService(UserManager.class);
-            final UserInfo userInfo = um.getUserInfo(getUser().getIdentifier());
+            final UserInfo userInfo = um.getUserInfo(getUserId());
             if (userInfo.isManagedProfile()) {
                 final Intent intent = new Intent(getIntent())
-                        .setClass(this, DeepLinkHomepageActivityInternal.class)
                         .addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
-                        .putExtra(EXTRA_USER_HANDLE, getUser());
+                        .putExtra(EXTRA_USER_HANDLE, getUser())
+                        .putExtra(EXTRA_INITIAL_REFERRER, getCurrentReferrer());
+                if (TextUtils.equals(intent.getAction(), ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)
+                        && this instanceof DeepLinkHomepageActivity) {
+                    intent.setClass(this, DeepLinkHomepageActivityInternal.class);
+                }
                 intent.removeFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 startActivityAsUser(intent, um.getProfileParent(userInfo.id).getUserHandle());
                 finish();
@@ -471,7 +479,7 @@
             return;
         }
 
-        ActivityInfo targetActivityInfo = null;
+        ActivityInfo targetActivityInfo;
         try {
             targetActivityInfo = getPackageManager().getActivityInfo(targetComponentName,
                     /* flags= */ 0);
@@ -481,23 +489,29 @@
             return;
         }
 
-        int callingUid = -1;
-        try {
-            callingUid = ActivityManager.getService().getLaunchedFromUid(getActivityToken());
-        } catch (RemoteException re) {
-            Log.e(TAG, "Not able to get callingUid: " + re);
-            finish();
-            return;
+        UserHandle user = intent.getParcelableExtra(EXTRA_USER_HANDLE, UserHandle.class);
+        String caller = getInitialReferrer();
+        int callerUid = -1;
+        if (caller != null) {
+            try {
+                callerUid = getPackageManager().getApplicationInfoAsUser(caller,
+                        ApplicationInfoFlags.of(/* flags= */ 0),
+                        user != null ? user.getIdentifier() : getUserId()).uid;
+            } catch (PackageManager.NameNotFoundException e) {
+                Log.e(TAG, "Not able to get callerUid: " + e);
+                finish();
+                return;
+            }
         }
 
-        if (!hasPrivilegedAccess(callingUid, targetActivityInfo)) {
+        if (!hasPrivilegedAccess(caller, callerUid, targetActivityInfo.packageName)) {
             if (!targetActivityInfo.exported) {
                 Log.e(TAG, "Target Activity is not exported");
                 finish();
                 return;
             }
 
-            if (!isCallingAppPermitted(targetActivityInfo.permission)) {
+            if (!isCallingAppPermitted(targetActivityInfo.permission, callerUid)) {
                 Log.e(TAG, "Calling app must have the permission of deep link Activity");
                 finish();
                 return;
@@ -510,7 +524,7 @@
                 & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
         if (targetIntent.getData() != null
                 && uriPermissionFlags != 0
-                && checkUriPermission(targetIntent.getData(), /* pid= */ -1, callingUid,
+                && checkUriPermission(targetIntent.getData(), /* pid= */ -1, callerUid,
                         uriPermissionFlags) == PackageManager.PERMISSION_DENIED) {
             Log.e(TAG, "Calling app must have the permission to access Uri and grant permission");
             finish();
@@ -547,7 +561,6 @@
                 SplitRule.FinishBehavior.ALWAYS,
                 true /* clearTop */);
 
-        final UserHandle user = intent.getParcelableExtra(EXTRA_USER_HANDLE, UserHandle.class);
         if (user != null) {
             startActivityAsUser(targetIntent, user);
         } else {
@@ -555,31 +568,30 @@
         }
     }
 
-    // Check if calling app has privileged access to launch Activity of activityInfo.
-    private boolean hasPrivilegedAccess(int callingUid, ActivityInfo activityInfo) {
-        if (TextUtils.equals(PasswordUtils.getCallingAppPackageName(getActivityToken()),
-                    getPackageName())) {
+    // Check if the caller has privileged access to launch the target page.
+    private boolean hasPrivilegedAccess(String callerPkg, int callerUid, String targetPackage) {
+        if (TextUtils.equals(callerPkg, getPackageName())) {
             return true;
         }
 
         int targetUid = -1;
         try {
-            targetUid = getPackageManager().getApplicationInfo(activityInfo.packageName,
-                    /* flags= */ 0).uid;
-        } catch (PackageManager.NameNotFoundException nnfe) {
-            Log.e(TAG, "Not able to get targetUid: " + nnfe);
+            targetUid = getPackageManager().getApplicationInfo(targetPackage,
+                    ApplicationInfoFlags.of(/* flags= */ 0)).uid;
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.e(TAG, "Not able to get targetUid: " + e);
             return false;
         }
 
         // When activityInfo.exported is false, Activity still can be launched if applications have
         // the same user ID.
-        if (UserHandle.isSameApp(callingUid, targetUid)) {
+        if (UserHandle.isSameApp(callerUid, targetUid)) {
             return true;
         }
 
         // When activityInfo.exported is false, Activity still can be launched if calling app has
         // root or system privilege.
-        int callingAppId = UserHandle.getAppId(callingUid);
+        int callingAppId = UserHandle.getAppId(callerUid);
         if (callingAppId == Process.ROOT_UID || callingAppId == Process.SYSTEM_UID) {
             return true;
         }
@@ -588,9 +600,31 @@
     }
 
     @VisibleForTesting
-    boolean isCallingAppPermitted(String permission) {
-        return TextUtils.isEmpty(permission) || PasswordUtils.isCallingAppPermitted(
-                this, getActivityToken(), permission);
+    String getInitialReferrer() {
+        String referrer = getCurrentReferrer();
+        if (!TextUtils.equals(referrer, getPackageName())) {
+            return referrer;
+        }
+
+        String initialReferrer = getIntent().getStringExtra(EXTRA_INITIAL_REFERRER);
+        return TextUtils.isEmpty(initialReferrer) ? referrer : initialReferrer;
+    }
+
+    @VisibleForTesting
+    String getCurrentReferrer() {
+        Intent intent = getIntent();
+        // Clear extras to get the real referrer
+        intent.removeExtra(Intent.EXTRA_REFERRER);
+        intent.removeExtra(Intent.EXTRA_REFERRER_NAME);
+        Uri referrer = getReferrer();
+        return referrer != null ? referrer.getHost() : null;
+    }
+
+    @VisibleForTesting
+    boolean isCallingAppPermitted(String permission, int callerUid) {
+        return TextUtils.isEmpty(permission)
+                || checkPermission(permission, /* pid= */ -1, callerUid)
+                        == PackageManager.PERMISSION_GRANTED;
     }
 
     private String getHighlightMenuKey() {
diff --git a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
index 85b67ea..03461af 100644
--- a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
+++ b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
@@ -16,16 +16,15 @@
 
 package com.android.settings.inputmethod;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.provider.Settings;
 import android.util.FeatureFlagUtils;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
 
-import com.android.settings.Settings.PhysicalKeyboardActivity;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -34,18 +33,14 @@
 
 public class KeyboardSettingsPreferenceController extends BasePreferenceController {
 
-    private Context mContext;
     private CachedBluetoothDevice mCachedDevice;
-    private Activity mActivity;
 
     public KeyboardSettingsPreferenceController(Context context, String key) {
         super(context, key);
-        mContext = context;
     }
 
-    public void init(@NonNull CachedBluetoothDevice cachedDevice, @NonNull Activity activity) {
+    public void init(@NonNull CachedBluetoothDevice cachedDevice) {
         mCachedDevice = cachedDevice;
-        mActivity = activity;
     }
 
     @Override
@@ -53,18 +48,26 @@
         if (!getPreferenceKey().equals(preference.getKey())) {
             return false;
         }
-
-        final Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
-        intent.setClass(mContext, PhysicalKeyboardActivity.class);
-        intent.putExtra(PhysicalKeyboardFragment.EXTRA_BT_ADDRESS, mCachedDevice.getAddress());
-        mActivity.startActivityForResult(intent, 0);
+        List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboardList();
+        for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
+            if (mCachedDevice.getAddress().equals(hardKeyboardDeviceInfo.mBluetoothAddress)) {
+                Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+                intent.putExtra(
+                        NewKeyboardSettingsUtils.EXTRA_INTENT_FROM,
+                        "com.android.settings.inputmethod.KeyboardSettingsPreferenceController");
+                intent.putExtra(
+                        Settings.EXTRA_INPUT_DEVICE_IDENTIFIER,
+                        hardKeyboardDeviceInfo.mDeviceIdentifier);
+                mContext.startActivity(intent);
+                break;
+            }
+        }
         return true;
     }
 
     @Override
     public int getAvailabilityStatus() {
-        final List<HardKeyboardDeviceInfo> newHardKeyboards =
-                PhysicalKeyboardFragment.getHardKeyboards(mContext);
+        List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboardList();
         if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI)
                 && !newHardKeyboards.isEmpty()) {
             for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
@@ -78,4 +81,9 @@
         }
         return CONDITIONALLY_UNAVAILABLE;
     }
+
+    @VisibleForTesting
+    List<HardKeyboardDeviceInfo> getHardKeyboardList() {
+        return PhysicalKeyboardFragment.getHardKeyboards(mContext);
+    }
 }
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
index 0f49ee1..3344f4e 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
@@ -23,6 +23,7 @@
 import android.hardware.input.KeyboardLayout;
 import android.os.Bundle;
 import android.os.UserHandle;
+import android.util.Log;
 import android.view.InputDevice;
 import android.view.inputmethod.InputMethodInfo;
 import android.view.inputmethod.InputMethodManager;
@@ -59,10 +60,19 @@
     public void onActivityCreated(final Bundle icicle) {
         super.onActivityCreated(icicle);
         Bundle arguments = getArguments();
-        final String title =
-                arguments.getString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_DEVICE_NAME);
         mInputDeviceIdentifier =
                 arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
+        if (mInputDeviceIdentifier == null) {
+            Log.e(TAG, "The inputDeviceIdentifier should not be null");
+            return;
+        }
+        InputDevice inputDevice =
+                NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
+        if (inputDevice == null) {
+            Log.e(TAG, "inputDevice is null");
+            return;
+        }
+        final String title = inputDevice.getName();
         getActivity().setTitle(title);
         updateCheckedState();
     }
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
index 761e95e..110147a 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
@@ -47,6 +47,7 @@
                 arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
         if (identifier == null
                 || NewKeyboardSettingsUtils.getInputDevice(inputManager, identifier) == null) {
+            getActivity().finish();
             return;
         }
         getActivity().setTitle(title);
diff --git a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
index 506d1e7..fe0c9d4 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
@@ -32,7 +32,12 @@
  */
 public class NewKeyboardSettingsUtils {
 
-    static final String EXTRA_KEYBOARD_DEVICE_NAME = "extra_keyboard_device_name";
+    /**
+     * Record the class name of the intent sender for metrics.
+     */
+    public static final String EXTRA_INTENT_FROM =
+            "com.android.settings.inputmethod.EXTRA_INTENT_FROM";
+
     static final String EXTRA_TITLE = "keyboard_layout_picker_title";
     static final String EXTRA_KEYBOARD_LAYOUT = "keyboard_layout";
     static final String EXTRA_USER_ID = "user_id";
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index e9dba57..22f5b65 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -87,7 +87,6 @@
     @Override
     public void onCreatePreferences(Bundle bundle, String s) {
         Activity activity = Preconditions.checkNotNull(getActivity());
-        mBluetoothAddress = activity.getIntent().getStringExtra(EXTRA_BT_ADDRESS);
         addPreferencesFromResource(R.xml.physical_keyboard_settings);
         mIm = Preconditions.checkNotNull(activity.getSystemService(InputManager.class));
         mImm = Preconditions.checkNotNull(activity.getSystemService(InputMethodManager.class));
@@ -104,6 +103,19 @@
         if (!isModifierKeySettingsEnabled) {
             mKeyboardAssistanceCategory.removePreference(findPreference(MODIFIER_KEYS_SETTINGS));
         }
+        InputDeviceIdentifier inputDeviceIdentifier = activity.getIntent().getParcelableExtra(
+                KeyboardLayoutPickerFragment.EXTRA_INPUT_DEVICE_IDENTIFIER);
+        // TODO (b/271391879): The EXTRA_INTENT_FROM is used for the future metrics.
+        if (inputDeviceIdentifier != null) {
+            Bundle arguments = new Bundle();
+            arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
+                    inputDeviceIdentifier);
+            new SubSettingLauncher(getContext())
+                    .setSourceMetricsCategory(getMetricsCategory())
+                    .setDestination(NewKeyboardLayoutEnabledLocalesFragment.class.getName())
+                    .setArguments(arguments)
+                    .launch();
+        }
     }
 
     @Override
@@ -187,14 +199,6 @@
         preferenceScreen.addPreference(category);
 
         for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
-
-            // if user go into this page from Connected devices entry, we should distinguish the
-            // user-selected keyboard from all enabled keyboards.
-            if (mBluetoothAddress != null
-                    && !mBluetoothAddress.equals(hardKeyboardDeviceInfo.mBluetoothAddress)) {
-                continue;
-            }
-
             // TODO(yukawa): Consider using com.android.settings.widget.GearPreference
             final Preference pref = new Preference(getPrefContext());
             pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
@@ -247,7 +251,6 @@
         Bundle arguments = new Bundle();
         arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
                 inputDeviceIdentifier);
-        arguments.putString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_DEVICE_NAME, keyboardName);
         new SubSettingLauncher(getContext())
                 .setSourceMetricsCategory(getMetricsCategory())
                 .setDestination(NewKeyboardLayoutEnabledLocalesFragment.class.getName())
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
index 3dcae09..1f01b98 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
@@ -17,8 +17,10 @@
 package com.android.settings.inputmethod;
 
 import android.content.Context;
+import android.content.Intent;
 import android.hardware.input.InputManager;
 import android.icu.text.ListFormatter;
+import android.provider.Settings;
 
 import androidx.preference.Preference;
 
@@ -59,6 +61,19 @@
     }
 
     @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (!getPreferenceKey().equals(preference.getKey())) {
+            return false;
+        }
+        Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+        intent.putExtra(
+                NewKeyboardSettingsUtils.EXTRA_INTENT_FROM,
+                "com.android.settings.inputmethod.PhysicalKeyboardPreferenceController");
+        mContext.startActivity(intent);
+        return true;
+    }
+
+    @Override
     public void updateState(Preference preference) {
         mPreference = preference;
         updateEntry();
diff --git a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
index bece414..958001e 100644
--- a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
+++ b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
@@ -165,7 +165,7 @@
 
         dragCell.setLabelAndDescription(label, description);
         dragCell.setLocalized(feedItem.isTranslated());
-        dragCell.setCurrentDefault(feedItem.getLocale().equals(Locale.getDefault()));
+        dragCell.setCurrentDefault(feedItem.getLocale().equals(LocalePicker.getLocales().get(0)));
         dragCell.setMiniLabel(mNumberFormatter.format(i + 1));
         dragCell.setShowCheckbox(mRemoveMode);
         dragCell.setShowMiniLabel(!mRemoveMode);
diff --git a/src/com/android/settings/location/LocationServicesForWork.java b/src/com/android/settings/location/LocationServicesForWork.java
index 29285ad..f61918e 100644
--- a/src/com/android/settings/location/LocationServicesForWork.java
+++ b/src/com/android/settings/location/LocationServicesForWork.java
@@ -21,13 +21,13 @@
 
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.SearchIndexable;
 
 /**
  * A page that configures the Location Services settings for work profile.
+ *
+ * Note that this page should not provide indexes because it is only used in the two tabs
+ * {@link ProfileSelectFragment} scenario and should not be launched independently.
  */
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
 public class LocationServicesForWork extends DashboardFragment {
     private static final String TAG = "LocationServicesForWork";
 
@@ -51,10 +51,4 @@
         super.onAttach(context);
         use(LocationInjectedServicesForWorkPreferenceController.class).init(this);
     }
-
-    /**
-     * For Search.
-     */
-    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider(R.xml.location_services_workprofile);
 }
diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index bec65e2..f5ea968 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -39,6 +39,7 @@
 import android.telephony.UiccPortInfo;
 import android.telephony.UiccSlotInfo;
 import android.util.ArrayMap;
+import android.util.IndentingPrintWriter;
 import android.util.Log;
 
 import com.android.settings.network.telephony.MobileNetworkUtils;
@@ -736,4 +737,17 @@
         default void onCallStateChanged(int state) {
         }
     }
+
+    public void dump(IndentingPrintWriter printwriter) {
+        printwriter.println(TAG + ": ");
+        printwriter.increaseIndent();
+        printwriter.println(" availableSubInfoEntityList= " + mAvailableSubInfoEntityList);
+        printwriter.println(" activeSubInfoEntityList=" + mActiveSubInfoEntityList);
+        printwriter.println(" mobileNetworkInfoEntityList= " + mMobileNetworkInfoEntityList);
+        printwriter.println(" uiccInfoEntityList= " + mUiccInfoEntityList);
+        printwriter.println(" CacheSubscriptionInfoEntityMap= " + sCacheSubscriptionInfoEntityMap);
+        printwriter.println(" SubscriptionInfoMap= " + mSubscriptionInfoMap);
+        printwriter.flush();
+        printwriter.decreaseIndent();
+    }
 }
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 39cf136..4ea3464 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -30,6 +30,7 @@
 import androidx.lifecycle.LifecycleOwner;
 
 import com.android.settings.R;
+import com.android.settings.SettingsDumpService;
 import com.android.settings.Utils;
 import com.android.settings.core.OnActivityResultListener;
 import com.android.settings.dashboard.DashboardFragment;
@@ -122,6 +123,11 @@
         }
         controllers.add(privateDnsPreferenceController);
         controllers.add(new NetworkProviderCallsSmsController(context, lifecycle, lifecycleOwner));
+
+        // Start SettingsDumpService after the MobileNetworkRepository is created.
+        Intent intent = new Intent(context, SettingsDumpService.class);
+        intent.putExtra(SettingsDumpService.EXTRA_KEY_SHOW_NETWORK_DUMP, true);
+        context.startService(intent);
         return controllers;
     }
 
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 0f2d02bf..ce83053 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -489,7 +489,7 @@
 
             Iterator<Integer> iterator = mSubscriptionInfoMap.keySet().iterator();
             while (iterator.hasNext()) {
-                if (iterator.next() == mSubId) {
+                if (iterator.next() == mSubId && getActivity() != null) {
                     finishFragment();
                     return;
                 }
diff --git a/src/com/android/settings/notification/SilentStatusBarPreferenceController.java b/src/com/android/settings/notification/SilentStatusBarPreferenceController.java
index 4c4c99d..d8c856e 100644
--- a/src/com/android/settings/notification/SilentStatusBarPreferenceController.java
+++ b/src/com/android/settings/notification/SilentStatusBarPreferenceController.java
@@ -17,6 +17,7 @@
 package com.android.settings.notification;
 
 import android.content.Context;
+import android.os.UserManager;
 
 import com.android.settings.R;
 import com.android.settings.core.TogglePreferenceController;
@@ -51,7 +52,7 @@
 
     @Override
     public int getAvailabilityStatus() {
-        return AVAILABLE;
+        return UserManager.get(mContext).isGuestUser() ? DISABLED_FOR_USER : AVAILABLE;
     }
 
     @Override
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index edd9188..2a30b42 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -911,6 +911,10 @@
                         mIsManagedProfile));
                 setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE);
                 mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0));
+
+                // Hide the pin_confirm option when we are just asking user to confirm the pwd.
+                mAutoPinConfirmOption.setVisibility(View.GONE);
+                mAutoConfirmSecurityMessage.setVisibility(View.GONE);
             }
             final int stage = getStageType();
             if (getStageType() != Stage.TYPE_NONE) {
@@ -1017,12 +1021,14 @@
                             profileCredential);
                 }
             }
-            mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
-                    mChosenPassword, mCurrentCredential, mUserId);
-            // update the pin_auto_confirm setting accordingly.
+            // update the setting before triggering the password save workflow,
+            // so that pinLength information is stored accordingly when setting is turned on.
             mLockPatternUtils.setAutoPinConfirm(
                     (mAutoPinConfirmOption != null && mAutoPinConfirmOption.isChecked()),
                     mUserId);
+
+            mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
+                    mChosenPassword, mCurrentCredential, mUserId);
         }
 
         @Override
diff --git a/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java b/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
index ff4a8b7..a41a0b2 100644
--- a/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
+++ b/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
@@ -16,14 +16,19 @@
 
 package com.android.settings.security.screenlock;
 
+import static com.android.internal.widget.LockPatternUtils.MIN_AUTO_PIN_REQUIREMENT_LENGTH;
+
 import android.content.Context;
 
 import androidx.preference.Preference;
 import androidx.preference.TwoStatePreference;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
 import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.password.ChooseLockSettingsHelper;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
 
 /**
  * Preference controller for the pin_auto_confirm setting.
@@ -32,21 +37,23 @@
         PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
 
     private static final String PREF_KEY_PIN_AUTO_CONFIRM = "auto_pin_confirm";
-    private static final long MIN_AUTO_PIN_REQUIREMENT_LENGTH = 6L;
 
     private final int mUserId;
     private final LockPatternUtils mLockPatternUtils;
+    private final ObservablePreferenceFragment mParentFragment;
 
     public AutoPinConfirmPreferenceController(Context context, int userId,
-            LockPatternUtils lockPatternUtils) {
+            LockPatternUtils lockPatternUtils,
+            ObservablePreferenceFragment parentFragment) {
         super(context);
         mUserId = userId;
         mLockPatternUtils = lockPatternUtils;
+        mParentFragment = parentFragment;
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
-        setPinAutoConfirmSettingState((boolean) newValue);
+        launchPinConfirmActivity((boolean) newValue);
         return true;
     }
 
@@ -82,4 +89,18 @@
     private void setPinAutoConfirmSettingState(boolean state) {
         mLockPatternUtils.setAutoPinConfirm(state, mUserId);
     }
+
+    private void launchPinConfirmActivity(boolean newState) {
+        new ChooseLockSettingsHelper.Builder(mParentFragment.getActivity(), mParentFragment)
+                .setUserId(mUserId)
+                .setRequestCode(newState
+                        ? ScreenLockSettings.AUTO_PIN_SETTING_ENABLING_REQUEST_CODE
+                        : ScreenLockSettings.AUTO_PIN_SETTING_DISABLING_REQUEST_CODE)
+                .setTitle(mContext.getString(R.string.lock_screen_auto_pin_confirm_title))
+                .setDescription(newState
+                        ? mContext.getString(R.string.auto_confirm_on_pin_verify_description)
+                        : mContext.getString(R.string.auto_confirm_off_pin_verify_description))
+                .setReturnCredentials(true)
+                .show();
+    }
 }
diff --git a/src/com/android/settings/security/screenlock/ScreenLockSettings.java b/src/com/android/settings/security/screenlock/ScreenLockSettings.java
index 78edb7f..b2ee76c 100644
--- a/src/com/android/settings/security/screenlock/ScreenLockSettings.java
+++ b/src/com/android/settings/security/screenlock/ScreenLockSettings.java
@@ -16,10 +16,14 @@
 
 package com.android.settings.security.screenlock;
 
+import android.app.Activity;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
+import android.content.Intent;
 import android.os.UserHandle;
 
+import androidx.annotation.Nullable;
+
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
@@ -38,6 +42,10 @@
     private static final String TAG = "ScreenLockSettings";
 
     private static final int MY_USER_ID = UserHandle.myUserId();
+
+    static final int AUTO_PIN_SETTING_ENABLING_REQUEST_CODE = 111;
+    static final int AUTO_PIN_SETTING_DISABLING_REQUEST_CODE = 112;
+
     private LockPatternUtils mLockPatternUtils;
 
     @Override
@@ -79,7 +87,7 @@
         controllers.add(new LockAfterTimeoutPreferenceController(
                 context, MY_USER_ID, lockPatternUtils));
         controllers.add(new AutoPinConfirmPreferenceController(
-                context, MY_USER_ID, lockPatternUtils));
+                context, MY_USER_ID, lockPatternUtils, parent));
         controllers.add(new OwnerInfoPreferenceController(context, parent));
         return controllers;
     }
@@ -94,4 +102,17 @@
                             new LockPatternUtils(context));
                 }
             };
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+        if (requestCode == AUTO_PIN_SETTING_ENABLING_REQUEST_CODE) {
+            if (resultCode == Activity.RESULT_OK) {
+                mLockPatternUtils.setAutoPinConfirm(/* enabled= */ true, MY_USER_ID);
+            }
+        } else if (requestCode == AUTO_PIN_SETTING_DISABLING_REQUEST_CODE) {
+            if (resultCode == Activity.RESULT_OK) {
+                mLockPatternUtils.setAutoPinConfirm(/* enabled= */ false, MY_USER_ID);
+            }
+        }
+    }
 }
diff --git a/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt b/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt
index 450f984..a41a697 100644
--- a/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt
+++ b/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt
@@ -112,11 +112,10 @@
     @Composable
     private fun confirmDialogPresenter() = rememberAlertDialogPresenter(
         confirmButton = AlertDialogButton(
-            text = stringResource(R.string.reset_app_preferences_button),
+            text = stringResource(R.string.app_disable_dlg_positive),
             onClick = packageInfoPresenter::disable,
         ),
         dismissButton = AlertDialogButton(stringResource(R.string.cancel)),
-        title = stringResource(R.string.app_disable_dlg_positive),
         text = { Text(stringResource(R.string.app_disable_dlg_text)) },
     )
 }
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 621b222..9f1d2f3 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -811,6 +811,14 @@
     }
 
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider(R.xml.tts_settings);
+            new BaseSearchIndexProvider(R.xml.tts_settings) {
+                @Override
+                protected boolean isPageSearchEnabled(Context context) {
+                    TtsEngines ttsEngines = new TtsEngines(context);
+                    return !ttsEngines.getEngines().isEmpty() &&
+                            context.getResources().getBoolean(
+                                    R.bool.config_show_tts_settings_summary);
+                }
+            };
 
 }
diff --git a/src/com/android/settings/widget/LabeledSeekBarPreference.java b/src/com/android/settings/widget/LabeledSeekBarPreference.java
index 5d10116..6300bd3 100644
--- a/src/com/android/settings/widget/LabeledSeekBarPreference.java
+++ b/src/com/android/settings/widget/LabeledSeekBarPreference.java
@@ -63,6 +63,8 @@
     private OnPreferenceChangeListener mStopListener;
     private SeekBar.OnSeekBarChangeListener mSeekBarChangeListener;
 
+    private SeekBar mSeekBar;
+
     public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
             int defStyleRes) {
 
@@ -104,6 +106,10 @@
                 com.android.internal.R.attr.seekBarPreferenceStyle), 0);
     }
 
+    public SeekBar getSeekbar() {
+        return mSeekBar;
+    }
+
     @Override
     public void onBindViewHolder(PreferenceViewHolder holder) {
         super.onBindViewHolder(holder);
@@ -133,19 +139,19 @@
         final boolean isValidTextResIdExist = mTextStartId > 0 || mTextEndId > 0;
         labelFrame.setVisibility(isValidTextResIdExist ? View.VISIBLE : View.GONE);
 
-        final SeekBar seekBar = (SeekBar) holder.findViewById(com.android.internal.R.id.seekbar);
+        mSeekBar = (SeekBar) holder.findViewById(com.android.internal.R.id.seekbar);
         if (mTickMarkId != 0) {
             final Drawable tickMark = getContext().getDrawable(mTickMarkId);
-            seekBar.setTickMark(tickMark);
+            mSeekBar.setTickMark(tickMark);
         }
 
         final ViewGroup iconStartFrame = (ViewGroup) holder.findViewById(R.id.icon_start_frame);
         final ImageView iconStartView = (ImageView) holder.findViewById(R.id.icon_start);
-        updateIconStartIfNeeded(iconStartFrame, iconStartView, seekBar);
+        updateIconStartIfNeeded(iconStartFrame, iconStartView, mSeekBar);
 
         final ViewGroup iconEndFrame = (ViewGroup) holder.findViewById(R.id.icon_end_frame);
         final ImageView iconEndView = (ImageView) holder.findViewById(R.id.icon_end);
-        updateIconEndIfNeeded(iconEndFrame, iconEndView, seekBar);
+        updateIconEndIfNeeded(iconEndFrame, iconEndView, mSeekBar);
     }
 
     public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) {
diff --git a/src/com/android/settings/wifi/factory/WifiFeatureProvider.java b/src/com/android/settings/wifi/factory/WifiFeatureProvider.java
index 433ff0c..ea15c43 100644
--- a/src/com/android/settings/wifi/factory/WifiFeatureProvider.java
+++ b/src/com/android/settings/wifi/factory/WifiFeatureProvider.java
@@ -16,14 +16,17 @@
 
 package com.android.settings.wifi.factory;
 
+import android.annotation.Nullable;
 import android.content.Context;
 import android.net.wifi.WifiManager;
+import android.util.Log;
 
 import androidx.annotation.NonNull;
 import androidx.lifecycle.ViewModelProvider;
 import androidx.lifecycle.ViewModelStoreOwner;
 
 import com.android.settings.wifi.repository.WifiHotspotRepository;
+import com.android.settings.wifi.tether.WifiHotspotSpeedViewModel;
 import com.android.settings.wifi.tether.WifiTetherViewModel;
 
 import org.jetbrains.annotations.NotNull;
@@ -32,9 +35,11 @@
  * Wi-Fi Feature Provider
  */
 public class WifiFeatureProvider {
+    private static final String TAG = "WifiFeatureProvider";
 
     private final Context mAppContext;
     private WifiManager mWifiManager;
+    private WifiVerboseLogging mWifiVerboseLogging;
     private WifiHotspotRepository mWifiHotspotRepository;
 
     public WifiFeatureProvider(@NonNull Context appContext) {
@@ -52,11 +57,22 @@
     }
 
     /**
-     * Get WifiRepository
+     * Get WifiVerboseLogging
+     */
+    public WifiVerboseLogging getWifiVerboseLogging() {
+        if (mWifiVerboseLogging == null) {
+            mWifiVerboseLogging = new WifiVerboseLogging(mAppContext, getWifiManager());
+        }
+        return mWifiVerboseLogging;
+    }
+
+    /**
+     * Get WifiHotspotRepository
      */
     public WifiHotspotRepository getWifiHotspotRepository() {
         if (mWifiHotspotRepository == null) {
             mWifiHotspotRepository = new WifiHotspotRepository(mAppContext, getWifiManager());
+            verboseLog(TAG, "getWifiHotspotRepository():" + mWifiHotspotRepository);
         }
         return mWifiHotspotRepository;
     }
@@ -68,5 +84,26 @@
         return new ViewModelProvider(owner).get(WifiTetherViewModel.class);
     }
 
+    /**
+     * Get WifiHotspotSpeedViewModel
+     */
+    public WifiHotspotSpeedViewModel getWifiHotspotSpeedViewModel(
+            @NotNull ViewModelStoreOwner owner) {
+        WifiHotspotSpeedViewModel viewModel =
+                new ViewModelProvider(owner).get(WifiHotspotSpeedViewModel.class);
+        verboseLog(TAG, "getWifiHotspotSpeedViewModel():" + viewModel);
+        return viewModel;
+    }
+
+    /**
+     * Send a {@link Log#VERBOSE} log message.
+     *
+     * @param tag Used to identify the source of a log message.  It usually identifies
+     *            the class or activity where the log call occurs.
+     * @param msg The message you would like logged.
+     */
+    public void verboseLog(@Nullable String tag, @NonNull String msg) {
+        getWifiVerboseLogging().log(tag, msg);
+    }
 }
 
diff --git a/src/com/android/settings/wifi/factory/WifiVerboseLogging.java b/src/com/android/settings/wifi/factory/WifiVerboseLogging.java
new file mode 100644
index 0000000..2935ed4
--- /dev/null
+++ b/src/com/android/settings/wifi/factory/WifiVerboseLogging.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.factory;
+
+import android.annotation.Nullable;
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Wi-Fi Verbose Logging
+ */
+public class WifiVerboseLogging {
+    private static final String TAG = "WifiVerboseLogging";
+
+    protected final Context mAppContext;
+    protected final WifiManager mWifiManager;
+    protected final boolean mIsVerboseLoggingEnabled;
+
+    public WifiVerboseLogging(@NonNull Context appContext, @NonNull WifiManager wifiManager) {
+        mAppContext = appContext;
+        mWifiManager = wifiManager;
+        mIsVerboseLoggingEnabled = wifiManager.isVerboseLoggingEnabled();
+        Log.v(TAG, "isVerboseLoggingEnabled:" + mIsVerboseLoggingEnabled);
+    }
+
+    /**
+     * Send a {@link Log#VERBOSE} log message.
+     *
+     * @param tag Used to identify the source of a log message.  It usually identifies
+     *            the class or activity where the log call occurs.
+     * @param msg The message you would like logged.
+     */
+    public void log(@Nullable String tag, @NonNull String msg) {
+        if (mIsVerboseLoggingEnabled) {
+            Log.v(tag, msg);
+        }
+    }
+}
diff --git a/src/com/android/settings/wifi/repository/WifiHotspotRepository.java b/src/com/android/settings/wifi/repository/WifiHotspotRepository.java
index ee1ceea..ff6d883 100644
--- a/src/com/android/settings/wifi/repository/WifiHotspotRepository.java
+++ b/src/com/android/settings/wifi/repository/WifiHotspotRepository.java
@@ -32,7 +32,8 @@
 import androidx.annotation.NonNull;
 import androidx.lifecycle.LiveData;
 import androidx.lifecycle.MutableLiveData;
-import androidx.lifecycle.Transformations;
+
+import com.android.settings.overlay.FeatureFactory;
 
 import java.util.HashMap;
 import java.util.List;
@@ -45,7 +46,6 @@
  */
 public class WifiHotspotRepository {
     private static final String TAG = "WifiHotspotRepository";
-    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
     /** Wi-Fi hotspot band unknown. */
     public static final int BAND_UNKNOWN = 0;
@@ -84,8 +84,12 @@
     protected MutableLiveData<Integer> mSpeedType;
 
     protected Boolean mIsDualBand;
+    protected Boolean mIs5gBandSupported;
     protected Boolean mIs5gAvailable;
+    protected MutableLiveData<Boolean> m5gAvailable;
+    protected Boolean mIs6gBandSupported;
     protected Boolean mIs6gAvailable;
+    protected MutableLiveData<Boolean> m6gAvailable;
     protected String mCurrentCountryCode;
     protected ActiveCountryCodeChangedCallback mActiveCountryCodeChangedCallback;
 
@@ -140,6 +144,8 @@
      * Refresh data from the SoftApConfiguration.
      */
     public void refresh() {
+        update6gAvailable();
+        update5gAvailable();
         updateSpeedType();
     }
 
@@ -163,8 +169,9 @@
         if (mSpeedType == null) {
             mSpeedType = new MutableLiveData<>();
             updateSpeedType();
+            log("getSpeedType():" + mSpeedType.getValue());
         }
-        return Transformations.distinctUntilChanged(mSpeedType);
+        return mSpeedType;
     }
 
     protected void updateSpeedType() {
@@ -177,7 +184,7 @@
             return;
         }
         int keyBand = config.getBand();
-        logd("updateSpeedType(), getBand():" + keyBand);
+        log("updateSpeedType(), getBand():" + keyBand);
         if (!is5gAvailable()) {
             keyBand &= ~BAND_5GHZ;
         }
@@ -195,52 +202,172 @@
         } else {
             keyBand = 0;
         }
-        logd("updateSpeedType(), keyBand:" + keyBand);
+        log("updateSpeedType(), keyBand:" + keyBand);
         mSpeedType.setValue(sSpeedMap.get(keyBand));
     }
 
-    protected boolean isDualBand() {
+    /**
+     * Sets SpeedType
+     *
+     * @param speedType the Wi-Fi hotspot speed type.
+     */
+    public void setSpeedType(int speedType) {
+        log("setSpeedType():" + speedType);
+        if (mSpeedType == null) {
+            getSpeedType();
+        }
+        if (speedType == mSpeedType.getValue()) {
+            Log.w(TAG, "setSpeedType() is no changed! mSpeedType:" + mSpeedType.getValue());
+            return;
+        }
+        SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
+        if (config == null) {
+            mSpeedType.setValue(SPEED_UNKNOWN);
+            Log.e(TAG, "setSpeedType(), WifiManager#getSoftApConfiguration() return null!");
+            return;
+        }
+        SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(config);
+        if (speedType == SPEED_6GHZ) {
+            log("setSpeedType(), setBand(BAND_2GHZ_5GHZ_6GHZ)");
+            configBuilder.setBand(BAND_2GHZ_5GHZ_6GHZ);
+        } else if (speedType == SPEED_5GHZ) {
+            log("setSpeedType(), setBand(BAND_2GHZ_5GHZ)");
+            configBuilder.setBand(BAND_2GHZ_5GHZ);
+        } else if (mIsDualBand) {
+            log("setSpeedType(), setBands(BAND_2GHZ + BAND_2GHZ_5GHZ)");
+            int[] bands = {BAND_2GHZ, BAND_2GHZ_5GHZ};
+            configBuilder.setBands(bands);
+        } else {
+            log("setSpeedType(), setBand(BAND_2GHZ)");
+            configBuilder.setBand(BAND_2GHZ);
+        }
+        setSoftApConfiguration(configBuilder.build());
+    }
+
+    /**
+     * Return whether Wi-Fi Dual Band is supported or not.
+     * @return {@code true} if Wi-Fi Dual Band is supported
+     */
+    public boolean isDualBand() {
         if (mIsDualBand == null) {
             mIsDualBand = mWifiManager.isBridgedApConcurrencySupported();
-            logd("isDualBand():" + mIsDualBand);
+            log("isDualBand():" + mIsDualBand);
         }
         return mIsDualBand;
     }
 
-    protected boolean is5gAvailable() {
+    /**
+     * Return whether Wi-Fi 5 GHz band is supported or not.
+     * @return {@code true} if Wi-Fi 5 GHz Band is supported
+     */
+    public boolean is5GHzBandSupported() {
+        if (mIs5gBandSupported == null) {
+            mIs5gBandSupported = mWifiManager.is5GHzBandSupported();
+            log("is5GHzBandSupported():" + mIs5gBandSupported);
+        }
+        return mIs5gBandSupported;
+    }
+
+    /**
+     * Return whether Wi-Fi Hotspot 5 GHz band is available or not.
+     * @return {@code true} if Wi-Fi Hotspot 5 GHz Band is available
+     */
+    public boolean is5gAvailable() {
         if (mIs5gAvailable == null) {
-            // TODO(b/272450463): isBandAvailable(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS) will
-            //  cause crash in the old model device, use a simple check to workaround it first.
-            mIs5gAvailable = (mWifiManager.is5GHzBandSupported() && mCurrentCountryCode != null);
-            logd("is5gAvailable():" + mIs5gAvailable);
+            // If Settings is unable to get available 5GHz SAP information, Wi-Fi Framework's
+            // proposal is to assume that 5GHz is available. (See b/272450463#comment16)
+            mIs5gAvailable = is5GHzBandSupported()
+                    && isChannelAvailable(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS,
+                    true /* defaultValue */);
+            log("is5gAvailable():" + mIs5gAvailable);
         }
         return mIs5gAvailable;
     }
 
-    protected boolean is6gAvailable() {
+    /**
+     * Gets is5gAvailable LiveData
+     */
+    public LiveData<Boolean> get5gAvailable() {
+        if (m5gAvailable == null) {
+            m5gAvailable = new MutableLiveData<>();
+            m5gAvailable.setValue(is5gAvailable());
+        }
+        return m5gAvailable;
+    }
+
+    protected void update5gAvailable() {
+        if (m5gAvailable != null) {
+            m5gAvailable.setValue(is5gAvailable());
+        }
+    }
+
+    /**
+     * Return whether Wi-Fi 6 GHz band is supported or not.
+     * @return {@code true} if Wi-Fi 6 GHz Band is supported
+     */
+    public boolean is6GHzBandSupported() {
+        if (mIs6gBandSupported == null) {
+            mIs6gBandSupported = mWifiManager.is6GHzBandSupported();
+            log("is6GHzBandSupported():" + mIs6gBandSupported);
+        }
+        return mIs6gBandSupported;
+    }
+
+    /**
+     * Return whether Wi-Fi Hotspot 6 GHz band is available or not.
+     * @return {@code true} if Wi-Fi Hotspot 6 GHz Band is available
+     */
+    public boolean is6gAvailable() {
         if (mIs6gAvailable == null) {
-            mIs6gAvailable = mWifiManager.is6GHzBandSupported()
-                    && isBandAvailable(WifiScanner.WIFI_BAND_6_GHZ);
-            logd("is6gAvailable():" + mIs6gAvailable);
+            mIs6gAvailable = is6GHzBandSupported()
+                    && isChannelAvailable(WifiScanner.WIFI_BAND_6_GHZ, false /* defaultValue */);
+            log("is6gAvailable():" + mIs6gAvailable);
         }
         return mIs6gAvailable;
     }
 
     /**
-     * Return whether the Hotspot band is available or not.
-     *
-     * @param band one of the following band constants defined in {@code WifiScanner#WIFI_BAND_*}
-     *             constants.
-     *             1. {@code WifiScanner#WIFI_BAND_5_GHZ_WITH_DFS}
-     *             2. {@code WifiScanner#WIFI_BAND_6_GHZ}
+     * Gets is6gAvailable LiveData
      */
-    protected boolean isBandAvailable(int band) {
-        List<WifiAvailableChannel> channels = mWifiManager.getUsableChannels(band, OP_MODE_SAP);
-        return (channels != null && channels.size() > 0);
+    public LiveData<Boolean> get6gAvailable() {
+        if (m6gAvailable == null) {
+            m6gAvailable = new MutableLiveData<>();
+            m6gAvailable.setValue(is6gAvailable());
+        }
+        return m6gAvailable;
+    }
+
+    protected void update6gAvailable() {
+        if (m6gAvailable != null) {
+            m6gAvailable.setValue(is6gAvailable());
+        }
+    }
+
+    /**
+     * Return whether the Hotspot channel is available or not.
+     *
+     * @param band         one of the following band constants defined in
+     *                     {@code WifiScanner#WIFI_BAND_*} constants.
+     *                     1. {@code WifiScanner#WIFI_BAND_5_GHZ_WITH_DFS}
+     *                     2. {@code WifiScanner#WIFI_BAND_6_GHZ}
+     * @param defaultValue returns the default value if WifiManager#getUsableChannels is
+     *                     unavailable to get the SAP information.
+     */
+    protected boolean isChannelAvailable(int band, boolean defaultValue) {
+        try {
+            List<WifiAvailableChannel> channels = mWifiManager.getUsableChannels(band, OP_MODE_SAP);
+            log("isChannelAvailable(), band:" + band + ", channels:" + channels);
+            return (channels != null && channels.size() > 0);
+        } catch (IllegalArgumentException e) {
+            Log.e(TAG, "Querying usable SAP channels failed, band:" + band);
+        } catch (UnsupportedOperationException e) {
+            // This is expected on some hardware.
+            Log.e(TAG, "Querying usable SAP channels is unsupported, band:" + band);
+        }
+        return defaultValue;
     }
 
     protected void purgeRefreshData() {
-        mIsDualBand = null;
         mIs5gAvailable = null;
         mIs6gAvailable = null;
     }
@@ -249,7 +376,7 @@
         if (mActiveCountryCodeChangedCallback != null) {
             return;
         }
-        logd("startMonitorSoftApConfiguration()");
+        log("startMonitorSoftApConfiguration()");
         mActiveCountryCodeChangedCallback = new ActiveCountryCodeChangedCallback();
         mWifiManager.registerActiveCountryCodeChangedCallback(mAppContext.getMainExecutor(),
                 mActiveCountryCodeChangedCallback);
@@ -259,7 +386,7 @@
         if (mActiveCountryCodeChangedCallback == null) {
             return;
         }
-        logd("stopMonitorSoftApConfiguration()");
+        log("stopMonitorSoftApConfiguration()");
         mWifiManager.unregisterActiveCountryCodeChangedCallback(mActiveCountryCodeChangedCallback);
         mActiveCountryCodeChangedCallback = null;
     }
@@ -268,7 +395,7 @@
             WifiManager.ActiveCountryCodeChangedCallback {
         @Override
         public void onActiveCountryCodeChanged(String country) {
-            logd("onActiveCountryCodeChanged(), country:" + country);
+            log("onActiveCountryCodeChanged(), country:" + country);
             mCurrentCountryCode = country;
             purgeRefreshData();
             refresh();
@@ -276,16 +403,14 @@
 
         @Override
         public void onCountryCodeInactive() {
-            logd("onCountryCodeInactive()");
+            log("onCountryCodeInactive()");
             mCurrentCountryCode = null;
             purgeRefreshData();
             refresh();
         }
     }
 
-    private static void logd(String msg) {
-        if (DEBUG) {
-            Log.d(TAG, msg);
-        }
+    private void log(String msg) {
+        FeatureFactory.getFactory(mAppContext).getWifiFeatureProvider().verboseLog(TAG, msg);
     }
 }
diff --git a/src/com/android/settings/wifi/tether/WifiHotspotSpeedSettings.java b/src/com/android/settings/wifi/tether/WifiHotspotSpeedSettings.java
new file mode 100644
index 0000000..467d394
--- /dev/null
+++ b/src/com/android/settings/wifi/tether/WifiHotspotSpeedSettings.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.tether;
+
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_6GHZ;
+
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.widget.SelectorWithWidgetPreference;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Wi-Fi Hotspot Speed & compatibility Settings
+ */
+public class WifiHotspotSpeedSettings extends DashboardFragment implements
+        SelectorWithWidgetPreference.OnClickListener {
+
+    private static final String TAG = "WifiHotspotSpeedSettings";
+
+    protected static final String KEY_SPEED_2GHZ = "wifi_hotspot_speed_2g";
+    protected static final String KEY_SPEED_5GHZ = "wifi_hotspot_speed_5g";
+    protected static final String KEY_SPEED_2GHZ_5GHZ = "wifi_hotspot_speed_2g_5g";
+    protected static final String KEY_SPEED_6GHZ = "wifi_hotspot_speed_6g";
+    protected static Map<String, Integer> sSpeedKeyMap = new HashMap<>();
+
+    static {
+        sSpeedKeyMap.put(KEY_SPEED_2GHZ, SPEED_2GHZ);
+        sSpeedKeyMap.put(KEY_SPEED_5GHZ, SPEED_5GHZ);
+        sSpeedKeyMap.put(KEY_SPEED_2GHZ_5GHZ, SPEED_2GHZ_5GHZ);
+        sSpeedKeyMap.put(KEY_SPEED_6GHZ, SPEED_6GHZ);
+    }
+
+    protected WifiHotspotSpeedViewModel mWifiHotspotSpeedViewModel;
+    protected Map<Integer, SelectorWithWidgetPreference> mSpeedPreferenceMap = new HashMap<>();
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.wifi_hotspot_speed;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.WIFI_TETHER_SETTINGS;
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        loadPreferences();
+        mWifiHotspotSpeedViewModel = FeatureFactory.getFactory(getContext())
+                .getWifiFeatureProvider().getWifiHotspotSpeedViewModel(this);
+        onSpeedInfoMapDataChanged(mWifiHotspotSpeedViewModel.getSpeedInfoMapData().getValue());
+        mWifiHotspotSpeedViewModel.getSpeedInfoMapData()
+                .observe(this, this::onSpeedInfoMapDataChanged);
+    }
+
+    protected void loadPreferences() {
+        for (Map.Entry<String, Integer> entry : sSpeedKeyMap.entrySet()) {
+            SelectorWithWidgetPreference preference = findPreference(entry.getKey());
+            if (preference != null) {
+                preference.setOnClickListener(this);
+                mSpeedPreferenceMap.put(entry.getValue(), preference);
+            }
+        }
+    }
+
+    protected void onSpeedInfoMapDataChanged(
+            Map<Integer, WifiHotspotSpeedViewModel.SpeedInfo> speedInfoMap) {
+        log("onSpeedViewDataChanged(), speedInfoMap:" + speedInfoMap);
+        for (Map.Entry<Integer, SelectorWithWidgetPreference> entry :
+                mSpeedPreferenceMap.entrySet()) {
+            WifiHotspotSpeedViewModel.SpeedInfo speedInfo = speedInfoMap.get(entry.getKey());
+            if (speedInfo == null) {
+                continue;
+            }
+            SelectorWithWidgetPreference radioButton = entry.getValue();
+            if (radioButton == null) {
+                continue;
+            }
+            if (radioButton.isChecked() != speedInfo.mIsChecked) {
+                radioButton.setChecked(speedInfo.mIsChecked);
+            }
+            if (radioButton.isEnabled() != speedInfo.mIsEnabled) {
+                radioButton.setEnabled(speedInfo.mIsEnabled);
+            }
+            if (radioButton.isVisible() != speedInfo.mIsVisible) {
+                radioButton.setVisible(speedInfo.mIsVisible);
+            }
+        }
+    }
+
+    @Override
+    public void onRadioButtonClicked(SelectorWithWidgetPreference emiter) {
+        String key = emiter.getKey();
+        log("onRadioButtonClicked(), key:" + key);
+        if (sSpeedKeyMap.containsKey(key)) {
+            mWifiHotspotSpeedViewModel.setSpeedType(sSpeedKeyMap.get(key));
+        }
+    }
+
+    private void log(String msg) {
+        FeatureFactory.getFactory(getContext()).getWifiFeatureProvider().verboseLog(TAG, msg);
+    }
+}
diff --git a/src/com/android/settings/wifi/tether/WifiHotspotSpeedViewModel.java b/src/com/android/settings/wifi/tether/WifiHotspotSpeedViewModel.java
new file mode 100644
index 0000000..c30174e
--- /dev/null
+++ b/src/com/android/settings/wifi/tether/WifiHotspotSpeedViewModel.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.tether;
+
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_6GHZ;
+
+import android.app.Application;
+
+import androidx.lifecycle.AndroidViewModel;
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.Observer;
+
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.wifi.repository.WifiHotspotRepository;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Wi-Fi Hotspot Speed View Model
+ */
+public class WifiHotspotSpeedViewModel extends AndroidViewModel {
+    private static final String TAG = "WifiHotspotSpeedViewModel";
+
+    protected final WifiHotspotRepository mWifiHotspotRepository;
+    protected Map<Integer, SpeedInfo> mSpeedInfoMap = new HashMap<>();
+    protected MutableLiveData<Map<Integer, SpeedInfo>> mSpeedInfoMapData;
+    protected SpeedInfo mSpeedInfo2g = new SpeedInfo(false, true, false);
+    protected SpeedInfo mSpeedInfo5g = new SpeedInfo(false, true, false);
+    protected SpeedInfo mSpeedInfo2g5g = new SpeedInfo(false, true, true);
+    protected SpeedInfo mSpeedInfo6g = new SpeedInfo(false, true, true);
+
+    protected final Observer<Boolean> m6gAvailableObserver = a -> on6gAvailableChanged(a);
+    protected final Observer<Boolean> m5gAvailableObserver = a -> on5gAvailableChanged(a);
+    protected final Observer<Integer> mSpeedTypeObserver = st -> onSpeedTypeChanged(st);
+
+    public WifiHotspotSpeedViewModel(@NotNull Application application) {
+        super(application);
+        mWifiHotspotRepository = FeatureFactory.getFactory(application).getWifiFeatureProvider()
+                .getWifiHotspotRepository();
+        mWifiHotspotRepository.get6gAvailable().observeForever(m6gAvailableObserver);
+        mWifiHotspotRepository.get5gAvailable().observeForever(m5gAvailableObserver);
+        mWifiHotspotRepository.getSpeedType().observeForever(mSpeedTypeObserver);
+        mWifiHotspotRepository.setAutoRefresh(true);
+
+        // The visibility of the 6 GHz speed option will not change on a Pixel device.
+        mSpeedInfo6g.mIsVisible = mWifiHotspotRepository.is6GHzBandSupported();
+    }
+
+    @Override
+    protected void onCleared() {
+        mWifiHotspotRepository.get6gAvailable().removeObserver(m6gAvailableObserver);
+        mWifiHotspotRepository.get5gAvailable().removeObserver(m5gAvailableObserver);
+        mWifiHotspotRepository.getSpeedType().removeObserver(mSpeedTypeObserver);
+    }
+
+    protected void on6gAvailableChanged(Boolean available) {
+        log("on6gAvailableChanged(), available:" + available);
+        mSpeedInfo6g.mIsEnabled = available;
+        updateSpeedInfoMapData();
+    }
+
+    protected void on5gAvailableChanged(Boolean available) {
+        log("on5gAvailableChanged(), available:" + available);
+        mSpeedInfo5g.mIsEnabled = available;
+
+        boolean showDualBand = mWifiHotspotRepository.isDualBand() && available;
+        log("on5gAvailableChanged(), showDualBand:" + showDualBand);
+        mSpeedInfo2g5g.mIsVisible = showDualBand;
+        mSpeedInfo2g.mIsVisible = !showDualBand;
+        mSpeedInfo5g.mIsVisible = !showDualBand;
+        updateSpeedInfoMapData();
+    }
+
+    protected void onSpeedTypeChanged(Integer speedType) {
+        log("onSpeedTypeChanged(), speedType:" + speedType);
+        mSpeedInfo2g.mIsChecked = speedType.equals(SPEED_2GHZ);
+        mSpeedInfo5g.mIsChecked = speedType.equals(SPEED_5GHZ);
+        mSpeedInfo2g5g.mIsChecked = speedType.equals(SPEED_2GHZ_5GHZ);
+        mSpeedInfo6g.mIsChecked = speedType.equals(SPEED_6GHZ);
+        updateSpeedInfoMapData();
+    }
+
+    /**
+     * Sets SpeedType
+     */
+    public void setSpeedType(Integer speedType) {
+        mWifiHotspotRepository.setSpeedType(speedType);
+    }
+
+    /**
+     * Gets Speed Information LiveData
+     */
+    public LiveData<Map<Integer, SpeedInfo>> getSpeedInfoMapData() {
+        if (mSpeedInfoMapData == null) {
+            mSpeedInfoMapData = new MutableLiveData<>();
+            mSpeedInfoMapData.setValue(mSpeedInfoMap);
+            log("getSpeedViewData(), mSpeedInfoMap:" + mSpeedInfoMapData.getValue());
+        }
+        return mSpeedInfoMapData;
+    }
+
+    protected void updateSpeedInfoMapData() {
+        mSpeedInfoMap.put(SPEED_2GHZ, mSpeedInfo2g);
+        mSpeedInfoMap.put(SPEED_5GHZ, mSpeedInfo5g);
+        mSpeedInfoMap.put(SPEED_2GHZ_5GHZ, mSpeedInfo2g5g);
+        mSpeedInfoMap.put(SPEED_6GHZ, mSpeedInfo6g);
+        if (mSpeedInfoMapData != null) {
+            mSpeedInfoMapData.setValue(mSpeedInfoMap);
+        }
+    }
+
+    /**
+     * Wi-Fi Hotspot Speed Information
+     */
+    public static final class SpeedInfo {
+        Boolean mIsChecked;
+        boolean mIsEnabled;
+        boolean mIsVisible;
+
+        public SpeedInfo(boolean isChecked, boolean isEnabled, boolean isVisible) {
+            this.mIsChecked = isChecked;
+            this.mIsEnabled = isEnabled;
+            this.mIsVisible = isVisible;
+        }
+
+        @Override
+        public String toString() {
+            return new StringBuilder("SpeedInfo{")
+                    .append("isChecked:").append(mIsChecked)
+                    .append(",isEnabled:").append(mIsEnabled)
+                    .append(",isVisible:").append(mIsVisible)
+                    .append('}').toString();
+        }
+    }
+
+    private void log(String msg) {
+        FeatureFactory.getFactory(getApplication()).getWifiFeatureProvider().verboseLog(TAG, msg);
+    }
+}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherViewModel.java b/src/com/android/settings/wifi/tether/WifiTetherViewModel.java
index 4abca02..8cb74c3 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherViewModel.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherViewModel.java
@@ -46,13 +46,12 @@
     private static final String TAG = "WifiTetherViewModel";
 
     protected static Map<Integer, Integer> sSpeedSummaryResMap = new HashMap<>();
-
     static {
         sSpeedSummaryResMap.put(SPEED_UNKNOWN, R.string.summary_placeholder);
-        sSpeedSummaryResMap.put(SPEED_2GHZ, R.string.wifi_hotspot_speed_2g_summary);
-        sSpeedSummaryResMap.put(SPEED_5GHZ, R.string.wifi_hotspot_speed_5g_summary);
-        sSpeedSummaryResMap.put(SPEED_6GHZ, R.string.wifi_hotspot_speed_6g_summary);
-        sSpeedSummaryResMap.put(SPEED_2GHZ_5GHZ, R.string.wifi_hotspot_speed_2g_and_5g_summary);
+        sSpeedSummaryResMap.put(SPEED_2GHZ, R.string.wifi_hotspot_speed_summary_2g);
+        sSpeedSummaryResMap.put(SPEED_5GHZ, R.string.wifi_hotspot_speed_summary_5g);
+        sSpeedSummaryResMap.put(SPEED_6GHZ, R.string.wifi_hotspot_speed_summary_6g);
+        sSpeedSummaryResMap.put(SPEED_2GHZ_5GHZ, R.string.wifi_hotspot_speed_summary_2g_and_5g);
     }
 
     protected final WifiHotspotRepository mWifiHotspotRepository;
diff --git a/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java
index 52ccb37..6b0f5c0 100644
--- a/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/PreviewSizeSeekBarControllerTest.java
@@ -16,29 +16,45 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.internal.accessibility.AccessibilityShortcutController.FONT_SIZE_COMPONENT_NAME;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyString;
+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.ComponentName;
 import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.widget.PopupWindow;
 import android.widget.SeekBar;
 
+import androidx.preference.PreferenceManager;
 import androidx.preference.PreferenceScreen;
+import androidx.preference.PreferenceViewHolder;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.testutils.shadow.ShadowFragment;
 import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
 import com.android.settings.widget.LabeledSeekBarPreference;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowApplication;
 
 /**
  * Tests for {@link PreviewSizeSeekBarController}.
@@ -47,30 +63,67 @@
 @Config(shadows = {ShadowInteractionJankMonitor.class})
 public class PreviewSizeSeekBarControllerTest {
     private static final String FONT_SIZE_KEY = "font_size";
+    private static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
+    @Spy
     private final Context mContext = ApplicationProvider.getApplicationContext();
     private PreviewSizeSeekBarController mSeekBarController;
     private FontSizeData mFontSizeData;
     private LabeledSeekBarPreference mSeekBarPreference;
 
-    @Mock
     private PreferenceScreen mPreferenceScreen;
+    private TestFragment mFragment;
+    private PreferenceViewHolder mHolder;
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private PreferenceManager mPreferenceManager;
 
     @Mock
     private PreviewSizeSeekBarController.ProgressInteractionListener mInteractionListener;
 
+    private static PopupWindow getLatestPopupWindow() {
+        final ShadowApplication shadowApplication =
+                Shadow.extract(ApplicationProvider.getApplicationContext());
+        return shadowApplication.getLatestPopupWindow();
+    }
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mFontSizeData = new FontSizeData(mContext);
-
-        mSeekBarController =
-                new PreviewSizeSeekBarController(mContext, FONT_SIZE_KEY, mFontSizeData);
-
+        mContext.setTheme(R.style.Theme_AppCompat);
+        mFragment = spy(new TestFragment());
+        when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
+        when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
+        when(mFragment.getContext()).thenReturn(mContext);
+        mPreferenceScreen = spy(new PreferenceScreen(mContext, /* attrs= */ null));
+        when(mPreferenceScreen.getPreferenceManager()).thenReturn(mPreferenceManager);
+        doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
         mSeekBarPreference = spy(new LabeledSeekBarPreference(mContext, /* attrs= */ null));
+        mSeekBarPreference.setKey(FONT_SIZE_KEY);
+
+        LayoutInflater inflater = LayoutInflater.from(mContext);
+        mHolder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(
+                R.layout.preference_labeled_slider, null));
+        mSeekBarPreference.onBindViewHolder(mHolder);
+
         when(mPreferenceScreen.findPreference(anyString())).thenReturn(mSeekBarPreference);
 
+        mFontSizeData = new FontSizeData(mContext);
+        mSeekBarController =
+                new PreviewSizeSeekBarController(mContext, FONT_SIZE_KEY, mFontSizeData) {
+                    @Override
+                    ComponentName getTileComponentName() {
+                        return FONT_SIZE_COMPONENT_NAME;
+                    }
+
+                    @Override
+                    CharSequence getTileTooltipContent() {
+                        return mContext.getText(
+                                R.string.accessibility_font_scaling_auto_added_qs_tooltip_content);
+                    }
+                };
         mSeekBarController.setInteractionListener(mInteractionListener);
+        when(mPreferenceScreen.findPreference(mSeekBarController.getPreferenceKey())).thenReturn(
+                mSeekBarPreference);
     }
 
     @Test
@@ -123,4 +176,64 @@
 
         verify(mInteractionListener).notifyPreferenceChanged();
     }
+
+    @Test
+    public void onProgressChanged_showTooltipView() {
+        mSeekBarController.displayPreference(mPreferenceScreen);
+
+        // Simulate changing the progress for the first time
+        int newProgress = (mSeekBarPreference.getProgress() != 0) ? 0 : mSeekBarPreference.getMax();
+        mSeekBarPreference.setProgress(newProgress);
+        mSeekBarPreference.onProgressChanged(new SeekBar(mContext),
+                newProgress,
+                /* fromUser= */ false);
+
+        assertThat(getLatestPopupWindow().isShowing()).isTrue();
+    }
+
+    @Test
+    public void onProgressChanged_tooltipViewHasBeenShown_notShowTooltipView() {
+        mSeekBarController.displayPreference(mPreferenceScreen);
+        // Simulate changing the progress for the first time
+        int newProgress = (mSeekBarPreference.getProgress() != 0) ? 0 : mSeekBarPreference.getMax();
+        mSeekBarPreference.setProgress(newProgress);
+        mSeekBarPreference.onProgressChanged(new SeekBar(mContext),
+                newProgress,
+                /* fromUser= */ false);
+        getLatestPopupWindow().dismiss();
+
+        // Simulate progress changing for the second time
+        newProgress = (mSeekBarPreference.getProgress() != 0) ? 0 : mSeekBarPreference.getMax();
+        mSeekBarPreference.setProgress(newProgress);
+        mSeekBarPreference.onProgressChanged(new SeekBar(mContext),
+                newProgress,
+                /* fromUser= */ false);
+
+        assertThat(getLatestPopupWindow().isShowing()).isFalse();
+    }
+
+    @Test
+    @Config(shadows = ShadowFragment.class)
+    public void restoreValueFromSavedInstanceState_showTooltipView() {
+        final Bundle savedInstanceState = new Bundle();
+        savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
+        mSeekBarController.onCreate(savedInstanceState);
+
+        mSeekBarController.displayPreference(mPreferenceScreen);
+
+        assertThat(getLatestPopupWindow().isShowing()).isTrue();
+    }
+
+    private static class TestFragment extends SettingsPreferenceFragment {
+
+        @Override
+        protected boolean shouldSkipForInitialSUW() {
+            return false;
+        }
+
+        @Override
+        public int getMetricsCategory() {
+            return 0;
+        }
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/HearingDeviceCallRoutingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/HearingDeviceCallRoutingPreferenceControllerTest.java
new file mode 100644
index 0000000..dec4cc4
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/bluetooth/HearingDeviceCallRoutingPreferenceControllerTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2023 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.bluetooth;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.telephony.TelephonyManager;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link HearingDeviceCallRoutingPreferenceController}. */
+@RunWith(RobolectricTestRunner.class)
+public class HearingDeviceCallRoutingPreferenceControllerTest {
+
+    @Rule
+    public MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+    @Spy
+    private final Context mContext = ApplicationProvider.getApplicationContext();
+    private static final String FAKE_KEY = "fake_key";
+
+    @Mock
+    private TelephonyManager mTelephonyManager;
+    private HearingDeviceCallRoutingPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
+        mController = new HearingDeviceCallRoutingPreferenceController(mContext, FAKE_KEY);
+    }
+
+    @Test
+    public void getAvailabilityStatus_hasTelephonyCalling_available() {
+        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_noTelephonyCalling_unsupported() {
+        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
+
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
index 56a8373..fc3e6c0 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
@@ -286,8 +286,8 @@
 
     @Test
     public void handwritingPreference_checkedWhenFlagTrue() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
 
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -297,8 +297,8 @@
 
     @Test
     public void handwritingPreference_uncheckedWhenFlagFalse() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
 
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -308,22 +308,22 @@
 
     @Test
     public void handwritingPreference_updatesFlagOnClick() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
         handwritingPref.performClick();
 
         assertThat(handwritingPref.isChecked()).isEqualTo(true);
-        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
     }
 
     @Test
     public void handwritingPreference_startsHandwritingSettingsOnClickIfChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
@@ -335,8 +335,8 @@
 
     @Test
     public void handwritingPreference_doesNotStartHandwritingSettingsOnClickIfNotChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
@@ -350,8 +350,8 @@
     public void handwritingPreference_doesNotStartHandwritingSettingsIfNoIntent() {
         when(mInputMethodInfo.createStylusHandwritingSettingsActivityIntent())
                 .thenReturn(null);
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
diff --git a/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
index 12b5fe9..51b83b3 100644
--- a/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
@@ -63,8 +63,8 @@
     public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
         mController.onPreferenceChange(mPreference, true /* new value */);
 
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+        final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
 
         assertThat(mode).isEqualTo(SETTING_VALUE_ON);
     }
@@ -73,16 +73,16 @@
     public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
         mController.onPreferenceChange(mPreference, false /* new value */);
 
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+        final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
 
         assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
     }
 
     @Test
     public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
         mController.updateState(mPreference);
 
         verify(mPreference).setChecked(false);
@@ -90,22 +90,11 @@
 
     @Test
     public void updateState_settingEnabled_preferenceShouldBeChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
         mController.updateState(mPreference);
 
         verify(mPreference).setChecked(true);
     }
 
-    @Test
-    public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
-        mController.onDeveloperOptionsSwitchDisabled();
-
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
-
-        assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
-        verify(mPreference).setChecked(false);
-        verify(mPreference).setEnabled(false);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiverTest.java
index 6048197..cb8a886 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiverTest.java
@@ -57,6 +57,7 @@
         mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
         mBatteryUsageBroadcastReceiver = new BatteryUsageBroadcastReceiver();
         doReturn(mPackageManager).when(mContext).getPackageManager();
+        DatabaseUtils.getSharedPreferences(mContext).edit().clear().apply();
     }
 
     @Test
@@ -77,6 +78,7 @@
                 new Intent(Intent.ACTION_BATTERY_LEVEL_CHANGED));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isFalse();
+        assertSharedPreferences(Intent.ACTION_BATTERY_LEVEL_CHANGED);
     }
 
     @Test
@@ -94,6 +96,7 @@
                 new Intent(Intent.ACTION_BATTERY_LEVEL_CHANGED));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isFalse();
+        assertSharedPreferences(Intent.ACTION_BATTERY_LEVEL_CHANGED);
     }
 
     @Test
@@ -110,6 +113,7 @@
                 new Intent(Intent.ACTION_BATTERY_LEVEL_CHANGED));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isFalse();
+        assertSharedPreferences(Intent.ACTION_BATTERY_LEVEL_CHANGED);
     }
 
     @Test
@@ -126,6 +130,7 @@
                 new Intent(Intent.ACTION_BATTERY_LEVEL_CHANGED));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isTrue();
+        assertSharedPreferences(Intent.ACTION_BATTERY_LEVEL_CHANGED);
     }
 
     @Test
@@ -139,6 +144,7 @@
                 new Intent(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isFalse();
+        assertSharedPreferences(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING);
     }
 
     @Test
@@ -156,6 +162,7 @@
                 new Intent(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isFalse();
+        assertSharedPreferences(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING);
     }
 
     @Test
@@ -172,6 +179,7 @@
                 new Intent(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isFalse();
+        assertSharedPreferences(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING);
     }
 
     @Test
@@ -188,6 +196,7 @@
                 new Intent(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING));
 
         assertThat(mBatteryUsageBroadcastReceiver.mFetchBatteryUsageData).isTrue();
+        assertSharedPreferences(BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING);
     }
 
     @Test
@@ -202,6 +211,8 @@
                 new Intent(BatteryUsageBroadcastReceiver.ACTION_CLEAR_BATTERY_CACHE_DATA));
 
         assertThat(BatteryDiffEntry.sValidForRestriction).isEmpty();
+        assertSharedPreferences(
+                BatteryUsageBroadcastReceiver.ACTION_CLEAR_BATTERY_CACHE_DATA);
     }
 
     @Test
@@ -216,6 +227,8 @@
                 new Intent(BatteryUsageBroadcastReceiver.ACTION_CLEAR_BATTERY_CACHE_DATA));
 
         assertThat(BatteryDiffEntry.sValidForRestriction).isNotEmpty();
+        assertSharedPreferences(
+                BatteryUsageBroadcastReceiver.ACTION_CLEAR_BATTERY_CACHE_DATA);
     }
 
     private static Intent getBatteryIntent(int level, int status) {
@@ -225,4 +238,9 @@
         intent.putExtra(BatteryManager.EXTRA_STATUS, status);
         return intent;
     }
+
+    private void assertSharedPreferences(String preferenceKey) {
+        assertThat(DatabaseUtils.getSharedPreferences(mContext).contains(preferenceKey))
+                .isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiverTest.java
index ba51e29..aa1ebd7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BootBroadcastReceiverTest.java
@@ -81,18 +81,6 @@
     }
 
     @Test
-    public void onReceive_withMyPackageReplacedIntent_refreshesJob() {
-        mReceiver.onReceive(mContext, new Intent(Intent.ACTION_MY_PACKAGE_REPLACED));
-        assertThat(mShadowAlarmManager.peekNextScheduledAlarm()).isNotNull();
-    }
-
-    @Test
-    public void onReceive_withMyPackageUnsuspendIntent_refreshesJob() {
-        mReceiver.onReceive(mContext, new Intent(Intent.ACTION_MY_PACKAGE_UNSUSPENDED));
-        assertThat(mShadowAlarmManager.peekNextScheduledAlarm()).isNotNull();
-    }
-
-    @Test
     public void onReceive_withBootCompletedIntent_refreshesJob() {
         mReceiver.onReceive(mContext, new Intent(Intent.ACTION_BOOT_COMPLETED));
         assertThat(mShadowAlarmManager.peekNextScheduledAlarm()).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
index 154497e..0cb3d1d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
@@ -46,6 +46,8 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -73,6 +75,7 @@
         doReturn(mMockContentResolver).when(mContext).getContentResolver();
         doReturn(mPackageManager).when(mMockContext).getPackageManager();
         doReturn(mPackageManager).when(mContext).getPackageManager();
+        DatabaseUtils.getSharedPreferences(mContext).edit().clear().apply();
     }
 
     @Test
@@ -396,6 +399,38 @@
         assertThat(batteryHistMap).isEmpty();
     }
 
+    @Test
+    public void recordDateTime_writeDataIntoSharedPreferences() {
+        final String preferenceKey = "test_preference_key";
+        DatabaseUtils.recordDateTime(mContext, preferenceKey);
+
+        assertThat(DatabaseUtils.getSharedPreferences(mContext).contains(preferenceKey))
+                .isTrue();
+    }
+
+    @Test
+    public void dump_dumpExpectedData() {
+        DatabaseUtils.recordDateTime(mContext,
+                Intent.ACTION_BATTERY_LEVEL_CHANGED);
+        DatabaseUtils.recordDateTime(mContext,
+                BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING);
+        DatabaseUtils.recordDateTime(mContext,
+                DatabaseUtils.KEY_LAST_LOAD_FULL_CHARGE_TIME);
+        DatabaseUtils.recordDateTime(mContext,
+                DatabaseUtils.KEY_LAST_UPLOAD_FULL_CHARGE_TIME);
+        final StringWriter stringWriter = new StringWriter();
+        final PrintWriter printWriter = new PrintWriter(stringWriter);
+
+        DatabaseUtils.dump(mContext, printWriter);
+
+        String dumpContent = stringWriter.toString();
+        assertThat(dumpContent.contains("BatteryLevelChanged")).isTrue();
+        assertThat(dumpContent.contains("BatteryUnplugging")).isTrue();
+        assertThat(dumpContent.contains("ClearBatteryCacheData")).isTrue();
+        assertThat(dumpContent.contains("LastLoadFullChargeTime")).isTrue();
+        assertThat(dumpContent.contains("LastUploadFullChargeTime")).isTrue();
+    }
+
     private static void verifyBatteryEntryContentValues(
             double consumedPower, ContentValues values) {
         final BatteryInformation batteryInformation =
diff --git a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
index 60f153c..f1d6796 100644
--- a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
@@ -20,8 +20,13 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
@@ -30,6 +35,8 @@
 
 import android.app.ActivityManager;
 import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
 import android.os.Build;
 import android.view.View;
 import android.view.Window;
@@ -215,29 +222,89 @@
     }
 
     @Test
-    @Config(shadows = {ShadowPasswordUtils.class})
+    public void getInitialReferrer_differentPackage_returnCurrentReferrer() {
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
+        String referrer = "com.abc";
+        doReturn(referrer).when(activity).getCurrentReferrer();
+
+        assertEquals(activity.getInitialReferrer(), referrer);
+    }
+
+    @Test
+    public void getInitialReferrer_noReferrerExtra_returnCurrentReferrer() {
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
+        String referrer = activity.getPackageName();
+        doReturn(referrer).when(activity).getCurrentReferrer();
+
+        assertEquals(activity.getInitialReferrer(), referrer);
+    }
+
+    @Test
+    public void getInitialReferrer_hasReferrerExtra_returnGivenReferrer() {
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
+        doReturn(activity.getPackageName()).when(activity).getCurrentReferrer();
+        String referrer = "com.abc";
+        activity.setIntent(new Intent().putExtra(SettingsHomepageActivity.EXTRA_INITIAL_REFERRER,
+                referrer));
+
+        assertEquals(activity.getInitialReferrer(), referrer);
+    }
+
+    @Test
+    public void getCurrentReferrer_hasReferrerExtra_shouldNotEqual() {
+        String referrer = "com.abc";
+        Uri uri = new Uri.Builder().scheme("android-app").authority(referrer).build();
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
+        activity.setIntent(new Intent().putExtra(Intent.EXTRA_REFERRER, uri));
+
+        assertNotEquals(activity.getCurrentReferrer(), referrer);
+    }
+
+    @Test
+    public void getCurrentReferrer_hasReferrerNameExtra_shouldNotEqual() {
+        String referrer = "com.abc";
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
+        activity.setIntent(new Intent().putExtra(Intent.EXTRA_REFERRER_NAME, referrer));
+
+        assertNotEquals(activity.getCurrentReferrer(), referrer);
+    }
+
+    @Test
     public void isCallingAppPermitted_emptyPermission_returnTrue() {
-        SettingsHomepageActivity homepageActivity = spy(new SettingsHomepageActivity());
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
+        doReturn(PackageManager.PERMISSION_DENIED).when(activity)
+                .checkPermission(anyString(), anyInt(), anyInt());
 
-        assertTrue(homepageActivity.isCallingAppPermitted(""));
+        assertTrue(activity.isCallingAppPermitted("", 1000));
     }
 
     @Test
-    @Config(shadows = {ShadowPasswordUtils.class})
-    public void isCallingAppPermitted_noGrantedPermission_returnFalse() {
-        SettingsHomepageActivity homepageActivity = spy(new SettingsHomepageActivity());
+    public void isCallingAppPermitted_notGrantedPermission_returnFalse() {
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
+        doReturn(PackageManager.PERMISSION_DENIED).when(activity)
+                .checkPermission(anyString(), anyInt(), anyInt());
 
-        assertFalse(homepageActivity.isCallingAppPermitted("android.permission.TEST"));
+        assertFalse(activity.isCallingAppPermitted("android.permission.TEST", 1000));
     }
 
     @Test
-    @Config(shadows = {ShadowPasswordUtils.class})
     public void isCallingAppPermitted_grantedPermission_returnTrue() {
-        SettingsHomepageActivity homepageActivity = spy(new SettingsHomepageActivity());
+        SettingsHomepageActivity activity =
+                spy(Robolectric.buildActivity(SettingsHomepageActivity.class).get());
         String permission = "android.permission.TEST";
-        ShadowPasswordUtils.addGrantedPermission(permission);
+        doReturn(PackageManager.PERMISSION_DENIED).when(activity)
+                .checkPermission(anyString(), anyInt(), anyInt());
+        doReturn(PackageManager.PERMISSION_GRANTED).when(activity)
+                .checkPermission(eq(permission), anyInt(), eq(1000));
 
-        assertTrue(homepageActivity.isCallingAppPermitted(permission));
+        assertTrue(activity.isCallingAppPermitted(permission, 1000));
     }
 
     @Implements(SuggestionFeatureProviderImpl.class)
diff --git a/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
index d1c21a4..1bf61a4 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
@@ -18,18 +18,21 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+import android.hardware.input.InputDeviceIdentifier;
 import android.provider.Settings;
 
 import androidx.preference.Preference;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 
 import org.junit.Before;
@@ -37,12 +40,14 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 import org.robolectric.RobolectricTestRunner;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /** Tests for {@link KeyboardSettingsPreferenceController} */
 @RunWith(RobolectricTestRunner.class)
 public class KeyboardSettingsPreferenceControllerTest {
@@ -53,31 +58,42 @@
     private static final String PREFERENCE_KEY = "keyboard_settings";
 
     @Mock
-    private Activity mActivity;
-    @Mock
     private CachedBluetoothDevice mCachedBluetoothDevice;
-    @Captor
-    private ArgumentCaptor<Intent> mIntentArgumentCaptor;
+    @Mock
+    private InputDeviceIdentifier mInputDeviceIdentifier;
+
     private Context mContext;
     private KeyboardSettingsPreferenceController mController;
 
     @Before
     public void setUp() {
         mContext = spy(ApplicationProvider.getApplicationContext());
-        mController = new KeyboardSettingsPreferenceController(mContext, PREFERENCE_KEY);
-        mController.init(mCachedBluetoothDevice, mActivity);
+        doNothing().when(mContext).startActivity(any());
+        mController = spy(new KeyboardSettingsPreferenceController(mContext, PREFERENCE_KEY));
+        mController.init(mCachedBluetoothDevice);
     }
 
     @Test
     public void handlePreferenceTreeClick_expected() {
         Preference mKeyboardPreference = new Preference(mContext);
         mKeyboardPreference.setKey(PREFERENCE_KEY);
+        final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+        String address = "BT_ADDRESS";
+        HardKeyboardDeviceInfo deviceInfo =
+                new HardKeyboardDeviceInfo(
+                        "TEST_DEVICE",
+                        mInputDeviceIdentifier,
+                        "TEST_DEVICE_LABEL",
+                        address);
+        List<HardKeyboardDeviceInfo> keyboards = new ArrayList<>();
+        keyboards.add(deviceInfo);
+        when(mController.getHardKeyboardList()).thenReturn(keyboards);
+        when(mCachedBluetoothDevice.getAddress()).thenReturn(address);
 
         mController.handlePreferenceTreeClick(mKeyboardPreference);
 
-        verify(mActivity).startActivityForResult(mIntentArgumentCaptor.capture(), eq(0));
-        Intent expectedIntent = mIntentArgumentCaptor.getValue();
-        assertThat(expectedIntent.getAction()).isEqualTo(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+        verify(mContext).startActivity(captor.capture());
+        assertThat(captor.getValue().getAction()).isEqualTo(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java
index a913b9e..9d1dbfb 100644
--- a/tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SilentStatusBarPreferenceControllerTest.java
@@ -16,14 +16,21 @@
 
 package com.android.settings.notification;
 
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
 
 import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
@@ -35,6 +42,7 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowUserManager;
 
 @RunWith(RobolectricTestRunner.class)
 public class SilentStatusBarPreferenceControllerTest {
@@ -60,6 +68,27 @@
     }
 
     @Test
+    public void isAvailable_systemUser_available() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+
+    @Test
+    public void isAvailable_extraUser_available() {
+        ShadowUserManager um = shadowOf(mContext.getSystemService(UserManager.class));
+        um.addUser(UserHandle.myUserId(), "Another User", UserInfo.FLAG_FULL);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+
+    @Test
+    public void isAvailable_guestUser_disabled() {
+        ShadowUserManager um = shadowOf(mContext.getSystemService(UserManager.class));
+        um.addUser(UserHandle.myUserId(), "Guest", UserInfo.FLAG_GUEST);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
+    }
+
+    @Test
     public void isChecked_settingIsOff() {
         when(mBackend.shouldHideSilentStatusBarIcons(any())).thenReturn(false);
         assertThat(mController.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
index 55e1f1a..715913c 100644
--- a/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
@@ -22,7 +22,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -33,6 +32,7 @@
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -48,6 +48,8 @@
     private static final Integer TEST_USER_ID = 1;
     @Mock
     private LockPatternUtils mLockPatternUtils;
+    @Mock
+    private ObservablePreferenceFragment mParentFragment;
     private AutoPinConfirmPreferenceController mController;
     private SwitchPreference mPreference;
 
@@ -56,7 +58,8 @@
         MockitoAnnotations.initMocks(this);
         Context context = ApplicationProvider.getApplicationContext();
         mController =
-                new AutoPinConfirmPreferenceController(context, TEST_USER_ID, mLockPatternUtils);
+                new AutoPinConfirmPreferenceController(context, TEST_USER_ID, mLockPatternUtils,
+                        mParentFragment);
         mPreference = new SwitchPreference(context);
     }
 
@@ -86,7 +89,7 @@
                 "true", /* makeDefault */ false);
         when(mLockPatternUtils.getCredentialTypeForUser(TEST_USER_ID))
                 .thenReturn(LockPatternUtils.CREDENTIAL_TYPE_PIN);
-        when(mLockPatternUtils.getPinLength(TEST_USER_ID)).thenReturn(5L);
+        when(mLockPatternUtils.getPinLength(TEST_USER_ID)).thenReturn(5);
 
         assertThat(mController.isAvailable()).isFalse();
     }
@@ -98,7 +101,7 @@
         when(mLockPatternUtils.isSecure(TEST_USER_ID)).thenReturn(true);
         when(mLockPatternUtils.getCredentialTypeForUser(TEST_USER_ID))
                 .thenReturn(LockPatternUtils.CREDENTIAL_TYPE_PIN);
-        when(mLockPatternUtils.getPinLength(TEST_USER_ID)).thenReturn(6L);
+        when(mLockPatternUtils.getPinLength(TEST_USER_ID)).thenReturn(6);
 
         assertThat(mController.isAvailable()).isTrue();
     }
@@ -128,12 +131,4 @@
         mController.updateState(mPreference);
         assertThat(mPreference.isChecked()).isTrue();
     }
-
-    @Test
-    public void onPreferenceChange_shouldUpdatePinAutoConfirmSetting() {
-        DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
-                "true", /* makeDefault */ false);
-        mController.onPreferenceChange(mPreference, /* newValue= */ true);
-        verify(mLockPatternUtils).setAutoPinConfirm(true, TEST_USER_ID);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiHotspotSpeedSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiHotspotSpeedSettingsTest.java
new file mode 100644
index 0000000..ec8cfe8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiHotspotSpeedSettingsTest.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.tether;
+
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_6GHZ;
+import static com.android.settings.wifi.tether.WifiHotspotSpeedSettings.KEY_SPEED_2GHZ;
+import static com.android.settings.wifi.tether.WifiHotspotSpeedSettings.KEY_SPEED_2GHZ_5GHZ;
+import static com.android.settings.wifi.tether.WifiHotspotSpeedSettings.KEY_SPEED_5GHZ;
+import static com.android.settings.wifi.tether.WifiHotspotSpeedSettings.KEY_SPEED_6GHZ;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+
+import androidx.lifecycle.ViewModelStoreOwner;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.wifi.factory.WifiFeatureProvider;
+import com.android.settingslib.widget.SelectorWithWidgetPreference;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiHotspotSpeedSettingsTest {
+    @Rule
+    public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+    @Spy
+    Context mContext = ApplicationProvider.getApplicationContext();
+    @Mock
+    ViewModelStoreOwner mViewModelStoreOwner;
+    @Mock
+    WifiHotspotSpeedViewModel mViewModel;
+    @Mock
+    SelectorWithWidgetPreference mRadioButton;
+
+    Map<Integer, WifiHotspotSpeedViewModel.SpeedInfo> mSpeedInfoMap = new HashMap<>();
+    WifiHotspotSpeedViewModel.SpeedInfo mSpeedInfo2g =
+            new WifiHotspotSpeedViewModel.SpeedInfo(false, true, false);
+    WifiHotspotSpeedViewModel.SpeedInfo mSpeedInfo5g =
+            new WifiHotspotSpeedViewModel.SpeedInfo(false, true, false);
+    WifiHotspotSpeedViewModel.SpeedInfo mSpeedInfo2g5g =
+            new WifiHotspotSpeedViewModel.SpeedInfo(false, true, true);
+    WifiHotspotSpeedViewModel.SpeedInfo mSpeedInfo6g =
+            new WifiHotspotSpeedViewModel.SpeedInfo(false, true, true);
+
+    WifiHotspotSpeedSettings mSettings;
+
+    @Before
+    public void setUp() {
+        WifiFeatureProvider provider = FakeFeatureFactory.setupForTest().getWifiFeatureProvider();
+        when(provider.getWifiHotspotSpeedViewModel(mViewModelStoreOwner)).thenReturn(mViewModel);
+
+        mSettings = new WifiHotspotSpeedSettings();
+        mSettings.mWifiHotspotSpeedViewModel = mViewModel;
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_checkedSpeed2g_checkedToRadioButton2g() {
+        mSpeedInfo2g = new WifiHotspotSpeedViewModel.SpeedInfo(false, true, false);
+        updateSpeedInfoMap();
+        mockRadioButton(true, false, true);
+        mSettings.mSpeedPreferenceMap.put(SPEED_2GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(false, true, false);
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_uncheckedSpeed2g_uncheckedToRadioButton2g() {
+        mSpeedInfo2g = new WifiHotspotSpeedViewModel.SpeedInfo(true, false, true);
+        updateSpeedInfoMap();
+        mockRadioButton(false, true, false);
+        mSettings.mSpeedPreferenceMap.put(SPEED_2GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(true, false, true);
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_checkedSpeed5g_checkedToRadioButton5g() {
+        mSpeedInfo5g = new WifiHotspotSpeedViewModel.SpeedInfo(false, true, false);
+        updateSpeedInfoMap();
+        mockRadioButton(true, false, true);
+        mSettings.mSpeedPreferenceMap.put(SPEED_5GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(false, true, false);
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_uncheckedSpeed5g_uncheckedToRadioButton5g() {
+        mSpeedInfo5g = new WifiHotspotSpeedViewModel.SpeedInfo(true, false, true);
+        updateSpeedInfoMap();
+        mockRadioButton(false, true, false);
+        mSettings.mSpeedPreferenceMap.put(SPEED_5GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(true, false, true);
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_checkedSpeed2g5g_checkedToRadioButton2g5g() {
+        mSpeedInfo2g5g = new WifiHotspotSpeedViewModel.SpeedInfo(false, true, false);
+        updateSpeedInfoMap();
+        mockRadioButton(true, false, true);
+        mSettings.mSpeedPreferenceMap.put(SPEED_2GHZ_5GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(false, true, false);
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_uncheckedSpeed25g_uncheckedToRadioButton25g() {
+        mSpeedInfo2g5g = new WifiHotspotSpeedViewModel.SpeedInfo(true, false, true);
+        updateSpeedInfoMap();
+        mockRadioButton(false, true, false);
+        mSettings.mSpeedPreferenceMap.put(SPEED_2GHZ_5GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(true, false, true);
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_checkedSpeed6g_checkedToRadioButton6g() {
+        mSpeedInfo6g = new WifiHotspotSpeedViewModel.SpeedInfo(false, true, false);
+        updateSpeedInfoMap();
+        mockRadioButton(true, false, true);
+        mSettings.mSpeedPreferenceMap.put(SPEED_6GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(false, true, false);
+    }
+
+    @Test
+    public void onSpeedInfoMapDataChanged_uncheckedSpeed6g_uncheckedToRadioButton6g() {
+        mSpeedInfo6g = new WifiHotspotSpeedViewModel.SpeedInfo(true, false, true);
+        updateSpeedInfoMap();
+        mockRadioButton(false, true, false);
+        mSettings.mSpeedPreferenceMap.put(SPEED_6GHZ, mRadioButton);
+
+        mSettings.onSpeedInfoMapDataChanged(mSpeedInfoMap);
+
+        verifyRadioButton(true, false, true);
+    }
+
+    @Test
+    public void onRadioButtonClicked_toSpeed2g_setSpeedType2g() {
+        when(mRadioButton.getKey()).thenReturn(KEY_SPEED_2GHZ);
+
+        mSettings.onRadioButtonClicked(mRadioButton);
+
+        verify(mViewModel).setSpeedType(SPEED_2GHZ);
+    }
+
+    @Test
+    public void onRadioButtonClicked_toSpeed5g_setSpeedType5g() {
+        when(mRadioButton.getKey()).thenReturn(KEY_SPEED_5GHZ);
+
+        mSettings.onRadioButtonClicked(mRadioButton);
+
+        verify(mViewModel).setSpeedType(SPEED_5GHZ);
+    }
+
+    @Test
+    public void onRadioButtonClicked_toSpeed2g5g_setSpeedType2g5g() {
+        when(mRadioButton.getKey()).thenReturn(KEY_SPEED_2GHZ_5GHZ);
+
+        mSettings.onRadioButtonClicked(mRadioButton);
+
+        verify(mViewModel).setSpeedType(SPEED_2GHZ_5GHZ);
+    }
+
+    @Test
+    public void onRadioButtonClicked_toSpeed6g_setSpeedType6g() {
+        when(mRadioButton.getKey()).thenReturn(KEY_SPEED_6GHZ);
+
+        mSettings.onRadioButtonClicked(mRadioButton);
+
+        verify(mViewModel).setSpeedType(SPEED_6GHZ);
+    }
+
+    private void updateSpeedInfoMap() {
+        mSpeedInfoMap.put(SPEED_2GHZ, mSpeedInfo2g);
+        mSpeedInfoMap.put(SPEED_5GHZ, mSpeedInfo5g);
+        mSpeedInfoMap.put(SPEED_2GHZ_5GHZ, mSpeedInfo2g5g);
+        mSpeedInfoMap.put(SPEED_6GHZ, mSpeedInfo6g);
+    }
+
+    private void mockRadioButton(boolean isChecked, boolean isEnabled, boolean isVisible) {
+        when(mRadioButton.isChecked()).thenReturn(isChecked);
+        when(mRadioButton.isEnabled()).thenReturn(isEnabled);
+        when(mRadioButton.isVisible()).thenReturn(isVisible);
+    }
+
+    private void verifyRadioButton(boolean isChecked, boolean isEnabled, boolean isVisible) {
+        verify(mRadioButton).setChecked(isChecked);
+        verify(mRadioButton).setEnabled(isEnabled);
+        verify(mRadioButton).setVisible(isVisible);
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
index 582f792..0c2bbf5 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
@@ -157,7 +157,7 @@
 
     @Test
     public void onSpeedSummaryChanged_canNotShowWifiHotspot_returnFalse() {
-        int stringResId = R.string.wifi_hotspot_speed_6g_summary;
+        int stringResId = R.string.wifi_hotspot_speed_summary_6g;
         mWifiTetherSettings.mWifiHotspotSpeed = mock(Preference.class);
 
         mWifiTetherSettings.onSpeedSummaryChanged(stringResId);
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
index 9cfa7ed..042c9b6 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
@@ -24,13 +24,20 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 
+import android.app.Activity;
 import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.ServiceInfo;
 import android.credentials.CredentialProviderInfo;
+import android.net.Uri;
 import android.os.Looper;
+import android.os.UserHandle;
+import android.provider.Settings;
 
 import androidx.lifecycle.Lifecycle;
+import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
 import androidx.preference.PreferenceManager;
 import androidx.preference.PreferenceScreen;
@@ -47,6 +54,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
 @RunWith(AndroidJUnit4.class)
@@ -55,6 +63,8 @@
     private Context mContext;
     private PreferenceScreen mScreen;
     private PreferenceCategory mCredentialsPreferenceCategory;
+    private CredentialManagerPreferenceController.Delegate mDelegate;
+    private Optional<Integer> mReceivedResultCode;
 
     private static final String TEST_PACKAGE_NAME_A = "com.android.providerA";
     private static final String TEST_PACKAGE_NAME_B = "com.android.providerB";
@@ -62,6 +72,8 @@
     private static final String TEST_TITLE_APP_A = "test app A";
     private static final String TEST_TITLE_APP_B = "test app B";
     private static final String TEST_TITLE_SERVICE_C = "test service C1";
+    private static final String PRIMARY_INTENT = "android.settings.CREDENTIAL_PROVIDER";
+    private static final String ALTERNATE_INTENT = "android.settings.SYNC_SETTINGS";
 
     @Before
     public void setUp() {
@@ -73,9 +85,17 @@
         mCredentialsPreferenceCategory = new PreferenceCategory(mContext);
         mCredentialsPreferenceCategory.setKey("credentials_test");
         mScreen.addPreference(mCredentialsPreferenceCategory);
+        mReceivedResultCode = Optional.empty();
+        mDelegate =
+                new CredentialManagerPreferenceController.Delegate() {
+                    @Override
+                    public void setActivityResult(int resultCode) {
+                        mReceivedResultCode = Optional.of(resultCode);
+                    }
+                };
     }
 
-    /*@Test
+    @Test
     // Tests that getAvailabilityStatus() does not throw an exception if it's called before the
     // Controller is initialized (this can happen during indexing).
     public void getAvailabilityStatus_withoutInit_returnsUnavailable() {
@@ -103,11 +123,42 @@
     }
 
     @Test
-    public void displayPreference_noServices_noPreferencesAdded() {
+    public void displayPreference_noServices_noPreferencesAdded_useAutofillUri() {
+        Settings.Secure.putStringForUser(
+                mContext.getContentResolver(),
+                Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
+                "test",
+                UserHandle.myUserId());
+
         CredentialManagerPreferenceController controller =
                 createControllerWithServices(Collections.emptyList());
         controller.displayPreference(mScreen);
-        assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
+        assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+
+        Preference pref = mCredentialsPreferenceCategory.getPreference(0);
+        assertThat(pref.getTitle()).isEqualTo("Add service");
+
+        assertThat(controller.getAddServiceUri(mContext)).isEqualTo("test");
+    }
+
+    @Test
+    public void displayPreference_noServices_noPreferencesAdded_useCredManUri() {
+        Settings.Secure.putStringForUser(
+                mContext.getContentResolver(),
+                Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
+                "test",
+                UserHandle.myUserId());
+
+        CredentialManagerPreferenceController controller =
+                createControllerWithServicesAndAddServiceOverride(
+                        Collections.emptyList(), "credman");
+        controller.displayPreference(mScreen);
+        assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+
+        Preference pref = mCredentialsPreferenceCategory.getPreference(0);
+        assertThat(pref.getTitle()).isEqualTo("Add service");
+
+        assertThat(controller.getAddServiceUri(mContext)).isEqualTo("credman");
     }
 
     @Test
@@ -117,6 +168,9 @@
         controller.displayPreference(mScreen);
         assertThat(controller.isConnected()).isFalse();
         assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+
+        Preference pref = mCredentialsPreferenceCategory.getPreference(0);
+        assertThat(pref.getTitle()).isNotEqualTo("Add account");
     }
 
     @Test
@@ -252,7 +306,7 @@
         assertThat(enabledServices.size()).isEqualTo(1);
         assertThat(enabledServices.contains("com.android.provider1/ClassA")).isFalse();
         assertThat(enabledServices.contains("com.android.provider2/ClassA")).isTrue();
-    }*/
+    }
 
     @Test
     public void displayPreference_withServices_preferencesAdded_sameAppShouldBeMerged() {
@@ -299,7 +353,8 @@
 
         Map<String, SwitchPreference> prefs =
                 controller.buildPreferenceList(mContext, mCredentialsPreferenceCategory);
-        assertThat(prefs.keySet()).containsExactly(TEST_PACKAGE_NAME_A, TEST_PACKAGE_NAME_B, TEST_PACKAGE_NAME_C);
+        assertThat(prefs.keySet())
+                .containsExactly(TEST_PACKAGE_NAME_A, TEST_PACKAGE_NAME_B, TEST_PACKAGE_NAME_C);
         assertThat(prefs.size()).isEqualTo(3);
         assertThat(prefs.containsKey(TEST_PACKAGE_NAME_A)).isTrue();
         assertThat(prefs.get(TEST_PACKAGE_NAME_A).getTitle()).isEqualTo(TEST_TITLE_APP_A);
@@ -312,12 +367,125 @@
         assertThat(prefs.get(TEST_PACKAGE_NAME_C).isChecked()).isTrue();
     }
 
+    @Test
+    public void handleIntentWithProviderServiceInfo_handleBadIntent_missingData() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+
+        // Create an intent with missing data.
+        Intent missingDataIntent = new Intent(PRIMARY_INTENT);
+        assertThat(controller.verifyReceivedIntent(missingDataIntent)).isFalse();
+    }
+
+    @Test
+    public void handleIntentWithProviderServiceInfo_handleBadIntent_successDialog() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+        String packageName = cpi.getServiceInfo().packageName;
+
+        // Create an intent with valid data.
+        Intent intent = new Intent(PRIMARY_INTENT);
+        intent.setData(Uri.parse("package:" + packageName));
+        assertThat(controller.verifyReceivedIntent(intent)).isTrue();
+        controller.completeEnableProviderDialogBox(DialogInterface.BUTTON_POSITIVE, packageName);
+        assertThat(mReceivedResultCode.get()).isEqualTo(Activity.RESULT_OK);
+    }
+
+    @Test
+    public void handleIntentWithProviderServiceInfo_handleIntent_cancelDialog() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+        String packageName = cpi.getServiceInfo().packageName;
+
+        // Create an intent with valid data.
+        Intent intent = new Intent(PRIMARY_INTENT);
+        intent.setData(Uri.parse("package:" + packageName));
+        assertThat(controller.verifyReceivedIntent(intent)).isTrue();
+        controller.completeEnableProviderDialogBox(DialogInterface.BUTTON_NEGATIVE, packageName);
+        assertThat(mReceivedResultCode.get()).isEqualTo(Activity.RESULT_CANCELED);
+    }
+
+    @Test
+    public void handleOtherIntentWithProviderServiceInfo_handleBadIntent_missingData() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+
+        // Create an intent with missing data.
+        Intent missingDataIntent = new Intent(ALTERNATE_INTENT);
+        assertThat(controller.verifyReceivedIntent(missingDataIntent)).isFalse();
+    }
+
+    @Test
+    public void handleOtherIntentWithProviderServiceInfo_handleBadIntent_successDialog() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+        String packageName = cpi.getServiceInfo().packageName;
+
+        // Create an intent with valid data.
+        Intent intent = new Intent(ALTERNATE_INTENT);
+        intent.setData(Uri.parse("package:" + packageName));
+        assertThat(controller.verifyReceivedIntent(intent)).isTrue();
+        controller.completeEnableProviderDialogBox(DialogInterface.BUTTON_POSITIVE, packageName);
+        assertThat(mReceivedResultCode.get()).isEqualTo(Activity.RESULT_OK);
+    }
+
+    @Test
+    public void handleOtherIntentWithProviderServiceInfo_handleIntent_cancelDialog() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+        String packageName = cpi.getServiceInfo().packageName;
+
+        // Create an intent with valid data.
+        Intent intent = new Intent(ALTERNATE_INTENT);
+        intent.setData(Uri.parse("package:" + packageName));
+        assertThat(controller.verifyReceivedIntent(intent)).isTrue();
+        controller.completeEnableProviderDialogBox(DialogInterface.BUTTON_NEGATIVE, packageName);
+        assertThat(mReceivedResultCode.get()).isEqualTo(Activity.RESULT_CANCELED);
+    }
+
+    @Test
+    public void handleIntentWithProviderServiceInfo_handleIntent_incorrectAction() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+        String packageName = cpi.getServiceInfo().packageName;
+
+        // Create an intent with valid data.
+        Intent intent = new Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE);
+        intent.setData(Uri.parse("package:" + packageName));
+        assertThat(controller.verifyReceivedIntent(intent)).isFalse();
+        assertThat(mReceivedResultCode.isPresent()).isFalse();
+    }
+
+    @Test
+    public void handleIntentWithProviderServiceInfo_handleNullIntent() {
+        CredentialProviderInfo cpi = createCredentialProviderInfo();
+        CredentialManagerPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(cpi));
+
+        // Use a null intent.
+        assertThat(controller.verifyReceivedIntent(null)).isFalse();
+        assertThat(mReceivedResultCode.isPresent()).isFalse();
+    }
+
     private CredentialManagerPreferenceController createControllerWithServices(
             List<CredentialProviderInfo> availableServices) {
+        return createControllerWithServicesAndAddServiceOverride(availableServices, null);
+    }
+
+    private CredentialManagerPreferenceController createControllerWithServicesAndAddServiceOverride(
+            List<CredentialProviderInfo> availableServices, String addServiceOverride) {
         CredentialManagerPreferenceController controller =
                 new CredentialManagerPreferenceController(
                         mContext, mCredentialsPreferenceCategory.getKey());
-        controller.setAvailableServices(() -> mock(Lifecycle.class), availableServices);
+        controller.setAvailableServices(() -> mock(Lifecycle.class), availableServices, addServiceOverride);
+        controller.setDelegate(mDelegate);
         return controller;
     }
 
diff --git a/tests/unit/src/com/android/settings/wifi/repository/WifiHotspotRepositoryTest.java b/tests/unit/src/com/android/settings/wifi/repository/WifiHotspotRepositoryTest.java
index 52f02f5..b75f9fc 100644
--- a/tests/unit/src/com/android/settings/wifi/repository/WifiHotspotRepositoryTest.java
+++ b/tests/unit/src/com/android/settings/wifi/repository/WifiHotspotRepositoryTest.java
@@ -19,6 +19,7 @@
 import static android.net.wifi.SoftApConfiguration.BAND_2GHZ;
 import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_OPEN;
 import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_WPA3_SAE;
+import static android.net.wifi.WifiAvailableChannel.OP_MODE_SAP;
 
 import static com.android.settings.wifi.repository.WifiHotspotRepository.BAND_2GHZ_5GHZ;
 import static com.android.settings.wifi.repository.WifiHotspotRepository.BAND_2GHZ_5GHZ_6GHZ;
@@ -31,13 +32,17 @@
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
 import android.net.wifi.SoftApConfiguration;
+import android.net.wifi.WifiAvailableChannel;
 import android.net.wifi.WifiManager;
+import android.net.wifi.WifiScanner;
+import android.util.SparseIntArray;
 
 import androidx.lifecycle.MutableLiveData;
 import androidx.test.annotation.UiThreadTest;
@@ -48,11 +53,15 @@
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.Spy;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 
+import java.util.Arrays;
+import java.util.List;
+
 @RunWith(AndroidJUnit4.class)
 public class WifiHotspotRepositoryTest {
     static final String WIFI_SSID = "wifi_ssid";
@@ -61,6 +70,9 @@
 
     static final int WIFI_5GHZ_BAND_PREFERRED = BAND_2GHZ_5GHZ;
     static final int WIFI_6GHZ_BAND_PREFERRED = BAND_2GHZ_5GHZ_6GHZ;
+    static final int CHANNEL_NOT_FOUND = -1;
+    static final int FREQ_5GHZ = 5000;
+    static final int FREQ_6GHZ = 6000;
 
     @Rule
     public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@@ -73,10 +85,15 @@
 
     WifiHotspotRepository mWifiHotspotRepository;
     SoftApConfiguration mSoftApConfiguration;
+    ArgumentCaptor<SoftApConfiguration> mSoftApConfigCaptor =
+            ArgumentCaptor.forClass(SoftApConfiguration.class);
 
     @Before
     public void setUp() {
+        doReturn(SPEED_6GHZ).when(mSpeedType).getValue();
+
         mWifiHotspotRepository = new WifiHotspotRepository(mContext, mWifiManager);
+        mWifiHotspotRepository.mSpeedType = mSpeedType;
         mWifiHotspotRepository.mCurrentCountryCode = WIFI_CURRENT_COUNTRY_CODE;
         mWifiHotspotRepository.mIsDualBand = true;
         mWifiHotspotRepository.mIs5gAvailable = true;
@@ -148,8 +165,7 @@
 
     @Test
     public void refresh_liveDataIsUsed_getConfigAndUpdateLiveData() {
-        // If LiveData is used then it's not null.
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
+        mWifiHotspotRepository.getSpeedType();
 
         mWifiHotspotRepository.refresh();
 
@@ -191,7 +207,6 @@
         mWifiHotspotRepository.mIsDualBand = false;
         SoftApConfiguration config = new SoftApConfiguration.Builder().setBand(BAND_2GHZ).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
@@ -204,7 +219,6 @@
         SoftApConfiguration config = new SoftApConfiguration.Builder()
                 .setBand(WIFI_5GHZ_BAND_PREFERRED).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
@@ -218,7 +232,6 @@
         SoftApConfiguration config = new SoftApConfiguration.Builder()
                 .setBand(WIFI_5GHZ_BAND_PREFERRED).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
@@ -231,7 +244,6 @@
         SoftApConfiguration config = new SoftApConfiguration.Builder()
                 .setBand(WIFI_6GHZ_BAND_PREFERRED).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
@@ -245,7 +257,6 @@
         SoftApConfiguration config = new SoftApConfiguration.Builder()
                 .setBand(WIFI_6GHZ_BAND_PREFERRED).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
@@ -260,7 +271,6 @@
         SoftApConfiguration config = new SoftApConfiguration.Builder()
                 .setBand(WIFI_6GHZ_BAND_PREFERRED).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
@@ -273,7 +283,6 @@
         SoftApConfiguration config = new SoftApConfiguration.Builder()
                 .setBand(WIFI_5GHZ_BAND_PREFERRED).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
@@ -287,10 +296,201 @@
         SoftApConfiguration config = new SoftApConfiguration.Builder()
                 .setBand(WIFI_5GHZ_BAND_PREFERRED).build();
         when(mWifiManager.getSoftApConfiguration()).thenReturn(config);
-        mWifiHotspotRepository.mSpeedType = mSpeedType;
 
         mWifiHotspotRepository.updateSpeedType();
 
         verify(mSpeedType).setValue(SPEED_2GHZ);
     }
+
+    @Test
+    public void setSpeedType_sameValue_doNotSetConfig() {
+        doReturn(SPEED_6GHZ).when(mSpeedType).getValue();
+
+        mWifiHotspotRepository.setSpeedType(SPEED_6GHZ);
+
+        verify(mWifiManager, never()).setSoftApConfiguration(any());
+    }
+
+    @Test
+    public void setSpeedType_from2g5ghz_setConfigBandTo6ghzPreferred() {
+        mockGetSoftApConfiguration(SPEED_2GHZ_5GHZ);
+
+        mWifiHotspotRepository.setSpeedType(SPEED_6GHZ);
+
+        verify(mWifiManager).setSoftApConfiguration(mSoftApConfigCaptor.capture());
+        assertThat(mSoftApConfigCaptor.getValue().getBand()).isEqualTo(BAND_2GHZ_5GHZ_6GHZ);
+    }
+
+    @Test
+    public void setSpeedType_from6ghz_setConfigBandsTo2g5ghz() {
+        mockGetSoftApConfiguration(SPEED_6GHZ);
+        mWifiHotspotRepository.mIsDualBand = true;
+
+        mWifiHotspotRepository.setSpeedType(SPEED_2GHZ_5GHZ);
+
+        verify(mWifiManager).setSoftApConfiguration(mSoftApConfigCaptor.capture());
+        SparseIntArray channels = mSoftApConfigCaptor.getValue().getChannels();
+        assertThat(channels.get(BAND_2GHZ, CHANNEL_NOT_FOUND)).isNotEqualTo(CHANNEL_NOT_FOUND);
+        assertThat(channels.get(BAND_2GHZ_5GHZ, CHANNEL_NOT_FOUND)).isNotEqualTo(CHANNEL_NOT_FOUND);
+    }
+
+    @Test
+    public void setSpeedType_from2ghz_setConfigBandTo5ghzPreferred() {
+        mockGetSoftApConfiguration(SPEED_2GHZ);
+
+        mWifiHotspotRepository.setSpeedType(SPEED_5GHZ);
+
+        verify(mWifiManager).setSoftApConfiguration(mSoftApConfigCaptor.capture());
+        assertThat(mSoftApConfigCaptor.getValue().getBand()).isEqualTo(WIFI_5GHZ_BAND_PREFERRED);
+    }
+
+    @Test
+    public void setSpeedType_from5ghz_setConfigBandTo6ghzPreferred() {
+        mockGetSoftApConfiguration(SPEED_5GHZ);
+
+        mWifiHotspotRepository.setSpeedType(SPEED_6GHZ);
+
+        verify(mWifiManager).setSoftApConfiguration(mSoftApConfigCaptor.capture());
+        assertThat(mSoftApConfigCaptor.getValue().getBand()).isEqualTo(WIFI_6GHZ_BAND_PREFERRED);
+    }
+
+    @Test
+    public void setSpeedType_from5gTo6ghz_setConfigBandTo2ghz() {
+        mockGetSoftApConfiguration(SPEED_6GHZ);
+
+        mWifiHotspotRepository.setSpeedType(SPEED_2GHZ);
+
+        verify(mWifiManager).setSoftApConfiguration(mSoftApConfigCaptor.capture());
+        assertThat(mSoftApConfigCaptor.getValue().getBand()).isEqualTo(BAND_2GHZ);
+    }
+
+    @Test
+    public void isDualBand_resultSameAsWifiManager() {
+        // Reset mIsDualBand to trigger an update
+        mWifiHotspotRepository.mIsDualBand = null;
+        when(mWifiManager.isBridgedApConcurrencySupported()).thenReturn(true);
+
+        assertThat(mWifiHotspotRepository.isDualBand()).isTrue();
+
+        // Reset mIsDualBand to trigger an update
+        mWifiHotspotRepository.mIsDualBand = null;
+        when(mWifiManager.isBridgedApConcurrencySupported()).thenReturn(false);
+
+        assertThat(mWifiHotspotRepository.isDualBand()).isFalse();
+    }
+
+    @Test
+    public void is5GHzBandSupported_resultSameAsWifiManager() {
+        // Reset mIs5gBandSupported to trigger an update
+        mWifiHotspotRepository.mIs5gBandSupported = null;
+        when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
+
+        assertThat(mWifiHotspotRepository.is5GHzBandSupported()).isTrue();
+
+        // Reset mIs5gBandSupported to trigger an update
+        mWifiHotspotRepository.mIs5gBandSupported = null;
+        when(mWifiManager.is5GHzBandSupported()).thenReturn(false);
+
+        assertThat(mWifiHotspotRepository.is5GHzBandSupported()).isFalse();
+    }
+
+    @Test
+    public void is5gAvailable_hasUsableChannels_returnTrue() {
+        mWifiHotspotRepository.mIs5gBandSupported = true;
+        // Reset mIs5gAvailable to trigger an update
+        mWifiHotspotRepository.mIs5gAvailable = null;
+        List<WifiAvailableChannel> channels =
+                Arrays.asList(new WifiAvailableChannel(FREQ_5GHZ, OP_MODE_SAP));
+        when(mWifiManager.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS, OP_MODE_SAP))
+                .thenReturn(channels);
+
+        assertThat(mWifiHotspotRepository.is5gAvailable()).isTrue();
+    }
+
+    @Test
+    public void is5gAvailable_noUsableChannels_returnFalse() {
+        mWifiHotspotRepository.mIs5gBandSupported = true;
+        // Reset mIs5gAvailable to trigger an update
+        mWifiHotspotRepository.mIs5gAvailable = null;
+        when(mWifiManager.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS, OP_MODE_SAP))
+                .thenReturn(null);
+
+        assertThat(mWifiHotspotRepository.is5gAvailable()).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void get5gAvailable_shouldNotReturnNull() {
+        // Reset m5gAvailable to trigger an update
+        mWifiHotspotRepository.m5gAvailable = null;
+
+        assertThat(mWifiHotspotRepository.get5gAvailable()).isNotNull();
+    }
+
+    @Test
+    public void is6GHzBandSupported_resultSameAsWifiManager() {
+        // Reset mIs6gBandSupported to trigger an update
+        mWifiHotspotRepository.mIs6gBandSupported = null;
+        when(mWifiManager.is6GHzBandSupported()).thenReturn(true);
+
+        assertThat(mWifiHotspotRepository.is6GHzBandSupported()).isTrue();
+
+        // Reset mIs6gBandSupported to trigger an update
+        mWifiHotspotRepository.mIs6gBandSupported = null;
+        when(mWifiManager.is6GHzBandSupported()).thenReturn(false);
+
+        assertThat(mWifiHotspotRepository.is6GHzBandSupported()).isFalse();
+    }
+
+    @Test
+    public void is6gAvailable_hasUsableChannels_returnTrue() {
+        mWifiHotspotRepository.mIs6gBandSupported = true;
+        // Reset mIs6gAvailable to trigger an update
+        mWifiHotspotRepository.mIs6gAvailable = null;
+        List<WifiAvailableChannel> channels =
+                Arrays.asList(new WifiAvailableChannel(FREQ_6GHZ, OP_MODE_SAP));
+        when(mWifiManager.getUsableChannels(WifiScanner.WIFI_BAND_6_GHZ, OP_MODE_SAP))
+                .thenReturn(channels);
+
+        assertThat(mWifiHotspotRepository.is6gAvailable()).isTrue();
+    }
+
+    @Test
+    public void is6gAvailable_noUsableChannels_returnFalse() {
+        mWifiHotspotRepository.mIs6gBandSupported = true;
+        // Reset mIs6gAvailable to trigger an update
+        mWifiHotspotRepository.mIs6gAvailable = null;
+        when(mWifiManager.getUsableChannels(WifiScanner.WIFI_BAND_6_GHZ, OP_MODE_SAP))
+                .thenReturn(null);
+
+        assertThat(mWifiHotspotRepository.is6gAvailable()).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void get6gAvailable_shouldNotReturnNull() {
+        // Reset m6gAvailable to trigger an update
+        mWifiHotspotRepository.m6gAvailable = null;
+
+        assertThat(mWifiHotspotRepository.get6gAvailable()).isNotNull();
+    }
+
+    private void mockGetSoftApConfiguration(int speedType) {
+        doReturn(speedType).when(mSpeedType).getValue();
+        mWifiHotspotRepository.mIsDualBand = true;
+        SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
+        if (speedType == SPEED_2GHZ) {
+            mWifiHotspotRepository.mIsDualBand = false;
+            configBuilder.setBand(BAND_2GHZ);
+        } else if (speedType == SPEED_5GHZ) {
+            mWifiHotspotRepository.mIsDualBand = false;
+            configBuilder.setBand(BAND_2GHZ_5GHZ);
+        } else if (speedType == SPEED_2GHZ_5GHZ) {
+            int[] bands = {BAND_2GHZ, BAND_2GHZ_5GHZ};
+            configBuilder.setBands(bands);
+        } else if (speedType == SPEED_6GHZ) {
+            configBuilder.setBand(BAND_2GHZ_5GHZ_6GHZ);
+        }
+        when(mWifiManager.getSoftApConfiguration()).thenReturn(configBuilder.build());
+    }
 }
diff --git a/tests/unit/src/com/android/settings/wifi/tether/WifiHotspotSpeedViewModelTest.java b/tests/unit/src/com/android/settings/wifi/tether/WifiHotspotSpeedViewModelTest.java
new file mode 100644
index 0000000..7308161
--- /dev/null
+++ b/tests/unit/src/com/android/settings/wifi/tether/WifiHotspotSpeedViewModelTest.java
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi.tether;
+
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_2GHZ_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_5GHZ;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.SPEED_6GHZ;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Application;
+import android.content.Context;
+
+import androidx.lifecycle.MutableLiveData;
+import androidx.test.annotation.UiThreadTest;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.wifi.repository.WifiHotspotRepository;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+
+import java.util.Map;
+
+@RunWith(AndroidJUnit4.class)
+public class WifiHotspotSpeedViewModelTest {
+    @Rule
+    public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+    @Spy
+    Context mContext = ApplicationProvider.getApplicationContext();
+    @Mock
+    WifiHotspotRepository mWifiHotspotRepository;
+    @Mock
+    MutableLiveData<Integer> mSpeedType;
+    @Mock
+    MutableLiveData<Boolean> m5gAvailable;
+    @Mock
+    MutableLiveData<Boolean> m6gAvailable;
+    @Mock
+    MutableLiveData<Map<Integer, WifiHotspotSpeedViewModel.SpeedInfo>> mSpeedInfoMapData;
+
+    WifiHotspotSpeedViewModel mViewModel;
+
+    @Before
+    public void setUp() {
+        FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
+        when(featureFactory.getWifiFeatureProvider().getWifiHotspotRepository())
+                .thenReturn(mWifiHotspotRepository);
+        when(mWifiHotspotRepository.getSpeedType()).thenReturn(mSpeedType);
+        when(mWifiHotspotRepository.is5GHzBandSupported()).thenReturn(true);
+        when(mWifiHotspotRepository.get5gAvailable()).thenReturn(m5gAvailable);
+        when(mWifiHotspotRepository.is6GHzBandSupported()).thenReturn(true);
+        when(mWifiHotspotRepository.get6gAvailable()).thenReturn(m6gAvailable);
+
+        mViewModel = new WifiHotspotSpeedViewModel((Application) mContext);
+        mViewModel.mSpeedInfoMapData = mSpeedInfoMapData;
+    }
+
+    @Test
+    @UiThreadTest
+    public void constructor_observeDataAndSetAutoRefresh() {
+        verify(mSpeedType).observeForever(mViewModel.mSpeedTypeObserver);
+        verify(m5gAvailable).observeForever(mViewModel.m5gAvailableObserver);
+        verify(m6gAvailable).observeForever(mViewModel.m6gAvailableObserver);
+        verify(mWifiHotspotRepository).setAutoRefresh(true);
+    }
+
+    @Test
+    @UiThreadTest
+    public void constructor_supported6GHzBand_set6gVisible() {
+        assertThat(mViewModel.mSpeedInfo6g.mIsVisible).isTrue();
+    }
+
+    @Test
+    @UiThreadTest
+    public void constructor_notSupported6GHzBand_set6gVisible() {
+        when(mWifiHotspotRepository.is6GHzBandSupported()).thenReturn(false);
+
+        WifiHotspotSpeedViewModel viewModel = new WifiHotspotSpeedViewModel((Application) mContext);
+
+        assertThat(viewModel.mSpeedInfo6g.mIsVisible).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void onCleared_removeObserverData() {
+        mViewModel.onCleared();
+
+        verify(mSpeedType).removeObserver(mViewModel.mSpeedTypeObserver);
+        verify(m5gAvailable).removeObserver(mViewModel.m5gAvailableObserver);
+        verify(m6gAvailable).removeObserver(mViewModel.m6gAvailableObserver);
+    }
+
+    @Test
+    @UiThreadTest
+    public void on6gAvailableChanged_itsAvailable_setLiveData6gEnabled() {
+        mViewModel.mSpeedInfo6g.mIsEnabled = false;
+
+        mViewModel.on6gAvailableChanged(true);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_6GHZ).mIsEnabled).isTrue();
+    }
+
+    @Test
+    @UiThreadTest
+    public void on6gAvailableChanged_notAvailable_setLiveData6gDisabled() {
+        mViewModel.mSpeedInfo6g.mIsEnabled = true;
+
+        mViewModel.on6gAvailableChanged(false);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_6GHZ).mIsEnabled).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void on5gAvailableChanged_itsAvailable_setLiveData5gEnabled() {
+        mViewModel.mSpeedInfo5g.mIsEnabled = false;
+
+        mViewModel.on5gAvailableChanged(true);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsEnabled).isTrue();
+    }
+
+    @Test
+    @UiThreadTest
+    public void on5gAvailableChanged_notAvailable_setLiveData5gDisabled() {
+        mViewModel.mSpeedInfo5g.mIsEnabled = true;
+
+        mViewModel.on5gAvailableChanged(false);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsEnabled).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void on5gAvailableChanged_inSingleBand_setLiveDataToShowSingleBand() {
+        when(mWifiHotspotRepository.isDualBand()).thenReturn(false);
+
+        mViewModel.on5gAvailableChanged(true);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ).mIsVisible).isTrue();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsVisible).isTrue();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ_5GHZ).mIsVisible).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void on5gAvailableChanged_inDualBandAnd5gUnavailable_setLiveDataToShowSingleBand() {
+        when(mWifiHotspotRepository.isDualBand()).thenReturn(true);
+
+        mViewModel.on5gAvailableChanged(false);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ).mIsVisible).isTrue();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsVisible).isTrue();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ_5GHZ).mIsVisible).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void on5gAvailableChanged_inDualBandAnd5gAvailable_setLiveDataToShowDualBand() {
+        when(mWifiHotspotRepository.isDualBand()).thenReturn(true);
+
+        mViewModel.on5gAvailableChanged(true);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ).mIsVisible).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsVisible).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ_5GHZ).mIsVisible).isTrue();
+    }
+
+    @Test
+    @UiThreadTest
+    public void onSpeedTypeChanged_toSpeed2g_setLiveData2gChecked() {
+        mViewModel.mSpeedInfo2g.mIsChecked = false;
+
+        mViewModel.onSpeedTypeChanged(SPEED_2GHZ);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ).mIsChecked).isTrue();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ_5GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_6GHZ).mIsChecked).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void onSpeedTypeChanged_toSpeed5g_setLiveData5gChecked() {
+        mViewModel.mSpeedInfo5g.mIsChecked = false;
+
+        mViewModel.onSpeedTypeChanged(SPEED_5GHZ);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsChecked).isTrue();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ_5GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_6GHZ).mIsChecked).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void onSpeedTypeChanged_toSpeed2g5g_setLiveData5gChecked() {
+        mViewModel.mSpeedInfo2g5g.mIsChecked = false;
+
+        mViewModel.onSpeedTypeChanged(SPEED_2GHZ_5GHZ);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ_5GHZ).mIsChecked).isTrue();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_6GHZ).mIsChecked).isFalse();
+    }
+
+    @Test
+    @UiThreadTest
+    public void onSpeedTypeChanged_toSpeed6g_setLiveData5gChecked() {
+        mViewModel.mSpeedInfo6g.mIsChecked = false;
+
+        mViewModel.onSpeedTypeChanged(SPEED_6GHZ);
+
+        verify(mSpeedInfoMapData).setValue(mViewModel.mSpeedInfoMap);
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_5GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_2GHZ_5GHZ).mIsChecked).isFalse();
+        assertThat(mViewModel.mSpeedInfoMap.get(SPEED_6GHZ).mIsChecked).isTrue();
+    }
+
+    @Test
+    @UiThreadTest
+    public void setSpeedType_passedToRepository() {
+        mViewModel.setSpeedType(SPEED_2GHZ);
+
+        verify(mWifiHotspotRepository).setSpeedType(SPEED_2GHZ);
+
+        mViewModel.setSpeedType(SPEED_5GHZ);
+
+        verify(mWifiHotspotRepository).setSpeedType(SPEED_5GHZ);
+
+        mViewModel.setSpeedType(SPEED_2GHZ_5GHZ);
+
+        verify(mWifiHotspotRepository).setSpeedType(SPEED_2GHZ_5GHZ);
+
+        mViewModel.setSpeedType(SPEED_6GHZ);
+
+        verify(mWifiHotspotRepository).setSpeedType(SPEED_6GHZ);
+    }
+
+    @Test
+    @UiThreadTest
+    public void getSpeedInfoMapData_shouldNotReturnNull() {
+        // Reset mSpeedInfoMapData to trigger an update
+        mViewModel.mSpeedInfoMapData = null;
+
+        assertThat(mViewModel.getSpeedInfoMapData()).isNotNull();
+    }
+}