Merge "[Wi-Fi] Remove unsupported EAP methods for WPA3-Enterprise 192-bit - I"
diff --git a/Android.bp b/Android.bp
index fb1a802..15e36f1 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,6 +1,7 @@
 java_library {
     name: "settings-logtags",
     srcs: ["src/**/*.logtags"],
+    static_libs: ["WifiTrackerLib"],
 }
 
 // Build the Settings APK
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0b6e384..3101e9a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -269,6 +269,26 @@
         </activity>
 
         <activity
+            android:name="Settings$WifiSettings2Activity"
+            android:label="@string/wifi_settings"
+            android:icon="@drawable/ic_settings_wireless"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:parentActivityName="Settings">
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.WIFI_SETTINGS2" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter android:priority="1">
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.SHORTCUT" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.wifi.WifiSettings2" />
+            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+                       android:value="true" />
+        </activity>
+
+        <activity
             android:name=".wifi.WifiPickerActivity"
             android:parentActivityName="Settings">
             <intent-filter android:priority="1">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 04dbdd7..29f89c5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10668,13 +10668,11 @@
     <string-array name="game_driver_all_apps_preference_values">
         <item>@string/game_driver_app_preference_default</item>
         <item>@string/game_driver_app_preference_game_driver</item>
-        <item>@string/game_driver_app_preference_prerelease_driver</item>
     </string-array>
     <!-- All the values for Game Driver app preference [CHAR LIMIT=50] -->
     <string-array name="game_driver_app_preference_values">
         <item>@string/game_driver_app_preference_default</item>
         <item>@string/game_driver_app_preference_game_driver</item>
-        <item>@string/game_driver_app_preference_prerelease_driver</item>
         <item>@string/game_driver_app_preference_system</item>
     </string-array>
 
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 54b43dc..c45e6a2 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -119,12 +119,11 @@
         android:fragment="com.android.settings.dream.DreamSettings"
         settings:searchable="false" />
 
-    <com.android.settingslib.RestrictedPreference
+    <Preference
         android:key="lockscreen_from_display_settings"
         android:title="@string/lockscreen_settings_title"
         android:fragment="com.android.settings.security.LockscreenDashboardFragment"
-        settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController"
-        settings:userRestriction="no_ambient_display" />
+        settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController" />
 
     <SwitchPreference
         android:key="camera_gesture"
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 611d33f..fdbee40 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -53,11 +53,12 @@
         android:title="@string/ambient_display_category_triggers"
         android:order="1000">
 
-        <SwitchPreference
+        <com.android.settingslib.RestrictedSwitchPreference
             android:key="ambient_display_always_on"
             android:title="@string/doze_always_on_title"
             android:summary="@string/doze_always_on_summary"
-            settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
+            settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController"
+            settings:userRestriction="no_ambient_display" />
 
         <Preference
             android:key="ambient_display_tap"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index ab59da4..add1178 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -43,6 +43,7 @@
     public static class PrivateVolumeSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PublicVolumeSettingsActivity extends SettingsActivity { /* empty */ }
     public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
+    public static class WifiSettings2Activity extends SettingsActivity { /* empty */ }
     public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AvailableVirtualKeyboardActivity extends SettingsActivity { /* empty */ }
     public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index c3f794f..c23aee6 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -172,11 +172,11 @@
         if (mUserId == UserHandle.USER_NULL) {
             launchedConfirmationActivity = helper.launchConfirmationActivity(CONFIRM_REQUEST,
                     getString(titleResId),
-                    null, null, challenge);
+                    null, null, challenge, true /* foregroundOnly */);
         } else {
             launchedConfirmationActivity = helper.launchConfirmationActivity(CONFIRM_REQUEST,
                     getString(titleResId),
-                    null, null, challenge, mUserId);
+                    null, null, challenge, mUserId, true /* foregroundOnly */);
         }
         if (!launchedConfirmationActivity) {
             // This shouldn't happen, as we should only end up at this step if a lock thingy is
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index 99d96dd..011cc12 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -134,7 +134,10 @@
         final AccessibilityManager accessibilityManager = getApplicationContext().getSystemService(
                 AccessibilityManager.class);
         if (accessibilityManager != null) {
-            accessibilityEnabled = accessibilityManager.isEnabled();
+            // Add additional check for touch exploration. This prevents other accessibility
+            // features such as Live Transcribe from defaulting to the accessibility setup.
+            accessibilityEnabled = accessibilityManager.isEnabled()
+                    && accessibilityManager.isTouchExplorationEnabled();
         }
         mFooterBarMixin.setPrimaryButton(footerButton);
         final Context context = getApplicationContext();
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 79198c5..f289af3 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -179,7 +179,7 @@
             mConfirmingPassword = true;
             if (!helper.launchConfirmationActivity(CONFIRM_REQUEST,
                     getString(R.string.security_settings_face_preference_title),
-                    null, null, challenge, mUserId)) {
+                    null, null, challenge, mUserId, true /* foregroundOnly */)) {
                 Log.e(TAG, "Password not set");
                 finish();
             }
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index ad0ae6f..3fbcfd4 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -617,7 +617,7 @@
             ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);
             if (!helper.launchConfirmationActivity(CONFIRM_REQUEST,
                     getString(R.string.security_settings_fingerprint_preference_title),
-                    null, null, challenge, mUserId)) {
+                    null, null, challenge, mUserId, true /* foregroundOnly */)) {
                 intent.setClassName(SETTINGS_PACKAGE_NAME, ChooseLockGeneric.class.getName());
                 intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
                         DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 74d3b6a..c56c50e 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -32,6 +32,7 @@
 import android.view.View;
 import android.widget.ImageView;
 
+import androidx.annotation.IntDef;
 import androidx.annotation.VisibleForTesting;
 import androidx.appcompat.app.AlertDialog;
 import androidx.preference.Preference;
@@ -44,6 +45,9 @@
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
 /**
  * BluetoothDevicePreference is the preference type used to display each remote
  * Bluetooth device in the Bluetooth Settings screen.
@@ -54,9 +58,19 @@
 
     private static int sDimAlpha = Integer.MIN_VALUE;
 
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef({SortType.TYPE_DEFAULT,
+            SortType.TYPE_FIFO})
+    public @interface SortType {
+        int TYPE_DEFAULT = 1;
+        int TYPE_FIFO = 2;
+    }
+
     private final CachedBluetoothDevice mCachedDevice;
     private final UserManager mUserManager;
     private final boolean mShowDevicesWithoutNames;
+    private final long mCurrentTime;
+    private final int mType;
 
     private AlertDialog mDisconnectDialog;
     private String contentDescription = null;
@@ -67,7 +81,7 @@
     Resources mResources;
 
     public BluetoothDevicePreference(Context context, CachedBluetoothDevice cachedDevice,
-            boolean showDeviceWithoutNames) {
+            boolean showDeviceWithoutNames, @SortType int type) {
         super(context, null);
         mResources = getContext().getResources();
         mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -81,6 +95,8 @@
 
         mCachedDevice = cachedDevice;
         mCachedDevice.registerCallback(this);
+        mCurrentTime = System.currentTimeMillis();
+        mType = type;
 
         onDeviceAttributesChanged();
     }
@@ -200,8 +216,15 @@
             return super.compareTo(another);
         }
 
-        return mCachedDevice
-                .compareTo(((BluetoothDevicePreference) another).mCachedDevice);
+        switch (mType) {
+            case SortType.TYPE_DEFAULT:
+                return mCachedDevice
+                        .compareTo(((BluetoothDevicePreference) another).mCachedDevice);
+            case SortType.TYPE_FIFO:
+                return (int)(mCurrentTime - ((BluetoothDevicePreference) another).mCurrentTime);
+            default:
+                return super.compareTo(another);
+        }
     }
 
     void onClicked() {
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 31055cc..7cf7fd5 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -226,7 +226,8 @@
         if (!mPreferenceMap.containsKey(device)) {
             BluetoothDevicePreference btPreference =
                     new BluetoothDevicePreference(mPrefContext, cachedDevice,
-                            true /* showDeviceWithoutNames */);
+                            true /* showDeviceWithoutNames */,
+                            BluetoothDevicePreference.SortType.TYPE_DEFAULT);
             btPreference.setOnGearClickListener(mDeviceProfilesListener);
             if (this instanceof Preference.OnPreferenceClickListener) {
                 btPreference.setOnPreferenceClickListener(
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index 4f27a39..8a286e4 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -191,7 +191,7 @@
 
         if (preference == null) {
             preference = new BluetoothDevicePreference(getPrefContext(), cachedDevice,
-                    mShowDevicesWithoutNames);
+                    mShowDevicesWithoutNames, BluetoothDevicePreference.SortType.TYPE_FIFO);
             preference.setKey(key);
             //Set hideSecondTarget is true if it's bonded device.
             preference.hideSecondTarget(true);
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 384f262..945ac5c 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -141,6 +141,7 @@
 import com.android.settings.wifi.WifiAPITest;
 import com.android.settings.wifi.WifiInfo;
 import com.android.settings.wifi.WifiSettings;
+import com.android.settings.wifi.WifiSettings2;
 import com.android.settings.wifi.calling.WifiCallingDisclaimerFragment;
 import com.android.settings.wifi.calling.WifiCallingSettings;
 import com.android.settings.wifi.p2p.WifiP2pSettings;
@@ -157,6 +158,7 @@
             AdvancedConnectedDeviceDashboardFragment.class.getName(),
             CreateShortcut.class.getName(),
             WifiSettings.class.getName(),
+            WifiSettings2.class.getName(),
             ConfigureWifiSettings.class.getName(),
             SavedAccessPointsWifiSettings.class.getName(),
             SimSettings.class.getName(),
@@ -301,6 +303,7 @@
             SupportDashboardActivity.class.getName(),
             // Home page > Network & Internet
             Settings.WifiSettingsActivity.class.getName(),
+            Settings.WifiSettings2Activity.class.getName(),
             Settings.DataUsageSummaryActivity.class.getName(),
             // Home page > Connected devices
             Settings.BluetoothSettingsActivity.class.getName(),
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
index bd5a10d..66b665b 100644
--- a/src/com/android/settings/password/BiometricFragment.java
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -58,11 +58,13 @@
     private Bundle mBundle;
     private BiometricPrompt mBiometricPrompt;
     private CancellationSignal mCancellationSignal;
+    private boolean mAuthenticating;
 
     private AuthenticationCallback mAuthenticationCallback =
             new AuthenticationCallback() {
         @Override
         public void onAuthenticationError(int error, @NonNull CharSequence message) {
+            mAuthenticating = false;
             mClientExecutor.execute(() -> {
                 mClientCallback.onAuthenticationError(error, message);
             });
@@ -71,6 +73,7 @@
 
         @Override
         public void onAuthenticationSucceeded(AuthenticationResult result) {
+            mAuthenticating = false;
             mClientExecutor.execute(() -> {
                 mClientCallback.onAuthenticationSucceeded(result);
             });
@@ -134,6 +137,10 @@
         }
     }
 
+    boolean isAuthenticating() {
+        return mAuthenticating;
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -180,6 +187,7 @@
         mCancellationSignal = new CancellationSignal();
 
         // TODO: CC doesn't use crypto for now
+        mAuthenticating = true;
         mBiometricPrompt.authenticateUser(mCancellationSignal, mClientExecutor,
                 mAuthenticationCallback, mUserId, mCancelCallback);
     }
diff --git a/src/com/android/settings/password/ChooseLockSettingsHelper.java b/src/com/android/settings/password/ChooseLockSettingsHelper.java
index 28ded2d..3353d62 100644
--- a/src/com/android/settings/password/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/password/ChooseLockSettingsHelper.java
@@ -47,6 +47,7 @@
     public static final String EXTRA_KEY_FOR_FINGERPRINT = "for_fingerprint";
     public static final String EXTRA_KEY_FOR_FACE = "for_face";
     public static final String EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT = "for_cred_req_boot";
+    public static final String EXTRA_KEY_FOREGROUND_ONLY = "foreground_only";
 
     /**
      * Intent extra for passing the requested min password complexity to later steps in the set new
@@ -105,7 +106,8 @@
                 null /* header */,
                 null /* description */,
                 false /* returnCredentials */,
-                false /* external */);
+                false /* external */,
+                false /* foregroundOnly */);
     }
 
     /**
@@ -124,7 +126,8 @@
                 null /* header */,
                 null /* description */,
                 returnCredentials /* returnCredentials */,
-                false /* external */);
+                false /* external */,
+                false /* foregroundOnly */);
     }
 
     /**
@@ -148,7 +151,8 @@
                 false /* external */,
                 false /* hasChallenge */,
                 0 /* challenge */,
-                Utils.enforceSameOwner(mActivity, userId) /* userId */);
+                Utils.enforceSameOwner(mActivity, userId) /* userId */,
+                false /* foregroundOnly */);
     }
 
     /**
@@ -162,12 +166,13 @@
      * @param external specifies whether this activity is launched externally, meaning that it will
      *                 get a dark theme, allow fingerprint authentication and it will forward
      *                 activity result.
+     * @param foregroundOnly if the confirmation activity should be finished if it loses foreground.
      * @return true if one exists and we launched an activity to confirm it
      * @see Activity#onActivityResult(int, int, android.content.Intent)
      */
     boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
-            boolean returnCredentials, boolean external) {
+            boolean returnCredentials, boolean external, boolean foregroundOnly) {
         return launchConfirmationActivity(
                 request /* request */,
                 title /* title */,
@@ -177,7 +182,8 @@
                 external /* external */,
                 false /* hasChallenge */,
                 0 /* challenge */,
-                Utils.getCredentialOwnerUserId(mActivity) /* userId */);
+                Utils.getCredentialOwnerUserId(mActivity) /* userId */,
+                foregroundOnly /* foregroundOnly */);
     }
 
     /**
@@ -207,7 +213,8 @@
                 external /* external */,
                 false /* hasChallenge */,
                 0 /* challenge */,
-                Utils.enforceSameOwner(mActivity, userId) /* userId */);
+                Utils.enforceSameOwner(mActivity, userId) /* userId */,
+                false /* foregroundOnly */);
     }
 
     /**
@@ -217,12 +224,13 @@
      * @param header header of the confirmation screen; shown as large text
      * @param description description of the confirmation screen
      * @param challenge a challenge to be verified against the device credential.
+     * @param foregroundOnly if the confirmation activity should be finished if it loses foreground.
      * @return true if one exists and we launched an activity to confirm it
      * @see Activity#onActivityResult(int, int, android.content.Intent)
      */
     public boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
-            long challenge) {
+            long challenge, boolean foregroundOnly) {
         return launchConfirmationActivity(
                 request /* request */,
                 title /* title */,
@@ -232,7 +240,8 @@
                 false /* external */,
                 true /* hasChallenge */,
                 challenge /* challenge */,
-                Utils.getCredentialOwnerUserId(mActivity) /* userId */);
+                Utils.getCredentialOwnerUserId(mActivity) /* userId */,
+                foregroundOnly /* foregroundOnly */);
     }
 
     /**
@@ -243,12 +252,13 @@
      * @param description description of the confirmation screen
      * @param challenge a challenge to be verified against the device credential.
      * @param userId The userId for whom the lock should be confirmed.
+     * @param foregroundOnly if the confirmation activity should be finished if it loses foreground.
      * @return true if one exists and we launched an activity to confirm it
      * @see Activity#onActivityResult(int, int, android.content.Intent)
      */
     public boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
-            long challenge, int userId) {
+            long challenge, int userId, boolean foregroundOnly) {
         return launchConfirmationActivity(
                 request /* request */,
                 title /* title */,
@@ -258,7 +268,8 @@
                 false /* external */,
                 true /* hasChallenge */,
                 challenge /* challenge */,
-                Utils.enforceSameOwner(mActivity, userId) /* userId */);
+                Utils.enforceSameOwner(mActivity, userId) /* userId */,
+                foregroundOnly);
     }
 
     /**
@@ -287,7 +298,8 @@
                 external /* external */,
                 true /* hasChallenge */,
                 challenge /* challenge */,
-                Utils.enforceSameOwner(mActivity, userId) /* userId */);
+                Utils.enforceSameOwner(mActivity, userId) /* userId */,
+                false /* foregroundOnly */);
     }
 
     /**
@@ -316,7 +328,7 @@
     private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             boolean returnCredentials, boolean external, boolean hasChallenge,
-            long challenge, int userId) {
+            long challenge, int userId, boolean foregroundOnly) {
         return launchConfirmationActivity(
                 request /* request */,
                 title /* title */,
@@ -328,7 +340,8 @@
                 challenge /* challenge */,
                 userId /* userId */,
                 null /* alternateButton */,
-                null /* extras */);
+                null /* extras */,
+                foregroundOnly /* foregroundOnly */);
     }
 
     private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@@ -346,7 +359,8 @@
                 challenge /* challenge */,
                 userId /* userId */,
                 null /* alternateButton */,
-                extras /* extras */);
+                extras /* extras */,
+                false /* foregroundOnly */);
     }
 
     public boolean launchFrpConfirmationActivity(int request, @Nullable CharSequence header,
@@ -362,13 +376,15 @@
                 0 /* challenge */,
                 LockPatternUtils.USER_FRP /* userId */,
                 alternateButton /* alternateButton */,
-                null /* extras */);
+                null /* extras */,
+                false /* foregroundOnly */);
     }
 
     private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             boolean returnCredentials, boolean external, boolean hasChallenge,
-            long challenge, int userId, @Nullable CharSequence alternateButton, Bundle extras) {
+            long challenge, int userId, @Nullable CharSequence alternateButton, Bundle extras,
+            boolean foregroundOnly) {
         final int effectiveUserId = UserManager.get(mActivity).getCredentialOwnerProfile(userId);
         boolean launched = false;
 
@@ -378,7 +394,8 @@
                         returnCredentials || hasChallenge
                                 ? ConfirmLockPattern.InternalActivity.class
                                 : ConfirmLockPattern.class, returnCredentials, external,
-                                hasChallenge, challenge, userId, alternateButton, extras);
+                                hasChallenge, challenge, userId, alternateButton, extras,
+                                foregroundOnly);
                 break;
             case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
             case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
@@ -390,7 +407,8 @@
                         returnCredentials || hasChallenge
                                 ? ConfirmLockPassword.InternalActivity.class
                                 : ConfirmLockPassword.class, returnCredentials, external,
-                                hasChallenge, challenge, userId, alternateButton, extras);
+                                hasChallenge, challenge, userId, alternateButton, extras,
+                                foregroundOnly);
                 break;
         }
         return launched;
@@ -399,7 +417,8 @@
     private boolean launchConfirmationActivity(int request, CharSequence title, CharSequence header,
             CharSequence message, Class<?> activityClass, boolean returnCredentials,
             boolean external, boolean hasChallenge, long challenge,
-            int userId, @Nullable CharSequence alternateButton, Bundle extras) {
+            int userId, @Nullable CharSequence alternateButton, Bundle extras,
+            boolean foregroundOnly) {
         final Intent intent = new Intent();
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title);
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header);
@@ -414,6 +433,7 @@
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
         intent.putExtra(Intent.EXTRA_USER_ID, userId);
         intent.putExtra(KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL, alternateButton);
+        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOREGROUND_ONLY, foregroundOnly);
         if (extras != null) {
             intent.putExtras(extras);
         }
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 53841e8..8476f92 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -251,7 +251,10 @@
         if (!isChangingConfigurations()) {
             mGoingToBackground = true;
             if (mBiometricFragment != null) {
-                mBiometricFragment.cancel();
+                Log.d(TAG, "Authenticating: " + mBiometricFragment.isAuthenticating());
+                if (mBiometricFragment.isAuthenticating()) {
+                    mBiometricFragment.cancel();
+                }
             }
 
             if (mIsFallback && !mCCLaunched) {
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index 998b3fc..5407776 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -172,6 +172,10 @@
             mBiometricManager.onConfirmDeviceCredentialError(
                     BiometricConstants.BIOMETRIC_ERROR_USER_CANCELED,
                     getString(com.android.internal.R.string.biometric_error_user_canceled));
+            if (getIntent().getBooleanExtra(
+                    ChooseLockSettingsHelper.EXTRA_KEY_FOREGROUND_ONLY, false)) {
+                finish();
+            }
         }
     }
 
diff --git a/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
index 2ff071e..cf8688a 100644
--- a/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
+++ b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
@@ -19,6 +19,7 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.provider.Settings;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.android.settings.bluetooth.BluetoothSliceBuilder;
@@ -71,6 +72,7 @@
     }
 
     private static Uri parse(Uri uri) {
-        return Uri.parse(uri.getQueryParameter(EXTRA_SLICE));
+        final String sliceParameter = uri.getQueryParameter(EXTRA_SLICE);
+        return TextUtils.isEmpty(sliceParameter) ? null : Uri.parse(sliceParameter);
     }
 }
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 8c4bfa2..514e5b2 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -224,6 +224,12 @@
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
+        if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_WIFITRACKER2)) {
+            getContext().startActivity(new Intent("android.settings.WIFI_SETTINGS2"));
+            finish();
+            return;
+        }
+
         // TODO(b/37429702): Add animations and preference comparator back after initial screen is
         // loaded (ODR).
         setAnimationAllowed(false);
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
new file mode 100644
index 0000000..713679e
--- /dev/null
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -0,0 +1,35 @@
+/*
+ * 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.wifi;
+
+import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.RestrictedSettingsFragment;
+
+public class WifiSettings2 extends RestrictedSettingsFragment {
+
+    public WifiSettings2() {
+        super(DISALLOW_CONFIG_WIFI);
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.WIFI;
+    }
+}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 372476c..e2da0ed 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -78,10 +78,11 @@
 com.android.settings.vpn2.AppManagementFragment
 com.android.settings.vpn2.VpnSettings
 com.android.settings.wallpaper.WallpaperTypeSettings
-com.android.settings.wifi.calling.WifiCallingSettingsForSub
 com.android.settings.wifi.ChangeWifiStateDetails
+com.android.settings.wifi.calling.WifiCallingSettingsForSub
 com.android.settings.wifi.details.WifiNetworkDetailsFragment
+com.android.settings.wifi.dpp.WifiNetworkListFragment
 com.android.settings.wifi.p2p.WifiP2pSettings
 com.android.settings.wifi.savedaccesspoints.SavedAccessPointsWifiSettings
 com.android.settings.wifi.WifiInfo
-com.android.settings.wifi.dpp.WifiNetworkListFragment
+com.android.settings.wifi.WifiSettings2
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index 29640d6..4348e1b 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -91,7 +91,8 @@
         mBluetoothDeviceUpdater = spy(new AvailableMediaBluetoothDeviceUpdater(mContext,
                 mDashboardFragment, mDevicePreferenceCallback));
         mBluetoothDeviceUpdater.setPrefContext(mContext);
-        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
+        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false,
+                BluetoothDevicePreference.SortType.TYPE_DEFAULT);
         doNothing().when(mBluetoothDeviceUpdater).addPreference(any());
         doNothing().when(mBluetoothDeviceUpdater).removePreference(any());
     }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index 92f2354..a02ab4a 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -24,7 +24,6 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.bluetooth.BluetoothClass;
 import android.bluetooth.BluetoothDevice;
 import android.content.Context;
 import android.os.UserManager;
@@ -48,19 +47,36 @@
 import org.robolectric.annotation.Config;
 import org.robolectric.util.ReflectionHelpers;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
 @RunWith(RobolectricTestRunner.class)
 @Config(shadows = {ShadowAlertDialogCompat.class})
 public class BluetoothDevicePreferenceTest {
     private static final boolean SHOW_DEVICES_WITHOUT_NAMES = true;
     private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
+    private static final String MAC_ADDRESS_2 = "05:52:C7:0B:D8:3C";
+    private static final String MAC_ADDRESS_3 = "06:52:C7:0B:D8:3C";
+    private static final String MAC_ADDRESS_4 = "07:52:C7:0B:D8:3C";
+    private static final Comparator<BluetoothDevicePreference> COMPARATOR =
+            Comparator.naturalOrder();
 
     private Context mContext;
     @Mock
     private CachedBluetoothDevice mCachedBluetoothDevice;
+    @Mock
+    private CachedBluetoothDevice mCachedDevice1;
+    @Mock
+    private CachedBluetoothDevice mCachedDevice2;
+    @Mock
+    private CachedBluetoothDevice mCachedDevice3;
 
     private FakeFeatureFactory mFakeFeatureFactory;
     private MetricsFeatureProvider mMetricsFeatureProvider;
     private BluetoothDevicePreference mPreference;
+    private List<BluetoothDevicePreference> mPreferenceList = new ArrayList<>();
 
     @Before
     public void setUp() {
@@ -70,8 +86,11 @@
         mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
         mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
         when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
+        when(mCachedDevice1.getAddress()).thenReturn(MAC_ADDRESS_2);
+        when(mCachedDevice2.getAddress()).thenReturn(MAC_ADDRESS_3);
+        when(mCachedDevice3.getAddress()).thenReturn(MAC_ADDRESS_4);
         mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
-                SHOW_DEVICES_WITHOUT_NAMES);
+                SHOW_DEVICES_WITHOUT_NAMES, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
     }
 
     @Test
@@ -170,7 +189,8 @@
         doReturn(false).when(mCachedBluetoothDevice).hasHumanReadableName();
         BluetoothDevicePreference preference =
                 new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
-                        SHOW_DEVICES_WITHOUT_NAMES);
+                        SHOW_DEVICES_WITHOUT_NAMES,
+                        BluetoothDevicePreference.SortType.TYPE_DEFAULT);
 
         assertThat(preference.isVisible()).isTrue();
     }
@@ -179,7 +199,8 @@
     public void isVisible_hideDeviceWithoutNames_invisible() {
         doReturn(false).when(mCachedBluetoothDevice).hasHumanReadableName();
         BluetoothDevicePreference preference =
-                new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
+                new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
+                        false, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
 
         assertThat(preference.isVisible()).isFalse();
     }
@@ -190,4 +211,48 @@
 
         assertThat(mPreference.mNeedNotifyHierarchyChanged).isTrue();
     }
+
+    @Test
+    public void compareTo_sortTypeFIFO() {
+        final BluetoothDevicePreference preference3 = new BluetoothDevicePreference(mContext,
+                mCachedDevice3, SHOW_DEVICES_WITHOUT_NAMES,
+                BluetoothDevicePreference.SortType.TYPE_FIFO);
+        final BluetoothDevicePreference preference2 = new BluetoothDevicePreference(mContext,
+                mCachedDevice2, SHOW_DEVICES_WITHOUT_NAMES,
+                BluetoothDevicePreference.SortType.TYPE_FIFO);
+        final BluetoothDevicePreference preference1 = new BluetoothDevicePreference(mContext,
+                mCachedDevice1, SHOW_DEVICES_WITHOUT_NAMES,
+                BluetoothDevicePreference.SortType.TYPE_FIFO);
+
+        mPreferenceList.add(preference1);
+        mPreferenceList.add(preference2);
+        mPreferenceList.add(preference3);
+        Collections.sort(mPreferenceList, COMPARATOR);
+
+        assertThat(mPreferenceList.get(0)).isEqualTo(preference3);
+        assertThat(mPreferenceList.get(1)).isEqualTo(preference2);
+        assertThat(mPreferenceList.get(2)).isEqualTo(preference1);
+    }
+
+    @Test
+    public void compareTo_sortTypeDefault() {
+        final BluetoothDevicePreference preference3 = new BluetoothDevicePreference(mContext,
+                mCachedDevice3, SHOW_DEVICES_WITHOUT_NAMES,
+                BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+        final BluetoothDevicePreference preference2 = new BluetoothDevicePreference(mContext,
+                mCachedDevice2, SHOW_DEVICES_WITHOUT_NAMES,
+                BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+        final BluetoothDevicePreference preference1 = new BluetoothDevicePreference(mContext,
+                mCachedDevice1, SHOW_DEVICES_WITHOUT_NAMES,
+                BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+
+        mPreferenceList.add(preference1);
+        mPreferenceList.add(preference2);
+        mPreferenceList.add(preference3);
+        Collections.sort(mPreferenceList, COMPARATOR);
+
+        assertThat(mPreferenceList.get(0)).isEqualTo(preference1);
+        assertThat(mPreferenceList.get(1)).isEqualTo(preference2);
+        assertThat(mPreferenceList.get(2)).isEqualTo(preference3);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
index 1066552..66bf959 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
@@ -99,7 +99,8 @@
         when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
         when(mSubBluetoothDevice.getAddress()).thenReturn(SUB_MAC_ADDRESS);
 
-        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
+        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
+                false, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
         mBluetoothDeviceUpdater =
             new BluetoothDeviceUpdater(mDashboardFragment, mDevicePreferenceCallback,
                     mLocalManager) {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
index 615f67a..13e138c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
@@ -239,7 +239,8 @@
     @Test
     public void addPreference_addPreference_shouldHideSecondTarget() {
         BluetoothDevicePreference btPreference =
-                new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, true);
+                new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
+                        true, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
         mBluetoothDeviceUpdater.mPreferenceMap.put(mBluetoothDevice, btPreference);
 
         mBluetoothDeviceUpdater.addPreference(mCachedBluetoothDevice);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index ac7692d..4cc9b87 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -72,7 +72,8 @@
         mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mContext, mDashboardFragment,
                 mDevicePreferenceCallback));
         mBluetoothDeviceUpdater.setPrefContext(mContext);
-        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
+        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
+                false, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
         doNothing().when(mBluetoothDeviceUpdater).addPreference(any());
         doNothing().when(mBluetoothDeviceUpdater).removePreference(any());
     }
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
index f007ce2..dd5af2b 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
@@ -56,8 +56,7 @@
 
     private static final int DEFAULT = 0;
     private static final int GAME_DRIVER = 1;
-    private static final int PRERELEASE_DRIVER = 2;
-    private static final int SYSTEM = 3;
+    private static final int SYSTEM = 2;
     private static final String TEST_APP_NAME = "testApp";
     private static final String TEST_PKG_NAME = "testPkg";
 
@@ -80,6 +79,7 @@
     private GameDriverAppPreferenceController mController;
     private CharSequence[] mValueList;
     private String mDialogTitle;
+    private String mPreferencePrereleaseDriver;
 
     @Before
     public void setUp() {
@@ -89,6 +89,8 @@
         mValueList =
                 mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
         mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
+        mPreferencePrereleaseDriver =
+                mContext.getResources().getString(R.string.game_driver_app_preference_prerelease_driver);
     }
 
     @Test
@@ -207,9 +209,7 @@
         assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
         assertThat(preference.getEntries()).isEqualTo(mValueList);
         assertThat(preference.getEntryValues()).isEqualTo(mValueList);
-        assertThat(preference.getEntry()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
-        assertThat(preference.getValue()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
-        assertThat(preference.getSummary()).isEqualTo(mValueList[PRERELEASE_DRIVER]);
+        assertThat(preference.getSummary()).isEqualTo(mPreferencePrereleaseDriver);
     }
 
     @Test