Merge "[Provider Model] Adjust slice title and subtitle" into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6ac1ac9..1632e7e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2902,6 +2902,12 @@
             android:grantUriPermissions="true"
             android:exported="false"/>
 
+        <provider
+            android:name=".emergency.EmergencyActionContentProvider"
+            android:authorities="com.android.settings.emergency"
+            android:permission="android.permission.CALL_PRIVILEGED"
+            android:exported="true"/>
+
         <activity
             android:name=".wifi.RequestToggleWiFiActivity"
             android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
@@ -3751,6 +3757,25 @@
             android:launchMode="singleTask">
         </activity>
 
+        <activity android:name="Settings$FactoryResetActivity"
+                  android:permission="android.permission.BACKUP"
+                  android:label="@string/main_clear_title"
+                  android:exported="true"
+                  android:theme="@style/SudThemeGlif.Light">
+            <intent-filter>
+                <action android:name="com.android.settings.action.FACTORY_RESET"/>
+                <category android:name="android.intent.category.DEFAULT"/>
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.MainClear"/>
+        </activity>
+
+        <activity android:name="Settings$FactoryResetConfirmActivity"
+                  android:label="@string/main_clear_confirm_title"
+                  android:exported="false"
+                  android:theme="@style/SudThemeGlif.Light">
+        </activity>
+
         <!-- This is the longest AndroidManifest.xml ever. -->
     </application>
 </manifest>
diff --git a/res/drawable/ic_battery_low.xml b/res/drawable/ic_battery_low.xml
new file mode 100644
index 0000000..82f9546
--- /dev/null
+++ b/res/drawable/ic_battery_low.xml
@@ -0,0 +1,28 @@
+<!--
+  Copyright (C) 2021 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+  <path
+      android:fillColor="?android:attr/colorAccent"
+      android:pathData="M12,19m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"/>
+  <path
+      android:fillColor="?android:attr/colorAccent"
+      android:pathData="M10,3h4v12h-4z"/>
+</vector>
diff --git a/res/layout/view_airplane_mode_networks_button.xml b/res/layout/airplane_mode_message_preference.xml
similarity index 62%
rename from res/layout/view_airplane_mode_networks_button.xml
rename to res/layout/airplane_mode_message_preference.xml
index 0599274..032161b 100644
--- a/res/layout/view_airplane_mode_networks_button.xml
+++ b/res/layout/airplane_mode_message_preference.xml
@@ -22,7 +22,6 @@
     android:orientation="vertical">
 
     <TextView
-        android:id="@+id/airplane_mode_text"
         android:text="@string/condition_airplane_title"
         android:textAppearance="?android:attr/textAppearanceSmall"
         android:layout_width="wrap_content"
@@ -30,17 +29,6 @@
         android:layout_gravity="center_horizontal"
         android:layout_marginStart="@dimen/content_margin_left"
         android:layout_marginEnd="@dimen/content_margin_left"
-        android:layout_marginTop="@dimen/view_airplane_mode_networks_button_margin_vertical"
-        android:layout_marginBottom="@dimen/view_airplane_mode_networks_button_margin_vertical"/>
-
-    <Button
-        android:id="@+id/view_airplane_mode_networks_button"
-        android:text="@string/view_airplane_safe_networks"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_horizontal"
-        android:layout_marginStart="@dimen/content_margin_left"
-        android:layout_marginEnd="@dimen/content_margin_left"
-        android:layout_marginBottom="@dimen/view_airplane_mode_networks_button_margin_vertical"
-        style="@style/ActionPrimaryButton"/>
+        android:layout_marginTop="@dimen/airplane_mode_message_margin_vertical"
+        android:layout_marginBottom="@dimen/airplane_mode_message_margin_vertical"/>
 </LinearLayout>
\ No newline at end of file
diff --git a/res/layout/manage_applications_apps_v2.xml b/res/layout/manage_applications_apps_v2.xml
index ecc764a..72c8ee8 100644
--- a/res/layout/manage_applications_apps_v2.xml
+++ b/res/layout/manage_applications_apps_v2.xml
@@ -48,7 +48,7 @@
             android:id="@android:id/empty"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:gravity="center"
+            android:gravity="bottom|center_horizontal"
             android:layout_gravity="center"
             android:text="@string/no_applications"
             android:textAppearance="?android:attr/textAppearanceLarge"
diff --git a/res/layout/settings_collapsing_base_layout.xml b/res/layout/settings_collapsing_base_layout.xml
index ba9e625..7ebf433 100644
--- a/res/layout/settings_collapsing_base_layout.xml
+++ b/res/layout/settings_collapsing_base_layout.xml
@@ -39,7 +39,7 @@
             app:statusBarScrim="?android:attr/colorPrimary"
             app:layout_scrollFlags="scroll|exitUntilCollapsed"
             app:expandedTitleMarginStart="18dp"
-            app:expandedTitleMarginEnd="18dp"
+            app:expandedTitleMarginEnd="16dp"
             app:toolbarId="@id/action_bar">
 
             <Toolbar
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index f78120c..bde5288 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -170,6 +170,7 @@
     <declare-styleable name="LabeledSeekBarPreference">
         <attr name="textStart" format="reference" />
         <attr name="textEnd" format="reference" />
+        <attr name="tickMark" format="reference" />
     </declare-styleable>
 
     <declare-styleable name="TintDrawable">
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 16db908..4fef726 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -213,7 +213,7 @@
     <dimen name="wifi_detail_page_header_image_size">32dp</dimen>
 
     <!-- Internet Preferences -->
-    <dimen name="view_airplane_mode_networks_button_margin_vertical">24dp</dimen>
+    <dimen name="airplane_mode_message_margin_vertical">24dp</dimen>
     <dimen name="reset_internet_ring_progress_right_margin">4dp</dimen>
 
     <!-- Color picker -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1cd6b8a..7ad7fe1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2836,7 +2836,9 @@
     <!-- adaptive_sleep settings screen, title about the required permission is missing [CHAR LIMIT=NONE]-->
     <string name="adaptive_sleep_title_no_permission">Camera access needed</string>
     <!-- adaptive_sleep settings screen, subtitle when permission is missing [CHAR LIMIT=NONE]-->
-    <string name="adaptive_sleep_summary_no_permission">Tap to manage permissions for Device Personalization Services</string>
+    <string name="adaptive_sleep_summary_no_permission">Camera access is required for screen attention. Tap to manage permissions for Device Personalization Services</string>
+    <!-- adaptive_sleep settings screen, text for the camera permission button [CHAR LIMIT=NONE]-->
+    <string name="adaptive_sleep_manage_permission_button">Manage permissions</string>
     <!-- Description about the feature adaptive sleep [CHAR LIMIT=NONE]-->
     <string name="adaptive_sleep_description">Prevents your screen from turning off if you\u2019re looking at it</string>
     <!-- Description feature's privacy sensitive details to make sure users understand what feature users, what it saves/sends etc [CHAR LIMIT=NONE]-->
@@ -4059,18 +4061,8 @@
     <!-- [CHAR LIMIT=50] Location settings screen, sub category for location services for managed profile -->
     <string name="managed_profile_location_services">Location services for work</string>
 
-    <!-- [CHAR LIMIT=60] Location settings screen, screen title -->
-    <string name="location_time_zone_detection_screen_title">Use location to set time zone</string>
-    <!-- [CHAR LIMIT=50] Location settings screen, title for the setting that control whether the
-         device can use its location for time zone detection. -->
-    <string name="location_time_zone_detection_enabled_title">Location time zone detection</string>
-    <!-- [CHAR LIMIT=NONE] Preference description text for location time zone detection -->
-    <string name="location_time_zone_detection_enabled_description">Allows the device\u2019s location to be used to detect the current time zone. Other location settings such as Wi\u2011Fi scanning can affect the accuracy of time zone detection.</string>
-
-    <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is on -->
-    <string name="location_time_zone_detection_on">On</string>
-    <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is off -->
-    <string name="location_time_zone_detection_off">Off</string>
+    <!-- [CHAR LIMIT=60] Date&Time settings screen, toggle button title -->
+    <string name="location_time_zone_detection_toggle_title">Use location to set time zone</string>
     <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
          applicable due to other settings like the "automatic time zone detection enabled" setting
          being set to "off". -->
@@ -7841,10 +7833,10 @@
     <string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness, Auto brightness</string>
 
     <!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
-    <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
+    <string name="keywords_display_adaptive_sleep">smart, dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
 
     <!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
-    <string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
+    <string name="keywords_auto_rotate">camera, smart, auto rotate, auto-rotate, rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
 
     <!-- List of synonyms for the System Update (update the operating system) setting, used to match in settings search [CHAR LIMIT=NONE] -->
     <string name="keywords_system_update_settings">upgrade, android</string>
@@ -12788,13 +12780,15 @@
     <string name="category_name_others">Others</string>
     <!-- General category name [CHAR LIMIT=none] -->
     <string name="category_name_general">General</string>
+    <!-- Title for Dark theme main switch preferences. [CHAR LIMIT=50] -->
+    <string name="dark_theme_main_switch_title">Use Dark theme</string>
+    <!-- Title for bluetooth main switch. [CHAR LIMIT=50] -->
+    <string name="bluetooth_main_switch_title">Use Bluetooth</string>
 
     <!-- Do not translate. Title for prevent ringing main switch. [CHAR LIMIT=50] -->
     <string name="prevent_ringing_main_switch_title" translatable="false">Use prevent ringing</string>
     <!-- Do not translate. Title for use wifi hotspot main switch [CHAR LIMIT=50]-->
     <string name="use_wifi_hotsopt_main_switch_title" translatable="false">Use Wi\u2011Fi hotspot</string>
-    <!-- Do not translate. Title for bluetooth main switch. [CHAR LIMIT=50] -->
-    <string name="bluetooth_main_switch_title" translatable="false">Use bluetooth</string>
     <!-- Do not translate. Title for app pinning main switch. [CHAR LIMIT=50] -->
     <string name="app_pinning_main_switch_title" translatable="false">Use app pinning</string>
     <!-- Do not translate. Title for developer options main switch. [CHAR LIMIT=50] -->
@@ -12811,8 +12805,6 @@
     <string name="battery_saver_main_switch_title" translatable="false">Use battery saver</string>
     <!-- Do not translate. Title for Do Not Disturb main switch preferences. [CHAR LIMIT=50] -->
     <string name="do_not_disturb_main_switch_title" translatable="false">Use Do Not Disturb</string>
-    <!-- Do not translate. Title for Dark theme main switch preferences. [CHAR LIMIT=50] -->
-    <string name="dark_theme_main_switch_title" translatable="false">Use Dark Theme</string>
     <!-- Do not translate. Title for Night Light main switch preferences. [CHAR LIMIT=50] -->
     <string name="night_light_main_switch_title" translatable="false">Use Night Light</string>
     <!-- Do not translate. Title for NFC main switch preferences. [CHAR LIMIT=50] -->
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index 43a797a..6fc0b25 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -53,12 +53,12 @@
         settings:keywords="@string/keywords_time_zone"/>
 
     <!-- This preference gets removed if location-based time zone detection is not supported -->
-    <com.android.settingslib.RestrictedPreference
+    <com.android.settingslib.RestrictedSwitchPreference
         android:key="location_time_zone_detection"
-        android:title="@string/location_time_zone_detection_screen_title"
+        android:title="@string/location_time_zone_detection_toggle_title"
         settings:controller="com.android.settings.datetime.LocationTimeZoneDetectionPreferenceController"
-        android:fragment="com.android.settings.datetime.locationtimezone.TimeZoneDetectionSettings"
-        settings:userRestriction="no_config_date_time"/>
+        settings:userRestriction="no_config_date_time"
+    />
 
     <PreferenceCategory
         android:key="time_format_preference_category"
diff --git a/res/xml/location_time_zone_detection.xml b/res/xml/location_time_zone_detection.xml
deleted file mode 100644
index 9f5e775..0000000
--- a/res/xml/location_time_zone_detection.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:settings="http://schemas.android.com/apk/res-auto"
-    android:title="@string/location_time_zone_detection_screen_title">
-
-    <SwitchPreference
-        android:title="@string/location_time_zone_detection_enabled_title"
-        android:summary="@string/location_time_zone_detection_enabled_description"
-        settings:controller="com.android.settings.datetime.locationtimezone.TimeZoneDetectionTogglePreferenceController"
-        android:key="location_time_zone_detection_enabled" />
-
-</PreferenceScreen>
diff --git a/res/xml/network_provider_settings.xml b/res/xml/network_provider_settings.xml
index a824b34..30fe6fe 100644
--- a/res/xml/network_provider_settings.xml
+++ b/res/xml/network_provider_settings.xml
@@ -28,12 +28,12 @@
         android:layout="@layout/resetting_internet"
         settings:allowDividerBelow="true"/>
 
-    <!-- View airplane mode networks button -->
+    <!-- Airplane mode message -->
     <com.android.settingslib.widget.LayoutPreference
-        android:key="view_airplane_mode_netwokrs_button"
+        android:key="airplane_mode_message"
         android:title="@string/condition_airplane_title"
         android:selectable="false"
-        android:layout="@layout/view_airplane_mode_networks_button"
+        android:layout="@layout/airplane_mode_message_preference"
         settings:allowDividerBelow="true"/>
 
     <Preference
diff --git a/src/com/android/settings/ActivityPicker.java b/src/com/android/settings/ActivityPicker.java
index ae61944..f75ce37 100644
--- a/src/com/android/settings/ActivityPicker.java
+++ b/src/com/android/settings/ActivityPicker.java
@@ -16,6 +16,8 @@
 
 package com.android.settings;
 
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
 import android.app.Activity;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -71,6 +73,8 @@
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+
+        getWindow().addPrivateFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
         
         final Intent intent = getIntent();
         
diff --git a/src/com/android/settings/applications/AppDashboardFragment.java b/src/com/android/settings/applications/AppDashboardFragment.java
index fc4bcd0..3b1a977 100644
--- a/src/com/android/settings/applications/AppDashboardFragment.java
+++ b/src/com/android/settings/applications/AppDashboardFragment.java
@@ -48,7 +48,7 @@
 
     @Override
     public int getMetricsCategory() {
-        return SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY;
+        return SettingsEnums.MANAGE_APPLICATIONS;
     }
 
     @Override
diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
index 792f2ee..f27530e 100644
--- a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
+++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
@@ -31,6 +31,7 @@
 import androidx.preference.PreferenceGroup;
 import androidx.preference.PreferenceScreen;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.Utils;
 import com.android.settings.core.BasePreferenceController;
 
@@ -47,16 +48,23 @@
     private final List<AutofillServiceInfo> mServices;
 
     public PasswordsPreferenceController(Context context, String preferenceKey) {
+        this(context, preferenceKey,
+                AutofillServiceInfo.getAvailableServices(context, UserHandle.myUserId()));
+    }
+
+    @VisibleForTesting
+    public PasswordsPreferenceController(
+            Context context, String preferenceKey, List<AutofillServiceInfo> availableServices) {
         super(context, preferenceKey);
         mPm = context.getPackageManager();
         mIconFactory = IconDrawableFactory.newInstance(mContext);
-        mServices = AutofillServiceInfo.getAvailableServices(mContext, UserHandle.myUserId());
-        for (int i = mServices.size() - 1; i >= 0; i--) {
-            final String passwordsActivity = mServices.get(i).getPasswordsActivity();
+        for (int i = availableServices.size() - 1; i >= 0; i--) {
+            final String passwordsActivity = availableServices.get(i).getPasswordsActivity();
             if (TextUtils.isEmpty(passwordsActivity)) {
-                mServices.remove(i);
+                availableServices.remove(i);
             }
         }
+        mServices = availableServices;
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 3fb8941..67148d1 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -48,6 +48,8 @@
     public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
     public static final String EXTRA_KEY_REQUIRE_VISION = "accessibility_vision";
     public static final String EXTRA_KEY_REQUIRE_DIVERSITY = "accessibility_diversity";
+    public static final String EXTRA_KEY_SENSOR_ID = "sensor_id";
+    public static final String EXTRA_KEY_CHALLENGE = "challenge";
 
     /**
      * Used by the choose fingerprint wizard to indicate the wizard is
@@ -90,12 +92,16 @@
     protected boolean mLaunchedConfirmLock;
     protected byte[] mToken;
     protected int mUserId;
+    protected int mSensorId;
+    protected long mChallenge;
     protected boolean mFromSettingsSummary;
     protected FooterBarMixin mFooterBarMixin;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        mChallenge = getIntent().getLongExtra(EXTRA_KEY_CHALLENGE, -1L);
+        mSensorId = getIntent().getIntExtra(EXTRA_KEY_SENSOR_ID, -1);
         // Don't need to retrieve the HAT if it already exists. In some cases, the extras do not
         // contain EXTRA_KEY_CHALLENGE_TOKEN but contain EXTRA_KEY_GK_PW, in which case enrollment
         // classes may request a HAT to be created (as opposed to being passed in)
@@ -110,6 +116,8 @@
                     ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
             mFromSettingsSummary =
                     savedInstanceState.getBoolean(EXTRA_FROM_SETTINGS_SUMMARY, false);
+            mChallenge = savedInstanceState.getLong(EXTRA_KEY_CHALLENGE);
+            mSensorId = savedInstanceState.getInt(EXTRA_KEY_SENSOR_ID);
         }
         mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
     }
@@ -127,6 +135,8 @@
         outState.putBoolean(EXTRA_KEY_LAUNCHED_CONFIRM, mLaunchedConfirmLock);
         outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
         outState.putBoolean(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
+        outState.putLong(EXTRA_KEY_CHALLENGE, mChallenge);
+        outState.putInt(EXTRA_KEY_SENSOR_ID, mSensorId);
     }
 
     @Override
@@ -173,10 +183,18 @@
         setHeaderText(resId, false /* force */);
     }
 
+    protected void setHeaderText(CharSequence title) {
+        getLayout().setHeaderText(title);
+    }
+
     protected void setDescriptionText(int resId) {
         getLayout().setDescriptionText(resId);
     }
 
+    protected void setDescriptionText(CharSequence descriptionText) {
+        getLayout().setDescriptionText(descriptionText);
+    }
+
     protected FooterButton getNextButton() {
         if (mFooterBarMixin != null) {
             return mFooterBarMixin.getPrimaryButton();
@@ -192,6 +210,8 @@
         intent.setClassName(SETTINGS_PACKAGE_NAME, FingerprintEnrollEnrolling.class.getName());
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
         intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
+        intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+        intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
         if (mUserId != UserHandle.USER_NULL) {
             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
         }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 09344b0..b44c2c9 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -243,6 +243,8 @@
         }
         BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
         intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
+        intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+        intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
         startActivityForResult(intent, BIOMETRIC_FIND_SENSOR_REQUEST);
     }
 
@@ -262,6 +264,8 @@
                 overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
                 getNextButton().setEnabled(false);
                 getChallenge(((sensorId, challenge) -> {
+                    mSensorId = sensorId;
+                    mChallenge = challenge;
                     mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
                     BiometricUtils.removeGatekeeperPasswordHandle(this, data);
                     getNextButton().setEnabled(true);
@@ -276,6 +280,8 @@
                 overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
                 getNextButton().setEnabled(false);
                 getChallenge(((sensorId, challenge) -> {
+                    mSensorId = sensorId;
+                    mChallenge = challenge;
                     mToken = BiometricUtils.requestGatekeeperHat(this, data, mUserId, challenge);
                     BiometricUtils.removeGatekeeperPasswordHandle(this, data);
                     getNextButton().setEnabled(true);
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 9b86e78..0bfe56e 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -121,6 +121,8 @@
                 | Intent.FLAG_ACTIVITY_CLEAR_TOP
                 | Intent.FLAG_ACTIVITY_SINGLE_TOP);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
+        intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, mSensorId);
+        intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
         intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
         if (mUserId != UserHandle.USER_NULL) {
             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
diff --git a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
index 1ea6b08..84128e2 100644
--- a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
+++ b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
@@ -72,6 +72,8 @@
                     mGkPwHandle, mUserId, challenge);
             final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity,
                     mActivity.getIntent());
+            faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
+            faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
 
             if (mRequestEnrollFingerprint) {
                 // Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it
@@ -97,6 +99,8 @@
                     mGkPwHandle, mUserId, challenge);
             final Intent intent = BiometricUtils.getFingerprintIntroIntent(mActivity,
                     mActivity.getIntent());
+            intent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
+            intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
             BiometricUtils.launchEnrollForResult(mActivity, intent, REQUEST_FINGERPRINT_ENROLL,
                     hardwareAuthToken, mGkPwHandle, mUserId);
         }));
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index 3e9fba2..6c5a4b4 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -183,6 +183,8 @@
         if (mUserId != UserHandle.USER_NULL) {
             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
         }
+        intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+        intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
         intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
         BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
         final String flattenedString = getString(R.string.config_face_enroll);
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 3bffbbf..9110292 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -112,6 +112,8 @@
             // the challenge is ready. Let's just do this for now.
             mFaceManager.generateChallenge((sensorId, challenge) -> {
                 mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
+                mSensorId = sensorId;
+                mChallenge = challenge;
                 if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) {
                     BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
                 }
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 7751485..038d448 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -37,6 +37,7 @@
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.Utils;
+import com.android.settings.biometrics.BiometricEnrollBase;
 import com.android.settings.biometrics.BiometricUtils;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
@@ -67,6 +68,8 @@
     private UserManager mUserManager;
     private FaceManager mFaceManager;
     private int mUserId;
+    private int mSensorId;
+    private long mChallenge;
     private byte[] mToken;
     private FaceSettingsAttentionPreferenceController mAttentionController;
     private FaceSettingsRemoveButtonPreferenceController mRemoveController;
@@ -147,6 +150,8 @@
         mUserManager = context.getSystemService(UserManager.class);
         mFaceManager = context.getSystemService(FaceManager.class);
         mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
+        mSensorId = getIntent().getIntExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, -1);
+        mChallenge = getIntent().getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, 0L);
 
         mUserId = getActivity().getIntent().getIntExtra(
                 Intent.EXTRA_USER_ID, UserHandle.myUserId());
@@ -247,6 +252,8 @@
                 mFaceManager.generateChallenge((sensorId, challenge) -> {
                     mToken = BiometricUtils.requestGatekeeperHat(getPrefContext(), data, mUserId,
                             challenge);
+                    mSensorId = sensorId;
+                    mChallenge = challenge;
                     BiometricUtils.removeGatekeeperPasswordHandle(getPrefContext(), data);
                     mAttentionController.setToken(mToken);
                     mEnrollController.setToken(mToken);
@@ -269,7 +276,7 @@
                 && !mConfirmingPassword) {
             // Revoke challenge and finish
             if (mToken != null) {
-                mFaceManager.revokeChallenge();
+                mFaceManager.revokeChallenge(mSensorId, mUserId, mChallenge);
                 mToken = null;
             }
             finish();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index b403e42..10b31e3 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -324,7 +324,9 @@
     @Override
     public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
         if (!TextUtils.isEmpty(helpString)) {
-            mErrorText.removeCallbacks(mTouchAgainRunnable);
+            if (!mCanAssumeUdfps) {
+                mErrorText.removeCallbacks(mTouchAgainRunnable);
+            }
             showError(helpString);
         }
     }
@@ -345,7 +347,9 @@
         }
         showErrorDialog(getText(msgId), errMsgId);
         stopIconAnimation();
-        mErrorText.removeCallbacks(mTouchAgainRunnable);
+        if (!mCanAssumeUdfps) {
+            mErrorText.removeCallbacks(mTouchAgainRunnable);
+        }
     }
 
     @Override
@@ -354,8 +358,10 @@
         updateTitleAndDescription();
         clearError();
         animateFlash();
-        mErrorText.removeCallbacks(mTouchAgainRunnable);
-        mErrorText.postDelayed(mTouchAgainRunnable, HINT_TIMEOUT_DURATION);
+        if (!mCanAssumeUdfps) {
+            mErrorText.removeCallbacks(mTouchAgainRunnable);
+            mErrorText.postDelayed(mTouchAgainRunnable, HINT_TIMEOUT_DURATION);
+        }
     }
 
     private void updateProgress(boolean animate) {
@@ -397,22 +403,28 @@
     }
 
     private void showError(CharSequence error) {
-        mErrorText.setText(error);
-        if (mErrorText.getVisibility() == View.INVISIBLE) {
-            mErrorText.setVisibility(View.VISIBLE);
-            mErrorText.setTranslationY(getResources().getDimensionPixelSize(
-                    R.dimen.fingerprint_error_text_appear_distance));
-            mErrorText.setAlpha(0f);
-            mErrorText.animate()
-                    .alpha(1f)
-                    .translationY(0f)
-                    .setDuration(200)
-                    .setInterpolator(mLinearOutSlowInInterpolator)
-                    .start();
+        if (mCanAssumeUdfps) {
+            setHeaderText(error);
+            // Show nothing for subtitle when getting an error message.
+            setDescriptionText("");
         } else {
-            mErrorText.animate().cancel();
-            mErrorText.setAlpha(1f);
-            mErrorText.setTranslationY(0f);
+            mErrorText.setText(error);
+            if (mErrorText.getVisibility() == View.INVISIBLE) {
+                mErrorText.setVisibility(View.VISIBLE);
+                mErrorText.setTranslationY(getResources().getDimensionPixelSize(
+                        R.dimen.fingerprint_error_text_appear_distance));
+                mErrorText.setAlpha(0f);
+                mErrorText.animate()
+                        .alpha(1f)
+                        .translationY(0f)
+                        .setDuration(200)
+                        .setInterpolator(mLinearOutSlowInInterpolator)
+                        .start();
+            } else {
+                mErrorText.animate().cancel();
+                mErrorText.setAlpha(1f);
+                mErrorText.setTranslationY(0f);
+            }
         }
         if (isResumed()) {
             mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
@@ -420,7 +432,7 @@
     }
 
     private void clearError() {
-        if (mErrorText.getVisibility() == View.VISIBLE) {
+        if (!mCanAssumeUdfps && mErrorText.getVisibility() == View.VISIBLE) {
             mErrorText.animate()
                     .alpha(0f)
                     .translationY(getResources().getDimensionPixelSize(
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 094336a..94eb278 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -81,6 +81,8 @@
         if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
             final FingerprintManager fpm = getSystemService(FingerprintManager.class);
             fpm.generateChallenge(mUserId, (sensorId, challenge) -> {
+                mChallenge = challenge;
+                mSensorId = sensorId;
                 mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
                 BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
 
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 481da1b..a989eef 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -141,7 +141,7 @@
     private void postEnroll() {
         final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
         if (fpm != null) {
-            fpm.revokeChallenge(mUserId);
+            fpm.revokeChallenge(mUserId, mChallenge);
         }
     }
 
@@ -151,6 +151,7 @@
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
         intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
+        intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
         startActivity(intent);
     }
 
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 1d2793a..3e0591f 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -138,6 +138,8 @@
         private CharSequence mFooterTitle;
         private boolean mEnrollClicked;
 
+        private long mChallenge;
+
         private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar";
         private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar";
         private FingerprintAuthenticateSidecar mAuthenticateSidecar;
@@ -287,6 +289,8 @@
 
             mToken = getIntent().getByteArrayExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
+            mChallenge = activity.getIntent()
+                    .getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, -1L);
 
             mAuthenticateSidecar = (FingerprintAuthenticateSidecar)
                     getFragmentManager().findFragmentByTag(TAG_AUTHENTICATE_SIDECAR);
@@ -577,6 +581,7 @@
                         mFingerprintManager.generateChallenge(mUserId, (sensorId, challenge) -> {
                             mToken = BiometricUtils.requestGatekeeperHat(getActivity(), data,
                                     mUserId, challenge);
+                            mChallenge = challenge;
                             BiometricUtils.removeGatekeeperPasswordHandle(getActivity(), data);
                             updateAddPreference();
                         });
@@ -602,7 +607,7 @@
         public void onDestroy() {
             super.onDestroy();
             if (getActivity().isFinishing()) {
-                mFingerprintManager.revokeChallenge(mUserId);
+                mFingerprintManager.revokeChallenge(mUserId, mChallenge);
             }
         }
 
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
index 394b673..5f2fbb5 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
@@ -40,6 +40,8 @@
     protected Intent getFingerprintEnrollingIntent() {
         Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
+        intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+        intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
         if (mUserId != UserHandle.USER_NULL) {
             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
         }
diff --git a/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java b/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java
index bbfbb19..1a45640 100644
--- a/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java
+++ b/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceController.java
@@ -31,7 +31,7 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.TogglePreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -43,7 +43,7 @@
  * screen.
  */
 public class LocationTimeZoneDetectionPreferenceController
-        extends BasePreferenceController
+        extends TogglePreferenceController
         implements LifecycleObserver, OnStart, OnStop, TimeManager.TimeZoneDetectorListener {
 
     private final TimeManager mTimeManager;
@@ -58,6 +58,22 @@
     }
 
     @Override
+    public boolean isChecked() {
+        TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
+                mTimeManager.getTimeZoneCapabilitiesAndConfig();
+        TimeZoneConfiguration configuration = capabilitiesAndConfig.getConfiguration();
+        return configuration.isGeoDetectionEnabled();
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
+                .setGeoDetectionEnabled(isChecked)
+                .build();
+        return mTimeManager.updateTimeZoneConfiguration(configuration);
+    }
+
+    @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
@@ -126,10 +142,10 @@
                 summaryResId = R.string.location_time_zone_detection_not_applicable;
             }
         } else if (configureGeoDetectionEnabledCapability == CAPABILITY_POSSESSED) {
-            boolean isGeoDetectionEnabled = configuration.isGeoDetectionEnabled();
-            summaryResId = isGeoDetectionEnabled
-                    ? R.string.location_time_zone_detection_on
-                    : R.string.location_time_zone_detection_off;
+            // If capability is possessed, toggle status already tells all the information needed.
+            // Returning null will make previous text stick on toggling.
+            // See AbstractPreferenceController#refreshSummary.
+            return "";
         } else {
             // This is unexpected: getAvailabilityStatus() should ensure that the UI element isn't
             // even shown for known cases, or the capability is unknown.
diff --git a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettings.java b/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettings.java
deleted file mode 100644
index db6ffc4..0000000
--- a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettings.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.datetime.locationtimezone;
-
-import android.app.settings.SettingsEnums;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.SearchIndexable;
-
-/**
- * The controller for the "location time zone detection" screen.
- */
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
-public class TimeZoneDetectionSettings extends DashboardFragment {
-    private static final String TAG = "LTZDetectionSettings";
-
-    @Override
-    public int getMetricsCategory() {
-        return SettingsEnums.LOCATION_TIME_ZONE_DETECTION;
-    }
-
-    @Override
-    protected int getPreferenceScreenResId() {
-        return R.xml.location_time_zone_detection;
-    }
-
-    @Override
-    protected String getLogTag() {
-        return TAG;
-    }
-
-    /**
-     * For Search.
-     */
-    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider(R.xml.location_time_zone_detection);
-}
diff --git a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceController.java b/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceController.java
deleted file mode 100644
index c91be7f..0000000
--- a/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceController.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.datetime.locationtimezone;
-
-import android.app.time.TimeManager;
-import android.app.time.TimeZoneCapabilitiesAndConfig;
-import android.app.time.TimeZoneConfiguration;
-import android.content.Context;
-
-import com.android.settings.core.TogglePreferenceController;
-
-/**
- * The controller for the "location time zone detection" switch on the location time zone detection
- * screen.
- */
-public class TimeZoneDetectionTogglePreferenceController extends TogglePreferenceController {
-
-    private final TimeManager mTimeManager;
-
-    public TimeZoneDetectionTogglePreferenceController(Context context, String key) {
-        super(context, key);
-        mTimeManager = context.getSystemService(TimeManager.class);
-    }
-
-    @Override
-    public int getAvailabilityStatus() {
-        return AVAILABLE;
-    }
-
-    @Override
-    public boolean isChecked() {
-        TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
-                mTimeManager.getTimeZoneCapabilitiesAndConfig();
-        TimeZoneConfiguration configuration = capabilitiesAndConfig.getConfiguration();
-        return configuration.isGeoDetectionEnabled();
-    }
-
-    @Override
-    public boolean setChecked(boolean isChecked) {
-        TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
-                .setGeoDetectionEnabled(isChecked)
-                .build();
-        return mTimeManager.updateTimeZoneConfiguration(configuration);
-    }
-}
diff --git a/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
index 1110ad2..0d21e9c 100644
--- a/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
+++ b/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
@@ -23,11 +23,11 @@
 import android.content.pm.PackageManager;
 import android.net.Uri;
 
-import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
+import com.android.settingslib.widget.BannerMessagePreference;
 
 /**
  * The controller of Screen attention's permission warning preference. The preference appears when
@@ -35,8 +35,8 @@
  */
 public class AdaptiveSleepPermissionPreferenceController {
     @VisibleForTesting
-    Preference mPreference;
-    private PackageManager mPackageManager;
+    BannerMessagePreference mPreference;
+    private final PackageManager mPackageManager;
 
     public AdaptiveSleepPermissionPreferenceController(Context context) {
         final String packageName = context.getPackageManager().getAttentionServicePackageName();
@@ -44,13 +44,12 @@
         final Intent intent = new Intent(
                 android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
         intent.setData(Uri.parse("package:" + packageName));
-        mPreference = new Preference(context);
+        mPreference = new BannerMessagePreference(context);
         mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
         mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
-        mPreference.setIcon(R.drawable.ic_info_outline_24);
-        mPreference.setOnPreferenceClickListener(p -> {
+        mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
+        mPreference.setPositiveButtonOnClickListener(p -> {
             context.startActivity(intent);
-            return true;
         });
     }
 
diff --git a/src/com/android/settings/display/ScreenTimeoutSettings.java b/src/com/android/settings/display/ScreenTimeoutSettings.java
index f9bb99e..3b0d333 100644
--- a/src/com/android/settings/display/ScreenTimeoutSettings.java
+++ b/src/com/android/settings/display/ScreenTimeoutSettings.java
@@ -23,7 +23,6 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
-import android.os.Bundle;
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.text.SpannableString;
@@ -39,8 +38,6 @@
 import com.android.settings.R;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.actionbar.SearchMenuController;
-import com.android.settings.support.actionbar.HelpMenuController;
 import com.android.settings.support.actionbar.HelpResourceProvider;
 import com.android.settings.widget.RadioButtonPickerFragment;
 import com.android.settingslib.RestrictedLockUtils;
@@ -92,13 +89,6 @@
     }
 
     @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        SearchMenuController.init(this /* host */);
-        HelpMenuController.init(this /* host */);
-    }
-
-    @Override
     public void onAttach(Context context) {
         super.onAttach(context);
         mInitialEntries = getResources().getStringArray(R.array.screen_timeout_entries);
diff --git a/src/com/android/settings/emergency/EmergencyActionContentProvider.java b/src/com/android/settings/emergency/EmergencyActionContentProvider.java
new file mode 100644
index 0000000..03f0faf
--- /dev/null
+++ b/src/com/android/settings/emergency/EmergencyActionContentProvider.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.emergency;
+
+import static android.telecom.TelecomManager.EXTRA_CALL_SOURCE;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Bundle;
+import android.telecom.PhoneAccount;
+import android.telecom.TelecomManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.settings.R;
+import com.android.settingslib.emergencynumber.EmergencyNumberUtils;
+
+/**
+ * ContentProvider to delegate emergency action work
+ */
+public class EmergencyActionContentProvider extends ContentProvider {
+    private static final String TAG = "EmergencyActionContentP";
+
+    private static final String ACTION_START_EMERGENCY_CALL =
+            "com.android.settings.emergency.MAKE_EMERGENCY_CALL";
+
+    @Override
+    public Bundle call(String authority, String method, String arg, Bundle extras) {
+        int uid = Binder.getCallingUid();
+        Log.d(TAG, "calling pid/uid" + Binder.getCallingPid() + "/" + uid);
+        if (!isEmergencyInfo(getContext())) {
+            throw new SecurityException("Uid is not allowed: " + uid);
+        }
+        if (!TextUtils.equals(method, ACTION_START_EMERGENCY_CALL)) {
+            throw new IllegalArgumentException("Unsupported operation");
+        }
+        placeEmergencyCall(getContext());
+        return new Bundle();
+    }
+
+    @Override
+    public boolean onCreate() {
+        return true;
+    }
+
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+            String sortOrder) {
+        return null;
+    }
+
+    @Override
+    public String getType(Uri uri) {
+        return null;
+    }
+
+    @Override
+    public Uri insert(Uri uri, ContentValues values) {
+        return null;
+    }
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+        return 0;
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+        return 0;
+    }
+
+    private static boolean isEmergencyInfo(Context context) {
+        final int callingUid = Binder.getCallingUid();
+        final String callingPackage = context.getPackageManager().getPackagesForUid(callingUid)[0];
+        return TextUtils.equals(callingPackage,
+                context.getString(R.string.config_aosp_emergency_package_name));
+    }
+
+    private static void placeEmergencyCall(Context context) {
+        if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+            Log.i(TAG, "Telephony is not supported, skipping.");
+            return;
+        }
+        Bundle extras = new Bundle();
+        extras.putBoolean(TelecomManager.EXTRA_IS_USER_INTENT_EMERGENCY_CALL, true);
+        extras.putInt(EXTRA_CALL_SOURCE, TelecomManager.CALL_SOURCE_EMERGENCY_SHORTCUT);
+        TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
+        EmergencyNumberUtils emergencyNumberUtils = new EmergencyNumberUtils(context);
+        telecomManager.placeCall(
+                Uri.fromParts(PhoneAccount.SCHEME_TEL, emergencyNumberUtils.getPoliceNumber(),
+                        /* fragment= */ null), extras);
+    }
+}
diff --git a/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java b/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java
index 43ff215..ab2c473 100644
--- a/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java
+++ b/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceController.java
@@ -49,11 +49,11 @@
         final String emergencyGestureSettingsPackageName = context.getResources().getString(
                 R.string.emergency_gesture_settings_package);
         if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
-            mUseCustomIntent = true;
-            // Use custom intent if it's configured and system can resolve it.
             final Intent intent = new Intent(ACTION_EMERGENCY_GESTURE_SETTINGS)
                     .setPackage(emergencyGestureSettingsPackageName);
             if (canResolveIntent(intent)) {
+                // Use custom intent if it's configured and system can resolve it.
+                mUseCustomIntent = true;
                 mIntent = intent;
             }
         }
diff --git a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
index 4415e71..51d74d5 100644
--- a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
@@ -21,10 +21,12 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.graphics.ColorFilter;
 import android.icu.text.NumberFormat;
 import android.os.BatteryManager;
 import android.os.PowerManager;
 import android.text.TextUtils;
+import android.widget.ImageView;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.PreferenceFragmentCompat;
@@ -60,6 +62,7 @@
     private Activity mActivity;
     private PreferenceFragmentCompat mHost;
     private Lifecycle mLifecycle;
+    private ColorFilter mAccentColorFilter;
     private final PowerManager mPowerManager;
 
     public BatteryHeaderPreferenceController(Context context, String key) {
@@ -85,6 +88,9 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mBatteryUsageProgressBarPref = screen.findPreference(getPreferenceKey());
+        mAccentColorFilter = com.android.settings.Utils.getAlphaInvariantColorFilterForColor(
+                com.android.settings.Utils.getColorAttrDefaultColor(
+                        mContext, android.R.attr.colorAccent));
 
         if (com.android.settings.Utils.isBatteryPresent(mContext)) {
             quickUpdateHeaderPreference();
@@ -116,13 +122,12 @@
     }
 
     public void updateHeaderPreference(BatteryInfo info) {
-
-        //TODO(b/179237746): Make progress bar widget support battery state icon
-
         mBatteryUsageProgressBarPref.setUsageSummary(
                 formatBatteryPercentageText(info.batteryLevel));
         mBatteryUsageProgressBarPref.setTotalSummary(generateLabel(info));
         mBatteryUsageProgressBarPref.setPercent(info.batteryLevel, BATTERY_MAX_LEVEL);
+        mBatteryUsageProgressBarPref.setCustomContent(
+                getBatteryIcon(!info.discharging, info.batteryLevel));
     }
 
     /**
@@ -139,14 +144,30 @@
         final boolean discharging =
                 batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
 
-        //TODO(b/179237746): Make progress bar widget support battery state icon
-
         mBatteryUsageProgressBarPref.setUsageSummary(formatBatteryPercentageText(batteryLevel));
         mBatteryUsageProgressBarPref.setPercent(batteryLevel, BATTERY_MAX_LEVEL);
+        mBatteryUsageProgressBarPref.setCustomContent(getBatteryIcon(!discharging, batteryLevel));
     }
 
     private CharSequence formatBatteryPercentageText(int batteryLevel) {
         return TextUtils.expandTemplate(mContext.getText(R.string.battery_header_title_alternate),
                 NumberFormat.getIntegerInstance().format(batteryLevel));
     }
+
+    //TODO(b/179237746): Update the battery icon after receiving final asset
+    private ImageView getBatteryIcon(boolean isCharging, int batteryLevel) {
+        ImageView batteryIcon = new ImageView(mContext);
+
+        if (batteryLevel <= (mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_lowBatteryWarningLevel))) {
+            batteryIcon.setImageResource(R.drawable.ic_battery_low);
+        } else if (isCharging) {
+            batteryIcon.setColorFilter(mAccentColorFilter);
+            batteryIcon.setImageResource(R.drawable.ic_battery_charging_full);
+        } else {
+            batteryIcon = null;
+        }
+
+        return batteryIcon;
+    }
 }
diff --git a/src/com/android/settings/inputmethod/OWNERS b/src/com/android/settings/inputmethod/OWNERS
index 9f33394..556de5f 100644
--- a/src/com/android/settings/inputmethod/OWNERS
+++ b/src/com/android/settings/inputmethod/OWNERS
@@ -1,5 +1,7 @@
-# Default reviewers for this and subdirectories.
-yukawa@google.com
-michaelwr@google.com
+# Bug component: 34867
+include platform/frameworks/base:/services/core/java/com/android/server/inputmethod/OWNERS
 
-# Emergency approvers in case the above are not available
\ No newline at end of file
+# Settings for physical keyboard and game pad are better to be reviewed by the input team
+per-file GameControllerPreferenceController.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
+per-file KeyboardLayoutPicker*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
+per-file PhysicalKeyboard*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index 4d6849b..803b981 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -55,6 +55,7 @@
 import androidx.preference.PreferenceScreen;
 import androidx.recyclerview.widget.RecyclerView;
 
+import com.android.settings.AirplaneModeEnabler;
 import com.android.settings.R;
 import com.android.settings.RestrictedSettingsFragment;
 import com.android.settings.core.FeatureFlags;
@@ -98,7 +99,8 @@
 public class NetworkProviderSettings extends RestrictedSettingsFragment
         implements Indexable, WifiPickerTracker.WifiPickerTrackerCallback,
         WifiDialog2.WifiDialog2Listener, DialogInterface.OnDismissListener,
-        ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback {
+        ConnectivitySubsystemsRecoveryManager.RecoveryStatusCallback,
+        AirplaneModeEnabler.OnAirplaneModeChangedListener {
 
     public static final String ACTION_NETWORK_PROVIDER_SETTINGS =
             "android.settings.NETWORK_PROVIDER_SETTINGS";
@@ -118,6 +120,7 @@
     static final int CONFIG_NETWORK_REQUEST = 3;
     static final int MANAGE_SUBSCRIPTION = 4;
 
+    private static final String PREF_KEY_AIRPLANE_MODE_MSG = "airplane_mode_message";
     private static final String PREF_KEY_EMPTY_WIFI_LIST = "wifi_empty_list";
     // TODO(b/70983952): Rename these to use WifiEntry instead of AccessPoint.
     private static final String PREF_KEY_CONNECTED_ACCESS_POINTS = "connected_access_point";
@@ -185,6 +188,8 @@
     private boolean mIsRestricted;
 
     @VisibleForTesting
+    AirplaneModeEnabler mAirplaneModeEnabler;
+    @VisibleForTesting
     WifiPickerTracker mWifiPickerTracker;
     private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
 
@@ -204,8 +209,7 @@
     @VisibleForTesting
     DataUsagePreference mDataUsagePreference;
     @VisibleForTesting
-    ViewAirplaneModeNetworksLayoutPreferenceController
-            mViewAirplaneModeNetworksButtonPreference;
+    Preference mAirplaneModeMsgPreference;
     @VisibleForTesting
     LayoutPreference mResetInternetPreference;
     @VisibleForTesting
@@ -241,6 +245,7 @@
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
+        mAirplaneModeEnabler = new AirplaneModeEnabler(getContext(), this);
 
         // TODO(b/37429702): Add animations and preference comparator back after initial screen is
         // loaded (ODR).
@@ -254,6 +259,8 @@
     private void addPreferences() {
         addPreferencesFromResource(R.xml.network_provider_settings);
 
+        mAirplaneModeMsgPreference = findPreference(PREF_KEY_AIRPLANE_MODE_MSG);
+        updateAirplaneModeMsgPreference(mAirplaneModeEnabler.isAirplaneModeOn() /* visible */);
         mConnectedWifiEntryPreferenceCategory = findPreference(PREF_KEY_CONNECTED_ACCESS_POINTS);
         mWifiEntryPreferenceCategory = findPreference(PREF_KEY_ACCESS_POINTS);
         mConfigureWifiSettingsPreference = findPreference(PREF_KEY_CONFIGURE_WIFI_SETTINGS);
@@ -269,11 +276,16 @@
             mResetInternetPreference.setVisible(false);
         }
         addNetworkMobileProviderController();
-        addViewAirplaneModeNetworksButtonController();
         addConnectedEthernetNetworkController();
         addWifiSwitchPreferenceController();
     }
 
+    private void updateAirplaneModeMsgPreference(boolean visible) {
+        if (mAirplaneModeMsgPreference != null) {
+            mAirplaneModeMsgPreference.setVisible(visible);
+        }
+    }
+
     private void addNetworkMobileProviderController() {
         if (mNetworkMobileProviderController == null) {
             mNetworkMobileProviderController = new NetworkMobileProviderController(
@@ -283,15 +295,6 @@
         mNetworkMobileProviderController.displayPreference(getPreferenceScreen());
     }
 
-    private void addViewAirplaneModeNetworksButtonController() {
-        if (mViewAirplaneModeNetworksButtonPreference == null) {
-            mViewAirplaneModeNetworksButtonPreference =
-                    new ViewAirplaneModeNetworksLayoutPreferenceController(
-                            getContext(), getSettingsLifecycle());
-        }
-        mViewAirplaneModeNetworksButtonPreference.displayPreference(getPreferenceScreen());
-    }
-
     private void addConnectedEthernetNetworkController() {
         if (mConnectedEthernetNetworkController == null) {
             mConnectedEthernetNetworkController =
@@ -386,10 +389,11 @@
     @Override
     public void onStart() {
         super.onStart();
-
         if (mIsRestricted) {
             restrictUi();
+            return;
         }
+        mAirplaneModeEnabler.start();
     }
 
     private void restrictUi() {
@@ -419,6 +423,7 @@
     public void onStop() {
         getView().removeCallbacks(mUpdateWifiEntryPreferencesRunnable);
         getView().removeCallbacks(mHideProgressBarRunnable);
+        mAirplaneModeEnabler.stop();
         super.onStop();
     }
 
@@ -1188,9 +1193,7 @@
         if (mResetInternetPreference != null) {
             mResetInternetPreference.setVisible(true);
         }
-        if (mViewAirplaneModeNetworksButtonPreference != null) {
-            mViewAirplaneModeNetworksButtonPreference.setVisible(false);
-        }
+        updateAirplaneModeMsgPreference(false /* visible */);
     }
 
     /**
@@ -1200,9 +1203,18 @@
         if (mResetInternetPreference != null) {
             mResetInternetPreference.setVisible(false);
         }
-        if (mViewAirplaneModeNetworksButtonPreference != null
-                && mViewAirplaneModeNetworksButtonPreference.isAvailable()) {
-            mViewAirplaneModeNetworksButtonPreference.setVisible(true);
+        if (mAirplaneModeEnabler.isAirplaneModeOn()) {
+            updateAirplaneModeMsgPreference(true /* visible */);
         }
     }
+
+    /**
+     * Called when airplane mode status is changed.
+     *
+     * @param isAirplaneModeOn The airplane mode is on
+     */
+    @Override
+    public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
+        updateAirplaneModeMsgPreference(isAirplaneModeOn /* visible */);
+    }
 }
diff --git a/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceController.java b/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceController.java
deleted file mode 100644
index 923e773..0000000
--- a/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceController.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.network;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.wifi.WifiManager;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.AirplaneModeEnabler;
-import com.android.settings.R;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.widget.LayoutPreference;
-
-/**
- * This controls the airplane mode message and click button of the "View airplane mode networks"
- * item on the Network & internet page.
- */
-public class ViewAirplaneModeNetworksLayoutPreferenceController extends AbstractPreferenceController
-        implements LifecycleObserver, AirplaneModeEnabler.OnAirplaneModeChangedListener,
-        View.OnClickListener {
-
-    public static final String KEY = "view_airplane_mode_netwokrs_button";
-
-    private LayoutPreference mPreference;
-    @VisibleForTesting
-    TextView mTextView;
-    @VisibleForTesting
-    Button mButton;
-
-    private AirplaneModeEnabler mAirplaneModeEnabler;
-    private final WifiManager mWifiManager;
-    private final IntentFilter mIntentFilter;
-    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
-                refreshLayout();
-            }
-        }
-    };
-
-    public ViewAirplaneModeNetworksLayoutPreferenceController(Context context,
-            Lifecycle lifecycle) {
-        super(context);
-        if (lifecycle == null) {
-            throw new IllegalArgumentException("Lifecycle must be set");
-        }
-        mAirplaneModeEnabler = new AirplaneModeEnabler(context, this);
-        mWifiManager = context.getSystemService(WifiManager.class);
-        mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
-        lifecycle.addObserver(this);
-    }
-
-    @Override
-    public boolean isAvailable() {
-        return mAirplaneModeEnabler.isAirplaneModeOn();
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return KEY;
-    }
-
-    @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mPreference = screen.findPreference(getPreferenceKey());
-        generateLayout();
-    }
-
-    /** Lifecycle.Event.ON_START */
-    @OnLifecycleEvent(Lifecycle.Event.ON_START)
-    public void onStart() {
-        mAirplaneModeEnabler.start();
-    }
-
-    /** Lifecycle.Event.ON_STOP */
-    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
-    public void onStop() {
-        mAirplaneModeEnabler.stop();
-    }
-
-    /** Lifecycle.Event.ON_RESUME */
-    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
-    public void onResume() {
-        mContext.registerReceiver(mBroadcastReceiver, mIntentFilter);
-    }
-
-    /** Lifecycle.Event.ON_PAUSE */
-    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
-    public void onPause() {
-        mContext.unregisterReceiver(mBroadcastReceiver);
-    }
-
-    @Override
-    public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
-        if (mPreference != null) {
-            mPreference.setVisible(isAirplaneModeOn);
-        }
-    }
-
-    @Override
-    public void onClick(View v) {
-        mWifiManager.setWifiEnabled(true);
-    }
-
-    private void generateLayout() {
-        if (mPreference == null) {
-            return;
-        }
-        if (mTextView == null) {
-            mTextView = mPreference.findViewById(R.id.airplane_mode_text);
-        }
-        if (mButton == null) {
-            mButton = mPreference.findViewById(R.id.view_airplane_mode_networks_button);
-        }
-        if (mButton != null) {
-            mButton.setOnClickListener(this);
-        }
-        refreshLayout();
-    }
-
-    @VisibleForTesting
-    void refreshLayout() {
-        boolean isWifiEnabled = mWifiManager.isWifiEnabled();
-        if (mTextView != null) {
-            mTextView.setText(isWifiEnabled ? R.string.viewing_airplane_mode_networks
-                    : R.string.condition_airplane_title);
-        }
-        if (mButton != null) {
-            mButton.setVisibility(isWifiEnabled ? View.GONE : View.VISIBLE);
-        }
-    }
-
-    /**
-     * Sets the visibility of the preference.
-     */
-    public void setVisible(boolean visible) {
-        if (mPreference != null) {
-            mPreference.setVisible(visible);
-        }
-    }
-}
diff --git a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
index 8d037fb..d00efc7 100644
--- a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
@@ -106,7 +106,7 @@
             return false;
         }
         try {
-            return imsMmTelMgr.isCrossSimCallingEnabledByUser();
+            return imsMmTelMgr.isCrossSimCallingEnabled();
         } catch (ImsException exception) {
             Log.w(LOG_TAG, "fail to get cross SIM calling configuration", exception);
         }
diff --git a/src/com/android/settings/widget/LabeledSeekBarPreference.java b/src/com/android/settings/widget/LabeledSeekBarPreference.java
index e2b2d68..3a9ac18 100644
--- a/src/com/android/settings/widget/LabeledSeekBarPreference.java
+++ b/src/com/android/settings/widget/LabeledSeekBarPreference.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.widget.SeekBar;
 import android.widget.TextView;
@@ -32,6 +33,7 @@
 
     private final int mTextStartId;
     private final int mTextEndId;
+    private final int mTickMarkId;
     private OnPreferenceChangeListener mStopListener;
 
     public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
@@ -48,6 +50,8 @@
         mTextEndId = styledAttrs.getResourceId(
                 R.styleable.LabeledSeekBarPreference_textEnd,
                 R.string.summary_placeholder);
+        mTickMarkId = styledAttrs.getResourceId(
+                R.styleable.LabeledSeekBarPreference_tickMark, /* defValue= */ 0);
         styledAttrs.recycle();
     }
 
@@ -65,6 +69,13 @@
         final TextView endText = (TextView) holder.findViewById(android.R.id.text2);
         startText.setText(mTextStartId);
         endText.setText(mTextEndId);
+
+        if (mTickMarkId != 0) {
+            final Drawable tickMark = getContext().getDrawable(mTickMarkId);
+            final SeekBar seekBar = (SeekBar) holder.findViewById(
+                    com.android.internal.R.id.seekbar);
+            seekBar.setTickMark(tickMark);
+        }
     }
 
     public void setOnPreferenceChangeStopListener(OnPreferenceChangeListener listener) {
diff --git a/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java
index 0758869..ae200b9 100644
--- a/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/LocationTimeZoneDetectionPreferenceControllerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.time.TimeManager;
@@ -62,9 +63,33 @@
     }
 
     @Test
+    public void setChecked_withTrue_shouldUpdateSetting() {
+        // Simulate the UI being clicked.
+        mController.setChecked(true);
+
+        // Verify the TimeManager was updated with the UI value.
+        TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
+                .setGeoDetectionEnabled(true)
+                .build();
+        verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
+    }
+
+    @Test
+    public void setChecked_withFalse_shouldUpdateSetting() {
+        // Simulate the UI being clicked.
+        mController.setChecked(false);
+
+        // Verify the TimeManager was updated with the UI value.
+        TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
+                .setGeoDetectionEnabled(false)
+                .build();
+        verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
+    }
+
+    @Test
     public void testLocationTimeZoneDetection_supported_shouldBeShown() {
         TimeZoneCapabilities capabilities =
-                createTimeZoneCapabilities(/* geoDetectionSupported= */ true);
+                createTimeZoneCapabilities(CAPABILITY_POSSESSED);
         TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
         TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
                 new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
@@ -76,7 +101,7 @@
     @Test
     public void testLocationTimeZoneDetection_unsupported_shouldNotBeShown() {
         TimeZoneCapabilities capabilities =
-                createTimeZoneCapabilities(/* geoDetectionSupported= */ false);
+                createTimeZoneCapabilities(CAPABILITY_NOT_SUPPORTED);
         TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
         TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
                 new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
@@ -91,20 +116,34 @@
     @Test
     public void testLocationTimeZoneDetection_summary_geoDetectionEnabled() {
         TimeZoneCapabilities capabilities =
-                createTimeZoneCapabilities(/* geoDetectionSupported= */ true);
+                createTimeZoneCapabilities(CAPABILITY_POSSESSED);
         TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
         TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
                 new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
 
         when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
-        assertThat(mController.getSummary()).isEqualTo(
-                mContext.getString(R.string.location_time_zone_detection_on));
+        assertThat(mController.getSummary().toString()).isEmpty();
     }
 
-    private static TimeZoneCapabilities createTimeZoneCapabilities(boolean geoDetectionSupported) {
+    @Test
+    public void testLocationTimeZoneDetection_toggleIsOn_whenGeoDetectionEnabledAnsMlsIsOff() {
+        TimeZoneCapabilities capabilities =
+                createTimeZoneCapabilities(CAPABILITY_NOT_APPLICABLE);
+        TimeZoneConfiguration configuration = createTimeZoneConfig(/* geoDetectionEnabled= */ true);
+        TimeZoneCapabilitiesAndConfig capabilitiesAndConfig =
+                new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
+
+        when(mTimeManager.getTimeZoneCapabilitiesAndConfig()).thenReturn(capabilitiesAndConfig);
+        when(mLocationManager.isLocationEnabled()).thenReturn(false);
+
+        assertThat(mController.isChecked()).isTrue();
+        assertThat(mController.getSummary()).isEqualTo(
+                mContext.getString(R.string.location_app_permission_summary_location_off));
+    }
+
+    private static TimeZoneCapabilities createTimeZoneCapabilities(
+            @TimeZoneCapabilities.CapabilityState int geoDetectionCapability) {
         UserHandle arbitraryUserHandle = UserHandle.of(123);
-        int geoDetectionCapability =
-                geoDetectionSupported ? CAPABILITY_POSSESSED : CAPABILITY_NOT_SUPPORTED;
         return new TimeZoneCapabilities.Builder(arbitraryUserHandle)
                 .setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED)
                 .setConfigureGeoDetectionEnabledCapability(geoDetectionCapability)
diff --git a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettingsTest.java b/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettingsTest.java
deleted file mode 100644
index 9f16492..0000000
--- a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionSettingsTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.datetime.locationtimezone;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class TimeZoneDetectionSettingsTest {
-
-    private Context mContext;
-
-    @Before
-    public void setUp() {
-        mContext = RuntimeEnvironment.application;
-    }
-
-    @Test
-    public void searchProvider_shouldIndexDefaultXml() {
-        final List<SearchIndexableResource> sir =
-                TimeZoneDetectionSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
-                        mContext, /* enabled= */ true);
-
-        assertThat(sir).hasSize(1);
-        assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.location_time_zone_detection);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceControllerTest.java
deleted file mode 100644
index 27a9859..0000000
--- a/tests/robotests/src/com/android/settings/datetime/locationtimezone/TimeZoneDetectionTogglePreferenceControllerTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.datetime.locationtimezone;
-
-import static android.app.time.TimeZoneCapabilities.CAPABILITY_NOT_APPLICABLE;
-import static android.app.time.TimeZoneCapabilities.CAPABILITY_POSSESSED;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.time.TimeManager;
-import android.app.time.TimeZoneCapabilities;
-import android.app.time.TimeZoneCapabilitiesAndConfig;
-import android.app.time.TimeZoneConfiguration;
-import android.content.Context;
-import android.os.UserHandle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-
-@RunWith(RobolectricTestRunner.class)
-public class TimeZoneDetectionTogglePreferenceControllerTest {
-
-    private static final String PREF_KEY = "test_key";
-
-    @Mock
-    private Context mContext;
-
-    @Mock
-    private TimeManager mTimeManager;
-    private TimeZoneDetectionTogglePreferenceController mController;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        when(mContext.getSystemService(TimeManager.class)).thenReturn(mTimeManager);
-
-        mController = new TimeZoneDetectionTogglePreferenceController(mContext, PREF_KEY);
-    }
-
-    @Test
-    public void isAvailable_shouldReturnTrue() {
-        assertThat(mController.isAvailable()).isTrue();
-    }
-
-    @Test
-    public void isChecked_whenEnabled_shouldReturnTrue() {
-        when(mTimeManager.getTimeZoneCapabilitiesAndConfig())
-                .thenReturn(createTimeZoneCapabilitiesAndConfig(true));
-
-        assertThat(mController.isChecked()).isTrue();
-    }
-
-    @Test
-    public void isChecked_whenDisabled_shouldReturnFalse() {
-        when(mTimeManager.getTimeZoneCapabilitiesAndConfig())
-                .thenReturn(createTimeZoneCapabilitiesAndConfig(false));
-
-        assertThat(mController.isChecked()).isFalse();
-    }
-
-    @Test
-    public void setChecked_withTrue_shouldUpdateSetting() {
-        // Simulate the UI being clicked.
-        mController.setChecked(true);
-
-        // Verify the TimeManager was updated with the UI value.
-        TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
-                .setGeoDetectionEnabled(true)
-                .build();
-        verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
-    }
-
-    @Test
-    public void setChecked_withFalse_shouldUpdateSetting() {
-        // Simulate the UI being clicked.
-        mController.setChecked(false);
-
-        // Verify the TimeManager was updated with the UI value.
-        TimeZoneConfiguration expectedConfiguration = new TimeZoneConfiguration.Builder()
-                .setGeoDetectionEnabled(false)
-                .build();
-        verify(mTimeManager).updateTimeZoneConfiguration(expectedConfiguration);
-    }
-
-    private static TimeZoneCapabilitiesAndConfig createTimeZoneCapabilitiesAndConfig(
-            boolean geoDetectionEnabled) {
-        UserHandle arbitraryUserHandle = UserHandle.of(123);
-        TimeZoneCapabilities capabilities = new TimeZoneCapabilities.Builder(arbitraryUserHandle)
-                .setConfigureAutoDetectionEnabledCapability(CAPABILITY_POSSESSED)
-                .setConfigureGeoDetectionEnabledCapability(CAPABILITY_POSSESSED)
-                .setSuggestManualTimeZoneCapability(CAPABILITY_NOT_APPLICABLE)
-                .build();
-        TimeZoneConfiguration configuration = new TimeZoneConfiguration.Builder()
-                .setAutoDetectionEnabled(true)
-                .setGeoDetectionEnabled(geoDetectionEnabled)
-                .build();
-        return new TimeZoneCapabilitiesAndConfig(capabilities, configuration);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java
index 65fa187..8d38509 100644
--- a/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/emergency/EmergencyGestureEntrypointPreferenceControllerTest.java
@@ -105,7 +105,7 @@
     }
 
     @Test
-    public void getAvailabilityStatus_noSuitableIntent_shouldReturnUnsupported() {
+    public void getAvailabilityStatus_noSuitableIntent_shouldReturnAvailable() {
         SettingsShadowResources.overrideResource(
                 R.bool.config_show_emergency_gesture_settings,
                 Boolean.TRUE);
@@ -117,7 +117,8 @@
         EmergencyGestureEntrypointPreferenceController controller =
                 new EmergencyGestureEntrypointPreferenceController(mContext, PREF_KEY);
 
-        assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+        assertThat(controller.mIntent).isNull();
     }
 
     private void prepareCustomIntent() {
diff --git a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
index aa96666..d7c0ffe 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
@@ -54,6 +54,7 @@
 import androidx.preference.PreferenceScreen;
 import androidx.recyclerview.widget.RecyclerView;
 
+import com.android.settings.AirplaneModeEnabler;
 import com.android.settings.R;
 import com.android.settings.datausage.DataUsagePreference;
 import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
@@ -90,6 +91,8 @@
     @Mock
     private UserManager mUserManager;
     @Mock
+    private AirplaneModeEnabler mAirplaneModeEnabler;
+    @Mock
     private DataUsagePreference mDataUsagePreference;
     private Context mContext;
     private NetworkProviderSettings mNetworkProviderSettings;
@@ -100,8 +103,7 @@
     @Mock
     private ConnectivitySubsystemsRecoveryManager mConnectivitySubsystemsRecoveryManager;
     @Mock
-    private ViewAirplaneModeNetworksLayoutPreferenceController
-            mViewAirplaneModeNetworksButtonPreference;
+    private Preference mAirplaneModeMsgPreference;
     @Mock
     private LayoutPreference mResetInternetPreference;
     @Mock
@@ -126,6 +128,9 @@
                 new Preference(mContext);
         mNetworkProviderSettings.mWifiPickerTracker = mMockWifiPickerTracker;
         mNetworkProviderSettings.mWifiManager = mWifiManager;
+        mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
+        mNetworkProviderSettings.mAirplaneModeMsgPreference = mAirplaneModeMsgPreference;
+        mNetworkProviderSettings.mAirplaneModeEnabler = mAirplaneModeEnabler;
     }
 
     @Test
@@ -421,27 +426,35 @@
     }
 
     @Test
-    public void onSubsystemRestartOperationBegin_showResetInternetHideApmNetworks() {
-        mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
-        mNetworkProviderSettings.mViewAirplaneModeNetworksButtonPreference =
-                mViewAirplaneModeNetworksButtonPreference;
-
+    public void onSubsystemRestartOperationBegin_showResetInternetHideApmMsg() {
         mNetworkProviderSettings.onSubsystemRestartOperationBegin();
 
         verify(mResetInternetPreference).setVisible(true);
-        verify(mViewAirplaneModeNetworksButtonPreference).setVisible(false);
+        verify(mAirplaneModeMsgPreference).setVisible(false);
     }
 
     @Test
-    public void onSubsystemRestartOperationEnd_showApmNetworksHideResetInternet() {
-        mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
-        mNetworkProviderSettings.mViewAirplaneModeNetworksButtonPreference =
-                mViewAirplaneModeNetworksButtonPreference;
-        doReturn(true).when(mViewAirplaneModeNetworksButtonPreference).isAvailable();
+    public void onSubsystemRestartOperationEnd_showApmMsgHideResetInternet() {
+        doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
 
         mNetworkProviderSettings.onSubsystemRestartOperationEnd();
 
         verify(mResetInternetPreference).setVisible(false);
-        verify(mViewAirplaneModeNetworksButtonPreference).setVisible(true);
+        verify(mAirplaneModeMsgPreference).setVisible(true);
+    }
+
+    @Test
+    public void onAirplaneModeChanged_apmIsOn_showApmMsg() {
+        mNetworkProviderSettings.onAirplaneModeChanged(true);
+
+        verify(mAirplaneModeMsgPreference).setVisible(true);
+    }
+
+
+    @Test
+    public void onAirplaneModeChanged_apmIsOff_hideApmMsg() {
+        mNetworkProviderSettings.onAirplaneModeChanged(false);
+
+        verify(mAirplaneModeMsgPreference).setVisible(false);
     }
 }
diff --git a/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java
new file mode 100644
index 0000000..216658f
--- /dev/null
+++ b/tests/unit/src/com/android/settings/applications/autofill/PasswordsPreferenceControllerTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications.autofill;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.Looper;
+import android.service.autofill.AutofillServiceInfo;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.google.android.collect.Lists;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Collections;
+import java.util.List;
+
+@RunWith(AndroidJUnit4.class)
+public class PasswordsPreferenceControllerTest {
+
+    private Context mContext;
+    private PreferenceScreen mScreen;
+    private PreferenceCategory mPasswordsPreferenceCategory;
+
+    @Before
+    public void setUp() {
+        mContext = ApplicationProvider.getApplicationContext();
+        if (Looper.myLooper() == null) {
+            Looper.prepare(); // needed to create the preference screen
+        }
+        mScreen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
+        mPasswordsPreferenceCategory = new PreferenceCategory(mContext);
+        mPasswordsPreferenceCategory.setKey("passwords");
+        mScreen.addPreference(mPasswordsPreferenceCategory);
+    }
+
+    @Test
+    public void getAvailabilityStatus_noServices_returnsUnavailable() {
+        PasswordsPreferenceController controller =
+                createControllerWithServices(Collections.emptyList());
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_noPasswords_returnsUnavailable() {
+        AutofillServiceInfo service = new AutofillServiceInfo.TestDataBuilder().build();
+        PasswordsPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(service));
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_withPasswords_returnsAvailable() {
+        PasswordsPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(createServiceWithPasswords()));
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+
+    @Test
+    public void displayPreference_noServices_noPreferencesAdded() {
+        PasswordsPreferenceController controller =
+                createControllerWithServices(Collections.emptyList());
+        controller.displayPreference(mScreen);
+        assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
+    }
+
+    @Test
+    public void displayPreference_noPasswords_noPreferencesAdded() {
+        AutofillServiceInfo service = new AutofillServiceInfo.TestDataBuilder().build();
+        PasswordsPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(service));
+        controller.displayPreference(mScreen);
+        assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
+    }
+
+    @Test
+    public void displayPreference_withPasswords_addsPreference() {
+        AutofillServiceInfo service = createServiceWithPasswords();
+        PasswordsPreferenceController controller =
+                createControllerWithServices(Lists.newArrayList(service));
+        controller.displayPreference(mScreen);
+
+        assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+        Preference pref = mPasswordsPreferenceCategory.getPreference(0);
+        assertThat(pref.getIcon()).isNotNull();
+        assertThat(pref.getIntent().getComponent())
+                .isEqualTo(
+                        new ComponentName(
+                                service.getServiceInfo().packageName,
+                                service.getPasswordsActivity()));
+    }
+
+    private PasswordsPreferenceController createControllerWithServices(
+            List<AutofillServiceInfo> availableServices) {
+        return new PasswordsPreferenceController(
+                mContext, mPasswordsPreferenceCategory.getKey(), availableServices);
+    }
+
+    private AutofillServiceInfo createServiceWithPasswords() {
+        return new AutofillServiceInfo.TestDataBuilder()
+                .setPasswordsActivity("com.android.test.Passwords")
+                .build();
+    }
+}
diff --git a/tests/unit/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceControllerTest.java
deleted file mode 100644
index 972e3fb..0000000
--- a/tests/unit/src/com/android/settings/network/ViewAirplaneModeNetworksLayoutPreferenceControllerTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.network;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.os.Looper;
-import android.view.View;
-
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.settings.testutils.AirplaneModeRule;
-import com.android.settings.testutils.ResourcesUtils;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.widget.LayoutPreference;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-@RunWith(AndroidJUnit4.class)
-public class ViewAirplaneModeNetworksLayoutPreferenceControllerTest {
-
-    private static final String KEY = ViewAirplaneModeNetworksLayoutPreferenceController.KEY;
-    private static final String RES_ID_AIRPLANE_MODE_IS_ON = "condition_airplane_title";
-    private static final String RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS =
-            "viewing_airplane_mode_networks";
-
-    @Rule
-    public final MockitoRule mMockitoRule = MockitoJUnit.rule();
-    @Rule
-    public AirplaneModeRule mAirplaneModeRule = new AirplaneModeRule();
-    @Mock
-    private WifiManager mWifiManager;
-
-    private Context mContext;
-    private PreferenceScreen mScreen;
-    private LayoutPreference mPreference;
-    private ViewAirplaneModeNetworksLayoutPreferenceController mController;
-
-    @Before
-    public void setUp() {
-        mContext = spy(ApplicationProvider.getApplicationContext());
-        doReturn(mWifiManager).when(mContext).getSystemService(Context.WIFI_SERVICE);
-
-        mController = new ViewAirplaneModeNetworksLayoutPreferenceController(mContext,
-                mock(Lifecycle.class));
-        if (Looper.myLooper() == null) {
-            Looper.prepare();
-        }
-        final PreferenceManager preferenceManager = new PreferenceManager(mContext);
-        mScreen = preferenceManager.createPreferenceScreen(mContext);
-        mPreference = new LayoutPreference(mContext,
-                ResourcesUtils.getResourcesId(
-                        mContext, "layout", "view_airplane_mode_networks_button"));
-        mPreference.setKey(KEY);
-        mScreen.addPreference(mPreference);
-    }
-
-    @Test
-    public void isAvailable_airplaneModeOff_returnFalse() {
-        mAirplaneModeRule.setAirplaneMode(false);
-
-        assertThat(mController.isAvailable()).isFalse();
-    }
-
-    @Test
-    public void isAvailable_airplaneModeOn_returnTrue() {
-        mAirplaneModeRule.setAirplaneMode(true);
-
-        assertThat(mController.isAvailable()).isTrue();
-    }
-
-    @Test
-    public void displayPreference_wifiDisabled_showAirplaneModeIsOnButtonVisible() {
-        mAirplaneModeRule.setAirplaneMode(true);
-        doReturn(false).when(mWifiManager).isWifiEnabled();
-
-        mController.displayPreference(mScreen);
-
-        assertThat(mController.mTextView.getText())
-                .isEqualTo(ResourcesUtils.getResourcesString(mContext, RES_ID_AIRPLANE_MODE_IS_ON));
-        assertThat(mController.mButton.getVisibility()).isEqualTo(View.VISIBLE);
-    }
-
-    @Test
-    public void displayPreference_wifiEnabled_showViewingAirplaneModeNetworksButtonGone() {
-        mAirplaneModeRule.setAirplaneMode(true);
-        doReturn(true).when(mWifiManager).isWifiEnabled();
-
-        mController.displayPreference(mScreen);
-
-        assertThat(mController.mTextView.getText()).isEqualTo(
-                ResourcesUtils.getResourcesString(mContext, RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS));
-        assertThat(mController.mButton.getVisibility()).isEqualTo(View.GONE);
-    }
-
-    @Test
-    public void refreshLayout_wifiEnabledThenDisabled_showAirplaneModeIsOnButtonVisible() {
-        mAirplaneModeRule.setAirplaneMode(true);
-        // Wi-Fi enabled
-        doReturn(true).when(mWifiManager).isWifiEnabled();
-        // Display preference
-        mController.displayPreference(mScreen);
-        // Then Wi-Fi disabled
-        doReturn(false).when(mWifiManager).isWifiEnabled();
-
-        // Refresh layout
-        mController.refreshLayout();
-
-        assertThat(mController.mTextView.getText())
-                .isEqualTo(ResourcesUtils.getResourcesString(mContext, RES_ID_AIRPLANE_MODE_IS_ON));
-        assertThat(mController.mButton.getVisibility()).isEqualTo(View.VISIBLE);
-    }
-
-    @Test
-    public void refreshLayout_wifiDisabledThenEnabled_showViewingAirplaneModeNetworksButtonGone() {
-        mAirplaneModeRule.setAirplaneMode(true);
-        // Wi-Fi disabled
-        doReturn(false).when(mWifiManager).isWifiEnabled();
-        // Display preference
-        mController.displayPreference(mScreen);
-        // Then Wi-Fi enabled
-        doReturn(true).when(mWifiManager).isWifiEnabled();
-
-        // Refresh layout
-        mController.refreshLayout();
-
-        assertThat(mController.mTextView.getText()).isEqualTo(
-                ResourcesUtils.getResourcesString(mContext, RES_ID_VIEWING_AIRPLANE_MODE_NETWORKS));
-        assertThat(mController.mButton.getVisibility()).isEqualTo(View.GONE);
-    }
-
-    @Test
-    public void onClick_shouldSetWifiEnabled() {
-        mAirplaneModeRule.setAirplaneMode(true);
-        doReturn(false).when(mWifiManager).isWifiEnabled();
-
-        mController.onClick(mock(View.class));
-
-        verify(mWifiManager).setWifiEnabled(true);
-    }
-}