Merge "Fix ANR of SimSlotChangeService" into udc-dev
diff --git a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
deleted file mode 100644
index 11bb0ae..0000000
--- a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2018 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.
--->
-
-<com.google.android.setupdesign.GlifLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:icon="@drawable/ic_scan_32dp"
-    app:sudDescriptionText="@string/wifi_dpp_scan_qr_code_join_unknown_network">
-
-    <LinearLayout
-        style="@style/SudContentFrame"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:gravity="center_horizontal"
-        android:orientation="vertical">
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:gravity="center"
-            android:orientation="vertical">
-
-            <FrameLayout
-                android:layout_width="@dimen/qrcode_preview_size"
-                android:layout_height="@dimen/qrcode_preview_size"
-                android:clipChildren="true">
-                <TextureView
-                    android:id="@+id/preview_view"
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"/>
-                <com.android.settingslib.qrcode.QrDecorateView
-                    android:id="@+id/decorate_view"
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"/>
-            </FrameLayout>
-
-            <TextView
-                android:id="@+id/error_message"
-                style="@style/TextAppearance.ErrorText"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="16dp"
-                android:layout_marginStart="?attr/sudMarginStart"
-                android:layout_marginEnd="?attr/sudMarginEnd"
-                android:textAlignment="center"
-                android:visibility="invisible"/>
-
-        </LinearLayout>
-
-    </LinearLayout>
-
-</com.google.android.setupdesign.GlifLayout>
-
diff --git a/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml b/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml
index 74c8226..e770123 100644
--- a/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml
+++ b/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml
@@ -58,7 +58,7 @@
                     android:src="@drawable/ic_info_outline_24dp"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:tint="?android:attr/textColorTertiary"/>
+                    android:tint="?android:attr/textColorSecondary"/>
                 <TextView
                     android:id="@+id/info_outline"
                     android:layout_width="wrap_content"
diff --git a/res/layout/user_credential.xml b/res/layout/user_credential.xml
index fa7abb3..adf2680 100644
--- a/res/layout/user_credential.xml
+++ b/res/layout/user_credential.xml
@@ -52,7 +52,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="?android:attr/textColorTertiary"
+            android:textColor="?android:attr/textColorSecondary"
             android:paddingStart="?android:attr/listPreferredItemPaddingStart"/>
 
         <TextView
@@ -69,7 +69,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="?android:attr/textColorTertiary"
+            android:textColor="?android:attr/textColorSecondary"
             android:paddingStart="?android:attr/listPreferredItemPaddingStart"/>
 
         <TextView
@@ -78,7 +78,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="?android:attr/textColorTertiary"
+            android:textColor="?android:attr/textColorSecondary"
             android:paddingStart="?android:attr/listPreferredItemPaddingStart"/>
 
         <TextView
@@ -87,7 +87,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textAppearance="?android:attr/textAppearanceSmall"
-            android:textColor="?android:attr/textColorTertiary"
+            android:textColor="?android:attr/textColorSecondary"
             android:paddingStart="?android:attr/listPreferredItemPaddingStart"/>
     </LinearLayout>
 </LinearLayout>
diff --git a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
index dd96d7e..84470ba 100644
--- a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
@@ -36,19 +36,31 @@
             android:gravity="center"
             android:orientation="vertical">
 
-            <FrameLayout
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:clipChildren="true">
-                <TextureView
-                    android:id="@+id/preview_view"
-                    android:layout_width="match_parent"
-                    android:layout_height="@dimen/qrcode_preview_size"/>
-                <com.android.settingslib.qrcode.QrDecorateView
-                    android:id="@+id/decorate_view"
-                    android:layout_width="match_parent"
-                    android:layout_height="@dimen/qrcode_preview_size"/>
-            </FrameLayout>
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:maxWidth="@dimen/qrcode_preview_size"
+                android:maxHeight="@dimen/qrcode_preview_size">
+
+                <FrameLayout
+                    android:layout_width="0dp"
+                    android:layout_height="0dp"
+                    app:layout_constraintDimensionRatio="1:1"
+                    app:layout_constraintTop_toTopOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    android:clipChildren="true">
+                    <TextureView
+                        android:id="@+id/preview_view"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"/>
+                    <com.android.settingslib.qrcode.QrDecorateView
+                        android:id="@+id/decorate_view"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"/>
+                </FrameLayout>
+
+            </androidx.constraintlayout.widget.ConstraintLayout>
 
             <TextView
                 android:id="@+id/error_message"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 184b7c7..b12f390 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -818,6 +818,10 @@
     <string name="biometric_settings_intro_with_fingerprint">You can unlock with your watch when your fingerprint isn\u2019t recognized.</string>
      <!-- Introduction shown in face page to explain that watch unlock can be used if face isn't recognized. [CHAR LIMIT=NONE]-->
     <string name="biometric_settings_intro_with_face">You can unlock with your watch when your face isn\u2019t recognized.</string>
+    <string name="biometric_settings_use_fingerprint_or_watch_for"> Use fingerprint or watch to</string>
+    <string name="biometric_settings_use_face_or_watch_for"> Use face or watch to</string>
+    <string name="biometric_settings_use_face_fingerprint_or_watch_for"> Use face, fingerprint, or watch to</string>
+    <string name="biometric_settings_use_watch_for"> Use watch to</string>
     <!-- Message for a biometric preference toggle, indicating that an action can only be performed by using Face Unlock or Watch Unlock. [CHAR LIMIT=50] -->
     <string name="biometric_settings_use_face_or_watch_preference_summary">Using face or watch</string>
     <!-- Message for a biometric preference toggle, indicating that an action can only be performed by using Fingerprint Unlock or Watch Unlock. [CHAR LIMIT=50] -->
diff --git a/res/xml/accounts_work_dashboard_settings_credman.xml b/res/xml/accounts_work_dashboard_settings_credman.xml
index 1529920..bb9976e 100644
--- a/res/xml/accounts_work_dashboard_settings_credman.xml
+++ b/res/xml/accounts_work_dashboard_settings_credman.xml
@@ -28,8 +28,8 @@
         android:title="@string/credman_chosen_app_title">
 
         <com.android.settings.widget.GearPreference
-            android:fragment="com.android.settings.applications.credentials.DefaultCombinedPicker"
-            android:key="default_credman_autofill_main"
+            android:fragment="com.android.settings.applications.credentials.DefaultCombinedPickerWork"
+            android:key="default_credman_autofill_main_work"
             android:title="@string/credman_chosen_app_title"
             settings:searchable="false">
             <extra
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index e4c2031..7816fd7 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -86,7 +86,7 @@
                     forceUpdatePreferences();
                 }
             };
-            cmpp.init(this, getFragmentManager(), getIntent(), delegate);
+            cmpp.init(this, getFragmentManager(), getIntent(), delegate, /*isWorkProfile=*/false);
         } else {
             getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
         }
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index 32c3c13..cd1cd5c 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -78,7 +78,7 @@
                     forceUpdatePreferences();
                 }
             };
-            cmpp.init(this, getFragmentManager(), getIntent(), delegate);
+            cmpp.init(this, getFragmentManager(), getIntent(), delegate, /*isWorkProfile=*/false);
         } else {
             getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
         }
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index 39146c7..f0da2fb 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -78,7 +78,7 @@
                     forceUpdatePreferences();
                 }
             };
-            cmpp.init(this, getFragmentManager(), getIntent(), delegate);
+            cmpp.init(this, getFragmentManager(), getIntent(), delegate, /*isWorkProfile=*/true);
         } else {
             getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
         }
diff --git a/src/com/android/settings/applications/credentials/CombinedProviderInfo.java b/src/com/android/settings/applications/credentials/CombinedProviderInfo.java
index 89a13ef..1fd3075 100644
--- a/src/com/android/settings/applications/credentials/CombinedProviderInfo.java
+++ b/src/com/android/settings/applications/credentials/CombinedProviderInfo.java
@@ -26,6 +26,7 @@
 import android.graphics.drawable.Drawable;
 import android.service.autofill.AutofillServiceInfo;
 import android.text.TextUtils;
+import android.util.IconDrawableFactory;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -83,11 +84,12 @@
 
     /** Returns the app icon. */
     @Nullable
-    public Drawable getAppIcon(@NonNull Context context) {
+    public Drawable getAppIcon(@NonNull Context context, int userId) {
+        IconDrawableFactory factory = IconDrawableFactory.newInstance(context);
         Drawable icon = null;
         ServiceInfo brandingService = getBrandingService();
         if (brandingService != null) {
-            icon = brandingService.loadIcon(context.getPackageManager());
+            icon = factory.getBadgedIcon(brandingService, getApplicationInfo(), userId);
         }
 
         // If the branding service gave us a icon then use that.
@@ -95,8 +97,8 @@
             return icon;
         }
 
-        // Otherwise fallback to the app label and then the package name.
-        return getApplicationInfo().loadIcon(context.getPackageManager());
+        // Otherwise fallback to the app icon and then the package name.
+        return factory.getBadgedIcon(getApplicationInfo(), userId);
     }
 
     /** Returns the app name. */
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index 9d86c58a..e906e48 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -41,6 +41,7 @@
 import android.os.Handler;
 import android.os.OutcomeReceiver;
 import android.os.UserHandle;
+import android.os.UserManager;
 import android.provider.Settings;
 import android.service.autofill.AutofillServiceInfo;
 import android.text.TextUtils;
@@ -110,6 +111,7 @@
     private @Nullable PreferenceScreen mPreferenceScreen = null;
 
     private boolean mVisibility = false;
+    private boolean mIsWorkProfile = false;
 
     public CredentialManagerPreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
@@ -169,14 +171,17 @@
      * @param fragmentManager the fragment manager to use
      * @param intent the intent used to start the activity
      * @param delegate the delegate to send results back to
+     * @param isWorkProfile whether this controller is under a work profile user
      */
     public void init(
             DashboardFragment fragment,
             FragmentManager fragmentManager,
             @Nullable Intent launchIntent,
-            @NonNull Delegate delegate) {
+            @NonNull Delegate delegate,
+            boolean isWorkProfile) {
         fragment.getSettingsLifecycle().addObserver(this);
         mFragmentManager = fragmentManager;
+        mIsWorkProfile = isWorkProfile;
         setDelegate(delegate);
         verifyReceivedIntent(launchIntent);
     }
@@ -420,7 +425,7 @@
                 continue;
             }
 
-            Drawable icon = combinedInfo.getAppIcon(context);
+            Drawable icon = combinedInfo.getAppIcon(context, getUser());
             CharSequence title = combinedInfo.getAppName(context);
 
             // Build the pref and add it to the output & group.
@@ -681,9 +686,12 @@
         return new ConfirmationDialogFragment(host, packageName, appName);
     }
 
-    private int getUser() {
-        UserHandle workUser = getWorkProfileUser();
-        return workUser != null ? workUser.getIdentifier() : UserHandle.myUserId();
+    protected int getUser() {
+        if (mIsWorkProfile) {
+            UserHandle workProfile = Utils.getManagedProfile(UserManager.get(mContext));
+            return workProfile.getIdentifier();
+        }
+        return UserHandle.myUserId();
     }
 
     /** Called when the dialog button is clicked. */
diff --git a/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java b/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java
index 634be4c..b8d104c 100644
--- a/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java
+++ b/src/com/android/settings/applications/credentials/DefaultCombinedPicker.java
@@ -47,9 +47,7 @@
 import com.android.settingslib.widget.CandidateInfo;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 public class DefaultCombinedPicker extends DefaultAppPickerFragment {
 
@@ -65,6 +63,7 @@
     private DialogInterface.OnClickListener mCancelListener;
 
     private CredentialManager mCredentialManager;
+    private int mIntentSenderUserId = -1;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -79,9 +78,11 @@
                     };
             // If mCancelListener is not null, fragment is started from
             // ACTION_REQUEST_SET_AUTOFILL_SERVICE and we should always use the calling uid.
-            mUserId = UserHandle.myUserId();
+            mIntentSenderUserId = UserHandle.myUserId();
         }
 
+        getUser();
+
         mSettingsPackageMonitor.register(activity, activity.getMainLooper(), false);
         update();
     }
@@ -167,7 +168,7 @@
                 Settings.Secure.getStringForUser(
                         getActivity().getContentResolver(),
                         Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
-                        mUserId);
+                        getUser());
         if (TextUtils.isEmpty(searchUri)) {
             return null;
         }
@@ -177,7 +178,7 @@
         final Preference preference = new Preference(context);
         preference.setOnPreferenceClickListener(
                 p -> {
-                    context.startActivityAsUser(addNewServiceIntent, UserHandle.of(mUserId));
+                    context.startActivityAsUser(addNewServiceIntent, UserHandle.of(getUser()));
                     return true;
                 });
         preference.setTitle(R.string.print_menu_item_add_service);
@@ -212,17 +213,17 @@
     private List<CombinedProviderInfo> getAllProviders() {
         final Context context = getContext();
         final List<AutofillServiceInfo> autofillProviders =
-                AutofillServiceInfo.getAvailableServices(context, mUserId);
+                AutofillServiceInfo.getAvailableServices(context, getUser());
 
         final CredentialManager service = getCredentialProviderService();
         final List<CredentialProviderInfo> credManProviders = new ArrayList<>();
         if (service != null) {
             credManProviders.addAll(
                     service.getCredentialProviderServices(
-                            mUserId, CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY));
+                            getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY));
         }
 
-        final String selectedAutofillProvider = getSelectedAutofillProvider(context, mUserId);
+        final String selectedAutofillProvider = getSelectedAutofillProvider(context, getUser());
         return CombinedProviderInfo.buildMergedList(
                 autofillProviders, credManProviders, selectedAutofillProvider);
     }
@@ -244,7 +245,7 @@
                         new DefaultAppInfo(
                                 context,
                                 mPm,
-                                mUserId,
+                                getUser(),
                                 cpi.getApplicationInfo(),
                                 cpi.getSettingsSubtitle(),
                                 true));
@@ -253,7 +254,7 @@
                         new DefaultAppInfo(
                                 context,
                                 mPm,
-                                mUserId,
+                                getUser(),
                                 brandingService,
                                 cpi.getSettingsSubtitle(),
                                 true));
@@ -350,7 +351,7 @@
         }
 
         Settings.Secure.putStringForUser(
-                getContext().getContentResolver(), AUTOFILL_SETTING, autofillProvider, mUserId);
+                getContext().getContentResolver(), AUTOFILL_SETTING, autofillProvider, getUser());
 
         final CredentialManager service = getCredentialProviderService();
         if (service == null) {
@@ -362,19 +363,24 @@
         final List<String> credManProviders = new ArrayList<>();
         for (CredentialProviderInfo cpi :
                 service.getCredentialProviderServices(
-                        mUserId, CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY)) {
+                        getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY)) {
 
-            if (cpi.isEnabled()) {
+            if (cpi.isEnabled() && !cpi.isPrimary()) {
                 credManProviders.add(cpi.getServiceInfo().getComponentName().flattenToString());
             }
         }
 
         credManProviders.addAll(primaryCredManProviders);
 
+        // If there is no provider then clear all the providers.
+        if (TextUtils.isEmpty(autofillProvider) && primaryCredManProviders.isEmpty()) {
+            credManProviders.clear();
+        }
+
         service.setEnabledProviders(
                 primaryCredManProviders,
                 credManProviders,
-                mUserId,
+                getUser(),
                 ContextCompat.getMainExecutor(getContext()),
                 new OutcomeReceiver<Void, SetEnabledProvidersException>() {
                     @Override
@@ -388,4 +394,11 @@
                     }
                 });
     }
+
+    protected int getUser() {
+        if (mIntentSenderUserId >= 0) {
+            return mIntentSenderUserId;
+        }
+        return UserHandle.myUserId();
+    }
 }
diff --git a/src/com/android/settings/applications/credentials/DefaultCombinedPickerWork.java b/src/com/android/settings/applications/credentials/DefaultCombinedPickerWork.java
new file mode 100644
index 0000000..9808502
--- /dev/null
+++ b/src/com/android/settings/applications/credentials/DefaultCombinedPickerWork.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications.credentials;
+
+import android.os.UserHandle;
+import android.os.UserManager;
+
+import com.android.settings.Utils;
+
+public class DefaultCombinedPickerWork extends DefaultCombinedPicker {
+
+    @Override
+    protected int getUser() {
+        UserHandle workProfile = Utils.getManagedProfile(UserManager.get(getContext()));
+        return workProfile.getIdentifier();
+    }
+}
diff --git a/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java b/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java
index 64d4f0d..34881ab 100644
--- a/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java
@@ -24,6 +24,7 @@
 import android.content.pm.ServiceInfo;
 import android.credentials.CredentialManager;
 import android.credentials.CredentialProviderInfo;
+import android.os.UserHandle;
 import android.provider.Settings;
 import android.service.autofill.AutofillService;
 import android.service.autofill.AutofillServiceInfo;
@@ -75,13 +76,13 @@
             return null;
         }
         final AutofillSettingIntentProvider intentProvider =
-                new AutofillSettingIntentProvider(mContext, mUserId, info.getKey());
+                new AutofillSettingIntentProvider(mContext, getUser(), info.getKey());
         return intentProvider.getIntent();
     }
 
     @Override
     protected DefaultAppInfo getDefaultAppInfo() {
-        List<CombinedProviderInfo> providers = getAllProviders(mUserId);
+        List<CombinedProviderInfo> providers = getAllProviders(getUser());
         CombinedProviderInfo topProvider = CombinedProviderInfo.getTopProvider(providers);
         if (topProvider != null) {
             ServiceInfo brandingService = topProvider.getBrandingService();
@@ -89,7 +90,7 @@
                 return new DefaultAppInfo(
                         mContext,
                         mPackageManager,
-                        mUserId,
+                        getUser(),
                         topProvider.getApplicationInfo(),
                         topProvider.getSettingsSubtitle(),
                         true);
@@ -97,7 +98,7 @@
                 return new DefaultAppInfo(
                         mContext,
                         mPackageManager,
-                        mUserId,
+                        getUser(),
                         brandingService,
                         topProvider.getSettingsSubtitle(),
                         true);
@@ -178,4 +179,8 @@
             return null;
         }
     }
+
+    protected int getUser() {
+        return UserHandle.myUserId();
+    }
 }
diff --git a/src/com/android/settings/applications/credentials/DefaultWorkCombinedPreferenceController.java b/src/com/android/settings/applications/credentials/DefaultWorkCombinedPreferenceController.java
index 0990f3b..74bf9026 100644
--- a/src/com/android/settings/applications/credentials/DefaultWorkCombinedPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/DefaultWorkCombinedPreferenceController.java
@@ -44,7 +44,7 @@
 
     @Override
     public String getPreferenceKey() {
-        return "default_autofill_work";
+        return "default_credman_autofill_main_work";
     }
 
     @Override
@@ -81,4 +81,9 @@
     protected void startActivity(Intent intent) {
         mContext.startActivityAsUser(intent, mUserHandle);
     }
+
+    @Override
+    protected int getUser() {
+        return mUserHandle.getIdentifier();
+    }
 }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index 4d05946..ebbe2e8 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -326,8 +326,8 @@
             }
         }
 
-        boolean canUseFace = mIsFaceEnrollable;
-        boolean canUseFingerprint = mIsFingerprintEnrollable;
+        boolean canUseFace = mHasFeatureFace;
+        boolean canUseFingerprint = mHasFeatureFingerprint;
         if (mParentalOptionsRequired) {
             if (mParentalOptions == null) {
                 throw new IllegalStateException("consent options required, but not set");
@@ -345,10 +345,12 @@
         } else if (canUseFace || canUseFingerprint) {
             if (mGkPwHandle == null) {
                 setOrConfirmCredentialsNow();
-            } else if (canUseFingerprint) {
+            } else if (canUseFingerprint && mIsFingerprintEnrollable) {
                 launchFingerprintOnlyEnroll();
-            } else {
+            } else if (canUseFace && mIsFaceEnrollable) {
                 launchFaceOnlyEnroll();
+            } else {
+                setOrConfirmCredentialsNow();
             }
         } else { // no modalities available
             if (mParentalOptionsRequired) {
diff --git a/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtils.java b/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtils.java
index 4ff2b87..8f9da54 100644
--- a/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtils.java
+++ b/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtils.java
@@ -268,6 +268,30 @@
         }
     }
 
+    /**
+     * Returns the preference title of how to use biometrics when active unlock is enabled.
+     */
+    public String getUseBiometricTitleForActiveUnlock() {
+        final boolean faceAllowed = Utils.hasFaceHardware(mContext);
+        final boolean fingerprintAllowed = Utils.hasFingerprintHardware(mContext);
+
+        return mContext.getString(getUseBiometricTitleRes(faceAllowed, fingerprintAllowed));
+    }
+
+    @StringRes
+    private static int getUseBiometricTitleRes(
+            boolean isFaceAllowed, boolean isFingerprintAllowed) {
+        if (isFaceAllowed && isFingerprintAllowed) {
+            return R.string.biometric_settings_use_face_fingerprint_or_watch_for;
+        } else if (isFaceAllowed) {
+            return R.string.biometric_settings_use_face_or_watch_for;
+        } else if (isFingerprintAllowed) {
+            return R.string.biometric_settings_use_fingerprint_or_watch_for;
+        } else {
+            return R.string.biometric_settings_use_watch_for;
+        }
+    }
+
     private static String getFlagState() {
         return DeviceConfig.getProperty(DeviceConfig.NAMESPACE_REMOTE_AUTH, CONFIG_FLAG_NAME);
     }
diff --git a/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java b/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
index d0e986f..671a5b6 100644
--- a/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
+++ b/src/com/android/settings/biometrics/combination/CombinedBiometricSettings.java
@@ -46,6 +46,7 @@
     private static final String KEY_UNLOCK_PHONE = "biometric_settings_biometric_keyguard";
     private static final String KEY_USE_IN_APPS = "biometric_settings_biometric_app";
     private static final String KEY_INTRO_PREFERENCE = "biometric_intro";
+    private static final String KEY_USE_BIOMETRIC_PREFERENCE = "biometric_ways_to_use";
 
     private ActiveUnlockStatusUtils mActiveUnlockStatusUtils;
     private CombinedBiometricStatusUtils mCombinedBiometricStatusUtils;
@@ -83,6 +84,11 @@
         if (introPreference != null) {
             introPreference.setTitle(mActiveUnlockStatusUtils.getIntroForActiveUnlock());
         }
+        final Preference useBiometricPreference = findPreference(KEY_USE_BIOMETRIC_PREFERENCE);
+        if (useBiometricPreference != null) {
+            useBiometricPreference.setTitle(
+                    mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock());
+        }
         getActivity().setTitle(mActiveUnlockStatusUtils.getTitleForActiveUnlock());
     }
 
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 707eebf..dc36220 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -798,7 +798,12 @@
             // If the stage changed, announce the header for accessibility. This
             // is a no-op when accessibility is disabled.
             if (previousStage != stage || announceAlways) {
-                mHeaderText.announceForAccessibility(mHeaderText.getText());
+                if (stage == Stage.NeedToConfirm) {
+                    // If the Stage is NeedToConfirm, move the a11y focus to the header.
+                    mHeaderText.requestAccessibilityFocus();
+                } else {
+                    mHeaderText.announceForAccessibility(mHeaderText.getText());
+                }
             }
         }
 
diff --git a/tests/robotests/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtilsTest.java b/tests/robotests/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtilsTest.java
index d420f78..e5eac12 100644
--- a/tests/robotests/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/activeunlock/ActiveUnlockStatusUtilsTest.java
@@ -222,4 +222,44 @@
                 .isEqualTo(mApplicationContext.getString(
                         R.string.biometric_settings_use_face_or_watch_preference_summary));
     }
+
+    @Test
+    public void getUseBiometricTitle_faceAndFingerprintEnabled_returnsFaceFingerprintOrWatch() {
+        when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
+        when(mFaceManager.isHardwareDetected()).thenReturn(true);
+
+        assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
+                .isEqualTo(mApplicationContext.getString(
+                        R.string.biometric_settings_use_face_fingerprint_or_watch_for));
+    }
+
+    @Test
+    public void getUseBiometricTitle_fingerprintEnabled_returnsFingerprintOrWatch() {
+        when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
+        when(mFaceManager.isHardwareDetected()).thenReturn(false);
+
+        assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
+                .isEqualTo(mApplicationContext.getString(
+                        R.string.biometric_settings_use_fingerprint_or_watch_for));
+    }
+
+    @Test
+    public void getUseBiometricTitle_faceEnabled_returnsFaceOrWatch() {
+        when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
+        when(mFaceManager.isHardwareDetected()).thenReturn(true);
+
+        assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
+                .isEqualTo(mApplicationContext.getString(
+                        R.string.biometric_settings_use_face_or_watch_for));
+    }
+
+    @Test
+    public void getUseBiometricTitle_withoutFaceOrFingerprint_returnsWatch() {
+        when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
+        when(mFaceManager.isHardwareDetected()).thenReturn(false);
+
+        assertThat(mActiveUnlockStatusUtils.getUseBiometricTitleForActiveUnlock())
+                .isEqualTo(mApplicationContext.getString(
+                        R.string.biometric_settings_use_watch_for));
+    }
 }