Merge "[Wi-Fi] Support disconnect button for connected Wi-Fi AP"
diff --git a/res/layout/accessibility_shortcut_secondary_action.xml b/res/layout/accessibility_shortcut_secondary_action.xml
index b46c303..caf9b1c 100644
--- a/res/layout/accessibility_shortcut_secondary_action.xml
+++ b/res/layout/accessibility_shortcut_secondary_action.xml
@@ -87,6 +87,7 @@
     </LinearLayout>
 
     <View
+        android:id="@+id/divider"
         android:layout_width="1dp"
         android:layout_height="match_parent"
         android:layout_marginTop="16dp"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 03b52b4..74f4621 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -490,8 +490,6 @@
     <string name="activity_picker_label">Choose activity</string>
     <!-- Do not translate. -->
     <string name="debug_intent_sender_label">Debug intent sender</string>
-    <!-- The title of the activity to see random device info. -->
-    <string name="device_info_label">Device info</string>
     <!-- The title of the activity to adjust display settings -->
     <string name="display_label">Screen</string>
     <!-- The title of the activity to adjust SD card settings [CHAR LIMIT=25] -->
@@ -1765,7 +1763,8 @@
     <string name="tx_link_speed"><xliff:g id="Transmit link speed" example="150 Mbps">%1$d</xliff:g> Mbps</string>
     <!-- Receive Link speed on Wifi Status screen [CHAR LIMIT=32] -->
     <string name="rx_link_speed"><xliff:g id="Receive link speed" example="54 Mbps">%1$d</xliff:g> Mbps</string>
-
+    <!-- Link speed on Wifi Status screen [CHAR LIMIT=32] -->
+    <string name="link_speed"><xliff:g id="Link speed" example="54 Mbps">%1$d</xliff:g> Mbps</string>
     <!-- This string asks the user whether or not to allow an app to enable WiFi. [CHAR LIMIT=NONE] -->
     <string name="wifi_ask_enable"><xliff:g id="requester" example="FancyApp">%s</xliff:g> wants to turn on Wi-Fi</string>
     <!-- This string asks the user whether or not to allow an app to disable WiFi. [CHAR LIMIT=NONE] -->
@@ -1976,6 +1975,8 @@
     <string name="tx_wifi_speed">Transmit link speed</string>
     <!-- Label for the receive link speed of the connection. [CHAR LIMIT=32] -->
     <string name="rx_wifi_speed">Receive link speed</string>
+    <!-- Label for the link speed of the connection. [CHAR LIMIT=32] -->
+    <string name="wifi_speed">Link speed</string>
     <!-- Label for the frequency band of the connection -->
     <string name="wifi_frequency">Frequency</string>
     <!-- Label for the IP address of the connection -->
@@ -7317,6 +7318,8 @@
     <string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string>
     <!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]-->
     <string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
+    <!-- Search keyword for "Wi-fi data usage" settings. [CHAR_LIMIT=NONE]-->
+    <string name="keywords_wifi_data_usage">data usage</string>
     <!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
     <string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
     <!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
@@ -11213,9 +11216,6 @@
     <!-- Available networks screen, summary when button disallowed due to permanent automatic mode [CHAR LIMIT=NONE] -->
     <string name="manual_mode_disallowed_summary">Unavailable when connected to <xliff:g id="carrier" example="verizon">%1$s</xliff:g></string>
 
-    <!-- Used for EmergencyInfoSlice slice helper class [CHAR LIMIT=NONE]-->
-    <string name="emergency_info_contextual_card_summary">Medical info, emergency contacts</string>
-
     <!-- See more items in contextual homepage [CHAR LIMIT=30]-->
     <string name="see_more">See more</string>
     <!-- See less items in contextual homepage [CHAR LIMIT=30]-->
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index cd05512..cc45a96 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -71,17 +71,19 @@
         android:title="@string/security_settings_face_preference_title">
         <com.android.settingslib.widget.LayoutPreference
             android:key="security_settings_face_delete_faces_container"
+            android:title="@string/security_settings_face_settings_remove_face_data"
             android:selectable="false"
             android:layout="@layout/face_remove_button"
             settings:allowDividerBelow="true"/>
 
         <com.android.settingslib.widget.LayoutPreference
             android:key="security_settings_face_enroll_faces_container"
+            android:title="@string/security_settings_face_settings_enroll"
             android:selectable="false"
-            android:layout="@layout/face_enroll_button "
+            android:layout="@layout/face_enroll_button"
             settings:allowDividerBelow="true"/>
     </PreferenceCategory>
 
     <com.android.settingslib.widget.FooterPreference
         settings:allowDividerAbove="true"/>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/wifi_settings.xml b/res/xml/wifi_settings.xml
index d7c299e..5fac85a 100644
--- a/res/xml/wifi_settings.xml
+++ b/res/xml/wifi_settings.xml
@@ -17,19 +17,21 @@
 <PreferenceScreen
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:settings="http://schemas.android.com/apk/res-auto"
-        android:title="@string/wifi_settings"
-        settings:keywords="@string/keywords_wifi">
+        android:title="@string/wifi_settings">
 
     <com.android.settings.wifi.LinkablePreference
-        android:key="wifi_status_message"/>
+        android:key="wifi_status_message"
+        settings:searchable="false"/>
 
     <PreferenceCategory
         android:key="connected_access_point"
-        android:layout="@layout/preference_category_no_label"/>
+        android:layout="@layout/preference_category_no_label"
+        settings:searchable="false"/>
 
     <PreferenceCategory
         android:key="access_points"
-        android:layout="@layout/preference_category_no_label"/>
+        android:layout="@layout/preference_category_no_label"
+        settings:searchable="false"/>
 
     <Preference
         android:key="configure_settings"
@@ -44,5 +46,6 @@
 
     <com.android.settings.datausage.DataUsagePreference
         android:key="wifi_data_usage"
-        android:title="@string/wifi_data_usage"/>
+        android:title="@string/wifi_data_usage"
+        settings:keywords="@string/keywords_wifi_data_usage"/>
 </PreferenceScreen>
diff --git a/src/com/android/settings/AirplaneModeEnabler.java b/src/com/android/settings/AirplaneModeEnabler.java
index ee3eaa4..a843a04 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -22,19 +22,18 @@
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.telephony.PhoneStateListener;
-import android.telephony.ServiceState;
 import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.util.Log;
 
+import androidx.annotation.VisibleForTesting;
+
 import com.android.settings.network.GlobalSettingsChangeListener;
 import com.android.settings.network.ProxySubscriptionManager;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.WirelessUtils;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -60,13 +59,12 @@
     }
 
     private TelephonyManager mTelephonyManager;
-    private ProxySubscriptionManager mProxySubscriptionMgr;
-    private List<ServiceStateListener> mServiceStateListeners;
+    @VisibleForTesting
+    PhoneStateListener mPhoneStateListener;
 
     private GlobalSettingsChangeListener mAirplaneModeObserver;
 
-    public AirplaneModeEnabler(Context context,
-            OnAirplaneModeChangedListener listener) {
+    public AirplaneModeEnabler(Context context, OnAirplaneModeChangedListener listener) {
         super(context, Settings.Global.AIRPLANE_MODE_ON);
 
         mContext = context;
@@ -74,7 +72,16 @@
         mOnAirplaneModeChangedListener = listener;
 
         mTelephonyManager = context.getSystemService(TelephonyManager.class);
-        mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(context);
+
+        mPhoneStateListener = new PhoneStateListener() {
+            @Override
+            public void onRadioPowerStateChanged(int state) {
+                if (DEBUG) {
+                    Log.d(LOG_TAG, "RadioPower: " + state);
+                }
+                onAirplaneModeChanged();
+            }
+        };
     }
 
     /**
@@ -88,35 +95,13 @@
     }
 
     public void resume() {
-        final List<SubscriptionInfo> subInfoList =
-                mProxySubscriptionMgr.getActiveSubscriptionsInfo();
-
-        mServiceStateListeners = new ArrayList<ServiceStateListener>();
-
-        // add default listener
-        mServiceStateListeners.add(new ServiceStateListener(mTelephonyManager,
-                SubscriptionManager.INVALID_SUBSCRIPTION_ID, this));
-
-        if (subInfoList != null) {
-            for (SubscriptionInfo subInfo : subInfoList) {
-                mServiceStateListeners.add(new ServiceStateListener(mTelephonyManager,
-                        subInfo.getSubscriptionId(), this));
-            }
-        }
-
-        for (ServiceStateListener listener : mServiceStateListeners) {
-            listener.start();
-        }
+        mTelephonyManager.listen(mPhoneStateListener,
+                PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED);
     }
 
     public void pause() {
-        if (mServiceStateListeners == null) {
-            return;
-        }
-        for (ServiceStateListener listener : mServiceStateListeners) {
-            listener.stop();
-        }
-        mServiceStateListeners = null;
+        mTelephonyManager.listen(mPhoneStateListener,
+                PhoneStateListener.LISTEN_NONE);
     }
 
     private void setAirplaneModeOn(boolean enabling) {
@@ -159,7 +144,7 @@
             return true;
         }
         final List<SubscriptionInfo> subInfoList =
-                mProxySubscriptionMgr.getActiveSubscriptionsInfo();
+                ProxySubscriptionManager.getInstance(mContext).getActiveSubscriptionsInfo();
         if (subInfoList == null) {
             return false;
         }
@@ -200,51 +185,4 @@
     public boolean isAirplaneModeOn() {
         return WirelessUtils.isAirplaneModeOn(mContext);
     }
-
-    private static class ServiceStateListener extends PhoneStateListener {
-        private ServiceStateListener(TelephonyManager telephonyManager, int subscriptionId,
-                AirplaneModeEnabler enabler) {
-            super();
-            mSubId = subscriptionId;
-            mTelephonyManager = getSubIdSpecificTelephonyManager(telephonyManager);
-            mEnabler = enabler;
-        }
-
-        private final int mSubId;
-        private final TelephonyManager mTelephonyManager;
-        private final AirplaneModeEnabler mEnabler;
-
-        int getSubscriptionId() {
-            return mSubId;
-        }
-
-        void start() {
-            if (mTelephonyManager != null) {
-                mTelephonyManager.listen(this, PhoneStateListener.LISTEN_SERVICE_STATE);
-            }
-        }
-
-        void stop() {
-            if (mTelephonyManager != null) {
-                mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
-            }
-        }
-
-        @Override
-        public void onServiceStateChanged(ServiceState serviceState) {
-            if (DEBUG) {
-                Log.d(LOG_TAG, "ServiceState in sub" + mSubId + ": " + serviceState);
-            }
-            mEnabler.onAirplaneModeChanged();
-        }
-
-        private TelephonyManager getSubIdSpecificTelephonyManager(
-                TelephonyManager telephonyManager) {
-            if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
-                return telephonyManager;
-            }
-            return telephonyManager.createForSubscriptionId(mSubId);
-        }
-    }
-
 }
diff --git a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
index 1d87477..7136172 100644
--- a/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
+++ b/src/com/android/settings/accessibility/AccessibilityEditDialogUtils.java
@@ -16,8 +16,6 @@
 
 package com.android.settings.accessibility;
 
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.res.TypedArray;
@@ -245,27 +243,21 @@
         });
     }
 
-    private static boolean isGestureNavigateEnabled(Context context) {
-        return context.getResources().getInteger(
-                com.android.internal.R.integer.config_navBarInteractionMode)
-                == NAV_BAR_MODE_GESTURAL;
-    }
-
     private static CharSequence retrieveTitle(Context context) {
-        return context.getString(isGestureNavigateEnabled(context)
+        return context.getString(AccessibilityUtil.isGestureNavigateEnabled(context)
                 ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
                 : R.string.accessibility_shortcut_edit_dialog_title_software);
     }
 
     private static CharSequence retrieveSummary(Context context, int lineHeight) {
-        return isGestureNavigateEnabled(context)
+        return AccessibilityUtil.isGestureNavigateEnabled(context)
                 ? context.getString(
                 R.string.accessibility_shortcut_edit_dialog_summary_software_gesture)
                 : getSummaryStringWithIcon(context, lineHeight);
     }
 
     private static int retrieveImageResId(Context context) {
-        return isGestureNavigateEnabled(context)
+        return AccessibilityUtil.isGestureNavigateEnabled(context)
                 ? R.drawable.accessibility_shortcut_type_software_gesture
                 : R.drawable.accessibility_shortcut_type_software;
         // TODO(b/142531156): Use vector drawable instead of temporal png file to avoid distorted.
diff --git a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
index 153fa19..5e6eced 100644
--- a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
+++ b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java
@@ -16,8 +16,6 @@
 
 package com.android.settings.accessibility;
 
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.res.TypedArray;
@@ -83,7 +81,7 @@
         final AlertDialog alertDialog = createDialog(context,
                 DialogType.LAUNCH_SERVICE_BY_ACCESSIBILITY_BUTTON);
 
-        if (!isGestureNavigateEnabled(context)) {
+        if (!AccessibilityUtil.isGestureNavigateEnabled(context)) {
             updateMessageWithIcon(context, alertDialog);
         }
 
@@ -206,12 +204,6 @@
         return colorResId;
     }
 
-    private static boolean isGestureNavigateEnabled(Context context) {
-        return context.getResources().getInteger(
-                com.android.internal.R.integer.config_navBarInteractionMode)
-                == NAV_BAR_MODE_GESTURAL;
-    }
-
     private static boolean isTouchExploreOn(Context context) {
         return ((AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE))
                 .isTouchExplorationEnabled();
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index a3682b2..4b3a341 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.accessibility;
 
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.content.Context;
 import android.os.Build;
@@ -55,18 +57,78 @@
     }
 
     /**
+     * Annotation for different shortcut type UI type.
+     *
+     * {@code DEFAULT} for displaying default value.
+     * {@code SOFTWARE} for displaying specifying the accessibility services or features which
+     * choose accessibility button in the navigation bar as preferred shortcut.
+     * {@code HARDWARE} for displaying specifying the accessibility services or features which
+     * choose accessibility shortcut as preferred shortcut.
+     * {@code TRIPLETAP} for displaying specifying magnification to be toggled via quickly
+     * tapping screen 3 times as preferred shortcut.
+     */
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef({
+            ShortcutType.DEFAULT,
+            ShortcutType.SOFTWARE,
+            ShortcutType.HARDWARE,
+            ShortcutType.TRIPLETAP,
+    })
+
+    /** Denotes the shortcut type. */
+    public @interface ShortcutType {
+        int DEFAULT = 0;
+        int SOFTWARE = 1; // 1 << 0
+        int HARDWARE = 2; // 1 << 1
+        int TRIPLETAP = 4; // 1 << 2
+    }
+
+    /** Denotes the accessibility enabled status */
+    @Retention(RetentionPolicy.SOURCE)
+    public @interface State {
+        int OFF = 0;
+        int ON = 1;
+    }
+
+    /**
      * Return On/Off string according to the setting which specifies the integer value 1 or 0. This
      * setting is defined in the secure system settings {@link android.provider.Settings.Secure}.
      */
     static CharSequence getSummary(Context context, String settingsSecureKey) {
         final boolean enabled = Settings.Secure.getInt(context.getContentResolver(),
-                settingsSecureKey, 0) == 1;
+                settingsSecureKey, State.OFF) == State.ON;
         final int resId = enabled ? R.string.accessibility_feature_state_on
                 : R.string.accessibility_feature_state_off;
         return context.getResources().getText(resId);
     }
 
     /**
+     * Capitalizes a string by capitalizing the first character and making the remaining characters
+     * lower case.
+     */
+    public static String capitalize(String stringToCapitalize) {
+        if (stringToCapitalize == null) {
+            return null;
+        }
+
+        StringBuilder capitalizedString = new StringBuilder();
+        if (stringToCapitalize.length() > 0) {
+            capitalizedString.append(stringToCapitalize.substring(0, 1).toUpperCase());
+            if (stringToCapitalize.length() > 1) {
+                capitalizedString.append(stringToCapitalize.substring(1).toLowerCase());
+            }
+        }
+        return capitalizedString.toString();
+    }
+
+    /** Determines if a gesture navigation bar is being used. */
+    public static boolean isGestureNavigateEnabled(Context context) {
+        return context.getResources().getInteger(
+                com.android.internal.R.integer.config_navBarInteractionMode)
+                == NAV_BAR_MODE_GESTURAL;
+    }
+
+    /**
      * Gets the corresponding fragment type of a given accessibility service
      *
      * @param accessibilityServiceInfo The accessibilityService's info
diff --git a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
index a55f53a..4714fb3 100644
--- a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
@@ -21,6 +21,8 @@
 
 import androidx.preference.PreferenceScreen;
 
+import com.android.settings.R;
+
 /** For accessibility services that target SDK <= Q. */
 public class LegacyAccessibilityServicePreferenceFragment extends
         ToggleAccessibilityServicePreferenceFragment {
@@ -29,10 +31,13 @@
         super.onViewCreated(view, savedInstanceState);
 
         final PreferenceScreen preferenceScreen = getPreferenceScreen();
-        final ShortcutPreference preference = preferenceScreen.findPreference(
+        final ShortcutPreference shortcutPreference = preferenceScreen.findPreference(
                 getShortcutPreferenceKey());
-        if (preference != null) {
-            preference.setSettingsVisibility(View.GONE);
+        if (shortcutPreference != null) {
+            final CharSequence hardwareTitle = getPrefContext().getText(
+                    R.string.accessibility_shortcut_edit_dialog_title_hardware);
+            shortcutPreference.setSummary(hardwareTitle);
+            shortcutPreference.setSettingsVisibility(View.GONE);
         }
     }
 }
diff --git a/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
index 834e0c6..2b618cb 100644
--- a/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/MagnificationPreferenceFragment.java
@@ -16,8 +16,6 @@
 
 package com.android.settings.accessibility;
 
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.app.settings.SettingsEnums;
 import android.content.ComponentName;
@@ -25,7 +23,6 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.os.Bundle;
-import android.provider.SearchIndexableResource;
 import android.provider.Settings;
 import android.text.TextUtils;
 import android.view.accessibility.AccessibilityManager;
@@ -36,12 +33,10 @@
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
 import com.android.settings.search.actionbar.SearchMenuController;
 import com.android.settings.support.actionbar.HelpResourceProvider;
 import com.android.settingslib.search.SearchIndexable;
 
-import java.util.Arrays;
 import java.util.List;
 
 @SearchIndexable
@@ -134,7 +129,7 @@
                 if (info.getComponentName().equals(assignedComponentName)) {
                     final CharSequence assignedServiceName = info.getResolveInfo().loadLabel(
                             context.getPackageManager());
-                    final int messageId = isGestureNavigateEnabled(context)
+                    final int messageId = AccessibilityUtil.isGestureNavigateEnabled(context)
                             ? R.string.accessibility_screen_magnification_gesture_navigation_warning
                             : R.string.accessibility_screen_magnification_navbar_configuration_warning;
                     return context.getString(messageId, assignedServiceName);
@@ -161,12 +156,6 @@
         return res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
     }
 
-    private static boolean isGestureNavigateEnabled(Context context) {
-        return context.getResources().getInteger(
-                com.android.internal.R.integer.config_navBarInteractionMode)
-                == NAV_BAR_MODE_GESTURAL;
-    }
-
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider(R.xml.accessibility_magnification_settings) {
 
diff --git a/src/com/android/settings/accessibility/ShortcutPreference.java b/src/com/android/settings/accessibility/ShortcutPreference.java
index f76bb01..b66a2b6 100644
--- a/src/com/android/settings/accessibility/ShortcutPreference.java
+++ b/src/com/android/settings/accessibility/ShortcutPreference.java
@@ -73,9 +73,11 @@
         }
 
         final View settings = holder.itemView.findViewById(android.R.id.widget_frame);
-        if (settings != null) {
+        final View divider = holder.itemView.findViewById(R.id.divider);
+        if (settings != null && divider != null) {
             settings.setOnClickListener(view -> callOnSettingsClicked());
             settings.setVisibility(mSettingsVisibility);
+            divider.setVisibility(mSettingsVisibility);
         }
     }
 
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 3248e00..269bc04 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -16,8 +16,6 @@
 
 package com.android.settings.accessibility;
 
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.app.Activity;
 import android.app.Dialog;
@@ -43,17 +41,22 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityManager;
+import android.widget.CheckBox;
 
 import androidx.preference.PreferenceScreen;
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
+import com.android.settings.accessibility.AccessibilityUtil.ShortcutType;
 import com.android.settings.password.ConfirmDeviceCredentialActivity;
 import com.android.settings.widget.SwitchBar;
 import com.android.settings.widget.ToggleSwitch;
 import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
 import com.android.settingslib.accessibility.AccessibilityUtils;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
 import java.util.List;
 
 /** Fragment for providing toggle bar and basic accessibility service setup. */
@@ -61,22 +64,18 @@
         ToggleFeaturePreferenceFragment implements ShortcutPreference.OnClickListener {
 
     private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
-    private static final int DIALOG_ID_ENABLE_WARNING = 1;
-    private static final int DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL = 2;
-    private static final int DIALOG_ID_EDIT_SHORTCUT = 3;
+    private static final String EXTRA_SHORTCUT_TYPE = "shortcutType";
+    // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
+    private static final String KEY_SHORTCUT_TYPE = Settings.System.MASTER_MONO;
+    private ShortcutPreference mShortcutPreference;
+    private int mShortcutType = ShortcutType.DEFAULT;
+    private CheckBox mSoftwareTypeCheckBox;
+    private CheckBox mHardwareTypeCheckBox;
 
     public static final int ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION = 1;
-
     private CharSequence mDialogTitle;
-
     private LockPatternUtils mLockPatternUtils;
 
-    private final DialogInterface.OnClickListener mDialogListener =
-            (DialogInterface dialog, int id) -> {
-                if (id == DialogInterface.BUTTON_POSITIVE) {
-                    // TODO(b/142531156): Save the shortcut type preference.
-                }
-            };
 
     private final SettingsContentObserver mSettingsContentObserver =
             new SettingsContentObserver(new Handler()) {
@@ -99,7 +98,7 @@
                     } else {
                         handleConfirmServiceEnabled(true);
                         if (isServiceSupportAccessibilityButton()) {
-                            showDialog(DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL);
+                            showDialog(DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL);
                         }
                     }
                 } else if (view.getId() == R.id.permission_enable_deny_button) {
@@ -131,11 +130,17 @@
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
-        initShortcutPreference();
+        initShortcutPreference(savedInstanceState);
         return super.onCreateView(inflater, container, savedInstanceState);
     }
 
     @Override
+    public void onSaveInstanceState(Bundle outState) {
+        outState.putInt(EXTRA_SHORTCUT_TYPE, mShortcutType);
+        super.onSaveInstanceState(outState);
+    }
+
+    @Override
     public void onResume() {
         mSettingsContentObserver.register(getContentResolver());
         updateSwitchBarToggleSwitch();
@@ -176,7 +181,7 @@
     @Override
     public Dialog onCreateDialog(int dialogId) {
         switch (dialogId) {
-            case DIALOG_ID_ENABLE_WARNING: {
+            case DialogType.ENABLE_WARNING: {
                 final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
                 if (info == null) {
                     return null;
@@ -185,8 +190,8 @@
                         .createCapabilitiesDialog(getActivity(), info, mViewOnClickListener);
                 break;
             }
-            case DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL: {
-                if (isGestureNavigateEnabled()) {
+            case DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL: {
+                if (AccessibilityUtil.isGestureNavigateEnabled(getContext())) {
                     mDialog = AccessibilityGestureNavigationTutorial
                             .showGestureNavigationTutorialDialog(getActivity());
                 } else {
@@ -195,30 +200,129 @@
                 }
                 break;
             }
-            case DIALOG_ID_EDIT_SHORTCUT: {
+            case DialogType.EDIT_SHORTCUT: {
                 final CharSequence dialogTitle = getActivity().getString(
                         R.string.accessibility_shortcut_edit_dialog_title, mDialogTitle);
                 mDialog = AccessibilityEditDialogUtils.showEditShortcutDialog(getActivity(),
-                        dialogTitle, mDialogListener);
+                        dialogTitle, this::callOnAlertDialogCheckboxClicked);
+                initializeDialogCheckBox(mDialog);
                 break;
             }
             default: {
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
             }
         }
         return mDialog;
     }
 
+    private void initializeDialogCheckBox(Dialog dialog) {
+        final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
+        mSoftwareTypeCheckBox = dialogSoftwareView.findViewById(R.id.checkbox);
+        final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
+        mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
+        updateAlertDialogCheckState();
+        updateAlertDialogEnableState();
+    }
+
+    private void updateAlertDialogCheckState() {
+        updateCheckStatus(mSoftwareTypeCheckBox, ShortcutType.SOFTWARE);
+        updateCheckStatus(mHardwareTypeCheckBox, ShortcutType.HARDWARE);
+    }
+
+    private void updateAlertDialogEnableState() {
+        if (!mSoftwareTypeCheckBox.isChecked()) {
+            mHardwareTypeCheckBox.setEnabled(false);
+        } else if (!mHardwareTypeCheckBox.isChecked()) {
+            mSoftwareTypeCheckBox.setEnabled(false);
+        } else {
+            mSoftwareTypeCheckBox.setEnabled(true);
+            mHardwareTypeCheckBox.setEnabled(true);
+        }
+    }
+
+    private void updateCheckStatus(CheckBox checkBox, @ShortcutType int type) {
+        checkBox.setChecked((mShortcutType & type) == type);
+        checkBox.setOnClickListener(v -> {
+            updateShortcutType(false);
+            updateAlertDialogEnableState();
+        });
+    }
+
+    private void updateShortcutType(boolean saveToDB) {
+        mShortcutType = ShortcutType.DEFAULT;
+        if (mSoftwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.SOFTWARE;
+        }
+        if (mHardwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.HARDWARE;
+        }
+        if (saveToDB) {
+            setShortcutType(mShortcutType);
+        }
+    }
+
+    private void setSecureIntValue(String key, @ShortcutType int value) {
+        Settings.Secure.putIntForUser(getPrefContext().getContentResolver(),
+                key, value, getPrefContext().getContentResolver().getUserId());
+    }
+
+    private void setShortcutType(@ShortcutType int type) {
+        setSecureIntValue(KEY_SHORTCUT_TYPE, type);
+    }
+
+    private String getShortcutTypeSummary(Context context) {
+        final int shortcutType = getShortcutType(context);
+        final CharSequence softwareTitle =
+                context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
+                ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
+                : R.string.accessibility_shortcut_edit_dialog_title_software);
+
+        List<CharSequence> list = new ArrayList<>();
+        if ((shortcutType & ShortcutType.SOFTWARE) == ShortcutType.SOFTWARE) {
+            list.add(softwareTitle);
+        }
+        if ((shortcutType & ShortcutType.HARDWARE) == ShortcutType.HARDWARE) {
+            final CharSequence hardwareTitle = context.getText(
+                    R.string.accessibility_shortcut_edit_dialog_title_hardware);
+            list.add(hardwareTitle);
+        }
+
+        // Show software shortcut if first time to use.
+        if (list.isEmpty()) {
+            list.add(softwareTitle);
+        }
+        final String joinStrings = TextUtils.join(/* delimiter= */", ", list);
+        return AccessibilityUtil.capitalize(joinStrings);
+    }
+
+    @ShortcutType
+    private int getShortcutType(Context context) {
+        return getSecureIntValue(context, KEY_SHORTCUT_TYPE, ShortcutType.SOFTWARE);
+    }
+
+    @ShortcutType
+    private int getSecureIntValue(Context context, String key, @ShortcutType int defaultValue) {
+        return Settings.Secure.getIntForUser(
+                context.getContentResolver(),
+                key, defaultValue, context.getContentResolver().getUserId());
+    }
+
+    private void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
+        updateShortcutType(true);
+        mShortcutPreference.setSummary(
+                getShortcutTypeSummary(getPrefContext()));
+    }
+
     @Override
     public int getDialogMetricsCategory(int dialogId) {
         switch (dialogId) {
-            case DIALOG_ID_ENABLE_WARNING:
+            case DialogType.ENABLE_WARNING:
                 return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_ENABLE;
-            case DIALOG_ID_LAUNCH_ACCESSIBILITY_TUTORIAL:
-                return isGestureNavigateEnabled()
+            case DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL:
+                return AccessibilityUtil.isGestureNavigateEnabled(getContext())
                         ? SettingsEnums.DIALOG_TOGGLE_SCREEN_GESTURE_NAVIGATION
                         : SettingsEnums.DIALOG_TOGGLE_SCREEN_ACCESSIBILITY_BUTTON;
-            case DIALOG_ID_EDIT_SHORTCUT:
+            case DialogType.EDIT_SHORTCUT:
                 return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_EDIT_SHORTCUT;
             default:
                 return 0;
@@ -234,21 +338,29 @@
         switchBar.setSwitchBarText(switchBarText, switchBarText);
     }
 
-    private void initShortcutPreference() {
-        final PreferenceScreen preferenceScreen = getPreferenceScreen();
-        final ShortcutPreference shortcutPreference = new ShortcutPreference(
-                preferenceScreen.getContext(), null);
-        // Put the shortcutPreference before settingsPreference.
-        shortcutPreference.setPersistent(false);
-        shortcutPreference.setKey(getShortcutPreferenceKey());
-        shortcutPreference.setOrder(-1);
-        shortcutPreference.setTitle(R.string.accessibility_shortcut_title);
-        shortcutPreference.setOnClickListener(this);
+    private void initShortcutPreference(Bundle savedInstanceState) {
+        // Restore the Shortcut type
+        if (savedInstanceState != null) {
+            mShortcutType = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE, ShortcutType.DEFAULT);
+        }
+        if (mShortcutType == ShortcutType.DEFAULT) {
+            mShortcutType = getShortcutType(getPrefContext());
+        }
 
-        // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
-        // TODO(b/142530063): Check if gesture mode is on to decide which summary should be shown.
+        // Initial ShortcutPreference widget
+        final PreferenceScreen preferenceScreen = getPreferenceScreen();
+        mShortcutPreference = new ShortcutPreference(
+                preferenceScreen.getContext(), null);
+        mShortcutPreference.setPersistent(false);
+        mShortcutPreference.setKey(getShortcutPreferenceKey());
+        mShortcutPreference.setOrder(-1);
+        mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
+        mShortcutPreference.setOnClickListener(this);
+        mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
+        // Put the shortcutPreference before settingsPreference.
+        mShortcutPreference.setOrder(-1);
+        preferenceScreen.addPreference(mShortcutPreference);
         // TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
-        preferenceScreen.addPreference(shortcutPreference);
     }
 
     public String getShortcutPreferenceKey() {
@@ -290,12 +402,6 @@
         }
     }
 
-    private boolean isGestureNavigateEnabled() {
-        return getContext().getResources().getInteger(
-                com.android.internal.R.integer.config_navBarInteractionMode)
-                == NAV_BAR_MODE_GESTURAL;
-    }
-
     private boolean isServiceSupportAccessibilityButton() {
         final AccessibilityManager ams = (AccessibilityManager) getContext().getSystemService(
                 Context.ACCESSIBILITY_SERVICE);
@@ -346,7 +452,7 @@
                 if (checked) {
                     mSwitchBar.setCheckedInternal(false);
                     getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, false);
-                    showDialog(DIALOG_ID_ENABLE_WARNING);
+                    showDialog(DialogType.ENABLE_WARNING);
                 } else {
                     handleConfirmServiceEnabled(false);
                 }
@@ -366,7 +472,8 @@
 
     @Override
     public void onSettingsClicked(ShortcutPreference preference) {
-        showDialog(DIALOG_ID_EDIT_SHORTCUT);
+        mShortcutType = getShortcutType(getPrefContext());
+        showDialog(DialogType.EDIT_SHORTCUT);
     }
 
     @Override
@@ -402,4 +509,11 @@
         mDialogTitle = getAccessibilityServiceInfo().getResolveInfo().loadLabel(
                 getPackageManager());
     }
+
+    @Retention(RetentionPolicy.SOURCE)
+    private @interface DialogType {
+        int ENABLE_WARNING = 1;
+        int LAUNCH_ACCESSIBILITY_TUTORIAL = 2;
+        int EDIT_SHORTCUT = 3;
+    }
 }
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index 880efb6..1c7a5f3 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -18,26 +18,30 @@
 
 import android.app.Dialog;
 import android.app.settings.SettingsEnums;
+import android.content.Context;
 import android.content.DialogInterface;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.provider.Settings;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CheckBox;
 import android.widget.Switch;
 
+import androidx.appcompat.app.AlertDialog;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
+import com.android.settings.accessibility.AccessibilityUtil.ShortcutType;
+import com.android.settings.accessibility.AccessibilityUtil.State;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.widget.SwitchBar;
 import com.android.settingslib.search.SearchIndexable;
 
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -52,15 +56,15 @@
     private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
     private static final String DISPLAY_INVERSION_ENABLED =
             Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
-    private final DialogInterface.OnClickListener mDialogListener =
-            (DialogInterface dialog, int id) -> {
-                if (id == DialogInterface.BUTTON_POSITIVE) {
-                    // TODO(b/142531156): Save the shortcut type preference.
-                }
-            };
+    private static final String EXTRA_SHORTCUT_TYPE = "shortcutType";
+    // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
+    private static final String KEY_SHORTCUT_TYPE = Settings.System.MASTER_MONO;
     private final Handler mHandler = new Handler();
-    private Dialog mDialog;
+    private ShortcutPreference mShortcutPreference;
     private SettingsContentObserver mSettingsContentObserver;
+    private int mShortcutType = ShortcutType.DEFAULT;
+    private CheckBox mSoftwareTypeCheckBox;
+    private CheckBox mHardwareTypeCheckBox;
 
     @Override
     public void onStart() {
@@ -119,10 +123,10 @@
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
-        initShortcutPreference();
-        final List<String> shortcutFeatureKeys = new ArrayList<>(1);
-        shortcutFeatureKeys.add(DISPLAY_INVERSION_ENABLED);
-        mSettingsContentObserver = new SettingsContentObserver(mHandler, shortcutFeatureKeys) {
+        initShortcutPreference(savedInstanceState);
+        final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
+        enableServiceFeatureKeys.add(DISPLAY_INVERSION_ENABLED);
+        mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
             @Override
             public void onChange(boolean selfChange, Uri uri) {
                 mSwitchBar.setCheckedInternal(
@@ -134,15 +138,121 @@
     }
 
     @Override
+    public void onSaveInstanceState(Bundle outState) {
+        outState.putInt(EXTRA_SHORTCUT_TYPE, mShortcutType);
+        super.onSaveInstanceState(outState);
+    }
+
+    @Override
     public Dialog onCreateDialog(int dialogId) {
         if (dialogId == DIALOG_ID_EDIT_SHORTCUT) {
             final CharSequence dialogTitle = getActivity().getString(
                     R.string.accessibility_shortcut_edit_dialog_title_daltonizer);
-            mDialog = AccessibilityEditDialogUtils.showEditShortcutDialog(getActivity(),
-                    dialogTitle, mDialogListener);
+            final AlertDialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
+                    getActivity(),
+                    dialogTitle, this::callOnAlertDialogCheckboxClicked);
+            initializeDialogCheckBox(dialog);
+            return dialog;
+        }
+        throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
+    }
+
+    private void initializeDialogCheckBox(AlertDialog dialog) {
+        final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
+        mSoftwareTypeCheckBox = dialogSoftwareView.findViewById(R.id.checkbox);
+        final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
+        mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
+        updateAlertDialogCheckState();
+        updateAlertDialogEnableState();
+    }
+
+    private void updateAlertDialogCheckState() {
+        updateCheckStatus(mSoftwareTypeCheckBox, ShortcutType.SOFTWARE);
+        updateCheckStatus(mHardwareTypeCheckBox, ShortcutType.HARDWARE);
+    }
+
+    private void updateAlertDialogEnableState() {
+        if (!mSoftwareTypeCheckBox.isChecked()) {
+            mHardwareTypeCheckBox.setEnabled(false);
+        } else if (!mHardwareTypeCheckBox.isChecked()) {
+            mSoftwareTypeCheckBox.setEnabled(false);
+        } else {
+            mSoftwareTypeCheckBox.setEnabled(true);
+            mHardwareTypeCheckBox.setEnabled(true);
+        }
+    }
+
+    private void updateCheckStatus(CheckBox checkBox, @ShortcutType int type) {
+        checkBox.setChecked((mShortcutType & type) == type);
+        checkBox.setOnClickListener(v -> {
+            updateShortcutType(false);
+            updateAlertDialogEnableState();
+        });
+    }
+
+    private void updateShortcutType(boolean saveToDB) {
+        mShortcutType = ShortcutType.DEFAULT;
+        if (mSoftwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.SOFTWARE;
+        }
+        if (mHardwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.HARDWARE;
+        }
+        if (saveToDB) {
+            setShortcutType(mShortcutType);
+        }
+    }
+
+    private void setSecureIntValue(String key, @ShortcutType int value) {
+        Settings.Secure.putIntForUser(getPrefContext().getContentResolver(),
+                key, value, getPrefContext().getContentResolver().getUserId());
+    }
+
+    private void setShortcutType(@ShortcutType int type) {
+        setSecureIntValue(KEY_SHORTCUT_TYPE, type);
+    }
+
+    private String getShortcutTypeSummary(Context context) {
+        final int shortcutType = getShortcutType(context);
+        final CharSequence softwareTitle =
+                context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
+                        ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
+                        : R.string.accessibility_shortcut_edit_dialog_title_software);
+
+        List<CharSequence> list = new ArrayList<>();
+        if ((shortcutType & ShortcutType.SOFTWARE) == ShortcutType.SOFTWARE) {
+            list.add(softwareTitle);
+        }
+        if ((shortcutType & ShortcutType.HARDWARE) == ShortcutType.HARDWARE) {
+            final CharSequence hardwareTitle = context.getText(
+                    R.string.accessibility_shortcut_edit_dialog_title_hardware);
+            list.add(hardwareTitle);
         }
 
-        return mDialog;
+        // Show software shortcut if first time to use.
+        if (list.isEmpty()) {
+            list.add(softwareTitle);
+        }
+        final String joinStrings = TextUtils.join(/* delimiter= */", ", list);
+        return AccessibilityUtil.capitalize(joinStrings);
+    }
+
+    @ShortcutType
+    private int getShortcutType(Context context) {
+        return getSecureIntValue(context, KEY_SHORTCUT_TYPE, ShortcutType.SOFTWARE);
+    }
+
+    @ShortcutType
+    private int getSecureIntValue(Context context, String key, @ShortcutType int defaultValue) {
+        return Settings.Secure.getIntForUser(
+                context.getContentResolver(),
+                key, defaultValue, context.getContentResolver().getUserId());
+    }
+
+    private void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
+        updateShortcutType(true);
+        mShortcutPreference.setSummary(
+                getShortcutTypeSummary(getPrefContext()));
     }
 
     @Override
@@ -153,21 +263,29 @@
         return 0;
     }
 
-    private void initShortcutPreference() {
+    private void initShortcutPreference(Bundle savedInstanceState) {
+        // Restore the Shortcut type
+        if (savedInstanceState != null) {
+            mShortcutType = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE, ShortcutType.DEFAULT);
+        }
+        if (mShortcutType == ShortcutType.DEFAULT) {
+            mShortcutType = getShortcutType(getPrefContext());
+        }
+
+        // Initial ShortcutPreference widget
         final PreferenceScreen preferenceScreen = getPreferenceScreen();
-        final ShortcutPreference shortcutPreference = new ShortcutPreference(
+        mShortcutPreference = new ShortcutPreference(
                 preferenceScreen.getContext(), null);
         final Preference previewPreference = findPreference(PREVIEW_PREFERENCE_KEY);
         // Put the shortcutPreference before radioButtonPreference.
-        shortcutPreference.setPersistent(false);
-        shortcutPreference.setKey(getShortcutPreferenceKey());
-        shortcutPreference.setOrder(previewPreference.getOrder() - 1);
-        shortcutPreference.setTitle(R.string.accessibility_shortcut_title);
-        shortcutPreference.setOnClickListener(this);
-        // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
-        // TODO(b/142530063): Check if gesture mode is on to decide which summary should be shown.
+        mShortcutPreference.setPersistent(false);
+        mShortcutPreference.setKey(getShortcutPreferenceKey());
+        mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
+        mShortcutPreference.setOnClickListener(this);
+        mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
+        mShortcutPreference.setOrder(previewPreference.getOrder() - 1);
+        preferenceScreen.addPreference(mShortcutPreference);
         // TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
-        preferenceScreen.addPreference(shortcutPreference);
     }
 
     public String getShortcutPreferenceKey() {
@@ -185,15 +303,10 @@
 
     @Override
     public void onSettingsClicked(ShortcutPreference preference) {
+        mShortcutType = getShortcutType(getPrefContext());
         showDialog(DIALOG_ID_EDIT_SHORTCUT);
     }
 
-    @Retention(RetentionPolicy.SOURCE)
-    private @interface State {
-        int OFF = 0;
-        int ON = 1;
-    }
-
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider(R.xml.accessibility_color_inversion_settings);
 }
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index a4f3e62..7fb05da 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -23,15 +23,20 @@
 import android.content.res.Resources;
 import android.os.Bundle;
 import android.provider.Settings;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CheckBox;
 import android.widget.Switch;
 
+import androidx.appcompat.app.AlertDialog;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
+import com.android.settings.accessibility.AccessibilityUtil.ShortcutType;
+import com.android.settings.accessibility.AccessibilityUtil.State;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.widget.SwitchBar;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -48,9 +53,16 @@
         SwitchBar.OnSwitchChangeListener, ShortcutPreference.OnClickListener {
 
     private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
-    private static final String RADIOPREFERENCE_KEY = "daltonizer_mode_deuteranomaly";
+    private static final String PREFERENCE_KEY = "daltonizer_mode_deuteranomaly";
+    private static final String EXTRA_SHORTCUT_TYPE = "shortcutType";
+    // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
+    private static final String KEY_SHORTCUT_TYPE = Settings.System.MASTER_MONO;
     private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
     private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
+    private ShortcutPreference mShortcutPreference;
+    private int mShortcutType = ShortcutType.DEFAULT;
+    private CheckBox mSoftwareTypeCheckBox;
+    private CheckBox mHardwareTypeCheckBox;
 
     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
             Lifecycle lifecycle) {
@@ -67,15 +79,6 @@
         return sControllers;
     }
 
-    private final DialogInterface.OnClickListener mDialogListener =
-            (DialogInterface dialog, int id) -> {
-                if (id == DialogInterface.BUTTON_POSITIVE) {
-                    // TODO(b/142531156): Save the shortcut type preference.
-                }
-            };
-
-    private Dialog mDialog;
-
     @Override
     public void onCheckedChanged(Preference preference) {
         for (AbstractPreferenceController controller : sControllers) {
@@ -86,11 +89,17 @@
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
-        initShortcutPreference();
+        initShortcutPreference(savedInstanceState);
         return super.onCreateView(inflater, container, savedInstanceState);
     }
 
     @Override
+    public void onSaveInstanceState(Bundle outState) {
+        outState.putInt(EXTRA_SHORTCUT_TYPE, mShortcutType);
+        super.onSaveInstanceState(outState);
+    }
+
+    @Override
     public void onResume() {
         super.onResume();
         for (AbstractPreferenceController controller :
@@ -115,11 +124,111 @@
         if (dialogId == DIALOG_ID_EDIT_SHORTCUT) {
             final CharSequence dialogTitle = getActivity().getString(
                     R.string.accessibility_shortcut_edit_dialog_title_daltonizer);
-            mDialog = AccessibilityEditDialogUtils.showEditShortcutDialog(getActivity(),
-                    dialogTitle, mDialogListener);
+            final AlertDialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
+                    getActivity(),
+                    dialogTitle, this::callOnAlertDialogCheckboxClicked);
+            initializeDialogCheckBox(dialog);
+            return dialog;
+        }
+        throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
+    }
+
+    private void initializeDialogCheckBox(AlertDialog dialog) {
+        final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
+        mSoftwareTypeCheckBox = dialogSoftwareView.findViewById(R.id.checkbox);
+        final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
+        mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
+        updateAlertDialogCheckState();
+        updateAlertDialogEnableState();
+    }
+
+    private void updateAlertDialogCheckState() {
+        updateCheckStatus(mSoftwareTypeCheckBox, ShortcutType.SOFTWARE);
+        updateCheckStatus(mHardwareTypeCheckBox, ShortcutType.HARDWARE);
+    }
+
+    private void updateAlertDialogEnableState() {
+        if (!mSoftwareTypeCheckBox.isChecked()) {
+            mHardwareTypeCheckBox.setEnabled(false);
+        } else if (!mHardwareTypeCheckBox.isChecked()) {
+            mSoftwareTypeCheckBox.setEnabled(false);
+        } else {
+            mSoftwareTypeCheckBox.setEnabled(true);
+            mHardwareTypeCheckBox.setEnabled(true);
+        }
+    }
+
+    private void updateCheckStatus(CheckBox checkBox, @ShortcutType int type) {
+        checkBox.setChecked((mShortcutType & type) == type);
+        checkBox.setOnClickListener(v -> {
+            updateShortcutType(false);
+            updateAlertDialogEnableState();
+        });
+    }
+
+    private void updateShortcutType(boolean saveToDB) {
+        mShortcutType = ShortcutType.DEFAULT;
+        if (mSoftwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.SOFTWARE;
+        }
+        if (mHardwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.HARDWARE;
+        }
+        if (saveToDB) {
+            setShortcutType(mShortcutType);
+        }
+    }
+
+    private void setSecureIntValue(String key, @ShortcutType int value) {
+        Settings.Secure.putIntForUser(getPrefContext().getContentResolver(),
+                key, value, getPrefContext().getContentResolver().getUserId());
+    }
+
+    private void setShortcutType(@ShortcutType int type) {
+        setSecureIntValue(KEY_SHORTCUT_TYPE, type);
+    }
+
+    private String getShortcutTypeSummary(Context context) {
+        final int shortcutType = getShortcutType(context);
+        final CharSequence softwareTitle =
+                context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
+                        ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
+                        : R.string.accessibility_shortcut_edit_dialog_title_software);
+
+        List<CharSequence> list = new ArrayList<>();
+        if ((shortcutType & ShortcutType.SOFTWARE) == ShortcutType.SOFTWARE) {
+            list.add(softwareTitle);
+        }
+        if ((shortcutType & ShortcutType.HARDWARE) == ShortcutType.HARDWARE) {
+            final CharSequence hardwareTitle = context.getText(
+                    R.string.accessibility_shortcut_edit_dialog_title_hardware);
+            list.add(hardwareTitle);
         }
 
-        return mDialog;
+        // Show software shortcut if first time to use.
+        if (list.isEmpty()) {
+            list.add(softwareTitle);
+        }
+        final String joinStrings = TextUtils.join(/* delimiter= */", ", list);
+        return AccessibilityUtil.capitalize(joinStrings);
+    }
+
+    @ShortcutType
+    private int getShortcutType(Context context) {
+        return getSecureIntValue(context, KEY_SHORTCUT_TYPE, ShortcutType.SOFTWARE);
+    }
+
+    @ShortcutType
+    private int getSecureIntValue(Context context, String key, @ShortcutType int defaultValue) {
+        return Settings.Secure.getIntForUser(
+                context.getContentResolver(),
+                key, defaultValue, context.getContentResolver().getUserId());
+    }
+
+    private void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
+        updateShortcutType(true);
+        mShortcutPreference.setSummary(
+                getShortcutTypeSummary(getPrefContext()));
     }
 
     @Override
@@ -147,7 +256,7 @@
 
     @Override
     protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
-        Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? 0 : 1);
+        Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? State.OFF : State.ON);
     }
 
     @Override
@@ -165,14 +274,14 @@
 
     @Override
     public void onSwitchChanged(Switch switchView, boolean isChecked) {
-        Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? 1 : 0);
+        Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
     }
 
     @Override
     protected void onInstallSwitchBarToggleSwitch() {
         super.onInstallSwitchBarToggleSwitch();
         mSwitchBar.setCheckedInternal(
-                Settings.Secure.getInt(getContentResolver(), ENABLED, 0) == 1);
+                Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF) == State.ON);
         mSwitchBar.addOnSwitchChangeListener(this);
     }
 
@@ -187,22 +296,31 @@
 
     @Override
     public void onSettingsClicked(ShortcutPreference preference) {
+        mShortcutType = getShortcutType(getPrefContext());
         showDialog(DIALOG_ID_EDIT_SHORTCUT);
     }
 
-    private void initShortcutPreference() {
+    private void initShortcutPreference(Bundle savedInstanceState) {
+        // Restore the Shortcut type
+        if (savedInstanceState != null) {
+            mShortcutType = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE, ShortcutType.DEFAULT);
+        }
+        if (mShortcutType == ShortcutType.DEFAULT) {
+            mShortcutType = getShortcutType(getPrefContext());
+        }
+
+        // Initial ShortcutPreference widget
         final PreferenceScreen preferenceScreen = getPreferenceScreen();
-        final ShortcutPreference shortcutPreference = new ShortcutPreference(
+        mShortcutPreference = new ShortcutPreference(
                 preferenceScreen.getContext(), null);
-        final RadioButtonPreference radioButtonPreference = findPreference(RADIOPREFERENCE_KEY);
+        mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
+        mShortcutPreference.setOnClickListener(this);
+        mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
         // Put the shortcutPreference before radioButtonPreference.
-        shortcutPreference.setOrder(radioButtonPreference.getOrder() - 1);
-        shortcutPreference.setTitle(R.string.accessibility_shortcut_title);
-        // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
-        // TODO(b/142530063): Check if gesture mode is on to decide which summary should be shown.
+        final RadioButtonPreference radioButtonPreference = findPreference(PREFERENCE_KEY);
+        mShortcutPreference.setOrder(radioButtonPreference.getOrder() - 1);
+        preferenceScreen.addPreference(mShortcutPreference);
         // TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
-        shortcutPreference.setOnClickListener(this);
-        preferenceScreen.addPreference(shortcutPreference);
     }
 
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 2111f9e..515d80c 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -16,15 +16,12 @@
 
 package com.android.settings.accessibility;
 
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-
 import android.app.Dialog;
 import android.app.settings.SettingsEnums;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.res.Resources;
-import android.graphics.Point;
 import android.media.AudioManager;
 import android.media.MediaPlayer;
 import android.media.MediaPlayer.OnPreparedListener;
@@ -32,41 +29,43 @@
 import android.os.Bundle;
 import android.provider.Settings;
 import android.text.TextUtils;
-import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewTreeObserver.OnGlobalLayoutListener;
-import android.view.WindowManager;
+import android.widget.CheckBox;
 import android.widget.ImageView;
 import android.widget.RelativeLayout.LayoutParams;
 import android.widget.Switch;
 import android.widget.VideoView;
 
+import androidx.appcompat.app.AlertDialog;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 import androidx.preference.PreferenceViewHolder;
 
 import com.android.settings.R;
+import com.android.settings.accessibility.AccessibilityUtil.ShortcutType;
 import com.android.settings.widget.SwitchBar;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
+import java.util.List;
+
 public class ToggleScreenMagnificationPreferenceFragment extends
         ToggleFeaturePreferenceFragment implements SwitchBar.OnSwitchChangeListener,
         ShortcutPreference.OnClickListener {
 
     private static final String SETTINGS_KEY = "screen_magnification_settings";
-    private static final int DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL = 1;
-    private static final int DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL = 2;
-    private static final int DIALOG_ID_EDIT_SHORTCUT = 3;
-
-    private final DialogInterface.OnClickListener mDialogListener =
-            (DialogInterface dialog, int id) -> {
-                if (id == DialogInterface.BUTTON_POSITIVE) {
-                    // TODO(b/142531156): Save the shortcut type preference.
-                }
-            };
-
-    private Dialog mDialog;
+    private static final String EXTRA_SHORTCUT_TYPE = "shortcutType";
+    // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
+    private static final String KEY_SHORTCUT_TYPE = Settings.System.MASTER_MONO;
+    private ShortcutPreference mShortcutPreference;
+    private int mShortcutType = ShortcutType.DEFAULT;
+    private CheckBox mSoftwareTypeCheckBox;
+    private CheckBox mHardwareTypeCheckBox;
+    private CheckBox mTripleTapTypeCheckBox;
 
     protected class VideoPreference extends Preference {
         private ImageView mVideoBackgroundView;
@@ -147,9 +146,6 @@
     protected VideoPreference mVideoPreference;
     protected Preference mConfigWarningPreference;
 
-    private boolean mLaunchFromSuw = false;
-    private boolean mInitialSetting = false;
-
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -185,11 +181,17 @@
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
             Bundle savedInstanceState) {
-        initShortcutPreference();
+        initShortcutPreference(savedInstanceState);
         return super.onCreateView(inflater, container, savedInstanceState);
     }
 
     @Override
+    public void onSaveInstanceState(Bundle outState) {
+        outState.putInt(EXTRA_SHORTCUT_TYPE, mShortcutType);
+        super.onSaveInstanceState(outState);
+    }
+
+    @Override
     public void onResume() {
         super.onResume();
 
@@ -204,25 +206,142 @@
     @Override
     public Dialog onCreateDialog(int dialogId) {
         switch (dialogId) {
-            case DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL:
-                mDialog = AccessibilityGestureNavigationTutorial
+            case DialogType.GESTURE_NAVIGATION_TUTORIAL:
+                return AccessibilityGestureNavigationTutorial
                         .showGestureNavigationTutorialDialog(getActivity());
-                break;
-            case DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL:
-                mDialog = AccessibilityGestureNavigationTutorial
+            case DialogType.ACCESSIBILITY_BUTTON_TUTORIAL:
+                return AccessibilityGestureNavigationTutorial
                         .showAccessibilityButtonTutorialDialog(getActivity());
-                break;
-            case DIALOG_ID_EDIT_SHORTCUT:
+            case DialogType.EDIT_SHORTCUT:
                 final CharSequence dialogTitle = getActivity().getString(
                         R.string.accessibility_shortcut_edit_dialog_title_magnification);
-                mDialog = AccessibilityEditDialogUtils.showMagnificationEditShortcutDialog(
-                        getActivity(), dialogTitle, mDialogListener);
-                break;
-            default:
-                throw new IllegalArgumentException();
+                final AlertDialog dialog =
+                        AccessibilityEditDialogUtils.showMagnificationEditShortcutDialog(
+                                getActivity(), dialogTitle, this::callOnAlertDialogCheckboxClicked);
+                initializeDialogCheckBox(dialog);
+                return dialog;
+        }
+        throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
+    }
+
+    private void initializeDialogCheckBox(AlertDialog dialog) {
+        final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
+        mSoftwareTypeCheckBox = dialogSoftwareView.findViewById(R.id.checkbox);
+        final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
+        mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
+        final View dialogTripleTapView = dialog.findViewById(R.id.triple_tap_shortcut);
+        mTripleTapTypeCheckBox = dialogTripleTapView.findViewById(R.id.checkbox);
+        final View advancedView = dialog.findViewById(R.id.advanced_shortcut);
+        updateAlertDialogCheckState();
+        updateAlertDialogEnableState();
+
+        // Shows the triple tap checkbox directly if clicked.
+        if (mTripleTapTypeCheckBox.isChecked()) {
+            advancedView.setVisibility(View.GONE);
+            dialogTripleTapView.setVisibility(View.VISIBLE);
+        }
+    }
+
+    private void updateAlertDialogCheckState() {
+        updateCheckStatus(mSoftwareTypeCheckBox, ShortcutType.SOFTWARE);
+        updateCheckStatus(mHardwareTypeCheckBox, ShortcutType.HARDWARE);
+        updateCheckStatus(mTripleTapTypeCheckBox, ShortcutType.TRIPLETAP);
+    }
+
+    private void updateAlertDialogEnableState() {
+        if (!mSoftwareTypeCheckBox.isChecked() && !mTripleTapTypeCheckBox.isChecked()) {
+            mHardwareTypeCheckBox.setEnabled(false);
+        } else if (!mHardwareTypeCheckBox.isChecked() && !mTripleTapTypeCheckBox.isChecked()) {
+            mSoftwareTypeCheckBox.setEnabled(false);
+        } else if (!mSoftwareTypeCheckBox.isChecked() && !mHardwareTypeCheckBox.isChecked()) {
+            mTripleTapTypeCheckBox.setEnabled(false);
+        } else {
+            mSoftwareTypeCheckBox.setEnabled(true);
+            mHardwareTypeCheckBox.setEnabled(true);
+            mTripleTapTypeCheckBox.setEnabled(true);
+        }
+    }
+
+    private void updateCheckStatus(CheckBox checkBox, @ShortcutType int type) {
+        checkBox.setChecked((mShortcutType & type) == type);
+        checkBox.setOnClickListener(v -> {
+            updateShortcutType(false);
+            updateAlertDialogEnableState();
+        });
+    }
+
+    private void updateShortcutType(boolean saveToDB) {
+        mShortcutType = ShortcutType.DEFAULT;
+        if (mSoftwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.SOFTWARE;
+        }
+        if (mHardwareTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.HARDWARE;
+        }
+        if (mTripleTapTypeCheckBox.isChecked()) {
+            mShortcutType |= ShortcutType.TRIPLETAP;
+        }
+        if (saveToDB) {
+            setShortcutType(mShortcutType);
+        }
+    }
+
+    private void setSecureIntValue(String key, @ShortcutType int value) {
+        Settings.Secure.putIntForUser(getPrefContext().getContentResolver(),
+                key, value, getPrefContext().getContentResolver().getUserId());
+    }
+
+    private void setShortcutType(@ShortcutType int type) {
+        setSecureIntValue(KEY_SHORTCUT_TYPE, type);
+    }
+
+    private String getShortcutTypeSummary(Context context) {
+        final int shortcutType = getShortcutType(context);
+        final CharSequence softwareTitle =
+                context.getText(AccessibilityUtil.isGestureNavigateEnabled(context)
+                        ? R.string.accessibility_shortcut_edit_dialog_title_software_gesture
+                        : R.string.accessibility_shortcut_edit_dialog_title_software);
+
+        List<CharSequence> list = new ArrayList<>();
+        if ((shortcutType & ShortcutType.SOFTWARE) == ShortcutType.SOFTWARE) {
+            list.add(softwareTitle);
+        }
+        if ((shortcutType & ShortcutType.HARDWARE) == ShortcutType.HARDWARE) {
+            final CharSequence hardwareTitle = context.getText(
+                    R.string.accessibility_shortcut_edit_dialog_title_hardware);
+            list.add(hardwareTitle);
         }
 
-        return mDialog;
+        if ((shortcutType & ShortcutType.TRIPLETAP) == ShortcutType.TRIPLETAP) {
+            final CharSequence tripleTapTitle = context.getText(
+                    R.string.accessibility_shortcut_edit_dialog_title_triple_tap);
+            list.add(tripleTapTitle);
+        }
+
+        // Show software shortcut if first time to use.
+        if (list.isEmpty()) {
+            list.add(softwareTitle);
+        }
+        final String joinStrings = TextUtils.join(/* delimiter= */", ", list);
+        return AccessibilityUtil.capitalize(joinStrings);
+    }
+
+    @ShortcutType
+    private int getShortcutType(Context context) {
+        return getSecureIntValue(context, KEY_SHORTCUT_TYPE, ShortcutType.SOFTWARE);
+    }
+
+    @ShortcutType
+    private int getSecureIntValue(Context context, String key, @ShortcutType int defaultValue) {
+        return Settings.Secure.getIntForUser(
+                context.getContentResolver(),
+                key, defaultValue, context.getContentResolver().getUserId());
+    }
+
+    private void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
+        updateShortcutType(true);
+        mShortcutPreference.setSummary(
+                getShortcutTypeSummary(getPrefContext()));
     }
 
     @Override
@@ -234,11 +353,11 @@
     @Override
     public int getDialogMetricsCategory(int dialogId) {
         switch (dialogId) {
-            case DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL:
+            case DialogType.GESTURE_NAVIGATION_TUTORIAL:
                 return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_GESTURE_NAVIGATION;
-            case DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL:
+            case DialogType.ACCESSIBILITY_BUTTON_TUTORIAL:
                 return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_ACCESSIBILITY_BUTTON;
-            case DIALOG_ID_EDIT_SHORTCUT:
+            case DialogType.EDIT_SHORTCUT:
                 return SettingsEnums.DIALOG_MAGNIFICATION_EDIT_SHORTCUT;
             default:
                 return 0;
@@ -255,8 +374,9 @@
         if (enabled && TextUtils.equals(
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
                 preferenceKey)) {
-            showDialog(isGestureNavigateEnabled() ? DIALOG_ID_GESTURE_NAVIGATION_TUTORIAL
-                    : DIALOG_ID_ACCESSIBILITY_BUTTON_TUTORIAL);
+            showDialog(AccessibilityUtil.isGestureNavigateEnabled(getContext())
+                    ? DialogType.GESTURE_NAVIGATION_TUTORIAL
+                    : DialogType.ACCESSIBILITY_BUTTON_TUTORIAL);
         }
         MagnificationPreferenceFragment.setChecked(getContentResolver(), preferenceKey, enabled);
         updateConfigurationWarningIfNeeded();
@@ -293,20 +413,10 @@
 
         if (arguments.containsKey(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) {
             mVideoPreference.setVisible(true);
-            final int resId = arguments.getInt(
-                    AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID);
         } else {
             mVideoPreference.setVisible(false);
         }
 
-        if (arguments.containsKey(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW)) {
-            mLaunchFromSuw = arguments.getBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW);
-        }
-
-        if (arguments.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
-            mInitialSetting = arguments.getBoolean(AccessibilitySettings.EXTRA_CHECKED);
-        }
-
         if (arguments.containsKey(AccessibilitySettings.EXTRA_TITLE_RES)) {
             final int titleRes = arguments.getInt(AccessibilitySettings.EXTRA_TITLE_RES);
             if (titleRes > 0) {
@@ -326,27 +436,30 @@
 
     @Override
     public void onSettingsClicked(ShortcutPreference preference) {
-        showDialog(DIALOG_ID_EDIT_SHORTCUT);
+        mShortcutType = getShortcutType(getPrefContext());
+        showDialog(DialogType.EDIT_SHORTCUT);
     }
 
-    private void initShortcutPreference() {
+    private void initShortcutPreference(Bundle savedInstanceState) {
+        // Restore the Shortcut type
+        if (savedInstanceState != null) {
+            mShortcutType = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE, ShortcutType.DEFAULT);
+        }
+        if (mShortcutType == ShortcutType.DEFAULT) {
+            mShortcutType = getShortcutType(getPrefContext());
+        }
+
+        // Initial ShortcutPreference widget
         final PreferenceScreen preferenceScreen = getPreferenceScreen();
-        final ShortcutPreference shortcutPreference = new ShortcutPreference(
+        mShortcutPreference = new ShortcutPreference(
                 preferenceScreen.getContext(), null);
+        mShortcutPreference.setTitle(R.string.accessibility_magnification_shortcut_title);
+        mShortcutPreference.setOnClickListener(this);
+        mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
         // Put the shortcutPreference before videoPreference.
-        shortcutPreference.setOrder(mVideoPreference.getOrder() - 1);
-        shortcutPreference.setTitle(R.string.accessibility_magnification_shortcut_title);
-        shortcutPreference.setOnClickListener(this);
-        // TODO(b/142530063): Check the new setting key to decide which summary should be shown.
-        // TODO(b/142530063): Check if gesture mode is on to decide which summary should be shown.
+        mShortcutPreference.setOrder(mVideoPreference.getOrder() - 1);
+        preferenceScreen.addPreference(mShortcutPreference);
         // TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
-        preferenceScreen.addPreference(shortcutPreference);
-    }
-
-    private boolean isGestureNavigateEnabled() {
-        return getContext().getResources().getInteger(
-                com.android.internal.R.integer.config_navBarInteractionMode)
-                == NAV_BAR_MODE_GESTURAL;
     }
 
     private void updateConfigurationWarningIfNeeded() {
@@ -359,11 +472,11 @@
         mConfigWarningPreference.setVisible(warningMessage != null);
     }
 
-    private static int getScreenWidth(Context context) {
-        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
-        Display display = wm.getDefaultDisplay();
-        Point size = new Point();
-        display.getSize(size);
-        return size.x;
+    @Retention(RetentionPolicy.SOURCE)
+    private @interface DialogType {
+        int GESTURE_NAVIGATION_TUTORIAL = 1;
+        int ACCESSIBILITY_BUTTON_TUTORIAL = 2;
+        int EDIT_SHORTCUT = 3;
     }
+
 }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index c23aee6..308878f 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -36,6 +36,7 @@
 
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupcompat.util.WizardManagerHelper;
 import com.google.android.setupdesign.GlifLayout;
 
 /**
@@ -120,6 +121,19 @@
         initViews();
     }
 
+    @Override
+    protected void onStop() {
+        super.onStop();
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
+    }
+
+    protected boolean shouldFinishWhenBackgrounded() {
+        return !WizardManagerHelper.isAnySetupWizard(getIntent());
+    }
+
     protected void initViews() {
         getWindow().setStatusBarColor(Color.TRANSPARENT);
     }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index d94686e..d815f57 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -178,6 +178,11 @@
         }
     }
 
+    @Override
+    protected boolean shouldFinishWhenBackgrounded() {
+        return super.shouldFinishWhenBackgrounded() && !mConfirmingCredentials && !mNextClicked;
+    }
+
     private void updatePasswordQuality() {
         final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
                 .getActivePasswordQuality(mUserManager.getCredentialOwnerProfile(mUserId));
@@ -243,7 +248,8 @@
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST) {
-            if (resultCode == RESULT_FINISHED || resultCode == RESULT_SKIP) {
+            if (resultCode == RESULT_FINISHED || resultCode == RESULT_SKIP
+                    || resultCode == RESULT_TIMEOUT) {
                 setResult(resultCode, data);
                 finish();
                 return;
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index a246055..17a933b 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -23,6 +23,8 @@
 import com.android.settings.R;
 import com.android.settings.password.ChooseLockSettingsHelper;
 
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
 /**
  * Abstract base activity which handles the actual enrolling for biometrics.
  */
@@ -58,7 +60,6 @@
 
     @Override
     protected void onStop() {
-        super.onStop();
         if (mSidecar != null) {
             mSidecar.setListener(null);
         }
@@ -69,6 +70,9 @@
                 getSupportFragmentManager()
                         .beginTransaction().remove(mSidecar).commitAllowingStateLoss();
             }
+            if (!WizardManagerHelper.isAnySetupWizard(getIntent())) {
+                setResult(RESULT_TIMEOUT);
+            }
             finish();
         }
     }
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index e1253c1..3b84c35 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -16,17 +16,13 @@
 
 package com.android.settings.biometrics.face;
 
-import static android.security.KeyStore.getApplicationContext;
-
 import android.app.settings.SettingsEnums;
 import android.content.ComponentName;
-import android.content.Context;
 import android.content.Intent;
 import android.hardware.face.FaceManager;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.UserHandle;
-import android.provider.Settings;
 import android.text.TextUtils;
 import android.view.View;
 import android.view.accessibility.AccessibilityManager;
@@ -173,14 +169,8 @@
     }
 
     @Override
-    protected void onStop() {
-        super.onStop();
-
-        if (!isChangingConfigurations() && !WizardManagerHelper.isAnySetupWizard(getIntent())
-                && !mNextClicked) {
-            setResult(RESULT_SKIP);
-            finish();
-        }
+    protected boolean shouldFinishWhenBackgrounded() {
+        return super.shouldFinishWhenBackgrounded() && !mNextClicked;
     }
 
     @Override
@@ -216,11 +206,13 @@
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
         mResultIntent = data;
         if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST) {
             // If the user finished or skipped enrollment, finish this activity
-            if (resultCode == RESULT_SKIP || resultCode == RESULT_FINISHED) {
-                setResult(resultCode);
+            if (resultCode == RESULT_FINISHED || resultCode == RESULT_SKIP
+                    || resultCode == RESULT_TIMEOUT) {
+                setResult(resultCode, data);
                 finish();
             }
         }
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 073c7e6..6709a6a 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -100,16 +100,6 @@
     }
 
     @Override
-    protected void onStop() {
-        super.onStop();
-
-        if (!isChangingConfigurations() && !mConfirmingCredentials && !mNextClicked
-                && !WizardManagerHelper.isAnySetupWizard(getIntent())) {
-            finish();
-        }
-    }
-
-    @Override
     protected boolean isDisabledByAdmin() {
         return RestrictedLockUtilsInternal.checkIfKeyguardFeaturesDisabled(
                 this, DevicePolicyManager.KEYGUARD_DISABLE_FACE, mUserId) != null;
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index ca51f18..e1ca4f7 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -19,7 +19,9 @@
 import static android.app.Activity.RESULT_OK;
 
 import static com.android.settings.biometrics.BiometricEnrollBase.CONFIRM_REQUEST;
+import static com.android.settings.biometrics.BiometricEnrollBase.ENROLL_REQUEST;
 import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_FINISHED;
+import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_TIMEOUT;
 
 import android.app.settings.SettingsEnums;
 import android.content.Context;
@@ -56,6 +58,11 @@
     private static final String TAG = "FaceSettings";
     private static final String KEY_TOKEN = "hw_auth_token";
 
+    private static final String PREF_KEY_DELETE_FACE_DATA =
+            "security_settings_face_delete_faces_container";
+    private static final String PREF_KEY_ENROLL_FACE_UNLOCK =
+            "security_settings_face_enroll_faces_container";
+
     private UserManager mUserManager;
     private FaceManager mFaceManager;
     private int mUserId;
@@ -85,6 +92,9 @@
         mEnrollButton.setVisible(true);
     };
 
+    private final FaceSettingsEnrollButtonPreferenceController.Listener mEnrollListener = intent ->
+            startActivityForResult(intent, ENROLL_REQUEST);
+
     public static boolean isAvailable(Context context) {
         FaceManager manager = Utils.getFaceManagerOrNull(context);
         return manager != null && manager.isHardwareDetected();
@@ -225,11 +235,16 @@
                     }
                 }
             }
+        } else if (requestCode == ENROLL_REQUEST) {
+            if (resultCode == RESULT_TIMEOUT) {
+                setResult(resultCode, data);
+                finish();
+            }
         }
 
         if (mToken == null) {
             // Didn't get an authentication, finishing
-            getActivity().finish();
+            finish();
         }
     }
 
@@ -247,7 +262,7 @@
                 }
                 mToken = null;
             }
-            getActivity().finish();
+            finish();
         }
     }
 
@@ -272,6 +287,7 @@
                 mRemoveController.setActivity((SettingsActivity) getActivity());
             } else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) {
                 mEnrollController = (FaceSettingsEnrollButtonPreferenceController) controller;
+                mEnrollController.setListener(mEnrollListener);
                 mEnrollController.setActivity((SettingsActivity) getActivity());
             }
         }
@@ -309,6 +325,15 @@
                 protected boolean isPageSearchEnabled(Context context) {
                     return isAvailable(context);
                 }
-            };
 
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    final List<String> keys = super.getNonIndexableKeys(context);
+                    final FaceManager faceManager = context.getSystemService(FaceManager.class);
+                    final boolean hasEnrolled = faceManager.hasEnrolledTemplates(
+                            UserHandle.myUserId());
+                    keys.add(hasEnrolled ? PREF_KEY_ENROLL_FACE_UNLOCK : PREF_KEY_DELETE_FACE_DATA);
+                    return keys;
+                }
+            };
 }
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsEnrollButtonPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsEnrollButtonPreferenceController.java
index a087ccc..e89eca4 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsEnrollButtonPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsEnrollButtonPreferenceController.java
@@ -43,6 +43,7 @@
     private SettingsActivity mActivity;
     private Button mButton;
     private boolean mIsClicked;
+    private Listener mListener;
 
     public FaceSettingsEnrollButtonPreferenceController(Context context) {
         this(context, KEY);
@@ -69,7 +70,11 @@
         intent.setClassName("com.android.settings", FaceEnrollIntroduction.class.getName());
         intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
-        mContext.startActivity(intent);
+        if (mListener != null) {
+            mListener.onStartEnrolling(intent);
+        } else {
+            mContext.startActivity(intent);
+        }
     }
 
     @Override
@@ -95,4 +100,19 @@
     public void setActivity(SettingsActivity activity) {
         mActivity = activity;
     }
+
+    public void setListener(Listener listener) {
+        mListener = listener;
+    }
+
+    /**
+     * Interface for registering callbacks related to the face enroll preference button.
+     */
+    public interface Listener {
+        /**
+         * Called when the user has indicated an intent to begin enrolling a new face.
+         * @param intent The Intent that should be used to launch face enrollment.
+         */
+        void onStartEnrolling(Intent intent);
+    }
 }
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index e92c967..8194878 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -222,8 +222,8 @@
 
     @Override
     protected void onStop() {
-        super.onStop();
         stopIconAnimation();
+        super.onStop();
     }
 
     private void animateProgress(int progress) {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 733fb3f..9508268 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -115,10 +115,15 @@
 
     @Override
     protected void onStop() {
-        super.onStop();
         if (mAnimation != null) {
             mAnimation.pauseAnimation();
         }
+        super.onStop();
+    }
+
+    @Override
+    protected boolean shouldFinishWhenBackgrounded() {
+        return super.shouldFinishWhenBackgrounded() && !mNextClicked;
     }
 
     @Override
@@ -163,26 +168,25 @@
                 finish();
             }
         } else if (requestCode == ENROLL_REQUEST) {
-            if (resultCode == RESULT_FINISHED) {
-                setResult(RESULT_FINISHED);
-                finish();
-            } else if (resultCode == RESULT_SKIP) {
-                setResult(RESULT_SKIP);
-                finish();
-            } else if (resultCode == RESULT_TIMEOUT) {
-                setResult(RESULT_TIMEOUT);
-                finish();
-            } else {
-                FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
-                int enrolled = fpm.getEnrolledFingerprints().size();
-                int max = getResources().getInteger(
-                        com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
-                if (enrolled >= max) {
+            switch (resultCode) {
+                case RESULT_FINISHED:
+                case RESULT_SKIP:
+                case RESULT_TIMEOUT:
+                    setResult(resultCode);
                     finish();
-                } else {
-                    // We came back from enrolling but it wasn't completed, start again.
-                    startLookingForFingerprint();
-                }
+                    break;
+                default:
+                    FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
+                    int enrolled = fpm.getEnrolledFingerprints().size();
+                    int max = getResources().getInteger(
+                            com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
+                    if (enrolled >= max) {
+                        finish();
+                    } else {
+                        // We came back from enrolling but it wasn't completed, start again.
+                        startLookingForFingerprint();
+                    }
+                    break;
             }
         } else {
             super.onActivityResult(requestCode, resultCode, data);
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 68b21f5..1a8e481 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -133,6 +133,7 @@
         private Drawable mHighlightDrawable;
         private int mUserId;
         private CharSequence mFooterTitle;
+        private boolean mEnrollClicked;
 
         private static final String TAG_AUTHENTICATE_SIDECAR = "authenticate_sidecar";
         private static final String TAG_REMOVAL_SIDECAR = "removal_sidecar";
@@ -464,6 +465,14 @@
         }
 
         @Override
+        public void onStop() {
+            super.onStop();
+            if (!getActivity().isChangingConfigurations() && !mLaunchedConfirm && !mEnrollClicked) {
+                getActivity().finish();
+            }
+        }
+
+        @Override
         public void onSaveInstanceState(final Bundle outState) {
             outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
                     mToken);
@@ -475,6 +484,7 @@
         public boolean onPreferenceTreeClick(Preference pref) {
             final String key = pref.getKey();
             if (KEY_FINGERPRINT_ADD.equals(key)) {
+                mEnrollClicked = true;
                 Intent intent = new Intent();
                 intent.setClassName(SETTINGS_PACKAGE_NAME,
                         FingerprintEnrollEnrolling.class.getName());
@@ -564,9 +574,10 @@
                     }
                 }
             } else if (requestCode == ADD_FINGERPRINT_REQUEST) {
+                mEnrollClicked = false;
                 if (resultCode == RESULT_TIMEOUT) {
                     Activity activity = getActivity();
-                    activity.setResult(RESULT_TIMEOUT);
+                    activity.setResult(resultCode);
                     activity.finish();
                 }
             }
diff --git a/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java b/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java
index bdd76fc..3543832 100644
--- a/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/BrandedAccountPreferenceController.java
@@ -32,13 +32,13 @@
 import com.android.settings.overlay.FeatureFactory;
 
 public class BrandedAccountPreferenceController extends BasePreferenceController {
-    private final Account[] mAccounts;
+    private final AccountFeatureProvider mAccountFeatureProvider;
+    private Account[] mAccounts;
 
     public BrandedAccountPreferenceController(Context context, String key) {
         super(context, key);
-        final AccountFeatureProvider accountFeatureProvider = FeatureFactory.getFactory(
-                mContext).getAccountFeatureProvider();
-        mAccounts = accountFeatureProvider.getAccounts(mContext);
+        mAccountFeatureProvider = FeatureFactory.getFactory(mContext).getAccountFeatureProvider();
+        mAccounts = mAccountFeatureProvider.getAccounts(mContext);
     }
 
     @Override
@@ -56,8 +56,6 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        final AccountFeatureProvider accountFeatureProvider = FeatureFactory.getFactory(
-                mContext).getAccountFeatureProvider();
         final Preference accountPreference = screen.findPreference(getPreferenceKey());
         if (accountPreference != null && (mAccounts == null || mAccounts.length == 0)) {
             screen.removePreference(accountPreference);
@@ -72,7 +70,7 @@
             args.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE,
                     android.os.Process.myUserHandle());
             args.putString(AccountDetailDashboardFragment.KEY_ACCOUNT_TYPE,
-                    accountFeatureProvider.getAccountType());
+                    mAccountFeatureProvider.getAccountType());
 
             new SubSettingLauncher(mContext)
                     .setDestination(AccountDetailDashboardFragment.class.getName())
@@ -83,4 +81,13 @@
             return true;
         });
     }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        mAccounts = mAccountFeatureProvider.getAccounts(mContext);
+        if (mAccounts == null || mAccounts.length == 0) {
+            preference.setVisible(false);
+        }
+    }
 }
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 5a04143..b9b8b87 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -49,7 +49,7 @@
 public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>> {
 
     @VisibleForTesting
-    static final int DEFAULT_CARD_COUNT = 2;
+    static final int DEFAULT_CARD_COUNT = 3;
     static final int CARD_CONTENT_LOADER_ID = 1;
 
     private static final String TAG = "ContextualCardLoader";
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java
deleted file mode 100644
index 419b770..0000000
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import android.app.PendingIntent;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.text.Spannable;
-import android.text.SpannableString;
-import android.text.TextUtils;
-import android.text.format.Formatter;
-import android.text.style.TextAppearanceSpan;
-
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.SliceAction;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.settings.R;
-import com.android.settings.SubSettings;
-import com.android.settings.Utils;
-import com.android.settings.datausage.DataUsageSummary;
-import com.android.settings.datausage.DataUsageUtils;
-import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SliceBuilderUtils;
-import com.android.settingslib.net.DataUsageController;
-
-import java.util.concurrent.TimeUnit;
-
-public class DataUsageSlice implements CustomSliceable {
-    private static final String TAG = "DataUsageSlice";
-    private static final long MILLIS_IN_A_DAY = TimeUnit.DAYS.toMillis(1);
-
-
-    private final Context mContext;
-
-    public DataUsageSlice(Context context) {
-        mContext = context;
-    }
-
-    @Override
-    public Uri getUri() {
-        return CustomSliceRegistry.DATA_USAGE_SLICE_URI;
-    }
-
-    @Override
-    public Slice getSlice() {
-        final IconCompat icon = IconCompat.createWithResource(mContext,
-                R.drawable.ic_settings_data_usage);
-        final String title = mContext.getString(R.string.data_usage_summary_title);
-        final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon,
-                ListBuilder.ICON_IMAGE, title);
-        final DataUsageController dataUsageController = new DataUsageController(mContext);
-        final DataUsageController.DataUsageInfo info = dataUsageController.getDataUsageInfo();
-        final ListBuilder listBuilder =
-                new ListBuilder(mContext, CustomSliceRegistry.DATA_USAGE_SLICE_URI,
-                        ListBuilder.INFINITY)
-                        .setAccentColor(Utils.getColorAccentDefaultColor(mContext))
-                        .setHeader(new ListBuilder.HeaderBuilder().setTitle(title));
-        if (DataUsageUtils.hasSim(mContext)) {
-            listBuilder.addRow(new ListBuilder.RowBuilder()
-                    .setTitle(getDataUsageText(info))
-                    .setSubtitle(getCycleTime(info))
-                    .setPrimaryAction(primaryAction));
-        } else {
-            listBuilder.addRow(new ListBuilder.RowBuilder()
-                    .setTitle(mContext.getText(R.string.no_sim_card))
-                    .setPrimaryAction(primaryAction));
-        }
-        return listBuilder.build();
-    }
-
-    @Override
-    public Intent getIntent() {
-        final String screenTitle = mContext.getText(R.string.data_usage_wifi_title).toString();
-        return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
-                DataUsageSummary.class.getName(), "" /* key */, screenTitle,
-                SettingsEnums.SLICE)
-                .setClassName(mContext.getPackageName(), SubSettings.class.getName())
-                .setData(CustomSliceRegistry.DATA_USAGE_SLICE_URI);
-    }
-
-    private PendingIntent getPrimaryAction() {
-        final Intent intent = getIntent();
-        return PendingIntent.getActivity(mContext, 0  /* requestCode */, intent, 0  /* flags */);
-    }
-
-    @VisibleForTesting
-    CharSequence getDataUsageText(DataUsageController.DataUsageInfo info) {
-        final Formatter.BytesResult usedResult = Formatter.formatBytes(mContext.getResources(),
-                info.usageLevel, Formatter.FLAG_CALCULATE_ROUNDED | Formatter.FLAG_IEC_UNITS);
-        final SpannableString usageNumberText = new SpannableString(usedResult.value);
-        usageNumberText.setSpan(
-                new TextAppearanceSpan(mContext, android.R.style.TextAppearance_Large), 0,
-                usageNumberText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-        return TextUtils.expandTemplate(mContext.getText(R.string.data_used_formatted),
-                usageNumberText, usedResult.units);
-    }
-
-    @VisibleForTesting
-    CharSequence getCycleTime(DataUsageController.DataUsageInfo info) {
-        final long millisLeft = info.cycleEnd - System.currentTimeMillis();
-        if (millisLeft <= 0) {
-            return mContext.getString(R.string.billing_cycle_none_left);
-        } else {
-            final int daysLeft = (int) (millisLeft / MILLIS_IN_A_DAY);
-            return daysLeft < 1 ? mContext.getString(R.string.billing_cycle_less_than_one_day_left)
-                    : mContext.getResources().getQuantityString(R.plurals.billing_cycle_days_left,
-                            daysLeft, daysLeft);
-        }
-    }
-
-    @Override
-    public void onNotifyChange(Intent intent) {
-
-    }
-}
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java
deleted file mode 100644
index 4a028b0..0000000
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import android.app.PendingIntent;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.SliceAction;
-
-import com.android.settings.R;
-import com.android.settings.SubSettings;
-import com.android.settings.Utils;
-import com.android.settings.deviceinfo.HardwareInfoPreferenceController;
-import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
-import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SliceBuilderUtils;
-import com.android.settingslib.DeviceInfoUtils;
-
-import java.util.List;
-
-public class DeviceInfoSlice implements CustomSliceable {
-    private static final String TAG = "DeviceInfoSlice";
-
-    private final Context mContext;
-    private final SubscriptionManager mSubscriptionManager;
-
-    public DeviceInfoSlice(Context context) {
-        mContext = context;
-        mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
-    }
-
-    @Override
-    public Slice getSlice() {
-        final IconCompat icon = IconCompat.createWithResource(mContext,
-                R.drawable.ic_info_outline_24dp);
-        final String title = mContext.getString(R.string.device_info_label);
-        final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon,
-                ListBuilder.ICON_IMAGE, title);
-        return new ListBuilder(mContext, CustomSliceRegistry.DEVICE_INFO_SLICE_URI,
-                ListBuilder.INFINITY)
-                .setAccentColor((Utils.getColorAccentDefaultColor(mContext)))
-                .setHeader(new ListBuilder.HeaderBuilder().setTitle(title))
-                .addRow(new ListBuilder.RowBuilder()
-                        .setTitle(getPhoneNumber())
-                        .setSubtitle(getDeviceModel())
-                        .setPrimaryAction(primaryAction))
-                .build();
-    }
-
-    @Override
-    public Uri getUri() {
-        return CustomSliceRegistry.DEVICE_INFO_SLICE_URI;
-    }
-
-    @Override
-    public Intent getIntent() {
-        final String screenTitle = mContext.getText(R.string.device_info_label).toString();
-        return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
-                MyDeviceInfoFragment.class.getName(), "" /* key */, screenTitle,
-                SettingsEnums.SLICE)
-                .setClassName(mContext.getPackageName(), SubSettings.class.getName())
-                .setData(CustomSliceRegistry.DEVICE_INFO_SLICE_URI);
-    }
-
-    private PendingIntent getPrimaryAction() {
-        final Intent intent = getIntent();
-        return PendingIntent.getActivity(mContext, 0  /* requestCode */, intent, 0  /* flags */);
-    }
-
-    @VisibleForTesting
-    CharSequence getPhoneNumber() {
-        final SubscriptionInfo subscriptionInfo = getFirstSubscriptionInfo();
-        if (subscriptionInfo == null) {
-            return mContext.getString(R.string.device_info_default);
-        }
-        final String phoneNumber = DeviceInfoUtils.getBidiFormattedPhoneNumber(mContext,
-                subscriptionInfo);
-        return TextUtils.isEmpty(phoneNumber) ? mContext.getString(R.string.device_info_default)
-                : phoneNumber;
-    }
-
-    private CharSequence getDeviceModel() {
-        return HardwareInfoPreferenceController.getDeviceModel();
-    }
-
-    @VisibleForTesting
-    SubscriptionInfo getFirstSubscriptionInfo() {
-        final List<SubscriptionInfo> subscriptionInfoList =
-                mSubscriptionManager.getActiveSubscriptionInfoList();
-        if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
-            return null;
-        }
-        return subscriptionInfoList.get(0);
-    }
-
-    @Override
-    public void onNotifyChange(Intent intent) {
-
-    }
-}
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java
deleted file mode 100644
index 10e87ff..0000000
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.builders.ListBuilder;
-import androidx.slice.builders.SliceAction;
-
-import com.android.settings.R;
-import com.android.settings.accounts.EmergencyInfoPreferenceController;
-import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.slices.CustomSliceable;
-
-// This is a slice helper class for EmergencyInfo
-public class EmergencyInfoSlice implements CustomSliceable {
-
-    private final Context mContext;
-
-    public EmergencyInfoSlice(Context context) {
-        mContext = context;
-    }
-
-    @Override
-    public Slice getSlice() {
-        final ListBuilder listBuilder = new ListBuilder(mContext,
-                CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI,
-                ListBuilder.INFINITY);
-        listBuilder.addRow(
-                new ListBuilder.RowBuilder()
-                        .setTitle(mContext.getText(R.string.emergency_info_title))
-                        .setSubtitle(
-                                mContext.getText(R.string.emergency_info_contextual_card_summary))
-                        .setPrimaryAction(createPrimaryAction()));
-        return listBuilder.build();
-    }
-
-    @Override
-    public Uri getUri() {
-        return CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI;
-    }
-
-    @Override
-    public Intent getIntent() {
-        return new Intent(EmergencyInfoPreferenceController.getIntentAction(mContext));
-    }
-
-    @Override
-    public void onNotifyChange(Intent intent) {
-    }
-
-    private SliceAction createPrimaryAction() {
-        final PendingIntent pendingIntent =
-                PendingIntent.getActivity(
-                        mContext,
-                        0 /* requestCode */,
-                        getIntent(),
-                        PendingIntent.FLAG_UPDATE_CURRENT);
-
-        return SliceAction.createDeeplink(
-                pendingIntent,
-                IconCompat.createWithResource(mContext, R.drawable.empty_icon),
-                ListBuilder.ICON_IMAGE,
-                mContext.getText(R.string.emergency_info_title));
-    }
-}
diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java
index 66cc600..700fe2e 100644
--- a/src/com/android/settings/slices/CustomSliceRegistry.java
+++ b/src/com/android/settings/slices/CustomSliceRegistry.java
@@ -29,9 +29,6 @@
 import com.android.settings.display.AdaptiveSleepPreferenceController;
 import com.android.settings.flashlight.FlashlightSlice;
 import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
-import com.android.settings.homepage.contextualcards.deviceinfo.DataUsageSlice;
-import com.android.settings.homepage.contextualcards.deviceinfo.DeviceInfoSlice;
-import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
 import com.android.settings.homepage.contextualcards.deviceinfo.StorageSlice;
 import com.android.settings.homepage.contextualcards.slices.BatteryFixSlice;
 import com.android.settings.homepage.contextualcards.slices.BluetoothDevicesSlice;
@@ -117,34 +114,6 @@
             .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
             .appendPath("contextual_wifi")
             .build();
-
-    /**
-     * Backing Uri for the Data usage Slice.
-     */
-    public static final Uri DATA_USAGE_SLICE_URI = new Uri.Builder()
-            .scheme(ContentResolver.SCHEME_CONTENT)
-            .authority(SettingsSliceProvider.SLICE_AUTHORITY)
-            .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
-            .appendPath("data_usage_card")
-            .build();
-    /**
-     * Backing Uri for the Device info Slice.
-     */
-    public static final Uri DEVICE_INFO_SLICE_URI = new Uri.Builder()
-            .scheme(ContentResolver.SCHEME_CONTENT)
-            .authority(SettingsSliceProvider.SLICE_AUTHORITY)
-            .appendPath(SettingsSlicesContract.PATH_SETTING_INTENT)
-            .appendPath("device_info_card")
-            .build();
-    /**
-     * Backing Uri for the Emergency Info Slice.
-     */
-    public static final Uri EMERGENCY_INFO_SLICE_URI = new Uri.Builder()
-            .scheme(ContentResolver.SCHEME_CONTENT)
-            .authority(SettingsSliceProvider.SLICE_AUTHORITY)
-            .appendPath(SettingsSlicesContract.PATH_SETTING_INTENT)
-            .appendPath("emergency_info_card")
-            .build();
     /**
      * Slice Uri for Enhanced 4G slice
      */
@@ -355,9 +324,6 @@
         sUriToSlice.put(CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI,
                 ContextualNotificationChannelSlice.class);
         sUriToSlice.put(CONTEXTUAL_WIFI_SLICE_URI, ContextualWifiSlice.class);
-        sUriToSlice.put(DATA_USAGE_SLICE_URI, DataUsageSlice.class);
-        sUriToSlice.put(DEVICE_INFO_SLICE_URI, DeviceInfoSlice.class);
-        sUriToSlice.put(EMERGENCY_INFO_SLICE_URI, EmergencyInfoSlice.class);
         sUriToSlice.put(FACE_ENROLL_SLICE_URI, FaceSetupSlice.class);
         sUriToSlice.put(FLASHLIGHT_SLICE_URI, FlashlightSlice.class);
         sUriToSlice.put(LOCATION_SLICE_URI, LocationSlice.class);
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 3e8a42c..c6b4702 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -366,7 +366,7 @@
             } else {
                 final String signalLevel = getSignalString();
 
-                if (mWifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED
+                if (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED
                             && signalLevel != null) {
                     mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
                 } else {
@@ -388,16 +388,10 @@
                     }
 
                     final ConnectedInfo info = mWifiEntry.getConnectedInfo();
-                    // TODO(b/143326832): Replace it with ConnectedInfo#linkSpeedMbps.
-                   //if (info != null && info.getTxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
-                    //    addRow(group, R.string.tx_wifi_speed, String.format(
-                   //            res.getString(R.string.tx_link_speed), info.getTxLinkSpeedMbps()));
-                    //}
-
-                   //if (info != null && info.getRxLinkSpeedMbps() != WifiInfo.LINK_SPEED_UNKNOWN) {
-                    //    addRow(group, R.string.rx_wifi_speed, String.format(
-                   //            res.getString(R.string.rx_link_speed), info.getRxLinkSpeedMbps()));
-                    //}
+                    if (info != null && info.linkSpeedMbps >= 0) {
+                        addRow(group, R.string.wifi_speed, String.format(
+                                res.getString(R.string.link_speed), info.linkSpeedMbps));
+                    }
 
                     if (info != null && info.frequencyMhz != WifiEntry.FREQUENCY_UNKNOWN) {
                         final int frequency = info.frequencyMhz;
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index eb02833..4310476 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -493,7 +493,7 @@
             // could only be disconnected and be put in blacklists so it won't be used again.
             if (mSelectedAccessPoint.isSaved() || mSelectedAccessPoint.isEphemeral()) {
                 final int stringId = mSelectedAccessPoint.isEphemeral() ?
-                    R.string.wifi_disconnect_button_text : R.string.forget;
+                        R.string.wifi_disconnect_button_text : R.string.forget;
                 menu.add(Menu.NONE, MENU_ID_FORGET, 0 /* order */, stringId);
             }
 
@@ -1210,28 +1210,6 @@
         ((AccessPointPreference) accessPoint.getTag()).onLevelChanged();
     }
 
-    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider() {
-                @Override
-                public List<SearchIndexableRaw> getRawDataToIndex(Context context,
-                        boolean enabled) {
-                    final List<SearchIndexableRaw> result = new ArrayList<>();
-                    final Resources res = context.getResources();
-
-                    // Add fragment title if we are showing this fragment
-                    if (res.getBoolean(R.bool.config_show_wifi_settings)) {
-                        SearchIndexableRaw data = new SearchIndexableRaw(context);
-                        data.title = res.getString(R.string.wifi_settings);
-                        data.screenTitle = res.getString(R.string.wifi_settings);
-                        data.keywords = res.getString(R.string.keywords_wifi);
-                        data.key = DATA_KEY_REFERENCE;
-                        result.add(data);
-                    }
-
-                    return result;
-                }
-            };
-
     private void handleConfigNetworkSubmitEvent(Intent data) {
         final WifiConfiguration wifiConfiguration = data.getParcelableExtra(
                 ConfigureAccessPointFragment.NETWORK_CONFIG_KEY);
@@ -1257,4 +1235,42 @@
                 .setResultListener(this, CONFIG_NETWORK_REQUEST)
                 .launch();
     }
+
+    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider(R.xml.wifi_settings) {
+                @Override
+                public List<SearchIndexableRaw> getRawDataToIndex(Context context,
+                        boolean enabled) {
+                    final List<SearchIndexableRaw> result = new ArrayList<>();
+                    final Resources res = context.getResources();
+
+                    // Add fragment title if we are showing this fragment
+                    if (res.getBoolean(R.bool.config_show_wifi_settings)) {
+                        SearchIndexableRaw data = new SearchIndexableRaw(context);
+                        data.title = res.getString(R.string.wifi_settings);
+                        data.screenTitle = res.getString(R.string.wifi_settings);
+                        data.keywords = res.getString(R.string.keywords_wifi);
+                        data.key = DATA_KEY_REFERENCE;
+                        result.add(data);
+                    }
+                    return result;
+                }
+
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    final List<String> keys = super.getNonIndexableKeys(context);
+
+                    final WifiManager wifiManager = context.getSystemService(WifiManager.class);
+                    final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(
+                            context, wifiManager);
+                    if (accessPoints == null || accessPoints.size() <= 0) {
+                        keys.add(PREF_KEY_SAVED_NETWORKS);
+                    }
+
+                    if (!DataUsageUtils.hasWifiRadio(context)) {
+                        keys.add(PREF_KEY_DATA_USAGE);
+                    }
+                    return keys;
+                }
+            };
 }
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index 96f3a4f..58f903c 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -139,6 +139,19 @@
     private String mDialogWifiEntryKey;
     private WifiEntry mDialogWifiEntry;
 
+    // This boolean extra specifies whether to enable the Next button when connected. Used by
+    // account creation outside of setup wizard.
+    private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
+
+    // Enable the Next button when a Wi-Fi network is connected.
+    private boolean mEnableNextOnConnection;
+
+    // This string extra specifies a network to open the connect dialog on, so the user can enter
+    // network credentials.  This is used by quick settings for secured networks, among other
+    // things.
+    private static final String EXTRA_START_CONNECT_SSID = "wifi_start_connect_ssid";
+    private String mOpenSsid;
+
     private static boolean isVerboseLoggingEnabled() {
         return WifiPickerTracker.isVerboseLoggingEnabled();
     }
@@ -326,6 +339,15 @@
                 }
             }
         }
+
+        // If we're supposed to enable/disable the Next button based on our current connection
+        // state, start it off in the right state.
+        final Intent intent = getActivity().getIntent();
+        mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
+
+        if (intent.hasExtra(EXTRA_START_CONNECT_SSID)) {
+            mOpenSsid = intent.getStringExtra(EXTRA_START_CONNECT_SSID);
+        }
     }
 
     @Override
@@ -381,6 +403,23 @@
         if (mWifiEnabler != null) {
             mWifiEnabler.resume(activity);
         }
+
+        changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
+
+        // Edit the Wi-Fi network of specified SSID.
+        if (mOpenSsid != null) {
+            Optional<WifiEntry> matchedWifiEntry = mWifiPickerTracker.getWifiEntries().stream()
+                    .filter(wifiEntry -> TextUtils.equals(mOpenSsid, wifiEntry.getSsid()))
+                    .filter(wifiEntry -> wifiEntry.getSecurity() != WifiEntry.SECURITY_NONE
+                            && wifiEntry.getSecurity() != WifiEntry.SECURITY_OWE)
+                    .filter(wifiEntry -> !wifiEntry.isSaved()
+                            || isDisabledByWrongPassword(wifiEntry))
+                    .findFirst();
+            if (matchedWifiEntry.isPresent()) {
+                mOpenSsid = null;
+                launchConfigNewNetworkFragment(matchedWifiEntry.get());
+            }
+        }
     }
 
     @Override
@@ -582,6 +621,16 @@
         mDialogWifiEntryKey = null;
     }
 
+    @Override
+    public int getDialogMetricsCategory(int dialogId) {
+        switch (dialogId) {
+            case WIFI_DIALOG_ID:
+                return SettingsEnums.DIALOG_WIFI_AP_EDIT;
+            default:
+                return 0;
+        }
+    }
+
     /** Called when the state of Wifi has changed. */
     @Override
     public void onWifiStateChanged() {
@@ -623,6 +672,7 @@
     @Override
     public void onWifiEntriesChanged() {
         updateWifiEntryPreferencesDelayed();
+        changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
     }
 
     @Override
@@ -879,6 +929,19 @@
         return R.string.help_url_wifi;
     }
 
+    /**
+     * Renames/replaces "Next" button when appropriate. "Next" button usually exists in
+     * Wi-Fi setup screens, not in usual wifi settings screen.
+     *
+     * @param enabled true when the device is connected to a wifi network.
+     */
+    @VisibleForTesting
+    void changeNextButtonState(boolean enabled) {
+        if (mEnableNextOnConnection && hasNextButton()) {
+            getNextButton().setEnabled(enabled);
+        }
+    }
+
     @Override
     public void onForget(WifiDialog2 dialog) {
         forget(mDialogWifiEntry);
@@ -1004,16 +1067,7 @@
                 if (mEditIfNoConfig) {
                     // Edit an unsaved secure Wi-Fi network.
                     if (mFullScreenEdit) {
-                        final Bundle bundle = new Bundle();
-                        bundle.putString(WifiNetworkDetailsFragment2.KEY_CHOSEN_WIFIENTRY_KEY,
-                                mConnectWifiEntry.getKey());
-                        new SubSettingLauncher(getContext())
-                                .setTitleText(mConnectWifiEntry.getTitle())
-                                .setDestination(ConfigureWifiEntryFragment.class.getName())
-                                .setArguments(bundle)
-                                .setSourceMetricsCategory(getMetricsCategory())
-                                .setResultListener(WifiSettings2.this, CONFIG_NETWORK_REQUEST)
-                                .launch();
+                        launchConfigNewNetworkFragment(mConnectWifiEntry);
                     } else {
                         showDialog(mConnectWifiEntry, WifiConfigUiBase2.MODE_MODIFY);
                     }
@@ -1028,4 +1082,32 @@
     private boolean isFisishingOrDestroyed(Activity activity) {
         return activity == null || activity.isFinishing() || activity.isDestroyed();
     }
+
+    private void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
+        final Bundle bundle = new Bundle();
+        bundle.putString(WifiNetworkDetailsFragment2.KEY_CHOSEN_WIFIENTRY_KEY,
+                wifiEntry.getKey());
+        new SubSettingLauncher(getContext())
+                .setTitleText(wifiEntry.getTitle())
+                .setDestination(ConfigureWifiEntryFragment.class.getName())
+                .setArguments(bundle)
+                .setSourceMetricsCategory(getMetricsCategory())
+                .setResultListener(WifiSettings2.this, CONFIG_NETWORK_REQUEST)
+                .launch();
+    }
+
+    /** Helper method to return whether an WifiEntry is disabled due to a wrong password */
+    private static boolean isDisabledByWrongPassword(WifiEntry wifiEntry) {
+        WifiConfiguration config = wifiEntry.getWifiConfiguration();
+        if (config == null) {
+            return false;
+        }
+        WifiConfiguration.NetworkSelectionStatus networkStatus =
+                config.getNetworkSelectionStatus();
+        if (networkStatus == null || networkStatus.isNetworkEnabled()) {
+            return false;
+        }
+        int reason = networkStatus.getNetworkSelectionDisableReason();
+        return WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD == reason;
+    }
 }
diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
index 0741695..b9b0d64 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
@@ -105,8 +105,8 @@
         // 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
         // 3: With Dual mode support we can't have BAND_5GHZ only - include 2GHZ
         if (!isDualMode
-                && ((band & (SoftApConfiguration.BAND_5GHZ
-                | SoftApConfiguration.BAND_2GHZ)) != 0)) {
+                && ((band & SoftApConfiguration.BAND_5GHZ) != 0)
+                && ((band & SoftApConfiguration.BAND_2GHZ) != 0)) {
             return SoftApConfiguration.BAND_5GHZ;
         } else if (!is5GhzBandSupported() && SoftApConfiguration.BAND_5GHZ == band) {
             return SoftApConfiguration.BAND_2GHZ;
diff --git a/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java b/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
new file mode 100644
index 0000000..24abac9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/AirplaneModeEnablerTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.telephony.TelephonyManager;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowSettings;
+
+
+@RunWith(AndroidJUnit4.class)
+public final class AirplaneModeEnablerTest {
+
+    private Context mContext;
+
+    @Mock
+    private AirplaneModeChangedListener mAirplaneModeChangedListener;
+    private AirplaneModeEnabler mAirplaneModeEnabler;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application.getBaseContext();
+        mAirplaneModeEnabler = new AirplaneModeEnabler(mContext,
+                mAirplaneModeChangedListener);
+    }
+
+    @Test
+    public void onRadioPowerStateChanged_beenInvoke_invokeOnAirplaneModeChanged() {
+        mAirplaneModeEnabler.resume();
+
+        ShadowSettings.setAirplaneMode(true);
+
+        mAirplaneModeEnabler.mPhoneStateListener.onRadioPowerStateChanged(
+                TelephonyManager.RADIO_POWER_OFF);
+
+        verify(mAirplaneModeChangedListener, times(1)).onAirplaneModeChanged(true);
+    }
+
+    private class AirplaneModeChangedListener
+            implements AirplaneModeEnabler.OnAirplaneModeChangedListener {
+        public void onAirplaneModeChanged(boolean isAirplaneModeOn) {}
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
index 27db431..2ccfd05 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
@@ -54,6 +54,16 @@
     }
 
     @Test
+    public void capitalize_shouldReturnCapitalizedString() {
+        assertThat(AccessibilityUtil.capitalize(null)).isNull();
+        assertThat(AccessibilityUtil.capitalize("")).isEmpty();
+        assertThat(AccessibilityUtil.capitalize("Hans")).isEqualTo("Hans");
+        assertThat(AccessibilityUtil.capitalize("hans")).isEqualTo("Hans");
+        assertThat(AccessibilityUtil.capitalize(",hans")).isEqualTo(",hans");
+        assertThat(AccessibilityUtil.capitalize("Hans, Hans")).isEqualTo("Hans, hans");
+    }
+
+    @Test
     public void getSummary_hasValueAndEqualsToOne_shouldReturnOnString() {
         Settings.Secure.putInt(mContext.getContentResolver(), SECURE_TEST_KEY, ON);
 
@@ -90,7 +100,6 @@
 
         assertThat(AccessibilityUtil.getAccessibilityServiceFragmentType(info)).isEqualTo(
                 AccessibilityUtil.AccessibilityServiceFragmentType.LEGACY);
-
     }
 
     @Test
@@ -102,7 +111,6 @@
 
         assertThat(AccessibilityUtil.getAccessibilityServiceFragmentType(info)).isEqualTo(
                 AccessibilityUtil.AccessibilityServiceFragmentType.INVISIBLE);
-
     }
 
     @Test
@@ -114,7 +122,6 @@
 
         assertThat(AccessibilityUtil.getAccessibilityServiceFragmentType(info)).isEqualTo(
                 AccessibilityUtil.AccessibilityServiceFragmentType.INTUITIVE);
-
     }
 
 
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
index 7b70dad..3777920 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
@@ -31,7 +31,6 @@
 import androidx.slice.SliceProvider;
 import androidx.slice.widget.SliceLiveData;
 
-import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
 import com.android.settings.slices.CustomSliceRegistry;
 import com.android.settings.wifi.slice.ContextualWifiSlice;
 
@@ -66,14 +65,6 @@
     }
 
     @Test
-    public void isSliceToggleable_cardWithoutToggle_returnFalse() {
-        final EmergencyInfoSlice emergencyInfoSlice = new EmergencyInfoSlice(mContext);
-        final Slice slice = emergencyInfoSlice.getSlice();
-
-        assertThat(mEligibleCardChecker.isSliceToggleable(slice)).isFalse();
-    }
-
-    @Test
     public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
         final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
         final Slice slice = wifiSlice.getSlice();
@@ -85,17 +76,6 @@
     }
 
     @Test
-    public void isCardEligibleToDisplay_notToggleSlice_hasInlineActionShouldBeFalse() {
-        final EmergencyInfoSlice emergencyInfoSlice = new EmergencyInfoSlice(mContext);
-        final Slice slice = emergencyInfoSlice.getSlice();
-        doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
-
-        mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
-
-        assertThat(mEligibleCardChecker.mCard.hasInlineAction()).isFalse();
-    }
-
-    @Test
     public void isCardEligibleToDisplay_customCard_returnTrue() {
         final ContextualCard customCard = new ContextualCard.Builder()
                 .setName("custom_card")
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
deleted file mode 100644
index 13f26e4..0000000
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.app.usage.NetworkStatsManager;
-import android.content.Context;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.SliceMetadata;
-import androidx.slice.SliceProvider;
-import androidx.slice.core.SliceAction;
-import androidx.slice.widget.SliceLiveData;
-import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
-import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowTelephonyManager;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowDataUsageUtils.class)
-public class DataUsageSliceTest {
-    private static final String DATA_USAGE_TITLE = "Data usage";
-    private static final String DATA_USAGE_SUMMARY = "test_summary";
-
-    @Mock
-    private NetworkStatsManager mNetworkStatsManager;
-
-    private Context mContext;
-    private DataUsageSlice mDataUsageSlice;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        mContext = spy(RuntimeEnvironment.application);
-        // Set-up specs for SliceMetadata.
-        SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
-        when(mContext.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager);
-
-        mDataUsageSlice = spy(new DataUsageSlice(mContext));
-
-        final TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
-        final ShadowTelephonyManager shadowTelephonyManager = Shadows.shadowOf(telephonyManager);
-        shadowTelephonyManager.setTelephonyManagerForSubscriptionId(
-                SubscriptionManager.INVALID_SUBSCRIPTION_ID, telephonyManager);
-    }
-
-    @Test
-    public void getSlice_hasSim_shouldBeCorrectSliceContent() {
-        ShadowDataUsageUtils.HAS_SIM = true;
-        doReturn(DATA_USAGE_TITLE).when(mDataUsageSlice).getDataUsageText(any());
-        doReturn(DATA_USAGE_SUMMARY).when(mDataUsageSlice).getCycleTime(any());
-
-        final Slice slice = mDataUsageSlice.getSlice();
-
-        final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
-        assertThat(metadata.getTitle()).isEqualTo(
-                mContext.getString(R.string.data_usage_summary_title));
-
-        final SliceAction primaryAction = metadata.getPrimaryAction();
-        final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
-                R.drawable.ic_settings_data_usage);
-        assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
-    }
-
-    @Test
-    public void getSlice_hasNoSim_shouldShowNoSimCard() {
-        ShadowDataUsageUtils.HAS_SIM = false;
-
-        final Slice slice = mDataUsageSlice.getSlice();
-
-        final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
-        assertThat(metadata.getTitle()).isEqualTo(
-                mContext.getString(R.string.data_usage_summary_title));
-
-        final List<SliceItem> sliceItems = slice.getItems();
-        SliceTester.assertAnySliceItemContainsTitle(sliceItems,
-                mContext.getString(R.string.no_sim_card));
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java
deleted file mode 100644
index ddc7218..0000000
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.homepage.contextualcards.deviceinfo;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-
-import android.content.Context;
-import android.telephony.SubscriptionInfo;
-
-import androidx.core.graphics.drawable.IconCompat;
-import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.SliceMetadata;
-import androidx.slice.SliceProvider;
-import androidx.slice.core.SliceAction;
-import androidx.slice.widget.SliceLiveData;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class DeviceInfoSliceTest {
-
-    @Mock
-    private SubscriptionInfo mSubscriptionInfo;
-
-    private Context mContext;
-    private DeviceInfoSlice mDeviceInfoSlice;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-
-        // Set-up specs for SliceMetadata.
-        SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
-
-        mDeviceInfoSlice = spy(new DeviceInfoSlice(mContext));
-    }
-
-    @Test
-    public void getSlice_hasSubscriptionInfo_shouldBeCorrectSliceContent() {
-        final String phoneNumber = "1111111111";
-        doReturn(mSubscriptionInfo).when(mDeviceInfoSlice).getFirstSubscriptionInfo();
-        doReturn(phoneNumber).when(mDeviceInfoSlice).getPhoneNumber();
-
-        final Slice slice = mDeviceInfoSlice.getSlice();
-
-        final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
-        assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
-
-        final SliceAction primaryAction = metadata.getPrimaryAction();
-        final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
-                R.drawable.ic_info_outline_24dp);
-        assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
-
-        final List<SliceItem> sliceItems = slice.getItems();
-        SliceTester.assertAnySliceItemContainsTitle(sliceItems, phoneNumber);
-    }
-
-    @Test
-    public void getSlice_hasNoSubscriptionInfo_shouldShowUnknown() {
-        final Slice slice = mDeviceInfoSlice.getSlice();
-
-        final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
-        assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
-
-        final List<SliceItem> sliceItems = slice.getItems();
-        SliceTester.assertAnySliceItemContainsTitle(sliceItems,
-                mContext.getString(R.string.device_info_default));
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index 9f4fffc..37036c4 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -36,7 +36,6 @@
 import androidx.slice.Slice;
 
 import com.android.settings.R;
-import com.android.settings.slices.CustomSliceRegistry;
 import com.android.settings.testutils.FakeFeatureFactory;
 
 import org.junit.Before;
@@ -54,8 +53,6 @@
 @RunWith(RobolectricTestRunner.class)
 public class PanelSlicesAdapterTest {
 
-    private static final Uri DATA_URI = CustomSliceRegistry.DATA_USAGE_SLICE_URI;
-
     private Context mContext;
     private PanelFragment mPanelFragment;
     private PanelFeatureProvider mPanelFeatureProvider;
@@ -97,18 +94,6 @@
     }
 
     @Test
-    public void onCreateViewHolder_returnsSliceRowViewHolder() {
-        addTestLiveData(DATA_URI);
-        final PanelSlicesAdapter adapter =
-                new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
-        final ViewGroup view = new FrameLayout(mContext);
-        final PanelSlicesAdapter.SliceRowViewHolder viewHolder =
-                adapter.onCreateViewHolder(view, 0);
-
-        assertThat(viewHolder.sliceView).isNotNull();
-    }
-
-    @Test
     public void sizeOfAdapter_shouldNotExceedMaxNum() {
         for (int i = 0; i < MAX_NUM_OF_SLICES + 2; i++) {
             addTestLiveData(Uri.parse("uri" + i));
@@ -127,22 +112,6 @@
     }
 
     @Test
-    public void nonMediaOutputIndicatorSlice_shouldAllowDividerAboveAndBelow() {
-        addTestLiveData(DATA_URI);
-        final PanelSlicesAdapter adapter =
-                new PanelSlicesAdapter(mPanelFragment, mData, 0 /* metrics category */);
-        final int position = 0;
-        final ViewGroup view = new FrameLayout(mContext);
-        final PanelSlicesAdapter.SliceRowViewHolder viewHolder =
-                adapter.onCreateViewHolder(view, 0 /* view type*/);
-
-        adapter.onBindViewHolder(viewHolder, position);
-
-        assertThat(viewHolder.isDividerAllowedAbove()).isTrue();
-        assertThat(viewHolder.isDividerAllowedBelow()).isTrue();
-    }
-
-    @Test
     public void mediaOutputIndicatorSlice_shouldNotAllowDividerAbove() {
         addTestLiveData(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
 
@@ -157,4 +126,4 @@
 
         assertThat(viewHolder.isDividerAllowedAbove()).isFalse();
     }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index aeec19a..eb4f326 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -18,6 +18,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doNothing;
@@ -278,4 +279,11 @@
         verify(menu).add(anyInt(), eq(WifiSettings2.MENU_ID_FORGET), anyInt(), anyInt());
         verify(menu).add(anyInt(), eq(WifiSettings2.MENU_ID_DISCONNECT), anyInt(), anyInt());
     }
+
+    @Test
+    public void onWifiEntriesChanged_shouldChangeNextButtonState() {
+        mWifiSettings2.onWifiEntriesChanged();
+
+        verify(mWifiSettings2).changeNextButtonState(anyBoolean());
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
index 820a78b..36279cb 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
@@ -35,7 +35,6 @@
 import com.android.settings.R;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -49,6 +48,13 @@
     private static final String ALL_BANDS = "5.0 GHz Band preferred";
     private static final String TWO_GHZ_STRING = "2.4 GHz Band";
     private static final String FIVE_GHZ_STRING = "5.0 GHz Band";
+    private static final String VAL_2GHZ_STR  = "1";
+    private static final String VAL_5GHZ_STR = "2";
+    private static final String VAL_2_5_GHZ_STR = "3";
+    private static final int VAL_2GHZ_INT = 1;
+    private static final int VAL_5GHZ_INT = 2;
+    private static final int VAL_2_5_GHZ_INT = 3;
+
     private Context mContext;
     @Mock
     private ConnectivityManager mConnectivityManager;
@@ -81,14 +87,16 @@
     }
 
     @Test
-    @Ignore
     public void display_5GhzSupported_shouldDisplayFullList() {
         when(mWifiManager.getCountryCode()).thenReturn("US");
         when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
         when(mWifiManager.isDualModeSupported()).thenReturn(true);
 
+        // Create a new instance to pick the proper value of isDualModeSupported()
+        mController = new WifiTetherApBandPreferenceController(mContext, mListener);
+
         mController.displayPreference(mScreen);
-        mController.onPreferenceChange(mPreference, "-1");
+        mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
 
         assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
     }
@@ -118,77 +126,77 @@
     }
 
     @Test
-    @Ignore
     public void changePreference_noDualModeWith5G_shouldUpdateValue() {
         when(mWifiManager.getCountryCode()).thenReturn("US");
         when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
 
         mController.displayPreference(mScreen);
 
-        // -1 is SoftApConfiguration.BAND_ANY, for 'Auto' option. This should be prevented from
-        // being set since it is invalid for this configuration
-        mController.onPreferenceChange(mPreference, "-1");
-        assertThat(mController.getBandIndex()).isEqualTo(1);
+        // 'Auto' option should be prevented from being set since
+        // it is invalid for this configuration
+        mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
         assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
         verify(mListener, times(1)).onTetherConfigUpdated(mController);
 
         // set to 5 Ghz
-        mController.onPreferenceChange(mPreference, "1");
-        assertThat(mController.getBandIndex()).isEqualTo(1);
+        mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
         assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
         verify(mListener, times(2)).onTetherConfigUpdated(mController);
 
         // set to 2 Ghz
-        mController.onPreferenceChange(mPreference, "0");
-        assertThat(mController.getBandIndex()).isEqualTo(0);
+        mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
         assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
         verify(mListener, times(3)).onTetherConfigUpdated(mController);
     }
 
     @Test
-    @Ignore
     public void changePreference_dualModeWith5G_shouldUpdateValue() {
         when(mWifiManager.getCountryCode()).thenReturn("US");
         when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
         when(mWifiManager.isDualModeSupported()).thenReturn(true);
 
+        // Create a new instance to pick the proper value of isDualModeSupported()
+        mController = new WifiTetherApBandPreferenceController(mContext, mListener);
+
         mController.displayPreference(mScreen);
 
-        // -1 is SoftApConfiguration.BAND_ANY, for 'Auto' option.
-        mController.onPreferenceChange(mPreference, "-1");
-        assertThat(mController.getBandIndex()).isEqualTo(-1);
+        // 'Auto' option
+        mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_2_5_GHZ_INT);
         assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
         verify(mListener, times(1)).onTetherConfigUpdated(mController);
 
         // should revert to the default for 5 Ghz only since this is not supported with this config
-        mController.onPreferenceChange(mPreference, "1");
-        assertThat(mController.getBandIndex()).isEqualTo(-1);
+        mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_2_5_GHZ_INT);
         assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
         verify(mListener, times(2)).onTetherConfigUpdated(mController);
 
         // set to 2 Ghz
-        mController.onPreferenceChange(mPreference, "0");
-        assertThat(mController.getBandIndex()).isEqualTo(0);
+        mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
         assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
         verify(mListener, times(3)).onTetherConfigUpdated(mController);
     }
 
     @Test
-    @Ignore
     public void updateDisplay_shouldUpdateValue() {
         when(mWifiManager.getCountryCode()).thenReturn("US");
         when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
 
-        // Set controller band index to 1 and verify is set.
+        // Set controller band index to 5GHz and verify is set.
         mController.displayPreference(mScreen);
-        mController.onPreferenceChange(mPreference, "1");
-        assertThat(mController.getBandIndex()).isEqualTo(1);
+        mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
 
         // Disable 5Ghz band
         when(mWifiManager.is5GHzBandSupported()).thenReturn(false);
 
         // Call updateDisplay and verify it's changed.
         mController.updateDisplay();
-        assertThat(mController.getBandIndex()).isEqualTo(0);
+        assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
     }
 }