Merge "Fix Startup fails when click "Color correction" of the selection menu in "Color correction" page"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ac1e440..3cabb0e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -102,6 +102,7 @@
     <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
     <uses-permission android:name="android.permission.INSTALL_DYNAMIC_SYSTEM" />
+    <uses-permission android:name="android.permission.BIND_CELL_BROADCAST_SERVICE" />
 
     <application android:label="@string/settings_label"
             android:icon="@drawable/ic_launcher_settings"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e5e55c6..05a80a3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2091,7 +2091,9 @@
          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>
+    <string name="wifi_auto_connect_summary" product="default">Allow phone to automatically connect near this network</string>
+    <!-- Hint for Wi-Fi Auto-connect [CHAR LIMIT=NONE]  -->
+    <string name="wifi_auto_connect_summary" product="tablet">Allow tablet to automatically connect near this network</string>
     <!-- Label for "Use a QR code to add a device to this network" [CHAR LIMIT=50]  -->
     <string name="wifi_dpp_add_device">Add device</string>
     <!-- Hint for "Add device" [CHAR LIMIT=NONE]  -->
@@ -2352,7 +2354,7 @@
     <!-- Title for the panel of add Wi-Fi network from APP [CHAR LIMIT=50] -->
     <string name="wifi_add_app_single_network_title">Save this network?</string>
     <!-- Summary for the panel of add Wi-Fi network from APP [CHAR LIMIT=NONE] -->
-    <string name="wifi_add_app_single_network_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> would like to save a network to your phone</string>
+    <string name="wifi_add_app_single_network_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save a network to your phone</string>
     <!-- Summary for saving status when saving single network [CHAR LIMIT=30] -->
     <string name="wifi_add_app_single_network_saving_summary">Saving\u2026</string>
     <!-- Summary for saved status when saving single network   [CHAR LIMIT=30] -->
@@ -2362,7 +2364,7 @@
     <!--  Title for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=50] -->
     <string name="wifi_add_app_networks_title">Save networks?</string>
     <!-- Summary for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
-    <string name="wifi_add_app_networks_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> would like to save these networks to your phone</string>
+    <string name="wifi_add_app_networks_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save these networks to your phone</string>
     <!-- Summary for the panel of add Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
     <string name="wifi_add_app_networks_saving_summary">Saving <xliff:g id="number" example="3">%d</xliff:g> networks\u2026</string>
     <!-- Summary for saved status when saving multiple networks   [CHAR LIMIT=NONE] -->
@@ -5077,9 +5079,12 @@
     <!-- Label describing a high intensity vibration option. [CHAR LIMIT=15] -->
     <string name="accessibility_vibration_intensity_high">High</string>
 
-    <!-- Title for accessibility menu item to lauch a settings activity. [CHAR LIMIT=15] -->
+    <!-- Title for accessibility menu item to launch a settings activity. [CHAR LIMIT=15] -->
     <string name="accessibility_menu_item_settings">Settings</string>
 
+    <!-- Title for accessibility menu item to launch a settings activity with app name. [CHAR LIMIT=30] -->
+    <string name="accessibility_service_menu_item_settings"><xliff:g example="TalkBack" id="accessibility_app_name">%1$s</xliff:g> settings</string>
+
     <!-- Summary for the enabled state of an accessibility feature. [CHAR LIMIT=10] -->
     <string name="accessibility_feature_state_on">On</string>
     <!-- Summary for the disabled state of an accessibility feature. [CHAR LIMIT=10] -->
@@ -5530,13 +5535,9 @@
     <!-- Title for the smart battery toggle [CHAR LIMIT=NONE] -->
     <string name="smart_battery_title">Manage apps automatically</string>
     <!-- Summary for the smart battery toggle [CHAR LIMIT=NONE] -->
-    <string name="smart_battery_summary">Limit battery for apps that you don\u2019t use often</string>
+    <string name="smart_battery_summary" product="default">Limit battery for apps that you don\u2019t use often</string>
     <!-- Footer for the aosp smart battery page -->
-    <string name="smart_battery_footer" product="default">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
-    <!-- Footer for the aosp smart battery page -->
-    <string name="smart_battery_footer" product="tablet">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
-    <!-- Footer for the aosp smart battery page -->
-    <string name="smart_battery_footer" product="device">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
+    <string name="smart_battery_footer">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
     <!-- Title for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
     <string name="restricted_app_title">Restricted apps</string>
     <!-- Summary for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
@@ -5557,7 +5558,8 @@
     <string name="battery_auto_restriction_summary">Detect when apps drain battery</string>
 
     <!-- Summary for battery manager when it is on -->
-    <string name="battery_manager_on">On / Detecting when apps drain battery</string>
+    <string name="battery_manager_on" product="default">On / Detecting when apps drain battery</string>
+
     <!-- Summary for battery manager when it is off -->
     <string name="battery_manager_off">Off</string>
     <!-- Summary for battery manager, showing app restricted -->
@@ -7572,6 +7574,15 @@
     <!-- Sound: Title for the option managing whether or not to vibrate when ringing. [CHAR LIMIT=30] -->
     <string name="vibrate_when_ringing_title">Vibrate for calls</string>
 
+    <!-- Sound: Option for vibrate when ringing setting: Never vibrate. [CHAR LIMIT=40] -->
+    <string name="vibrate_when_ringing_option_never_vibrate">Never vibrate</string>
+
+    <!-- Sound: Option for vibrate when ringing setting: Always vibrate. [CHAR LIMIT=40] -->
+    <string name="vibrate_when_ringing_option_always_vibrate">Always vibrate</string>
+
+    <!-- Sound: Option for vibrate when ringing setting: Ramping ringer. [CHAR LIMIT=80] -->
+    <string name="vibrate_when_ringing_option_ramping_ringer">Vibrate first then ring gradually</string>
+
     <!-- Sound: Title for the other sounds option and associated settings page. [CHAR LIMIT=30] -->
     <string name="other_sound_settings">Other sounds</string>
 
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index d82a324..a24a95f 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -88,11 +88,12 @@
         settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>
 
     <!-- Also vibrate for calls -->
-    <SwitchPreference
-        android:key="vibrate_when_ringing"
+    <Preference
+        android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
+        android:key="vibrate_for_calls"
         android:title="@string/vibrate_when_ringing_title"
-        settings:controller="com.android.settings.notification.VibrateWhenRingPreferenceController"
-        android:order="-130"/>
+        android:order="-130"
+        settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"/>
 
     <!-- Interruptions -->
     <com.android.settingslib.RestrictedPreference
diff --git a/res/xml/vibrate_for_calls_settings.xml b/res/xml/vibrate_for_calls_settings.xml
new file mode 100644
index 0000000..5b6d217
--- /dev/null
+++ b/res/xml/vibrate_for_calls_settings.xml
@@ -0,0 +1,20 @@
+<?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"
+    android:title="@string/vibrate_when_ringing_title" />
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 8a96484..315cba1 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -688,6 +688,15 @@
         return um.getCredentialOwnerProfile(userId);
     }
 
+    /**
+     * Returns the credential type of the given user id.
+     */
+    public static @LockPatternUtils.CredentialType int getCredentialType(Context context,
+            int userId) {
+        final LockPatternUtils lpu = new LockPatternUtils(context);
+        return lpu.getCredentialTypeForUser(userId);
+    }
+
     private static final StringBuilder sBuilder = new StringBuilder(50);
     private static final java.util.Formatter sFormatter = new java.util.Formatter(
             sBuilder, Locale.getDefault());
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1722c99..6f51fd3 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -437,7 +437,8 @@
             final String settingsClassName = info.getSettingsActivityName();
             if (!TextUtils.isEmpty(settingsClassName)) {
                 extras.putString(EXTRA_SETTINGS_TITLE,
-                        getString(R.string.accessibility_menu_item_settings));
+                        getString(R.string.accessibility_service_menu_item_settings,
+                                resolveInfo.loadLabel(getPackageManager())));
                 extras.putString(EXTRA_SETTINGS_COMPONENT_NAME,
                         new ComponentName(packageName, settingsClassName).flattenToString());
             }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index 159e609..2bcb5b3 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType.LEGACY;
+
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.app.settings.SettingsEnums;
 import android.content.ComponentName;
@@ -99,9 +101,11 @@
     public void onResume() {
         super.onResume();
         updateAccessibilityServicePreference(mScreenReaderPreference,
-                findService(SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME));
+                SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME,
+                LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.class.getName());
         updateAccessibilityServicePreference(mSelectToSpeakPreference,
-                findService(SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME));
+                SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME,
+                LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.class.getName());
         configureMagnificationPreferenceIfNeeded(mDisplayMagnificationPreference);
     }
 
@@ -143,7 +147,8 @@
     }
 
     private void updateAccessibilityServicePreference(Preference preference,
-            AccessibilityServiceInfo info) {
+            String packageName, String serviceName, String targetLegacyFragment) {
+        final AccessibilityServiceInfo info = findService(packageName, serviceName);
         if (info == null) {
             getPreferenceScreen().removePreference(preference);
             return;
@@ -154,6 +159,9 @@
         preference.setTitle(title);
         ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
         preference.setKey(componentName.flattenToString());
+        if (AccessibilityUtil.getAccessibilityServiceFragmentType(info) == LEGACY) {
+            preference.setFragment(targetLegacyFragment);
+        }
 
         // Update the extras.
         Bundle extras = preference.getExtras();
diff --git a/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
new file mode 100644
index 0000000..c9257a9
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * 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.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleScreenReaderPreferenceFragmentForSetupWizard
+        extends LegacyAccessibilityServicePreferenceFragment {
+
+    private boolean mToggleSwitchWasInitiallyChecked;
+
+    @Override
+    protected void onProcessArguments(Bundle arguments) {
+        super.onProcessArguments(arguments);
+        mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+    }
+
+    @Override
+    public void onStop() {
+        // Log the final choice in value if it's different from the previous value.
+        if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+            mMetricsFeatureProvider.action(getContext(),
+                    SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
+                    mToggleSwitch.isChecked());
+        }
+
+        super.onStop();
+    }
+}
diff --git a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
new file mode 100644
index 0000000..2c8485b
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * 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.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard
+        extends LegacyAccessibilityServicePreferenceFragment {
+
+    private boolean mToggleSwitchWasInitiallyChecked;
+
+    @Override
+    protected void onProcessArguments(Bundle arguments) {
+        super.onProcessArguments(arguments);
+        mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+    }
+
+    @Override
+    public void onStop() {
+        // Log the final choice in value if it's different from the previous value.
+        if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+            mMetricsFeatureProvider.action(getContext(),
+                    SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
+                    mToggleSwitch.isChecked());
+        }
+
+        super.onStop();
+    }
+}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index b82a344..401ca5e 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -188,12 +188,6 @@
 
         initShortcutPreference();
 
-        mSettingsPreference = new Preference(getPrefContext());
-        mSettingsPreference.setTitle(R.string.accessibility_magnification_service_settings_title);
-        mSettingsPreference.setKey(SETTINGS_KEY);
-        mSettingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
-        mSettingsPreference.setPersistent(false);
-
         super.onViewCreated(view, savedInstanceState);
 
         mConfigWarningPreference = new Preference(getPrefContext());
diff --git a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
index fc68e03..29c031d 100644
--- a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -46,4 +46,3 @@
         super.onStop();
     }
 }
-
diff --git a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
index 5f01e4b..da94abc 100644
--- a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -47,4 +47,3 @@
         super.onStop();
     }
 }
-
diff --git a/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
index 4d19151..a3ea478 100644
--- a/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
@@ -127,7 +127,7 @@
                 return mContext.getString(R.string.no_data_usage);
             }
             return mContext.getString(R.string.data_summary_format,
-                    Formatter.formatFileSize(mContext, totalBytes),
+                    Formatter.formatFileSize(mContext, totalBytes, Formatter.FLAG_IEC_UNITS),
                     DateUtils.formatDateTime(mContext, startTime,
                             DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH));
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 4226720..86b72ec 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -60,10 +60,12 @@
 
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({SortType.TYPE_DEFAULT,
-            SortType.TYPE_FIFO})
+            SortType.TYPE_FIFO,
+            SortType.TYPE_NO_SORT})
     public @interface SortType {
         int TYPE_DEFAULT = 1;
         int TYPE_FIFO = 2;
+        int TYPE_NO_SORT = 3;
     }
 
     private final CachedBluetoothDevice mCachedDevice;
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index e2715d3..3778862 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -232,12 +232,21 @@
      * Add the {@link Preference} that represents the {@code cachedDevice}
      */
     protected void addPreference(CachedBluetoothDevice cachedDevice) {
+        addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+    }
+
+    /**
+     * Add the {@link Preference} with {@link BluetoothDevicePreference.SortType} that
+     * represents the {@code cachedDevice}
+     */
+    protected void addPreference(CachedBluetoothDevice cachedDevice,
+            @BluetoothDevicePreference.SortType int type) {
         final BluetoothDevice device = cachedDevice.getDevice();
         if (!mPreferenceMap.containsKey(device)) {
             BluetoothDevicePreference btPreference =
                     new BluetoothDevicePreference(mPrefContext, cachedDevice,
                             true /* showDeviceWithoutNames */,
-                            BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+                            type);
             btPreference.setKey(getPreferenceKey());
             btPreference.setOnGearClickListener(mDeviceProfilesListener);
             if (this instanceof Preference.OnPreferenceClickListener) {
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index fdd7a1e..6893c25 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -15,6 +15,7 @@
  */
 package com.android.settings.bluetooth;
 
+import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.content.Context;
 import android.util.Log;
@@ -24,6 +25,7 @@
 import com.android.settings.connecteddevice.DevicePreferenceCallback;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
 
 /**
  * Maintain and update saved bluetooth devices(bonded but not connected)
@@ -42,6 +44,26 @@
     }
 
     @Override
+    public void forceUpdate() {
+        if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
+            final CachedBluetoothDeviceManager cachedManager =
+                    mLocalManager.getCachedDeviceManager();
+            for (BluetoothDevice device
+                    : BluetoothAdapter.getDefaultAdapter().getMostRecentlyConnectedDevices()) {
+                final CachedBluetoothDevice cachedDevice = cachedManager.findDevice(device);
+                if (isFilterMatched(cachedDevice)) {
+                    // Add the preference if it is new one
+                    addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_NO_SORT);
+                } else {
+                    removePreference(cachedDevice);
+                }
+            }
+        } else {
+            removeAllDevicesFromPreference();
+        }
+    }
+
+    @Override
     public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
         final BluetoothDevice device = cachedDevice.getDevice();
         if (DBG) {
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index 6abd52d..1986965 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -16,22 +16,26 @@
 
 package com.android.settings.deviceinfo.simstatus;
 
-import android.Manifest;
+import android.annotation.Nullable;
 import android.content.BroadcastReceiver;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.ServiceConnection;
 import android.content.res.Resources;
-import android.os.Bundle;
+import android.os.IBinder;
 import android.os.PersistableBundle;
-import android.os.UserHandle;
+import android.os.RemoteException;
 import android.telephony.Annotation;
 import android.telephony.CarrierConfigManager;
+import android.telephony.CellBroadcastIntents;
+import android.telephony.CellBroadcastService;
 import android.telephony.CellSignalStrength;
+import android.telephony.ICellBroadcastService;
 import android.telephony.PhoneStateListener;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
-import android.telephony.SmsCbMessage;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
@@ -39,6 +43,7 @@
 import android.telephony.UiccCardInfo;
 import android.telephony.euicc.EuiccManager;
 import android.text.TextUtils;
+import android.util.Log;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
@@ -58,6 +63,8 @@
 
     private final static String TAG = "SimStatusDialogCtrl";
 
+    private static final String CELL_BROADCAST_SERVICE_PACKAGE = "com.android.cellbroadcastservice";
+
     @VisibleForTesting
     final static int NETWORK_PROVIDER_VALUE_ID = R.id.operator_name_value;
     @VisibleForTesting
@@ -96,12 +103,6 @@
     @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 =
-            "com.android.cellbroadcastreceiver.GET_LATEST_CB_AREA_INFO";
-    private final static String CELL_BROADCAST_RECEIVER_APP = "com.android.cellbroadcastreceiver";
-
     private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
             new OnSubscriptionsChangedListener() {
                 @Override
@@ -131,23 +132,48 @@
     private final BroadcastReceiver mAreaInfoReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
-            final String action = intent.getAction();
-            if (TextUtils.equals(action, CB_AREA_INFO_RECEIVED_ACTION)) {
-                final Bundle extras = intent.getExtras();
-                if (extras == null) {
-                    return;
-                }
-                final SmsCbMessage cbMessage = (SmsCbMessage) extras.get("message");
-                if (cbMessage != null && mSlotIndex == cbMessage.getSlotIndex()) {
-                    final String latestAreaInfo = cbMessage.getMessageBody();
-                    mDialog.setText(OPERATOR_INFO_VALUE_ID, latestAreaInfo);
-                }
-            }
+            updateAreaInfoText();
         }
     };
 
     private PhoneStateListener mPhoneStateListener;
 
+    private CellBroadcastServiceConnection mCellBroadcastServiceConnection;
+
+    private class CellBroadcastServiceConnection implements ServiceConnection {
+        private IBinder mService;
+
+        @Nullable
+        public IBinder getService() {
+            return mService;
+        }
+
+        @Override
+        public void onServiceConnected(ComponentName className, IBinder service) {
+            Log.d(TAG, "connected to CellBroadcastService");
+            this.mService = service;
+            updateAreaInfoText();
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName className) {
+            this.mService = null;
+            Log.d(TAG, "mICellBroadcastService has disconnected unexpectedly");
+        }
+
+        @Override
+        public void onBindingDied(ComponentName name) {
+            this.mService = null;
+            Log.d(TAG, "Binding died");
+        }
+
+        @Override
+        public void onNullBinding(ComponentName name) {
+            this.mService = null;
+            Log.d(TAG, "Null binding");
+        }
+    }
+
     public SimStatusDialogController(@NonNull SimStatusDialogFragment dialog, Lifecycle lifecycle,
             int slotId) {
         mDialog = dialog;
@@ -190,6 +216,19 @@
         updateImsRegistrationState();
     }
 
+    /**
+     * Deinitialization works
+     */
+    public void deinitialize() {
+        if (mShowLatestAreaInfo) {
+            if (mCellBroadcastServiceConnection != null
+                    && mCellBroadcastServiceConnection.getService() != null) {
+                mContext.unbindService(mCellBroadcastServiceConnection);
+            }
+            mCellBroadcastServiceConnection = null;
+        }
+    }
+
     @Override
     public void onResume() {
         if (mSubscriptionInfo == null) {
@@ -204,14 +243,9 @@
         mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
 
         if (mShowLatestAreaInfo) {
+            updateAreaInfoText();
             mContext.registerReceiver(mAreaInfoReceiver,
-                    new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
-                    Manifest.permission.RECEIVE_EMERGENCY_BROADCAST, null /* scheduler */);
-            // Ask CellBroadcastReceiver to broadcast the latest area info received
-            final Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION);
-            getLatestIntent.setPackage(CELL_BROADCAST_RECEIVER_APP);
-            mContext.sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
-                    Manifest.permission.RECEIVE_EMERGENCY_BROADCAST);
+                    new IntentFilter(CellBroadcastIntents.ACTION_AREA_INFO_UPDATED));
         }
     }
 
@@ -265,13 +299,54 @@
         mDialog.setText(CELLULAR_NETWORK_STATE, networkStateValue);
     }
 
+    /**
+     * Update area info text retrieved from
+     * {@link CellBroadcastService#getCellBroadcastAreaInfo(int)}
+     */
+    private void updateAreaInfoText() {
+        if (!mShowLatestAreaInfo || mCellBroadcastServiceConnection == null) return;
+        ICellBroadcastService cellBroadcastService =
+                ICellBroadcastService.Stub.asInterface(
+                        mCellBroadcastServiceConnection.getService());
+        if (cellBroadcastService == null) return;
+        try {
+            mDialog.setText(OPERATOR_INFO_VALUE_ID,
+                    cellBroadcastService.getCellBroadcastAreaInfo(
+                            SimStatusDialogController.this.mSlotIndex));
+
+        } catch (RemoteException e) {
+            Log.d(TAG, "Can't get area info. e=" + e);
+        }
+    }
+
+    /**
+     * Bind cell broadcast service.
+     */
+    private void bindCellBroadcastService() {
+        mCellBroadcastServiceConnection = new CellBroadcastServiceConnection();
+        Intent intent = new Intent(CellBroadcastService.CELL_BROADCAST_SERVICE_INTERFACE);
+        intent.setPackage(CELL_BROADCAST_SERVICE_PACKAGE);
+        if (mCellBroadcastServiceConnection != null
+                && mCellBroadcastServiceConnection.getService() == null) {
+            if (!mContext.bindService(intent, mCellBroadcastServiceConnection,
+                    Context.BIND_AUTO_CREATE)) {
+                Log.e(TAG, "Unable to bind to service");
+            }
+        } else {
+            Log.d(TAG, "skipping bindService because connection already exists");
+        }
+    }
 
     private void updateLatestAreaInfo() {
         mShowLatestAreaInfo = Resources.getSystem().getBoolean(
                 com.android.internal.R.bool.config_showAreaUpdateInfoSettings)
                 && mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA;
 
-        if (!mShowLatestAreaInfo) {
+        if (mShowLatestAreaInfo) {
+            // Bind cell broadcast service to get the area info. The info will be updated once
+            // the service is connected.
+            bindCellBroadcastService();
+        } else {
             mDialog.removeSettingFromScreen(OPERATOR_INFO_LABEL_ID);
             mDialog.removeSettingFromScreen(OPERATOR_INFO_VALUE_ID);
         }
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java
index d2d563f..93323b3 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogFragment.java
@@ -74,6 +74,12 @@
         return builder.setView(mRootView).create();
     }
 
+    @Override
+    public void onDestroy() {
+        mController.deinitialize();
+        super.onDestroy();
+    }
+
     public void removeSettingFromScreen(int viewId) {
         final View view = mRootView.findViewById(viewId);
         if (view != null) {
diff --git a/src/com/android/settings/display/darkmode/DarkModeObserver.java b/src/com/android/settings/display/darkmode/DarkModeObserver.java
index 4d0d7c5..1482a2a 100644
--- a/src/com/android/settings/display/darkmode/DarkModeObserver.java
+++ b/src/com/android/settings/display/darkmode/DarkModeObserver.java
@@ -49,12 +49,7 @@
                 super.onChange(selfChange, uri);
                 final String setting = uri == null ? null : uri.getLastPathSegment();
                 if (setting != null && mCallback != null) {
-                    switch (setting) {
-                        case Settings.Secure.UI_NIGHT_MODE:
-                            mCallback.run();
-                            break;
-                        default:
-                    }
+                    mCallback.run();
                 }
             }
         };
@@ -69,7 +64,16 @@
         callback.run();
         mCallback = callback;
         final Uri uri = Settings.Secure.getUriFor(Settings.Secure.UI_NIGHT_MODE);
-        mContext.getContentResolver().registerContentObserver(uri, false, mContentObserver);
+        final Uri customStart =
+                Settings.Secure.getUriFor(Settings.Secure.DARK_THEME_CUSTOM_START_TIME);
+        final Uri customEnd =
+                Settings.Secure.getUriFor(Settings.Secure.DARK_THEME_CUSTOM_END_TIME);
+        mContext.getContentResolver()
+                .registerContentObserver(uri, false, mContentObserver);
+        mContext.getContentResolver()
+                .registerContentObserver(customStart, false, mContentObserver);
+        mContext.getContentResolver()
+                .registerContentObserver(customEnd, false, mContentObserver);
         final IntentFilter batteryFilter = new IntentFilter();
         batteryFilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
         mContext.registerReceiver(
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/CellularDataConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/CellularDataConditionController.java
index 93b937b..4c0ddc9 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/CellularDataConditionController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/CellularDataConditionController.java
@@ -17,17 +17,18 @@
 package com.android.settings.homepage.contextualcards.conditional;
 
 import android.app.settings.SettingsEnums;
-import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
-import android.content.IntentFilter;
 import android.net.ConnectivityManager;
+import android.telephony.PhoneStateListener;
+import android.telephony.PreciseDataConnectionState;
+import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 
-import com.android.internal.telephony.TelephonyIntents;
 import com.android.settings.R;
 import com.android.settings.Settings;
 import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.network.GlobalSettingsChangeListener;
 
 import java.util.Objects;
 
@@ -35,22 +36,35 @@
 
     static final int ID = Objects.hash("CellularDataConditionController");
 
-    private static final IntentFilter DATA_CONNECTION_FILTER =
-            new IntentFilter(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
-
     private final Context mAppContext;
     private final ConditionManager mConditionManager;
-    private final Receiver mReceiver;
-    private final TelephonyManager mTelephonyManager;
+    private final GlobalSettingsChangeListener mDefaultDataSubscriptionIdListener;
     private final ConnectivityManager mConnectivityManager;
 
+    private int mSubId;
+    private TelephonyManager mTelephonyManager;
+    private boolean mIsListeningConnectionChange;
+
     public CellularDataConditionController(Context appContext, ConditionManager conditionManager) {
         mAppContext = appContext;
         mConditionManager = conditionManager;
-        mReceiver = new Receiver();
+        mSubId = getDefaultDataSubscriptionId(appContext);
+        mTelephonyManager = getTelephonyManager(appContext, mSubId);
+        mDefaultDataSubscriptionIdListener = new GlobalSettingsChangeListener(appContext,
+                android.provider.Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION) {
+            public void onChanged(String field) {
+                final int subId = getDefaultDataSubscriptionId(mAppContext);
+                if (subId == mSubId) {
+                    return;
+                }
+                mSubId = subId;
+                if (mIsListeningConnectionChange) {
+                    restartPhoneStateListener(mAppContext, subId);
+                }
+            }
+        };
         mConnectivityManager = appContext.getSystemService(
                 ConnectivityManager.class);
-        mTelephonyManager = appContext.getSystemService(TelephonyManager.class);
     }
 
     @Override
@@ -95,21 +109,50 @@
 
     @Override
     public void startMonitoringStateChange() {
-        mAppContext.registerReceiver(mReceiver, DATA_CONNECTION_FILTER);
+        restartPhoneStateListener(mAppContext, mSubId);
     }
 
     @Override
     public void stopMonitoringStateChange() {
-        mAppContext.unregisterReceiver(mReceiver);
+        stopPhoneStateListener();
     }
 
-    public class Receiver extends BroadcastReceiver {
+    private int getDefaultDataSubscriptionId(Context context) {
+        final SubscriptionManager subscriptionManager =
+                context.getSystemService(SubscriptionManager.class);
+        return subscriptionManager.getDefaultDataSubscriptionId();
+    }
+
+    private TelephonyManager getTelephonyManager(Context context, int subId) {
+        final TelephonyManager telephonyManager =
+                context.getSystemService(TelephonyManager.class);
+        return telephonyManager.createForSubscriptionId(subId);
+    }
+
+    private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
         @Override
-        public void onReceive(Context context, Intent intent) {
-            if (TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED.equals(
-                    intent.getAction())) {
-                mConditionManager.onConditionChanged();
-            }
+        public void onPreciseDataConnectionStateChanged(
+                PreciseDataConnectionState dataConnectionState) {
+            mConditionManager.onConditionChanged();
         }
+    };
+
+    private void stopPhoneStateListener() {
+        mIsListeningConnectionChange = false;
+        mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+    }
+
+    // restart monitoring when subscription has been changed
+    private void restartPhoneStateListener(Context context, int subId) {
+        stopPhoneStateListener();
+        mIsListeningConnectionChange = true;
+
+        // switch mTelephonyManager only when subscription been updated to valid ones
+        if (SubscriptionManager.isValidSubscriptionId(subId)) {
+            mTelephonyManager = getTelephonyManager(context, subId);
+        }
+
+        mTelephonyManager.listen(mPhoneStateListener,
+                PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE);
     }
 }
diff --git a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
index c4765c3..3c88eb2 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
@@ -162,11 +162,10 @@
 
     @VisibleForTesting
     boolean isAvailable(Context context) {
-        // checking dark theme mode.
-        if (isDarkThemeMode(context)) {
+        // check if dark theme mode is enabled or if dark theme scheduling is on.
+        if (isDarkThemeMode(context) || isNightModeScheduled()) {
             return false;
         }
-
         // checking the current battery level
         final BatteryManager batteryManager = context.getSystemService(BatteryManager.class);
         final int level = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
@@ -186,6 +185,18 @@
         sSliceClicked = clicked;
     }
 
+    private boolean isNightModeScheduled() {
+        final int mode = mUiModeManager.getNightMode();
+        if (DEBUG) {
+            Log.d(TAG, "night mode : " + mode);
+        }
+        // Turn on from sunset to sunrise or turn on at custom time
+        if (mode == UiModeManager.MODE_NIGHT_AUTO || mode == UiModeManager.MODE_NIGHT_CUSTOM) {
+            return true;
+        }
+        return false;
+    }
+
     public static class DarkThemeWorker extends SliceBackgroundWorker<Void> {
         private final Context mContext;
         private final ContentObserver mContentObserver =
diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
index e7aab17..2d9a736 100644
--- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java
+++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
@@ -146,6 +146,19 @@
         return mTopDevice;
     }
 
+    /**
+     * Request to set volume.
+     *
+     * @param device for the targeted device.
+     * @param volume for the new value.
+     *
+     */
+    public void adjustVolume(MediaDevice device, int volume) {
+        ThreadUtils.postOnBackgroundThread(() -> {
+            device.requestSetVolume(volume);
+        });
+    }
+
     private class DevicesChangedBroadcastReceiver extends BroadcastReceiver {
         @Override
         public void onReceive(Context context, Intent intent) {
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 47a5d7a..36dba22 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.media;
 
+import static android.app.slice.Slice.EXTRA_RANGE_VALUE;
+
 import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
 
 import android.app.PendingIntent;
@@ -49,6 +51,7 @@
 
     private static final String TAG = "MediaOutputSlice";
     private static final String MEDIA_DEVICE_ID = "media_device_id";
+    private static final int NON_SLIDER_VALUE = -1;
 
     public static final String MEDIA_PACKAGE_NAME = "media_package_name";
 
@@ -86,7 +89,7 @@
         final MediaDevice topDevice = isTouched ? worker.getTopDevice() : connectedDevice;
 
         if (topDevice != null) {
-            listBuilder.addRow(getActiveDeviceHeaderRow(topDevice));
+            listBuilder.addInputRange(getActiveDeviceHeaderRow(topDevice));
             worker.setTopDevice(topDevice);
         }
 
@@ -100,7 +103,7 @@
         return listBuilder.build();
     }
 
-    private ListBuilder.RowBuilder getActiveDeviceHeaderRow(MediaDevice device) {
+    private ListBuilder.InputRangeBuilder getActiveDeviceHeaderRow(MediaDevice device) {
         final String title = device.getName();
         final IconCompat icon = getDeviceIconCompat(device);
 
@@ -108,14 +111,23 @@
                 getBroadcastIntent(mContext, device.getId(), device.hashCode());
         final SliceAction primarySliceAction = SliceAction.createDeeplink(broadcastAction, icon,
                 ListBuilder.ICON_IMAGE, title);
-
-        final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
+        final ListBuilder.InputRangeBuilder builder = new ListBuilder.InputRangeBuilder()
                 .setTitleItem(icon, ListBuilder.ICON_IMAGE)
                 .setTitle(title)
-                .setSubtitle(device.getSummary())
-                .setPrimaryAction(primarySliceAction);
+                .setPrimaryAction(primarySliceAction)
+                .setInputAction(getSliderInputAction(device.hashCode(), device.getId()))
+                .setMax(device.getMaxVolume())
+                .setValue(device.getCurrentVolume());
+        return builder;
+    }
 
-        return rowBuilder;
+    private PendingIntent getSliderInputAction(int requestCode, String id) {
+        final Intent intent = new Intent(getUri().toString())
+                .setData(getUri())
+                .putExtra(MEDIA_DEVICE_ID, id)
+                .setClass(mContext, SliceBroadcastReceiver.class);
+
+        return PendingIntent.getBroadcast(mContext, requestCode, intent, 0);
     }
 
     private IconCompat getDeviceIconCompat(MediaDevice device) {
@@ -152,7 +164,7 @@
                 .setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon,
                         ListBuilder.ICON_IMAGE, title))
                 .setTitle(title)
-                .setSubtitle(device.getSummary());
+                .setSubtitle(device.isConnected() ? null : device.getSummary());
 
         return rowBuilder;
     }
@@ -162,7 +174,7 @@
         intent.setClass(context, SliceBroadcastReceiver.class);
         intent.putExtra(MEDIA_DEVICE_ID, id);
         intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
-        return PendingIntent.getBroadcast(context, requestCode /* requestCode */, intent,
+        return PendingIntent.getBroadcast(context, requestCode, intent,
                 PendingIntent.FLAG_UPDATE_CURRENT);
     }
 
@@ -175,11 +187,22 @@
     public void onNotifyChange(Intent intent) {
         final MediaDeviceUpdateWorker worker = getWorker();
         final String id = intent != null ? intent.getStringExtra(MEDIA_DEVICE_ID) : "";
+        if (TextUtils.isEmpty(id)) {
+            return;
+        }
         final MediaDevice device = worker.getMediaDeviceById(id);
-        if (device != null) {
+        if (device == null) {
+            return;
+        }
+        final int newPosition = intent.getIntExtra(EXTRA_RANGE_VALUE, NON_SLIDER_VALUE);
+        if (newPosition == NON_SLIDER_VALUE) {
+            // Intent for device connection
             Log.d(TAG, "onNotifyChange() device name : " + device.getName());
             worker.setIsTouched(true);
             worker.connectDevice(device);
+        } else {
+            // Intent for volume adjustment
+            worker.adjustVolume(device, newPosition);
         }
     }
 
diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java
index 83d6578..5519ddd 100644
--- a/src/com/android/settings/network/ims/ImsQueryController.java
+++ b/src/com/android/settings/network/ims/ImsQueryController.java
@@ -16,6 +16,10 @@
 
 package com.android.settings.network.ims;
 
+import android.telephony.AccessNetworkConstants;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
+
 import androidx.annotation.VisibleForTesting;
 
 /**
@@ -23,8 +27,38 @@
  */
 abstract class ImsQueryController {
 
+    private volatile int mCapability;
+    private volatile int mTech;
+    private volatile int mTransportType;
+
+    /**
+     * Constructor for query IMS status
+     */
+    ImsQueryController() {}
+
+    /**
+     * Constructor for query IMS status
+     *
+     * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+     * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
+     * @param transportType {@link AccessNetworkConstants#TransportType}
+     */
+    ImsQueryController(
+            @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
+            @ImsRegistrationImplBase.ImsRegistrationTech int tech,
+            @AccessNetworkConstants.TransportType int transportType) {
+        mCapability = capability;
+        mTech = tech;
+        mTransportType = transportType;
+    }
+
     @VisibleForTesting
     ImsQuery isTtyOnVolteEnabled(int subId) {
         return new ImsQueryTtyOnVolteStat(subId);
     }
+
+    @VisibleForTesting
+    ImsQuery isProvisionedOnDevice(int subId) {
+        return new ImsQueryProvisioningStat(subId, mCapability, mTech);
+    }
 }
diff --git a/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java b/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java
new file mode 100644
index 0000000..b577948
--- /dev/null
+++ b/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java
@@ -0,0 +1,47 @@
+/*
+ * 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.network.ims;
+
+import android.telephony.ims.ImsMmTelManager;
+
+
+/**
+ * An {@code ImsQuery} for accessing IMS user setting for enhanced 4G LTE
+ */
+public class ImsQueryEnhanced4gLteModeUserSetting implements ImsQuery {
+
+    /**
+     * Constructor
+     * @param subId subscription id
+     */
+    public ImsQueryEnhanced4gLteModeUserSetting(int subId) {
+        mSubId = subId;
+    }
+
+    private volatile int mSubId;
+
+    /**
+     * Implementation of interface {@code ImsQuery}
+     *
+     * @return result of query
+     */
+    public boolean query() {
+        final ImsMmTelManager imsMmTelManager =
+                ImsMmTelManager.createForSubscriptionId(mSubId);
+        return imsMmTelManager.isAdvancedCallingSettingEnabled();
+    }
+}
diff --git a/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
new file mode 100644
index 0000000..34f232d
--- /dev/null
+++ b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
@@ -0,0 +1,57 @@
+/*
+ * 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.network.ims;
+
+import android.telephony.ims.ProvisioningManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
+
+
+/**
+ * An {@link ImsQuery} for accessing IMS provision stat
+ */
+public class ImsQueryProvisioningStat implements ImsQuery {
+
+    private volatile int mSubId;
+    private volatile int mCapability;
+    private volatile int mTech;
+
+    /**
+     * Constructor
+     * @param subId subscription id
+     * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+     * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
+     */
+    public ImsQueryProvisioningStat(int subId,
+            @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
+            @ImsRegistrationImplBase.ImsRegistrationTech int tech) {
+        mSubId = subId;
+        mCapability = capability;
+        mTech = tech;
+    }
+
+    /**
+     * Implementation of interface {@link ImsQuery}
+     *
+     * @return result of query
+     */
+    public boolean query() {
+        final ProvisioningManager privisionManager =
+                ProvisioningManager.createForSubscriptionId(mSubId);
+        return privisionManager.getProvisioningStatusForCapability(mCapability, mTech);
+    }
+}
diff --git a/src/com/android/settings/network/ims/VolteQueryImsState.java b/src/com/android/settings/network/ims/VolteQueryImsState.java
index 320aa26..608768a 100644
--- a/src/com/android/settings/network/ims/VolteQueryImsState.java
+++ b/src/com/android/settings/network/ims/VolteQueryImsState.java
@@ -18,13 +18,16 @@
 
 import android.content.Context;
 import android.telecom.TelecomManager;
+import android.telephony.AccessNetworkConstants;
 import android.telephony.SubscriptionManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
 
 import androidx.annotation.VisibleForTesting;
 
 import com.android.ims.ImsManager;
 import com.android.settings.network.SubscriptionUtil;
-
+import com.android.settings.network.telephony.MobileNetworkUtils;
 
 /**
  * Controller class for querying Volte status
@@ -41,11 +44,53 @@
      * @param subId subscription's id
      */
     public VolteQueryImsState(Context context, int subId) {
+        super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
+                ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
+                AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
         mContext = context;
         mSubId = subId;
     }
 
     /**
+     * Implementation of ImsQueryController#isEnabledByUser(int subId)
+     */
+    @VisibleForTesting
+    ImsQuery isEnabledByUser(int subId) {
+        return new ImsQueryEnhanced4gLteModeUserSetting(subId);
+    }
+
+    @VisibleForTesting
+    ImsManager getImsManager(int subId) {
+        return ImsManager.getInstance(mContext,
+                SubscriptionUtil.getPhoneId(mContext, subId));
+    }
+
+    /**
+     * Check whether VoLTE has been provisioned or not on this subscription
+     *
+     * @return true when VoLTE has been enabled, otherwise false
+     */
+    public boolean isVoLteProvisioned() {
+        final ImsManager imsManager = getImsManager(mSubId);
+        if (imsManager == null) {
+            return false;
+        }
+
+        return imsManager.isVolteEnabledByPlatform()
+                && isProvisionedOnDevice(mSubId).query();
+    }
+
+    /**
+     * Check whether VoLTE can be perform or not on this subscription
+     *
+     * @return true when VoLTE can be performed, otherwise false
+     */
+    public boolean isReadyToVoLte() {
+        return isVoLteProvisioned()
+                && MobileNetworkUtils.isImsServiceStateReady(getImsManager(mSubId));
+    }
+
+    /**
      * Get allowance status for user to alter configuration
      *
      * @return true when changing configuration by user is allowed.
@@ -74,8 +119,6 @@
         if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
             return false;
         }
-        ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
-                    mContext, mSubId));
-        return imsManager.isEnhanced4gLteModeSettingEnabledByUser();
+        return isEnabledByUser(mSubId).query();
     }
 }
diff --git a/src/com/android/settings/network/ims/VtQueryImsState.java b/src/com/android/settings/network/ims/VtQueryImsState.java
index 5ac07a3..a9003b1 100644
--- a/src/com/android/settings/network/ims/VtQueryImsState.java
+++ b/src/com/android/settings/network/ims/VtQueryImsState.java
@@ -18,10 +18,17 @@
 
 import android.content.Context;
 import android.telecom.TelecomManager;
+import android.telephony.AccessNetworkConstants;
 import android.telephony.SubscriptionManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
 
 import androidx.annotation.VisibleForTesting;
 
+import com.android.ims.ImsManager;
+import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.telephony.MobileNetworkUtils;
+
 /**
  * Controller class for querying VT status
  */
@@ -37,6 +44,9 @@
      * @param subId subscription's id
      */
     public VtQueryImsState(Context context, int subId) {
+        super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
+                ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
+                AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
         mContext = context;
         mSubId = subId;
     }
@@ -49,6 +59,28 @@
         return new ImsQueryVtUserSetting(subId);
     }
 
+    @VisibleForTesting
+    ImsManager getImsManager(int subId) {
+        return ImsManager.getInstance(mContext,
+                SubscriptionUtil.getPhoneId(mContext, subId));
+    }
+
+    /**
+     * Check whether Video Call can be perform or not on this subscription
+     *
+     * @return true when Video Call can be performed, otherwise false
+     */
+    public boolean isReadyToVideoCall() {
+        final ImsManager imsManager = getImsManager(mSubId);
+        if (imsManager == null) {
+            return false;
+        }
+
+        return imsManager.isVtEnabledByPlatform()
+                && isProvisionedOnDevice(mSubId).query()
+                && MobileNetworkUtils.isImsServiceStateReady(imsManager);
+    }
+
     /**
      * Get allowance status for user to alter configuration
      *
diff --git a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
index e1b3bbf..d6703d1 100644
--- a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
+++ b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
@@ -37,6 +37,7 @@
      * @param subId subscription's id
      */
     public WifiCallingQueryImsState(Context context, int subId) {
+        super();
         mContext = context;
         mSubId = subId;
     }
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index 123e100..efbbbf8 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -23,9 +23,6 @@
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
 import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
@@ -33,8 +30,6 @@
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 
-import com.android.ims.ImsManager;
-import com.android.settings.network.SubscriptionUtil;
 import com.android.settings.network.ims.VolteQueryImsState;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
@@ -55,8 +50,6 @@
     Preference mPreference;
     private CarrierConfigManager mCarrierConfigManager;
     private PersistableBundle mCarrierConfig;
-    @VisibleForTesting
-    ImsManager mImsManager;
     private PhoneCallStateListener mPhoneStateListener;
     @VisibleForTesting
     Integer mCallState;
@@ -81,10 +74,6 @@
         }
         mSubId = subId;
         mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
-        if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
-            mImsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
-                    mContext, mSubId));
-        }
 
         final boolean show4GForLTE = mCarrierConfig.getBoolean(
                 CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
@@ -96,29 +85,26 @@
         return this;
     }
 
-    @VisibleForTesting
-    ProvisioningManager getProvisioningManager(int subId) {
-        return ProvisioningManager.createForSubscriptionId(subId);
-    }
-
     @Override
     public int getAvailabilityStatus(int subId) {
         init(subId);
         if (!isModeMatched()) {
             return CONDITIONALLY_UNAVAILABLE;
         }
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            return CONDITIONALLY_UNAVAILABLE;
+        }
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        if ((carrierConfig == null)
+                || carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL)) {
+            return CONDITIONALLY_UNAVAILABLE;
+        }
         final VolteQueryImsState queryState = queryImsState(subId);
-        final boolean isVisible = SubscriptionManager.isValidSubscriptionId(subId)
-                && mImsManager != null && carrierConfig != null
-                && mImsManager.isVolteEnabledByPlatform()
-                && isVolteProvisionedOnDevice(mSubId)
-                && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
-                && !carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL);
-        return isVisible
-                ? (isUserControlAllowed() && queryState.isAllowUserControl()
-                ? AVAILABLE : AVAILABLE_UNSEARCHABLE)
-                : CONDITIONALLY_UNAVAILABLE;
+        if (!queryState.isReadyToVoLte()) {
+            return CONDITIONALLY_UNAVAILABLE;
+        }
+        return (isUserControlAllowed() && queryState.isAllowUserControl())
+                ? AVAILABLE : AVAILABLE_UNSEARCHABLE;
     }
 
     @Override
@@ -200,19 +186,6 @@
                 CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL);
     }
 
-    private boolean isVolteProvisionedOnDevice(int subId) {
-        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
-            return true;
-        }
-        final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
-        if (provisioningMgr == null) {
-            return true;
-        }
-        return provisioningMgr.getProvisioningStatusForCapability(
-                MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
-                ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
-    }
-
     private class PhoneCallStateListener extends PhoneStateListener {
 
         PhoneCallStateListener() {
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index 3cad316..31e8239 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -28,9 +28,6 @@
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionManager;
 import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
 import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
@@ -40,10 +37,8 @@
 import androidx.slice.builders.ListBuilder.RowBuilder;
 import androidx.slice.builders.SliceAction;
 
-import com.android.ims.ImsManager;
 import com.android.settings.R;
 import com.android.settings.Utils;
-import com.android.settings.network.SubscriptionUtil;
 import com.android.settings.network.ims.VolteQueryImsState;
 import com.android.settings.slices.CustomSliceRegistry;
 import com.android.settings.slices.SliceBroadcastReceiver;
@@ -112,14 +107,6 @@
             return null;
         }
 
-        final ImsManager imsManager = getImsManager(subId);
-
-        if (!imsManager.isVolteEnabledByPlatform()
-                || !isVolteProvisionedOnDevice(subId)) {
-            Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
-            return null;
-        }
-
         if (isCarrierConfigManagerKeyEnabled(
                 CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL, subId, false)
                 || !isCarrierConfigManagerKeyEnabled(
@@ -130,6 +117,11 @@
         }
 
         final VolteQueryImsState queryState = queryImsState(subId);
+        if (!queryState.isVoLteProvisioned()) {
+            Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
+            return null;
+        }
+
         try {
             return getEnhanced4gLteSlice(sliceUri,
                     queryState.isEnabledByUser(), subId);
@@ -164,15 +156,6 @@
                 .build();
     }
 
-    protected ImsManager getImsManager(int subId) {
-        return ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId));
-    }
-
-    @VisibleForTesting
-    ProvisioningManager getProvisioningManager(int subId) {
-        return ProvisioningManager.createForSubscriptionId(subId);
-    }
-
     /**
      * Handles Enhanced 4G LTE mode setting change from Enhanced 4G LTE slice and posts
      * notification. Should be called when intent action is ACTION_ENHANCED_4G_LTE_CHANGED
@@ -183,9 +166,8 @@
         final int subId = getDefaultVoiceSubId();
 
         if (SubscriptionManager.isValidSubscriptionId(subId)) {
-            final ImsManager imsManager = getImsManager(subId);
-            if (imsManager.isVolteEnabledByPlatform() && isVolteProvisionedOnDevice(subId)) {
-                final VolteQueryImsState queryState = queryImsState(subId);
+            final VolteQueryImsState queryState = queryImsState(subId);
+            if (queryState.isVoLteProvisioned()) {
                 final boolean currentValue = queryState.isEnabledByUser()
                         && queryState.isAllowUserControl();
                 final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
@@ -285,16 +267,6 @@
         return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
     }
 
-    private boolean isVolteProvisionedOnDevice(int subId) {
-        final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
-        if (provisioningMgr == null) {
-            return true;
-        }
-        return provisioningMgr.getProvisioningStatusForCapability(
-                MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
-                ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
-    }
-
     @VisibleForTesting
     VolteQueryImsState queryImsState(int subId) {
         return new VolteQueryImsState(mContext, subId);
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index ab8327c..fa5deab 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -48,6 +48,8 @@
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
 import com.android.settingslib.DeviceInfoUtils;
 
+import java.util.List;
+
 /**
  * A dialog allowing the display name of a mobile network subscription to be changed
  */
@@ -115,9 +117,9 @@
                 .setPositiveButton(R.string.mobile_network_sim_name_rename, (dialog, which) -> {
                     mSubscriptionManager.setDisplayName(mNameView.getText().toString(), mSubId,
                             SubscriptionManager.NAME_SOURCE_USER_INPUT);
-                    mSubscriptionManager.setIconTint(
-                            mColors[mColorSpinner.getSelectedItemPosition()].getColor(),
-                            mSubId);
+                    final Color color = (mColorSpinner == null) ? mColors[0]
+                            : mColors[mColorSpinner.getSelectedItemPosition()];
+                    mSubscriptionManager.setIconTint(color.getColor(), mSubId);
                 })
                 .setNegativeButton(android.R.string.cancel, null);
         return builder.create();
@@ -126,7 +128,17 @@
     @VisibleForTesting
     protected void populateView(View view) {
         mNameView = view.findViewById(R.id.name_edittext);
-        final SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
+        SubscriptionInfo info = null;
+        final List<SubscriptionInfo> infoList = mSubscriptionManager
+                .getAvailableSubscriptionInfoList();
+        if (infoList != null) {
+            for (SubscriptionInfo subInfo : infoList) {
+                if (subInfo.getSubscriptionId() == mSubId) {
+                    info = subInfo;
+                    break;
+                }
+            }
+        }
         if (info == null) {
             Log.w(TAG, "got null SubscriptionInfo for mSubId:" + mSubId);
             return;
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index 6fba161..eed4046 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -23,9 +23,6 @@
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
 import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
@@ -33,9 +30,7 @@
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 
-import com.android.ims.ImsManager;
 import com.android.settings.network.MobileDataEnabledListener;
-import com.android.settings.network.SubscriptionUtil;
 import com.android.settings.network.ims.VolteQueryImsState;
 import com.android.settings.network.ims.VtQueryImsState;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -54,8 +49,6 @@
 
     private Preference mPreference;
     private CarrierConfigManager mCarrierConfigManager;
-    @VisibleForTesting
-    ImsManager mImsManager;
     private PhoneCallStateListener mPhoneStateListener;
     @VisibleForTesting
     Integer mCallState;
@@ -101,7 +94,7 @@
             return;
         }
         final SwitchPreference switchPreference = (SwitchPreference) preference;
-        final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
+        final boolean videoCallEnabled = isVideoCallEnabled(mSubId);
         switchPreference.setVisible(videoCallEnabled);
         if (videoCallEnabled) {
             final boolean videoCallEditable = queryVoLteState(mSubId).isEnabledByUser()
@@ -138,53 +131,29 @@
 
     public VideoCallingPreferenceController init(int subId) {
         mSubId = subId;
-        if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
-            mImsManager = ImsManager.getInstance(mContext,
-                    SubscriptionUtil.getPhoneId(mContext, mSubId));
-        }
 
         return this;
     }
 
-    private boolean isVideoCallEnabled(int subId) {
-        final ImsManager imsManager = SubscriptionManager.isValidSubscriptionId(subId)
-                ? ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId))
-                : null;
-        return isVideoCallEnabled(subId, imsManager);
-    }
-
     @VisibleForTesting
-    ProvisioningManager getProvisioningManager(int subId) {
-        return ProvisioningManager.createForSubscriptionId(subId);
-    }
-
-    private boolean isVtProvisionedOnDevice(int subId) {
-        if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
-            return true;
+    boolean isVideoCallEnabled(int subId) {
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            return false;
         }
-        final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
-        if (provisioningMgr == null) {
-            return true;
-        }
-        return provisioningMgr.getProvisioningStatusForCapability(
-                MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
-                ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
-    }
 
-    @VisibleForTesting
-    boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
-        TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
-        if (SubscriptionManager.isValidSubscriptionId(subId)) {
-            telephonyManager = telephonyManager.createForSubscriptionId(subId);
+        if (carrierConfig == null) {
+            return false;
         }
-        return carrierConfig != null && imsManager != null
-                && imsManager.isVtEnabledByPlatform()
-                && isVtProvisionedOnDevice(subId)
-                && MobileNetworkUtils.isImsServiceStateReady(imsManager)
-                && (carrierConfig.getBoolean(
+
+        if (!carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
-                || telephonyManager.isDataEnabled());
+                && (!mContext.getSystemService(TelephonyManager.class)
+                    .createForSubscriptionId(subId).isDataEnabled())) {
+            return false;
+        }
+
+        return queryImsState(subId).isReadyToVideoCall();
     }
 
     @Override
diff --git a/src/com/android/settings/notification/RedactNotificationPreferenceController.java b/src/com/android/settings/notification/RedactNotificationPreferenceController.java
index 94d7fc1..2814e1b 100644
--- a/src/com/android/settings/notification/RedactNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/RedactNotificationPreferenceController.java
@@ -23,17 +23,29 @@
 import android.app.KeyguardManager;
 import android.app.admin.DevicePolicyManager;
 import android.content.Context;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.os.Looper;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.provider.Settings;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.Utils;
 import com.android.settings.core.TogglePreferenceController;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
 
-public class RedactNotificationPreferenceController extends TogglePreferenceController {
-
+/**
+ * The controller of the sensitive notifications.
+ */
+public class RedactNotificationPreferenceController extends TogglePreferenceController implements
+        LifecycleObserver, OnStart, OnStop {
     private static final String TAG = "LockScreenNotifPref";
 
     static final String KEY_LOCKSCREEN_REDACT = "lock_screen_redact";
@@ -43,6 +55,17 @@
     private UserManager mUm;
     private KeyguardManager mKm;
     private final int mProfileUserId;
+    private Preference mPreference;
+    private ContentObserver mContentObserver =
+            new ContentObserver(new Handler(Looper.getMainLooper())) {
+                @Override
+                public void onChange(boolean selfChange) {
+                    if (mPreference != null) {
+                        mPreference.setEnabled(
+                                getAvailabilityStatus() != DISABLED_DEPENDENT_SETTING);
+                    }
+                }
+            };
 
     public RedactNotificationPreferenceController(Context context, String settingKey) {
         super(context, settingKey);
@@ -55,6 +78,12 @@
     }
 
     @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(getPreferenceKey());
+    }
+
+    @Override
     public boolean isChecked() {
         int userId = KEY_LOCKSCREEN_REDACT.equals(getPreferenceKey())
                 ? UserHandle.myUserId() : mProfileUserId;
@@ -108,6 +137,18 @@
         return AVAILABLE;
     }
 
+    @Override
+    public void onStart() {
+        mContext.getContentResolver().registerContentObserver(
+                Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS),
+                false /* notifyForDescendants */, mContentObserver);
+    }
+
+    @Override
+    public void onStop() {
+        mContext.getContentResolver().unregisterContentObserver(mContentObserver);
+    }
+
     private boolean adminAllowsNotifications(int userId) {
         final int dpmFlags = mDpm.getKeyguardDisabledFeatures(null/* admin */, userId);
         return (dpmFlags & KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0;
@@ -123,7 +164,7 @@
                 LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, userId) != 0;
     }
 
-   private boolean getLockscreenNotificationsEnabled(int userId) {
+    private boolean getLockscreenNotificationsEnabled(int userId) {
         return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                 Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1, userId) != 0;
     }
diff --git a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
deleted file mode 100644
index 503b5bc..0000000
--- a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2016 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.notification;
-
-import static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.Utils;
-import com.android.settings.core.TogglePreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
-
-public class VibrateWhenRingPreferenceController extends TogglePreferenceController
-        implements LifecycleObserver, OnResume, OnPause {
-
-    /** Flag for whether or not to apply ramping ringer on incoming phone calls. */
-    private static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
-    private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
-    private final int DEFAULT_VALUE = 0;
-    private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
-    private SettingObserver mSettingObserver;
-
-    public VibrateWhenRingPreferenceController(Context context, String key) {
-        super(context, key);
-    }
-
-    @Override
-    public boolean isChecked() {
-        return Settings.System.getInt(mContext.getContentResolver(),
-                VIBRATE_WHEN_RINGING, DEFAULT_VALUE) != DEFAULT_VALUE;
-    }
-
-    @Override
-    public boolean setChecked(boolean isChecked) {
-        return Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
-                isChecked ? NOTIFICATION_VIBRATE_WHEN_RINGING : DEFAULT_VALUE);
-    }
-
-    @Override
-    @AvailabilityStatus
-    public int getAvailabilityStatus() {
-        // If ramping ringer is enabled then this setting will be injected
-        // with additional options.
-        return Utils.isVoiceCapable(mContext) && !isRampingRingerEnabled()
-            ? AVAILABLE
-            : UNSUPPORTED_ON_DEVICE;
-    }
-
-    @Override
-    public boolean isSliceable() {
-        return TextUtils.equals(getPreferenceKey(), "vibrate_when_ringing");
-    }
-
-    @Override
-    public boolean isPublicSlice() {
-        return true;
-    }
-
-    @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        Preference preference = screen.findPreference(KEY_VIBRATE_WHEN_RINGING);
-        if (preference != null) {
-            mSettingObserver = new SettingObserver(preference);
-            preference.setPersistent(false);
-        }
-    }
-
-    @Override
-    public void onResume() {
-        if (mSettingObserver != null) {
-            mSettingObserver.register(true /* register */);
-        }
-    }
-
-    @Override
-    public void onPause() {
-        if (mSettingObserver != null) {
-            mSettingObserver.register(false /* register */);
-        }
-    }
-
-    private final class SettingObserver extends ContentObserver {
-
-        private final Uri VIBRATE_WHEN_RINGING_URI =
-                Settings.System.getUriFor(VIBRATE_WHEN_RINGING);
-
-        private final Preference mPreference;
-
-        public SettingObserver(Preference preference) {
-            super(new Handler());
-            mPreference = preference;
-        }
-
-        public void register(boolean register) {
-            final ContentResolver cr = mContext.getContentResolver();
-            if (register) {
-                cr.registerContentObserver(VIBRATE_WHEN_RINGING_URI, false, this);
-            } else {
-                cr.unregisterContentObserver(this);
-            }
-        }
-
-        @Override
-        public void onChange(boolean selfChange, Uri uri) {
-            super.onChange(selfChange, uri);
-            if (VIBRATE_WHEN_RINGING_URI.equals(uri)) {
-                updateState(mPreference);
-            }
-        }
-    }
-
-    private boolean isRampingRingerEnabled() {
-        return DeviceConfig.getBoolean(
-                DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
-    }
-
-}
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 8947f8f..6f505bd 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -182,6 +182,15 @@
         if ((mTitle == null) && isManagedProfile) {
             mTitle = getTitleFromOrganizationName(mUserId);
         }
+        final @LockPatternUtils.CredentialType int credentialType = Utils.getCredentialType(
+                mContext, effectiveUserId);
+        if (mTitle == null) {
+            mTitle = getTitleFromCredentialType(credentialType, isManagedProfile);
+        }
+        if (mDetails == null) {
+            mDetails = getDetailsFromCredentialType(credentialType, isManagedProfile);
+        }
+
         mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
         final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
 
@@ -233,6 +242,44 @@
         }
     }
 
+    private String getTitleFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
+            boolean isManagedProfile) {
+        switch (credentialType) {
+            case LockPatternUtils.CREDENTIAL_TYPE_PIN:
+                return isManagedProfile
+                        ? getString(R.string.lockpassword_confirm_your_work_pin_header)
+                        : getString(R.string.lockpassword_confirm_your_pin_header);
+            case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
+                return isManagedProfile
+                        ? getString(R.string.lockpassword_confirm_your_work_pattern_header)
+                        : getString(R.string.lockpassword_confirm_your_pattern_header);
+            case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
+                return isManagedProfile
+                        ? getString(R.string.lockpassword_confirm_your_work_password_header)
+                        : getString(R.string.lockpassword_confirm_your_password_header);
+        }
+        return null;
+    }
+
+    private String getDetailsFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
+            boolean isManagedProfile) {
+        switch (credentialType) {
+            case LockPatternUtils.CREDENTIAL_TYPE_PIN:
+                return isManagedProfile
+                        ? getString(R.string.lockpassword_confirm_your_pin_generic_profile)
+                        : getString(R.string.lockpassword_confirm_your_pin_generic);
+            case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
+                return isManagedProfile
+                        ? getString(R.string.lockpassword_confirm_your_pattern_generic_profile)
+                        : getString(R.string.lockpassword_confirm_your_pattern_generic);
+            case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
+                return isManagedProfile
+                        ? getString(R.string.lockpassword_confirm_your_password_generic_profile)
+                        : getString(R.string.lockpassword_confirm_your_password_generic);
+        }
+        return null;
+    }
+
     @Override
     protected void onStart() {
         super.onStart();
diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceController.java b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java
new file mode 100644
index 0000000..31abd8a
--- /dev/null
+++ b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java
@@ -0,0 +1,66 @@
+/*
+ * 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.sound;
+
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * Controller for vibrate for calls settings.
+ */
+public class VibrateForCallsPreferenceController extends BasePreferenceController {
+
+    private static final int ON = 1;
+    private static final int OFF = 0;
+    @VisibleForTesting
+    static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
+
+    public VibrateForCallsPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    @AvailabilityStatus
+    public int getAvailabilityStatus() {
+        return Utils.isVoiceCapable(mContext) && !DeviceConfig.getBoolean(
+                DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false)
+            ? AVAILABLE
+            : UNSUPPORTED_ON_DEVICE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        if (Settings.Global.getInt(
+                mContext.getContentResolver(),
+                Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
+            return mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer);
+        } else if (Settings.System.getInt(
+                    mContext.getContentResolver(),
+                    Settings.System.VIBRATE_WHEN_RINGING, OFF) == ON) {
+            return mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate);
+        } else {
+            return mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate);
+        }
+    }
+}
diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java
new file mode 100644
index 0000000..73b9f2f
--- /dev/null
+++ b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java
@@ -0,0 +1,167 @@
+/*
+ * 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.sound;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPickerFragment;
+import com.android.settingslib.widget.CandidateInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Fragment for changing vibrate for calls options.
+ */
+public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment {
+    private static final String TAG = "VibrateForCallsPreferenceFragment";
+
+    @VisibleForTesting
+    static final String KEY_NEVER_VIBRATE = "never_vibrate";
+    @VisibleForTesting
+    static final String KEY_ALWAYS_VIBRATE = "always_vibrate";
+    @VisibleForTesting
+    static final String KEY_RAMPING_RINGER = "ramping_ringer";
+
+    private static final int ON = 1;
+    private static final int OFF = 0;
+
+    private final Map<String, VibrateForCallsCandidateInfo> mCandidates;
+
+    public VibrateForCallsPreferenceFragment() {
+        mCandidates = new ArrayMap<>();
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        loadCandidates(context);
+    }
+
+    private void loadCandidates(Context context) {
+        mCandidates.put(KEY_NEVER_VIBRATE,
+                new VibrateForCallsCandidateInfo(
+                        KEY_NEVER_VIBRATE, R.string.vibrate_when_ringing_option_never_vibrate));
+        mCandidates.put(KEY_ALWAYS_VIBRATE,
+                new VibrateForCallsCandidateInfo(
+                        KEY_ALWAYS_VIBRATE, R.string.vibrate_when_ringing_option_always_vibrate));
+        mCandidates.put(KEY_RAMPING_RINGER,
+                new VibrateForCallsCandidateInfo(
+                        KEY_RAMPING_RINGER, R.string.vibrate_when_ringing_option_ramping_ringer));
+    }
+
+    private void updateSettings(VibrateForCallsCandidateInfo candidate) {
+        final String key = candidate.getKey();
+        if (TextUtils.equals(key, KEY_ALWAYS_VIBRATE)) {
+            Settings.System.putInt(
+                    getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, ON);
+            Settings.Global.putInt(
+                    getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
+        } else if (TextUtils.equals(key, KEY_RAMPING_RINGER)) {
+            Settings.System.putInt(
+                    getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
+            Settings.Global.putInt(
+                    getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON);
+        } else {
+            Settings.System.putInt(
+                    getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
+            Settings.Global.putInt(
+                    getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
+        }
+    }
+
+    @Override
+    protected List<? extends CandidateInfo> getCandidates() {
+        final List<VibrateForCallsCandidateInfo> candidates = new ArrayList<>();
+        candidates.add(mCandidates.get(KEY_NEVER_VIBRATE));
+        candidates.add(mCandidates.get(KEY_ALWAYS_VIBRATE));
+        candidates.add(mCandidates.get(KEY_RAMPING_RINGER));
+        return candidates;
+    }
+
+    @Override
+    protected String getDefaultKey() {
+        if (Settings.Global.getInt(
+                 getContext().getContentResolver(),
+                 Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
+            return KEY_RAMPING_RINGER;
+        } else if (Settings.System.getInt(
+                    getContext().getContentResolver(),
+                    Settings.System.VIBRATE_WHEN_RINGING, OFF) == ON) {
+            return KEY_ALWAYS_VIBRATE;
+        } else {
+            return KEY_NEVER_VIBRATE;
+        }
+    }
+
+    @Override
+    protected boolean setDefaultKey(String key) {
+        final VibrateForCallsCandidateInfo candidate = mCandidates.get(key);
+        if (candidate == null) {
+            Log.e(TAG, "Unknown vibrate for calls candidate (key = " + key + ")!");
+            return false;
+        }
+        updateSettings(candidate);
+        return true;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.vibrate_for_calls_settings;
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.VIBRATE_FOR_CALLS;
+    }
+
+    @VisibleForTesting
+    class VibrateForCallsCandidateInfo extends CandidateInfo {
+        private final String mKey;
+        private final int mLabelId;
+
+        VibrateForCallsCandidateInfo(String key, int labelId) {
+            super(true /* enabled */);
+            mKey = key;
+            mLabelId = labelId;
+        }
+
+        @Override
+        public CharSequence loadLabel() {
+            return getContext().getString(mLabelId);
+        }
+
+        @Override
+        public Drawable loadIcon() {
+            return null;
+        }
+
+        @Override
+        public String getKey() {
+            return mKey;
+        }
+    }
+}
diff --git a/src/com/android/settings/vpn2/AppDialogFragment.java b/src/com/android/settings/vpn2/AppDialogFragment.java
index 2f9cd7a..ea9e546 100644
--- a/src/com/android/settings/vpn2/AppDialogFragment.java
+++ b/src/com/android/settings/vpn2/AppDialogFragment.java
@@ -22,6 +22,7 @@
 import android.content.DialogInterface;
 import android.content.pm.PackageInfo;
 import android.net.IConnectivityManager;
+import android.net.VpnManager;
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.ServiceManager;
@@ -145,7 +146,8 @@
         }
         final int userId = getUserId();
         try {
-            mService.setVpnPackageAuthorization(mPackageInfo.packageName, userId, false);
+            mService.setVpnPackageAuthorization(
+                    mPackageInfo.packageName, userId, VpnManager.TYPE_VPN_NONE);
             onDisconnect(dialog);
         } catch (RemoteException e) {
             Log.e(TAG, "Failed to forget authorization of " + mPackageInfo.packageName +
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 5f46446..8e3d9bb 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -15,6 +15,7 @@
  */
 package com.android.settings.vpn2;
 
+import static android.app.AppOpsManager.OP_ACTIVATE_PLATFORM_VPN;
 import static android.app.AppOpsManager.OP_ACTIVATE_VPN;
 
 import android.annotation.NonNull;
@@ -312,7 +313,7 @@
         final AppOpsManager service =
                 (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
         final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
-                application.packageName, new int[]{OP_ACTIVATE_VPN});
+                application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
         return !ArrayUtils.isEmpty(ops);
     }
 
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 83cdf71..8a2b465 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.vpn2;
 
+import static android.app.AppOpsManager.OP_ACTIVATE_PLATFORM_VPN;
 import static android.app.AppOpsManager.OP_ACTIVATE_VPN;
 
 import android.annotation.UiThread;
@@ -522,7 +523,8 @@
 
         // Fetch VPN-enabled apps from AppOps.
         AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
-        List<AppOpsManager.PackageOps> apps = aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN});
+        List<AppOpsManager.PackageOps> apps =
+                aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
         if (apps != null) {
             for (AppOpsManager.PackageOps pkg : apps) {
                 int userId = UserHandle.getUserId(pkg.getUid());
@@ -533,8 +535,8 @@
                 // Look for a MODE_ALLOWED permission to activate VPN.
                 boolean allowed = false;
                 for (AppOpsManager.OpEntry op : pkg.getOps()) {
-                    if (op.getOp() == OP_ACTIVATE_VPN &&
-                            op.getMode() == AppOpsManager.MODE_ALLOWED) {
+                    if ((op.getOp() == OP_ACTIVATE_VPN || op.getOp() == OP_ACTIVATE_PLATFORM_VPN)
+                            && op.getMode() == AppOpsManager.MODE_ALLOWED) {
                         allowed = true;
                     }
                 }
diff --git a/src/com/android/settings/widget/MasterSwitchPreference.java b/src/com/android/settings/widget/MasterSwitchPreference.java
index b34b162..9fe077e 100644
--- a/src/com/android/settings/widget/MasterSwitchPreference.java
+++ b/src/com/android/settings/widget/MasterSwitchPreference.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Switch;
@@ -81,6 +82,11 @@
                     }
                 }
             });
+
+            // Consumes move events to ignore drag actions.
+            switchWidget.setOnTouchListener((v, event) -> {
+                return event.getActionMasked() == MotionEvent.ACTION_MOVE;
+            });
         }
 
         mSwitch = (Switch) holder.findViewById(R.id.switchWidget);
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index 225e68c..932f5d9 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -707,10 +707,10 @@
 
         boolean hasAvailableWifiEntries = false;
         mStatusMessagePreference.setVisible(false);
-        mConnectedWifiEntryPreferenceCategory.setVisible(true);
         mWifiEntryPreferenceCategory.setVisible(true);
 
         final WifiEntry connectedEntry = mWifiPickerTracker.getConnectedWifiEntry();
+        mConnectedWifiEntryPreferenceCategory.setVisible(connectedEntry != null);
         if (connectedEntry != null) {
             final LongPressWifiEntryPreference connectedPref =
                     mConnectedWifiEntryPreferenceCategory.findPreference(connectedEntry.getKey());
diff --git a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
index b584ea1..05c7b4e 100644
--- a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
+++ b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
@@ -715,7 +715,7 @@
     }
 
     @VisibleForTesting
-    void updateScanResults(List<AccessPoint> allAccessPoints) {
+    void updateScanResultsToUi(List<AccessPoint> allAccessPoints) {
         if (mUiToRequestedList == null) {
             // Nothing need to be updated.
             return;
@@ -723,13 +723,16 @@
 
         // Update the signal level of the UI networks.
         for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
-            final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
-                    .stream()
-                    .filter(accesspoint -> accesspoint.matches(
-                            uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
-                    .findFirst();
-            uiConfigurationItem.mLevel =
-                    matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+            uiConfigurationItem.mLevel = 0;
+            if (allAccessPoints != null) {
+                final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
+                        .stream()
+                        .filter(accesspoint -> accesspoint.matches(
+                                uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
+                        .findFirst();
+                uiConfigurationItem.mLevel =
+                        matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+            }
         }
 
         if (mIsSingleNetwork) {
@@ -742,7 +745,17 @@
     }
 
     @Override
+    public void onResume() {
+        super.onResume();
+        onAccessPointsChanged();
+    }
+
+    /**
+     * Update the results when data changes
+     */
+    @Override
     public void onAccessPointsChanged() {
-        updateScanResults(mWifiTracker.getAccessPoints());
+        updateScanResultsToUi(
+                mWifiTracker.getManager().isWifiEnabled() ? mWifiTracker.getAccessPoints() : null);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
index be3c685..d179cae 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
@@ -33,14 +33,19 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.robolectric.Shadows.shadowOf;
 
 import android.content.Context;
 import android.net.Uri;
 import android.os.Bundle;
 import android.provider.Settings;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
 import android.util.ArrayMap;
 import android.util.FeatureFlagUtils;
 
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
 import com.android.settings.core.FeatureFlags;
 import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardController;
 import com.android.settings.homepage.contextualcards.conditional.ConditionFooterContextualCard;
@@ -58,8 +63,9 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -67,8 +73,9 @@
 import java.util.Map;
 import java.util.stream.Collectors;
 
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
 public class ContextualCardManagerTest {
+    private static final int SUB_ID = 2;
 
     private static final String TEST_SLICE_URI = "context://test/test";
     private static final String TEST_SLICE_NAME = "test_name";
@@ -79,6 +86,8 @@
     Lifecycle mLifecycle;
 
     private Context mContext;
+    private ShadowSubscriptionManager mShadowSubscriptionManager;
+    private ShadowTelephonyManager mShadowTelephonyManager;
     private ContextualCardManager mManager;
 
     @Before
@@ -86,6 +95,16 @@
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
         FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONDITIONAL_CARDS, true);
+
+        mShadowSubscriptionManager = shadowOf(
+                mContext.getSystemService(SubscriptionManager.class));
+        mShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID);
+
+        final TelephonyManager telephonyManager =
+                mContext.getSystemService(TelephonyManager.class);
+        mShadowTelephonyManager = shadowOf(telephonyManager);
+        mShadowTelephonyManager.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
+
         mManager = new ContextualCardManager(mContext, mLifecycle, null /* bundle */);
     }
 
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ControllerRendererPoolTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ControllerRendererPoolTest.java
index 0cb0598..ad2dd2a 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ControllerRendererPoolTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ControllerRendererPoolTest.java
@@ -18,7 +18,13 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
+
 import android.content.Context;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
 
 import androidx.lifecycle.LifecycleOwner;
 
@@ -27,11 +33,17 @@
 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.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
 
 @RunWith(RobolectricTestRunner.class)
 public class ControllerRendererPoolTest {
+    private static final int SUB_ID = 1;
 
     private static final int UNSUPPORTED_CARD_TYPE = -99999;
     private static final int UNSUPPORTED_VIEW_TYPE = -99999;
@@ -41,12 +53,27 @@
     private Lifecycle mLifecycle;
     private LifecycleOwner mLifecycleOwner;
 
+    @Mock
+    private TelephonyManager mTelephonyMgr;
+
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
         mContext = RuntimeEnvironment.application;
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
 
+        // SubscriptionManager and TelephonyManager for CellularDataConditionController
+        ShadowSubscriptionManager shadowSubscriptionMgr = shadowOf(
+                mContext.getSystemService(SubscriptionManager.class));
+        shadowSubscriptionMgr.setDefaultDataSubscriptionId(SUB_ID);
+
+        ShadowTelephonyManager shadowTelephonyMgr = Shadow.extract(
+                mContext.getSystemService(TelephonyManager.class));
+        shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(SUB_ID, mTelephonyMgr);
+        when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
+
         mPool = new ControllerRendererPool();
     }
 
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
index 06f9b98..ad2930d 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
@@ -23,8 +23,11 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
 
 import android.content.Context;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
 
 import com.android.settings.homepage.contextualcards.ContextualCard;
 import com.android.settings.homepage.contextualcards.ContextualCard.CardType;
@@ -37,6 +40,8 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
 import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
@@ -45,6 +50,7 @@
 
 @RunWith(RobolectricTestRunner.class)
 public class ConditionContextualCardControllerTest {
+    private static final int SUB_ID = 2;
 
     @Mock
     private ConditionManager mConditionManager;
@@ -57,6 +63,17 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
+
+        // parameters required by CellularDataConditionController
+        final ShadowSubscriptionManager shadowSubscriptionMgr = shadowOf(
+                mContext.getSystemService(SubscriptionManager.class));
+        shadowSubscriptionMgr.setDefaultDataSubscriptionId(SUB_ID);
+
+        final TelephonyManager telephonyManager =
+                spy(mContext.getSystemService(TelephonyManager.class));
+        final ShadowTelephonyManager shadowTelephonyMgr = shadowOf(telephonyManager);
+        shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
+
         mController = spy(new ConditionContextualCardController(mContext));
         ReflectionHelpers.setField(mController, "mConditionManager", mConditionManager);
     }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
index 7170bdd..3be65dc 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
@@ -25,6 +25,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
+import android.app.UiModeManager;
 import android.content.Context;
 import android.net.Uri;
 import android.os.BatteryManager;
@@ -54,6 +55,8 @@
     private BatteryManager mBatteryManager;
     @Mock
     private PowerManager mPowerManager;
+    @Mock
+    private UiModeManager mUiModeManager;
 
     private Context mContext;
     private DarkThemeSlice mDarkThemeSlice;
@@ -68,6 +71,7 @@
         mFeatureFactory.slicesFeatureProvider.newUiSession();
         doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
         when(mPowerManager.isPowerSaveMode()).thenReturn(false);
+        doReturn(mUiModeManager).when(mContext).getSystemService(UiModeManager.class);
 
         // Set-up specs for SliceMetadata.
         SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -90,8 +94,25 @@
     }
 
     @Test
+    public void isAvailable_nonDarkTheme_autoNightMode_returnFalse() {
+        mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
+        setNightMode(UiModeManager.MODE_NIGHT_AUTO);
+
+        assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
+    }
+
+    @Test
+    public void isAvailable_nonDarkTheme_customNightMode_returnFalse() {
+        mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
+        setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
+
+        assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
+    }
+
+    @Test
     public void isAvailable_nonDarkThemeBatteryCapacityEq100_returnFalse() {
         setBatteryCapacityLevel(100);
+        setNightMode(UiModeManager.MODE_NIGHT_NO);
 
         assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
     }
@@ -99,6 +120,7 @@
     @Test
     public void isAvailable_nonDarkThemeBatteryCapacityLt50_returnTrue() {
         setBatteryCapacityLevel(40);
+        setNightMode(UiModeManager.MODE_NIGHT_NO);
 
         assertThat(mDarkThemeSlice.isAvailable(mContext)).isTrue();
     }
@@ -142,6 +164,7 @@
                 mFeatureFactory.slicesFeatureProvider.getUiSessionToken();
         mDarkThemeSlice.sKeepSliceShow = true;
         setBatteryCapacityLevel(40);
+        setNightMode(UiModeManager.MODE_NIGHT_NO);
 
         assertThat(mDarkThemeSlice.getSlice()).isNotNull();
     }
@@ -162,6 +185,7 @@
         mDarkThemeSlice.sSliceClicked = true;
 
         setBatteryCapacityLevel(40);
+        setNightMode(UiModeManager.MODE_NIGHT_NO);
 
         assertThat(mDarkThemeSlice.getSlice()).isNotNull();
     }
@@ -169,6 +193,7 @@
     @Test
     public void getSlice_isAvailable_returnSlice() {
         setBatteryCapacityLevel(40);
+        setNightMode(UiModeManager.MODE_NIGHT_NO);
 
         assertThat(mDarkThemeSlice.getSlice()).isNotNull();
     }
@@ -176,6 +201,7 @@
     @Test
     public void getSlice_isAvailable_showTitleSubtitle() {
         setBatteryCapacityLevel(40);
+        setNightMode(UiModeManager.MODE_NIGHT_NO);
 
         final Slice slice = mDarkThemeSlice.getSlice();
         final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
@@ -191,4 +217,8 @@
         when(mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY))
                 .thenReturn(power_level);
     }
+
+    private void setNightMode(int mode) {
+        when(mUiModeManager.getNightMode()).thenReturn(mode);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
index bd04b12..4b0df98 100644
--- a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
@@ -38,6 +38,7 @@
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -113,6 +114,7 @@
     }
 
     @Test
+    @Ignore
     public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() {
         mController.displayPreference(mScreen);
         final EnforcedAdmin admin = mock(EnforcedAdmin.class);
@@ -126,6 +128,7 @@
     }
 
     @Test
+    @Ignore
     public void onLocationModeChanged_locationOff_shouldDisablePreference() {
         mController.displayPreference(mScreen);
         doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
index c9b9ff9..adbd14d 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
@@ -17,6 +17,7 @@
 
 package com.android.settings.media;
 
+import static android.app.slice.Slice.EXTRA_RANGE_VALUE;
 import static android.app.slice.Slice.HINT_LIST_ITEM;
 import static android.app.slice.SliceItem.FORMAT_SLICE;
 
@@ -144,6 +145,7 @@
         final MediaDevice device = mock(MediaDevice.class);
         when(device.getName()).thenReturn(TEST_DEVICE_1_NAME);
         when(device.getIcon()).thenReturn(mTestDrawable);
+        when(device.getMaxVolume()).thenReturn(100);
         when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(device);
 
         final Slice mediaSlice = mMediaOutputSlice.getSlice();
@@ -188,4 +190,23 @@
 
         verify(mLocalMediaManager, never()).connectDevice(device);
     }
+
+    @Test
+    public void onNotifyChange_adjustVolume() {
+        mDevices.clear();
+        final MediaDevice device = mock(MediaDevice.class);
+        when(device.getId()).thenReturn(TEST_DEVICE_1_ID);
+        when(mLocalMediaManager.getMediaDeviceById(mDevices, TEST_DEVICE_1_ID)).thenReturn(device);
+        mDevices.add(device);
+
+        mMediaDeviceUpdateWorker.onDeviceListUpdate(mDevices);
+
+        final Intent intent = new Intent();
+        intent.putExtra("media_device_id", TEST_DEVICE_1_ID);
+        intent.putExtra(EXTRA_RANGE_VALUE, 30);
+
+        mMediaOutputSlice.onNotifyChange(intent);
+
+        verify(device).requestSetVolume(30);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java b/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
new file mode 100644
index 0000000..d2a7129
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
@@ -0,0 +1,38 @@
+/*
+ * 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.network.ims;
+
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class MockImsQueryResult {
+
+    public static class BooleanResult implements ImsQuery {
+        private boolean mResult;
+
+        public BooleanResult(boolean result) {
+            super();
+            mResult = result;
+        }
+
+        public boolean query() {
+            return mResult;
+        }
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
new file mode 100644
index 0000000..42ddd70
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
@@ -0,0 +1,84 @@
+/*
+ * 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+
+/**
+ * Controller class for mock VoLte status
+ */
+public class MockVolteQueryImsState extends VolteQueryImsState {
+
+    private ImsQuery mIsTtyOnVolteEnabled;
+    private ImsQuery mIsProvisionedOnDevice;
+    private ImsQuery mIsEnabledByUser;
+
+    /**
+     * Constructor
+     *
+     * @param context {@link Context}
+     * @param subId subscription's id
+     */
+    public MockVolteQueryImsState(Context context, int subId) {
+        super(context, subId);
+    }
+
+    public ImsManager getImsManager(int subId) {
+        return super.getImsManager(subId);
+    }
+
+    public void setIsTtyOnVolteEnabled(boolean enabled) {
+        mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+    }
+
+    @Override
+    ImsQuery isTtyOnVolteEnabled(int subId) {
+        if (mIsTtyOnVolteEnabled != null) {
+            return mIsTtyOnVolteEnabled;
+        }
+        return super.isTtyOnVolteEnabled(subId);
+    }
+
+    public void setIsProvisionedOnDevice(boolean isProvisioned) {
+        mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+    }
+
+    @Override
+    ImsQuery isProvisionedOnDevice(int subId) {
+        if (mIsProvisionedOnDevice != null) {
+            return mIsProvisionedOnDevice;
+        }
+        return super.isProvisionedOnDevice(subId);
+    }
+
+    public void setIsEnabledByUser(boolean enabled) {
+        mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+    }
+
+    @Override
+    ImsQuery isEnabledByUser(int subId) {
+        if (mIsEnabledByUser != null) {
+            return mIsEnabledByUser;
+        }
+        return super.isEnabledByUser(subId);
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
new file mode 100644
index 0000000..b5971e9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
@@ -0,0 +1,82 @@
+/*
+ * 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+/**
+ * Controller class for mock VT status
+ */
+public class MockVtQueryImsState extends VtQueryImsState {
+
+    private ImsQuery mIsTtyOnVolteEnabled;
+    private ImsQuery mIsProvisionedOnDevice;
+    private ImsQuery mIsEnabledByUser;
+
+    /**
+     * Constructor
+     *
+     * @param context {@link Context}
+     * @param subId subscription's id
+     */
+    public MockVtQueryImsState(Context context, int subId) {
+        super(context, subId);
+    }
+
+    public ImsManager getImsManager(int subId) {
+        return super.getImsManager(subId);
+    }
+
+    public void setIsTtyOnVolteEnabled(boolean enabled) {
+        mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+    }
+
+    @Override
+    ImsQuery isTtyOnVolteEnabled(int subId) {
+        if (mIsTtyOnVolteEnabled != null) {
+            return mIsTtyOnVolteEnabled;
+        }
+        return super.isTtyOnVolteEnabled(subId);
+    }
+
+    public void setIsProvisionedOnDevice(boolean isProvisioned) {
+        mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+    }
+
+    @Override
+    ImsQuery isProvisionedOnDevice(int subId) {
+        if (mIsProvisionedOnDevice != null) {
+            return mIsProvisionedOnDevice;
+        }
+        return super.isProvisionedOnDevice(subId);
+    }
+
+    public void setIsEnabledByUser(boolean enabled) {
+        mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+    }
+
+    @Override
+    ImsQuery isEnabledByUser(int subId) {
+        if (mIsEnabledByUser != null) {
+            return mIsEnabledByUser;
+        }
+        return super.isEnabledByUser(subId);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
index 3e0bfa3..d7db984 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
@@ -35,7 +35,7 @@
 
 import com.android.ims.ImsManager;
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
 import com.android.settingslib.RestrictedSwitchPreference;
 
 import org.junit.Before;
@@ -63,7 +63,7 @@
     @Mock
     private ProvisioningManager mProvisioningManager;
 
-    private VolteQueryImsState mQueryImsState;
+    private MockVolteQueryImsState mQueryImsState;
 
     private Enhanced4gLtePreferenceController mController;
     private SwitchPreference mPreference;
@@ -85,17 +85,13 @@
         mCarrierConfig = new PersistableBundle();
         doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
 
-        mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+        mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+        doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
+        mQueryImsState.setIsProvisionedOnDevice(true);
 
         mPreference = new RestrictedSwitchPreference(mContext);
-        mController = spy(new Enhanced4gLtePreferenceController(mContext, "roaming") {
-            @Override
-            ProvisioningManager getProvisioningManager(int subId) {
-                return mProvisioningManager;
-            }
-        });
+        mController = spy(new Enhanced4gLtePreferenceController(mContext, "VoLTE"));
         mController.init(SUB_ID);
-        mController.mImsManager = mImsManager;
         doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
         mPreference.setKey(mController.getPreferenceKey());
     }
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
index c9abe23..a89a7aa 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
@@ -34,8 +34,6 @@
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionManager;
 import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
 
 import androidx.slice.Slice;
 import androidx.slice.SliceItem;
@@ -47,7 +45,7 @@
 
 import com.android.ims.ImsManager;
 import com.android.settings.R;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
 import com.android.settings.slices.CustomSliceRegistry;
 import com.android.settings.slices.SettingsSliceProvider;
 import com.android.settings.slices.SliceBroadcastReceiver;
@@ -81,7 +79,7 @@
     private ProvisioningManager mProvisioningManager;
 
     private ShadowSubscriptionManager mShadowSubscriptionManager;
-    private VolteQueryImsState mQueryImsState;
+    private MockVolteQueryImsState mQueryImsState;
 
     private Context mContext;
     private FakeEnhanced4gLteSliceHelper mEnhanced4gLteSliceHelper;
@@ -110,7 +108,9 @@
         //setup for SliceBroadcastReceiver test
         mReceiver = spy(new SliceBroadcastReceiver());
 
-        mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+        mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+        doReturn(mMockImsManager).when(mQueryImsState).getImsManager(anyInt());
+        mQueryImsState.setIsProvisionedOnDevice(true);
 
         mEnhanced4gLteSliceHelper = spy(new FakeEnhanced4gLteSliceHelper(mContext));
         doReturn(mQueryImsState).when(mEnhanced4gLteSliceHelper).queryImsState(anyInt());
@@ -143,9 +143,7 @@
     @Test
     public void test_CreateEnhanced4gLteSlice_success() {
         when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
-        when(mProvisioningManager.getProvisioningStatusForCapability(
-                MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
-                ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+        mQueryImsState.setIsProvisionedOnDevice(true);
         doReturn(true).when(mQueryImsState).isEnabledByUser();
         when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
         when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -160,9 +158,7 @@
     @Test
     public void test_SettingSliceProvider_getsRightSliceEnhanced4gLte() {
         when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
-        when(mProvisioningManager.getProvisioningStatusForCapability(
-                MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
-                ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+        mQueryImsState.setIsProvisionedOnDevice(true);
         doReturn(true).when(mQueryImsState).isEnabledByUser();
         when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
         when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -179,9 +175,7 @@
     @Ignore
     public void test_SliceBroadcastReceiver_toggleOffEnhanced4gLte() {
         when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
-        when(mProvisioningManager.getProvisioningStatusForCapability(
-                MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
-                ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+        mQueryImsState.setIsProvisionedOnDevice(true);
         doReturn(false).when(mQueryImsState).isEnabledByUser();
         when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
         when(mSlicesFeatureProvider.getNewEnhanced4gLteSliceHelper(mContext))
@@ -278,7 +272,7 @@
     }
 
     private class FakeEnhanced4gLteSliceHelper extends Enhanced4gLteSliceHelper {
-        int mSubId = 1;
+        int mSubId = SUB_ID;
 
         FakeEnhanced4gLteSliceHelper(Context context) {
             super(context);
@@ -289,16 +283,6 @@
             return mMockCarrierConfigManager;
         }
 
-        @Override
-        protected ImsManager getImsManager(int subId) {
-            return mMockImsManager;
-        }
-
-        @Override
-        ProvisioningManager getProvisioningManager(int subId) {
-            return mProvisioningManager;
-        }
-
         protected int getDefaultVoiceSubId() {
             return mSubId;
         }
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 a69ab53..5b34106 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
@@ -23,12 +23,12 @@
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
 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;
 
+import android.content.Context;
 import android.content.DialogInterface;
 import android.graphics.Color;
 import android.telephony.ServiceState;
@@ -56,7 +56,13 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowTelephonyManager;
+
+import java.util.ArrayList;
+import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
 @Config(shadows = ShadowAlertDialogCompat.class)
@@ -65,6 +71,8 @@
     @Mock
     private TelephonyManager mTelephonyMgr;
     @Mock
+    private ServiceState mServiceState;
+    @Mock
     private SubscriptionManager mSubscriptionMgr;
     @Mock
     private SubscriptionInfo mSubscriptionInfo;
@@ -72,26 +80,39 @@
     private FragmentActivity mActivity;
     private RenameMobileNetworkDialogFragment mFragment;
     private int mSubscriptionId = 1234;
+    private List<SubscriptionInfo> mSubscriptionInfoList;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
+
+        Context context = spy(RuntimeEnvironment.application);
+
+        final ShadowTelephonyManager stm = Shadow.extract(context.getSystemService(
+                TelephonyManager.class));
+        stm.setTelephonyManagerForSubscriptionId(mSubscriptionId, mTelephonyMgr);
+        when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
+
+        when(mTelephonyMgr.getServiceState()).thenReturn(mServiceState);
+        when(mServiceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
 
         when(mSubscriptionInfo.getSubscriptionId()).thenReturn(mSubscriptionId);
         when(mSubscriptionInfo.getDisplayName()).thenReturn("test");
+        when(mSubscriptionMgr.setDisplayName(any(), anyInt(), anyInt())).thenReturn(0);
+
+        mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).setup().get());
 
         mFragment = spy(RenameMobileNetworkDialogFragment.newInstance(mSubscriptionId));
-        doReturn(mTelephonyMgr).when(mFragment).getTelephonyManager(any());
         doReturn(mSubscriptionMgr).when(mFragment).getSubscriptionManager(any());
 
-        final ServiceState serviceState = mock(ServiceState.class);
-        when(serviceState.getOperatorAlphaLong()).thenReturn("fake carrier name");
-        when(mTelephonyMgr.createForSubscriptionId(anyInt())).thenReturn(mTelephonyMgr);
-        when(mTelephonyMgr.getServiceState()).thenReturn(serviceState);
+        mSubscriptionInfoList = new ArrayList<SubscriptionInfo>();
+        mSubscriptionInfoList.add(mSubscriptionInfo);
+        when(mSubscriptionMgr.getAvailableSubscriptionInfoList()).thenReturn(
+                mSubscriptionInfoList);
     }
 
     @Test
+    @Ignore
     public void dialog_subscriptionMissing_noCrash() {
         final AlertDialog dialog = startDialog();
         final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
@@ -102,8 +123,6 @@
     @Test
     @Ignore
     public void dialog_cancelButtonClicked_setDisplayNameAndIconTintNotCalled() {
-        when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
-                mSubscriptionInfo);
         final AlertDialog dialog = startDialog();
         final EditText nameView = mFragment.getNameView();
         nameView.setText("test2");
@@ -118,9 +137,6 @@
     @Test
     @Ignore
     public void dialog_saveButtonClicked_setDisplayNameAndIconTint() {
-        when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
-                mSubscriptionInfo);
-
         final AlertDialog dialog = startDialog();
         final EditText nameView = mFragment.getNameView();
         nameView.setText("test2");
@@ -144,8 +160,6 @@
     public void populateView_infoIsOpportunistic_hideNumberLabel() {
         final View view = LayoutInflater.from(mActivity).inflate(
                 R.layout.dialog_mobile_network_rename, null);
-        when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
-                mSubscriptionInfo);
         when(mSubscriptionInfo.isOpportunistic()).thenReturn(true);
 
         startDialog();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index e68a0f4..c766289 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -20,7 +20,6 @@
 
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.eq;
 import static org.mockito.Mockito.spy;
 
 import android.content.Context;
@@ -29,14 +28,13 @@
 import android.telephony.TelephonyManager;
 import android.telephony.ims.ProvisioningManager;
 import android.telephony.ims.feature.ImsFeature;
-import android.telephony.ims.feature.MmTelFeature;
 
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 
 import com.android.ims.ImsManager;
+import com.android.settings.network.ims.MockVtQueryImsState;
 import com.android.settings.network.ims.VolteQueryImsState;
-import com.android.settings.network.ims.VtQueryImsState;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -61,7 +59,7 @@
     @Mock
     private PreferenceScreen mPreferenceScreen;
 
-    private VtQueryImsState mQueryImsState;
+    private MockVtQueryImsState mQueryImsState;
     private VolteQueryImsState mQueryVoLteState;
 
     private VideoCallingPreferenceController mController;
@@ -74,7 +72,6 @@
         MockitoAnnotations.initMocks(this);
 
         mContext = spy(RuntimeEnvironment.application);
-        doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
         doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
         doReturn(mCarrierConfigManager).when(mContext)
                 .getSystemService(CarrierConfigManager.class);
@@ -85,29 +82,22 @@
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
         doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
 
-        mQueryImsState = spy(new VtQueryImsState(mContext, SUB_ID));
+        mQueryImsState = spy(new MockVtQueryImsState(mContext, SUB_ID));
         doReturn(true).when(mQueryImsState).isEnabledByUser();
+        doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
 
         mQueryVoLteState = spy(new VolteQueryImsState(mContext, SUB_ID));
         doReturn(true).when(mQueryVoLteState).isEnabledByUser();
 
         mPreference = new SwitchPreference(mContext);
-        mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling") {
-            @Override
-            ProvisioningManager getProvisioningManager(int subId) {
-                return mProvisioningManager;
-            }
-        });
+        mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling"));
         mController.init(SUB_ID);
-        mController.mImsManager = mImsManager;
         doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
         doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
         mPreference.setKey(mController.getPreferenceKey());
 
         doReturn(true).when(mImsManager).isVtEnabledByPlatform();
-        doReturn(true).when(mProvisioningManager)
-                .getProvisioningStatusForCapability(
-                eq(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO), anyInt());
+        mQueryImsState.setIsProvisionedOnDevice(true);
         doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
         doReturn(true).when(mTelephonyManager).isDataEnabled();
 
@@ -116,14 +106,15 @@
 
     @Test
     public void isVideoCallEnabled_allFlagsOn_returnTrue() {
-        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
+        assertThat(mController.isVideoCallEnabled(SUB_ID)).isTrue();
     }
 
     @Test
     public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
+        mQueryImsState.setIsProvisionedOnDevice(false);
         doReturn(false).when(mImsManager).isVtEnabledByPlatform();
 
-        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
+        assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
     }
 
     @Test
@@ -132,7 +123,7 @@
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
         doReturn(false).when(mTelephonyManager).isDataEnabled();
 
-        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
+        assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
deleted file mode 100644
index ec275c1..0000000
--- a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2016 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.notification;
-
-import static android.provider.Settings.System.VIBRATE_WHEN_RINGING;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
-import android.telephony.TelephonyManager;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
-import com.android.settings.testutils.shadow.ShadowDeviceConfig;
-
-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 org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowContentResolver;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows={ShadowDeviceConfig.class})
-public class VibrateWhenRingPreferenceControllerTest {
-
-    private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
-    private final int DEFAULT_VALUE = 0;
-    private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
-    private Context mContext;
-    private ContentResolver mContentResolver;
-    @Mock
-    private PreferenceScreen mScreen;
-    @Mock
-    private TelephonyManager mTelephonyManager;
-    private VibrateWhenRingPreferenceController mController;
-    private Preference mPreference;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
-        mContentResolver = mContext.getContentResolver();
-        when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
-        mController = new VibrateWhenRingPreferenceController(mContext, KEY_VIBRATE_WHEN_RINGING);
-        mPreference = new Preference(mContext);
-        mPreference.setKey(mController.getPreferenceKey());
-        when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
-    }
-
-    @Test
-    public void display_shouldDisplay() {
-        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
-        DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
-        mController.displayPreference(mScreen);
-        assertThat(mPreference.isVisible()).isTrue();
-    }
-
-    @Test
-    public void display_shouldNotDisplay_notVoiceCapable() {
-        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
-        DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
-        mController.displayPreference(mScreen);
-        assertThat(mPreference.isVisible()).isFalse();
-    }
-
-    @Test
-    public void display_shouldNotDisplay_RampingRingerEnabled() {
-        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
-        DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
-        mController.displayPreference(mScreen);
-        assertThat(mPreference.isVisible()).isFalse();
-    }
-
-    @Test
-    public void display_shouldNotDisplay_VoiceEnabled_RampingRingerEnabled() {
-        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
-        DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
-        mController.displayPreference(mScreen);
-        assertThat(mPreference.isVisible()).isFalse();
-    }
-
-    @Test
-    public void display_shouldNotDisplay_VoiceDisabled_RampingRingerEnabled() {
-        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
-        DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
-        mController.displayPreference(mScreen);
-        assertThat(mPreference.isVisible()).isFalse();
-    }
-
-    @Test
-    public void testOnPreferenceChange_turnOn_returnOn() {
-        mController.onPreferenceChange(null, true);
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
-                VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
-
-        assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
-    }
-
-    @Test
-    public void testOnPreferenceChange_turnOff_returnOff() {
-        mController.onPreferenceChange(null, false);
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
-                VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
-
-        assertThat(mode).isEqualTo(DEFAULT_VALUE);
-    }
-
-    @Test
-    public void voiceCapable_availabled() {
-        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
-        DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
-        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
-    }
-
-    @Test
-    public void voiceCapable_notAvailabled() {
-        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
-        DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
-        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
-    }
-
-    @Test
-    public void updateState_settingIsOn_preferenceShouldBeChecked() {
-        final TwoStatePreference preference = mock(TwoStatePreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 1);
-
-        mController.updateState(preference);
-
-        assertThat(mController.isChecked()).isTrue();
-    }
-
-    @Test
-    public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
-        final TwoStatePreference preference = mock(TwoStatePreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
-
-        mController.updateState(preference);
-
-        assertThat(mController.isChecked()).isFalse();
-    }
-
-    @Test
-    public void setChecked_settingsIsOn() {
-        mController.setChecked(true);
-        final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
-                -1);
-
-        assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
-    }
-
-    @Test
-    public void setChecked_settingsIsOff() {
-        mController.setChecked(false);
-        final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
-                -1);
-
-        assertThat(mode).isEqualTo(DEFAULT_VALUE);
-    }
-
-    @Test
-    public void testObserver_onResume_shouldRegisterObserver() {
-        final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
-        mController.displayPreference(mScreen);
-
-        mController.onResume();
-
-        assertThat(shadowContentResolver.getContentObservers(
-                Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isNotEmpty();
-    }
-
-    @Test
-    public void testObserver_onPause_shouldUnregisterObserver() {
-        final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
-        mController.displayPreference(mScreen);
-
-        mController.onResume();
-        mController.onPause();
-
-        assertThat(shadowContentResolver.getContentObservers(
-                Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isEmpty();
-    }
-
-    @Test
-    public void isSliceableCorrectKey_returnsTrue() {
-        final VibrateWhenRingPreferenceController controller =
-                new VibrateWhenRingPreferenceController(mContext, "vibrate_when_ringing");
-        assertThat(controller.isSliceable()).isTrue();
-    }
-
-    @Test
-    public void isSliceableIncorrectKey_returnsFalse() {
-        final VibrateWhenRingPreferenceController controller =
-                new VibrateWhenRingPreferenceController(mContext, "bad_key");
-        assertThat(controller.isSliceable()).isFalse();
-    }
-
-    @Test
-    public void isPublicSlice_returnTrue() {
-        assertThat(mController.isPublicSlice()).isTrue();
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java
new file mode 100644
index 0000000..bf2b0f3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.sound;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+import android.telephony.TelephonyManager;
+
+import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+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;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowDeviceConfig.class})
+public class VibrateForCallsPreferenceControllerTest {
+
+    private static final int OFF = 0;
+    private static final int ON = 1;
+    private Context mContext;
+    private ContentResolver mContentResolver;
+    @Mock
+    private TelephonyManager mTelephonyManager;
+    private VibrateForCallsPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        mContentResolver = mContext.getContentResolver();
+        when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
+        mController = new VibrateForCallsPreferenceController(
+            mContext, VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED);
+    }
+
+    @Test
+    public void getAvailabilityStatus_notVoiceCapable_returnUnsupportedOnDevice() {
+        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
+        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+                VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "false", false);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_rampingRingerEnabled_returnUnsupportedOnDevice() {
+        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+                VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "true", false);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_voiceCapableAndRampingRingerDisabled_returnAvailable() {
+        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+                VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "false", false);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+
+    @Test
+    public void getSummary_applyRampingRinger_rampingRingerSummary() {
+        Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+        Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
+
+        assertThat(mController.getSummary()).isEqualTo(
+                mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer));
+    }
+
+    @Test
+    public void getSummary_enableVibrateWhenRinging_alwaysVibrateSummary() {
+        Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
+        Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+        assertThat(mController.getSummary()).isEqualTo(
+                mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate));
+    }
+
+    @Test
+    public void getSummary_notApplyRampingRingerDisableVibrateWhenRinging_neverVibrateSummary() {
+        Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+        Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+        assertThat(mController.getSummary()).isEqualTo(
+                mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate));
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java
new file mode 100644
index 0000000..0a766d6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.sound;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.ContentResolver;
+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 VibrateForCallsPreferenceFragmentTest {
+
+    private static final int OFF = 0;
+    private static final int ON = 1;
+    private Context mContext;
+    private ContentResolver mContentResolver;
+    private VibrateForCallsPreferenceFragment mFragment;
+
+    @Before
+    public void setUp() {
+        mContext = spy(RuntimeEnvironment.application);
+        mContentResolver = mContext.getContentResolver();
+        mFragment = spy(new VibrateForCallsPreferenceFragment());
+        doReturn(mContext).when(mFragment).getContext();
+        mFragment.onAttach(mContext);
+    }
+
+    @Test
+    public void getDefaultKey_applyRampingRinger_keyRampingRinger() {
+        Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+        Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
+
+        assertThat(mFragment.getDefaultKey()).isEqualTo(
+                VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
+    }
+
+    @Test
+    public void getDefaultKey_enableVibrateWhenRinging_keyAlwaysVibrate() {
+        Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
+        Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+        assertThat(mFragment.getDefaultKey()).isEqualTo(
+                VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
+    }
+
+    @Test
+    public void getDefaultKey_notApplyRampingRingerDisableVibrateWhenRinging_keyNeverVibrate() {
+        Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+        Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+        assertThat(mFragment.getDefaultKey()).isEqualTo(
+                VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
+    }
+
+    @Test
+    public void setDefaultKey_keyRampingRinger_applyRampingRingerDisableVibrateWhenRinging() {
+        mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
+
+        assertThat(Settings.Global.getInt(
+            mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON);
+        assertThat(Settings.System.getInt(
+            mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
+    }
+
+    @Test
+    public void setDefaultKey_keyAlwaysVibrate_notApplyRampingRingerEnableVibrateWhenRinging() {
+        mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
+
+        assertThat(Settings.Global.getInt(
+            mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
+        assertThat(Settings.System.getInt(
+            mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(ON);
+    }
+
+    @Test
+    public void setDefaultKey_keyNeverVibrate_notApplyRampingRingerDisableVibrateWhenRinging() {
+        mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
+
+        assertThat(Settings.Global.getInt(
+            mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
+        assertThat(Settings.System.getInt(
+            mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
index ae236bf..955b721 100644
--- a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
@@ -26,6 +26,7 @@
 
 import android.app.settings.SettingsEnums;
 import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
 import android.net.wifi.WifiNetworkSuggestion;
 import android.os.Bundle;
 import android.os.Parcelable;
@@ -59,7 +60,8 @@
     private static final String FAKE_NEW_SAVED_WPA_SSID = "\"fake_new_wpa_ssid\"";
     private static final String KEY_SSID = "key_ssid";
     private static final String KEY_SECURITY = "key_security";
-    private static final int SCANED_LEVEL = 4;
+    private static final int SCANED_LEVEL0 = 0;
+    private static final int SCANED_LEVEL4 = 4;
 
     private AddAppNetworksFragment mAddAppNetworksFragment;
     private List<WifiNetworkSuggestion> mFakedSpecifiedNetworksList;
@@ -76,6 +78,9 @@
     @Mock
     private WifiTracker mMockWifiTracker;
 
+    @Mock
+    private WifiManager mMockWifiManager;
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
@@ -86,10 +91,13 @@
                 WifiConfiguration.KeyMgmt.NONE, null);
         mSavedWpaConfigurationEntry = generateRegularWifiConfiguration(FAKE_NEW_SAVED_WPA_SSID,
                 WifiConfiguration.KeyMgmt.WPA_PSK, "\"1234567890\"");
+        when(mMockWifiTracker.getManager()).thenReturn(mMockWifiManager);
+        when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
+
         mAddAppNetworksFragment.mWifiTracker = mMockWifiTracker;
         WifiTrackerFactory.setTestingWifiTracker(mMockWifiTracker);
 
-        setUpOneScannedNetworkWithScanedLevel();
+        setUpOneScannedNetworkWithScanedLevel4();
     }
 
     @Test
@@ -208,6 +216,7 @@
     @Test
     public void withOneSuggestion_whenScanResultChanged_uiListShouldHaveNewLevel() {
         // Arrange
+        when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(true);
         // Setup a fake saved network list and assign to fragment.
         addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
         // Setup one specified networks and its results and assign to fragment.
@@ -221,16 +230,36 @@
 
         // Assert
         assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
-                SCANED_LEVEL);
+                SCANED_LEVEL4);
     }
 
-    private void setUpOneScannedNetworkWithScanedLevel() {
+    @Test
+    public void withOneSuggestion_whenScanResultChangedButWifiOff_uiListShouldHaveZeroLevel() {
+        // Arrange
+        when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(false);
+        // Setup a fake saved network list and assign to fragment.
+        addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
+        // Setup one specified networks and its results and assign to fragment.
+        addOneSpecifiedRegularNetworkSuggestion(mNewOpenSuggestionEntry);
+        mAddAppNetworksFragment.mAllSpecifiedNetworksList = mFakedSpecifiedNetworksList;
+        // Call filterSavedNetworks to generate necessary objects.
+        mAddAppNetworksFragment.filterSavedNetworks(mFakeSavedNetworksList);
+
+        // Act
+        mAddAppNetworksFragment.onAccessPointsChanged();
+
+        // Assert
+        assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
+                SCANED_LEVEL0);
+    }
+
+    private void setUpOneScannedNetworkWithScanedLevel4() {
         final ArrayList list = new ArrayList<>();
         list.add(mMockAccessPoint);
         when(mMockWifiTracker.getAccessPoints()).thenReturn(list);
         when(mMockAccessPoint.getSsidStr()).thenReturn(FAKE_NEW_OPEN_SSID);
         when(mMockAccessPoint.matches(any(WifiConfiguration.class))).thenReturn(true);
-        when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL);
+        when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL4);
     }
 
     private void addOneSavedNetworkConfiguration(@NonNull WifiConfiguration wifiConfiguration) {
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
index b4ad167..e864ce3 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
@@ -28,14 +28,13 @@
 import com.android.settings.R;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowLooper;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 public class ListWithEntrySummaryPreferenceTest {
 
     private Context mContext;
@@ -55,6 +54,7 @@
     public void setUp() {
         mContext = RuntimeEnvironment.application;
         mContext.setTheme(R.style.Theme_Settings_Home);
+        ShadowLooper.pauseMainLooper();
         mPreference = new ListWithEntrySummaryPreference(mContext, null);
         mPreference.setEntries(mDefaultEntries);
         mPreference.setEntryValues(mDefaultEntryValues);
@@ -62,7 +62,7 @@
     }
 
     @Test
-    public void initialize_defaultEntries_shouldDisplayDefalutEntries() {
+    public void initialize_defaultEntries_shouldDisplayDefaultEntries() {
         AlertDialog dialog = showDialog(mPreference);
         ListAdapter adapter = dialog.getListView().getAdapter();