Merge "Accessibility shortcut secondary action - auto hide divider in shortcutPreference"
diff --git a/res/layout/edit_user_info_dialog_content.xml b/res/layout/edit_user_info_dialog_content.xml
index 30ae1d8..62c711b 100644
--- a/res/layout/edit_user_info_dialog_content.xml
+++ b/res/layout/edit_user_info_dialog_content.xml
@@ -37,6 +37,7 @@
         android:layout_gravity="bottom"
         android:layout_weight="1"
         android:layout_marginStart="6dp"
+        android:minHeight="@dimen/min_tap_target_size"
         android:ellipsize="end"
         android:singleLine="true"
         android:textAppearance="?android:attr/textAppearanceMedium"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index edc96f9..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] -->
@@ -1776,9 +1775,9 @@
     <!-- Debugging developer settings: Enable ART verifier for Debuggable Apps [CHAR LIMIT=NONE] -->
     <string name="art_verifier_for_debuggable_summary">Allow ART to verify bytecode for debuggable apps</string>
 
-    <!-- Debugging developer settings: show refresh rate? [CHAR LIMIT=25] -->
+    <!-- Debugging developer settings: show refresh rate? [CHAR LIMIT=36] -->
     <string name="show_refresh_rate">Show refresh rate</string>
-    <!-- Debugging developer settings: show refresh rate summary [CHAR LIMIT=50] -->
+    <!-- Debugging developer settings: show refresh rate summary [CHAR LIMIT=58] -->
     <string name="show_refresh_rate_summary">Show the current display refresh rate</string>
 
     <!-- NFC settings -->
@@ -1956,8 +1955,6 @@
     <string name="wifi_show_advanced">Advanced options</string>
     <!-- Message for talkback to say when focus on Advanced Options[CHAR LIMIT=NONE] -->
     <string name="wifi_advanced_toggle_description">Drop down list Advanced Options</string>
-    <!-- Extended message for talkback to say when Advanced Options is expanded. (e.g., Double-tap to collapse) [CHAR LIMIT=NONE] -->
-    <string name="wifi_advanced_toggle_description_expanded">collapse</string>
     <!-- Extended message for talkback to say when Advanced Options is collapsed. (e.g., Double-tap to expand) [CHAR LIMIT=NONE] -->
     <string name="wifi_advanced_toggle_description_collapsed">expand</string>
     <!-- Label for the SSID of the network -->
@@ -1978,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 -->
@@ -7319,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]-->
@@ -11215,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 64ad17d..f1d36f2 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -22,9 +22,7 @@
 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;
 
@@ -34,7 +32,6 @@
 import com.android.settingslib.WirelessUtils;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -61,12 +58,11 @@
 
     private TelephonyManager mTelephonyManager;
     private ProxySubscriptionManager mProxySubscriptionMgr;
-    private List<ServiceStateListener> mServiceStateListeners;
+    private 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;
@@ -75,6 +71,16 @@
 
         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 +94,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 ssListener : mServiceStateListeners) {
-            ssListener.start();
-        }
+        mTelephonyManager.listen(mPhoneStateListener,
+                PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED);
     }
 
     public void pause() {
-        if (mServiceStateListeners == null) {
-            return;
-        }
-        for (ServiceStateListener ssListener : mServiceStateListeners) {
-            ssListener.stop();
-        }
-        mServiceStateListeners = null;
+        mTelephonyManager.listen(mPhoneStateListener,
+                PhoneStateListener.LISTEN_NONE);
     }
 
     private void setAirplaneModeOn(boolean enabling) {
@@ -200,51 +184,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 int mSubId;
-        private TelephonyManager mTelephonyManager;
-        private 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/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/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index ca51f18..5795e65 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -56,6 +56,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;
@@ -309,6 +314,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/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 292b203..bee93fb 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -73,6 +73,8 @@
     @VisibleForTesting
     Handler mHandler = new Handler(Looper.getMainLooper());
     @VisibleForTesting
+    boolean mIsRegisterCallback = false;
+    @VisibleForTesting
     final BluetoothAdapter.OnMetadataChangedListener mMetadataListener =
             new BluetoothAdapter.OnMetadataChangedListener() {
                 @Override
@@ -96,6 +98,7 @@
         final boolean untetheredHeadset = mCachedDevice != null
                 && BluetoothUtils.getBooleanMetaData(
                 mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
+        Log.d(TAG, "getAvailabilityStatus() is untethered : " + untetheredHeadset);
         return advancedEnabled && untetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
@@ -113,6 +116,7 @@
         if (!isAvailable()) {
             return;
         }
+        mIsRegisterCallback = true;
         mCachedDevice.registerCallback(this);
         mBluetoothAdapter.addOnMetadataChangedListener(mCachedDevice.getDevice(),
                 mContext.getMainExecutor(), mMetadataListener);
@@ -120,19 +124,17 @@
 
     @Override
     public void onStop() {
-        if (!isAvailable()) {
+        if (!mIsRegisterCallback) {
             return;
         }
         mCachedDevice.unregisterCallback(this);
         mBluetoothAdapter.removeOnMetadataChangedListener(mCachedDevice.getDevice(),
                 mMetadataListener);
+        mIsRegisterCallback = false;
     }
 
     @Override
     public void onDestroy() {
-        if (!isAvailable()) {
-            return;
-        }
         // Destroy icon bitmap associated with this header
         for (Bitmap bitmap : mIconCache.values()) {
             if (bitmap != null) {
diff --git a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
index 8226a6c..60cd636 100644
--- a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
+++ b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
@@ -25,6 +25,7 @@
 import android.content.SharedPreferences;
 import android.icu.util.TimeZone;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.util.Log;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -123,9 +124,9 @@
         super.onCreate(icicle);
         // Hide all interactive preferences
         setPreferenceCategoryVisible((PreferenceCategory) findPreference(
-            PREF_KEY_REGION_CATEGORY), false);
+                PREF_KEY_REGION_CATEGORY), false);
         setPreferenceCategoryVisible((PreferenceCategory) findPreference(
-            PREF_KEY_FIXED_OFFSET_CATEGORY), false);
+                PREF_KEY_FIXED_OFFSET_CATEGORY), false);
 
         // Start loading TimeZoneData
         getLoaderManager().initLoader(0, null, new TimeZoneDataLoader.LoaderCreator(
@@ -237,7 +238,7 @@
         String tzId = data.getStringExtra(RegionZonePicker.EXTRA_RESULT_TIME_ZONE_ID);
         // Ignore the result if user didn't change the region or time zone.
         if (Objects.equals(regionId, use(RegionPreferenceController.class).getRegionId())
-            && Objects.equals(tzId, mSelectedTimeZoneId)) {
+                && Objects.equals(tzId, mSelectedTimeZoneId)) {
             return;
         }
 
@@ -327,9 +328,9 @@
     private void setSelectByRegion(boolean selectByRegion) {
         mSelectByRegion = selectByRegion;
         setPreferenceCategoryVisible((PreferenceCategory) findPreference(
-            PREF_KEY_REGION_CATEGORY), selectByRegion);
+                PREF_KEY_REGION_CATEGORY), selectByRegion);
         setPreferenceCategoryVisible((PreferenceCategory) findPreference(
-            PREF_KEY_FIXED_OFFSET_CATEGORY), !selectByRegion);
+                PREF_KEY_FIXED_OFFSET_CATEGORY), !selectByRegion);
         final String localeRegionId = getLocaleRegionId();
         final Set<String> allCountryIsoCodes = mTimeZoneData.getRegionIds();
 
@@ -353,6 +354,7 @@
      * Find the a region associated with the specified time zone, based on the time zone data.
      * If there are multiple regions associated with the given time zone, the priority will be given
      * to the region the user last picked and the country in user's locale.
+     *
      * @return null if no region associated with the time zone
      */
     private String findRegionIdForTzId(String tzId) {
@@ -378,7 +380,7 @@
     }
 
     private void setPreferenceCategoryVisible(PreferenceCategory category,
-        boolean isVisible) {
+            boolean isVisible) {
         // Hiding category doesn't hide all the children preference. Set visibility of its children.
         // Do not care grandchildren as time_zone_pref.xml has only 2 levels.
         category.setVisible(isVisible);
@@ -392,5 +394,13 @@
     }
 
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider(R.xml.time_zone_prefs);
+            new BaseSearchIndexProvider(R.xml.time_zone_prefs) {
+                @Override
+                protected boolean isPageSearchEnabled(Context context) {
+                    // We can't enter this page if the auto time zone is enabled.
+                    final int autoTimeZone = Settings.Global.getInt(context.getContentResolver(),
+                            Settings.Global.AUTO_TIME_ZONE, 1);
+                    return autoTimeZone == 1 ? false : true;
+                }
+            };
 }
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/deviceinfo/MigrateEstimateTask.java b/src/com/android/settings/deviceinfo/MigrateEstimateTask.java
index c41ebe0..a5790b3 100644
--- a/src/com/android/settings/deviceinfo/MigrateEstimateTask.java
+++ b/src/com/android/settings/deviceinfo/MigrateEstimateTask.java
@@ -29,7 +29,7 @@
 import android.os.UserManager;
 import android.os.storage.StorageManager;
 import android.os.storage.VolumeInfo;
-import android.telecom.Log;
+import android.util.Log;
 import android.text.format.DateUtils;
 import android.text.format.Formatter;
 
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/network/ProxySubscriptionManager.java b/src/com/android/settings/network/ProxySubscriptionManager.java
index b10c727..0306b55 100644
--- a/src/com/android/settings/network/ProxySubscriptionManager.java
+++ b/src/com/android/settings/network/ProxySubscriptionManager.java
@@ -77,7 +77,7 @@
         mActiveSubscriptionsListeners =
                 new ArrayList<OnActiveSubscriptionChangedListener>();
 
-        mSubsciptionsMonitor = new ActiveSubsciptionsListener(looper, context) {
+        mSubscriptionMonitor = new ActiveSubsciptionsListener(looper, context) {
             public void onChanged() {
                 notifyAllListeners();
             }
@@ -85,16 +85,16 @@
         mAirplaneModeMonitor = new GlobalSettingsChangeListener(looper,
                 context, Settings.Global.AIRPLANE_MODE_ON) {
             public void onChanged(String field) {
-                mSubsciptionsMonitor.clearCache();
+                mSubscriptionMonitor.clearCache();
                 notifyAllListeners();
             }
         };
 
-        mSubsciptionsMonitor.start();
+        mSubscriptionMonitor.start();
     }
 
     private Lifecycle mLifecycle;
-    private ActiveSubsciptionsListener mSubsciptionsMonitor;
+    private ActiveSubsciptionsListener mSubscriptionMonitor;
     private GlobalSettingsChangeListener mAirplaneModeMonitor;
 
     private List<OnActiveSubscriptionChangedListener> mActiveSubscriptionsListeners;
@@ -130,17 +130,17 @@
 
     @OnLifecycleEvent(ON_START)
     void onStart() {
-        mSubsciptionsMonitor.start();
+        mSubscriptionMonitor.start();
     }
 
     @OnLifecycleEvent(ON_STOP)
     void onStop() {
-        mSubsciptionsMonitor.stop();
+        mSubscriptionMonitor.stop();
     }
 
     @OnLifecycleEvent(ON_DESTROY)
     void onDestroy() {
-        mSubsciptionsMonitor.close();
+        mSubscriptionMonitor.close();
         mAirplaneModeMonitor.close();
 
         if (mLifecycle != null) {
@@ -157,7 +157,7 @@
      * @return a SubscriptionManager
      */
     public SubscriptionManager get() {
-        return mSubsciptionsMonitor.getSubscriptionManager();
+        return mSubscriptionMonitor.getSubscriptionManager();
     }
 
     /**
@@ -166,7 +166,7 @@
      * @return max. number of active subscription info(s)
      */
     public int getActiveSubscriptionInfoCountMax() {
-        return mSubsciptionsMonitor.getActiveSubscriptionInfoCountMax();
+        return mSubscriptionMonitor.getActiveSubscriptionInfoCountMax();
     }
 
     /**
@@ -175,7 +175,7 @@
      * @return A list of active subscription info
      */
     public List<SubscriptionInfo> getActiveSubscriptionsInfo() {
-        return mSubsciptionsMonitor.getActiveSubscriptionsInfo();
+        return mSubscriptionMonitor.getActiveSubscriptionsInfo();
     }
 
     /**
@@ -185,7 +185,7 @@
      * @return A subscription info which is active list
      */
     public SubscriptionInfo getActiveSubscriptionInfo(int subId) {
-        return mSubsciptionsMonitor.getActiveSubscriptionInfo(subId);
+        return mSubscriptionMonitor.getActiveSubscriptionInfo(subId);
     }
 
     /**
@@ -194,7 +194,7 @@
      * @return A list of accessible subscription info
      */
     public List<SubscriptionInfo> getAccessibleSubscriptionsInfo() {
-        return mSubsciptionsMonitor.getAccessibleSubscriptionsInfo();
+        return mSubscriptionMonitor.getAccessibleSubscriptionsInfo();
     }
 
     /**
@@ -204,14 +204,14 @@
      * @return A subscription info which is accessible list
      */
     public SubscriptionInfo getAccessibleSubscriptionInfo(int subId) {
-        return mSubsciptionsMonitor.getAccessibleSubscriptionInfo(subId);
+        return mSubscriptionMonitor.getAccessibleSubscriptionInfo(subId);
     }
 
     /**
      * Clear data cached within proxy
      */
     public void clearCache() {
-        mSubsciptionsMonitor.clearCache();
+        mSubscriptionMonitor.clearCache();
     }
 
     /**
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/ConfigureWifiEntryFragment.java b/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java
new file mode 100644
index 0000000..a28f990
--- /dev/null
+++ b/src/com/android/settings/wifi/ConfigureWifiEntryFragment.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkScoreManager;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Process;
+import android.os.SimpleClock;
+import android.os.SystemClock;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.wifi.details2.WifiNetworkDetailsFragment2;
+import com.android.wifitrackerlib.NetworkDetailsTracker;
+import com.android.wifitrackerlib.WifiEntry;
+
+import java.time.Clock;
+import java.time.ZoneOffset;
+
+/**
+ * Detail page for configuring Wi-Fi network.
+ *
+ * The WifiEntry should be saved to the argument when launching this class in order to properly
+ * render this page.
+ */
+public class ConfigureWifiEntryFragment extends InstrumentedFragment implements WifiConfigUiBase2 {
+
+    private static final String TAG = "ConfigureWifiEntryFragment";
+
+    public static final String NETWORK_CONFIG_KEY = "network_config_key";
+
+    private static final int SUBMIT_BUTTON_ID = android.R.id.button1;
+    private static final int CANCEL_BUTTON_ID = android.R.id.button2;
+
+    // Max age of tracked WifiEntries
+    private static final long MAX_SCAN_AGE_MILLIS = 15_000;
+    // Interval between initiating SavedNetworkTracker scans
+    private static final long SCAN_INTERVAL_MILLIS = 10_000;
+
+    private WifiConfigController2 mUiController;
+    private Button mSubmitBtn;
+    private Button mCancelBtn;
+    private WifiEntry mWifiEntry;
+    private NetworkDetailsTracker mNetworkDetailsTracker;
+    private HandlerThread mWorkerThread;
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+
+        setupNetworkDetailsTracker();
+        mWifiEntry = mNetworkDetailsTracker.getWifiEntry();
+    }
+
+    @Override
+    public void onDestroy() {
+        if (mWorkerThread != null) {
+            mWorkerThread.quit();
+        }
+
+        super.onDestroy();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.SETTINGS_WIFI_CONFIGURE_NETWORK;
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        final View rootView = inflater.inflate(R.layout.wifi_add_network_view,
+                container, false /* attachToRoot */);
+
+        final Button neutral = rootView.findViewById(android.R.id.button3);
+        if (neutral != null) {
+            neutral.setVisibility(View.GONE);
+        }
+
+        mSubmitBtn = rootView.findViewById(SUBMIT_BUTTON_ID);
+        mCancelBtn = rootView.findViewById(CANCEL_BUTTON_ID);
+        mSubmitBtn.setOnClickListener(view -> handleSubmitAction());
+        mCancelBtn.setOnClickListener(view -> handleCancelAction());
+
+        mUiController = new WifiConfigController2(this, rootView, mWifiEntry,
+                getMode(), false /* requestFocus */);
+
+        /**
+         * For this add WifiEntry UI, need to remove the Home button, so set related feature as
+         * false.
+         */
+        final ActionBar actionBar = getActivity().getActionBar();
+        if (actionBar != null) {
+            actionBar.setDisplayHomeAsUpEnabled(false);
+            actionBar.setHomeButtonEnabled(false);
+            actionBar.setDisplayShowHomeEnabled(false);
+        }
+
+        return rootView;
+    }
+
+    @Override
+    public void onViewStateRestored(Bundle savedInstanceState) {
+        super.onViewStateRestored(savedInstanceState);
+        mUiController.updatePassword();
+    }
+
+    @Override
+    public int getMode() {
+        return WifiConfigUiBase2.MODE_CONNECT;
+    }
+
+    @Override
+    public WifiConfigController2 getController() {
+        return mUiController;
+    }
+
+    @Override
+    public void dispatchSubmit() {
+        // Do nothing
+    }
+
+    @Override
+    public void setTitle(int id) {
+        getActivity().setTitle(id);
+    }
+
+    @Override
+    public void setTitle(CharSequence title) {
+        getActivity().setTitle(title);
+    }
+
+    @Override
+    public void setSubmitButton(CharSequence text) {
+        mSubmitBtn.setText(text);
+    }
+
+    @Override
+    public void setCancelButton(CharSequence text) {
+        mCancelBtn.setText(text);
+    }
+
+    @Override
+    public void setForgetButton(CharSequence text) {
+        // AddNetwork doesn't need forget button.
+    }
+
+    @Override
+    public Button getSubmitButton() {
+        return mSubmitBtn;
+    }
+
+    @Override
+    public Button getCancelButton() {
+        return mCancelBtn;
+    }
+
+    @Override
+    public Button getForgetButton() {
+        // AddNetwork doesn't need forget button.
+        return null;
+    }
+
+    @VisibleForTesting
+    void handleSubmitAction() {
+        final Intent intent = new Intent();
+        final Activity activity = getActivity();
+        intent.putExtra(NETWORK_CONFIG_KEY, mUiController.getConfig());
+        activity.setResult(Activity.RESULT_OK, intent);
+        activity.finish();
+    }
+
+    @VisibleForTesting
+    void handleCancelAction() {
+        getActivity().finish();
+    }
+
+    private void setupNetworkDetailsTracker() {
+        if (mNetworkDetailsTracker != null) {
+            return;
+        }
+
+        final Context context = getContext();
+        mWorkerThread = new HandlerThread(TAG
+                + "{" + Integer.toHexString(System.identityHashCode(this)) + "}",
+                Process.THREAD_PRIORITY_BACKGROUND);
+        mWorkerThread.start();
+        final Clock elapsedRealtimeClock = new SimpleClock(ZoneOffset.UTC) {
+            @Override
+            public long millis() {
+                return SystemClock.elapsedRealtime();
+            }
+        };
+
+        mNetworkDetailsTracker = NetworkDetailsTracker.createNetworkDetailsTracker(
+                getSettingsLifecycle(),
+                context,
+                context.getSystemService(WifiManager.class),
+                context.getSystemService(ConnectivityManager.class),
+                context.getSystemService(NetworkScoreManager.class),
+                new Handler(Looper.getMainLooper()),
+                mWorkerThread.getThreadHandler(),
+                elapsedRealtimeClock,
+                MAX_SCAN_AGE_MILLIS,
+                SCAN_INTERVAL_MILLIS,
+                getArguments().getString(WifiNetworkDetailsFragment2.KEY_CHOSEN_WIFIENTRY_KEY));
+    }
+}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 05fcf5e..e228a14 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -347,9 +347,13 @@
                 showProxyFields();
                 final CheckBox advancedTogglebox =
                         (CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox);
-                advancedTogglebox.setOnCheckedChangeListener(this);
-                advancedTogglebox.setChecked(showAdvancedFields);
-                setAdvancedOptionAccessibilityString(showAdvancedFields);
+                if (!showAdvancedFields) {
+                    // Need to show Advanced Option button.
+                    mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
+                    advancedTogglebox.setOnCheckedChangeListener(this);
+                    advancedTogglebox.setChecked(showAdvancedFields);
+                    setAdvancedOptionAccessibilityString();
+                }
                 mView.findViewById(R.id.wifi_advanced_fields)
                         .setVisibility(showAdvancedFields ? View.VISIBLE : View.GONE);
             }
@@ -1553,17 +1557,10 @@
                 ((EditText) mPasswordView).setSelection(pos);
             }
         } else if (view.getId() == R.id.wifi_advanced_togglebox) {
-            final int toggleVisibility;
-            final int stringID;
-            if (isChecked) {
-                toggleVisibility = View.VISIBLE;
-                // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
-                hideSoftKeyboard(mView.getWindowToken());
-            } else {
-                toggleVisibility = View.GONE;
-            }
-            mView.findViewById(R.id.wifi_advanced_fields).setVisibility(toggleVisibility);
-            setAdvancedOptionAccessibilityString(isChecked);
+            // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
+            hideSoftKeyboard(mView.getWindowToken());
+            view.setVisibility(View.GONE);
+            mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
         }
     }
 
@@ -1673,7 +1670,7 @@
         ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
                 .setOnCheckedChangeListener(this);
         // Set correct accessibility strings.
-        setAdvancedOptionAccessibilityString(false /* showAdvancedFields */);
+        setAdvancedOptionAccessibilityString();
     }
 
     /**
@@ -1765,7 +1762,7 @@
         inputMethodManager.hideSoftInputFromWindow(windowToken, 0 /* flags */);
     }
 
-    private void setAdvancedOptionAccessibilityString(boolean showAdvancedFields) {
+    private void setAdvancedOptionAccessibilityString() {
         final CheckBox advancedToggleBox = mView.findViewById(R.id.wifi_advanced_togglebox);
         advancedToggleBox.setAccessibilityDelegate(new AccessibilityDelegate() {
             @Override
@@ -1776,12 +1773,10 @@
                 info.setCheckable(false /* checkable */);
                 // To let TalkBack don't pronounce CheckBox.
                 info.setClassName(null /* className */);
-                final CharSequence accessibilityDoubleTapExtend = mContext.getString(
-                        showAdvancedFields ? R.string.wifi_advanced_toggle_description_expanded
-                                : R.string.wifi_advanced_toggle_description_collapsed);
                 // Customize TalkBack's pronunciation which been appended to "Double-tap to".
                 final AccessibilityAction customClick = new AccessibilityAction(
-                        AccessibilityNodeInfo.ACTION_CLICK, accessibilityDoubleTapExtend);
+                        AccessibilityNodeInfo.ACTION_CLICK,
+                        mContext.getString(R.string.wifi_advanced_toggle_description_collapsed));
                 info.addAction(customClick);
             }
         });
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 3c52cc3..c6b4702 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -22,7 +22,6 @@
 import android.net.IpConfiguration.IpAssignment;
 import android.net.IpConfiguration.ProxySettings;
 import android.net.LinkAddress;
-import android.net.NetworkInfo.DetailedState;
 import android.net.NetworkUtils;
 import android.net.ProxyInfo;
 import android.net.StaticIpConfiguration;
@@ -33,7 +32,6 @@
 import android.net.wifi.WifiEnterpriseConfig;
 import android.net.wifi.WifiEnterpriseConfig.Eap;
 import android.net.wifi.WifiEnterpriseConfig.Phase2;
-import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.IBinder;
 import android.os.UserManager;
@@ -76,6 +74,8 @@
 import com.android.settingslib.Utils;
 import com.android.settingslib.utils.ThreadUtils;
 import com.android.settingslib.wifi.AccessPoint;
+import com.android.wifitrackerlib.WifiEntry;
+import com.android.wifitrackerlib.WifiEntry.ConnectedInfo;
 
 import java.net.Inet4Address;
 import java.net.InetAddress;
@@ -96,7 +96,7 @@
 
     private final WifiConfigUiBase2 mConfigUi;
     private final View mView;
-    private final AccessPoint mAccessPoint;
+    private final WifiEntry mWifiEntry;
 
     /* This value comes from "wifi_ip_settings" resource array */
     private static final int DHCP = 0;
@@ -138,9 +138,9 @@
     /* Phase2 methods supported by TTLS are limited */
     private ArrayAdapter<CharSequence> mPhase2TtlsAdapter;
 
-    // e.g. AccessPoint.SECURITY_NONE
+    // e.g. WifiEntry.SECURITY_NONE
     @VisibleForTesting
-    int mAccessPointSecurity;
+    int mWifiEntrySecurity;
     private TextView mPasswordView;
     private TextView mSaePasswordIdView;
     private ImageButton mSsidScanButton;
@@ -199,41 +199,41 @@
 
     private final WifiManager mWifiManager;
 
-    public WifiConfigController2(WifiConfigUiBase2 parent, View view, AccessPoint accessPoint,
+    public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
             int mode) {
-        this (parent, view, accessPoint, mode, true /* requestFocus */);
+        this (parent, view, wifiEntry, mode, true /* requestFocus */);
     }
 
-    public WifiConfigController2(WifiConfigUiBase2 parent, View view, AccessPoint accessPoint,
+    public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
             int mode, boolean requestFocus) {
         mConfigUi = parent;
 
         mView = view;
-        mAccessPoint = accessPoint;
+        mWifiEntry = wifiEntry;
         mContext = mConfigUi.getContext();
         mRequestFocus = requestFocus;
 
         // Init Wi-Fi manager
         mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
-        initWifiConfigController2(accessPoint, mode);
+        initWifiConfigController2(wifiEntry, mode);
     }
 
     @VisibleForTesting
-    public WifiConfigController2(WifiConfigUiBase2 parent, View view, AccessPoint accessPoint,
+    public WifiConfigController2(WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry,
             int mode, WifiManager wifiManager) {
         mConfigUi = parent;
 
         mView = view;
-        mAccessPoint = accessPoint;
+        mWifiEntry = wifiEntry;
         mContext = mConfigUi.getContext();
         mWifiManager = wifiManager;
-        initWifiConfigController2(accessPoint, mode);
+        initWifiConfigController2(wifiEntry, mode);
     }
 
-    private void initWifiConfigController2(AccessPoint accessPoint, int mode) {
+    private void initWifiConfigController2(WifiEntry wifiEntry, int mode) {
 
-        mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
-                accessPoint.getSecurity();
+        mWifiEntrySecurity = (wifiEntry == null) ? WifiEntry.SECURITY_NONE :
+                wifiEntry.getSecurity();
         mMode = mode;
 
         final Resources res = mContext.getResources();
@@ -277,19 +277,19 @@
                 mHiddenSettingsSpinner.getSelectedItemPosition() == NOT_HIDDEN_NETWORK
                         ? View.GONE
                         : View.VISIBLE);
-        mSecurityInPosition = new Integer[AccessPoint.SECURITY_MAX_VAL];
+        mSecurityInPosition = new Integer[WifiEntry.SECURITY_MAX_VAL];
 
-        if (mAccessPoint == null) { // new network
+        if (mWifiEntry == null) { // new network
             configureSecuritySpinner();
             mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
         } else {
-            mConfigUi.setTitle(mAccessPoint.getTitle());
+            mConfigUi.setTitle(mWifiEntry.getTitle());
 
             ViewGroup group = (ViewGroup) mView.findViewById(R.id.info);
 
             boolean showAdvancedFields = false;
-            if (mAccessPoint.isSaved()) {
-                WifiConfiguration config = mAccessPoint.getConfig();
+            if (mWifiEntry.isSaved()) {
+                WifiConfiguration config = mWifiEntry.getWifiConfiguration();
                 mMeteredSettingsSpinner.setSelection(config.meteredOverride);
                 mHiddenSettingsSpinner.setSelection(config.hiddenSSID
                         ? HIDDEN_NETWORK
@@ -339,17 +339,22 @@
                 }
             }
 
-            if ((!mAccessPoint.isSaved() && !mAccessPoint.isActive()
-                    && !mAccessPoint.isPasspointConfig())
+            if ((!mWifiEntry.isSaved()
+                    && mWifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED
+                    && !WifiEntryShell.isPasspoint(mWifiEntry))
                     || mMode != WifiConfigUiBase2.MODE_VIEW) {
                 showSecurityFields(/* refreshEapMethods */ true, /* refreshCertificates */ true);
                 showIpConfigFields();
                 showProxyFields();
                 final CheckBox advancedTogglebox =
                         (CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox);
-                advancedTogglebox.setOnCheckedChangeListener(this);
-                advancedTogglebox.setChecked(showAdvancedFields);
-                setAdvancedOptionAccessibilityString(showAdvancedFields);
+                if (!showAdvancedFields) {
+                    // Need to show Advanced Option button.
+                    mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
+                    advancedTogglebox.setOnCheckedChangeListener(this);
+                    advancedTogglebox.setChecked(showAdvancedFields);
+                    setAdvancedOptionAccessibilityString();
+                }
                 mView.findViewById(R.id.wifi_advanced_fields)
                         .setVisibility(showAdvancedFields ? View.VISIBLE : View.GONE);
             }
@@ -359,55 +364,44 @@
             } else if (mMode == WifiConfigUiBase2.MODE_CONNECT) {
                 mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
             } else {
-                final DetailedState state = mAccessPoint.getDetailedState();
                 final String signalLevel = getSignalString();
 
-                if ((state == null || state == DetailedState.DISCONNECTED) && signalLevel != null) {
+                if (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED
+                            && signalLevel != null) {
                     mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
                 } else {
-                    if (state != null) {
-                        boolean isEphemeral = mAccessPoint.isEphemeral();
-                        WifiConfiguration config = mAccessPoint.getConfig();
-                        String providerFriendlyName = null;
-                        if (config != null && config.isPasspoint()) {
-                            providerFriendlyName = config.providerFriendlyName;
-                        }
-                        String suggestionOrSpecifierPackageName = null;
-                        if (config != null
-                                && (config.fromWifiNetworkSpecifier
-                                || config.fromWifiNetworkSuggestion)) {
-                            suggestionOrSpecifierPackageName = config.creatorName;
-                        }
-                        String summary = AccessPoint.getSummary(
-                                mConfigUi.getContext(), /* ssid */ null, state, isEphemeral,
-                                suggestionOrSpecifierPackageName);
-                        addRow(group, R.string.wifi_status, summary);
-                    }
+                    // TODO(b/143326832): Add fine-grained state information.
+                    //WifiConfiguration config = mWifiEntry.getWifiConfiguration();
+                    //String suggestionOrSpecifierPackageName = null;
+                    //if (config != null
+                    //        && (config.fromWifiNetworkSpecifier
+                    //        || config.fromWifiNetworkSuggestion)) {
+                    //    suggestionOrSpecifierPackageName = config.creatorName;
+                    //}
+                    //String summary = AccessPoint.getSummary(
+                    //        mConfigUi.getContext(), /* ssid */ null, state, isEphemeral,
+                    //        suggestionOrSpecifierPackageName);
+                    //addRow(group, R.string.wifi_status, summary);
 
                     if (signalLevel != null) {
                         addRow(group, R.string.wifi_signal, signalLevel);
                     }
 
-                    WifiInfo info = mAccessPoint.getInfo();
-                    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()));
+                    final ConnectedInfo info = mWifiEntry.getConnectedInfo();
+                    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.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.getFrequency() != -1) {
-                        final int frequency = info.getFrequency();
+                    if (info != null && info.frequencyMhz != WifiEntry.FREQUENCY_UNKNOWN) {
+                        final int frequency = info.frequencyMhz;
                         String band = null;
 
-                        if (frequency >= AccessPoint.LOWER_FREQ_24GHZ
-                                && frequency < AccessPoint.HIGHER_FREQ_24GHZ) {
+                        if (frequency >= WifiEntryShell.LOWER_FREQ_24GHZ
+                                && frequency < WifiEntryShell.HIGHER_FREQ_24GHZ) {
                             band = res.getString(R.string.wifi_band_24ghz);
-                        } else if (frequency >= AccessPoint.LOWER_FREQ_5GHZ
-                                && frequency < AccessPoint.HIGHER_FREQ_5GHZ) {
+                        } else if (frequency >= WifiEntryShell.LOWER_FREQ_5GHZ
+                                && frequency < WifiEntryShell.HIGHER_FREQ_5GHZ) {
                             band = res.getString(R.string.wifi_band_5ghz);
                         } else {
                             Log.e(TAG, "Unexpected frequency " + frequency);
@@ -417,11 +411,13 @@
                         }
                     }
 
-                    addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
+                    addRow(group, R.string.wifi_security,
+                            WifiEntryShell.getSecurityString(mWifiEntry, false));
                     mView.findViewById(R.id.ip_fields).setVisibility(View.GONE);
                 }
-                if (mAccessPoint.isSaved() || mAccessPoint.isActive()
-                        || mAccessPoint.isPasspointConfig()) {
+                if (mWifiEntry.isSaved()
+                        || mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
+                        || WifiEntryShell.isPasspoint(mWifiEntry)) {
                     mConfigUi.setForgetButton(res.getString(R.string.wifi_forget));
                 }
             }
@@ -460,10 +456,10 @@
 
     @VisibleForTesting
     String getSignalString() {
-        if (!mAccessPoint.isReachable()) {
+        if (mWifiEntry.getLevel() == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
             return null;
         }
-        final int level = mAccessPoint.getLevel();
+        final int level = mWifiEntry.getLevel();
 
         return (level > -1 && level < mLevels.length) ? mLevels[level] : null;
     }
@@ -510,27 +506,27 @@
         boolean enabled = false;
         boolean passwordInvalid = false;
         if (mPasswordView != null
-                && ((mAccessPointSecurity == AccessPoint.SECURITY_WEP
+                && ((mWifiEntrySecurity == WifiEntry.SECURITY_WEP
                         && mPasswordView.length() == 0)
-                    || (mAccessPointSecurity == AccessPoint.SECURITY_PSK
+                    || (mWifiEntrySecurity == WifiEntry.SECURITY_PSK
                            && !isValidPsk(mPasswordView.getText().toString()))
-                    || (mAccessPointSecurity == AccessPoint.SECURITY_SAE
+                    || (mWifiEntrySecurity == WifiEntry.SECURITY_SAE
                         && !isValidSaePassword(mPasswordView.getText().toString())))) {
             passwordInvalid = true;
         }
         if ((mSsidView != null && mSsidView.length() == 0)
-                // If Accesspoint is not saved, apply passwordInvalid check
-                || ((mAccessPoint == null || !mAccessPoint.isSaved()) && passwordInvalid
-                // If AccessPoint is saved (modifying network) and password is changed, apply
+                // If WifiEntry is not saved, apply passwordInvalid check
+                || ((mWifiEntry == null || !mWifiEntry.isSaved()) && passwordInvalid
+                // If WifiEntry is saved (modifying network) and password is changed, apply
                 // Invalid password check
-                || mAccessPoint != null && mAccessPoint.isSaved() && passwordInvalid
+                || mWifiEntry != null && mWifiEntry.isSaved() && passwordInvalid
                     && mPasswordView.length() > 0)) {
             enabled = false;
         } else {
             enabled = ipAndProxyFieldsAreValid();
         }
-        if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP
-                || mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
+        if ((mWifiEntrySecurity == WifiEntry.SECURITY_EAP
+                || mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B)
                 && mEapCaCertSpinner != null
                 && mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
             String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
@@ -548,8 +544,8 @@
                 enabled = false;
             }
         }
-        if ((mAccessPointSecurity == AccessPoint.SECURITY_EAP
-                || mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B)
+        if ((mWifiEntrySecurity == WifiEntry.SECURITY_EAP
+                || mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B)
                 && mEapUserCertSpinner != null
                 && mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
                 && mEapUserCertSpinner.getSelectedItem().equals(mUnspecifiedCertString)) {
@@ -591,7 +587,7 @@
             }
         }
 
-        if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B
+        if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B
                 && mEapMethodSpinner.getSelectedItemPosition() == WIFI_EAP_METHOD_TLS) {
             String userCertSelection = (String) mEapUserCertSpinner.getSelectedItem();
             if (userCertSelection.equals(mUnspecifiedCertString)) {
@@ -601,7 +597,7 @@
     }
 
     /**
-     * @return {@link WifiConfiguration} from mAccessPoint and UI edit result.
+     * @return {@link WifiConfiguration} from mWifiEntry and UI edit result.
      */
     public WifiConfiguration getConfig() {
         if (mMode == WifiConfigUiBase2.MODE_VIEW) {
@@ -610,27 +606,27 @@
 
         WifiConfiguration config = new WifiConfiguration();
 
-        if (mAccessPoint == null) {
+        if (mWifiEntry == null) {
             config.SSID = AccessPoint.convertToQuotedString(
                     mSsidView.getText().toString());
             // If the user adds a network manually, assume that it is hidden.
             config.hiddenSSID = mHiddenSettingsSpinner.getSelectedItemPosition() == HIDDEN_NETWORK;
-        } else if (!mAccessPoint.isSaved()) {
+        } else if (!mWifiEntry.isSaved()) {
             config.SSID = AccessPoint.convertToQuotedString(
-                    mAccessPoint.getSsidStr());
+                    mWifiEntry.getTitle());
         } else {
-            config.networkId = mAccessPoint.getConfig().networkId;
-            config.hiddenSSID = mAccessPoint.getConfig().hiddenSSID;
+            config.networkId = mWifiEntry.getWifiConfiguration().networkId;
+            config.hiddenSSID = mWifiEntry.getWifiConfiguration().hiddenSSID;
         }
 
         config.shared = mSharedCheckBox.isChecked();
 
-        switch (mAccessPointSecurity) {
-            case AccessPoint.SECURITY_NONE:
+        switch (mWifiEntrySecurity) {
+            case WifiEntry.SECURITY_NONE:
                 config.allowedKeyManagement.set(KeyMgmt.NONE);
                 break;
 
-            case AccessPoint.SECURITY_WEP:
+            case WifiEntry.SECURITY_WEP:
                 config.allowedKeyManagement.set(KeyMgmt.NONE);
                 config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
                 config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
@@ -647,7 +643,7 @@
                 }
                 break;
 
-            case AccessPoint.SECURITY_PSK:
+            case WifiEntry.SECURITY_PSK:
                 config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
                 if (mPasswordView.length() != 0) {
                     String password = mPasswordView.getText().toString();
@@ -659,11 +655,11 @@
                 }
                 break;
 
-            case AccessPoint.SECURITY_EAP:
-            case AccessPoint.SECURITY_EAP_SUITE_B:
+            case WifiEntry.SECURITY_EAP:
+            case WifiEntry.SECURITY_EAP_SUITE_B:
                 config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
                 config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
-                if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
+                if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
                     config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192);
                     config.requirePMF = true;
                     config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
@@ -736,14 +732,13 @@
                 } else if (caCert.equals(mUseSystemCertsString)) {
                     config.enterpriseConfig.setCaPath(SYSTEM_CA_STORE_PATH);
                 } else if (caCert.equals(mMultipleCertSetString)) {
-                    if (mAccessPoint != null) {
-                        if (!mAccessPoint.isSaved()) {
+                    if (mWifiEntry != null) {
+                        if (!mWifiEntry.isSaved()) {
                             Log.e(TAG, "Multiple certs can only be set "
                                     + "when editing saved network");
                         }
                         config.enterpriseConfig.setCaCertificateAliases(
-                                mAccessPoint
-                                        .getConfig()
+                                mWifiEntry.getWifiConfiguration()
                                         .enterpriseConfig
                                         .getCaCertificateAliases());
                     }
@@ -803,7 +798,7 @@
                     config.enterpriseConfig.setPassword(mPasswordView.getText().toString());
                 }
                 break;
-            case AccessPoint.SECURITY_SAE:
+            case WifiEntry.SECURITY_SAE:
                 config.allowedKeyManagement.set(KeyMgmt.SAE);
                 config.requirePMF = true;
                 if (mPasswordView.length() != 0) {
@@ -817,7 +812,7 @@
                 }
                 break;
 
-            case AccessPoint.SECURITY_OWE:
+            case WifiEntry.SECURITY_OWE:
                 config.allowedKeyManagement.set(KeyMgmt.OWE);
                 config.requirePMF = true;
                 break;
@@ -981,8 +976,8 @@
     }
 
     private void showSecurityFields(boolean refreshEapMethods, boolean refreshCertificates) {
-        if (mAccessPointSecurity == AccessPoint.SECURITY_NONE
-                || mAccessPointSecurity == AccessPoint.SECURITY_OWE) {
+        if (mWifiEntrySecurity == WifiEntry.SECURITY_NONE
+                || mWifiEntrySecurity == WifiEntry.SECURITY_OWE) {
             mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
             return;
         }
@@ -996,7 +991,7 @@
             ((CheckBox) mView.findViewById(R.id.show_password))
                 .setOnCheckedChangeListener(this);
 
-            if (mAccessPoint != null && mAccessPoint.isSaved()) {
+            if (mWifiEntry != null && mWifiEntry.isSaved()) {
                 mPasswordView.setHint(R.string.wifi_unchanged);
             }
         }
@@ -1007,19 +1002,19 @@
             mSaePasswordIdView.setOnKeyListener(this);
         }
 
-        if (mAccessPointSecurity == AccessPoint.SECURITY_SAE) {
+        if (mWifiEntrySecurity == WifiEntry.SECURITY_SAE) {
             mView.findViewById(R.id.sae_password_id_layout).setVisibility(View.VISIBLE);
-            if (mAccessPoint != null && mAccessPoint.isSaved()) {
-                if (!TextUtils.isEmpty(mAccessPoint.getConfig().saePasswordId)) {
-                    mSaePasswordIdView.setText(mAccessPoint.getConfig().saePasswordId);
+            if (mWifiEntry != null && mWifiEntry.isSaved()) {
+                if (!TextUtils.isEmpty(mWifiEntry.getWifiConfiguration().saePasswordId)) {
+                    mSaePasswordIdView.setText(mWifiEntry.getWifiConfiguration().saePasswordId);
                 }
             }
         } else {
             setSaePasswordIdInvisible();
         }
 
-        if (mAccessPointSecurity != AccessPoint.SECURITY_EAP
-                && mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
+        if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP
+                && mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
             mView.findViewById(R.id.eap).setVisibility(View.GONE);
             return;
         }
@@ -1046,7 +1041,7 @@
 
         if (refreshEapMethods) {
             ArrayAdapter<CharSequence> eapMethodSpinnerAdapter;
-            if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
+            if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
                 eapMethodSpinnerAdapter = getSpinnerAdapter(R.array.wifi_eap_method);
                 mEapMethodSpinner.setAdapter(eapMethodSpinnerAdapter);
                 // WAP3-Enterprise 192-bit only allows EAP method TLS
@@ -1086,8 +1081,9 @@
         }
 
         // Modifying an existing network
-        if (initiateEnterpriseNetworkUi && mAccessPoint != null && mAccessPoint.isSaved()) {
-            WifiEnterpriseConfig enterpriseConfig = mAccessPoint.getConfig().enterpriseConfig;
+        if (initiateEnterpriseNetworkUi && mWifiEntry != null && mWifiEntry.isSaved()) {
+            WifiEnterpriseConfig enterpriseConfig = mWifiEntry.getWifiConfiguration()
+                    .enterpriseConfig;
             int eapMethod = enterpriseConfig.getEapMethod();
             int phase2Method = enterpriseConfig.getPhase2Method();
             mEapMethodSpinner.setSelection(eapMethod);
@@ -1340,8 +1336,8 @@
 
         mView.findViewById(R.id.ip_fields).setVisibility(View.VISIBLE);
 
-        if (mAccessPoint != null && mAccessPoint.isSaved()) {
-            config = mAccessPoint.getConfig();
+        if (mWifiEntry != null && mWifiEntry.isSaved()) {
+            config = mWifiEntry.getWifiConfiguration();
         }
 
         if (mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP) {
@@ -1392,8 +1388,8 @@
 
         mView.findViewById(R.id.proxy_settings_fields).setVisibility(View.VISIBLE);
 
-        if (mAccessPoint != null && mAccessPoint.isSaved()) {
-            config = mAccessPoint.getConfig();
+        if (mWifiEntry != null && mWifiEntry.isSaved()) {
+            config = mWifiEntry.getWifiConfiguration();
         }
 
         if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) {
@@ -1471,7 +1467,7 @@
         } catch (Exception e) {
             Log.e(TAG, "can't get the certificate list from KeyStore");
         }
-        if (mAccessPointSecurity != AccessPoint.SECURITY_EAP_SUITE_B) {
+        if (mWifiEntrySecurity != WifiEntry.SECURITY_EAP_SUITE_B) {
             certs.add(noCertificateString);
         }
 
@@ -1556,17 +1552,10 @@
                 ((EditText) mPasswordView).setSelection(pos);
             }
         } else if (view.getId() == R.id.wifi_advanced_togglebox) {
-            final int toggleVisibility;
-            final int stringID;
-            if (isChecked) {
-                toggleVisibility = View.VISIBLE;
-                // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
-                hideSoftKeyboard(mView.getWindowToken());
-            } else {
-                toggleVisibility = View.GONE;
-            }
-            mView.findViewById(R.id.wifi_advanced_fields).setVisibility(toggleVisibility);
-            setAdvancedOptionAccessibilityString(isChecked);
+            // Hide the SoftKeyboard temporary to let user can see most of the expanded items.
+            hideSoftKeyboard(mView.getWindowToken());
+            view.setVisibility(View.GONE);
+            mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
         }
     }
 
@@ -1574,10 +1563,10 @@
     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
         if (parent == mSecuritySpinner) {
             // Convert menu position to actual Wi-Fi security type
-            mAccessPointSecurity = mSecurityInPosition[position];
+            mWifiEntrySecurity = mSecurityInPosition[position];
             showSecurityFields(/* refreshEapMethods */ true, /* refreshCertificates */ true);
 
-            if (WifiDppUtils.isSupportEnrolleeQrCodeScanner(mContext, mAccessPointSecurity)) {
+            if (WifiDppUtils.isSupportEnrolleeQrCodeScanner(mContext, mWifiEntrySecurity)) {
                 mSsidScanButton.setVisibility(View.VISIBLE);
             } else {
                 mSsidScanButton.setVisibility(View.GONE);
@@ -1624,8 +1613,8 @@
                    : InputType.TYPE_TEXT_VARIATION_PASSWORD));
     }
 
-    public AccessPoint getAccessPoint() {
-        return mAccessPoint;
+    public WifiEntry getWifiEntry() {
+        return mWifiEntry;
     }
 
     private void configureSecuritySpinner() {
@@ -1644,24 +1633,24 @@
 
         // Populate the Wi-Fi security spinner with the various supported key management types
         spinnerAdapter.add(mContext.getString(R.string.wifi_security_none));
-        mSecurityInPosition[idx++] = AccessPoint.SECURITY_NONE;
+        mSecurityInPosition[idx++] = WifiEntry.SECURITY_NONE;
         if (mWifiManager.isEnhancedOpenSupported()) {
             spinnerAdapter.add(mContext.getString(R.string.wifi_security_owe));
-            mSecurityInPosition[idx++] = AccessPoint.SECURITY_OWE;
+            mSecurityInPosition[idx++] = WifiEntry.SECURITY_OWE;
         }
         spinnerAdapter.add(mContext.getString(R.string.wifi_security_wep));
-        mSecurityInPosition[idx++] = AccessPoint.SECURITY_WEP;
+        mSecurityInPosition[idx++] = WifiEntry.SECURITY_WEP;
         spinnerAdapter.add(mContext.getString(R.string.wifi_security_wpa_wpa2));
-        mSecurityInPosition[idx++] = AccessPoint.SECURITY_PSK;
+        mSecurityInPosition[idx++] = WifiEntry.SECURITY_PSK;
         if (mWifiManager.isWpa3SaeSupported()) {
             spinnerAdapter.add(mContext.getString(R.string.wifi_security_sae));
-            mSecurityInPosition[idx++] = AccessPoint.SECURITY_SAE;
+            mSecurityInPosition[idx++] = WifiEntry.SECURITY_SAE;
         }
         spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap));
-        mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP;
+        mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP;
         if (mWifiManager.isWpa3SuiteBSupported()) {
             spinnerAdapter.add(mContext.getString(R.string.wifi_security_eap_suiteb));
-            mSecurityInPosition[idx++] = AccessPoint.SECURITY_EAP_SUITE_B;
+            mSecurityInPosition[idx++] = WifiEntry.SECURITY_EAP_SUITE_B;
         }
 
         spinnerAdapter.notifyDataSetChanged();
@@ -1676,7 +1665,7 @@
         ((CheckBox) mView.findViewById(R.id.wifi_advanced_togglebox))
                 .setOnCheckedChangeListener(this);
         // Set correct accessibility strings.
-        setAdvancedOptionAccessibilityString(false /* showAdvancedFields */);
+        setAdvancedOptionAccessibilityString();
     }
 
     /**
@@ -1768,7 +1757,7 @@
         inputMethodManager.hideSoftInputFromWindow(windowToken, 0 /* flags */);
     }
 
-    private void setAdvancedOptionAccessibilityString(boolean showAdvancedFields) {
+    private void setAdvancedOptionAccessibilityString() {
         final CheckBox advancedToggleBox = mView.findViewById(R.id.wifi_advanced_togglebox);
         advancedToggleBox.setAccessibilityDelegate(new AccessibilityDelegate() {
             @Override
@@ -1779,12 +1768,10 @@
                 info.setCheckable(false /* checkable */);
                 // To let TalkBack don't pronounce CheckBox.
                 info.setClassName(null /* className */);
-                final CharSequence accessibilityDoubleTapExtend = mContext.getString(
-                        showAdvancedFields ? R.string.wifi_advanced_toggle_description_expanded
-                                : R.string.wifi_advanced_toggle_description_collapsed);
                 // Customize TalkBack's pronunciation which been appended to "Double-tap to".
                 final AccessibilityAction customClick = new AccessibilityAction(
-                        AccessibilityNodeInfo.ACTION_CLICK, accessibilityDoubleTapExtend);
+                        AccessibilityNodeInfo.ACTION_CLICK,
+                        mContext.getString(R.string.wifi_advanced_toggle_description_collapsed));
                 info.addAction(customClick);
             }
         });
diff --git a/src/com/android/settings/wifi/WifiDialog2.java b/src/com/android/settings/wifi/WifiDialog2.java
index 0716ea5..acd6f17 100644
--- a/src/com/android/settings/wifi/WifiDialog2.java
+++ b/src/com/android/settings/wifi/WifiDialog2.java
@@ -30,7 +30,7 @@
 import com.android.settings.R;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.android.settingslib.wifi.AccessPoint;
+import com.android.wifitrackerlib.WifiEntry;
 
 /**
  * Dialog for users to edit a Wi-Fi network.
@@ -66,7 +66,7 @@
 
     private final int mMode;
     private final WifiDialog2Listener mListener;
-    private final AccessPoint mAccessPoint;
+    private final WifiEntry mWifiEntry;
 
     private View mView;
     private WifiConfigController2 mController;
@@ -77,8 +77,8 @@
      * view.
      */
     public static WifiDialog2 createModal(Context context, WifiDialog2Listener listener,
-            AccessPoint accessPoint, int mode) {
-        return new WifiDialog2(context, listener, accessPoint, mode, 0 /* style */,
+            WifiEntry wifiEntry, int mode) {
+        return new WifiDialog2(context, listener, wifiEntry, mode, 0 /* style */,
                 mode == WifiConfigUiBase2.MODE_VIEW /* hideSubmitButton */);
     }
 
@@ -87,17 +87,17 @@
      * view.
      */
     public static WifiDialog2 createModal(Context context, WifiDialog2Listener listener,
-            AccessPoint accessPoint, int mode, @StyleRes int style) {
-        return new WifiDialog2(context, listener, accessPoint, mode, style,
+            WifiEntry wifiEntry, int mode, @StyleRes int style) {
+        return new WifiDialog2(context, listener, wifiEntry, mode, style,
                 mode == WifiConfigUiBase2.MODE_VIEW /* hideSubmitButton */);
     }
 
-    /* package */ WifiDialog2(Context context, WifiDialog2Listener listener,
-                AccessPoint accessPoint, int mode, @StyleRes int style, boolean hideSubmitButton) {
+    /* package */ WifiDialog2(Context context, WifiDialog2Listener listener, WifiEntry wifiEntry,
+            int mode, @StyleRes int style, boolean hideSubmitButton) {
         super(context, style);
         mMode = mode;
         mListener = listener;
-        mAccessPoint = accessPoint;
+        mWifiEntry = wifiEntry;
         mHideSubmitButton = hideSubmitButton;
     }
 
@@ -110,7 +110,7 @@
     protected void onCreate(Bundle savedInstanceState) {
         mView = getLayoutInflater().inflate(R.layout.wifi_dialog, /* root */ null);
         setView(mView);
-        mController = new WifiConfigController2(this, mView, mAccessPoint, mMode);
+        mController = new WifiConfigController2(this, mView, mWifiEntry, mMode);
         super.onCreate(savedInstanceState);
 
         if (mHideSubmitButton) {
@@ -121,7 +121,7 @@
             mController.enableSubmitIfAppropriate();
         }
 
-        if (mAccessPoint == null) {
+        if (mWifiEntry == null) {
             mController.hideForgetButton();
         }
     }
@@ -168,7 +168,8 @@
                     mListener.onSubmit(this);
                     break;
                 case BUTTON_FORGET:
-                    if (WifiUtils.isNetworkLockedDown(getContext(), mAccessPoint.getConfig())) {
+                    if (WifiUtils.isNetworkLockedDown(getContext(),
+                            mWifiEntry.getWifiConfiguration())) {
                         RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(),
                                 RestrictedLockUtilsInternal.getDeviceOwner(getContext()));
                         return;
diff --git a/src/com/android/settings/wifi/WifiEntryShell.java b/src/com/android/settings/wifi/WifiEntryShell.java
index 6b6fef8..781bc84 100644
--- a/src/com/android/settings/wifi/WifiEntryShell.java
+++ b/src/com/android/settings/wifi/WifiEntryShell.java
@@ -16,7 +16,7 @@
 
 package com.android.settings.wifi;
 
-import android.net.NetworkInfo.DetailedState;
+import android.net.wifi.WifiConfiguration;
 
 import com.android.wifitrackerlib.WifiEntry;
 
@@ -65,26 +65,12 @@
     }
 
     /**
-     * Mapping of the corresponding {@link WifiDetailPreferenceController} method
-     */
-    public static boolean canModifyNetwork(WifiEntry wifiEntry) {
-        return false;
-    }
-
-    /**
      * Mapping of the corresponding {@link AccessPoint} method
      */
     public static String getSecurityString(WifiEntry wifiEntry, boolean concise) {
         return "None";
     }
 
-    /**
-     * Mapping of the corresponding {@link AccessPoint} method
-     */
-    public static DetailedState getDetailedState(WifiEntry wifiEntry) {
-        return null;
-    }
-
     // Passpoint methods
 
     /**
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 ac9374f..bd79b3f 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -19,9 +19,11 @@
 import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
 
 import android.app.Activity;
+import android.app.Dialog;
 import android.app.settings.SettingsEnums;
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.res.Resources;
 import android.net.ConnectivityManager;
@@ -38,10 +40,12 @@
 import android.os.SimpleClock;
 import android.os.SystemClock;
 import android.provider.Settings;
+import android.text.TextUtils;
 import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
+import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.Toast;
@@ -64,27 +68,45 @@
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.widget.SwitchBarController;
 import com.android.settings.wifi.details2.WifiNetworkDetailsFragment2;
+import com.android.settings.wifi.dpp.WifiDppUtils;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtilsInternal;
 import com.android.settingslib.search.Indexable;
 import com.android.settingslib.search.SearchIndexable;
 import com.android.settingslib.search.SearchIndexableRaw;
 import com.android.settingslib.wifi.LongPressWifiEntryPreference;
 import com.android.wifitrackerlib.WifiEntry;
+import com.android.wifitrackerlib.WifiEntry.WifiEntryCallback;
+import com.android.wifitrackerlib.WifiEntry.WifiEntryCallback.ConnectStatus;
+import com.android.wifitrackerlib.WifiEntry.WifiEntryCallback.DisconnectStatus;
+import com.android.wifitrackerlib.WifiEntry.WifiEntryCallback.ForgetStatus;
+import com.android.wifitrackerlib.WifiEntry.WifiEntryCallback.SignInStatus;
 import com.android.wifitrackerlib.WifiPickerTracker;
 
 import java.time.Clock;
 import java.time.ZoneOffset;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * UI for Wi-Fi settings screen
  */
 @SearchIndexable
 public class WifiSettings2 extends RestrictedSettingsFragment
-        implements Indexable, WifiPickerTracker.WifiPickerTrackerCallback {
+        implements Indexable, WifiPickerTracker.WifiPickerTrackerCallback,
+        WifiDialog2.WifiDialog2Listener, DialogInterface.OnDismissListener {
 
     private static final String TAG = "WifiSettings2";
 
+    // IDs of context menu
+    static final int MENU_ID_CONNECT = Menu.FIRST + 1;
+    @VisibleForTesting
+    static final int MENU_ID_DISCONNECT = Menu.FIRST + 2;
+    @VisibleForTesting
+    static final int MENU_ID_FORGET = Menu.FIRST + 3;
+    static final int MENU_ID_MODIFY = Menu.FIRST + 4;
+
     // Max age of tracked WifiEntries
     private static final long MAX_SCAN_AGE_MILLIS = 15_000;
     // Interval between initiating WifiPickerTracker scans
@@ -92,6 +114,7 @@
 
     @VisibleForTesting
     static final int ADD_NETWORK_REQUEST = 2;
+    static final int CONFIG_NETWORK_REQUEST = 3;
 
     private static final String PREF_KEY_EMPTY_WIFI_LIST = "wifi_empty_list";
     // TODO(b/70983952): Rename these to use WifiEntry instead of AccessPoint.
@@ -105,6 +128,33 @@
 
     private static final int REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER = 0;
 
+    public static final int WIFI_DIALOG_ID = 1;
+
+    // Instance state keys
+    private static final String SAVE_DIALOG_MODE = "dialog_mode";
+    private static final String SAVE_DIALOG_WIFIENTRY_KEY = "wifi_ap_key";
+
+    // Cache at onCreateContextMenu and use at onContextItemSelected. Don't use it in other methods.
+    private WifiEntry mSelectedWifiEntry;
+
+    // Save the dialog details
+    private int mDialogMode;
+    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();
     }
@@ -136,7 +186,7 @@
     @VisibleForTesting
     WifiPickerTracker mWifiPickerTracker;
 
-    private WifiDialog mDialog;
+    private WifiDialog2 mDialog;
 
     private View mProgressHeader;
 
@@ -275,6 +325,32 @@
         };
         registerForContextMenu(getListView());
         setHasOptionsMenu(true);
+
+        if (savedInstanceState != null) {
+            mDialogMode = savedInstanceState.getInt(SAVE_DIALOG_MODE);
+            mDialogWifiEntryKey = savedInstanceState.getString(SAVE_DIALOG_WIFIENTRY_KEY);
+
+            if (!TextUtils.isEmpty(mDialogWifiEntryKey)) {
+                List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries();
+                Optional<WifiEntry> matchedWifiEntry = wifiEntries.stream().filter(wifiEntry ->
+                        TextUtils.equals(wifiEntry.getKey(), mDialogWifiEntryKey)).findAny();
+                if (matchedWifiEntry.isPresent()) {
+                    mDialogWifiEntry = matchedWifiEntry.get();
+                } else {
+                    throw new IllegalStateException("Failed to restore WifiEntry of key: "
+                            + mDialogWifiEntryKey);
+                }
+            }
+        }
+
+        // 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
@@ -283,7 +359,7 @@
             mWifiEnabler.teardownSwitchController();
         }
         mWorkerThread.quit();
-        
+
         super.onDestroyView();
     }
 
@@ -330,6 +406,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
@@ -361,6 +454,16 @@
                 }
             }
             return;
+        } else if (requestCode == CONFIG_NETWORK_REQUEST) {
+            if (resultCode == Activity.RESULT_OK) {
+                final WifiConfiguration wifiConfiguration = data.getParcelableExtra(
+                        ConfigureWifiEntryFragment.NETWORK_CONFIG_KEY);
+                if (wifiConfiguration != null) {
+                    mWifiManager.save(wifiConfiguration,
+                            new WifiSaveThenConnectActionListener(wifiConfiguration));
+                }
+            }
+            return;
         }
 
         final boolean formerlyRestricted = mIsRestricted;
@@ -385,16 +488,72 @@
     }
 
     @Override
+    public void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        // If dialog has been shown, save its state.
+        if (mDialog != null) {
+            outState.putInt(SAVE_DIALOG_MODE, mDialogMode);
+            outState.putString(SAVE_DIALOG_WIFIENTRY_KEY, mDialogWifiEntryKey);
+        }
+    }
+
+    @Override
     public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {
-        // TODO(b/70983952): Add context menu options here. This should be driven by the appropriate
-        // "can do action" APIs from WifiEntry.
+        Preference preference = (Preference) view.getTag();
+        if (!(preference instanceof LongPressWifiEntryPreference)) {
+            // Do nothing.
+            return;
+        }
+
+        // Cache the WifiEntry for onContextItemSelected. Don't use it in other methods.
+        mSelectedWifiEntry = ((LongPressWifiEntryPreference) preference).getWifiEntry();
+
+        menu.setHeaderTitle(mSelectedWifiEntry.getTitle());
+        if (mSelectedWifiEntry.canConnect()) {
+            menu.add(Menu.NONE, MENU_ID_CONNECT, 0 /* order */, R.string.wifi_connect);
+        }
+
+        if (mSelectedWifiEntry.canDisconnect()) {
+            menu.add(Menu.NONE, MENU_ID_DISCONNECT, 0 /* order */,
+                    R.string.wifi_disconnect_button_text);
+        }
+
+        // "forget" for normal saved network. And "disconnect" for ephemeral network because it
+        // could only be disconnected and be put in blacklists so it won't be used again.
+        if (mSelectedWifiEntry.canForget()) {
+            menu.add(Menu.NONE, MENU_ID_FORGET, 0 /* order */, R.string.forget);
+        }
+
+        WifiConfiguration config = mSelectedWifiEntry.getWifiConfiguration();
+        // Some configs are ineditable
+        if (WifiUtils.isNetworkLockedDown(getActivity(), config)) {
+            return;
+        }
+
+        if (mSelectedWifiEntry.isSaved() && mSelectedWifiEntry.getConnectedState()
+                != WifiEntry.CONNECTED_STATE_CONNECTED) {
+            menu.add(Menu.NONE, MENU_ID_MODIFY, 0 /* order */, R.string.wifi_modify);
+        }
     }
 
     @Override
     public boolean onContextItemSelected(MenuItem item) {
-        // TODO(b/70983952): Add context menu selection logic here. This should simply call the
-        // appropriate WifiEntry action APIs (connect, forget, disconnect, etc).
-        return false;
+        switch (item.getItemId()) {
+            case MENU_ID_CONNECT:
+                connect(mSelectedWifiEntry, true /* editIfNoConfig */, false /* fullScreenEdit */);
+                return true;
+            case MENU_ID_DISCONNECT:
+                mSelectedWifiEntry.disconnect();
+                return true;
+            case MENU_ID_FORGET:
+                forget(mSelectedWifiEntry);
+                return true;
+            case MENU_ID_MODIFY:
+                showDialog(mSelectedWifiEntry, WifiConfigUiBase2.MODE_MODIFY);
+                return true;
+            default:
+                return super.onContextItemSelected(item);
+        }
     }
 
     @Override
@@ -405,12 +564,10 @@
             return super.onPreferenceTreeClick(preference);
         }
 
-        // TODO(b/70983952) Add WifiEntry click logic. This should be as simple as calling
-        // WifiEntry.connect().
         if (preference instanceof LongPressWifiEntryPreference) {
             final WifiEntry selectedEntry =
                     ((LongPressWifiEntryPreference) preference).getWifiEntry();
-            selectedEntry.connect();
+            connect(selectedEntry, true /* editIfNoConfig */, true /* fullScreenEdit */);
         } else if (preference == mAddWifiNetworkPreference) {
             onAddNetworkPressed();
         } else {
@@ -419,6 +576,54 @@
         return true;
     }
 
+    private void showDialog(WifiEntry wifiEntry, int dialogMode) {
+        if (WifiUtils.isNetworkLockedDown(getActivity(), wifiEntry.getWifiConfiguration())
+                && wifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED) {
+            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
+                    RestrictedLockUtilsInternal.getDeviceOwner(getActivity()));
+            return;
+        }
+
+        if (mDialog != null) {
+            removeDialog(WIFI_DIALOG_ID);
+            mDialog = null;
+        }
+
+        // Save the access point and edit mode
+        mDialogWifiEntry = wifiEntry;
+        mDialogWifiEntryKey = wifiEntry.getKey();
+        mDialogMode = dialogMode;
+
+        showDialog(WIFI_DIALOG_ID);
+    }
+
+    @Override
+    public Dialog onCreateDialog(int dialogId) {
+        switch (dialogId) {
+            case WIFI_DIALOG_ID:
+                // modify network
+                mDialog = WifiDialog2
+                        .createModal(getActivity(), this, mDialogWifiEntry, mDialogMode);
+                return mDialog;
+            default:
+                return super.onCreateDialog(dialogId);
+        }
+    }
+
+    @Override
+    public void onDialogShowing() {
+        super.onDialogShowing();
+        setOnDismissListener(this);
+    }
+
+    @Override
+    public void onDismiss(DialogInterface dialog) {
+        // We don't keep any dialog object when dialog was dismissed.
+        mDialog = null;
+        mDialogWifiEntry = null;
+        mDialogWifiEntryKey = null;
+    }
+
     /** Called when the state of Wifi has changed. */
     @Override
     public void onWifiStateChanged() {
@@ -460,6 +665,7 @@
     @Override
     public void onWifiEntriesChanged() {
         updateWifiEntryPreferencesDelayed();
+        changeNextButtonState(mWifiPickerTracker.getConnectedWifiEntry() != null);
     }
 
     @Override
@@ -584,7 +790,8 @@
                 .launch();
     }
 
-    private LongPressWifiEntryPreference createLongPressWifiEntryPreference(WifiEntry wifiEntry) {
+    @VisibleForTesting
+    LongPressWifiEntryPreference createLongPressWifiEntryPreference(WifiEntry wifiEntry) {
         return new LongPressWifiEntryPreference(getPrefContext(), wifiEntry, this);
     }
 
@@ -715,6 +922,101 @@
         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);
+    }
+
+    @Override
+    public void onSubmit(WifiDialog2 dialog) {
+        final int dialogMode = mDialog.getController().getMode();
+
+        if (dialogMode == WifiConfigUiBase2.MODE_MODIFY) {
+            mWifiManager.save(mDialogWifiEntry.getWifiConfiguration(), mSaveListener);
+        } else if (dialogMode == WifiConfigUiBase2.MODE_CONNECT
+                || (dialogMode == WifiConfigUiBase2.MODE_VIEW && mDialogWifiEntry.canConnect())) {
+            connect(mDialogWifiEntry, false /* editIfNoConfig */, false /* fullScreenEdit*/);
+        }
+    }
+
+    @Override
+    public void onScan(WifiDialog2 dialog, String ssid) {
+        // Launch QR code scanner to join a network.
+        startActivityForResult(WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid),
+                REQUEST_CODE_WIFI_DPP_ENROLLEE_QR_CODE_SCANNER);
+    }
+
+    private void forget(WifiEntry wifiEntry) {
+        mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
+        wifiEntry.forget();
+    }
+
+    private void connect(WifiEntry wifiEntry, boolean editIfNoConfig, boolean fullScreenEdit) {
+        mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_WIFI_CONNECT,
+                wifiEntry.isSaved());
+
+        // If it's an unsaved secure WifiEntry, it will callback
+        // WifiEntryCallback#onConnectResult with
+        // WifiEntryCallback#CONNECT_STATUS_FAILURE_NO_CONFIG
+        wifiEntry.setListener(new WifiEntryConnectCallback(wifiEntry, editIfNoConfig,
+                fullScreenEdit));
+        wifiEntry.connect();
+    }
+
+    private class WifiSaveThenConnectActionListener implements WifiManager.ActionListener {
+        final WifiConfiguration mWifiConfiguration;
+
+        WifiSaveThenConnectActionListener(WifiConfiguration wifiConfiguration) {
+            mWifiConfiguration = wifiConfiguration;
+        }
+
+        @Override
+        public void onSuccess() {
+            mWifiManager.connect(mWifiConfiguration, new WifiConnectActionListener());
+        }
+
+        @Override
+        public void onFailure(int reason) {
+            final Activity activity = getActivity();
+            if (isFisishingOrDestroyed(activity)) {
+                return;
+            }
+
+            Toast.makeText(activity, R.string.wifi_failed_save_message, Toast.LENGTH_SHORT).show();
+        }
+    };
+
+    private class WifiConnectActionListener implements WifiManager.ActionListener {
+        @Override
+        public void onSuccess() {
+            // Do nothing.
+        }
+
+        @Override
+        public void onFailure(int reason) {
+            final Activity activity = getActivity();
+            if (isFisishingOrDestroyed(activity)) {
+                return;
+            }
+
+            Toast.makeText(activity, R.string.wifi_failed_connect_message, Toast.LENGTH_SHORT)
+                    .show();
+        }
+    };
+
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -736,4 +1038,91 @@
                     return result;
                 }
             };
+
+    private class WifiEntryConnectCallback implements WifiEntryCallback {
+        final WifiEntry mConnectWifiEntry;
+        final boolean mEditIfNoConfig;
+        final boolean mFullScreenEdit;
+
+        WifiEntryConnectCallback(WifiEntry connectWifiEntry, boolean editIfNoConfig,
+                boolean fullScreenEdit) {
+            mConnectWifiEntry = connectWifiEntry;
+            mEditIfNoConfig = editIfNoConfig;
+            mFullScreenEdit = fullScreenEdit;
+        }
+
+        @Override
+        public void onUpdated() {
+            // Do nothing.
+        }
+
+        @Override
+        public void onConnectResult(@ConnectStatus int status) {
+            final Activity activity = getActivity();
+            if (isFisishingOrDestroyed(activity)) {
+                return;
+            }
+
+            if (status == WifiEntryCallback.CONNECT_STATUS_FAILURE_NO_CONFIG) {
+                if (mEditIfNoConfig) {
+                    // Edit an unsaved secure Wi-Fi network.
+                    if (mFullScreenEdit) {
+                        launchConfigNewNetworkFragment(mConnectWifiEntry);
+                    } else {
+                        showDialog(mConnectWifiEntry, WifiConfigUiBase2.MODE_MODIFY);
+                    }
+                }
+            } else if (status == CONNECT_STATUS_FAILURE_UNKNOWN) {
+                Toast.makeText(getContext(), R.string.wifi_failed_connect_message,
+                        Toast.LENGTH_SHORT).show();
+            }
+        }
+
+        @Override
+        public void onDisconnectResult(@DisconnectStatus int status) {
+            // Do nothing.
+        }
+
+        @Override
+        public void onForgetResult(@ForgetStatus int status) {
+            // Do nothing.
+        }
+
+        @Override
+        public void onSignInResult(@SignInStatus int status) {
+            // Do nothing.
+        }
+    }
+
+    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/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index f94ca9d..5f74d56 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -61,9 +61,10 @@
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settings.datausage.WifiDataUsageSummaryPreferenceController;
 import com.android.settings.widget.EntityHeaderController;
-import com.android.settings.wifi.WifiDialog;
-import com.android.settings.wifi.WifiDialog.WifiDialogListener;
+import com.android.settings.wifi.WifiDialog2;
+import com.android.settings.wifi.WifiDialog2.WifiDialog2Listener;
 import com.android.settings.wifi.WifiEntryShell;
+import com.android.settings.wifi.WifiUtils;
 import com.android.settings.wifi.dpp.WifiDppUtils;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -93,7 +94,7 @@
  * {@link WifiNetworkDetailsFragment}.
  */
 public class WifiDetailPreferenceController2 extends AbstractPreferenceController
-        implements PreferenceControllerMixin, WifiDialogListener, LifecycleObserver, OnPause,
+        implements PreferenceControllerMixin, WifiDialog2Listener, LifecycleObserver, OnPause,
         OnResume, WifiEntryCallback {
 
     private static final String TAG = "WifiDetailsPrefCtrl2";
@@ -588,16 +589,24 @@
     private void refreshButtons() {
         boolean canForgetNetwork = mWifiEntry.canForget();
         boolean canSignIntoNetwork = canSignIntoNetwork();
-        boolean canConnectNetwork = mWifiEntry.canConnect();
+        boolean showConnectButton = mWifiEntry.canConnect()
+                || mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTING;
         boolean canShareNetwork = canShareNetwork();
 
         mButtonsPref.setButton1Visible(canForgetNetwork);
         mButtonsPref.setButton2Visible(canSignIntoNetwork);
-        mButtonsPref.setButton3Visible(canConnectNetwork);
+        mButtonsPref.setButton3Visible(showConnectButton);
+        if (showConnectButton) {
+            if (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTING) {
+                mButtonsPref.setButton3Text(R.string.wifi_connecting).setButton3Enabled(false);
+            } else {
+                mButtonsPref.setButton3Text(R.string.wifi_connect).setButton3Enabled(true);
+            }
+        }
         mButtonsPref.setButton4Visible(canShareNetwork);
         mButtonsPref.setVisible(canForgetNetwork
                 || canSignIntoNetwork
-                || canConnectNetwork
+                || showConnectButton
                 || canShareNetwork);
     }
 
@@ -670,7 +679,8 @@
      * Returns whether the network represented by this preference can be modified.
      */
     public boolean canModifyNetwork() {
-        return WifiEntryShell.canModifyNetwork(mWifiEntry);
+        return mWifiEntry.isSaved()
+                && !WifiUtils.isNetworkLockedDown(mContext, mWifiEntry.getWifiConfiguration());
     }
 
     /**
@@ -762,7 +772,7 @@
     }
 
     @Override
-    public void onSubmit(WifiDialog dialog) {
+    public void onSubmit(WifiDialog2 dialog) {
         if (dialog.getController() != null) {
             mWifiManager.save(dialog.getController().getConfig(), new WifiManager.ActionListener() {
                 @Override
@@ -804,8 +814,6 @@
 
     @VisibleForTesting
     void connectNetwork() {
-        // TODO(b/143326832): What to do with WifiManager#isWifiEnabled() false case?
-        mButtonsPref.setButton3Text(R.string.wifi_connecting).setButton3Enabled(false);
         mWifiEntry.connect();
     }
 
@@ -845,8 +853,6 @@
             Toast.makeText(mContext,
                     mContext.getString(R.string.wifi_connected_to_message, mWifiEntry.getTitle()),
                     Toast.LENGTH_SHORT).show();
-            updateNetworkInfo();
-            refreshPage();
         } else if (mWifiEntry.getLevel() == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
             Toast.makeText(mContext,
                     R.string.wifi_not_in_range_message,
diff --git a/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java
index 0915152..7df62bf 100644
--- a/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java
@@ -18,6 +18,7 @@
 
 import android.app.backup.BackupManager;
 import android.content.Context;
+import android.net.wifi.WifiConfiguration;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.DropDownPreference;
@@ -25,7 +26,7 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.wifi.WifiDialog;
+import com.android.settings.wifi.WifiDialog2;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.wifitrackerlib.WifiEntry;
 
@@ -33,7 +34,7 @@
  * {@link AbstractPreferenceController} that controls whether the wifi network is metered or not
  */
 public class WifiMeteredPreferenceController2 extends BasePreferenceController implements
-        Preference.OnPreferenceChangeListener, WifiDialog.WifiDialogListener {
+        Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
 
     private static final String KEY_WIFI_METERED = "metered";
     private WifiEntry mWifiEntry;
@@ -89,18 +90,30 @@
     }
 
     @Override
-    public void onSubmit(WifiDialog dialog) {
-        // TODO(b/143326832): Create WifiDialog2 and let it work for WifiEntry.
-        //if (dialog.getController() != null) {
-        //    final WifiConfiguration newConfig = dialog.getController().getConfig();
-        //    if (newConfig == null || mWifiConfiguration == null) {
-        //        return;
-        //    }
-        //
-        //    if (newConfig.meteredOverride != mWifiConfiguration.meteredOverride) {
-        //        mWifiConfiguration = newConfig;
-        //        onPreferenceChange(mPreference, String.valueOf(newConfig.meteredOverride));
-        //    }
-        //}
+    public void onSubmit(WifiDialog2 dialog) {
+        if (dialog.getController() != null) {
+            final WifiConfiguration newConfig = dialog.getController().getConfig();
+            if (newConfig == null || !mWifiEntry.isSaved()) {
+                return;
+            }
+
+            if (newConfig.meteredOverride != mWifiEntry.getWifiConfiguration().meteredOverride) {
+                mWifiEntry.setMeteredChoice(getWifiEntryMeteredChoice(newConfig));
+                onPreferenceChange(mPreference, String.valueOf(newConfig.meteredOverride));
+            }
+        }
+    }
+
+    private int getWifiEntryMeteredChoice(WifiConfiguration wifiConfiguration) {
+        switch (wifiConfiguration.meteredOverride) {
+            case WifiConfiguration.METERED_OVERRIDE_NONE:
+                return WifiEntry.METERED_CHOICE_AUTO;
+            case WifiConfiguration.METERED_OVERRIDE_METERED:
+                return WifiEntry.METERED_CHOICE_METERED;
+            case WifiConfiguration.METERED_OVERRIDE_NOT_METERED:
+                return WifiEntry.METERED_CHOICE_UNMETERED;
+            default:
+                return WifiEntry.METERED_CHOICE_UNKNOWN;
+        }
     }
 }
diff --git a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
index 7e4c856..bdd63dc 100644
--- a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
+++ b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
@@ -35,7 +35,8 @@
 
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.wifi.WifiDialog;
+import com.android.settings.wifi.WifiConfigUiBase2;
+import com.android.settings.wifi.WifiDialog2;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtilsInternal;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -54,7 +55,7 @@
  * in order to properly render this page.
  */
 public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
-        WifiDialog.WifiDialogListener {
+        WifiDialog2.WifiDialog2Listener {
 
     private static final String TAG = "WifiNetworkDetailsFrg2";
 
@@ -69,7 +70,7 @@
     private NetworkDetailsTracker mNetworkDetailsTracker;
     private HandlerThread mWorkerThread;
     private WifiDetailPreferenceController2 mWifiDetailPreferenceController2;
-    private List<WifiDialog.WifiDialogListener> mWifiDialogListeners = new ArrayList<>();
+    private List<WifiDialog2.WifiDialog2Listener> mWifiDialogListeners = new ArrayList<>();
 
     @Override
     public void onDestroy() {
@@ -106,10 +107,10 @@
         if (getActivity() == null || mWifiDetailPreferenceController2 == null) {
             return null;
         }
-        // TODO(b/143326832): Replace it with WifiEntry.
-        return null;
-        //return WifiDialog.createModal(getActivity(), this, mAccessPoint,
-        //        WifiConfigUiBase.MODE_MODIFY);
+
+        final WifiEntry wifiEntry = mNetworkDetailsTracker.getWifiEntry();
+        return WifiDialog2.createModal(getActivity(), this, wifiEntry,
+                WifiConfigUiBase2.MODE_MODIFY);
     }
 
     @Override
@@ -177,8 +178,8 @@
     }
 
     @Override
-    public void onSubmit(WifiDialog dialog) {
-        for (WifiDialog.WifiDialogListener listener : mWifiDialogListeners) {
+    public void onSubmit(WifiDialog2 dialog) {
+        for (WifiDialog2.WifiDialog2Listener listener : mWifiDialogListeners) {
             listener.onSubmit(dialog);
         }
     }
diff --git a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
index bca4de1..db4cb6c 100644
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
@@ -17,6 +17,7 @@
 package com.android.settings.wifi.details2;
 
 import android.content.Context;
+import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
 
 import androidx.annotation.VisibleForTesting;
@@ -26,7 +27,7 @@
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.wifi.WifiDialog;
+import com.android.settings.wifi.WifiDialog2;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.wifitrackerlib.WifiEntry;
 
@@ -35,7 +36,7 @@
  * or not
  */
 public class WifiPrivacyPreferenceController2 extends BasePreferenceController implements
-        Preference.OnPreferenceChangeListener, WifiDialog.WifiDialogListener {
+        Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
 
     private static final String KEY_WIFI_PRIVACY = "privacy";
     private WifiManager mWifiManager;
@@ -134,18 +135,29 @@
     }
 
     @Override
-    public void onSubmit(WifiDialog dialog) {
-        // TODO(b/143326832): Create WifiDialog2 and let it work for WifiEntry.
-        //if (dialog.getController() != null) {
-        //    final WifiConfiguration newConfig = dialog.getController().getConfig();
-        //    if (newConfig == null || mWifiConfiguration == null) {
-        //        return;
-        //    }
-        //
-        //    if (newConfig.macRandomizationSetting != mWifiConfiguration.macRandomizationSetting) {
-        //        mWifiConfiguration = newConfig;
-       //        onPreferenceChange(mPreference, String.valueOf(newConfig.macRandomizationSetting));
-        //    }
-        //}
+    public void onSubmit(WifiDialog2 dialog) {
+        if (dialog.getController() != null) {
+            final WifiConfiguration newConfig = dialog.getController().getConfig();
+            if (newConfig == null || !mWifiEntry.isSaved()) {
+                return;
+            }
+
+            if (newConfig.macRandomizationSetting
+                        != mWifiEntry.getWifiConfiguration().macRandomizationSetting) {
+                mWifiEntry.setPrivacy(getWifiEntryPrivacy(newConfig));
+                onPreferenceChange(mPreference, String.valueOf(newConfig.macRandomizationSetting));
+            }
+        }
+    }
+
+    private int getWifiEntryPrivacy(WifiConfiguration wifiConfiguration) {
+        switch (wifiConfiguration.macRandomizationSetting) {
+            case WifiConfiguration.RANDOMIZATION_NONE:
+                return WifiEntry.PRIVACY_DEVICE_MAC;
+            case WifiConfiguration.RANDOMIZATION_PERSISTENT:
+                return WifiEntry.PRIVACY_RANDOMIZED_MAC;
+            default:
+                return WifiEntry.PRIVACY_UNKNOWN;
+        }
     }
 }
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/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/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index 03e9b6f..80ab42c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -210,11 +210,8 @@
     }
 
     @Test
-    public void onStop_isAvailable_unregisterCallback() {
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
-                SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
-                .thenReturn("true".getBytes());
+    public void onStop_isRegisterCallback_unregisterCallback() {
+        mController.mIsRegisterCallback = true;
 
         mController.onStop();
 
@@ -234,9 +231,8 @@
     }
 
     @Test
-    public void onStop_notAvailable_unregisterCallback() {
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
-                .thenReturn("false".getBytes());
+    public void onStop_notRegisterCallback_unregisterCallback() {
+        mController.mIsRegisterCallback = false;
 
         mController.onStop();
 
@@ -245,11 +241,7 @@
     }
 
     @Test
-    public void onDestroy_isAvailable_recycleBitmap() {
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
-                SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, "true", true);
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
-                .thenReturn("true".getBytes());
+    public void onDestroy_recycleBitmap() {
         mController.mIconCache.put(ICON_URI, mBitmap);
 
         mController.onDestroy();
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/ConfigureWifiEntryFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java
new file mode 100644
index 0000000..1f0c312
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wifi;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+import com.android.settings.testutils.shadow.ShadowConnectivityManager;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
+
+// TODO(b/70983952): Can't test because b/146802959, should remove @Ignore tag after it's fixed.
+@Ignore
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowConnectivityManager.class)
+public class ConfigureWifiEntryFragmentTest {
+
+    private static final String KEY_SSID = "key_ssid";
+    private static final String KEY_SECURITY = "key_security";
+
+    private ConfigureWifiEntryFragment mConfigureWifiEntryFragment;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        Bundle bundle = new Bundle();
+
+        bundle.putString(KEY_SSID, "Test AP");
+        bundle.putInt(KEY_SECURITY, 1 /* WEP */);
+        mConfigureWifiEntryFragment = spy(new ConfigureWifiEntryFragment());
+        mConfigureWifiEntryFragment.setArguments(bundle);
+        FragmentController.setupFragment(mConfigureWifiEntryFragment);
+    }
+
+    @Test
+    public void getMetricsCategory_shouldReturnConfigureNetwork() {
+        assertThat(mConfigureWifiEntryFragment.getMetricsCategory()).isEqualTo(
+                SettingsEnums.SETTINGS_WIFI_CONFIGURE_NETWORK);
+    }
+
+    @Test
+    public void getMode_shouldBeModeConnected() {
+        assertThat(mConfigureWifiEntryFragment.getMode()).isEqualTo(
+                WifiConfigUiBase.MODE_CONNECT);
+    }
+
+    @Test
+    public void launchFragment_shouldShowSubmitButton() {
+        assertThat(mConfigureWifiEntryFragment.getSubmitButton()).isNotNull();
+    }
+
+    @Test
+    public void launchFragment_shouldShowCancelButton() {
+        assertThat(mConfigureWifiEntryFragment.getCancelButton()).isNotNull();
+    }
+
+    @Test
+    public void onClickSubmitButton_shouldHandleSubmitAction() {
+        mConfigureWifiEntryFragment.getSubmitButton().performClick();
+
+        verify(mConfigureWifiEntryFragment).handleSubmitAction();
+    }
+
+    @Test
+    public void onClickCancelButton_shouldHandleCancelAction() {
+        mConfigureWifiEntryFragment.getCancelButton().performClick();
+
+        verify(mConfigureWifiEntryFragment).handleCancelAction();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
index ccaca02..a79ffd8 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
@@ -43,7 +43,7 @@
 import com.android.settings.R;
 import com.android.settings.testutils.shadow.ShadowConnectivityManager;
 import com.android.settings.wifi.details.WifiPrivacyPreferenceController;
-import com.android.settingslib.wifi.AccessPoint;
+import com.android.wifitrackerlib.WifiEntry;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -65,7 +65,7 @@
     @Mock
     private Context mContext;
     @Mock
-    private AccessPoint mAccessPoint;
+    private WifiEntry mWifiEntry;
     @Mock
     private KeyStore mKeyStore;
     private View mView;
@@ -89,19 +89,19 @@
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
         when(mConfigUiBase.getContext()).thenReturn(mContext);
-        when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_PSK);
+        when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_PSK);
         mView = LayoutInflater.from(mContext).inflate(R.layout.wifi_dialog, null);
         final Spinner ipSettingsSpinner = mView.findViewById(R.id.ip_settings);
         mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
         ipSettingsSpinner.setSelection(DHCP);
 
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
                 WifiConfigUiBase2.MODE_CONNECT);
     }
 
     @Test
     public void ssidExceeds32Bytes_shouldShowSsidTooLongWarning() {
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
                 WifiConfigUiBase2.MODE_CONNECT);
         final TextView ssid = mView.findViewById(R.id.ssid);
         assertThat(ssid).isNotNull();
@@ -114,7 +114,7 @@
 
     @Test
     public void ssidShorterThan32Bytes_shouldNotShowSsidTooLongWarning() {
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
                 WifiConfigUiBase2.MODE_CONNECT);
 
         final TextView ssid = mView.findViewById(R.id.ssid);
@@ -177,12 +177,12 @@
         final TextView password = mView.findViewById(R.id.password);
         assertThat(password).isNotNull();
         password.setText("");
-        when(mAccessPoint.isSaved()).thenReturn(true);
+        when(mWifiEntry.isSaved()).thenReturn(true);
         assertThat(mController.isSubmittable()).isTrue();
     }
 
     @Test
-    public void isSubmittable_nullAccessPoint_noException() {
+    public void isSubmittable_nullWifiEntry_noException() {
         mController = new TestWifiConfigController2(mConfigUiBase, mView, null,
                 WifiConfigUiBase2.MODE_CONNECT);
         mController.isSubmittable();
@@ -197,11 +197,11 @@
         final Spinner securitySpinner = mView.findViewById(R.id.security);
         assertThat(password).isNotNull();
         assertThat(securitySpinner).isNotNull();
-        when(mAccessPoint.isSaved()).thenReturn(true);
+        when(mWifiEntry.isSaved()).thenReturn(true);
 
         // Change it from EAP to PSK
-        mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_EAP, 0);
-        mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_PSK, 0);
+        mController.onItemSelected(securitySpinner, null, WifiEntry.SECURITY_EAP, 0);
+        mController.onItemSelected(securitySpinner, null, WifiEntry.SECURITY_PSK, 0);
         password.setText(GOOD_PSK);
         ssid.setText(GOOD_SSID);
 
@@ -210,8 +210,8 @@
 
     @Test
     public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() {
-        when(mAccessPoint.isSaved()).thenReturn(true);
-        mController.mAccessPointSecurity = AccessPoint.SECURITY_EAP;
+        when(mWifiEntry.isSaved()).thenReturn(true);
+        mController.mWifiEntrySecurity = WifiEntry.SECURITY_EAP;
         mView.findViewById(R.id.l_ca_cert).setVisibility(View.GONE);
 
         assertThat(mController.isSubmittable()).isTrue();
@@ -219,7 +219,7 @@
 
     @Test
     public void getSignalString_notReachable_shouldHaveNoSignalString() {
-        when(mAccessPoint.isReachable()).thenReturn(false);
+        when(mWifiEntry.getLevel()).thenReturn(WifiEntry.WIFI_LEVEL_UNREACHABLE);
 
         assertThat(mController.getSignalString()).isNull();
     }
@@ -227,11 +227,11 @@
     @Test
     public void loadCertificates_keyStoreListFail_shouldNotCrash() {
         // Set up
-        when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
+        when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
         when(mKeyStore.list(anyString()))
             .thenThrow(new ServiceSpecificException(-1, "permission error"));
 
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
               WifiConfigUiBase2.MODE_CONNECT);
 
         // Verify that the EAP method menu is visible.
@@ -241,10 +241,10 @@
 
     @Test
     public void ssidGetFocus_addNewNetwork_shouldReturnTrue() {
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
                 WifiConfigUiBase2.MODE_CONNECT);
         final TextView ssid = mView.findViewById(R.id.ssid);
-        // Verify ssid text get focus when add new network (accesspoint is null)
+        // Verify ssid text get focus when add new network (wifiEntry is null)
         assertThat(ssid.isFocused()).isTrue();
     }
 
@@ -270,7 +270,7 @@
         View hiddenField = mView.findViewById(R.id.hidden_settings_field);
         assertThat(hiddenField.getVisibility()).isEqualTo(View.GONE);
 
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
                 WifiConfigUiBase2.MODE_CONNECT);
         assertThat(hiddenField.getVisibility()).isEqualTo(View.VISIBLE);
     }
@@ -302,7 +302,7 @@
         when(wifiManager.isWpa3SuiteBSupported()).thenReturn(suitebVisible);
         when(wifiManager.isEnhancedOpenSupported()).thenReturn(oweVisible);
 
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
                 WifiConfigUiBase2.MODE_MODIFY, wifiManager);
 
         final Spinner securitySpinner = mView.findViewById(R.id.security);
@@ -346,14 +346,14 @@
     public class TestWifiConfigController2 extends WifiConfigController2 {
 
         private TestWifiConfigController2(
-                WifiConfigUiBase2 parent, View view, AccessPoint accessPoint, int mode) {
-            super(parent, view, accessPoint, mode);
+                WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry, int mode) {
+            super(parent, view, wifiEntry, mode);
         }
 
         private TestWifiConfigController2(
-                WifiConfigUiBase2 parent, View view, AccessPoint accessPoint, int mode,
+                WifiConfigUiBase2 parent, View view, WifiEntry wifiEntry, int mode,
                     WifiManager wifiManager) {
-            super(parent, view, accessPoint, mode, wifiManager);
+            super(parent, view, wifiEntry, mode, wifiManager);
         }
 
         @Override
@@ -389,11 +389,11 @@
     }
 
     private void checkSavedMacRandomizedValue(int macRandomizedValue) {
-        when(mAccessPoint.isSaved()).thenReturn(true);
+        when(mWifiEntry.isSaved()).thenReturn(true);
         final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
-        when(mAccessPoint.getConfig()).thenReturn(mockWifiConfig);
+        when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
         mockWifiConfig.macRandomizationSetting = macRandomizedValue;
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
                 WifiConfigUiBase2.MODE_CONNECT);
 
         final Spinner privacySetting = mView.findViewById(R.id.privacy_settings);
@@ -467,7 +467,7 @@
     public void selectSecurity_wpa3Eap192bit_eapMethodTls() {
         final WifiManager wifiManager = mock(WifiManager.class);
         when(wifiManager.isWpa3SuiteBSupported()).thenReturn(true);
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* accessPoint */,
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, null /* wifiEntry */,
                 WifiConfigUiBase2.MODE_MODIFY, wifiManager);
         final Spinner securitySpinner = mView.findViewById(R.id.security);
         final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
@@ -475,7 +475,7 @@
         final int securityCount = mController.mSecurityInPosition.length;
         for (int i = 0; i < securityCount; i++) {
             if (mController.mSecurityInPosition[i] != null
-                    && mController.mSecurityInPosition[i] == AccessPoint.SECURITY_EAP_SUITE_B) {
+                    && mController.mSecurityInPosition[i] == WifiEntry.SECURITY_EAP_SUITE_B) {
                 wpa3Eap192bitPosition = i;
             }
         }
@@ -501,15 +501,15 @@
     }
 
     @Test
-    public void selectEapMethod_savedAccessPoint_shouldGetCorrectPosition() {
-        when(mAccessPoint.isSaved()).thenReturn(true);
-        when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
+    public void selectEapMethod_savedWifiEntry_shouldGetCorrectPosition() {
+        when(mWifiEntry.isSaved()).thenReturn(true);
+        when(mWifiEntry.getSecurity()).thenReturn(WifiEntry.SECURITY_EAP);
         final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
         final WifiEnterpriseConfig mockWifiEnterpriseConfig = mock(WifiEnterpriseConfig.class);
         when(mockWifiEnterpriseConfig.getEapMethod()).thenReturn(Eap.PEAP);
         mockWifiConfig.enterpriseConfig = mockWifiEnterpriseConfig;
-        when(mAccessPoint.getConfig()).thenReturn(mockWifiConfig);
-        mController = new TestWifiConfigController2(mConfigUiBase, mView, mAccessPoint,
+        when(mWifiEntry.getWifiConfiguration()).thenReturn(mockWifiConfig);
+        mController = new TestWifiConfigController2(mConfigUiBase, mView, mWifiEntry,
                 WifiConfigUiBase2.MODE_MODIFY);
         final Spinner eapMethodSpinner = mView.findViewById(R.id.method);
         final Spinner phase2Spinner = mView.findViewById(R.id.phase2);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index e1202ae..bf50742 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -549,4 +549,13 @@
         assertThat(advButton.getContentDescription()).isEqualTo(
                 mContext.getString(R.string.wifi_advanced_toggle_description));
     }
+
+    @Test
+    public void getVisibility_whenAdvancedOptionClicked_shouldBeGone() {
+        final CheckBox advButton = mView.findViewById(R.id.wifi_advanced_togglebox);
+
+        advButton.performClick();
+
+        assertThat(advButton.getVisibility()).isEqualTo(View.GONE);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiDialog2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiDialog2Test.java
index a283591..f1ab438 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiDialog2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiDialog2Test.java
@@ -23,7 +23,7 @@
 import com.android.settings.R;
 import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
 import com.android.settings.wifi.WifiDialog2.WifiDialog2Listener;
-import com.android.settingslib.wifi.AccessPoint;
+import com.android.wifitrackerlib.WifiEntry;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -37,7 +37,7 @@
 @RunWith(RobolectricTestRunner.class)
 @Config(shadows = ShadowEntityHeaderController.class)
 public class WifiDialog2Test {
-    @Mock private AccessPoint mMockAccessPoint;
+    @Mock private WifiEntry mMockWifiEntry;
 
     private Context mContext = RuntimeEnvironment.application;
 
@@ -51,9 +51,9 @@
     @Test
     public void createModal_usesDefaultTheme() {
         WifiDialog2 modal = WifiDialog2
-                .createModal(mContext, mListener, mMockAccessPoint, WifiConfigUiBase2.MODE_CONNECT);
+                .createModal(mContext, mListener, mMockWifiEntry, WifiConfigUiBase2.MODE_CONNECT);
 
-        WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockAccessPoint,
+        WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockWifiEntry,
                 WifiConfigUiBase2.MODE_CONNECT, 0 /* style */, false /* hideSubmitButton */);
         assertThat(modal.getContext().getThemeResId())
                 .isEqualTo(wifiDialog2.getContext().getThemeResId());
@@ -61,10 +61,10 @@
 
     @Test
     public void createModal_whenSetTheme_shouldBeCustomizedTheme() {
-        WifiDialog2 modal = WifiDialog2.createModal(mContext, mListener, mMockAccessPoint,
+        WifiDialog2 modal = WifiDialog2.createModal(mContext, mListener, mMockWifiEntry,
                 WifiConfigUiBase2.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light);
 
-        WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockAccessPoint,
+        WifiDialog2 wifiDialog2 = new WifiDialog2(mContext, mListener, mMockWifiEntry,
                 WifiConfigUiBase2.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light,
                         false /* hideSubmitButton */);
         assertThat(modal.getContext().getThemeResId())
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index d523866..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;
@@ -36,6 +37,8 @@
 import android.os.PowerManager;
 import android.os.UserManager;
 import android.provider.Settings;
+import android.view.ContextMenu;
+import android.view.View;
 
 import androidx.fragment.app.FragmentActivity;
 import androidx.preference.Preference;
@@ -47,9 +50,12 @@
 import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
 import com.android.settings.testutils.shadow.ShadowFragment;
 import com.android.settingslib.search.SearchIndexableRaw;
+import com.android.settingslib.wifi.LongPressWifiEntryPreference;
+import com.android.wifitrackerlib.WifiEntry;
 import com.android.wifitrackerlib.WifiPickerTracker;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -249,26 +255,35 @@
         assertThat(adapter.hasStableIds()).isTrue();
     }
 
-// TODO(b/70983952): Add test for context menu
-//    @Test
-//    public void onCreateContextMenu_shouldHaveForgetMenuForConnectedAccessPreference() {
-//        final FragmentActivity mockActivity = mock(FragmentActivity.class);
-//        when(mockActivity.getApplicationContext()).thenReturn(mContext);
-//        when(mWifiSettings2.getActivity()).thenReturn(mockActivity);
-//
-//        final AccessPoint accessPoint = mock(AccessPoint.class);
-//        when(accessPoint.isConnectable()).thenReturn(false);
-//        when(accessPoint.isSaved()).thenReturn(true);
-//        when(accessPoint.isActive()).thenReturn(true);
-//
-//        final ConnectedAccessPointPreference connectedPreference =
-//                mWifiSettings2.createConnectedAccessPointPreference(accessPoint, mContext);
-//        final View view = mock(View.class);
-//        when(view.getTag()).thenReturn(connectedPreference);
-//
-//        final ContextMenu menu = mock(ContextMenu.class);
-//        mWifiSettings2.onCreateContextMenu(menu, view, null /* info */);
-//
-//        verify(menu).add(anyInt(), eq(WifiSettings.MENU_ID_FORGET), anyInt(), anyInt());
-//    }
+    //TODO(b/70983952): Remove @Ignore when WifiEntry API is constructed.
+    @Test
+    @Ignore
+    public void onCreateContextMenu_shouldHaveForgetAndDisconnectMenuForConnectedWifiEntry() {
+        final FragmentActivity activity = mock(FragmentActivity.class);
+        when(activity.getApplicationContext()).thenReturn(mContext);
+        when(mWifiSettings2.getActivity()).thenReturn(activity);
+
+        final WifiEntry wifiEntry = mock(WifiEntry.class);
+        when(wifiEntry.canDisconnect()).thenReturn(true);
+        when(wifiEntry.isSaved()).thenReturn(true);
+        when(wifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
+
+        final LongPressWifiEntryPreference connectedWifiEntryPreference =
+                mWifiSettings2.createLongPressWifiEntryPreference(wifiEntry);
+        final View view = mock(View.class);
+        when(view.getTag()).thenReturn(connectedWifiEntryPreference);
+
+        final ContextMenu menu = mock(ContextMenu.class);
+        mWifiSettings2.onCreateContextMenu(menu, view, null /* info */);
+
+        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);
     }
 }