Merge "Fix the Robolectric Tests Failures"
diff --git a/res/drawable/accessibility_qs_tooltips_background.xml b/res/drawable/accessibility_qs_tooltips_background.xml
index a704b2e..bfce47f 100644
--- a/res/drawable/accessibility_qs_tooltips_background.xml
+++ b/res/drawable/accessibility_qs_tooltips_background.xml
@@ -19,7 +19,7 @@
     <item android:top="8dp">
         <shape
             android:shape="rectangle">
-            <solid android:color="#BCEDDF"/>
+            <solid android:color="@*android:color/accent_primary_device_default"/>
             <corners android:radius="28dp" />
             <padding android:top="8dp" />
         </shape>
@@ -32,7 +32,7 @@
         android:top="-6dp">
         <rotate android:fromDegrees="45">
             <shape android:shape="rectangle">
-            <solid android:color="#BCEDDF"/>
+            <solid android:color="@*android:color/accent_primary_device_default"/>
             </shape>
         </rotate>
     </item>
diff --git a/res/drawable/accessibility_text_reading_preview.xml b/res/drawable/accessibility_text_reading_preview.xml
new file mode 100644
index 0000000..54f3a42
--- /dev/null
+++ b/res/drawable/accessibility_text_reading_preview.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2022 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+    android:shape="rectangle">
+
+    <corners android:radius="28dp" />
+    <solid android:color="?androidprv:attr/colorSurface" />
+</shape>
diff --git a/res/layout/accessibility_text_reading_preview.xml b/res/layout/accessibility_text_reading_preview.xml
new file mode 100644
index 0000000..9caed30
--- /dev/null
+++ b/res/layout/accessibility_text_reading_preview.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2022 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@drawable/accessibility_text_reading_preview"
+        android:clipChildren="true"
+        android:orientation="vertical"
+        android:padding="18dp">
+
+        <TextView
+            android:id="@+id/preview_label"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/screen_zoom_preview_title"
+            style="@style/AccessibilityTextReadingPreviewTitle" />
+
+        <androidx.viewpager.widget.ViewPager
+            android:id="@+id/preview_pager"
+            android:layout_width="match_parent"
+            android:layout_height="217dp"
+            android:contentDescription="@string/preview_pager_content_description" />
+
+        <com.android.settings.widget.DotsPageIndicator
+            android:id="@+id/page_indicator"
+            style="@style/PreviewPagerPageIndicator"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:padding="6dp"
+            android:visibility="gone" />
+    </LinearLayout>
+</FrameLayout>
diff --git a/res/layout/udfps_enroll_enrolling.xml b/res/layout/udfps_enroll_enrolling.xml
index 67c127b..e933753 100644
--- a/res/layout/udfps_enroll_enrolling.xml
+++ b/res/layout/udfps_enroll_enrolling.xml
@@ -17,6 +17,7 @@
 
 <com.google.android.setupdesign.GlifLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -30,15 +31,45 @@
         android:clipChildren="false"
         android:orientation="vertical">
 
-        <TextView
-            android:id="@+id/error_text"
-            style="@style/TextAppearance.ErrorText"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_horizontal|bottom"
-            android:accessibilityLiveRegion="polite"
-            android:gravity="center_horizontal"
-            android:visibility="invisible" />
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1"
+            android:gravity="center|bottom"
+            android:orientation="vertical">
+
+          <FrameLayout
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:clipChildren="false"
+              android:clipToPadding="false"
+              android:layout_gravity="center_horizontal|bottom">
+
+              <!-- Animation res MUST be set in code -->
+              <com.airbnb.lottie.LottieAnimationView
+                  android:id="@+id/illustration_lottie"
+                  android:layout_width="match_parent"
+                  android:layout_height="200dp"
+                  android:layout_marginTop="@dimen/udfps_lottie_translate_y"
+                  android:scaleType="centerInside"
+                  android:visibility="gone"
+                  app:lottie_autoPlay="true"
+                  app:lottie_loop="true"
+                  android:clipChildren="false"
+                  android:clipToPadding="false"
+                  app:lottie_speed=".85" />
+          </FrameLayout>
+
+          <TextView
+              android:id="@+id/error_text"
+              style="@style/TextAppearance.ErrorText"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:layout_gravity="center_horizontal|bottom"
+              android:accessibilityLiveRegion="polite"
+              android:gravity="center_horizontal"
+              android:visibility="invisible" />
+      </LinearLayout>
     </LinearLayout>
 
 </com.google.android.setupdesign.GlifLayout>
diff --git a/res/raw/udfps_edge_hint_lottie.json b/res/raw/udfps_edge_hint_lottie.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/udfps_edge_hint_lottie.json
diff --git a/res/raw/udfps_tip_hint_lottie.json b/res/raw/udfps_tip_hint_lottie.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/udfps_tip_hint_lottie.json
diff --git a/res/values/config.xml b/res/values/config.xml
index fe9f42d..7a2f641 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -197,11 +197,24 @@
     <!-- Whether or not to show the night light suggestion. -->
     <bool name="config_night_light_suggestion_enabled">true</bool>
 
-    <!-- Whether or not the device is capable of multiple levels of vibration intensity.
-         Note that this is different from whether it can control the vibration amplitude as some
-         devices will be able to vary their amplitude but do not possess enough dynamic range to
-         have distinct intensity levels -->
-    <bool name="config_vibration_supports_multiple_intensities">false</bool>
+    <!-- The number of vibration intensity levels supported by the device.
+
+         Note that this should correspond to the ability to vary the vibration amplitude, with
+         enough dynamic range to have at least as many distinct intensity levels as defined here.
+
+         Supported values are 1, 2, 3. If '1', the settings app will use a toggle for the settings,
+         otherwise a slider. If '3', the settings app maps intensities directly to the levels
+         supported by the Vibrator HAL APIs. If '2', then the levels will be mapped to
+         VIBRATION_INTENSITY_LOW and VIBRATION_INTENSITY_HIGH, which gives the most range for
+         scaling vibrations. The medium intensity will be skipped.
+
+         The default intensity values are configured at
+         frameworks/base/core/res/res/values/config.xml's config_default[type]VibrationIntensity.
+         Make sure that each default intensity value is consistent with the supported levels set
+         here. If this settings supports only 2 levels, for example, then the default intensity
+         should be either LOW (1) or HIGH (3).
+    -->
+    <integer name="config_vibration_supported_intensity_levels">1</integer>
 
     <!--
         Whether or not the homepage should be powered by legacy suggestion (versus contextual cards)
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 00372cb..0a31c61 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -212,6 +212,7 @@
          fingerprint_finish_max_size = fingerprint_progress_bar_max_size
                   + (fingerprint_enrolling_content_margin_vertical x 2) -->
     <dimen name="fingerprint_finish_max_size">288dp</dimen>
+    <dimen name="udfps_lottie_translate_y">0dp</dimen>
 
     <!-- Face -->
     <item name="face_preview_translate_y" format="float" type="dimen">0</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1eaa222..5fec077 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1113,6 +1113,10 @@
     <string name="security_settings_fingerprint_enroll_finish_message">Now you can use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps</string>
     <!-- Button text to skip enrollment of fingerprint [CHAR LIMIT=40] -->
     <string name="security_settings_fingerprint_enroll_enrolling_skip">Do it later</string>
+    <!-- Accessibility message for fingerprint enrollment asking the user to place the tip of their finger on the fingerprint sensor [CHAR LIMIT=NONE] -->
+    <string name="security_settings_udfps_tip_fingerprint_help">Lift, then touch again</string>
+    <!-- Accessibility message for fingerprint enrollment asking the user to place the sides of their finger on the fingerprint sensor [CHAR LIMIT=NONE] -->
+    <string name="security_settings_udfps_side_fingerprint_help">Place the side of your fingerprint on the sensor and hold, then switch to the other side</string>
     <!-- Title of the dialog shown when the user tries to skip fingerprint setup, asking them to confirm the action [CHAR LIMIT=40] -->
     <string name="setup_fingerprint_enroll_enrolling_skip_title">Skip fingerprint setup?</string>
     <!-- Content of the dialog shown when the user tries to skip fingerprint setup, asking them to confirm the action [CHAR LIMIT=NONE] -->
@@ -5461,6 +5465,10 @@
     <string name="accessibility_notification_alarm_vibration_category_title">Notifications and alarms</string>
     <!-- Title for the category of preferences to configure device vibrations triggered by user interaction with the device. [CHAR LIMIT=NONE] -->
     <string name="accessibility_interactive_haptics_category_title">Interactive haptics</string>
+    <!-- Title for preference for configuring alarm vibrations. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_alarm_vibration_title">Alarm vibration</string>
+    <!-- Title for preference for configuring media vibrations (e.g. vibrations played together with animations, music, videos, etc). [CHAR LIMIT=NONE] -->
+    <string name="accessibility_media_vibration_title">Media vibration</string>
     <!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
     <string name="accessibility_ring_vibration_title">Ring vibration</string>
     <!-- Title for accessibility preference for configuring notification vibrations. -->
@@ -8254,7 +8262,11 @@
     <!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
     <string name="keywords_ramping_ringer_vibration">haptics, vibrate, phone, call, ring, gradually</string>
     <!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
-    <string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
+    <string name="keywords_notification_vibration">haptics, vibrate, sensitivity, notification</string>
+    <!-- List of synonyms for alarm vibration setting (changes whether your phone vibrates when an alarm goes off), used to match in settings search [CHAR LIMIT=NONE] -->
+    <string name="keywords_alarm_vibration">haptics, vibrate, sensitivity, alarm</string>
+    <!-- List of synonyms for media vibration setting (changes whether your phone vibrates as part of a music, animation, video, etc), used to match in settings search [CHAR LIMIT=NONE] -->
+    <string name="keywords_media_vibration">haptics, vibrate, sensitivity, media</string>
     <!-- List of synonyms for vibration and haptics setting, used to match in settings search [CHAR LIMIT=NONE] -->
     <string name="keywords_vibration">haptics, vibrate, vibration</string>
     <!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 838d63b..7e70144 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -730,6 +730,12 @@
         <item name="android:background">?android:attr/selectableItemBackground</item>
     </style>
 
+    <style name="AccessibilityTextReadingPreviewTitle"
+        parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title" >
+        <item name="android:layout_gravity">center_horizontal</item>
+        <item name="android:padding">6dp</item>
+    </style>
+
     <style name="Widget.PopupWindow.Settings"
            parent="@android:style/Widget.DeviceDefault.PopupWindow">
         <item name="android:clipToPadding">true</item>
diff --git a/res/xml/accessibility_vibration_intensity_settings.xml b/res/xml/accessibility_vibration_intensity_settings.xml
index d9a97f0..7982268 100644
--- a/res/xml/accessibility_vibration_intensity_settings.xml
+++ b/res/xml/accessibility_vibration_intensity_settings.xml
@@ -47,6 +47,12 @@
             app:keywords="@string/keywords_notification_vibration"
             app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
 
+        <com.android.settings.widget.SeekBarPreference
+            android:key="alarm_vibration_preference_screen"
+            android:title="@string/accessibility_alarm_vibration_title"
+            app:keywords="@string/keywords_alarm_vibration"
+            app:controller="com.android.settings.accessibility.AlarmVibrationIntensityPreferenceController" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
@@ -59,6 +65,12 @@
             app:keywords="@string/keywords_touch_vibration"
             app:controller="com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController" />
 
+        <com.android.settings.widget.SeekBarPreference
+            android:key="media_vibration_preference_screen"
+            android:title="@string/accessibility_media_vibration_title"
+            app:keywords="@string/keywords_media_vibration"
+            app:controller="com.android.settings.accessibility.MediaVibrationIntensityPreferenceController" />
+
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/accessibility_vibration_settings.xml b/res/xml/accessibility_vibration_settings.xml
index 18cd718..af78433 100644
--- a/res/xml/accessibility_vibration_settings.xml
+++ b/res/xml/accessibility_vibration_settings.xml
@@ -47,6 +47,12 @@
             app:keywords="@string/keywords_notification_vibration"
             app:controller="com.android.settings.accessibility.NotificationVibrationTogglePreferenceController" />
 
+        <SwitchPreference
+            android:key="alarm_vibration_preference_screen"
+            android:title="@string/accessibility_alarm_vibration_title"
+            app:keywords="@string/keywords_alarm_vibration"
+            app:controller="com.android.settings.accessibility.AlarmVibrationTogglePreferenceController" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
@@ -59,6 +65,12 @@
             app:keywords="@string/keywords_touch_vibration"
             app:controller="com.android.settings.accessibility.HapticFeedbackTogglePreferenceController" />
 
+        <SwitchPreference
+            android:key="media_vibration_preference_screen"
+            android:title="@string/accessibility_media_vibration_title"
+            app:keywords="@string/keywords_media_vibration"
+            app:controller="com.android.settings.accessibility.MediaVibrationTogglePreferenceController" />
+
     </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceController.java
new file mode 100644
index 0000000..9e60f21
--- /dev/null
+++ b/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceController.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+import android.os.VibrationAttributes;
+import android.provider.Settings;
+
+/** Preference controller for alarm vibration intensity */
+public class AlarmVibrationIntensityPreferenceController
+        extends VibrationIntensityPreferenceController {
+
+    /** General configuration for alarm vibration intensity settings. */
+    public static final class AlarmVibrationPreferenceConfig extends VibrationPreferenceConfig {
+
+        public AlarmVibrationPreferenceConfig(Context context) {
+            super(context, Settings.System.ALARM_VIBRATION_INTENSITY,
+                    VibrationAttributes.USAGE_ALARM);
+        }
+    }
+
+    public AlarmVibrationIntensityPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey, new AlarmVibrationPreferenceConfig(context));
+    }
+
+    protected AlarmVibrationIntensityPreferenceController(Context context, String preferenceKey,
+            int supportedIntensityLevels) {
+        super(context, preferenceKey, new AlarmVibrationPreferenceConfig(context),
+                supportedIntensityLevels);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceController.java b/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceController.java
new file mode 100644
index 0000000..63281dd
--- /dev/null
+++ b/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceController.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+
+import com.android.settings.accessibility.AlarmVibrationIntensityPreferenceController.AlarmVibrationPreferenceConfig;
+
+/** Preference controller for alarm vibration with only a toggle for on/off states. */
+public class AlarmVibrationTogglePreferenceController extends VibrationTogglePreferenceController {
+
+    public AlarmVibrationTogglePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey, new AlarmVibrationPreferenceConfig(context));
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
index 99d2bf5..98fd5f2 100644
--- a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
@@ -74,6 +74,12 @@
         super(context, preferenceKey, new HapticFeedbackVibrationPreferenceConfig(context));
     }
 
+    protected HapticFeedbackIntensityPreferenceController(Context context, String preferenceKey,
+            int supportedIntensityLevels) {
+        super(context, preferenceKey, new HapticFeedbackVibrationPreferenceConfig(context),
+                supportedIntensityLevels);
+    }
+
     @Override
     public int getAvailabilityStatus() {
         return AVAILABLE;
diff --git a/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceController.java
new file mode 100644
index 0000000..0678e58
--- /dev/null
+++ b/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceController.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+import android.os.VibrationAttributes;
+import android.provider.Settings;
+
+/** Preference controller for am vibration intensity */
+public class MediaVibrationIntensityPreferenceController
+        extends VibrationIntensityPreferenceController {
+
+    /** General configuration for alarm vibration intensity settings. */
+    public static final class MediaVibrationPreferenceConfig extends VibrationPreferenceConfig {
+
+        public MediaVibrationPreferenceConfig(Context context) {
+            super(context, Settings.System.MEDIA_VIBRATION_INTENSITY,
+                    VibrationAttributes.USAGE_MEDIA);
+        }
+    }
+
+    public MediaVibrationIntensityPreferenceController(Context context,
+            String preferenceKey) {
+        super(context, preferenceKey, new MediaVibrationPreferenceConfig(context));
+    }
+
+    protected MediaVibrationIntensityPreferenceController(Context context, String preferenceKey,
+            int supportedIntensityLevels) {
+        super(context, preferenceKey, new MediaVibrationPreferenceConfig(context),
+                supportedIntensityLevels);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceController.java b/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceController.java
new file mode 100644
index 0000000..f7b0e39
--- /dev/null
+++ b/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceController.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+
+import com.android.settings.accessibility.MediaVibrationIntensityPreferenceController.MediaVibrationPreferenceConfig;
+
+/** Preference controller for alarm vibration with only a toggle for on/off states. */
+public class MediaVibrationTogglePreferenceController extends VibrationTogglePreferenceController {
+
+    public MediaVibrationTogglePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey, new MediaVibrationPreferenceConfig(context));
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
index 31ae187..cee45f6 100644
--- a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
@@ -39,6 +39,12 @@
         super(context, preferenceKey, new NotificationVibrationPreferenceConfig(context));
     }
 
+    protected NotificationVibrationIntensityPreferenceController(Context context,
+            String preferenceKey, int supportedIntensityLevels) {
+        super(context, preferenceKey, new NotificationVibrationPreferenceConfig(context),
+                supportedIntensityLevels);
+    }
+
     @Override
     public int getAvailabilityStatus() {
         return AVAILABLE;
diff --git a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
index 1ddcf2b..894d818 100644
--- a/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceController.java
@@ -71,6 +71,12 @@
         super(context, preferenceKey, new RingVibrationPreferenceConfig(context));
     }
 
+    protected RingVibrationIntensityPreferenceController(Context context, String preferenceKey,
+            int supportedIntensityLevels) {
+        super(context, preferenceKey, new RingVibrationPreferenceConfig(context),
+                supportedIntensityLevels);
+    }
+
     @Override
     public int getAvailabilityStatus() {
         return AVAILABLE;
diff --git a/src/com/android/settings/accessibility/TextReadingPreviewPreference.java b/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
new file mode 100644
index 0000000..1b9cc4b
--- /dev/null
+++ b/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+import androidx.viewpager.widget.ViewPager;
+
+import com.android.internal.util.Preconditions;
+import com.android.settings.R;
+import com.android.settings.display.PreviewPagerAdapter;
+import com.android.settings.widget.DotsPageIndicator;
+
+/**
+ * A {@link Preference} that could show the preview related to the text and reading options.
+ */
+final class TextReadingPreviewPreference extends Preference {
+    private int mCurrentItem;
+    private PreviewPagerAdapter mPreviewAdapter;
+
+    TextReadingPreviewPreference(Context context) {
+        super(context);
+        init();
+    }
+
+    TextReadingPreviewPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        init();
+    }
+
+    TextReadingPreviewPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        init();
+    }
+
+    TextReadingPreviewPreference(Context context, AttributeSet attrs, int defStyleAttr,
+            int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+        init();
+    }
+
+    @Override
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
+
+        final ViewPager viewPager = (ViewPager) holder.findViewById(R.id.preview_pager);
+        final DotsPageIndicator pageIndicator =
+                (DotsPageIndicator) holder.findViewById(R.id.page_indicator);
+        updateAdapterIfNeeded(viewPager, pageIndicator, mPreviewAdapter);
+        updatePagerAndIndicator(viewPager, pageIndicator);
+    }
+
+    void setPreviewAdapter(PreviewPagerAdapter previewAdapter) {
+        if (previewAdapter != mPreviewAdapter) {
+            mPreviewAdapter = previewAdapter;
+            notifyChanged();
+        }
+    }
+
+    void setCurrentItem(int currentItem) {
+        Preconditions.checkNotNull(mPreviewAdapter,
+                "Preview adapter is null, you should init the preview adapter first");
+
+        if (currentItem != mCurrentItem) {
+            mCurrentItem = currentItem;
+            notifyChanged();
+        }
+    }
+
+    int getCurrentItem() {
+        return mCurrentItem;
+    }
+
+    private void updateAdapterIfNeeded(ViewPager viewPager, DotsPageIndicator pageIndicator,
+            PreviewPagerAdapter previewAdapter) {
+        if (viewPager.getAdapter() == previewAdapter) {
+            return;
+        }
+
+        viewPager.setAdapter(previewAdapter);
+
+        if (previewAdapter != null) {
+            pageIndicator.setViewPager(viewPager);
+        } else {
+            mCurrentItem = 0;
+        }
+    }
+
+    private void updatePagerAndIndicator(ViewPager viewPager, DotsPageIndicator pageIndicator) {
+        if (viewPager.getAdapter() == null) {
+            return;
+        }
+
+        if (viewPager.getCurrentItem() != mCurrentItem) {
+            viewPager.setCurrentItem(mCurrentItem);
+        }
+
+        pageIndicator.setVisibility(
+                viewPager.getAdapter().getCount() > 1 ? View.VISIBLE : View.GONE);
+    }
+
+    private void init() {
+        setLayoutResource(R.layout.accessibility_text_reading_preview);
+    }
+}
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index e35b42c..ef15f06 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -21,6 +21,7 @@
 
 import androidx.preference.PreferenceScreen;
 
+import com.android.settings.R;
 import com.android.settings.core.SliderPreferenceController;
 import com.android.settings.widget.SeekBarPreference;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -36,13 +37,22 @@
 
     protected final VibrationPreferenceConfig mPreferenceConfig;
     private final VibrationPreferenceConfig.SettingObserver mSettingsContentObserver;
+    private final int mMaxIntensity;
 
     protected VibrationIntensityPreferenceController(Context context, String prefkey,
             VibrationPreferenceConfig preferenceConfig) {
+        this(context, prefkey, preferenceConfig,
+                context.getResources().getInteger(
+                        R.integer.config_vibration_supported_intensity_levels));
+    }
+
+    protected VibrationIntensityPreferenceController(Context context, String prefkey,
+            VibrationPreferenceConfig preferenceConfig, int supportedIntensityLevels) {
         super(context, prefkey);
         mPreferenceConfig = preferenceConfig;
         mSettingsContentObserver = new VibrationPreferenceConfig.SettingObserver(
                 preferenceConfig);
+        mMaxIntensity = Math.min(Vibrator.VIBRATION_INTENSITY_HIGH, supportedIntensityLevels);
     }
 
     @Override
@@ -74,7 +84,7 @@
 
     @Override
     public int getMax() {
-        return Vibrator.VIBRATION_INTENSITY_HIGH;
+        return mMaxIntensity;
     }
 
     @Override
@@ -85,7 +95,8 @@
 
     @Override
     public boolean setSliderPosition(int position) {
-        final boolean success = mPreferenceConfig.updateIntensity(position);
+        final int intensity = calculateVibrationIntensity(position);
+        final boolean success = mPreferenceConfig.updateIntensity(intensity);
 
         if (success && (position != Vibrator.VIBRATION_INTENSITY_OFF)) {
             mPreferenceConfig.playVibrationPreview();
@@ -93,4 +104,19 @@
 
         return success;
     }
+
+    private int calculateVibrationIntensity(int position) {
+        int maxPosition = getMax();
+        if (position >= maxPosition) {
+            if (maxPosition == 1) {
+                // If there is only one intensity available besides OFF, then use the device default
+                // intensity to ensure no scaling will ever happen in the platform.
+                return mPreferenceConfig.getDefaultIntensity();
+            }
+            // If the settings granularity is lower than the platform's then map the max position to
+            // the highest vibration intensity, skipping intermediate values in the scale.
+            return Vibrator.VIBRATION_INTENSITY_HIGH;
+        }
+        return position;
+    }
 }
diff --git a/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java b/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
index 4a86538..21a5e36 100644
--- a/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
@@ -21,7 +21,6 @@
 import android.media.AudioManager;
 import android.net.Uri;
 import android.os.Handler;
-import android.os.Looper;
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.provider.DeviceConfig;
@@ -37,8 +36,6 @@
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
 
-import com.google.common.annotations.VisibleForTesting;
-
 /**
  * Preference controller for the ramping ringer setting key, controlled via {@link AudioManager}.
  *
@@ -50,9 +47,15 @@
 public class VibrationRampingRingerTogglePreferenceController
         extends TogglePreferenceController implements LifecycleObserver, OnStart, OnStop {
 
-    @VisibleForTesting
-    static final String DEVICE_CONFIG_KEY = "ramping_ringer_enabled";
+    /** Wrapper around static {@link DeviceConfig} accessor for testing. */
+    protected static class DeviceConfigProvider {
+        public boolean isRampingRingerEnabledOnTelephonyConfig() {
+            return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_TELEPHONY,
+                    "ramping_ringer_enabled", false);
+        }
+    }
 
+    private final DeviceConfigProvider mDeviceConfigProvider;
     private final ContentObserver mSettingObserver;
     private final Vibrator mVibrator;
     private final AudioManager mAudioManager;
@@ -60,10 +63,16 @@
     private Preference mPreference;
 
     public VibrationRampingRingerTogglePreferenceController(Context context, String preferenceKey) {
+        this(context, preferenceKey, new DeviceConfigProvider());
+    }
+
+    protected VibrationRampingRingerTogglePreferenceController(Context context,
+            String preferenceKey, DeviceConfigProvider deviceConfigProvider) {
         super(context, preferenceKey);
+        mDeviceConfigProvider = deviceConfigProvider;
         mVibrator = context.getSystemService(Vibrator.class);
         mAudioManager = context.getSystemService(AudioManager.class);
-        mSettingObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {
+        mSettingObserver = new ContentObserver(new Handler(/* async= */ true)) {
             @Override
             public void onChange(boolean selfChange, Uri uri) {
                 updateState(mPreference);
@@ -74,7 +83,7 @@
     @Override
     public int getAvailabilityStatus() {
         final boolean rampingRingerEnabledOnTelephonyConfig =
-                DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_TELEPHONY, DEVICE_CONFIG_KEY, false);
+                mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig();
         return (Utils.isVoiceCapable(mContext) && !rampingRingerEnabledOnTelephonyConfig)
                 ? AVAILABLE
                 : UNSUPPORTED_ON_DEVICE;
diff --git a/src/com/android/settings/accessibility/VibrationSettings.java b/src/com/android/settings/accessibility/VibrationSettings.java
index 277cfee..1bf75f7 100644
--- a/src/com/android/settings/accessibility/VibrationSettings.java
+++ b/src/com/android/settings/accessibility/VibrationSettings.java
@@ -41,9 +41,9 @@
 
     @Override
     protected int getPreferenceScreenResId() {
-        final boolean supportsMultipleIntensities = getContext().getResources().getBoolean(
-                R.bool.config_vibration_supports_multiple_intensities);
-        return supportsMultipleIntensities
+        final int supportedIntensities = getContext().getResources().getInteger(
+                R.integer.config_vibration_supported_intensity_levels);
+        return supportedIntensities > 1
                 ? R.xml.accessibility_vibration_intensity_settings
                 : R.xml.accessibility_vibration_settings;
     }
diff --git a/src/com/android/settings/biometrics/BiometricUtils.java b/src/com/android/settings/biometrics/BiometricUtils.java
index 5ee7880..febe3c6 100644
--- a/src/com/android/settings/biometrics/BiometricUtils.java
+++ b/src/com/android/settings/biometrics/BiometricUtils.java
@@ -289,4 +289,14 @@
         }
         return false;
     }
+
+    /**
+     * Returns {@code true} if the screen is going into a landscape mode and the angle is equal to
+     * 90.
+     * @param context Context that we use to get the display this context is associated with
+     * @return True if the angle of the rotation is equal to 90.
+     */
+    public static boolean isLandscape(@NonNull Context context) {
+        return context.getDisplay().getRotation() == Surface.ROTATION_90;
+    }
 }
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index c2bcee3..d42e8f1 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -19,11 +19,13 @@
 import android.animation.Animator;
 import android.animation.ObjectAnimator;
 import android.annotation.IntDef;
+import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.app.Dialog;
 import android.app.settings.SettingsEnums;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.res.Configuration;
 import android.graphics.drawable.Animatable2;
 import android.graphics.drawable.AnimatedVectorDrawable;
 import android.graphics.drawable.Drawable;
@@ -54,7 +56,9 @@
 import com.android.settings.biometrics.BiometricUtils;
 import com.android.settings.biometrics.BiometricsEnrollEnrolling;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settingslib.display.DisplayDensityUtils;
 
+import com.airbnb.lottie.LottieAnimationView;
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
 import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -126,6 +130,10 @@
     private boolean mIsSetupWizard;
     private AccessibilityManager mAccessibilityManager;
     private boolean mIsAccessibilityEnabled;
+    private LottieAnimationView mIllustrationLottie;
+    private boolean mHaveShownUdfpsTipLottie;
+    private boolean mHaveShownUdfpsSideLottie;
+    private boolean mShouldShowLottie;
 
     private OrientationEventListener mOrientationEventListener;
     private int mPreviousRotation = 0;
@@ -163,6 +171,20 @@
             setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title);
         }
 
+        DisplayDensityUtils displayDensity =
+                new DisplayDensityUtils(getApplicationContext());
+        int currentDensityIndex = displayDensity.getCurrentIndex();
+        final int currentDensity = displayDensity.getValues()[currentDensityIndex];
+        final int defaultDensity = displayDensity.getDefaultDensity();
+        mShouldShowLottie = defaultDensity == currentDensity;
+        // Only show the lottie if the current display density is the default density.
+        // Otherwise, the lottie will overlap with the settings header text.
+        boolean isLandscape = BiometricUtils.isReverseLandscape(getApplicationContext())
+                || BiometricUtils.isLandscape(getApplicationContext());
+
+        updateOrientation((isLandscape
+                ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT));
+
         mErrorText = findViewById(R.id.error_text);
         mProgressBar = findViewById(R.id.fingerprint_progress_bar);
         mVibrator = getSystemService(Vibrator.class);
@@ -339,20 +361,34 @@
 
             case STAGE_FINGERTIP:
                 setHeaderText(R.string.security_settings_udfps_enroll_fingertip_title);
-                if (isStageHalfCompleted()) {
-                    setDescriptionText(R.string.security_settings_fingerprint_enroll_repeat_title);
-                } else {
+                if (!mHaveShownUdfpsTipLottie && mIllustrationLottie != null) {
+                    mHaveShownUdfpsTipLottie = true;
                     setDescriptionText("");
+                    mIllustrationLottie.setAnimation(R.raw.udfps_tip_hint_lottie);
+                    mIllustrationLottie.setVisibility(View.VISIBLE);
+                    mIllustrationLottie.playAnimation();
+                    mIllustrationLottie.setContentDescription(
+                            getString(R.string.security_settings_udfps_tip_fingerprint_help));
                 }
                 break;
 
             case STAGE_EDGES:
                 setHeaderText(R.string.security_settings_udfps_enroll_edge_title);
-                if (isStageHalfCompleted()) {
-                    setDescriptionText(
-                            R.string.security_settings_fingerprint_enroll_repeat_message);
-                } else {
-                    setDescriptionText(R.string.security_settings_udfps_enroll_edge_message);
+                if (!mHaveShownUdfpsSideLottie && mIllustrationLottie != null) {
+                    mHaveShownUdfpsSideLottie = true;
+                    setDescriptionText("");
+                    mIllustrationLottie.setAnimation(R.raw.udfps_edge_hint_lottie);
+                    mIllustrationLottie.setVisibility(View.VISIBLE);
+                    mIllustrationLottie.playAnimation();
+                    mIllustrationLottie.setContentDescription(
+                            getString(R.string.security_settings_udfps_side_fingerprint_help));
+                } else if (mIllustrationLottie == null) {
+                    if (isStageHalfCompleted()) {
+                        setDescriptionText(
+                                R.string.security_settings_fingerprint_enroll_repeat_message);
+                    } else {
+                        setDescriptionText(R.string.security_settings_udfps_enroll_edge_message);
+                    }
                 }
                 break;
 
@@ -634,6 +670,41 @@
         return SettingsEnums.FINGERPRINT_ENROLLING;
     }
 
+    private void updateOrientation(int orientation) {
+        switch(orientation) {
+            case Configuration.ORIENTATION_LANDSCAPE: {
+                mIllustrationLottie = null;
+                break;
+            }
+            case Configuration.ORIENTATION_PORTRAIT: {
+                if (mShouldShowLottie) {
+                    mIllustrationLottie = findViewById(R.id.illustration_lottie);
+                }
+                break;
+            }
+            default:
+                Log.e(TAG, "Error unhandled configuration change");
+                break;
+        }
+    }
+
+    @Override
+    public void onConfigurationChanged(@NonNull Configuration newConfig) {
+        switch(newConfig.orientation) {
+            case Configuration.ORIENTATION_LANDSCAPE: {
+                updateOrientation(Configuration.ORIENTATION_LANDSCAPE);
+                break;
+            }
+            case Configuration.ORIENTATION_PORTRAIT: {
+                updateOrientation(Configuration.ORIENTATION_PORTRAIT);
+                break;
+            }
+            default:
+                Log.e(TAG, "Error unhandled configuration change");
+                break;
+        }
+    }
+
     public static class IconTouchDialog extends InstrumentedDialogFragment {
 
         @Override
diff --git a/src/com/android/settings/network/VpnPreferenceController.java b/src/com/android/settings/network/VpnPreferenceController.java
index a1e72b0..be07809 100644
--- a/src/com/android/settings/network/VpnPreferenceController.java
+++ b/src/com/android/settings/network/VpnPreferenceController.java
@@ -30,7 +30,6 @@
 import android.security.Credentials;
 import android.security.LegacyVpnProfileStore;
 import android.util.Log;
-import android.util.SparseArray;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
@@ -140,6 +139,7 @@
             }
             VpnConfig vpn = vpnManager.getVpnConfig(uid);
             if ((vpn != null) && vpn.legacy) {
+                // Copied from SystemUI::SecurityControllerImpl
                 // Legacy VPNs should do nothing if the network is disconnected. Third-party
                 // VPN warnings need to continue as traffic can still go to the app.
                 final LegacyVpnInfo legacyVpn = vpnManager.getLegacyVpnInfo(uid);
@@ -158,34 +158,19 @@
     }
 
     protected int getNumberOfNonLegacyVpn(UserManager userManager, VpnManager vpnManager) {
-        // Copied from SystemUI::SecurityControllerImpl
-        SparseArray<VpnConfig> vpns = new SparseArray<>();
-        final List<UserInfo> users = userManager.getUsers();
-        int connectedLegacyVpnCount = 0;
-        for (UserInfo user : users) {
-            VpnConfig cfg = vpnManager.getVpnConfig(user.id);
-            if (cfg == null) {
-                continue;
-            } else if (cfg.legacy) {
-                // Legacy VPNs should do nothing if the network is disconnected. Third-party
-                // VPN warnings need to continue as traffic can still go to the app.
-                final LegacyVpnInfo legacyVpn = vpnManager.getLegacyVpnInfo(user.id);
-                if (legacyVpn == null || legacyVpn.state != LegacyVpnInfo.STATE_CONNECTED) {
-                    continue;
-                } else {
-                    connectedLegacyVpnCount++;
-                }
-            }
-            vpns.put(user.id, cfg);
-        }
-        return vpns.size() - connectedLegacyVpnCount;
+        // Converted from SystemUI::SecurityControllerImpl
+        return (int) userManager.getUsers().stream()
+                .map(user -> vpnManager.getVpnConfig(user.id))
+                .filter(cfg -> (cfg != null) && (!cfg.legacy))
+                .count();
     }
 
     protected String getInsecureVpnSummaryOverride(UserManager userManager,
             VpnManager vpnManager) {
         // Optionally add warning icon if an insecure VPN is present.
         if (mPreference instanceof VpnInfoPreference) {
-            final int insecureVpnCount = getInsecureVpnCount();
+            String [] legacyVpnProfileKeys = LegacyVpnProfileStore.list(Credentials.VPN);
+            final int insecureVpnCount = getInsecureVpnCount(legacyVpnProfileKeys);
             boolean isInsecureVPN = insecureVpnCount > 0;
             ((VpnInfoPreference) mPreference).setInsecureVpn(isInsecureVPN);
 
@@ -193,11 +178,14 @@
             if (isInsecureVPN) {
                 // Add the users and the number of legacy vpns to determine if there is more than
                 // one vpn, since there can be more than one VPN per user.
-                final int vpnCount = getNumberOfNonLegacyVpn(userManager, vpnManager)
-                        + LegacyVpnProfileStore.list(Credentials.VPN).length;
-                if (vpnCount == 1) {
-                    return mContext.getString(R.string.vpn_settings_insecure_single);
-                } else if (insecureVpnCount == 1) {
+                int vpnCount = legacyVpnProfileKeys.length;
+                if (vpnCount <= 1) {
+                    vpnCount += getNumberOfNonLegacyVpn(userManager, vpnManager);
+                    if (vpnCount == 1) {
+                        return mContext.getString(R.string.vpn_settings_insecure_single);
+                    }
+                }
+                if (insecureVpnCount == 1) {
                     return mContext.getString(
                             R.string.vpn_settings_single_insecure_multiple_total,
                             insecureVpnCount);
@@ -229,10 +217,10 @@
     }
 
     @VisibleForTesting
-    protected int getInsecureVpnCount() {
+    protected int getInsecureVpnCount(String [] legacyVpnProfileKeys) {
         final Function<String, VpnProfile> keyToProfile = key ->
                 VpnProfile.decode(key, LegacyVpnProfileStore.get(Credentials.VPN + key));
-        return (int) Arrays.stream(LegacyVpnProfileStore.list(Credentials.VPN))
+        return (int) Arrays.stream(legacyVpnProfileKeys)
                 .map(keyToProfile)
                 // Return whether any profile is an insecure type.
                 .filter(profile -> VpnProfile.isLegacyType(profile.type))
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 255b85f..dc4bca3 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -814,8 +814,8 @@
         }
         try {
             getContext().getSystemService(UserManager.class)
-                    .removeUserOrSetEphemeral(UserHandle.myUserId(),
-                            /* evenWhenDisallowed= */ false);
+                    .removeUserWhenPossible(UserHandle.of(UserHandle.myUserId()),
+                            /* overrideDevicePolicy= */ false);
             ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM);
         } catch (RemoteException re) {
             Log.e(TAG, "Unable to remove self user");
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
index 67f5944..94bd78a 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
@@ -37,6 +37,7 @@
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
 import com.android.settingslib.wifi.WifiEnterpriseRestrictionUtils;
+import com.android.settingslib.wifi.WifiUtils;
 
 import java.util.List;
 
@@ -136,9 +137,9 @@
                         if (mPreference != null
                                 && mSoftApState == WifiManager.WIFI_AP_STATE_ENABLED) {
                             // Only show the number of clients when state is on
-                            mPreference.setSummary(mContext.getResources().getQuantityString(
-                                    R.plurals.wifi_tether_connected_summary, clients.size(),
-                                    clients.size()));
+                            mPreference.setSummary(
+                                    WifiUtils.getWifiTetherSummaryForConnectedDevices(mContext,
+                                            clients.size()));
                         }
                     }
                 });
diff --git a/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceControllerTest.java
new file mode 100644
index 0000000..22e2b8a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationIntensityPreferenceControllerTest.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.VibrationAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+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;
+
+@RunWith(RobolectricTestRunner.class)
+public class AlarmVibrationIntensityPreferenceControllerTest {
+
+    private static final String PREFERENCE_KEY = "preference_key";
+
+    @Mock private PreferenceScreen mScreen;
+
+    private Lifecycle mLifecycle;
+    private Context mContext;
+    private Vibrator mVibrator;
+    private AlarmVibrationIntensityPreferenceController mController;
+    private SeekBarPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
+        mVibrator = mContext.getSystemService(Vibrator.class);
+        mController = new AlarmVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY,
+                Vibrator.VIBRATION_INTENSITY_HIGH);
+        mLifecycle.addObserver(mController);
+        mPreference = new SeekBarPreference(mContext);
+        mPreference.setSummary("Test summary");
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+        mController.displayPreference(mScreen);
+    }
+
+    @Test
+    public void verifyConstants() {
+        assertThat(mController.getPreferenceKey()).isEqualTo(PREFERENCE_KEY);
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.AVAILABLE);
+        assertThat(mController.getMin()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+        assertThat(mController.getMax()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+    }
+
+    @Test
+    public void missingSetting_shouldReturnDefault() {
+        Settings.System.putString(mContext.getContentResolver(),
+                Settings.System.ALARM_VIBRATION_INTENSITY, /* value= */ null);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.getProgress()).isEqualTo(
+                mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_ALARM));
+    }
+
+    @Test
+    public void updateState_shouldDisplayIntensityInSliderPosition() {
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+
+    @Test
+    public void setProgress_updatesIntensitySetting() throws Exception {
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
+        assertThat(readSetting(Settings.System.ALARM_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(readSetting(Settings.System.ALARM_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        assertThat(readSetting(Settings.System.ALARM_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
+        assertThat(readSetting(Settings.System.ALARM_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+    }
+
+    private void updateSetting(String key, int value) {
+        Settings.System.putInt(mContext.getContentResolver(), key, value);
+    }
+
+    private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
+        return Settings.System.getInt(mContext.getContentResolver(), settingKey);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceControllerTest.java
new file mode 100644
index 0000000..82d65f7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AlarmVibrationTogglePreferenceControllerTest.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.VibrationAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+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;
+
+@RunWith(RobolectricTestRunner.class)
+public class AlarmVibrationTogglePreferenceControllerTest {
+
+    private static final String PREFERENCE_KEY = "preference_key";
+
+    @Mock private PreferenceScreen mScreen;
+
+    private Lifecycle mLifecycle;
+    private Context mContext;
+    private Vibrator mVibrator;
+    private AlarmVibrationTogglePreferenceController mController;
+    private SwitchPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
+        mVibrator = mContext.getSystemService(Vibrator.class);
+        mController = new AlarmVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
+        mLifecycle.addObserver(mController);
+        mPreference = new SwitchPreference(mContext);
+        mPreference.setSummary("Test summary");
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+        mController.displayPreference(mScreen);
+    }
+
+    @Test
+    public void verifyConstants() {
+        assertThat(mController.getPreferenceKey()).isEqualTo(PREFERENCE_KEY);
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void missingSetting_shouldReturnDefault() {
+        Settings.System.putString(mContext.getContentResolver(),
+                Settings.System.ALARM_VIBRATION_INTENSITY, /* value= */ null);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void updateState_shouldDisplayOnOffState() {
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void setChecked_updatesIntensityAndDependentSettings() throws Exception {
+        updateSetting(Settings.System.ALARM_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        mController.setChecked(true);
+        assertThat(readSetting(Settings.System.ALARM_VIBRATION_INTENSITY)).isEqualTo(
+                mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_ALARM));
+
+        mController.setChecked(false);
+        assertThat(readSetting(Settings.System.ALARM_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+    private void updateSetting(String key, int value) {
+        Settings.System.putInt(mContext.getContentResolver(), key, value);
+    }
+
+    private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
+        return Settings.System.getInt(mContext.getContentResolver(), settingKey);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java
index e59b85e..2273a3e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java
@@ -18,7 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -26,7 +25,6 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 
-import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceScreen;
 import androidx.test.core.app.ApplicationProvider;
 
@@ -49,10 +47,8 @@
     private static final int OFF = 0;
     private static final int ON = 1;
 
-    @Mock
-    private PreferenceScreen mScreen;
+    @Mock private PreferenceScreen mScreen;
 
-    private LifecycleOwner mLifecycleOwner;
     private Lifecycle mLifecycle;
     private Context mContext;
     private Vibrator mVibrator;
@@ -62,16 +58,16 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
-        mContext = spy(ApplicationProvider.getApplicationContext());
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
         mVibrator = mContext.getSystemService(Vibrator.class);
-        mController = new HapticFeedbackIntensityPreferenceController(mContext, PREFERENCE_KEY);
+        mController = new HapticFeedbackIntensityPreferenceController(mContext, PREFERENCE_KEY,
+                Vibrator.VIBRATION_INTENSITY_HIGH);
         mLifecycle.addObserver(mController);
         mPreference = new SeekBarPreference(mContext);
         mPreference.setSummary("Test summary");
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        showPreference();
+        mController.displayPreference(mScreen);
     }
 
     @Test
@@ -115,27 +111,27 @@
     @Test
     @Ignore
     public void setProgress_updatesIntensityAndDependentSettings() throws Exception {
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED)).isEqualTo(OFF);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED)).isEqualTo(ON);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED)).isEqualTo(ON);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED)).isEqualTo(ON);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED)).isEqualTo(OFF);
@@ -148,8 +144,4 @@
     private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
         return Settings.System.getInt(mContext.getContentResolver(), settingKey);
     }
-
-    private void showPreference() {
-        mController.displayPreference(mScreen);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java
index 0e0a194..f992b0e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java
@@ -18,7 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -26,7 +25,6 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 
-import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 import androidx.test.core.app.ApplicationProvider;
@@ -49,10 +47,8 @@
     private static final int OFF = 0;
     private static final int ON = 1;
 
-    @Mock
-    private PreferenceScreen mScreen;
+    @Mock private PreferenceScreen mScreen;
 
-    private LifecycleOwner mLifecycleOwner;
     private Lifecycle mLifecycle;
     private Context mContext;
     private Vibrator mVibrator;
@@ -62,16 +58,15 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
-        mContext = spy(ApplicationProvider.getApplicationContext());
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new HapticFeedbackTogglePreferenceController(mContext, PREFERENCE_KEY);
         mLifecycle.addObserver(mController);
         mPreference = new SwitchPreference(mContext);
         mPreference.setSummary("Test summary");
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        showPreference();
+        mController.displayPreference(mScreen);
     }
 
     @Test
@@ -116,12 +111,12 @@
         mController.updateState(mPreference);
         assertThat(mPreference.isChecked()).isFalse();
 
-        mPreference.setChecked(true);
+        mController.setChecked(true);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY))
                 .isEqualTo(mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_TOUCH));
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED)).isEqualTo(ON);
 
-        mPreference.setChecked(false);
+        mController.setChecked(false);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED)).isEqualTo(OFF);
@@ -134,8 +129,4 @@
     private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
         return Settings.System.getInt(mContext.getContentResolver(), settingKey);
     }
-
-    private void showPreference() {
-        mController.displayPreference(mScreen);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java
new file mode 100644
index 0000000..0a9f242
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationIntensityPreferenceControllerTest.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.VibrationAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+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;
+
+/** Test for {@link MediaVibrationIntensityPreferenceController}. */
+@RunWith(RobolectricTestRunner.class)
+public class MediaVibrationIntensityPreferenceControllerTest {
+
+    private static final String PREFERENCE_KEY = "preference_key";
+
+    @Mock private PreferenceScreen mScreen;
+
+    private Lifecycle mLifecycle;
+    private Context mContext;
+    private Vibrator mVibrator;
+    private MediaVibrationIntensityPreferenceController mController;
+    private SeekBarPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
+        mVibrator = mContext.getSystemService(Vibrator.class);
+        mController = new MediaVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY,
+                Vibrator.VIBRATION_INTENSITY_HIGH);
+        mLifecycle.addObserver(mController);
+        mPreference = new SeekBarPreference(mContext);
+        mPreference.setSummary("Test summary");
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+        mController.displayPreference(mScreen);
+    }
+
+    @Test
+    public void verifyConstants() {
+        assertThat(mController.getPreferenceKey()).isEqualTo(PREFERENCE_KEY);
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.AVAILABLE);
+        assertThat(mController.getMin()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+        assertThat(mController.getMax()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+    }
+
+    @Test
+    public void missingSetting_shouldReturnDefault() {
+        Settings.System.putString(mContext.getContentResolver(),
+                Settings.System.MEDIA_VIBRATION_INTENSITY, /* value= */ null);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.getProgress()).isEqualTo(
+                mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_MEDIA));
+    }
+
+    @Test
+    public void updateState_shouldDisplayIntensityInSliderPosition() {
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+
+    @Test
+    public void setProgress_updatesIntensitySetting() throws Exception {
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
+        assertThat(readSetting(Settings.System.MEDIA_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(readSetting(Settings.System.MEDIA_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        assertThat(readSetting(Settings.System.MEDIA_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
+        assertThat(readSetting(Settings.System.MEDIA_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+    }
+
+    private void updateSetting(String key, int value) {
+        Settings.System.putInt(mContext.getContentResolver(), key, value);
+    }
+
+    private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
+        return Settings.System.getInt(mContext.getContentResolver(), settingKey);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java
new file mode 100644
index 0000000..7923cca
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/MediaVibrationTogglePreferenceControllerTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.VibrationAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+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;
+
+/** Test for {@link MediaVibrationIntensityPreferenceController}. */
+@RunWith(RobolectricTestRunner.class)
+public class MediaVibrationTogglePreferenceControllerTest {
+
+    private static final String PREFERENCE_KEY = "preference_key";
+
+    @Mock private PreferenceScreen mScreen;
+
+    private Lifecycle mLifecycle;
+    private Context mContext;
+    private Vibrator mVibrator;
+    private MediaVibrationTogglePreferenceController mController;
+    private SwitchPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
+        mVibrator = mContext.getSystemService(Vibrator.class);
+        mController = new MediaVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
+        mLifecycle.addObserver(mController);
+        mPreference = new SwitchPreference(mContext);
+        mPreference.setSummary("Test summary");
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+        mController.displayPreference(mScreen);
+    }
+
+    @Test
+    public void verifyConstants() {
+        assertThat(mController.getPreferenceKey()).isEqualTo(PREFERENCE_KEY);
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void missingSetting_shouldReturnDefault() {
+        Settings.System.putString(mContext.getContentResolver(),
+                Settings.System.MEDIA_VIBRATION_INTENSITY, /* value= */ null);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void updateState_shouldDisplayOnOffState() {
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void setChecked_updatesIntensityAndDependentSettings() throws Exception {
+        updateSetting(Settings.System.MEDIA_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        mController.setChecked(true);
+        assertThat(readSetting(Settings.System.MEDIA_VIBRATION_INTENSITY)).isEqualTo(
+                mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_MEDIA));
+
+        mController.setChecked(false);
+        assertThat(readSetting(Settings.System.MEDIA_VIBRATION_INTENSITY))
+                .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+    private void updateSetting(String key, int value) {
+        Settings.System.putInt(mContext.getContentResolver(), key, value);
+    }
+
+    private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
+        return Settings.System.getInt(mContext.getContentResolver(), settingKey);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
index 913a3d9..d0be8b5 100644
--- a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
@@ -18,7 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -26,7 +25,6 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 
-import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceScreen;
 import androidx.test.core.app.ApplicationProvider;
 
@@ -47,10 +45,8 @@
 
     private static final String PREFERENCE_KEY = "preference_key";
 
-    @Mock
-    private PreferenceScreen mScreen;
+    @Mock private PreferenceScreen mScreen;
 
-    private LifecycleOwner mLifecycleOwner;
     private Lifecycle mLifecycle;
     private Context mContext;
     private Vibrator mVibrator;
@@ -60,17 +56,16 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
-        mContext = spy(ApplicationProvider.getApplicationContext());
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new NotificationVibrationIntensityPreferenceController(mContext,
-                PREFERENCE_KEY);
+                PREFERENCE_KEY, Vibrator.VIBRATION_INTENSITY_HIGH);
         mLifecycle.addObserver(mController);
         mPreference = new SeekBarPreference(mContext);
         mPreference.setSummary("Test summary");
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        showPreference();
+        mController.displayPreference(mScreen);
     }
 
     @Test
@@ -118,19 +113,19 @@
     @Test
     @Ignore
     public void setProgress_updatesIntensitySetting() throws Exception {
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
         assertThat(readSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
         assertThat(readSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
         assertThat(readSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
     }
@@ -142,8 +137,4 @@
     private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
         return Settings.System.getInt(mContext.getContentResolver(), settingKey);
     }
-
-    private void showPreference() {
-        mController.displayPreference(mScreen);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java
index b83b024..adf9436 100644
--- a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java
@@ -18,7 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -26,7 +25,6 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 
-import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 import androidx.test.core.app.ApplicationProvider;
@@ -47,10 +45,8 @@
 
     private static final String PREFERENCE_KEY = "preference_key";
 
-    @Mock
-    private PreferenceScreen mScreen;
+    @Mock private PreferenceScreen mScreen;
 
-    private LifecycleOwner mLifecycleOwner;
     private Lifecycle mLifecycle;
     private Context mContext;
     private Vibrator mVibrator;
@@ -60,16 +56,15 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
-        mContext = spy(ApplicationProvider.getApplicationContext());
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new NotificationVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
         mLifecycle.addObserver(mController);
         mPreference = new SwitchPreference(mContext);
         mPreference.setSummary("Test summary");
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        showPreference();
+        mController.displayPreference(mScreen);
     }
 
     @Test
@@ -118,11 +113,11 @@
         mController.updateState(mPreference);
         assertThat(mPreference.isChecked()).isFalse();
 
-        mPreference.setChecked(true);
+        mController.setChecked(true);
         assertThat(readSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY)).isEqualTo(
                 mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_NOTIFICATION));
 
-        mPreference.setChecked(false);
+        mController.setChecked(false);
         assertThat(readSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
     }
@@ -134,8 +129,4 @@
     private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
         return Settings.System.getInt(mContext.getContentResolver(), settingKey);
     }
-
-    private void showPreference() {
-        mController.displayPreference(mScreen);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
index b653359..d891926 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
@@ -18,7 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -26,7 +25,6 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 
-import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceScreen;
 import androidx.test.core.app.ApplicationProvider;
 
@@ -50,10 +48,8 @@
     private static final int OFF = 0;
     private static final int ON = 1;
 
-    @Mock
-    private PreferenceScreen mScreen;
+    @Mock private PreferenceScreen mScreen;
 
-    private LifecycleOwner mLifecycleOwner;
     private Lifecycle mLifecycle;
     private Context mContext;
     private Vibrator mVibrator;
@@ -63,16 +59,16 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
-        mContext = spy(ApplicationProvider.getApplicationContext());
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
         mVibrator = mContext.getSystemService(Vibrator.class);
-        mController = new RingVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY);
+        mController = new RingVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY,
+                Vibrator.VIBRATION_INTENSITY_HIGH);
         mLifecycle.addObserver(mController);
         mPreference = new SeekBarPreference(mContext);
         mPreference.setSummary("Test summary");
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        showPreference();
+        mController.displayPreference(mScreen);
     }
 
     @Test
@@ -117,27 +113,27 @@
     @Test
     @Ignore
     public void setProgress_updatesIntensityAndDependentSettings() throws Exception {
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.RING_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.VIBRATE_WHEN_RINGING)).isEqualTo(OFF);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
         assertThat(readSetting(Settings.System.RING_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
         assertThat(readSetting(Settings.System.VIBRATE_WHEN_RINGING)).isEqualTo(ON);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
         assertThat(readSetting(Settings.System.RING_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
         assertThat(readSetting(Settings.System.VIBRATE_WHEN_RINGING)).isEqualTo(ON);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
         assertThat(readSetting(Settings.System.RING_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
         assertThat(readSetting(Settings.System.VIBRATE_WHEN_RINGING)).isEqualTo(ON);
 
-        mPreference.setProgress(Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.RING_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.VIBRATE_WHEN_RINGING)).isEqualTo(OFF);
@@ -150,8 +146,4 @@
     private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
         return Settings.System.getInt(mContext.getContentResolver(), settingKey);
     }
-
-    private void showPreference() {
-        mController.displayPreference(mScreen);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
index f58b64b..8e85c86 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
@@ -18,7 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -26,7 +25,6 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 
-import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 import androidx.test.core.app.ApplicationProvider;
@@ -49,10 +47,8 @@
     private static final int OFF = 0;
     private static final int ON = 1;
 
-    @Mock
-    private PreferenceScreen mScreen;
+    @Mock private PreferenceScreen mScreen;
 
-    private LifecycleOwner mLifecycleOwner;
     private Lifecycle mLifecycle;
     private Context mContext;
     private Vibrator mVibrator;
@@ -62,16 +58,15 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
-        mContext = spy(ApplicationProvider.getApplicationContext());
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new RingVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
         mLifecycle.addObserver(mController);
         mPreference = new SwitchPreference(mContext);
         mPreference.setSummary("Test summary");
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        showPreference();
+        mController.displayPreference(mScreen);
     }
 
     @Test
@@ -116,12 +111,12 @@
         mController.updateState(mPreference);
         assertThat(mPreference.isChecked()).isFalse();
 
-        mPreference.setChecked(true);
+        mController.setChecked(true);
         assertThat(readSetting(Settings.System.RING_VIBRATION_INTENSITY)).isEqualTo(
                 mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_RINGTONE));
         assertThat(readSetting(Settings.System.VIBRATE_WHEN_RINGING)).isEqualTo(ON);
 
-        mPreference.setChecked(false);
+        mController.setChecked(false);
         assertThat(readSetting(Settings.System.RING_VIBRATION_INTENSITY))
                 .isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
         assertThat(readSetting(Settings.System.VIBRATE_WHEN_RINGING)).isEqualTo(OFF);
@@ -134,8 +129,4 @@
     private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
         return Settings.System.getInt(mContext.getContentResolver(), settingKey);
     }
-
-    private void showPreference() {
-        mController.displayPreference(mScreen);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewPreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewPreferenceTest.java
new file mode 100644
index 0000000..6b9395a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingPreviewPreferenceTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import androidx.preference.PreferenceViewHolder;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.viewpager.widget.ViewPager;
+
+import com.android.settings.R;
+import com.android.settings.display.PreviewPagerAdapter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+/**
+ * Tests for {@link TextReadingPreferenceFragment}.
+ */
+@RunWith(RobolectricTestRunner.class)
+public class TextReadingPreviewPreferenceTest {
+
+    private TextReadingPreviewPreference mTextReadingPreviewPreference;
+    private PreferenceViewHolder mHolder;
+    private ViewPager mViewPager;
+    private PreviewPagerAdapter mPreviewPagerAdapter;
+
+    @Before
+    public void setUp() {
+        final Context context = ApplicationProvider.getApplicationContext();
+        final int[] sampleResIds = new int[]{1, 2, 3, 4, 5, 6};
+        final Configuration[] configurations = createConfigurations(6);
+        mTextReadingPreviewPreference = new TextReadingPreviewPreference(context);
+        mPreviewPagerAdapter =
+                new PreviewPagerAdapter(context, /* isLayoutRtl= */ false, sampleResIds,
+                        configurations);
+        final LayoutInflater inflater = LayoutInflater.from(context);
+        final View view =
+                inflater.inflate(mTextReadingPreviewPreference.getLayoutResource(),
+                        new LinearLayout(context), false);
+        mHolder = PreferenceViewHolder.createInstanceForTests(view);
+        mViewPager = view.findViewById(R.id.preview_pager);
+    }
+
+    @Test
+    public void setPreviewerAdapter_success() {
+        mTextReadingPreviewPreference.setPreviewAdapter(mPreviewPagerAdapter);
+        mTextReadingPreviewPreference.onBindViewHolder(mHolder);
+
+        assertThat(mViewPager.getAdapter()).isEqualTo(mPreviewPagerAdapter);
+    }
+
+    @Test
+    public void setPreviewAdapterWithNull_resetCurrentItem() {
+        final int currentItem = 2;
+        mTextReadingPreviewPreference.setPreviewAdapter(mPreviewPagerAdapter);
+        mTextReadingPreviewPreference.setCurrentItem(currentItem);
+        mTextReadingPreviewPreference.onBindViewHolder(mHolder);
+
+        mTextReadingPreviewPreference.setPreviewAdapter(null);
+        mTextReadingPreviewPreference.onBindViewHolder(mHolder);
+
+        assertThat(mTextReadingPreviewPreference.getCurrentItem()).isEqualTo(0);
+    }
+
+    @Test
+    public void setCurrentItem_success() {
+        final int currentItem = 3;
+        mTextReadingPreviewPreference.setPreviewAdapter(mPreviewPagerAdapter);
+        mTextReadingPreviewPreference.onBindViewHolder(mHolder);
+
+        mTextReadingPreviewPreference.setCurrentItem(currentItem);
+        mTextReadingPreviewPreference.onBindViewHolder(mHolder);
+
+        assertThat(mViewPager.getCurrentItem()).isEqualTo(currentItem);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void setCurrentItemBeforeSetPreviewAdapter_throwNPE() {
+        final int currentItem = 5;
+
+        mTextReadingPreviewPreference.setCurrentItem(currentItem);
+    }
+
+    private static Configuration[] createConfigurations(int count) {
+        final Configuration[] configurations = new Configuration[count];
+        for (int i = 0; i < count; i++) {
+            configurations[i] = new Configuration();
+        }
+
+        return configurations;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/VibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/VibrationIntensityPreferenceControllerTest.java
new file mode 100644
index 0000000..ba48f66
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/VibrationIntensityPreferenceControllerTest.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.VibrationAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+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;
+
+@RunWith(RobolectricTestRunner.class)
+public class VibrationIntensityPreferenceControllerTest {
+
+    private static final String SETTING_KEY = Settings.System.NOTIFICATION_VIBRATION_INTENSITY;
+    private static final int VIBRATION_USAGE = VibrationAttributes.USAGE_NOTIFICATION;
+
+    /** Basic implementation of preference controller to test generic behavior. */
+    private static class TestPreferenceController extends VibrationIntensityPreferenceController {
+
+        TestPreferenceController(Context context, int supportedIntensityLevels) {
+            super(context, "preference_key",
+                    new VibrationPreferenceConfig(context, SETTING_KEY, VIBRATION_USAGE) {},
+                    supportedIntensityLevels);
+        }
+
+        @Override
+        public int getAvailabilityStatus() {
+            return AVAILABLE;
+        }
+    }
+
+    @Mock private PreferenceScreen mScreen;
+
+    private Lifecycle mLifecycle;
+    private Context mContext;
+    private Vibrator mVibrator;
+    private SeekBarPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mContext = ApplicationProvider.getApplicationContext();
+        mVibrator = mContext.getSystemService(Vibrator.class);
+    }
+
+    @Test
+    public void missingSetting_shouldReturnDefault() {
+        VibrationIntensityPreferenceController controller = createPreferenceController(3);
+        Settings.System.putString(mContext.getContentResolver(), SETTING_KEY, null);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress())
+                .isEqualTo(mVibrator.getDefaultVibrationIntensity(VIBRATION_USAGE));
+    }
+
+    @Test
+    public void updateState_allLevelsSupported_shouldDisplayIntensityInSliderPosition() {
+        VibrationIntensityPreferenceController controller = createPreferenceController(3);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_LOW);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_OFF);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+    @Test
+    public void updateState_twoLevelsSupported_shouldDisplayMediumAndHighAtLastPosition() {
+        VibrationIntensityPreferenceController controller = createPreferenceController(2);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_LOW);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_OFF);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+    @Test
+    public void updateState_oneLevelSupported_shouldDisplayAllAtLastPosition() {
+        VibrationIntensityPreferenceController controller = createPreferenceController(1);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_LOW);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        updateSetting(SETTING_KEY, Vibrator.VIBRATION_INTENSITY_OFF);
+        controller.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+    @Test
+    public void setProgress_allSupportedPositions_updatesIntensitySetting() throws Exception {
+        VibrationIntensityPreferenceController controller = createPreferenceController(3);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+    }
+
+    @Test
+    public void setProgress_twoSupportedPositions_updatesMediumPositionToHigh() throws Exception {
+        VibrationIntensityPreferenceController controller = createPreferenceController(2);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
+    }
+
+    @Test
+    public void setProgress_oneSupportedPosition_updatesOnPositionsToDeviceDefault()
+            throws Exception {
+        int defaultIntensity = mVibrator.getDefaultVibrationIntensity(VIBRATION_USAGE);
+        VibrationIntensityPreferenceController controller = createPreferenceController(1);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_OFF);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(defaultIntensity);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(defaultIntensity);
+
+        controller.setSliderPosition(Vibrator.VIBRATION_INTENSITY_HIGH);
+        assertThat(readSetting(SETTING_KEY)).isEqualTo(defaultIntensity);
+    }
+
+    private void updateSetting(String key, int value) {
+        Settings.System.putInt(mContext.getContentResolver(), key, value);
+    }
+
+    private int readSetting(String settingKey) throws Settings.SettingNotFoundException {
+        return Settings.System.getInt(mContext.getContentResolver(), settingKey);
+    }
+
+    private VibrationIntensityPreferenceController createPreferenceController(
+            int supportedIntensityLevels) {
+        VibrationIntensityPreferenceController controller =
+                new TestPreferenceController(mContext, supportedIntensityLevels);
+        mLifecycle.addObserver(controller);
+        mPreference = new SeekBarPreference(mContext);
+        mPreference.setSummary("Test summary");
+        when(mScreen.findPreference(controller.getPreferenceKey())).thenReturn(mPreference);
+        controller.displayPreference(mScreen);
+        return controller;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java
index 630de33..1f2c0d9 100644
--- a/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java
@@ -30,11 +30,9 @@
 import android.content.Context;
 import android.media.AudioManager;
 import android.os.Vibrator;
-import android.provider.DeviceConfig;
 import android.provider.Settings;
 import android.telephony.TelephonyManager;
 
-import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 import androidx.test.core.app.ApplicationProvider;
@@ -54,14 +52,12 @@
 
     private static final String PREFERENCE_KEY = "preference_key";
 
-    @Mock
-    private PreferenceScreen mScreen;
-    @Mock
-    private TelephonyManager mTelephonyManager;
-    @Mock
-    private AudioManager mAudioManager;
+    @Mock private PreferenceScreen mScreen;
+    @Mock private TelephonyManager mTelephonyManager;
+    @Mock private AudioManager mAudioManager;
+    @Mock private VibrationRampingRingerTogglePreferenceController.DeviceConfigProvider
+            mDeviceConfigProvider;
 
-    private LifecycleOwner mLifecycleOwner;
     private Lifecycle mLifecycle;
     private Context mContext;
     private VibrationRampingRingerTogglePreferenceController mController;
@@ -70,18 +66,17 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
+        mLifecycle = new Lifecycle(() -> mLifecycle);
         mContext = spy(ApplicationProvider.getApplicationContext());
         when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
         when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
         mController = new VibrationRampingRingerTogglePreferenceController(mContext,
-                PREFERENCE_KEY);
+                PREFERENCE_KEY, mDeviceConfigProvider);
         mLifecycle.addObserver(mController);
         mPreference = new SwitchPreference(mContext);
         mPreference.setSummary("Test summary");
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        showPreference();
+        mController.displayPreference(mScreen);
     }
 
     @Test
@@ -93,8 +88,7 @@
     @Ignore
     public void getAvailabilityStatus_notVoiceCapable_returnUnsupportedOnDevice() {
         when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
-                VibrationRampingRingerTogglePreferenceController.DEVICE_CONFIG_KEY, "false", false);
+        when(mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig()).thenReturn(false);
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
     }
@@ -103,8 +97,7 @@
     @Ignore
     public void getAvailabilityStatus_rampingRingerEnabled_returnUnsupportedOnDevice() {
         when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
-                VibrationRampingRingerTogglePreferenceController.DEVICE_CONFIG_KEY, "true", false);
+        when(mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig()).thenReturn(true);
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
     }
@@ -113,8 +106,7 @@
     @Ignore
     public void getAvailabilityStatus_voiceCapableAndRampingRingerDisabled_returnAvailable() {
         when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
-                VibrationRampingRingerTogglePreferenceController.DEVICE_CONFIG_KEY, "false", false);
+        when(mDeviceConfigProvider.isRampingRingerEnabledOnTelephonyConfig()).thenReturn(false);
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
     }
@@ -147,8 +139,8 @@
     public void setChecked_withRingDisabled_ignoresUpdates() {
         updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
 
-        mPreference.setChecked(true);
-        mPreference.setChecked(false);
+        mController.setChecked(true);
+        mController.setChecked(false);
         verify(mAudioManager, never()).setRampingRingerEnabled(anyBoolean());
     }
 
@@ -157,18 +149,14 @@
     public void setChecked_withRingEnabled_updatesSetting() {
         updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
 
-        mPreference.setChecked(true);
+        mController.setChecked(true);
         verify(mAudioManager).setRampingRingerEnabled(true);
 
-        mPreference.setChecked(false);
+        mController.setChecked(false);
         verify(mAudioManager).setRampingRingerEnabled(false);
     }
 
     private void updateSetting(String key, int value) {
         Settings.System.putInt(mContext.getContentResolver(), key, value);
     }
-
-    private void showPreference() {
-        mController.displayPreference(mScreen);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
index dcb1a50..17283cf 100644
--- a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
@@ -38,7 +38,6 @@
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -138,13 +137,13 @@
     }
 
     @Test
-    @Ignore
     public void initializingSwitchDoesNotTriggerView() {
         Settings.Secure.putInt(
                 mContext.getContentResolver(),
                 Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED,
                 1);
 
+        mSwitchBar = new SettingsMainSwitchBar(mContext);
         mController =
                 new AutomaticStorageManagerSwitchBarController(
                         mContext,
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
index 4df3bc9..9204d43 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
@@ -19,6 +19,9 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
@@ -26,6 +29,7 @@
 
 import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.Intent;
 import android.content.IntentFilter;
 import android.net.ConnectivityManager;
 import android.net.NetworkRequest;
@@ -42,7 +46,6 @@
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -56,6 +59,8 @@
 public class WifiPrimarySwitchPreferenceControllerTest {
 
     @Mock
+    private Intent mIntentReceiver;
+    @Mock
     private WifiManager mWifiManager;
     @Mock
     private PreferenceScreen mScreen;
@@ -75,6 +80,9 @@
         MockitoAnnotations.initMocks(this);
         mMetricsFeatureProvider = FakeFeatureFactory.setupForTest().getMetricsFeatureProvider();
         mContext = spy(RuntimeEnvironment.application.getApplicationContext());
+        doReturn(mIntentReceiver).when(mContext)
+                .registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class), anyInt());
+        doNothing().when(mContext).unregisterReceiver(any(BroadcastReceiver.class));
         when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
         when(mContext.getSystemService(NetworkScoreManager.class)).thenReturn(mNetworkScoreManager);
         mController = new WifiPrimarySwitchPreferenceController(mContext, mMetricsFeatureProvider);
@@ -95,11 +103,11 @@
     }
 
     @Test
-    @Ignore
     public void onResume_shouldRegisterCallback() {
         mController.onResume();
 
-        verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
+        verify(mContext).registerReceiver(
+                any(BroadcastReceiver.class), any(IntentFilter.class), anyInt());
         verify(mConnectivityManager).registerNetworkCallback(
                 any(NetworkRequest.class),
                 any(ConnectivityManager.NetworkCallback.class),
@@ -107,7 +115,6 @@
     }
 
     @Test
-    @Ignore
     public void onPause_shouldUnregisterCallback() {
         mController.onResume();
         mController.onPause();