Merge "Add Category for contextual cards"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8cad8a4..aa98c62 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -59,6 +59,7 @@
     <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
     <uses-permission android:name="android.permission.STATUS_BAR" />
     <uses-permission android:name="android.permission.MANAGE_USB" />
+    <uses-permission android:name="android.permission.MANAGE_DEBUGGING" />
     <uses-permission android:name="android.permission.SET_POINTER_SPEED" />
     <uses-permission android:name="android.permission.SET_KEYBOARD_LAYOUT" />
     <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
@@ -80,6 +81,8 @@
     <uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
     <uses-permission android:name="android.permission.USE_FINGERPRINT" />
     <uses-permission android:name="android.permission.MANAGE_FINGERPRINT" />
+    <uses-permission android:name="android.permission.USE_BIOMETRIC" />
+    <uses-permission android:name="android.permission.USE_BIOMETRIC_INTERNAL" />
     <uses-permission android:name="android.permission.USER_ACTIVITY" />
     <uses-permission android:name="android.permission.CHANGE_APP_IDLE_STATE" />
     <uses-permission android:name="android.permission.PEERS_MAC_ADDRESS"/>
@@ -1451,7 +1454,7 @@
         <!-- Lock screen settings -->
         <activity android:name=".password.ConfirmDeviceCredentialActivity"
             android:exported="true"
-            android:theme="@android:style/Theme.NoDisplay">
+            android:theme="@android:style/Theme.Translucent.NoTitleBar">
             <intent-filter android:priority="1">
                 <action android:name="android.app.action.CONFIRM_DEVICE_CREDENTIAL" />
                 <action android:name="android.app.action.CONFIRM_FRP_CREDENTIAL" />
@@ -1524,6 +1527,15 @@
             android:exported="false"
             android:screenOrientation="portrait"/>
 
+        <activity android:name=".biometrics.BiometricEnrollActivity"
+            android:exported="true"
+            android:theme="@style/GlifTheme.Light">
+            <intent-filter>
+                <action android:name="android.settings.BIOMETRIC_ENROLL" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".biometrics.fingerprint.FingerprintSettings" android:exported="false"/>
         <activity android:name=".biometrics.fingerprint.FingerprintEnrollFindSensor" android:exported="false"/>
         <activity android:name=".biometrics.fingerprint.FingerprintEnrollEnrolling" android:exported="false"/>
diff --git a/res/anim/confirm_credential_biometric_transition_enter.xml b/res/anim/confirm_credential_biometric_transition_enter.xml
new file mode 100644
index 0000000..56f3593
--- /dev/null
+++ b/res/anim/confirm_credential_biometric_transition_enter.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ 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
+  -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shareInterpolator="false"
+    android:zAdjustment="top">
+    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
+        android:interpolator="@android:interpolator/linear_out_slow_in"
+        android:duration="350"/>
+</set>
\ No newline at end of file
diff --git a/res/anim/confirm_credential_biometric_transition_exit.xml b/res/anim/confirm_credential_biometric_transition_exit.xml
new file mode 100644
index 0000000..debdce2
--- /dev/null
+++ b/res/anim/confirm_credential_biometric_transition_exit.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ 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
+  -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shareInterpolator="false"
+    android:zAdjustment="top">
+    <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
+        android:interpolator="@android:interpolator/linear_out_slow_in"
+        android:duration="350" />
+</set>
\ No newline at end of file
diff --git a/res/mipmap-hdpi/ic_accessibility_generic.png b/res/drawable-hdpi/ic_accessibility_generic.png
similarity index 100%
rename from res/mipmap-hdpi/ic_accessibility_generic.png
rename to res/drawable-hdpi/ic_accessibility_generic.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_accessibility_generic.png b/res/drawable-mdpi/ic_accessibility_generic.png
similarity index 100%
rename from res/mipmap-mdpi/ic_accessibility_generic.png
rename to res/drawable-mdpi/ic_accessibility_generic.png
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_accessibility_generic.png b/res/drawable-xhdpi/ic_accessibility_generic.png
similarity index 100%
rename from res/mipmap-xhdpi/ic_accessibility_generic.png
rename to res/drawable-xhdpi/ic_accessibility_generic.png
Binary files differ
diff --git a/res/mipmap-xxhdpi/ic_accessibility_generic.png b/res/drawable-xxhdpi/ic_accessibility_generic.png
similarity index 100%
rename from res/mipmap-xxhdpi/ic_accessibility_generic.png
rename to res/drawable-xxhdpi/ic_accessibility_generic.png
Binary files differ
diff --git a/res/mipmap-xxxhdpi/ic_accessibility_generic.png b/res/drawable-xxxhdpi/ic_accessibility_generic.png
similarity index 100%
rename from res/mipmap-xxxhdpi/ic_accessibility_generic.png
rename to res/drawable-xxxhdpi/ic_accessibility_generic.png
Binary files differ
diff --git a/res/drawable/ic_fingerprint_error.xml b/res/drawable/ic_fingerprint_error.xml
deleted file mode 100644
index c9363bc..0000000
--- a/res/drawable/ic_fingerprint_error.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
-  ~ Copyright (C) 2015 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
-  -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="32dp"
-        android:height="32dp"
-        android:viewportWidth="32.0"
-        android:viewportHeight="32.0">
-    <path
-        android:fillColor="?android:attr/colorError"
-        android:pathData="M15.99,2.5C8.53,2.5 2.5,8.54 2.5,16.0s6.03,13.5 13.49,13.5S29.5,23.46 29.5,16.0S23.45,2.5 15.99,2.5zM16.0,26.8c-5.97,0.0 -10.8,-4.83 -10.8,-10.8S10.03,5.2 16.0,5.2S26.8,10.03 26.8,16.0S21.97,26.8 16.0,26.8z"/>
-    <path
-        android:fillColor="?android:attr/colorError"
-        android:pathData="M14.65,20.05l2.7,0.0l0.0,2.7l-2.7,0.0z"/>
-    <path
-        android:fillColor="?android:attr/colorError"
-        android:pathData="M14.65,9.25l2.7,0.0l0.0,8.1l-2.7,0.0z"/>
-</vector>
diff --git a/res/layout-land/confirm_lock_password.xml b/res/layout-land/confirm_lock_password.xml
index 218192c..a6a85d3 100644
--- a/res/layout-land/confirm_lock_password.xml
+++ b/res/layout-land/confirm_lock_password.xml
@@ -87,14 +87,6 @@
 
             </LinearLayout>
 
-            <ImageView
-                android:id="@+id/fingerprintIcon"
-                android:layout_gravity="end|bottom"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginBottom="28dp"
-                android:layout_marginEnd="20dp"
-                android:visibility="gone"/>
         </FrameLayout>
 
     </LinearLayout>
diff --git a/res/layout-land/confirm_lock_pattern.xml b/res/layout-land/confirm_lock_pattern.xml
index 81f257e..b0a0a96 100644
--- a/res/layout-land/confirm_lock_pattern.xml
+++ b/res/layout-land/confirm_lock_pattern.xml
@@ -108,14 +108,6 @@
                 android:layout_width="0dp"
                 android:layout_height="match_parent"
                 android:layout_weight="1"/>
-
-            <ImageView
-                android:id="@+id/fingerprintIcon"
-                android:layout_gravity="center_vertical"
-                android:layout_width="0dp"
-                android:layout_weight="1"
-                android:layout_height="wrap_content"
-                android:visibility="gone"/>
         </LinearLayout>
 
     </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
diff --git a/res/layout-land/confirm_lock_pattern_normal.xml b/res/layout-land/confirm_lock_pattern_normal.xml
index 9c90d6f..158d343 100644
--- a/res/layout-land/confirm_lock_pattern_normal.xml
+++ b/res/layout-land/confirm_lock_pattern_normal.xml
@@ -85,14 +85,6 @@
                     android:layout_marginEnd="?attr/suwMarginSides"
                     android:layout_marginBottom="24dp"
                     android:gravity="center_vertical"/>
-
-                <ImageView
-                    android:id="@+id/fingerprintIcon"
-                    android:layout_gravity="center_horizontal"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:contentDescription="@string/confirm_fingerprint_icon_content_description"
-                    android:visibility="gone"/>
             </LinearLayout>
 
         </ScrollView>
diff --git a/res/layout/confirm_lock_password_base.xml b/res/layout/confirm_lock_password_base.xml
index 05e90d2..1e42fbe 100644
--- a/res/layout/confirm_lock_password_base.xml
+++ b/res/layout/confirm_lock_password_base.xml
@@ -89,19 +89,5 @@
 
         </LinearLayout>
 
-        <View android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1"/>
-
-        <ImageView
-            android:id="@+id/fingerprintIcon"
-            android:layout_gravity="center_horizontal"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            android:layout_marginBottom="24dp"
-            android:contentDescription="@string/confirm_fingerprint_icon_content_description"
-            android:visibility="gone"/>
-
     </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
 </FrameLayout>
diff --git a/res/layout/confirm_lock_password_normal.xml b/res/layout/confirm_lock_password_normal.xml
index 05bd4a0..0b516ca 100644
--- a/res/layout/confirm_lock_password_normal.xml
+++ b/res/layout/confirm_lock_password_normal.xml
@@ -70,16 +70,6 @@
             android:layout_height="0dp"
             android:layout_weight="1" />
 
-        <ImageView
-            android:id="@+id/fingerprintIcon"
-            android:layout_gravity="center_horizontal"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            android:layout_marginBottom="24dp"
-            android:contentDescription="@string/confirm_fingerprint_icon_content_description"
-            android:visibility="gone"/>
-
         <Button
             android:id="@+id/cancelButton"
             style="@style/SuwGlifButton.Secondary"
diff --git a/res/layout/confirm_lock_pattern_base.xml b/res/layout/confirm_lock_pattern_base.xml
index e6b7887..f841391 100644
--- a/res/layout/confirm_lock_pattern_base.xml
+++ b/res/layout/confirm_lock_pattern_base.xml
@@ -97,15 +97,6 @@
                 android:layout_marginEnd="12dp"
                 android:gravity="center_vertical"/>
 
-            <ImageView
-                android:id="@+id/fingerprintIcon"
-                android:layout_gravity="center_horizontal"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="true"
-                android:layout_marginBottom="24dp"
-                android:contentDescription="@string/confirm_fingerprint_icon_content_description"
-                android:visibility="gone"/>
         </LinearLayout>
 
     </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
diff --git a/res/layout/confirm_lock_pattern_normal_base.xml b/res/layout/confirm_lock_pattern_normal_base.xml
index 6773ec0..bfabf99 100644
--- a/res/layout/confirm_lock_pattern_normal_base.xml
+++ b/res/layout/confirm_lock_pattern_normal_base.xml
@@ -90,16 +90,6 @@
                 android:layout_marginTop="12dp"
                 android:gravity="center_vertical"/>
 
-            <ImageView
-                android:id="@+id/fingerprintIcon"
-                android:layout_gravity="center_horizontal"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginHorizontal="?attr/suwMarginSides"
-                android:layout_marginBottom="24dp"
-                android:contentDescription="@string/confirm_fingerprint_icon_content_description"
-                android:visibility="gone"/>
-
             <Button
                 android:id="@+id/cancelButton"
                 style="@style/SuwGlifButton.Secondary"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index bd69eee..28cdfb1 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -17,7 +17,6 @@
 
 <androidx.cardview.widget.CardView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     style="@style/ContextualCardStyle">
@@ -25,10 +24,10 @@
     <androidx.slice.widget.SliceView
         android:id="@+id/slice_view"
         android:layout_width="match_parent"
-        android:layout_height="@dimen/homepage_slice_card_max_height"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="@dimen/homepage_card_vertical_margin"
+        android:layout_marginTop="@dimen/homepage_card_vertical_margin"
         android:paddingStart="@dimen/homepage_card_padding_start"
-        android:paddingEnd="@dimen/homepage_card_padding_end"
-        android:paddingTop="@dimen/homepage_card_padding_top"
-        android:paddingBottom="@dimen/homepage_card_padding_bottom"/>
+        android:paddingEnd="@dimen/homepage_card_padding_end"/>
 
 </androidx.cardview.widget.CardView>
diff --git a/res/layout/network_request_dialog_title.xml b/res/layout/network_request_dialog_title.xml
new file mode 100644
index 0000000..fa01085
--- /dev/null
+++ b/res/layout/network_request_dialog_title.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingEnd="?android:attr/dialogPreferredPadding"
+    android:orientation="horizontal"
+    android:background="?android:attr/selectableItemBackground"
+    android:minHeight="?android:attr/listPreferredItemHeightSmall">
+
+  <TextView
+      android:id="@+id/network_request_title_text"
+      android:layout_width="0dp"
+      android:layout_height="match_parent"
+      android:paddingLeft="16dip"
+      android:layout_weight="1"
+      android:textSize="18sp"
+      android:gravity="center_vertical"
+      style="@style/info_label"/>
+
+  <ProgressBar
+      android:id="@+id/network_request_title_progress"
+      style="?android:attr/progressBarStyleSmallTitle"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_gravity="center_vertical"
+      android:layout_marginStart="16dip"
+      android:minWidth="32dp"
+      android:text="@string/progress_scanning"/>
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 8059097..9b33388 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -327,17 +327,10 @@
     <!-- Homepage cards size and padding -->
     <dimen name="homepage_card_corner_radius">8dp</dimen>
     <dimen name="homepage_card_elevation">2dp</dimen>
-    <dimen name="homepage_card_top_margin">6dp</dimen>
-    <dimen name="homepage_card_bottom_margin">6dp</dimen>
+    <dimen name="homepage_card_vertical_margin">6dp</dimen>
     <dimen name="homepage_card_side_margin">16dp</dimen>
     <dimen name="homepage_card_padding_start">16dp</dimen>
     <dimen name="homepage_card_padding_end">16dp</dimen>
-    <dimen name="homepage_card_padding_top">6dp</dimen>
-    <dimen name="homepage_card_padding_bottom">6dp</dimen>
-
-    <!-- Slice cards maximum height (4 rows + show more)
-        MODE_LARGE height(3 rows + show more) 240dp + one line text(1 row) 48dp = 288dp -->
-    <dimen name="homepage_slice_card_max_height">288dp</dimen>
 
     <!-- Signal icon in NetworkSelectSetting -->
     <dimen name="signal_strength_icon_size">24dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 56dbc6b..0f3b18d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1051,9 +1051,6 @@
     <!-- Button to confirm the last removing the last fingerprint. [CHAR LIMIT=20]-->
     <string name="fingerprint_last_delete_confirm">Yes, remove</string>
 
-    <!-- Content description for the fingerprint icon when the user is prompted to enter his credentials. Not shown on the screen. [CHAR LIMIT=NONE] -->
-    <string name="confirm_fingerprint_icon_content_description">Use your fingerprint to continue.</string>
-
     <!-- Title of the preferences category for preference items to control encryption -->
     <string name="crypt_keeper_settings_title">Encryption</string>
 
@@ -3709,6 +3706,10 @@
     <!-- About phone settings screen, Safety Legal dialog title until the link is fully loaded -->
     <string name="settings_safetylegal_activity_loading">Loading\u2026</string>
 
+    <!-- ConfirmDeviceCredential settings-->
+    <!-- Button text shown on BiometricPrompt (system dialog that asks for biometric authentication) giving the user the option to use an alternate form of authentication (Pin/Pattern/Pass) [CHAR LIMIT=30] -->
+    <string name="confirm_device_credential_use_alternate_method">Use alternate method</string>
+
     <!-- Lock Pattern settings -->
     <!-- Header on first screen of choose password/PIN flow [CHAR LIMIT=40] -->
     <string name="lockpassword_choose_your_screen_lock_header">Set screen lock</string>
@@ -3771,8 +3772,8 @@
     <string name="lockpassword_confirm_your_password_generic_profile">Enter your work password to continue</string>
 
     <!-- This string shows up on a screen where a user can enter a pattern that
-         unlocks their device. This is an extra security measure that's required for them to
-         continue. [CHAR LIMIT=100] -->
+     unlocks their device. This is an extra security measure that's required for them to
+     continue. [CHAR LIMIT=100] -->
     <string name="lockpassword_strong_auth_required_device_pattern">For added security, use your device pattern</string>
     <!-- This string shows up on a screen where a user can enter a PIN that unlocks their device.
          This is an extra security measure that's required for them to continue. [CHAR LIMIT=100]
@@ -7185,20 +7186,26 @@
     <string name="zen_mode_behavior_alarms_only">No sound except alarms and media</string>
 
     <!--  Do not disturb: Title for the zen mode automation option in Settings. [CHAR LIMIT=40] -->
-    <string name="zen_mode_automation_settings_title">Turn on automatically</string>
+    <string name="zen_mode_automation_settings_title">Schedules</string>
 
     <!--  Do not disturb: Title for the zen mode automatic rules page in settings. [CHAR LIMIT=30] -->
-    <string name="zen_mode_automation_settings_page_title">Automatic rules</string>
+    <string name="zen_mode_automation_settings_page_title">Do Not Disturb</string>
 
     <!--  Do not disturb: Title for a specific zen mode automatic rule in settings. [CHAR LIMIT=30] -->
     <string name="zen_mode_automatic_rule_settings_page_title">Automatic rule</string>
 
+    <!--  Do not disturb: Title do not disturb settings representing automatic (scheduled) do not disturb rules. [CHAR LIMIT=30] -->
+    <string name="zen_mode_schedule_category_title">Schedule</string>
+
     <!--  Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=46] -->
     <string name="zen_mode_automation_suggestion_title">Silence phone at certain times</string>
 
     <!--  Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=55] -->
     <string name="zen_mode_automation_suggestion_summary">Set Do Not Disturb rules</string>
 
+    <!--  Do not disturb: Header for the Do Not Disturb automatic rules. [CHAR LIMIT=55] -->
+    <string name="zen_mode_schedule_title">Schedule</string>
+
     <!--  Do not disturb: Switch toggle to toggle whether to use an automatic dnd rule or not [CHAR LIMIT=40] -->
     <string name="zen_mode_use_automatic_rule">Use rule</string>
 
@@ -7221,10 +7228,10 @@
     <string name="zen_mode_visual_signals_settings_subtitle">Allow visual signals</string>
 
     <!-- Do not disturb: zen settings screens category title [CHAR LIMIT=100] -->
-    <string name="zen_mode_settings_category">When Do Not Disturb is turned on</string>
+    <string name="zen_mode_settings_category">When Do Not Disturb is on</string>
 
-    <!-- Do not disturb: restrict notifications title [CHAR LIMIT=60] -->
-    <string name="zen_mode_restrict_notifications_title">Notifications</string>
+    <!-- Do not disturb: restrict notifications title [CHAR LIMIT=80] -->
+    <string name="zen_mode_restrict_notifications_title">Notification restrictions</string>
     <!-- Do not disturb: Mute notifications option [CHAR LIMIT=60] -->
     <string name="zen_mode_restrict_notifications_mute">No sound from notifications</string>
     <!-- Do not disturb:Mute notifications summary [CHAR LIMIT=NONE] -->
@@ -7356,15 +7363,15 @@
         <item quantity="other"><xliff:g id="on_count" example="3">%d</xliff:g> rules can turn on automatically</item>
     </plurals>
 
-    <!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
-    <string name="zen_category_behavior">Behavior</string>
-    <!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
+    <!-- Do not disturb settings, category header [CHAR LIMIT=120]-->
+    <string name="zen_category_behavior">Mute phone, but allow exceptions</string>
+    <!-- Do not disturb settings, exceptions to dnd title [CHAR LIMIT=100]-->
     <string name="zen_category_exceptions">Exceptions</string>
     <!-- Do not disturb settings, category header [CHAR LIMIT=100]-->
     <string name="zen_category_schedule">Schedule</string>
 
-    <!-- Do not disturb settings, sound and vibrations title [CHAR LIMIT=100]-->
-    <string name="zen_sound_title">Sound &amp; vibration</string>
+    <!-- Do not disturb settings, sound and vibrations exceptions title [CHAR LIMIT=100]-->
+    <string name="zen_sound_title">See all exceptions</string>
     <!-- Do not disturb settings, sound and vibrations screen footer [CHAR LIMIT=NONE]-->
     <string name="zen_sound_footer">When Do Not Disturb is on, sound and vibration will be muted, except for the items you allow above.</string>
     <!-- Do not disturb settings, sound and vibrations screen category [CHAR LIMIT=100]-->
@@ -7816,8 +7823,8 @@
     <!-- [CHAR LIMIT=100] Zen mode settings: Warning text for invalid zen rule names -->
     <string name="zen_mode_rule_name_warning">Rule name already in use</string>
 
-    <!-- [CHAR LIMIT=40] Zen mode settings: Add rule menu option name -->
-    <string name="zen_mode_add_rule">Add rule</string>
+    <!-- [CHAR LIMIT=40] Zen mode settings: Add another automatic zen rule option name-->
+    <string name="zen_mode_add_rule">Add more</string>
 
     <!-- [CHAR LIMIT=40] Zen mode settings: Add event-based rule, set rule name title -->
     <string name="zen_mode_add_event_rule">Add event rule</string>
@@ -7942,6 +7949,9 @@
     <!-- [CHAR LIMIT=20] Zen mode settings: Messages option -->
     <string name="zen_mode_messages">Messages</string>
 
+    <!-- Do not disturb settings, messages, events and reminders footer [CHAR LIMIT=NONE]-->
+    <string name="zen_mode_messages_footer">When Do Not Disturb is on, incoming text messages are blocked. You can adjust settings to allow your friends, family, or other contacts to reach you.</string>
+
     <!-- [CHAR LIMIT=40] Zen mode settings: Allow messages toggle title -->
     <string name="zen_mode_messages_title">Allow messages</string>
 
@@ -7978,42 +7988,36 @@
     <!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: None -->
     <string name="zen_mode_from_none">None</string>
 
-    <!-- [CHAR LIMIT=50] Zen mode settings: Alarms option -->
-    <string name="zen_mode_alarms">Alarms</string>
+    <!-- [CHAR LIMIT=80] Zen mode settings: Allow alarms option -->
+    <string name="zen_mode_alarms">Allow alarms</string>
 
     <!-- [CHAR LIMIT=50] Zen mode settings: Alarms option (ie: sound from alarm clock) -->
     <string name="zen_mode_alarms_list">alarms</string>
 
-    <!-- [CHAR LIMIT=50] Zen mode settings: Media option -->
-    <string name="zen_mode_media">Media</string>
+    <!-- [CHAR LIMIT=80] Zen mode settings: Allow media (sound from video) to bypass dnd -->
+    <string name="zen_mode_media">Allow media</string>
 
     <!-- [CHAR LIMIT=50] Zen mode settings: Media (ie: sound from video) -->
     <string name="zen_mode_media_list">media</string>
 
-    <!-- [CHAR LIMIT=50] Zen mode settings: System option which includes sounds such as touch sounds -->
-    <string name="zen_mode_system">Touch sounds</string>
+    <!-- [CHAR LIMIT=80] Zen mode settings: allow touch sounds to bypass DND  -->
+    <string name="zen_mode_system">Allow touch sounds</string>
 
     <!-- [CHAR LIMIT=50] Zen mode settings: System sounds (ie: touch sounds) -->
     <string name="zen_mode_system_list">touch sounds</string>
 
-    <!-- [CHAR LIMIT=50] Zen mode settings: Reminders option -->
-    <string name="zen_mode_reminders">Reminders</string>
+    <!-- [CHAR LIMIT=80] Zen mode settings: Allow reminder notifications/sounds to bypass DND  -->
+    <string name="zen_mode_reminders">Allow reminders</string>
 
     <!-- [CHAR LIMIT=50] Zen mode settings: Reminders (ie: calendar reminders are allowed to bypass dnd) -->
     <string name="zen_mode_reminders_list">reminders</string>
 
-    <!-- [CHAR LIMIT=70] Zen mode settings: Allow reminders toggle title -->
-    <string name="zen_mode_reminders_title">Allow reminders</string>
-
-    <!-- [CHAR LIMIT=50] Zen mode settings: Events option -->
-    <string name="zen_mode_events">Events</string>
+    <!-- [CHAR LIMIT=80] Zen mode settings: Allow event notifications/sounds to bypass DND -->
+    <string name="zen_mode_events">Allow events</string>
 
     <!-- [CHAR LIMIT=50] Zen mode settings: Events (ie: calendar events) -->
     <string name="zen_mode_events_list">events</string>
 
-    <!-- [CHAR LIMIT=70] Zen mode settings: Allow events toggle title -->
-    <string name="zen_mode_events_title">Allow events</string>
-
     <!-- [CHAR LIMIT=50] Zen mode settings: All callers summary -->
     <string name="zen_mode_all_callers">anyone</string>
 
@@ -8371,9 +8375,6 @@
     <!-- Explanation that the app that will NEVER be launched to open web links to domains that it understands -->
     <string name="app_link_open_never">Don&#8217;t open in this app</string>
 
-    <!-- Fingerprint hint message when finger was not recognized.-->
-    <string name="fingerprint_not_recognized">Not recognized</string>
-
     <!-- Title for Default Apps settings [CHAR LIMIT=30] -->
     <string name="default_apps_title">Default</string>
 
@@ -10269,7 +10270,9 @@
     <!-- See less items in contextual homepage [CHAR LIMIT=30]-->
     <string name="see_less">See less</string>
 
-    <!-- Summary for connected devices count in connected device slice. [CHAR LIMIT=NONE] -->
+    <!-- Title for Network connection request Dialog [CHAR LIMIT=30] -->
+    <string name="network_connection_request_dialog_title">Choose device</string>
+
     <plurals name="show_connected_devices">
         <item quantity="one"><xliff:g id="number_device_count">%1$d</xliff:g> device connected</item>
         <item quantity="other"><xliff:g id="number_device_count">%1$d</xliff:g> devices connected</item>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index fa7b1d7..83971b6 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -455,8 +455,8 @@
     </style>
 
     <style name="ContextualCardStyle">
-        <item name="android:layout_marginTop">@dimen/homepage_card_top_margin</item>
-        <item name="android:layout_marginBottom">@dimen/homepage_card_bottom_margin</item>
+        <item name="android:layout_marginTop">@dimen/homepage_card_vertical_margin</item>
+        <item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
         <item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
         <item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
         <item name="cardCornerRadius">@dimen/homepage_card_corner_radius</item>
diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml
index 889761b..e11d84a 100644
--- a/res/xml/top_level_settings.xml
+++ b/res/xml/top_level_settings.xml
@@ -113,7 +113,7 @@
         android:title="@string/header_category_system"
         android:summary="@string/system_dashboard_summary"
         android:icon="@drawable/ic_homepage_system_dashboard"
-        android:order="-10"
+        android:order="10"
         android:fragment="com.android.settings.system.SystemDashboardFragment"/>
 
     <Preference
diff --git a/res/xml/usb_details_fragment.xml b/res/xml/usb_details_fragment.xml
index 4efad6d..5c1efcf 100644
--- a/res/xml/usb_details_fragment.xml
+++ b/res/xml/usb_details_fragment.xml
@@ -36,9 +36,4 @@
     <PreferenceCategory
         android:key="usb_details_power_role"/>
 
-    <!-- Empty category for spacing -->
-    <PreferenceCategory
-        android:key="usb_details_space"
-        settings:allowDividerAbove="false"/>
-
 </PreferenceScreen>
diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index 934cb5a..b01e1f3 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -23,7 +23,8 @@
     <PreferenceCategory
         android:key="user_list"
         android:title="@string/user_list_title"
-        android:order="10">
+        android:order="10"
+        settings:searchable="false">
     </PreferenceCategory>
 
     <com.android.settingslib.RestrictedPreference
diff --git a/res/xml/zen_mode_automation_settings.xml b/res/xml/zen_mode_automation_settings.xml
index 99826ea..dade454 100644
--- a/res/xml/zen_mode_automation_settings.xml
+++ b/res/xml/zen_mode_automation_settings.xml
@@ -19,9 +19,9 @@
                   android:key="zen_mode_automation_settings_page"
                   android:title="@string/zen_mode_automation_settings_page_title" >
 
-
     <PreferenceCategory
-        android:key="zen_mode_automatic_rules">
+        android:key="zen_mode_automatic_rules"
+        android:title="@string/zen_mode_schedule_title">
         <!-- Rules added at runtime -->
     </PreferenceCategory>
 
diff --git a/res/xml/zen_mode_calls_settings.xml b/res/xml/zen_mode_calls_settings.xml
index 2da022c..74b6986 100644
--- a/res/xml/zen_mode_calls_settings.xml
+++ b/res/xml/zen_mode_calls_settings.xml
@@ -17,6 +17,7 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="zen_mode_calls_settings_page"
     android:title="@string/zen_mode_calls" >
 
diff --git a/res/xml/zen_mode_messages_settings.xml b/res/xml/zen_mode_messages_settings.xml
new file mode 100644
index 0000000..4ca6c92
--- /dev/null
+++ b/res/xml/zen_mode_messages_settings.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     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.
+-->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:key="zen_mode_messages_settings_page"
+    android:title="@string/zen_mode_messages" >
+
+    <PreferenceCategory
+        android:title="@string/zen_mode_settings_category"
+        android:key="zen_mode_settings_category_messages">
+        <!-- Messages -->
+        <ListPreference
+            android:key="zen_mode_messages"
+            android:title="@string/zen_mode_messages_title"
+            android:entries="@array/zen_mode_contacts_entries"
+            android:entryValues="@array/zen_mode_contacts_values"/>
+
+        <Preference
+            android:key="zen_mode_starred_contacts_messages"
+            android:title="@string/zen_mode_starred_contacts_title"/>
+    </PreferenceCategory>
+
+    <com.android.settingslib.widget.FooterPreference/>
+
+</PreferenceScreen>
diff --git a/res/xml/zen_mode_msg_event_reminder_settings.xml b/res/xml/zen_mode_msg_event_reminder_settings.xml
deleted file mode 100644
index 8fc6b47..0000000
--- a/res/xml/zen_mode_msg_event_reminder_settings.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     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.
--->
-
-<PreferenceScreen
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:key="zen_mode_msg_event_reminder_settings_page"
-    android:title="@string/zen_msg_event_reminder_title" >
-
-   <PreferenceCategory
-      android:title="@string/zen_mode_settings_category"
-      android:key="zen_mode_settings_category_msg_event_reminder">
-      <!-- Messages -->
-      <ListPreference
-          android:key="zen_mode_messages"
-          android:title="@string/zen_mode_messages_title"
-          android:entries="@array/zen_mode_contacts_entries"
-          android:entryValues="@array/zen_mode_contacts_values"/>
-
-      <Preference
-          android:key="zen_mode_starred_contacts_messages"
-          android:title="@string/zen_mode_starred_contacts_title"/>
-
-      <!-- Reminders -->
-      <SwitchPreference
-          android:key="zen_mode_reminders"
-          android:title="@string/zen_mode_reminders_title"/>
-
-      <!-- Events -->
-      <SwitchPreference
-          android:key="zen_mode_events"
-          android:title="@string/zen_mode_events_title"/>
-   </PreferenceCategory>
-
-   <com.android.settingslib.widget.FooterPreference />
-
-</PreferenceScreen>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index b8af650..1966484 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -25,62 +25,59 @@
     <PreferenceCategory
         android:key="zen_mode_settings_category_behavior"
         android:title="@string/zen_category_behavior">
-        <!-- sound vibration -->
+        <!-- Calls -->
+        <Preference
+            android:key="zen_mode_behavior_calls"
+            android:title="@string/zen_mode_calls_title"
+            android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
+
+        <!-- Messages -->
+        <Preference
+            android:key="zen_mode_behavior_messages"
+            android:title="@string/zen_mode_messages_title"
+            android:fragment="com.android.settings.notification.ZenModeMessagesSettings" />
+
+        <!-- Alarms -->
+        <SwitchPreference
+            android:key="zen_mode_behavior_alarms"
+            android:title="@string/zen_mode_alarms"/>
+
+        <!-- All sounds -->
         <Preference
             android:key="zen_sound_vibration_settings"
             android:title="@string/zen_sound_title"
-            android:fragment="com.android.settings.notification.ZenModeSoundVibrationSettings"/>
-
-        <!-- What to block (effects) -->
-        <Preference
-            android:key="zen_mode_block_effects_settings"
-            android:title="@string/zen_mode_restrict_notifications_title"
-            android:fragment="com.android.settings.notification.ZenModeRestrictNotificationsSettings" />
+            android:fragment="com.android.settings.notification.ZenModeSoundVibrationSettings"
+            android:icon="@drawable/ic_chevron_right_24dp"/>
     </PreferenceCategory>
 
-    <PreferenceCategory
-        android:key="zen_mode_settings_category_exceptions"
-        android:title="@string/zen_category_exceptions">
-        <Preference
-            android:key="zen_mode_calls_settings"
-            android:title="@string/zen_mode_calls"
-            android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
-        <Preference
-            android:key="zen_mode_msg_event_reminder_settings"
-            android:title="@string/zen_msg_event_reminder_title"
-            android:fragment="com.android.settings.notification.ZenModeMsgEventReminderSettings" />
+    <!-- What to block (effects) -->
+    <Preference
+        android:key="zen_mode_block_effects_settings"
+        android:title="@string/zen_mode_restrict_notifications_title"
+        android:fragment="com.android.settings.notification.ZenModeRestrictNotificationsSettings"
+        settings:allowDividerAbove="true"/>
 
-    </PreferenceCategory>
+    <!-- DND duration settings -->
+    <com.android.settings.notification.ZenDurationDialogPreference
+        android:key="zen_mode_duration_settings"
+        android:title="@string/zen_mode_duration_settings_title"
+        android:widgetLayout="@null"/>
 
-    <PreferenceCategory
-        android:key="zen_mode_settings_category_schedule"
-        android:title="@string/zen_category_schedule">
-        <!-- DND duration settings -->
-        <com.android.settings.notification.ZenDurationDialogPreference
-            android:key="zen_mode_duration_settings"
-            android:title="@string/zen_mode_duration_settings_title"
-            android:widgetLayout="@null"/>
-
-        <!-- Automatic rules -->
-        <Preference
-            android:key="zen_mode_automation_settings"
-            android:title="@string/zen_mode_automation_settings_title"
-            android:fragment="com.android.settings.notification.ZenModeAutomationSettings" />
-    </PreferenceCategory>
+    <!-- Automatic rules -->
+    <Preference
+        android:key="zen_mode_automation_settings"
+        android:title="@string/zen_mode_automation_settings_title"
+        android:fragment="com.android.settings.notification.ZenModeAutomationSettings"/>
 
     <!-- Turn on DND button -->
-    <!-- Layout preference doesn't obey allowDividerAbove, so put it in a PreferenceCategory -->
-    <PreferenceCategory
-        android:key="zen_mode_settings_button_category">
-        <com.android.settings.applications.LayoutPreference
-            android:key="zen_mode_settings_button_container"
-            android:selectable="false"
-            android:layout="@layout/zen_mode_settings_button" />
-    </PreferenceCategory>
+    <com.android.settings.applications.LayoutPreference
+        android:key="zen_mode_settings_button_container"
+        android:selectable="false"
+        android:layout="@layout/zen_mode_settings_button"
+        settings:allowDividerAbove="true"
+        settings:allowDividerBelow="true"/>
 
-    <PreferenceCategory
-        android:key="zen_mode_footer_container">
-        <com.android.settingslib.widget.FooterPreference />
-    </PreferenceCategory>
+    <!-- Footer that shows if user is put into alarms only or total silence mode by an app -->
+    <com.android.settingslib.widget.FooterPreference/>
 
 </PreferenceScreen>
diff --git a/res/xml/zen_mode_sound_vibration_settings.xml b/res/xml/zen_mode_sound_vibration_settings.xml
index b3b8139..3d1da2f 100644
--- a/res/xml/zen_mode_sound_vibration_settings.xml
+++ b/res/xml/zen_mode_sound_vibration_settings.xml
@@ -18,11 +18,24 @@
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:key="zen_mode_sound_vibration_settings_page"
-    android:title="@string/zen_sound_title" >
+    android:title="@string/zen_category_exceptions" >
 
    <PreferenceCategory
        android:title="@string/zen_mode_settings_category"
        android:key="zen_mode_settings_category_sound_vibration">
+
+      <!-- Calls -->
+      <Preference
+          android:key="zen_mode_calls_settings"
+          android:title="@string/zen_mode_calls_title"
+          android:fragment="com.android.settings.notification.ZenModeCallsSettings" />
+
+      <!-- Messages -->
+      <Preference
+          android:key="zen_mode_messages_settings"
+          android:title="@string/zen_mode_messages_title"
+          android:fragment="com.android.settings.notification.ZenModeMessagesSettings" />
+
       <!-- Alarms -->
       <SwitchPreference
           android:key="zen_mode_alarms"
@@ -37,6 +50,18 @@
       <SwitchPreference
           android:key="zen_mode_system"
           android:title="@string/zen_mode_system"/>
+
+      <!-- Reminders -->
+      <SwitchPreference
+          android:key="zen_mode_reminders"
+          android:title="@string/zen_mode_reminders"/>
+
+      <!-- Events -->
+      <SwitchPreference
+          android:key="zen_mode_events"
+          android:title="@string/zen_mode_events"/>
+
+      <!-- TODO: beverlyt, add "Allow apps to override" -->
    </PreferenceCategory>
 
    <com.android.settingslib.widget.FooterPreference/>
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 9a8ef54..65b0e86 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -550,7 +550,7 @@
 
             Drawable icon;
             if (resolveInfo.getIconResource() == 0) {
-                icon = ContextCompat.getDrawable(getContext(), R.mipmap.ic_accessibility_generic);
+                icon = ContextCompat.getDrawable(getContext(), R.drawable.ic_accessibility_generic);
             } else {
                 icon = resolveInfo.loadIcon(getPackageManager());
             }
diff --git a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
index aa5cd59..213bfbd 100644
--- a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
+++ b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
@@ -258,7 +258,7 @@
         public Drawable loadIcon() {
             final ResolveInfo resolveInfo = mServiceInfo.getResolveInfo();
             return (resolveInfo.getIconResource() == 0)
-                    ? getContext().getDrawable(R.mipmap.ic_accessibility_generic)
+                    ? getContext().getDrawable(R.drawable.ic_accessibility_generic)
                     : resolveInfo.loadIcon(getContext().getPackageManager());
         }
 
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
new file mode 100644
index 0000000..ee35945
--- /dev/null
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -0,0 +1,60 @@
+/*
+ * 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.biometrics;
+
+import android.app.settings.SettingsEnums;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+
+import com.android.settings.biometrics.face.FaceEnrollIntroduction;
+import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.core.InstrumentedActivity;
+
+/**
+ * Trampoline activity launched by the {@code android.settings.BIOMETRIC_ENROLL} action which
+ * shows the user an appropriate enrollment flow depending on the device's biometric hardware.
+ * This activity must only allow enrollment of biometrics that can be used by
+ * {@link android.hardware.biometrics.BiometricPrompt}.
+ */
+public class BiometricEnrollActivity extends InstrumentedActivity {
+
+    private static final String SETTINGS_PACKAGE = "com.android.settings";
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        final PackageManager pm = getApplicationContext().getPackageManager();
+        final Intent intent = new Intent();
+
+        // This logic may have to be modified on devices with multiple biometrics.
+        if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
+            intent.setClassName(SETTINGS_PACKAGE, FingerprintEnrollIntroduction.class.getName());
+        } else if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
+            intent.setClassName(SETTINGS_PACKAGE, FaceEnrollIntroduction.class.getName());
+        }
+
+        startActivity(intent);
+        finish();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
+    }
+}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintUiHelper.java b/src/com/android/settings/biometrics/fingerprint/FingerprintUiHelper.java
deleted file mode 100644
index 012f802..0000000
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintUiHelper.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2015 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.biometrics.fingerprint;
-
-import android.hardware.fingerprint.FingerprintManager;
-import android.os.CancellationSignal;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.settings.R;
-import com.android.settings.Utils;
-
-/**
- * Small helper class to manage text/icon around fingerprint authentication UI.
- */
-public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallback {
-
-    private static final long ERROR_TIMEOUT = 1300;
-
-    private ImageView mIcon;
-    private TextView mErrorTextView;
-    private CancellationSignal mCancellationSignal;
-    private int mUserId;
-
-    private Callback mCallback;
-    private FingerprintManager mFingerprintManager;
-
-    public FingerprintUiHelper(ImageView icon, TextView errorTextView, Callback callback,
-            int userId) {
-        mFingerprintManager = Utils.getFingerprintManagerOrNull(icon.getContext());
-        mIcon = icon;
-        mErrorTextView = errorTextView;
-        mCallback = callback;
-        mUserId = userId;
-    }
-
-    public void startListening() {
-        if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()
-                && mFingerprintManager.getEnrolledFingerprints(mUserId).size() > 0) {
-            mCancellationSignal = new CancellationSignal();
-            mFingerprintManager.setActiveUser(mUserId);
-            mFingerprintManager.authenticate(
-                    null, mCancellationSignal, 0 /* flags */, this, null, mUserId);
-            setFingerprintIconVisibility(true);
-            mIcon.setImageResource(R.drawable.ic_fingerprint);
-        }
-    }
-
-    public void stopListening() {
-        if (mCancellationSignal != null) {
-            mCancellationSignal.cancel();
-            mCancellationSignal = null;
-        }
-    }
-
-    public boolean isListening() {
-        return mCancellationSignal != null && !mCancellationSignal.isCanceled();
-    }
-
-    private void setFingerprintIconVisibility(boolean visible) {
-        mIcon.setVisibility(visible ? View.VISIBLE : View.GONE);
-        mCallback.onFingerprintIconVisibilityChanged(visible);
-    }
-
-    @Override
-    public void onAuthenticationError(int errMsgId, CharSequence errString) {
-        if (errMsgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED) {
-            // Only happens if we get preempted by another activity. Ignored.
-            return;
-        }
-        showError(errString);
-        setFingerprintIconVisibility(false);
-    }
-
-    @Override
-    public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
-        showError(helpString);
-    }
-
-    @Override
-    public void onAuthenticationFailed() {
-        showError(mIcon.getResources().getString(
-                R.string.fingerprint_not_recognized));
-    }
-
-    @Override
-    public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
-        mIcon.setImageResource(R.drawable.ic_fingerprint_success);
-        mCallback.onAuthenticated();
-    }
-
-    private void showError(CharSequence error) {
-        if (!isListening()) {
-            return;
-        }
-
-        mIcon.setImageResource(R.drawable.ic_fingerprint_error);
-        mErrorTextView.setText(error);
-        mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
-        mErrorTextView.postDelayed(mResetErrorTextRunnable, ERROR_TIMEOUT);
-    }
-
-    private Runnable mResetErrorTextRunnable = new Runnable() {
-        @Override
-        public void run() {
-            mErrorTextView.setText("");
-            mIcon.setImageResource(R.drawable.ic_fingerprint);
-        }
-    };
-
-    public interface Callback {
-        void onAuthenticated();
-        void onFingerprintIconVisibilityChanged(boolean visible);
-    }
-}
diff --git a/src/com/android/settings/development/ClearAdbKeysPreferenceController.java b/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
index ce23e3f..e1fda67 100644
--- a/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
+++ b/src/com/android/settings/development/ClearAdbKeysPreferenceController.java
@@ -17,7 +17,7 @@
 package com.android.settings.development;
 
 import android.content.Context;
-import android.hardware.usb.IUsbManager;
+import android.debug.IAdbManager;
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.SystemProperties;
@@ -42,7 +42,7 @@
     @VisibleForTesting
     static final String RO_ADB_SECURE_PROPERTY_KEY = "ro.adb.secure";
 
-    private final IUsbManager mUsbManager;
+    private final IAdbManager mAdbManager;
     private final DevelopmentSettingsDashboardFragment mFragment;
 
     public ClearAdbKeysPreferenceController(Context context,
@@ -50,7 +50,7 @@
         super(context);
 
         mFragment = fragment;
-        mUsbManager = IUsbManager.Stub.asInterface(ServiceManager.getService(Context.USB_SERVICE));
+        mAdbManager = IAdbManager.Stub.asInterface(ServiceManager.getService(Context.ADB_SERVICE));
     }
 
     @Override
@@ -94,7 +94,7 @@
 
     public void onClearAdbKeysConfirmed() {
         try {
-            mUsbManager.clearUsbDebuggingKeys();
+            mAdbManager.clearDebuggingKeys();
         } catch (RemoteException e) {
             Log.e(TAG, "Unable to clear adb keys", e);
         }
diff --git a/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java b/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
index 83a6af5..54cd82f 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
@@ -95,8 +95,6 @@
     private static final Comparator<CachedBluetoothDevice> COMPARATOR
             = Comparator.naturalOrder();
 
-    private static final int DEFAULT_EXPANDED_ROW_COUNT = 4;
-
     private static final String TAG = "ConnectedDeviceSlice";
 
     private final Context mContext;
@@ -162,13 +160,6 @@
         for (ListBuilder.RowBuilder rowBuilder : rows) {
             listBuilder.addRow(rowBuilder);
         }
-
-        // Only show "see more" button when the number of data row is more than or equal to 4.
-        // TODO(b/118465996): SHOW MORE button won't work properly when having two data rows
-        if (rows.size() >= DEFAULT_EXPANDED_ROW_COUNT) {
-            listBuilder.setSeeMoreAction(primaryActionIntent);
-        }
-
         return listBuilder.build();
     }
 
diff --git a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
index fabe295..f920fdc 100644
--- a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
+++ b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
@@ -23,7 +23,6 @@
     @Override
     public boolean isAvailable() {
         return Settings.Global.getInt(mContext.getContentResolver(),
-                android.provider.Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 1)
-                == 1;
+                Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 1) == 1;
     }
 }
diff --git a/src/com/android/settings/network/telephony/CarrierPreferenceController.java b/src/com/android/settings/network/telephony/CarrierPreferenceController.java
index 406ef7b..8210c4b 100644
--- a/src/com/android/settings/network/telephony/CarrierPreferenceController.java
+++ b/src/com/android/settings/network/telephony/CarrierPreferenceController.java
@@ -37,6 +37,7 @@
 
     public CarrierPreferenceController(Context context, String key) {
         super(context, key);
+        mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
         mCarrierConfigManager = new CarrierConfigManager(context);
         mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
     }
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index 065f182..b1124f8 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -59,6 +59,7 @@
 
     public MobileDataPreferenceController(Context context, String key) {
         super(context, key);
+        mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
         mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
         mDataContentObserver = new DataContentObserver(new Handler(Looper.getMainLooper()));
         mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index f397382..e85c917 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -82,7 +82,7 @@
      * Returns true if Wifi calling is enabled for at least one phone.
      */
     public static boolean isWifiCallingEnabled(Context context) {
-        int phoneCount = TelephonyManager.from(context).getPhoneCount();
+        int phoneCount = context.getSystemService(TelephonyManager.class).getPhoneCount();
         for (int i = 0; i < phoneCount; i++) {
             if (isWifiCallingEnabled(context, i)) {
                 return true;
@@ -218,7 +218,7 @@
      */
     public static void setMobileDataEnabled(Context context, int subId, boolean enabled,
             boolean disableOtherSubscriptions) {
-        final TelephonyManager telephonyManager = TelephonyManager.from(context)
+        final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
                 .createForSubscriptionId(subId);
         final SubscriptionManager subscriptionManager = context.getSystemService(
                 SubscriptionManager.class);
@@ -230,7 +230,7 @@
             if (subInfoList != null) {
                 for (SubscriptionInfo subInfo : subInfoList) {
                     if (subInfo.getSubscriptionId() != subId) {
-                        TelephonyManager.from(context).createForSubscriptionId(
+                        context.getSystemService(TelephonyManager.class).createForSubscriptionId(
                                 subInfo.getSubscriptionId()).setDataEnabled(false);
                     }
                 }
@@ -245,7 +245,7 @@
         if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             return false;
         }
-        final TelephonyManager telephonyManager = TelephonyManager.from(context)
+        final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
                 .createForSubscriptionId(subId);
         final PersistableBundle carrierConfig = context.getSystemService(
                 CarrierConfigManager.class).getConfigForSubId(subId);
@@ -307,7 +307,7 @@
     }
 
     private static boolean isGsmBasicOptions(Context context, int subId) {
-        final TelephonyManager telephonyManager = TelephonyManager.from(context)
+        final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
                 .createForSubscriptionId(subId);
         final PersistableBundle carrierConfig = context.getSystemService(
                 CarrierConfigManager.class).getConfigForSubId(subId);
@@ -329,7 +329,7 @@
      * settings
      */
     public static boolean isWorldMode(Context context, int subId) {
-        final TelephonyManager telephonyManager = TelephonyManager.from(context)
+        final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
                 .createForSubscriptionId(subId);
         boolean worldModeOn = false;
         final String configString = context.getString(R.string.config_world_mode);
@@ -392,7 +392,7 @@
             Context con = context.createPackageContext("com.android.systemui", 0);
             int id = con.getResources().getIdentifier("config_show4GForLTE",
                     "bool", "com.android.systemui");
-             return con.getResources().getBoolean(id);
+            return con.getResources().getBoolean(id);
         } catch (PackageManager.NameNotFoundException e) {
             Log.e(TAG, "NameNotFoundException for show4GFotLTE");
             return false;
@@ -404,7 +404,7 @@
      */
     public static boolean isTdscdmaSupported(Context context, int subId) {
         return isTdscdmaSupported(context,
-                TelephonyManager.from(context).createForSubscriptionId(subId));
+                context.getSystemService(TelephonyManager.class).createForSubscriptionId(subId));
     }
 
     //TODO(b/117651939): move it to telephony
diff --git a/src/com/android/settings/network/telephony/RoamingPreferenceController.java b/src/com/android/settings/network/telephony/RoamingPreferenceController.java
index b2eba08..688268c 100644
--- a/src/com/android/settings/network/telephony/RoamingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/RoamingPreferenceController.java
@@ -59,6 +59,7 @@
 
     public RoamingPreferenceController(Context context, String key) {
         super(context, key);
+        mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
         mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
         mDataContentObserver = new DataContentObserver(new Handler(Looper.getMainLooper()));
         mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
index 6258f9d..a5498bc 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
@@ -22,6 +22,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.provider.Settings;
+import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 
 import androidx.preference.Preference;
@@ -48,6 +49,7 @@
 
     public CdmaBasePreferenceController(Context context, String key) {
         super(context, key);
+        mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
         mDataContentObserver = new DataContentObserver(new Handler(Looper.getMainLooper()));
     }
 
diff --git a/src/com/android/settings/notification/NotificationPreferenceController.java b/src/com/android/settings/notification/NotificationPreferenceController.java
index c3552cc..22f07be 100644
--- a/src/com/android/settings/notification/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/NotificationPreferenceController.java
@@ -28,7 +28,6 @@
 import android.util.Log;
 
 import androidx.preference.Preference;
-import androidx.preference.PreferenceGroup;
 
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -83,24 +82,6 @@
         return true;
     }
 
-    // finds the preference recursively and removes it from its parent
-    private void findAndRemovePreference(PreferenceGroup prefGroup, String key) {
-        final int preferenceCount = prefGroup.getPreferenceCount();
-        for (int i = preferenceCount - 1; i >= 0; i--) {
-            final Preference preference = prefGroup.getPreference(i);
-            final String curKey = preference.getKey();
-
-            if (curKey != null && curKey.equals(key)) {
-                mPreference = preference;
-                prefGroup.removePreference(preference);
-            }
-
-            if (preference instanceof PreferenceGroup) {
-                findAndRemovePreference((PreferenceGroup) preference, key);
-            }
-        }
-    }
-
     protected void onResume(NotificationBackend.AppRow appRow,
             @Nullable NotificationChannel channel, @Nullable NotificationChannelGroup group,
             RestrictedLockUtils.EnforcedAdmin admin) {
diff --git a/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java b/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java
index 96495df..67d9e93 100644
--- a/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeAlarmsPreferenceController.java
@@ -21,19 +21,20 @@
 import android.provider.Settings;
 import android.util.Log;
 
-import androidx.preference.Preference;
-import androidx.preference.SwitchPreference;
-
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
 public class ZenModeAlarmsPreferenceController extends
         AbstractZenModePreferenceController implements Preference.OnPreferenceChangeListener {
 
-    protected static final String KEY = "zen_mode_alarms";
+    private final String KEY;
 
-    public ZenModeAlarmsPreferenceController(Context context, Lifecycle lifecycle) {
-        super(context, KEY, lifecycle);
+    public ZenModeAlarmsPreferenceController(Context context, Lifecycle lifecycle, String key) {
+        super(context, key, lifecycle);
+        KEY = key;
     }
 
     @Override
diff --git a/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java
deleted file mode 100644
index 0dba4d6..0000000
--- a/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceController.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class ZenModeBehaviorCallsPreferenceController extends
-        AbstractZenModePreferenceController implements PreferenceControllerMixin {
-
-    protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_calls_settings";
-    private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
-
-    public ZenModeBehaviorCallsPreferenceController(Context context, Lifecycle lifecycle) {
-        super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
-        mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return KEY_BEHAVIOR_SETTINGS;
-    }
-
-    @Override
-    public boolean isAvailable() {
-        return true;
-    }
-
-    @Override
-    public void updateState(Preference preference) {
-        super.updateState(preference);
-
-        preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
-    }
-}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java
deleted file mode 100644
index 2046244..0000000
--- a/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceController.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class ZenModeBehaviorMsgEventReminderPreferenceController extends
-        AbstractZenModePreferenceController implements PreferenceControllerMixin {
-
-    protected static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_msg_event_reminder_settings";
-    private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
-
-    public ZenModeBehaviorMsgEventReminderPreferenceController(Context context,
-            Lifecycle lifecycle) {
-        super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
-        mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return KEY_BEHAVIOR_SETTINGS;
-    }
-
-    @Override
-    public boolean isAvailable() {
-        return true;
-    }
-
-    @Override
-    public void updateState(Preference preference) {
-        super.updateState(preference);
-
-        preference.setSummary(mSummaryBuilder.getMsgEventReminderSettingSummary(getPolicy()));
-    }
-}
diff --git a/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java b/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java
deleted file mode 100644
index 425f770..0000000
--- a/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceController.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class ZenModeBehaviorSoundPreferenceController extends
-        AbstractZenModePreferenceController implements PreferenceControllerMixin {
-
-    protected static final String KEY_BEHAVIOR_SETTINGS = "zen_sound_vibration_settings";
-    private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
-
-    public ZenModeBehaviorSoundPreferenceController(Context context, Lifecycle lifecycle) {
-        super(context, KEY_BEHAVIOR_SETTINGS, lifecycle);
-        mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return KEY_BEHAVIOR_SETTINGS;
-    }
-
-    @Override
-    public boolean isAvailable() {
-        return true;
-    }
-
-    @Override
-    public void updateState(Preference preference) {
-        super.updateState(preference);
-
-        preference.setSummary(mSummaryBuilder.getSoundSettingSummary(getPolicy()));
-    }
-}
diff --git a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
index 3f689d7..5bacafb 100644
--- a/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeCallsPreferenceController.java
@@ -16,36 +16,29 @@
 
 package com.android.settings.notification;
 
-import android.app.NotificationManager;
 import android.content.Context;
-import android.provider.Settings;
-import android.text.TextUtils;
 
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.ListPreference;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
-public class ZenModeCallsPreferenceController extends AbstractZenModePreferenceController implements
-        Preference.OnPreferenceChangeListener {
+import androidx.preference.Preference;
 
-    protected static final String KEY = "zen_mode_calls";
-    private final ZenModeBackend mBackend;
-    private ListPreference mPreference;
-    private final String[] mListValues;
+public class ZenModeCallsPreferenceController extends
+        AbstractZenModePreferenceController implements PreferenceControllerMixin {
 
-    public ZenModeCallsPreferenceController(Context context, Lifecycle lifecycle) {
-        super(context, KEY, lifecycle);
-        mBackend = ZenModeBackend.getInstance(context);
-        mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+    private final String KEY_BEHAVIOR_SETTINGS;
+    private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
+
+    public ZenModeCallsPreferenceController(Context context, Lifecycle lifecycle,
+            String key) {
+        super(context, key, lifecycle);
+        KEY_BEHAVIOR_SETTINGS = key;
+        mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
     }
 
     @Override
     public String getPreferenceKey() {
-        return KEY;
+        return KEY_BEHAVIOR_SETTINGS;
     }
 
     @Override
@@ -54,54 +47,9 @@
     }
 
     @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mPreference = (ListPreference) screen.findPreference(KEY);
-    }
-
-    @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
-        updateFromContactsValue(preference);
-    }
 
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
-        mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS,
-                ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
-        updateFromContactsValue(preference);
-        return true;
-    }
-
-    private void updateFromContactsValue(Preference preference) {
-        mPreference = (ListPreference) preference;
-        switch (getZenMode()) {
-            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
-            case Settings.Global.ZEN_MODE_ALARMS:
-                mPreference.setEnabled(false);
-                mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
-                mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
-                break;
-            default:
-                preference.setEnabled(true);
-                preference.setSummary(mBackend.getContactsSummary(
-                        NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
-
-                final String currentVal = ZenModeBackend.getKeyFromSetting(
-                        mBackend.getPriorityCallSenders());
-                mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
-        }
-    }
-
-    @VisibleForTesting
-    protected int getIndexOfSendersValue(String currentVal) {
-        int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
-        for (int i = 0; i < mListValues.length; i++) {
-            if (TextUtils.equals(currentVal, mListValues[i])) {
-                return i;
-            }
-        }
-
-        return index;
+        preference.setSummary(mSummaryBuilder.getCallsSettingSummary(getPolicy()));
     }
 }
diff --git a/src/com/android/settings/notification/ZenModeCallsSettings.java b/src/com/android/settings/notification/ZenModeCallsSettings.java
index 6ba53b5..fa77bb0 100644
--- a/src/com/android/settings/notification/ZenModeCallsSettings.java
+++ b/src/com/android/settings/notification/ZenModeCallsSettings.java
@@ -43,7 +43,7 @@
     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
             Lifecycle lifecycle) {
         List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new ZenModeCallsPreferenceController(context, lifecycle));
+        controllers.add(new ZenModePriorityCallsPreferenceController(context, lifecycle));
         controllers.add(new ZenModeStarredContactsPreferenceController(context, lifecycle,
                 PRIORITY_CATEGORY_CALLS, "zen_mode_starred_contacts_callers"));
         controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
diff --git a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
index 321d94e..19ee809 100644
--- a/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeMessagesPreferenceController.java
@@ -1,31 +1,38 @@
+/*
+ * 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.notification;
 
-import android.app.NotificationManager;
 import android.content.Context;
-import android.provider.Settings;
-import android.text.TextUtils;
 
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.ListPreference;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
-public class ZenModeMessagesPreferenceController extends AbstractZenModePreferenceController
-        implements Preference.OnPreferenceChangeListener {
+import androidx.preference.Preference;
 
-    protected static final String KEY = "zen_mode_messages";
+public class ZenModeMessagesPreferenceController extends
+        AbstractZenModePreferenceController implements PreferenceControllerMixin {
 
-    private final ZenModeBackend mBackend;
-    private ListPreference mPreference;
-    private final String[] mListValues;
+    private final String KEY;
+    private final ZenModeSettings.SummaryBuilder mSummaryBuilder;
 
-    public ZenModeMessagesPreferenceController(Context context, Lifecycle lifecycle) {
-        super(context, KEY, lifecycle);
-        mBackend = ZenModeBackend.getInstance(context);
-        mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+    public ZenModeMessagesPreferenceController(Context context, Lifecycle lifecycle, String key) {
+        super(context, key, lifecycle);
+        KEY = key;
+        mSummaryBuilder = new ZenModeSettings.SummaryBuilder(context);
     }
 
     @Override
@@ -39,54 +46,8 @@
     }
 
     @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mPreference = (ListPreference) screen.findPreference(KEY);
-    }
-
-    @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
-        updateFromContactsValue(preference);
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
-        mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES,
-                ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
-        updateFromContactsValue(preference);
-        return true;
-    }
-
-    private void updateFromContactsValue(Preference preference) {
-        mPreference = (ListPreference) preference;
-        switch (getZenMode()) {
-            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
-            case Settings.Global.ZEN_MODE_ALARMS:
-                mPreference.setEnabled(false);
-                mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
-                mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
-                break;
-            default:
-                preference.setEnabled(true);
-                preference.setSummary(mBackend.getContactsSummary(
-                        NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
-
-                final String currentVal = ZenModeBackend.getKeyFromSetting(
-                        mBackend.getPriorityMessageSenders());
-                mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
-        }
-    }
-
-    @VisibleForTesting
-    protected int getIndexOfSendersValue(String currentVal) {
-        int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
-        for (int i = 0; i < mListValues.length; i++) {
-            if (TextUtils.equals(currentVal, mListValues[i])) {
-                return i;
-            }
-        }
-
-        return index;
+        // TODO: (b/111475013 - beverlyt) set messages summary
     }
 }
diff --git a/src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java b/src/com/android/settings/notification/ZenModeMessagesSettings.java
similarity index 75%
rename from src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java
rename to src/com/android/settings/notification/ZenModeMessagesSettings.java
index 0e6747a..e09d583 100644
--- a/src/com/android/settings/notification/ZenModeMsgEventReminderSettings.java
+++ b/src/com/android/settings/notification/ZenModeMessagesSettings.java
@@ -33,7 +33,7 @@
 import java.util.List;
 
 @SearchIndexable
-public class ZenModeMsgEventReminderSettings extends ZenModeSettingsBase implements Indexable {
+public class ZenModeMessagesSettings extends ZenModeSettingsBase implements Indexable {
 
     @Override
     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
@@ -43,19 +43,17 @@
     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
             Lifecycle lifecycle) {
         List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
-        controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
-        controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle));
+        controllers.add(new ZenModePriorityMessagesPreferenceController(context, lifecycle));
         controllers.add(new ZenModeStarredContactsPreferenceController(context, lifecycle,
                 PRIORITY_CATEGORY_MESSAGES, "zen_mode_starred_contacts_messages"));
-        controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
-                R.string.zen_msg_event_reminder_footer));
+        controllers.add(new ZenModeBehaviorFooterPreferenceController(
+                context, lifecycle, R.string.zen_mode_messages_footer));
         return controllers;
     }
 
     @Override
     protected int getPreferenceScreenResId() {
-        return R.xml.zen_mode_msg_event_reminder_settings;
+        return R.xml.zen_mode_messages_settings;
     }
 
     @Override
@@ -66,7 +64,7 @@
     /**
      * For Search.
      */
-    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
 
                 @Override
@@ -75,14 +73,15 @@
                     final ArrayList<SearchIndexableResource> result = new ArrayList<>();
 
                     final SearchIndexableResource sir = new SearchIndexableResource(context);
-                    sir.xmlResId = R.xml.zen_mode_msg_event_reminder_settings;
+                    sir.xmlResId = R.xml.zen_mode_messages_settings;
                     result.add(sir);
                     return result;
                 }
 
-            @Override
-            public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-                return buildPreferenceControllers(context, null);
-            }
-        };
+                @Override
+                public List<AbstractPreferenceController> createPreferenceControllers(
+                        Context context) {
+                    return buildPreferenceControllers(context, null);
+                }
+            };
 }
diff --git a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
new file mode 100644
index 0000000..44b6c24
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
@@ -0,0 +1,107 @@
+/*
+ * 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.notification;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+public class ZenModePriorityCallsPreferenceController extends AbstractZenModePreferenceController
+        implements Preference.OnPreferenceChangeListener {
+
+    protected static final String KEY = "zen_mode_calls";
+    private final ZenModeBackend mBackend;
+    private ListPreference mPreference;
+    private final String[] mListValues;
+
+    public ZenModePriorityCallsPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context, KEY, lifecycle);
+        mBackend = ZenModeBackend.getInstance(context);
+        mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = (ListPreference) screen.findPreference(KEY);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        updateFromContactsValue(preference);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
+        mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS,
+                ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
+        updateFromContactsValue(preference);
+        return true;
+    }
+
+    private void updateFromContactsValue(Preference preference) {
+        mPreference = (ListPreference) preference;
+        switch (getZenMode()) {
+            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+            case Settings.Global.ZEN_MODE_ALARMS:
+                mPreference.setEnabled(false);
+                mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
+                mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
+                break;
+            default:
+                preference.setEnabled(true);
+                preference.setSummary(mBackend.getContactsSummary(
+                        NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
+
+                final String currentVal = ZenModeBackend.getKeyFromSetting(
+                        mBackend.getPriorityCallSenders());
+                mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
+        }
+    }
+
+    @VisibleForTesting
+    protected int getIndexOfSendersValue(String currentVal) {
+        int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
+        for (int i = 0; i < mListValues.length; i++) {
+            if (TextUtils.equals(currentVal, mListValues[i])) {
+                return i;
+            }
+        }
+
+        return index;
+    }
+}
diff --git a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
new file mode 100644
index 0000000..56829a7
--- /dev/null
+++ b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
@@ -0,0 +1,107 @@
+/*
+ * 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.notification;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+public class ZenModePriorityMessagesPreferenceController extends AbstractZenModePreferenceController
+        implements Preference.OnPreferenceChangeListener {
+
+    protected static final String KEY = "zen_mode_messages";
+    private final ZenModeBackend mBackend;
+    private ListPreference mPreference;
+    private final String[] mListValues;
+
+    public ZenModePriorityMessagesPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context, KEY, lifecycle);
+        mBackend = ZenModeBackend.getInstance(context);
+        mListValues = context.getResources().getStringArray(R.array.zen_mode_contacts_values);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = (ListPreference) screen.findPreference(KEY);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        updateFromContactsValue(preference);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
+        mBackend.saveSenders(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES,
+                ZenModeBackend.getSettingFromPrefKey(selectedContactsFrom.toString()));
+        updateFromContactsValue(preference);
+        return true;
+    }
+
+    private void updateFromContactsValue(Preference preference) {
+        mPreference = (ListPreference) preference;
+        switch (getZenMode()) {
+            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+            case Settings.Global.ZEN_MODE_ALARMS:
+                mPreference.setEnabled(false);
+                mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
+                mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
+                break;
+            default:
+                preference.setEnabled(true);
+                preference.setSummary(mBackend.getContactsSummary(
+                        NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
+
+                final String currentVal = ZenModeBackend.getKeyFromSetting(
+                        mBackend.getPriorityMessageSenders());
+                mPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
+        }
+    }
+
+    @VisibleForTesting
+    protected int getIndexOfSendersValue(String currentVal) {
+        int index = 3; // defaults to "none" based on R.array.zen_mode_contacts_values
+        for (int i = 0; i < mListValues.length; i++) {
+            if (TextUtils.equals(currentVal, mListValues[i])) {
+                return i;
+            }
+        }
+
+        return index;
+    }
+}
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 9cd3107..3a270d2 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -82,9 +82,12 @@
     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
             Lifecycle lifecycle, FragmentManager fragmentManager) {
         List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new ZenModeBehaviorMsgEventReminderPreferenceController(context, lifecycle));
-        controllers.add(new ZenModeBehaviorSoundPreferenceController(context, lifecycle));
-        controllers.add(new ZenModeBehaviorCallsPreferenceController(context, lifecycle));
+        controllers.add(new ZenModeCallsPreferenceController(context, lifecycle,
+                "zen_mode_behavior_calls"));
+        controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
+                "zen_mode_behavior_messages"));
+        controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
+                "zen_mode_behavior_alarms"));
         controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
         controllers.add(new ZenModeDurationPreferenceController(context, lifecycle));
         controllers.add(new ZenModeAutomationPreferenceController(context));
diff --git a/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java b/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
index 32ff2d1..df92446 100644
--- a/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
+++ b/src/com/android/settings/notification/ZenModeSoundVibrationSettings.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.notification;
 
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+
 import android.content.Context;
 import android.provider.SearchIndexableResource;
 
@@ -41,9 +43,16 @@
     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
             Lifecycle lifecycle) {
         List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle));
+        controllers.add(new ZenModeCallsPreferenceController(context, lifecycle,
+                "zen_mode_calls_settings"));
+        controllers.add(new ZenModeMessagesPreferenceController(context, lifecycle,
+                "zen_mode_messages_settings"));
+        controllers.add(new ZenModeAlarmsPreferenceController(context, lifecycle,
+                "zen_mode_alarms"));
         controllers.add(new ZenModeMediaPreferenceController(context, lifecycle));
         controllers.add(new ZenModeSystemPreferenceController(context, lifecycle));
+        controllers.add(new ZenModeRemindersPreferenceController(context, lifecycle));
+        controllers.add(new ZenModeEventsPreferenceController(context, lifecycle));
         controllers.add(new ZenModeBehaviorFooterPreferenceController(context, lifecycle,
                 R.string.zen_sound_footer));
         return controllers;
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
new file mode 100644
index 0000000..6e1ae10
--- /dev/null
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -0,0 +1,198 @@
+/*
+ * 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.password;
+
+import android.app.settings.SettingsEnums;
+import android.content.DialogInterface;
+import android.hardware.biometrics.BiometricConstants;
+import android.hardware.biometrics.BiometricPrompt;
+import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
+import android.hardware.biometrics.BiometricPrompt.AuthenticationResult;
+import android.os.Bundle;
+import android.os.CancellationSignal;
+import android.os.Handler;
+import android.os.Looper;
+
+import com.android.settings.core.InstrumentedFragment;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import java.util.concurrent.Executor;
+
+/**
+ * A fragment that wraps the BiometricPrompt and manages its lifecycle.
+ */
+public class BiometricFragment extends InstrumentedFragment {
+
+    private static final String KEY_TITLE = "title";
+    private static final String KEY_SUBTITLE = "subtitle";
+    private static final String KEY_DESCRIPTION = "description";
+    private static final String KEY_NEGATIVE_TEXT = "negative_text";
+
+    // Re-set by the application. Should be done upon orientation changes, etc
+    private Executor mClientExecutor;
+    private AuthenticationCallback mClientCallback;
+
+    // Created/Initialized once and retained
+    private final Handler mHandler = new Handler(Looper.getMainLooper());
+    private PromptInfo mPromptInfo;
+    private BiometricPrompt mBiometricPrompt;
+    private CancellationSignal mCancellationSignal;
+
+    private AuthenticationCallback mAuthenticationCallback =
+            new AuthenticationCallback() {
+        @Override
+        public void onAuthenticationError(int error, @NonNull CharSequence message) {
+            mClientExecutor.execute(() -> {
+                mClientCallback.onAuthenticationError(error, message);
+            });
+            cleanup();
+        }
+
+        @Override
+        public void onAuthenticationSucceeded(AuthenticationResult result) {
+            mClientExecutor.execute(() -> {
+                mClientCallback.onAuthenticationSucceeded(result);
+            });
+            cleanup();
+        }
+    };
+
+    private final DialogInterface.OnClickListener mNegativeButtonListener =
+            new DialogInterface.OnClickListener() {
+        @Override
+        public void onClick(DialogInterface dialog, int which) {
+            mAuthenticationCallback.onAuthenticationError(
+                    BiometricConstants.BIOMETRIC_ERROR_NEGATIVE_BUTTON,
+                    mPromptInfo.getNegativeButtonText());
+        }
+    };
+
+    public static BiometricFragment newInstance(PromptInfo info) {
+        BiometricFragment biometricFragment = new BiometricFragment();
+        biometricFragment.setArguments(info.getBundle());
+        return biometricFragment;
+    }
+
+    public void setCallbacks(Executor executor, AuthenticationCallback callback) {
+        mClientExecutor = executor;
+        mClientCallback = callback;
+    }
+
+    public void cancel() {
+        if (mCancellationSignal != null) {
+            mCancellationSignal.cancel();
+        }
+        cleanup();
+    }
+
+    private void cleanup() {
+        if (getActivity() != null) {
+            getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
+        }
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setRetainInstance(true);
+
+        mPromptInfo = new PromptInfo(getArguments());
+        mBiometricPrompt = new BiometricPrompt.Builder(getContext())
+            .setTitle(mPromptInfo.getTitle())
+            .setUseDefaultTitle() // use default title if title is null/empty
+            .setSubtitle(mPromptInfo.getSubtitle())
+            .setDescription(mPromptInfo.getDescription())
+            .setNegativeButton(mPromptInfo.getNegativeButtonText(), mClientExecutor,
+                    mNegativeButtonListener)
+            .build();
+        mCancellationSignal = new CancellationSignal();
+
+        // TODO: CC doesn't use crypto for now
+        mBiometricPrompt.authenticate(mCancellationSignal, mClientExecutor,
+                mAuthenticationCallback);
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.BIOMETRIC_FRAGMENT;
+    }
+
+    /**
+     * A simple wrapper for BiometricPrompt.PromptInfo. Since we want to manage the lifecycle
+     * of BiometricPrompt correctly, the information needs to be stored in here.
+     */
+    static class PromptInfo {
+        private final Bundle mBundle;
+
+        private PromptInfo(Bundle bundle) {
+            mBundle = bundle;
+        }
+
+        Bundle getBundle() {
+            return mBundle;
+        }
+
+        public CharSequence getTitle() {
+            return mBundle.getCharSequence(KEY_TITLE);
+        }
+
+        public CharSequence getSubtitle() {
+            return mBundle.getCharSequence(KEY_SUBTITLE);
+        }
+
+        public CharSequence getDescription() {
+            return mBundle.getCharSequence(KEY_DESCRIPTION);
+        }
+
+        public CharSequence getNegativeButtonText() {
+            return mBundle.getCharSequence(KEY_NEGATIVE_TEXT);
+        }
+
+        public static class Builder {
+            private final Bundle mBundle = new Bundle();
+
+            public Builder setTitle(@NonNull CharSequence title) {
+                mBundle.putCharSequence(KEY_TITLE, title);
+                return this;
+            }
+
+            public Builder setSubtitle(@Nullable CharSequence subtitle) {
+                mBundle.putCharSequence(KEY_SUBTITLE, subtitle);
+                return this;
+            }
+
+            public Builder setDescription(@Nullable CharSequence description) {
+                mBundle.putCharSequence(KEY_DESCRIPTION, description);
+                return this;
+            }
+
+            public Builder setNegativeButtonText(@NonNull CharSequence text) {
+                mBundle.putCharSequence(KEY_NEGATIVE_TEXT, text);
+                return this;
+            }
+
+            public PromptInfo build() {
+                return new PromptInfo(mBundle);
+            }
+        }
+    }
+}
+
diff --git a/src/com/android/settings/password/ChooseLockSettingsHelper.java b/src/com/android/settings/password/ChooseLockSettingsHelper.java
index 3c83f07..d5182b3 100644
--- a/src/com/android/settings/password/ChooseLockSettingsHelper.java
+++ b/src/com/android/settings/password/ChooseLockSettingsHelper.java
@@ -78,7 +78,13 @@
      * @see Activity#onActivityResult(int, int, android.content.Intent)
      */
     public boolean launchConfirmationActivity(int request, CharSequence title) {
-        return launchConfirmationActivity(request, title, null, null, false, false);
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                null /* header */,
+                null /* description */,
+                false /* returnCredentials */,
+                false /* external */);
     }
 
     /**
@@ -91,7 +97,13 @@
      * @see Activity#onActivityResult(int, int, android.content.Intent)
      */
     public boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials) {
-        return launchConfirmationActivity(request, title, null, null, returnCredentials, false);
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                null /* header */,
+                null /* description */,
+                returnCredentials /* returnCredentials */,
+                false /* external */);
     }
 
     /**
@@ -106,8 +118,16 @@
      */
     public boolean launchConfirmationActivity(int request, CharSequence title,
             boolean returnCredentials, int userId) {
-        return launchConfirmationActivity(request, title, null, null,
-                returnCredentials, false, false, 0, Utils.enforceSameOwner(mActivity, userId));
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                null /* header */,
+                null /* description */,
+                returnCredentials /* returnCredentials */,
+                false /* external */,
+                false /* hasChallenge */,
+                0 /* challenge */,
+                Utils.enforceSameOwner(mActivity, userId) /* userId */);
     }
 
     /**
@@ -127,8 +147,16 @@
     boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             boolean returnCredentials, boolean external) {
-        return launchConfirmationActivity(request, title, header, description,
-                returnCredentials, external, false, 0, Utils.getCredentialOwnerUserId(mActivity));
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                returnCredentials /* returnCredentials */,
+                external /* external */,
+                false /* hasChallenge */,
+                0 /* challenge */,
+                Utils.getCredentialOwnerUserId(mActivity) /* userId */);
     }
 
     /**
@@ -149,8 +177,16 @@
     boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             boolean returnCredentials, boolean external, int userId) {
-        return launchConfirmationActivity(request, title, header, description,
-                returnCredentials, external, false, 0, Utils.enforceSameOwner(mActivity, userId));
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                returnCredentials /* returnCredentials */,
+                external /* external */,
+                false /* hasChallenge */,
+                0 /* challenge */,
+                Utils.enforceSameOwner(mActivity, userId) /* userId */);
     }
 
     /**
@@ -166,8 +202,16 @@
     public boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             long challenge) {
-        return launchConfirmationActivity(request, title, header, description,
-                true, false, true, challenge, Utils.getCredentialOwnerUserId(mActivity));
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                true /* returnCredentials */,
+                false /* external */,
+                true /* hasChallenge */,
+                challenge /* challenge */,
+                Utils.getCredentialOwnerUserId(mActivity) /* userId */);
     }
 
     /**
@@ -184,8 +228,16 @@
     public boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             long challenge, int userId) {
-        return launchConfirmationActivity(request, title, header, description,
-                true, false, true, challenge, Utils.enforceSameOwner(mActivity, userId));
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                true /* returnCredentials */,
+                false /* external */,
+                true /* hasChallenge */,
+                challenge /* challenge */,
+                Utils.enforceSameOwner(mActivity, userId) /* userId */);
     }
 
     /**
@@ -205,8 +257,16 @@
     public boolean launchConfirmationActivityWithExternalAndChallenge(int request,
             @Nullable CharSequence title, @Nullable CharSequence header,
             @Nullable CharSequence description, boolean external, long challenge, int userId) {
-        return launchConfirmationActivity(request, title, header, description, false,
-                external, true, challenge, Utils.enforceSameOwner(mActivity, userId));
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                false /* returnCredentials */,
+                external /* external */,
+                true /* hasChallenge */,
+                challenge /* challenge */,
+                Utils.enforceSameOwner(mActivity, userId) /* userId */);
     }
 
     /**
@@ -219,31 +279,69 @@
             @Nullable CharSequence description, int userId) {
         final Bundle extras = new Bundle();
         extras.putBoolean(EXTRA_ALLOW_ANY_USER, true);
-        return launchConfirmationActivity(request, title, header, description, false,
-                false, true, 0, userId, extras);
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                false /* returnCredentials */,
+                false /* external */,
+                true /* hasChallenge */,
+                0 /* challenge */,
+                userId /* userId */,
+                extras /* extras */);
     }
 
     private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             boolean returnCredentials, boolean external, boolean hasChallenge,
             long challenge, int userId) {
-        return launchConfirmationActivity(request, title, header, description, returnCredentials,
-                external, hasChallenge, challenge, userId, null /* alternateButton */, null);
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                returnCredentials /* returnCredentials */,
+                external /* external */,
+                hasChallenge /* hasChallenge */,
+                challenge /* challenge */,
+                userId /* userId */,
+                null /* alternateButton */,
+                null /* extras */);
     }
 
     private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
             @Nullable CharSequence header, @Nullable CharSequence description,
             boolean returnCredentials, boolean external, boolean hasChallenge,
             long challenge, int userId, Bundle extras) {
-        return launchConfirmationActivity(request, title, header, description, returnCredentials,
-                external, hasChallenge, challenge, userId, null /* alternateButton */, extras);
+        return launchConfirmationActivity(
+                request /* request */,
+                title /* title */,
+                header /* header */,
+                description /* description */,
+                returnCredentials /* returnCredentials */,
+                external /* external */,
+                hasChallenge /* hasChallenge */,
+                challenge /* challenge */,
+                userId /* userId */,
+                null /* alternateButton */,
+                extras /* extras */);
     }
 
     public boolean launchFrpConfirmationActivity(int request, @Nullable CharSequence header,
             @Nullable CharSequence description, @Nullable CharSequence alternateButton) {
-        return launchConfirmationActivity(request, null /* title */, header, description,
-                false /* returnCredentials */, true /* external */, false /* hasChallenge */,
-                0 /* challenge */, LockPatternUtils.USER_FRP, alternateButton, null);
+        return launchConfirmationActivity(
+                request /* request */,
+                null /* title */,
+                header /* header */,
+                description /* description */,
+                false /* returnCredentials */,
+                true /* external */,
+                false /* hasChallenge */,
+                0 /* challenge */,
+                LockPatternUtils.USER_FRP /* userId */,
+                alternateButton /* alternateButton */,
+                null /* extras */);
     }
 
     private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@@ -285,11 +383,11 @@
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title);
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header);
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.DETAILS_TEXT, message);
-        intent.putExtra(ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, external);
         // TODO: Remove dark theme and show_cancel_button options since they are no longer used
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false);
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_CANCEL_BUTTON, false);
         intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, external);
+        intent.putExtra(ConfirmDeviceCredentialBaseFragment.USE_FADE_ANIMATION, external);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_RETURN_CREDENTIALS, returnCredentials);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, hasChallenge);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index f5b3b05..f68c04a 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -22,21 +22,40 @@
 import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
+import android.hardware.biometrics.BiometricConstants;
+import android.hardware.biometrics.BiometricManager;
+import android.hardware.biometrics.BiometricPrompt;
+import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.util.Log;
 
+import androidx.annotation.NonNull;
+import androidx.fragment.app.FragmentActivity;
+
 import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
 import com.android.settings.Utils;
 
+import java.util.concurrent.Executor;
+
 /**
  * Launch this when you want to confirm the user is present by asking them to enter their
  * PIN/password/pattern.
  */
-public class ConfirmDeviceCredentialActivity extends Activity {
+public class ConfirmDeviceCredentialActivity extends FragmentActivity {
     public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
 
+    // The normal flow that apps go through
+    private static final int CREDENTIAL_NORMAL = 1;
+    // Unlocks the managed profile when the primary profile is unlocked
+    private static final int CREDENTIAL_MANAGED = 2;
+
+    private static final String TAG_BIOMETRIC_FRAGMENT = "fragment";
+
     public static class InternalActivity extends ConfirmDeviceCredentialActivity {
     }
 
@@ -60,57 +79,217 @@
         return intent;
     }
 
+    private BiometricManager mBiometricManager;
+    private BiometricFragment mBiometricFragment;
+    private DevicePolicyManager mDevicePolicyManager;
+    private LockPatternUtils mLockPatternUtils;
+    private UserManager mUserManager;
+    private ChooseLockSettingsHelper mChooseLockSettingsHelper;
+    private Handler mHandler = new Handler(Looper.getMainLooper());
+
+    private String mTitle;
+    private String mDetails;
+    private int mUserId;
+    private int mEffectiveUserId;
+    private int mCredentialMode;
+    private boolean mGoingToBackground;
+
+    private Executor mExecutor = (runnable -> {
+        mHandler.post(runnable);
+    });
+
+    private AuthenticationCallback mAuthenticationCallback = new AuthenticationCallback() {
+        public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
+            if (!mGoingToBackground) {
+                if (errorCode == BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED) {
+                    finish();
+                } else {
+                    // All other errors go to some version of CC
+                    showConfirmCredentials();
+                }
+            }
+
+        }
+
+        public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
+            setResult(Activity.RESULT_OK);
+            finish();
+        }
+    };
+
     @Override
-    public void onCreate(Bundle savedInstanceState) {
+    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        mBiometricManager = getSystemService(BiometricManager.class);
+        mDevicePolicyManager = getSystemService(DevicePolicyManager.class);
+        mUserManager = UserManager.get(this);
+        mLockPatternUtils = new LockPatternUtils(this);
+
         Intent intent = getIntent();
-        String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
-        String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
+        mTitle = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
+        mDetails = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
         String alternateButton = intent.getStringExtra(
                 KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL);
         boolean frp = KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction());
 
-        int userId = UserHandle.myUserId();
+        mUserId = UserHandle.myUserId();
+        mEffectiveUserId = mUserManager.getCredentialOwnerProfile(mUserId);
         if (isInternalActivity()) {
             try {
-                userId = Utils.getUserIdFromBundle(this, intent.getExtras());
+                mUserId = Utils.getUserIdFromBundle(this, intent.getExtras());
             } catch (SecurityException se) {
                 Log.e(TAG, "Invalid intent extra", se);
             }
         }
-        final boolean isManagedProfile = UserManager.get(this).isManagedProfile(userId);
+        final boolean isManagedProfile = UserManager.get(this).isManagedProfile(mUserId);
         // if the client app did not hand in a title and we are about to show the work challenge,
         // check whether there is a policy setting the organization name and use that as title
-        if ((title == null) && isManagedProfile) {
-            title = getTitleFromOrganizationName(userId);
+        if ((mTitle == null) && isManagedProfile) {
+            mTitle = getTitleFromOrganizationName(mUserId);
         }
-        ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);
+        mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
         final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
-        boolean launched;
+
+        boolean launchedBiometric = false;
+        boolean launchedCDC = false;
         // If the target is a managed user and user key not unlocked yet, we will force unlock
         // tied profile so it will enable work mode and unlock managed profile, when personal
         // challenge is unlocked.
         if (frp) {
-            launched = helper.launchFrpConfirmationActivity(0, title, details, alternateButton);
+            launchedCDC = mChooseLockSettingsHelper.launchFrpConfirmationActivity(
+                    0, mTitle, mDetails, alternateButton);
         } else if (isManagedProfile && isInternalActivity()
-                && !lockPatternUtils.isSeparateProfileChallengeEnabled(userId)) {
+                && !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
+            mCredentialMode = CREDENTIAL_MANAGED;
+            if (isBiometricAllowed()) {
+                showBiometricPrompt();
+                launchedBiometric = true;
+            } else {
+                showConfirmCredentials();
+            }
+        } else {
+            mCredentialMode = CREDENTIAL_NORMAL;
+            if (isBiometricAllowed()) {
+                // Don't need to check if biometrics / pin/pattern/pass are enrolled. It will go to
+                // onAuthenticationError and do the right thing automatically.
+                showBiometricPrompt();
+                launchedBiometric = true;
+            } else {
+                showConfirmCredentials();
+            }
+        }
+
+        if (launchedCDC) {
+            finish();
+        } else if (launchedBiometric) {
+            // Keep this activity alive until BiometricPrompt goes away
+        } else {
+            Log.d(TAG, "No pattern, password or PIN set.");
+            setResult(Activity.RESULT_OK);
+            finish();
+        }
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        // Translucent activity that is "visible", so it doesn't complain about finish()
+        // not being called before onResume().
+        setVisible(true);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        if (!isChangingConfigurations()) {
+            mGoingToBackground = true;
+            if (mBiometricFragment != null) {
+                mBiometricFragment.cancel();
+            }
+            finish();
+        } else {
+            mGoingToBackground = false;
+        }
+    }
+
+    // User could be locked while Effective user is unlocked even though the effective owns the
+    // credential. Otherwise, biometric can't unlock fbe/keystore through
+    // verifyTiedProfileChallenge. In such case, we also wanna show the user message that
+    // biometric is disabled due to device restart.
+    private boolean isStrongAuthRequired() {
+        return !mLockPatternUtils.isBiometricAllowedForUser(mEffectiveUserId)
+                || !mUserManager.isUserUnlocked(mUserId);
+    }
+
+    private boolean isBiometricDisabledByAdmin() {
+        final int disabledFeatures =
+                mDevicePolicyManager.getKeyguardDisabledFeatures(null, mEffectiveUserId);
+        return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_BIOMETRICS) != 0;
+    }
+
+    private boolean isBiometricAllowed() {
+        return !isStrongAuthRequired() && !isBiometricDisabledByAdmin();
+    }
+
+    private void showBiometricPrompt() {
+        mBiometricManager.setActiveUser(mUserId);
+
+        mBiometricFragment = (BiometricFragment) getSupportFragmentManager()
+                .findFragmentByTag(TAG_BIOMETRIC_FRAGMENT);
+        boolean newFragment = false;
+
+        if (mBiometricFragment == null) {
+            final BiometricFragment.PromptInfo info = new BiometricFragment.PromptInfo.Builder()
+                    .setTitle(mTitle)
+                    .setSubtitle(mDetails)
+                    .setNegativeButtonText(getResources()
+                            .getString(R.string.confirm_device_credential_use_alternate_method))
+                    .build();
+            mBiometricFragment = BiometricFragment.newInstance(info);
+            newFragment = true;
+        }
+        mBiometricFragment.setCallbacks(mExecutor, mAuthenticationCallback);
+
+        if (newFragment) {
+            getSupportFragmentManager().beginTransaction()
+                    .add(mBiometricFragment, TAG_BIOMETRIC_FRAGMENT).commit();
+        }
+    }
+
+    /**
+     * Shows ConfirmDeviceCredentials for normal apps.
+     */
+    private void showConfirmCredentials() {
+        boolean launched = false;
+        if (mCredentialMode == CREDENTIAL_MANAGED) {
             // We set the challenge as 0L, so it will force to unlock managed profile when it
             // unlocks primary profile screen lock, by calling verifyTiedProfileChallenge()
-            launched = helper.launchConfirmationActivityWithExternalAndChallenge(
-                    0 /* request code */, null /* title */, title, details, true /* isExternal */,
-                    0L /* challenge */, userId);
-        } else {
-            launched = helper.launchConfirmationActivity(0 /* request code */, null /* title */,
-                    title, details, false /* returnCredentials */, true /* isExternal */, userId);
+            launched = mChooseLockSettingsHelper
+                    .launchConfirmationActivityWithExternalAndChallenge(
+                            0 /* request code */, null /* title */, mTitle, mDetails,
+                            true /* isExternal */, 0L /* challenge */, mUserId);
+        } else if (mCredentialMode == CREDENTIAL_NORMAL){
+            launched = mChooseLockSettingsHelper.launchConfirmationActivity(
+                    0 /* request code */, null /* title */,
+                    mTitle, mDetails, false /* returnCredentials */, true /* isExternal */,
+                    mUserId);
         }
         if (!launched) {
-            Log.d(TAG, "No pattern, password or PIN set.");
+            Log.d(TAG, "No pin/pattern/pass set");
             setResult(Activity.RESULT_OK);
         }
         finish();
     }
 
+    @Override
+    public void finish() {
+        super.finish();
+        // Finish without animation since the activity is just there so we can launch
+        // BiometricPrompt.
+        overridePendingTransition(R.anim.confirm_credential_biometric_transition_enter, 0);
+    }
+
     private boolean isInternalActivity() {
         return this instanceof ConfirmDeviceCredentialActivity.InternalActivity;
     }
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index cae3ae6..c00f9ab 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -140,6 +140,15 @@
         }
     }
 
+    @Override
+    public void finish() {
+        super.finish();
+        if (getIntent().getBooleanExtra(
+                ConfirmDeviceCredentialBaseFragment.USE_FADE_ANIMATION, false)) {
+            overridePendingTransition(0, R.anim.confirm_credential_biometric_transition_exit);
+        }
+    }
+
     public void prepareEnterAnimation() {
         getFragment().prepareEnterAnimation();
     }
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
index a9542e5..9b677aa 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
@@ -53,26 +53,24 @@
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
 import com.android.settings.Utils;
-import com.android.settings.biometrics.fingerprint.FingerprintUiHelper;
 import com.android.settings.core.InstrumentedFragment;
 
 /**
  * Base fragment to be shared for PIN/Pattern/Password confirmation fragments.
  */
-public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFragment
-        implements FingerprintUiHelper.Callback {
+public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFragment {
 
     public static final String PACKAGE = "com.android.settings";
     public static final String TITLE_TEXT = PACKAGE + ".ConfirmCredentials.title";
     public static final String HEADER_TEXT = PACKAGE + ".ConfirmCredentials.header";
     public static final String DETAILS_TEXT = PACKAGE + ".ConfirmCredentials.details";
-    public static final String ALLOW_FP_AUTHENTICATION =
-            PACKAGE + ".ConfirmCredentials.allowFpAuthentication";
     public static final String DARK_THEME = PACKAGE + ".ConfirmCredentials.darkTheme";
     public static final String SHOW_CANCEL_BUTTON =
             PACKAGE + ".ConfirmCredentials.showCancelButton";
     public static final String SHOW_WHEN_LOCKED =
             PACKAGE + ".ConfirmCredentials.showWhenLocked";
+    public static final String USE_FADE_ANIMATION =
+            PACKAGE + ".ConfirmCredentials.useFadeAnimation";
 
     protected static final int USER_TYPE_PRIMARY = 1;
     protected static final int USER_TYPE_MANAGED_PROFILE = 2;
@@ -81,10 +79,8 @@
     /** Time we wait before clearing a wrong input attempt (e.g. pattern) and the error message. */
     protected static final long CLEAR_WRONG_ATTEMPT_TIMEOUT_MS = 3000;
 
-    private FingerprintUiHelper mFingerprintHelper;
     protected boolean mReturnCredentials = false;
     protected Button mCancelButton;
-    protected ImageView mFingerprintIcon;
     protected int mEffectiveUserId;
     protected int mUserId;
     protected UserManager mUserManager;
@@ -123,9 +119,7 @@
     public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
         mCancelButton = (Button) view.findViewById(R.id.cancelButton);
-        mFingerprintIcon = (ImageView) view.findViewById(R.id.fingerprintIcon);
-        mFingerprintHelper = new FingerprintUiHelper(
-                mFingerprintIcon, view.findViewById(R.id.errorText), this, mUserId);
+
         boolean showCancelButton = getActivity().getIntent().getBooleanExtra(
                 SHOW_CANCEL_BUTTON, false);
         boolean hasAlternateButton = mFrp && !TextUtils.isEmpty(mFrpAlternateButtonText);
@@ -153,29 +147,16 @@
         }
     }
 
-    private boolean isFingerprintDisabledByAdmin() {
-        final int disabledFeatures =
-                mDevicePolicyManager.getKeyguardDisabledFeatures(null, mEffectiveUserId);
-        return (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) != 0;
-    }
-
     // User could be locked while Effective user is unlocked even though the effective owns the
     // credential. Otherwise, fingerprint can't unlock fbe/keystore through
     // verifyTiedProfileChallenge. In such case, we also wanna show the user message that
     // fingerprint is disabled due to device restart.
     protected boolean isStrongAuthRequired() {
         return mFrp
-                || !mLockPatternUtils.isFingerprintAllowedForUser(mEffectiveUserId)
+                || !mLockPatternUtils.isBiometricAllowedForUser(mEffectiveUserId)
                 || !mUserManager.isUserUnlocked(mUserId);
     }
 
-    private boolean isFingerprintAllowed() {
-        return !mReturnCredentials
-                && getActivity().getIntent().getBooleanExtra(ALLOW_FP_AUTHENTICATION, false)
-                && !isStrongAuthRequired()
-                && !isFingerprintDisabledByAdmin();
-    }
-
     @Override
     public void onResume() {
         super.onResume();
@@ -183,13 +164,6 @@
     }
 
     protected void refreshLockScreen() {
-        if (isFingerprintAllowed()) {
-            mFingerprintHelper.startListening();
-        } else {
-            if (mFingerprintHelper.isListening()) {
-                mFingerprintHelper.stopListening();
-            }
-        }
         updateErrorMessage(mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId));
     }
 
@@ -214,28 +188,10 @@
     @Override
     public void onPause() {
         super.onPause();
-        if (mFingerprintHelper.isListening()) {
-            mFingerprintHelper.stopListening();
-        }
-    }
-
-    @Override
-    public void onAuthenticated() {
-        // Check whether we are still active.
-        if (getActivity() != null && getActivity().isResumed()) {
-            TrustManager trustManager =
-                (TrustManager) getActivity().getSystemService(Context.TRUST_SERVICE);
-            trustManager.setDeviceLockedForUser(mEffectiveUserId, false);
-            authenticationSucceeded();
-            checkForPendingIntent();
-        }
     }
 
     protected abstract void authenticationSucceeded();
 
-    @Override
-    public void onFingerprintIconVisibilityChanged(boolean visible) {
-    }
 
     public void prepareEnterAnimation() {
     }
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 38561fb..d380fc9 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -105,7 +105,6 @@
         private CountDownTimer mCountdownTimer;
         private boolean mIsAlpha;
         private InputMethodManager mImm;
-        private boolean mUsingFingerprint = false;
         private AppearAnimationUtils mAppearAnimationUtils;
         private DisappearAnimationUtils mDisappearAnimationUtils;
 
@@ -243,7 +242,6 @@
             mCancelButton.setAlpha(0f);
             mPasswordEntry.setAlpha(0f);
             mErrorTextView.setAlpha(0f);
-            mFingerprintIcon.setAlpha(0f);
         }
 
         private View[] getActiveViews() {
@@ -255,9 +253,6 @@
             }
             result.add(mPasswordEntry);
             result.add(mErrorTextView);
-            if (mFingerprintIcon.getVisibility() == View.VISIBLE) {
-                result.add(mFingerprintIcon);
-            }
             return result.toArray(new View[] {});
         }
 
@@ -303,17 +298,12 @@
             mCredentialCheckResultTracker.setResult(true, new Intent(), 0, mEffectiveUserId);
         }
 
-        @Override
-        public void onFingerprintIconVisibilityChanged(boolean visible) {
-            mUsingFingerprint = visible;
-        }
-
         private void updatePasswordEntry() {
             final boolean isLockedOut =
                     mLockPatternUtils.getLockoutAttemptDeadline(mEffectiveUserId) != 0;
             mPasswordEntry.setEnabled(!isLockedOut);
             mPasswordEntryInputDisabler.setInputEnabled(!isLockedOut);
-            if (isLockedOut || mUsingFingerprint) {
+            if (isLockedOut) {
                 mImm.hideSoftInputFromWindow(mPasswordEntry.getWindowToken(), 0 /*flags*/);
             } else {
                 mPasswordEntry.scheduleShowSoftInput();
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index 84db540..95a0aca 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -231,7 +231,6 @@
             mCancelButton.setAlpha(0f);
             mLockPatternView.setAlpha(0f);
             mDetailsTextView.setAlpha(0f);
-            mFingerprintIcon.setAlpha(0f);
         }
 
         private int getDefaultDetails() {
@@ -265,9 +264,6 @@
                 }
                 result.add(row);
             }
-            if (mFingerprintIcon.getVisibility() == View.VISIBLE) {
-                result.add(new ArrayList<Object>(Collections.singletonList(mFingerprintIcon)));
-            }
             Object[][] resultArr = new Object[result.size()][cellStates[0].length];
             for (int i = 0; i < result.size(); i++) {
                 ArrayList<Object> row = result.get(i);
@@ -377,16 +373,6 @@
             }
         }
 
-        @Override
-        public void onFingerprintIconVisibilityChanged(boolean visible) {
-            if (mLeftSpacerLandscape != null && mRightSpacerLandscape != null) {
-
-                // In landscape, adjust spacing depending on fingerprint icon visibility.
-                mLeftSpacerLandscape.setVisibility(visible ? View.GONE : View.VISIBLE);
-                mRightSpacerLandscape.setVisibility(visible ? View.GONE : View.VISIBLE);
-            }
-        }
-
         /**
          * The pattern listener that responds according to a user confirming
          * an existing lock pattern.
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index a947fb2..2432cc6 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -385,7 +385,7 @@
         final Set<String> keywords = buildSliceKeywords(data);
         @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
         final CharSequence summary = context.getText(R.string.disabled_dependent_setting_summary);
-        final IconCompat icon = IconCompat.createWithResource(context, data.getIconResource());
+        final IconCompat icon = getSafeIcon(context, data);
         final SliceAction primaryAction = new SliceAction(getContentPendingIntent(context, data),
                 icon, title);
 
diff --git a/src/com/android/settings/slices/SliceDataConverter.java b/src/com/android/settings/slices/SliceDataConverter.java
index 29e3d6b..cb2980d 100644
--- a/src/com/android/settings/slices/SliceDataConverter.java
+++ b/src/com/android/settings/slices/SliceDataConverter.java
@@ -226,7 +226,7 @@
                         SliceBuilderUtils.getPreferenceController(mContext, xmlSlice);
 
                 // Only add pre-approved Slices available on the device.
-                if (controller.isAvailable() && controller.isSliceable()) {
+                if (controller.isSliceable() && controller.isAvailable()) {
                     xmlSliceData.add(xmlSlice);
                 }
             }
@@ -277,7 +277,7 @@
             final String title = resolveInfo.loadLabel(packageManager).toString();
             int iconResource = resolveInfo.getIconResource();
             if (iconResource == 0) {
-                iconResource = R.mipmap.ic_accessibility_generic;
+                iconResource = R.drawable.ic_accessibility_generic;
             }
 
             sliceDataBuilder.setKey(flattenedName)
diff --git a/src/com/android/settings/slices/SlicesIndexer.java b/src/com/android/settings/slices/SlicesIndexer.java
index 0ccd223..0c39429 100644
--- a/src/com/android/settings/slices/SlicesIndexer.java
+++ b/src/com/android/settings/slices/SlicesIndexer.java
@@ -66,12 +66,11 @@
             return;
         }
 
-        SQLiteDatabase database = mHelper.getWritableDatabase();
+        final SQLiteDatabase database = mHelper.getWritableDatabase();
 
+        long startTime = System.currentTimeMillis();
+        database.beginTransaction();
         try {
-            long startTime = System.currentTimeMillis();
-            database.beginTransaction();
-
             mHelper.reconstruct(mHelper.getWritableDatabase());
             List<SliceData> indexData = getSliceData();
             insertSliceData(database, indexData);
@@ -85,6 +84,7 @@
         } finally {
             database.endTransaction();
         }
+        database.close();
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
new file mode 100644
index 0000000..9aac509
--- /dev/null
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -0,0 +1,117 @@
+/*
+ * 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.wifi;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import androidx.appcompat.app.AlertDialog;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settingslib.wifi.AccessPoint;
+import java.util.ArrayList;
+import java.util.List;
+
+public class NetworkRequestDialogFragment extends InstrumentedDialogFragment implements
+    DialogInterface.OnClickListener {
+
+  private List<AccessPoint> mAccessPointList;
+
+  public static NetworkRequestDialogFragment newInstance(int uid, String packageName) {
+    Bundle args = new Bundle();
+    args.putInt("uid", uid);
+    args.putString("packageName", packageName);
+    NetworkRequestDialogFragment dialogFragment = new NetworkRequestDialogFragment();
+    dialogFragment.setArguments(args);
+    return dialogFragment;
+  }
+
+  @Override
+  public Dialog onCreateDialog(Bundle savedInstanceState) {
+    Context context = getContext();
+
+    // Prepares title.
+    LayoutInflater inflater = LayoutInflater.from(context);
+    View customTitle = inflater.inflate(R.layout.network_request_dialog_title, null);
+
+    TextView title = customTitle.findViewById(R.id.network_request_title_text);
+    title.setText(R.string.network_connection_request_dialog_title);
+    ProgressBar progressBar = customTitle.findViewById(R.id.network_request_title_progress);
+    progressBar.setVisibility(View.VISIBLE);
+
+    // Prepares adapter.
+    AccessPointAdapter adapter = new AccessPointAdapter(context,
+        R.layout.preference_access_point, getAccessPointList());
+
+    AlertDialog.Builder builder = new AlertDialog.Builder(context)
+        .setCustomTitle(customTitle)
+        .setAdapter(adapter, this)
+        .setPositiveButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
+    return builder.create();
+  }
+
+  List<AccessPoint> getAccessPointList() {
+    // Initials list for adapter, in case of display crashing.
+    if (mAccessPointList == null) {
+      mAccessPointList = new ArrayList<>();
+    }
+    return mAccessPointList;
+  }
+
+  @Override
+  public void onClick(DialogInterface dialog, int which) {
+  }
+
+  @Override
+  public int getMetricsCategory() {
+    return MetricsProto.MetricsEvent.WIFI_SCANNING_NEEDED_DIALOG;
+  }
+
+  private class AccessPointAdapter extends ArrayAdapter<AccessPoint> {
+
+    private final int mResourceId;
+    private final LayoutInflater mInflater;
+
+    public AccessPointAdapter(Context context, int resourceId, List<AccessPoint> objects) {
+      super(context, resourceId, objects);
+      mResourceId = resourceId;
+      mInflater = LayoutInflater.from(context);
+    }
+
+    @Override
+    public View getView(int position, View view, ViewGroup parent) {
+      if (view == null) {
+        view = mInflater.inflate(mResourceId, parent, false);
+      }
+
+      // TODO: Sets correct information to list item.
+      final View divider = view.findViewById(com.android.settingslib.R.id.two_target_divider);
+      divider.setVisibility(View.GONE);
+
+      return view;
+    }
+  }
+}
+
diff --git a/src/com/android/settings/wifi/WifiSlice.java b/src/com/android/settings/wifi/WifiSlice.java
index e483d16..43f5372 100644
--- a/src/com/android/settings/wifi/WifiSlice.java
+++ b/src/com/android/settings/wifi/WifiSlice.java
@@ -71,7 +71,7 @@
             .build();
 
     @VisibleForTesting
-    static final int DEFAULT_EXPANDED_ROW_COUNT = 4;
+    static final int DEFAULT_EXPANDED_ROW_COUNT = 3;
 
     private final Context mContext;
 
@@ -137,10 +137,7 @@
                         .setSubtitle(placeholder));
             }
         }
-        // Add more button
-        return listBuilder
-                .setSeeMoreAction(primaryAction)
-                .build();
+        return listBuilder.build();
     }
 
     private RowBuilder getAccessPointRow(AccessPoint accessPoint) {
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index bf9d167..435f8f1 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -68,7 +68,7 @@
 
     @Override
     public boolean isAvailable() {
-      return true;
+        return true;
     }
 
     @Override
@@ -108,8 +108,8 @@
         final SwitchPreference enableWifiWakeup = (SwitchPreference) preference;
 
         enableWifiWakeup.setChecked(getWifiWakeupEnabled()
-                        && getWifiScanningEnabled()
-                        && mLocationManager.isLocationEnabled());
+                && getWifiScanningEnabled()
+                && mLocationManager.isLocationEnabled());
         if (!mLocationManager.isLocationEnabled()) {
             preference.setSummary(getNoLocationSummary());
         } else {
@@ -117,7 +117,8 @@
         }
     }
 
-    @VisibleForTesting CharSequence getNoLocationSummary() {
+    @VisibleForTesting
+    CharSequence getNoLocationSummary() {
         AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo("link", null);
         CharSequence locationText = mContext.getText(R.string.wifi_wakeup_summary_no_location);
         return AnnotationSpan.linkify(locationText, linkInfo);
diff --git a/tests/robotests/src/com/android/settings/RestrictedListPreferenceTest.java b/tests/robotests/src/com/android/settings/RestrictedListPreferenceTest.java
index d66cd8f..42fa79f 100644
--- a/tests/robotests/src/com/android/settings/RestrictedListPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/RestrictedListPreferenceTest.java
@@ -23,6 +23,7 @@
 import static org.mockito.Mockito.when;
 import static org.robolectric.RuntimeEnvironment.application;
 
+import android.app.Activity;
 import android.app.KeyguardManager;
 import android.content.Intent;
 import android.os.Bundle;
@@ -35,6 +36,7 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
 import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowKeyguardManager;
@@ -43,8 +45,8 @@
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(
         shadows = {
-            ShadowUserManager.class,
-            ShadowKeyguardManager.class,
+                ShadowUserManager.class,
+                ShadowKeyguardManager.class,
         })
 public class RestrictedListPreferenceTest {
     private static final int PROFILE_USER_ID = 11;
@@ -52,6 +54,7 @@
     private static final int UNLAUNCHABLE_REASON_QUIET_MODE = 1;
     private static final String EXTRA_UNLAUNCHABLE_REASON = "unlaunchable_reason";
 
+    private Activity mActivity;
     private ShadowUserManager mShadowUserManager;
     private ShadowKeyguardManager mShadowKeyguardManager;
     private RestrictedListPreference mPreference;
@@ -59,11 +62,12 @@
 
     @Before
     public void setUp() {
+        mActivity = Robolectric.setupActivity(Activity.class);
         mShadowKeyguardManager =
                 Shadows.shadowOf(application.getSystemService(KeyguardManager.class));
         mMockHelper = mock(RestrictedPreferenceHelper.class);
         mShadowUserManager = ShadowUserManager.getShadow();
-        mPreference = new RestrictedListPreference(application, mock(AttributeSet.class));
+        mPreference = new RestrictedListPreference(mActivity, mock(AttributeSet.class));
         mPreference.setProfileUserId(PROFILE_USER_ID);
         ReflectionHelpers.setField(mPreference, "mHelper", mMockHelper);
     }
@@ -80,7 +84,7 @@
         // Make sure that the performClick method on the helper is never reached.
         verify(mMockHelper, never()).performClick();
         // Assert that a CONFIRM_DEVICE_CREDENTIAL intent has been started.
-        Intent started = Shadows.shadowOf(application).getNextStartedActivity();
+        Intent started = Shadows.shadowOf(mActivity).getNextStartedActivity();
         assertThat(started.getExtras().getInt(Intent.EXTRA_USER_ID)).isEqualTo(PROFILE_USER_ID);
         assertThat(started.getAction())
                 .isEqualTo(KeyguardManager.ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER);
@@ -95,7 +99,7 @@
         // Make sure that the performClick method on the helper is never reached.
         verify(mMockHelper, never()).performClick();
         // Assert that a new intent for enabling the work profile is started.
-        Intent started = Shadows.shadowOf(application).getNextStartedActivity();
+        Intent started = Shadows.shadowOf(mActivity).getNextStartedActivity();
         Bundle extras = started.getExtras();
         int reason = extras.getInt(EXTRA_UNLAUNCHABLE_REASON);
         assertThat(reason).isEqualTo(UNLAUNCHABLE_REASON_QUIET_MODE);
diff --git a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
index 83a7272..beabd15 100644
--- a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
@@ -16,8 +16,6 @@
 
 package com.android.settings;
 
-import static com.android.settings.testutils.ResIdSubject.assertResId;
-
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Intent;
@@ -33,7 +31,7 @@
 public class SetupWizardUtilsTest {
 
     @Test
-    public void testCopySetupExtras() throws Throwable {
+    public void testCopySetupExtras() {
         Intent fromIntent = new Intent();
         final String theme = "TEST_THEME";
         fromIntent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
@@ -53,7 +51,7 @@
         Intent intent = new Intent();
         intent.putExtra(WizardManagerHelper.EXTRA_THEME, WizardManagerHelper.THEME_GLIF_V2);
 
-        assertResId(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme);
+        assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme);
     }
 
     @Test
@@ -62,7 +60,7 @@
                 WizardManagerHelper.THEME_GLIF_V2_LIGHT);
         Intent intent = new Intent();
 
-        assertResId(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
+        assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
     }
 
     @Test
@@ -71,8 +69,8 @@
                 WizardManagerHelper.THEME_GLIF_V3_LIGHT);
         Intent intent = new Intent();
 
-        assertResId(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
-        assertResId(SetupWizardUtils.getTransparentTheme(intent))
+        assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
+        assertThat(SetupWizardUtils.getTransparentTheme(intent))
                 .isEqualTo(R.style.GlifV3Theme_Light_Transparent);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
index cdd0838..06fd1fc 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -25,13 +25,13 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothHearingAid;
 import android.bluetooth.BluetoothManager;
 import android.bluetooth.BluetoothProfile;
 import android.content.BroadcastReceiver;
-import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 
@@ -53,7 +53,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadow.api.Shadow;
 
@@ -71,7 +71,7 @@
     private ShadowBluetoothAdapter mShadowBluetoothAdapter;
     private BluetoothManager mBluetoothManager;
     private BluetoothDevice mBluetoothDevice;
-    private Context mContext;
+    private Activity mContext;
     private Preference mHearingAidPreference;
     private AccessibilityHearingAidPreferenceController mPreferenceController;
 
@@ -89,7 +89,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         setupBluetoothEnvironment();
         setupHearingAidEnvironment();
         mHearingAidPreference = new Preference(mContext);
@@ -145,8 +145,8 @@
     }
 
     @Test
-    public void handleHearingAidPreferenceClick_withHearingAid_launchBluetoothDeviceDetailSetting()
-    {
+    public void handleHearingAidPreferenceClick_withHearingAid_launchBluetoothDeviceDetailSetting
+            () {
         mPreferenceController = spy(new AccessibilityHearingAidPreferenceController(mContext,
                 HEARING_AID_PREFERENCE));
         mPreferenceController.setPreference(mHearingAidPreference);
@@ -161,7 +161,8 @@
     public void onNotSupportHearingAidProfile_doNotDoReceiverOperation() {
         //clear bluetooth supported profile
         mShadowBluetoothAdapter.clearSupportedProfiles();
-        mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext, HEARING_AID_PREFERENCE);
+        mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext,
+                HEARING_AID_PREFERENCE);
         mPreferenceController.setPreference(mHearingAidPreference);
         //not call registerReceiver()
         mPreferenceController.onResume();
diff --git a/tests/robotests/src/com/android/settings/accessibility/ColorInversionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/ColorInversionPreferenceControllerTest.java
index 6fb6f0e..2648a50 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ColorInversionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ColorInversionPreferenceControllerTest.java
@@ -59,7 +59,7 @@
 
     @Test
     public void isChecked_enabled() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, ON);
 
         mController.updateState(mPreference);
@@ -70,7 +70,7 @@
 
     @Test
     public void isChecked_disabled() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF);
 
         mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java
index 020906ae..a143d25 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationGesturesPreferenceControllerTest.java
@@ -60,13 +60,13 @@
 
     @Test
     public void updateState_shouldRefreshSummary() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
         mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
                 .isEqualTo(mContext.getString(R.string.accessibility_feature_state_on));
 
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
         mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
@@ -84,7 +84,7 @@
 
     @Test
     public void isChecked_enabled() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
 
         assertThat(mController.isChecked()).isTrue();
@@ -92,7 +92,7 @@
 
     @Test
     public void isChecked_disabled() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
 
         assertThat(mController.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java
index 225a2bb..89a7884 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationNavbarPreferenceControllerTest.java
@@ -85,13 +85,13 @@
 
     @Test
     public void updateState_shouldRefreshSummary() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, ON);
         mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
                 .isEqualTo(mContext.getText(R.string.accessibility_feature_state_on));
 
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, OFF);
         mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
@@ -109,7 +109,7 @@
 
     @Test
     public void isChecked_enabled() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, ON);
 
         assertThat(mController.isChecked()).isTrue();
@@ -117,7 +117,7 @@
 
     @Test
     public void isChecked_disabled() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, OFF);
 
         assertThat(mController.isChecked()).isFalse();
@@ -151,7 +151,7 @@
         }
 
         @Implementation
-        static boolean isApplicable(Resources res) {
+        protected static boolean isApplicable(Resources res) {
             return sIsApplicable;
         }
 
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountSyncPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountSyncPreferenceControllerTest.java
index 672baaa..0681c82 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountSyncPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountSyncPreferenceControllerTest.java
@@ -24,6 +24,7 @@
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AuthenticatorDescription;
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SyncAdapterType;
@@ -43,7 +44,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
@@ -54,24 +55,24 @@
     @Mock(answer = RETURNS_DEEP_STUBS)
     private AccountManager mAccountManager;
 
-    private Context mContext;
+    private Activity mActivity;
     private AccountSyncPreferenceController mController;
     private Preference mPreference;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
+        mActivity = Robolectric.setupActivity(Activity.class);
         ShadowApplication.getInstance().setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
 
         when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(
                 new AuthenticatorDescription[0]);
         when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
 
-        mPreference = new Preference(mContext);
+        mPreference = new Preference(mActivity);
         mPreference.setKey("account_sync");
 
-        mController = new AccountSyncPreferenceController(mContext);
+        mController = new AccountSyncPreferenceController(mActivity);
         mController.init(new Account("acct1", "type1"), new UserHandle(3));
     }
 
@@ -102,7 +103,7 @@
         mController.updateSummary(mPreference);
 
         assertThat(mPreference.getSummary())
-                .isEqualTo(mContext.getString(R.string.account_sync_summary_all_off));
+                .isEqualTo(mActivity.getString(R.string.account_sync_summary_all_off));
     }
 
     @Test
@@ -115,7 +116,7 @@
         mController.updateSummary(mPreference);
 
         assertThat(mPreference.getSummary())
-                .isEqualTo(mContext.getString(R.string.account_sync_summary_all_off));
+                .isEqualTo(mActivity.getString(R.string.account_sync_summary_all_off));
     }
 
     @Test
@@ -129,7 +130,7 @@
         mController.updateSummary(mPreference);
 
         assertThat(mPreference.getSummary())
-                .isEqualTo(mContext.getString(R.string.account_sync_summary_all_off));
+                .isEqualTo(mActivity.getString(R.string.account_sync_summary_all_off));
     }
 
     @Test
@@ -144,7 +145,7 @@
         mController.updateSummary(mPreference);
 
         assertThat(mPreference.getSummary())
-                .isEqualTo(mContext.getString(R.string.account_sync_summary_all_off));
+                .isEqualTo(mActivity.getString(R.string.account_sync_summary_all_off));
     }
 
     @Test
@@ -157,7 +158,7 @@
         mController.updateSummary(mPreference);
 
         assertThat(mPreference.getSummary())
-                .isEqualTo(mContext.getString(R.string.account_sync_summary_all_on));
+                .isEqualTo(mActivity.getString(R.string.account_sync_summary_all_on));
     }
 
     @Test
@@ -179,6 +180,6 @@
         mController.updateSummary(mPreference);
 
         assertThat(mPreference.getSummary())
-                .isEqualTo(mContext.getString(R.string.account_sync_summary_some_on, 3, 4));
+                .isEqualTo(mActivity.getString(R.string.account_sync_summary_some_on, 3, 4));
     }
 }
diff --git a/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java
index 623a76e..9e476bd 100644
--- a/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java
@@ -25,6 +25,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ResolveInfo;
@@ -45,6 +46,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
@@ -69,7 +71,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mController = new EmergencyInfoPreferenceController(mContext);
-        mPreference = new Preference(RuntimeEnvironment.application);
+        mPreference = new Preference(Robolectric.setupActivity(Activity.class));
         mPreference.setKey(mController.getPreferenceKey());
         when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
     }
@@ -136,16 +138,16 @@
         mController.updateState(preference);
 
         verify(preference).setSummary(
-            mContext.getString(R.string.emergency_info_summary, "user 1"));
+                mContext.getString(R.string.emergency_info_summary, "user 1"));
     }
 
     @Test
     public void handlePreferenceTreeClick_shouldStartActivity() {
         final ShadowApplication application = ShadowApplication.getInstance();
-        final Context context = RuntimeEnvironment.application;
-        final Preference preference = new Preference(context);
+        final Activity activity = Robolectric.setupActivity(Activity.class);
+        final Preference preference = new Preference(activity);
         preference.setKey("emergency_info");
-        mController = new EmergencyInfoPreferenceController(context);
+        mController = new EmergencyInfoPreferenceController(activity);
 
         mController.handlePreferenceTreeClick(preference);
 
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
index a32c23c..733e22e 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
@@ -25,7 +25,6 @@
 
 import android.content.Context;
 import android.content.Intent;
-import android.os.UserManager;
 import android.provider.Settings;
 
 import androidx.preference.Preference;
@@ -36,7 +35,9 @@
 import com.android.settings.applications.ProcessStatsDetail;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -44,11 +45,11 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowUserManager.class})
 public class AppMemoryPreferenceControllerTest {
 
     @Mock
@@ -67,8 +68,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
-        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        Shadows.shadowOf(userManager).setIsAdminUser(true);
+        ShadowUserManager.getShadow().setIsAdminUser(true);
         mController =
                 spy(new AppMemoryPreferenceController(mContext, mFragment, null /* lifecycle */));
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
@@ -77,6 +77,11 @@
         when(mFragment.getActivity()).thenReturn(mActivity);
     }
 
+    @After
+    public void tearDown() {
+        ShadowUserManager.getShadow().reset();
+    }
+
     @Test
     @Config(qualifiers = "mcc999")
     public void getAvailabilityStatus_developmentSettingsEnabled_shouldReturnAvailable() {
@@ -84,7 +89,7 @@
                 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
 
         assertThat(mController.getAvailabilityStatus())
-            .isEqualTo(BasePreferenceController.AVAILABLE);
+                .isEqualTo(BasePreferenceController.AVAILABLE);
     }
 
     @Test
@@ -93,7 +98,7 @@
                 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
 
         assertThat(mController.getAvailabilityStatus())
-            .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
     }
 
     @Test
@@ -102,7 +107,7 @@
                 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
 
         assertThat(mController.getAvailabilityStatus())
-            .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppSettingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppSettingPreferenceControllerTest.java
index de95a1c..9f0fd31 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppSettingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppSettingPreferenceControllerTest.java
@@ -18,7 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.app.Application;
+import android.app.Activity;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ResolveInfo;
@@ -32,6 +32,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.Shadows;
 import org.robolectric.shadows.ShadowPackageManager;
@@ -50,19 +51,19 @@
 
     @Mock
     private AppInfoDashboardFragment mParent;
-    private Application mApplication;
     private ShadowPackageManager mPackageManager;
     private AppSettingPreferenceController mController;
     private Preference mPreference;
+    private Activity mActivity;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mApplication = RuntimeEnvironment.application;
-        mPackageManager = Shadows.shadowOf(mApplication.getPackageManager());
-        mController = new AppSettingPreferenceController(mApplication, "test_key");
+        mActivity = Robolectric.setupActivity(Activity.class);
+        mPackageManager = Shadows.shadowOf(RuntimeEnvironment.application.getPackageManager());
+        mController = new AppSettingPreferenceController(mActivity, "test_key");
         mController.setPackageName(TEST_PKG_NAME).setParentFragment(mParent);
-        mPreference = new Preference(mApplication);
+        mPreference = new Preference(mActivity);
         mPreference.setKey(mController.getPreferenceKey());
     }
 
@@ -108,7 +109,7 @@
         mPackageManager.addResolveInfoForIntent(RESOLVED_INTENT, info);
 
         assertThat(mController.handlePreferenceTreeClick(mPreference)).isTrue();
-        assertThat(Shadows.shadowOf(mApplication).getNextStartedActivity().getComponent())
+        assertThat(Shadows.shadowOf(mActivity).getNextStartedActivity().getComponent())
                 .isEqualTo(TEST_INTENT.getComponent());
     }
 }
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
index f41ccf8..da1c6b4 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
@@ -23,11 +23,11 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.Context;
 import android.os.UserManager;
 
 import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -39,7 +39,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class DefaultAppShortcutPreferenceControllerBaseTest {
@@ -49,19 +49,17 @@
     @Mock
     private AppInfoDashboardFragment mFragment;
     @Mock
-    private PreferenceScreen mScreen;
-    @Mock
     private Preference mPreference;
 
-    private Context mContext;
+    private Activity mActivity;
     private TestPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
-        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
-        mController = new TestPreferenceController(mContext, mFragment);
+        mActivity = spy(Robolectric.setupActivity(Activity.class));
+        when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+        mController = new TestPreferenceController(mActivity, mFragment);
         final String key = mController.getPreferenceKey();
         when(mPreference.getKey()).thenReturn(key);
     }
@@ -95,7 +93,7 @@
         mController.isDefault = true;
 
         mController.updateState(mPreference);
-        String yesString = mContext.getString(R.string.yes);
+        String yesString = mActivity.getString(R.string.yes);
         verify(mPreference).setSummary(yesString);
     }
 
@@ -105,7 +103,7 @@
 
         mController.updateState(mPreference);
 
-        String noString = mContext.getString(R.string.no);
+        String noString = mActivity.getString(R.string.no);
         verify(mPreference).setSummary(noString);
     }
 
@@ -113,7 +111,7 @@
     public void handlePreferenceTreeClick_shouldStartDefaultAppSettings() {
         mController.handlePreferenceTreeClick(mPreference);
 
-        verify(mContext).startActivity(argThat(intent -> intent != null
+        verify(mActivity).startActivity(argThat(intent -> intent != null
                 && intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT).equals(
                 DefaultAppSettings.class.getName())
                 && intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ExternalSourcesDetailsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ExternalSourcesDetailsTest.java
index e625eee..d3a90da 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/ExternalSourcesDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/ExternalSourcesDetailsTest.java
@@ -17,6 +17,7 @@
 package com.android.settings.applications.appinfo;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.doAnswer;
@@ -29,12 +30,14 @@
 import android.content.pm.PackageInfo;
 import android.os.UserHandle;
 import android.os.UserManager;
+
 import com.android.settings.applications.AppStateInstallAppsBridge;
 import com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState;
-import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settingslib.RestrictedPreferenceHelper;
 import com.android.settingslib.RestrictedSwitchPreference;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -135,7 +138,7 @@
         assertThat(fragment.refreshUi()).isTrue();
 
         // Assertions
-        assertThat(shadowUserManager.hasUserRestriction(
+        assertThat(userManager.hasUserRestriction(
                 UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
                 UserHandle.of(UserHandle.myUserId()))).isTrue();
         assertThat(mSwitchPref.isDisabledByAdmin()).isTrue();
@@ -174,7 +177,7 @@
         assertThat(fragment.refreshUi()).isTrue();
 
         // Assertions
-        assertThat(shadowUserManager.hasUserRestriction(
+        assertThat(userManager.hasUserRestriction(
                 UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY,
                 UserHandle.of(UserHandle.myUserId()))).isTrue();
         assertThat(mSwitchPref.isDisabledByAdmin()).isTrue();
@@ -215,10 +218,10 @@
         assertThat(fragment.refreshUi()).isTrue();
 
         // Assertions
-        assertThat(shadowUserManager.hasUserRestriction(
+        assertThat(userManager.hasUserRestriction(
                 UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY,
                 UserHandle.of(UserHandle.myUserId()))).isTrue();
-        assertThat(shadowUserManager.hasUserRestriction(
+        assertThat(userManager.hasUserRestriction(
                 UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
                 UserHandle.of(UserHandle.myUserId()))).isTrue();
         assertThat(mSwitchPref.isDisabledByAdmin()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppAccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppAccountPreferenceControllerTest.java
index cb62800..f09e400 100644
--- a/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppAccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppAccountPreferenceControllerTest.java
@@ -62,13 +62,13 @@
         mContext = spy(RuntimeEnvironment.application);
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
         mContentResolver = mContext.getContentResolver();
-        mEnableEphemeralFeature = Settings.Secure.getInt(mContentResolver,
+        mEnableEphemeralFeature = Settings.Global.getInt(mContentResolver,
                 ENABLE_EPHEMERAL_FEATURE, 1);
     }
 
     @After
     public void tearDown() {
-        Settings.Secure.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE,
+        Settings.Global.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE,
                 mEnableEphemeralFeature);
     }
 
@@ -81,10 +81,10 @@
     }
 
     @Test
-    public void testGetAvailabilityStatus_enableWebActiions() {
+    public void testGetAvailabilityStatus_enableWebActions() {
         when(mPackageManager.getInstantAppResolverSettingsComponent()).thenReturn(mComponentName);
         mController = new InstantAppAccountPreferenceController(mContext, PREF_KEY);
-        Settings.Secure.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 1);
+        Settings.Global.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 1);
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
     }
@@ -93,7 +93,7 @@
     public void testGetAvailabilityStatus_disableWebActions() {
         when(mPackageManager.getInstantAppResolverSettingsComponent()).thenReturn(mComponentName);
         mController = new InstantAppAccountPreferenceController(mContext, PREF_KEY);
-        Settings.Secure.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 0);
+        Settings.Global.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 0);
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
     }
diff --git a/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppWebActionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppWebActionPreferenceControllerTest.java
index 6a1222d..b4ff2fa 100644
--- a/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppWebActionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/managedomainurls/InstantAppWebActionPreferenceControllerTest.java
@@ -57,26 +57,26 @@
         mContentResolver = mContext.getContentResolver();
         mController = new InstantAppWebActionPreferenceController(mContext, PREF_KEY);
         mSwitchPreference = new SwitchPreference(mContext);
-        mEnableEphemeralFeature = Settings.Secure.getInt(mContentResolver,
+        mEnableEphemeralFeature = Settings.Global.getInt(mContentResolver,
                 ENABLE_EPHEMERAL_FEATURE, 1);
     }
 
     @After
     public void tearDown() {
-        Settings.Secure.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE,
+        Settings.Global.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE,
                 mEnableEphemeralFeature);
     }
 
     @Test
     public void testGetAvailabilityStatus_enableWebActions() {
-        Settings.Secure.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 1);
+        Settings.Global.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 1);
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
     }
 
     @Test
     public void testGetAvailabilityStatus_disableWebActions() {
-        Settings.Secure.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 0);
+        Settings.Global.putInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 0);
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
     }
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
index c01f688..fb50b3c 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -19,18 +19,13 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Matchers.anyInt;
 import static org.mockito.Mockito.verify;
-import static org.robolectric.RuntimeEnvironment.application;
 
 import android.content.Intent;
 import android.hardware.fingerprint.FingerprintManager;
 import android.hardware.fingerprint.FingerprintManager.EnrollmentCallback;
-import android.media.AudioAttributes;
 import android.os.CancellationSignal;
-import android.os.VibrationEffect;
-import android.os.Vibrator;
 import android.widget.TextView;
 
 import com.android.settings.R;
@@ -39,7 +34,7 @@
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
 import com.android.settings.testutils.shadow.ShadowUtils;
-import com.android.settings.testutils.shadow.ShadowVibrator;
+
 
 import org.junit.After;
 import org.junit.Before;
@@ -50,15 +45,11 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
 import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
-
-import java.util.concurrent.TimeUnit;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = {
         SettingsShadowResourcesImpl.class,
-        ShadowUtils.class,
-        ShadowVibrator.class})
+        ShadowUtils.class})
 public class FingerprintEnrollEnrollingTest {
 
     @Mock
@@ -70,7 +61,6 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         ShadowUtils.setFingerprintManager(mFingerprintManager);
-        ShadowVibrator.addToServiceMap();
 
         FakeFeatureFactory.setupForTest();
         mActivity = Robolectric.buildActivity(
@@ -84,11 +74,10 @@
     @After
     public void tearDown() {
         ShadowUtils.reset();
-        ShadowVibrator.reset();
     }
 
     @Test
-    public void fingerprintEnrollHelp_shouldShowHelpTextAndVibrate() {
+    public void fingerprintEnrollHelp_shouldShowHelpText() {
         EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
 
         enrollmentCallback.onEnrollmentProgress(123);
@@ -98,17 +87,6 @@
 
         TextView errorText = mActivity.findViewById(R.id.error_text);
         assertThat(errorText.getText()).isEqualTo("test enrollment help");
-
-        Robolectric.getForegroundThreadScheduler().advanceBy(2, TimeUnit.MILLISECONDS);
-
-        ShadowVibrator shadowVibrator =
-                Shadow.extract(application.getSystemService(Vibrator.class));
-        verify(shadowVibrator.delegate).vibrate(
-                anyInt(),
-                nullable(String.class),
-                any(VibrationEffect.class),
-                nullable(String.class),
-                nullable(AudioAttributes.class));
     }
 
     private EnrollmentCallback verifyAndCaptureEnrollmentCallback() {
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
index 6689518..aed1ea9 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java
@@ -73,7 +73,6 @@
 
         Shadows.shadowOf(application.getPackageManager())
             .setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
-        ShadowFingerprintManager.addToServiceMap();
 
         FakeFeatureFactory.setupForTest();
 
@@ -86,7 +85,6 @@
     @After
     public void tearDown() {
         ShadowStorageManager.reset();
-        ShadowFingerprintManager.reset();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java b/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
index 446b71c..0083478 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
@@ -26,18 +26,14 @@
 import android.content.Intent;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowBluetoothAdapter.class})
 public class AlwaysDiscoverableTest {
 
     @Mock
@@ -45,14 +41,12 @@
 
     private AlwaysDiscoverable mAlwaysDiscoverable;
     private BluetoothAdapter mBluetoothAdapter;
-    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mAlwaysDiscoverable = new AlwaysDiscoverable(mContext);
         mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
     }
 
     @Test
@@ -82,7 +76,7 @@
 
     @Test
     public void startSetsModeAndRegistersReceiver() {
-        mShadowBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE);
+        mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE);
         mAlwaysDiscoverable.start();
         assertThat(mBluetoothAdapter.getScanMode())
                 .isEqualTo(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
@@ -110,7 +104,7 @@
     }
 
     private void sendScanModeChangedIntent(int newMode, int previousMode) {
-        mShadowBluetoothAdapter.setScanMode(newMode);
+        mBluetoothAdapter.setScanMode(newMode);
         Intent intent = new Intent(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
         intent.putExtra(BluetoothAdapter.EXTRA_SCAN_MODE, newMode);
         intent.putExtra(BluetoothAdapter.EXTRA_PREVIOUS_SCAN_MODE, previousMode);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index d129944..12c7193 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -38,6 +38,7 @@
 import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.testutils.DrawableTestHelper;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -79,7 +80,7 @@
         mPreference.onClicked();
 
         verify(mMetricsFeatureProvider)
-            .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
+                .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_DISCONNECT);
     }
 
     @Test
@@ -90,7 +91,7 @@
         mPreference.onClicked();
 
         verify(mMetricsFeatureProvider)
-            .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
+                .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT);
     }
 
     @Test
@@ -103,9 +104,10 @@
         mPreference.onClicked();
 
         verify(mMetricsFeatureProvider)
-            .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+                .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
         verify(mMetricsFeatureProvider, never())
-            .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
+                .action(mContext,
+                        MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
     }
 
     @Test
@@ -118,9 +120,10 @@
         mPreference.onClicked();
 
         verify(mMetricsFeatureProvider)
-            .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
+                .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
         verify(mMetricsFeatureProvider)
-            .action(mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
+                .action(mContext,
+                        MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
     }
 
     @Test
@@ -164,13 +167,12 @@
     @Test
     public void imagingDeviceIcon_isICSettingsPrint() {
         when(mCachedBluetoothDevice.getBatteryLevel())
-            .thenReturn(BluetoothDevice.BATTERY_LEVEL_UNKNOWN);
+                .thenReturn(BluetoothDevice.BATTERY_LEVEL_UNKNOWN);
         when(mCachedBluetoothDevice.getBtClass())
-            .thenReturn(new BluetoothClass(BluetoothClass.Device.Major.IMAGING));
+                .thenReturn(new BluetoothClass(BluetoothClass.Device.Major.IMAGING));
 
         mPreference.onDeviceAttributesChanged();
-        assertThat(mPreference.getIcon()).isEqualTo(
-                mContext.getDrawable(R.drawable.ic_settings_print));
+        DrawableTestHelper.assertDrawableResId(mPreference.getIcon(), R.drawable.ic_settings_print);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java
index be86241..27ea6be 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingPreferenceControllerTest.java
@@ -32,6 +32,7 @@
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.testutils.DrawableTestHelper;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -72,10 +73,10 @@
         Preference pref = mController.createBluetoothPairingPreference(ORDER);
 
         assertThat(pref.getKey()).isEqualTo(BluetoothPairingPreferenceController.KEY_PAIRING);
-        assertThat(pref.getIcon()).isEqualTo(mContext.getDrawable(R.drawable.ic_menu_add));
+        DrawableTestHelper.assertDrawableResId(pref.getIcon(), R.drawable.ic_menu_add);
         assertThat(pref.getOrder()).isEqualTo(ORDER);
         assertThat(pref.getTitle())
-            .isEqualTo(mContext.getString(R.string.bluetooth_pairing_pref_title));
+                .isEqualTo(mContext.getString(R.string.bluetooth_pairing_pref_title));
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java
index bd6f508..913e7d9 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java
@@ -49,7 +49,6 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
 import org.robolectric.shadows.ShadowApplication;
 
 import java.util.ArrayList;
@@ -75,7 +74,6 @@
     private DiscoverableFooterPreferenceController mDiscoverableFooterPreferenceController;
     private BroadcastReceiver mBluetoothChangedReceiver;
     private ShadowApplication mShadowApplication;
-    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
@@ -91,7 +89,6 @@
                 mAlwaysDiscoverable);
         mBluetoothChangedReceiver = mDiscoverableFooterPreferenceController
                 .mBluetoothChangedReceiver;
-        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
     }
 
     @Test
@@ -137,15 +134,15 @@
 
     @Test
     public void onBluetoothStateChanged_bluetoothOn_updateTitle() {
-        mShadowBluetoothAdapter.setName(DEVICE_NAME);
+        BluetoothAdapter.getDefaultAdapter().setName(DEVICE_NAME);
         sendBluetoothStateChangedIntent(BluetoothAdapter.STATE_ON);
 
         assertThat(mPreference.getTitle()).isEqualTo(generateTitle(DEVICE_NAME));
     }
 
     @Test
-    public void onBluetoothStateChanged_bluetoothOff_updateTitle(){
-        mShadowBluetoothAdapter.setName(DEVICE_NAME);
+    public void onBluetoothStateChanged_bluetoothOff_updateTitle() {
+        BluetoothAdapter.getDefaultAdapter().setName(DEVICE_NAME);
         sendBluetoothStateChangedIntent(BluetoothAdapter.STATE_OFF);
 
         assertThat(mPreference.getTitle()).isEqualTo(generateTitle(null));
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
index ad04e7e..643d6b2 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
@@ -28,6 +28,7 @@
 import com.android.settings.connecteddevice.DevicePreferenceCallback;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.testutils.DrawableTestHelper;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -68,8 +69,8 @@
         mDeviceUpdater.initUsbPreference(mContext);
 
         assertThat(mDeviceUpdater.mUsbPreference.getTitle()).isEqualTo("USB");
-        assertThat(mDeviceUpdater.mUsbPreference.getIcon())
-            .isEqualTo(mContext.getDrawable(R.drawable.ic_usb));
+        DrawableTestHelper.assertDrawableResId(
+                mDeviceUpdater.mUsbPreference.getIcon(), R.drawable.ic_usb);
         assertThat(mDeviceUpdater.mUsbPreference.isSelectable()).isTrue();
     }
 
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
index f34446c..ec697ad 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
@@ -16,10 +16,12 @@
 
 package com.android.settings.connecteddevice.usb;
 
+import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.graphics.drawable.Drawable;
 import android.hardware.usb.UsbManager;
 import android.hardware.usb.UsbPort;
 
@@ -34,12 +36,14 @@
 import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
 import com.android.settings.widget.EntityHeaderController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.testutils.DrawableTestHelper;
 
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
+import org.mockito.ArgumentMatcher;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
@@ -100,7 +104,10 @@
         mDetailsHeaderController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
                 UsbPort.DATA_ROLE_DEVICE);
         verify(mHeaderController).setLabel(mContext.getString(R.string.usb_pref));
-        verify(mHeaderController).setIcon(mContext.getDrawable(R.drawable.ic_usb));
+        verify(mHeaderController).setIcon(argThat((ArgumentMatcher<Drawable>) t -> {
+            DrawableTestHelper.assertDrawableResId(t, R.drawable.ic_usb);
+            return true;
+        }));
         verify(mHeaderController).done(mActivity, true);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/core/instrumentation/InstrumentedDialogFragmentTest.java b/tests/robotests/src/com/android/settings/core/instrumentation/InstrumentedDialogFragmentTest.java
index c5a6bca..644f249 100644
--- a/tests/robotests/src/com/android/settings/core/instrumentation/InstrumentedDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/core/instrumentation/InstrumentedDialogFragmentTest.java
@@ -24,6 +24,7 @@
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -56,7 +57,7 @@
         // Precondition: no metrics feature
         assertThat(fragment.getMetricsFeatureProvider()).isNull();
 
-        fragment.onAttach(ShadowApplication.getInstance().getApplicationContext());
+        fragment.onAttach(RuntimeEnvironment.application);
 
         // Verify: has metrics feature
         assertThat(fragment.getMetricsFeatureProvider()).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/dashboard/CategoryManagerTest.java b/tests/robotests/src/com/android/settings/dashboard/CategoryManagerTest.java
index 61ef390..d8fb65d 100644
--- a/tests/robotests/src/com/android/settings/dashboard/CategoryManagerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/CategoryManagerTest.java
@@ -157,8 +157,7 @@
         mCategoryByKeyMap.put(CATEGORY_HOMEPAGE, category);
 
         // Sort their priorities
-        mCategoryManager.sortCategories(ShadowApplication.getInstance().getApplicationContext(),
-                mCategoryByKeyMap);
+        mCategoryManager.sortCategories(RuntimeEnvironment.application, mCategoryByKeyMap);
 
         // Verify they are now sorted.
         assertThat(category.getTile(0)).isSameAs(tile3);
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index 4e788a1..634bdb7 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -75,7 +75,6 @@
 import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowActivity;
-import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
@@ -348,8 +347,7 @@
         ReflectionHelpers.setField(
                 mImpl, "mPackageManager", RuntimeEnvironment.application.getPackageManager());
         FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
-        final ShadowApplication application = ShadowApplication.getInstance();
-        final Preference preference = new Preference(application.getApplicationContext());
+        final Preference preference = new Preference(RuntimeEnvironment.application);
         final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
         mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
         mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
index 121d9a2..855e40b 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -22,8 +22,8 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.ComponentName;
-import android.content.Context;
 import android.content.Intent;
 import android.graphics.Typeface;
 import android.net.NetworkTemplate;
@@ -51,7 +51,6 @@
 import org.junit.runner.RunWith;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
-import org.robolectric.RuntimeEnvironment;
 import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowActivity;
@@ -66,7 +65,7 @@
     private static final long UPDATE_LAG_MILLIS = 10000000L;
     private static final String DUMMY_CARRIER = "z-mobile";
 
-    private Context mContext;
+    private Activity mActivity;
     private PreferenceViewHolder mHolder;
     private DataUsageSummaryPreference mSummaryPreference;
     private TextView mUsageTitle;
@@ -87,9 +86,9 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
-        mSummaryPreference = new DataUsageSummaryPreference(mContext, null /* attrs */);
-        LayoutInflater inflater = LayoutInflater.from(mContext);
+        mActivity = spy(Robolectric.setupActivity(Activity.class));
+        mSummaryPreference = new DataUsageSummaryPreference(mActivity, null /* attrs */);
+        LayoutInflater inflater = LayoutInflater.from(mActivity);
         View view = inflater.inflate(mSummaryPreference.getLayoutResource(), null /* root */,
                 false /* attachToRoot */);
 
@@ -227,7 +226,7 @@
         bindViewHolder();
         assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mCarrierInfo.getCurrentTextColor()).isEqualTo(
-                Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorSecondary));
+                Utils.getColorAttrDefaultColor(mActivity, android.R.attr.textColorSecondary));
         assertThat(mCarrierInfo.getTypeface()).isEqualTo(Typeface.SANS_SERIF);
     }
 
@@ -240,7 +239,7 @@
         bindViewHolder();
         assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mCarrierInfo.getCurrentTextColor()).isEqualTo(
-                Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorError));
+                Utils.getColorAttrDefaultColor(mActivity, android.R.attr.colorError));
         assertThat(mCarrierInfo.getTypeface()).isEqualTo(
                 DataUsageSummaryPreference.SANS_SERIF_MEDIUM);
     }
@@ -273,7 +272,7 @@
         bindViewHolder();
         assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mCycleTime.getText()).isEqualTo(
-                mContext.getString(R.string.billing_cycle_less_than_one_day_left));
+                mActivity.getString(R.string.billing_cycle_less_than_one_day_left));
     }
 
     @Test
@@ -285,7 +284,7 @@
         bindViewHolder();
         assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mCycleTime.getText()).isEqualTo(
-                mContext.getString(R.string.billing_cycle_none_left));
+                mActivity.getString(R.string.billing_cycle_none_left));
     }
 
     @Test
@@ -384,7 +383,7 @@
         assertThat(mDataUsed.getText().toString()).isEqualTo("1.00 MB used");
         assertThat(mDataRemaining.getText().toString()).isEqualTo("9.00 MB left");
         assertThat(mDataRemaining.getVisibility()).isEqualTo(View.VISIBLE);
-        final int colorId = Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorAccent);
+        final int colorId = Utils.getColorAttrDefaultColor(mActivity, android.R.attr.colorAccent);
         assertThat(mDataRemaining.getCurrentTextColor()).isEqualTo(colorId);
     }
 
@@ -400,7 +399,7 @@
         bindViewHolder();
         assertThat(mDataUsed.getText().toString()).isEqualTo("11.00 MB used");
         assertThat(mDataRemaining.getText().toString()).isEqualTo("1.00 MB over");
-        final int colorId = Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorError);
+        final int colorId = Utils.getColorAttrDefaultColor(mActivity, android.R.attr.colorError);
         assertThat(mDataRemaining.getCurrentTextColor()).isEqualTo(colorId);
     }
 
@@ -429,7 +428,7 @@
         bindViewHolder();
         assertThat(mLaunchButton.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mLaunchButton.getText())
-                .isEqualTo(mContext.getString(R.string.launch_mdp_app_text));
+                .isEqualTo(mActivity.getString(R.string.launch_mdp_app_text));
 
         mLaunchButton.callOnClick();
         ShadowActivity shadowActivity = Shadows.shadowOf(activity);
@@ -443,12 +442,12 @@
 
     @Test
     public void testSetUsageInfo_withOverflowStrings_dataRemainingNotShown() {
-        LayoutInflater inflater = LayoutInflater.from(mContext);
+        LayoutInflater inflater = LayoutInflater.from(mActivity);
         View view = inflater.inflate(mSummaryPreference.getLayoutResource(), null /* root */,
                 false /* attachToRoot */);
 
-        TextView dataUsed = spy(new TextView(mContext));
-        TextView dataRemaining = spy(new TextView(mContext));
+        TextView dataUsed = spy(new TextView(mActivity));
+        TextView dataRemaining = spy(new TextView(mActivity));
         doReturn(dataUsed).when(mHolder).findViewById(R.id.data_usage_view);
         doReturn(dataRemaining).when(mHolder).findViewById(R.id.data_remaining_view);
 
@@ -459,10 +458,10 @@
                 10 * BillingCycleSettings.MIB_IN_BYTES,
                 true /* hasMobileData */);
 
-        when(mContext.getResources()).thenCallRealMethod();
-        when(mContext.getText(R.string.data_used_formatted))
+        when(mActivity.getResources()).thenCallRealMethod();
+        when(mActivity.getText(R.string.data_used_formatted))
                 .thenReturn("^1 ^2 used with long trailing text");
-        when(mContext.getText(R.string.data_remaining)).thenReturn("^1 left");
+        when(mActivity.getText(R.string.data_remaining)).thenReturn("^1 left");
 
         bindViewHolder();
 
@@ -497,7 +496,7 @@
 
         bindViewHolder();
         assertThat(mUsageTitle.getText().toString())
-                .isEqualTo(mContext.getString(R.string.data_usage_wifi_title));
+                .isEqualTo(mActivity.getString(R.string.data_usage_wifi_title));
         assertThat(mUsageTitle.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mCycleTime.getText()).isEqualTo(cycleText);
@@ -505,7 +504,7 @@
         assertThat(mDataLimits.getVisibility()).isEqualTo(View.GONE);
         assertThat(mLaunchButton.getVisibility()).isEqualTo(View.VISIBLE);
         assertThat(mLaunchButton.getText())
-                .isEqualTo(mContext.getString(R.string.launch_wifi_text));
+                .isEqualTo(mActivity.getString(R.string.launch_wifi_text));
 
         mLaunchButton.callOnClick();
         ShadowActivity shadowActivity = Shadows.shadowOf(activity);
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
index e52ff20..49e3e86 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryTest.java
@@ -39,23 +39,27 @@
 import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
 import com.android.settings.testutils.shadow.ShadowDashboardFragment;
 import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.testutils.shadow.ShadowUtils;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
 @Config(shadows = {
-    SettingsShadowResourcesImpl.class,
-    SettingsShadowResources.SettingsShadowTheme.class,
-    ShadowUtils.class,
-    ShadowDataUsageUtils.class,
-    ShadowDashboardFragment.class
+        SettingsShadowResourcesImpl.class,
+        SettingsShadowResources.SettingsShadowTheme.class,
+        ShadowUtils.class,
+        ShadowDataUsageUtils.class,
+        ShadowDashboardFragment.class,
+        ShadowUserManager.class,
 })
 @RunWith(SettingsRobolectricTestRunner.class)
 public class DataUsageSummaryTest {
@@ -77,15 +81,21 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowContext = ShadowApplication.getInstance();
+        ShadowUserManager.getShadow().setIsAdminUser(true);
         shadowContext.setSystemService(Context.NETWORK_POLICY_SERVICE, mNetworkPolicyManager);
 
-        mContext = shadowContext.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).get());
 
         mSummaryProvider = DataUsageSummary.SUMMARY_PROVIDER_FACTORY
                 .createSummaryProvider(mActivity, mSummaryLoader);
     }
 
+    @After
+    public void tearDown() {
+        ShadowUserManager.getShadow().reset();
+    }
+
     @Test
     public void formatUsage_shouldLookLikeFormatFileSize() {
         SettingsShadowResources.overrideResource(com.android.internal.R.string.fileSizeSuffix,
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
index 4ab4256..9a67df8 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
@@ -39,6 +39,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -57,7 +58,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowContext = ShadowApplication.getInstance();
-        mContext = shadowContext.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
         shadowContext.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
         shadowContext.setSystemService(Context.NETWORK_STATS_SERVICE, mNetworkStatsManager);
@@ -109,6 +110,6 @@
         DataUsageUtils.hasEthernet(mContext);
 
         verify(mNetworkStatsManager).querySummaryForUser(eq(ConnectivityManager.TYPE_ETHERNET),
-            eq(subscriber), anyLong() /* startTime */, anyLong() /* endTime */);
+                eq(subscriber), anyLong() /* startTime */, anyLong() /* endTime */);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java
index ef7e076..e472dbb 100644
--- a/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AdbPreferenceControllerTest.java
@@ -68,7 +68,7 @@
     @Test
     public void onDeveloperOptionsDisabled_shouldDisablePreference() {
         mController.onDeveloperOptionsDisabled();
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.ADB_ENABLED, -1);
 
         assertThat(mode).isEqualTo(AdbPreferenceController.ADB_SETTING_OFF);
@@ -79,7 +79,7 @@
     @Test
     public void onAdbDialogConfirmed_shouldEnableAdbSetting() {
         mController.onAdbDialogConfirmed();
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.ADB_ENABLED, -1);
 
         assertThat(mode).isEqualTo(AdbPreferenceController.ADB_SETTING_ON);
@@ -87,7 +87,7 @@
 
     @Test
     public void onAdbDialogDismissed_preferenceShouldNotBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(), Settings.Global.ADB_ENABLED,
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ADB_ENABLED,
                 AdbPreferenceController.ADB_SETTING_OFF);
         mController.onAdbDialogDismissed();
 
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java
index 0cab3ec..9750d3a 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothDeviceNoNamePreferenceControllerTest.java
@@ -25,6 +25,7 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.os.SystemProperties;
 
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
@@ -37,7 +38,6 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowSystemProperties;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class BluetoothDeviceNoNamePreferenceControllerTest {
@@ -56,7 +56,7 @@
         mContext = RuntimeEnvironment.application;
         mController = new BluetoothDeviceNoNamePreferenceController(mContext);
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
-            .thenReturn(mPreference);
+                .thenReturn(mPreference);
         mController.displayPreference(mPreferenceScreen);
     }
 
@@ -64,8 +64,9 @@
     public void onPreferenceChanged_settingEnabled_shouldTurnOnBluetoothDeviceNoName() {
         mController.onPreferenceChange(mPreference, true /* new value */);
 
-        final boolean mode = ShadowSystemProperties
-            .native_get_boolean(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false /* default */);
+        final boolean mode = SystemProperties.getBoolean(
+                BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY,
+                false /* default */);
 
         assertThat(mode).isTrue();
     }
@@ -74,16 +75,16 @@
     public void onPreferenceChanged_settingDisabled_shouldTurnOffBluetoothDeviceNoName() {
         mController.onPreferenceChange(mPreference, false /* new value */);
 
-        final boolean mode = ShadowSystemProperties
-            .native_get_boolean(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, true /* default */);
+        final boolean mode = SystemProperties.getBoolean(
+                BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, true /* default */);
 
         assertThat(mode).isFalse();
     }
 
     @Test
     public void updateState_settingEnabled_preferenceShouldBeChecked() {
-        ShadowSystemProperties
-            .native_set(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, Boolean.toString(true));
+        SystemProperties.set(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY,
+                Boolean.toString(true));
         mController.updateState(mPreference);
 
         verify(mPreference).setChecked(true);
@@ -91,8 +92,8 @@
 
     @Test
     public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
-        ShadowSystemProperties
-            .native_set(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, Boolean.toString(false));
+        SystemProperties.set(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY,
+                Boolean.toString(false));
         mController.updateState(mPreference);
 
         verify(mPreference).setChecked(false);
@@ -102,8 +103,9 @@
     public void onDeveloperOptionsDisabled_shouldDisablePreference() {
         mController.onDeveloperOptionsDisabled();
 
-        final boolean mode = ShadowSystemProperties
-            .native_get_boolean(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, true /* default */);
+        final boolean mode = SystemProperties.getBoolean(
+                BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY,
+                true /* default */);
 
         assertThat(mode).isFalse();
         verify(mPreference).setEnabled(false);
diff --git a/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
index 56f1944..6ab4d4c 100644
--- a/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ClearAdbKeysPreferenceControllerTest.java
@@ -28,7 +28,7 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
-import android.hardware.usb.IUsbManager;
+import android.debug.IAdbManager;
 import android.os.RemoteException;
 import android.os.SystemProperties;
 
@@ -60,7 +60,7 @@
     @Mock
     private SwitchPreference mPreference;
     @Mock
-    private IUsbManager mUsbManager;
+    private IAdbManager mAdbManager;
     @Mock
     private DevelopmentSettingsDashboardFragment mFragment;
 
@@ -71,7 +71,7 @@
         MockitoAnnotations.initMocks(this);
         final Context context = RuntimeEnvironment.application;
         mController = spy(new ClearAdbKeysPreferenceController(context, mFragment));
-        ReflectionHelpers.setField(mController, "mUsbManager", mUsbManager);
+        ReflectionHelpers.setField(mController, "mAdbManager", mAdbManager);
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
     }
 
@@ -168,7 +168,7 @@
     public void onClearAdbKeysConfirmed_shouldClearKeys() throws RemoteException {
         mController.onClearAdbKeysConfirmed();
 
-        verify(mUsbManager).clearUsbDebuggingKeys();
+        verify(mAdbManager).clearDebuggingKeys();
     }
 
     @Implements(ClearAdbKeysWarningDialog.class)
diff --git a/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java
index e737077..790b46a 100644
--- a/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DebugViewAttributesPreferenceControllerTest.java
@@ -61,7 +61,7 @@
     public void onPreferenceChanged_turnOnViewAttributes() {
         mController.onPreferenceChange(null, true);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.DEBUG_VIEW_ATTRIBUTES, -1);
 
         assertThat(mode).isEqualTo(DebugViewAttributesPreferenceController.SETTING_VALUE_ON);
@@ -71,7 +71,7 @@
     public void onPreferenceChanged_turnOffViewAttributes() {
         mController.onPreferenceChange(null, false);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.DEBUG_VIEW_ATTRIBUTES, -1);
 
         assertThat(mode).isEqualTo(DebugViewAttributesPreferenceController.SETTING_VALUE_OFF);
@@ -79,7 +79,7 @@
 
     @Test
     public void updateState_preferenceShouldBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(), Settings.Global.DEBUG_VIEW_ATTRIBUTES,
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEBUG_VIEW_ATTRIBUTES,
                 DebugViewAttributesPreferenceController.SETTING_VALUE_ON);
         mController.updateState(mPreference);
 
@@ -88,7 +88,7 @@
 
     @Test
     public void updateState_preferenceShouldNotBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(), Settings.Global.DEBUG_VIEW_ATTRIBUTES,
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEBUG_VIEW_ATTRIBUTES,
                 DebugViewAttributesPreferenceController.SETTING_VALUE_OFF);
         mController.updateState(mPreference);
 
@@ -98,7 +98,7 @@
     @Test
     public void onDeveloperOptionsDisabled_shouldDisablePreference() {
         mController.onDeveloperOptionsDisabled();
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.DEBUG_VIEW_ATTRIBUTES, -1);
 
         assertThat(mode).isEqualTo(DebugViewAttributesPreferenceController.SETTING_VALUE_OFF);
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
index fffcd4c..a3abb07 100644
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
@@ -25,7 +25,6 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
-import android.os.UserManager;
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
 
@@ -33,6 +32,7 @@
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.widget.SwitchBar;
 import com.android.settings.widget.ToggleSwitch;
 import com.android.settingslib.development.AbstractEnableAdbPreferenceController;
@@ -44,16 +44,15 @@
 import org.junit.runner.RunWith;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
-import org.robolectric.shadows.ShadowUserManager;
 import org.robolectric.util.ReflectionHelpers;
 
 import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = ShadowUserManager.class)
 public class DevelopmentSettingsDashboardFragmentTest {
 
     private ToggleSwitch mSwitch;
@@ -69,14 +68,14 @@
         mSwitch = switchBar.getSwitch();
         mDashboard = spy(new DevelopmentSettingsDashboardFragment());
         ReflectionHelpers.setField(mDashboard, "mSwitchBar", switchBar);
-        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        mShadowUserManager = Shadows.shadowOf(userManager);
+        mShadowUserManager = ShadowUserManager.getShadow();
         mShadowUserManager.setIsAdminUser(true);
     }
 
     @After
     public void tearDown() {
         ShadowEnableDevelopmentSettingWarningDialog.reset();
+        mShadowUserManager.reset();
     }
 
     @Test
@@ -87,7 +86,7 @@
     @Test
     public void shouldLogAsFeatureFlagPage() {
         assertThat(mDashboard.getMetricsCategory())
-            .isEqualTo(MetricsProto.MetricsEvent.DEVELOPMENT);
+                .isEqualTo(MetricsProto.MetricsEvent.DEVELOPMENT);
     }
 
     @Test
@@ -184,7 +183,7 @@
     public void onOemUnlockDialogConfirmed_shouldCallControllerOemConfirmed() {
         final OemUnlockPreferenceController controller = mock(OemUnlockPreferenceController.class);
         doReturn(controller).when(mDashboard)
-            .getDevelopmentOptionsController(OemUnlockPreferenceController.class);
+                .getDevelopmentOptionsController(OemUnlockPreferenceController.class);
         mDashboard.onOemUnlockDialogConfirmed();
         verify(controller).onOemUnlockConfirmed();
     }
@@ -193,7 +192,7 @@
     public void onOemUnlockDialogConfirmed_shouldCallControllerOemDismissed() {
         final OemUnlockPreferenceController controller = mock(OemUnlockPreferenceController.class);
         doReturn(controller).when(mDashboard)
-            .getDevelopmentOptionsController(OemUnlockPreferenceController.class);
+                .getDevelopmentOptionsController(OemUnlockPreferenceController.class);
         mDashboard.onOemUnlockDialogDismissed();
         verify(controller).onOemUnlockDismissed();
     }
@@ -202,7 +201,7 @@
     public void onAdbDialogConfirmed_shouldCallControllerDialogConfirmed() {
         final AdbPreferenceController controller = mock(AdbPreferenceController.class);
         doReturn(controller).when(mDashboard)
-            .getDevelopmentOptionsController(AdbPreferenceController.class);
+                .getDevelopmentOptionsController(AdbPreferenceController.class);
         mDashboard.onEnableAdbDialogConfirmed();
 
         verify(controller).onAdbDialogConfirmed();
@@ -212,7 +211,7 @@
     public void onAdbDialogDismissed_shouldCallControllerOemDismissed() {
         final AdbPreferenceController controller = mock(AdbPreferenceController.class);
         doReturn(controller).when(mDashboard)
-            .getDevelopmentOptionsController(AdbPreferenceController.class);
+                .getDevelopmentOptionsController(AdbPreferenceController.class);
         mDashboard.onEnableAdbDialogDismissed();
 
         verify(controller).onAdbDialogDismissed();
@@ -221,9 +220,9 @@
     @Test
     public void onAdbClearKeysDialogConfirmed_shouldCallControllerDialogConfirmed() {
         final ClearAdbKeysPreferenceController controller =
-            mock(ClearAdbKeysPreferenceController.class);
+                mock(ClearAdbKeysPreferenceController.class);
         doReturn(controller).when(mDashboard)
-            .getDevelopmentOptionsController(ClearAdbKeysPreferenceController.class);
+                .getDevelopmentOptionsController(ClearAdbKeysPreferenceController.class);
         mDashboard.onAdbClearKeysDialogConfirmed();
 
         verify(controller).onClearAdbKeysConfirmed();
@@ -232,9 +231,9 @@
     @Test
     public void onDisableLogPersistDialogConfirmed_shouldCallControllerDialogConfirmed() {
         final LogPersistPreferenceController controller =
-            mock(LogPersistPreferenceController.class);
+                mock(LogPersistPreferenceController.class);
         doReturn(controller).when(mDashboard)
-            .getDevelopmentOptionsController(LogPersistPreferenceController.class);
+                .getDevelopmentOptionsController(LogPersistPreferenceController.class);
         mDashboard.onDisableLogPersistDialogConfirmed();
 
         verify(controller).onDisableLogPersistDialogConfirmed();
@@ -243,9 +242,9 @@
     @Test
     public void onDisableLogPersistDialogRejected_shouldCallControllerDialogRejected() {
         final LogPersistPreferenceController controller =
-            mock(LogPersistPreferenceController.class);
+                mock(LogPersistPreferenceController.class);
         doReturn(controller).when(mDashboard)
-            .getDevelopmentOptionsController(LogPersistPreferenceController.class);
+                .getDevelopmentOptionsController(LogPersistPreferenceController.class);
         mDashboard.onDisableLogPersistDialogRejected();
 
         verify(controller).onDisableLogPersistDialogRejected();
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
index a6d11e9..688db76 100644
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
@@ -24,11 +24,11 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
-import android.os.UserManager;
 
 import androidx.lifecycle.LifecycleOwner;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.testutils.shadow.ShadowUtils;
 import com.android.settings.widget.SwitchBar;
 import com.android.settings.widget.SwitchBar.OnSwitchChangeListener;
@@ -41,14 +41,13 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.util.ReflectionHelpers;
 
 import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowUtils.class)
+@Config(shadows = {ShadowUtils.class, ShadowUserManager.class})
 public class DevelopmentSwitchBarControllerTest {
 
     @Mock
@@ -61,8 +60,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         final Context context = RuntimeEnvironment.application;
-        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
-        Shadows.shadowOf(userManager).setIsAdminUser(true);
+        ShadowUserManager.getShadow().setIsAdminUser(true);
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
         mSwitchBar = new SwitchBar(context);
@@ -72,6 +70,7 @@
     @After
     public void tearDown() {
         ShadowUtils.reset();
+        ShadowUserManager.getShadow().reset();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
index 8bc3ef6..5c76e08 100644
--- a/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
@@ -61,7 +61,7 @@
     public void onPreferenceChanged_turnOnAutomaticUpdates() {
         mController.onPreferenceChange(null, true);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, -1);
 
         assertThat(mode).isEqualTo(
@@ -72,7 +72,7 @@
     public void onPreferenceChanged_turnOffAutomaticUpdates() {
         mController.onPreferenceChange(null, false);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, -1);
 
         assertThat(mode).isEqualTo(
@@ -81,7 +81,7 @@
 
     @Test
     public void updateState_preferenceShouldBeChecked() {
-        Settings.System
+        Settings.Global
                 .putInt(mContext.getContentResolver(), Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
                         DisableAutomaticUpdatesPreferenceController.ENABLE_UPDATES_SETTING);
         mController.updateState(mPreference);
@@ -91,7 +91,7 @@
 
     @Test
     public void updateState_preferenceShouldNotBeChecked() {
-        Settings.System
+        Settings.Global
                 .putInt(mContext.getContentResolver(), Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
                         DisableAutomaticUpdatesPreferenceController.DISABLE_UPDATES_SETTING);
         mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java
index a71f9b0..05aee64 100644
--- a/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/KeepActivitiesPreferenceControllerTest.java
@@ -84,7 +84,7 @@
 
     @Test
     public void updateState_settingEnabled_preferenceShouldBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.ALWAYS_FINISH_ACTIVITIES, SETTING_VALUE_ON);
         mController.updateState(mPreference);
 
@@ -93,7 +93,7 @@
 
     @Test
     public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.ALWAYS_FINISH_ACTIVITIES, SETTING_VALUE_OFF);
         mController.updateState(mPreference);
 
diff --git a/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java
index 7424753..a578429 100644
--- a/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/MobileDataAlwaysOnPreferenceControllerTest.java
@@ -61,7 +61,7 @@
     public void onPreferenceChanged_turnOnPreference_shouldEnableMobileDataAlwaysOn() {
         mController.onPreferenceChange(mPreference, true /* new value */);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.MOBILE_DATA_ALWAYS_ON, -1 /* default */);
 
         assertThat(mode).isEqualTo(MobileDataAlwaysOnPreferenceController.SETTING_VALUE_ON);
@@ -71,7 +71,7 @@
     public void onPreferenceChanged_turnOffPreference_shouldDisableMobileDataAlwaysOn() {
         mController.onPreferenceChange(mPreference, false /* new value */);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.MOBILE_DATA_ALWAYS_ON, -1 /* default */);
 
         assertThat(mode).isEqualTo(MobileDataAlwaysOnPreferenceController.SETTING_VALUE_OFF);
@@ -79,7 +79,7 @@
 
     @Test
     public void updateState_settingEnabled_preferenceShouldBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON,
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON,
                 MobileDataAlwaysOnPreferenceController.SETTING_VALUE_ON);
         mController.updateState(mPreference);
 
@@ -88,7 +88,7 @@
 
     @Test
     public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON,
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON,
                 MobileDataAlwaysOnPreferenceController.SETTING_VALUE_OFF);
         mController.updateState(mPreference);
 
@@ -98,7 +98,7 @@
     @Test
     public void onDeveloperOptionsSwitchDisabled_preferenceShouldBeDisabled() {
         mController.onDeveloperOptionsSwitchDisabled();
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.MOBILE_DATA_ALWAYS_ON, -1 /* default */);
 
         assertThat(mode).isEqualTo(MobileDataAlwaysOnPreferenceController.SETTING_VALUE_OFF);
diff --git a/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java
index 05edd14..97b4bf0 100644
--- a/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/StayAwakePreferenceControllerTest.java
@@ -72,7 +72,7 @@
     public void onPreferenceChanged_turnOnStayAwake() {
         mController.onPreferenceChange(null, true);
 
-        final int mode = Settings.System.getInt(mContentResolver,
+        final int mode = Settings.Global.getInt(mContentResolver,
                 Settings.Global.STAY_ON_WHILE_PLUGGED_IN, -1);
 
         assertThat(mode).isEqualTo(StayAwakePreferenceController.SETTING_VALUE_ON);
@@ -82,7 +82,7 @@
     public void onPreferenceChanged_turnOffStayAwake() {
         mController.onPreferenceChange(null, false);
 
-        final int mode = Settings.System.getInt(mContentResolver,
+        final int mode = Settings.Global.getInt(mContentResolver,
                 Settings.Global.STAY_ON_WHILE_PLUGGED_IN, -1);
 
         assertThat(mode).isEqualTo(StayAwakePreferenceController.SETTING_VALUE_OFF);
@@ -90,7 +90,7 @@
 
     @Test
     public void updateState_preferenceShouldBeChecked() {
-        Settings.System.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
+        Settings.Global.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
                 StayAwakePreferenceController.SETTING_VALUE_ON);
         mController.updateState(mPreference);
 
@@ -99,7 +99,7 @@
 
     @Test
     public void updateState_preferenceShouldNotBeChecked() {
-        Settings.System.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
+        Settings.Global.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
                 StayAwakePreferenceController.SETTING_VALUE_OFF);
         mController.updateState(mPreference);
 
@@ -119,7 +119,7 @@
 
     @Test
     public void observerOnChangeCalledWithSameUri_preferenceShouldBeUpdated() {
-        Settings.System.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
+        Settings.Global.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
                 StayAwakePreferenceController.SETTING_VALUE_ON);
         mController.onResume();
         mController.mSettingsObserver.onChange(false,
@@ -130,7 +130,7 @@
 
     @Test
     public void observerOnChangeCalledWithDifferentUri_preferenceShouldNotBeUpdated() {
-        Settings.System.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
+        Settings.Global.putInt(mContentResolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
                 StayAwakePreferenceController.SETTING_VALUE_ON);
         mController.onResume();
         mController.mSettingsObserver.onChange(false, null);
diff --git a/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java
index e44aeb4..dc1d622 100644
--- a/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/TetheringHardwareAccelPreferenceControllerTest.java
@@ -61,7 +61,7 @@
     public void onPreferenceChanged_settingEnabled_turnOnTetheringAccel() {
         mController.onPreferenceChange(mPreference, true /* new value */);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.TETHER_OFFLOAD_DISABLED, -1 /* default */);
 
         assertThat(mode).isEqualTo(TetheringHardwareAccelPreferenceController.SETTING_VALUE_ON);
@@ -71,7 +71,7 @@
     public void onPreferenceChanged_settingDisabled_turnOffTetheringAccel() {
         mController.onPreferenceChange(mPreference, false /* new value */);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.TETHER_OFFLOAD_DISABLED, -1 /* default */);
 
         assertThat(mode).isEqualTo(TetheringHardwareAccelPreferenceController.SETTING_VALUE_OFF);
@@ -79,7 +79,7 @@
 
     @Test
     public void updateState_settingEnabled_preferenceShouldBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.TETHER_OFFLOAD_DISABLED,
                 TetheringHardwareAccelPreferenceController.SETTING_VALUE_ON);
         mController.updateState(mPreference);
@@ -89,7 +89,7 @@
 
     @Test
     public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.TETHER_OFFLOAD_DISABLED,
                 TetheringHardwareAccelPreferenceController.SETTING_VALUE_OFF);
         mController.updateState(mPreference);
@@ -100,7 +100,7 @@
     @Test
     public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
         mController.onDeveloperOptionsSwitchDisabled();
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.TETHER_OFFLOAD_DISABLED, -1 /* default */);
 
         assertThat(mode).isEqualTo(TetheringHardwareAccelPreferenceController.SETTING_VALUE_OFF);
diff --git a/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java
index 742bc7f..f712423 100644
--- a/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WifiDisplayCertificationPreferenceControllerTest.java
@@ -61,7 +61,7 @@
     public void onPreferenceChanged_turnOnWifiDisplayCertification() {
         mController.onPreferenceChange(mPreference, true /* new value */);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, -1 /* default */);
 
         assertThat(mode).isEqualTo(WifiDisplayCertificationPreferenceController.SETTING_VALUE_ON);
@@ -71,7 +71,7 @@
     public void onPreferenceChanged_turnOffWifiDisplayCertification() {
         mController.onPreferenceChange(mPreference, false /* new value */);
 
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, -1 /* default */);
 
         assertThat(mode).isEqualTo(WifiDisplayCertificationPreferenceController.SETTING_VALUE_OFF);
@@ -79,7 +79,7 @@
 
     @Test
     public void updateState_preferenceShouldBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON,
                 WifiDisplayCertificationPreferenceController.SETTING_VALUE_ON);
         mController.updateState(mPreference);
@@ -89,7 +89,7 @@
 
     @Test
     public void updateState_preferenceShouldNotBeChecked() {
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON,
                 WifiDisplayCertificationPreferenceController.SETTING_VALUE_OFF);
         mController.updateState(mPreference);
@@ -100,7 +100,7 @@
     @Test
     public void onDeveloperOptionsDisabled_shouldDisablePreference() {
         mController.onDeveloperOptionsDisabled();
-        final int mode = Settings.System.getInt(mContext.getContentResolver(),
+        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, -1 /* default */);
 
         assertThat(mode).isEqualTo(WifiDisplayCertificationPreferenceController.SETTING_VALUE_OFF);
diff --git a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilesTest.java b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilesTest.java
index c6ac4ae..12661e3 100644
--- a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilesTest.java
+++ b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilesTest.java
@@ -24,6 +24,7 @@
 
 import android.content.ComponentName;
 import android.content.pm.PackageManager;
+import android.os.UserManager;
 import android.service.quicksettings.Tile;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -35,6 +36,9 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowUserManager;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class DevelopmentTilesTest {
@@ -50,6 +54,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mService = spy(Robolectric.setupService(DevelopmentTiles.ShowLayout.class));
+        final ShadowUserManager um = Shadows.shadowOf(
+                RuntimeEnvironment.application.getSystemService(UserManager.class));
+        um.setIsAdminUser(true);
         doReturn(mTile).when(mService).getQsTile();
     }
 
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
index d1d98eb..c88237d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
@@ -81,10 +81,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
-        final UserManager userManager =
-                (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        mShadowUserManager = Shadows.shadowOf(userManager);
-        mShadowUserManager.setIsAdminUser(true);
+        mShadowUserManager = Shadows.shadowOf(
+                RuntimeEnvironment.application.getSystemService(UserManager.class));
         mFactory = FakeFeatureFactory.setupForTest();
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
@@ -101,8 +99,6 @@
     @After
     public void tearDown() {
         ShadowUtils.reset();
-        mShadowUserManager.setIsAdminUser(false);
-        mShadowUserManager.setIsDemoUser(false);
     }
 
     @Test
@@ -201,6 +197,7 @@
 
     @Test
     public void onActivityResult_confirmPasswordRequestCompleted_enableDevPref() {
+        mShadowUserManager.setIsAdminUser(true);
         mController =
                 new BuildNumberPreferenceController(mContext, mActivity, mFragment, mLifecycle);
 
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java
index 8662c7f..9fb756a 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java
@@ -44,6 +44,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
@@ -67,7 +68,7 @@
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.WIFI_SERVICE, mWifiManager);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mPreference = new ValidatedEditTextPreference(mContext);
         when(mScreen.findPreference(anyString())).thenReturn(mPreference);
         final WifiConfiguration configuration = new WifiConfiguration();
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
index 8ba4553..983621c 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PrivateVolumeOptionMenuControllerTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.pm.PackageManager;
 import android.os.storage.VolumeInfo;
 import android.view.Menu;
@@ -37,7 +38,7 @@
 import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -68,7 +69,7 @@
         when(mMigrateMenuItem.getItemId()).thenReturn(100);
 
         mController = new PrivateVolumeOptionMenuController(
-                RuntimeEnvironment.application, mPrimaryInfo, mPm);
+                Robolectric.setupActivity(Activity.class), mPrimaryInfo, mPm);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SecurityPatchLevelDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SecurityPatchLevelDialogControllerTest.java
index 8cb484e..fe7633c 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SecurityPatchLevelDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/SecurityPatchLevelDialogControllerTest.java
@@ -29,6 +29,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.Build;
@@ -41,7 +42,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 import org.robolectric.util.ReflectionHelpers;
 
 import java.util.Collections;
@@ -62,7 +63,7 @@
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         when(mDialog.getContext()).thenReturn(mContext);
     }
 
@@ -91,7 +92,7 @@
     @Test
     public void onClick_noActivityIntent_shouldDoNothing() {
         when(mPackageManager.queryIntentActivities(any(), anyInt()))
-            .thenReturn(Collections.emptyList());
+                .thenReturn(Collections.emptyList());
         mController = new SecurityPatchLevelDialogController(mDialog);
         ReflectionHelpers.setField(mController, "mPackageManager", mPackageManager);
 
@@ -103,7 +104,7 @@
     @Test
     public void onClick_activityIntentFound_shouldStartActivity() {
         when(mPackageManager.queryIntentActivities(any(), anyInt()))
-            .thenReturn(Collections.singletonList(null));
+                .thenReturn(Collections.singletonList(null));
         mController = new SecurityPatchLevelDialogController(mDialog);
         ReflectionHelpers.setField(mController, "mPackageManager", mPackageManager);
 
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
index b51ae00..6892191 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
@@ -28,6 +28,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.Context;
 import android.os.storage.VolumeInfo;
 import android.text.format.Formatter;
@@ -51,15 +52,15 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 import org.robolectric.annotation.Config;
 
 import java.io.File;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = {
-    SettingsShadowResources.class,
-    SettingsShadowResources.SettingsShadowTheme.class
+        SettingsShadowResources.class,
+        SettingsShadowResources.SettingsShadowTheme.class
 })
 public class StorageSummaryDonutPreferenceControllerTest {
 
@@ -74,7 +75,7 @@
     public void setUp() throws Exception {
         SettingsShadowResources.overrideResource(
                 com.android.internal.R.string.config_headlineFontFamily, "");
-        mContext = spy(RuntimeEnvironment.application.getApplicationContext());
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
         mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
         mController = new StorageSummaryDonutPreferenceController(mContext);
@@ -82,7 +83,8 @@
 
         LayoutInflater inflater = LayoutInflater.from(mContext);
         final View view =
-            inflater.inflate(mPreference.getLayoutResource(), new LinearLayout(mContext), false);
+                inflater.inflate(mPreference.getLayoutResource(), new LinearLayout(mContext),
+                        false);
         mHolder = PreferenceViewHolder.createInstanceForTests(view);
     }
 
@@ -92,37 +94,37 @@
     }
 
     @Test
-    public void testEmpty() throws Exception {
+    public void testEmpty() {
         final long totalSpace = 32 * GIGABYTE;
         final long usedSpace = 0;
         mController.updateBytes(0, 32 * GIGABYTE);
         mController.updateState(mPreference);
 
         final Formatter.BytesResult usedSpaceResults =
-            Formatter.formatBytes(mContext.getResources(), usedSpace, 0 /* flags */);
+                Formatter.formatBytes(mContext.getResources(), usedSpace, 0 /* flags */);
         assertThat(mPreference.getTitle().toString())
-            .isEqualTo(usedSpaceResults.value + " " + usedSpaceResults.units);
+                .isEqualTo(usedSpaceResults.value + " " + usedSpaceResults.units);
         assertThat(mPreference.getSummary().toString())
-            .isEqualTo("Used of " + Formatter.formatShortFileSize(mContext, totalSpace));
+                .isEqualTo("Used of " + Formatter.formatShortFileSize(mContext, totalSpace));
     }
 
     @Test
-    public void testTotalStorage() throws Exception {
+    public void testTotalStorage() {
         final long totalSpace = KILOBYTE * 10;
         final long usedSpace = KILOBYTE;
         mController.updateBytes(KILOBYTE, totalSpace);
         mController.updateState(mPreference);
 
         final Formatter.BytesResult usedSpaceResults =
-            Formatter.formatBytes(mContext.getResources(), usedSpace, 0 /* flags */);
+                Formatter.formatBytes(mContext.getResources(), usedSpace, 0 /* flags */);
         assertThat(mPreference.getTitle().toString())
-            .isEqualTo(usedSpaceResults.value + " " + usedSpaceResults.units);
+                .isEqualTo(usedSpaceResults.value + " " + usedSpaceResults.units);
         assertThat(mPreference.getSummary().toString())
-            .isEqualTo("Used of " + Formatter.formatShortFileSize(mContext, totalSpace));
+                .isEqualTo("Used of " + Formatter.formatShortFileSize(mContext, totalSpace));
     }
 
     @Test
-    public void testPopulateWithVolume() throws Exception {
+    public void testPopulateWithVolume() {
         final long totalSpace = KILOBYTE * 10;
         final long freeSpace = KILOBYTE;
         final long usedSpace = totalSpace - freeSpace;
@@ -138,21 +140,21 @@
         mController.updateState(mPreference);
 
         final Formatter.BytesResult usedSpaceResults =
-            Formatter.formatBytes(mContext.getResources(), usedSpace, 0 /* flags */);
+                Formatter.formatBytes(mContext.getResources(), usedSpace, 0 /* flags */);
         assertThat(mPreference.getTitle().toString())
-            .isEqualTo(usedSpaceResults.value + " " + usedSpaceResults.units);
+                .isEqualTo(usedSpaceResults.value + " " + usedSpaceResults.units);
         assertThat(mPreference.getSummary().toString())
-            .isEqualTo("Used of " + Formatter.formatShortFileSize(mContext, totalSpace));
+                .isEqualTo("Used of " + Formatter.formatShortFileSize(mContext, totalSpace));
     }
 
     @Test
-    public void testFreeUpSpaceMetricIsTriggered() throws Exception {
+    public void testFreeUpSpaceMetricIsTriggered() {
         mPreference.onBindViewHolder(mHolder);
         final Button button = (Button) mHolder.findViewById(R.id.deletion_helper_button);
 
         mPreference.onClick(button);
 
         verify(mMetricsFeatureProvider, times(1))
-            .action(any(Context.class), eq(MetricsEvent.STORAGE_FREE_UP_SPACE_NOW));
+                .action(any(Context.class), eq(MetricsEvent.STORAGE_FREE_UP_SPACE_NOW));
     }
 }
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java
index 419aab5..4706b7d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java
@@ -25,6 +25,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.UserInfo;
@@ -47,7 +48,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class UserProfileControllerTest {
@@ -64,7 +65,7 @@
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         mPrimaryProfile = new UserInfo();
         mController = new UserProfileController(mContext, mPrimaryProfile, 0);
         when(mScreen.getContext()).thenReturn(mContext);
@@ -74,7 +75,7 @@
     }
 
     @Test
-    public void controllerAddsPrimaryProfilePreference() throws Exception {
+    public void controllerAddsPrimaryProfilePreference() {
         final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
         verify(mScreen).addPreference(argumentCaptor.capture());
         final Preference preference = argumentCaptor.getValue();
@@ -84,7 +85,7 @@
     }
 
     @Test
-    public void tappingProfilePreferenceSendsToStorageProfileFragment() throws Exception {
+    public void tappingProfilePreferenceSendsToStorageProfileFragment() {
 
         final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
         verify(mScreen).addPreference(argumentCaptor.capture());
@@ -100,7 +101,7 @@
     }
 
     @Test
-    public void acceptingResultUpdatesPreferenceSize() throws Exception {
+    public void acceptingResultUpdatesPreferenceSize() {
         final SparseArray<StorageAsyncLoader.AppsStorageResult> result = new SparseArray<>();
         final StorageAsyncLoader.AppsStorageResult userResult =
                 new StorageAsyncLoader.AppsStorageResult();
@@ -121,7 +122,7 @@
     }
 
     @Test
-    public void iconCallbackChangesPreferenceIcon() throws Exception {
+    public void iconCallbackChangesPreferenceIcon() {
         final SparseArray<Drawable> icons = new SparseArray<>();
         final UserIconDrawable drawable = mock(UserIconDrawable.class);
         when(drawable.mutate()).thenReturn(drawable);
diff --git a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java
index 0a265a1..0a661b4 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java
@@ -67,7 +67,7 @@
 
     @Before
     public void setUp() {
-        mActivity = Robolectric.buildActivity(CustomActivity.class).get();
+        mActivity = Robolectric.setupActivity(CustomActivity.class);
         mActivityShadow = Shadow.extract(mActivity);
         mHelper = new ActionDisabledByAdminDialogHelper(mActivity);
     }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
index 98031c9..0d3a391 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
@@ -26,6 +26,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.Activity;
 import android.app.AppOpsManager;
 import android.content.Context;
 import android.content.Intent;
@@ -45,7 +46,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -92,7 +93,7 @@
         mOtherUserPackageOps = new AppOpsManager.PackageOps(
                 RESTRICTED_PACKAGE_NAME, OTHER_USER_UID, restrictedOps);
 
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
         doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
         doReturn(mContext).when(mFragment).getContext();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java
index 39555b2..55ab113 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java
@@ -18,6 +18,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.Activity;
 import android.content.Context;
 
 import com.android.internal.logging.nano.MetricsProto;
@@ -37,7 +38,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -63,7 +64,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
+        mContext = Robolectric.setupActivity(Activity.class);
 
         mAppInfos = new ArrayList<>();
         mAppInfos.add(new AppInfo.Builder()
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTipTest.java
index 371bfb4..1c8bfdb 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryTipTest.java
@@ -27,6 +27,7 @@
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.testutils.DrawableTestHelper;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -59,7 +60,7 @@
 
         assertThat(preference.getTitle()).isEqualTo(TITLE);
         assertThat(preference.getSummary()).isEqualTo(SUMMARY);
-        assertThat(preference.getIcon()).isEqualTo(mContext.getDrawable(ICON_ID));
+        DrawableTestHelper.assertDrawableResId(preference.getIcon(), ICON_ID);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
index 7d8a88e..20bf4e6 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
@@ -82,7 +82,7 @@
     @Test
     public void testIsChecked_configIsNotSet_shouldReturnTrue() {
         // Set the setting to be enabled.
-        Settings.System.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, ON);
+        Settings.Secure.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, ON);
         mController = new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
 
         assertThat(mController.isChecked()).isTrue();
@@ -91,7 +91,7 @@
     @Test
     public void testIsChecked_configIsSet_shouldReturnFalse() {
         // Set the setting to be disabled.
-        Settings.System.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, OFF);
+        Settings.Secure.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, OFF);
         mController = new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
 
         assertThat(mController.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
index 0fce463..ae97336 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
@@ -139,7 +139,7 @@
     public void testIsChecked_configIsSet_shouldReturnTrue() {
         // Set the setting to be enabled.
         final Context context = RuntimeEnvironment.application;
-        Settings.System.putInt(context.getContentResolver(),
+        Settings.Secure.putInt(context.getContentResolver(),
                 Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
         mController = new DoubleTwistPreferenceController(context, KEY_DOUBLE_TWIST);
 
@@ -150,7 +150,7 @@
     public void testIsChecked_configIsNotSet_shouldReturnFalse() {
         // Set the setting to be disabled.
         final Context context = RuntimeEnvironment.application;
-        Settings.System.putInt(context.getContentResolver(),
+        Settings.Secure.putInt(context.getContentResolver(),
                 Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 0);
         mController = new DoubleTwistPreferenceController(context, KEY_DOUBLE_TWIST);
 
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index fefff22..b2816b5 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -100,7 +100,7 @@
         when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
         // Set the setting to be enabled.
         final Context context = RuntimeEnvironment.application;
-        Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 1);
+        Settings.Secure.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 1);
         mController = new SwipeToNotificationPreferenceController(context, KEY_SWIPE_DOWN);
 
         assertThat(mController.isChecked()).isTrue();
@@ -112,7 +112,7 @@
         when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
         // Set the setting to be disabled.
         final Context context = RuntimeEnvironment.application;
-        Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 0);
+        Settings.Secure.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 0);
         mController = new SwipeToNotificationPreferenceController(context, KEY_SWIPE_DOWN);
 
         assertThat(mController.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
index b140b52..1ce6d0a 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
@@ -21,7 +21,9 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
 
 import com.android.internal.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -69,7 +71,14 @@
                 mContext.getString(com.android.internal.R.string.config_recentsComponentName));
         final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
                 .setPackage(recentsComponentName.getPackageName());
-        mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
+        final ResolveInfo info = new ResolveInfo();
+        info.serviceInfo = new ServiceInfo();
+        info.resolvePackageName = recentsComponentName.getPackageName();
+        info.serviceInfo.packageName = info.resolvePackageName;
+        info.serviceInfo.name = recentsComponentName.getClassName();
+        info.serviceInfo.applicationInfo = new ApplicationInfo();
+        info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
+        mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
 
         assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isTrue();
     }
@@ -121,7 +130,7 @@
     @Test
     public void isSliceableCorrectKey_returnsTrue() {
         final SwipeUpPreferenceController controller =
-                new SwipeUpPreferenceController(mContext,"gesture_swipe_up");
+                new SwipeUpPreferenceController(mContext, "gesture_swipe_up");
         assertThat(controller.isSliceable()).isTrue();
     }
 
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BackgroundDataConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BackgroundDataConditionControllerTest.java
index 05060aa..a962bc1 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BackgroundDataConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BackgroundDataConditionControllerTest.java
@@ -17,11 +17,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.Activity;
+import android.content.ComponentName;
 import android.content.Context;
-import android.content.Intent;
 import android.net.NetworkPolicyManager;
 
 import com.android.settings.Settings;
@@ -30,10 +30,11 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowActivity;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -43,7 +44,7 @@
     private ConditionManager mConditionManager;
     @Mock
     private NetworkPolicyManager mNetworkPolicyManager;
-    private Context mContext;
+    private Activity mActivity;
     private BackgroundDataConditionController mController;
 
     @Before
@@ -51,19 +52,19 @@
         MockitoAnnotations.initMocks(this);
         ShadowApplication.getInstance().setSystemService(Context.NETWORK_POLICY_SERVICE,
                 mNetworkPolicyManager);
-        mContext = spy(RuntimeEnvironment.application);
-        mController = new BackgroundDataConditionController(mContext, mConditionManager);
+        mActivity = Robolectric.setupActivity(Activity.class);
+        mController = new BackgroundDataConditionController(mActivity, mConditionManager);
     }
 
     @Test
     public void onPrimaryClick_shouldReturn2SummaryActivity() {
-        final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        mController.onPrimaryClick(mContext);
-        verify(mContext).startActivity(argumentCaptor.capture());
-        Intent intent = argumentCaptor.getValue();
+        final ComponentName componentName =
+                new ComponentName(mActivity, Settings.DataUsageSummaryActivity.class);
 
-        assertThat(intent.getComponent().getClassName()).isEqualTo(
-                Settings.DataUsageSummaryActivity.class.getName());
+        mController.onPrimaryClick(mActivity);
+
+        final ShadowActivity shadowActivity = Shadow.extract(mActivity);
+        assertThat(shadowActivity.getNextStartedActivity().getComponent()).isEqualTo(componentName);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/WorkModeConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/WorkModeConditionControllerTest.java
index 847d28c..2bc92a3 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/WorkModeConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/WorkModeConditionControllerTest.java
@@ -16,12 +16,12 @@
 
 package com.android.settings.homepage.contextualcards.conditional;
 
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
+import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
+
+import android.app.Activity;
 import android.content.ComponentName;
-import android.content.Context;
 
 import com.android.settings.Settings;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -31,32 +31,34 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowActivity;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class WorkModeConditionControllerTest {
 
     @Mock
     private ConditionManager mConditionManager;
-    private Context mContext;
+    private Activity mActivity;
     private WorkModeConditionController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
-        mController = new WorkModeConditionController(mContext, mConditionManager);
+        mActivity = spy(Robolectric.setupActivity(Activity.class));
+        mController = new WorkModeConditionController(mActivity, mConditionManager);
     }
 
     @Test
     public void onPrimaryClick_shouldLaunchAccountsSetting() {
         final ComponentName componentName =
-                new ComponentName(mContext, Settings.AccountDashboardActivity.class);
+                new ComponentName(mActivity, Settings.AccountDashboardActivity.class);
 
-        mController.onPrimaryClick(mContext);
+        mController.onPrimaryClick(mActivity);
 
-        verify(mContext).startActivity(
-                argThat(intent -> intent.getComponent().equals(componentName)));
+        final ShadowActivity shadowActivity = Shadow.extract(mActivity);
+        assertThat(shadowActivity.getNextStartedActivity().getComponent()).isEqualTo(componentName);
     }
 
 }
diff --git a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
index 16c694e..a15fdff 100644
--- a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
@@ -31,16 +31,16 @@
 
     @Test
     public void isAvailable_noLocationLinkPermission_shouldReturnFalse() {
-        Settings.System.putInt(mContext.getContentResolver(),
-                android.provider.Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 0);
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 0);
 
         assertThat(mController.isAvailable()).isFalse();
     }
 
     @Test
     public void displayPreference_hasLocationLinkPermission_shouldReturnTrue() {
-        Settings.System.putInt(mContext.getContentResolver(),
-                android.provider.Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 1);
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED, 1);
 
         assertThat(mController.isAvailable()).isTrue();
     }
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
index 1687210..a8959c7 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
@@ -30,6 +30,7 @@
 import static org.mockito.Mockito.when;
 import static org.robolectric.shadow.api.Shadow.extract;
 
+import android.app.Activity;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -59,7 +60,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 import org.robolectric.annotation.Config;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -83,7 +84,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
         when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
diff --git a/tests/robotests/src/com/android/settings/network/TopLevelNetworkEntryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/TopLevelNetworkEntryPreferenceControllerTest.java
index 004e352..8198042 100644
--- a/tests/robotests/src/com/android/settings/network/TopLevelNetworkEntryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TopLevelNetworkEntryPreferenceControllerTest.java
@@ -21,6 +21,7 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.os.UserManager;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
@@ -32,9 +33,12 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowUserManager;
 import org.robolectric.util.ReflectionHelpers;
 
+
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
 public class TopLevelNetworkEntryPreferenceControllerTest {
@@ -53,6 +57,10 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
+        final ShadowUserManager um = Shadows.shadowOf(
+                RuntimeEnvironment.application.getSystemService(UserManager.class));
+        um.setIsAdminUser(true);
+
         mController = new TopLevelNetworkEntryPreferenceController(mContext, "test_key");
 
         ReflectionHelpers.setField(mController, "mWifiPreferenceController",
@@ -61,7 +69,6 @@
                 mMobileNetworkPreferenceController);
         ReflectionHelpers.setField(mController, "mTetherPreferenceController",
                 mTetherPreferenceController);
-
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
index 0fda51f..dc277d2 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/ApnPreferenceControllerTest.java
@@ -25,6 +25,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.os.PersistableBundle;
@@ -44,7 +45,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class ApnPreferenceControllerTest {
@@ -67,7 +68,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
         doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
         doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/DataServiceSetupPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DataServiceSetupPreferenceControllerTest.java
index 644a5bc..85a627d 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/DataServiceSetupPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/DataServiceSetupPreferenceControllerTest.java
@@ -25,6 +25,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
@@ -47,7 +48,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class DataServiceSetupPreferenceControllerTest {
@@ -71,7 +72,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
         doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
         doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(
diff --git a/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java
index 013fb08..ea6f903 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.provider.Settings;
@@ -39,7 +40,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class DataUsagePreferenceControllerTest {
@@ -55,7 +56,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
         doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
 
diff --git a/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java
index 89e299c..8fd2c28 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.telephony.TelephonyManager;
@@ -37,7 +38,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class EuiccPreferenceControllerTest {
@@ -54,7 +55,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = spy(Robolectric.setupActivity(Activity.class));
         doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
         doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
 
diff --git a/tests/robotests/src/com/android/settings/nfc/NfcAirplaneModeObserverTest.java b/tests/robotests/src/com/android/settings/nfc/NfcAirplaneModeObserverTest.java
index 5caf009..5dfc4f7 100644
--- a/tests/robotests/src/com/android/settings/nfc/NfcAirplaneModeObserverTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/NfcAirplaneModeObserverTest.java
@@ -34,7 +34,6 @@
 import org.junit.runner.RunWith;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -48,10 +47,10 @@
 
     @Before
     public void setUp() {
-        mContext = ShadowApplication.getInstance().getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mNfcAdapter = NfcAdapter.getDefaultAdapter(mContext);
 
-        mNfcPreference = new SwitchPreference(RuntimeEnvironment.application);
+        mNfcPreference = new SwitchPreference(mContext);
 
         mNfcAirplaneModeObserver =
                 new NfcAirplaneModeObserver(mContext, mNfcAdapter, mNfcPreference);
@@ -76,7 +75,7 @@
         final ContentResolver contentResolver = mContext.getContentResolver();
         Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
         Settings.Global.putString(contentResolver,
-            Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Settings.Global.RADIO_NFC);
+                Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Settings.Global.RADIO_NFC);
 
         mNfcAirplaneModeObserver.onChange(false, NfcAirplaneModeObserver.AIRPLANE_MODE_URI);
 
@@ -89,7 +88,7 @@
         final ContentResolver contentResolver = mContext.getContentResolver();
         Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
         Settings.Global.putString(contentResolver,
-            Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Global.RADIO_WIFI);
+                Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, Global.RADIO_WIFI);
 
         mNfcAirplaneModeObserver.onChange(false, NfcAirplaneModeObserver.AIRPLANE_MODE_URI);
 
diff --git a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
index af53f23..06ef601 100644
--- a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java
@@ -54,6 +54,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -81,7 +82,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = spy(new BlockPreferenceController(mContext, mImportanceListener, mBackend));
         mSwitch = new SwitchBar(mContext);
         when(mPreference.findViewById(R.id.switch_bar)).thenReturn(mSwitch);
diff --git a/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
index 0aa94c7..220269e 100644
--- a/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
@@ -27,6 +27,7 @@
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
 
+import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
@@ -35,7 +36,6 @@
 import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.shadows.ShadowSystemProperties;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class BootSoundPreferenceControllerTest {
@@ -52,8 +52,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        when(mContext.getResources().getBoolean(com.android.settings.R.bool.has_boot_sounds))
-            .thenReturn(true);
+        when(mContext.getResources().getBoolean(R.bool.has_boot_sounds))
+                .thenReturn(true);
         mController = new BootSoundPreferenceController(mContext);
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
         when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
@@ -62,7 +62,7 @@
     @Test
     public void isAvailable_hasBootSounds_shouldReturnTrue() {
         when(mContext.getResources().getBoolean(
-            com.android.settings.R.bool.has_boot_sounds)).thenReturn(true);
+                R.bool.has_boot_sounds)).thenReturn(true);
 
         assertThat(mController.isAvailable()).isTrue();
     }
@@ -70,15 +70,14 @@
     @Test
     public void isAvailable_noBootSounds_shouldReturnFale() {
         when(mContext.getResources().getBoolean(
-            com.android.settings.R.bool.has_boot_sounds)).thenReturn(false);
+                R.bool.has_boot_sounds)).thenReturn(false);
 
         assertThat(mController.isAvailable()).isFalse();
     }
 
     @Test
     public void displayPreference_bootSoundEnabled_shouldCheckedPreference() {
-        ShadowSystemProperties.native_set(BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, "1");
-
+        SystemProperties.set(BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, "true");
         mController.displayPreference(mScreen);
 
         verify(mPreference).setChecked(true);
@@ -86,7 +85,7 @@
 
     @Test
     public void displayPreference_bootSoundDisabled_shouldUncheckedPreference() {
-        ShadowSystemProperties.native_set(BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, "0");
+        SystemProperties.set(BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, "0");
 
         mController.displayPreference(mScreen);
 
@@ -100,7 +99,7 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         assertThat(SystemProperties.get(
-            BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, null)).isEqualTo("1");
+                BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, null)).isEqualTo("1");
     }
 
     @Test
@@ -110,6 +109,6 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         assertThat(SystemProperties.get(
-            BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, null)).isEqualTo("0");
+                BootSoundPreferenceController.PROPERTY_BOOT_SOUNDS, null)).isEqualTo("0");
     }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
index 35c7a11..6d3f1b4 100644
--- a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
@@ -42,6 +42,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -63,7 +64,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = new DeletedChannelsPreferenceController(mContext, mBackend);
     }
 
diff --git a/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java
index 0d82fcb..649918a 100644
--- a/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DescriptionPreferenceControllerTest.java
@@ -62,7 +62,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = spy(new DescriptionPreferenceController(mContext));
     }
 
diff --git a/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java
index 871aafb..57c8712 100644
--- a/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/HeaderPreferenceControllerTest.java
@@ -45,6 +45,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -68,7 +69,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         PreferenceFragmentCompat fragment = mock(PreferenceFragmentCompat.class);
         when(fragment.getContext()).thenReturn(mContext);
         FragmentActivity activity = mock(FragmentActivity.class);
diff --git a/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
index c276825..6ceaffa 100644
--- a/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/LightsPreferenceControllerTest.java
@@ -85,7 +85,7 @@
         // By default allow lights
         SettingsShadowResources.overrideResource(
                 com.android.internal.R.bool.config_intrusiveNotificationLed, true);
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 1);
+        Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 1);
     }
 
     @Test
@@ -107,7 +107,7 @@
 
     @Test
     public void testIsAvailable_notIfSettingNotAllowed() {
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0);
+        Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0);
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
         mController.onResume(appRow, channel, null, null);
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
index 3c83c4e..5d6e1fe 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
@@ -51,6 +51,7 @@
 import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 @RunWith(SettingsRobolectricTestRunner.class)
@@ -73,7 +74,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = new TestPreferenceController(mContext, mBackend);
     }
 
diff --git a/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java
index df1ee6f..235d7b2 100644
--- a/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/PulseNotificationPreferenceControllerTest.java
@@ -138,14 +138,14 @@
 
     @Test
     public void isChecked_configOn_shouldReturnTrue() {
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 1);
+        Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 1);
 
         assertThat(mController.isChecked()).isTrue();
     }
 
     @Test
     public void isChecked_configOff_shouldReturnFalse() {
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0);
+        Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0);
 
         assertThat(mController.isChecked()).isFalse();
     }
@@ -156,7 +156,7 @@
 
         assertThat(mController.isChecked()).isTrue();
         assertThat(
-                Settings.Secure.getInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0))
+                Settings.System.getInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0))
                 .isEqualTo(1);
     }
 
@@ -166,7 +166,7 @@
 
         assertThat(mController.isChecked()).isFalse();
         assertThat(
-                Settings.Secure.getInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 1))
+                Settings.System.getInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 1))
                 .isEqualTo(0);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
index 3fc563a..cfffbdc 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
@@ -59,6 +59,7 @@
 import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
@@ -90,7 +91,7 @@
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
         SettingsShadowResources.overrideResource(com.android.internal.R.string.ringtone_silent,
                 "silent");
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = spy(new SoundPreferenceController(
                 mContext, mFragment, mImportanceListener, mBackend));
     }
diff --git a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
index d0e7b5a..8aad02e 100644
--- a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
@@ -59,6 +59,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
@@ -91,7 +92,7 @@
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
         shadowApplication.setSystemService(Context.DEVICE_POLICY_SERVICE, mDm);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = spy(new VisibilityPreferenceController(mContext, mLockUtils, mBackend));
 
         // by default the lockscreen is secure
@@ -202,7 +203,7 @@
         mController.updateState(pref);
 
         ArgumentCaptor<CharSequence[]> argumentCaptor =
-            ArgumentCaptor.forClass(CharSequence[].class);
+                ArgumentCaptor.forClass(CharSequence[].class);
         verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
         assertFalse(toStringList(argumentCaptor.getValue())
                 .contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
@@ -250,7 +251,7 @@
         mController.updateState(pref);
 
         ArgumentCaptor<CharSequence[]> argumentCaptor =
-            ArgumentCaptor.forClass(CharSequence[].class);
+                ArgumentCaptor.forClass(CharSequence[].class);
         verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
         assertEquals(2, toStringList(argumentCaptor.getValue()).size());
         assertFalse(toStringList(argumentCaptor.getValue())
@@ -267,7 +268,7 @@
         mController.updateState(pref);
 
         ArgumentCaptor<CharSequence[]> argumentCaptor =
-            ArgumentCaptor.forClass(CharSequence[].class);
+                ArgumentCaptor.forClass(CharSequence[].class);
         verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
         List<String> values = toStringList(argumentCaptor.getValue());
         assertEquals(3, values.size());
diff --git a/tests/robotests/src/com/android/settings/notification/ZenFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenFooterPreferenceControllerTest.java
index 81ed5ef..eb89f82 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenFooterPreferenceControllerTest.java
@@ -47,6 +47,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -61,7 +62,8 @@
     private Context mContext;
     @Mock
     private PreferenceScreen mScreen;
-    @Mock NotificationManager mNotificationManager;
+    @Mock
+    NotificationManager mNotificationManager;
 
     private static final String PREF_KEY = "main_pref";
 
@@ -69,7 +71,7 @@
     public void setup() {
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
         when(mNotificationManager.getNotificationPolicy()).thenReturn(
                 mock(NotificationManager.Policy.class));
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java
index 7caccf2..df4df51 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeAlarmsPreferenceControllerTest.java
@@ -30,9 +30,6 @@
 import android.content.Context;
 import android.provider.Settings;
 
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
@@ -45,6 +42,9 @@
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
 @RunWith(SettingsRobolectricTestRunner.class)
 public class ZenModeAlarmsPreferenceControllerTest {
 
@@ -72,14 +72,15 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
-        mController = new ZenModeAlarmsPreferenceController(mContext, mock(Lifecycle.class));
+        mController = new ZenModeAlarmsPreferenceController(mContext, mock(Lifecycle.class),
+                "zen_mode_behavior_alarms");
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
 
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
-            .thenReturn(mockPref);
+                .thenReturn(mockPref);
         mController.displayPreference(mPreferenceScreen);
     }
 
@@ -124,7 +125,7 @@
         mController.onPreferenceChange(mockPref, allowAlarms);
 
         verify(mBackend)
-            .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS, allowAlarms);
+                .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS, allowAlarms);
     }
 
     @Test
@@ -133,6 +134,6 @@
         mController.onPreferenceChange(mockPref, allowAlarms);
 
         verify(mBackend)
-            .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS, allowAlarms);
+                .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS, allowAlarms);
     }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java
deleted file mode 100644
index f1f1b2e..0000000
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorCallsPreferenceControllerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.NotificationManager;
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-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.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public final class ZenModeBehaviorCallsPreferenceControllerTest {
-
-    private ZenModeBehaviorCallsPreferenceController mController;
-    @Mock
-    private NotificationManager mNotificationManager;
-    @Mock
-    private NotificationManager.Policy mPolicy;
-
-    private Context mContext;
-    @Mock
-    private ZenModeBackend mBackend;
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-
-        mContext = RuntimeEnvironment.application;
-        when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
-
-        mController = new ZenModeBehaviorCallsPreferenceController(
-                mContext, mock(Lifecycle.class));
-        ReflectionHelpers.setField(mController, "mBackend", mBackend);
-    }
-
-    @Test
-    public void testIsAvailable() {
-        assertTrue(mController.isAvailable());
-    }
-
-    @Test
-    public void testHasSummary() {
-        Preference pref = mock(Preference.class);
-        mController.updateState(pref);
-        verify(pref).setSummary(any());
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java
index 4170ee8..c4b2b3d 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorFooterPreferenceControllerTest.java
@@ -86,7 +86,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         when(mNotificationManager.getZenModeConfig()).thenReturn(mZenModeConfig);
 
@@ -95,7 +95,7 @@
         ReflectionHelpers.setField(mController, "mZenModeConfigWrapper", mConfigWrapper);
 
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
-            .thenReturn(mockPref);
+                .thenReturn(mockPref);
         mController.displayPreference(mPreferenceScreen);
     }
 
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java
deleted file mode 100644
index 11cdfcc..0000000
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorMsgEventReminderPreferenceControllerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.NotificationManager;
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-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.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public final class ZenModeBehaviorMsgEventReminderPreferenceControllerTest {
-
-    private ZenModeBehaviorMsgEventReminderPreferenceController mController;
-    @Mock
-    private NotificationManager mNotificationManager;
-    @Mock
-    private NotificationManager.Policy mPolicy;
-
-    private Context mContext;
-    @Mock
-    private ZenModeBackend mBackend;
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-
-        mContext = RuntimeEnvironment.application;
-        when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
-
-        mController = new ZenModeBehaviorMsgEventReminderPreferenceController(
-                mContext, mock(Lifecycle.class));
-        ReflectionHelpers.setField(mController, "mBackend", mBackend);
-    }
-
-    @Test
-    public void testIsAvailable() {
-        assertTrue(mController.isAvailable());
-    }
-
-    @Test
-    public void testHasSummary() {
-        Preference pref = mock(Preference.class);
-        mController.updateState(pref);
-        verify(pref).setSummary(any());
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java
deleted file mode 100644
index c854e8a..0000000
--- a/tests/robotests/src/com/android/settings/notification/ZenModeBehaviorSoundPreferenceControllerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.NotificationManager;
-import android.content.Context;
-
-import androidx.preference.Preference;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-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.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public final class ZenModeBehaviorSoundPreferenceControllerTest {
-
-    private ZenModeBehaviorSoundPreferenceController mController;
-    @Mock
-    private NotificationManager mNotificationManager;
-    @Mock
-    private NotificationManager.Policy mPolicy;
-
-    private Context mContext;
-    @Mock
-    private ZenModeBackend mBackend;
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-
-        mContext = RuntimeEnvironment.application;
-        when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
-
-        mController = new ZenModeBehaviorSoundPreferenceController(
-                mContext, mock(Lifecycle.class));
-        ReflectionHelpers.setField(mController, "mBackend", mBackend);
-    }
-
-    @Test
-    public void testIsAvailable() {
-        assertTrue(mController.isAvailable());
-    }
-
-    @Test
-    public void testHasSummary() {
-        Preference pref = mock(Preference.class);
-        mController.updateState(pref);
-        verify(pref).setSummary(any());
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeButtonPreferenceControllerTest.java
index 6701174..a3c3261 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeButtonPreferenceControllerTest.java
@@ -77,7 +77,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         mController = new ZenModeButtonPreferenceController(mContext, mock(Lifecycle.class),
                 mock(FragmentManager.class));
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java
index 3093b6a..fdc43f3 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeCallsPreferenceControllerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * 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.
@@ -16,24 +16,15 @@
 
 package com.android.settings.notification;
 
-import static android.provider.Settings.Global.ZEN_MODE;
-import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
-import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
-import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
-
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.NotificationManager;
-import android.content.ContentResolver;
 import android.content.Context;
-import android.provider.Settings;
 
-import androidx.preference.ListPreference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
@@ -46,32 +37,20 @@
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
+import androidx.preference.Preference;
+
 @RunWith(SettingsRobolectricTestRunner.class)
-public class ZenModeCallsPreferenceControllerTest {
+public final class ZenModeCallsPreferenceControllerTest {
 
     private ZenModeCallsPreferenceController mController;
-
-    @Mock
-    private ZenModeBackend mBackend;
     @Mock
     private NotificationManager mNotificationManager;
     @Mock
-    private ListPreference mockPref;
-    @Mock
     private NotificationManager.Policy mPolicy;
-    @Mock
-    private PreferenceScreen mPreferenceScreen;
-    private ContentResolver mContentResolver;
-    private Context mContext;
 
-    /**
-     * Array Values Key
-     * 0: anyone
-     * 1: contacts
-     * 2: starred
-     * 3: none
-     */
-    private String[] mValues;
+    private Context mContext;
+    @Mock
+    private ZenModeBackend mBackend;
 
     @Before
     public void setup() {
@@ -79,101 +58,23 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
-        mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
-        mContentResolver = RuntimeEnvironment.application.getContentResolver();
+        mContext = RuntimeEnvironment.application;
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
 
-        when(mBackend.getPriorityCallSenders())
-            .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
-        when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
-                .thenCallRealMethod();
-        when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
-                .thenCallRealMethod();
-
-        mController = new ZenModeCallsPreferenceController(mContext, mock(Lifecycle.class));
+        mController = new ZenModeCallsPreferenceController(
+                mContext, mock(Lifecycle.class), "zen_mode_calls_settings");
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
-
-        when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
-                mockPref);
-        mController.displayPreference(mPreferenceScreen);
     }
 
     @Test
-    public void updateState_TotalSilence() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
-
-        when(mBackend.isPriorityCategoryEnabled(
-                NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
-                .thenReturn(false);
-        final ListPreference mockPref = mock(ListPreference.class);
-        mController.updateState(mockPref);
-
-        verify(mockPref).setEnabled(false);
-        verify(mockPref).setSummary(R.string.zen_mode_from_none);
+    public void testIsAvailable() {
+        assertTrue(mController.isAvailable());
     }
 
     @Test
-    public void updateState_AlarmsOnly() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
-
-        final ListPreference mockPref = mock(ListPreference.class);
-        mController.updateState(mockPref);
-
-        verify(mockPref).setEnabled(false);
-        verify(mockPref).setSummary(R.string.zen_mode_from_none);
+    public void testHasSummary() {
+        Preference pref = mock(Preference.class);
+        mController.updateState(pref);
+        verify(pref).setSummary(any());
     }
-
-    @Test
-    public void updateState_Priority() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-
-        when(mBackend.isPriorityCategoryEnabled(
-                NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
-                .thenReturn(true);
-
-        mController.updateState(mockPref);
-
-        verify(mockPref).setEnabled(true);
-        verify(mockPref).setSummary(R.string.zen_mode_from_starred);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_any() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityCallSenders()).thenReturn(
-                NotificationManager.Policy.PRIORITY_SENDERS_ANY);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_none() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityCallSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_NONE)]);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_starred() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityCallSenders()).thenReturn(
-                NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_contacts() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityCallSenders()).thenReturn(
-                NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
-    }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java
index b9d2978..2d5e54a 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java
@@ -57,7 +57,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         mController = new ZenModeDurationPreferenceController(mContext, mock(Lifecycle.class));
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeEventRuleSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeEventRuleSettingsTest.java
index 5d8be5a..9a922ba 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeEventRuleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeEventRuleSettingsTest.java
@@ -29,6 +29,8 @@
 import android.content.Intent;
 import android.content.res.Resources;
 
+import androidx.fragment.app.FragmentActivity;
+
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
@@ -38,6 +40,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.shadows.ShadowToast;
@@ -45,8 +48,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import androidx.fragment.app.FragmentActivity;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
 public class ZenModeEventRuleSettingsTest {
@@ -69,7 +70,7 @@
 
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
 
         mFragment = spy(new TestFragment());
         mFragment.onAttach(application);
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeMediaPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeMediaPreferenceControllerTest.java
index f5eca34..9217f64 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeMediaPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeMediaPreferenceControllerTest.java
@@ -70,7 +70,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
 
@@ -79,7 +79,7 @@
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
 
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
-            .thenReturn(mockPref);
+                .thenReturn(mockPref);
         mController.displayPreference(mPreferenceScreen);
     }
 
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java
index 37ffd78..890f6c2 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesPreferenceControllerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * 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.
@@ -16,24 +16,13 @@
 
 package com.android.settings.notification;
 
-import static android.provider.Settings.Global.ZEN_MODE;
-import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
-import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
-import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
-
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.NotificationManager;
-import android.content.ContentResolver;
 import android.content.Context;
-import android.provider.Settings;
 
-import androidx.preference.ListPreference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
@@ -47,31 +36,17 @@
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-public class ZenModeMessagesPreferenceControllerTest {
+public final class ZenModeMessagesPreferenceControllerTest {
 
     private ZenModeMessagesPreferenceController mController;
-
-    @Mock
-    private ZenModeBackend mBackend;
     @Mock
     private NotificationManager mNotificationManager;
     @Mock
-    private ListPreference mockPref;
-    @Mock
     private NotificationManager.Policy mPolicy;
-    @Mock
-    private PreferenceScreen mPreferenceScreen;
-    private ContentResolver mContentResolver;
-    private Context mContext;
 
-    /**
-     * Array Values Key
-     * 0: anyone
-     * 1: contacts
-     * 2: starred
-     * 3: none
-     */
-    private String[] mValues;
+    private Context mContext;
+    @Mock
+    private ZenModeBackend mBackend;
 
     @Before
     public void setup() {
@@ -79,101 +54,24 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
-        mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
-        mContentResolver = RuntimeEnvironment.application.getContentResolver();
+        mContext = RuntimeEnvironment.application;
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
 
-        when(mBackend.getPriorityMessageSenders())
-            .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
-        when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
-                .thenCallRealMethod();
-        when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
-                .thenCallRealMethod();
-
-        mController = new ZenModeMessagesPreferenceController(mContext, mock(Lifecycle.class));
+        mController = new ZenModeMessagesPreferenceController(
+                mContext, mock(Lifecycle.class), "zen_mode_messages_settings");
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
-
-        when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
-                mockPref);
-        mController.displayPreference(mPreferenceScreen);
     }
 
     @Test
-    public void updateState_TotalSilence() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
-
-        when(mBackend.isPriorityCategoryEnabled(
-                NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
-                .thenReturn(false);
-        final ListPreference mockPref = mock(ListPreference.class);
-        mController.updateState(mockPref);
-
-        verify(mockPref).setEnabled(false);
-        verify(mockPref).setSummary(R.string.zen_mode_from_none);
+    public void testIsAvailable() {
+        assertTrue(mController.isAvailable());
     }
 
-    @Test
-    public void updateState_AlarmsOnly() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
-
-        final ListPreference mockPref = mock(ListPreference.class);
-        mController.updateState(mockPref);
-
-        verify(mockPref).setEnabled(false);
-        verify(mockPref).setSummary(R.string.zen_mode_from_none);
-    }
-
-    @Test
-    public void updateState_Priority() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-
-        when(mBackend.isPriorityCategoryEnabled(
-                NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
-                .thenReturn(true);
-
-        mController.updateState(mockPref);
-
-        verify(mockPref).setEnabled(true);
-        verify(mockPref).setSummary(R.string.zen_mode_from_starred);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_any() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityMessageSenders()).thenReturn(
-                NotificationManager.Policy.PRIORITY_SENDERS_ANY);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_none() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityMessageSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_NONE)]);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_starred() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityMessageSenders()).thenReturn(
-                NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
-    }
-
-    @Test
-    public void onPreferenceChange_setSelectedContacts_contacts() {
-        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
-        when(mBackend.getPriorityMessageSenders()).thenReturn(
-                NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
-        mController.updateState(mockPref);
-        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
-                ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
-    }
-}
\ No newline at end of file
+// TODO: (b/111475013 - beverlyt) set messages summary
+//    @Test
+//    public void testHasSummary() {
+//        Preference pref = mock(Preference.class);
+//        mController.updateState(pref);
+//        verify(pref).setSummary(any());
+//    }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java
index 80e1e1b..141813b 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModePreferenceControllerTest.java
@@ -41,6 +41,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -64,7 +65,7 @@
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = new ZenModePreferenceController(mContext, KEY_ZEN_MODE);
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
         mSummaryBuilder = spy(new ZenModeSettings.SummaryBuilder(mContext));
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModePriorityCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModePriorityCallsPreferenceControllerTest.java
new file mode 100644
index 0000000..36a1382
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModePriorityCallsPreferenceControllerTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.notification;
+
+import static android.provider.Settings.Global.ZEN_MODE;
+import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
+import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+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.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ZenModePriorityCallsPreferenceControllerTest {
+
+    private ZenModePriorityCallsPreferenceController mController;
+
+    @Mock
+    private ZenModeBackend mBackend;
+    @Mock
+    private NotificationManager mNotificationManager;
+    @Mock
+    private ListPreference mockPref;
+    @Mock
+    private NotificationManager.Policy mPolicy;
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
+    private ContentResolver mContentResolver;
+    private Context mContext;
+
+    /**
+     * Array Values Key
+     * 0: anyone
+     * 1: contacts
+     * 2: starred
+     * 3: none
+     */
+    private String[] mValues;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        ShadowApplication shadowApplication = ShadowApplication.getInstance();
+        shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+        mContext = RuntimeEnvironment.application;
+        mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
+        mContentResolver = RuntimeEnvironment.application.getContentResolver();
+        when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+        when(mBackend.getPriorityCallSenders())
+                .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+        when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
+                .thenCallRealMethod();
+        when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+                .thenCallRealMethod();
+
+        mController = new ZenModePriorityCallsPreferenceController(mContext, mock(Lifecycle.class));
+        ReflectionHelpers.setField(mController, "mBackend", mBackend);
+
+        when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+                mockPref);
+        mController.displayPreference(mPreferenceScreen);
+    }
+
+    @Test
+    public void updateState_TotalSilence() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
+
+        when(mBackend.isPriorityCategoryEnabled(
+                NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+                .thenReturn(false);
+        final ListPreference mockPref = mock(ListPreference.class);
+        mController.updateState(mockPref);
+
+        verify(mockPref).setEnabled(false);
+        verify(mockPref).setSummary(R.string.zen_mode_from_none);
+    }
+
+    @Test
+    public void updateState_AlarmsOnly() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
+
+        final ListPreference mockPref = mock(ListPreference.class);
+        mController.updateState(mockPref);
+
+        verify(mockPref).setEnabled(false);
+        verify(mockPref).setSummary(R.string.zen_mode_from_none);
+    }
+
+    @Test
+    public void updateState_Priority() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+
+        when(mBackend.isPriorityCategoryEnabled(
+                NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
+                .thenReturn(true);
+
+        mController.updateState(mockPref);
+
+        verify(mockPref).setEnabled(true);
+        verify(mockPref).setSummary(R.string.zen_mode_from_starred);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_any() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityCallSenders()).thenReturn(
+                NotificationManager.Policy.PRIORITY_SENDERS_ANY);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_none() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityCallSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_NONE)]);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_starred() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityCallSenders()).thenReturn(
+                NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_contacts() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityCallSenders()).thenReturn(
+                NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
+    }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceControllerTest.java
new file mode 100644
index 0000000..75605a4
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceControllerTest.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Global.ZEN_MODE;
+import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
+import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+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.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ZenModePriorityMessagesPreferenceControllerTest {
+
+    private ZenModePriorityMessagesPreferenceController mController;
+
+    @Mock
+    private ZenModeBackend mBackend;
+    @Mock
+    private NotificationManager mNotificationManager;
+    @Mock
+    private ListPreference mockPref;
+    @Mock
+    private NotificationManager.Policy mPolicy;
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
+    private ContentResolver mContentResolver;
+    private Context mContext;
+
+    /**
+     * Array Values Key
+     * 0: anyone
+     * 1: contacts
+     * 2: starred
+     * 3: none
+     */
+    private String[] mValues;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        ShadowApplication shadowApplication = ShadowApplication.getInstance();
+        shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+        mContext = RuntimeEnvironment.application;
+        mValues = mContext.getResources().getStringArray(R.array.zen_mode_contacts_values);
+        mContentResolver = RuntimeEnvironment.application.getContentResolver();
+        when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+        when(mBackend.getPriorityMessageSenders())
+            .thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+        when(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE))
+                .thenCallRealMethod();
+        when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
+                .thenCallRealMethod();
+
+        mController = new ZenModePriorityMessagesPreferenceController(mContext, mock(Lifecycle.class));
+        ReflectionHelpers.setField(mController, "mBackend", mBackend);
+
+        when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+                mockPref);
+        mController.displayPreference(mPreferenceScreen);
+    }
+
+    @Test
+    public void updateState_TotalSilence() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
+
+        when(mBackend.isPriorityCategoryEnabled(
+                NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
+                .thenReturn(false);
+        final ListPreference mockPref = mock(ListPreference.class);
+        mController.updateState(mockPref);
+
+        verify(mockPref).setEnabled(false);
+        verify(mockPref).setSummary(R.string.zen_mode_from_none);
+    }
+
+    @Test
+    public void updateState_AlarmsOnly() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
+
+        final ListPreference mockPref = mock(ListPreference.class);
+        mController.updateState(mockPref);
+
+        verify(mockPref).setEnabled(false);
+        verify(mockPref).setSummary(R.string.zen_mode_from_none);
+    }
+
+    @Test
+    public void updateState_Priority() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+
+        when(mBackend.isPriorityCategoryEnabled(
+                NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
+                .thenReturn(true);
+
+        mController.updateState(mockPref);
+
+        verify(mockPref).setEnabled(true);
+        verify(mockPref).setSummary(R.string.zen_mode_from_starred);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_any() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityMessageSenders()).thenReturn(
+                NotificationManager.Policy.PRIORITY_SENDERS_ANY);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_ANYONE)]);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_none() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityMessageSenders()).thenReturn(ZenModeBackend.SOURCE_NONE);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_NONE)]);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_starred() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityMessageSenders()).thenReturn(
+                NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_STARRED)]);
+    }
+
+    @Test
+    public void onPreferenceChange_setSelectedContacts_contacts() {
+        Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+        when(mBackend.getPriorityMessageSenders()).thenReturn(
+                NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS);
+        mController.updateState(mockPref);
+        verify(mockPref).setValue(mValues[mController.getIndexOfSendersValue(
+                ZenModeBackend.ZEN_MODE_FROM_CONTACTS)]);
+    }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeRemindersPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeRemindersPreferenceControllerTest.java
index 4ddb5fc..de20fb4 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeRemindersPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeRemindersPreferenceControllerTest.java
@@ -72,7 +72,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
 
@@ -80,7 +80,7 @@
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
 
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
-            .thenReturn(mockPref);
+                .thenReturn(mockPref);
         mController.displayPreference(mPreferenceScreen);
     }
 
@@ -127,7 +127,7 @@
         mController.onPreferenceChange(mockPref, allow);
 
         verify(mBackend)
-            .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS, allow);
+                .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS, allow);
     }
 
     @Test
@@ -136,6 +136,6 @@
         mController.onPreferenceChange(mockPref, allow);
 
         verify(mBackend)
-            .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS, allow);
+                .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS, allow);
     }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeRepeatCallersPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeRepeatCallersPreferenceControllerTest.java
index 4518427..fd6a9af 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeRepeatCallersPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeRepeatCallersPreferenceControllerTest.java
@@ -71,7 +71,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
 
@@ -142,7 +142,8 @@
         mController.onPreferenceChange(mockPref, allow);
 
         verify(mBackend)
-            .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, allow);
+                .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS,
+                        allow);
     }
 
     @Test
@@ -151,6 +152,7 @@
         mController.onPreferenceChange(mockPref, allow);
 
         verify(mBackend)
-            .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, allow);
+                .saveSoundPolicy(NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS,
+                        allow);
     }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java
index 2596aa1..ecfb784 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeScheduleRuleSettingsTest.java
@@ -40,6 +40,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.shadows.ShadowToast;
@@ -66,7 +67,7 @@
 
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
 
         mFragment = spy(new TestFragment());
         mFragment.onAttach(application);
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsFooterPreferenceControllerTest.java
index b6efd78..c1634fb 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsFooterPreferenceControllerTest.java
@@ -88,12 +88,12 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         when(mNotificationManager.getZenModeConfig()).thenReturn(mZenModeConfig);
 
         mController =
-            new ZenModeSettingsFooterPreferenceController(mContext, mock(Lifecycle.class));
+                new ZenModeSettingsFooterPreferenceController(mContext, mock(Lifecycle.class));
         ReflectionHelpers.setField(mZenModeConfig, AUTOMATIC_RULES_FIELD, mInjectedAutomaticRules);
         ReflectionHelpers.setField(mController, "mZenModeConfigWrapper", mConfigWrapper);
 
@@ -276,7 +276,7 @@
         injectedManualRule.conditionId = mock(Uri.class);
         when(mConfigWrapper.parseManualRuleTime(injectedManualRule.conditionId)).thenReturn(time);
         when(mConfigWrapper.getFormattedTime(time, mContext.getUserId()))
-            .thenReturn(timePlaceholder);
+                .thenReturn(timePlaceholder);
         ReflectionHelpers.setField(mZenModeConfig, MANUAL_RULE_FIELD, injectedManualRule);
     }
 
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
index 96e5658..4fc7d57 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java
@@ -69,63 +69,6 @@
     }
 
     @Test
-    public void testGetMsgEventReminderSettingSummary_none() {
-        Policy policy = new Policy(0, 0, 0, 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("None");
-    }
-
-    @Test
-    public void testGetMsgEventReminderSettingSummary_single() {
-        Policy policy = new Policy(
-                Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_EVENTS, 0 , 0 , 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Events");
-    }
-
-    @Test
-    public void testGetMsgEventReminderSettingSummary_someMsgs() {
-        Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
-                Policy.PRIORITY_SENDERS_CONTACTS , 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
-
-        policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
-                Policy.PRIORITY_SENDERS_STARRED , 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
-    }
-
-    @Test
-    public void testGetMsgEventReminderSettingSummary_msgs() {
-        Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0, 0, 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Messages");
-    }
-
-    @Test
-    public void testGetMsgEventReminderSettingSummary_someMsgsAndOther() {
-        Policy policy = new Policy(
-                Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
-                0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
-                .isEqualTo("Some messages and reminders");
-    }
-
-    @Test
-    public void testGetMsgEventReminderSettingSummary_someMsgsAndAllOthers() {
-        Policy policy = new Policy(Policy.PRIORITY_CATEGORY_EVENTS
-                | Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
-                0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
-                .isEqualTo("Some messages, events, and reminders");
-    }
-
-    @Test
-    public void testGetMsgEventReminderSettingSummary_noMsgsAndOther() {
-        Policy policy = new Policy(
-                Policy.PRIORITY_CATEGORY_EVENTS | Policy.PRIORITY_CATEGORY_REMINDERS,
-                0,0, 0);
-        assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
-                .isEqualTo("Events and reminders");
-    }
-
-    @Test
     public void testGetCallsSettingSummary_none() {
         Policy policy = new Policy(0, 0, 0, 0);
         assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("None");
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeStarredContactsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeStarredContactsPreferenceControllerTest.java
index c2ca9be..9e6eb82 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeStarredContactsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeStarredContactsPreferenceControllerTest.java
@@ -45,6 +45,7 @@
 import org.mockito.MockitoAnnotations;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -78,7 +79,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
         when(testIntent.resolveActivity(any())).thenReturn(mComponentName);
 
@@ -163,8 +164,8 @@
 
         // expected - no null  values
         List<String> contacts = mMessagesController.getStarredContacts(testCursorWithNullValues);
-        for (int i = 0 ; i < contacts.size(); i++) {
-            assertThat(contacts.get(i)).isNotNull();
+        for (String contact : contacts) {
+            assertThat(contact).isNotNull();
         }
     }
 
@@ -183,6 +184,7 @@
 
         doAnswer(new Answer<Boolean>() {
             int count = 0;
+
             @Override
             public Boolean answer(InvocationOnMock invocation) throws Throwable {
                 if (count < size) {
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSystemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSystemPreferenceControllerTest.java
index 418af78..57bc303 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSystemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSystemPreferenceControllerTest.java
@@ -69,7 +69,7 @@
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
 
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
         mController = new ZenModeSystemPreferenceController(mContext, mock(Lifecycle.class));
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectPreferenceControllerTest.java
index 71720bf..65c39f8 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectPreferenceControllerTest.java
@@ -47,6 +47,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -62,7 +63,8 @@
     private FakeFeatureFactory mFeatureFactory;
     @Mock
     private PreferenceScreen mScreen;
-    @Mock NotificationManager mNotificationManager;
+    @Mock
+    NotificationManager mNotificationManager;
 
     private static final String PREF_KEY = "main_pref";
     private static final int PREF_METRICS = 1;
@@ -73,7 +75,7 @@
     public void setup() {
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
         when(mNotificationManager.getNotificationPolicy()).thenReturn(
@@ -129,7 +131,7 @@
     public void updateState_checkedFalse_parentChecked() {
         mController = new ZenModeVisEffectPreferenceController(mContext, mock(Lifecycle.class),
                 PREF_KEY, SUPPRESSED_EFFECT_PEEK, PREF_METRICS,
-                new int[] {PARENT_EFFECT1, PARENT_EFFECT2});
+                new int[]{PARENT_EFFECT1, PARENT_EFFECT2});
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
         when(mBackend.isVisualEffectSuppressed(SUPPRESSED_EFFECT_PEEK)).thenReturn(false);
         when(mBackend.isVisualEffectSuppressed(PARENT_EFFECT1)).thenReturn(false);
@@ -145,7 +147,7 @@
     public void updateState_checkedFalse_parentNotChecked() {
         mController = new ZenModeVisEffectPreferenceController(mContext, mock(Lifecycle.class),
                 PREF_KEY, SUPPRESSED_EFFECT_PEEK, PREF_METRICS,
-                new int[] {PARENT_EFFECT1, PARENT_EFFECT2});
+                new int[]{PARENT_EFFECT1, PARENT_EFFECT2});
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
         when(mBackend.isVisualEffectSuppressed(SUPPRESSED_EFFECT_PEEK)).thenReturn(false);
         when(mBackend.isVisualEffectSuppressed(PARENT_EFFECT1)).thenReturn(false);
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceControllerTest.java
index 3cada1e..5ae37e3 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceControllerTest.java
@@ -49,6 +49,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -64,7 +65,8 @@
     private FakeFeatureFactory mFeatureFactory;
     @Mock
     private PreferenceScreen mScreen;
-    @Mock NotificationManager mNotificationManager;
+    @Mock
+    NotificationManager mNotificationManager;
 
     private static final String PREF_KEY = "main_pref";
 
@@ -72,7 +74,7 @@
     public void setup() {
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
         when(mNotificationManager.getNotificationPolicy()).thenReturn(
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java
index f365882..a318a39 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceControllerTest.java
@@ -47,6 +47,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -62,7 +63,8 @@
     private FakeFeatureFactory mFeatureFactory;
     @Mock
     private PreferenceScreen mScreen;
-    @Mock NotificationManager mNotificationManager;
+    @Mock
+    NotificationManager mNotificationManager;
 
     private static final String PREF_KEY = "main_pref";
 
@@ -70,7 +72,7 @@
     public void setup() {
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
         when(mNotificationManager.getNotificationPolicy()).thenReturn(
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceControllerTest.java
index 08384af..fe45d1c 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceControllerTest.java
@@ -49,6 +49,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
@@ -64,16 +65,16 @@
     private FakeFeatureFactory mFeatureFactory;
     @Mock
     private PreferenceScreen mScreen;
-    @Mock NotificationManager mNotificationManager;
+    @Mock
+    NotificationManager mNotificationManager;
 
     private static final String PREF_KEY = "main_pref";
-    private static final int PREF_METRICS = 1;
 
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        mContext = shadowApplication.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
         when(mNotificationManager.getNotificationPolicy()).thenReturn(
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index cd99f36..ab7f795 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -31,14 +31,13 @@
 import com.android.settings.testutils.shadow.SettingsShadowResources;
 import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
 import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.settingslib.testutils.DrawableTestHelper;
 import com.android.setupwizardlib.GlifLayout;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.Robolectric;
-import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowDrawable;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = {
@@ -103,9 +102,8 @@
         ChooseLockPattern activity = createActivity(true);
         ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
                 activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
-
-        ShadowDrawable drawable = Shadows.shadowOf(((GlifLayout) fragment.getView()).getIcon());
-        assertThat(drawable.getCreatedFromResId()).isEqualTo(R.drawable.ic_fingerprint_header);
+        DrawableTestHelper.assertDrawableResId(((GlifLayout) fragment.getView()).getIcon(),
+                R.drawable.ic_fingerprint_header);
     }
 
     @Config(qualifiers = "sw300dp")
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
index 5d51178..e3f3833 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockSettingsHelperTest.java
@@ -62,8 +62,6 @@
         assertEquals(
                 true,
                 (startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
-        assertEquals(true, startedIntent.getBooleanExtra(
-                ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, false));
         assertFalse(startedIntent.getBooleanExtra(
                 ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
         assertFalse(startedIntent.getBooleanExtra(
@@ -100,8 +98,6 @@
         assertEquals(
                 false,
                 (startedIntent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0);
-        assertEquals(false, startedIntent.getBooleanExtra(
-                ConfirmDeviceCredentialBaseFragment.ALLOW_FP_AUTHENTICATION, false));
         assertFalse(startedIntent.getBooleanExtra(
                 ConfirmDeviceCredentialBaseFragment.DARK_THEME, false));
         assertFalse(startedIntent.getBooleanExtra(
diff --git a/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java b/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java
index 24e4e62..6a58482 100644
--- a/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java
+++ b/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java
@@ -36,6 +36,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 import java.util.ArrayList;
@@ -57,7 +58,7 @@
         ShadowApplication application = ShadowApplication.getInstance();
         application.setSystemService(Context.DEVICE_POLICY_SERVICE, mDevicePolicyManager);
         application.setSystemService(Context.USER_SERVICE, mUserManager);
-        mContext = application.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java
index ee9fb16..8221b15 100644
--- a/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java
@@ -24,49 +24,54 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Context;
-import android.os.UserManager;
 
 import androidx.preference.Preference;
 
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowLockPatternUtils.class)
+@Config(shadows = {ShadowLockPatternUtils.class, ShadowUserManager.class})
 public class EncryptionStatusPreferenceControllerTest {
 
     private Context mContext;
     private EncryptionStatusPreferenceController mController;
     private Preference mPreference;
+    private ShadowUserManager mShadowUserManager;
 
     @Before
     public void setUp() {
         mContext = RuntimeEnvironment.application;
         mController =
-            new EncryptionStatusPreferenceController(mContext, PREF_KEY_ENCRYPTION_DETAIL_PAGE);
+                new EncryptionStatusPreferenceController(mContext, PREF_KEY_ENCRYPTION_DETAIL_PAGE);
+        mShadowUserManager = ShadowUserManager.getShadow();
         mPreference = new Preference(mContext);
     }
 
+    @After
+    public void tearDown() {
+        mShadowUserManager.reset();
+    }
+
     @Test
     public void isAvailable_admin_true() {
-        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        Shadows.shadowOf(userManager).setIsAdminUser(true);
+        mShadowUserManager.setIsAdminUser(true);
 
         assertThat(mController.isAvailable()).isTrue();
     }
 
     @Test
     public void isAvailable_notAdmin_false() {
-        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        Shadows.shadowOf(userManager).setIsAdminUser(false);
+        mShadowUserManager.setIsAdminUser(false);
 
         assertThat(mController.isAvailable()).isFalse();
     }
@@ -83,8 +88,7 @@
         mController = new EncryptionStatusPreferenceController(mContext,
                 PREF_KEY_ENCRYPTION_SECURITY_PAGE);
 
-        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        Shadows.shadowOf(userManager).setIsAdminUser(true);
+        mShadowUserManager.setIsAdminUser(true);
         assertThat(mController.isAvailable()).isTrue();
     }
 
@@ -114,7 +118,8 @@
     @Test
     public void updateSummary_unencrypted_securityPage_shouldNotHaveEncryptionFragment() {
         mController =
-            new EncryptionStatusPreferenceController(mContext, PREF_KEY_ENCRYPTION_SECURITY_PAGE);
+                new EncryptionStatusPreferenceController(mContext,
+                        PREF_KEY_ENCRYPTION_SECURITY_PAGE);
         ShadowLockPatternUtils.setDeviceEncryptionEnabled(false);
 
         mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 26683db..a0fd21b 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -25,7 +25,6 @@
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
@@ -41,6 +40,7 @@
 import android.provider.Settings;
 import android.provider.SettingsSlicesContract;
 import android.util.ArraySet;
+import android.view.accessibility.AccessibilityManager;
 
 import androidx.slice.Slice;
 import androidx.slice.SliceProvider;
@@ -54,18 +54,26 @@
 import com.android.settings.testutils.DatabaseTestUtils;
 import com.android.settings.testutils.FakeToggleController;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
+import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
 import com.android.settings.testutils.shadow.ShadowThreadUtils;
+import com.android.settings.testutils.shadow.ShadowUserManager;
+import com.android.settings.testutils.shadow.ShadowUtils;
 import com.android.settings.wifi.WifiSlice;
 
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 import org.robolectric.annotation.Resetter;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowAccessibilityManager;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -81,7 +89,9 @@
  * TODO Investigate using ShadowContentResolver.registerProviderInternal(String, ContentProvider)
  */
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowThreadUtils.class)
+@Config(shadows = {ShadowUserManager.class, ShadowThreadUtils.class, ShadowUtils.class,
+        SlicesDatabaseAccessorTest.ShadowApplicationPackageManager.class,
+        ShadowBluetoothAdapter.class, ShadowLockPatternUtils.class})
 public class SettingsSliceProviderTest {
 
     private static final String KEY = "KEY";
@@ -97,7 +107,7 @@
 
     private Context mContext;
     private SettingsSliceProvider mProvider;
-    private SQLiteDatabase mDb;
+    @Mock
     private SliceManager mManager;
 
     private static final List<Uri> SPECIAL_CASE_PLATFORM_URIS = Arrays.asList(
@@ -113,7 +123,13 @@
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
+        // Register the fake a11y Service
+        ShadowAccessibilityManager shadowAccessibilityManager = Shadow.extract(
+                RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
+        shadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
+
         mProvider = spy(new SettingsSliceProvider());
         ShadowStrictMode.reset();
         mProvider.mSliceWeakDataCache = new HashMap<>();
@@ -122,10 +138,9 @@
         mProvider.mCustomSliceManager = spy(new CustomSliceManager(mContext));
         when(mProvider.getContext()).thenReturn(mContext);
 
-        mDb = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
         SlicesDatabaseHelper.getInstance(mContext).setIndexedState();
-        mManager = mock(SliceManager.class);
-        when(mContext.getSystemService(SliceManager.class)).thenReturn(mManager);
+
+        doReturn(mManager).when(mContext).getSystemService(SliceManager.class);
         when(mManager.getPinnedSlices()).thenReturn(Collections.emptyList());
 
         SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -562,7 +577,7 @@
     }
 
     private void insertSpecialCase(String key, boolean isPlatformSlice) {
-        ContentValues values = new ContentValues();
+        final ContentValues values = new ContentValues();
         values.put(SlicesDatabaseHelper.IndexColumns.KEY, key);
         values.put(SlicesDatabaseHelper.IndexColumns.TITLE, TITLE);
         values.put(SlicesDatabaseHelper.IndexColumns.SUMMARY, "s");
@@ -572,8 +587,15 @@
         values.put(SlicesDatabaseHelper.IndexColumns.CONTROLLER, PREF_CONTROLLER);
         values.put(SlicesDatabaseHelper.IndexColumns.PLATFORM_SLICE, isPlatformSlice);
         values.put(SlicesDatabaseHelper.IndexColumns.SLICE_TYPE, SliceData.SliceType.INTENT);
-
-        mDb.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
+        final SQLiteDatabase db = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
+        db.beginTransaction();
+        try {
+            db.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
+            db.setTransactionSuccessful();
+        } finally {
+            db.endTransaction();
+        }
+        db.close();
     }
 
     private static SliceData getDummyData() {
@@ -589,7 +611,7 @@
                 .build();
     }
 
-    @Implements(value = StrictMode.class, inheritImplementationMethods = true)
+    @Implements(value = StrictMode.class)
     public static class ShadowStrictMode {
 
         private static int sSetThreadPolicyCount;
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index f9cc427..1055667 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -433,6 +433,25 @@
     }
 
     @Test
+    public void buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon() {
+        final int expectedIconResource = IconCompat.createWithResource(mContext,
+                R.drawable.ic_settings).toIcon().getResId();
+        final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
+                SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
+                IS_DYNAMIC_SUMMARY_ALLOWED);
+        Settings.Global.putInt(mContext.getContentResolver(),
+                FakeUnavailablePreferenceController.AVAILABILITY_KEY,
+                BasePreferenceController.DISABLED_DEPENDENT_SETTING);
+
+        final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
+
+        final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+        final SliceAction primaryAction = metadata.getPrimaryAction();
+        final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
+        assertThat(actualIconResource).isEqualTo(expectedIconResource);
+    }
+
+    @Test
     public void buildToggleSlice_noIconPassed_returnsSliceWithIcon() {
         final int expectedIconResource = IconCompat.createWithResource(mContext,
                 R.drawable.ic_settings).toIcon().getResId();
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
index 949d151..bebf797 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
@@ -21,6 +21,8 @@
 
 import static org.mockito.Mockito.spy;
 
+import android.app.ApplicationPackageManager;
+import android.content.ComponentName;
 import android.content.ContentValues;
 import android.content.Context;
 import android.database.sqlite.SQLiteDatabase;
@@ -33,6 +35,10 @@
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.FakeIndexProvider;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
+import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
+import com.android.settings.testutils.shadow.ShadowUserManager;
+import com.android.settings.testutils.shadow.ShadowUtils;
 
 import org.junit.After;
 import org.junit.Before;
@@ -40,6 +46,8 @@
 import org.junit.runner.RunWith;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
 import org.robolectric.shadow.api.Shadow;
 import org.robolectric.shadows.ShadowAccessibilityManager;
 
@@ -49,6 +57,9 @@
 
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowUserManager.class, ShadowUtils.class,
+        SlicesDatabaseAccessorTest.ShadowApplicationPackageManager.class,
+        ShadowBluetoothAdapter.class, ShadowLockPatternUtils.class})
 public class SlicesDatabaseAccessorTest {
 
     private final String FAKE_TITLE = "title";
@@ -66,6 +77,7 @@
     @Before
     public void setUp() {
         mContext = RuntimeEnvironment.application;
+        ShadowUserManager.getShadow().setIsAdminUser(true);
         mAccessor = spy(new SlicesDatabaseAccessor(mContext));
         mDb = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
         SlicesDatabaseHelper.getInstance(mContext).setIndexedState();
@@ -78,6 +90,7 @@
 
     @After
     public void cleanUp() {
+        ShadowUserManager.getShadow().reset();
         DatabaseTestUtils.clearDb(mContext);
     }
 
@@ -258,4 +271,14 @@
 
         mDb.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
     }
+
+    @Implements(ApplicationPackageManager.class)
+    public static class ShadowApplicationPackageManager extends
+            org.robolectric.shadows.ShadowApplicationPackageManager {
+
+        @Implementation
+        protected ComponentName getInstantAppResolverSettingsComponent() {
+            return null;
+        }
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java b/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
index c92ee91..4602711 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesIndexerTest.java
@@ -60,13 +60,11 @@
 
     private SlicesIndexer mManager;
 
-    private SQLiteDatabase mDb;
 
     @Before
     public void setUp() {
         mContext = RuntimeEnvironment.application;
         mManager = spy(new SlicesIndexer(mContext));
-        mDb = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
     }
 
     @After
@@ -84,11 +82,16 @@
         // Attempt indexing - should not do anything.
         mManager.run();
 
-        Cursor cursor = mDb.rawQuery("SELECT * FROM slices_index", null);
-        cursor.moveToFirst();
-        assertThat(cursor.getCount()).isEqualTo(1);
-        assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.KEY))).isEqualTo(newKey);
-        assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE))).isEqualTo(newTitle);
+        final SQLiteDatabase db = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
+        try (final Cursor cursor = db.rawQuery("SELECT * FROM slices_index", null)) {
+            cursor.moveToFirst();
+            assertThat(cursor.getCount()).isEqualTo(1);
+            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.KEY))).isEqualTo(newKey);
+            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE)))
+                    .isEqualTo(newTitle);
+        } finally {
+            db.close();
+        }
     }
 
     @Test
@@ -109,33 +112,43 @@
 
         mManager.run();
 
-        final Cursor cursor = mDb.rawQuery("SELECT * FROM slices_index", null);
-        assertThat(cursor.getCount()).isEqualTo(sliceData.size());
+        final SQLiteDatabase db = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
+        try (final Cursor cursor = db.rawQuery("SELECT * FROM slices_index", null)) {
+            assertThat(cursor.getCount()).isEqualTo(sliceData.size());
 
-        cursor.moveToFirst();
-        for (int i = 0; i < sliceData.size(); i++) {
-            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.KEY))).isEqualTo(
-                    KEYS[i]);
-            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE))).isEqualTo(
-                    TITLES[i]);
-            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.FRAGMENT))).isEqualTo(
-                    FRAGMENT_NAME);
-            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.SCREENTITLE))).isEqualTo(
-                    SCREEN_TITLE);
-            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.KEYWORDS))).isEqualTo(
-                    KEYWORDS);
-            assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.ICON_RESOURCE))).isEqualTo(
-                    ICON);
-            assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.CONTROLLER))).isEqualTo(
-                    PREF_CONTROLLER);
-            assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.PLATFORM_SLICE))).isEqualTo(
-                    1 /* true */);
-            assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.SLICE_TYPE))).isEqualTo(
-                    SLICE_TYPE);
-            assertThat(cursor.getInt(
-                    cursor.getColumnIndex(IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE))).isEqualTo(
-                    1 /* true */);
-            cursor.moveToNext();
+            cursor.moveToFirst();
+            for (int i = 0; i < sliceData.size(); i++) {
+                assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.KEY)))
+                        .isEqualTo(KEYS[i]);
+                assertThat(cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE)))
+                        .isEqualTo(TITLES[i]);
+                assertThat(
+                        cursor.getString(cursor.getColumnIndex(IndexColumns.FRAGMENT)))
+                        .isEqualTo(FRAGMENT_NAME);
+                assertThat(cursor.getString(
+                        cursor.getColumnIndex(IndexColumns.SCREENTITLE))).isEqualTo(SCREEN_TITLE);
+                assertThat(
+                        cursor.getString(cursor.getColumnIndex(IndexColumns.KEYWORDS)))
+                        .isEqualTo(KEYWORDS);
+                assertThat(
+                        cursor.getInt(cursor.getColumnIndex(IndexColumns.ICON_RESOURCE)))
+                        .isEqualTo(ICON);
+                assertThat(
+                        cursor.getString(cursor.getColumnIndex(IndexColumns.CONTROLLER)))
+                        .isEqualTo(PREF_CONTROLLER);
+                assertThat(cursor.getInt(
+                        cursor.getColumnIndex(IndexColumns.PLATFORM_SLICE)))
+                        .isEqualTo(1 /* true */);
+                assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.SLICE_TYPE)))
+                        .isEqualTo(SLICE_TYPE);
+                assertThat(cursor.getInt(
+                        cursor.getColumnIndex(
+                                IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE)))
+                        .isEqualTo(1 /* true */);
+                cursor.moveToNext();
+            }
+        } finally {
+            db.close();
         }
     }
 
@@ -143,8 +156,15 @@
         final ContentValues values = new ContentValues();
         values.put(IndexColumns.KEY, key);
         values.put(IndexColumns.TITLE, title);
-
-        mDb.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
+        final SQLiteDatabase db = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
+        db.beginTransaction();
+        try {
+            db.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, values);
+            db.setTransactionSuccessful();
+        } finally {
+            db.endTransaction();
+        }
+        db.close();
     }
 
     private List<SliceData> getDummyIndexableData() {
diff --git a/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
index 1b5bdf8..2ed1907 100644
--- a/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
@@ -169,7 +169,6 @@
     @After
     public void tearDown() {
         mShadowAudioManager.reset();
-        mShadowMediaRouter.reset();
         ShadowBluetoothUtils.reset();
     }
 
diff --git a/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
index 58df2d2..e3014b7 100644
--- a/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
@@ -164,7 +164,6 @@
     @After
     public void tearDown() {
         mShadowAudioManager.reset();
-        mShadowMediaRouter.reset();
         ShadowBluetoothUtils.reset();
     }
 
diff --git a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
index 9e1ac3d..cdee894 100644
--- a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
@@ -165,7 +165,6 @@
     @After
     public void tearDown() {
         mShadowAudioManager.reset();
-        mShadowMediaRouter.reset();
         ShadowBluetoothUtils.reset();
     }
 
diff --git a/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java
index ff09412..542a4a1 100644
--- a/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/system/FactoryResetPreferenceControllerTest.java
@@ -18,10 +18,10 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Context;
-import android.os.UserManager;
 import android.provider.Settings;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.testutils.shadow.ShadowUtils;
 
 import org.junit.After;
@@ -29,10 +29,10 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowUserManager;
+import org.robolectric.annotation.Config;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = ShadowUserManager.class)
 public class FactoryResetPreferenceControllerTest {
 
     private static final String FACTORY_RESET_KEY = "factory_reset";
@@ -45,8 +45,7 @@
     @Before
     public void setUp() {
         mContext = RuntimeEnvironment.application;
-        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        mShadowUserManager = Shadows.shadowOf(userManager);
+        mShadowUserManager = ShadowUserManager.getShadow();
 
         mController = new FactoryResetPreferenceController(mContext);
     }
diff --git a/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java
index 597389a..5f787a9 100644
--- a/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java
@@ -23,6 +23,7 @@
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.XmlTestUtils;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 
 import org.junit.After;
 import org.junit.Before;
@@ -34,18 +35,20 @@
 import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.class)
+@Config(shadows = {SettingsShadowResources.class, ShadowUserManager.class})
 public class SystemDashboardFragmentTest {
 
     @Before
     public void setup() {
         SettingsShadowResources.overrideResource(
                 com.android.internal.R.bool.config_supportSystemNavigationKeys, true);
+        ShadowUserManager.getShadow().setIsAdminUser(true);
     }
 
     @After
     public void tearDown() {
         SettingsShadowResources.reset();
+        ShadowUserManager.getShadow().reset();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
index 4245c96..bd17fd7 100644
--- a/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
@@ -29,13 +29,13 @@
 import android.os.Build;
 import android.os.Bundle;
 import android.os.SystemUpdateManager;
-import android.os.UserManager;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 
 import org.junit.After;
 import org.junit.Before;
@@ -44,15 +44,14 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.shadows.ShadowUserManager;
 
 import java.util.ArrayList;
 import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = ShadowUserManager.class)
 public class SystemUpdatePreferenceControllerTest {
 
     @Mock
@@ -69,8 +68,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
-        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
-        mShadowUserManager = Shadows.shadowOf(userManager);
+        mShadowUserManager = ShadowUserManager.getShadow();
 
         ShadowApplication.getInstance().setSystemService(Context.SYSTEM_UPDATE_SERVICE,
                 mSystemUpdateManager);
@@ -140,7 +138,8 @@
         mController.updateState(mPreference);
 
         assertThat(mPreference.getSummary())
-            .isEqualTo(mContext.getString(R.string.android_version_summary, Build.VERSION.RELEASE));
+                .isEqualTo(mContext.getString(R.string.android_version_summary,
+                        Build.VERSION.RELEASE));
     }
 
     @Test
@@ -155,7 +154,7 @@
         mController.updateState(mPreference);
 
         assertThat(mPreference.getSummary())
-            .isEqualTo(mContext.getString(R.string.android_version_summary, testReleaseName));
+                .isEqualTo(mContext.getString(R.string.android_version_summary, testReleaseName));
     }
 
     @Test
@@ -167,6 +166,6 @@
         mController.updateState(mPreference);
 
         assertThat(mPreference.getSummary())
-            .isEqualTo(mContext.getString(R.string.android_version_pending_update_summary));
+                .isEqualTo(mContext.getString(R.string.android_version_pending_update_summary));
     }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/testutils/ResIdSubject.java b/tests/robotests/src/com/android/settings/testutils/ResIdSubject.java
deleted file mode 100644
index 3803d75..0000000
--- a/tests/robotests/src/com/android/settings/testutils/ResIdSubject.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.testutils;
-
-import static com.google.common.truth.Truth.assertAbout;
-
-import static org.robolectric.RuntimeEnvironment.application;
-
-import androidx.annotation.Nullable;
-
-import com.google.common.truth.ComparableSubject;
-import com.google.common.truth.FailureStrategy;
-import com.google.common.truth.SubjectFactory;
-
-/**
- * Custom subject for use with {@link com.google.common.truth.Truth}, to provide a more readable
- * error message, so that instead of "Not true that 2130706432 equals to 17170444", it will say
- * "Not true that color/my_color equals to android:color/black".
- *
- * <p>Usage:
- * <pre>{@code
- *     ResIdSubject.assertResId(activity.getThemeResId()).isEqualTo(android.R.style.Theme_Material)
- * }</pre>
- */
-public class ResIdSubject extends ComparableSubject<ResIdSubject, Integer> {
-
-    public static final SubjectFactory<ResIdSubject, Integer> FACTORY =
-            new SubjectFactory<ResIdSubject, Integer>() {
-                @Override
-                public ResIdSubject getSubject(
-                        FailureStrategy failureStrategy, Integer integer) {
-                    return new ResIdSubject(failureStrategy, integer);
-                }
-            };
-
-    public static ResIdSubject assertResId(int resId) {
-        return assertAbout(ResIdSubject.FACTORY).that(resId);
-    }
-
-    public ResIdSubject(
-            FailureStrategy failureStrategy,
-            @Nullable Integer integer) {
-        super(failureStrategy, integer);
-    }
-
-    public void isEqualTo(int other) {
-        Integer subject = getSubject();
-        if (subject == null || subject != other) {
-            fail("equals to", resIdToString(other));
-        }
-    }
-
-    @Override
-    protected String getDisplaySubject() {
-        String resourceName = "<" + resIdToString(getSubject()) + ">";
-        String customName = internalCustomName();
-        if (customName != null) {
-            return customName + " " + resourceName;
-        } else {
-            return resourceName;
-        }
-    }
-
-    private static String resIdToString(int resId) {
-        return application.getResources().getResourceName(resId);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java b/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
index 49197e8..5e5410c 100644
--- a/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
+++ b/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
@@ -88,6 +88,8 @@
             paths.add(new ResourcePath(null,
                 Fs.fromURL(new URL("file:frameworks/opt/setupwizard/library/main/res")), null));
             paths.add(new ResourcePath(null,
+                    Fs.fromURL(new URL("file:out/target/common/obj/JAVA_LIBRARIES/robolectric_android-all-stub_intermediates/classes/raw-res/res")), null));
+            paths.add(new ResourcePath(null,
                 Fs.fromURL(new URL("file:frameworks/opt/setupwizard/library/gingerbread/res")), null));
             paths.add(new ResourcePath(null,
                 Fs.fromURL(new URL("file:frameworks/opt/setupwizard/library/recyclerview/res")), null));
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
index bd21cdc..c673508 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
@@ -24,13 +24,10 @@
 
 import com.android.settings.R;
 
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
 import org.robolectric.android.XmlResourceParserImpl;
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 import org.robolectric.annotation.RealObject;
-import org.robolectric.shadows.ShadowAssetManager;
 import org.robolectric.shadows.ShadowResources;
 import org.robolectric.util.ReflectionHelpers;
 import org.robolectric.util.ReflectionHelpers.ClassParameter;
@@ -40,7 +37,7 @@
  * Shadow Resources and Theme classes to handle resource references that Robolectric shadows cannot
  * handle because they are too new or private.
  */
-@Implements(value = Resources.class, inheritImplementationMethods = true)
+@Implements(value = Resources.class)
 public class SettingsShadowResources extends ShadowResources {
 
     @RealObject
@@ -178,17 +175,14 @@
                 ClassParameter.from(int.class, id));
     }
 
-    @Implements(value = Theme.class, inheritImplementationMethods = true)
-    public static class SettingsShadowTheme extends ShadowTheme {
+    @Implements(value = Theme.class)
+    public static class SettingsShadowTheme extends ShadowLegacyTheme {
 
         @RealObject
         Theme realTheme;
 
-        private ShadowAssetManager mAssetManager = Shadows.shadowOf(
-                RuntimeEnvironment.application.getAssets());
-
         @Implementation
-        public TypedArray obtainStyledAttributes(
+        protected TypedArray obtainStyledAttributes(
                 AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) {
             // Replace all private string references with a placeholder.
             if (set != null) {
@@ -228,7 +222,7 @@
         }
 
         private Resources getResources() {
-            return ReflectionHelpers.callInstanceMethod(ShadowTheme.class, this, "getResources");
+            return ReflectionHelpers.callInstanceMethod(ShadowLegacyTheme.class, this, "getResources");
         }
     }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
index dd51687..c76991e 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java
@@ -26,15 +26,14 @@
 
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
-import org.robolectric.shadows.ShadowResourcesImpl;
+import org.robolectric.shadows.ShadowLegacyResourcesImpl;
 
 @Implements(
         value = ResourcesImpl.class,
-        inheritImplementationMethods = true,
         isInAndroidSdk = false,
         minSdk = 26
 )
-public class SettingsShadowResourcesImpl extends ShadowResourcesImpl {
+public class SettingsShadowResourcesImpl extends ShadowLegacyResourcesImpl {
 
     @Implementation
     public Drawable loadDrawable(Resources wrapper, TypedValue value, int id, int density,
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowTypedArray.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowTypedArray.java
index fc3ff0c..1e64dd1 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowTypedArray.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowTypedArray.java
@@ -30,7 +30,7 @@
 import org.robolectric.annotation.RealObject;
 import org.robolectric.shadows.ShadowTypedArray;
 
-@Implements(value = TypedArray.class, inheritImplementationMethods = true)
+@Implements(value = TypedArray.class)
 public class SettingsShadowTypedArray extends ShadowTypedArray {
 
     @RealObject
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivity.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivity.java
index 0f67bbf..babf9e3 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivity.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivity.java
@@ -23,13 +23,12 @@
 
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
-import org.robolectric.shadows.ShadowApplication;
 
 @Implements(CustomActivity.class)
 public class ShadowActivity extends org.robolectric.shadows.ShadowActivity {
 
     @Implementation
-    public void startActivityAsUser(Intent intent, UserHandle user) {
-        ShadowApplication.getInstance().startActivity(intent);
+    protected void startActivityAsUser(Intent intent, UserHandle user) {
+        realActivity.startActivity(intent);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java
index bcf90c4..cea50f3 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAudioManager.java
@@ -38,7 +38,7 @@
 
 import java.util.ArrayList;
 
-@Implements(value = AudioManager.class, inheritImplementationMethods = true)
+@Implements(value = AudioManager.class)
 public class ShadowAudioManager extends org.robolectric.shadows.ShadowAudioManager {
     private int mRingerMode;
     private int mDeviceCodes;
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java
index 30837f4..371c1b1 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java
@@ -24,11 +24,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
-@Implements(value = BluetoothAdapter.class, inheritImplementationMethods = true)
+@Implements(value = BluetoothAdapter.class)
 public class ShadowBluetoothAdapter extends org.robolectric.shadows.ShadowBluetoothAdapter {
 
-    private String mName;
-    private int mScanMode;
     private int mState;
     private List<Integer> mSupportedProfiles = new ArrayList<Integer>();
 
@@ -45,25 +43,6 @@
         mSupportedProfiles.clear();
     }
 
-    public void setName(String name) {
-        mName = name;
-    }
-
-    @Implementation
-    public String getName() {
-        return mName;
-    }
-
-    @Implementation
-    public void setScanMode(int scanMode) {
-        mScanMode = scanMode;
-    }
-
-    @Implementation
-    public int getScanMode() {
-        return mScanMode;
-    }
-
     @Implementation
     public int getConnectionState() {
         return mState;
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothDevice.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothDevice.java
index a96f781..0b1665c 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothDevice.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothDevice.java
@@ -21,7 +21,7 @@
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 
-@Implements(value = BluetoothDevice.class, inheritImplementationMethods = true)
+@Implements(value = BluetoothDevice.class)
 public class ShadowBluetoothDevice extends org.robolectric.shadows.ShadowBluetoothDevice {
 
     private int mMessageAccessPermission = BluetoothDevice.ACCESS_UNKNOWN;
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowCardView.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowCardView.java
deleted file mode 100644
index 75526c8..0000000
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowCardView.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.testutils.shadow;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import androidx.cardview.widget.CardView;
-
-import org.robolectric.annotation.Implements;
-import org.robolectric.shadows.ShadowFrameLayout;
-
-/**
- * Shadow for CardView to get around view not implemented error.
- */
-@Implements(CardView.class)
-public class ShadowCardView extends ShadowFrameLayout {
-
-    public void __constructor__(Context context, AttributeSet attrs, int defStyleAttr) {
-        // do nothing
-    }
-
-}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java
index 05687f4..794fcbb 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java
@@ -24,7 +24,7 @@
 import org.robolectric.annotation.Implements;
 import org.robolectric.shadow.api.Shadow;
 
-@Implements(value = ConnectivityManager.class, inheritImplementationMethods = true)
+@Implements(value = ConnectivityManager.class)
 public class ShadowConnectivityManager extends org.robolectric.shadows.ShadowConnectivityManager {
 
     private final SparseBooleanArray mSupportedNetworkTypes = new SparseBooleanArray();
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFingerprintManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFingerprintManager.java
index e4be318..cb185a5 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFingerprintManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFingerprintManager.java
@@ -16,7 +16,6 @@
 
 package com.android.settings.testutils.shadow;
 
-import android.content.Context;
 import android.hardware.fingerprint.Fingerprint;
 import android.hardware.fingerprint.FingerprintManager;
 
@@ -25,36 +24,16 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
-import org.robolectric.annotation.Resetter;
 import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowContextImpl;
-import org.robolectric.util.ReflectionHelpers;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.IntStream;
 
 @Implements(FingerprintManager.class)
-public class ShadowFingerprintManager {
+public class ShadowFingerprintManager extends org.robolectric.shadows.ShadowFingerprintManager {
 
-    private static Map<String, String> getSystemServiceMap() {
-        return ReflectionHelpers.getStaticField(ShadowContextImpl.class, "SYSTEM_SERVICE_MAP");
-    }
-
-    /**
-     * Call this in @Before of a test to add FingerprintManager to Robolectric's system service
-     * map. Otherwise getSystemService(FINGERPRINT_SERVICE) will return null.
-     */
-    public static void addToServiceMap() {
-        getSystemServiceMap().put(Context.FINGERPRINT_SERVICE, FingerprintManager.class.getName());
-    }
-
-    @Resetter
-    public static void reset() {
-        getSystemServiceMap().remove(Context.FINGERPRINT_SERVICE);
-    }
 
     public boolean hardwareDetected = true;
 
@@ -62,22 +41,22 @@
     private List<Fingerprint> mFingerprints = Collections.emptyList();
 
     @Implementation
-    public boolean isHardwareDetected() {
+    protected boolean isHardwareDetected() {
         return hardwareDetected;
     }
 
     @Implementation
-    public boolean hasEnrolledFingerprints() {
+    protected boolean hasEnrolledFingerprints() {
         return !mFingerprints.isEmpty();
     }
 
     @Implementation
-    public List<Fingerprint> getEnrolledFingerprints() {
+    protected List<Fingerprint> getEnrolledFingerprints() {
         return mFingerprints;
     }
 
     @Implementation
-    public List<Fingerprint> getEnrolledFingerprints(int userId) {
+    protected List<Fingerprint> getEnrolledFingerprints(int userId) {
         return mFingerprints;
     }
 
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowMediaRouter.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowMediaRouter.java
index 68c92a7..a69faba 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowMediaRouter.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowMediaRouter.java
@@ -21,12 +21,11 @@
 import android.media.MediaRouter;
 
 import org.robolectric.annotation.Implements;
-import org.robolectric.annotation.Resetter;
 import org.robolectric.shadow.api.Shadow;
 
 import java.util.concurrent.CopyOnWriteArrayList;
 
-@Implements(value = MediaRouter.class, inheritImplementationMethods = true)
+@Implements(value = MediaRouter.class)
 public class ShadowMediaRouter extends org.robolectric.shadows.ShadowMediaRouter {
     MediaRouter.RouteInfo mSelectedRoute;
 
@@ -42,16 +41,12 @@
     }
 
     public void removeCallback(MediaRouter.Callback cb) {
-        if (mCallbacks.contains(cb))
+        if (mCallbacks.contains(cb)) {
             mCallbacks.remove(cb);
+        }
     }
 
     public static ShadowMediaRouter getShadow() {
         return Shadow.extract(application.getSystemService(MediaRouter.class));
     }
-
-    @Resetter
-    public void reset() {
-        mCallbacks.clear();
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
index bb691cb..61278f3 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java
@@ -37,7 +37,7 @@
 import java.util.Map;
 import java.util.Set;
 
-@Implements(value = UserManager.class, inheritImplementationMethods = true)
+@Implements(value = UserManager.class)
 public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager {
 
     private SparseArray<UserInfo> mUserInfos = new SparseArray<>();
@@ -46,7 +46,7 @@
     private final List<UserInfo> mUserProfileInfos = new ArrayList<>();
     private final Set<Integer> mManagedProfiles = new HashSet<>();
     private boolean mIsQuietModeEnabled = false;
-    private int[] profileIdsForUser;
+    private int[] profileIdsForUser = new int[0];
     private boolean mUserSwitchEnabled;
 
 
@@ -59,6 +59,7 @@
         mManagedProfiles.clear();
         mIsQuietModeEnabled = false;
         mUserSwitchEnabled = false;
+        profileIdsForUser = new int[0];
     }
 
     public void setUserInfo(int userHandle, UserInfo userInfo) {
@@ -66,7 +67,7 @@
     }
 
     @Implementation
-    public UserInfo getUserInfo(int userHandle) {
+    protected UserInfo getUserInfo(int userHandle) {
         return mUserInfos.get(userHandle);
     }
 
@@ -75,12 +76,12 @@
     }
 
     @Implementation
-    public List<UserInfo> getProfiles(@UserIdInt int userHandle) {
+    protected List<UserInfo> getProfiles(@UserIdInt int userHandle) {
         return mUserProfileInfos;
     }
 
     @Implementation
-    public int[] getProfileIds(@UserIdInt int userHandle, boolean enabledOnly) {
+    protected int[] getProfileIds(@UserIdInt int userHandle, boolean enabledOnly) {
         int[] ids = new int[mUserProfileInfos.size()];
         for (int i = 0; i < mUserProfileInfos.size(); i++) {
             ids[i] = mUserProfileInfos.get(i).id;
@@ -99,12 +100,12 @@
     }
 
     @Implementation
-    public int getCredentialOwnerProfile(@UserIdInt int userHandle) {
+    protected int getCredentialOwnerProfile(@UserIdInt int userHandle) {
         return userHandle;
     }
 
     @Implementation
-    public boolean hasBaseUserRestriction(String restrictionKey, UserHandle userHandle) {
+    protected boolean hasBaseUserRestriction(String restrictionKey, UserHandle userHandle) {
         return mRestrictions.contains(restrictionKey);
     }
 
@@ -118,7 +119,7 @@
     }
 
     @Implementation
-    public List<EnforcingUser> getUserRestrictionSources(
+    protected List<EnforcingUser> getUserRestrictionSources(
             String restrictionKey, UserHandle userHandle) {
         // Return empty list when there is no enforcing user, otherwise might trigger
         // NullPointer Exception in RestrictedLockUtils.checkIfRestrictionEnforced.
@@ -133,7 +134,7 @@
     }
 
     @Implementation
-    public boolean isManagedProfile(@UserIdInt int userId) {
+    protected boolean isManagedProfile(@UserIdInt int userId) {
         return mManagedProfiles.contains(userId);
     }
 
@@ -142,7 +143,7 @@
     }
 
     @Implementation
-    public boolean isQuietModeEnabled(UserHandle userHandle) {
+    protected boolean isQuietModeEnabled(UserHandle userHandle) {
         return mIsQuietModeEnabled;
     }
 
@@ -151,7 +152,7 @@
     }
 
     @Implementation
-    public int[] getProfileIdsWithDisabled(@UserIdInt int userId) {
+    protected int[] getProfileIdsWithDisabled(@UserIdInt int userId) {
         return profileIdsForUser;
     }
 
@@ -160,7 +161,7 @@
     }
 
     @Implementation
-    public boolean isUserSwitcherEnabled() {
+    protected boolean isUserSwitcherEnabled() {
         return mUserSwitchEnabled;
     }
 
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowVibrator.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowVibrator.java
deleted file mode 100644
index 69e08d5..0000000
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowVibrator.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.testutils.shadow;
-
-import static org.mockito.Mockito.mock;
-
-import android.content.Context;
-import android.media.AudioAttributes;
-import android.os.SystemVibrator;
-import android.os.VibrationEffect;
-import android.os.Vibrator;
-
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.fakes.RoboVibrator;
-import org.robolectric.shadows.ShadowContextImpl;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.Map;
-
-@Implements(SystemVibrator.class)
-public class ShadowVibrator {
-
-    private static Map<String, String> getSystemServiceMap() {
-        return ReflectionHelpers.getStaticField(ShadowContextImpl.class, "SYSTEM_SERVICE_MAP");
-    }
-
-    public static void addToServiceMap() {
-        getSystemServiceMap().put(Context.VIBRATOR_SERVICE, SystemVibrator.class.getName());
-    }
-
-    public static void reset() {
-        getSystemServiceMap().put(Context.VIBRATOR_SERVICE, RoboVibrator.class.getName());
-    }
-
-    public final Vibrator delegate = mock(Vibrator.class);
-
-    @Implementation
-    public void vibrate(int uid, String opPkg, VibrationEffect vibe, String reason,
-            AudioAttributes attributes) {
-        delegate.vibrate(uid, opPkg, vibe, reason, attributes);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
index d9bc486..b41b396 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java
@@ -30,7 +30,7 @@
 import java.util.Collections;
 import java.util.List;
 
-@Implements(value = WifiManager.class, inheritImplementationMethods = true)
+@Implements(value = WifiManager.class)
 public class ShadowWifiManager extends org.robolectric.shadows.ShadowWifiManager {
 
     public WifiConfiguration savedWifiConfig;
diff --git a/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
index 0f95334..2bd12c3 100644
--- a/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
@@ -38,6 +38,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
@@ -57,9 +58,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        ShadowApplication shadowContext = ShadowApplication.getInstance();
+        mContext = RuntimeEnvironment.application;
         mUserManager = ShadowUserManager.getShadow();
-        mContext = shadowContext.getApplicationContext();
         mController = new AddUserWhenLockedPreferenceController(mContext, "fake_key");
     }
 
diff --git a/tests/robotests/src/com/android/settings/users/AutoSyncDataPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/users/AutoSyncDataPreferenceControllerTest.java
index 04b314e..a791528 100644
--- a/tests/robotests/src/com/android/settings/users/AutoSyncDataPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/users/AutoSyncDataPreferenceControllerTest.java
@@ -64,7 +64,7 @@
         MockitoAnnotations.initMocks(this);
         ShadowApplication shadowContext = ShadowApplication.getInstance();
         shadowContext.setSystemService(Context.USER_SERVICE, mUserManager);
-        mContext = shadowContext.getApplicationContext();
+        mContext = RuntimeEnvironment.application;
         mController = new AutoSyncDataPreferenceController(mContext, mFragment);
         mConfirmSyncFragment = new AutoSyncDataPreferenceController.ConfirmAutoSyncChangeFragment();
         mConfirmSyncFragment.setTargetFragment(mFragment, 0);
diff --git a/tests/robotests/src/com/android/settings/users/AutoSyncPersonalDataPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/users/AutoSyncPersonalDataPreferenceControllerTest.java
index fb75701..1850f3a 100644
--- a/tests/robotests/src/com/android/settings/users/AutoSyncPersonalDataPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/users/AutoSyncPersonalDataPreferenceControllerTest.java
@@ -36,6 +36,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.shadows.ShadowApplication;
 
 import java.util.ArrayList;
@@ -58,9 +59,9 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
         ShadowApplication shadowContext = ShadowApplication.getInstance();
         shadowContext.setSystemService(Context.USER_SERVICE, mUserManager);
-        mContext = shadowContext.getApplicationContext();
         mController = new AutoSyncPersonalDataPreferenceController(mContext, mFragment);
         mPreference = new Preference(mContext);
         mPreference.setKey(mController.getPreferenceKey());
diff --git a/tests/robotests/src/com/android/settings/wallpaper/WallpaperTypePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wallpaper/WallpaperTypePreferenceControllerTest.java
index cf4a37f..e5519a3 100644
--- a/tests/robotests/src/com/android/settings/wallpaper/WallpaperTypePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wallpaper/WallpaperTypePreferenceControllerTest.java
@@ -18,6 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 
@@ -30,7 +31,7 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Robolectric;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class WallpaperTypePreferenceControllerTest {
@@ -43,7 +44,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
+        mContext = Robolectric.setupActivity(Activity.class);
         mController = new WallpaperTypePreferenceController(mContext, "pref_key");
         mIntent = new Intent();
         mPreference = new Preference(mContext);
diff --git a/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
index 042341b..aaffa93 100644
--- a/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RoundedHomepageIconTest.java
@@ -40,6 +40,7 @@
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.drawer.CategoryKey;
 import com.android.settingslib.drawer.Tile;
+import com.android.settingslib.testutils.DrawableTestHelper;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -67,8 +68,8 @@
                 new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
 
         assertThat(icon.getNumberOfLayers()).isEqualTo(2);
-        assertThat(icon.getDrawable(0))
-                .isEqualTo(mContext.getDrawable(R.drawable.ic_homepage_generic_background));
+        DrawableTestHelper.assertDrawableResId(icon.getDrawable(0),
+                R.drawable.ic_homepage_generic_background);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
index ebfe74c3..04b85dc 100644
--- a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
+++ b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
@@ -60,11 +60,10 @@
 
         assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
                 .isEqualTo(mContext.getString(defaultOffText));
-        assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND));
 
         mBar.setChecked(true);
 
-        assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND_ACTIVATED));
+        assertThat(mBar.getBackground()).isInstanceOf(ColorDrawable.class);
         assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
                 .isEqualTo(mContext.getString(defaultOnText));
     }
@@ -75,12 +74,12 @@
         final int offText = R.string.manage_space_text;
 
         mBar.setSwitchBarText(onText, offText);
-        assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND));
         assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
                 .isEqualTo(mContext.getString(offText));
 
         mBar.setChecked(true);
-        assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND_ACTIVATED));
+        assertThat(mBar.getBackground()).isInstanceOf(ColorDrawable.class);
+
         assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
                 .isEqualTo(mContext.getString(onText));
     }
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
new file mode 100644
index 0000000..f987f40
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.wifi;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.DialogInterface;
+import android.widget.Button;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {SettingsShadowResourcesImpl.class, ShadowAlertDialogCompat.class})
+public class NetworkRequestDialogFragmentTest {
+
+  private FragmentActivity mActivity;
+  private NetworkRequestDialogFragment networkRequestDialogFragment;
+
+  @Before
+  public void setUp() {
+    mActivity = Robolectric.setupActivity(FragmentActivity.class);
+    networkRequestDialogFragment = spy(NetworkRequestDialogFragment.newInstance(-1, null));
+  }
+
+  @Test
+  public void display_shouldShowTheDialog() {
+    networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
+    AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+    assertThat(alertDialog).isNotNull();
+    assertThat(alertDialog.isShowing()).isTrue();
+  }
+
+  @Test
+  public void clickPositiveButton_shouldCloseTheDialog() {
+    networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
+    AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
+    assertThat(alertDialog.isShowing()).isTrue();
+
+    Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
+    assertThat(positiveButton).isNotNull();
+
+    positiveButton.performClick();
+    assertThat(alertDialog.isShowing()).isFalse();
+  }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
index c9be0f6..bf4c6e7 100644
--- a/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
@@ -86,7 +86,7 @@
     @Test
     public void updateState_preferenceSetCheckedWhenSettingsAreEnabled() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1);
 
         mController.updateState(preference);
@@ -97,7 +97,7 @@
     @Test
     public void updateState_preferenceSetCheckedWhenSettingsAreDisabled() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(),
                 WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0);
 
         mController.updateState(preference);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
index bd1ad46..5ac25ed 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSliceTest.java
@@ -88,9 +88,8 @@
 
         int rows = SliceQuery.findAll(wifiSlice, FORMAT_SLICE, HINT_LIST_ITEM,
                 null /* nonHints */).size();
-        // All AP rows + title row + see more row
-        // (see more row will drop the last AP row, thus -1)
-        assertThat(rows).isEqualTo(DEFAULT_EXPANDED_ROW_COUNT - 1 + 2);
+        // All AP rows + title row
+        assertThat(rows).isEqualTo(DEFAULT_EXPANDED_ROW_COUNT + 1);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
index ffe1d8f..6deae7f 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
@@ -48,16 +48,14 @@
 @RunWith(SettingsRobolectricTestRunner.class)
 public class WifiWakeupPreferenceControllerTest {
 
-    private static final String NO_LOCATION_STRING =
-            "Unavailable because location is turned off. Turn on location.";
     private Context mContext;
     private WifiWakeupPreferenceController mController;
     @Mock
-    DashboardFragment mFragment;
+    private DashboardFragment mFragment;
     @Mock
-    LocationManager mLocationManager;
+    private LocationManager mLocationManager;
     @Mock
-    SwitchPreference mPreference;
+    private SwitchPreference mPreference;
 
     @Before
     public void setUp() {
@@ -67,7 +65,7 @@
         mController.mLocationManager = mLocationManager;
         mController.mPreference = mPreference;
 
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
         doReturn(true).when(mLocationManager).isLocationEnabled();
     }
 
@@ -105,7 +103,8 @@
     @Test
     public void updateState_preferenceSetCheckedWhenWakeupSettingEnabled() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
 
         mController.updateState(preference);
 
@@ -116,7 +115,7 @@
     @Test
     public void updateState_preferenceSetUncheckedWhenWakeupSettingDisabled() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
 
         mController.updateState(preference);
 
@@ -127,8 +126,8 @@
     @Test
     public void updateState_preferenceSetUncheckedWhenWifiScanningDisabled() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
 
         mController.updateState(preference);
 
@@ -138,7 +137,7 @@
     @Test
     public void updateState_preferenceSetUncheckedWhenWakeupSettingEnabledNoLocation() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
         doReturn(false).when(mLocationManager).isLocationEnabled();
 
         mController.updateState(preference);
@@ -150,7 +149,7 @@
     @Test
     public void updateState_preferenceSetUncheckedWhenWakeupSettingDisabledLocationEnabled() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
         doReturn(false).when(mLocationManager).isLocationEnabled();
 
         mController.updateState(preference);
@@ -162,8 +161,8 @@
     @Test
     public void updateState_preferenceSetUncheckedWhenWifiScanningDisabledLocationEnabled() {
         final SwitchPreference preference = mock(SwitchPreference.class);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
-        Settings.System.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+        Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
         doReturn(false).when(mLocationManager).isLocationEnabled();
 
         mController.updateState(preference);