Merge "Remove logic to manually search inactive pSIM."
diff --git a/Android.bp b/Android.bp
index d21a430..e1c002d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -54,6 +54,7 @@
 platform_compat_config {
     name: "settings-platform-compat-config",
     src: ":Settings-core",
+    system_ext_specific: true,
 }
 
 android_app {
@@ -62,7 +63,10 @@
     certificate: "platform",
     system_ext_specific: true,
     privileged: true,
-    required: ["privapp_whitelist_com.android.settings"],
+    required: [
+        "privapp_whitelist_com.android.settings",
+        "settings-platform-compat-config",
+    ],
     static_libs: ["Settings-core"],
     resource_dirs: [],
     optimize: {
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9478578..9bb810d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -39,6 +39,7 @@
     <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
     <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
     <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
     <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>
diff --git a/res/layout/preference_list_fragment.xml b/res/layout/preference_list_fragment.xml
index c673bc3..7225df1 100644
--- a/res/layout/preference_list_fragment.xml
+++ b/res/layout/preference_list_fragment.xml
@@ -66,6 +66,7 @@
             android:id="@+id/tabs"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layoutDirection="ltr"
             app:tabMaxWidth="0dp"
             app:tabGravity="fill"
             app:tabMode="fixed"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b16ab2c..6dc4a4d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2089,7 +2089,8 @@
     <string name="wifi_dpp_wifi_password">Wi\u2011Fi password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
     <!-- Hint for Wi-Fi hotspot password [CHAR LIMIT=50]  -->
     <string name="wifi_dpp_hotspot_password">Hotspot password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
-    <!-- Label for specifying if a Wi-Fi network supports auto connection [CHAR LIMIT=50]  -->
+    <!-- Label for a Wi-Fi network to specify if the device will auto connect to the Wi-Fi network
+         when signal of the Wi-Fi network is reachable [CHAR LIMIT=50]  -->
     <string name="wifi_auto_connect_title">Auto\u2011connect</string>
     <!-- Hint for Wi-Fi Auto-connect [CHAR LIMIT=NONE]  -->
     <string name="wifi_auto_connect_summary">Allow connection to this network when in range</string>
@@ -4772,6 +4773,8 @@
     <string name="accessibility_screen_magnification_title">Magnify</string>
     <!-- Title for the accessibility preference screen to edit magnification area. [CHAR LIMIT=35] -->
     <string name="accessibility_magnification_mode_title">Magnification area</string>
+    <!-- Title for the accessibility preference screen to edit magnification enable mode. [CHAR LIMIT=35] -->
+    <string name="accessibility_magnification_enable_mode_title">Magnification enable</string>
     <!-- Message for the accessibility preference screen to edit magnification area dialog. [CHAR LIMIT=none] -->
     <string name="accessibility_magnification_area_settings_message">Choose the magnification area(s) you want to use when magnifying the screen</string>
     <!-- Summary for the accessibility preference screen to edit full screen. [CHAR LIMIT=none] -->
@@ -4784,10 +4787,6 @@
     <string name="accessibility_magnification_area_settings_full_screen">Magnify entire screen</string>
     <!-- Message for the accessibility preference screen to edit part of screen. [CHAR LIMIT=none] -->
     <string name="accessibility_magnification_area_settings_window_screen">Magnify part of screen</string>
-    <!-- Title for the accessibility preference screen to show move controller. [CHAR LIMIT=35] -->
-    <string name="accessibility_magnification_window_control_switch_title">Show move controller</string>
-    <!-- Summary for the accessibility preference screen to show move controller. [CHAR LIMIT=none] -->
-    <string name="accessibility_magnification_window_control_switch_summary">Show a joystick-like controller to move the magnification area</string>
     <!-- Title for the accessibility preference screen to enable screen magnification settings. [CHAR LIMIT=35] -->
     <string name="accessibility_magnification_service_settings_title">Magnification settings</string>
     <!-- Title for the accessibility preference screen to enable triple-tap gesture screen magnification. [CHAR LIMIT=35] -->
@@ -9469,7 +9468,7 @@
     <!-- Description of allowing overlay setting [CHAR LIMIT=NONE] -->
     <string name="allow_overlay_description">Allow this app to display on top of other apps you\u2019re using. It may interfere with your use of those apps or change the way they seem to appear or behave.</string>
 
-    <!-- Manager External Storage settings title [CHAR LIMIT=30] -->
+    <!-- Manager External Storage settings title [CHAR LIMIT=40] -->
     <string name="manage_external_storage_title">All files access</string>
     <!-- Label for a setting which controls whether an app can manage external storage [CHAR LIMIT=45] -->
     <string name="permit_manage_external_storage">Allow access to manage all files</string>
diff --git a/res/xml/accessibility_magnification_service_settings.xml b/res/xml/accessibility_magnification_service_settings.xml
index d67fc66..74765b2 100644
--- a/res/xml/accessibility_magnification_service_settings.xml
+++ b/res/xml/accessibility_magnification_service_settings.xml
@@ -28,9 +28,11 @@
         settings:controller="com.android.settings.accessibility.MagnificationModePreferenceController" />
 
     <SwitchPreference
-        android:key="magnification_window_control_switch"
+        android:key="magnification_enable"
         android:persistent="false"
-        android:summary="@string/accessibility_magnification_window_control_switch_summary"
-        android:title="@string/accessibility_magnification_window_control_switch_title"
-        settings:controller="com.android.settings.accessibility.MagnificationWindowControlPreferenceController" />
+        android:title="@string/accessibility_magnification_enable_mode_title"
+        android:summaryOn="@string/accessibility_magnification_area_settings_full_screen_summary"
+        android:summaryOff="@string/accessibility_magnification_area_settings_window_screen_summary"
+        settings:controller="com.android.settings.accessibility.MagnificationEnablePreferenceController" />
+
 </PreferenceScreen>
diff --git a/res/xml/all_tether_prefs.xml b/res/xml/all_tether_prefs.xml
new file mode 100644
index 0000000..c541fe4
--- /dev/null
+++ b/res/xml/all_tether_prefs.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2020 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="tether_prefs_screen"
+    android:title="@string/tether_settings_title_all">
+
+    <PreferenceCategory
+        android:key="wifi_tether_settings_group"
+        android:title="@string/wifi_hotspot_checkbox_text"
+        settings:searchable="false">
+        <com.android.settings.wifi.tether.WifiTetherSsidPreference
+            android:key="wifi_tether_network_name"
+            android:title="@string/wifi_hotspot_name_title"
+            android:summary="@string/summary_placeholder"/>
+
+        <com.android.settings.widget.ValidatedEditTextPreference
+            android:key="wifi_tether_network_password"
+            android:persistent="false"
+            android:title="@string/wifi_hotspot_password_title"/>
+
+        <SwitchPreference
+            android:key="wifi_tether_auto_turn_off"
+            android:title="@string/wifi_hotspot_auto_off_title"
+            android:summary="@string/wifi_hotspot_auto_off_summary"/>
+
+        <ListPreference
+            android:key="wifi_tether_security"
+            android:title="@string/wifi_security"
+            android:summary="@string/summary_placeholder"
+            android:entries="@array/wifi_tether_security"
+            android:entryValues="@array/wifi_tether_security_values"/>
+
+        <ListPreference
+            android:key="wifi_tether_network_ap_band"
+            android:title="@string/wifi_hotspot_ap_band_title"/>
+    </PreferenceCategory>
+
+    <Preference
+        android:key="disabled_on_data_saver"
+        android:summary="@string/tether_settings_disabled_on_data_saver"
+        android:selectable="false"
+        settings:allowDividerAbove="true" />
+
+    <com.android.settingslib.widget.FooterPreference
+        android:key="tether_prefs_footer"
+        android:title="@string/tethering_footer_info"
+        android:selectable="false"
+        settings:searchable="false"/>
+</PreferenceScreen>
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 1859a1e..41d101b 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -51,10 +51,12 @@
     <Preference
         android:key="install_credentials"
         android:title="@string/wifi_install_credentials">
-        <intent android:action="android.credentials.INSTALL_AS_USER"
-                android:targetPackage="com.android.certinstaller"
-                android:targetClass="com.android.certinstaller.CertInstallerMain">
-            <extra android:name="install_as_uid" android:value="1010" />
+        <intent
+            android:action="android.credentials.INSTALL"
+            android:targetPackage="com.android.certinstaller"
+            android:targetClass="com.android.certinstaller.CertInstallerMain">
+            <!-- Same value as CERTIFICATE_USAGE_WIFI in keystore/java/android/security/Credentials.java -->
+            <extra android:name="certificate_install_usage" android:value="wifi"/>
         </intent>
     </Preference>
 
diff --git a/src/com/android/settings/AllInOneTetherSettings.java b/src/com/android/settings/AllInOneTetherSettings.java
new file mode 100644
index 0000000..d6366b2
--- /dev/null
+++ b/src/com/android/settings/AllInOneTetherSettings.java
@@ -0,0 +1,399 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import static android.net.ConnectivityManager.ACTION_TETHER_STATE_CHANGED;
+import static android.net.ConnectivityManager.TETHERING_WIFI;
+import static android.net.wifi.WifiManager.WIFI_AP_STATE_CHANGED_ACTION;
+
+import static com.android.settings.network.WifiTetherDisablePreferenceController
+        .KEY_ENABLE_WIFI_TETHERING;
+
+import android.app.settings.SettingsEnums;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.net.ConnectivityManager;
+import android.net.wifi.SoftApConfiguration;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.UserManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+
+import com.android.settings.dashboard.RestrictedDashboardFragment;
+import com.android.settings.datausage.DataSaverBackend;
+import com.android.settings.network.TetherEnabler;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.wifi.tether.WifiTetherApBandPreferenceController;
+import com.android.settings.wifi.tether.WifiTetherAutoOffPreferenceController;
+import com.android.settings.wifi.tether.WifiTetherBasePreferenceController;
+import com.android.settings.wifi.tether.WifiTetherPasswordPreferenceController;
+import com.android.settings.wifi.tether.WifiTetherSSIDPreferenceController;
+import com.android.settings.wifi.tether.WifiTetherSecurityPreferenceController;
+import com.android.settingslib.TetherUtil;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Displays preferences for Tethering.
+ * TODO(b/147322704): Use TetherEnabler in this fragment to manage tethering switch on/off.
+ * TODO(b/147323306): Add tether option preferences into this fragment after controllers created.
+ */
+@SearchIndexable
+public final class AllInOneTetherSettings extends RestrictedDashboardFragment
+        implements DataSaverBackend.Listener,
+        WifiTetherBasePreferenceController.OnTetherConfigUpdateListener,
+        SharedPreferences.OnSharedPreferenceChangeListener {
+
+    @VisibleForTesting
+    static final String KEY_TETHER_PREFS_SCREEN = "tether_prefs_screen";
+    @VisibleForTesting
+    static final String KEY_WIFI_TETHER_NETWORK_NAME = "wifi_tether_network_name";
+    @VisibleForTesting
+    static final String KEY_WIFI_TETHER_NETWORK_PASSWORD = "wifi_tether_network_password";
+    @VisibleForTesting
+    static final String KEY_WIFI_TETHER_AUTO_OFF = "wifi_tether_auto_turn_off";
+    @VisibleForTesting
+    static final String KEY_WIFI_TETHER_NETWORK_AP_BAND = "wifi_tether_network_ap_band";
+
+    private static final String KEY_WIFI_TETHER_GROUP = "wifi_tether_settings_group";
+    private static final String KEY_DATA_SAVER_FOOTER = "disabled_on_data_saver";
+    private static final int EXPANDED_CHILD_COUNT_WITH_SECURITY_NON = 2;
+    private static final int EXPANDED_CHILD_COUNT_DEFAULT = 3;
+    private static final String TAG = "AllInOneTetherSettings";
+
+    private boolean mUnavailable;
+
+    private DataSaverBackend mDataSaverBackend;
+    private boolean mDataSaverEnabled;
+    private Preference mDataSaverFooter;
+
+    private WifiManager mWifiManager;
+    private boolean mRestartWifiApAfterConfigChange;
+
+    private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
+    private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
+    private WifiTetherApBandPreferenceController mApBandPreferenceController;
+    private WifiTetherSecurityPreferenceController mSecurityPreferenceController;
+    private PreferenceGroup mWifiTetherGroup;
+    private SharedPreferences mSharedPreferences;
+    private ConnectivityManager mConnectivityManager;
+    private boolean mWifiTetherChosen;
+
+    private final BroadcastReceiver mTetherChangeReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context content, Intent intent) {
+            String action = intent.getAction();
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "updating display config due to receiving broadcast action " + action);
+            }
+            updateDisplayWithNewConfig();
+            if (TextUtils.equals(action, ACTION_TETHER_STATE_CHANGED)) {
+                if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED
+                        && mRestartWifiApAfterConfigChange) {
+                    mRestartWifiApAfterConfigChange = false;
+                    startTether();
+                }
+            } else if (TextUtils.equals(action, WIFI_AP_STATE_CHANGED_ACTION)) {
+                int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_AP_STATE, 0);
+                if (state == WifiManager.WIFI_AP_STATE_DISABLED
+                        && mRestartWifiApAfterConfigChange) {
+                    mRestartWifiApAfterConfigChange = false;
+                    startTether();
+                }
+            }
+        }
+    };
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.TETHER;
+    }
+
+    public AllInOneTetherSettings() {
+        super(UserManager.DISALLOW_CONFIG_TETHERING);
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        mConnectivityManager =
+                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mSharedPreferences =
+                context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
+
+        mSSIDPreferenceController = use(WifiTetherSSIDPreferenceController.class);
+        mSecurityPreferenceController = use(WifiTetherSecurityPreferenceController.class);
+        mPasswordPreferenceController = use(WifiTetherPasswordPreferenceController.class);
+        mApBandPreferenceController = use(WifiTetherApBandPreferenceController.class);
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        mDataSaverBackend = new DataSaverBackend(getContext());
+        mDataSaverEnabled = mDataSaverBackend.isDataSaverEnabled();
+        mDataSaverFooter = findPreference(KEY_DATA_SAVER_FOOTER);
+        mWifiTetherGroup = findPreference(KEY_WIFI_TETHER_GROUP);
+
+        setIfOnlyAvailableForAdmins(true);
+        if (isUiRestricted()) {
+            mUnavailable = true;
+            return;
+        }
+
+        mDataSaverBackend.addListener(this);
+
+        // Set initial state based on Data Saver mode.
+        onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled());
+
+        // Set initial state based on SharedPreferences value.
+        onSharedPreferenceChanged(mSharedPreferences, KEY_ENABLE_WIFI_TETHERING);
+
+        // TODO(b/147325229): Hide advanced settings like security and ap band.
+    }
+
+    @Override
+    public void onStart() {
+        super.onStart();
+
+        if (mUnavailable) {
+            if (!isUiRestrictedByOnlyAdmin()) {
+                getEmptyTextView().setText(R.string.tethering_settings_not_available);
+            }
+            getPreferenceScreen().removeAll();
+            return;
+        }
+        final Context context = getContext();
+        if (context != null) {
+            IntentFilter filter = new IntentFilter(ACTION_TETHER_STATE_CHANGED);
+            filter.addAction(WIFI_AP_STATE_CHANGED_ACTION);
+            context.registerReceiver(mTetherChangeReceiver, filter);
+        }
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+        final Context context = getContext();
+        if (context != null) {
+            context.unregisterReceiver(mTetherChangeReceiver);
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        mDataSaverBackend.remListener(this);
+        super.onDestroy();
+    }
+
+    @Override
+    public void onDataSaverChanged(boolean isDataSaving) {
+        mDataSaverEnabled = isDataSaving;
+        mDataSaverFooter.setVisible(mDataSaverEnabled);
+    }
+
+    @Override
+    public void onWhitelistStatusChanged(int uid, boolean isWhitelisted) {
+        // Do nothing
+    }
+
+    @Override
+    public void onBlacklistStatusChanged(int uid, boolean isBlacklisted) {
+        // Do nothing
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, this);
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+            WifiTetherBasePreferenceController.OnTetherConfigUpdateListener listener) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(
+                new WifiTetherSSIDPreferenceController(context, listener));
+        controllers.add(
+                new WifiTetherPasswordPreferenceController(context, listener));
+        controllers.add(
+                new WifiTetherApBandPreferenceController(context, listener));
+        controllers.add(
+                new WifiTetherSecurityPreferenceController(context, listener));
+        controllers.add(
+                new WifiTetherAutoOffPreferenceController(context, KEY_WIFI_TETHER_AUTO_OFF));
+
+        return controllers;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.all_tether_prefs;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public void onExpandButtonClick() {
+        super.onExpandButtonClick();
+        // TODO(b/147325229): Display hidden advanced settings like security and ap band.
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_tether;
+    }
+
+    @Override
+    public void onTetherConfigUpdated(AbstractPreferenceController controller) {
+        final SoftApConfiguration config = buildNewConfig();
+        mPasswordPreferenceController.updateVisibility(config.getSecurityType());
+        mWifiManager.setSoftApConfiguration(config);
+
+        if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED) {
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "Wifi AP config changed while enabled, stop and restart");
+            }
+            mRestartWifiApAfterConfigChange = true;
+            // TODO(b/147322704): Use TethetEnabler to stop tethering.
+            mConnectivityManager.stopTethering(TETHERING_WIFI);
+        }
+
+        if (controller instanceof WifiTetherSecurityPreferenceController) {
+            reConfigInitialExpandedChildCount();
+        }
+    }
+
+    private SoftApConfiguration buildNewConfig() {
+        final SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
+        final int securityType = mSecurityPreferenceController.getSecurityType();
+        configBuilder.setSsid(mSSIDPreferenceController.getSSID());
+        if (securityType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK) {
+            configBuilder.setPassphrase(
+                    mPasswordPreferenceController.getPasswordValidated(securityType),
+                    SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
+        }
+        configBuilder.setBand(mApBandPreferenceController.getBandIndex());
+        return configBuilder.build();
+    }
+
+    private void updateDisplayWithNewConfig() {
+        mSSIDPreferenceController.updateDisplay();
+        mSecurityPreferenceController.updateDisplay();
+        mPasswordPreferenceController.updateDisplay();
+        mApBandPreferenceController.updateDisplay();
+    }
+
+    @Override
+    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+        if (TextUtils.equals(key, KEY_ENABLE_WIFI_TETHERING)) {
+            mWifiTetherChosen = sharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true);
+            mWifiTetherGroup.setVisible(mWifiTetherChosen);
+            reConfigInitialExpandedChildCount();
+        }
+    }
+
+    private void startTether() {
+        // TODO(b/147322704): Use TetherEnabler to start tethering.
+        if (mWifiManager.isWifiApEnabled()) {
+            return;
+        }
+        mConnectivityManager.startTethering(ConnectivityManager.TETHERING_WIFI,
+                true /*showProvisioningUi*/,
+                new ConnectivityManager.OnStartTetheringCallback() {
+                    @Override
+                    public void onTetheringFailed() {
+                        super.onTetheringFailed();
+                        // Do nothing. There is no UI to update at this point.
+                    }
+                },
+                new Handler(Looper.getMainLooper()));
+    }
+
+    private void reConfigInitialExpandedChildCount() {
+        getPreferenceScreen().setInitialExpandedChildrenCount(getInitialExpandedChildCount());
+    }
+
+    @Override
+    public int getInitialExpandedChildCount() {
+        if (!mWifiTetherChosen) {
+            // Expand all preferences in the screen.
+            return getPreferenceScreen().getPreferenceCount();
+        }
+
+        if (mSecurityPreferenceController == null) {
+            return EXPANDED_CHILD_COUNT_DEFAULT;
+        }
+
+        return (mSecurityPreferenceController.getSecurityType()
+                == SoftApConfiguration.SECURITY_TYPE_OPEN)
+                ? EXPANDED_CHILD_COUNT_WITH_SECURITY_NON : EXPANDED_CHILD_COUNT_DEFAULT;
+    }
+
+    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider(R.xml.all_tether_prefs) {
+
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    final List<String> keys = super.getNonIndexableKeys(context);
+
+                    if (!TetherUtil.isTetherAvailable(context)) {
+                        keys.add(KEY_TETHER_PREFS_SCREEN);
+                        keys.add(KEY_WIFI_TETHER_NETWORK_NAME);
+                        keys.add(KEY_WIFI_TETHER_NETWORK_PASSWORD);
+                        keys.add(KEY_WIFI_TETHER_AUTO_OFF);
+                        keys.add(KEY_WIFI_TETHER_NETWORK_AP_BAND);
+                    }
+
+                    return keys;
+                }
+
+                @Override
+                public List<AbstractPreferenceController> createPreferenceControllers(
+                        Context context) {
+                    return buildPreferenceControllers(context, null /* AllTetherSettings */);
+                }
+            };
+}
diff --git a/src/com/android/settings/ResetNetwork.java b/src/com/android/settings/ResetNetwork.java
index e2adcc7..733d7fe 100644
--- a/src/com/android/settings/ResetNetwork.java
+++ b/src/com/android/settings/ResetNetwork.java
@@ -40,11 +40,9 @@
 import android.widget.Button;
 import android.widget.CheckBox;
 import android.widget.Spinner;
-import android.widget.TextView;
 
 import androidx.annotation.VisibleForTesting;
 
-import com.android.internal.telephony.PhoneConstants;
 import com.android.settings.core.InstrumentedFragment;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
@@ -121,10 +119,11 @@
         if (mSubscriptions != null && mSubscriptions.size() > 0) {
             int selectedIndex = mSubscriptionSpinner.getSelectedItemPosition();
             SubscriptionInfo subscription = mSubscriptions.get(selectedIndex);
-            args.putInt(PhoneConstants.SUBSCRIPTION_KEY, subscription.getSubscriptionId());
+            args.putInt(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
+                    subscription.getSubscriptionId());
         }
         args.putBoolean(MasterClear.ERASE_ESIMS_EXTRA,
-            mEsimContainer.getVisibility() == View.VISIBLE && mEsimCheckbox.isChecked());
+                mEsimContainer.getVisibility() == View.VISIBLE && mEsimCheckbox.isChecked());
         new SubSettingLauncher(getContext())
                 .setDestination(ResetNetworkConfirm.class.getName())
                 .setArguments(args)
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index f4b20eb..6856a5a 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -47,7 +47,6 @@
 import androidx.annotation.VisibleForTesting;
 import androidx.appcompat.app.AlertDialog;
 
-import com.android.internal.telephony.PhoneConstants;
 import com.android.settings.core.InstrumentedFragment;
 import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
 import com.android.settings.network.ApnSettings;
@@ -250,7 +249,7 @@
 
         Bundle args = getArguments();
         if (args != null) {
-            mSubId = args.getInt(PhoneConstants.SUBSCRIPTION_KEY,
+            mSubId = args.getInt(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
                     SubscriptionManager.INVALID_SUBSCRIPTION_ID);
             mEraseEsim = args.getBoolean(MasterClear.ERASE_ESIMS_EXTRA);
         }
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index 06c114b..fb7b01f 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -27,6 +27,7 @@
 
 import androidx.annotation.IntDef;
 import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
 
 import com.android.settings.R;
 
@@ -160,41 +161,76 @@
     }
 
     /**
-     * Opts in component name into colon-separated {@code shortcutType} key's string in Settings.
+     * Opts in component name into multiple {@code shortcutTypes} colon-separated string in
+     * Settings.
+     *
+     * @param context The current context.
+     * @param shortcutTypes  A combination of {@link UserShortcutType}.
+     * @param componentName The component name that need to be opted in Settings.
+     */
+    static void optInAllValuesToSettings(Context context, int shortcutTypes,
+            @NonNull ComponentName componentName) {
+        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
+            optInValueToSettings(context, UserShortcutType.SOFTWARE, componentName);
+        }
+        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
+            optInValueToSettings(context, UserShortcutType.HARDWARE, componentName);
+        }
+    }
+
+    /**
+     * Opts in component name into {@code shortcutType} colon-separated string in Settings.
      *
      * @param context The current context.
      * @param shortcutType The preferred shortcut type user selected.
      * @param componentName The component name that need to be opted in Settings.
      */
+    @VisibleForTesting
     static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
             @NonNull ComponentName componentName) {
         final String targetKey = convertKeyFromSettings(shortcutType);
         final String targetString = Settings.Secure.getString(context.getContentResolver(),
                 targetKey);
 
-        if (TextUtils.isEmpty(targetString)) {
-            return;
-        }
-
         if (hasValueInSettings(context, shortcutType, componentName)) {
             return;
         }
 
         final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
-
-        joiner.add(targetString);
+        if (!TextUtils.isEmpty(targetString)) {
+            joiner.add(targetString);
+        }
         joiner.add(componentName.flattenToString());
 
         Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
     }
 
     /**
-     * Opts out component name into colon-separated {@code shortcutType} key's string in Settings.
+     * Opts out component name into multiple {@code shortcutTypes} colon-separated string in
+     * Settings.
+     *
+     * @param context The current context.
+     * @param shortcutTypes A combination of {@link UserShortcutType}.
+     * @param componentName The component name that need to be opted out from Settings.
+     */
+    static void optOutAllValuesFromSettings(Context context, int shortcutTypes,
+            @NonNull ComponentName componentName) {
+        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
+            optOutValueFromSettings(context, UserShortcutType.SOFTWARE, componentName);
+        }
+        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
+            optOutValueFromSettings(context, UserShortcutType.HARDWARE, componentName);
+        }
+    }
+
+    /**
+     * Opts out component name into {@code shortcutType} colon-separated string in Settings.
      *
      * @param context The current context.
      * @param shortcutType The preferred shortcut type user selected.
      * @param componentName The component name that need to be opted out from Settings.
      */
+    @VisibleForTesting
     static void optOutValueFromSettings(Context context, @UserShortcutType int shortcutType,
             @NonNull ComponentName componentName) {
         final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
@@ -219,13 +255,34 @@
     }
 
     /**
-     * Returns if component name existed in Settings.
+     * Returns if component name existed in one of {@code shortcutTypes} string in Settings.
+     *
+     * @param context The current context.
+     * @param shortcutTypes A combination of {@link UserShortcutType}.
+     * @param componentName The component name that need to be checked existed in Settings.
+     * @return {@code true} if componentName existed in Settings.
+     */
+    static boolean hasValuesInSettings(Context context, int shortcutTypes,
+            @NonNull ComponentName componentName) {
+        boolean exist = false;
+        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
+            exist = hasValueInSettings(context, UserShortcutType.SOFTWARE, componentName);
+        }
+        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
+            exist |= hasValueInSettings(context, UserShortcutType.HARDWARE, componentName);
+        }
+        return exist;
+    }
+
+    /**
+     * Returns if component name existed in {@code shortcutType} string Settings.
      *
      * @param context The current context.
      * @param shortcutType The preferred shortcut type user selected.
      * @param componentName The component name that need to be checked existed in Settings.
      * @return {@code true} if componentName existed in Settings.
      */
+    @VisibleForTesting
     static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType,
             @NonNull ComponentName componentName) {
         final String targetKey = convertKeyFromSettings(shortcutType);
diff --git a/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
index ef658e0..afcd4c6 100644
--- a/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
@@ -18,9 +18,12 @@
 
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.os.Bundle;
+import android.view.View;
 
+import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.widget.SwitchBar;
+import com.android.settingslib.accessibility.AccessibilityUtils;
 
 /**
  * For accessibility services that target SDK > Q, and
@@ -28,7 +31,7 @@
  * is set.
  */
 public class InvisibleToggleAccessibilityServicePreferenceFragment extends
-        ToggleAccessibilityServicePreferenceFragment {
+        ToggleAccessibilityServicePreferenceFragment implements ShortcutPreference.OnClickListener{
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
@@ -38,4 +41,30 @@
         final SwitchBar mSwitchBar = activity.getSwitchBar();
         mSwitchBar.hide();
     }
+
+    /**
+     * {@inheritDoc}
+     *
+     * Enables accessibility service only when user had allowed permission.
+     */
+    @Override
+    public void onCheckboxClicked(ShortcutPreference preference) {
+        super.onCheckboxClicked(preference);
+        AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName,
+                getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED));
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * Enables accessibility service when user clicks permission allow button.
+     */
+    @Override
+    void onDialogButtonFromShortcutClicked(View view) {
+        super.onDialogButtonFromShortcutClicked(view);
+        if (view.getId() == R.id.permission_enable_allow_button) {
+            AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName,
+                    true);
+        }
+    }
 }
diff --git a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
index 4714fb3..13397a2 100644
--- a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
+
 import android.os.Bundle;
 import android.view.View;
 
@@ -23,9 +25,12 @@
 
 import com.android.settings.R;
 
+import com.google.common.collect.ImmutableSet;
+
 /** For accessibility services that target SDK <= Q. */
 public class LegacyAccessibilityServicePreferenceFragment extends
         ToggleAccessibilityServicePreferenceFragment {
+
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
@@ -39,5 +44,15 @@
             shortcutPreference.setSummary(hardwareTitle);
             shortcutPreference.setSettingsVisibility(View.GONE);
         }
+        // Only allowed hardware PreferredShortcutType in this fragment.
+        setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
+    }
+
+    private void setAllowedPreferredShortcutType(int type) {
+        final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(
+                getComponentName().flattenToString(), type);
+
+        SharedPreferenceUtils.setUserShortcutType(getPrefContext(),
+                ImmutableSet.of(shortcut.flattenToString()));
     }
 }
diff --git a/src/com/android/settings/accessibility/MagnificationEnablePreferenceController.java b/src/com/android/settings/accessibility/MagnificationEnablePreferenceController.java
new file mode 100644
index 0000000..a21c024
--- /dev/null
+++ b/src/com/android/settings/accessibility/MagnificationEnablePreferenceController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2020 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.accessibility;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.TogglePreferenceController;
+
+/** Controller that shows the magnification enable mode summary. */
+public class MagnificationEnablePreferenceController extends TogglePreferenceController {
+
+    private static final String KEY_ENABLE = Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE;
+
+    public MagnificationEnablePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public boolean isChecked() {
+        final int enableMode = Settings.Secure.getIntForUser(mContext.getContentResolver(),
+                KEY_ENABLE,
+                Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN,
+                UserHandle.USER_CURRENT);
+        return enableMode == Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        final int value = isChecked ? Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN
+                : Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW;
+        return Settings.Secure.putIntForUser(mContext.getContentResolver(), KEY_ENABLE, value,
+                UserHandle.USER_CURRENT);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/accessibility/MagnificationWindowControlPreferenceController.java b/src/com/android/settings/accessibility/MagnificationWindowControlPreferenceController.java
deleted file mode 100644
index 4badc3f..0000000
--- a/src/com/android/settings/accessibility/MagnificationWindowControlPreferenceController.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.accessibility;
-
-import android.content.Context;
-import android.os.UserHandle;
-import android.provider.Settings;
-
-import com.android.settings.core.TogglePreferenceController;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/** Controller that shows and updates the magnification window control switch. */
-public class MagnificationWindowControlPreferenceController extends TogglePreferenceController {
-
-    // TODO(b/146019459): Use magnification_window_control_enabled.
-    private static final String KEY_CONTROL = Settings.System.MASTER_MONO;
-
-    public MagnificationWindowControlPreferenceController(Context context, String preferenceKey) {
-        super(context, preferenceKey);
-    }
-
-    @Override
-    public boolean isChecked() {
-        return Settings.System.getIntForUser(mContext.getContentResolver(),
-                KEY_CONTROL, State.OFF, UserHandle.USER_CURRENT) == State.ON;
-    }
-
-    @Override
-    public boolean setChecked(boolean isChecked) {
-        return Settings.System.putIntForUser(mContext.getContentResolver(),
-                KEY_CONTROL, isChecked ? State.ON : State.OFF, UserHandle.USER_CURRENT);
-    }
-
-    @Override
-    public int getAvailabilityStatus() {
-        return AVAILABLE;
-    }
-
-    @Retention(RetentionPolicy.SOURCE)
-    private @interface State {
-        int OFF = 0;
-        int ON = 1;
-    }
-}
diff --git a/src/com/android/settings/accessibility/ShortcutPreference.java b/src/com/android/settings/accessibility/ShortcutPreference.java
index b66a2b6..84ced68 100644
--- a/src/com/android/settings/accessibility/ShortcutPreference.java
+++ b/src/com/android/settings/accessibility/ShortcutPreference.java
@@ -53,7 +53,10 @@
     }
     private OnClickListener mListener = null;
 
+    private static final float DISABLED_ALPHA = 0.5f;
+    private static final float ENABLED_ALPHA = 1.0f;
     private int mSettingsVisibility = View.VISIBLE;
+    private boolean mAutoEnabledSettings;
     private boolean mChecked = false;
 
     ShortcutPreference(Context context, AttributeSet attrs) {
@@ -65,24 +68,41 @@
     public void onBindViewHolder(PreferenceViewHolder holder) {
         super.onBindViewHolder(holder);
 
-        final CheckBox checkBox = holder.itemView.findViewById(R.id.checkbox);
         final LinearLayout mainFrame = holder.itemView.findViewById(R.id.main_frame);
-        if (mainFrame != null && checkBox != null) {
+        if (mainFrame != null) {
             mainFrame.setOnClickListener(view -> callOnCheckboxClicked());
+        }
+
+        final CheckBox checkBox = holder.itemView.findViewById(R.id.checkbox);
+        if (checkBox != null) {
             checkBox.setChecked(mChecked);
         }
 
+
         final View settings = holder.itemView.findViewById(android.R.id.widget_frame);
-        final View divider = holder.itemView.findViewById(R.id.divider);
-        if (settings != null && divider != null) {
+        if (settings != null) {
             settings.setOnClickListener(view -> callOnSettingsClicked());
+            settings.setEnabled(mAutoEnabledSettings ? mChecked : /* enabled */ true);
+
+            float alpha;
+            if (mAutoEnabledSettings) {
+                alpha = mChecked ? ENABLED_ALPHA : DISABLED_ALPHA;
+            } else {
+                alpha = ENABLED_ALPHA;
+            }
+
+            settings.setAlpha(alpha);
             settings.setVisibility(mSettingsVisibility);
+        }
+
+        final View divider = holder.itemView.findViewById(R.id.divider);
+        if (divider != null) {
             divider.setVisibility(mSettingsVisibility);
         }
     }
 
     /**
-     * Set the shortcut checkbox according to checked value.
+     * Sets the shortcut checkbox according to checked value.
      *
      * @param checked the state value of shortcut checkbox
      */
@@ -94,7 +114,7 @@
     }
 
     /**
-     * Get the checked value of shortcut checkbox.
+     * Gets the checked value of shortcut checkbox.
      *
      * @return the checked value of shortcut checkbox
      */
@@ -102,7 +122,22 @@
         return mChecked;
     }
 
-
+    /**
+     * Automatically/Manually enable settings according to checkbox click status.
+     *
+     * Automatically enable settings means settings view enabled when checkbox is clicked, and
+     * disabled when checkbox is not clicked.
+     * Manually enable settings means settings view always enabled.
+     *
+     * @param autoEnabled True will automatically enable settings, false will let settings view
+     *                    always enabled.
+     */
+    public void setAutoEnabledSettings(boolean autoEnabled) {
+        if (mAutoEnabledSettings != autoEnabled) {
+            mAutoEnabledSettings = autoEnabled;
+            notifyChanged();
+        }
+    }
 
     /**
      * Sets the visibility state of Settings view.
@@ -129,6 +164,7 @@
         setLayoutResource(R.layout.accessibility_shortcut_secondary_action);
         setWidgetLayoutResource(R.layout.preference_widget_settings);
         setIconSpaceReserved(false);
+        mAutoEnabledSettings = true;
     }
 
     private void callOnSettingsClicked() {
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index e275157..08dd533 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -317,6 +317,12 @@
         updateUserShortcutType(/* saveChanges= */ true);
         mShortcutPreference.setSummary(
                 getShortcutTypeSummary(getPrefContext()));
+        if (mShortcutPreference.getChecked()) {
+            AccessibilityUtil.optInAllValuesToSettings(getContext(), mUserShortcutType,
+                    mComponentName);
+            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), ~mUserShortcutType,
+                    mComponentName);
+        }
     }
 
     @Override
@@ -346,8 +352,7 @@
     }
 
     private void initShortcutPreference(Bundle savedInstanceState) {
-        mUserShortcutType = getUserShortcutType(getPrefContext(),
-                UserShortcutType.SOFTWARE);
+        mUserShortcutType = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
 
         // Restore the user shortcut type
         if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
@@ -366,7 +371,6 @@
         mShortcutPreference.setOnClickListener(this);
         // Put the shortcutPreference before settingsPreference.
         mShortcutPreference.setOrder(-1);
-        // TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
         preferenceScreen.addPreference(mShortcutPreference);
     }
 
@@ -376,11 +380,9 @@
                 getShortcutPreferenceKey());
 
         if (shortcutPreference != null) {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
+            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
             shortcutPreference.setChecked(
-                    AccessibilityUtil.hasValueInSettings(getContext(),
-                            UserShortcutType.SOFTWARE,
+                    AccessibilityUtil.hasValuesInSettings(getContext(), shortcutTypes,
                             mComponentName));
         }
     }
@@ -473,20 +475,17 @@
 
     @Override
     public void onCheckboxClicked(ShortcutPreference preference) {
+        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
         if (preference.getChecked()) {
             if (!getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
                 preference.setChecked(false);
                 showPopupDialog(DialogType.ENABLE_WARNING_FROM_SHORTCUT);
             } else {
-                // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog
-                //  shortcut preferred key.
-                AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
+                AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
                         mComponentName);
             }
         } else {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            AccessibilityUtil.optOutValueFromSettings(getContext(), UserShortcutType.SOFTWARE,
+            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
                     mComponentName);
         }
     }
@@ -565,7 +564,7 @@
         mDialog.dismiss();
     }
 
-    private void onDialogButtonFromShortcutClicked(View view) {
+    void onDialogButtonFromShortcutClicked(View view) {
         if (view.getId() == R.id.permission_enable_allow_button) {
             onAllowButtonFromShortcutClicked();
         } else if (view.getId() == R.id.permission_enable_deny_button) {
@@ -578,10 +577,9 @@
     private void onAllowButtonFromShortcutClicked() {
         final ShortcutPreference shortcutPreference = findPreference(getShortcutPreferenceKey());
         shortcutPreference.setChecked(true);
-        // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-        //  preferred key.
-        AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
-                mComponentName);
+
+        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
+        AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes, mComponentName);
 
         mDialog.dismiss();
     }
@@ -623,7 +621,7 @@
         }
     }
 
-    private ComponentName getComponentName() {
+    ComponentName getComponentName() {
         return mComponentName;
     }
 }
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index b4c7dce..610bb6b 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -273,6 +273,12 @@
         updateUserShortcutType(/* saveChanges= */ true);
         mShortcutPreference.setSummary(
                 getShortcutTypeSummary(getPrefContext()));
+        if (mShortcutPreference.getChecked()) {
+            AccessibilityUtil.optInAllValuesToSettings(getContext(), mUserShortcutType,
+                    getComponentName());
+            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), ~mUserShortcutType,
+                    getComponentName());
+        }
     }
 
     @Override
@@ -315,11 +321,9 @@
                 getShortcutPreferenceKey());
 
         if (shortcutPreference != null) {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
+            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
             shortcutPreference.setChecked(
-                    AccessibilityUtil.hasValueInSettings(getContext(),
-                            UserShortcutType.SOFTWARE,
+                    AccessibilityUtil.hasValuesInSettings(getContext(), shortcutTypes,
                             getComponentName()));
         }
     }
@@ -334,15 +338,12 @@
 
     @Override
     public void onCheckboxClicked(ShortcutPreference preference) {
+        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
         if (preference.getChecked()) {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
+            AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
                     getComponentName());
         } else {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            AccessibilityUtil.optOutValueFromSettings(getContext(), UserShortcutType.SOFTWARE,
+            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
                     getComponentName());
         }
     }
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 12a207e..c20e304 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -245,6 +245,12 @@
         updateUserShortcutType(/* saveChanges= */ true);
         mShortcutPreference.setSummary(
                 getShortcutTypeSummary(getPrefContext()));
+        if (mShortcutPreference.getChecked()) {
+            AccessibilityUtil.optInAllValuesToSettings(getContext(), mUserShortcutType,
+                    getComponentName());
+            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), ~mUserShortcutType,
+                    getComponentName());
+        }
     }
 
     @Override
@@ -303,15 +309,12 @@
 
     @Override
     public void onCheckboxClicked(ShortcutPreference preference) {
+        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
         if (preference.getChecked()) {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
+            AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
                     getComponentName());
         } else {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            AccessibilityUtil.optOutValueFromSettings(getContext(), UserShortcutType.SOFTWARE,
+            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
                     getComponentName());
         }
     }
@@ -355,11 +358,9 @@
                 getShortcutPreferenceKey());
 
         if (shortcutPreference != null) {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
+            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
             shortcutPreference.setChecked(
-                    AccessibilityUtil.hasValueInSettings(getContext(),
-                            UserShortcutType.SOFTWARE,
+                    AccessibilityUtil.hasValuesInSettings(getContext(), shortcutTypes,
                             getComponentName()));
         }
 
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index c6756a8..c0f6493 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -46,6 +46,7 @@
 import androidx.preference.PreferenceScreen;
 import androidx.preference.PreferenceViewHolder;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
 import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
 
@@ -256,6 +257,11 @@
         updateAlertDialogCheckState();
         updateAlertDialogEnableState();
 
+        // Window magnification mode doesn't support advancedView.
+        if (isWindowMagnification(getPrefContext())) {
+            advancedView.setVisibility(View.GONE);
+            return;
+        }
         // Shows the triple tap checkbox directly if clicked.
         if (mTripleTapTypeCheckBox.isChecked()) {
             advancedView.setVisibility(View.GONE);
@@ -372,6 +378,10 @@
         updateUserShortcutType(/* saveChanges= */ true);
         mShortcutPreference.setSummary(
                 getShortcutTypeSummary(getPrefContext()));
+        if (mShortcutPreference.getChecked()) {
+            optInAllMagnificationValuesToSettings(getContext(), mUserShortcutType);
+            optOutAllMagnificationValuesFromSettings(getContext(), ~mUserShortcutType);
+        }
     }
 
     private String getComponentName() {
@@ -435,38 +445,11 @@
 
     @Override
     public void onCheckboxClicked(ShortcutPreference preference) {
+        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
         if (preference.getChecked()) {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            optInMagnificationValueToSettings(getContext(), UserShortcutType.SOFTWARE);
-
-            // TODO(b/142531156): ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED need to be treated
-            //  as special case in this file.
-            if ((mUserShortcutType & UserShortcutType.SOFTWARE)
-                    == UserShortcutType.SOFTWARE) {
-                MagnificationPreferenceFragment.setChecked(getContentResolver(),
-                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
-                        /* isChecked= */ true);
-            }
-            if ((mUserShortcutType & UserShortcutType.TRIPLETAP)
-                    == UserShortcutType.TRIPLETAP) {
-                MagnificationPreferenceFragment.setChecked(getContentResolver(),
-                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
-                        /* isChecked= */ true);
-            }
+            optInAllMagnificationValuesToSettings(getContext(), shortcutTypes);
         } else {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            optOutMagnificationValueFromSettings(getContext(), UserShortcutType.SOFTWARE);
-
-            // TODO(b/142531156): ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED need to be treated
-            //  as special case in this file.
-            MagnificationPreferenceFragment.setChecked(getContentResolver(),
-                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
-                    /* isChecked= */ false);
-            MagnificationPreferenceFragment.setChecked(getContentResolver(),
-                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
-                    /* isChecked= */ false);
+            optOutAllMagnificationValuesFromSettings(getContext(), shortcutTypes);
         }
     }
 
@@ -505,11 +488,9 @@
                 getShortcutPreferenceKey());
 
         if (shortcutPreference != null) {
-            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
+            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
             shortcutPreference.setChecked(
-                    hasMagnificationValueInSettings(getContext(),
-                            UserShortcutType.SOFTWARE));
+                    hasMagnificationValuesInSettings(getContext(), shortcutTypes));
         }
     }
 
@@ -534,28 +515,52 @@
         int EDIT_SHORTCUT = 3;
     }
 
+    @VisibleForTesting
+    static void optInAllMagnificationValuesToSettings(Context context, int shortcutTypes) {
+        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
+            optInMagnificationValueToSettings(context, UserShortcutType.SOFTWARE);
+        }
+        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
+            optInMagnificationValueToSettings(context, UserShortcutType.HARDWARE);
+        }
+        if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
+            optInMagnificationValueToSettings(context, UserShortcutType.TRIPLETAP);
+        }
+    }
+
     private static void optInMagnificationValueToSettings(Context context,
             @UserShortcutType int shortcutType) {
         final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
         final String targetString = Settings.Secure.getString(context.getContentResolver(),
                 targetKey);
 
-        if (TextUtils.isEmpty(targetString)) {
-            return;
-        }
-
         if (hasMagnificationValueInSettings(context, shortcutType)) {
             return;
         }
 
         final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
-
-        joiner.add(Settings.Secure.getString(context.getContentResolver(), targetKey));
+        if (!TextUtils.isEmpty(targetString)) {
+            joiner.add(targetString);
+        }
         joiner.add(MAGNIFICATION_CONTROLLER_NAME);
 
         Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
     }
 
+    @VisibleForTesting
+    static void optOutAllMagnificationValuesFromSettings(Context context,
+            int shortcutTypes) {
+        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
+            optOutMagnificationValueFromSettings(context, UserShortcutType.SOFTWARE);
+        }
+        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
+            optOutMagnificationValueFromSettings(context, UserShortcutType.HARDWARE);
+        }
+        if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
+            optOutMagnificationValueFromSettings(context, UserShortcutType.TRIPLETAP);
+        }
+    }
+
     private static void optOutMagnificationValueFromSettings(Context context,
             @UserShortcutType int shortcutType) {
         final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
@@ -579,6 +584,22 @@
         Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
     }
 
+    @VisibleForTesting
+    static boolean hasMagnificationValuesInSettings(Context context, int shortcutTypes) {
+        boolean exist = false;
+
+        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
+            exist = hasMagnificationValueInSettings(context, UserShortcutType.SOFTWARE);
+        }
+        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
+            exist |= hasMagnificationValueInSettings(context, UserShortcutType.HARDWARE);
+        }
+        if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
+            exist |= hasMagnificationValueInSettings(context, UserShortcutType.TRIPLETAP);
+        }
+        return exist;
+    }
+
     private static boolean hasMagnificationValueInSettings(Context context,
             @UserShortcutType int shortcutType) {
         final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
@@ -598,4 +619,13 @@
         }
         return false;
     }
+
+    private boolean isWindowMagnification(Context context) {
+        final int mode = Settings.Secure.getIntForUser(
+                context.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE,
+                Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN,
+                context.getContentResolver().getUserId());
+        return mode == Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW;
+    }
 }
diff --git a/src/com/android/settings/applications/AppStateSmsPremBridge.java b/src/com/android/settings/applications/AppStateSmsPremBridge.java
index 5a79a62..66763fe 100644
--- a/src/com/android/settings/applications/AppStateSmsPremBridge.java
+++ b/src/com/android/settings/applications/AppStateSmsPremBridge.java
@@ -14,10 +14,8 @@
 package com.android.settings.applications;
 
 import android.content.Context;
-import android.os.RemoteException;
-import android.os.ServiceManager;
+import android.telephony.SmsManager;
 
-import com.android.internal.telephony.ISms;
 import com.android.internal.telephony.SmsUsageMonitor;
 import com.android.settingslib.applications.ApplicationsState;
 import com.android.settingslib.applications.ApplicationsState.AppEntry;
@@ -31,12 +29,12 @@
 public class AppStateSmsPremBridge extends AppStateBaseBridge {
 
     private final Context mContext;
-    private final ISms mSmsManager;
+    private final SmsManager mSmsManager;
 
     public AppStateSmsPremBridge(Context context, ApplicationsState appState, Callback callback) {
         super(appState, callback);
         mContext = context;
-        mSmsManager = ISms.Stub.asInterface(ServiceManager.getService("isms"));
+        mSmsManager = SmsManager.getDefault();
     }
 
     @Override
@@ -61,18 +59,11 @@
     }
 
     private int getSmsState(String pkg) {
-        try {
-            return mSmsManager.getPremiumSmsPermission(pkg);
-        } catch (RemoteException e) {
-            return SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN;
-        }
+        return mSmsManager.getPremiumSmsConsent(pkg);
     }
 
     public void setSmsState(String pkg, int state) {
-        try {
-            mSmsManager.setPremiumSmsPermission(pkg, state);
-        } catch (RemoteException e) {
-        }
+        mSmsManager.setPremiumSmsConsent(pkg, state);
     }
 
     public static class SmsState {
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java b/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java
index a7fae14..c807893 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsButtonsController.java
@@ -79,7 +79,7 @@
                         .setButton2Text(R.string.bluetooth_device_context_connect)
                         .setButton2Icon(R.drawable.ic_add_24dp)
                         .setButton2OnClickListener(
-                                view -> mCachedDevice.connect(true /* connectAllProfiles */));
+                                view -> mCachedDevice.connect());
                 mConnectButtonInitialized = true;
             }
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index a8b1c97..4226720 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -241,7 +241,7 @@
         } else if (bondState == BluetoothDevice.BOND_BONDED) {
             metricsFeatureProvider.action(context,
                     SettingsEnums.ACTION_SETTINGS_BLUETOOTH_CONNECT);
-            mCachedDevice.connect(true);
+            mCachedDevice.connect();
         } else if (bondState == BluetoothDevice.BOND_NONE) {
             metricsFeatureProvider.action(context,
                     SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR);
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index 8d91dfc..fdd7a1e 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -57,7 +57,7 @@
         mMetricsFeatureProvider.logClickedPreference(preference, mFragment.getMetricsCategory());
         final CachedBluetoothDevice device = ((BluetoothDevicePreference) preference)
                 .getBluetoothDevice();
-        device.connect(true);
+        device.connect();
         return true;
     }
 
diff --git a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
index f5cbf18..f719494 100644
--- a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
+++ b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
@@ -31,6 +31,7 @@
 import com.android.settings.display.NightDisplaySettings;
 import com.android.settings.enterprise.EnterprisePrivacySettings;
 import com.android.settings.fuelgauge.PowerUsageSummary;
+import com.android.settings.fuelgauge.SmartBatterySettings;
 import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 import com.android.settings.gestures.GestureSettings;
 import com.android.settings.homepage.TopLevelSettings;
@@ -116,6 +117,8 @@
                 CategoryKey.CATEGORY_MY_DEVICE_INFO);
         PARENT_TO_CATEGORY_KEY_MAP.put(BatterySaverSettings.class.getName(),
                 CategoryKey.CATEGORY_BATTERY_SAVER_SETTINGS);
+        PARENT_TO_CATEGORY_KEY_MAP.put(SmartBatterySettings.class.getName(),
+                CategoryKey.CATEGORY_SMART_BATTERY_SETTINGS);
 
         CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
 
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
index d0187b9..594e553 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
@@ -24,6 +24,7 @@
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.os.UserManager;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -45,6 +46,7 @@
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import java.util.Locale;
 
 /**
  * Base fragment class for profile settings.
@@ -93,6 +95,9 @@
      * Used in fragment argument with Extra key {@link SettingsActivity.EXTRA_SHOW_FRAGMENT_TAB}
      */
     public static final int WORK_TAB = 1;
+    private static final int[] LABEL = {
+            R.string.category_personal, R.string.category_work
+    };
 
     private ViewGroup mContentView;
 
@@ -101,7 +106,7 @@
             Bundle savedInstanceState) {
         mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
         final Activity activity = getActivity();
-        final int selectedTab = getTabId(activity, getArguments());
+        final int selectedTab = convertPosition(getTabId(activity, getArguments()));
 
         final View tabContainer = mContentView.findViewById(R.id.tab_container);
         final ViewPager viewPager = tabContainer.findViewById(R.id.view_pager);
@@ -180,7 +185,7 @@
 
         @Override
         public Fragment getItem(int position) {
-            return mChildFragments[position];
+            return mChildFragments[convertPosition(position)];
         }
 
         @Override
@@ -190,11 +195,15 @@
 
         @Override
         public CharSequence getPageTitle(int position) {
-            if (position == 0) {
-                return mContext.getString(R.string.category_personal);
-            } else {
-                return mContext.getString(R.string.category_work);
-            }
+            return mContext.getString(LABEL[convertPosition(position)]);
         }
     }
+
+    private static int convertPosition(int index) {
+        if (TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())
+                == View.LAYOUT_DIRECTION_RTL) {
+            return LABEL.length - 1 - index;
+        }
+        return index;
+    }
 }
diff --git a/src/com/android/settings/deviceinfo/ImsStatusPreferenceController.java b/src/com/android/settings/deviceinfo/ImsStatusPreferenceController.java
deleted file mode 100644
index 07bd4a6..0000000
--- a/src/com/android/settings/deviceinfo/ImsStatusPreferenceController.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.deviceinfo;
-
-import android.content.Context;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.deviceinfo.AbstractImsStatusPreferenceController;
-
-/**
- * Concrete subclass of IMS status preference controller
- */
-public class ImsStatusPreferenceController extends AbstractImsStatusPreferenceController
-        implements PreferenceControllerMixin {
-    public ImsStatusPreferenceController(Context context,
-            Lifecycle lifecycle) {
-        super(context, lifecycle);
-    }
-
-    // This space intentionally left blank
-}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index 26d8e2b..8096c0b 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -43,7 +43,6 @@
 import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
 
-import com.android.internal.telephony.PhoneConstants;
 import com.android.settings.R;
 import com.android.settingslib.DeviceInfoUtils;
 import com.android.settingslib.Utils;
@@ -94,6 +93,9 @@
     @VisibleForTesting
     final static int IMS_REGISTRATION_STATE_VALUE_ID = R.id.ims_reg_state_value;
 
+    @VisibleForTesting
+    static final int MAX_PHONE_COUNT_SINGLE_SIM = 1;
+
     private final static String CB_AREA_INFO_RECEIVED_ACTION =
             "com.android.cellbroadcastreceiver.CB_AREA_INFO_RECEIVED";
     private final static String GET_LATEST_CB_AREA_INFO_ACTION =
@@ -411,7 +413,7 @@
         boolean shouldHaveEid = false;
         String eid = null;
 
-        if (mTelephonyManager.getPhoneCount() > PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM) {
+        if (mTelephonyManager.getActiveModemCount() > MAX_PHONE_COUNT_SINGLE_SIM) {
             // Get EID per-SIM in multi-SIM mode
             Map<Integer, Integer> mapping = mTelephonyManager.getLogicalToPhysicalSlotMapping();
             int pSlotId = mapping.getOrDefault(mSlotIndex,
diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
index a9c9086..e7aab17 100644
--- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java
+++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
@@ -31,12 +31,15 @@
 import androidx.annotation.VisibleForTesting;
 
 import com.android.settings.slices.SliceBackgroundWorker;
+import com.android.settingslib.Utils;
 import com.android.settingslib.media.LocalMediaManager;
 import com.android.settingslib.media.MediaDevice;
 import com.android.settingslib.utils.ThreadUtils;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * SliceBackgroundWorker for get MediaDevice list and handle MediaDevice state change event.
@@ -45,10 +48,13 @@
         implements LocalMediaManager.DeviceCallback {
 
     private final Context mContext;
-    private final List<MediaDevice> mMediaDevices = new ArrayList<>();
+    private final Collection<MediaDevice> mMediaDevices = new CopyOnWriteArrayList<>();
     private final DevicesChangedBroadcastReceiver mReceiver;
     private final String mPackageName;
 
+    private boolean mIsTouched;
+    private MediaDevice mTopDevice;
+
     @VisibleForTesting
     LocalMediaManager mLocalMediaManager;
 
@@ -62,6 +68,7 @@
     @Override
     protected void onSlicePinned() {
         mMediaDevices.clear();
+        mIsTouched = false;
         if (mLocalMediaManager == null) {
             mLocalMediaManager = new LocalMediaManager(mContext, mPackageName, null);
         }
@@ -100,8 +107,13 @@
         notifySliceChange();
     }
 
-    public List<MediaDevice> getMediaDevices() {
-        return new ArrayList<>(mMediaDevices);
+    @Override
+    public void onDeviceAttributesChanged() {
+        notifySliceChange();
+    }
+
+    public Collection<MediaDevice> getMediaDevices() {
+        return mMediaDevices;
     }
 
     public void connectDevice(MediaDevice device) {
@@ -111,18 +123,35 @@
     }
 
     public MediaDevice getMediaDeviceById(String id) {
-        return mLocalMediaManager.getMediaDeviceById(mMediaDevices, id);
+        return mLocalMediaManager.getMediaDeviceById(new ArrayList<>(mMediaDevices), id);
     }
 
     public MediaDevice getCurrentConnectedMediaDevice() {
         return mLocalMediaManager.getCurrentConnectedDevice();
     }
 
+    void setIsTouched(boolean isTouched) {
+        mIsTouched = isTouched;
+    }
+
+    boolean getIsTouched() {
+        return mIsTouched;
+    }
+
+    void setTopDevice(MediaDevice device) {
+        mTopDevice = device;
+    }
+
+    MediaDevice getTopDevice() {
+        return mTopDevice;
+    }
+
     private class DevicesChangedBroadcastReceiver extends BroadcastReceiver {
         @Override
         public void onReceive(Context context, Intent intent) {
             final String action = intent.getAction();
-            if (TextUtils.equals(AudioManager.STREAM_DEVICES_CHANGED_ACTION, action)) {
+            if (TextUtils.equals(AudioManager.STREAM_DEVICES_CHANGED_ACTION, action)
+                    && Utils.isAudioModeOngoingCall(mContext)) {
                 notifySliceChange();
             }
         }
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index fbdf01c..47a5d7a 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -40,7 +40,7 @@
 import com.android.settings.slices.SliceBroadcastReceiver;
 import com.android.settingslib.media.MediaDevice;
 
-import java.util.List;
+import java.util.Collection;
 
 /**
  * Show the Media device that can be transfer the media.
@@ -61,7 +61,7 @@
     }
 
     @VisibleForTesting
-    void init(String packageName, MediaDeviceUpdateWorker worker) {
+    void init(MediaDeviceUpdateWorker worker) {
         mWorker = worker;
     }
 
@@ -78,16 +78,21 @@
             return listBuilder.build();
         }
 
-        final List<MediaDevice> devices = getMediaDevices();
+        final Collection<MediaDevice> devices = getMediaDevices();
+        final MediaDeviceUpdateWorker worker = getWorker();
+        final MediaDevice connectedDevice = worker.getCurrentConnectedMediaDevice();
+        final boolean isTouched = worker.getIsTouched();
+        // Fix the last top device when user press device to transfer.
+        final MediaDevice topDevice = isTouched ? worker.getTopDevice() : connectedDevice;
 
-        final MediaDevice connectedDevice = getWorker().getCurrentConnectedMediaDevice();
-        if (connectedDevice != null) {
-            listBuilder.addRow(getActiveDeviceHeaderRow(connectedDevice));
+        if (topDevice != null) {
+            listBuilder.addRow(getActiveDeviceHeaderRow(topDevice));
+            worker.setTopDevice(topDevice);
         }
 
         for (MediaDevice device : devices) {
-            if (connectedDevice == null
-                    || !TextUtils.equals(connectedDevice.getId(), device.getId())) {
+            if (topDevice == null
+                    || !TextUtils.equals(topDevice.getId(), device.getId())) {
                 listBuilder.addRow(getMediaDeviceRow(device));
             }
         }
@@ -131,8 +136,8 @@
         return mWorker;
     }
 
-    private List<MediaDevice> getMediaDevices() {
-        final List<MediaDevice> devices = getWorker().getMediaDevices();
+    private Collection<MediaDevice> getMediaDevices() {
+        final Collection<MediaDevice> devices = getWorker().getMediaDevices();
         return devices;
     }
 
@@ -173,6 +178,7 @@
         final MediaDevice device = worker.getMediaDeviceById(id);
         if (device != null) {
             Log.d(TAG, "onNotifyChange() device name : " + device.getName());
+            worker.setIsTouched(true);
             worker.connectDevice(device);
         }
     }
diff --git a/src/com/android/settings/network/ApnSettings.java b/src/com/android/settings/network/ApnSettings.java
index 88a13ae..eb6c9b1 100755
--- a/src/com/android/settings/network/ApnSettings.java
+++ b/src/com/android/settings/network/ApnSettings.java
@@ -174,9 +174,6 @@
 
         final TelephonyManager updatedTelephonyManager =
                 mTelephonyManager.createForSubscriptionId(subId);
-        if (updatedTelephonyManager == null) {
-            return;
-        }
 
         // restart monitoring when subscription has been changed
         mTelephonyManager.listen(mPhoneStateListener,
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 22c47a6..bcb4895 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -249,12 +249,11 @@
      * Get phoneId or logical slot index for a subId if active, or INVALID_PHONE_INDEX if inactive.
      */
     public static int getPhoneId(Context context, int subId) {
-        SubscriptionManager subManager = (SubscriptionManager)
-                context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+        final SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class);
         if (subManager == null) {
             return INVALID_SIM_SLOT_INDEX;
         }
-        SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId);
+        final SubscriptionInfo info = subManager.getActiveSubscriptionInfo(subId);
         if (info == null) {
             return INVALID_SIM_SLOT_INDEX;
         }
diff --git a/src/com/android/settings/network/TetherEnabler.java b/src/com/android/settings/network/TetherEnabler.java
index 6c6c959..9021a26 100644
--- a/src/com/android/settings/network/TetherEnabler.java
+++ b/src/com/android/settings/network/TetherEnabler.java
@@ -61,7 +61,8 @@
     public static final String SHARED_PREF = "tether_options";
 
     @VisibleForTesting
-    static final String WIFI_TETHER_KEY = WifiTetherDisablePreferenceController.PREF_KEY;
+    static final String WIFI_TETHER_KEY =
+            WifiTetherDisablePreferenceController.KEY_ENABLE_WIFI_TETHERING;
     @VisibleForTesting
     static final String USB_TETHER_KEY = UsbTetherPreferenceController.PREF_KEY;
     @VisibleForTesting
diff --git a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
index bf0e208..99fcfcd 100644
--- a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
+++ b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
@@ -49,8 +49,11 @@
 
     private static final String TAG = "WifiTetherDisablePreferenceController";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    @VisibleForTesting
-    static final String PREF_KEY = "enable_wifi_tethering";
+    public static final String PREF_KEY = "disable_wifi_tethering";
+
+    // This KEY is used for a shared preference value, not for any displayed preferences.
+    public static final String KEY_ENABLE_WIFI_TETHERING = "enable_wifi_tethering";
+
     private final ConnectivityManager mCm;
     private boolean mBluetoothTetherEnabled;
     private boolean mUSBTetherEnabled;
@@ -111,7 +114,7 @@
         mPreference = screen.findPreference(PREF_KEY);
         if (mPreference != null && mPreference instanceof SwitchPreference) {
             ((SwitchPreference) mPreference)
-                    .setChecked(!mSharedPreferences.getBoolean(PREF_KEY, true));
+                    .setChecked(!mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true));
             mPreference.setOnPreferenceChangeListener(this);
         }
         updateState(mPreference);
@@ -155,11 +158,11 @@
     public boolean onPreferenceChange(Preference preference, Object o) {
         // The shared preference's value is in the opposite of this preference's value.
         final boolean enableWifi = !(boolean) o;
-        if (true) {
+        if (DEBUG) {
             Log.d(TAG, "check state changing to " + o);
         }
         final SharedPreferences.Editor editor = mSharedPreferences.edit();
-        editor.putBoolean(PREF_KEY, enableWifi);
+        editor.putBoolean(KEY_ENABLE_WIFI_TETHERING, enableWifi);
         editor.apply();
         return true;
     }
diff --git a/src/com/android/settings/network/telephony/CellInfoUtil.java b/src/com/android/settings/network/telephony/CellInfoUtil.java
index ab172c8..7412428 100644
--- a/src/com/android/settings/network/telephony/CellInfoUtil.java
+++ b/src/com/android/settings/network/telephony/CellInfoUtil.java
@@ -33,8 +33,6 @@
 import android.text.TextDirectionHeuristics;
 import android.text.TextUtils;
 
-import com.android.internal.telephony.OperatorInfo;
-
 import java.util.List;
 import java.util.Objects;
 import java.util.stream.Collectors;
@@ -101,34 +99,6 @@
         return cellId;
     }
 
-    /**
-     * Creates a CellInfo object from OperatorInfo. GsmCellInfo is used here only because
-     * operatorInfo does not contain technology type while CellInfo is an abstract object that
-     * requires to specify technology type. It doesn't matter which CellInfo type to use here, since
-     * we only want to wrap the operator info and PLMN to a CellInfo object.
-     */
-    public static CellInfo convertOperatorInfoToCellInfo(OperatorInfo operatorInfo) {
-        final String operatorNumeric = operatorInfo.getOperatorNumeric();
-        String mcc = null;
-        String mnc = null;
-        if (operatorNumeric != null && operatorNumeric.matches("^[0-9]{5,6}$")) {
-            mcc = operatorNumeric.substring(0, 3);
-            mnc = operatorNumeric.substring(3);
-        }
-        final CellIdentityGsm cig = new CellIdentityGsm(
-                Integer.MAX_VALUE /* lac */,
-                Integer.MAX_VALUE /* cid */,
-                Integer.MAX_VALUE /* arfcn */,
-                Integer.MAX_VALUE /* bsic */,
-                mcc,
-                mnc,
-                operatorInfo.getOperatorAlphaLong(),
-                operatorInfo.getOperatorAlphaShort());
-
-        final CellInfoGsm ci = new CellInfoGsm();
-        ci.setCellIdentity(cig);
-        return ci;
-    }
 
     /** Convert a list of cellInfos to readable string without sensitive info. */
     public static String cellInfoListToString(List<CellInfo> cellInfos) {
diff --git a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
index 97894b1..7173ccc 100644
--- a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
+++ b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
@@ -57,7 +57,6 @@
     private List<String> mForbiddenPlmns;
     private int mLevel = LEVEL_NONE;
     private boolean mShow4GForLTE;
-    private boolean mUseNewApi;
 
     public NetworkOperatorPreference(Context context, CellInfo cellinfo,
             List<String> forbiddenPlmns, boolean show4GForLTE) {
@@ -76,8 +75,6 @@
         super(context);
         mForbiddenPlmns = forbiddenPlmns;
         mShow4GForLTE = show4GForLTE;
-        mUseNewApi = context.getResources().getBoolean(
-                com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI);
     }
 
     /**
@@ -218,7 +215,7 @@
     }
 
     private void updateIcon(int level) {
-        if (!mUseNewApi || level < 0 || level >= NUM_SIGNAL_STRENGTH_BINS) {
+        if (level < 0 || level >= NUM_SIGNAL_STRENGTH_BINS) {
             return;
         }
         final Context context = getContext();
diff --git a/src/com/android/settings/network/telephony/NetworkScanHelper.java b/src/com/android/settings/network/telephony/NetworkScanHelper.java
index 185090b..eb0d020 100644
--- a/src/com/android/settings/network/telephony/NetworkScanHelper.java
+++ b/src/com/android/settings/network/telephony/NetworkScanHelper.java
@@ -16,7 +16,6 @@
 
 package com.android.settings.network.telephony;
 
-import android.annotation.IntDef;
 import android.telephony.AccessNetworkConstants.AccessNetworkType;
 import android.telephony.CellInfo;
 import android.telephony.NetworkScan;
@@ -26,20 +25,8 @@
 import android.telephony.TelephonyScanManager;
 import android.util.Log;
 
-import com.android.internal.telephony.CellNetworkScanResult;
-
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.SettableFuture;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
 import java.util.List;
-import java.util.concurrent.CancellationException;
 import java.util.concurrent.Executor;
-import java.util.stream.Collectors;
 
 /**
  * A helper class that builds the common interface and performs the network scan for two different
@@ -82,33 +69,6 @@
         void onError(int errorCode);
     }
 
-    @Retention(RetentionPolicy.SOURCE)
-    @IntDef({NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS, NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS})
-    public @interface NetworkQueryType {}
-
-    /**
-     * Performs the network scan using {@link TelephonyManager#getAvailableNetworks()}. The network
-     * scan results won't be returned to the caller until the network scan is completed.
-     *
-     * <p> This is typically used when the modem doesn't support the new network scan api
-     * {@link TelephonyManager#requestNetworkScan(
-     * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}.
-     */
-    public static final int NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS = 1;
-
-    /**
-     * Performs the network scan using {@link TelephonyManager#requestNetworkScan(
-     * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)} The network scan
-     * results will be returned to the caller periodically in a small time window until the network
-     * scan is completed. The complete results should be returned in the last called of
-     * {@link NetworkScanCallback#onResults(List)}.
-     *
-     * <p> This is recommended to be used if modem supports the new network scan api
-     * {@link TelephonyManager#requestNetworkScan(
-     * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}
-     */
-    public static final int NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS = 2;
-
     /** The constants below are used in the async network scan. */
     private static final boolean INCREMENTAL_RESULTS = true;
     private static final int SEARCH_PERIODICITY_SEC = 5;
@@ -138,7 +98,7 @@
                             new RadioAccessSpecifier(
                                     AccessNetworkType.NGRAN,
                                     null /* bands */,
-                                    null /* channels */),
+                                    null /* channels */)
                     },
                     SEARCH_PERIODICITY_SEC,
                     MAX_SEARCH_TIME_SEC,
@@ -153,9 +113,6 @@
 
     private NetworkScan mNetworkScanRequester;
 
-    /** Callbacks for sync network scan */
-    private ListenableFuture<List<CellInfo>> mNetworkScanFuture;
-
     public NetworkScanHelper(TelephonyManager tm, NetworkScanCallback callback, Executor executor) {
         mTelephonyManager = tm;
         mNetworkScanCallback = callback;
@@ -164,63 +121,38 @@
     }
 
     /**
-     * Performs a network scan for the given type {@code type}.
-     * {@link #NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS} is recommended if modem supports
-     * {@link TelephonyManager#requestNetworkScan(
-     * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}.
+     * Request a network scan.
      *
-     * @param type used to tell which network scan API should be used.
+     * Performs the network scan using {@link TelephonyManager#requestNetworkScan(
+     * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)} The network scan
+     * results will be returned to the caller periodically in a small time window until the network
+     * scan is completed. The complete results should be returned in the last called of
+     * {@link NetworkScanCallback#onResults(List)}.
      */
-    public void startNetworkScan(@NetworkQueryType int type) {
-        if (type == NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS) {
-            mNetworkScanFuture = SettableFuture.create();
-            Futures.addCallback(mNetworkScanFuture, new FutureCallback<List<CellInfo>>() {
-                @Override
-                public void onSuccess(List<CellInfo> result) {
-                    onResults(result);
-                    onComplete();
-                }
-
-                @Override
-                public void onFailure(Throwable t) {
-                    if (t instanceof CancellationException) {
-                        return;
-                    }
-                    int errCode = Integer.parseInt(t.getMessage());
-                    onError(errCode);
-                }
-            }, MoreExecutors.directExecutor());
-            mExecutor.execute(new NetworkScanSyncTask(
-                    mTelephonyManager, (SettableFuture) mNetworkScanFuture));
-        } else if (type == NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS) {
-            if (mNetworkScanRequester != null) {
-                return;
-            }
-            mNetworkScanRequester = mTelephonyManager.requestNetworkScan(
-                    NETWORK_SCAN_REQUEST,
-                    mExecutor,
-                    mInternalNetworkScanCallback);
-            if (mNetworkScanRequester == null) {
-                onError(NetworkScan.ERROR_RADIO_INTERFACE_ERROR);
-            }
+    public void startNetworkScan() {
+        if (mNetworkScanRequester != null) {
+            return;
+        }
+        mNetworkScanRequester = mTelephonyManager.requestNetworkScan(
+                NETWORK_SCAN_REQUEST,
+                mExecutor,
+                mInternalNetworkScanCallback);
+        if (mNetworkScanRequester == null) {
+            onError(NetworkScan.ERROR_RADIO_INTERFACE_ERROR);
         }
     }
 
     /**
-     * The network scan of type {@link #NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS} can't be stopped,
-     * however, the result of the current network scan won't be returned to the callback after
-     * calling this method.
+     * Stops the network scan.
+     *
+     * Use this method to stop an ongoing scan. When user requests a new scan, a {@link NetworkScan}
+     * object will be returned, and the user can stop the scan by calling this method.
      */
     public void stopNetworkQuery() {
         if (mNetworkScanRequester != null) {
             mNetworkScanRequester.stopScan();
             mNetworkScanRequester = null;
         }
-
-        if (mNetworkScanFuture != null) {
-            mNetworkScanFuture.cancel(true /* mayInterruptIfRunning */);
-            mNetworkScanFuture = null;
-        }
     }
 
     private void onResults(List<CellInfo> cellInfos) {
@@ -235,23 +167,6 @@
         mNetworkScanCallback.onError(errCode);
     }
 
-    /**
-     * Converts the status code of {@link CellNetworkScanResult} to one of the
-     * {@link NetworkScan.ScanErrorCode}.
-     * @param errCode status code from {@link CellNetworkScanResult}.
-     *
-     * @return one of the scan error code from {@link NetworkScan.ScanErrorCode}.
-     */
-    private static int convertToScanErrorCode(int errCode) {
-        switch (errCode) {
-            case CellNetworkScanResult.STATUS_RADIO_NOT_AVAILABLE:
-                return NetworkScan.ERROR_RADIO_INTERFACE_ERROR;
-            case CellNetworkScanResult.STATUS_RADIO_GENERIC_FAILURE:
-            default:
-                return NetworkScan.ERROR_MODEM_ERROR;
-        }
-    }
-
     private final class NetworkScanCallbackImpl extends TelephonyScanManager.NetworkScanCallback {
         public void onResults(List<CellInfo> results) {
             Log.d(TAG, "Async scan onResults() results = "
@@ -269,35 +184,4 @@
             NetworkScanHelper.this.onError(errCode);
         }
     }
-
-    private static final class NetworkScanSyncTask implements Runnable {
-        private final SettableFuture<List<CellInfo>> mCallback;
-        private final TelephonyManager mTelephonyManager;
-
-        NetworkScanSyncTask(
-                TelephonyManager telephonyManager, SettableFuture<List<CellInfo>> callback) {
-            mTelephonyManager = telephonyManager;
-            mCallback = callback;
-        }
-
-        @Override
-        public void run() {
-            final CellNetworkScanResult result = mTelephonyManager.getAvailableNetworks();
-            if (result.getStatus() == CellNetworkScanResult.STATUS_SUCCESS) {
-                final List<CellInfo> cellInfos = result.getOperators()
-                        .stream()
-                        .map(operatorInfo
-                                -> CellInfoUtil.convertOperatorInfoToCellInfo(operatorInfo))
-                        .collect(Collectors.toList());
-                Log.d(TAG, "Sync network scan completed, cellInfos = "
-                        + CellInfoUtil.cellInfoListToString(cellInfos));
-                mCallback.set(cellInfos);
-            } else {
-                final Throwable error = new Throwable(
-                        Integer.toString(convertToScanErrorCode(result.getStatus())));
-                mCallback.setException(error);
-                Log.d(TAG, "Sync network scan error, ex = " + error);
-            }
-        }
-    }
 }
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index 8b3e913..584848f 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -93,8 +93,6 @@
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
-        mUseNewApi = getContext().getResources().getBoolean(
-                com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI);
         mSubId = getArguments().getInt(Settings.EXTRA_SUB_ID);
 
         mPreferenceCategory = findPreference(PREF_KEY_NETWORK_OPERATORS);
@@ -468,10 +466,7 @@
         if (mNetworkScanHelper != null) {
             mRequestIdManualNetworkScan = getNewRequestId();
             mWaitingForNumberOfScanResults = MIN_NUMBER_OF_SCAN_REQUIRED;
-            mNetworkScanHelper.startNetworkScan(
-                    mUseNewApi
-                            ? NetworkScanHelper.NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS
-                            : NetworkScanHelper.NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS);
+            mNetworkScanHelper.startNetworkScan();
         }
     }
 
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
index e6c1c22..ac068c1 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.os.SystemProperties;
 import android.provider.Settings;
+import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 
 import androidx.annotation.VisibleForTesting;
@@ -57,7 +58,7 @@
         listPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
         final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.CDMA_SUBSCRIPTION_MODE, Phone.PREFERRED_CDMA_SUBSCRIPTION);
-        if (mode != Phone.CDMA_SUBSCRIPTION_UNKNOWN) {
+        if (mode != TelephonyManager.CDMA_SUBSCRIPTION_UNKNOWN) {
             listPreference.setValue(Integer.toString(mode));
         }
     }
diff --git a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
index 82c6ce4..17475df 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
@@ -41,6 +41,8 @@
 
 import com.android.settings.R;
 
+import com.google.android.setupcompat.template.FooterButton;
+
 import org.json.JSONArray;
 import org.json.JSONObject;
 
@@ -88,8 +90,8 @@
                 Log.d(TAG, sb.toString());
             }
 
-            showErrorUi(code, ssid, channelListArray, operatingClassArray,
-                    /* isConfigurationChange */ false);
+            showErrorUi(code, getResultIntent(code, ssid, channelListArray,
+                    operatingClassArray), /* isConfigurationChange */ false);
         }
 
         @Override
@@ -120,8 +122,53 @@
         }
     }
 
-    private void showErrorUi(int code, String ssid, SparseArray<int[]> channelListArray,
-            int[] operatingClassArray, boolean isConfigurationChange) {
+    private Intent getResultIntent(int code, String ssid, SparseArray<int[]> channelListArray,
+            int[] operatingClassArray) {
+        Intent intent = new Intent();
+        intent.putExtra(EXTRA_EASY_CONNECT_ERROR_CODE, code);
+
+        if (!TextUtils.isEmpty(ssid)) {
+            intent.putExtra(EXTRA_EASY_CONNECT_ATTEMPTED_SSID, ssid);
+        }
+        if (channelListArray != null && channelListArray.size() != 0) {
+            int key;
+            int index = 0;
+            JSONObject formattedChannelList = new JSONObject();
+
+            // Build a JSON array of operating classes, with an array of channels for each
+            // operating class.
+            do {
+                try {
+                    key = channelListArray.keyAt(index);
+                } catch (java.lang.ArrayIndexOutOfBoundsException e) {
+                    break;
+                }
+                JSONArray channelsInClassArray = new JSONArray();
+
+                int[] output = channelListArray.get(key);
+                for (int i = 0; i < output.length; i++) {
+                    channelsInClassArray.put(output[i]);
+                }
+                try {
+                    formattedChannelList.put(Integer.toString(key), channelsInClassArray);
+                } catch (org.json.JSONException e) {
+                    formattedChannelList = new JSONObject();
+                    break;
+                }
+                index++;
+            } while (true);
+
+            intent.putExtra(EXTRA_EASY_CONNECT_CHANNEL_LIST,
+                    formattedChannelList.toString());
+        }
+        if (operatingClassArray != null && operatingClassArray.length != 0) {
+            intent.putExtra(EXTRA_EASY_CONNECT_BAND_LIST, operatingClassArray);
+        }
+
+        return intent;
+    }
+
+    private void showErrorUi(int code, Intent resultIntent, boolean isConfigurationChange) {
         CharSequence summaryCharSequence;
         switch (code) {
             case EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_INVALID_URI:
@@ -198,56 +245,18 @@
         mSummary.setText(summaryCharSequence);
         mWifiApPictureView.setImageResource(R.drawable.wifi_dpp_error);
         mChooseDifferentNetwork.setVisibility(View.INVISIBLE);
+        FooterButton finishingButton = mLeftButton;
         if (hasRetryButton(code)) {
             mRightButton.setText(getContext(), R.string.retry);
         } else {
             mRightButton.setText(getContext(), R.string.done);
-            mRightButton.setOnClickListener(v -> {
-                final Activity activity = getActivity();
-                final Intent intent = activity.getIntent();
-                intent.putExtra(EXTRA_EASY_CONNECT_ERROR_CODE, code);
-
-                if (!TextUtils.isEmpty(ssid)) {
-                    intent.putExtra(EXTRA_EASY_CONNECT_ATTEMPTED_SSID, ssid);
-                }
-                if (channelListArray != null && channelListArray.size() != 0) {
-                    int key;
-                    int index = 0;
-                    JSONObject formattedChannelList = new JSONObject();
-
-                    // Build a JSON array of operating classes, with an array of channels for each
-                    // operating class.
-                    do {
-                        try {
-                            key = channelListArray.keyAt(index);
-                        } catch (java.lang.ArrayIndexOutOfBoundsException e) {
-                            break;
-                        }
-                        JSONArray channelsInClassArray = new JSONArray();
-
-                        int[] output = channelListArray.get(key);
-                        for (int i = 0; i < output.length; i++) {
-                            channelsInClassArray.put(output[i]);
-                        }
-                        try {
-                            formattedChannelList.put(Integer.toString(key), channelsInClassArray);
-                        } catch (org.json.JSONException e) {
-                            formattedChannelList = new JSONObject();
-                            break;
-                        }
-                        index++;
-                    } while (true);
-
-                    intent.putExtra(EXTRA_EASY_CONNECT_CHANNEL_LIST,
-                            formattedChannelList.toString());
-                }
-                if (operatingClassArray != null && operatingClassArray.length != 0) {
-                    intent.putExtra(EXTRA_EASY_CONNECT_BAND_LIST, operatingClassArray);
-                }
-                activity.finish();
-            });
+            finishingButton = mRightButton;
             mLeftButton.setVisibility(View.INVISIBLE);
         }
+        finishingButton.setOnClickListener(v -> {
+            getActivity().setResult(Activity.RESULT_CANCELED, resultIntent);
+            getActivity().finish();
+        });
 
         if (isEasyConnectHandshaking()) {
             mSummary.setText(R.string.wifi_dpp_sharing_wifi_with_this_device);
@@ -356,8 +365,8 @@
                 mRightButton.setVisibility(isEasyConnectHandshaking() ?
                         View.INVISIBLE : View.VISIBLE);
             } else {
-                showErrorUi(mLatestStatusCode, /*ssid */null, /* channelListArray */
-                        null, /* operatingClassArray */ null, /* isConfigurationChange */ true);
+                showErrorUi(mLatestStatusCode, /* reslutIntent */ null, /* isConfigurationChange */
+                        true);
             }
         }
     }
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index cb72a6d..b19e3b8 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -78,6 +78,16 @@
     /** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_EASY_CONNECT_URI */
     private WifiQrCode mWifiDppQrCode;
 
+    /**
+     * The remote device's band support obtained as an (optional) extra
+     * EXTRA_EASY_CONNECT_BAND_LIST from the intent ACTION_PROCESS_WIFI_EASY_CONNECT_URI.
+     *
+     * The band support is provided as IEEE 802.11 Global Operating Classes. There may be a single
+     * or multiple operating classes specified. The array may also be a null if the extra wasn't
+     * specified.
+     */
+    private int[] mWifiDppRemoteBandSupport;
+
     /** Secret extra that allows fake networks to show in UI for testing purposes */
     private boolean mIsTest;
 
@@ -141,9 +151,16 @@
                 final String uriString = (uri == null) ? null : uri.toString();
                 mIsTest = intent.getBooleanExtra(WifiDppUtils.EXTRA_TEST, false);
                 mWifiDppQrCode = WifiQrCode.getValidWifiDppQrCodeOrNull(uriString);
+                mWifiDppRemoteBandSupport = intent.getIntArrayExtra(
+                        Settings.EXTRA_EASY_CONNECT_BAND_LIST); // returns null if none
                 final boolean isDppSupported = WifiDppUtils.isWifiDppEnabled(this);
                 if (!isDppSupported) {
-                    Log.d(TAG, "Device doesn't support Wifi DPP");
+                    Log.e(TAG,
+                            "ACTION_PROCESS_WIFI_EASY_CONNECT_URI for a device that doesn't "
+                                    + "support Wifi DPP - use WifiManager#isEasyConnectSupported");
+                }
+                if (mWifiDppQrCode == null) {
+                    Log.e(TAG, "ACTION_PROCESS_WIFI_EASY_CONNECT_URI with null URI!");
                 }
                 if (mWifiDppQrCode == null || !isDppSupported) {
                     cancelActivity = true;
diff --git a/tests/robotests/src/com/android/settings/AllInOneTetherSettingsTest.java b/tests/robotests/src/com/android/settings/AllInOneTetherSettingsTest.java
new file mode 100644
index 0000000..51c856a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/AllInOneTetherSettingsTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.os.UserHandle;
+import android.os.UserManager;
+
+import com.android.settings.testutils.shadow.ShadowWifiManager;
+import com.android.settings.wifi.tether.WifiTetherAutoOffPreferenceController;
+
+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.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowWifiManager.class})
+public class AllInOneTetherSettingsTest {
+    private static final String[] WIFI_REGEXS = {"wifi_regexs"};
+
+    private Context mContext;
+    private AllInOneTetherSettings mAllInOneTetherSettings;
+
+    @Mock
+    private ConnectivityManager mConnectivityManager;
+    @Mock
+    private UserManager mUserManager;
+
+    @Before
+    public void setUp() {
+        mContext = spy(RuntimeEnvironment.application);
+
+        MockitoAnnotations.initMocks(this);
+        doReturn(mConnectivityManager)
+                .when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
+        doReturn(WIFI_REGEXS).when(mConnectivityManager).getTetherableWifiRegexs();
+        doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
+
+        mAllInOneTetherSettings = new AllInOneTetherSettings();
+    }
+
+    @Test
+    public void getNonIndexableKeys_tetherAvailable_keysNotReturned() {
+        // To let TetherUtil.isTetherAvailable return true, select one of the combinations
+        setupIsTetherAvailable(true);
+
+        final List<String> niks =
+                AllInOneTetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+        assertThat(niks).doesNotContain(AllInOneTetherSettings.KEY_WIFI_TETHER_NETWORK_NAME);
+        assertThat(niks).doesNotContain(AllInOneTetherSettings.KEY_WIFI_TETHER_NETWORK_PASSWORD);
+        assertThat(niks).doesNotContain(AllInOneTetherSettings.KEY_WIFI_TETHER_AUTO_OFF);
+        assertThat(niks).doesNotContain(AllInOneTetherSettings.KEY_WIFI_TETHER_NETWORK_AP_BAND);
+        assertThat(niks).doesNotContain(AllInOneTetherSettings.KEY_TETHER_PREFS_SCREEN);
+    }
+
+    @Test
+    public void getNonIndexableKeys_tetherNotAvailable_keysReturned() {
+        // To let TetherUtil.isTetherAvailable return false, select one of the combinations
+        setupIsTetherAvailable(false);
+
+        final List<String> niks =
+                AllInOneTetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
+
+        assertThat(niks).contains(AllInOneTetherSettings.KEY_WIFI_TETHER_NETWORK_NAME);
+        assertThat(niks).contains(AllInOneTetherSettings.KEY_WIFI_TETHER_NETWORK_PASSWORD);
+        assertThat(niks).contains(AllInOneTetherSettings.KEY_WIFI_TETHER_AUTO_OFF);
+        assertThat(niks).contains(AllInOneTetherSettings.KEY_WIFI_TETHER_NETWORK_AP_BAND);
+        assertThat(niks).contains(AllInOneTetherSettings.KEY_TETHER_PREFS_SCREEN);
+    }
+
+    @Test
+    public void getPreferenceControllers_notEmpty() {
+        assertThat(AllInOneTetherSettings.SEARCH_INDEX_DATA_PROVIDER
+                .getPreferenceControllers(mContext)).isNotEmpty();
+    }
+
+    @Test
+    public void createPreferenceControllers_hasAutoOffPreference() {
+        assertThat(mAllInOneTetherSettings.createPreferenceControllers(mContext)
+                .stream()
+                .filter(controller -> controller instanceof WifiTetherAutoOffPreferenceController)
+                .count())
+                .isEqualTo(1);
+    }
+
+    private void setupIsTetherAvailable(boolean returnValue) {
+        when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
+
+        // For RestrictedLockUtils.checkIfRestrictionEnforced
+        final int userId = UserHandle.myUserId();
+        List<UserManager.EnforcingUser> enforcingUsers = new ArrayList<>();
+        when(mUserManager.getUserRestrictionSources(
+                UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.of(userId)))
+                .thenReturn(enforcingUsers);
+
+        // For RestrictedLockUtils.hasBaseUserRestriction
+        when(mUserManager.hasBaseUserRestriction(
+                UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.of(userId)))
+                .thenReturn(!returnValue);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
index 152ba22..e8116c4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
@@ -53,6 +53,8 @@
             DUMMY_CLASS_NAME2);
     private static final String SOFTWARE_SHORTCUT_KEY =
             Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT;
+    private static final String HARDWARE_SHORTCUT_KEY =
+            Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
 
     private Context mContext;
 
@@ -133,7 +135,7 @@
     }
 
     @Test
-    public void hasValueInSettings_dummyComponentName_hasValue() {
+    public void hasValueInSettings_putValue_hasValue() {
         putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString());
 
         assertThat(AccessibilityUtil.hasValueInSettings(mContext, UserShortcutType.SOFTWARE,
@@ -141,7 +143,20 @@
     }
 
     @Test
-    public void optInValueToSettings_optInDummyComponentName2_haveDummyComponentName2String() {
+    public void optInAllValuesToSettings_optInValue_haveMatchString() {
+        int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE;
+
+        AccessibilityUtil.optInAllValuesToSettings(mContext, shortcutTypes, DUMMY_COMPONENT_NAME);
+
+        assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
+                DUMMY_COMPONENT_NAME.flattenToString());
+        assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEqualTo(
+                DUMMY_COMPONENT_NAME.flattenToString());
+
+    }
+
+    @Test
+    public void optInValueToSettings_optInValue_haveMatchString() {
         putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString());
         AccessibilityUtil.optInValueToSettings(mContext, UserShortcutType.SOFTWARE,
                 DUMMY_COMPONENT_NAME2);
@@ -152,7 +167,7 @@
     }
 
     @Test
-    public void optInValueToSettings_optInTwoDummyComponentName_haveOneDummyComponentName2String() {
+    public void optInValueToSettings_optInTwoValues_haveMatchString() {
         putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString());
         AccessibilityUtil.optInValueToSettings(mContext, UserShortcutType.SOFTWARE,
                 DUMMY_COMPONENT_NAME2);
@@ -165,7 +180,21 @@
     }
 
     @Test
-    public void optOutValueFromSettings_optOutDummyComponentName_emptyValue() {
+    public void optOutAllValuesToSettings_optOutValue_emptyString() {
+        putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString());
+        putStringIntoSettings(HARDWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString());
+        int shortcutTypes =
+                UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP;
+
+        AccessibilityUtil.optOutAllValuesFromSettings(mContext, shortcutTypes,
+                DUMMY_COMPONENT_NAME);
+
+        assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty();
+        assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEmpty();
+    }
+
+    @Test
+    public void optOutValueFromSettings_optOutValue_emptyString() {
         putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString());
         AccessibilityUtil.optOutValueFromSettings(mContext, UserShortcutType.SOFTWARE,
                 DUMMY_COMPONENT_NAME);
@@ -174,7 +203,7 @@
     }
 
     @Test
-    public void optOutValueFromSettings_optOutDummyComponentName2_haveDummyComponentName() {
+    public void optOutValueFromSettings_optOutValue_haveMatchString() {
         putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString() + ":"
                 + DUMMY_COMPONENT_NAME2.flattenToString());
         AccessibilityUtil.optOutValueFromSettings(mContext, UserShortcutType.SOFTWARE,
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationEnablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationEnablePreferenceControllerTest.java
new file mode 100644
index 0000000..a34e04a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationEnablePreferenceControllerTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2020 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import androidx.preference.SwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class MagnificationEnablePreferenceControllerTest {
+    private static final String PREF_KEY = "screen_magnification_enable";
+    private static final String KEY_ENABLE = Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE;
+    private static final int UNKNOWN = -1;
+    private Context mContext;
+    private SwitchPreference mPreference;
+    private MagnificationEnablePreferenceController mController;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SwitchPreference(mContext);
+        mController = new MagnificationEnablePreferenceController(mContext, PREF_KEY);
+    }
+
+    @Test
+    public void isChecked_enabledFullscreenMagnificationMode_shouldReturnTrue() {
+        Settings.Secure.putIntForUser(mContext.getContentResolver(),
+                KEY_ENABLE, Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN,
+                UserHandle.USER_CURRENT);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isTrue();
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void isChecked_enabledWindowMagnificationMode_shouldReturnFalse() {
+        Settings.Secure.putIntForUser(mContext.getContentResolver(),
+                KEY_ENABLE, Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW,
+                UserHandle.USER_CURRENT);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isFalse();
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+
+    @Test
+    public void setChecked_setTrue_shouldEnableFullscreenMagnificationMode() {
+        mController.setChecked(true);
+
+        assertThat(Settings.Secure.getIntForUser(mContext.getContentResolver(),
+                KEY_ENABLE, UNKNOWN,
+                UserHandle.USER_CURRENT)).isEqualTo(
+                Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
+    }
+
+    @Test
+    public void setChecked_setFalse_shouldEnableWindowMagnificationMode() {
+        mController.setChecked(false);
+
+        assertThat(Settings.Secure.getIntForUser(mContext.getContentResolver(),
+                KEY_ENABLE, UNKNOWN,
+                UserHandle.USER_CURRENT)).isEqualTo(
+                Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationWindowControlPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationWindowControlPreferenceControllerTest.java
deleted file mode 100644
index 05dbb57..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationWindowControlPreferenceControllerTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.os.UserHandle;
-import android.provider.Settings;
-
-import androidx.preference.SwitchPreference;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@RunWith(RobolectricTestRunner.class)
-public class MagnificationWindowControlPreferenceControllerTest {
-    private static final String PREF_KEY = "screen_magnification_window_control_switch";
-    // TODO(b/146019459): Use magnification_window_control_enabled.
-    private static final String KEY_CONTROL = Settings.System.MASTER_MONO;
-    private Context mContext;
-    private SwitchPreference mPreference;
-    private MagnificationWindowControlPreferenceController mController;
-
-    @Before
-    public void setUp() {
-        mContext = RuntimeEnvironment.application;
-        mPreference = new SwitchPreference(mContext);
-        mController = new MagnificationWindowControlPreferenceController(mContext, PREF_KEY);
-    }
-
-    @Test
-    public void isChecked_enabledWindowControl_shouldReturnTrue() {
-        Settings.System.putIntForUser(mContext.getContentResolver(),
-                KEY_CONTROL, State.ON, UserHandle.USER_CURRENT);
-
-        mController.updateState(mPreference);
-
-        assertThat(mController.isChecked()).isTrue();
-        assertThat(mPreference.isChecked()).isTrue();
-    }
-
-    @Test
-    public void isChecked_disabledWindowControl_shouldReturnFalse() {
-        Settings.System.putIntForUser(mContext.getContentResolver(),
-                KEY_CONTROL, State.OFF, UserHandle.USER_CURRENT);
-
-        mController.updateState(mPreference);
-
-        assertThat(mController.isChecked()).isFalse();
-        assertThat(mPreference.isChecked()).isFalse();
-    }
-
-    @Test
-    public void setChecked_setTrue_shouldEnableWindowControl() {
-        mController.setChecked(true);
-
-        assertThat(Settings.System.getIntForUser(mContext.getContentResolver(),
-                KEY_CONTROL, State.UNKNOWN, UserHandle.USER_CURRENT)).isEqualTo(State.ON);
-    }
-
-    @Test
-    public void setChecked_setFalse_shouldDisableWindowControl() {
-        mController.setChecked(false);
-
-        assertThat(Settings.System.getIntForUser(mContext.getContentResolver(),
-                KEY_CONTROL, State.UNKNOWN, UserHandle.USER_CURRENT)).isEqualTo(State.OFF);
-    }
-
-    @Retention(RetentionPolicy.SOURCE)
-    private @interface State {
-        int UNKNOWN = -1;
-        int OFF = 0;
-        int ON = 1;
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java
index 15c3c21..f3522a9 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ShortcutPreferenceTest.java
@@ -69,7 +69,7 @@
     }
 
     @Test
-    public void testClickLinearLayout_checkboxClicked() {
+    public void clickLinearLayout_checkboxClicked() {
         mShortcutPreference.onBindViewHolder(mPreferenceViewHolder);
         mShortcutPreference.setOnClickListener(mListener);
 
@@ -81,7 +81,7 @@
     }
 
     @Test
-    public void testClickSettings_settingsClicked() {
+    public void clickSettings_settingsClicked() {
         mShortcutPreference.onBindViewHolder(mPreferenceViewHolder);
         mShortcutPreference.setOnClickListener(mListener);
 
@@ -92,7 +92,7 @@
     }
 
     @Test
-    public void testSetCheckedTrue_getCheckedIsTrue() {
+    public void setCheckedTrue_getCheckedIsTrue() {
         mShortcutPreference.setChecked(true);
 
         assertThat(mShortcutPreference.getChecked()).isEqualTo(true);
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
new file mode 100644
index 0000000..3a2aa4c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2020 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.accessibility;
+
+import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.provider.Settings;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class ToggleScreenMagnificationPreferenceFragmentTest {
+
+    private static final String DUMMY_PACKAGE_NAME = "com.dummy.example";
+    private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".dummy_a11y_service";
+    private static final ComponentName DUMMY_COMPONENT_NAME = new ComponentName(DUMMY_PACKAGE_NAME,
+            DUMMY_CLASS_NAME);
+    private static final String SOFTWARE_SHORTCUT_KEY =
+            Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT;
+    private static final String HARDWARE_SHORTCUT_KEY =
+            Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
+    private static final String TRIPLETAP_SHORTCUT_KEY =
+            Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED;
+    private static final String MAGNIFICATION_CONTROLLER_NAME =
+            "com.android.server.accessibility.MagnificationController";
+
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+    }
+
+    @Test
+    public void hasValueInSettings_putValue_hasValue() {
+        putStringIntoSettings(TRIPLETAP_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
+
+        assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
+                mContext, UserShortcutType.TRIPLETAP)).isTrue();
+    }
+
+    @Test
+    public void optInAllValuesToSettings_optInValue_haveMatchString() {
+        int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP;
+
+        ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
+                shortcutTypes);
+
+        assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
+                MAGNIFICATION_CONTROLLER_NAME);
+        assertThat(getStringFromSettings(TRIPLETAP_SHORTCUT_KEY)).isEqualTo(
+                MAGNIFICATION_CONTROLLER_NAME);
+
+    }
+
+    @Test
+    public void optInAllValuesToSettings_existOtherValue_optInValue_haveMatchString() {
+        putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, DUMMY_COMPONENT_NAME.flattenToString());
+
+        ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
+                UserShortcutType.SOFTWARE);
+
+        assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
+                DUMMY_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
+
+    }
+
+    @Test
+    public void optOutAllValuesToSettings_optOutValue_emptyString() {
+        putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
+        putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
+        putStringIntoSettings(TRIPLETAP_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
+        int shortcutTypes =
+                UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP;
+
+        ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
+                mContext, shortcutTypes);
+
+        assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty();
+        assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEmpty();
+        assertThat(getStringFromSettings(TRIPLETAP_SHORTCUT_KEY)).isEmpty();
+    }
+
+    @Test
+    public void optOutValueFromSettings_existOtherValue_optOutValue_haveMatchString() {
+        putStringIntoSettings(SOFTWARE_SHORTCUT_KEY,
+                DUMMY_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
+        putStringIntoSettings(HARDWARE_SHORTCUT_KEY,
+                DUMMY_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
+        int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE;
+
+        ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
+                mContext, shortcutTypes);
+
+        assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
+                DUMMY_COMPONENT_NAME.flattenToString());
+        assertThat(getStringFromSettings(HARDWARE_SHORTCUT_KEY)).isEqualTo(
+                DUMMY_COMPONENT_NAME.flattenToString());
+    }
+
+    private void putStringIntoSettings(String key, String componentName) {
+        Settings.Secure.putString(mContext.getContentResolver(), key, componentName);
+    }
+
+    private String getStringFromSettings(String key) {
+        return Settings.Secure.getString(mContext.getContentResolver(), key);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
index eaa4c3c..f52685c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsButtonsControllerTest.java
@@ -22,7 +22,6 @@
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -103,7 +102,7 @@
         verify(mButtonsPref).setButton2Text(R.string.bluetooth_device_context_connect);
 
         mConnectButton.callOnClick();
-        verify(mCachedDevice).connect(eq(true));
+        verify(mCachedDevice).connect();
     }
 
     @Test
@@ -119,7 +118,7 @@
 
         // Click the button and make sure that connect (not disconnect) gets called.
         mConnectButton.callOnClick();
-        verify(mCachedDevice).connect(eq(true));
+        verify(mCachedDevice).connect();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index 4cc9b87..d329f5c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -122,6 +122,6 @@
     public void onClick_Preference_setConnect() {
         mBluetoothDeviceUpdater.onPreferenceClick(mPreference);
 
-        verify(mCachedBluetoothDevice).connect(true);
+        verify(mCachedBluetoothDevice).connect();
     }
 }
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
index 88acbd0..851dfe0 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
@@ -24,6 +24,7 @@
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.ICCID_INFO_VALUE_ID;
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.IMS_REGISTRATION_STATE_LABEL_ID;
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.IMS_REGISTRATION_STATE_VALUE_ID;
+import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.MAX_PHONE_COUNT_SINGLE_SIM;
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.NETWORK_PROVIDER_VALUE_ID;
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.OPERATOR_INFO_LABEL_ID;
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.OPERATOR_INFO_VALUE_ID;
@@ -33,6 +34,7 @@
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.SIGNAL_STRENGTH_LABEL_ID;
 import static com.android.settings.deviceinfo.simstatus.SimStatusDialogController.SIGNAL_STRENGTH_VALUE_ID;
 
+
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;
@@ -61,7 +63,6 @@
 
 import androidx.lifecycle.LifecycleOwner;
 
-import com.android.internal.telephony.PhoneConstants;
 import com.android.settings.R;
 import com.android.settings.testutils.shadow.ShadowDeviceInfoUtils;
 import com.android.settingslib.DeviceInfoUtils;
@@ -125,6 +126,8 @@
     private static final String TEST_EID_FROM_CARD = "11111111111111111111111111111111";
     private static final String TEST_EID_FROM_MANAGER = "22222222222222222222222222222222";
 
+    private static final int MAX_PHONE_COUNT_DUAL_SIM = 2;
+
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
@@ -152,8 +155,7 @@
         ReflectionHelpers.setField(mController, "mEuiccManager", mEuiccManager);
         ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
 
-        when(mTelephonyManager.getPhoneCount()).thenReturn(
-                PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
         when(mTelephonyManager.getUiccCardsInfo()).thenReturn(new ArrayList<UiccCardInfo>());
         when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn(
                 new HashMap<Integer, Integer>());
@@ -429,7 +431,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldNotSetEid() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -468,7 +470,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldSetEidFromCard() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -507,7 +509,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldSetEidFromManager() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -549,7 +551,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldRemoveEid() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo1 = new UiccCardInfo(
@@ -589,8 +591,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldNotSetEidInSingleSimMode() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(
-                PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo = new UiccCardInfo(
@@ -620,8 +621,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldSetEidInSingleSimModeWithEnabledEuicc() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(
-                PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo = new UiccCardInfo(
@@ -653,8 +653,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldSetEidInSingleSimModeWithDisabledEuicc() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(
-                PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo = new UiccCardInfo(
@@ -686,8 +685,7 @@
     @Test
     @Ignore
     public void initialize_updateEid_shouldRemoveEidInSingleSimMode() {
-        when(mTelephonyManager.getPhoneCount()).thenReturn(
-                PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM);
+        when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
         ArrayList<UiccCardInfo> uiccCardInfos = new ArrayList<>();
         UiccCardInfo uiccCardInfo = new UiccCardInfo(
diff --git a/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java
index 2e9fa30..f92b012 100644
--- a/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaDeviceUpdateWorkerTest.java
@@ -20,6 +20,7 @@
 
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -31,6 +32,7 @@
 import android.media.AudioManager;
 import android.net.Uri;
 
+import com.android.settings.testutils.shadow.ShadowAudioManager;
 import com.android.settingslib.media.LocalMediaManager;
 import com.android.settingslib.media.MediaDevice;
 
@@ -40,12 +42,14 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
 import java.util.ArrayList;
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowAudioManager.class)
 public class MediaDeviceUpdateWorkerTest {
 
     private static final Uri URI = Uri.parse("content://com.android.settings.slices/test");
@@ -61,6 +65,7 @@
     private MediaDevice mMediaDevice1;
     private MediaDevice mMediaDevice2;
     private ShadowApplication mShadowApplication;
+    private AudioManager mAudioManager;
 
     @Before
     public void setUp() {
@@ -69,6 +74,7 @@
         mMediaDeviceUpdateWorker = new MediaDeviceUpdateWorker(mContext, URI);
         mResolver = mock(ContentResolver.class);
         mShadowApplication = ShadowApplication.getInstance();
+        mAudioManager = mContext.getSystemService(AudioManager.class);
 
         mMediaDevice1 = mock(MediaDevice.class);
         when(mMediaDevice1.getId()).thenReturn(TEST_DEVICE_1_ID);
@@ -95,6 +101,13 @@
     }
 
     @Test
+    public void onDeviceAttributesChanged_shouldNotifyChange() {
+        mMediaDeviceUpdateWorker.onDeviceAttributesChanged();
+
+        verify(mResolver).notifyChange(URI, null);
+    }
+
+    @Test
     public void onDeviceListUpdate_sameDeviceList_shouldBeEqual() {
         mMediaDeviceUpdateWorker.onDeviceListUpdate(mMediaDevices);
 
@@ -103,7 +116,8 @@
         newDevices.add(mMediaDevice2);
 
         mMediaDeviceUpdateWorker.onDeviceListUpdate(newDevices);
-        final List<MediaDevice> devices = mMediaDeviceUpdateWorker.getMediaDevices();
+        final List<MediaDevice> devices =
+                new ArrayList<>(mMediaDeviceUpdateWorker.getMediaDevices());
 
         assertThat(devices.get(0).getId()).isEqualTo(newDevices.get(0).getId());
         assertThat(devices.get(1).getId()).isEqualTo(newDevices.get(1).getId());
@@ -121,7 +135,8 @@
         newDevices.add(device3);
 
         mMediaDeviceUpdateWorker.onDeviceListUpdate(newDevices);
-        final List<MediaDevice> devices = mMediaDeviceUpdateWorker.getMediaDevices();
+        final List<MediaDevice> devices =
+                new ArrayList<>(mMediaDeviceUpdateWorker.getMediaDevices());
 
         assertThat(devices.size()).isEqualTo(newDevices.size());
     }
@@ -134,14 +149,16 @@
         newDevices.add(mMediaDevice1);
 
         mMediaDeviceUpdateWorker.onDeviceListUpdate(newDevices);
-        final List<MediaDevice> devices = mMediaDeviceUpdateWorker.getMediaDevices();
+        final List<MediaDevice> devices =
+                new ArrayList<>(mMediaDeviceUpdateWorker.getMediaDevices());
 
         assertThat(devices.size()).isEqualTo(newDevices.size());
     }
 
     @Test
-    public void onReceive_shouldNotifyChange() {
+    public void onReceive_inCallState_shouldNotifyChange() {
         mMediaDeviceUpdateWorker.mLocalMediaManager = mock(LocalMediaManager.class);
+        mAudioManager.setMode(AudioManager.MODE_IN_CALL);
 
         mMediaDeviceUpdateWorker.onSlicePinned();
         final Intent intent = new Intent(AudioManager.STREAM_DEVICES_CHANGED_ACTION);
@@ -151,4 +168,18 @@
 
         verify(mResolver).notifyChange(URI, null);
     }
+
+    @Test
+    public void onReceive_notInCallState_doNothing() {
+        mMediaDeviceUpdateWorker.mLocalMediaManager = mock(LocalMediaManager.class);
+        mAudioManager.setMode(AudioManager.MODE_NORMAL);
+
+        mMediaDeviceUpdateWorker.onSlicePinned();
+        final Intent intent = new Intent(AudioManager.STREAM_DEVICES_CHANGED_ACTION);
+        for (BroadcastReceiver receiver : mShadowApplication.getReceiversForIntent(intent)) {
+            receiver.onReceive(mContext, intent);
+        }
+
+        verify(mResolver, never()).notifyChange(URI, null);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
index 288c8e8..c9b9ff9 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
@@ -64,7 +64,6 @@
 @Config(shadows = {ShadowBluetoothAdapter.class})
 public class MediaOutputSliceTest {
 
-    private static final String TEST_PACKAGE_NAME = "com.fake.android.music";
     private static final String TEST_DEVICE_1_ID = "test_device_1_id";
     private static final String TEST_DEVICE_1_NAME = "test_device_1_name";
     private static final int TEST_DEVICE_1_ICON =
@@ -100,12 +99,12 @@
         mMediaDeviceUpdateWorker = new MediaDeviceUpdateWorker(mContext, MEDIA_OUTPUT_SLICE_URI);
         mMediaDeviceUpdateWorker.onDeviceListUpdate(mDevices);
         mMediaDeviceUpdateWorker.mLocalMediaManager = mLocalMediaManager;
-        mMediaOutputSlice.init(TEST_PACKAGE_NAME, mMediaDeviceUpdateWorker);
+        mMediaOutputSlice.init(mMediaDeviceUpdateWorker);
     }
 
     @Test
     public void getSlice_workerIsNull_shouldReturnZeroRow() {
-        mMediaOutputSlice.init(TEST_PACKAGE_NAME, null);
+        mMediaOutputSlice.init(null);
 
         final Slice slice = mMediaOutputSlice.getSlice();
 
diff --git a/tests/robotests/src/com/android/settings/network/telephony/NetworkOperatorPreferenceTest.java b/tests/robotests/src/com/android/settings/network/telephony/NetworkOperatorPreferenceTest.java
index 3a61195..0c772b7 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/NetworkOperatorPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/NetworkOperatorPreferenceTest.java
@@ -16,35 +16,25 @@
 
 package com.android.settings.network.telephony;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
 import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.telephony.CellInfo;
 
 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.ArrayList;
-
 @RunWith(RobolectricTestRunner.class)
 public class NetworkOperatorPreferenceTest {
     private static final int LEVEL = 2;
 
     @Mock
     private Resources mResources;
-    @Mock
-    private CellInfo mCellInfo;
     private Context mContext;
 
     @Before
@@ -55,16 +45,5 @@
         when(mContext.getResources()).thenReturn(mResources);
     }
 
-    @Test
-    public void setIcon_useOldApi_doNothing() {
-        when(mResources.getBoolean(com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI))
-                .thenReturn(false);
-        final NetworkOperatorPreference preference = spy(
-                new NetworkOperatorPreference(mContext, mCellInfo,
-                        new ArrayList<>() /* forbiddenPlmns */, false /* show4GForLTE */));
-
-        preference.setIcon(LEVEL);
-
-        verify(preference, never()).setIcon(any(Drawable.class));
-    }
+    //TODO: add test cases.
 }
diff --git a/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
index f87a459..b90f0cf 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
@@ -33,9 +33,6 @@
 import android.telephony.TelephonyManager;
 import android.telephony.TelephonyScanManager;
 
-import com.android.internal.telephony.CellNetworkScanResult;
-import com.android.internal.telephony.OperatorInfo;
-
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -47,12 +44,10 @@
 import org.mockito.stubbing.Answer;
 import org.robolectric.RobolectricTestRunner;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
 
 @RunWith(RobolectricTestRunner.class)
 public class NetworkScanHelperTest {
@@ -61,7 +56,7 @@
     private TelephonyManager mTelephonyManager;
 
     @Mock
-    private CellNetworkScanResult mCellNetworkScanResult;
+    private List<CellInfo> mCellInfos;
 
     @Mock
     private NetworkScanHelper.NetworkScanCallback mNetworkScanCallback;
@@ -75,7 +70,6 @@
     private static final int SUB_ID = 1;
 
     private NetworkScan mNetworkScan;
-    private OperatorInfo mOperatorInfo;
 
     @Before
     public void setUp() {
@@ -87,62 +81,11 @@
                 mNetworkScanCallback, mNetworkScanExecutor);
 
         mNetworkScan = spy(new NetworkScan(SCAN_ID, SUB_ID));
-        mOperatorInfo = new OperatorInfo("Testing", "Test", "12345", "unknown");
-    }
-
-    @Test
-    public void startNetworkScan_scanOnceAndSuccess_completionWithResult() {
-        ArrayList<OperatorInfo> expectedResult = new ArrayList<OperatorInfo>();
-        expectedResult.add(mOperatorInfo);
-
-        when(mTelephonyManager.getAvailableNetworks()).thenReturn(mCellNetworkScanResult);
-        when(mCellNetworkScanResult.getStatus()).thenReturn(
-                CellNetworkScanResult.STATUS_SUCCESS);
-        when(mCellNetworkScanResult.getOperators()).thenReturn(expectedResult);
-
-        ArgumentCaptor<List<CellInfo>> argument = ArgumentCaptor.forClass(List.class);
-
-        startNetworkScan_waitForAll(true);
-
-        verify(mNetworkScanCallback, times(1)).onResults(argument.capture());
-        List<CellInfo> actualResult = argument.getValue();
-        assertThat(actualResult.size()).isEqualTo(expectedResult.size());
-        verify(mNetworkScanCallback, times(1)).onComplete();
-    }
-
-    @Test
-    public void startNetworkScan_scanOnceAndFail_failureWithErrorCode() {
-        when(mTelephonyManager.getAvailableNetworks()).thenReturn(mCellNetworkScanResult);
-        when(mCellNetworkScanResult.getStatus()).thenReturn(
-                CellNetworkScanResult.STATUS_RADIO_GENERIC_FAILURE);
-
-        startNetworkScan_waitForAll(true);
-
-        verify(mNetworkScanCallback, times(1)).onError(anyInt());
-    }
-
-    @Test
-    public void startNetworkScan_scanOnceAndAbort_withoutCrash() {
-        when(mCellNetworkScanResult.getStatus()).thenReturn(
-                CellNetworkScanResult.STATUS_RADIO_GENERIC_FAILURE);
-
-        doAnswer(new Answer() {
-            @Override
-            public Object answer(InvocationOnMock invocation) throws Throwable {
-                Thread.sleep(THREAD_EXECUTION_TIMEOUT_MS);
-                return mCellNetworkScanResult;
-            }
-        }).when(mTelephonyManager).getAvailableNetworks();
-
-        startNetworkScan_waitForAll(false);
-
-        verify(mNetworkScanCallback, times(0)).onError(anyInt());
     }
 
     @Test
     public void startNetworkScan_incrementalAndSuccess_completionWithResult() {
-        ArrayList<CellInfo> expectedResult = new ArrayList<CellInfo>();
-        expectedResult.add(CellInfoUtil.convertOperatorInfoToCellInfo(mOperatorInfo));
+        when(mCellInfos.size()).thenReturn(1);
 
         doAnswer(new Answer() {
             @Override
@@ -150,7 +93,7 @@
                 TelephonyScanManager.NetworkScanCallback callback =
                         (TelephonyScanManager.NetworkScanCallback)
                         (invocation.getArguments()[2]);
-                callback.onResults(expectedResult);
+                callback.onResults(mCellInfos);
                 callback.onComplete();
                 return mNetworkScan;
             }
@@ -164,7 +107,7 @@
 
         verify(mNetworkScanCallback, times(1)).onResults(argument.capture());
         List<CellInfo> actualResult = argument.getValue();
-        assertThat(actualResult.size()).isEqualTo(expectedResult.size());
+        assertThat(actualResult.size()).isEqualTo(mCellInfos.size());
         verify(mNetworkScanCallback, times(1)).onComplete();
     }
 
@@ -187,7 +130,7 @@
                 TelephonyScanManager.NetworkScanCallback callback =
                         (TelephonyScanManager.NetworkScanCallback)
                         (invocation.getArguments()[2]);
-                callback.onError(CellNetworkScanResult.STATUS_RADIO_GENERIC_FAILURE);
+                callback.onError(NetworkScan.ERROR_MODEM_ERROR);
                 return mNetworkScan;
             }
         }).when(mTelephonyManager).requestNetworkScan(
@@ -211,28 +154,8 @@
         verify(mNetworkScan, times(1)).stopScan();
     }
 
-    private void startNetworkScan_waitForAll(boolean waitForCompletion) {
-        mNetworkScanHelper.startNetworkScan(
-                NetworkScanHelper.NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS);
-        if (!waitForCompletion) {
-            mNetworkScanHelper.stopNetworkQuery();
-        }
-
-        mNetworkScanExecutor.shutdown();
-
-        boolean executorTerminate = false;
-        try {
-            executorTerminate = mNetworkScanExecutor.awaitTermination(
-                    THREAD_EXECUTION_TIMEOUT_MS, TimeUnit.MILLISECONDS);
-        } catch (Exception ex) {
-        }
-
-        assertThat(executorTerminate).isEqualTo(waitForCompletion);
-    }
-
     private void startNetworkScan_incremental(boolean waitForCompletion) {
-        mNetworkScanHelper.startNetworkScan(
-                NetworkScanHelper.NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS);
+        mNetworkScanHelper.startNetworkScan();
         if (!waitForCompletion) {
             mNetworkScanHelper.stopNetworkQuery();
         }
diff --git a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
index 0d94928..a69ab53 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
@@ -48,6 +48,7 @@
 import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -99,6 +100,7 @@
     }
 
     @Test
+    @Ignore
     public void dialog_cancelButtonClicked_setDisplayNameAndIconTintNotCalled() {
         when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
                 mSubscriptionInfo);
@@ -114,6 +116,7 @@
     }
 
     @Test
+    @Ignore
     public void dialog_saveButtonClicked_setDisplayNameAndIconTint() {
         when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
                 mSubscriptionInfo);
@@ -137,6 +140,7 @@
     }
 
     @Test
+    @Ignore
     public void populateView_infoIsOpportunistic_hideNumberLabel() {
         final View view = LayoutInflater.from(mActivity).inflate(
                 R.layout.dialog_mobile_network_rename, null);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceControllerTest.java
index d94ffae..bcc82ba 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceControllerTest.java
@@ -34,8 +34,6 @@
 import androidx.preference.ListPreference;
 import androidx.preference.PreferenceManager;
 
-import com.android.internal.telephony.Phone;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -90,33 +88,37 @@
     public void onPreferenceChange_selectNV_returnNVMode() {
         doReturn(true).when(mTelephonyManager).setCdmaSubscriptionMode(anyInt());
 
-        mController.onPreferenceChange(mPreference, Integer.toString(Phone.CDMA_SUBSCRIPTION_NV));
+        mController.onPreferenceChange(mPreference, Integer.toString(
+                TelephonyManager.CDMA_SUBSCRIPTION_NV));
 
         assertThat(Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.CDMA_SUBSCRIPTION_MODE,
-                Phone.CDMA_SUBSCRIPTION_RUIM_SIM)).isEqualTo(Phone.CDMA_SUBSCRIPTION_NV);
+                TelephonyManager.CDMA_SUBSCRIPTION_RUIM_SIM)).isEqualTo(
+                        TelephonyManager.CDMA_SUBSCRIPTION_NV);
     }
 
     @Test
     public void updateState_stateRUIM_displayRUIM() {
         Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.CDMA_SUBSCRIPTION_MODE, Phone.CDMA_SUBSCRIPTION_NV);
+                Settings.Global.CDMA_SUBSCRIPTION_MODE, TelephonyManager.CDMA_SUBSCRIPTION_NV);
 
         mController.updateState(mPreference);
 
-        assertThat(mPreference.getValue()).isEqualTo(Integer.toString(Phone.CDMA_SUBSCRIPTION_NV));
+        assertThat(mPreference.getValue()).isEqualTo(Integer.toString(
+                TelephonyManager.CDMA_SUBSCRIPTION_NV));
     }
 
     @Test
     public void updateState_stateUnknown_doNothing() {
-        mPreference.setValue(Integer.toString(Phone.CDMA_SUBSCRIPTION_NV));
+        mPreference.setValue(Integer.toString(TelephonyManager.CDMA_SUBSCRIPTION_NV));
         Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.CDMA_SUBSCRIPTION_MODE, Phone.CDMA_SUBSCRIPTION_UNKNOWN);
+                Settings.Global.CDMA_SUBSCRIPTION_MODE, TelephonyManager.CDMA_SUBSCRIPTION_UNKNOWN);
 
         mController.updateState(mPreference);
 
         // Still NV mode
-        assertThat(mPreference.getValue()).isEqualTo(Integer.toString(Phone.CDMA_SUBSCRIPTION_NV));
+        assertThat(mPreference.getValue()).isEqualTo(Integer.toString(
+                TelephonyManager.CDMA_SUBSCRIPTION_NV));
     }
 
     @Test
diff --git a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
index d068ce0..4ebfef7 100644
--- a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
+++ b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
@@ -15,7 +15,6 @@
  */
 package com.android.settings.wifi;
 
-import static androidx.test.InstrumentationRegistry.getInstrumentation;
 import static androidx.test.espresso.Espresso.onView;
 import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
 import static androidx.test.espresso.assertion.ViewAssertions.matches;
@@ -28,9 +27,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.not;
 import static org.hamcrest.Matchers.startsWith;
-import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -39,9 +36,9 @@
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
-import android.net.wifi.WifiSsid;
 import android.provider.Settings;
 
 import androidx.fragment.app.Fragment;
@@ -60,13 +57,13 @@
 import com.google.common.collect.Lists;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 @RunWith(AndroidJUnit4.class)
@@ -129,11 +126,12 @@
         config.SSID = TEST_SSID;
         config.BSSID = TEST_BSSID;
         config.networkId = TEST_NETWORK_ID;
-        WifiInfo wifiInfo = new WifiInfo();
-        wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
-        wifiInfo.setBSSID(TEST_BSSID);
-        wifiInfo.setRssi(TEST_RSSI);
-        wifiInfo.setNetworkId(TEST_NETWORK_ID);
+        WifiInfo wifiInfo = new WifiInfo.Builder()
+                .setSsid(TEST_UNQUOTED_SSID.getBytes(StandardCharsets.UTF_8))
+                .setBssid(TEST_BSSID)
+                .setRssi(TEST_RSSI)
+                .setNetworkId(TEST_NETWORK_ID)
+                .build();
         NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, null, null);
         networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
         AccessPoint accessPoint = new AccessPoint(mContext, config);
@@ -294,19 +292,20 @@
         config.networkId = TEST_NETWORK_ID;
         config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
 
-        WifiConfiguration.NetworkSelectionStatus selectionStatus =
-                new WifiConfiguration.NetworkSelectionStatus();
-        selectionStatus.setNetworkSelectionDisableReason(
-                WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
-        selectionStatus.setNetworkSelectionStatus(
-                WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED);
+        NetworkSelectionStatus selectionStatus = new NetworkSelectionStatus.Builder()
+                .setNetworkSelectionDisableReason(
+                        NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD)
+                .setNetworkSelectionStatus(
+                        NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED)
+                .build();
         config.setNetworkSelectionStatus(selectionStatus);
 
-        WifiInfo wifiInfo = new WifiInfo();
-        wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
-        wifiInfo.setBSSID(TEST_BSSID);
-        wifiInfo.setRssi(TEST_RSSI);
-        wifiInfo.setNetworkId(TEST_NETWORK_ID);
+        WifiInfo wifiInfo = new WifiInfo.Builder()
+                .setSsid(TEST_UNQUOTED_SSID.getBytes(StandardCharsets.UTF_8))
+                .setBssid(TEST_BSSID)
+                .setRssi(TEST_RSSI)
+                .setNetworkId(TEST_NETWORK_ID)
+                .build();
         AccessPoint accessPoint = new AccessPoint(mContext, config);
         accessPoint.update(config, wifiInfo, null);
 
@@ -315,12 +314,11 @@
         assertThat(accessPoint.getBssid()).isEqualTo(TEST_BSSID);
         assertThat(accessPoint.isActive()).isFalse();
         assertThat(accessPoint.getConfig()).isNotNull();
-        WifiConfiguration.NetworkSelectionStatus networkStatus =
-                accessPoint.getConfig().getNetworkSelectionStatus();
+        NetworkSelectionStatus networkStatus = accessPoint.getConfig().getNetworkSelectionStatus();
         assertThat(networkStatus).isNotNull();
         assertThat(networkStatus.isNetworkEnabled()).isFalse();
         assertThat(networkStatus.getNetworkSelectionDisableReason()).isEqualTo(
-                WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
+                NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
 
         when(mWifiTracker.getAccessPoints()).thenReturn(Lists.newArrayList(accessPoint));
         launchActivity(WifiSettings.EXTRA_START_CONNECT_SSID, accessPoint.getSsidStr());
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
index fe21596..fec0c6f 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiNetworkListFragmentTest.java
@@ -23,9 +23,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
 
 import android.content.Context;
 import android.content.Intent;
@@ -35,7 +33,6 @@
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
-import android.net.wifi.WifiSsid;
 import android.provider.Settings;
 
 import androidx.fragment.app.Fragment;
@@ -45,19 +42,18 @@
 
 import com.android.settingslib.wifi.AccessPoint;
 import com.android.settingslib.wifi.WifiTracker;
-import com.android.settingslib.wifi.WifiTracker.WifiListener;
 import com.android.settingslib.wifi.WifiTrackerFactory;
 
 import com.google.common.collect.Lists;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 @RunWith(AndroidJUnit4.class)
@@ -136,11 +132,12 @@
         config.BSSID = TEST_BSSID;
         config.networkId = TEST_NETWORK_ID;
         config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
-        final WifiInfo wifiInfo = new WifiInfo();
-        wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
-        wifiInfo.setBSSID(TEST_BSSID);
-        wifiInfo.setRssi(TEST_RSSI);
-        wifiInfo.setNetworkId(TEST_NETWORK_ID);
+        final WifiInfo wifiInfo = new WifiInfo.Builder()
+                .setSsid(TEST_UNQUOTED_SSID.getBytes(StandardCharsets.UTF_8))
+                .setBssid(TEST_BSSID)
+                .setRssi(TEST_RSSI)
+                .setNetworkId(TEST_NETWORK_ID)
+                .build();
         final NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, null, null);
         networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
         final AccessPoint accessPoint = new AccessPoint(mContext, config);