Merge "Change string of switchbar and installed service category title"
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 8e1ab2b..883e968 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -3,3 +3,4 @@
 
 strings_lint_hook = ${REPO_ROOT}/frameworks/base/tools/stringslint/stringslint_sha.sh ${PREUPLOAD_COMMIT}
 
+checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
diff --git a/res/drawable/ic_suggestion_close_button.xml b/res/drawable/ic_suggestion_close_button.xml
index 615b215..8b1f0f8 100644
--- a/res/drawable/ic_suggestion_close_button.xml
+++ b/res/drawable/ic_suggestion_close_button.xml
@@ -18,8 +18,10 @@
         android:width="24dp"
         android:height="24dp"
         android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorControlNormal">
+
     <path
-        android:fillColor="#FF000000"
+        android:fillColor="@android:color/white"
         android:pathData="M18.3,5.71a0.996,0.996 0,0 0,-1.41 0L12,10.59 7.11,5.7A0.996,0.996 0,1 0,5.7 7.11L10.59,12 5.7,16.89a0.996,0.996 0,1 0,1.41 1.41L12,13.41l4.89,4.89a0.996,0.996 0,1 0,1.41 -1.41L13.41,12l4.89,-4.89c0.38,-0.38 0.38,-1.02 0,-1.4z"/>
 </vector>
diff --git a/res/layout/profile_select_tablayout.xml b/res/layout/profile_select_tablayout.xml
new file mode 100644
index 0000000..afacaae
--- /dev/null
+++ b/res/layout/profile_select_tablayout.xml
@@ -0,0 +1,42 @@
+<!--
+  Copyright (C) 2019 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:theme="@style/Theme.MaterialComponents.DayNight"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <androidx.viewpager.widget.ViewPager
+        android:id="@+id/view_pager"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <com.google.android.material.tabs.TabLayout
+            android:background="@android:color/transparent"
+            android:id="@+id/tabs"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:tabMaxWidth="0dp"
+            app:tabGravity="fill"
+            app:tabMode="fixed"
+            app:tabIndicatorColor="@*android:color/accent_device_default"
+            app:tabSelectedTextColor="@*android:color/accent_device_default"
+            app:tabTextColor="?android:attr/textColorSecondary" />
+    </androidx.viewpager.widget.ViewPager>
+</LinearLayout>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index c9460dd..75205e9 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1254,7 +1254,7 @@
         <item>LTE/TDSCDMA/CDMA/EVDO/GSM/WCDMA</item>
         <item>NR only</item>
         <item>NR/LTE</item>
-        <item>NR/LTE/CDME/EvDo</item>
+        <item>NR/LTE/CDMA/EvDo</item>
         <item>NR/LTE/GSM/WCDMA</item>
         <item>NR/LTE/CDMA/EvDo/GSM/WCDMA</item>
         <item>NR/LTE/WCDMA</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bdb2e57..7f6ea05 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -554,11 +554,11 @@
     <!-- mobile network settings screen, button on dialog box that appears when you are roaming and clear the "Data roaming" check box -->
     <string name="roaming_turn_it_on_button">Turn it on</string>
     <!-- mobile network settings screen, message in dialog box that appears when you select the "Data roaming" check box -->
-    <string name="roaming_warning">You may incur significant charges.</string>
+    <string name="roaming_warning">Roaming charges may apply.</string>
     <!-- mobile network settings screen, message in dialog box that appears when you select the "Data roaming" check box. This is for multiuser tablets [CHAR LIMIT=none] -->
-    <string name="roaming_warning_multiuser" product="tablet">When you allow data roaming, you may incur significant roaming charges!\n\nThis setting affects all users on this tablet.</string>
+    <string name="roaming_warning_multiuser" product="tablet">When you allow data roaming, roaming charges may apply.\n\nThis setting affects all users on this tablet.</string>
     <!-- mobile network settings screen, message in dialog box that appears when you select the "Data roaming" check box. This is for multiuser phones [CHAR LIMIT=none] -->
-    <string name="roaming_warning_multiuser" product="default">When you allow data roaming, you may incur significant roaming charges!\n\nThis setting affects all users on this phone.</string>
+    <string name="roaming_warning_multiuser" product="default">When you allow data roaming, roaming charges may apply.\n\nThis setting affects all users on this phone.</string>
     <!-- mobile network settings screen, title of dialog box that appears when you select the "Data roaming" check box -->
     <string name="roaming_reenable_title">Allow data roaming?</string>
     <!-- mobile network settings screen, setting option name -->
@@ -1643,7 +1643,7 @@
     <!-- Bluetooth connecting error message [CHAR LIMIT=NONE] -->
     <string name="bluetooth_connect_failed">Couldn\'t connect. Try again.</string>
 
-    <!-- Title of device details screen [CHAR LIMIT=40]-->
+    <!-- Title of device details screen [CHAR LIMIT=28]-->
     <string name="device_details_title">Device details</string>
     <!-- Title of the item to show device MAC address -->
     <string name="bluetooth_device_mac_address">Device\'s Bluetooth address: <xliff:g id="address">%1$s</xliff:g></string>
@@ -2025,7 +2025,7 @@
     <string name="wifi_ip_settings">IP settings</string>
     <!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
     <string name="wifi_privacy_settings">Privacy</string>
-    <!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=40] -->
+    <!-- Summary for Wifi MAC randomization option when it is ephemeral network [CHAR LIMIT=50] -->
     <string name="wifi_privacy_settings_ephemeral_summary">Randomized MAC</string>
     <!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50]  -->
     <string name="wifi_dpp_add_device_to_network">Add a device</string>
@@ -2208,9 +2208,9 @@
     <string name="wifi_advanced_titlebar">Advanced Wi\u2011Fi</string>
     <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's SSID. [CHAR LIMIT=20] -->
     <string name="wifi_advanced_ssid_title">SSID</string>
-    <!-- Wi-Fi settings screen, advanced, title of the item to show the factory's Wi-Fi MAC address. [CHAR LIMIT=30] -->
+    <!-- Wi-Fi settings screen, advanced, title of the item to show the factory's Wi-Fi MAC address. [CHAR LIMIT=50] -->
     <string name="wifi_advanced_factory_mac_address_title">Factory MAC address</string>
-    <!-- Wi-Fi settings screen, advanced, title of the item to show the randomized Wi-Fi MAC address. [CHAR LIMIT=30] -->
+    <!-- Wi-Fi settings screen, advanced, title of the item to show the randomized Wi-Fi MAC address. [CHAR LIMIT=50] -->
     <string name="wifi_advanced_randomized_mac_address_title">Randomized MAC address</string>
     <!-- Title of the screen to adjust IP settings -->
     <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's current IP address. -->
@@ -3037,7 +3037,7 @@
     <string name="status_operator">Network</string>
     <!-- About phone, status item title.  The MAC address of the Wi-Fi network adapter. -->
     <string name="status_wifi_mac_address">Wi\u2011Fi MAC address</string>
-    <!-- About phone, status item title.  The Factory MAC address of the Wi-Fi network adapter. [CHAR LIMIT=30] -->
+    <!-- About phone, status item title.  The Factory MAC address of the Wi-Fi network adapter. [CHAR LIMIT=50] -->
     <string name="status_factory_wifi_mac_address">Factory Wi\u2011Fi MAC address</string>
     <!-- About phone, status item title.  The bluetooth adapter's hardware address-->
     <string name="status_bt_address">Bluetooth address</string>
@@ -10732,8 +10732,8 @@
     <string name="preferred_network_mode_nr_only_summary">Preferred network mode: NR only</string>
     <!-- NR / LTE [CHAR LIMIT=NONE] -->
     <string name="preferred_network_mode_nr_lte_summary">Preferred network mode: NR / LTE</string>
-    <!-- NR/LTE/CDME/EvDo [CHAR LIMIT=NONE] -->
-    <string name="preferred_network_mode_nr_lte_cdma_evdo_summary">Preferred network mode: NR/LTE/CDME/EvDo</string>
+    <!-- NR/LTE/CDMA/EvDo [CHAR LIMIT=NONE] -->
+    <string name="preferred_network_mode_nr_lte_cdma_evdo_summary">Preferred network mode: NR/LTE/CDMA/EvDo</string>
     <!-- NR/LTE/GSM/WCDMA [CHAR LIMIT=NONE] -->
     <string name="preferred_network_mode_nr_lte_gsm_wcdma_summary">Preferred network mode: NR/LTE/GSM/WCDMA</string>
     <!-- NR/LTE/TDSCDMA/CDMA/EvDo/GSM/WCDMA [CHAR LIMIT=NONE] -->
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
new file mode 100644
index 0000000..db57e3d
--- /dev/null
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2019 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="user_and_account_settings_screen"
+    android:title="@string/account_dashboard_title"
+    settings:keywords="@string/keywords_accounts">
+
+    <PreferenceCategory
+        android:key="dashboard_tile_placeholder"
+        android:order="30"/>
+
+    <SwitchPreference
+        android:key="auto_sync_account_data"
+        android:title="@string/auto_sync_account_title"
+        android:summary="@string/auto_sync_account_summary"
+        android:order="100"
+        settings:allowDividerAbove="true"/>
+
+    <SwitchPreference
+        android:key="auto_sync_personal_account_data"
+        android:title="@string/account_settings_menu_auto_sync_personal"
+        android:summary="@string/auto_sync_account_summary"
+        android:order="110"/>
+
+</PreferenceScreen>
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
new file mode 100644
index 0000000..b27357d
--- /dev/null
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2019 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="user_and_account_settings_screen"
+    android:title="@string/account_dashboard_title"
+    settings:keywords="@string/keywords_accounts">
+
+    <PreferenceCategory
+        android:key="dashboard_tile_placeholder"
+        android:order="30"/>
+
+    <SwitchPreference
+        android:key="auto_sync_account_data"
+        android:title="@string/auto_sync_account_title"
+        android:summary="@string/auto_sync_account_summary"
+        android:order="100"
+        settings:allowDividerAbove="true"/>
+
+    <SwitchPreference
+        android:key="auto_sync_work_account_data"
+        android:title="@string/account_settings_menu_auto_sync_work"
+        android:summary="@string/auto_sync_account_summary"
+        android:order="110"/>
+
+</PreferenceScreen>
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index af1fe20..1b08a5c 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -137,6 +137,9 @@
         <Preference
             android:key="carrier_settings_version_key"
             android:title="@string/carrier_settings_version"
+            android:enabled="false"
+            android:shouldDisableView="false"
+            android:selectable="false"
             settings:controller="com.android.settings.network.telephony.CarrierSettingsVersionPreferenceController"
             settings:enableCopying="true"/>
 
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 05054b4..604333f 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -727,7 +727,7 @@
         public void onPatternDetected(List<LockPatternView.Cell> pattern) {
             mLockPatternView.setEnabled(false);
             if (pattern.size() >= MIN_LENGTH_BEFORE_REPORT) {
-                new DecryptTask().execute(LockPatternUtils.patternToString(pattern));
+                new DecryptTask().execute(new String(LockPatternUtils.patternToByteArray(pattern)));
             } else {
                 // Allow user to make as many of these as they want.
                 fakeUnlockAttempt(mLockPatternView);
diff --git a/src/com/android/settings/RegulatoryInfoDisplayActivity.java b/src/com/android/settings/RegulatoryInfoDisplayActivity.java
index 4c7515d..20aafc2 100644
--- a/src/com/android/settings/RegulatoryInfoDisplayActivity.java
+++ b/src/com/android/settings/RegulatoryInfoDisplayActivity.java
@@ -60,12 +60,6 @@
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        Resources resources = getResources();
-
-        if (!resources.getBoolean(R.bool.config_show_regulatory_info)) {
-            finish();   // no regulatory info to display for this device
-        }
-
         AlertDialog.Builder builder = new AlertDialog.Builder(this)
                 .setTitle(R.string.regulatory_labels)
                 .setOnDismissListener(this);
@@ -95,7 +89,8 @@
             }
         }
 
-        CharSequence regulatoryText = resources.getText(R.string.regulatory_info_text);
+        CharSequence regulatoryText = getResources()
+                .getText(R.string.regulatory_info_text);
 
         if (regulatoryInfoDrawableExists) {
             View view = getLayoutInflater().inflate(R.layout.regulatory_info, null);
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 9270a5a..4d813d5 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -35,6 +35,7 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
@@ -52,11 +53,13 @@
 import com.android.internal.util.ArrayUtils;
 import com.android.settings.Settings.WifiSettingsActivity;
 import com.android.settings.applications.manageapplications.ManageApplications;
+import com.android.settings.core.FeatureFlags;
 import com.android.settings.core.OnActivityResultListener;
 import com.android.settings.core.SettingsBaseActivity;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.core.gateway.SettingsGateway;
 import com.android.settings.dashboard.DashboardFeatureProvider;
+import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
 import com.android.settings.homepage.TopLevelSettings;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.wfd.WifiDisplaySettings;
@@ -565,7 +568,15 @@
             throw new IllegalArgumentException("Invalid fragment for this activity: "
                     + fragmentName);
         }
-        Fragment f = Fragment.instantiate(this, fragmentName, args);
+        Fragment f = null;
+        if (FeatureFlagUtils.isEnabled(this, FeatureFlags.PERSONAL_WORK_PROFILE)
+                && UserManager.get(this).getUserProfiles().size() > 1
+                && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null) {
+            f = Fragment.instantiate(this, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),
+                    args);
+        } else {
+            f = Fragment.instantiate(this, fragmentName, args);
+        }
         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
         transaction.replace(R.id.main_content, f);
         if (titleResId > 0) {
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 83f071a..46c08ab 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -23,6 +23,7 @@
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.users.AutoSyncDataPreferenceController;
 import com.android.settings.users.AutoSyncPersonalDataPreferenceController;
@@ -70,7 +71,8 @@
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
 
         final AccountPreferenceController accountPrefController =
-                new AccountPreferenceController(context, parent, authorities);
+                new AccountPreferenceController(context, parent, authorities,
+                        ProfileSelectFragment.ALL);
         if (parent != null) {
             parent.getSettingsLifecycle().addObserver(accountPrefController);
         }
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
new file mode 100644
index 0000000..ac426a2
--- /dev/null
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accounts;
+
+import static android.provider.Settings.EXTRA_AUTHORITIES;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
+import com.android.settings.users.AutoSyncDataPreferenceController;
+import com.android.settings.users.AutoSyncPersonalDataPreferenceController;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Account Setting page for personal profile.
+ */
+@SearchIndexable
+public class AccountPersonalDashboardFragment extends DashboardFragment {
+
+    private static final String TAG = "AccountPersonalFrag";
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.ACCOUNT;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.accounts_personal_dashboard_settings;
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_user_and_account_dashboard;
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
+        return buildPreferenceControllers(context, this /* parent */, authorities);
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+            SettingsPreferenceFragment parent, String[] authorities) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+
+        final AccountPreferenceController accountPrefController =
+                new AccountPreferenceController(context, parent, authorities,
+                        ProfileSelectFragment.PERSONAL);
+        if (parent != null) {
+            parent.getSettingsLifecycle().addObserver(accountPrefController);
+        }
+        controllers.add(accountPrefController);
+        controllers.add(new AutoSyncDataPreferenceController(context, parent));
+        controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
+        return controllers;
+    }
+
+    // TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
+//    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+//            new BaseSearchIndexProvider(R.xml.accounts_personal_dashboard_settings) {
+//
+//                @Override
+//                public List<AbstractPreferenceController> createPreferenceControllers(
+//                        Context context) {
+//                    return buildPreferenceControllers(
+//                            context, null /* parent */, null /* authorities*/);
+//                }
+//            };
+}
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 5c930e2..8e3e702 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -53,8 +53,8 @@
 import com.android.settings.Utils;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.search.SearchIndexableRaw;
 import com.android.settingslib.RestrictedPreference;
 import com.android.settingslib.accounts.AuthenticatorHelper;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -62,6 +62,7 @@
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnPause;
 import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.search.SearchIndexableRaw;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -81,8 +82,8 @@
 
     private UserManager mUm;
     private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>();
-    private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver
-                = new ManagedProfileBroadcastReceiver();
+    private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver =
+            new ManagedProfileBroadcastReceiver();
     private Preference mProfileNotAvailablePreference;
     private String[] mAuthorities;
     private int mAuthoritiesCount = 0;
@@ -90,6 +91,7 @@
     private int mAccountProfileOrder = ORDER_ACCOUNT_PROFILES;
     private AccountRestrictionHelper mHelper;
     private MetricsFeatureProvider mMetricsFeatureProvider;
+    private @ProfileSelectFragment.ProfileType int mType;
 
     /**
      * Holds data related to the accounts belonging to one profile.
@@ -130,13 +132,14 @@
     }
 
     public AccountPreferenceController(Context context, SettingsPreferenceFragment parent,
-        String[] authorities) {
-        this(context, parent, authorities, new AccountRestrictionHelper(context));
+            String[] authorities, @ProfileSelectFragment.ProfileType int type) {
+        this(context, parent, authorities, new AccountRestrictionHelper(context), type);
     }
 
     @VisibleForTesting
     AccountPreferenceController(Context context, SettingsPreferenceFragment parent,
-        String[] authorities, AccountRestrictionHelper helper) {
+            String[] authorities, AccountRestrictionHelper helper,
+            @ProfileSelectFragment.ProfileType int type) {
         super(context);
         mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
         mAuthorities = authorities;
@@ -147,6 +150,7 @@
         final FeatureFactory featureFactory = FeatureFactory.getFactory(mContext);
         mMetricsFeatureProvider = featureFactory.getMetricsFeatureProvider();
         mHelper = helper;
+        mType = type;
     }
 
     @Override
@@ -186,7 +190,7 @@
                 }
                 if (userInfo.isManagedProfile()) {
                     if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE,
-                        UserHandle.myUserId())) {
+                            UserHandle.myUserId())) {
                         SearchIndexableRaw data = new SearchIndexableRaw(mContext);
                         data.title = res.getString(R.string.remove_managed_profile_label);
                         data.screenTitle = screenTitle;
@@ -277,7 +281,13 @@
             List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
             final int profilesCount = profiles.size();
             for (int i = 0; i < profilesCount; i++) {
-                updateProfileUi(profiles.get(i));
+                if (profiles.get(i).isManagedProfile()
+                        && (mType & ProfileSelectFragment.WORK) != 0) {
+                    updateProfileUi(profiles.get(i));
+                } else if (!profiles.get(i).isManagedProfile()
+                        && (mType & ProfileSelectFragment.PERSONAL) != 0) {
+                    updateProfileUi(profiles.get(i));
+                }
             }
         }
         cleanUpPreferences();
@@ -302,7 +312,7 @@
             if (userInfo.isEnabled()) {
                 // recreate the authentication helper to refresh the list of enabled accounts
                 data.authenticatorHelper =
-                    new AuthenticatorHelper(mContext, userInfo.getUserHandle(), this);
+                        new AuthenticatorHelper(mContext, userInfo.getUserHandle(), this);
             }
             return;
         }
@@ -310,27 +320,28 @@
         final ProfileData profileData = new ProfileData();
         profileData.userInfo = userInfo;
         AccessiblePreferenceCategory preferenceGroup =
-            mHelper.createAccessiblePreferenceCategory(mParent.getPreferenceManager().getContext());
+                mHelper.createAccessiblePreferenceCategory(
+                        mParent.getPreferenceManager().getContext());
         preferenceGroup.setOrder(mAccountProfileOrder++);
         if (isSingleProfile()) {
             preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
                     BidiFormatter.getInstance().unicodeWrap(userInfo.name)));
             preferenceGroup.setContentDescription(
-                mContext.getString(R.string.account_settings));
+                    mContext.getString(R.string.account_settings));
         } else if (userInfo.isManagedProfile()) {
             preferenceGroup.setTitle(R.string.category_work);
             String workGroupSummary = getWorkGroupSummary(context, userInfo);
             preferenceGroup.setSummary(workGroupSummary);
             preferenceGroup.setContentDescription(
-                mContext.getString(R.string.accessibility_category_work, workGroupSummary));
+                    mContext.getString(R.string.accessibility_category_work, workGroupSummary));
             profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference();
             mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference,
-                DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
+                    DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
             profileData.managedProfilePreference = newManagedProfileSettings();
         } else {
             preferenceGroup.setTitle(R.string.category_personal);
             preferenceGroup.setContentDescription(
-                mContext.getString(R.string.accessibility_category_personal));
+                    mContext.getString(R.string.accessibility_category_personal));
         }
         final PreferenceScreen screen = mParent.getPreferenceScreen();
         if (screen != null) {
@@ -342,14 +353,14 @@
                     userInfo.getUserHandle(), this);
             profileData.addAccountPreference = newAddAccountPreference();
             mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference,
-                DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
+                    DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
         }
         mProfiles.put(userInfo.id, profileData);
     }
 
     private RestrictedPreference newAddAccountPreference() {
         RestrictedPreference preference =
-            new RestrictedPreference(mParent.getPreferenceManager().getContext());
+                new RestrictedPreference(mParent.getPreferenceManager().getContext());
         preference.setTitle(R.string.add_account_label);
         preference.setIcon(R.drawable.ic_add_24dp);
         preference.setOnPreferenceClickListener(this);
@@ -359,7 +370,7 @@
 
     private RestrictedPreference newRemoveWorkProfilePreference() {
         RestrictedPreference preference = new RestrictedPreference(
-            mParent.getPreferenceManager().getContext());
+                mParent.getPreferenceManager().getContext());
         preference.setTitle(R.string.remove_managed_profile_label);
         preference.setIcon(R.drawable.ic_delete);
         preference.setOnPreferenceClickListener(this);
@@ -393,7 +404,7 @@
             return;
         }
         final int count = mProfiles.size();
-        for (int i = count-1; i >= 0; i--) {
+        for (int i = count - 1; i >= 0; i--) {
             final ProfileData data = mProfiles.valueAt(i);
             if (data.pendingRemoval) {
                 screen.removePreference(data.preferenceGroup);
@@ -449,7 +460,7 @@
             }
             for (String key : preferenceToRemove.keySet()) {
                 profileData.preferenceGroup.removePreference(
-                    profileData.accountPreferences.get(key));
+                        profileData.accountPreferences.get(key));
                 profileData.accountPreferences.remove(key);
             }
         } else {
@@ -457,7 +468,7 @@
             // Put a label instead of the accounts list
             if (mProfileNotAvailablePreference == null) {
                 mProfileNotAvailablePreference =
-                    new Preference(mParent.getPreferenceManager().getContext());
+                        new Preference(mParent.getPreferenceManager().getContext());
             }
             mProfileNotAvailablePreference.setEnabled(false);
             mProfileNotAvailablePreference.setIcon(R.drawable.empty_icon);
@@ -507,26 +518,26 @@
                     continue;
                 }
                 final ArrayList<String> auths =
-                    helper.getAuthoritiesForAccountType(account.type);
+                        helper.getAuthoritiesForAccountType(account.type);
                 if (!AccountRestrictionHelper.showAccount(mAuthorities, auths)) {
                     continue;
                 }
                 final Bundle fragmentArguments = new Bundle();
                 fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT,
-                    account);
+                        account);
                 fragmentArguments.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
-                    userHandle);
+                        userHandle);
                 fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
-                    accountType);
+                        accountType);
                 fragmentArguments.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_LABEL,
-                    label.toString());
+                        label.toString());
                 fragmentArguments.putInt(AccountDetailDashboardFragment.KEY_ACCOUNT_TITLE_RES,
-                    titleResId);
+                        titleResId);
                 fragmentArguments.putParcelable(EXTRA_USER, userHandle);
                 accountTypePreferences.add(new AccountTypePreference(
-                    prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent),
-                    account, titleResPackageName, titleResId, label,
-                    AccountDetailDashboardFragment.class.getName(), fragmentArguments, icon));
+                        prefContext, mMetricsFeatureProvider.getMetricsCategory(mParent),
+                        account, titleResPackageName, titleResId, label,
+                        AccountDetailDashboardFragment.class.getName(), fragmentArguments, icon));
             }
             helper.preloadDrawableForType(mContext, accountType);
         }
@@ -536,7 +547,7 @@
             public int compare(AccountTypePreference t1, AccountTypePreference t2) {
                 int result = t1.getSummary().toString().compareTo(t2.getSummary().toString());
                 return result != 0
-                    ? result : t1.getTitle().toString().compareTo(t2.getTitle().toString());
+                        ? result : t1.getTitle().toString().compareTo(t2.getTitle().toString());
             }
         });
         return accountTypePreferences;
diff --git a/src/com/android/settings/accounts/AccountProfileSelectFragment.java b/src/com/android/settings/accounts/AccountProfileSelectFragment.java
new file mode 100644
index 0000000..128596d
--- /dev/null
+++ b/src/com/android/settings/accounts/AccountProfileSelectFragment.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accounts;
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
+
+/**
+ * Account Setting page for personal/managed profile.
+ */
+public class AccountProfileSelectFragment extends ProfileSelectFragment {
+
+    @Override
+    public Fragment[] getFragments() {
+        return new Fragment[] {
+                new AccountPersonalDashboardFragment(),
+                new AccountWorkProfileDashboardFragment()
+        };
+    }
+}
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
new file mode 100644
index 0000000..e3fceb8
--- /dev/null
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accounts;
+
+import static android.provider.Settings.EXTRA_AUTHORITIES;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
+import com.android.settings.users.AutoSyncDataPreferenceController;
+import com.android.settings.users.AutoSyncWorkDataPreferenceController;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Account Setting page for work profile.
+ */
+@SearchIndexable
+public class AccountWorkProfileDashboardFragment extends DashboardFragment {
+
+    private static final String TAG = "AccountWorkProfileFrag";
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.ACCOUNT;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.accounts_work_dashboard_settings;
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_user_and_account_dashboard;
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
+        return buildPreferenceControllers(context, this /* parent */, authorities);
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+            SettingsPreferenceFragment parent, String[] authorities) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+
+        final AccountPreferenceController accountPrefController =
+                new AccountPreferenceController(context, parent, authorities,
+                        ProfileSelectFragment.WORK);
+        if (parent != null) {
+            parent.getSettingsLifecycle().addObserver(accountPrefController);
+        }
+        controllers.add(accountPrefController);
+        controllers.add(new AutoSyncDataPreferenceController(context, parent));
+        controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
+        return controllers;
+    }
+
+    // TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
+//    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+//            new BaseSearchIndexProvider(R.xml.accounts_work_dashboard_settings) {
+//
+//                @Override
+//                public List<AbstractPreferenceController> createPreferenceControllers(
+//                        Context context) {
+//                    return buildPreferenceControllers(
+//                            context, null /* parent */, null /* authorities*/);
+//                }
+//            };
+}
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index fee9c42..8203b35 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -27,4 +27,5 @@
     public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
     public static final String WIFI_DETAILS_DATAUSAGE_HEADER =
             "settings_wifi_details_datausage_header";
+    public static final String PERSONAL_WORK_PROFILE = "settings_work_profile";
 }
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
new file mode 100644
index 0000000..797782a
--- /dev/null
+++ b/src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard.profileselector;
+
+import android.util.ArrayMap;
+
+import com.android.settings.accounts.AccountDashboardFragment;
+import com.android.settings.accounts.AccountProfileSelectFragment;
+
+import java.util.Map;
+
+/**
+ * A registry to keep track of which page and its own profile selection page.
+ */
+public class ProfileFragmentBridge {
+
+    /**
+     * Map from parent fragment to category key. The parent fragment hosts child with
+     * category_key.
+     */
+    public static final Map<String, String> FRAGMENT_MAP;
+
+    static {
+        FRAGMENT_MAP = new ArrayMap<>();
+        FRAGMENT_MAP.put(AccountDashboardFragment.class.getName(),
+                AccountProfileSelectFragment.class.getName());
+    }
+}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
new file mode 100644
index 0000000..96eace8
--- /dev/null
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard.profileselector;
+
+import android.annotation.IntDef;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentStatePagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+
+import com.android.settings.R;
+import com.android.settings.core.InstrumentedFragment;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Base fragment class for per profile settings.
+ */
+public abstract class ProfileSelectFragment extends InstrumentedFragment {
+
+    /**
+     * Denotes the profile type.
+     */
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef({PERSONAL, WORK, ALL})
+    public @interface ProfileType {
+    }
+
+    /**
+     * It is personal work profile.
+     */
+    public static final int PERSONAL = 1;
+
+    /**
+     * It is work profile
+     */
+    public static final int WORK = 1 << 1;
+
+    /**
+     * It is personal and work profile
+     */
+    public static final int ALL = PERSONAL | WORK;
+
+    private View mContentView;
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        mContentView = inflater.inflate(R.layout.profile_select_tablayout, null /* root */);
+        final ViewPager viewPager = mContentView.findViewById(R.id.view_pager);
+        viewPager.setAdapter(new ViewPagerAdapter(this));
+        return mContentView;
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return METRICS_CATEGORY_UNKNOWN;
+    }
+
+    /**
+     * Returns an array of {@link Fragment} to display in the
+     * {@link com.google.android.material.tabs.TabLayout}
+     */
+    public abstract Fragment[] getFragments();
+
+    static class ViewPagerAdapter extends FragmentStatePagerAdapter {
+
+        private final Fragment[] mChildFragments;
+        private final Context mContext;
+
+        ViewPagerAdapter(ProfileSelectFragment fragment) {
+            super(fragment.getActivity().getSupportFragmentManager());
+            mContext = fragment.getContext();
+            mChildFragments = fragment.getFragments();
+        }
+
+        @Override
+        public Fragment getItem(int position) {
+            return mChildFragments[position];
+        }
+
+        @Override
+        public int getCount() {
+            return mChildFragments.length;
+        }
+
+        @Override
+        public CharSequence getPageTitle(int position) {
+            if (position == 0) {
+                return mContext.getString(R.string.category_personal);
+            } else {
+                return mContext.getString(R.string.category_work);
+            }
+        }
+    }
+}
diff --git a/src/com/android/settings/datausage/DataSaverBackend.java b/src/com/android/settings/datausage/DataSaverBackend.java
index db92659..92b2ef9 100644
--- a/src/com/android/settings/datausage/DataSaverBackend.java
+++ b/src/com/android/settings/datausage/DataSaverBackend.java
@@ -23,6 +23,7 @@
 import android.net.INetworkPolicyListener;
 import android.net.NetworkPolicyManager;
 import android.os.RemoteException;
+import android.telephony.SubscriptionPlan;
 import android.util.SparseIntArray;
 
 import com.android.settings.overlay.FeatureFactory;
@@ -199,8 +200,11 @@
         }
 
         @Override
-        public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue,
-                long networkTypeMask) {
+        public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue) {
+        }
+
+        @Override
+        public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) {
         }
     };
 
diff --git a/src/com/android/settings/notification/AllowSoundPreferenceController.java b/src/com/android/settings/notification/AllowSoundPreferenceController.java
index 7862f4b..dcf4779 100644
--- a/src/com/android/settings/notification/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/AllowSoundPreferenceController.java
@@ -34,10 +34,10 @@
 
     private static final String TAG = "AllowSoundPrefContr";
     private static final String KEY_IMPORTANCE = "allow_sound";
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     public AllowSoundPreferenceController(Context context,
-            NotificationSettingsBase.ImportanceListener importanceListener,
+            NotificationSettings.ImportanceListener importanceListener,
             NotificationBackend backend) {
         super(context, backend);
         mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
index 82bab24..860c445 100644
--- a/src/com/android/settings/notification/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
@@ -30,7 +30,7 @@
 import java.util.List;
 
 @SearchIndexable
-public class AppBubbleNotificationSettings extends NotificationSettingsBase implements
+public class AppBubbleNotificationSettings extends NotificationSettings implements
         GlobalBubblePermissionObserverMixin.Listener {
     private static final String TAG = "AppBubNotiSettings";
     private GlobalBubblePermissionObserverMixin mObserverMixin;
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index dc06f47..24f38b1 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -34,7 +34,7 @@
 import androidx.preference.PreferenceScreen;
 
 /** These settings are per app, so should not be returned in global search results. */
-public class AppNotificationSettings extends NotificationSettingsBase {
+public class AppNotificationSettings extends NotificationSettings {
     private static final String TAG = "AppNotificationSettings";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
diff --git a/src/com/android/settings/notification/BlockPreferenceController.java b/src/com/android/settings/notification/BlockPreferenceController.java
index 37589d9..27144b8 100644
--- a/src/com/android/settings/notification/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/BlockPreferenceController.java
@@ -35,10 +35,10 @@
         implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
 
     private static final String KEY_BLOCK = "block";
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     public BlockPreferenceController(Context context,
-            NotificationSettingsBase.ImportanceListener importanceListener,
+            NotificationSettings.ImportanceListener importanceListener,
             NotificationBackend backend) {
         super(context, backend);
         mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 09bf0e2..ff3eebc 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -35,7 +35,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-public class ChannelNotificationSettings extends NotificationSettingsBase {
+public class ChannelNotificationSettings extends NotificationSettings {
     private static final String TAG = "ChannelSettings";
 
     @Override
diff --git a/src/com/android/settings/notification/HighImportancePreferenceController.java b/src/com/android/settings/notification/HighImportancePreferenceController.java
index da9b3b4..6c8c354 100644
--- a/src/com/android/settings/notification/HighImportancePreferenceController.java
+++ b/src/com/android/settings/notification/HighImportancePreferenceController.java
@@ -31,10 +31,10 @@
         implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener  {
 
     private static final String KEY_IMPORTANCE = "high_importance";
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     public HighImportancePreferenceController(Context context,
-            NotificationSettingsBase.ImportanceListener importanceListener,
+            NotificationSettings.ImportanceListener importanceListener,
             NotificationBackend backend) {
         super(context, backend);
         mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java
index 4ef4593..a9bd182 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -32,10 +32,10 @@
         implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener  {
 
     private static final String KEY_IMPORTANCE = "importance";
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     public ImportancePreferenceController(Context context,
-            NotificationSettingsBase.ImportanceListener importanceListener,
+            NotificationSettings.ImportanceListener importanceListener,
             NotificationBackend backend) {
         super(context, backend);
         mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/MinImportancePreferenceController.java b/src/com/android/settings/notification/MinImportancePreferenceController.java
index 0af0c8d..19d950c 100644
--- a/src/com/android/settings/notification/MinImportancePreferenceController.java
+++ b/src/com/android/settings/notification/MinImportancePreferenceController.java
@@ -31,10 +31,10 @@
         implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener  {
 
     private static final String KEY_IMPORTANCE = "min_importance";
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     public MinImportancePreferenceController(Context context,
-            NotificationSettingsBase.ImportanceListener importanceListener,
+            NotificationSettings.ImportanceListener importanceListener,
             NotificationBackend backend) {
         super(context, backend);
         mImportanceListener = importanceListener;
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettings.java
similarity index 98%
rename from src/com/android/settings/notification/NotificationSettingsBase.java
rename to src/com/android/settings/notification/NotificationSettings.java
index 27a2de0..938a7ba 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettings.java
@@ -64,7 +64,7 @@
 import java.util.Comparator;
 import java.util.List;
 
-abstract public class NotificationSettingsBase extends DashboardFragment {
+abstract public class NotificationSettings extends DashboardFragment {
     private static final String TAG = "NotifiSettingsBase";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index c2c8b60..754dfa2 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -79,6 +79,9 @@
     private static class HistoricalNotificationInfo {
         public String key;
         public NotificationChannel channel;
+        // Historical notifications don't have Ranking information. for most fields that's ok
+        // but we need channel id to launch settings.
+        public String channelId;
         public String pkg;
         public Drawable pkgicon;
         public CharSequence pkgname;
@@ -416,6 +419,7 @@
         info.timestamp = sbn.getPostTime();
         info.priority = n.priority;
         info.key = sbn.getKey();
+        info.channelId = sbn.getNotification().getChannelId();
 
         info.active = active;
         info.notificationExtra = generateExtraText(sbn, info);
@@ -724,7 +728,8 @@
         public void performClick() {
             Intent intent =  new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
                     .putExtra(EXTRA_APP_PACKAGE, mInfo.pkg)
-                    .putExtra(EXTRA_CHANNEL_ID, mInfo.channel.getId());
+                    .putExtra(EXTRA_CHANNEL_ID,
+                            mInfo.channel != null ? mInfo.channel.getId() : mInfo.channelId);
             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             getContext().startActivity(intent);
         }
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index 566f3f2..8530de0 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -39,12 +39,12 @@
 
     private static final String KEY_SOUND = "ringtone";
     private final SettingsPreferenceFragment mFragment;
-    private final NotificationSettingsBase.ImportanceListener mListener;
+    private final NotificationSettings.ImportanceListener mListener;
     private NotificationSoundPreference mPreference;
     protected static final int CODE = 200;
 
     public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment,
-            NotificationSettingsBase.ImportanceListener importanceListener,
+            NotificationSettings.ImportanceListener importanceListener,
             NotificationBackend backend) {
         super(context, backend);
         mFragment = hostFragment;
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index f86292b..4f1b050 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -61,6 +61,7 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.EncryptionInterstitial;
 import com.android.settings.EventLogTags;
 import com.android.settings.R;
@@ -151,7 +152,7 @@
         private boolean mPasswordConfirmed = false;
         private boolean mWaitingForConfirmation = false;
         private boolean mForChangeCredRequiredForBoot = false;
-        private byte[] mUserPassword;
+        private LockscreenCredential mUserPassword;
         private LockPatternUtils mLockPatternUtils;
         private FingerprintManager mFingerprintManager;
         private FaceManager mFaceManager;
@@ -207,7 +208,7 @@
                 .getBooleanExtra(CONFIRM_CREDENTIALS, true);
             if (getActivity() instanceof ChooseLockGeneric.InternalActivity) {
                 mPasswordConfirmed = !confirmCredentials;
-                mUserPassword = getActivity().getIntent().getByteArrayExtra(
+                mUserPassword = getActivity().getIntent().getParcelableExtra(
                         ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
             }
 
@@ -233,7 +234,7 @@
                 mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
                 mWaitingForConfirmation = savedInstanceState.getBoolean(WAITING_FOR_CONFIRMATION);
                 if (mUserPassword == null) {
-                    mUserPassword = savedInstanceState.getByteArray(
+                    mUserPassword = savedInstanceState.getParcelable(
                             ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
                 }
             }
@@ -392,11 +393,11 @@
             if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
                 mPasswordConfirmed = true;
                 mUserPassword = data != null
-                    ? data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)
+                    ? data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)
                     : null;
                 updatePreferencesOrFinish(false /* isRecreatingActivity */);
                 if (mForChangeCredRequiredForBoot) {
-                    if (!(mUserPassword == null || mUserPassword.length == 0)) {
+                    if (mUserPassword != null && !mUserPassword.isNone()) {
                         maybeEnableEncryption(
                                 mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId), false);
                     } else {
@@ -459,7 +460,7 @@
             outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed);
             outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation);
             if (mUserPassword != null) {
-                outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
+                outState.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
             }
         }
 
@@ -682,7 +683,7 @@
             setPreferenceSummary(ScreenLockType.MANAGED, R.string.secure_lock_encryption_warning);
         }
 
-        protected Intent getLockManagedPasswordIntent(byte[] password) {
+        protected Intent getLockManagedPasswordIntent(LockscreenCredential password) {
             return mManagedPasswordProvider.createIntent(false, password);
         }
 
@@ -759,7 +760,8 @@
             if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
                 // Clearing of user biometrics when screen lock is cleared is done at
                 // LockSettingsService.removeBiometricsForUser().
-                mChooseLockSettingsHelper.utils().clearLock(mUserPassword, mUserId);
+                mChooseLockSettingsHelper.utils().setLockCredential(
+                        LockscreenCredential.createNone(), mUserPassword, mUserId);
                 mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
                 getActivity().setResult(Activity.RESULT_OK);
                 finish();
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 820aecb..6872543 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -63,6 +63,7 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.widget.LockPatternUtils;
 import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
+import com.android.internal.widget.LockscreenCredential;
 import com.android.internal.widget.TextViewInputDisabler;
 import com.android.settings.EncryptionInterstitial;
 import com.android.settings.R;
@@ -124,7 +125,7 @@
             return this;
         }
 
-        public IntentBuilder setPassword(byte[] password) {
+        public IntentBuilder setPassword(LockscreenCredential password) {
             mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password);
             return this;
         }
@@ -180,13 +181,13 @@
 
     public static class ChooseLockPasswordFragment extends InstrumentedFragment
             implements OnEditorActionListener, TextWatcher, SaveAndFinishWorker.Listener {
-        private static final String KEY_FIRST_PIN = "first_pin";
+        private static final String KEY_FIRST_PASSWORD = "first_password";
         private static final String KEY_UI_STAGE = "ui_stage";
-        private static final String KEY_CURRENT_PASSWORD = "current_password";
+        private static final String KEY_CURRENT_CREDENTIAL = "current_credential";
         private static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
 
-        private byte[] mCurrentPassword;
-        private byte[] mChosenPassword;
+        private LockscreenCredential mCurrentCredential;
+        private LockscreenCredential mChosenPassword;
         private boolean mHasChallenge;
         private long mChallenge;
         private ImeAwareEditText mPasswordEntry;
@@ -215,7 +216,7 @@
         protected boolean mForFingerprint;
         protected boolean mForFace;
 
-        private byte[] mFirstPin;
+        private LockscreenCredential mFirstPassword;
         private RecyclerView mPasswordRestrictionView;
         protected boolean mIsAlphaMode;
         protected FooterButton mSkipOrClearButton;
@@ -394,13 +395,13 @@
                 SaveAndFinishWorker w = new SaveAndFinishWorker();
                 final boolean required = getActivity().getIntent().getBooleanExtra(
                         EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
-                byte[] currentBytes = intent.getByteArrayExtra(
+                LockscreenCredential currentCredential = intent.getParcelableExtra(
                         ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
 
                 w.setBlocking(true);
                 w.setListener(this);
                 w.start(mChooseLockSettingsHelper.utils(), required, false, 0,
-                        currentBytes, currentBytes, mRequestedQuality, mUserId);
+                        currentCredential, currentCredential, mUserId);
             }
             mTextChangedHandler = new TextChangedHandler();
         }
@@ -482,7 +483,7 @@
             Intent intent = getActivity().getIntent();
             final boolean confirmCredentials = intent.getBooleanExtra(
                     ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
-            mCurrentPassword = intent.getByteArrayExtra(
+            mCurrentCredential = intent.getParcelableExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
             mHasChallenge = intent.getBooleanExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
@@ -497,15 +498,15 @@
             } else {
 
                 // restore from previous state
-                mFirstPin = savedInstanceState.getByteArray(KEY_FIRST_PIN);
+                mFirstPassword = savedInstanceState.getParcelable(KEY_FIRST_PASSWORD);
                 final String state = savedInstanceState.getString(KEY_UI_STAGE);
                 if (state != null) {
                     mUiStage = Stage.valueOf(state);
                     updateStage(mUiStage);
                 }
 
-                if (mCurrentPassword == null) {
-                    mCurrentPassword = savedInstanceState.getByteArray(KEY_CURRENT_PASSWORD);
+                if (mCurrentCredential == null) {
+                    mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_CREDENTIAL);
                 }
 
                 // Re-attach to the exiting worker if there is one.
@@ -563,8 +564,8 @@
         public void onSaveInstanceState(Bundle outState) {
             super.onSaveInstanceState(outState);
             outState.putString(KEY_UI_STAGE, mUiStage.name());
-            outState.putByteArray(KEY_FIRST_PIN, mFirstPin);
-            outState.putByteArray(KEY_CURRENT_PASSWORD, mCurrentPassword);
+            outState.putParcelable(KEY_FIRST_PASSWORD, mFirstPassword);
+            outState.putParcelable(KEY_CURRENT_CREDENTIAL, mCurrentCredential);
         }
 
         @Override
@@ -577,7 +578,7 @@
                         getActivity().setResult(RESULT_FINISHED);
                         getActivity().finish();
                     } else {
-                        mCurrentPassword = data.getByteArrayExtra(
+                        mCurrentCredential = data.getParcelableExtra(
                                 ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
                     }
                     break;
@@ -722,7 +723,8 @@
          * @return the validation result.
          */
         @VisibleForTesting
-        int validatePassword(byte[] password) {
+        int validatePassword(LockscreenCredential credential) {
+            final byte[] password = credential.getCredential();
             int errorCode = NO_ERROR;
             final PasswordMetrics metrics = PasswordMetrics.computeForPassword(password);
             mergeMinComplexityAndDpmRequirements(metrics.quality);
@@ -812,7 +814,8 @@
         private byte[] getPasswordHistoryHashFactor() {
             if (mPasswordHistoryHashFactor == null) {
                 mPasswordHistoryHashFactor = mLockPatternUtils.getPasswordHistoryHashFactor(
-                        mCurrentPassword, mUserId);
+                        mCurrentCredential != null ? mCurrentCredential
+                                : LockscreenCredential.createNone(), mUserId);
             }
             return mPasswordHistoryHashFactor;
         }
@@ -820,20 +823,22 @@
         public void handleNext() {
             if (mSaveAndFinishWorker != null) return;
             // TODO(b/120484642): This is a point of entry for passwords from the UI
-            mChosenPassword = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
-            if (mChosenPassword == null || mChosenPassword.length == 0) {
+            final Editable passwordText = mPasswordEntry.getText();
+            if (TextUtils.isEmpty(passwordText)) {
                 return;
             }
+            mChosenPassword = mIsAlphaMode ? LockscreenCredential.createPassword(passwordText)
+                    : LockscreenCredential.createPin(passwordText);
             if (mUiStage == Stage.Introduction) {
                 if (validatePassword(mChosenPassword) == NO_ERROR) {
-                    mFirstPin = mChosenPassword;
+                    mFirstPassword = mChosenPassword;
                     mPasswordEntry.setText("");
                     updateStage(Stage.NeedToConfirm);
                 } else {
-                    Arrays.fill(mChosenPassword, (byte) 0);
+                    mChosenPassword.zeroize();
                 }
             } else if (mUiStage == Stage.NeedToConfirm) {
-                if (Arrays.equals(mFirstPin, mChosenPassword)) {
+                if (mChosenPassword.equals(mFirstPassword)) {
                     startSaveAndFinish();
                 } else {
                     CharSequence tmp = mPasswordEntry.getText();
@@ -841,7 +846,7 @@
                         Selection.setSelection((Spannable) tmp, 0, tmp.length());
                     }
                     updateStage(Stage.ConfirmWrong);
-                    Arrays.fill(mChosenPassword, (byte) 0);
+                    mChosenPassword.zeroize();
                 }
             }
         }
@@ -954,8 +959,11 @@
          */
         protected void updateUi() {
             final boolean canInput = mSaveAndFinishWorker == null;
-            byte[] password = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
-            final int length = password.length;
+
+            LockscreenCredential password = mIsAlphaMode
+                    ? LockscreenCredential.createPasswordOrNone(mPasswordEntry.getText())
+                    : LockscreenCredential.createPinOrNone(mPasswordEntry.getText());
+            final int length = password.size();
             if (mUiStage == Stage.Introduction) {
                 mPasswordRestrictionView.setVisibility(View.VISIBLE);
                 final int errorCode = validatePassword(password);
@@ -981,7 +989,7 @@
 
             setNextText(mUiStage.buttonText);
             mPasswordEntryInputDisabler.setInputEnabled(canInput);
-            Arrays.fill(password, (byte) 0);
+            password.zeroize();
         }
 
         protected int toVisibility(boolean visibleOrGone) {
@@ -1033,7 +1041,7 @@
             final boolean required = getActivity().getIntent().getBooleanExtra(
                     EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
             mSaveAndFinishWorker.start(mLockPatternUtils, required, mHasChallenge, mChallenge,
-                    mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId);
+                    mChosenPassword, mCurrentCredential, mUserId);
         }
 
         @Override
@@ -1041,13 +1049,13 @@
             getActivity().setResult(RESULT_FINISHED, resultData);
 
             if (mChosenPassword != null) {
-                Arrays.fill(mChosenPassword, (byte) 0);
+                mChosenPassword.zeroize();
             }
-            if (mCurrentPassword != null) {
-                Arrays.fill(mCurrentPassword, (byte) 0);
+            if (mCurrentCredential != null) {
+                mCurrentCredential.zeroize();
             }
-            if (mFirstPin != null) {
-                Arrays.fill(mFirstPin, (byte) 0);
+            if (mFirstPassword != null) {
+                mFirstPassword.zeroize();
             }
 
             mPasswordEntry.setText("");
@@ -1088,18 +1096,18 @@
 
     public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
 
-        private byte[] mChosenPassword;
-        private byte[] mCurrentPassword;
-        private int mRequestedQuality;
+        private LockscreenCredential mChosenPassword;
+        private LockscreenCredential mCurrentCredential;
 
         public void start(LockPatternUtils utils, boolean required,
                 boolean hasChallenge, long challenge,
-                byte[] chosenPassword, byte[] currentPassword, int requestedQuality, int userId) {
+                LockscreenCredential chosenPassword, LockscreenCredential currentCredential,
+                int userId) {
             prepare(utils, required, hasChallenge, challenge, userId);
 
             mChosenPassword = chosenPassword;
-            mCurrentPassword = currentPassword;
-            mRequestedQuality = requestedQuality;
+            mCurrentCredential = currentCredential != null ? currentCredential
+                    : LockscreenCredential.createNone();
             mUserId = userId;
 
             start();
@@ -1107,13 +1115,13 @@
 
         @Override
         protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
-            final boolean success = mUtils.saveLockPassword(
-                    mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId);
+            final boolean success = mUtils.setLockCredential(
+                    mChosenPassword, mCurrentCredential, mUserId);
             Intent result = null;
             if (success && mHasChallenge) {
                 byte[] token;
                 try {
-                    token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId);
+                    token = mUtils.verifyCredential(mChosenPassword, mChallenge, mUserId);
                 } catch (RequestThrottledException e) {
                     token = null;
                 }
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 5de4e3a..b81b0c4 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -36,12 +36,14 @@
 
 import androidx.fragment.app.Fragment;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient;
 import com.android.internal.widget.LockPatternUtils;
 import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
 import com.android.internal.widget.LockPatternView;
 import com.android.internal.widget.LockPatternView.Cell;
 import com.android.internal.widget.LockPatternView.DisplayMode;
+import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.EncryptionInterstitial;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -116,7 +118,7 @@
             return this;
         }
 
-        public IntentBuilder setPattern(byte[] pattern) {
+        public IntentBuilder setPattern(LockscreenCredential pattern) {
             mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
             return this;
         }
@@ -188,7 +190,7 @@
 
         private static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
 
-        private byte[] mCurrentPattern;
+        private LockscreenCredential mCurrentCredential;
         private boolean mHasChallenge;
         private long mChallenge;
         protected TextView mTitleText;
@@ -198,7 +200,7 @@
         protected TextView mFooterText;
         protected FooterButton mSkipOrClearButton;
         private FooterButton mNextButton;
-        protected List<LockPatternView.Cell> mChosenPattern = null;
+        @VisibleForTesting protected LockscreenCredential mChosenPattern;
         private ColorStateList mDefaultHeaderColorList;
 
         // ScrollView that contains title and header, only exist in land mode
@@ -225,7 +227,7 @@
                         getActivity().setResult(RESULT_FINISHED);
                         getActivity().finish();
                     } else {
-                        mCurrentPattern = data.getByteArrayExtra(
+                        mCurrentCredential = data.getParcelableExtra(
                                 ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
                     }
 
@@ -262,16 +264,19 @@
                     if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) {
                         if (mChosenPattern == null) throw new IllegalStateException(
                                 "null chosen pattern in stage 'need to confirm");
-                        if (mChosenPattern.equals(pattern)) {
-                            updateStage(Stage.ChoiceConfirmed);
-                        } else {
-                            updateStage(Stage.ConfirmWrong);
+                        try (LockscreenCredential confirmPattern =
+                                LockscreenCredential.createPattern(pattern)) {
+                            if (mChosenPattern.equals(confirmPattern)) {
+                                updateStage(Stage.ChoiceConfirmed);
+                            } else {
+                                updateStage(Stage.ConfirmWrong);
+                            }
                         }
                     } else if (mUiStage == Stage.Introduction || mUiStage == Stage.ChoiceTooShort){
                         if (pattern.size() < LockPatternUtils.MIN_LOCK_PATTERN_SIZE) {
                             updateStage(Stage.ChoiceTooShort);
                         } else {
-                            mChosenPattern = new ArrayList<LockPatternView.Cell>(pattern);
+                            mChosenPattern = LockscreenCredential.createPattern(pattern);
                             updateStage(Stage.FirstChoiceValid);
                         }
                     } else {
@@ -458,12 +463,12 @@
                 SaveAndFinishWorker w = new SaveAndFinishWorker();
                 final boolean required = getActivity().getIntent().getBooleanExtra(
                         EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
-                byte[] current = intent.getByteArrayExtra(
+                LockscreenCredential current = intent.getParcelableExtra(
                         ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
                 w.setBlocking(true);
                 w.setListener(this);
                 w.start(mChooseLockSettingsHelper.utils(), required,
-                        false, 0, LockPatternUtils.byteArrayToPattern(current), current, mUserId);
+                        false, 0, current, current, mUserId);
             }
             mForFingerprint = intent.getBooleanExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
@@ -541,8 +546,8 @@
             final boolean confirmCredentials = getActivity().getIntent()
                     .getBooleanExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
             Intent intent = getActivity().getIntent();
-            mCurrentPattern =
-                    intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+            mCurrentCredential =
+                    intent.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
             mHasChallenge = intent.getBooleanExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
             mChallenge = intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
@@ -565,13 +570,10 @@
                 }
             } else {
                 // restore from previous state
-                final byte[] pattern = savedInstanceState.getByteArray(KEY_PATTERN_CHOICE);
-                if (pattern != null) {
-                    mChosenPattern = LockPatternUtils.byteArrayToPattern(pattern);
-                }
+                mChosenPattern = savedInstanceState.getParcelable(KEY_PATTERN_CHOICE);
 
-                if (mCurrentPattern == null) {
-                    mCurrentPattern = savedInstanceState.getByteArray(KEY_CURRENT_PATTERN);
+                if (mCurrentCredential == null) {
+                    mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_PATTERN);
                 }
                 updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
 
@@ -606,6 +608,7 @@
 
         public void handleLeftButton() {
             if (mUiStage.leftMode == LeftButtonMode.Retry) {
+                mChosenPattern.zeroize();
                 mChosenPattern = null;
                 mLockPatternView.clearPattern();
                 updateStage(Stage.Introduction);
@@ -667,12 +670,11 @@
 
             outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
             if (mChosenPattern != null) {
-                outState.putByteArray(KEY_PATTERN_CHOICE,
-                        LockPatternUtils.patternToByteArray(mChosenPattern));
+                outState.putParcelable(KEY_PATTERN_CHOICE, mChosenPattern);
             }
 
-            if (mCurrentPattern != null) {
-                outState.putByteArray(KEY_CURRENT_PATTERN, mCurrentPattern);
+            if (mCurrentCredential != null) {
+                outState.putParcelable(KEY_CURRENT_PATTERN, mCurrentCredential);
             }
         }
 
@@ -812,15 +814,18 @@
             final boolean required = getActivity().getIntent().getBooleanExtra(
                     EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
             mSaveAndFinishWorker.start(mChooseLockSettingsHelper.utils(), required,
-                    mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern, mUserId);
+                    mHasChallenge, mChallenge, mChosenPattern, mCurrentCredential, mUserId);
         }
 
         @Override
         public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData) {
             getActivity().setResult(RESULT_FINISHED, resultData);
 
-            if (mCurrentPattern != null) {
-                Arrays.fill(mCurrentPattern, (byte) 0);
+            if (mChosenPattern != null) {
+                mChosenPattern.zeroize();
+            }
+            if (mCurrentCredential != null) {
+                mCurrentCredential.zeroize();
             }
 
             if (!wasSecureBefore) {
@@ -835,16 +840,17 @@
 
     public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
 
-        private List<LockPatternView.Cell> mChosenPattern;
-        private byte[] mCurrentPattern;
+        private LockscreenCredential mChosenPattern;
+        private LockscreenCredential mCurrentCredential;
         private boolean mLockVirgin;
 
-        public void start(LockPatternUtils utils, boolean credentialRequired,
-                boolean hasChallenge, long challenge,
-                List<LockPatternView.Cell> chosenPattern, byte[] currentPattern, int userId) {
+        public void start(LockPatternUtils utils, boolean credentialRequired, boolean hasChallenge,
+                long challenge, LockscreenCredential chosenPattern,
+                LockscreenCredential currentCredential, int userId) {
             prepare(utils, credentialRequired, hasChallenge, challenge, userId);
 
-            mCurrentPattern = currentPattern;
+            mCurrentCredential = currentCredential != null ? currentCredential
+                    : LockscreenCredential.createNone();
             mChosenPattern = chosenPattern;
             mUserId = userId;
 
@@ -856,12 +862,13 @@
         @Override
         protected Pair<Boolean, Intent> saveAndVerifyInBackground() {
             final int userId = mUserId;
-            final boolean success = mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId);
+            final boolean success = mUtils.setLockCredential(mChosenPattern, mCurrentCredential,
+                    userId);
             Intent result = null;
             if (success && mHasChallenge) {
                 byte[] token;
                 try {
-                    token = mUtils.verifyPattern(mChosenPattern, mChallenge, userId);
+                    token = mUtils.verifyCredential(mChosenPattern, mChallenge, userId);
                 } catch (RequestThrottledException e) {
                     token = null;
                 }
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 5c891cd..13d3749 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -27,6 +27,7 @@
 import android.os.SystemClock;
 import android.os.UserManager;
 import android.os.storage.StorageManager;
+import android.text.Editable;
 import android.text.InputType;
 import android.text.TextUtils;
 import android.view.KeyEvent;
@@ -44,6 +45,7 @@
 
 import com.android.internal.widget.LockPatternChecker;
 import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
 import com.android.internal.widget.TextViewInputDisabler;
 import com.android.settings.R;
 import com.android.settings.widget.ImeAwareEditText;
@@ -332,10 +334,13 @@
             }
 
             // TODO(b/120484642): This is a point of entry for passwords from the UI
-            final byte[] pin = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
-            if (pin == null || pin.length == 0) {
+            final Editable passwordText = mPasswordEntry.getText();
+            if (TextUtils.isEmpty(passwordText)) {
                 return;
             }
+            final LockscreenCredential credential =
+                    mIsAlpha ? LockscreenCredential.createPassword(passwordText)
+                    : LockscreenCredential.createPin(passwordText);
 
             mPasswordEntryInputDisabler.setInputEnabled(false);
             final boolean verifyChallenge = getActivity().getIntent().getBooleanExtra(
@@ -344,11 +349,11 @@
             Intent intent = new Intent();
             if (verifyChallenge)  {
                 if (isInternalActivity()) {
-                    startVerifyPassword(pin, intent);
+                    startVerifyPassword(credential, intent);
                     return;
                 }
             } else {
-                startCheckPassword(pin, intent);
+                startCheckPassword(credential, intent);
                 return;
             }
 
@@ -359,7 +364,7 @@
             return getActivity() instanceof ConfirmLockPassword.InternalActivity;
         }
 
-        private void startVerifyPassword(final byte[] pin, final Intent intent) {
+        private void startVerifyPassword(LockscreenCredential credential, final Intent intent) {
             long challenge = getActivity().getIntent().getLongExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
             final int localEffectiveUserId = mEffectiveUserId;
@@ -383,29 +388,32 @@
                         }
             };
             mPendingLockCheck = (localEffectiveUserId == localUserId)
-                    ? LockPatternChecker.verifyPassword(
-                            mLockPatternUtils, pin, challenge, localUserId, onVerifyCallback)
+                    ? LockPatternChecker.verifyCredential(
+                            mLockPatternUtils, credential, challenge, localUserId, onVerifyCallback)
                     : LockPatternChecker.verifyTiedProfileChallenge(
-                            mLockPatternUtils, pin, false, challenge, localUserId,
+                            mLockPatternUtils, credential, challenge, localUserId,
                             onVerifyCallback);
         }
 
-        private void startCheckPassword(final byte[] pin, final Intent intent) {
+        private void startCheckPassword(final LockscreenCredential credential,
+                final Intent intent) {
             final int localEffectiveUserId = mEffectiveUserId;
-            mPendingLockCheck = LockPatternChecker.checkPassword(
+            mPendingLockCheck = LockPatternChecker.checkCredential(
                     mLockPatternUtils,
-                    pin,
+                    credential,
                     localEffectiveUserId,
                     new LockPatternChecker.OnCheckCallback() {
                         @Override
                         public void onChecked(boolean matched, int timeoutMs) {
                             mPendingLockCheck = null;
                             if (matched && isInternalActivity() && mReturnCredentials) {
+                                // TODO: get rid of EXTRA_KEY_TYPE, since EXTRA_KEY_PASSWORD already
+                                // distinguishes beteween PIN and password.
                                 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
                                                 mIsAlpha ? StorageManager.CRYPT_TYPE_PASSWORD
                                                          : StorageManager.CRYPT_TYPE_PIN);
                                 intent.putExtra(
-                                        ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pin);
+                                        ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, credential);
                             }
                             mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
                                     localEffectiveUserId);
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index b1d8e60..2f7557e 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -37,6 +37,7 @@
 import com.android.internal.widget.LockPatternUtils;
 import com.android.internal.widget.LockPatternView;
 import com.android.internal.widget.LockPatternView.Cell;
+import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.R;
 import com.android.settingslib.animation.AppearAnimationCreator;
 import com.android.settingslib.animation.AppearAnimationUtils;
@@ -401,14 +402,16 @@
 
                 final boolean verifyChallenge = getActivity().getIntent().getBooleanExtra(
                         ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
+                final LockscreenCredential credential = LockscreenCredential.createPattern(pattern);
+                //TODO: how to sanitize this?
                 Intent intent = new Intent();
                 if (verifyChallenge) {
                     if (isInternalActivity()) {
-                        startVerifyPattern(pattern, intent);
+                        startVerifyPattern(credential, intent);
                         return;
                     }
                 } else {
-                    startCheckPattern(pattern, intent);
+                    startCheckPattern(credential, intent);
                     return;
                 }
 
@@ -419,7 +422,7 @@
                 return getActivity() instanceof ConfirmLockPattern.InternalActivity;
             }
 
-            private void startVerifyPattern(final List<LockPatternView.Cell> pattern,
+            private void startVerifyPattern(final LockscreenCredential pattern,
                     final Intent intent) {
                 final int localEffectiveUserId = mEffectiveUserId;
                 final int localUserId = mUserId;
@@ -444,15 +447,15 @@
                         }
                     };
                 mPendingLockCheck = (localEffectiveUserId == localUserId)
-                        ? LockPatternChecker.verifyPattern(
+                        ? LockPatternChecker.verifyCredential(
                                 mLockPatternUtils, pattern, challenge, localUserId,
                                 onVerifyCallback)
                         : LockPatternChecker.verifyTiedProfileChallenge(
-                                mLockPatternUtils, LockPatternUtils.patternToByteArray(pattern),
-                                true, challenge, localUserId, onVerifyCallback);
+                                mLockPatternUtils, pattern,
+                                challenge, localUserId, onVerifyCallback);
             }
 
-            private void startCheckPattern(final List<LockPatternView.Cell> pattern,
+            private void startCheckPattern(final LockscreenCredential pattern,
                     final Intent intent) {
                 if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
                     // Pattern size is less than the minimum, do not count it as an fail attempt.
@@ -461,7 +464,7 @@
                 }
 
                 final int localEffectiveUserId = mEffectiveUserId;
-                mPendingLockCheck = LockPatternChecker.checkPattern(
+                mPendingLockCheck = LockPatternChecker.checkCredential(
                         mLockPatternUtils,
                         pattern,
                         localEffectiveUserId,
@@ -473,7 +476,7 @@
                                     intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
                                                     StorageManager.CRYPT_TYPE_PATTERN);
                                     intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
-                                                    LockPatternUtils.patternToByteArray(pattern));
+                                                    pattern);
                                 }
                                 mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
                                         localEffectiveUserId);
diff --git a/src/com/android/settings/password/ManagedLockPasswordProvider.java b/src/com/android/settings/password/ManagedLockPasswordProvider.java
index 5006926..ac8a73a 100644
--- a/src/com/android/settings/password/ManagedLockPasswordProvider.java
+++ b/src/com/android/settings/password/ManagedLockPasswordProvider.java
@@ -19,6 +19,8 @@
 import android.content.Context;
 import android.content.Intent;
 
+import com.android.internal.widget.LockscreenCredential;
+
 /**
  * Helper for handling managed passwords in security settings UI.
  * It provides resources that should be shown in settings UI when lock password quality is set to
@@ -59,7 +61,7 @@
      * @param password Current lock password.
      * @return Intent that should update lock password to a managed password.
      */
-    Intent createIntent(boolean requirePasswordToDecrypt, byte[] password) {
+    Intent createIntent(boolean requirePasswordToDecrypt, LockscreenCredential password) {
         return null;
     }
 }
diff --git a/src/com/android/settings/security/CryptKeeperSettings.java b/src/com/android/settings/security/CryptKeeperSettings.java
index 6555f56..aa47b2b 100644
--- a/src/com/android/settings/security/CryptKeeperSettings.java
+++ b/src/com/android/settings/security/CryptKeeperSettings.java
@@ -37,6 +37,7 @@
 import androidx.appcompat.app.AlertDialog;
 import androidx.preference.Preference;
 
+import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.CryptKeeperConfirm;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -193,9 +194,10 @@
         // confirmation prompt; otherwise, go back to the initial state.
         if (resultCode == Activity.RESULT_OK && data != null) {
             int type = data.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE, -1);
-            byte[] password = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
-            if (!(password == null || password.length == 0)) {
-                showFinalConfirmation(type, password);
+            LockscreenCredential password = data.getParcelableExtra(
+                    ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+            if (password != null && !password.isNone()) {
+                showFinalConfirmation(type, password.getCredential());
             }
         }
     }
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index bf374de..4bac601 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -32,6 +32,7 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.core.PreferenceControllerMixin;
@@ -70,8 +71,8 @@
     private RestrictedSwitchPreference mUnifyProfile;
 
 
-    private byte[] mCurrentDevicePassword;
-    private byte[] mCurrentProfilePassword;
+    private LockscreenCredential mCurrentDevicePassword;
+    private LockscreenCredential mCurrentProfilePassword;
     private boolean mKeepDeviceLock;
 
     @Override
@@ -89,6 +90,8 @@
                 .getSecurityFeatureProvider()
                 .getLockPatternUtils(context);
         mProfileUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
+        mCurrentDevicePassword = LockscreenCredential.createNone();
+        mCurrentProfilePassword = LockscreenCredential.createNone();
     }
 
     @Override
@@ -151,13 +154,13 @@
         } else if (requestCode == UNIFY_LOCK_CONFIRM_DEVICE_REQUEST
                 && resultCode == Activity.RESULT_OK) {
             mCurrentDevicePassword =
-                    data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+                    data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
             launchConfirmProfileLock();
             return true;
         } else if (requestCode == UNIFY_LOCK_CONFIRM_PROFILE_REQUEST
                 && resultCode == Activity.RESULT_OK) {
             mCurrentProfilePassword =
-                    data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
+                    data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
             unifyLocks();
             return true;
         }
@@ -221,17 +224,8 @@
     }
 
     private void unifyKeepingWorkLock() {
-        final int profileQuality =
-                mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileUserId);
-        // PASSWORD_QUALITY_SOMETHING means pattern, everything above means PIN/password.
-        if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
-            mLockPatternUtils.saveLockPattern(
-                    LockPatternUtils.byteArrayToPattern(mCurrentProfilePassword),
-                    mCurrentDevicePassword, MY_USER_ID);
-        } else {
-            mLockPatternUtils.saveLockPassword(
-                    mCurrentProfilePassword, mCurrentDevicePassword, profileQuality, MY_USER_ID);
-        }
+        mLockPatternUtils.setLockCredential(
+                mCurrentProfilePassword, mCurrentDevicePassword, MY_USER_ID);
         mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileUserId, false,
                 mCurrentProfilePassword);
         final boolean profilePatternVisibility =
diff --git a/src/com/android/settings/slices/SlicePreference.java b/src/com/android/settings/slices/SlicePreference.java
index a2a7fe1..fe5ed60 100644
--- a/src/com/android/settings/slices/SlicePreference.java
+++ b/src/com/android/settings/slices/SlicePreference.java
@@ -46,6 +46,7 @@
         mSliceView = findViewById(R.id.slice_view);
         mSliceView.setShowTitleItems(true);
         mSliceView.setScrollable(false);
+        mSliceView.setVisibility(View.GONE);
     }
 
     public void onSliceUpdated(Slice slice) {
diff --git a/src/com/android/settings/slices/SlicePreferenceController.java b/src/com/android/settings/slices/SlicePreferenceController.java
index 8f3d0fb..df28304 100644
--- a/src/com/android/settings/slices/SlicePreferenceController.java
+++ b/src/com/android/settings/slices/SlicePreferenceController.java
@@ -65,7 +65,6 @@
         mUri = uri;
         mLiveData = SliceLiveData.fromUri(mContext, mUri, (int type, Throwable source) -> {
             Log.w(TAG, "Slice may be null. uri = " + uri + ", error = " + type);
-            onChanged(null);
         });
 
         //TODO(b/120803703): figure out why we need to remove observer first
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
index b8e36a4..81803dd 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
@@ -16,10 +16,8 @@
 
 package com.android.settings.wifi.savedaccesspoints;
 
-
 import android.content.Context;
 import android.net.wifi.WifiManager;
-import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
@@ -27,10 +25,6 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.R;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.utils.ThreadUtils;
 import com.android.settingslib.wifi.AccessPoint;
 import com.android.settingslib.wifi.AccessPointPreference;
 import com.android.settingslib.wifi.AccessPointPreference.UserBadgeCache;
@@ -38,21 +32,22 @@
 
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Controller that manages a PreferenceGroup, which contains a list of saved access points.
  */
 public class SavedAccessPointsPreferenceController extends BasePreferenceController implements
-        LifecycleObserver, OnStart, Preference.OnPreferenceClickListener,
-        WifiManager.ActionListener {
+        Preference.OnPreferenceClickListener {
 
-    private static final String TAG = "SavedAPPrefCtrl";
+    private static final String TAG = "SavedApPrefCtrl";
 
     private final WifiManager mWifiManager;
-
     private final UserBadgeCache mUserBadgeCache;
     private PreferenceGroup mPreferenceGroup;
     private SavedAccessPointsWifiSettings mHost;
+    @VisibleForTesting
+    List<AccessPoint> mAccessPoints;
 
     public SavedAccessPointsPreferenceController(Context context,
             String preferenceKey) {
@@ -68,86 +63,46 @@
 
     @Override
     public int getAvailabilityStatus() {
-        return AVAILABLE;
+        return mAccessPoints.size() > 0 ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
         mPreferenceGroup = screen.findPreference(getPreferenceKey());
-    }
-
-    @Override
-    public void onStart() {
         refreshSavedAccessPoints();
-    }
-
-    public void postRefreshSavedAccessPoints() {
-        ThreadUtils.postOnMainThread(() -> refreshSavedAccessPoints());
+        updatePreference();
+        super.displayPreference(screen);
     }
 
     @Override
     public boolean onPreferenceClick(Preference preference) {
-        final Preference preferenceInGroup = mPreferenceGroup.findPreference(preference.getKey());
         if (mHost != null) {
+            final Preference preferenceInGroup =
+                    mPreferenceGroup.findPreference(preference.getKey());
             mHost.showWifiPage((AccessPointPreference) preferenceInGroup);
         }
         return false;
     }
 
-    @Override
-    public void onSuccess() {
-        postRefreshSavedAccessPoints();
+    private void refreshSavedAccessPoints() {
+        mAccessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager).stream()
+                .filter(accessPoint -> !accessPoint.isPasspointConfig())
+                .sorted(SavedNetworkComparator.INSTANCE)
+                .collect(Collectors.toList());
     }
 
-    @Override
-    public void onFailure(int reason) {
-        postRefreshSavedAccessPoints();
-    }
-
-    @VisibleForTesting
-    void refreshSavedAccessPoints() {
-        if (mPreferenceGroup == null) {
-            Log.w(TAG, "PreferenceGroup is null, skipping.");
-            return;
-        }
-        final Context prefContext = mPreferenceGroup.getContext();
-
-        final List<AccessPoint> accessPoints =
-                WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
-        Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
+    private void updatePreference() {
         mPreferenceGroup.removeAll();
+        for (AccessPoint accessPoint : mAccessPoints) {
+            final String key = accessPoint.getKey();
 
-        final int accessPointsSize = accessPoints.size();
-        for (int i = 0; i < accessPointsSize; ++i) {
-            AccessPoint ap = accessPoints.get(i);
-
-            if (mHost != null && mHost.isSubscriptionsFeatureEnabled()
-                    && ap.isPasspointConfig()) {
-                continue;
-            }
-
-            String key = ap.getKey();
-            AccessPointPreference preference = new AccessPointPreference(ap, prefContext,
-                    mUserBadgeCache, true);
+            final AccessPointPreference preference = new AccessPointPreference(accessPoint,
+                    mContext, mUserBadgeCache, true /* forSavedNetworks */);
             preference.setKey(key);
             preference.setIcon(null);
             preference.setOnPreferenceClickListener(this);
+
             mPreferenceGroup.addPreference(preference);
-            preference.setOrder(i);
-        }
-
-        if (mPreferenceGroup.getPreferenceCount() < 1) {
-            Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
-            mPreferenceGroup.setVisible(false);
-        } else {
-            mPreferenceGroup.setVisible(true);
-        }
-
-        if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
-            mPreferenceGroup.setVisible(true);
-            mPreferenceGroup.setTitle(null);
-            mPreferenceGroup.setLayoutResource(R.layout.preference_category_no_label);
         }
     }
 }
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
index cf2fc99..863e87a 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettings.java
@@ -20,13 +20,13 @@
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.os.Bundle;
-import android.util.FeatureFlagUtils;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.development.featureflags.FeatureFlagPersistent;
 import com.android.settings.wifi.WifiSettings;
 import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
 import com.android.settingslib.wifi.AccessPoint;
@@ -39,7 +39,8 @@
 
     private static final String TAG = "SavedAccessPoints";
 
-    private Bundle mAccessPointSavedState;
+    @VisibleForTesting
+    Bundle mAccessPointSavedState;
     private AccessPoint mSelectedAccessPoint;
 
     // Instance state key
@@ -76,10 +77,22 @@
             if (savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
                 mAccessPointSavedState =
                         savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
+            } else {
+                mAccessPointSavedState = null;
             }
         }
     }
 
+    @Override
+    public void onStart() {
+        super.onStart();
+        if (mAccessPointSavedState != null) {
+            final PreferenceScreen screen = getPreferenceScreen();
+            use(SavedAccessPointsPreferenceController.class).displayPreference(screen);
+            use(SubscribedAccessPointsPreferenceController.class).displayPreference(screen);
+        }
+    }
+
     public void showWifiPage(@Nullable AccessPointPreference accessPoint) {
         removeDialog(WifiSettings.WIFI_DIALOG_ID);
 
@@ -117,9 +130,4 @@
             outState.putBundle(SAVE_DIALOG_ACCESS_POINT_STATE, mAccessPointSavedState);
         }
     }
-
-    boolean isSubscriptionsFeatureEnabled() {
-        return FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.MOBILE_NETWORK_V2)
-                && FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2);
-    }
 }
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
index 048999a..4d7dc60 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceController.java
@@ -16,10 +16,8 @@
 
 package com.android.settings.wifi.savedaccesspoints;
 
-
 import android.content.Context;
 import android.net.wifi.WifiManager;
-import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
@@ -27,10 +25,6 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.utils.PreferenceGroupChildrenCache;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.utils.ThreadUtils;
 import com.android.settingslib.wifi.AccessPoint;
 import com.android.settingslib.wifi.AccessPointPreference;
 import com.android.settingslib.wifi.AccessPointPreference.UserBadgeCache;
@@ -38,29 +32,28 @@
 
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Controller that manages a PreferenceGroup, which contains a list of subscribed access points.
  */
-// TODO(b/127206629): Code refactor to avoid duplicated coding after removed feature flag.
 public class SubscribedAccessPointsPreferenceController extends BasePreferenceController implements
-        LifecycleObserver, OnStart, Preference.OnPreferenceClickListener,
-        WifiManager.ActionListener {
+        Preference.OnPreferenceClickListener {
 
-    private static final String TAG = "SubscribedAPPrefCtrl";
+    private static final String TAG = "SubscribedApPrefCtrl";
 
     private final WifiManager mWifiManager;
-    private final PreferenceGroupChildrenCache mChildrenCache;
     private final UserBadgeCache mUserBadgeCache;
     private PreferenceGroup mPreferenceGroup;
     private SavedAccessPointsWifiSettings mHost;
+    @VisibleForTesting
+    List<AccessPoint> mAccessPoints;
 
     public SubscribedAccessPointsPreferenceController(Context context,
             String preferenceKey) {
         super(context, preferenceKey);
         mUserBadgeCache = new AccessPointPreference.UserBadgeCache(context.getPackageManager());
         mWifiManager = context.getSystemService(WifiManager.class);
-        mChildrenCache = new PreferenceGroupChildrenCache();
     }
 
     public SubscribedAccessPointsPreferenceController setHost(SavedAccessPointsWifiSettings host) {
@@ -70,89 +63,46 @@
 
     @Override
     public int getAvailabilityStatus() {
-        return AVAILABLE;
+        return mAccessPoints.size() > 0 ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
         mPreferenceGroup = screen.findPreference(getPreferenceKey());
-    }
-
-    @Override
-    public void onStart() {
         refreshSubscribedAccessPoints();
-    }
-
-    public void postRefreshSubscribedAccessPoints() {
-        ThreadUtils.postOnMainThread(() -> refreshSubscribedAccessPoints());
+        updatePreference();
+        super.displayPreference(screen);
     }
 
     @Override
     public boolean onPreferenceClick(Preference preference) {
         if (mHost != null) {
-            mHost.showWifiPage((AccessPointPreference) preference);
+            final Preference preferenceInGroup =
+                    mPreferenceGroup.findPreference(preference.getKey());
+            mHost.showWifiPage((AccessPointPreference) preferenceInGroup);
         }
         return false;
     }
 
-    @Override
-    public void onSuccess() {
-        postRefreshSubscribedAccessPoints();
+    private void refreshSubscribedAccessPoints() {
+        mAccessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager).stream()
+                .filter(accessPoint -> accessPoint.isPasspointConfig())
+                .sorted(SavedNetworkComparator.INSTANCE)
+                .collect(Collectors.toList());
     }
 
-    @Override
-    public void onFailure(int reason) {
-        postRefreshSubscribedAccessPoints();
-    }
+    private void updatePreference() {
+        mPreferenceGroup.removeAll();
+        for (AccessPoint accessPoint : mAccessPoints) {
+            final String key = accessPoint.getKey();
 
-    @VisibleForTesting
-    void refreshSubscribedAccessPoints() {
-        if (mPreferenceGroup == null) {
-            Log.w(TAG, "PreferenceGroup is null, skipping.");
-            return;
-        }
+            final AccessPointPreference preference = new AccessPointPreference(accessPoint,
+                    mContext, mUserBadgeCache, true /* forSavedNetworks */);
+            preference.setKey(key);
+            preference.setIcon(null);
+            preference.setOnPreferenceClickListener(this);
 
-        if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
-            mPreferenceGroup.setVisible(false);
-            return;
-        }
-
-        final Context prefContext = mPreferenceGroup.getContext();
-
-        final List<AccessPoint> accessPoints =
-                WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
-        Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
-        mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
-
-        final int accessPointsSize = accessPoints.size();
-        for (int i = 0; i < accessPointsSize; ++i) {
-            AccessPoint ap = accessPoints.get(i);
-            if (!ap.isPasspointConfig()) {
-                continue;
-            }
-
-            final String key = ap.getKey();
-            AccessPointPreference preference =
-                    (AccessPointPreference) mChildrenCache.getCachedPreference(key);
-            if (preference == null) {
-                preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
-                preference.setKey(key);
-                preference.setIcon(null);
-                preference.setOnPreferenceClickListener(this);
-                mPreferenceGroup.addPreference(preference);
-            }
-            preference.setOrder(i);
-        }
-
-        mChildrenCache.removeCachedPrefs(mPreferenceGroup);
-
-        if (mPreferenceGroup.getPreferenceCount() < 1) {
-            Log.w(TAG, "Subscribed networks activity loaded,"
-                    + " but there are no subscribed networks!");
-            mPreferenceGroup.setVisible(false);
-        } else {
-            mPreferenceGroup.setVisible(true);
+            mPreferenceGroup.addPreference(preference);
         }
     }
 }
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index 65f485e..bf64190 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -46,6 +46,7 @@
 import com.android.settings.AccessiblePreferenceCategory;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
 import com.android.settings.testutils.shadow.ShadowAccountManager;
 import com.android.settings.testutils.shadow.ShadowContentResolver;
 import com.android.settingslib.search.SearchIndexableRaw;
@@ -96,7 +97,8 @@
         when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
             .thenReturn(new AuthenticatorDescription[0]);
         when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
-        mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper);
+        mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper,
+                ProfileSelectFragment.ALL);
     }
 
     @After
diff --git a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
index f747842..f59ef85 100644
--- a/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AllowSoundPreferenceControllerTest.java
@@ -67,7 +67,7 @@
     private PreferenceScreen mScreen;
 
     @Mock
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     private AllowSoundPreferenceController mController;
 
diff --git a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
index 41655fa..4c22a6d 100644
--- a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
@@ -68,7 +68,7 @@
     private UserManager mUm;
 
     @Mock
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     private BlockPreferenceController mController;
     @Mock
diff --git a/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java
index a89a826..db2eca0 100644
--- a/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/HighImportancePreferenceControllerTest.java
@@ -60,7 +60,7 @@
     @Mock
     private NotificationBackend mBackend;
     @Mock
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
     @Mock
     private UserManager mUm;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
index 999631e..9b91a07 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
@@ -66,7 +66,7 @@
     @Mock
     private NotificationBackend mBackend;
     @Mock
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
     @Mock
     private UserManager mUm;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java
index b8ef7d1..abed4aa 100644
--- a/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/MinImportancePreferenceControllerTest.java
@@ -60,7 +60,7 @@
     @Mock
     private NotificationBackend mBackend;
     @Mock
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
     @Mock
     private UserManager mUm;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
index f09f63b..3e727e9 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
@@ -79,7 +79,7 @@
     @Mock
     private SettingsPreferenceFragment mFragment;
     @Mock
-    private NotificationSettingsBase.ImportanceListener mImportanceListener;
+    private NotificationSettings.ImportanceListener mImportanceListener;
 
     private SoundPreferenceController mController;
 
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
index 73707a6..084d710 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
@@ -41,6 +41,7 @@
 import android.content.Intent;
 import android.os.UserHandle;
 
+import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.R;
 import com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment;
 import com.android.settings.password.ChooseLockPassword.IntentBuilder;
@@ -87,7 +88,7 @@
     @Test
     public void intentBuilder_setPassword_shouldAddExtras() {
         Intent intent = new IntentBuilder(application)
-                .setPassword("password".getBytes())
+                .setPassword(LockscreenCredential.createPassword("password"))
                 .setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
                 .setUserId(123)
                 .build();
@@ -95,9 +96,10 @@
         assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
                 .named("EXTRA_KEY_HAS_CHALLENGE")
                 .isFalse();
-        assertThat(intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
+        assertThat((LockscreenCredential) intent.getParcelableExtra(
+                ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
                 .named("EXTRA_KEY_PASSWORD")
-                .isEqualTo("password".getBytes());
+                .isEqualTo(LockscreenCredential.createPassword("password"));
         assertThat(intent.getIntExtra(PASSWORD_TYPE_KEY, 0))
                 .named("PASSWORD_TYPE_KEY")
                 .isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
@@ -154,7 +156,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "",
+                /* userEnteredPassword= */ LockscreenCredential.createNone(),
                 "Must contain at least 1 letter",
                 "Must be at least 10 characters");
     }
@@ -166,7 +168,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_NUMERIC,
-                /* userEnteredPassword= */ "",
+                /* userEnteredPassword= */ LockscreenCredential.createNone(),
                 "PIN must be at least 8 digits");
     }
 
@@ -177,7 +179,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_MEDIUM,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "",
+                /* userEnteredPassword= */ LockscreenCredential.createNone(),
                 "Must contain at least 1 letter",
                 "Must be at least 4 characters");
     }
@@ -190,7 +192,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_LOW,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "",
+                /* userEnteredPassword= */ LockscreenCredential.createNone(),
                 "Must contain at least 1 letter",
                 "Must contain at least 1 numerical digit",
                 "Must be at least 9 characters");
@@ -204,7 +206,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_MEDIUM,
                 /* passwordType= */ PASSWORD_QUALITY_NUMERIC,
-                /* userEnteredPassword= */ "",
+                /* userEnteredPassword= */ LockscreenCredential.createNone(),
                 "PIN must be at least 11 digits");
     }
 
@@ -216,7 +218,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "",
+                /* userEnteredPassword= */ LockscreenCredential.createNone(),
                 "Must contain at least 2 special symbols",
                 "Must be at least 6 characters");
     }
@@ -229,7 +231,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
                 /* passwordType= */ PASSWORD_QUALITY_NUMERIC,
-                /* userEnteredPassword= */ "12345678",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
                 "Ascending, descending, or repeated sequence of digits isn't allowed");
     }
 
@@ -241,7 +243,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_NONE,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "12345678",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
                 "Ascending, descending, or repeated sequence of digits isn't allowed");
     }
 
@@ -253,7 +255,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_NUMERIC,
-                /* userEnteredPassword= */ "12345678",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
                 "Ascending, descending, or repeated sequence of digits isn't allowed");
     }
 
@@ -265,7 +267,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_NUMERIC,
-                /* userEnteredPassword= */ "12345678",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
                 "Ascending, descending, or repeated sequence of digits isn't allowed");
     }
 
@@ -277,7 +279,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_LOW,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "12345678",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("12345678"),
                 "Must contain at least 1 letter");
     }
 
@@ -288,7 +290,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "",
+                /* userEnteredPassword= */ LockscreenCredential.createNone(),
                 "Must contain at least 1 letter",
                 "Must be at least 6 characters");
     }
@@ -300,7 +302,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "1",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("1"),
                 "Must contain at least 1 letter",
                 "Must be at least 6 characters");
     }
@@ -312,7 +314,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "b",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("b"),
                 "Must be at least 6 characters");
     }
 
@@ -323,7 +325,7 @@
         assertPasswordValidationResult(
                 /* minComplexity= */ PASSWORD_COMPLEXITY_HIGH,
                 /* passwordType= */ PASSWORD_QUALITY_ALPHABETIC,
-                /* userEnteredPassword= */ "b1",
+                /* userEnteredPassword= */ LockscreenCredential.createPassword("b1"),
                 "Must be at least 6 characters");
     }
 
@@ -359,16 +361,15 @@
     }
 
     private void assertPasswordValidationResult(@PasswordComplexity int minComplexity,
-            int passwordType, String userEnteredPassword, String... expectedValidationResult) {
+            int passwordType, LockscreenCredential userEnteredPassword,
+            String... expectedValidationResult) {
         Intent intent = new Intent();
         intent.putExtra(CONFIRM_CREDENTIALS, false);
         intent.putExtra(PASSWORD_TYPE_KEY, passwordType);
         intent.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, minComplexity);
         ChooseLockPassword activity = buildChooseLockPasswordActivity(intent);
         ChooseLockPasswordFragment fragment = getChooseLockPasswordFragment(activity);
-        byte[] userEnteredPasswordBytes = userEnteredPassword != null
-                ? userEnteredPassword.getBytes() : null;
-        int validateResult = fragment.validatePassword(userEnteredPasswordBytes);
+        int validateResult = fragment.validatePassword(userEnteredPassword);
         String[] messages = fragment.convertErrorCodeToMessages(validateResult);
 
         assertThat(messages).asList().containsExactly((Object[]) expectedValidationResult);
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index 48ebbec..0100744 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -24,6 +24,8 @@
 import android.os.UserHandle;
 import android.view.View;
 
+import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.R;
 import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
 import com.android.settings.password.ChooseLockPattern.IntentBuilder;
@@ -52,7 +54,7 @@
     @Test
     public void intentBuilder_setPattern_shouldAddExtras() {
         Intent intent = new IntentBuilder(application)
-                .setPattern("pattern".getBytes())
+                .setPattern(createPattern("1234"))
                 .setUserId(123)
                 .build();
 
@@ -60,10 +62,10 @@
                 .getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
                 .named("EXTRA_KEY_HAS_CHALLENGE")
                 .isFalse();
-        assertThat(intent
-                .getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
+        assertThat((LockscreenCredential) intent
+                .getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
                 .named("EXTRA_KEY_PASSWORD")
-                .isEqualTo("pattern".getBytes());
+                .isEqualTo(createPattern("1234"));
         assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
                 .named("EXTRA_USER_ID")
                 .isEqualTo(123);
@@ -120,4 +122,9 @@
                         .build())
                 .setup().get();
     }
+
+    private LockscreenCredential createPattern(String patternString) {
+        return LockscreenCredential.createPattern(LockPatternUtils.byteArrayToPattern(
+                patternString.getBytes()));
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
index e9be346..38756ac 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
@@ -20,6 +20,7 @@
 import android.content.ComponentName;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
 
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
@@ -66,7 +67,8 @@
     }
 
     @Implementation
-    protected byte[] getPasswordHistoryHashFactor(byte[] currentPassword, int userId) {
+    protected byte[] getPasswordHistoryHashFactor(LockscreenCredential currentPassword,
+            int userId) {
         return null;
     }
 
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
index 196c97b..73e1297 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceControllerTest.java
@@ -17,11 +17,11 @@
 package com.android.settings.wifi.savedaccesspoints;
 
 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 static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
@@ -30,16 +30,19 @@
 import android.content.Context;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
+import android.os.Bundle;
 
 import androidx.preference.PreferenceCategory;
 import androidx.preference.PreferenceScreen;
 
-import com.android.settings.core.FeatureFlags;
-import com.android.settings.development.featureflags.FeatureFlagPersistent;
 import com.android.settings.testutils.shadow.ShadowAccessPoint;
 import com.android.settings.testutils.shadow.ShadowWifiManager;
+import com.android.settingslib.wifi.AccessPoint;
 import com.android.settingslib.wifi.AccessPointPreference;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -79,47 +82,21 @@
     }
 
     @Test
-    public void getAvailability_alwaysAvailable() {
+    public void getAvailability_noSavedAccessPoint_shouldNotAvailable() {
+        mController.mAccessPoints = new ArrayList<>();
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+    }
+
+    @Test
+    public void getAvailability_oneSavedAccessPoint_shouldAvailable() {
+        final AccessPoint accessPoint = new AccessPoint(mContext, new Bundle() /* savedState */);
+        mController.mAccessPoints = new ArrayList<AccessPoint>(Arrays.asList(accessPoint));
+
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
     }
 
     @Test
-    public void onStart_shouldRefreshApList() {
-        doNothing().when(mController).refreshSavedAccessPoints();
-
-        mController.onStart();
-
-        verify(mController).refreshSavedAccessPoints();
-    }
-
-    @Test
-    public void postRefresh_shouldRefreshApList() {
-        doNothing().when(mController).refreshSavedAccessPoints();
-
-        mController.postRefreshSavedAccessPoints();
-
-        verify(mController).refreshSavedAccessPoints();
-    }
-
-    @Test
-    public void forget_onSuccess_shouldRefreshApList() {
-        doNothing().when(mController).refreshSavedAccessPoints();
-
-        mController.onSuccess();
-
-        verify(mController).refreshSavedAccessPoints();
-    }
-
-    @Test
-    public void forget_onFailure_shouldRefreshApList() {
-        doNothing().when(mController).refreshSavedAccessPoints();
-
-        mController.onFailure(0 /* reason */);
-
-        verify(mController).refreshSavedAccessPoints();
-    }
-
-    @Test
     @Config(shadows = ShadowAccessPoint.class)
     public void refreshSavedAccessPoints_shouldListNonSubscribedAPs() {
         final WifiConfiguration config = new WifiConfiguration();
@@ -131,7 +108,6 @@
         final ArgumentCaptor<AccessPointPreference> captor =
                 ArgumentCaptor.forClass(AccessPointPreference.class);
         mController.displayPreference(mPreferenceScreen);
-        mController.refreshSavedAccessPoints();
 
         verify(mPreferenceCategory).addPreference(captor.capture());
 
@@ -142,13 +118,10 @@
     @Test
     @Config(shadows = ShadowAccessPoint.class)
     public void refreshSavedAccessPoints_shouldNotListSubscribedAPs() {
-        FeatureFlagPersistent.setEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2, true);
-
         mWifiManager.addOrUpdatePasspointConfiguration(
                 SubscribedAccessPointsPreferenceControllerTest.createMockPasspointConfiguration());
 
         mController.displayPreference(mPreferenceScreen);
-        mController.refreshSavedAccessPoints();
 
         verify(mPreferenceCategory, never()).addPreference(any(AccessPointPreference.class));
     }
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
index cda4005..923f05e 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsWifiSettingsTest.java
@@ -23,6 +23,7 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settingslib.core.AbstractPreferenceController;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
index 581f531..f9307db 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
@@ -17,11 +17,11 @@
 package com.android.settings.wifi.savedaccesspoints;
 
 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 static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
@@ -32,16 +32,19 @@
 import android.net.wifi.WifiManager;
 import android.net.wifi.hotspot2.PasspointConfiguration;
 import android.net.wifi.hotspot2.pps.HomeSp;
+import android.os.Bundle;
 
 import androidx.preference.PreferenceCategory;
 import androidx.preference.PreferenceScreen;
 
-import com.android.settings.core.FeatureFlags;
-import com.android.settings.development.featureflags.FeatureFlagPersistent;
 import com.android.settings.testutils.shadow.ShadowAccessPoint;
 import com.android.settings.testutils.shadow.ShadowWifiManager;
+import com.android.settingslib.wifi.AccessPoint;
 import com.android.settingslib.wifi.AccessPointPreference;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -78,52 +81,24 @@
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
                 .thenReturn(mPreferenceCategory);
         when(mPreferenceCategory.getContext()).thenReturn(mContext);
-
-        FeatureFlagPersistent.setEnabled(mContext, FeatureFlags.NETWORK_INTERNET_V2, true);
     }
 
     @Test
-    public void getAvailability_alwaysAvailable() {
+    public void getAvailability_noSavedAccessPoint_shouldNotAvailable() {
+        mController.mAccessPoints = new ArrayList<>();
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+    }
+
+    @Test
+    public void getAvailability_oneSavedAccessPoint_shouldAvailable() {
+        final AccessPoint accessPoint = new AccessPoint(mContext, new Bundle() /* savedState */);
+        mController.mAccessPoints = new ArrayList<AccessPoint>(Arrays.asList(accessPoint));
+
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
     }
 
     @Test
-    public void onStart_shouldRefreshApList() {
-        doNothing().when(mController).refreshSubscribedAccessPoints();
-
-        mController.onStart();
-
-        verify(mController).refreshSubscribedAccessPoints();
-    }
-
-    @Test
-    public void postRefresh_shouldRefreshApList() {
-        doNothing().when(mController).refreshSubscribedAccessPoints();
-
-        mController.postRefreshSubscribedAccessPoints();
-
-        verify(mController).refreshSubscribedAccessPoints();
-    }
-
-    @Test
-    public void forget_onSuccess_shouldRefreshApList() {
-        doNothing().when(mController).refreshSubscribedAccessPoints();
-
-        mController.onSuccess();
-
-        verify(mController).refreshSubscribedAccessPoints();
-    }
-
-    @Test
-    public void forget_onFailure_shouldRefreshApList() {
-        doNothing().when(mController).refreshSubscribedAccessPoints();
-
-        mController.onFailure(0 /* reason */);
-
-        verify(mController).refreshSubscribedAccessPoints();
-    }
-
-    @Test
     @Config(shadows = ShadowAccessPoint.class)
     public void refreshSubscribedAccessPoints_shouldNotListNonSubscribedAPs() {
         final WifiConfiguration config = new WifiConfiguration();
@@ -133,7 +108,6 @@
         mWifiManager.addNetwork(config);
 
         mController.displayPreference(mPreferenceScreen);
-        mController.refreshSubscribedAccessPoints();
 
         verify(mPreferenceCategory, never()).addPreference(any(AccessPointPreference.class));
     }
@@ -144,7 +118,6 @@
         mWifiManager.addOrUpdatePasspointConfiguration(createMockPasspointConfiguration());
 
         mController.displayPreference(mPreferenceScreen);
-        mController.refreshSubscribedAccessPoints();
 
         final ArgumentCaptor<AccessPointPreference> captor =
                 ArgumentCaptor.forClass(AccessPointPreference.class);
diff --git a/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java b/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java
deleted file mode 100644
index 1701ddf..0000000
--- a/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java
+++ /dev/null
@@ -1,73 +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;
-
-import static junit.framework.Assert.fail;
-
-import android.app.Instrumentation;
-import android.app.UiAutomation;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ResolveInfo;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class RegulatoryInfoDisplayActivityTest {
-    private static final String TAG = "RegulatoryInfoTest";
-
-    private Instrumentation mInstrumentation;
-    private Intent mRegulatoryInfoIntent;
-    private UiAutomation mUiAutomation;
-
-    @Before
-    public void setUp() {
-        mInstrumentation = InstrumentationRegistry.getInstrumentation();
-        mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
-        mRegulatoryInfoIntent = new Intent("android.settings.SHOW_REGULATORY_INFO")
-                .addCategory(Intent.CATEGORY_DEFAULT)
-                .setPackage(mInstrumentation.getTargetContext().getPackageName());
-    }
-
-    @Test
-    public void resolveRegulatoryInfoIntent_intentShouldMatchConfig() {
-        // Load intent from PackageManager and load config from Settings app
-        final Context context = mInstrumentation.getTargetContext();
-
-        final boolean hasRegulatoryInfo = context.getResources()
-                .getBoolean(R.bool.config_show_regulatory_info);
-        final ResolveInfo resolveInfo = mInstrumentation.getTargetContext().getPackageManager()
-                .resolveActivity(mRegulatoryInfoIntent, 0 /* flags */);
-
-        // Check config and intent both enable or both disabled.
-        if (hasRegulatoryInfo && resolveInfo == null) {
-            fail("Config enables regulatory info but there is no handling intent");
-            return;
-        }
-        if (!hasRegulatoryInfo && resolveInfo != null) {
-            fail("Config disables regulatory info but there is at least one handling intent");
-            return;
-        }
-    }
-}
diff --git a/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java b/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java
index 582afd2..4b539cc 100644
--- a/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java
+++ b/tests/unit/src/com/android/settings/password/ChooseLockGenericTest.java
@@ -43,6 +43,7 @@
 import androidx.test.runner.lifecycle.Stage;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockscreenCredential;
 
 import org.junit.Before;
 import org.junit.Rule;
@@ -150,7 +151,7 @@
                 .putExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
                         DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
                 .putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
-                        "12345")
+                        LockscreenCredential.createPin("12345"))
                 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         getInstrumentation().getContext().startActivity(newPasswordIntent);
         mDevice.waitForIdle();