Merge "Move profile selector dialog to Settings"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ccdc2dc..bb43bbf 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -425,6 +425,17 @@
                 android:value="com.android.settings.gestures.AssistGestureSettings" />
         </activity>
 
+        <activity android:name="Settings$FaceSettingsActivity"
+            android:label="@string/security_settings_face_preference_title"
+            android:icon="@drawable/ic_face_header">
+            <intent-filter>
+                <action android:name="android.settings.FACE_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                android:value="com.android.settings.biometrics.face.FaceSettings" />
+        </activity>
+
         <activity android:name=".bluetooth.DevicePickerActivity"
                 android:label="@string/device_picker"
                 android:configChanges="orientation|keyboardHidden|screenSize"
@@ -1945,13 +1956,6 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".connecteddevice.usb.UsbModeChooserActivity"
-                  android:excludeFromRecents="true"
-                  android:exported="true"
-                  android:permission="android.permission.MANAGE_USB"
-                  android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar">
-        </activity>
-
         <activity android:name=".Settings$UsbDetailsActivity"
                   android:excludeFromRecents="true"
                   android:permission="android.permission.MANAGE_USB"
diff --git a/res/drawable/ic_accessibility_illustration_colorblind.xml b/res/drawable/ic_accessibility_illustration_colorblind.xml
new file mode 100644
index 0000000..e2e73aa
--- /dev/null
+++ b/res/drawable/ic_accessibility_illustration_colorblind.xml
@@ -0,0 +1,67 @@
+<!--
+  ~ 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
+  -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportHeight="264.0"
+        android:viewportWidth="264.0">
+    <path android:fillColor="#FBBC04"
+          android:pathData="M112.52,208.91c-0.15,-0.9 -0.95,-1.54 -1.87,-1.51c-17.81,0.66 -36.14,-7.45 -51.36,-19.19c-24.31,-18.75 -40.49,-51.17 -34.81,-79.36l-3.53,-1.81c-24.28,31.54 -18.42,76.8 13.11,101.11c23.58,18.19 53.7,19.43 78.15,5.76L112.52,208.91z"/>
+    <path android:fillColor="#FDE293"
+          android:pathData="M44.48,195.92c18.36,14.16 46.39,20.23 66.95,18.26c1.04,-0.1 1.79,-1.05 1.62,-2.09l-0.52,-3.19c-0.15,-0.9 -0.95,-1.54 -1.87,-1.51c-17.81,0.66 -36.14,-7.45 -51.36,-19.19c-24.31,-18.75 -40.49,-51.17 -34.81,-79.36l-3.53,-1.81C9.98,136.93 15.03,173.21 44.48,195.92z"/>
+    <path android:fillColor="#6D4C41"
+          android:pathData="M20.8,107.25l1.15,-7.6c0.18,-1.17 1.42,-1.85 2.5,-1.38l3.31,1.44c1.01,0.44 1.39,1.67 0.81,2.6l-4.08,6.55L20.8,107.25z"/>
+    <path android:fillColor="#6D4C41"
+          android:pathData="M102,74.65l-0.03,2.62c-1.15,0.05 -2.31,0.04 -3.46,-0.02c-0.01,-0.04 0.01,-2.58 0,-2.62c-1.03,-7.56 0.59,-13.08 1.98,-16.21c0.35,-0.79 1.22,-1.2 2.05,-0.98c1.22,0.33 2.44,0.68 3.64,1.04c1.1,0.34 1.58,1.65 0.94,2.61C102.05,68.82 102,74.65 102,74.65z"/>
+    <path android:fillColor="#FEEFC3"
+          android:pathData="M148.04,97.35c-1.11,-13.75 -12.4,-24.77 -26.17,-25.59c-3.6,-0.21 -7.06,0.26 -10.28,1.29c-7.39,2.39 -15.3,2.33 -22.66,-0.15c-3.2,-1.08 -6.65,-1.6 -10.26,-1.43c-13.78,0.63 -25.21,11.5 -26.51,25.24c-0.47,4.97 0.38,9.7 2.22,13.9l-0.01,0l18.44,43.41c0.04,0.1 0.08,0.2 0.12,0.29l0.15,0.36l0.02,0c2.21,4.75 6.99,8.06 12.57,8.1c2.57,0.02 4.99,-0.66 7.07,-1.86c4.26,-2.46 9.62,-2.42 13.85,0.09c2.06,1.23 4.47,1.94 7.04,1.96c5.58,0.04 10.41,-3.21 12.68,-7.93l0.02,0l0.16,-0.36c0.04,-0.1 0.09,-0.19 0.13,-0.29l19.02,-43.16l-0.01,0C147.53,107.05 148.45,102.33 148.04,97.35z"/>
+    <path android:fillColor="#EA4335"
+          android:pathData="M79.99,77.27c2.43,0 4.81,0.39 7.08,1.16c4.34,1.47 8.86,2.21 13.42,2.21c4.38,0 8.71,-0.68 12.89,-2.03c2.18,-0.71 4.47,-1.06 6.79,-1.06c0.45,0 0.9,0.01 1.35,0.04c10.92,0.65 19.83,9.35 20.71,20.25c0.31,3.83 -0.33,7.53 -1.9,10.99l-3.94,8.69l0.13,-0.01l-15.22,34.54l-0.03,0.06l-0.02,0.04l0,0.01l-0.17,0.36c-1.38,2.86 -4.19,4.63 -7.34,4.63l-0.06,0c-1.45,-0.01 -2.87,-0.4 -4.1,-1.14c-3,-1.78 -6.45,-2.73 -9.98,-2.73c-3.44,0 -6.81,0.9 -9.75,2.6c-1.23,0.71 -2.63,1.08 -4.06,1.08l-0.06,0c-3.13,-0.02 -6,-1.88 -7.33,-4.73l-0.15,-0.33l-0.02,-0.05l-0.02,-0.05l-0.02,-0.05l-14.77,-34.77l0.13,0.01l-3.82,-8.71c-1.53,-3.48 -2.12,-7.19 -1.76,-11.02c1.03,-10.88 10.05,-19.47 20.98,-19.97C79.3,77.28 79.64,77.27 79.99,77.27L79.99,77.27M79.99,71.45c-0.44,0 -0.87,0.01 -1.31,0.03c-13.78,0.63 -25.21,11.5 -26.51,25.24c-0.47,4.97 0.38,9.7 2.22,13.9l-0.01,0l18.44,43.41c0.04,0.1 0.08,0.2 0.12,0.29l0.15,0.36l0.02,0c2.21,4.75 6.99,8.06 12.57,8.1c0.03,0 0.06,0 0.1,0c2.54,0 4.92,-0.68 6.97,-1.86c2.1,-1.21 4.47,-1.82 6.84,-1.82c2.43,0 4.86,0.64 7,1.91c2.06,1.23 4.47,1.94 7.04,1.96c0.03,0 0.06,0 0.1,0c5.54,0 10.33,-3.24 12.58,-7.93l0.02,0l0.16,-0.36c0.04,-0.1 0.09,-0.19 0.13,-0.29l19.02,-43.16l-0.01,0c1.9,-4.17 2.81,-8.9 2.41,-13.87c-1.11,-13.75 -12.4,-24.77 -26.17,-25.59c-0.57,-0.03 -1.13,-0.05 -1.69,-0.05c-2.99,0 -5.88,0.47 -8.58,1.35c-3.62,1.17 -7.36,1.75 -11.1,1.75c-3.9,0 -7.8,-0.63 -11.56,-1.9C86.13,71.96 83.12,71.45 79.99,71.45L79.99,71.45z"/>
+    <path android:fillColor="#FBBC04"
+          android:pathData="M87.76,114.52c-1.45,-0.01 -2.63,1.16 -2.64,2.6c-0.01,1.45 1.16,2.63 2.6,2.64c1.45,0.01 5.26,-2.59 5.26,-2.59S89.21,114.53 87.76,114.52z"/>
+    <path android:fillColor="#FBBC04"
+          android:pathData="M93.4,106.75c-1.02,-1.03 -2.68,-1.04 -3.71,-0.02c-1.03,1.02 -1.04,2.68 -0.02,3.71c1.02,1.03 5.55,1.89 5.55,1.89S94.42,107.78 93.4,106.75z"/>
+    <path android:fillColor="#FBBC04"
+          android:pathData="M93.26,128.06c-1.03,1.02 -2.69,1.01 -3.71,-0.02c-1.02,-1.03 -1.01,-2.69 0.02,-3.71c1.03,-1.02 5.57,-1.82 5.57,-1.82S94.29,127.04 93.26,128.06z"/>
+    <path android:fillColor="#EA4335"
+          android:pathData="M148.04,97.35c-1.11,-13.75 -12.4,-24.77 -26.17,-25.59c-3.6,-0.21 -7.06,0.26 -10.28,1.29c-3.69,1.19 -7.52,1.78 -11.34,1.75l-0.56,84.29c2.4,0.02 4.8,0.65 6.91,1.91c2.06,1.23 4.47,1.94 7.04,1.96c5.58,0.04 10.41,-3.21 12.68,-7.93l0.02,0l0.16,-0.36c0.04,-0.1 0.09,-0.19 0.13,-0.29l19.02,-43.16l-0.01,0C147.53,107.05 148.45,102.33 148.04,97.35z"/>
+    <path android:fillColor="#9CCC65"
+          android:pathData="M169.25,173.55c-0.75,-0.24 -1.54,-0.38 -2.37,-0.37c-4.11,0.03 -7.42,3.38 -7.39,7.49C164.05,180.63 167.9,177.65 169.25,173.55z"/>
+    <path android:fillColor="#9CCC65"
+          android:pathData="M149.06,170.38c0.04,5.72 4.71,10.33 10.43,10.29C159.45,174.94 154.78,170.34 149.06,170.38z"/>
+    <path android:fillColor="#F57C00"
+          android:pathData="M128.64,213.24a31.07,31.07 0,1 0,62.14 -0.42a31.07,31.07 0,1 0,-62.14 0.42z"/>
+    <path android:fillColor="#9CCC65"
+          android:pathData="M153.74,20.13c-1.04,0.17 -1.87,0.99 -2.04,2.04c-0.86,5.29 0.73,10.9 4.81,14.97s9.69,5.67 14.97,4.81c1.04,-0.17 1.87,-0.99 2.04,-2.04c0.86,-5.29 -0.73,-10.9 -4.81,-14.97C164.64,20.86 159.03,19.27 153.74,20.13z"/>
+    <path android:fillColor="#3949AB"
+          android:pathData="M158.58,69.64a12.99,12.99 62.72,1 0,4.91 -25.51a12.99,12.99 62.72,1 0,-4.91 25.51z"/>
+    <path android:fillColor="#1A237E"
+          android:pathData="M159.66,51.83l2.66,2.78l3.74,0.91l-2.78,2.66l-0.91,3.75l-2.66,-2.79l-3.74,-0.91l2.78,-2.66z"/>
+    <path android:fillColor="#3949AB"
+          android:pathData="M185.95,62.31a12.99,12.99 114.61,1 0,4.91 -25.51a12.99,12.99 62.72,1 0,-4.91 25.51z"/>
+    <path android:fillColor="#1A237E"
+          android:pathData="M187.03,44.49l2.66,2.79l3.74,0.91l-2.78,2.66l-0.91,3.74l-2.66,-2.78l-3.74,-0.91l2.78,-2.66z"/>
+    <path android:fillColor="#3949AB"
+          android:pathData="M169.42,83.27a12.99,12.99 87.23,1 0,21.51 -14.57a12.99,12.99 123.26,1 0,-21.51 14.57z"/>
+    <path android:fillColor="#1A237E"
+          android:pathData="M182.79,71.45l-0.09,3.85l2,3.29l-3.85,-0.09l-3.29,2l0.09,-3.85l-2,-3.29l3.85,0.09z"/>
+    <path android:fillColor="#8D6E63"
+          android:pathData="M242.38,62.35c0.98,2.75 2.3,9.01 -1.42,17.85l2.91,0.73c0,0 5.93,-9.31 4.14,-20.42c-0.2,-1.27 -1.58,-2 -2.76,-1.49c-0.72,0.31 -1.35,0.61 -1.88,0.87C242.47,60.35 242.04,61.4 242.38,62.35z"/>
+    <path android:fillColor="#9CCC65"
+          android:pathData="M255.94,108.8c2.85,-6.33 2.91,-13.91 -0.73,-20.75c-4.98,-9.36 -15.93,-14.24 -26.21,-11.7c-7.34,1.81 -12.85,6.72 -15.72,12.86c-4.4,9.42 -11.23,17.6 -19.98,23.21c-7.06,4.53 -12.73,11.42 -15.69,20.17c-5.98,17.69 1.9,37.45 18.39,46.22c19.93,10.6 44.32,1.98 53.36,-18.29c3.05,-6.84 3.95,-14.1 2.98,-21.01C250.87,129.11 251.62,118.38 255.94,108.8z"/>
+    <path android:fillColor="#81C995"
+          android:pathData="M252.33,139.52c-1.46,-10.41 -0.71,-21.14 3.61,-30.72c2.85,-6.33 2.91,-13.91 -0.73,-20.75c-0.9,-1.69 -1.99,-3.22 -3.24,-4.6c1.62,5.53 1.11,11.25 -1.12,16.2c-4.32,9.59 -5.07,20.31 -3.61,30.72c0.97,6.91 0.08,14.17 -2.98,21.01c-9.04,20.26 -33.43,28.89 -53.36,18.29c-5.07,-2.7 -9.32,-6.43 -12.61,-10.83c3.26,8.34 9.38,15.56 17.7,19.98c19.93,10.6 44.32,1.98 53.36,-18.29C252.41,153.69 253.31,146.43 252.33,139.52z"/>
+</vector>
diff --git a/res/layout/face_remove_button.xml b/res/layout/face_remove_button.xml
new file mode 100644
index 0000000..7fd28b6
--- /dev/null
+++ b/res/layout/face_remove_button.xml
@@ -0,0 +1,30 @@
+<?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">
+
+    <Button
+        android:id="@+id/security_settings_face_settings_remove_button"
+        android:layout_marginStart="@dimen/screen_margin_sides"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="start"
+        android:text="@string/security_settings_face_settings_remove_face_data"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 06f4123..df98e0e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -889,6 +889,17 @@
     <string name="security_settings_face_enroll_finish_title">All set. Looking good.</string>
     <!-- Button text to exit face wizard after everything is done [CHAR LIMIT=15] -->
     <string name="security_settings_face_enroll_done">Done</string>
+    <!-- Title for a category shown for the face settings page. [CHAR LIMIT=20] -->
+    <string name="security_settings_face_settings_use_face_category">Use your face to</string>
+    <!-- Text shown on a toggle which allows or disallows the device to use face for unlocking the device. [CHAR LIMIT=20] -->
+    <string name="security_settings_face_settings_use_face_unlock_phone">Unlock your device</string>
+    <!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] -->
+    <string name="security_settings_face_settings_remove_face_data">Remove face data</string>
+    <!-- Text shown in face settings allowing the user to update/improve the enrolled face. This brings the user back to the enrollment flow. [CHAR LIMIT=30] -->
+    <string name="security_settings_face_settings_improve_face">Improve your face data</string>
+    <!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
+    <string name="security_settings_face_settings_footer">Your face can be used to unlock your device and access apps.
+        <annotation id="url">Learn more</annotation></string>
 
     <!-- Fingerprint enrollment and settings --><skip />
     <!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
@@ -4574,6 +4585,8 @@
     <!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
     <string name="accessibility_caption_master_switch_title">Use captions</string>
 
+    <!-- Button text for the accessibility dialog continue to the next screen for hearing aid. [CHAR LIMIT=32] -->
+    <string name="accessibility_hearingaid_instruction_continue_button">Continue</string>
     <!-- Title for the accessibility preference for hearing aid. [CHAR LIMIT=35] -->
     <string name="accessibility_hearingaid_title">Hearing aids</string>
     <!-- Summary for the accessibility preference for hearing aid when not connected. [CHAR LIMIT=50] -->
@@ -6639,6 +6652,8 @@
     <string name="help_url_nfc_payment" translatable="false"></string>
     <!-- Help URL, Remote display [DO NOT TRANSLATE] -->
     <string name="help_url_remote_display" translatable="false"></string>
+    <!-- Help URL, Face [DO NOT TRANSLATE] -->
+    <string name="help_url_face" translatable="false"></string>
     <!-- Help URL, Fingerprint [DO NOT TRANSLATE] -->
     <string name="help_url_fingerprint" translatable="false"></string>
     <!-- Help URL, Gesture settings -->
@@ -6967,6 +6982,7 @@
     <string name="keywords_payment_settings">pay, tap, payments</string>
     <string name="keywords_backup">backup, back up</string>
     <string name="keywords_assist_gesture_launch">gesture</string>
+    <string name="keywords_face_unlock">face, unlock</string>
     <string name="keywords_imei_info">imei, meid, min, prl version, imei sv</string>
     <string name="keywords_sim_status">network, mobile network state, service state, signal strength, mobile network type, roaming, iccid</string>
     <string name="keywords_model_and_hardware">serial number, hardware version</string>
@@ -9870,8 +9886,8 @@
     <!-- UI debug setting: logging level for Android Autofill [CHAR LIMIT=25] -->
     <string name="autofill_logging_level_title">Logging level</string>
 
-    <!-- Title of developer options to set the maximum number of partitions per session [CHAR LIMIT=60]-->
-    <string name="autofill_max_partitions">Max partitions</string>
+    <!-- Title of developer options to set the maximum number of requests per session [CHAR LIMIT=60]-->
+    <string name="autofill_max_partitions">Max requests per session</string>
 
     <!-- Title of developer options to set the maximum number of visible datasets in the autofill UX [CHAR LIMIT=60]-->
     <string name="autofill_max_visible_datasets">Max visible datasets</string>
diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml
index fc26fd3..9cd3865 100644
--- a/res/xml/accessibility_daltonizer_settings.xml
+++ b/res/xml/accessibility_daltonizer_settings.xml
@@ -24,6 +24,7 @@
         android:entryValues="@array/daltonizer_type_values"
         android:key="type"
         android:summary="%s"
-        android:title="@string/daltonizer_type" />
+        android:title="@string/daltonizer_type"
+        android:icon="@drawable/ic_accessibility_illustration_colorblind" />
 
 </PreferenceScreen>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 9dda18f..e36f578 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -114,6 +114,11 @@
                 android:persistent="false"/>
 
         <Preference
+            android:key="hearing_aid_preference"
+            android:summary="@string/accessibility_hearingaid_not_connected_summary"
+            android:title="@string/accessibility_hearingaid_title"/>
+
+        <Preference
                 android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
                 android:key="captioning_preference_screen"
                 android:title="@string/accessibility_captioning_title" />
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
new file mode 100644
index 0000000..3dfcfd7
--- /dev/null
+++ b/res/xml/security_settings_face.xml
@@ -0,0 +1,56 @@
+<!--
+  ~ 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"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:key="security_settings_face_settings_page"
+    android:title="@string/security_settings_face_preference_title">
+
+    <com.android.settings.widget.VideoPreference
+        android:key="security_settings_face_video"
+        app:animation="@raw/gesture_fingerprint_swipe"
+        app:preview="@drawable/face_enroll_introduction" />
+
+    <PreferenceCategory
+        android:key="security_settings_face_unlock_category"
+        android:title="@string/security_settings_face_settings_use_face_category">
+        <SwitchPreference
+            android:key="security_settings_face_unlock"
+            android:title="@string/security_settings_face_settings_use_face_unlock_phone"
+            app:keywords="@string/keywords_face_unlock"
+            app:controller="com.android.settings.biometrics.face.FaceSettingsUnlockPreferenceController"/>
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:key="security_settings_face_manage_category">
+        <Preference
+            android:key="security_settings_face_improve"
+            android:title="@string/security_settings_face_settings_improve_face">
+        </Preference>
+
+        <com.android.settings.applications.LayoutPreference
+            android:key="security_settings_face_delete_faces_container"
+            android:selectable="false"
+            android:layout="@layout/face_remove_button" />
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:key="security_settings_face_footer_container">
+        <com.android.settingslib.widget.FooterPreference />
+    </PreferenceCategory>
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 99d7d47..4f011c1 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -31,6 +31,7 @@
     public static class AssistGestureSettingsActivity extends SettingsActivity { /* empty */}
     public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
     public static class CreateShortcutActivity extends SettingsActivity { /* empty */ }
+    public static class FaceSettingsActivity extends SettingsActivity { /* empty */ }
     public static class SimSettingsActivity extends SettingsActivity { /* empty */ }
     public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
     public static class WifiTetherSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index cacd04e..f95a303 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -290,8 +290,10 @@
             launchSettingFragment(initialFragmentName, isSubSettings, intent);
         }
 
+        final boolean deviceProvisioned = Utils.isDeviceProvisioned(this);
         if (mIsShowingDashboard) {
-            findViewById(R.id.search_bar).setVisibility(View.VISIBLE);
+            findViewById(R.id.search_bar).setVisibility(
+                    deviceProvisioned ? View.VISIBLE : View.INVISIBLE);
             findViewById(R.id.action_bar).setVisibility(View.GONE);
             final Toolbar toolbar = findViewById(R.id.search_action_bar);
             FeatureFactory.getFactory(this).getSearchFeatureProvider()
@@ -310,7 +312,6 @@
 
         ActionBar actionBar = getActionBar();
         if (actionBar != null) {
-            boolean deviceProvisioned = Utils.isDeviceProvisioned(this);
             actionBar.setDisplayHomeAsUpEnabled(deviceProvisioned);
             actionBar.setHomeButtonEnabled(deviceProvisioned);
             actionBar.setDisplayShowTitleEnabled(!mIsShowingDashboard);
diff --git a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
new file mode 100644
index 0000000..b946e3e
--- /dev/null
+++ b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothHearingAid;
+import android.bluetooth.BluetoothProfile;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.fragment.app.FragmentManager;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+
+/**
+ * Controller that shows and updates the bluetooth device name
+ */
+public class AccessibilityHearingAidPreferenceController extends BasePreferenceController
+        implements LifecycleObserver, OnResume, OnPause {
+    private static final String TAG = "AccessibilityHearingAidPreferenceController";
+    private Preference mHearingAidPreference;
+
+    private final BroadcastReceiver mHearingAidChangedReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) {
+                final int state = intent.getIntExtra(BluetoothHearingAid.EXTRA_STATE,
+                        BluetoothHearingAid.STATE_DISCONNECTED);
+                if (state == BluetoothHearingAid.STATE_CONNECTED) {
+                    updateState(mHearingAidPreference);
+                } else {
+                    mHearingAidPreference
+                            .setSummary(R.string.accessibility_hearingaid_not_connected_summary);
+                }
+            } else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) {
+                final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
+                        BluetoothAdapter.ERROR);
+                if (state != BluetoothAdapter.STATE_ON) {
+                    mHearingAidPreference
+                            .setSummary(R.string.accessibility_hearingaid_not_connected_summary);
+                }
+            }
+        }
+    };
+
+    private final LocalBluetoothManager mLocalBluetoothManager;
+    //cache value of supporting hearing aid or not
+    private boolean mHearingAidProfileSupported;
+    private FragmentManager mFragmentManager;
+
+    public AccessibilityHearingAidPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+        mLocalBluetoothManager = getLocalBluetoothManager();
+        mHearingAidProfileSupported = isHearingAidProfileSupported();
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mHearingAidPreference = screen.findPreference(getPreferenceKey());
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return mHearingAidProfileSupported ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+    }
+
+    @Override
+    public void onResume() {
+        if (mHearingAidProfileSupported) {
+            IntentFilter filter = new IntentFilter();
+            filter.addAction(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
+            filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
+            mContext.registerReceiver(mHearingAidChangedReceiver, filter);
+        }
+    }
+
+    @Override
+    public void onPause() {
+        if (mHearingAidProfileSupported) {
+            mContext.unregisterReceiver(mHearingAidChangedReceiver);
+        }
+    }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (TextUtils.equals(preference.getKey(), getPreferenceKey())){
+            final CachedBluetoothDevice device = getConnectedHearingAidDevice();
+            if (device == null) {
+                launchHearingAidInstructionDialog();
+            } else {
+                launchBluetoothDeviceDetailSetting(device);
+            }
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        final CachedBluetoothDevice device = getConnectedHearingAidDevice();
+        if (device == null) {
+            return mContext.getText(R.string.accessibility_hearingaid_not_connected_summary);
+        }
+        return device.getName();
+    }
+
+    public void setFragmentManager(FragmentManager fragmentManager) {
+        mFragmentManager = fragmentManager;
+    }
+
+    private CachedBluetoothDevice getConnectedHearingAidDevice() {
+        if (!mHearingAidProfileSupported) {
+            return null;
+        }
+        final LocalBluetoothAdapter localAdapter = mLocalBluetoothManager.getBluetoothAdapter();
+        if (!localAdapter.isEnabled()) {
+            return null;
+        }
+        final List<BluetoothDevice> deviceList = mLocalBluetoothManager.getProfileManager()
+                .getHearingAidProfile().getConnectedDevices();
+        final Iterator it = deviceList.iterator();
+        if (it.hasNext()) {
+            BluetoothDevice obj = (BluetoothDevice)it.next();
+            return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
+        }
+        return null;
+    }
+
+    private boolean isHearingAidProfileSupported() {
+        final LocalBluetoothAdapter localAdapter = mLocalBluetoothManager.getBluetoothAdapter();
+        final List<Integer> supportedList = localAdapter.getSupportedProfiles();
+        if (supportedList.contains(BluetoothProfile.HEARING_AID)) {
+            return true;
+        }
+        return false;
+    }
+
+    private LocalBluetoothManager getLocalBluetoothManager() {
+        final FutureTask<LocalBluetoothManager> localBtManagerFutureTask = new FutureTask<>(
+                // Avoid StrictMode ThreadPolicy violation
+                () -> com.android.settings.bluetooth.Utils.getLocalBtManager(mContext));
+        try {
+            localBtManagerFutureTask.run();
+            return localBtManagerFutureTask.get();
+        } catch (InterruptedException | ExecutionException e) {
+            Log.w(TAG, "Error getting LocalBluetoothManager.", e);
+            return null;
+        }
+    }
+
+    @VisibleForTesting(otherwise = VisibleForTesting.NONE)
+    void setPreference(Preference preference) {
+        mHearingAidPreference = preference;
+    }
+
+    @VisibleForTesting
+    void launchBluetoothDeviceDetailSetting(final CachedBluetoothDevice device) {
+        if (device == null) {
+            return;
+        }
+        final Bundle args = new Bundle();
+        args.putString(BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS,
+                device.getDevice().getAddress());
+
+        new SubSettingLauncher(mContext)
+                .setDestination(BluetoothDeviceDetailsFragment.class.getName())
+                .setArguments(args)
+                .setTitleRes(R.string.device_details_title)
+                .setSourceMetricsCategory(MetricsProto.MetricsEvent.ACCESSIBILITY)
+                .launch();
+    }
+
+    @VisibleForTesting
+    void launchHearingAidInstructionDialog() {
+        HearingAidDialogFragment fragment = HearingAidDialogFragment.newInstance();
+        fragment.show(mFragmentManager, HearingAidDialogFragment.class.toString());
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 22cff3e..d1b1ad4 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -110,6 +110,8 @@
             "select_long_press_timeout_preference";
     private static final String ACCESSIBILITY_SHORTCUT_PREFERENCE =
             "accessibility_shortcut_preference";
+    private static final String HEARING_AID_PREFERENCE =
+            "hearing_aid_preference";
     private static final String CAPTIONING_PREFERENCE_SCREEN =
             "captioning_preference_screen";
     private static final String DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN =
@@ -221,9 +223,11 @@
     private Preference mAutoclickPreferenceScreen;
     private Preference mAccessibilityShortcutPreferenceScreen;
     private Preference mDisplayDaltonizerPreferenceScreen;
+    private Preference mHearingAidPreference;
     private Preference mVibrationPreferenceScreen;
     private SwitchPreference mToggleInversionPreference;
     private ColorInversionPreferenceController mInversionPreferenceController;
+    private AccessibilityHearingAidPreferenceController mHearingAidPreferenceController;
 
     private int mLongPressTimeoutDefault;
 
@@ -276,6 +280,15 @@
     }
 
     @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        mHearingAidPreferenceController = new AccessibilityHearingAidPreferenceController
+                (context, HEARING_AID_PREFERENCE);
+        mHearingAidPreferenceController.setFragmentManager(getFragmentManager());
+        getLifecycle().addObserver(mHearingAidPreferenceController);
+    }
+
+    @Override
     public void onResume() {
         super.onResume();
         updateAllPreferences();
@@ -335,6 +348,8 @@
         } else if (mToggleMasterMonoPreference == preference) {
             handleToggleMasterMonoPreferenceClick();
             return true;
+        } else if (mHearingAidPreferenceController.handlePreferenceTreeClick(preference)) {
+            return true;
         }
         return super.onPreferenceTreeClick(preference);
     }
@@ -452,6 +467,10 @@
             }
         }
 
+        // Hearing Aid.
+        mHearingAidPreference = findPreference(HEARING_AID_PREFERENCE);
+        mHearingAidPreferenceController.displayPreference(getPreferenceScreen());
+
         // Captioning.
         mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
 
@@ -686,6 +705,8 @@
 
         updateVibrationSummary(mVibrationPreferenceScreen);
 
+        mHearingAidPreferenceController.updateState(mHearingAidPreference);
+
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
                 mCaptioningPreferenceScreen);
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
diff --git a/src/com/android/settings/accessibility/HearingAidDialogFragment.java b/src/com/android/settings/accessibility/HearingAidDialogFragment.java
new file mode 100644
index 0000000..0380ed3
--- /dev/null
+++ b/src/com/android/settings/accessibility/HearingAidDialogFragment.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.bluetooth.BluetoothPairingDetail;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+
+public class HearingAidDialogFragment extends InstrumentedDialogFragment {
+    public static HearingAidDialogFragment newInstance() {
+        HearingAidDialogFragment frag = new HearingAidDialogFragment();
+        return frag;
+    }
+
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+        return new AlertDialog.Builder(getActivity())
+                .setTitle(R.string.accessibility_hearingaid_pair_instructions_first_message)
+                .setMessage(R.string.accessibility_hearingaid_pair_instructions_second_message)
+                .setPositiveButton(R.string.accessibility_hearingaid_instruction_continue_button,
+                        new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) {
+                                launchBluetoothAddDeviceSetting();
+                            }
+                        })
+                .setNegativeButton(android.R.string.cancel,
+                        new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) { }
+                        })
+                .create();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.DIALOG_ACCESSIBILITY_HEARINGAID;
+    }
+
+    private void launchBluetoothAddDeviceSetting() {
+        new SubSettingLauncher(getActivity())
+                .setDestination(BluetoothPairingDetail.class.getName())
+                .setSourceMetricsCategory(MetricsProto.MetricsEvent.ACCESSIBILITY)
+                .launch();
+    }
+}
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index 298891e..130f20f 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.biometrics;
 
+import static android.app.Activity.RESULT_FIRST_USER;
+
 import android.annotation.Nullable;
 import android.content.Intent;
 import android.content.res.Resources;
@@ -39,11 +41,33 @@
  */
 public abstract class BiometricEnrollBase extends InstrumentedActivity
         implements View.OnClickListener {
-    public static final int RESULT_FINISHED = BiometricSettings.RESULT_FINISHED;
-    public static final int RESULT_SKIP = BiometricSettings.RESULT_SKIP;
-    public static final int RESULT_TIMEOUT = BiometricSettings.RESULT_TIMEOUT;
     public static final String EXTRA_KEY_LAUNCHED_CONFIRM = "launched_confirm_lock";
 
+
+    /**
+     * Used by the choose fingerprint wizard to indicate the wizard is
+     * finished, and each activity in the wizard should finish.
+     * <p>
+     * Previously, each activity in the wizard would finish itself after
+     * starting the next activity. However, this leads to broken 'Back'
+     * behavior. So, now an activity does not finish itself until it gets this
+     * result.
+     */
+    public static final int RESULT_FINISHED = RESULT_FIRST_USER;
+
+    /**
+     * Used by the enrolling screen during setup wizard to skip over setting up fingerprint, which
+     * will be useful if the user accidentally entered this flow.
+     */
+    public static final int RESULT_SKIP = RESULT_FIRST_USER + 1;
+
+    /**
+     * Like {@link #RESULT_FINISHED} except this one indicates enrollment failed because the
+     * device was left idle. This is used to clear the credential token to require the user to
+     * re-enter their pin/pattern/password before continuing.
+     */
+    public static final int RESULT_TIMEOUT = RESULT_FIRST_USER + 2;
+
     public static final int CONFIRM_REQUEST = 1;
     public static final int ENROLLING = 2;
 
diff --git a/src/com/android/settings/biometrics/BiometricErrorDialog.java b/src/com/android/settings/biometrics/BiometricErrorDialog.java
index 5c4e891..6e5a221 100644
--- a/src/com/android/settings/biometrics/BiometricErrorDialog.java
+++ b/src/com/android/settings/biometrics/BiometricErrorDialog.java
@@ -16,8 +16,8 @@
 
 package com.android.settings.biometrics;
 
-import static com.android.settings.biometrics.BiometricSettings.RESULT_FINISHED;
-import static com.android.settings.biometrics.BiometricSettings.RESULT_TIMEOUT;
+import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_FINISHED;
+import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_TIMEOUT;
 
 import android.app.Activity;
 import android.app.Dialog;
diff --git a/src/com/android/settings/biometrics/BiometricSettings.java b/src/com/android/settings/biometrics/BiometricSettings.java
deleted file mode 100644
index ccb4c5e..0000000
--- a/src/com/android/settings/biometrics/BiometricSettings.java
+++ /dev/null
@@ -1,48 +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.biometrics;
-
-import com.android.settings.SubSettings;
-
-/**
- * Abstract base class for biometric settings, such as Fingerprint, Face, Iris
- */
-public abstract class BiometricSettings extends SubSettings {
-    /**
-     * Used by the choose fingerprint wizard to indicate the wizard is
-     * finished, and each activity in the wizard should finish.
-     * <p>
-     * Previously, each activity in the wizard would finish itself after
-     * starting the next activity. However, this leads to broken 'Back'
-     * behavior. So, now an activity does not finish itself until it gets this
-     * result.
-     */
-    protected static final int RESULT_FINISHED = RESULT_FIRST_USER;
-
-    /**
-     * Used by the enrolling screen during setup wizard to skip over setting up fingerprint, which
-     * will be useful if the user accidentally entered this flow.
-     */
-    protected static final int RESULT_SKIP = RESULT_FIRST_USER + 1;
-
-    /**
-     * Like {@link #RESULT_FINISHED} except this one indicates enrollment failed because the
-     * device was left idle. This is used to clear the credential token to require the user to
-     * re-enter their pin/pattern/password before continuing.
-     */
-    protected static final int RESULT_TIMEOUT = RESULT_FIRST_USER + 2;
-}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
new file mode 100644
index 0000000..4944c7f
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -0,0 +1,134 @@
+/*
+ * 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.face;
+
+import static com.android.settings.biometrics.BiometricEnrollBase.CONFIRM_REQUEST;
+
+import android.content.Context;
+import android.hardware.face.FaceManager;
+import android.os.Bundle;
+import android.provider.SearchIndexableResource;
+import android.util.Log;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Settings screen for face authentication.
+ */
+@SearchIndexable
+public class FaceSettings extends DashboardFragment {
+
+    private static final String TAG = "FaceSettings";
+    private static final String KEY_LAUNCHED_CONFIRM = "key_launched_confirm";
+
+    private boolean mLaunchedConfirm;
+
+    public static boolean isAvailable(Context context) {
+        FaceManager manager = Utils.getFaceManagerOrNull(context);
+        return manager != null && manager.isHardwareDetected();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.FACE;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.security_settings_face;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putBoolean(KEY_LAUNCHED_CONFIRM, mLaunchedConfirm);
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (savedInstanceState != null) {
+            mLaunchedConfirm = savedInstanceState.getBoolean(KEY_LAUNCHED_CONFIRM, false);
+        }
+
+        if (!mLaunchedConfirm) {
+            ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);
+            if (!helper.launchConfirmationActivity(CONFIRM_REQUEST,
+                    getString(R.string.security_settings_face_preference_title))) {
+                Log.e(TAG, "Password not set");
+                finish();
+            }
+        }
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, getSettingsLifecycle());
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+            Lifecycle lifecycle) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(new FaceSettingsVideoPreferenceController(context));
+        controllers.add(new FaceSettingsImprovePreferenceController(context));
+        controllers.add(new FaceSettingsUnlockPreferenceController(context));
+        controllers.add(new FaceSettingsRemoveButtonPreferenceController(context));
+        controllers.add(new FaceSettingsFooterPreferenceController(context));
+        return controllers;
+    }
+
+    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(
+                        Context context, boolean enabled) {
+                    final SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.security_settings_face;
+                    return Arrays.asList(sir);
+                }
+
+                @Override
+                public List<AbstractPreferenceController> createPreferenceControllers(
+                        Context context) {
+                    return buildPreferenceControllers(context, null /* lifecycle */);
+                }
+
+                @Override
+                protected boolean isPageSearchEnabled(Context context) {
+                    return isAvailable(context);
+                }
+            };
+
+}
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsFooterPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsFooterPreferenceController.java
new file mode 100644
index 0000000..855b169
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsFooterPreferenceController.java
@@ -0,0 +1,61 @@
+/*
+ * 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.face;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.utils.AnnotationSpan;
+import com.android.settingslib.HelpUtils;
+import com.android.settingslib.widget.FooterPreference;
+
+import androidx.preference.Preference;
+
+/**
+ * Footer for face settings showing the help text and help link.
+ */
+public class FaceSettingsFooterPreferenceController extends BasePreferenceController {
+
+    private static final String ANNOTATION_URL = "url";
+
+    public FaceSettingsFooterPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    public FaceSettingsFooterPreferenceController(Context context) {
+        this(context, FooterPreference.KEY_FOOTER);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+
+        final Intent helpIntent = HelpUtils.getHelpIntent(
+                mContext, mContext.getString(R.string.help_url_face), getClass().getName());
+        final AnnotationSpan.LinkInfo linkInfo =
+                new AnnotationSpan.LinkInfo(mContext, ANNOTATION_URL, helpIntent);
+        preference.setTitle(AnnotationSpan.linkify(
+                mContext.getText(R.string.security_settings_face_settings_footer), linkInfo));
+    }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsImprovePreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsImprovePreferenceController.java
new file mode 100644
index 0000000..94b14b5
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsImprovePreferenceController.java
@@ -0,0 +1,54 @@
+/*
+ * 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.face;
+
+import android.content.Context;
+
+import com.android.settings.core.BasePreferenceController;
+
+import androidx.preference.Preference;
+
+/**
+ * Preference controller which allows the user to update their enrolled face.
+ */
+public class FaceSettingsImprovePreferenceController extends BasePreferenceController {
+
+    private static final String KEY = "security_settings_face_improve";
+
+    public FaceSettingsImprovePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    public FaceSettingsImprovePreferenceController(Context context) {
+        this(context, KEY);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY;
+    }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        return false;
+    }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
new file mode 100644
index 0000000..b1dcce0
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
@@ -0,0 +1,72 @@
+/*
+ * 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.face;
+
+import android.content.Context;
+import android.view.View;
+import android.widget.Button;
+
+import com.android.settings.R;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.core.BasePreferenceController;
+
+import androidx.preference.Preference;
+
+/**
+ * Controller for the remove button.
+ */
+public class FaceSettingsRemoveButtonPreferenceController extends BasePreferenceController
+        implements View.OnClickListener {
+
+    private static final String KEY = "security_settings_face_delete_faces_container";
+
+    private Button mButton;
+
+    public FaceSettingsRemoveButtonPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    public FaceSettingsRemoveButtonPreferenceController(Context context) {
+        this(context, KEY);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+
+        mButton = ((LayoutPreference) preference)
+                .findViewById(R.id.security_settings_face_settings_remove_button);
+        mButton.setOnClickListener(this);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY;
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v == mButton) {
+
+        }
+    }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsUnlockPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsUnlockPreferenceController.java
new file mode 100644
index 0000000..b483dc6
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsUnlockPreferenceController.java
@@ -0,0 +1,92 @@
+/*
+ * 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.face;
+
+import static android.provider.Settings.Secure.FACE_UNLOCK_KEYGUARD_ENABLED;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+import androidx.preference.Preference;
+
+/**
+ * Preference controller for Face settings page controlling the ability to unlock the phone
+ * with face.
+ */
+public class FaceSettingsUnlockPreferenceController extends TogglePreferenceController {
+
+    private static final String KEY = "security_settings_face_unlock";
+
+    private static final int ON = 1;
+    private static final int OFF = 0;
+    private static final int DEFAULT = ON;  // face unlock is enabled on keyguard by default
+
+    public FaceSettingsUnlockPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    public FaceSettingsUnlockPreferenceController(Context context) {
+        this(context, KEY);
+    }
+
+    @Override
+    public boolean isChecked() {
+        if (!FaceSettings.isAvailable(mContext)) {
+            return false;
+        } else if (adminDisabled()) {
+            return false;
+        }
+        return Settings.Secure.getInt(
+                mContext.getContentResolver(), FACE_UNLOCK_KEYGUARD_ENABLED, DEFAULT) == ON;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(), FACE_UNLOCK_KEYGUARD_ENABLED,
+                isChecked ? ON : OFF);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        if (!FaceSettings.isAvailable(mContext)) {
+            preference.setEnabled(false);
+        } else if (adminDisabled()) {
+            preference.setEnabled(false);
+        } else {
+            preference.setEnabled(true);
+        }
+    }
+
+    private boolean adminDisabled() {
+        DevicePolicyManager dpm =
+                (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
+        return dpm != null &&
+                (dpm.getKeyguardDisabledFeatures(null, UserHandle.myUserId())
+                        & DevicePolicyManager.KEYGUARD_DISABLE_FACE)
+                        != 0;
+    }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
new file mode 100644
index 0000000..6fbb9c4
--- /dev/null
+++ b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
@@ -0,0 +1,40 @@
+/*
+ * 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.face;
+
+import android.content.Context;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class FaceSettingsVideoPreferenceController extends BasePreferenceController {
+
+    private static final String PREF_KEY_VIDEO = "security_settings_face_video";
+
+    public FaceSettingsVideoPreferenceController(Context context,
+            String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    public FaceSettingsVideoPreferenceController(Context context) {
+        this(context, PREF_KEY_VIDEO);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java b/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
index 96f22e0..9a14660 100644
--- a/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
@@ -20,6 +20,7 @@
 import android.hardware.face.FaceManager;
 
 import com.android.settings.R;
+import com.android.settings.Settings;
 import com.android.settings.Utils;
 import com.android.settings.biometrics.BiometricStatusPreferenceController;
 
@@ -62,7 +63,7 @@
 
     @Override
     protected String getSettingsClassName() {
-        return null;
+        return Settings.FaceSettingsActivity.class.getName();
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index d318fef..3309b78 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -40,8 +40,9 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.SubSettings;
 import com.android.settings.Utils;
-import com.android.settings.biometrics.BiometricSettings;
+import com.android.settings.biometrics.BiometricEnrollBase;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
 import com.android.settings.password.ChooseLockGeneric;
 import com.android.settings.password.ChooseLockSettingsHelper;
@@ -66,7 +67,7 @@
 /**
  * Settings screen for fingerprints
  */
-public class FingerprintSettings extends BiometricSettings {
+public class FingerprintSettings extends SubSettings {
 
     private static final String TAG = "FingerprintSettings";
 
@@ -75,6 +76,10 @@
     public static final String ANNOTATION_URL = "url";
     public static final String ANNOTATION_ADMIN_DETAILS = "admin_details";
 
+    private static final int RESULT_FINISHED = BiometricEnrollBase.RESULT_FINISHED;
+    private static final int RESULT_SKIP = BiometricEnrollBase.RESULT_SKIP;
+    private static final int RESULT_TIMEOUT = BiometricEnrollBase.RESULT_TIMEOUT;
+
     @Override
     public Intent getIntent() {
         Intent modIntent = new Intent(super.getIntent());
diff --git a/src/com/android/settings/bluetooth/AlwaysDiscoverable.java b/src/com/android/settings/bluetooth/AlwaysDiscoverable.java
index b89706d..7b94871 100644
--- a/src/com/android/settings/bluetooth/AlwaysDiscoverable.java
+++ b/src/com/android/settings/bluetooth/AlwaysDiscoverable.java
@@ -22,8 +22,6 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-
 import androidx.annotation.VisibleForTesting;
 
 /** Helper class, intended to be used by an Activity, to keep the local Bluetooth adapter in
@@ -35,15 +33,15 @@
     private static final String TAG = "AlwaysDiscoverable";
 
     private Context mContext;
-    private LocalBluetoothAdapter mLocalAdapter;
+    private BluetoothAdapter mBluetoothAdapter;
     private IntentFilter mIntentFilter;
 
     @VisibleForTesting
     boolean mStarted;
 
-    public AlwaysDiscoverable(Context context, LocalBluetoothAdapter localAdapter) {
+    public AlwaysDiscoverable(Context context) {
         mContext = context;
-        mLocalAdapter = localAdapter;
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
         mIntentFilter = new IntentFilter();
         mIntentFilter.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
     }
@@ -56,8 +54,9 @@
         }
         mContext.registerReceiver(this, mIntentFilter);
         mStarted = true;
-        if (mLocalAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
-            mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
+        if (mBluetoothAdapter.getScanMode()
+                != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
+            mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
         }
     }
 
@@ -67,7 +66,7 @@
         }
         mContext.unregisterReceiver(this);
         mStarted = false;
-        mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
+        mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
     }
 
     @Override
@@ -76,8 +75,9 @@
         if (action != BluetoothAdapter.ACTION_SCAN_MODE_CHANGED) {
             return;
         }
-        if (mLocalAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
-            mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
+        if (mBluetoothAdapter.getScanMode()
+                != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
+            mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
         }
     }
 }
diff --git a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
index 44ef4be..2b9c2cb 100644
--- a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
@@ -60,25 +60,6 @@
     }
 
     @Override
-    public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
-            int bluetoothProfile) {
-        if (DBG) {
-            Log.d(TAG, "onProfileConnectionStateChanged() device: " +
-                    cachedDevice.getName() + ", state: " + state + ", bluetoothProfile: "
-                    + bluetoothProfile);
-        }
-        if (state == BluetoothProfile.STATE_CONNECTED) {
-            if (isFilterMatched(cachedDevice)) {
-                addPreference(cachedDevice);
-            } else {
-                removePreference(cachedDevice);
-            }
-        } else if (state == BluetoothProfile.STATE_DISCONNECTED) {
-            removePreference(cachedDevice);
-        }
-    }
-
-    @Override
     public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
         final int audioMode = mAudioManager.getMode();
         final int currentAudioProfile;
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java b/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java
index 5b65335..b9154f5 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceController.java
@@ -27,8 +27,6 @@
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -46,8 +44,7 @@
 
     @VisibleForTesting
     Preference mPreference;
-    private LocalBluetoothManager mLocalManager;
-    protected LocalBluetoothAdapter mLocalAdapter;
+    protected BluetoothAdapter mBluetoothAdapter;
 
     /**
      * Constructor exclusively used for Slice.
@@ -55,19 +52,11 @@
     public BluetoothDeviceNamePreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
 
-        mLocalManager = Utils.getLocalBtManager(context);
-        if (mLocalManager == null) {
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (mBluetoothAdapter == null) {
             Log.e(TAG, "Bluetooth is not supported on this device");
             return;
         }
-        mLocalAdapter = mLocalManager.getBluetoothAdapter();
-    }
-
-    @VisibleForTesting
-    BluetoothDeviceNamePreferenceController(Context context, LocalBluetoothAdapter localAdapter,
-            String preferenceKey) {
-        super(context, preferenceKey);
-        mLocalAdapter = localAdapter;
     }
 
     @Override
@@ -91,7 +80,7 @@
 
     @Override
     public int getAvailabilityStatus() {
-        return mLocalAdapter != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+        return mBluetoothAdapter != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
     }
 
     @Override
@@ -138,7 +127,7 @@
     }
 
     protected String getDeviceName() {
-        return mLocalAdapter.getName();
+        return mBluetoothAdapter.getName();
     }
 
     /**
@@ -152,7 +141,8 @@
             final String action = intent.getAction();
 
             if (TextUtils.equals(action, BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED)) {
-                if (mPreference != null && mLocalAdapter != null && mLocalAdapter.isEnabled()) {
+                if (mPreference != null && mBluetoothAdapter != null
+                        && mBluetoothAdapter.isEnabled()) {
                     updatePreferenceState(mPreference);
                 }
             } else if (TextUtils.equals(action, BluetoothAdapter.ACTION_STATE_CHANGED)) {
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java b/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
index 0fb2f87..24fcf6a 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
@@ -16,12 +16,12 @@
 
 package com.android.settings.bluetooth;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.text.TextUtils;
 
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 import androidx.annotation.VisibleForTesting;
@@ -42,13 +42,6 @@
         mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
     }
 
-    @VisibleForTesting
-    BluetoothDeviceRenamePreferenceController(Context context, LocalBluetoothAdapter localAdapter,
-            String preferenceKey) {
-        super(context, localAdapter, preferenceKey);
-        mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
-    }
-
     /**
      * Set the {@link Fragment} that used to show {@link LocalDeviceNameDialogFragment}
      * in {@code handlePreferenceTreeClick}
@@ -61,7 +54,7 @@
     @Override
     protected void updatePreferenceState(final Preference preference) {
         preference.setSummary(getSummary());
-        preference.setVisible(mLocalAdapter != null && mLocalAdapter.isEnabled());
+        preference.setVisible(mBluetoothAdapter != null && mBluetoothAdapter.isEnabled());
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index 0c0c5ea..dece0cc 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -162,6 +162,11 @@
     @Override
     public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
             int bluetoothProfile) {
+        if (DBG) {
+            Log.d(TAG, "onProfileConnectionStateChanged() device: " + cachedDevice.getName()
+                    + ", state: " + state + ", bluetoothProfile: " + bluetoothProfile);
+        }
+        update(cachedDevice);
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
index 3db3005..aec6d2d 100755
--- a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
@@ -28,7 +28,6 @@
 
 import com.android.settings.R;
 import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 
 import androidx.preference.Preference;
 
@@ -64,7 +63,7 @@
     private final Handler mUiHandler;
     private final Preference mDiscoveryPreference;
 
-    private final LocalBluetoothAdapter mLocalAdapter;
+    private final BluetoothAdapter mBluetoothAdapter;
 
     private final SharedPreferences mSharedPreferences;
 
@@ -92,17 +91,16 @@
         }
     };
 
-    BluetoothDiscoverableEnabler(LocalBluetoothAdapter adapter,
-            Preference discoveryPreference) {
+    BluetoothDiscoverableEnabler(Preference discoveryPreference) {
         mUiHandler = new Handler();
-        mLocalAdapter = adapter;
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
         mDiscoveryPreference = discoveryPreference;
         mSharedPreferences = discoveryPreference.getSharedPreferences();
         discoveryPreference.setPersistent(false);
     }
 
     public void resume(Context context) {
-        if (mLocalAdapter == null) {
+        if (mBluetoothAdapter == null) {
             return;
         }
 
@@ -113,11 +111,11 @@
         IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
         mContext.registerReceiver(mReceiver, filter);
         mDiscoveryPreference.setOnPreferenceClickListener(this);
-        handleModeChanged(mLocalAdapter.getScanMode());
+        handleModeChanged(mBluetoothAdapter.getScanMode());
     }
 
     public void pause() {
-        if (mLocalAdapter == null) {
+        if (mBluetoothAdapter == null) {
             return;
         }
 
@@ -139,7 +137,8 @@
             long endTimestamp = System.currentTimeMillis() + timeout * 1000L;
             LocalBluetoothPreferences.persistDiscoverableEndTimestamp(mContext, endTimestamp);
 
-            mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, timeout);
+            mBluetoothAdapter
+                    .setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, timeout);
             updateCountdownSummary();
 
             Log.d(TAG, "setEnabled(): enabled = " + enable + "timeout = " + timeout);
@@ -151,7 +150,7 @@
             }
 
         } else {
-            mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
+            mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
             BluetoothDiscoverableTimeoutReceiver.cancelDiscoverableAlarm(mContext);
         }
     }
@@ -250,7 +249,7 @@
 
     void setNumberOfPairedDevices(int pairedDevices) {
         mNumberOfPairedDevices = pairedDevices;
-        handleModeChanged(mLocalAdapter.getScanMode());
+        handleModeChanged(mBluetoothAdapter.getScanMode());
     }
 
     void handleModeChanged(int mode) {
@@ -273,7 +272,7 @@
     }
 
     private void updateCountdownSummary() {
-        int mode = mLocalAdapter.getScanMode();
+        int mode = mBluetoothAdapter.getScanMode();
         if (mode != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
             return;
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index 98a4b9c..9c00a50 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -29,8 +29,6 @@
 import com.android.settings.widget.SwitchWidgetController;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 import com.android.settingslib.WirelessUtils;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 import androidx.annotation.VisibleForTesting;
@@ -45,7 +43,7 @@
     private final MetricsFeatureProvider mMetricsFeatureProvider;
     private Context mContext;
     private boolean mValidListener;
-    private final LocalBluetoothAdapter mLocalAdapter;
+    private final BluetoothAdapter mBluetoothAdapter;
     private final IntentFilter mIntentFilter;
     private final RestrictionUtils mRestrictionUtils;
     private SwitchWidgetController.OnSwitchChangeListener mCallback;
@@ -65,15 +63,14 @@
     };
 
     public BluetoothEnabler(Context context, SwitchWidgetController switchController,
-            MetricsFeatureProvider metricsFeatureProvider, LocalBluetoothManager manager,
-            int metricsEvent) {
-        this(context, switchController, metricsFeatureProvider, manager, metricsEvent,
+            MetricsFeatureProvider metricsFeatureProvider, int metricsEvent) {
+        this(context, switchController, metricsFeatureProvider, metricsEvent,
                 new RestrictionUtils());
     }
 
     public BluetoothEnabler(Context context, SwitchWidgetController switchController,
-            MetricsFeatureProvider metricsFeatureProvider, LocalBluetoothManager manager,
-            int metricsEvent, RestrictionUtils restrictionUtils) {
+            MetricsFeatureProvider metricsFeatureProvider, int metricsEvent,
+            RestrictionUtils restrictionUtils) {
         mContext = context;
         mMetricsFeatureProvider = metricsFeatureProvider;
         mSwitchController = switchController;
@@ -81,12 +78,10 @@
         mValidListener = false;
         mMetricsEvent = metricsEvent;
 
-        if (manager == null) {
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (mBluetoothAdapter == null) {
             // Bluetooth is not supported
-            mLocalAdapter = null;
             mSwitchController.setEnabled(false);
-        } else {
-            mLocalAdapter = manager.getBluetoothAdapter();
         }
         mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
         mRestrictionUtils = restrictionUtils;
@@ -107,14 +102,14 @@
 
         final boolean restricted = maybeEnforceRestrictions();
 
-        if (mLocalAdapter == null) {
+        if (mBluetoothAdapter == null) {
             mSwitchController.setEnabled(false);
             return;
         }
 
         // Bluetooth state is not sticky, so set it manually
         if (!restricted) {
-            handleStateChanged(mLocalAdapter.getBluetoothState());
+            handleStateChanged(mBluetoothAdapter.getState());
         }
 
         mSwitchController.startListening();
@@ -123,7 +118,7 @@
     }
 
     public void pause() {
-        if (mLocalAdapter == null) {
+        if (mBluetoothAdapter == null) {
             return;
         }
         if (mValidListener) {
@@ -188,8 +183,8 @@
 
         mMetricsFeatureProvider.action(mContext, mMetricsEvent, isChecked);
 
-        if (mLocalAdapter != null) {
-            boolean status = mLocalAdapter.setBluetoothEnabled(isChecked);
+        if (mBluetoothAdapter != null) {
+            boolean status = setBluetoothEnabled(isChecked);
             // If we cannot toggle it ON then reset the UI assets:
             // a) The switch should be OFF but it should still be togglable (enabled = True)
             // b) The switch bar should have OFF text.
@@ -249,4 +244,8 @@
             mCallback.onSwitchToggled(isChecked);
         }
     }
+
+    private boolean setBluetoothEnabled(boolean isEnabled) {
+        return isEnabled ? mBluetoothAdapter.enable() : mBluetoothAdapter.disable();
+    }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
index af2711c..905327d 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
@@ -63,7 +63,7 @@
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         mInitialScanStarted = false;
-        mAlwaysDiscoverable = new AlwaysDiscoverable(getContext(), mLocalAdapter);
+        mAlwaysDiscoverable = new AlwaysDiscoverable(getContext());
     }
 
     @Override
@@ -74,7 +74,7 @@
             return;
         }
         updateBluetooth();
-        mAvailableDevicesCategory.setProgress(mLocalAdapter.isDiscovering());
+        mAvailableDevicesCategory.setProgress(mBluetoothAdapter.isDiscovering());
     }
 
     @Override
@@ -85,11 +85,11 @@
 
     @VisibleForTesting
     void updateBluetooth() {
-        if (mLocalAdapter.isEnabled()) {
-            updateContent(mLocalAdapter.getBluetoothState());
+        if (mBluetoothAdapter.isEnabled()) {
+            updateContent(mBluetoothAdapter.getState());
         } else {
             // Turn on bluetooth if it is disabled
-            mLocalAdapter.enable();
+            mBluetoothAdapter.enable();
         }
     }
 
@@ -148,7 +148,7 @@
         switch (bluetoothState) {
             case BluetoothAdapter.STATE_ON:
                 mDevicePreferenceMap.clear();
-                mLocalAdapter.setBluetoothEnabled(true);
+                mBluetoothAdapter.enable();
 
                 addDeviceCategory(mAvailableDevicesCategory,
                         R.string.bluetooth_preference_found_media_devices,
diff --git a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
index 7d5ae2b..7a56994 100644
--- a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
+++ b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
@@ -33,8 +33,6 @@
 import com.android.settings.connecteddevice.BluetoothDashboardFragment;
 import com.android.settings.slices.SliceBroadcastReceiver;
 import com.android.settings.slices.SliceBuilderUtils;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
@@ -119,10 +117,13 @@
      */
     public static void handleUriChange(Context context, Intent intent) {
         final boolean newBluetoothState = intent.getBooleanExtra(EXTRA_TOGGLE_STATE, false);
-        final LocalBluetoothAdapter adapter = LocalBluetoothManager.getInstance(context,
-                null /* callback */).getBluetoothAdapter();
+        final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
 
-        adapter.setBluetoothEnabled(newBluetoothState);
+        if (newBluetoothState) {
+            adapter.enable();
+        } else {
+            adapter.disable();
+        }
         // Do not notifyChange on Uri. The service takes longer to update the current value than it
         // does for the Slice to check the current value again. Let {@link SliceBroadcastRelay}
         // handle it.
diff --git a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
index 08aee5f..03fffa4 100644
--- a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
@@ -25,7 +25,6 @@
 import com.android.settings.widget.SummaryUpdater;
 import com.android.settingslib.bluetooth.BluetoothCallback;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import java.util.Set;
@@ -39,15 +38,14 @@
 public final class BluetoothSummaryUpdater extends SummaryUpdater implements BluetoothCallback {
     private static final String TAG = "BluetoothSummaryUpdater";
 
+    private final BluetoothAdapter mBluetoothAdapter;
     private final LocalBluetoothManager mBluetoothManager;
-    private final LocalBluetoothAdapter mBluetoothAdapter;
 
     public BluetoothSummaryUpdater(Context context, OnSummaryChangeListener listener,
             LocalBluetoothManager bluetoothManager) {
         super(context, listener);
         mBluetoothManager = bluetoothManager;
-        mBluetoothAdapter = mBluetoothManager != null
-                ? mBluetoothManager.getBluetoothAdapter() : null;
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceController.java b/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceController.java
index c6658e1..d828302 100644
--- a/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceController.java
+++ b/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceController.java
@@ -26,8 +26,6 @@
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.utils.AnnotationSpan;
 import com.android.settings.widget.SwitchWidgetController;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -43,10 +41,6 @@
         implements LifecycleObserver, OnStart, OnStop,
         SwitchWidgetController.OnSwitchChangeListener, View.OnClickListener {
 
-    @VisibleForTesting
-    LocalBluetoothAdapter mBluetoothAdapter;
-
-    private LocalBluetoothManager mBluetoothManager;
     private BluetoothEnabler mBluetoothEnabler;
     private RestrictionUtils mRestrictionUtils;
     private SwitchWidgetController mSwitch;
@@ -56,15 +50,12 @@
     public BluetoothSwitchPreferenceController(Context context,
             SwitchWidgetController switchController,
             FooterPreference footerPreference) {
-        this(context, Utils.getLocalBtManager(context), new RestrictionUtils(), switchController,
-                footerPreference);
+        this(context, new RestrictionUtils(), switchController, footerPreference);
     }
 
     @VisibleForTesting
-    public BluetoothSwitchPreferenceController(Context context,
-            LocalBluetoothManager bluetoothManager, RestrictionUtils restrictionUtils,
+    public BluetoothSwitchPreferenceController(Context context, RestrictionUtils restrictionUtils,
             SwitchWidgetController switchController, FooterPreference footerPreference) {
-        mBluetoothManager = bluetoothManager;
         mRestrictionUtils = restrictionUtils;
         mSwitch = switchController;
         mContext = context;
@@ -73,12 +64,9 @@
         mSwitch.setupView();
         updateText(mSwitch.isChecked());
 
-        if (mBluetoothManager != null) {
-            mBluetoothAdapter = mBluetoothManager.getBluetoothAdapter();
-        }
         mBluetoothEnabler = new BluetoothEnabler(context,
                 switchController,
-                FeatureFactory.getFactory(context).getMetricsFeatureProvider(), mBluetoothManager,
+                FeatureFactory.getFactory(context).getMetricsFeatureProvider(),
                 MetricsEvent.ACTION_SETTINGS_MASTER_SWITCH_BLUETOOTH_TOGGLE,
                 mRestrictionUtils);
         mBluetoothEnabler.setToggleCallback(this);
diff --git a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
index 500fb06..259a403 100644
--- a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
@@ -60,25 +60,6 @@
     }
 
     @Override
-    public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
-            int bluetoothProfile) {
-        if (DBG) {
-            Log.d(TAG, "onProfileConnectionStateChanged() device: " +
-                    cachedDevice.getName() + ", state: " + state + ", bluetoothProfile: "
-                    + bluetoothProfile);
-        }
-        if (state == BluetoothProfile.STATE_CONNECTED) {
-            if (isFilterMatched(cachedDevice)) {
-                addPreference(cachedDevice);
-            } else {
-                removePreference(cachedDevice);
-            }
-        } else if (state == BluetoothProfile.STATE_DISCONNECTED) {
-            removePreference(cachedDevice);
-        }
-    }
-
-    @Override
     public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
         final int audioMode = mAudioManager.getMode();
         final int currentAudioProfile;
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index 7c7e271..7c4224e 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -28,7 +28,6 @@
 import com.android.settingslib.bluetooth.BluetoothCallback;
 import com.android.settingslib.bluetooth.BluetoothDeviceFilter;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import java.util.Collection;
@@ -64,7 +63,7 @@
 
     BluetoothDevice mSelectedDevice;
 
-    LocalBluetoothAdapter mLocalAdapter;
+    BluetoothAdapter mBluetoothAdapter;
     LocalBluetoothManager mLocalManager;
 
     @VisibleForTesting
@@ -97,7 +96,7 @@
             Log.e(TAG, "Bluetooth is not supported on this device");
             return;
         }
-        mLocalAdapter = mLocalManager.getBluetoothAdapter();
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
         mShowDevicesWithoutNames = SystemProperties.getBoolean(
                 BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false);
 
@@ -146,7 +145,7 @@
     @Override
     public boolean onPreferenceTreeClick(Preference preference) {
         if (KEY_BT_SCAN.equals(preference.getKey())) {
-            mLocalAdapter.startScanning(true);
+            startScanning();
             return true;
         }
 
@@ -172,7 +171,7 @@
         }
 
         // Prevent updates while the list shows one of the state messages
-        if (mLocalAdapter.getBluetoothState() != BluetoothAdapter.STATE_ON) return;
+        if (mBluetoothAdapter.getState() != BluetoothAdapter.STATE_ON) return;
 
         if (mFilter.matches(cachedDevice.getDevice())) {
             createDevicePreference(cachedDevice);
@@ -214,7 +213,7 @@
 
         myDevicePreference.setTitle(getString(
                 R.string.bluetooth_footer_mac_message,
-                bidiFormatter.unicodeWrap(mLocalAdapter.getAddress())));
+                bidiFormatter.unicodeWrap(mBluetoothAdapter.getAddress())));
     }
 
     @Override
@@ -227,21 +226,21 @@
 
     @VisibleForTesting
     void enableScanning() {
-        // LocalBluetoothAdapter already handles repeated scan requests
-        mLocalAdapter.startScanning(true);
+        // BluetoothAdapter already handles repeated scan requests
+        startScanning();
         mScanEnabled = true;
     }
 
     @VisibleForTesting
     void disableScanning() {
-        mLocalAdapter.stopScanning();
+        stopScanning();
         mScanEnabled = false;
     }
 
     @Override
     public void onScanningStateChanged(boolean started) {
         if (!started && mScanEnabled) {
-            mLocalAdapter.startScanning(true);
+            startScanning();
         }
     }
 
@@ -287,4 +286,16 @@
     public boolean shouldShowDevicesWithoutNames() {
         return mShowDevicesWithoutNames;
     }
+
+    void startScanning() {
+        if (!mBluetoothAdapter.isDiscovering()) {
+            mBluetoothAdapter.startDiscovery();
+        }
+    }
+
+    void stopScanning() {
+        if (mBluetoothAdapter.isDiscovering()) {
+            mBluetoothAdapter.cancelDiscovery();
+        }
+    }
 }
diff --git a/src/com/android/settings/bluetooth/DevicePickerActivity.java b/src/com/android/settings/bluetooth/DevicePickerActivity.java
index 43ba05d..5228cd8 100644
--- a/src/com/android/settings/bluetooth/DevicePickerActivity.java
+++ b/src/com/android/settings/bluetooth/DevicePickerActivity.java
@@ -16,16 +16,17 @@
 
 package com.android.settings.bluetooth;
 
-import android.app.Activity;
 import android.os.Bundle;
 
 import com.android.settings.R;
 
+import androidx.fragment.app.FragmentActivity;
+
 /**
  * Activity for Bluetooth device picker dialog. The device picker logic
  * is implemented in the {@link BluetoothPairingDetail} fragment.
  */
-public final class DevicePickerActivity extends Activity {
+public final class DevicePickerActivity extends FragmentActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
diff --git a/src/com/android/settings/bluetooth/DevicePickerFragment.java b/src/com/android/settings/bluetooth/DevicePickerFragment.java
index 5d404d7..097fba7 100644
--- a/src/com/android/settings/bluetooth/DevicePickerFragment.java
+++ b/src/com/android/settings/bluetooth/DevicePickerFragment.java
@@ -94,7 +94,7 @@
         mSelectedDevice = null;
         if (mScanAllowed) {
             enableScanning();
-            mAvailableDevicesCategory.setProgress(mLocalAdapter.isDiscovering());
+            mAvailableDevicesCategory.setProgress(mBluetoothAdapter.isDiscovering());
         }
     }
 
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
index 2a65901..faed1c3 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
@@ -16,13 +16,13 @@
 
 package com.android.settings.bluetooth;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.text.TextUtils;
 import android.util.Log;
 
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 /**
@@ -89,7 +89,7 @@
         }
 
         // If the device was discoverING recently
-        LocalBluetoothAdapter adapter = manager.getBluetoothAdapter();
+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
         if (adapter != null) {
             if (adapter.isDiscovering()) {
                 return true;
diff --git a/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java b/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java
index 029b974..4cbcce8 100644
--- a/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java
+++ b/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java
@@ -25,13 +25,11 @@
 
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 /** Provides a dialog for changing the advertised name of the local bluetooth adapter. */
 public class LocalDeviceNameDialogFragment extends BluetoothNameDialogFragment {
     public static final String TAG = "LocalAdapterName";
-    private LocalBluetoothAdapter mLocalAdapter;
+    private BluetoothAdapter mBluetoothAdapter;
 
     public static LocalDeviceNameDialogFragment newInstance() {
         return new LocalDeviceNameDialogFragment();
@@ -53,8 +51,7 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        LocalBluetoothManager localManager = Utils.getLocalBtManager(getActivity());
-        mLocalAdapter = localManager.getBluetoothAdapter();
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
     }
 
     @Override
@@ -84,14 +81,14 @@
 
     @Override
     protected String getDeviceName() {
-        if (mLocalAdapter != null && mLocalAdapter.isEnabled()) {
-            return mLocalAdapter.getName();
+        if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
+            return mBluetoothAdapter.getName();
         }
         return null;
     }
 
     @Override
     protected void setDeviceName(String deviceName) {
-        mLocalAdapter.setName(deviceName);
+        mBluetoothAdapter.setName(deviceName);
     }
 }
diff --git a/src/com/android/settings/bluetooth/RequestPermissionActivity.java b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
index 5f6fc39..fff6f12 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
@@ -34,8 +34,6 @@
 
 import com.android.settings.R;
 import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import androidx.appcompat.app.AlertDialog;
 
@@ -58,7 +56,7 @@
     static final int REQUEST_ENABLE_DISCOVERABLE = 2;
     static final int REQUEST_DISABLE = 3;
 
-    private LocalBluetoothAdapter mLocalAdapter;
+    private BluetoothAdapter mBluetoothAdapter;
 
     private int mTimeout = BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT;
 
@@ -76,13 +74,13 @@
 
         setResult(Activity.RESULT_CANCELED);
 
-        // Note: initializes mLocalAdapter and returns true on error
+        // Note: initializes mBluetoothAdapter and returns true on error
         if (parseIntent()) {
             finish();
             return;
         }
 
-        int btState = mLocalAdapter.getState();
+        int btState = mBluetoothAdapter.getState();
 
         if (mRequest == REQUEST_DISABLE) {
             switch (btState) {
@@ -204,7 +202,7 @@
         switch (mRequest) {
             case REQUEST_ENABLE:
             case REQUEST_ENABLE_DISCOVERABLE: {
-                if (mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON) {
+                if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
                     proceedAndFinish();
                 } else {
                     // If BT is not up yet, show "Turning on Bluetooth..."
@@ -216,7 +214,7 @@
             } break;
 
             case REQUEST_DISABLE: {
-                if (mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_OFF) {
+                if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF) {
                     proceedAndFinish();
                 } else {
                     // If BT is not up yet, show "Turning off Bluetooth..."
@@ -252,7 +250,7 @@
         if (mRequest == REQUEST_ENABLE || mRequest == REQUEST_DISABLE) {
             // BT toggled. Done
             returnCode = RESULT_OK;
-        } else if (mLocalAdapter.setScanMode(
+        } else if (mBluetoothAdapter.setScanMode(
                 BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, mTimeout)) {
             // If already in discoverable mode, this will extend the timeout.
             long endTime = System.currentTimeMillis() + (long) mTimeout * 1000;
@@ -284,7 +282,7 @@
     }
 
     /**
-     * Parse the received Intent and initialize mLocalBluetoothAdapter.
+     * Parse the received Intent and initialize mBluetoothAdapter.
      * @return true if an error occurred; false otherwise
      */
     private boolean parseIntent() {
@@ -314,13 +312,6 @@
             return true;
         }
 
-        LocalBluetoothManager manager = Utils.getLocalBtManager(this);
-        if (manager == null) {
-            Log.e(TAG, "Error: there's a problem starting Bluetooth");
-            setResult(RESULT_CANCELED);
-            return true;
-        }
-
         String packageName = getCallingPackage();
         if (TextUtils.isEmpty(packageName)) {
             packageName = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
@@ -340,7 +331,12 @@
             }
         }
 
-        mLocalAdapter = manager.getBluetoothAdapter();
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (mBluetoothAdapter == null) {
+            Log.e(TAG, "Error: there's a problem starting Bluetooth");
+            setResult(RESULT_CANCELED);
+            return true;
+        }
 
         return false;
     }
diff --git a/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java b/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
index aaa7b50..99ac928 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionHelperActivity.java
@@ -28,8 +28,6 @@
 import com.android.internal.app.AlertActivity;
 import com.android.internal.app.AlertController;
 import com.android.settings.R;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 /**
  * RequestPermissionHelperActivity asks the user whether to toggle Bluetooth.
@@ -49,7 +47,7 @@
     public static final String EXTRA_APP_LABEL =
             "com.android.settings.bluetooth.extra.APP_LABEL";
 
-    private LocalBluetoothAdapter mLocalAdapter;
+    private BluetoothAdapter mBluetoothAdapter;
 
     private CharSequence mAppLabel;
 
@@ -63,7 +61,7 @@
 
         setResult(RESULT_CANCELED);
 
-        // Note: initializes mLocalAdapter and returns true on error
+        // Note: initializes mBluetoothAdapter and returns true on error
         if (!parseIntent()) {
             finish();
             return;
@@ -131,20 +129,20 @@
                         startActivity(intent);
                     }
                 } else {
-                    mLocalAdapter.enable();
+                    mBluetoothAdapter.enable();
                     setResult(Activity.RESULT_OK);
                 }
             } break;
 
             case RequestPermissionActivity.REQUEST_DISABLE: {
-                mLocalAdapter.disable();
+                mBluetoothAdapter.disable();
                 setResult(Activity.RESULT_OK);
             } break;
         }
     }
 
     /**
-     * Parse the received Intent and initialize mLocalBluetoothAdapter.
+     * Parse the received Intent and initialize mBluetoothAdapter.
      * @return true if an error occurred; false otherwise
      */
     private boolean parseIntent() {
@@ -167,16 +165,14 @@
             return false;
         }
 
-        LocalBluetoothManager manager = Utils.getLocalBtManager(this);
-        if (manager == null) {
+        mAppLabel = getIntent().getCharSequenceExtra(EXTRA_APP_LABEL);
+
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (mBluetoothAdapter == null) {
             Log.e(TAG, "Error: there's a problem starting Bluetooth");
             return false;
         }
 
-        mAppLabel = getIntent().getCharSequenceExtra(EXTRA_APP_LABEL);
-
-        mLocalAdapter = manager.getBluetoothAdapter();
-
         return true;
     }
 }
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index db11164..059a920 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -49,16 +49,6 @@
     }
 
     @Override
-    public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state,
-            int bluetoothProfile) {
-        if (state == BluetoothProfile.STATE_CONNECTED) {
-            removePreference(cachedDevice);
-        } else if (state == BluetoothProfile.STATE_DISCONNECTED) {
-            addPreference(cachedDevice);
-        }
-    }
-
-    @Override
     public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
         final BluetoothDevice device = cachedDevice.getDevice();
         if (DBG) {
diff --git a/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceController.java b/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceController.java
index e5e1a70..feb64b5 100644
--- a/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceController.java
@@ -30,7 +30,6 @@
 import com.android.settings.bluetooth.Utils;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnPause;
@@ -54,7 +53,7 @@
     LocalBluetoothManager mLocalManager;
     private FooterPreferenceMixinCompat mFooterPreferenceMixin;
     private FooterPreference mPreference;
-    private LocalBluetoothAdapter mLocalAdapter;
+    private BluetoothAdapter mBluetoothAdapter;
     private AlwaysDiscoverable mAlwaysDiscoverable;
 
     public DiscoverableFooterPreferenceController(Context context) {
@@ -63,8 +62,8 @@
         if (mLocalManager == null) {
             return;
         }
-        mLocalAdapter = mLocalManager.getBluetoothAdapter();
-        mAlwaysDiscoverable = new AlwaysDiscoverable(context, mLocalAdapter);
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        mAlwaysDiscoverable = new AlwaysDiscoverable(context);
         initReceiver();
     }
 
@@ -121,7 +120,7 @@
         mContext.registerReceiver(mBluetoothChangedReceiver,
                 new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
         mAlwaysDiscoverable.start();
-        updateFooterPreferenceTitle(mLocalAdapter.getState());
+        updateFooterPreferenceTitle(mBluetoothAdapter.getState());
     }
 
     @Override
@@ -142,7 +141,7 @@
     }
 
     private CharSequence getPreferenceTitle() {
-        final String deviceName = mLocalAdapter.getName();
+        final String deviceName = mBluetoothAdapter.getName();
         if (TextUtils.isEmpty(deviceName)) {
             return null;
         }
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 219c92c..4346973 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -52,6 +52,7 @@
 import com.android.settings.applications.specialaccess.vrlistener.VrListenerSettings;
 import com.android.settings.backup.PrivacySettings;
 import com.android.settings.backup.ToggleBackupSettingFragment;
+import com.android.settings.biometrics.face.FaceSettings;
 import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
 import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
@@ -187,6 +188,7 @@
             PowerUsageSummary.class.getName(),
             AccountSyncSettings.class.getName(),
             AssistGestureSettings.class.getName(),
+            FaceSettings.class.getName(),
             SwipeToNotificationSettings.class.getName(),
             DoubleTapPowerSettings.class.getName(),
             DoubleTapScreenSettings.class.getName(),
diff --git a/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java b/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
index 558e7cb..d8e2e79 100644
--- a/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
+++ b/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
@@ -16,7 +16,7 @@
 
 package com.android.settings.deviceinfo;
 
-import android.annotation.Nullable;
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
@@ -30,8 +30,6 @@
 import com.android.settings.R;
 import com.android.settings.widget.ValidatedEditTextPreference;
 import com.android.settings.wifi.tether.WifiDeviceNameTextValidator;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnCreate;
 import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
@@ -50,10 +48,9 @@
     private static final String KEY_PENDING_DEVICE_NAME = "key_pending_device_name";
     private String mDeviceName;
     protected WifiManager mWifiManager;
+    private final BluetoothAdapter mBluetoothAdapter;
     private final WifiDeviceNameTextValidator mWifiDeviceNameTextValidator;
     private ValidatedEditTextPreference mPreference;
-    @Nullable
-    private LocalBluetoothManager mBluetoothManager;
     private DeviceNamePreferenceHost mHost;
     private String mPendingDeviceName;
 
@@ -62,6 +59,7 @@
 
         mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mWifiDeviceNameTextValidator = new WifiDeviceNameTextValidator();
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
 
         initializeDeviceName();
     }
@@ -118,10 +116,6 @@
         return mWifiDeviceNameTextValidator.isTextValid(deviceName);
     }
 
-    public void setLocalBluetoothManager(LocalBluetoothManager localBluetoothManager) {
-        mBluetoothManager = localBluetoothManager;
-    }
-
     public void confirmDeviceName() {
         if (mPendingDeviceName != null) {
             setDeviceName(mPendingDeviceName);
@@ -149,14 +143,8 @@
     }
 
     private void setBluetoothDeviceName(String deviceName) {
-        // Bluetooth manager doesn't exist for certain devices.
-        if (mBluetoothManager == null) {
-            return;
-        }
-
-        final LocalBluetoothAdapter localBluetoothAdapter = mBluetoothManager.getBluetoothAdapter();
-        if (localBluetoothAdapter != null) {
-            localBluetoothAdapter.setName(getFilteredBluetoothString(deviceName));
+        if (mBluetoothAdapter != null) {
+            mBluetoothAdapter.setName(getFilteredBluetoothString(deviceName));
         }
     }
 
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index 29acf45..425edd9 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -16,8 +16,6 @@
 
 package com.android.settings.deviceinfo.aboutphone;
 
-import static com.android.settings.bluetooth.Utils.getLocalBtManager;
-
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
@@ -117,7 +115,6 @@
         controllers.add(new BrandedAccountPreferenceController(context));
         DeviceNamePreferenceController deviceNamePreferenceController =
                 new DeviceNamePreferenceController(context);
-        deviceNamePreferenceController.setLocalBluetoothManager(getLocalBtManager(context));
         deviceNamePreferenceController.setHost(fragment);
         if (lifecycle != null) {
             lifecycle.addObserver(deviceNamePreferenceController);
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java
index 452bf91..efa6041 100644
--- a/src/com/android/settings/nfc/AndroidBeam.java
+++ b/src/com/android/settings/nfc/AndroidBeam.java
@@ -53,6 +53,8 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         mNfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
+        if (mNfcAdapter == null)
+            getActivity().finish();
         setHasOptionsMenu(true);
     }
 
@@ -90,7 +92,6 @@
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
-
         SettingsActivity activity = (SettingsActivity) getActivity();
 
         mOldActivityTitle = activity.getActionBar().getTitle();
diff --git a/src/com/android/settings/nfc/PaymentDefaultDialog.java b/src/com/android/settings/nfc/PaymentDefaultDialog.java
index 949f87d..73b92e7 100644
--- a/src/com/android/settings/nfc/PaymentDefaultDialog.java
+++ b/src/com/android/settings/nfc/PaymentDefaultDialog.java
@@ -42,7 +42,11 @@
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        mBackend = new PaymentBackend(this);
+        try {
+            mBackend = new PaymentBackend(this);
+        } catch (NullPointerException e) {
+            finish();
+        }
         Intent intent = getIntent();
         ComponentName component = intent.getParcelableExtra(
                 CardEmulation.EXTRA_SERVICE_COMPONENT);
diff --git a/src/com/android/settings/notification/AbstractZenModePreferenceController.java b/src/com/android/settings/notification/AbstractZenModePreferenceController.java
index 5d92279..791e28c 100644
--- a/src/com/android/settings/notification/AbstractZenModePreferenceController.java
+++ b/src/com/android/settings/notification/AbstractZenModePreferenceController.java
@@ -117,7 +117,7 @@
     }
 
     protected int getZenDuration() {
-        return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ZEN_DURATION,
+        return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ZEN_DURATION,
                 0);
     }
 
@@ -125,8 +125,8 @@
         private final Uri ZEN_MODE_URI = Settings.Global.getUriFor(Settings.Global.ZEN_MODE);
         private final Uri ZEN_MODE_CONFIG_ETAG_URI = Settings.Global.getUriFor(
                 Settings.Global.ZEN_MODE_CONFIG_ETAG);
-        private final Uri ZEN_MODE_DURATION_URI = Settings.Global.getUriFor(
-                Settings.Global.ZEN_DURATION);
+        private final Uri ZEN_MODE_DURATION_URI = Settings.Secure.getUriFor(
+                Settings.Secure.ZEN_DURATION);
 
         private final Preference mPreference;
 
diff --git a/src/com/android/settings/notification/ChargingSoundPreferenceController.java b/src/com/android/settings/notification/ChargingSoundPreferenceController.java
index fccde6a..c7cd232 100644
--- a/src/com/android/settings/notification/ChargingSoundPreferenceController.java
+++ b/src/com/android/settings/notification/ChargingSoundPreferenceController.java
@@ -16,10 +16,10 @@
 
 package com.android.settings.notification;
 
-import static com.android.settings.notification.SettingPref.TYPE_GLOBAL;
+import static com.android.settings.notification.SettingPref.TYPE_SECURE;
 
 import android.content.Context;
-import android.provider.Settings.Global;
+import android.provider.Settings.Secure;
 
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
@@ -33,7 +33,7 @@
             Lifecycle lifecycle) {
         super(context, parent, lifecycle);
         mPreference = new SettingPref(
-            TYPE_GLOBAL, KEY_CHARGING_SOUNDS, Global.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
+            TYPE_SECURE, KEY_CHARGING_SOUNDS, Secure.CHARGING_SOUNDS_ENABLED, DEFAULT_ON);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/SettingPref.java b/src/com/android/settings/notification/SettingPref.java
index a651e6a..f7152fa 100644
--- a/src/com/android/settings/notification/SettingPref.java
+++ b/src/com/android/settings/notification/SettingPref.java
@@ -21,6 +21,7 @@
 import android.content.res.Resources;
 import android.net.Uri;
 import android.provider.Settings.Global;
+import android.provider.Settings.Secure;
 import android.provider.Settings.System;
 
 import com.android.settings.SettingsPreferenceFragment;
@@ -34,6 +35,7 @@
 public class SettingPref {
     public static final int TYPE_GLOBAL = 1;
     public static final int TYPE_SYSTEM = 2;
+    public static final int TYPE_SECURE = 3;
 
     protected final int mType;
     private final String mKey;
@@ -132,6 +134,8 @@
                 return Global.getUriFor(setting);
             case TYPE_SYSTEM:
                 return System.getUriFor(setting);
+            case TYPE_SECURE:
+                return Secure.getUriFor(setting);
         }
         throw new IllegalArgumentException();
     }
@@ -142,6 +146,8 @@
                 return Global.putInt(cr, setting, value);
             case TYPE_SYSTEM:
                 return System.putInt(cr, setting, value);
+            case TYPE_SECURE:
+                return Secure.putInt(cr, setting, value);
         }
         throw new IllegalArgumentException();
     }
@@ -152,6 +158,8 @@
                 return Global.getInt(cr, setting, def);
             case TYPE_SYSTEM:
                 return System.getInt(cr, setting, def);
+            case TYPE_SECURE:
+                return Secure.getInt(cr, setting, def);
         }
         throw new IllegalArgumentException();
     }
diff --git a/src/com/android/settings/notification/ZenModeBackend.java b/src/com/android/settings/notification/ZenModeBackend.java
index 8242e3e..d63bed4 100644
--- a/src/com/android/settings/notification/ZenModeBackend.java
+++ b/src/com/android/settings/notification/ZenModeBackend.java
@@ -136,8 +136,8 @@
     }
 
     protected void saveVisualEffectsPolicy(int category, boolean suppress) {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.ZEN_SETTINGS_UPDATED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
 
         int suppressedEffects = getNewSuppressedEffects(suppress, category);
         savePolicy(mPolicy.priorityCategories, mPolicy.priorityCallSenders,
diff --git a/src/com/android/settings/notification/ZenModeButtonPreferenceController.java b/src/com/android/settings/notification/ZenModeButtonPreferenceController.java
index ac9aaba..03e63e3 100644
--- a/src/com/android/settings/notification/ZenModeButtonPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeButtonPreferenceController.java
@@ -97,14 +97,14 @@
     private void updateZenButtonOnClickListener() {
         int zenDuration = getZenDuration();
         switch (zenDuration) {
-            case Settings.Global.ZEN_DURATION_PROMPT:
+            case Settings.Secure.ZEN_DURATION_PROMPT:
                 mZenButtonOn.setOnClickListener(v -> {
                     mMetricsFeatureProvider.action(mContext,
                             MetricsProto.MetricsEvent.ACTION_ZEN_TOGGLE_DND_BUTTON, false);
                     new SettingsEnableZenModeDialog().show(mFragment, TAG);
                 });
                 break;
-            case Settings.Global.ZEN_DURATION_FOREVER:
+            case Settings.Secure.ZEN_DURATION_FOREVER:
                 mZenButtonOn.setOnClickListener(v -> {
                     mMetricsFeatureProvider.action(mContext,
                             MetricsProto.MetricsEvent.ACTION_ZEN_TOGGLE_DND_BUTTON, false);
diff --git a/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java b/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java
index 3cfd13d..1769871 100644
--- a/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java
+++ b/src/com/android/settings/notification/ZenModeScheduleRuleSettings.java
@@ -63,6 +63,7 @@
     private TimePickerPreference mStart;
     private TimePickerPreference mEnd;
     private SwitchPreference mExitAtAlarm;
+    private AlertDialog mDayDialog;
 
     private ScheduleInfo mSchedule;
 
@@ -195,7 +196,6 @@
         updateEndSummary();
     }
 
-
     @Override
     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
         List<AbstractPreferenceController> controllers = new ArrayList<>();
@@ -214,18 +214,27 @@
         return MetricsEvent.NOTIFICATION_ZEN_MODE_SCHEDULE_RULE;
     }
 
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        if (mDayDialog != null && mDayDialog.isShowing()) {
+            mDayDialog.dismiss();
+            mDayDialog = null;
+        }
+    }
+
     private void showDaysDialog() {
-        new AlertDialog.Builder(mContext)
+        mDayDialog = new AlertDialog.Builder(mContext)
                 .setTitle(R.string.zen_mode_schedule_rule_days)
                 .setView(new ZenModeScheduleDaysSelection(mContext, mSchedule.days) {
-                      @Override
-                      protected void onChanged(final int[] days) {
-                          if (mDisableListeners) return;
-                          if (Arrays.equals(days, mSchedule.days)) return;
-                          if (DEBUG) Log.d(TAG, "days.onChanged days=" + Arrays.asList(days));
-                          mSchedule.days = days;
-                          updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
-                      }
+                    @Override
+                    protected void onChanged(final int[] days) {
+                        if (mDisableListeners) return;
+                        if (Arrays.equals(days, mSchedule.days)) return;
+                        if (DEBUG) Log.d(TAG, "days.onChanged days=" + Arrays.asList(days));
+                        mSchedule.days = days;
+                        updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
+                    }
                 })
                 .setOnDismissListener(new OnDismissListener() {
                     @Override
@@ -249,7 +258,7 @@
             super(context);
             mContext = context;
             setPersistent(false);
-            setOnPreferenceClickListener(new OnPreferenceClickListener(){
+            setOnPreferenceClickListener(new OnPreferenceClickListener() {
                 @Override
                 public boolean onPreferenceClick(Preference preference) {
                     final TimePickerFragment frag = new TimePickerFragment();
diff --git a/src/com/android/settings/notification/ZenOnboardingActivity.java b/src/com/android/settings/notification/ZenOnboardingActivity.java
index 99bc172..3f12358 100644
--- a/src/com/android/settings/notification/ZenOnboardingActivity.java
+++ b/src/com/android/settings/notification/ZenOnboardingActivity.java
@@ -62,8 +62,8 @@
         setMetricsLogger(new MetricsLogger());
 
         Context context = getApplicationContext();
-        Settings.Global.putInt(context.getContentResolver(),
-                Settings.Global.ZEN_SETTINGS_SUGGESTION_VIEWED, 1);
+        Settings.Secure.putInt(context.getContentResolver(),
+                Settings.Secure.ZEN_SETTINGS_SUGGESTION_VIEWED, 1);
 
         setupUI();
     }
@@ -135,8 +135,8 @@
             mMetrics.action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
         }
 
-        Settings.Global.putInt(getApplicationContext().getContentResolver(),
-                Settings.Global.ZEN_SETTINGS_UPDATED, 1);
+        Settings.Secure.putInt(getApplicationContext().getContentResolver(),
+                Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
 
         finishAndRemoveTask();
     }
@@ -160,11 +160,11 @@
         NotificationManager nm = context.getSystemService(NotificationManager.class);
         if (NotificationManager.Policy.areAllVisualEffectsSuppressed(
                 nm.getNotificationPolicy().suppressedVisualEffects)) {
-            Settings.Global.putInt(context.getContentResolver(),
-                    Settings.Global.ZEN_SETTINGS_UPDATED, 1);
+            Settings.Secure.putInt(context.getContentResolver(),
+                    Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
         }
-        return Settings.Global.getInt(context.getContentResolver(),
-                Settings.Global.ZEN_SETTINGS_UPDATED, 0) != 0;
+        return Settings.Secure.getInt(context.getContentResolver(),
+                Settings.Secure.ZEN_SETTINGS_UPDATED, 0) != 0;
     }
 
     private static boolean showSuggestion(Context context) {
@@ -173,8 +173,8 @@
 
         // SHOW_ZEN_SETTINGS_SUGGESTION is also true when:
         // - automatic rule has started DND and user has not seen the first use dialog
-        return Settings.Global.getInt(context.getContentResolver(),
-                Settings.Global.SHOW_ZEN_SETTINGS_SUGGESTION, 0) != 0;
+        return Settings.Secure.getInt(context.getContentResolver(),
+                Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION, 0) != 0;
 
     }
 
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index 3dc4068..a45bea7 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -165,6 +165,11 @@
         @Override
         public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
+            final Activity activity = getActivity();
+            if (!Utils.isDeviceProvisioned(activity) && !canRunBeforeDeviceProvisioned()) {
+                activity.finish();
+                return;
+            }
 
             String chooseLockAction = getActivity().getIntent().getAction();
             mFingerprintManager = Utils.getFingerprintManagerOrNull(getActivity());
@@ -249,6 +254,10 @@
             addHeaderView();
         }
 
+        protected boolean canRunBeforeDeviceProvisioned() {
+            return false;
+        }
+
         protected void addHeaderView() {
             if (mForFingerprint) {
                 setHeaderView(R.layout.choose_lock_generic_fingerprint_header);
diff --git a/src/com/android/settings/password/SetupChooseLockGeneric.java b/src/com/android/settings/password/SetupChooseLockGeneric.java
index 6ca0916..1642bf0 100644
--- a/src/com/android/settings/password/SetupChooseLockGeneric.java
+++ b/src/com/android/settings/password/SetupChooseLockGeneric.java
@@ -130,6 +130,11 @@
             return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
         }
 
+        @Override
+        protected boolean canRunBeforeDeviceProvisioned() {
+            return true;
+        }
+
         /***
          * Disables preferences that are less secure than required quality and shows only secure
          * screen lock options here.
diff --git a/src/com/android/settings/search/actionbar/SearchMenuController.java b/src/com/android/settings/search/actionbar/SearchMenuController.java
index 2fcc048..54fae7e 100644
--- a/src/com/android/settings/search/actionbar/SearchMenuController.java
+++ b/src/com/android/settings/search/actionbar/SearchMenuController.java
@@ -24,6 +24,7 @@
 import android.view.MenuItem;
 
 import com.android.settings.R;
+import com.android.settings.Utils;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.SearchFeatureProvider;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -53,6 +54,9 @@
 
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        if (!Utils.isDeviceProvisioned(mHost.getContext())) {
+            return;
+        }
         if (menu == null) {
             return;
         }
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
index 74108aa..b8730b9 100644
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
@@ -40,9 +40,6 @@
 import android.widget.RemoteViews;
 
 import com.android.settings.R;
-import com.android.settings.bluetooth.Utils;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 /**
  * Provides control of power-related settings from a widget.
@@ -54,7 +51,7 @@
             new ComponentName("com.android.settings",
                     "com.android.settings.widget.SettingsAppWidgetProvider");
 
-    private static LocalBluetoothAdapter sLocalBluetoothAdapter = null;
+    private static BluetoothAdapter sBluetoothAdapter = null;
 
     private static final int BUTTON_WIFI = 0;
     private static final int BUTTON_BRIGHTNESS = 1;
@@ -450,23 +447,19 @@
 
         @Override
         public int getActualState(Context context) {
-            if (sLocalBluetoothAdapter == null) {
-                LocalBluetoothManager manager = Utils.getLocalBtManager(context);
-                if (manager == null) {
-                    return STATE_UNKNOWN;  // On emulator?
-                }
-                sLocalBluetoothAdapter = manager.getBluetoothAdapter();
-                if (sLocalBluetoothAdapter == null) {
+            if (sBluetoothAdapter == null) {
+                sBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+                if (sBluetoothAdapter == null) {
                     return STATE_UNKNOWN;  // On emulator?
                 }
             }
-            return bluetoothStateToFiveState(sLocalBluetoothAdapter.getBluetoothState());
+            return bluetoothStateToFiveState(sBluetoothAdapter.getState());
         }
 
         @Override
         protected void requestStateChange(Context context, final boolean desiredState) {
-            if (sLocalBluetoothAdapter == null) {
-                Log.d(TAG, "No LocalBluetoothManager");
+            if (sBluetoothAdapter == null) {
+                Log.d(TAG, "No BluetoothAdapter");
                 return;
             }
             // Actually request the Bluetooth change and persistent
@@ -476,7 +469,11 @@
             new AsyncTask<Void, Void, Void>() {
                 @Override
                 protected Void doInBackground(Void... args) {
-                    sLocalBluetoothAdapter.setBluetoothEnabled(desiredState);
+                    if (desiredState) {
+                        sBluetoothAdapter.enable();
+                    } else {
+                        sBluetoothAdapter.disable();
+                    }
                     return null;
                 }
             }.execute();
diff --git a/tests/robotests/src/com/android/settings/SettingsActivityTest.java b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
index d1033ea..3d529e4 100644
--- a/tests/robotests/src/com/android/settings/SettingsActivityTest.java
+++ b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
@@ -25,8 +25,11 @@
 import static org.mockito.Mockito.when;
 
 import android.app.ActivityManager;
+import android.content.Context;
 import android.content.Intent;
-
+import android.os.Bundle;
+import android.provider.Settings.Global;
+import android.view.View;
 import com.android.settings.core.OnActivityResultListener;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
@@ -35,6 +38,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
 import org.robolectric.RuntimeEnvironment;
 
 import java.util.ArrayList;
@@ -52,15 +56,38 @@
     @Mock
     private ActivityManager.TaskDescription mTaskDescription;
     private SettingsActivity mActivity;
+    private Context mContext;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
+        mContext = RuntimeEnvironment.application;
         mActivity = spy(new SettingsActivity());
     }
 
     @Test
+    public void onCreate_deviceNotProvisioned_shouldDisableSearch() {
+        Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
+        final Intent intent = new Intent(mContext, Settings.class);
+        final SettingsActivity activity =
+            Robolectric.buildActivity(SettingsActivity.class, intent).create(Bundle.EMPTY).get();
+
+        assertThat(activity.findViewById(R.id.search_bar).getVisibility())
+            .isEqualTo(View.INVISIBLE);
+    }
+
+    @Test
+    public void onCreate_deviceProvisioned_shouldEnableSearch() {
+        Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
+        final Intent intent = new Intent(mContext, Settings.class);
+        final SettingsActivity activity =
+            Robolectric.buildActivity(SettingsActivity.class, intent).create(Bundle.EMPTY).get();
+
+        assertThat(activity.findViewById(R.id.search_bar).getVisibility()).isEqualTo(View.VISIBLE);
+    }
+
+    @Test
     public void launchSettingFragment_nullExtraShowFragment_shouldNotCrash() {
         when(mActivity.getSupportFragmentManager()).thenReturn(mFragmentManager);
         when(mFragmentManager.beginTransaction()).thenReturn(mock(FragmentTransaction.class));
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
new file mode 100644
index 0000000..8957f85
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.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;
+
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
+import com.android.settingslib.bluetooth.HearingAidProfile;
+import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
+
+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.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothUtils.class})
+public class AccessibilityHearingAidPreferenceControllerTest {
+    private static final String TEST_DEVICE_ADDRESS = "00:A1:A1:A1:A1:A1";
+    private static final String TEST_DEVICE_NAME = "TEST_HEARING_AID_BT_DEVICE_NAME";
+    private static final String HEARING_AID_PREFERENCE = "hearing_aid_preference";
+
+    private BluetoothAdapter mBluetoothAdapter;
+    private BluetoothManager mBluetoothManager;
+    private BluetoothDevice mBluetoothDevice;
+    private Context mContext;
+    private Preference mHearingAidPreference;
+    private List<Integer> mProfileSupportedList;
+    private AccessibilityHearingAidPreferenceController mPreferenceController;
+
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDevice;
+    @Mock
+    private CachedBluetoothDeviceManager mCachedDeviceManager;
+    @Mock
+    private LocalBluetoothAdapter mLocalBluetoothAdapter;
+    @Mock
+    private LocalBluetoothManager mLocalBluetoothManager;
+    @Mock
+    private LocalBluetoothProfileManager mLocalBluetoothProfileManager;
+    @Mock
+    private HearingAidProfile mHearingAidProfile;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        setupBluetoothEnvironment();
+        setupHearingAidEnvironment();
+        mHearingAidPreference = new Preference(mContext);
+        mHearingAidPreference.setKey(HEARING_AID_PREFERENCE);
+        mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext,
+                HEARING_AID_PREFERENCE);
+        mPreferenceController.setPreference(mHearingAidPreference);
+        mHearingAidPreference.setSummary("");
+    }
+
+    @Test
+    public void onHearingAidStateChanged_connected_updateHearingAidSummary() {
+        when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
+        mPreferenceController.onResume();
+        Intent intent = new Intent(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
+        intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHearingAid.STATE_CONNECTED);
+        sendIntent(intent);
+
+        assertThat(mHearingAidPreference.getSummary()).isEqualTo(TEST_DEVICE_NAME);
+    }
+
+    @Test
+    public void onHearingAidStateChanged_disconnected_updateHearingAidSummary() {
+        mPreferenceController.onResume();
+        Intent intent = new Intent(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
+        intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHearingAid.STATE_DISCONNECTED);
+        sendIntent(intent);
+
+        assertThat(mHearingAidPreference.getSummary()).isEqualTo(
+                mContext.getText(R.string.accessibility_hearingaid_not_connected_summary));
+    }
+
+    @Test
+    public void onBluetoothStateChanged_bluetoothOff_updateHearingAidSummary() {
+        mPreferenceController.onResume();
+        Intent intent = new Intent(BluetoothAdapter.ACTION_STATE_CHANGED);
+        intent.putExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF);
+        sendIntent(intent);
+
+        assertThat(mHearingAidPreference.getSummary()).isEqualTo(
+                mContext.getText(R.string.accessibility_hearingaid_not_connected_summary));
+    }
+
+    @Test
+    public void handleHearingAidPreferenceClick_noHearingAid_launchHearingAidInstructionDialog() {
+        mPreferenceController = spy(new AccessibilityHearingAidPreferenceController(mContext,
+                HEARING_AID_PREFERENCE));
+        mPreferenceController.setPreference(mHearingAidPreference);
+        doNothing().when(mPreferenceController).launchHearingAidInstructionDialog();
+        mPreferenceController.handlePreferenceTreeClick(mHearingAidPreference);
+
+        verify(mPreferenceController).launchHearingAidInstructionDialog();
+    }
+
+    @Test
+    public void handleHearingAidPreferenceClick_withHearingAid_launchBluetoothDeviceDetailSetting()
+    {
+        mPreferenceController = spy(new AccessibilityHearingAidPreferenceController(mContext,
+                HEARING_AID_PREFERENCE));
+        mPreferenceController.setPreference(mHearingAidPreference);
+        when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
+        when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
+        mPreferenceController.handlePreferenceTreeClick(mHearingAidPreference);
+
+        verify(mPreferenceController).launchBluetoothDeviceDetailSetting(mCachedBluetoothDevice);
+    }
+
+    @Test
+    public void onNotSupportHearingAidProfile_doNotDoReceiverOperation() {
+        //clear bluetooth supported profile
+        mProfileSupportedList.clear();
+        mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext, HEARING_AID_PREFERENCE);
+        mPreferenceController.setPreference(mHearingAidPreference);
+        //not call registerReceiver()
+        mPreferenceController.onResume();
+        verify(mContext, never()).registerReceiver((BroadcastReceiver) any(), (IntentFilter) any());
+
+        //not call unregisterReceiver()
+        mPreferenceController.onPause();
+        verify(mContext, never()).unregisterReceiver((BroadcastReceiver) any());
+    }
+
+    private void setupBluetoothEnvironment() {
+        ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
+        mLocalBluetoothManager = ShadowBluetoothUtils.getLocalBtManager(mContext);
+        mBluetoothManager = new BluetoothManager(mContext);
+        mBluetoothAdapter = mBluetoothManager.getAdapter();
+        when(mLocalBluetoothManager.getBluetoothAdapter()).thenReturn(mLocalBluetoothAdapter);
+        when(mLocalBluetoothAdapter.isEnabled()).thenReturn(true);
+        when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
+        when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
+        when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
+    }
+
+    private void setupHearingAidEnvironment() {
+        mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS);
+        mProfileSupportedList = new ArrayList<Integer>();
+        mProfileSupportedList.add(BluetoothProfile.HEARING_AID);
+        when(mLocalBluetoothAdapter.getSupportedProfiles()).thenReturn(mProfileSupportedList);
+        when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice);
+        when(mCachedBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME);
+        when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
+    }
+
+    private void sendIntent(Intent intent) {
+        ArgumentCaptor<BroadcastReceiver> broadcastReceiverCaptor =
+                ArgumentCaptor.forClass(BroadcastReceiver.class);
+        verify(mContext).registerReceiver(
+                broadcastReceiverCaptor.capture(), (IntentFilter) any());
+        BroadcastReceiver br = broadcastReceiverCaptor.getValue();
+        br.onReceive(mContext, intent);
+    }
+
+    private List<BluetoothDevice> generateHearingAidDeviceList() {
+        final List<BluetoothDevice> deviceList = new ArrayList<>(1);
+        deviceList.add(mBluetoothDevice);
+        return deviceList;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java b/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
index d9261c2..1e323ef 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AlwaysDiscoverableTest.java
@@ -17,41 +17,41 @@
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
 import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.content.Intent;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
+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
-    private LocalBluetoothAdapter mLocalAdapter;
-
-    @Mock
     private Context mContext;
 
     private AlwaysDiscoverable mAlwaysDiscoverable;
+    private BluetoothAdapter mBluetoothAdapter;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mAlwaysDiscoverable = new AlwaysDiscoverable(mContext, mLocalAdapter);
+        mAlwaysDiscoverable = new AlwaysDiscoverable(mContext);
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
     }
 
     @Test
@@ -76,14 +76,15 @@
     public void stopWithoutStart() {
         mAlwaysDiscoverable.stop();
         // expect no crash
-        verify(mLocalAdapter, never()).setScanMode(anyInt());
+        mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
     }
 
     @Test
     public void startSetsModeAndRegistersReceiver() {
-        when(mLocalAdapter.getScanMode()).thenReturn(BluetoothAdapter.SCAN_MODE_NONE);
+        mShadowBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE);
         mAlwaysDiscoverable.start();
-        verify(mLocalAdapter).setScanMode(eq(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE));
+        assertThat(mBluetoothAdapter.getScanMode())
+                .isEqualTo(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
         verify(mContext).registerReceiver(eq(mAlwaysDiscoverable), any());
     }
 
@@ -97,18 +98,18 @@
     @Test
     public void resetsToDiscoverableModeWhenScanModeChanges() {
         mAlwaysDiscoverable.start();
-        verify(mLocalAdapter, times(1))
-            .setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
+        assertThat(mBluetoothAdapter.getScanMode())
+                .isEqualTo(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
 
         sendScanModeChangedIntent(BluetoothAdapter.SCAN_MODE_CONNECTABLE,
                 BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
 
-        verify(mLocalAdapter, times(2))
-            .setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
+        assertThat(mBluetoothAdapter.getScanMode())
+                .isEqualTo(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
     }
 
     private void sendScanModeChangedIntent(int newMode, int previousMode) {
-        when(mLocalAdapter.getScanMode()).thenReturn(newMode);
+        mShadowBluetoothAdapter.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/BluetoothDeviceNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
index dd5f278..afce68e 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceNamePreferenceControllerTest.java
@@ -24,22 +24,25 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 
+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.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
 public class BluetoothDeviceNamePreferenceControllerTest {
 
     private static final String DEVICE_NAME = "Nightshade";
@@ -48,8 +51,6 @@
 
     private Context mContext;
     @Mock
-    private LocalBluetoothAdapter mLocalAdapter;
-    @Mock
     private PreferenceScreen mPreferenceScreen;
     private Preference mPreference;
 
@@ -64,8 +65,7 @@
         when(mPreferenceScreen.getContext()).thenReturn(mContext);
         mPreference = new Preference(mContext);
         mPreference.setKey(KEY_DEVICE_NAME);
-        mController = spy(new BluetoothDeviceNamePreferenceController(mContext, mLocalAdapter,
-                KEY_DEVICE_NAME));
+        mController = spy(new BluetoothDeviceNamePreferenceController(mContext, KEY_DEVICE_NAME));
         doReturn(DEVICE_NAME).when(mController).getDeviceName();
     }
 
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
index 2b5c7e9..0fdfc52 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceControllerTest.java
@@ -24,11 +24,11 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -41,15 +41,16 @@
 import androidx.fragment.app.FragmentTransaction;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
 public class BluetoothDeviceRenamePreferenceControllerTest {
 
     private static final String DEVICE_NAME = "Nightshade";
     private static final String PREF_KEY = "bt_rename_devices";
 
-    @Mock
-    private LocalBluetoothAdapter mLocalAdapter;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Fragment mFragment;
     @Mock
@@ -59,6 +60,8 @@
     private Context mContext;
     private Preference mPreference;
     private BluetoothDeviceRenamePreferenceController mController;
+    private BluetoothAdapter mBluetoothAdapter;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
@@ -67,9 +70,10 @@
         mContext = spy(RuntimeEnvironment.application);
         mPreference = new Preference(mContext);
         mPreference.setKey(PREF_KEY);
+        mBluetoothAdapter = ShadowBluetoothAdapter.getDefaultAdapter();
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
 
-        mController = spy(new BluetoothDeviceRenamePreferenceController(mContext, mLocalAdapter,
-                PREF_KEY));
+        mController = spy(new BluetoothDeviceRenamePreferenceController(mContext, PREF_KEY));
         mController.setFragment(mFragment);
         doReturn(DEVICE_NAME).when(mController).getDeviceName();
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
@@ -102,7 +106,7 @@
 
     @Test
     public void updatePreferenceState_whenBTisOnPreferenceShouldBeVisible() {
-        when(mLocalAdapter.isEnabled()).thenReturn(true);
+        mShadowBluetoothAdapter.setEnabled(true);
 
         mController.updatePreferenceState(mPreference);
 
@@ -111,7 +115,7 @@
 
     @Test
     public void updatePreferenceState_whenBTisOffPreferenceShouldBeHide() {
-        when(mLocalAdapter.isEnabled()).thenReturn(false);
+        mShadowBluetoothAdapter.setEnabled(false);
 
         mController.updatePreferenceState(mPreference);
 
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java
index 6936177..927f622 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothEnablerTest.java
@@ -35,13 +35,12 @@
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settings.widget.SwitchBar;
 import com.android.settings.widget.SwitchBarController;
 import com.android.settings.widget.SwitchWidgetController;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 import com.android.settingslib.RestrictedSwitchPreference;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 import org.junit.Before;
@@ -53,11 +52,12 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
 import androidx.preference.PreferenceViewHolder;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
+@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class, ShadowBluetoothAdapter.class})
 public class BluetoothEnablerTest {
 
     private static EnforcedAdmin sFakeEnforcedAdmin;
@@ -74,21 +74,17 @@
     @Mock
     private RestrictionUtils mRestrictionUtils;
     @Mock
-    private LocalBluetoothManager mBluetoothManager;
-    @Mock
-    private LocalBluetoothAdapter mBluetoothAdapter;
-    @Mock
     private SwitchWidgetController.OnSwitchChangeListener mCallback;
 
     private Context mContext;
     private SwitchWidgetController mSwitchController;
     private BluetoothEnabler mBluetoothEnabler;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
-        when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
 
         mRestrictedSwitchPreference = new RestrictedSwitchPreference(mContext);
         mSwitchController = spy(new SwitchBarController(new SwitchBar(mContext)));
@@ -96,12 +92,12 @@
                 mContext,
                 mSwitchController,
                 mMetricsFeatureProvider,
-                mBluetoothManager,
                 123,
                 mRestrictionUtils);
         mHolder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
         mRestrictedSwitchPreference.onBindViewHolder(mHolder);
         mBluetoothEnabler.setToggleCallback(mCallback);
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
     }
 
     @Test
@@ -191,7 +187,7 @@
 
     @Test
     public void startWithBluetoothOff_switchIsOff() {
-        when(mBluetoothAdapter.getBluetoothState()).thenReturn(BluetoothAdapter.STATE_OFF);
+        mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_OFF);
         verify(mSwitchController, never()).setChecked(anyBoolean());
         mBluetoothEnabler.resume(mContext);
         verify(mSwitchController, never()).setChecked(true);
@@ -199,7 +195,7 @@
 
     @Test
     public void startWithBluetoothOn_switchIsOn() {
-        when(mBluetoothAdapter.getBluetoothState()).thenReturn(BluetoothAdapter.STATE_ON);
+        mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_ON);
         verify(mSwitchController, never()).setChecked(anyBoolean());
         mBluetoothEnabler.resume(mContext);
         verify(mSwitchController, never()).setChecked(false);
@@ -211,7 +207,7 @@
         // Start up with bluetooth turned on. The switch should get turned on.
         ArgumentCaptor<BroadcastReceiver> captor = ArgumentCaptor.forClass(BroadcastReceiver.class);
         when(mContext.registerReceiver(captor.capture(), any(IntentFilter.class))).thenReturn(null);
-        when(mBluetoothAdapter.getBluetoothState()).thenReturn(BluetoothAdapter.STATE_ON);
+        mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_ON);
         verify(mSwitchController, never()).setChecked(anyBoolean());
         mBluetoothEnabler.resume(mContext);
         verify(mSwitchController, never()).setChecked(false);
@@ -235,7 +231,7 @@
         // Start up with bluetooth turned on. The switch should be left off.
         ArgumentCaptor<BroadcastReceiver> captor = ArgumentCaptor.forClass(BroadcastReceiver.class);
         when(mContext.registerReceiver(captor.capture(), any(IntentFilter.class))).thenReturn(null);
-        when(mBluetoothAdapter.getBluetoothState()).thenReturn(BluetoothAdapter.STATE_OFF);
+        mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_OFF);
         verify(mSwitchController, never()).setChecked(anyBoolean());
         mBluetoothEnabler.resume(mContext);
         verify(mSwitchController, never()).setChecked(anyBoolean());
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
index a4b2141..6491843 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
@@ -33,8 +33,8 @@
 
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settingslib.bluetooth.BluetoothDeviceFilter;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.widget.FooterPreference;
 
@@ -45,16 +45,17 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
 import androidx.preference.PreferenceGroup;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
 public class BluetoothPairingDetailTest {
 
     @Mock
     private Resources mResource;
-    @Mock
-    private LocalBluetoothAdapter mLocalAdapter;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private LocalBluetoothManager mLocalManager;
     @Mock
@@ -63,6 +64,8 @@
     private Context mContext;
     private BluetoothProgressCategory mAvailableDevicesCategory;
     private FooterPreference mFooterPreference;
+    private BluetoothAdapter mBluetoothAdapter;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
@@ -75,11 +78,13 @@
 
         mAvailableDevicesCategory = spy(new BluetoothProgressCategory(mContext));
         mFooterPreference = new FooterPreference(mContext);
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
 
-        mFragment.mLocalAdapter = mLocalAdapter;
+        mFragment.mBluetoothAdapter = mBluetoothAdapter;
         mFragment.mLocalManager = mLocalManager;
         mFragment.mDeviceListGroup = mPreferenceGroup;
-        mFragment.mAlwaysDiscoverable = new AlwaysDiscoverable(mContext, mLocalAdapter);
+        mFragment.mAlwaysDiscoverable = new AlwaysDiscoverable(mContext);
     }
 
     @Test
@@ -102,7 +107,7 @@
 
         mFragment.enableScanning();
 
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
         verify(mAvailableDevicesCategory).removeAll();
     }
 
@@ -117,7 +122,8 @@
         verify(mFragment).addDeviceCategory(mAvailableDevicesCategory,
                 R.string.bluetooth_preference_found_media_devices,
                 BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER, false);
-        verify(mLocalAdapter).setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
+        assertThat(mBluetoothAdapter.getScanMode())
+                .isEqualTo(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
     }
 
     @Test
@@ -129,16 +135,16 @@
 
     @Test
     public void testUpdateBluetooth_bluetoothOff_turnOnBluetooth() {
-        doReturn(false).when(mLocalAdapter).isEnabled();
+        mShadowBluetoothAdapter.setEnabled(false);
 
         mFragment.updateBluetooth();
 
-        verify(mLocalAdapter).enable();
+        assertThat(mBluetoothAdapter.isEnabled()).isTrue();
     }
 
     @Test
     public void testUpdateBluetooth_bluetoothOn_updateState() {
-        doReturn(true).when(mLocalAdapter).isEnabled();
+        mShadowBluetoothAdapter.setEnabled(true);
         doNothing().when(mFragment).updateContent(anyInt());
 
         mFragment.updateBluetooth();
@@ -157,27 +163,27 @@
         mFragment.updateContent(BluetoothAdapter.STATE_ON);
         verify(mFragment).enableScanning();
         assertThat(mAvailableDevicesCategory.getPreferenceCount()).isEqualTo(0);
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
 
         // Subsequent scan started event will not trigger start/stop nor list clear
         mFragment.onScanningStateChanged(true);
-        verify(mLocalAdapter, times(1)).startScanning(anyBoolean());
+        verify(mFragment, times(1)).startScanning();
         verify(mAvailableDevicesCategory, times(1)).setProgress(true);
 
         // Subsequent scan finished event will trigger scan start without list clean
         mFragment.onScanningStateChanged(false);
-        verify(mLocalAdapter, times(2)).startScanning(true);
+        verify(mFragment, times(2)).startScanning();
         verify(mAvailableDevicesCategory, times(2)).setProgress(true);
 
         // Subsequent scan started event will not trigger any change
         mFragment.onScanningStateChanged(true);
-        verify(mLocalAdapter, times(2)).startScanning(anyBoolean());
+        verify(mFragment, times(2)).startScanning();
         verify(mAvailableDevicesCategory, times(3)).setProgress(true);
-        verify(mLocalAdapter, never()).stopScanning();
+        verify(mFragment, never()).stopScanning();
 
         // Disable scanning will trigger scan stop
         mFragment.disableScanning();
-        verify(mLocalAdapter, times(1)).stopScanning();
+        verify(mFragment, times(1)).stopScanning();
 
         // Subsequent scan start event will not trigger any change besides progress circle
         mFragment.onScanningStateChanged(true);
@@ -187,8 +193,8 @@
         // progress circle from spinning
         mFragment.onScanningStateChanged(false);
         verify(mAvailableDevicesCategory, times(1)).setProgress(false);
-        verify(mLocalAdapter, times(2)).startScanning(anyBoolean());
-        verify(mLocalAdapter, times(1)).stopScanning();
+        verify(mFragment, times(2)).startScanning();
+        verify(mFragment, times(1)).stopScanning();
 
         // Verify that clean up only happen once at initialization
         verify(mAvailableDevicesCategory, times(1)).removeAll();
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
index f85a584..75361d7 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
@@ -29,10 +30,7 @@
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.SliceTester;
-import com.android.settings.testutils.shadow.ShadowLocalBluetoothAdapter;
 import com.android.settings.testutils.shadow.ShadowLocalBluetoothProfileManager;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -52,7 +50,7 @@
 import androidx.slice.widget.SliceLiveData;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowLocalBluetoothAdapter.class, ShadowLocalBluetoothProfileManager.class})
+@Config(shadows = {ShadowLocalBluetoothProfileManager.class})
 public class BluetoothSliceBuilderTest {
 
     private Context mContext;
@@ -90,11 +88,10 @@
 
     @Test
     public void handleUriChange_updatesBluetooth() {
-        final LocalBluetoothAdapter adapter = LocalBluetoothManager.getInstance(mContext,
-                null /* callback */).getBluetoothAdapter();
+        final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
         final Intent intent = new Intent();
         intent.putExtra(android.app.slice.Slice.EXTRA_TOGGLE_STATE, true);
-        adapter.setBluetoothEnabled(false /* enabled */);
+        adapter.disable()/* enabled */;
 
         BluetoothSliceBuilder.handleUriChange(mContext, intent);
 
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
index 2ac1ed8..2cab95b 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
@@ -23,7 +23,6 @@
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
@@ -31,8 +30,8 @@
 
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import org.junit.Before;
@@ -42,11 +41,14 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
 import java.util.HashSet;
 import java.util.Set;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
 public class BluetoothSummaryUpdaterTest {
 
     private static final String DEVICE_NAME = "Nightshade";
@@ -56,8 +58,6 @@
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private LocalBluetoothManager mBluetoothManager;
     @Mock
-    private LocalBluetoothAdapter mBtAdapter;
-    @Mock
     private BluetoothDevice mConnectedDevice;
     @Mock
     private BluetoothDevice mConnectedKeyBoardDevice;
@@ -72,16 +72,13 @@
     private final boolean[] mDeviceConnected = {false, false};
     private final Set<BluetoothDevice> mBondedDevices = new HashSet<>();
     private BluetoothSummaryUpdater mSummaryUpdater;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application.getApplicationContext();
         doCallRealMethod().when(mListener).onSummaryChanged(anyString());
-        // Setup mock adapter
-        when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBtAdapter);
-        doAnswer(invocation -> mAdapterEnabled[0]).when(mBtAdapter).isEnabled();
-        doAnswer(invocation -> mAdapterConnectionState[0]).when(mBtAdapter).getConnectionState();
         mSummaryUpdater = new BluetoothSummaryUpdater(mContext, mListener, mBluetoothManager);
         // Setup first device
         doReturn(DEVICE_NAME).when(mConnectedDevice).getName();
@@ -89,7 +86,11 @@
         // Setup second device
         doReturn(DEVICE_KEYBOARD_NAME).when(mConnectedKeyBoardDevice).getName();
         doAnswer(invocation -> mDeviceConnected[1]).when(mConnectedKeyBoardDevice).isConnected();
-        doReturn(mBondedDevices).when(mBtAdapter).getBondedDevices();
+        // Setup BluetoothAdapter
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
+        mShadowBluetoothAdapter.setEnabled(mAdapterEnabled[0]);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
+        mShadowBluetoothAdapter.setConnectionState(mAdapterConnectionState[0]);
     }
 
     @Test
@@ -108,9 +109,10 @@
 
     @Test
     public void register_true_shouldSendSummaryChange() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         mDeviceConnected[0] = true;
 
         mSummaryUpdater.register(true);
@@ -122,8 +124,9 @@
     @Test
     public void onBluetoothStateChanged_btDisabled_shouldSendDisabledSummary() {
         // These states should be ignored
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTED;
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         mDeviceConnected[0] = true;
 
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF);
@@ -133,9 +136,10 @@
 
     @Test
     public void onBluetoothStateChanged_btEnabled_connected_shouldSendConnectedSummary() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         mDeviceConnected[0] = true;
 
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
@@ -146,9 +150,10 @@
 
     @Test
     public void onBluetoothStateChanged_btEnabled_connectedMisMatch_shouldSendNotConnected() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         // State mismatch
         mDeviceConnected[0] = false;
 
@@ -159,9 +164,10 @@
 
     @Test
     public void onBluetoothStateChanged_btEnabled_notConnected_shouldSendDisconnectedMessage() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_DISCONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_DISCONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         // This should be ignored
         mDeviceConnected[0] = true;
 
@@ -172,22 +178,23 @@
 
     @Test
     public void onBluetoothStateChanged_ConnectedDisabledEnabled_shouldSendDisconnectedSummary() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_DISCONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_DISCONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         mDeviceConnected[0] = false;
 
         mSummaryUpdater.register(true);
         verify(mListener).onSummaryChanged(mContext.getString(R.string.disconnected));
 
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTED;
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTED);
         mDeviceConnected[0] = true;
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
                 BluetoothAdapter.STATE_CONNECTED);
         verify(mListener).onSummaryChanged(
                 mContext.getString(R.string.bluetooth_connected_summary, DEVICE_NAME));
 
-        mAdapterEnabled[0] = false;
+        mShadowBluetoothAdapter.setEnabled(false);
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF);
         verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
 
@@ -196,7 +203,7 @@
         // There should still be only one invocation of disabled message
         verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
 
-        mAdapterEnabled[0] = true;
+        mShadowBluetoothAdapter.setEnabled(true);
         mDeviceConnected[0] = false;
         mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
         verify(mListener, times(2)).onSummaryChanged(mContext.getString(R.string.disconnected));
@@ -205,9 +212,10 @@
 
     @Test
     public void onConnectionStateChanged_connected_shouldSendConnectedMessage() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         mDeviceConnected[0] = true;
 
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
@@ -219,9 +227,10 @@
 
     @Test
     public void onConnectionStateChanged_inconsistentState_shouldSendDisconnectedMessage() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_DISCONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_DISCONNECTED);
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         mDeviceConnected[0] = false;
 
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
@@ -232,8 +241,8 @@
 
     @Test
     public void onConnectionStateChanged_noBondedDevice_shouldSendDisconnectedMessage() {
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTED;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTED);
 
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
                 BluetoothAdapter.STATE_CONNECTED);
@@ -244,8 +253,8 @@
     @Test
     public void onConnectionStateChanged_connecting_shouldSendConnectingMessage() {
         // No need for bonded devices
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_CONNECTING;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_CONNECTING);
 
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
                 BluetoothAdapter.STATE_CONNECTING);
@@ -256,8 +265,8 @@
     @Test
     public void onConnectionStateChanged_disconnecting_shouldSendDisconnectingMessage() {
         // No need for bonded devices
-        mAdapterEnabled[0] = true;
-        mAdapterConnectionState[0] = BluetoothAdapter.STATE_DISCONNECTING;
+        mShadowBluetoothAdapter.setEnabled(true);
+        mShadowBluetoothAdapter.setConnectionState(BluetoothAdapter.STATE_DISCONNECTING);
 
         mSummaryUpdater.onConnectionStateChanged(null /* device */,
                 BluetoothAdapter.STATE_DISCONNECTING);
@@ -268,6 +277,7 @@
     @Test
     public void getConnectedDeviceSummary_hasConnectedDevice_returnOneDeviceSummary() {
         mBondedDevices.add(mConnectedDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
         mDeviceConnected[0] = true;
         final String expectedSummary =
             mContext.getString(R.string.bluetooth_connected_summary, DEVICE_NAME);
@@ -279,6 +289,8 @@
     public void getConnectedDeviceSummary_multipleDevices_returnMultipleDevicesSummary() {
         mBondedDevices.add(mConnectedDevice);
         mBondedDevices.add(mConnectedKeyBoardDevice);
+        mShadowBluetoothAdapter.setBondedDevices(mBondedDevices);
+
         mDeviceConnected[0] = true;
         mDeviceConnected[1] = true;
         final String expectedSummary =
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
index 9f9aaf4..cca9ff0 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSwitchPreferenceControllerTest.java
@@ -43,8 +43,6 @@
 
     public static final String BLUETOOTH_INFO_STRING = "When Bluetooth is turned on, your device"
             + " can communicate with other nearby Bluetooth devices.";
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private LocalBluetoothManager mBluetoothManager;
     @Mock
     private RestrictionUtils mRestrictionUtils;
     @Mock
@@ -62,7 +60,7 @@
         FakeFeatureFactory.setupForTest();
 
         mController =
-            new BluetoothSwitchPreferenceController(mContext, mBluetoothManager, mRestrictionUtils,
+            new BluetoothSwitchPreferenceController(mContext, mRestrictionUtils,
                     mSwitchController, mFooterPreference);
     }
 
diff --git a/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java
index 7aacd38..c64b904 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/DeviceListPreferenceFragmentTest.java
@@ -18,20 +18,20 @@
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.content.res.Resources;
 
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.core.AbstractPreferenceController;
 
 import org.junit.Before;
@@ -40,12 +40,14 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
 
 import java.util.List;
 
 import androidx.preference.Preference;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
 public class DeviceListPreferenceFragmentTest {
 
     private static final String FOOTAGE_MAC_STRING = "Bluetooth mac: xxxx";
@@ -54,8 +56,7 @@
     private Resources mResource;
     @Mock
     private Context mContext;
-    @Mock
-    private LocalBluetoothAdapter mLocalAdapter;
+
     private TestFragment mFragment;
     private Preference mMyDevicePreference;
 
@@ -66,7 +67,7 @@
         mFragment = spy(new TestFragment());
         doReturn(mContext).when(mFragment).getContext();
         doReturn(mResource).when(mFragment).getResources();
-        mFragment.mLocalAdapter = mLocalAdapter;
+        mFragment.mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
 
         mMyDevicePreference = new Preference(RuntimeEnvironment.application);
     }
@@ -84,11 +85,11 @@
     @Test
     public void testEnableDisableScanning_testStateAfterEanbleDisable() {
         mFragment.enableScanning();
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
         assertThat(mFragment.mScanEnabled).isTrue();
 
         mFragment.disableScanning();
-        verify(mLocalAdapter).stopScanning();
+        verify(mFragment).stopScanning();
         assertThat(mFragment.mScanEnabled).isFalse();
     }
 
@@ -96,21 +97,21 @@
     public void testScanningStateChanged_testScanStarted() {
         mFragment.enableScanning();
         assertThat(mFragment.mScanEnabled).isTrue();
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
 
         mFragment.onScanningStateChanged(true);
-        verify(mLocalAdapter, times(1)).startScanning(anyBoolean());
+        verify(mFragment, times(1)).startScanning();
     }
 
     @Test
     public void testScanningStateChanged_testScanFinished() {
         // Could happen when last scanning not done while current scan gets enabled
         mFragment.enableScanning();
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
         assertThat(mFragment.mScanEnabled).isTrue();
 
         mFragment.onScanningStateChanged(false);
-        verify(mLocalAdapter, times(2)).startScanning(true);
+        verify(mFragment, times(2)).startScanning();
     }
 
     @Test
@@ -118,53 +119,53 @@
         // Could happen when last scanning not done while current scan gets enabled
         mFragment.enableScanning();
         assertThat(mFragment.mScanEnabled).isTrue();
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
 
         mFragment.onScanningStateChanged(true);
-        verify(mLocalAdapter, times(1)).startScanning(anyBoolean());
+        verify(mFragment, times(1)).startScanning();
 
         mFragment.onScanningStateChanged(false);
-        verify(mLocalAdapter, times(2)).startScanning(true);
+        verify(mFragment, times(2)).startScanning();
 
         mFragment.onScanningStateChanged(true);
-        verify(mLocalAdapter, times(2)).startScanning(anyBoolean());
+        verify(mFragment, times(2)).startScanning();
 
         mFragment.disableScanning();
-        verify(mLocalAdapter).stopScanning();
+        verify(mFragment).stopScanning();
 
         mFragment.onScanningStateChanged(false);
-        verify(mLocalAdapter, times(2)).startScanning(anyBoolean());
+        verify(mFragment, times(2)).startScanning();
 
         mFragment.onScanningStateChanged(true);
-        verify(mLocalAdapter, times(2)).startScanning(anyBoolean());
+        verify(mFragment, times(2)).startScanning();
     }
 
     @Test
     public void testScanningStateChanged_testScanFinishedAfterDisable() {
         mFragment.enableScanning();
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
         assertThat(mFragment.mScanEnabled).isTrue();
 
         mFragment.disableScanning();
-        verify(mLocalAdapter).stopScanning();
+        verify(mFragment).stopScanning();
         assertThat(mFragment.mScanEnabled).isFalse();
 
         mFragment.onScanningStateChanged(false);
-        verify(mLocalAdapter, times(1)).startScanning(anyBoolean());
+        verify(mFragment, times(1)).startScanning();
     }
 
     @Test
     public void testScanningStateChanged_testScanStartedAfterDisable() {
         mFragment.enableScanning();
-        verify(mLocalAdapter).startScanning(true);
+        verify(mFragment).startScanning();
         assertThat(mFragment.mScanEnabled).isTrue();
 
         mFragment.disableScanning();
-        verify(mLocalAdapter).stopScanning();
+        verify(mFragment).stopScanning();
         assertThat(mFragment.mScanEnabled).isFalse();
 
         mFragment.onScanningStateChanged(true);
-        verify(mLocalAdapter, times(1)).startScanning(anyBoolean());
+        verify(mFragment, times(1)).startScanning();
     }
 
     /**
diff --git a/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
index 2533341..49d72fb 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
@@ -30,7 +30,6 @@
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
 import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.testutils.FragmentTestUtils;
 
@@ -51,10 +50,6 @@
 public class LocalDeviceNameDialogFragmentTest {
 
     @Mock
-    private LocalBluetoothManager mManager;
-    @Mock
-    private LocalBluetoothAdapter mAdapter;
-    @Mock
     private InputMethodManager mInputMethodManager;
 
     private Context mContext;
@@ -65,8 +60,6 @@
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
         doReturn(mInputMethodManager).when(mContext).getSystemService(Context.INPUT_METHOD_SERVICE);
-        ReflectionHelpers.setStaticField(LocalBluetoothManager.class, "sInstance", mManager);
-        when(mManager.getBluetoothAdapter()).thenReturn(mAdapter);
 
         mFragment = spy(LocalDeviceNameDialogFragment.newInstance());
         when(mFragment.getContext()).thenReturn(mContext);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index a88d8ff..def8c4d 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -68,6 +68,7 @@
         doReturn(mContext).when(mDashboardFragment).getContext();
         when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
         when(mLocalManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
+        when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
 
         mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mDashboardFragment,
                 mDevicePreferenceCallback, mLocalManager));
@@ -99,6 +100,8 @@
 
     @Test
     public void onProfileConnectionStateChanged_deviceConnected_removePreference() {
+        when(mBluetoothDevice.isConnected()).thenReturn(true);
+
         mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
                 BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
 
@@ -107,6 +110,8 @@
 
     @Test
     public void onProfileConnectionStateChanged_deviceDisconnected_addPreference() {
+        when(mBluetoothDevice.isConnected()).thenReturn(false);
+
         mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
                 BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
 
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java
index 4c7cd51..e6ef2d9 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/DiscoverableFooterPreferenceControllerTest.java
@@ -35,7 +35,6 @@
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settings.testutils.shadow.ShadowBluetoothPan;
-import com.android.settings.testutils.shadow.ShadowLocalBluetoothAdapter;
 import com.android.settingslib.widget.FooterPreference;
 import com.android.settingslib.widget.FooterPreferenceMixinCompat;
 
@@ -47,6 +46,7 @@
 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;
@@ -55,8 +55,7 @@
 import androidx.preference.PreferenceScreen;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {ShadowBluetoothPan.class, ShadowBluetoothAdapter.class,
-        ShadowLocalBluetoothAdapter.class})
+@Config(shadows = {ShadowBluetoothPan.class, ShadowBluetoothAdapter.class})
 public class DiscoverableFooterPreferenceControllerTest {
     private static final String DEVICE_NAME = "device name";
     private static final String KEY = "discoverable_footer_preference";
@@ -75,6 +74,7 @@
     private DiscoverableFooterPreferenceController mDiscoverableFooterPreferenceController;
     private BroadcastReceiver mBluetoothChangedReceiver;
     private ShadowApplication mShadowApplication;
+    private ShadowBluetoothAdapter mShadowBluetoothAdapter;
 
     @Before
     public void setUp() {
@@ -90,6 +90,7 @@
                 mAlwaysDiscoverable);
         mBluetoothChangedReceiver = mDiscoverableFooterPreferenceController
                 .mBluetoothChangedReceiver;
+        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
     }
 
     @Test
@@ -135,7 +136,7 @@
 
     @Test
     public void onBluetoothStateChanged_bluetoothOn_updateTitle() {
-        ShadowLocalBluetoothAdapter.setName(DEVICE_NAME);
+        mShadowBluetoothAdapter.setName(DEVICE_NAME);
         sendBluetoothStateChangedIntent(BluetoothAdapter.STATE_ON);
 
         assertThat(mPreference.getTitle()).isEqualTo(generateTitle(DEVICE_NAME));
@@ -143,7 +144,7 @@
 
     @Test
     public void onBluetoothStateChanged_bluetoothOff_updateTitle(){
-        ShadowLocalBluetoothAdapter.setName(DEVICE_NAME);
+        mShadowBluetoothAdapter.setName(DEVICE_NAME);
         sendBluetoothStateChangedIntent(BluetoothAdapter.STATE_OFF);
 
         assertThat(mPreference.getTitle()).isEqualTo(generateTitle(null));
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java
index 68b48a8..3ca06aa 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/DeviceNamePreferenceControllerTest.java
@@ -20,11 +20,10 @@
 import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.bluetooth.BluetoothAdapter;
 import android.content.Context;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
@@ -32,14 +31,12 @@
 import android.provider.Settings;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settings.widget.ValidatedEditTextPreference;
-import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Answers;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
@@ -49,20 +46,18 @@
 import androidx.preference.PreferenceScreen;
 
 @RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
 public class DeviceNamePreferenceControllerTest {
     private static final String TESTING_STRING = "Testing";
 
     @Mock
-    private LocalBluetoothAdapter mBluetoothAdapter;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private LocalBluetoothManager mBluetoothManager;
-    @Mock
     private WifiManager mWifiManager;
     @Mock
     private PreferenceScreen mScreen;
     private ValidatedEditTextPreference mPreference;
     private DeviceNamePreferenceController mController;
     private Context mContext;
+    private BluetoothAdapter mBluetoothAdapter;
 
 
     @Before
@@ -72,14 +67,13 @@
         shadowApplication.setSystemService(Context.WIFI_SERVICE, mWifiManager);
         mContext = shadowApplication.getApplicationContext();
         mPreference = new ValidatedEditTextPreference(mContext);
-        when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
         when(mScreen.findPreference(anyString())).thenReturn(mPreference);
         final WifiConfiguration configuration = new WifiConfiguration();
         configuration.SSID = "test-ap";
         when(mWifiManager.getWifiApConfiguration()).thenReturn(configuration);
 
         mController = new DeviceNamePreferenceController(mContext);
-        mController.setLocalBluetoothManager(mBluetoothManager);
+        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
     }
 
     @Test
@@ -103,7 +97,6 @@
         Settings.Global.putString(
                 mContext.getContentResolver(), Settings.Global.DEVICE_NAME, "Test");
         mController = new DeviceNamePreferenceController(mContext);
-        mController.setLocalBluetoothManager(mBluetoothManager);
         assertThat(mController.getSummary()).isEqualTo("Test");
     }
 
@@ -132,7 +125,7 @@
         mController.displayPreference(mScreen);
         mController.onPreferenceChange(mPreference, TESTING_STRING);
 
-        verify(mBluetoothAdapter).setName(eq(TESTING_STRING));
+        assertThat(mBluetoothAdapter.getName()).isEqualTo(TESTING_STRING);
     }
 
     @Test
@@ -155,10 +148,11 @@
 
     @Test
     public void setDeviceName_ignoresIfCancelPressed() {
+        forceAcceptDeviceName();
         mController.displayPreference(mScreen);
         mController.onPreferenceChange(mPreference, TESTING_STRING);
 
-        verify(mBluetoothAdapter, never()).setName(eq(TESTING_STRING));
+        assertThat(mBluetoothAdapter.getName()).isEqualTo(TESTING_STRING);
     }
 
     private void forceAcceptDeviceName() {
diff --git a/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java
index d54ef6f..2796049 100644
--- a/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ChargingSoundPreferenceControllerTest.java
@@ -17,13 +17,14 @@
 package com.android.settings.notification;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.ContentResolver;
 import android.content.Context;
-import android.provider.Settings.Global;
+import android.provider.Settings.Secure;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
@@ -80,7 +81,7 @@
 
     @Test
     public void displayPreference_chargingSoundEnabled_shouldCheckedPreference() {
-        Global.putInt(mContentResolver, Global.CHARGING_SOUNDS_ENABLED, 1);
+        Secure.putInt(mContentResolver, Secure.CHARGING_SOUNDS_ENABLED, 1);
 
         mController.displayPreference(mScreen);
 
@@ -89,7 +90,7 @@
 
     @Test
     public void displayPreference_chargingSoundDisabled_shouldUncheckedPreference() {
-        Global.putInt(mContentResolver, Global.CHARGING_SOUNDS_ENABLED, 0);
+        Secure.putInt(mContentResolver, Secure.CHARGING_SOUNDS_ENABLED, 0);
 
         mController.displayPreference(mScreen);
 
@@ -102,7 +103,7 @@
 
         mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, true);
 
-        assertThat(Global.getInt(mContentResolver, Global.CHARGING_SOUNDS_ENABLED, 1))
+        assertThat(Secure.getInt(mContentResolver, Secure.CHARGING_SOUNDS_ENABLED, 1))
             .isEqualTo(1);
     }
 
@@ -112,7 +113,7 @@
 
         mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, false);
 
-        assertThat(Global.getInt(mContentResolver, Global.CHARGING_SOUNDS_ENABLED, 1))
+        assertThat(Secure.getInt(mContentResolver, Secure.CHARGING_SOUNDS_ENABLED, 1))
             .isEqualTo(0);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java
index b748bcb..bbb2142 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeDurationPreferenceControllerTest.java
@@ -78,8 +78,8 @@
 
     @Test
     public void updateState_DurationForever() {
-        Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
-                Settings.Global.ZEN_DURATION_FOREVER);
+        Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
+                Settings.Secure.ZEN_DURATION_FOREVER);
         final Preference mockPref = mock(Preference.class);
         mController.updateState(mockPref);
 
@@ -88,8 +88,8 @@
 
     @Test
     public void updateState_DurationPrompt() {
-        Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
-                Settings.Global.ZEN_DURATION_PROMPT);
+        Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
+                Settings.Secure.ZEN_DURATION_PROMPT);
         final Preference mockPref = mock(Preference.class);
         mController.updateState(mockPref);
 
@@ -100,7 +100,7 @@
     @Test
     public void updateState_DurationCustom() {
         int zenDuration = 45;
-        Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
+        Settings.Secure.putInt(mContentResolver, Settings.Secure.ZEN_DURATION,
                 zenDuration);
         final Preference mockPref = mock(Preference.class);
         mController.updateState(mockPref);
diff --git a/tests/robotests/src/com/android/settings/notification/ZenOnboardingActivityTest.java b/tests/robotests/src/com/android/settings/notification/ZenOnboardingActivityTest.java
index 5846833..5b031aa 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenOnboardingActivityTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenOnboardingActivityTest.java
@@ -177,16 +177,16 @@
         setShowSettingsSuggestion(true);
         setWithinTimeThreshold(true);
         assertThat(isSuggestionComplete(mContext)).isTrue();
-        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.ZEN_SETTINGS_UPDATED, -1)).isEqualTo(1);
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ZEN_SETTINGS_UPDATED, -1)).isEqualTo(1);
     }
 
 
     private void setZenUpdated(boolean updated) {
         int zenUpdated = updated ? 1 : 0;
 
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.ZEN_SETTINGS_UPDATED, zenUpdated);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ZEN_SETTINGS_UPDATED, zenUpdated);
     }
 
     private void setWithinTimeThreshold(boolean withinTime) {
@@ -208,8 +208,8 @@
             showZenSuggestion = 1;
         }
 
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.SHOW_ZEN_SETTINGS_SUGGESTION, showZenSuggestion);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION, showZenSuggestion);
     }
 
     private SharedPreferences getSharedPreferences() {
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
index 24a45da..369cb3c 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java
@@ -18,19 +18,54 @@
 
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.provider.Settings.Global;
 
 import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
 
+import androidx.fragment.app.FragmentActivity;
+
+import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class ChooseLockGenericTest {
 
+    @After
+    public void tearDown() {
+        Global.putInt(RuntimeEnvironment.application.getContentResolver(),
+            Global.DEVICE_PROVISIONED, 1);
+    }
+
+    @Test
+    @Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
+    public void onCreate_deviceNotProvisioned_shouldFinishActivity() {
+        final Context context = RuntimeEnvironment.application;
+        Global.putInt(context.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
+        final FragmentActivity activity = mock(FragmentActivity.class);
+        when(activity.getContentResolver()).thenReturn(context.getContentResolver());
+        when(activity.getTheme()).thenReturn(context.getTheme());
+
+        final ChooseLockGenericFragment fragment = spy(new ChooseLockGenericFragment());
+        when(fragment.getActivity()).thenReturn(activity);
+        when(fragment.getArguments()).thenReturn(Bundle.EMPTY);
+
+        fragment.onCreate(Bundle.EMPTY);
+        verify(activity).finish();
+    }
+
     @Test
     public void onActivityResult_nullIntentData_shouldNotCrash() {
         ChooseLockGenericFragment fragment = spy(new ChooseLockGenericFragment());
diff --git a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
index b36769d..394d5f4 100644
--- a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
@@ -17,11 +17,14 @@
 package com.android.settings.search.actionbar;
 
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
+import android.content.Context;
 import android.os.Bundle;
+import android.provider.Settings.Global;
 import android.view.Menu;
 import android.view.MenuItem;
 
@@ -35,6 +38,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 public class SearchMenuControllerTest {
@@ -43,12 +47,16 @@
     private Menu mMenu;
     private TestPreferenceFragment mPreferenceHost;
     private ObservableFragment mHost;
+    private Context mContext;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mHost = new ObservableFragment();
+        mContext = RuntimeEnvironment.application;
+        mHost = spy(new ObservableFragment());
+        when(mHost.getContext()).thenReturn(mContext);
         mPreferenceHost = new TestPreferenceFragment();
+        Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 1);
 
         when(mMenu.add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu))
                 .thenReturn(mock(MenuItem.class));
@@ -81,9 +89,23 @@
         verifyZeroInteractions(mMenu);
     }
 
+    @Test
+    public void init_deviceNotProvisioned_shouldNotAddMenu() {
+        Global.putInt(mContext.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
+        SearchMenuController.init(mHost);
+        mHost.getSettingsLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
+
+        verifyZeroInteractions(mMenu);
+    }
+
     private static class TestPreferenceFragment extends ObservablePreferenceFragment {
         @Override
         public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
         }
+
+        @Override
+        public Context getContext() {
+            return RuntimeEnvironment.application;
+        }
     }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java b/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
index 98693e3..ad808fc 100644
--- a/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
+++ b/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
@@ -84,9 +84,9 @@
             paths.add(new ResourcePath(null,
                 Fs.fromURL(new URL("file:frameworks/opt/setupwizard/library/recyclerview/res")), null));
             paths.add(new ResourcePath(null,
-                Fs.fromURL(new URL("file:frameworks/support/appcompat/res")), null));
+                Fs.fromURL(new URL("file:out/soong/.intermediates/prebuilts/sdk/current/androidx/androidx.appcompat_appcompat-nodeps/android_common/aar/res/")), null));
             paths.add(new ResourcePath(null,
-                Fs.fromURL(new URL("file:frameworks/support/cardview/res")), null));
+                Fs.fromURL(new URL("file:out/soong/.intermediates/prebuilts/sdk/current/androidx/androidx.cardview_cardview-nodeps/android_common/aar/res")), null));
         } catch (MalformedURLException e) {
             throw new RuntimeException("SettingsRobolectricTestRunner failure", e);
         }
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 2bd2ec3..91afb87 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java
@@ -26,6 +26,11 @@
 
 @Implements(value = BluetoothAdapter.class, inheritImplementationMethods = true)
 public class ShadowBluetoothAdapter extends org.robolectric.shadows.ShadowBluetoothAdapter {
+
+    private String mName;
+    private int mScanMode;
+    private int mState;
+
     /**
      * Do nothing, implement it to avoid null pointer error inside BluetoothAdapter
      */
@@ -33,4 +38,32 @@
     public List<Integer> getSupportedProfiles() {
         return new ArrayList<Integer>();
     }
+
+    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;
+    }
+
+    public void setConnectionState(int state) {
+        mState = state;
+    }
 }