Merge "Add null check for CarrierConfig"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6cb0023..70dce8f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -41,7 +41,7 @@
     <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
-    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
     <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>
     <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
     <uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
@@ -443,7 +443,7 @@
             android:exported="true"
             android:permission="android.permission.TETHER_PRIVILEGED" />
 
-        <activity android:name="network.TetherProvisioningActivity"
+        <activity android:name=".network.TetherProvisioningActivity"
             android:exported="true"
             android:permission="android.permission.TETHER_PRIVILEGED"
             android:excludeFromRecents="true"
diff --git a/res/drawable/ic_airplanemode_active.xml b/res/drawable/ic_airplanemode_active.xml
index 10dd7ed..7ade8b2 100644
--- a/res/drawable/ic_airplanemode_active.xml
+++ b/res/drawable/ic_airplanemode_active.xml
@@ -20,9 +20,6 @@
         android:viewportHeight="24.0"
         android:tint="?android:attr/colorControlNormal">
     <path
-        android:pathData="M20.8,13.56L13.5,9V3.5C13.5,2.67,12.83,2,12,2s-1.5,0.67-1.5,1.5V9l-7.3,4.56c-0.43,0.27-0.7,0.75-0.7,1.27v0.49
-c0,0.34,0.33,0.58,0.65,0.48l7.35-2.3V19l-1.6,1.2c-0.25,0.19-0.4,0.49-0.4,0.8v0.67c0,0.17,0.14,0.28,0.31,0.24
-c1.94-0.55,1.3-0.37,3.19-0.91c1.21,0.35,1.99,0.57,3.19,0.91c0.17,0.04,0.31-0.07,0.31-0.24V21c0-0.31-0.15-0.61-0.4-0.8L13.5,19
-v-5.5l7.35,2.3c0.32,0.1,0.65-0.14,0.65-0.48v-0.49C21.5,14.31,21.23,13.83,20.8,13.56z"
+        android:pathData="M21,16v-2l-8,-5V3.5C13,2.67 12.33,2 11.5,2S10,2.67 10,3.5V9l-8,5v2l8,-2.5V19l-2,1.5V22l3.5,-1l3.5,1v-1.5L13,19v-5.5L21,16z"
         android:fillColor="#FFFFFFFF"/>
 </vector>
diff --git a/res/drawable/ic_battery_saver_accent_24dp.xml b/res/drawable/ic_battery_saver_accent_24dp.xml
index c8def54..764402d 100644
--- a/res/drawable/ic_battery_saver_accent_24dp.xml
+++ b/res/drawable/ic_battery_saver_accent_24dp.xml
@@ -22,8 +22,8 @@
         android:tint="?android:attr/colorAccent">
     <path
         android:fillColor="#FF000000"
-        android:pathData="M15,14l-2,0l0,2l-2,0l0,-2l-2,0l0,-2l2,0l0,-2l2,0l0,2l2,0z"/>
+        android:pathData="M16.67,4H14.5V2h-5v2H7.33C6.6,4 6,4.6 6,5.33V15v5.67C6,21.4 6.6,22 7.33,22h9.33C17.4,22 18,21.4 18,20.67V15V5.33C18,4.6 17.4,4 16.67,4zM16,15v5H8v-5V6h8V15z"/>
     <path
         android:fillColor="#FF000000"
-        android:pathData="M16.2,22.5H7.8c-1.3,0 -2.3,-1 -2.3,-2.3V5.8c0,-1.3 1,-2.3 2.3,-2.3h0.7v-2h7v2h0.7c1.3,0 2.3,1.1 2.3,2.3v14.3C18.5,21.5 17.5,22.5 16.2,22.5zM7.8,5.5c-0.2,0 -0.3,0.2 -0.3,0.3v14.3c0,0.2 0.2,0.3 0.3,0.3h8.3c0.2,0 0.3,-0.1 0.3,-0.3V5.8c0,-0.2 -0.1,-0.3 -0.3,-0.3h-2.7v-2h-3v2H7.8z"/>
+        android:pathData="M15,12l-2,0l0,-2l-2,0l0,2l-2,0l0,2l2,0l0,2l2,0l0,-2l2,0z"/>
 </vector>
diff --git a/res/drawable/ic_friction_lock_closed.xml b/res/drawable/ic_friction_lock_closed.xml
index 56256a9..2f035e7 100644
--- a/res/drawable/ic_friction_lock_closed.xml
+++ b/res/drawable/ic_friction_lock_closed.xml
@@ -15,11 +15,11 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:viewportWidth="48"
-        android:viewportHeight="48"
-        android:width="18dp"
-        android:height="18dp">
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
     <path
-        android:pathData="M36 16l-2 0 0 -4C34 6.48 29.52 2 24 2 18.48 2 14 6.48 14 12l0 4 -2 0c-2.21 0 -4 1.79 -4 4l0 20c0 2.21 1.79 4 4 4l24 0c2.21 0 4 -1.79 4 -4l0 -20c0 -2.21 -1.79 -4 -4 -4zM24 34c-2.21 0 -4 -1.79 -4 -4 0 -2.21 1.79 -4 4 -4 2.21 0 4 1.79 4 4 0 2.21 -1.79 4 -4 4zm6.2 -18l-12.4 0 0 -4c0 -3.42 2.78 -6.2 6.2 -6.2 3.42 0 6.2 2.78 6.2 6.2l0 4z"
-        android:fillColor="?android:attr/colorControlNormal" />
+        android:fillColor="?android:attr/colorControlNormal"
+        android:pathData="M18,8h-1V6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2H6c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V10C20,8.9 19.1,8 18,8zM9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2H9V6zM18,20H6V10h12V20zM12,17c1.1,0 2,-0.9 2,-2c0,-1.1 -0.9,-2 -2,-2c-1.1,0 -2,0.9 -2,2C10,16.1 10.9,17 12,17z"/>
 </vector>
diff --git a/res/drawable/ic_settings.xml b/res/drawable/ic_settings.xml
deleted file mode 100644
index 3d8563d..0000000
--- a/res/drawable/ic_settings.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!--
-     Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24.0"
-    android:viewportHeight="24.0"
-    android:tint="?android:attr/colorAccent">
-    <path
-        android:fillColor="#FF000000"
-        android:pathData="M21.4 14.2l-1.94-1.45c.03-.25 .04 -.5 .04 -.76s-.01-.51-.04-.76L21.4 9.8c.42-.31
-.52 -.94 .24 -1.41l-1.6-2.76c-.28-.48-.88-.7-1.36-.5l-2.14 .91
-c-.48-.37-1.01-.68-1.57-.92l-.27-2.2c-.06-.52-.56-.92-1.11-.92h-3.18c-.55 0-1.05
-.4 -1.11 .92 l-.26 2.19c-.57 .24 -1.1 .55 -1.58 .92 l-2.14-.91c-.48-.2-1.08 .02
--1.36 .5 l-1.6 2.76c-.28 .48 -.18 1.1 .24 1.42l1.94 1.45c-.03 .24 -.04 .49 -.04
-.75 s.01 .51 .04 .76 L2.6 14.2c-.42 .31 -.52 .94 -.24 1.41l1.6 2.76c.28 .48 .88
-.7 1.36 .5 l2.14-.91c.48 .37 1.01 .68 1.57 .92 l.27 2.19c.06 .53 .56 .93 1.11
-.93 h3.18c.55 0 1.04-.4 1.11-.92l.27-2.19c.56-.24 1.09-.55 1.57-.92l2.14 .91
-c.48 .2 1.08-.02 1.36-.5l1.6-2.76c.28-.48 .18 -1.1-.24-1.42zM12 15.5c-1.93
-0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"/>
-</vector>
diff --git a/res/drawable/ic_settings_accent.xml b/res/drawable/ic_settings_accent.xml
new file mode 100644
index 0000000..7d871bc
--- /dev/null
+++ b/res/drawable/ic_settings_accent.xml
@@ -0,0 +1,29 @@
+<!--
+     Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorAccent">
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M13.85,22.25h-3.7c-0.74,0 -1.36,-0.54 -1.45,-1.27l-0.27,-1.89c-0.27,-0.14 -0.53,-0.29 -0.79,-0.46l-1.8,0.72c-0.7,0.26 -1.47,-0.03 -1.81,-0.65L2.2,15.53c-0.35,-0.66 -0.2,-1.44 0.36,-1.88l1.53,-1.19c-0.01,-0.15 -0.02,-0.3 -0.02,-0.46c0,-0.15 0.01,-0.31 0.02,-0.46l-1.52,-1.19C1.98,9.9 1.83,9.09 2.2,8.47l1.85,-3.19c0.34,-0.62 1.11,-0.9 1.79,-0.63l1.81,0.73c0.26,-0.17 0.52,-0.32 0.78,-0.46l0.27,-1.91c0.09,-0.7 0.71,-1.25 1.44,-1.25h3.7c0.74,0 1.36,0.54 1.45,1.27l0.27,1.89c0.27,0.14 0.53,0.29 0.79,0.46l1.8,-0.72c0.71,-0.26 1.48,0.03 1.82,0.65l1.84,3.18c0.36,0.66 0.2,1.44 -0.36,1.88l-1.52,1.19c0.01,0.15 0.02,0.3 0.02,0.46s-0.01,0.31 -0.02,0.46l1.52,1.19c0.56,0.45 0.72,1.23 0.37,1.86l-1.86,3.22c-0.34,0.62 -1.11,0.9 -1.8,0.63l-1.8,-0.72c-0.26,0.17 -0.52,0.32 -0.78,0.46l-0.27,1.91C15.21,21.71 14.59,22.25 13.85,22.25zM13.32,20.72c0,0.01 0,0.01 0,0.02L13.32,20.72zM10.68,20.7l0,0.02C10.69,20.72 10.69,20.71 10.68,20.7zM10.62,20.25h2.76l0.37,-2.55l0.53,-0.22c0.44,-0.18 0.88,-0.44 1.34,-0.78l0.45,-0.34l2.38,0.96l1.38,-2.4l-2.03,-1.58l0.07,-0.56c0.03,-0.26 0.06,-0.51 0.06,-0.78c0,-0.27 -0.03,-0.53 -0.06,-0.78l-0.07,-0.56l2.03,-1.58l-1.39,-2.4l-2.39,0.96l-0.45,-0.35c-0.42,-0.32 -0.87,-0.58 -1.33,-0.77L13.75,6.3l-0.37,-2.55h-2.76L10.25,6.3L9.72,6.51C9.28,6.7 8.84,6.95 8.38,7.3L7.93,7.63L5.55,6.68L4.16,9.07l2.03,1.58l-0.07,0.56C6.09,11.47 6.06,11.74 6.06,12c0,0.26 0.02,0.53 0.06,0.78l0.07,0.56l-2.03,1.58l1.38,2.4l2.39,-0.96l0.45,0.35c0.43,0.33 0.86,0.58 1.33,0.77l0.53,0.22L10.62,20.25zM18.22,17.72c0,0.01 -0.01,0.02 -0.01,0.03L18.22,17.72zM5.77,17.71l0.01,0.02C5.78,17.72 5.77,17.71 5.77,17.71zM3.93,9.47L3.93,9.47C3.93,9.47 3.93,9.47 3.93,9.47zM18.22,6.27c0,0.01 0.01,0.02 0.01,0.02L18.22,6.27zM5.79,6.25L5.78,6.27C5.78,6.27 5.79,6.26 5.79,6.25zM13.31,3.28c0,0.01 0,0.01 0,0.02L13.31,3.28zM10.69,3.26l0,0.02C10.69,3.27 10.69,3.27 10.69,3.26z"/>
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M12,12m-3.5,0a3.5,3.5 0,1 1,7 0a3.5,3.5 0,1 1,-7 0"/>
+</vector>
diff --git a/res/drawable/ic_settings_night_display.xml b/res/drawable/ic_settings_night_display.xml
index 3292ed4..4cd1347 100644
--- a/res/drawable/ic_settings_night_display.xml
+++ b/res/drawable/ic_settings_night_display.xml
@@ -21,5 +21,5 @@
         android:viewportWidth="24">
     <path
         android:fillColor="#FF000000"
-        android:pathData="M15.5,22c1.05,0 2.05,-0.16 3,-0.46c-4.06,-1.27 -7,-5.06 -7,-9.54s2.94,-8.27 7,-9.54C17.55,2.16 16.55,2 15.5,2c-5.52,0 -10,4.48 -10,10S9.98,22 15.5,22L15.5,22z"/>
+        android:pathData="M6.28,4.81c0,0.16 0.01,0.32 0.02,0.48c0.38,6.58 5.83,12.03 12.41,12.41c0.16,0.01 0.32,0.02 0.47,0.02c-1.58,1.2 -3.53,1.88 -5.56,1.88c-0.46,0 -0.93,-0.03 -1.4,-0.1c-3.96,-0.58 -7.13,-3.75 -7.71,-7.71C4.13,9.24 4.8,6.75 6.28,4.81M8.27,0.6c-0.08,0 -0.17,0.02 -0.25,0.07c-3.8,2.2 -6.2,6.56 -5.49,11.4c0.7,4.82 4.59,8.7 9.4,9.4c0.57,0.08 1.13,0.12 1.69,0.12c4.15,0 7.78,-2.26 9.72,-5.62c0.2,-0.35 -0.07,-0.76 -0.44,-0.76c-0.05,0 -0.1,0.01 -0.15,0.02c-1.03,0.31 -2.12,0.48 -3.25,0.48c-0.22,0 -0.44,-0.01 -0.67,-0.02C13.23,15.38 8.62,10.77 8.29,5.17C8.21,3.81 8.38,2.49 8.75,1.26C8.86,0.91 8.59,0.6 8.27,0.6L8.27,0.6z"/>
 </vector>
diff --git a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml b/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
deleted file mode 100644
index 070b9a1..0000000
--- a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<!-- Variant of progress_indeterminate_horizontal_material in frameworks/base/core/res, which
-     draws the whole height of the progress bar instead having blank space above and below the
-     bar. -->
-<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:drawable="@drawable/vector_drawable_progress_indeterminate_horizontal_trimmed" >
-    <target
-        android:name="rect2_grp"
-        android:animation="@*android:anim/progress_indeterminate_horizontal_rect2" />
-    <target
-        android:name="rect1_grp"
-        android:animation="@*android:anim/progress_indeterminate_horizontal_rect1" />
-</animated-vector>
diff --git a/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml b/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
deleted file mode 100644
index 39e3a37..0000000
--- a/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<!-- Variant of vector_drawable_progress_indeterminate_horizontal in frameworks/base/core/res, which
-     draws the whole height of the progress bar instead having blank space above and below the
-     bar. -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:height="10dp"
-    android:width="360dp"
-    android:viewportHeight="10"
-    android:viewportWidth="360" >
-    <group
-        android:name="progress_group"
-        android:translateX="180"
-        android:translateY="5" >
-        <path
-            android:name="background_track"
-            android:pathData="M -180.0,-5.0 l 360.0,0 l 0,10.0 l -360.0,0 Z"
-            android:fillColor="?android:attr/colorControlActivated"
-            android:fillAlpha="?android:attr/disabledAlpha"/>
-        <group
-            android:name="rect2_grp"
-            android:translateX="-197.60001"
-            android:scaleX="0.1" >
-            <path
-                android:name="rect2"
-                android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
-                android:fillColor="?android:attr/colorControlActivated" />
-        </group>
-        <group
-            android:name="rect1_grp"
-            android:translateX="-522.59998"
-            android:scaleX="0.1" >
-            <path
-                android:name="rect1"
-                android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
-                android:fillColor="?android:attr/colorControlActivated" />
-        </group>
-    </group>
-</vector>
diff --git a/res/layout-land/storage_summary_donut.xml b/res/layout-land/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-land/storage_summary_donut.xml
+++ b/res/layout-land/storage_summary_donut.xml
@@ -18,7 +18,6 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="?android:attr/colorPrimary"
     android:gravity="center_vertical"
     android:orientation="horizontal" >
 
diff --git a/res/layout-sw360dp/homepage_condition_full_tile.xml b/res/layout-sw360dp/homepage_condition_full_tile.xml
deleted file mode 100644
index e1c7b01..0000000
--- a/res/layout-sw360dp/homepage_condition_full_tile.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2018 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<com.google.android.material.card.MaterialCardView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    style="@style/ContextualCardStyle">
-
-    <LinearLayout
-        android:id="@+id/content"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="@dimen/homepage_card_padding_start"
-        android:paddingEnd="@dimen/homepage_full_card_padding_end"
-        android:paddingTop="@dimen/homepage_condition_full_card_padding_top"
-        android:paddingBottom="@dimen/homepage_condition_full_card_padding_bottom"
-        android:orientation="horizontal"
-        android:gravity="center_vertical">
-
-        <ImageView
-            android:id="@android:id/icon"
-            android:layout_width="@dimen/homepage_card_icon_size"
-            android:layout_height="@dimen/homepage_card_icon_size"
-            android:tint="?android:attr/colorAccent"/>
-
-        <LinearLayout
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:paddingStart="@dimen/homepage_condition_full_card_padding_start"
-            android:paddingEnd="@dimen/homepage_condition_full_card_padding_end"
-            android:orientation="vertical">
-
-            <TextView
-                android:id="@android:id/title"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
-                android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
-
-            <TextView
-                android:id="@android:id/summary"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
-
-        </LinearLayout>
-
-        <include layout="@layout/vertical_divider"/>
-
-        <Button
-            android:id="@+id/first_action"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            style="@style/ConditionFullCardBorderlessButton"/>
-
-    </LinearLayout>
-
-</com.google.android.material.card.MaterialCardView>
diff --git a/res/layout-sw360dp/storage_summary_donut.xml b/res/layout-sw360dp/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-sw360dp/storage_summary_donut.xml
+++ b/res/layout-sw360dp/storage_summary_donut.xml
@@ -18,7 +18,6 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="?android:attr/colorPrimary"
     android:gravity="center_vertical"
     android:orientation="horizontal" >
 
diff --git a/res/layout/card_preference_layout.xml b/res/layout/card_preference_layout.xml
index d4a06d6..bcaeb86 100644
--- a/res/layout/card_preference_layout.xml
+++ b/res/layout/card_preference_layout.xml
@@ -25,6 +25,10 @@
         android:layout_height="wrap_content"
         android:layout_margin="8dp"
         style="@style/ContextualCardStyle">
-        <include layout="@layout/preference_material" />
+        <include
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="-8dp"
+            layout="@layout/preference_material" />
     </com.google.android.material.card.MaterialCardView>
 </FrameLayout>
diff --git a/res/layout/homepage_condition_full_tile.xml b/res/layout/homepage_condition_full_tile.xml
index 2de1464..3d261ca 100644
--- a/res/layout/homepage_condition_full_tile.xml
+++ b/res/layout/homepage_condition_full_tile.xml
@@ -22,18 +22,20 @@
     style="@style/ContextualCardStyle">
 
     <LinearLayout
-        android:id="@+id/content"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingTop="@dimen/homepage_condition_half_card_padding_top"
         android:orientation="vertical">
 
         <LinearLayout
+            android:id="@+id/content"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:paddingStart="@dimen/homepage_card_padding_start"
-            android:paddingEnd="@dimen/homepage_card_padding_end"
-            android:orientation="vertical">
+            android:paddingEnd="@dimen/homepage_full_card_padding_end"
+            android:paddingTop="@dimen/homepage_condition_full_card_padding_top"
+            android:paddingBottom="@dimen/homepage_condition_full_card_padding_bottom"
+            android:orientation="horizontal"
+            android:gravity="center_vertical">
 
             <ImageView
                 android:id="@android:id/icon"
@@ -41,35 +43,45 @@
                 android:layout_height="@dimen/homepage_card_icon_size"
                 android:tint="?android:attr/colorAccent"/>
 
-            <TextView
-                android:id="@android:id/title"
-                android:layout_width="match_parent"
+            <LinearLayout
+                android:layout_width="0dp"
                 android:layout_height="wrap_content"
-                android:maxLines="1"
-                android:ellipsize="end"
-                android:layout_marginTop="@dimen/homepage_condition_half_card_title_margin_top"
-                android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
-                android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
+                android:layout_weight="1"
+                android:paddingStart="@dimen/homepage_condition_full_card_padding_start"
+                android:paddingEnd="@dimen/homepage_condition_full_card_padding_end"
+                android:orientation="vertical">
 
-            <TextView
-                android:id="@android:id/summary"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:maxLines="1"
-                android:ellipsize="end"
-                android:layout_marginBottom="@dimen/homepage_condition_half_card_summary_margin_bottom"
-                android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
+                <TextView
+                    android:id="@android:id/title"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
+                    android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
 
-            <include layout="@layout/horizontal_divider"/>
+                <TextView
+                    android:id="@android:id/summary"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
+
+            </LinearLayout>
 
         </LinearLayout>
+
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="12dp"
+            android:layout_marginEnd="12dp">
+            <include
+                layout="@layout/horizontal_divider"/>
+        </FrameLayout>
+
         <Button
             android:id="@+id/first_action"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:scrollbars="none"
-            style="@style/ConditionHalfCardBorderlessButton"/>
-
+            style="@style/ConditionFullCardBorderlessButton"/>
     </LinearLayout>
 
 </com.google.android.material.card.MaterialCardView>
diff --git a/res/layout/homepage_condition_half_tile.xml b/res/layout/homepage_condition_half_tile.xml
index 8f5af02..308b3a6 100644
--- a/res/layout/homepage_condition_half_tile.xml
+++ b/res/layout/homepage_condition_half_tile.xml
@@ -55,14 +55,22 @@
                 android:id="@android:id/summary"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:maxLines="1"
+                android:lines="2"
                 android:ellipsize="end"
                 android:layout_marginBottom="@dimen/homepage_condition_half_card_summary_margin_bottom"
                 android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
 
-            <include layout="@layout/horizontal_divider"/>
-
         </LinearLayout>
+
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="12dp"
+            android:layout_marginEnd="12dp">
+            <include
+                layout="@layout/horizontal_divider"/>
+        </FrameLayout>
+
         <Button
             android:id="@+id/first_action"
             android:layout_width="match_parent"
diff --git a/res/layout/homepage_slice_deferred_setup_tile.xml b/res/layout/homepage_slice_deferred_setup_tile.xml
index 8c83c09..73199d4 100644
--- a/res/layout/homepage_slice_deferred_setup_tile.xml
+++ b/res/layout/homepage_slice_deferred_setup_tile.xml
@@ -32,10 +32,10 @@
             android:layout_height="match_parent"
             android:gravity="left"
             android:orientation="vertical"
-            android:paddingBottom="@dimen/homepage_deferred_setup_card_padding_bottom"
-            android:paddingEnd="@dimen/homepage_card_padding_end"
             android:paddingStart="@dimen/homepage_card_padding_start"
-            android:paddingTop="@dimen/homepage_deferred_setup_card_padding_top">
+            android:paddingEnd="@dimen/homepage_card_padding_end"
+            android:paddingTop="@dimen/homepage_deferred_setup_card_padding_top"
+            android:paddingBottom="@dimen/homepage_deferred_setup_card_padding_bottom">
 
             <ImageView
                 android:id="@android:id/icon"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 2b7c1b0..807c26b 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -31,8 +31,7 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical"
-            android:paddingStart="@dimen/homepage_card_padding_start"
-            android:paddingEnd="@dimen/homepage_card_padding_end"/>
+            style="@style/SliceViewStyle"/>
 
         <!--dismissal view-->
         <include layout="@layout/homepage_dismissal_view"/>
diff --git a/res/layout/preference_app_restrictions.xml b/res/layout/preference_app_restrictions.xml
index 65fd06c..698f1ed 100644
--- a/res/layout/preference_app_restrictions.xml
+++ b/res/layout/preference_app_restrictions.xml
@@ -83,7 +83,7 @@
         android:layout_height="fill_parent"
         android:paddingStart="12dip"
         android:paddingEnd="12dp"
-        android:src="@drawable/ic_settings"
+        android:src="@drawable/ic_settings_accent"
         android:contentDescription="@string/apps_with_restrictions_settings_button"
         android:layout_gravity="center"
         android:clickable="true"
diff --git a/res/layout/preference_widget_gear.xml b/res/layout/preference_widget_gear.xml
index f533dcf..11870ac 100644
--- a/res/layout/preference_widget_gear.xml
+++ b/res/layout/preference_widget_gear.xml
@@ -25,6 +25,6 @@
     android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
     android:background="?android:attr/selectableItemBackground"
     android:scaleType="center"
-    android:src="@drawable/ic_settings"
+    android:src="@drawable/ic_settings_accent"
     android:contentDescription="@string/settings_button" />
 
diff --git a/res/layout/preference_widget_gear_no_bg.xml b/res/layout/preference_widget_gear_no_bg.xml
index 89d34d4..6a26fc8 100644
--- a/res/layout/preference_widget_gear_no_bg.xml
+++ b/res/layout/preference_widget_gear_no_bg.xml
@@ -22,6 +22,6 @@
     android:layout_height="match_parent"
     android:layout_gravity="center"
     android:scaleType="center"
-    android:src="@drawable/ic_settings"
+    android:src="@drawable/ic_settings_accent"
     android:contentDescription="@string/settings_button" />
 
diff --git a/res/layout/preference_widget_gear_optional_background.xml b/res/layout/preference_widget_gear_optional_background.xml
index d02f638..0c826df 100644
--- a/res/layout/preference_widget_gear_optional_background.xml
+++ b/res/layout/preference_widget_gear_optional_background.xml
@@ -25,7 +25,7 @@
         android:layout_height="match_parent"
         android:layout_gravity="center"
         android:scaleType="center"
-        android:src="@drawable/ic_settings"
+        android:src="@drawable/ic_settings_accent"
         android:contentDescription="@string/settings_button" />
     <!-- Additional overdraw background to stop parent's material ripple -->
     <FrameLayout
@@ -42,7 +42,7 @@
             android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
             android:background="?android:attr/selectableItemBackground"
             android:scaleType="center"
-            android:src="@drawable/ic_settings"
+            android:src="@drawable/ic_settings_accent"
             android:contentDescription="@string/settings_button" />
     </FrameLayout>
 </FrameLayout>
diff --git a/res/layout/restricted_preference_user_delete_widget.xml b/res/layout/restricted_preference_user_delete_widget.xml
index 7bafacc..71f1dd7 100644
--- a/res/layout/restricted_preference_user_delete_widget.xml
+++ b/res/layout/restricted_preference_user_delete_widget.xml
@@ -35,7 +35,7 @@
             android:layout_height="fill_parent"
             android:paddingStart="16dip"
             android:paddingEnd="16dip"
-            android:src="@drawable/ic_settings"
+            android:src="@drawable/ic_settings_accent"
             android:contentDescription="@string/settings_label"
             android:layout_gravity="center"
             android:background="?android:attr/selectableItemBackground" />
diff --git a/res/layout/storage_summary_donut.xml b/res/layout/storage_summary_donut.xml
index 1637189..88f5b36 100644
--- a/res/layout/storage_summary_donut.xml
+++ b/res/layout/storage_summary_donut.xml
@@ -17,7 +17,6 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="?android:attr/colorPrimary"
     android:gravity="center"
     android:orientation="vertical"
     android:paddingTop="32dp"
diff --git a/res/layout/wifi_display_preference.xml b/res/layout/wifi_display_preference.xml
index 99cb89c..4532441 100644
--- a/res/layout/wifi_display_preference.xml
+++ b/res/layout/wifi_display_preference.xml
@@ -37,7 +37,7 @@
         android:layout_gravity="center_vertical"
         android:padding="8dip"
         android:background="?android:attr/selectableItemBackground"
-        android:src="@drawable/ic_settings"
+        android:src="@drawable/ic_settings_accent"
         android:contentDescription="@string/wifi_display_details" />
 
 </LinearLayout>
diff --git a/res/layout/wifi_progress_header.xml b/res/layout/wifi_progress_header.xml
deleted file mode 100644
index 3f5d428..0000000
--- a/res/layout/wifi_progress_header.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-    Copyright (C) 2015 The Android Open Source Project
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
--->
-
-<FrameLayout
-    android:layout_width="match_parent"
-    android:layout_height="3dp"
-    xmlns:android="http://schemas.android.com/apk/res/android">
-    <View
-        android:id="@+id/progress_bar_background"
-        style="@style/TrimmedHorizontalProgressBar"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="?android:attr/colorSecondary" />
-    <ProgressBar
-        android:id="@+id/progress_bar_animation"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        style="@style/TrimmedHorizontalProgressBar"
-        android:indeterminate="true" />
-</FrameLayout>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index cdbeada..617feb3 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -23,6 +23,7 @@
   <color name="homepage_support_background">#3F5FBD</color>
   <!-- 80% black for status bar of homepage -->
   <color name="homepage_status_bar_color">#cc000000</color>
-  <color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
+  <color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
+  <color name="contextual_card_background">@*android:color/material_grey_900</color>
 </resources>
 
diff --git a/res/values/colors.xml b/res/values/colors.xml
index f6723a8..a10d1d7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -100,8 +100,10 @@
     <color name="homepage_location_background">#2EC7DC</color>
     <color name="homepage_about_background">#9FA8DA</color>
     <color name="homepage_privacy_background">#5E97F6</color>
+
     <color name="homepage_card_stroke_color">#1f000000</color>
     <color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
+    <color name="contextual_card_background">@*android:color/background_device_default_light</color>
     <!-- End of dashboard/homepage icon background colors -->
 
     <color name="switchbar_text_color">@android:color/white</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d42f073..963d19f 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -368,8 +368,8 @@
     <dimen name="homepage_condition_half_card_padding_top">12dp</dimen>
     <dimen name="homepage_condition_half_card_title_margin_top">12dp</dimen>
     <dimen name="homepage_condition_half_card_summary_margin_bottom">12dp</dimen>
-    <dimen name="homepage_condition_full_card_padding_start">24dp</dimen>
-    <dimen name="homepage_condition_full_card_padding_end">24dp</dimen>
+    <dimen name="homepage_condition_full_card_padding_start">12dp</dimen>
+    <dimen name="homepage_condition_full_card_padding_end">16dp</dimen>
     <dimen name="homepage_condition_full_card_padding_top">12dp</dimen>
     <dimen name="homepage_condition_full_card_padding_bottom">12dp</dimen>
     <dimen name="homepage_condition_header_padding_top">10dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9281979..88f66ff 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1433,13 +1433,13 @@
     <string name="unlock_change_lock_password_title">Change unlock password</string>
 
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and that it requests for a strong PIN or password  [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_high_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a strong PIN or password.</string>
+    <string name="unlock_footer_high_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a strong PIN or password and may not work as expected without one</string>
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and that it requests for a medium strength PIN or password [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_medium_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new PIN or password.</string>
+    <string name="unlock_footer_medium_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new PIN or password and may not work as expected without one</string>
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and it requests for any screen lock [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_low_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new pattern, PIN or password.</string>
+    <string name="unlock_footer_low_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new pattern, PIN, or password and may not work as expected without one</string>
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_none_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new screen lock.</string>
+    <string name="unlock_footer_none_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new screen lock</string>
 
 
     <!-- Message shown on the lock screen when the user incorrectly enters their lock and it counts towards the max attempts before their data on the device is wiped. [CHAR LIMIT=NONE] -->
@@ -6857,10 +6857,10 @@
     <!-- Wizard finish button label [CHAR LIMIT=25] -->
     <string name="wizard_finish">Finish</string>
 
-    <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
-    <string name="user_image_take_photo" msgid="7496128293167402354">Take photo</string>
-    <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
-    <string name="user_image_choose_photo" msgid="3746334626214970837">Choose photo from Gallery</string>
+    <!-- An option in a photo selection dialog to take a new photo [CHAR LIMIT=50] -->
+    <string name="user_image_take_photo" msgid="7496128293167402354">Take a photo</string>
+    <!-- An option in a photo selection dialog to choose a pre-existing image [CHAR LIMIT=50] -->
+    <string name="user_image_choose_photo" msgid="3746334626214970837">Choose an image</string>
     <!-- Accessibility message for the photo selector which is a button/popup with the current photo [CHAR LIMIT=50] -->
     <string name="user_image_photo_selector">Select photo</string>
 
@@ -7078,7 +7078,7 @@
     <string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
 
     <!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
-    <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention</string>
+    <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
 
     <!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
     <string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
@@ -10636,6 +10636,15 @@
     <!-- Text for permission bar chart details in Privacy page.  [CHAR LIMIT=NONE] -->
     <string name="permission_bar_chart_details">See all usage</string>
 
+    <!-- Title for the accessibility usage preference in the Privacy page.  [CHAR LIMIT=NONE] -->
+    <string name="accessibility_usage_title">Accessibility usage</string>
+
+    <!-- Summary for the accessibility usage preference in the Privacy page.  [CHAR LIMIT=NONE] -->
+    <plurals name="accessibility_usage_summary">
+        <item quantity="one">1 service has full access to your device</item>
+        <item quantity="other"><xliff:g id="service_count">%1$d</xliff:g> services have full access to your device</item>
+    </plurals>
+
     <!-- Title for notification channel slice. [CHAR LIMIT=NONE] -->
     <string name="manage_app_notification">Manage <xliff:g id="app_name" example="Settings">%1$s</xliff:g> Notifications</string>
     <!-- Title for no suggested app in notification channel slice. [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 84c8831..747210e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -82,15 +82,6 @@
         <item name="android:scrollbarStyle">outsideOverlay</item>
     </style>
 
-    <style name="TrimmedHorizontalProgressBar"
-           parent="android:Widget.Material.ProgressBar.Horizontal">
-        <item name="android:indeterminateDrawable">
-            @drawable/progress_indeterminate_horizontal_material_trimmed
-        </item>
-        <item name="android:minHeight">3dip</item>
-        <item name="android:maxHeight">3dip</item>
-    </style>
-
     <style name="bt_item">
         <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
@@ -286,6 +277,7 @@
 
     <style name="TextAppearance.ConditionCardTitle"
            parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
+        <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
         <item name="android:textSize">16sp</item>
     </style>
 
@@ -419,6 +411,7 @@
         <item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
         <item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
         <item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
+        <item name="cardBackgroundColor">@color/contextual_card_background</item>
         <item name="cardCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
         <item name="cardElevation">0dp</item>
         <item name="strokeColor">@color/homepage_card_stroke_color</item>
@@ -448,8 +441,9 @@
 
     <style name="ConditionFullCardBorderlessButton"
            parent="@style/ConditionCardBorderlessButton">
-        <item name="android:minWidth">24dp</item>
-        <item name="android:layout_marginStart">20dp</item>
+        <item name="android:textAlignment">viewStart</item>
+        <item name="android:paddingStart">50dp</item>
+        <item name="android:paddingEnd">50dp</item>
     </style>
 
     <style name="ContextualCardDismissalButton"
@@ -460,6 +454,7 @@
 
     <style name="Widget.SliceView.Settings">
         <item name="titleSize">@*android:dimen/text_size_subhead_material</item>
+        <item name="rowStyle">@style/SliceRowStyle.Settings</item>
     </style>
 
     <style name="TextAppearance.DeferredSetupCardTitle">
@@ -482,4 +477,41 @@
         <item name="android:textSize">14sp</item>
     </style>
 
+    <style name="SliceViewStyle">
+        <!-- 4dp start padding for the start icon -->
+        <item name="android:paddingStart">4dp</item>
+
+        <!-- End margin of content without end items is 24dp.
+             android:paddingEnd = 24 - 16(contentEndPadding) -->
+        <item name="android:paddingEnd">8dp</item>
+
+        <item name="rowStyle">@style/SliceRowStyle</item>
+    </style>
+
+    <style name="SliceRowStyle">
+        <item name="titleItemEndPadding">0dp</item>
+
+        <!-- Padding between content and the start icon is 12dp. -->
+        <item name="contentStartPadding">12dp</item>
+        <!-- Padding between content and end items is 16dp. -->
+        <item name="contentEndPadding">16dp</item>
+
+        <!-- Both side margins of end item are 16dp.
+             endItemEndPadding = 16 - 8(android:paddingEnd) -->
+        <item name="endItemStartPadding">16dp</item>
+        <item name="endItemEndPadding">8dp</item>
+
+        <!-- Both side margins of bottom divider are 12dp.
+             bottomDividerStartPadding = 12 - 4(android:paddingStart)
+             bottomDividerEndPadding = 12 - 8(android:paddingEnd) -->
+        <item name="bottomDividerStartPadding">8dp</item>
+        <item name="bottomDividerEndPadding">4dp</item>
+
+        <item name="actionDividerHeight">32dp</item>
+    </style>
+
+    <style name="SliceRowStyle.Settings">
+        <!-- Padding between content and the start icon is 8dp. -->
+        <item name="contentStartPadding">8dp</item>
+    </style>
 </resources>
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 44ac10a..eaca161 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -20,13 +20,22 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="privacy_dashboard_page"
     android:title="@string/privacy_dashboard_title"
-    settings:initialExpandedChildrenCount="3">
+    settings:initialExpandedChildrenCount="4">
 
     <com.android.settingslib.widget.BarChartPreference
         android:key="permission_bar_chart"
         android:title="@string/privacy_dashboard_title"
         settings:controller="com.android.settings.privacy.PermissionBarChartPreferenceController"/>
 
+    <!-- Accessibility usage -->
+    <Preference
+        android:key="privacy_accessibility_usage"
+        android:title="@string/accessibility_usage_title"
+        settings:allowDividerAbove="true"
+        settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
+        <intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
+    </Preference>
+
     <!-- App permissions -->
     <Preference
         android:key="privacy_manage_perms"
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index c5765d3..6833922 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -60,6 +60,12 @@
             settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
 
         <Preference
+            android:key="ambient_display_wake_screen"
+            android:title="@string/ambient_display_wake_screen_title"
+            android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
+            settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
+
+        <Preference
             android:key="ambient_display_tap"
             android:title="@string/ambient_display_tap_screen_title"
             android:fragment="com.android.settings.gestures.TapScreenGestureSettings"
@@ -77,12 +83,6 @@
             android:fragment="com.android.settings.gestures.PickupGestureSettings"
             settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
 
-        <Preference
-            android:key="ambient_display_wake_screen"
-            android:title="@string/ambient_display_wake_screen_title"
-            android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
-            settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
-
         <SwitchPreference
             android:key="ambient_display_notification"
             android:title="@string/doze_title"
diff --git a/src/com/android/settings/SmsDefaultDialog.java b/src/com/android/settings/SmsDefaultDialog.java
index e4b49ee..c25961d 100644
--- a/src/com/android/settings/SmsDefaultDialog.java
+++ b/src/com/android/settings/SmsDefaultDialog.java
@@ -16,6 +16,8 @@
 
 package com.android.settings;
 
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -30,6 +32,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
 import android.widget.BaseAdapter;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -60,6 +64,21 @@
     }
 
     @Override
+    protected void onStart() {
+        super.onStart();
+        getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        final Window window = getWindow();
+        final WindowManager.LayoutParams attrs = window.getAttributes();
+        attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+        window.setAttributes(attrs);
+    }
+
+    @Override
     public void onClick(DialogInterface dialog, int which) {
         switch (which) {
             case BUTTON_POSITIVE:
@@ -84,7 +103,7 @@
     }
 
     private boolean buildDialog(String packageName) {
-        TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
+        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
         if (!tm.isSmsCapable()) {
             // No phone, no SMS
             return false;
@@ -198,7 +217,7 @@
             } else {
                 view.findViewById(R.id.default_label).setVisibility(View.GONE);
             }
-            ImageView imageView = (ImageView)view.findViewById(android.R.id.icon);
+            ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
             imageView.setImageDrawable(item.icon);
             return view;
         }
diff --git a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
index 617a9bb..1881ca7 100644
--- a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
@@ -148,7 +148,8 @@
         mFragmentManager = fragmentManager;
     }
 
-    private CachedBluetoothDevice getConnectedHearingAidDevice() {
+    @VisibleForTesting
+    CachedBluetoothDevice getConnectedHearingAidDevice() {
         if (!mHearingAidProfileSupported) {
             return null;
         }
@@ -158,9 +159,11 @@
         final List<BluetoothDevice> deviceList = mLocalBluetoothManager.getProfileManager()
                 .getHearingAidProfile().getConnectedDevices();
         final Iterator it = deviceList.iterator();
-        if (it.hasNext()) {
+        while (it.hasNext()) {
             BluetoothDevice obj = (BluetoothDevice)it.next();
-            return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
+            if (!mLocalBluetoothManager.getCachedDeviceManager().isSubDevice(obj)) {
+                return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
+            }
         }
         return null;
     }
diff --git a/src/com/android/settings/accounts/AccountHeaderPreferenceController.java b/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
index d762095..11fcaff 100644
--- a/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
@@ -84,7 +84,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mHeaderPreference = (LayoutPreference) screen.findPreference(KEY_ACCOUNT_HEADER);
+        mHeaderPreference = screen.findPreference(KEY_ACCOUNT_HEADER);
     }
 
     @Override
diff --git a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
index 5523cce..938606b 100644
--- a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
+++ b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
@@ -66,8 +66,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        final LayoutPreference removeAccountPreference =
-                (LayoutPreference) screen.findPreference(KEY_REMOVE_ACCOUNT);
+        final LayoutPreference removeAccountPreference = screen.findPreference(KEY_REMOVE_ACCOUNT);
         Button removeAccountButton = (Button) removeAccountPreference.findViewById(R.id.button);
         removeAccountButton.setOnClickListener(this);
     }
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 364aeff..6e0ae45 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -138,7 +138,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mCategory = screen.findPreference(getPreferenceKey());
         mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
         mDivider = screen.findPreference(KEY_DIVIDER);
         super.displayPreference(screen);
diff --git a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
index f65bb9b..c9f0e31 100644
--- a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
@@ -63,7 +63,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mHeader = (LayoutPreference) screen.findPreference(KEY_HEADER);
+        mHeader = screen.findPreference(KEY_HEADER);
         final Activity activity = mParent.getActivity();
         mEntityHeaderController = EntityHeaderController
                 .newInstance(activity, mParent, mHeader.findViewById(R.id.entity_header))
diff --git a/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java b/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
index 23c0121..21e641d 100644
--- a/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
@@ -77,7 +77,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (LayoutPreference) screen.findPreference(KEY_INSTANT_APP_BUTTONS);
+        mPreference = screen.findPreference(KEY_INSTANT_APP_BUTTONS);
         initButtons(mPreference.findViewById(R.id.instant_app_button_container));
     }
 
@@ -85,7 +85,7 @@
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         if (!TextUtils.isEmpty(mLaunchUri)) {
             menu.add(0, AppInfoDashboardFragment.INSTALL_INSTANT_APP_MENU, 2, R.string.install_text)
-                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
         }
     }
 
@@ -137,7 +137,7 @@
 
     private void showDialog() {
         final DialogFragment newFragment =
-            InstantAppButtonDialogFragment.newInstance(mPackageName);
+                InstantAppButtonDialogFragment.newInstance(mPackageName);
         newFragment.setTargetFragment(mParent, 0);
         newFragment.show(mParent.getFragmentManager(), KEY_INSTANT_APP_BUTTONS);
     }
@@ -148,7 +148,7 @@
         intent.addCategory(Intent.CATEGORY_LAUNCHER);
         intent.setPackage(mPackageName);
         final List<ResolveInfo> infos = manager.queryIntentActivities(
-            intent, PackageManager.GET_META_DATA | PackageManager.MATCH_INSTANT);
+                intent, PackageManager.GET_META_DATA | PackageManager.MATCH_INSTANT);
         for (ResolveInfo info : infos) {
             final Bundle metaData = info.activityInfo.metaData;
             if (metaData != null) {
diff --git a/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java b/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
index 12d1512..c859db2 100644
--- a/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
+++ b/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
@@ -63,7 +63,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mDomainAppList = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mDomainAppList = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index 0ff4233..319d62f 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -116,7 +116,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 4e2c711..490580d 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -58,7 +58,9 @@
     private FaceSettingsAttentionPreferenceController mAttentionController;
 
     private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> {
-        getActivity().finish();
+        if (getActivity() != null) {
+            getActivity().finish();
+        }
     };
 
     public static boolean isAvailable(Context context) {
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
index b910fe5..da7e9b5 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (SwitchPreference) screen.findPreference(KEY);
+        mPreference = screen.findPreference(KEY);
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
index 8c063b5..4edbb67 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
@@ -44,7 +44,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mVideoPreference = (VideoPreference) screen.findPreference(KEY_VIDEO);
+        mVideoPreference = screen.findPreference(KEY_VIDEO);
         mVideoPreference.onViewVisible(false /* paused */);
     }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
index 95b16b9..994daa7 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
@@ -52,8 +52,7 @@
 
     @Override
     protected void init(PreferenceScreen screen) {
-        final LayoutPreference headerPreference =
-                (LayoutPreference) screen.findPreference(KEY_DEVICE_HEADER);
+        final LayoutPreference headerPreference = screen.findPreference(KEY_DEVICE_HEADER);
         mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
                 headerPreference.findViewById(R.id.entity_header));
         screen.addPreference(headerPreference);
diff --git a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
index 3239dd5..9706c17 100644
--- a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
@@ -68,7 +68,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreference = (Preference) screen.findPreference(getPreferenceKey());
+            mPreference = screen.findPreference(getPreferenceKey());
         }
     }
 
diff --git a/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java b/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
index 2681288..be82284 100644
--- a/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
@@ -84,7 +84,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+            mPreferenceGroup = screen.findPreference(KEY);
             mPreferenceGroup.setVisible(false);
             updateTitle();
             mBluetoothDeviceUpdater.setPrefContext(screen.getContext());
@@ -127,7 +127,7 @@
 
     @VisibleForTesting
     public void setBluetoothDeviceUpdater(BluetoothDeviceUpdater bluetoothDeviceUpdater) {
-        mBluetoothDeviceUpdater  = bluetoothDeviceUpdater;
+        mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
     }
 
     @Override
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
index daa9932..aa83e67 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
@@ -74,7 +74,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+            mPreferenceGroup = screen.findPreference(KEY);
             mPreferenceGroup.setVisible(false);
 
             final Context context = screen.getContext();
diff --git a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
index ffcd1fc..45f128d 100644
--- a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
@@ -47,7 +47,7 @@
         super(context, preferenceKey);
 
         mSavedDockUpdater = FeatureFactory.getFactory(
-            context).getDockUpdaterFeatureProvider().getSavedDockUpdater(context, this);
+                context).getDockUpdaterFeatureProvider().getSavedDockUpdater(context, this);
     }
 
     @Override
@@ -60,7 +60,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
         mPreferenceGroup.setVisible(false);
 
         if (isAvailable()) {
diff --git a/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
index 951f3d1..e1dc750 100644
--- a/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
@@ -74,7 +74,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         if (isAvailable()) {
-            mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+            mPreferenceGroup = screen.findPreference(KEY);
             mPreferenceGroup.setVisible(false);
 
             final Context context = screen.getContext();
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
index 01977d8..4b08b74 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
@@ -57,7 +57,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
         mHostPref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_HOST),
                 R.string.usb_control_host);
         mDevicePref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_DEVICE),
@@ -74,7 +74,7 @@
             mDevicePref.setChecked(false);
             mHostPref.setChecked(true);
             mPreferenceCategory.setEnabled(true);
-        } else if (!connected || dataRole == DATA_ROLE_NONE){
+        } else if (!connected || dataRole == DATA_ROLE_NONE) {
             mPreferenceCategory.setEnabled(false);
             if (mNextRolePref == null) {
                 // Disconnected with no operation pending, so clear subtexts
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index 77ae13f..858a01c 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -68,14 +68,14 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mProfilesContainer = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mProfilesContainer = screen.findPreference(getPreferenceKey());
     }
 
     /**
      * Gets a switch preference for the particular option, creating it if needed.
      */
     private RadioButtonPreference getProfilePreference(String key, int titleId) {
-        RadioButtonPreference pref = (RadioButtonPreference) mProfilesContainer.findPreference(key);
+        RadioButtonPreference pref = mProfilesContainer.findPreference(key);
         if (pref == null) {
             pref = new RadioButtonPreference(mProfilesContainer.getContext());
             pref.setKey(key);
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
index 26b21a1..e151258 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
@@ -40,8 +40,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        final LayoutPreference headerPreference =
-                (LayoutPreference) screen.findPreference(KEY_DEVICE_HEADER);
+        final LayoutPreference headerPreference = screen.findPreference(KEY_DEVICE_HEADER);
         mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
                 headerPreference.findViewById(R.id.entity_header));
     }
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
index 42c5bae..13b3076 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
@@ -58,7 +58,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
         mSwitchPreference = new SwitchPreference(mPreferenceCategory.getContext());
         mSwitchPreference.setTitle(R.string.usb_use_power_only);
         mSwitchPreference.setOnPreferenceClickListener(this);
@@ -70,7 +70,7 @@
         // Hide this option if this is not a PD compatible connection
         if (connected && !mUsbBackend.areAllRolesSupported()) {
             mFragment.getPreferenceScreen().removePreference(mPreferenceCategory);
-        } else if (connected && mUsbBackend.areAllRolesSupported()){
+        } else if (connected && mUsbBackend.areAllRolesSupported()) {
             mFragment.getPreferenceScreen().addPreference(mPreferenceCategory);
         }
         if (powerRole == POWER_ROLE_SOURCE) {
@@ -79,7 +79,7 @@
         } else if (powerRole == POWER_ROLE_SINK) {
             mSwitchPreference.setChecked(false);
             mPreferenceCategory.setEnabled(true);
-        } else if (!connected || powerRole == POWER_ROLE_NONE){
+        } else if (!connected || powerRole == POWER_ROLE_NONE) {
             mPreferenceCategory.setEnabled(false);
             if (mNextPowerRole == POWER_ROLE_NONE) {
                 mSwitchPreference.setSummary("");
diff --git a/src/com/android/settings/datausage/AppDataUsage.java b/src/com/android/settings/datausage/AppDataUsage.java
index 15c7754..8bab256 100644
--- a/src/com/android/settings/datausage/AppDataUsage.java
+++ b/src/com/android/settings/datausage/AppDataUsage.java
@@ -52,6 +52,7 @@
 import com.android.settingslib.net.UidDetail;
 import com.android.settingslib.net.UidDetailProvider;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceChangeListener,
@@ -59,8 +60,10 @@
 
     private static final String TAG = "AppDataUsage";
 
-    public static final String ARG_APP_ITEM = "app_item";
-    public static final String ARG_NETWORK_TEMPLATE = "network_template";
+    static final String ARG_APP_ITEM = "app_item";
+    static final String ARG_NETWORK_TEMPLATE = "network_template";
+    static final String ARG_NETWORK_CYCLES = "network_cycles";
+    static final String ARG_SELECTED_CYCLE = "selected_cycle";
 
     private static final String KEY_TOTAL_USAGE = "total_usage";
     private static final String KEY_FOREGROUND_USAGE = "foreground_usage";
@@ -99,6 +102,8 @@
     private RestrictedSwitchPreference mUnrestrictedData;
     private DataSaverBackend mDataSaverBackend;
     private Context mContext;
+    private ArrayList<Long> mCycles;
+    private long mSelectedCycle;
 
     @Override
     public void onCreate(Bundle icicle) {
@@ -110,6 +115,10 @@
         mAppItem = (args != null) ? (AppItem) args.getParcelable(ARG_APP_ITEM) : null;
         mTemplate = (args != null) ? (NetworkTemplate) args.getParcelable(ARG_NETWORK_TEMPLATE)
                 : null;
+        mCycles = (args != null) ? (ArrayList) args.getSerializable(ARG_NETWORK_CYCLES)
+            : null;
+        mSelectedCycle = (args != null) ? args.getLong(ARG_SELECTED_CYCLE) : 0L;
+
         if (mTemplate == null) {
             mTemplate = DataUsageUtils.getDefaultTemplate(mContext,
                     SubscriptionManager.getDefaultDataSubscriptionId());
@@ -393,6 +402,9 @@
                 } else {
                     builder.addUid(mAppItem.key);
                 }
+                if (mCycles != null) {
+                    builder.setCycles(mCycles);
+                }
                 return builder.build();
             }
 
@@ -401,7 +413,23 @@
                     List<NetworkCycleDataForUid> data) {
                 mUsageData = data;
                 mCycleAdapter.updateCycleList(data);
-                bindData(0 /* position */);
+                if (mSelectedCycle > 0L) {
+                    final int numCycles = data.size();
+                    int position = 0;
+                    for (int i = 0; i < numCycles; i++) {
+                        final NetworkCycleDataForUid cycleData = data.get(i);
+                        if (cycleData.getEndTime() == mSelectedCycle) {
+                            position = i;
+                            break;
+                        }
+                    }
+                    if (position > 0) {
+                        mCycle.setSelection(position);
+                    }
+                    bindData(position);
+                } else {
+                    bindData(0 /* position */);
+                }
             }
 
             @Override
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 8eeb925..e5158ff 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -109,6 +109,7 @@
     @VisibleForTesting
     int mNetworkType;
     private List<NetworkCycleChartData> mCycleData;
+    private ArrayList<Long> mCycles;
 
     private LoadingViewController mLoadingViewController;
     private UidDetailProvider mUidDetailProvider;
@@ -411,10 +412,23 @@
         }
     }
 
-    private void startAppDataUsage(AppItem item) {
+    @VisibleForTesting
+    void startAppDataUsage(AppItem item) {
         final Bundle args = new Bundle();
         args.putParcelable(AppDataUsage.ARG_APP_ITEM, item);
         args.putParcelable(AppDataUsage.ARG_NETWORK_TEMPLATE, mTemplate);
+        if (mCycles == null) {
+            mCycles = new ArrayList<>();
+            for (NetworkCycleChartData data : mCycleData) {
+                if (mCycles.isEmpty()) {
+                    mCycles.add(data.getEndTime());
+                }
+                mCycles.add(data.getStartTime());
+            }
+        }
+        args.putSerializable(AppDataUsage.ARG_NETWORK_CYCLES, mCycles);
+        args.putLong(AppDataUsage.ARG_SELECTED_CYCLE,
+            mCycleData.get(mCycleSpinner.getSelectedItemPosition()).getEndTime());
 
         new SubSettingLauncher(getContext())
                 .setDestination(AppDataUsage.class.getName())
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index 0f21dee..0f429c7 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -65,7 +65,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         // Set a default value because BluetoothCodecConfig is null initially.
         mPreference.setValue(mListValues[getDefaultIndex()]);
@@ -177,7 +177,7 @@
 
     @VisibleForTesting
     void setCodecConfigPreference(BluetoothDevice device,
-                                  BluetoothCodecConfig config) {
+            BluetoothCodecConfig config) {
         mBluetoothA2dp.setCodecConfigPreference(device, config);
     }
 
diff --git a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
index d26f0dd..d698436 100644
--- a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
@@ -55,8 +55,7 @@
         mListEntries = context.getResources().getStringArray(R.array.bt_hci_snoop_log_entries);
     }
 
-    // Default mode is FILTERED on userdebug/eng build, DISABLED on user build,
-    // or can be changed by modifying the global setting.
+    // Default mode is DISABLED. It can also be changed by modifying the global setting.
     public int getDefaultModeIndex() {
         if (!Build.IS_DEBUGGABLE) {
             return BTSNOOP_LOG_MODE_DISABLED_INDEX;
@@ -71,7 +70,7 @@
             }
         }
 
-        return BTSNOOP_LOG_MODE_FILTERED_INDEX;
+        return BTSNOOP_LOG_MODE_DISABLED_INDEX;
     }
 
     @Override
diff --git a/src/com/android/settings/development/OemUnlockPreferenceController.java b/src/com/android/settings/development/OemUnlockPreferenceController.java
index b6b4d17..2a397f1 100644
--- a/src/com/android/settings/development/OemUnlockPreferenceController.java
+++ b/src/com/android/settings/development/OemUnlockPreferenceController.java
@@ -77,7 +77,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/development/OverlayCategoryPreferenceController.java b/src/com/android/settings/development/OverlayCategoryPreferenceController.java
index 0ba9d79..7a2ee08 100644
--- a/src/com/android/settings/development/OverlayCategoryPreferenceController.java
+++ b/src/com/android/settings/development/OverlayCategoryPreferenceController.java
@@ -41,7 +41,6 @@
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Optional;
 
 /**
  * Preference controller to allow users to choose an overlay from a list for a given category.
@@ -91,7 +90,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        setPreference((ListPreference) screen.findPreference(getPreferenceKey()));
+        setPreference(screen.findPreference(getPreferenceKey()));
     }
 
     @VisibleForTesting
@@ -124,7 +123,8 @@
                     if (PACKAGE_DEVICE_DEFAULT.equals(packageName)) {
                         return mOverlayManager.setEnabled(currentPackageName, false, USER_SYSTEM);
                     } else {
-                        return mOverlayManager.setEnabledExclusiveInCategory(packageName, USER_SYSTEM);
+                        return mOverlayManager.setEnabledExclusiveInCategory(packageName,
+                                USER_SYSTEM);
                     }
                 } catch (RemoteException re) {
                     Log.w(TAG, "Error enabling overlay.", re);
diff --git a/src/com/android/settings/development/PictureColorModePreferenceController.java b/src/com/android/settings/development/PictureColorModePreferenceController.java
index 3cf1f4e..1acf5d0 100644
--- a/src/com/android/settings/development/PictureColorModePreferenceController.java
+++ b/src/com/android/settings/development/PictureColorModePreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ColorModePreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         if (mPreference != null) {
             mPreference.updateCurrentAndSupported();
         }
diff --git a/src/com/android/settings/development/StayAwakePreferenceController.java b/src/com/android/settings/development/StayAwakePreferenceController.java
index 4091537..25a92b2 100644
--- a/src/com/android/settings/development/StayAwakePreferenceController.java
+++ b/src/com/android/settings/development/StayAwakePreferenceController.java
@@ -40,7 +40,7 @@
 
 
 public class StayAwakePreferenceController extends DeveloperOptionsPreferenceController
-        implements Preference.OnPreferenceChangeListener, LifecycleObserver,  OnResume, OnPause,
+        implements Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause,
         PreferenceControllerMixin {
 
     private static final String TAG = "StayAwakeCtrl";
@@ -72,7 +72,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
index 1c4df4c..638c7c1 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
@@ -45,7 +45,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mGroup = screen.findPreference(getPreferenceKey());
     }
 
     @Override
@@ -60,6 +60,6 @@
         mGroup.removeAll();
         final Context prefContext = mGroup.getContext();
         featureMap.keySet().stream().sorted().forEach(feature ->
-            mGroup.addPreference(new FeatureFlagPreference(prefContext, feature)));
+                mGroup.addPreference(new FeatureFlagPreference(prefContext, feature)));
     }
 }
diff --git a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
index 3877c45..09659be 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
@@ -55,8 +55,8 @@
  */
 public class GameDriverAppPreferenceController extends BasePreferenceController
         implements Preference.OnPreferenceChangeListener,
-                   GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
-                   OnStart, OnStop {
+        GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
+        OnStart, OnStop {
 
     private final Context mContext;
     private final ContentResolver mContentResolver;
@@ -103,9 +103,9 @@
     @Override
     public int getAvailabilityStatus() {
         return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
-                        && (Settings.Global.getInt(mContentResolver,
-                                    Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
-                                != GAME_DRIVER_OFF)
+                && (Settings.Global.getInt(mContentResolver,
+                Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
+                != GAME_DRIVER_OFF)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
@@ -113,7 +113,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
 
         final Context context = mPreferenceGroup.getContext();
         for (AppInfo appInfo : mAppInfos) {
@@ -179,6 +179,7 @@
             info = applicationInfo;
             label = packageManager.getApplicationLabel(applicationInfo).toString();
         }
+
         final ApplicationInfo info;
         final String label;
     }
diff --git a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
index 95c02fd..50027f2 100644
--- a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
@@ -61,7 +61,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mSwitch = (MasterSwitchPreference) screen.findPreference(getPreferenceKey());
+        mSwitch = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
index ee9fad6..c78d108 100644
--- a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
+++ b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
@@ -49,8 +49,10 @@
     private static final int USER_PROFILE_INSERTION_LOCATION = 6;
     private static final int SIZE_NOT_SET = -1;
 
-    private @NonNull UserInfo mUser;
-    private @Nullable StorageItemPreference mStoragePreference;
+    private @NonNull
+    UserInfo mUser;
+    private @Nullable
+    StorageItemPreference mStoragePreference;
     private Drawable mUserIcon;
     private long mSize;
     private long mTotalSizeBytes;
@@ -58,7 +60,8 @@
     /**
      * Adds the appropriate controllers to a controller list for handling all secondary users on
      * a device.
-     * @param context Context for initializing the preference controllers.
+     *
+     * @param context     Context for initializing the preference controllers.
      * @param userManager UserManagerWrapper for figuring out which controllers to add.
      */
     public static List<AbstractPreferenceController> getSecondaryUserControllers(
@@ -91,8 +94,9 @@
 
     /**
      * Constructor for a given secondary user.
+     *
      * @param context Context to initialize the underlying {@link AbstractPreferenceController}.
-     * @param info {@link UserInfo} for the secondary user which this controllers covers.
+     * @param info    {@link UserInfo} for the secondary user which this controllers covers.
      */
     @VisibleForTesting
     SecondaryUserController(Context context, @NonNull UserInfo info) {
@@ -107,7 +111,7 @@
             mStoragePreference = new StorageItemPreference(screen.getContext());
 
             PreferenceGroup group =
-                    (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
+                    screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
             mStoragePreference.setTitle(mUser.name);
             mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
             if (mSize != SIZE_NOT_SET) {
@@ -140,6 +144,7 @@
 
     /**
      * Sets the size for the preference.
+     *
      * @param size Size in bytes.
      */
     public void setSize(long size) {
@@ -151,6 +156,7 @@
 
     /**
      * Sets the total size for the preference for the progress bar.
+     *
      * @param totalSizeBytes Total size in bytes.
      */
     public void setTotalSize(long totalSizeBytes) {
@@ -185,8 +191,7 @@
 
         @Override
         public void displayPreference(PreferenceScreen screen) {
-            PreferenceGroup group =
-                    (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
+            final PreferenceGroup group = screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
             if (group == null) {
                 return;
             }
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 4bc7cde..525a887 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -77,7 +77,7 @@
     static final String FILES_KEY = "pref_files";
 
     private final Fragment mFragment;
-    private final  MetricsFeatureProvider mMetricsFeatureProvider;
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
     private final StorageVolumeProvider mSvp;
     private VolumeInfo mVolume;
     private int mUserId;
@@ -225,7 +225,7 @@
 
     private static Drawable applyTint(Context context, Drawable icon) {
         TypedArray array =
-                context.obtainStyledAttributes(new int[] {android.R.attr.colorControlNormal});
+                context.obtainStyledAttributes(new int[]{android.R.attr.colorControlNormal});
         icon = icon.mutate();
         icon.setTint(array.getColor(0, 0));
         array.recycle();
@@ -235,13 +235,13 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         mScreen = screen;
-        mPhotoPreference = (StorageItemPreference) screen.findPreference(PHOTO_KEY);
-        mAudioPreference = (StorageItemPreference) screen.findPreference(AUDIO_KEY);
-        mGamePreference = (StorageItemPreference) screen.findPreference(GAME_KEY);
-        mMoviesPreference = (StorageItemPreference) screen.findPreference(MOVIES_KEY);
-        mAppPreference = (StorageItemPreference) screen.findPreference(OTHER_APPS_KEY);
-        mSystemPreference = (StorageItemPreference) screen.findPreference(SYSTEM_KEY);
-        mFilePreference = (StorageItemPreference) screen.findPreference(FILES_KEY);
+        mPhotoPreference = screen.findPreference(PHOTO_KEY);
+        mAudioPreference = screen.findPreference(AUDIO_KEY);
+        mGamePreference = screen.findPreference(GAME_KEY);
+        mMoviesPreference = screen.findPreference(MOVIES_KEY);
+        mAppPreference = screen.findPreference(OTHER_APPS_KEY);
+        mSystemPreference = screen.findPreference(SYSTEM_KEY);
+        mFilePreference = screen.findPreference(FILES_KEY);
 
         setFilesPreferenceVisibility();
     }
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
index 1dd3d98..d450a2a 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
@@ -46,7 +46,6 @@
     /**
      * Converts a used storage amount to a formatted text.
      *
-     * @param context Context
      * @param usedBytes used bytes of storage
      * @return a formatted text.
      */
@@ -59,7 +58,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mSummary = (StorageSummaryDonutPreference) screen.findPreference("pref_summary");
+        mSummary = screen.findPreference("pref_summary");
         mSummary.setEnabled(true);
     }
 
@@ -94,7 +93,7 @@
     /**
      * Updates the state of the donut preference for the next update.
      *
-     * @param used Total number of used bytes on the summarized volume.
+     * @param used  Total number of used bytes on the summarized volume.
      * @param total Total number of bytes on the summarized volume.
      */
     public void updateBytes(long used, long total) {
diff --git a/src/com/android/settings/display/NightModePreferenceController.java b/src/com/android/settings/display/NightModePreferenceController.java
index 5846a65..a4d96f6 100644
--- a/src/com/android/settings/display/NightModePreferenceController.java
+++ b/src/com/android/settings/display/NightModePreferenceController.java
@@ -52,8 +52,7 @@
             setVisible(screen, KEY_NIGHT_MODE, false /* visible */);
             return;
         }
-        ListPreference mNightModePreference = (ListPreference) screen.findPreference(
-                KEY_NIGHT_MODE);
+        final ListPreference mNightModePreference = screen.findPreference(KEY_NIGHT_MODE);
         if (mNightModePreference != null) {
             final UiModeManager uiManager =
                     (UiModeManager) mContext.getSystemService(UI_MODE_SERVICE);
diff --git a/src/com/android/settings/dream/StartNowPreferenceController.java b/src/com/android/settings/dream/StartNowPreferenceController.java
index 9e45ea3..0541bca 100644
--- a/src/com/android/settings/dream/StartNowPreferenceController.java
+++ b/src/com/android/settings/dream/StartNowPreferenceController.java
@@ -54,8 +54,8 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
-        Button startButton = (Button)pref.findViewById(R.id.dream_start_now_button);
+        LayoutPreference pref = screen.findPreference(getPreferenceKey());
+        Button startButton = pref.findViewById(R.id.dream_start_now_button);
         startButton.setOnClickListener(v -> mBackend.startDreaming());
     }
 
@@ -63,7 +63,7 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
 
-        Button startButton = (Button)((LayoutPreference)preference)
+        Button startButton = ((LayoutPreference) preference)
                 .findViewById(R.id.dream_start_now_button);
         startButton.setEnabled(mBackend.getWhenToDreamSetting() != DreamBackend.NEVER);
     }
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index e2d1c53..5366ba1 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -143,7 +143,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPrefContext = screen.getContext();
-        mAppListGroup = (PreferenceGroup) screen.findPreference(mPreferenceKey);
+        mAppListGroup = screen.findPreference(mPreferenceKey);
     }
 
     @Override
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 80a72e6..bb12d1a 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -72,7 +72,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (TwoStateButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/gestures/GesturePreferenceController.java b/src/com/android/settings/gestures/GesturePreferenceController.java
index a4274bf..d7b386a 100644
--- a/src/com/android/settings/gestures/GesturePreferenceController.java
+++ b/src/com/android/settings/gestures/GesturePreferenceController.java
@@ -51,7 +51,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mVideoPreference = (VideoPreference) screen.findPreference(getVideoPrefKey());
+            mVideoPreference = screen.findPreference(getVideoPrefKey());
         }
     }
 
diff --git a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
index d22e42a..04f7e476 100644
--- a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
@@ -45,9 +45,11 @@
         implements RadioButtonPreference.OnClickListener, LifecycleObserver, OnSaveInstanceState,
         OnResume, OnPause, OnCreate, PreferenceControllerMixin {
 
-    @VisibleForTesting static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
+    @VisibleForTesting
+    static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
 
-    @VisibleForTesting static final String KEY_MUTE = "prevent_ringing_option_mute";
+    @VisibleForTesting
+    static final String KEY_MUTE = "prevent_ringing_option_mute";
 
     private final String KEY_VIDEO_PAUSED = "key_video_paused";
     private final String PREF_KEY_VIDEO = "gesture_prevent_ringing_video";
@@ -57,9 +59,12 @@
     private VideoPreference mVideoPreference;
     private boolean mVideoPaused;
 
-    @VisibleForTesting PreferenceCategory mPreferenceCategory;
-    @VisibleForTesting RadioButtonPreference mVibratePref;
-    @VisibleForTesting RadioButtonPreference mMutePref;
+    @VisibleForTesting
+    PreferenceCategory mPreferenceCategory;
+    @VisibleForTesting
+    RadioButtonPreference mVibratePref;
+    @VisibleForTesting
+    RadioButtonPreference mMutePref;
 
     private SettingObserver mSettingObserver;
 
@@ -75,17 +80,18 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        if (isAvailable()) {
-            mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
-            mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
-            mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
-
-            if (mPreferenceCategory != null) {
-                mSettingObserver = new SettingObserver(mPreferenceCategory);
-            }
-
-            mVideoPreference = (VideoPreference) screen.findPreference(getVideoPrefKey());
+        if (!isAvailable()) {
+            return;
         }
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
+        mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
+        mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
+
+        if (mPreferenceCategory != null) {
+            mSettingObserver = new SettingObserver(mPreferenceCategory);
+        }
+
+        mVideoPreference = screen.findPreference(getVideoPrefKey());
     }
 
     @Override
diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
index b94cfff..35ff2ec 100644
--- a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
@@ -35,13 +35,14 @@
 import com.android.settingslib.widget.LayoutPreference;
 
 public class PreventRingingSwitchPreferenceController extends AbstractPreferenceController
-    implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
+        implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
 
     private static final String KEY = "gesture_prevent_ringing_switch";
     private final Context mContext;
     private SettingObserver mSettingObserver;
 
-    @VisibleForTesting SwitchBar mSwitch;
+    @VisibleForTesting
+    SwitchBar mSwitch;
 
     public PreventRingingSwitchPreferenceController(Context context) {
         super(context);
@@ -57,7 +58,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
+            LayoutPreference pref = screen.findPreference(getPreferenceKey());
             if (pref != null) {
                 mSettingObserver = new SettingObserver(pref);
                 mSwitch = pref.findViewById(R.id.switch_bar);
diff --git a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
index a43fad1..96a3580 100644
--- a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
@@ -53,7 +53,18 @@
                 || !mFeatureProvider.isSupported(mContext)) {
             return UNSUPPORTED_ON_DEVICE;
         }
-        return mFeatureProvider.isEnabled(mContext) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+
+        if (!mFeatureProvider.isEnabled(mContext)) {
+            return CONDITIONALLY_UNAVAILABLE;
+        }
+
+        return getAmbientConfig().alwaysOnEnabled(mUserId)
+                ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+    }
+
+    @Override
+    protected boolean canHandleClicks() {
+        return getAmbientConfig().alwaysOnEnabled(mUserId);
     }
 
     @Override
diff --git a/src/com/android/settings/location/LocationForWorkPreferenceController.java b/src/com/android/settings/location/LocationForWorkPreferenceController.java
index 580f888..1208ea2 100644
--- a/src/com/android/settings/location/LocationForWorkPreferenceController.java
+++ b/src/com/android/settings/location/LocationForWorkPreferenceController.java
@@ -57,8 +57,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference =
-                (RestrictedSwitchPreference) screen.findPreference(KEY_MANAGED_PROFILE_SWITCH);
+        mPreference = screen.findPreference(KEY_MANAGED_PROFILE_SWITCH);
     }
 
     @Override
diff --git a/src/com/android/settings/location/LocationServicePreferenceController.java b/src/com/android/settings/location/LocationServicePreferenceController.java
index 43d35f1..e604261 100644
--- a/src/com/android/settings/location/LocationServicePreferenceController.java
+++ b/src/com/android/settings/location/LocationServicePreferenceController.java
@@ -84,8 +84,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mCategoryLocationServices =
-                (PreferenceCategory) screen.findPreference(KEY_LOCATION_SERVICES);
+        mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES);
     }
 
     @Override
diff --git a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
index 214dcd5..44d600e 100644
--- a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
@@ -69,8 +69,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        final LayoutPreference preference = (LayoutPreference) screen.findPreference(
-                KEY_APPS_DASHBOARD);
+        final LayoutPreference preference = screen.findPreference(KEY_APPS_DASHBOARD);
         final View view = preference.findViewById(R.id.app_entities_header);
         mController = AppEntitiesHeaderController.newInstance(mContext, view)
                 .setHeaderTitleRes(R.string.location_category_recent_location_access)
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index 1490e8a..5c1913b 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -81,7 +81,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mAirplaneModePreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
+            mAirplaneModePreference = screen.findPreference(getPreferenceKey());
         }
     }
 
diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java
index fff1fea..dd282c6 100644
--- a/src/com/android/settings/network/MobileNetworkSummaryController.java
+++ b/src/com/android/settings/network/MobileNetworkSummaryController.java
@@ -31,6 +31,7 @@
 import com.android.settings.R;
 import com.android.settings.network.telephony.MobileNetworkActivity;
 import com.android.settings.widget.AddPreference;
+import com.android.settingslib.Utils;
 import com.android.settingslib.core.AbstractPreferenceController;
 
 import java.util.List;
@@ -50,6 +51,7 @@
     private SubscriptionManager mSubscriptionManager;
     private SubscriptionsChangeListener mChangeListener;
     private TelephonyManager mTelephonyMgr;
+    private EuiccManager mEuiccManager;
     private AddPreference mPreference;
 
     /**
@@ -71,6 +73,7 @@
         super(context);
         mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
         mTelephonyMgr = mContext.getSystemService(TelephonyManager.class);
+        mEuiccManager = mContext.getSystemService(EuiccManager.class);
         mChangeListener = new SubscriptionsChangeListener(context, this);
         lifecycle.addObserver(this);
     }
@@ -97,7 +100,11 @@
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
                 mSubscriptionManager);
         if (subs.isEmpty()) {
-            return mContext.getResources().getString(R.string.mobile_network_summary_add_a_network);
+            if (mEuiccManager.isEnabled()) {
+                return mContext.getResources().getString(
+                        R.string.mobile_network_summary_add_a_network);
+            }
+            return null;
         } else if (subs.size() == 1) {
             return subs.get(0).getDisplayName();
         } else {
@@ -112,20 +119,22 @@
         mContext.startActivity(intent);
     }
 
-    private boolean shouldEnableAddButton() {
-        // The add button should only show up if the device is in multi-sim mode.
-        return mTelephonyMgr.getMultiSimConfiguration() != UNKNOWN;
+    private boolean shouldShowAddButton() {
+        // The add button should only show up if the device is in multi-sim mode and the eSIM
+        // manager is enabled.
+        return mTelephonyMgr.getMultiSimConfiguration() != UNKNOWN && mEuiccManager.isEnabled();
     }
 
     private void update() {
         if (mPreference == null) {
             return;
         }
-        final boolean enableAddButton = shouldEnableAddButton();
+        final boolean showAddButton = shouldShowAddButton();
         refreshSummary(mPreference);
-        if (!enableAddButton) {
+        if (!showAddButton) {
             mPreference.setOnAddClickListener(null);
         } else {
+            mPreference.setAddWidgetEnabled(!mChangeListener.isAirplaneModeOn());
             mPreference.setOnAddClickListener(p -> {
                 startAddSimFlow();
             });
@@ -134,11 +143,11 @@
                 mSubscriptionManager);
         mPreference.setOnPreferenceClickListener(null);
         mPreference.setFragment(null);
-        mPreference.setEnabled(true);
+        mPreference.setEnabled(!mChangeListener.isAirplaneModeOn());
         if (subs.isEmpty()) {
-            if (enableAddButton) {
+            if (showAddButton) {
                 mPreference.setEnabled(false);
-            } else {
+            } else if (mEuiccManager.isEnabled()) {
                 mPreference.setOnPreferenceClickListener((Preference pref) -> {
                     startAddSimFlow();
                     return true;
@@ -157,7 +166,7 @@
 
     @Override
     public boolean isAvailable() {
-        return true;
+        return !Utils.isWifiOnly(mContext);
     }
 
     @Override
@@ -167,6 +176,7 @@
 
     @Override
     public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
+        update();
     }
 
     @Override
diff --git a/src/com/android/settings/network/MultiNetworkHeaderController.java b/src/com/android/settings/network/MultiNetworkHeaderController.java
index 938c753..ba201a5 100644
--- a/src/com/android/settings/network/MultiNetworkHeaderController.java
+++ b/src/com/android/settings/network/MultiNetworkHeaderController.java
@@ -65,7 +65,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(mPreferenceKey);
+        mPreferenceCategory = screen.findPreference(mPreferenceKey);
         mPreferenceCategory.setVisible(isAvailable());
         mWifiController.displayPreference(screen);
         mSubscriptionsController.displayPreference(screen);
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 237e08a..224fc41 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -38,7 +38,7 @@
         if (sResultsForTesting != null) {
             return sResultsForTesting;
         }
-        List<SubscriptionInfo> subscriptions = manager.getAvailableSubscriptionInfoList();
+        List<SubscriptionInfo> subscriptions = manager.getSelectableSubscriptionInfoList();
         if (subscriptions == null) {
             subscriptions = new ArrayList<>();
         }
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index a639782..b6e8f58 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -107,7 +107,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(mPreferenceGroupKey);
+        mPreferenceGroup = screen.findPreference(mPreferenceGroupKey);
         update();
     }
 
@@ -129,7 +129,7 @@
         mSubscriptionPreferences = new ArrayMap<>();
 
         int order = mStartOrder;
-        for (SubscriptionInfo info :  SubscriptionUtil.getAvailableSubscriptions(mManager)) {
+        for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager)) {
             final int subId = info.getSubscriptionId();
             Preference pref = existingPrefs.remove(subId);
             if (pref == null) {
@@ -209,7 +209,6 @@
     }
 
     /**
-     *
      * @return true if there are at least 2 available subscriptions.
      */
     @Override
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index c5e2215a..94b1761 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -54,6 +54,8 @@
     public int getAvailabilityStatus(int subId) {
         boolean visible;
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        final TelephonyManager telephonyManager = TelephonyManager
+                .from(mContext).createForSubscriptionId(subId);
         if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             visible = false;
         } else if (carrierConfig == null) {
@@ -63,8 +65,8 @@
             visible = false;
         } else if (carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
-                && !mTelephonyManager.getServiceState().getRoaming()
-                && mTelephonyManager.getServiceState().getDataRegState()
+                && !telephonyManager.getServiceState().getRoaming()
+                && telephonyManager.getServiceState().getDataRegState()
                 == ServiceState.STATE_IN_SERVICE) {
             visible = false;
         } else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index 821b1e1e..3c0940d 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -160,7 +160,7 @@
             final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
             if (subId != SUB_ID_NULL) {
                 for (SubscriptionInfo subscription :
-                        mSubscriptionManager.getAvailableSubscriptionInfoList()) {
+                        mSubscriptionManager.getSelectableSubscriptionInfoList()) {
                     if (subscription.getSubscriptionId() == subId) {
                         return subscription;
                     }
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index ff04583..2495ca5 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -122,7 +122,7 @@
 
         final Activity activity = getActivity();
         if (activity != null) {
-            mProgressHeader = setPinnedHeaderView(R.layout.wifi_progress_header)
+            mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
                     .findViewById(R.id.progress_bar_animation);
             setProgressBarVisible(false);
         }
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index 27a7bce..294f05f 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -30,7 +30,6 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
 
 /**
  * Preference controller for "Preferred network mode"
@@ -51,6 +50,8 @@
     @Override
     public int getAvailabilityStatus(int subId) {
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        final TelephonyManager telephonyManager = TelephonyManager
+                .from(mContext).createForSubscriptionId(subId);
         boolean visible;
         if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             visible = false;
@@ -61,8 +62,8 @@
             visible = false;
         } else if (carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
-                && !mTelephonyManager.getServiceState().getRoaming()
-                && mTelephonyManager.getServiceState().getDataRegState()
+                && !telephonyManager.getServiceState().getRoaming()
+                && telephonyManager.getServiceState().getDataRegState()
                 == ServiceState.STATE_IN_SERVICE) {
             visible = false;
         } else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index 44984e6..8c32df0 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -34,7 +34,6 @@
 import androidx.preference.SwitchPreference;
 
 import com.android.ims.ImsManager;
-import com.android.settings.core.TogglePreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -49,7 +48,6 @@
     private Preference mPreference;
     private TelephonyManager mTelephonyManager;
     private CarrierConfigManager mCarrierConfigManager;
-    private PersistableBundle mCarrierConfig;
     @VisibleForTesting
     ImsManager mImsManager;
     private PhoneCallStateListener mPhoneStateListener;
@@ -67,7 +65,7 @@
         return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
                 && MobileNetworkUtils.isWifiCallingEnabled(mContext,
                 SubscriptionManager.getPhoneId(subId))
-                && isVideoCallEnabled()
+                && isVideoCallEnabled(subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
@@ -94,7 +92,7 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
         final SwitchPreference switchPreference = (SwitchPreference) preference;
-        final boolean videoCallEnabled = isVideoCallEnabled();
+        final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
         switchPreference.setVisible(videoCallEnabled);
         if (videoCallEnabled) {
             final boolean is4gLteEnabled = mImsManager.isEnhanced4gLteModeSettingEnabledByUser()
@@ -119,7 +117,6 @@
     public VideoCallingPreferenceController init(int subId) {
         mSubId = subId;
         mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
-        mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
         if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
         }
@@ -127,15 +124,25 @@
         return this;
     }
 
+    private boolean isVideoCallEnabled(int subId) {
+        final ImsManager imsManager = subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
+                ? ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(subId))
+                : null;
+        return isVideoCallEnabled(subId, imsManager);
+    }
+
     @VisibleForTesting
-    boolean isVideoCallEnabled() {
-        return mCarrierConfig != null && mImsManager != null
-                && mImsManager.isVtEnabledByPlatform()
-                && mImsManager.isVtProvisionedOnDevice()
-                && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
-                && (mCarrierConfig.getBoolean(
+    boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
+        final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        final TelephonyManager telephonyManager = TelephonyManager
+                .from(mContext).createForSubscriptionId(subId);
+        return carrierConfig != null && imsManager != null
+                && imsManager.isVtEnabledByPlatform()
+                && imsManager.isVtProvisionedOnDevice()
+                && MobileNetworkUtils.isImsServiceStateReady(imsManager)
+                && (carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
-                || mTelephonyManager.isDataEnabled());
+                || telephonyManager.isDataEnabled());
     }
 
     @Override
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 26c4d06..dfa1271 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -67,7 +67,7 @@
     public int getAvailabilityStatus(int subId) {
         return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
                 && MobileNetworkUtils.isWifiCallingEnabled(mContext,
-                SubscriptionManager.getPhoneId(mSubId))
+                SubscriptionManager.getPhoneId(subId))
                 ? AVAILABLE
                 : UNSUPPORTED_ON_DEVICE;
     }
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
index a5498bc..ea7d82f 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
@@ -29,8 +29,8 @@
 import androidx.preference.PreferenceManager;
 import androidx.preference.PreferenceScreen;
 
-import com.android.settings.core.BasePreferenceController;
 import com.android.settings.network.telephony.MobileNetworkUtils;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -38,7 +38,7 @@
 /**
  * Preference controller related to CDMA category
  */
-public abstract class CdmaBasePreferenceController extends BasePreferenceController
+public abstract class CdmaBasePreferenceController extends TelephonyBasePreferenceController
         implements LifecycleObserver, OnStart, OnStop {
 
     protected Preference mPreference;
@@ -64,8 +64,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.isCdmaOptions(mContext, mSubId)
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.isCdmaOptions(mContext, subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
index c653890..e6c1c22 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
@@ -44,8 +44,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.isCdmaOptions(mContext, mSubId) && deviceSupportsNvAndRuim()
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.isCdmaOptions(mContext, subId) && deviceSupportsNvAndRuim()
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index f883d8a..7db9df0 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -29,9 +29,9 @@
 
 import com.android.settings.R;
 import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.core.TogglePreferenceController;
 import com.android.settings.network.telephony.MobileNetworkUtils;
 import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyTogglePreferenceController;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -39,7 +39,7 @@
 /**
  * Preference controller for "Auto Select Network"
  */
-public class AutoSelectPreferenceController extends TogglePreferenceController {
+public class AutoSelectPreferenceController extends TelephonyTogglePreferenceController {
 
     private int mSubId;
     private TelephonyManager mTelephonyManager;
@@ -54,8 +54,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext,mSubId)
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
diff --git a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
index e8a392a..9ac0d12 100644
--- a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
@@ -33,11 +33,13 @@
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.network.telephony.MobileNetworkUtils;
 import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
 
 /**
  * Preference controller for "Open network select"
  */
-public class OpenNetworkSelectPagePreferenceController extends BasePreferenceController implements
+public class OpenNetworkSelectPagePreferenceController extends
+        TelephonyBasePreferenceController implements
         AutoSelectPreferenceController.OnNetworkSelectModeListener {
 
     private int mSubId;
@@ -51,8 +53,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, mSubId)
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
diff --git a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
index b784dc5..15c15aa 100644
--- a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
+++ b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
@@ -47,8 +47,7 @@
             return;
         }
 
-        final RestrictedPreference restrictedPreference =
-                (RestrictedPreference) screen.findPreference(getPreferenceKey());
+        final RestrictedPreference restrictedPreference = screen.findPreference(getPreferenceKey());
         mAndroidBeamEnabler = new AndroidBeamEnabler(mContext, restrictedPreference);
     }
 
@@ -57,7 +56,7 @@
     public int getAvailabilityStatus() {
         PackageManager pm = mContext.getPackageManager();
         if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)) {
-                return UNSUPPORTED_ON_DEVICE;
+            return UNSUPPORTED_ON_DEVICE;
         }
         return mNfcAdapter != null
                 ? AVAILABLE
diff --git a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
index b0c9168..b02608e 100644
--- a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
@@ -81,16 +81,16 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (DropDownPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         if (mPreference == null) {
             return;
         }
 
-        mPreference.setEntries(new CharSequence[] {
+        mPreference.setEntries(new CharSequence[]{
                 mContext.getText(R.string.nfc_payment_favor_open),
                 mContext.getText(R.string.nfc_payment_favor_default)
         });
-        mPreference.setEntryValues(new CharSequence[] {"1", "0"});
+        mPreference.setEntryValues(new CharSequence[]{"1", "0"});
     }
 
     @Override
@@ -124,7 +124,7 @@
         mPaymentBackend.setForegroundMode(foregroundMode);
         mMetricsFeatureProvider.action(mContext,
                 foregroundMode ? SettingsEnums.ACTION_NFC_PAYMENT_FOREGROUND_SETTING
-                               : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
+                        : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
         return true;
     }
 
diff --git a/src/com/android/settings/nfc/NfcPaymentPreferenceController.java b/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
index a7dd2a6..5215243 100644
--- a/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
@@ -98,7 +98,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (NfcPaymentPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         if (mPreference != null) {
             mPreference.initialize(this);
         }
diff --git a/src/com/android/settings/nfc/SecureNfcPreferenceController.java b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
index 2c23672..cbff3ea 100644
--- a/src/com/android/settings/nfc/SecureNfcPreferenceController.java
+++ b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
@@ -17,7 +17,6 @@
 
 import android.content.Context;
 import android.nfc.NfcAdapter;
-import android.os.SystemProperties;
 
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
@@ -30,7 +29,6 @@
 public class SecureNfcPreferenceController extends TogglePreferenceController
         implements LifecycleObserver, OnResume, OnPause {
 
-    public static final String KEY_TOGGLE_NFC = "nfc_secure_setting";
     private final NfcAdapter mNfcAdapter;
     private SecureNfcEnabler mSecureNfcEnabler;
 
@@ -47,8 +45,7 @@
             return;
         }
 
-        final SwitchPreference switchPreference =
-                (SwitchPreference) screen.findPreference(getPreferenceKey());
+        final SwitchPreference switchPreference = screen.findPreference(getPreferenceKey());
 
         mSecureNfcEnabler = new SecureNfcEnabler(mContext, switchPreference);
     }
@@ -69,8 +66,9 @@
         if (mNfcAdapter == null) {
             return UNSUPPORTED_ON_DEVICE;
         }
-        return mNfcAdapter.deviceSupportsNfcSecure() ? AVAILABLE
-            : UNSUPPORTED_ON_DEVICE;
+        return mNfcAdapter.deviceSupportsNfcSecure()
+                ? AVAILABLE
+                : UNSUPPORTED_ON_DEVICE;
     }
 
     @Override
diff --git a/src/com/android/settings/notification/BootSoundPreferenceController.java b/src/com/android/settings/notification/BootSoundPreferenceController.java
index a687163..2e7327d 100644
--- a/src/com/android/settings/notification/BootSoundPreferenceController.java
+++ b/src/com/android/settings/notification/BootSoundPreferenceController.java
@@ -43,7 +43,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            SwitchPreference preference = (SwitchPreference) screen.findPreference(KEY_BOOT_SOUNDS);
+            SwitchPreference preference = screen.findPreference(KEY_BOOT_SOUNDS);
             preference.setChecked(SystemProperties.getBoolean(PROPERTY_BOOT_SOUNDS, true));
         }
     }
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index 1563bc4..1c024e3 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -92,13 +92,13 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mLockscreen = (RestrictedListPreference) screen.findPreference(mSettingKey);
+        mLockscreen = screen.findPreference(mSettingKey);
         if (mLockscreen == null) {
             Log.i(TAG, "Preference not found: " + mSettingKey);
             return;
         }
         if (mProfileUserId != UserHandle.USER_NULL) {
-            mLockscreenProfile = (RestrictedListPreference) screen.findPreference(mWorkSettingKey);
+            mLockscreenProfile = screen.findPreference(mWorkSettingKey);
             mLockscreenProfile.setRequiresActiveUnlockedProfile(true);
             mLockscreenProfile.setProfileUserId(mProfileUserId);
         } else {
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 1c8c88e..1ec3c4f 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -118,7 +118,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mCategory = screen.findPreference(getPreferenceKey());
         mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
         mDivider = screen.findPreference(KEY_DIVIDER);
         super.displayPreference(screen);
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index d0b098c..e53a560 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -67,7 +67,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        mPreference = (NotificationSoundPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     public void updateState(Preference preference) {
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java b/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
index 32f2aa6..fff9aaf 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
@@ -54,7 +54,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreference = (VolumeSeekBarPreference) screen.findPreference(getPreferenceKey());
+            mPreference = screen.findPreference(getPreferenceKey());
             mPreference.setCallback(mVolumePreferenceCallback);
             mPreference.setStream(getAudioStream());
             mPreference.setMuteIcon(getMuteIcon());
diff --git a/src/com/android/settings/notification/WorkSoundPreferenceController.java b/src/com/android/settings/notification/WorkSoundPreferenceController.java
index c708b37..e23d9ea 100644
--- a/src/com/android/settings/notification/WorkSoundPreferenceController.java
+++ b/src/com/android/settings/notification/WorkSoundPreferenceController.java
@@ -100,7 +100,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mWorkPreferenceCategory = (PreferenceGroup) screen.findPreference(KEY_WORK_CATEGORY);
+        mWorkPreferenceCategory = screen.findPreference(KEY_WORK_CATEGORY);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java b/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
index e5ca754..807d944 100644
--- a/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
+++ b/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        LayoutPreference pref = (LayoutPreference) screen.findPreference(KEY);
+        LayoutPreference pref = screen.findPreference(KEY);
         mSwitchBar = pref.findViewById(R.id.switch_bar);
 
         if (mSwitchBar != null) {
diff --git a/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java b/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
index 7da90c8..499bfbc 100644
--- a/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
         mPreferenceCategory.setPersistent(false);
     }
 
diff --git a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
index 9872188..cec97f5 100644
--- a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ListPreference) screen.findPreference(KEY);
+        mPreference = screen.findPreference(KEY);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
index cfda367..752edf2 100644
--- a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ListPreference) screen.findPreference(KEY);
+        mPreference = screen.findPreference(KEY);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
index 07e3429..14285d6 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
@@ -49,7 +49,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         mPreference.setOnRadioButtonClickListener(this);
     }
 
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
index 6948669..837f999 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
@@ -51,7 +51,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnGearClickListener(p -> {
             launchCustomSettings();
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
index 7f729c7..4a58c62 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
@@ -49,7 +49,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         mPreference.setOnRadioButtonClickListener(this);
     }
 
diff --git a/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java b/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
index e41d55f..527803df 100644
--- a/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
@@ -39,7 +39,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnGearClickListener(p -> {
             setCustomPolicy();
diff --git a/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java b/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
index da40e6c..b4036fa 100644
--- a/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
@@ -40,7 +40,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnRadioButtonClickListener(p -> {
             mRule.setZenPolicy(null);
diff --git a/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java b/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
index 1c6874e..7b7eae2 100644
--- a/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
@@ -41,7 +41,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnRadioButtonClickListener(p -> {
             mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_ZEN_SOUND_ONLY,
diff --git a/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java b/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
index 3cdd86a..2314c5a 100644
--- a/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
@@ -41,7 +41,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnGearClickListener(p -> {
             launchCustomSettings();
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index d20b75a..4e4fc0c 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.panel;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
@@ -64,4 +65,9 @@
     public Intent getSeeMoreIntent() {
         return new Intent(Settings.ACTION_WIRELESS_SETTINGS);
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_INTERNET_CONNECTIVITY;
+    }
 }
diff --git a/src/com/android/settings/panel/MediaOutputPanel.java b/src/com/android/settings/panel/MediaOutputPanel.java
index f7639d9..c42906d 100644
--- a/src/com/android/settings/panel/MediaOutputPanel.java
+++ b/src/com/android/settings/panel/MediaOutputPanel.java
@@ -19,6 +19,7 @@
 import static com.android.settings.media.MediaOutputSlice.MEDIA_PACKAGE_NAME;
 import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
@@ -71,4 +72,9 @@
     public Intent getSeeMoreIntent() {
         return null;
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_MEDIA_OUTPUT;
+    }
 }
diff --git a/src/com/android/settings/panel/NfcPanel.java b/src/com/android/settings/panel/NfcPanel.java
index 70452a3..8fa41d9 100644
--- a/src/com/android/settings/panel/NfcPanel.java
+++ b/src/com/android/settings/panel/NfcPanel.java
@@ -50,4 +50,9 @@
         intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
         return intent;
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_NFC;
+    }
 }
diff --git a/src/com/android/settings/panel/PanelContent.java b/src/com/android/settings/panel/PanelContent.java
index bd84c2f..496bac3 100644
--- a/src/com/android/settings/panel/PanelContent.java
+++ b/src/com/android/settings/panel/PanelContent.java
@@ -19,12 +19,14 @@
 import android.content.Intent;
 import android.net.Uri;
 
+import com.android.settingslib.core.instrumentation.Instrumentable;
+
 import java.util.List;
 
 /**
  * Represents the data class needed to create a Settings Panel. See {@link PanelFragment}.
  */
-public interface PanelContent {
+public interface PanelContent extends Instrumentable {
 
     /**
      * @return a string for the title of the Panel.
diff --git a/src/com/android/settings/panel/PanelFeatureProvider.java b/src/com/android/settings/panel/PanelFeatureProvider.java
index 5af5ac8..85e098d 100644
--- a/src/com/android/settings/panel/PanelFeatureProvider.java
+++ b/src/com/android/settings/panel/PanelFeatureProvider.java
@@ -21,7 +21,8 @@
 public interface PanelFeatureProvider {
 
     /**
-     * Returns {@link PanelContent} as specified by the {@code panelType} and {@code packageName}.
+     * Returns {@link PanelContent} as specified by the {@param panelType}, and
+     * {@param mediaPackageName}.
      */
-    PanelContent getPanel(Context context, String panelType, String packageName);
+    PanelContent getPanel(Context context, String panelType, String mediaPackageName);
 }
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index c3d611d..6b096a1 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -24,7 +24,7 @@
 public class PanelFeatureProviderImpl implements PanelFeatureProvider {
 
     @Override
-    public PanelContent getPanel(Context context, String panelType, String packageName) {
+    public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
         switch (panelType) {
             case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
                 return InternetConnectivityPanel.create(context);
@@ -33,7 +33,7 @@
             case Settings.Panel.ACTION_NFC:
                 return NfcPanel.create(context);
             case ACTION_MEDIA_OUTPUT:
-                return MediaOutputPanel.create(context, packageName);
+                return MediaOutputPanel.create(context, mediaPackageName);
         }
 
         throw new IllegalStateException("No matching panel for: "  + panelType);
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index db0bf0e..a222d36 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -16,9 +16,9 @@
 
 package com.android.settings.panel;
 
-import android.content.Intent;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -35,6 +35,8 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 public class PanelFragment extends Fragment {
 
@@ -45,15 +47,15 @@
     private Button mDoneButton;
     private RecyclerView mPanelSlices;
 
+    private PanelContent mPanel;
+    private final MetricsFeatureProvider mMetricsProvider;
+
     @VisibleForTesting
     PanelSlicesAdapter mAdapter;
 
-    private View.OnClickListener mDoneButtonListener = (v) -> {
-        Log.d(TAG, "Closing dialog");
-        getActivity().finish();
-    };
-
     public PanelFragment() {
+        final Context context = getActivity();
+        mMetricsProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
     }
 
     @Nullable
@@ -69,38 +71,70 @@
         mTitleView = view.findViewById(R.id.panel_title);
 
         final Bundle arguments = getArguments();
-        final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
-        final String packageName =
-                arguments.getString(SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME);
+        final String panelType =
+                arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
+        final String callingPackageName =
+                arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
+        final String mediaPackageName =
+                arguments.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
 
-        final PanelContent panel = FeatureFactory.getFactory(activity)
+        // TODO (b/124399577) transform interface to take a context and bundle.
+        mPanel = FeatureFactory.getFactory(activity)
                 .getPanelFeatureProvider()
-                .getPanel(activity, panelType, packageName);
+                .getPanel(activity, panelType, mediaPackageName);
 
-        mAdapter = new PanelSlicesAdapter(this, panel.getSlices());
+        // Log panel opened.
+        mMetricsProvider.action(
+                0 /* attribution */,
+                SettingsEnums.PAGE_VISIBLE /* opened panel - Action */,
+                mPanel.getMetricsCategory(),
+                callingPackageName,
+                0 /* value */);
+
+        mAdapter = new PanelSlicesAdapter(this, mPanel);
 
         mPanelSlices.setHasFixedSize(true);
         mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
         mPanelSlices.setAdapter(mAdapter);
 
-        mTitleView.setText(panel.getTitle());
+        mTitleView.setText(mPanel.getTitle());
 
-        mSeeMoreButton.setOnClickListener(getSeeMoreListener(panel.getSeeMoreIntent()));
-        mDoneButton.setOnClickListener(mDoneButtonListener);
+        mSeeMoreButton.setOnClickListener(getSeeMoreListener());
+        mDoneButton.setOnClickListener(getCloseListener());
 
         //If getSeeMoreIntent() is null, hide the mSeeMoreButton.
-        if (panel.getSeeMoreIntent() == null) {
+        if (mPanel.getSeeMoreIntent() == null) {
             mSeeMoreButton.setVisibility(View.GONE);
         }
 
         return view;
     }
 
-    private View.OnClickListener getSeeMoreListener(final Intent intent) {
+    @VisibleForTesting
+    View.OnClickListener getSeeMoreListener() {
         return (v) -> {
+            mMetricsProvider.action(
+                    0 /* attribution */,
+                    SettingsEnums.PAGE_HIDE ,
+                    mPanel.getMetricsCategory(),
+                    PanelClosedKeys.KEY_SEE_MORE,
+                    0 /* value */);
             final FragmentActivity activity = getActivity();
-            activity.startActivity(intent);
+            activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
             activity.finish();
         };
     }
+
+    @VisibleForTesting
+    View.OnClickListener getCloseListener() {
+        return (v) -> {
+            mMetricsProvider.action(
+                    0 /* attribution */,
+                    SettingsEnums.PAGE_HIDE,
+                    mPanel.getMetricsCategory(),
+                    PanelClosedKeys.KEY_DONE,
+                    0 /* value */);
+            getActivity().finish();
+        };
+    }
 }
diff --git a/src/com/android/settings/panel/PanelLoggingContract.java b/src/com/android/settings/panel/PanelLoggingContract.java
new file mode 100644
index 0000000..e149186
--- /dev/null
+++ b/src/com/android/settings/panel/PanelLoggingContract.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.panel;
+
+/**
+ * Simple contract class to track keys in Panel logging.
+ *
+ * <p>
+ *    Constants should only be removed if underlying panel, or use case is removed.
+ * </p>
+ */
+public class PanelLoggingContract {
+
+    /**
+     * Keys tracking different ways users exit Panels.
+     */
+    interface PanelClosedKeys {
+        /**
+         * The user clicked the See More button linking deeper into Settings.
+         */
+        String KEY_SEE_MORE = "see_more";
+
+        /**
+         * The user clicked the Done button, closing the Panel.
+         */
+        String KEY_DONE = "done";
+
+        /**
+         * The user clicked outside the dialog, closing the Panel.
+         */
+        String KEY_CLICKED_OUT = "clicked_out";
+    }
+}
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index f688512..c1cb049 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.panel;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.net.Uri;
 import android.view.LayoutInflater;
@@ -31,8 +32,8 @@
 import androidx.slice.widget.SliceView;
 
 import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -43,10 +44,12 @@
 
     private final List<Uri> mSliceUris;
     private final PanelFragment mPanelFragment;
+    private final PanelContent mPanelContent;
 
-    public PanelSlicesAdapter(PanelFragment fragment, List<Uri> sliceUris) {
+    public PanelSlicesAdapter(PanelFragment fragment, PanelContent panel) {
         mPanelFragment = fragment;
-        mSliceUris = new ArrayList<>(sliceUris);
+        mSliceUris = panel.getSlices();
+        mPanelContent = panel;
     }
 
     @NonNull
@@ -56,7 +59,7 @@
         final LayoutInflater inflater = LayoutInflater.from(context);
         final View view = inflater.inflate(R.layout.panel_slice_row, viewGroup, false);
 
-        return new SliceRowViewHolder(view);
+        return new SliceRowViewHolder(view, mPanelContent);
     }
 
     @Override
@@ -79,22 +82,38 @@
      */
     public static class SliceRowViewHolder extends RecyclerView.ViewHolder {
 
+        private final PanelContent mPanelContent;
+
         @VisibleForTesting
         LiveData<Slice> sliceLiveData;
 
         @VisibleForTesting
         final SliceView sliceView;
 
-        public SliceRowViewHolder(View view) {
+        public SliceRowViewHolder(View view, PanelContent panelContent) {
             super(view);
             sliceView = view.findViewById(R.id.slice_view);
             sliceView.setMode(SliceView.MODE_LARGE);
+            mPanelContent = panelContent;
         }
 
         public void onBind(PanelFragment fragment, Uri sliceUri) {
             final Context context = sliceView.getContext();
             sliceLiveData = SliceLiveData.fromUri(context, sliceUri);
             sliceLiveData.observe(fragment.getViewLifecycleOwner(), sliceView);
+
+            // Log Panel interaction
+            sliceView.setOnSliceActionListener(
+                    ((eventInfo, sliceItem) -> {
+                        FeatureFactory.getFactory(context)
+                                .getMetricsFeatureProvider()
+                                .action(0 /* attribution */,
+                                        SettingsEnums.ACTION_PANEL_INTERACTION,
+                                        mPanelContent.getMetricsCategory(),
+                                        sliceUri.toString() /* log key */,
+                                        eventInfo.actionType /* value */);
+                    })
+            );
         }
     }
 }
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 4cf535e..3819c80 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -19,11 +19,13 @@
 import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
 import static com.android.settingslib.media.MediaOutputSliceConstants.EXTRA_PACKAGE_NAME;
 
+import android.app.settings.SettingsEnums;
 import android.content.Intent;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.Gravity;
+import android.view.MotionEvent;
 import android.view.Window;
 import android.view.WindowManager;
 
@@ -34,6 +36,8 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
 
 /**
  * Dialog Activity to host Settings Slices.
@@ -49,7 +53,16 @@
      * Key specifying which Panel the app is requesting.
      */
     public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
-    public static final String KEY_PANEL_PACKAGE_NAME = "PANEL_PACKAGE_NAME";
+
+    /**
+     * Key specifying the package which requested the Panel.
+     */
+    public static final String KEY_CALLING_PACKAGE_NAME = "PANEL_CALLING_PACKAGE_NAME";
+
+    /**
+     * Key specifying the package name for which the
+     */
+    public static final String KEY_MEDIA_PACKAGE_NAME = "PANEL_MEDIA_PACKAGE_NAME";
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -62,12 +75,12 @@
             return;
         }
 
-        final String packageName =
+        final String mediaPackageName =
                 callingIntent.getStringExtra(EXTRA_PACKAGE_NAME);
 
         if (TextUtils.equals(ACTION_MEDIA_OUTPUT, callingIntent.getAction())
-                && TextUtils.isEmpty(packageName)) {
-            Log.e(TAG, "Null package name, closing Panel Activity");
+                && TextUtils.isEmpty(mediaPackageName)) {
+            Log.e(TAG, "Missing EXTRA_PACKAGE_NAME, closing Panel Activity");
             finish();
             return;
         }
@@ -81,7 +94,8 @@
                 WindowManager.LayoutParams.WRAP_CONTENT);
 
         mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
-        mBundle.putString(KEY_PANEL_PACKAGE_NAME, packageName);
+        mBundle.putString(KEY_CALLING_PACKAGE_NAME, getCallingPackage());
+        mBundle.putString(KEY_MEDIA_PACKAGE_NAME, mediaPackageName);
 
         final PanelFragment panelFragment = new PanelFragment();
         panelFragment.setArguments(mBundle);
@@ -92,4 +106,21 @@
             fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
         }
     }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
+            final PanelContent panelContent = FeatureFactory.getFactory(this)
+                    .getPanelFeatureProvider()
+                    .getPanel(this, getIntent().getAction(), null /* Media Package Name */);
+            FeatureFactory.getFactory(this)
+                    .getMetricsFeatureProvider()
+                    .action(0 /* attribution */,
+                            SettingsEnums.PAGE_HIDE,
+                            panelContent.getMetricsCategory(),
+                            PanelClosedKeys.KEY_CLICKED_OUT,
+                            0 /* value */);
+        }
+        return super.onTouchEvent(event);
+    }
 }
diff --git a/src/com/android/settings/panel/VolumePanel.java b/src/com/android/settings/panel/VolumePanel.java
index 352fed5..20c2272 100644
--- a/src/com/android/settings/panel/VolumePanel.java
+++ b/src/com/android/settings/panel/VolumePanel.java
@@ -21,6 +21,7 @@
 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_RINGER_URI;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
@@ -62,4 +63,9 @@
     public Intent getSeeMoreIntent() {
         return new Intent(Settings.ACTION_SOUND_SETTINGS);
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_VOLUME;
+    }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
new file mode 100644
index 0000000..8aff223
--- /dev/null
+++ b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.privacy;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.Context;
+import android.view.accessibility.AccessibilityManager;
+
+import androidx.annotation.NonNull;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import java.util.List;
+
+
+public class AccessibilityUsagePreferenceController extends BasePreferenceController  {
+
+    private final @NonNull List<AccessibilityServiceInfo> mEnabledServiceInfos;
+
+    public AccessibilityUsagePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+
+        final AccessibilityManager accessibilityManager = context.getSystemService(
+                AccessibilityManager.class);
+        mEnabledServiceInfos = accessibilityManager.getEnabledAccessibilityServiceList(
+                AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return mEnabledServiceInfos.isEmpty() ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        return mContext.getResources().getQuantityString(R.plurals.accessibility_usage_summary,
+                mEnabledServiceInfos.size(), mEnabledServiceInfos.size());
+    }
+}
diff --git a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
index 8b9b595..82464c9 100644
--- a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
+++ b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
@@ -73,7 +73,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mBarChartPreference = (BarChartPreference) screen.findPreference(getPreferenceKey());
+        mBarChartPreference = screen.findPreference(getPreferenceKey());
 
         final BarChartInfo info = new BarChartInfo.Builder()
                 .setTitle(R.string.permission_bar_chart_title)
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index 8f1d4c7..5823407 100644
--- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java
+++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
@@ -16,9 +16,16 @@
 
 package com.android.settings.privacy;
 
+import android.app.ActionBar;
+import android.app.Activity;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
+import android.os.Bundle;
 import android.provider.SearchIndexableResource;
+import android.util.Log;
+import android.view.View;
+
+import androidx.annotation.VisibleForTesting;
 
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
@@ -27,13 +34,14 @@
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.ActionBarShadowController;
 
 import java.util.ArrayList;
 import java.util.List;
 
 @SearchIndexable
 public class PrivacyDashboardFragment extends DashboardFragment {
-    private static final String TAG = "PrivacyDashboardFragment";
+    private static final String TAG = "PrivacyDashboardFrag";
     private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "privacy_lock_screen_notifications";
     private static final String KEY_WORK_PROFILE_CATEGORY =
             "privacy_work_profile_notifications_category";
@@ -65,6 +73,30 @@
         return buildPreferenceControllers(context, getSettingsLifecycle());
     }
 
+    @Override
+    public void onViewCreated(View view, Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        styleActionBar();
+    }
+
+    @VisibleForTesting
+    void styleActionBar() {
+        final Activity activity = getActivity();
+        final ActionBar actionBar = activity.getActionBar();
+        final Lifecycle lifecycle = getSettingsLifecycle();
+        final View scrollView = getListView();
+
+        if (actionBar == null) {
+            Log.w(TAG, "No actionbar, cannot style actionbar.");
+            return;
+        }
+
+        actionBar.setElevation(0);
+        if (lifecycle != null && scrollView != null) {
+            ActionBarShadowController.attachToView(activity, lifecycle, scrollView);
+        }
+    }
+
     private static List<AbstractPreferenceController> buildPreferenceControllers(
             Context context, Lifecycle lifecycle) {
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
diff --git a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
index a58c528..650b1e3 100644
--- a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
@@ -79,7 +79,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (RestrictedPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index 1aebe24..978986c 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -77,7 +77,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mUnifyProfile = (RestrictedSwitchPreference) screen.findPreference(KEY_UNIFICATION);
+        mUnifyProfile = screen.findPreference(KEY_UNIFICATION);
     }
 
     public LockUnificationPreferenceController(Context context, SecuritySettings host) {
diff --git a/src/com/android/settings/security/OwnerInfoPreferenceController.java b/src/com/android/settings/security/OwnerInfoPreferenceController.java
index f7a20ba..5276722 100644
--- a/src/com/android/settings/security/OwnerInfoPreferenceController.java
+++ b/src/com/android/settings/security/OwnerInfoPreferenceController.java
@@ -61,7 +61,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mOwnerInfoPref  = (RestrictedPreference) screen.findPreference(KEY_OWNER_INFO);
+        mOwnerInfoPref  = screen.findPreference(KEY_OWNER_INFO);
     }
 
     @Override
diff --git a/src/com/android/settings/security/ResetCredentialsPreferenceController.java b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
index ee09bca..0700b46 100644
--- a/src/com/android/settings/security/ResetCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
@@ -52,7 +52,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (RestrictedPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index 6f5d7eb..eb50b7c 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -91,7 +91,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mSecurityCategory = (PreferenceCategory) screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
+        mSecurityCategory = screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
         updateTrustAgents();
     }
 
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index 8b4bb74..8f85431 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -449,14 +449,14 @@
         int iconResource = data.getIconResource();
 
         if (iconResource == 0) {
-            iconResource = R.drawable.ic_settings;
+            iconResource = R.drawable.ic_settings_accent;
         }
         try {
             return IconCompat.createWithResource(context, iconResource);
         } catch (Exception e) {
             Log.w(TAG, "Falling back to settings icon because there is an error getting slice icon "
                     + data.getUri(), e);
-            return IconCompat.createWithResource(context, R.drawable.ic_settings);
+            return IconCompat.createWithResource(context, R.drawable.ic_settings_accent);
         }
     }
 }
diff --git a/src/com/android/settings/widget/AdaptiveHomepageIcon.java b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
index bec5d8d..bc7aaa7 100644
--- a/src/com/android/settings/widget/AdaptiveHomepageIcon.java
+++ b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
@@ -72,11 +72,13 @@
                 // If found anything, use it.
                 if (bgColor != 0) {
                     setBackgroundColor(bgColor);
+                    return;
                 }
             }
         } catch (PackageManager.NameNotFoundException e) {
             Log.e(TAG, "Failed to set background color for " + tile.getPackageName());
         }
+        setBackgroundColor(context.getColor(R.color.homepage_generic_icon_background));
     }
 
     public void setBackgroundColor(int color) {
diff --git a/src/com/android/settings/widget/AddPreference.java b/src/com/android/settings/widget/AddPreference.java
index ce36ab3..2183fd4 100644
--- a/src/com/android/settings/widget/AddPreference.java
+++ b/src/com/android/settings/widget/AddPreference.java
@@ -34,6 +34,7 @@
 
     private OnAddClickListener mListener;
     private View mWidgetFrame;
+    private View mAddWidget;
 
     public AddPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -53,6 +54,12 @@
        }
     }
 
+    public void setAddWidgetEnabled(boolean enabled) {
+        if (mAddWidget != null) {
+            mAddWidget.setEnabled(enabled);
+        }
+    }
+
     @Override
     protected int getSecondTargetResId() {
         return R.layout.preference_widget_add;
@@ -67,9 +74,9 @@
     public void onBindViewHolder(PreferenceViewHolder holder) {
         super.onBindViewHolder(holder);
         mWidgetFrame = holder.findViewById(android.R.id.widget_frame);
-        final View addWidget = holder.findViewById(getAddWidgetResId());
-        addWidget.setEnabled(true);
-        addWidget.setOnClickListener(this);
+        mAddWidget = holder.findViewById(getAddWidgetResId());
+        mAddWidget.setEnabled(true);
+        mAddWidget.setOnClickListener(this);
     }
 
     @Override
diff --git a/src/com/android/settings/widget/VideoPreferenceController.java b/src/com/android/settings/widget/VideoPreferenceController.java
index a7bb754..78a837c 100644
--- a/src/com/android/settings/widget/VideoPreferenceController.java
+++ b/src/com/android/settings/widget/VideoPreferenceController.java
@@ -43,7 +43,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mVideoPreference = (VideoPreference) screen.findPreference(getPreferenceKey());
+        mVideoPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
index 33eaceb..36c4455 100644
--- a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
@@ -99,7 +99,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(mPreferenceGroupKey);
+        mPreferenceGroup = screen.findPreference(mPreferenceGroupKey);
         mPrefContext = screen.getContext();
         update();
     }
diff --git a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
index 692608c..6a4774b 100644
--- a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
@@ -53,7 +53,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mWifiPreference = (MasterSwitchPreference) screen.findPreference(KEY_TOGGLE_WIFI);
+        mWifiPreference = screen.findPreference(KEY_TOGGLE_WIFI);
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 881e3d2..2e12bce 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -203,7 +203,7 @@
         super.onViewCreated(view, savedInstanceState);
         final Activity activity = getActivity();
         if (activity != null) {
-            mProgressHeader = setPinnedHeaderView(R.layout.wifi_progress_header)
+            mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
                     .findViewById(R.id.progress_bar_animation);
             setProgressBarVisible(false);
         }
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index 435f8f1..15bffd9 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -62,7 +62,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (SwitchPreference) screen.findPreference(KEY_ENABLE_WIFI_WAKEUP);
+        mPreference = screen.findPreference(KEY_ENABLE_WIFI_WAKEUP);
         updateState(mPreference);
     }
 
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 40cc0dc..9ed2035 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -29,6 +29,7 @@
 import android.telephony.PhoneStateListener;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
+import android.telephony.ims.ProvisioningManager;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -44,7 +45,9 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.ims.ImsConfig;
+import com.android.ims.ImsException;
 import com.android.ims.ImsManager;
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.Phone;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -152,6 +155,19 @@
                 }
             };
 
+    private final ProvisioningManager.Callback mProvisioningCallback =
+            new ProvisioningManager.Callback() {
+                @Override
+                public void onProvisioningIntChanged(int item, int value) {
+                    if (item == ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED
+                            || item == ImsConfig.ConfigConstants.VLT_SETTING_ENABLED) {
+                        // The provisioning policy might have changed. Update the body to make sure
+                        // this change takes effect if needed.
+                        updateBody();
+                    }
+                }
+            };
+
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
@@ -221,6 +237,11 @@
         return 0;
     }
 
+    @VisibleForTesting
+    ImsManager getImsManager() {
+        return ImsManager.getInstance(getActivity(), SubscriptionManager.getPhoneId(mSubId));
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -236,8 +257,7 @@
                     FRAGMENT_BUNDLE_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
         }
 
-        mImsManager = ImsManager.getInstance(
-                getActivity(), SubscriptionManager.getPhoneId(mSubId));
+        mImsManager = getImsManager();
 
         mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
                 .createForSubscriptionId(mSubId);
@@ -277,6 +297,13 @@
     }
 
     private void updateBody() {
+        if (!mImsManager.isWfcProvisionedOnDevice()) {
+            // This screen is not allowed to be shown due to provisioning policy and should
+            // therefore be closed.
+            finish();
+            return;
+        }
+
         CarrierConfigManager configManager = (CarrierConfigManager)
                 getSystemService(Context.CARRIER_CONFIG_SERVICE);
         boolean isWifiOnlySupported = true;
@@ -336,6 +363,14 @@
         if (intent.getBooleanExtra(Phone.EXTRA_KEY_ALERT_SHOW, false)) {
             showAlert(intent);
         }
+
+        // Register callback for provisioning changes.
+        try {
+            mImsManager.getConfigInterface().addConfigCallback(mProvisioningCallback);
+        } catch (ImsException e) {
+            Log.w(TAG, "onResume: Unable to register callback for provisioning changes.");
+        }
+
     }
 
     @Override
@@ -354,6 +389,15 @@
         }
 
         context.unregisterReceiver(mIntentReceiver);
+
+        // Remove callback for provisioning changes.
+        try {
+            mImsManager.getConfigInterface().removeConfigCallback(
+                    mProvisioningCallback.getBinder());
+        } catch (ImsException e) {
+            Log.w(TAG, "onPause: Unable to remove callback for provisioning changes");
+        }
+
     }
 
     /**
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 27db7cd..2efd4fc 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -305,14 +305,14 @@
         mSubnetPref = screen.findPreference(KEY_SUBNET_MASK_PREF);
         mDnsPref = screen.findPreference(KEY_DNS_PREF);
 
-        mIpv6Category = (PreferenceCategory) screen.findPreference(KEY_IPV6_CATEGORY);
+        mIpv6Category = screen.findPreference(KEY_IPV6_CATEGORY);
         mIpv6AddressPref = screen.findPreference(KEY_IPV6_ADDRESSES_PREF);
 
         mSecurityPref.setSummary(mAccessPoint.getSecurityString(/* concise */ false));
     }
 
     private void setupEntityHeader(PreferenceScreen screen) {
-        LayoutPreference headerPref = (LayoutPreference) screen.findPreference(KEY_HEADER);
+        LayoutPreference headerPref = screen.findPreference(KEY_HEADER);
         mEntityHeaderController =
                 EntityHeaderController.newInstance(
                         mFragment.getActivity(), mFragment,
@@ -502,7 +502,7 @@
     private static String ipv4PrefixLengthToSubnetMask(int prefixLength) {
         try {
             InetAddress all = InetAddress.getByAddress(
-                    new byte[] {(byte) 255, (byte) 255, (byte) 255, (byte) 255});
+                    new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255});
             return NetworkUtils.getNetworkPart(all, prefixLength).getHostAddress();
         } catch (UnknownHostException e) {
             return null;
diff --git a/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java b/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
index ac8113b..032649c 100644
--- a/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
+++ b/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
@@ -42,7 +42,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mCategory = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mCategory = screen.findPreference(getPreferenceKey());
     }
 
     public void removeAllChildren() {
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
index dea4443..4155ef7 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
@@ -76,7 +76,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 6e30b9e..b6fc17c 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -159,7 +159,7 @@
 
     private IconCompat getEndIcon(AccessPoint accessPoint) {
         if (accessPoint.isActive()) {
-            return IconCompat.createWithResource(mContext, R.drawable.ic_settings);
+            return IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent);
         } else if (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
             return IconCompat.createWithResource(mContext, R.drawable.ic_friction_lock_closed);
         } else if (accessPoint.isMetered()) {
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
index 951f203..3f4e82d 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -181,6 +181,15 @@
         verify(mContext, never()).unregisterReceiver(any());
     }
 
+    @Test
+    public void getConnectedHearingAidDevice_doNotReturnSubDevice() {
+        when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
+        when(mLocalBluetoothManager.getCachedDeviceManager().isSubDevice(mBluetoothDevice))
+                .thenReturn(true);
+
+        assertThat(mPreferenceController.getConnectedHearingAidDevice()).isNull();
+    }
+
     private void setupBluetoothEnvironment() {
         ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
         mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
index 4561ab6..6cecd98 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
@@ -345,6 +345,70 @@
         assertThat(uids.get(2)).isEqualTo(789);
     }
 
+    @Test
+    public void onCreateLoader_hasCyclesSpecified_shouldQueryDataUsageForSpecifiedCycles() {
+        final long startTime = 1521583200000L;
+        final long endTime = 1521676800000L;
+        ArrayList<Long> testCycles = new ArrayList<>();
+        testCycles.add(endTime);
+        testCycles.add(startTime);
+        final int uid = 123;
+        final AppItem appItem = new AppItem(uid);
+        appItem.category = AppItem.CATEGORY_APP;
+        appItem.addUid(uid);
+
+        mFragment = new AppDataUsage();
+        ReflectionHelpers.setField(mFragment, "mContext", RuntimeEnvironment.application);
+        ReflectionHelpers.setField(mFragment, "mCycles", testCycles);
+        ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
+        ReflectionHelpers.setField(mFragment, "mTemplate",
+            NetworkTemplate.buildTemplateWifiWildcard());
+
+        final NetworkCycleDataForUidLoader loader = (NetworkCycleDataForUidLoader)
+            mFragment.mUidDataCallbacks.onCreateLoader(0 /* id */, Bundle.EMPTY /* args */);
+
+        final ArrayList<Long> cycles = loader.getCycles();
+        assertThat(cycles).hasSize(2);
+        assertThat(cycles.get(0)).isEqualTo(endTime);
+        assertThat(cycles.get(1)).isEqualTo(startTime);
+    }
+
+    @Test
+    public void onLoadFinished_hasSelectedCycleSpecified_shouldSelectSpecifiedCycle() {
+        final long now = System.currentTimeMillis();
+        final long tenDaysAgo = now - (DateUtils.DAY_IN_MILLIS * 10);
+        final long twentyDaysAgo = now - (DateUtils.DAY_IN_MILLIS * 20);
+        final long thirtyDaysAgo = now - (DateUtils.DAY_IN_MILLIS * 30);
+        final List<NetworkCycleDataForUid> data = new ArrayList<>();
+        NetworkCycleDataForUid.Builder builder = new NetworkCycleDataForUid.Builder();
+        builder.setStartTime(thirtyDaysAgo).setEndTime(twentyDaysAgo).setTotalUsage(9876L);
+        data.add(builder.build());
+        builder = new NetworkCycleDataForUid.Builder();
+        builder.setStartTime(twentyDaysAgo).setEndTime(tenDaysAgo).setTotalUsage(5678L);
+        data.add(builder.build());
+        builder = new NetworkCycleDataForUid.Builder();
+        builder.setStartTime(tenDaysAgo).setEndTime(now).setTotalUsage(1234L);
+        data.add(builder.build());
+
+        mFragment = new AppDataUsage();
+        ReflectionHelpers.setField(mFragment, "mContext", RuntimeEnvironment.application);
+        ReflectionHelpers.setField(mFragment, "mCycleAdapter", mock(CycleAdapter.class));
+        ReflectionHelpers.setField(mFragment, "mSelectedCycle", tenDaysAgo);
+        final Preference backgroundPref = mock(Preference.class);
+        ReflectionHelpers.setField(mFragment, "mBackgroundUsage", backgroundPref);
+        final Preference foregroundPref = mock(Preference.class);
+        ReflectionHelpers.setField(mFragment, "mForegroundUsage", foregroundPref);
+        final Preference totalPref = mock(Preference.class);
+        ReflectionHelpers.setField(mFragment, "mTotalUsage", totalPref);
+        final SpinnerPreference cycle = mock(SpinnerPreference.class);
+        ReflectionHelpers.setField(mFragment, "mCycle", cycle);
+
+        mFragment.mUidDataCallbacks.onLoadFinished(null /* loader */, data);
+
+        verify(cycle).setSelection(1);
+    }
+
+    @Test
     @Config(shadows = {ShadowDataUsageUtils.class, ShadowSubscriptionManager.class})
     public void onCreate_noNetworkTemplateAndInvalidDataSubscription_shouldUseWifiTemplate() {
         ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = true;
@@ -355,6 +419,10 @@
         mFragment = spy(new AppDataUsage());
         doReturn(Robolectric.setupActivity(FragmentActivity.class)).when(mFragment).getActivity();
         doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
+        final UidDetailProvider uidDetailProvider = mock(UidDetailProvider.class);
+        doReturn(uidDetailProvider).when(mFragment).getUidDetailProvider();
+        doReturn(new UidDetail()).when(uidDetailProvider).getUidDetail(anyInt(), anyBoolean());
+
         ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider",
             FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
         final Bundle args = new Bundle();
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
index 427550c..7d042ce 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
@@ -30,19 +30,27 @@
 import android.net.NetworkTemplate;
 import android.os.Bundle;
 import android.provider.Settings;
+import android.widget.Spinner;
 
+import com.android.settings.SettingsActivity;
 import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settingslib.AppItem;
 import com.android.settingslib.NetworkPolicyEditor;
 import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
+import com.android.settingslib.net.NetworkCycleChartData;
 
 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.RobolectricTestRunner;
 import org.robolectric.util.ReflectionHelpers;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import androidx.fragment.app.FragmentActivity;
 import androidx.preference.PreferenceManager;
 
@@ -124,4 +132,32 @@
         assertThat(mDataUsageList.mTemplate).isNotNull();
         assertThat(mDataUsageList.mSubId).isEqualTo(3);
     }
+
+    @Test
+    public void startAppDataUsage_shouldAddCyclesInfoToLaunchArguments() {
+        final long startTime = 1521583200000L;
+        final long endTime = 1521676800000L;
+        final List<NetworkCycleChartData> data = new ArrayList<>();
+        final NetworkCycleChartData.Builder builder = new NetworkCycleChartData.Builder();
+        builder.setStartTime(startTime)
+            .setEndTime(endTime);
+        data.add(builder.build());
+        ReflectionHelpers.setField(mDataUsageList, "mCycleData", data);
+        final Spinner spinner = mock(Spinner.class);
+        when(spinner.getSelectedItemPosition()).thenReturn(0);
+        ReflectionHelpers.setField(mDataUsageList, "mCycleSpinner", spinner);
+        final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
+
+        mDataUsageList.startAppDataUsage(new AppItem());
+
+        verify(mContext).startActivity(intent.capture());
+        final Bundle arguments =
+            intent.getValue().getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
+        assertThat(arguments.getLong(AppDataUsage.ARG_SELECTED_CYCLE)).isEqualTo(endTime);
+        final ArrayList<Long> cycles =
+            (ArrayList) arguments.getSerializable(AppDataUsage.ARG_NETWORK_CYCLES);
+        assertThat(cycles).hasSize(2);
+        assertThat(cycles.get(0)).isEqualTo(endTime);
+        assertThat(cycles.get(1)).isEqualTo(startTime);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
index 6149539..ecda5fd 100644
--- a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
@@ -17,12 +17,14 @@
 package com.android.settings.gestures;
 
 import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
 import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
 
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -77,6 +79,7 @@
 
     @Test
     public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
         when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
         final int availabilityStatus = mController.getAvailabilityStatus();
 
@@ -85,6 +88,7 @@
 
     @Test
     public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
         when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
         final int availabilityStatus = mController.getAvailabilityStatus();
 
@@ -92,6 +96,25 @@
     }
 
     @Test
+    public void getAvailabilityStatus_gestureSupported_DISABLED_DEPENDENT_SETTING() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+        when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
+        final int availabilityStatus = mController.getAvailabilityStatus();
+
+        assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
+    }
+
+    @Test
+    public void canHandleClicks_onlyWhenAlwaysOn() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+        assertThat(mController.canHandleClicks()).isEqualTo(false);
+
+        reset(mAmbientDisplayConfiguration);
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+        assertThat(mController.canHandleClicks()).isEqualTo(true);
+    }
+
+    @Test
     public void isSliceableCorrectKey_returnsTrue() {
         final WakeScreenGesturePreferenceController controller =
                 new WakeScreenGesturePreferenceController(mContext, "gesture_wake_screen");
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
index 6a1abd1..ba152b9 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
@@ -24,6 +24,7 @@
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.ArgumentMatchers.notNull;
+import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
@@ -33,9 +34,12 @@
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.provider.Settings;
 import android.telephony.SubscriptionInfo;
 import android.telephony.TelephonyManager;
 import android.telephony.euicc.EuiccManager;
+import android.text.TextUtils;
 
 import com.android.settings.network.telephony.MobileNetworkActivity;
 import com.android.settings.widget.AddPreference;
@@ -61,7 +65,8 @@
     private Lifecycle mLifecycle;
     @Mock
     private TelephonyManager mTelephonyManager;
-
+    @Mock
+    private EuiccManager mEuiccManager;
     @Mock
     private PreferenceScreen mPreferenceScreen;
 
@@ -74,7 +79,9 @@
         MockitoAnnotations.initMocks(this);
         mContext = spy(Robolectric.setupActivity(Activity.class));
         when(mContext.getSystemService(eq(TelephonyManager.class))).thenReturn(mTelephonyManager);
+        when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
         when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(UNKNOWN);
+        when(mEuiccManager.isEnabled()).thenReturn(true);
 
         mController = new MobileNetworkSummaryController(mContext, mLifecycle);
         mPreference = spy(new AddPreference(mContext, null));
@@ -89,6 +96,14 @@
     }
 
     @Test
+    public void isAvailable_wifiOnlyMode_notAvailable() {
+        ConnectivityManager cm = mock(ConnectivityManager.class);
+        when(cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
+        when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(cm);
+        assertThat(mController.isAvailable()).isFalse();
+    }
+
+    @Test
     public void getSummary_noSubscriptions_correctSummaryAndClickHandler() {
         mController.displayPreference(mPreferenceScreen);
         mController.onResume();
@@ -102,6 +117,14 @@
     }
 
     @Test
+    public void getSummary_noSubscriptionsNoEuiccMgr_correctSummaryAndClickHandler() {
+        when(mEuiccManager.isEnabled()).thenReturn(false);
+        assertThat(TextUtils.isEmpty(mController.getSummary())).isTrue();
+        assertThat(mPreference.getOnPreferenceClickListener()).isNull();
+        assertThat(mPreference.getFragment()).isNull();
+    }
+
+    @Test
     public void getSummary_oneSubscription_correctSummaryAndClickHandler() {
         final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
         when(sub1.getSubscriptionId()).thenReturn(1);
@@ -205,6 +228,15 @@
     }
 
     @Test
+    public void addButton_noSubscriptionsMultiSimModeNoEuiccMgr_noAddClickListener() {
+        when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+        when(mEuiccManager.isEnabled()).thenReturn(false);
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+        verify(mPreference, never()).setOnAddClickListener(notNull());
+    }
+
+    @Test
     public void addButton_noSubscriptionsMultiSimMode_hasAddClickListenerAndPrefDisabled() {
         when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
         mController.displayPreference(mPreferenceScreen);
@@ -236,4 +268,73 @@
         verify(mPreference, never()).setOnAddClickListener(isNull());
         verify(mPreference).setOnAddClickListener(notNull());
     }
+
+    @Test
+    public void addButton_oneSubscriptionAirplaneModeTurnedOn_addButtonGetsDisabled() {
+        when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+        final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+        mController.onAirplaneModeChanged(true);
+
+        ArgumentCaptor<Boolean> captor = ArgumentCaptor.forClass(Boolean.class);
+        verify(mPreference, atLeastOnce()).setAddWidgetEnabled(captor.capture());
+        assertThat(captor.getValue()).isFalse();
+    }
+
+    @Test
+    public void onResume_oneSubscriptionAirplaneMode_isDisabled() {
+        when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+        final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        ArgumentCaptor<Boolean> captor = ArgumentCaptor.forClass(Boolean.class);
+        verify(mPreference, atLeastOnce()).setAddWidgetEnabled(captor.capture());
+        assertThat(captor.getValue()).isFalse();
+    }
+
+    @Test
+    public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOn_isDisabled() {
+        final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+        mController.onAirplaneModeChanged(true);
+
+        assertThat(mPreference.isEnabled()).isFalse();
+    }
+
+    @Test
+    public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOff_isEnabled() {
+        when(mTelephonyManager.getMultiSimConfiguration()).thenReturn(DSDS);
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
+        final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
+        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
+        mController.onAirplaneModeChanged(false);
+
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        ArgumentCaptor<Boolean> captor = ArgumentCaptor.forClass(Boolean.class);
+        verify(mPreference, atLeastOnce()).setAddWidgetEnabled(eq(false));
+        verify(mPreference, atLeastOnce()).setAddWidgetEnabled(captor.capture());
+        assertThat(captor.getValue()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index e0334b1..dbc122a 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -47,7 +47,7 @@
 
     @Test
     public void getAvailableSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(null);
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(null);
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
         assertThat(subs).isEmpty();
@@ -57,7 +57,7 @@
     public void getAvailableSubscriptions_oneSubscription_oneResult() {
         final SubscriptionInfo info = mock(SubscriptionInfo.class);
         when(info.getMncString()).thenReturn("fake1234");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
         assertThat(subs).hasSize(1);
@@ -69,7 +69,7 @@
         final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
         when(info1.getMncString()).thenReturn("fake1234");
         when(info2.getMncString()).thenReturn("fake5678");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
         assertThat(subs).hasSize(2);
@@ -82,7 +82,7 @@
         final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
         when(info1.getSubscriptionId()).thenReturn(1);
         when(info1.getMncString()).thenReturn("fake1234");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(
                 new ArrayList<>(Arrays.asList(info1, info2, info3)));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
@@ -100,7 +100,7 @@
         when(info1.getMncString()).thenReturn("fake1234");
         when(info4.getSubscriptionId()).thenReturn(4);
         when(info4.getMncString()).thenReturn("fake5678");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(new ArrayList<>(
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(new ArrayList<>(
                 Arrays.asList(info1, info2, info3, info4)));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index 447931e..3b5cdf9 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -148,7 +148,7 @@
         doReturn(intent).when(mMobileNetworkActivity).getIntent();
         mSubscriptionInfos.add(mSubscriptionInfo);
         mSubscriptionInfos.add(mSubscriptionInfo2);
-        doReturn(mSubscriptionInfos).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
+        doReturn(mSubscriptionInfos).when(mSubscriptionManager).getSelectableSubscriptionInfoList();
         doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(CURRENT_SUB_ID);
 
         assertThat(mMobileNetworkActivity.getSubscriptionId()).isEqualTo(CURRENT_SUB_ID);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index a057022..d904ab3 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -84,14 +84,14 @@
 
     @Test
     public void isVideoCallEnabled_allFlagsOn_returnTrue() {
-        assertThat(mController.isVideoCallEnabled()).isTrue();
+        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
     }
 
     @Test
     public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
         doReturn(false).when(mImsManager).isVtEnabledByPlatform();
 
-        assertThat(mController.isVideoCallEnabled()).isFalse();
+        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
     }
 
     @Test
@@ -100,7 +100,7 @@
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
         doReturn(false).when(mTelephonyManager).isDataEnabled();
 
-        assertThat(mController.isVideoCallEnabled()).isFalse();
+        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
index 1d79952..8f54115 100644
--- a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
+++ b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
@@ -18,6 +18,7 @@
 
 import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
 
+import android.app.settings.SettingsEnums;
 import android.content.Intent;
 import android.net.Uri;
 
@@ -53,4 +54,9 @@
     public Intent getSeeMoreIntent() {
         return INTENT;
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.TESTING;
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index 389c31e..be8d8bc 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -22,10 +22,13 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.os.Bundle;
 import android.view.LayoutInflater;
+import android.view.View;
 import android.widget.LinearLayout;
 
 import com.android.settings.R;
@@ -71,13 +74,14 @@
                                 .get()
                                 .getSupportFragmentManager()
                                 .findFragmentById(R.id.main_content));
+
+        final Bundle bundle = new Bundle();
+        bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
+        doReturn(bundle).when(mPanelFragment).getArguments();
     }
 
     @Test
     public void onCreateView_adapterGetsDataset() {
-        final Bundle bundle = new Bundle();
-        bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
-        doReturn(bundle).when(mPanelFragment).getArguments();
         mPanelFragment.onCreateView(LayoutInflater.from(mContext),
                 new LinearLayout(mContext), null);
         PanelSlicesAdapter adapter = mPanelFragment.mAdapter;
@@ -85,4 +89,43 @@
         assertThat(adapter.getData()).containsAllIn(mFakePanelContent.getSlices());
     }
 
+    @Test
+    public void onCreate_logsOpenEvent() {
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_VISIBLE,
+                mFakePanelContent.getMetricsCategory(),
+                null,
+                0);
+    }
+
+    @Test
+    public void panelSeeMoreClick_logsCloseEvent() {
+        final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();
+
+        listener.onClick(null);
+
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_HIDE,
+                mFakePanelContent.getMetricsCategory(),
+                PanelLoggingContract.PanelClosedKeys.KEY_SEE_MORE,
+                0
+        );
+    }
+
+    @Test
+    public void panelDoneClick_logsCloseEvent() {
+        final View.OnClickListener listener = mPanelFragment.getCloseListener();
+
+        listener.onClick(null);
+
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_HIDE,
+                mFakePanelContent.getMetricsCategory(),
+                PanelLoggingContract.PanelClosedKeys.KEY_DONE,
+                0
+        );
+    }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index abefa67..4dce15e 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -71,7 +71,7 @@
                                 .getSupportFragmentManager()
                                 .findFragmentById(R.id.main_content));
 
-        mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent.getSlices());
+        mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index 359cf5d..a51b7b0 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -16,13 +16,25 @@
 
 package com.android.settings.panel;
 
-import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME;
+import static com.android.settings.panel.SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME;
 import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT;
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.content.Intent;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+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.settings.SettingsEnums;
+import android.content.Intent;
+import android.view.MotionEvent;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.Robolectric;
@@ -31,6 +43,22 @@
 @RunWith(RobolectricTestRunner.class)
 public class SettingsPanelActivityTest {
 
+    private FakeFeatureFactory mFakeFeatureFactory;
+    private FakeSettingsPanelActivity mSettingsPanelActivity;
+    private PanelFeatureProvider mPanelFeatureProvider;
+    private FakePanelContent mFakePanelContent;
+
+    @Before
+    public void setUp() {
+        mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
+        mSettingsPanelActivity = Robolectric.buildActivity(FakeSettingsPanelActivity.class)
+                .create().get();
+        mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
+        mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
+        mFakePanelContent = new FakePanelContent();
+        doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
+    }
+
     @Test
     public void startMediaOutputSlice_withPackageName_bundleShouldHaveValue() {
         final Intent intent = new Intent()
@@ -41,7 +69,7 @@
         final SettingsPanelActivity activity =
                 Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
 
-        assertThat(activity.mBundle.getString(KEY_PANEL_PACKAGE_NAME))
+        assertThat(activity.mBundle.getString(KEY_MEDIA_PACKAGE_NAME))
                 .isEqualTo("com.google.android.music");
         assertThat(activity.mBundle.getString(KEY_PANEL_TYPE_ARGUMENT))
                 .isEqualTo("com.android.settings.panel.action.MEDIA_OUTPUT");
@@ -55,7 +83,23 @@
         final SettingsPanelActivity activity =
                 Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
 
-        assertThat(activity.mBundle.containsKey(KEY_PANEL_PACKAGE_NAME)).isFalse();
+        assertThat(activity.mBundle.containsKey(KEY_MEDIA_PACKAGE_NAME)).isFalse();
         assertThat(activity.mBundle.containsKey(KEY_PANEL_TYPE_ARGUMENT)).isFalse();
     }
+
+    @Test
+    public void onTouchEvent_outsideAction_logsPanelClosed() {
+        final MotionEvent event = mock(MotionEvent.class);
+        when(event.getAction()).thenReturn(MotionEvent.ACTION_OUTSIDE);
+
+        mSettingsPanelActivity.onTouchEvent(event);
+
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_HIDE,
+                SettingsEnums.TESTING,
+                PanelLoggingContract.PanelClosedKeys.KEY_CLICKED_OUT,
+                0
+        );
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
new file mode 100644
index 0000000..1033446
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.privacy;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.Context;
+import android.view.accessibility.AccessibilityManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowAccessibilityManager;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+@RunWith(RobolectricTestRunner.class)
+public class AccessibilityUsagePreferenceControllerTest {
+
+    private Context mContext;
+    private ShadowAccessibilityManager mAccessibilityManager;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mAccessibilityManager = Shadow.extract(
+                RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
+    }
+
+    @After
+    public void tearDown() {
+        ShadowAccessibilityManager.reset();
+    }
+
+    @Test
+    public void getAvailabilityStatus_noEnabledServices_shouldReturnUnsupported() {
+        mAccessibilityManager.setEnabledAccessibilityServiceList(new ArrayList<>());
+        AccessibilityUsagePreferenceController controller =
+                new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_enabledServices_shouldReturnAvailableUnsearchable() {
+        mAccessibilityManager.setEnabledAccessibilityServiceList(
+                new ArrayList<>(Arrays.asList(new AccessibilityServiceInfo())));
+        AccessibilityUsagePreferenceController controller =
+                new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
new file mode 100644
index 0000000..d073e9b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.privacy;
+
+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.ActionBar;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class PrivacyDashboardFragmentTest {
+
+    private Context mContext;
+    private PrivacyDashboardFragment mFragment;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mFragment = spy(new PrivacyDashboardFragment());
+    }
+
+    @Test
+    public void onViewCreated_shouldCallStyleActionBar() {
+        final FragmentActivity activity = spy(
+                Robolectric.buildActivity(FragmentActivity.class).get());
+        final ActionBar actionBar = mock(ActionBar.class);
+
+        when(mFragment.getActivity()).thenReturn(activity);
+        when(mFragment.getSettingsLifecycle()).thenReturn(mock(Lifecycle.class));
+        when(mFragment.getListView()).thenReturn(mock(RecyclerView.class));
+        when(activity.getActionBar()).thenReturn(actionBar);
+
+        mFragment.onViewCreated(new View(mContext), new Bundle());
+
+        verify(mFragment).styleActionBar();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index efdcc26..726e4bd 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -99,7 +99,7 @@
     private static final String SUMMARY = "summary";
     private static final String SCREEN_TITLE = "screen title";
     private static final String FRAGMENT_NAME = "fragment name";
-    private static final int ICON = R.drawable.ic_settings;
+    private static final int ICON = R.drawable.ic_settings_accent;
     private static final Uri URI = Uri.parse("content://com.android.settings.slices/test");
     private static final String PREF_CONTROLLER = FakeToggleController.class.getName();
 
@@ -578,7 +578,7 @@
         values.put(SlicesDatabaseHelper.IndexColumns.TITLE, TITLE);
         values.put(SlicesDatabaseHelper.IndexColumns.SUMMARY, "s");
         values.put(SlicesDatabaseHelper.IndexColumns.SCREENTITLE, "s");
-        values.put(SlicesDatabaseHelper.IndexColumns.ICON_RESOURCE, R.drawable.ic_settings);
+        values.put(SlicesDatabaseHelper.IndexColumns.ICON_RESOURCE, R.drawable.ic_settings_accent);
         values.put(SlicesDatabaseHelper.IndexColumns.FRAGMENT, "test");
         values.put(SlicesDatabaseHelper.IndexColumns.CONTROLLER, PREF_CONTROLLER);
         values.put(SlicesDatabaseHelper.IndexColumns.PLATFORM_SLICE, isPlatformSlice);
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index c2d1e93..0a42f42 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -63,7 +63,7 @@
     private final String SCREEN_TITLE = "screen title";
     private final String KEYWORDS = "a, b, c";
     private final String FRAGMENT_NAME = "fragment name";
-    private final int ICON = R.drawable.ic_settings;
+    private final int ICON = R.drawable.ic_settings_accent;
     private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
     private final Class TOGGLE_CONTROLLER = FakeToggleController.class;
     private final Class SLIDER_CONTROLLER = FakeSliderController.class;
@@ -431,7 +431,7 @@
     @Test
     public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
         final int expectedIconResource = IconCompat.createWithResource(mContext,
-                R.drawable.ic_settings).toIcon().getResId();
+                R.drawable.ic_settings_accent).toIcon().getResId();
         final SliceData sliceData = getDummyData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT,
                 0x0);
 
@@ -446,7 +446,7 @@
     @Test
     public void buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon() {
         final int expectedIconResource = IconCompat.createWithResource(mContext,
-                R.drawable.ic_settings).toIcon().getResId();
+                R.drawable.ic_settings_accent).toIcon().getResId();
         final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
                 SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
                 IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
@@ -465,7 +465,7 @@
     @Test
     public void buildToggleSlice_noIconPassed_returnsSliceWithIcon() {
         final int expectedIconResource = IconCompat.createWithResource(mContext,
-                R.drawable.ic_settings).toIcon().getResId();
+                R.drawable.ic_settings_accent).toIcon().getResId();
         final SliceData dummyData = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
                 0x0);
 
@@ -480,7 +480,7 @@
     @Test
     public void buildSliderSlice_noIconPassed_returnsSliceWithIcon() {
         final int expectedIconResource = IconCompat.createWithResource(mContext,
-                R.drawable.ic_settings).toIcon().getResId();
+                R.drawable.ic_settings_accent).toIcon().getResId();
         final SliceData data = getDummyData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER, 0x0);
 
         final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
@@ -493,7 +493,7 @@
 
     @Test
     public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
-        final int settingsIcon = R.drawable.ic_settings;
+        final int settingsIcon = R.drawable.ic_settings_accent;
         final int zeroIcon = 0x0;
         final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
                 zeroIcon);
@@ -507,7 +507,7 @@
 
     @Test
     public void getSafeIcon_invalidResource_shouldFallbackToSettingsIcon() {
-        final int settingsIcon = R.drawable.ic_settings;
+        final int settingsIcon = R.drawable.ic_settings_accent;
         final int badIcon = 0x12345678;
         final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
                 badIcon);
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
index 722df77..8736fe8 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
@@ -43,6 +43,6 @@
     @Implementation
     protected static Pair<String, Integer> getIconFromUri(Context context, String packageName,
             String uriString, Map<String, IContentProvider> providerMap) {
-        return Pair.create(RuntimeEnvironment.application.getPackageName(), R.drawable.ic_settings);
+        return Pair.create(RuntimeEnvironment.application.getPackageName(), R.drawable.ic_settings_accent);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
index 32690a3..05a9cfb 100644
--- a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
+++ b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
@@ -87,7 +87,7 @@
     public void setBackgroundColor_externalTileWithBackgroundColorRawValue_shouldUpdateIcon() {
         final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
         mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB, 0xff0000);
-        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
+        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
                 .when(tile).getIcon(mContext);
         final AdaptiveHomepageIcon icon =
                 new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
@@ -97,11 +97,25 @@
     }
 
     @Test
+    public void setBackgroundColor_tileWithoutBackgroundColor_shouldSetDefaultBackgroundColor() {
+        final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
+        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
+            .when(tile).getIcon(mContext);
+        final AdaptiveHomepageIcon icon =
+            new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
+
+        icon.setBackgroundColor(mContext, tile);
+
+        assertThat(icon.mBackgroundColor).isEqualTo(
+            mContext.getColor(R.color.homepage_generic_icon_background));
+    }
+
+    @Test
     public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() {
         final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
         mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
                 R.color.material_blue_500);
-        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
+        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
                 .when(tile).getIcon(mContext);
 
         final AdaptiveHomepageIcon icon =
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
index b194d73..98795a7 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
@@ -18,15 +18,140 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.telephony.TelephonyManager;
+import android.telephony.ims.ProvisioningManager;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.ims.ImsConfig;
+import com.android.ims.ImsException;
+import com.android.ims.ImsManager;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.widget.SwitchBar;
+import com.android.settings.widget.ToggleSwitch;
+
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
 public class WifiCallingSettingsForSubTest {
+    private TestFragment mFragment;
+    private Context mContext;
+    private TextView mEmptyView;
+
+    @Mock private ImsManager mImsManager;
+    @Mock private TelephonyManager mTelephonyManager;
+    @Mock private PreferenceScreen mPreferenceScreen;
+    @Mock private SettingsActivity mActivity;
+    @Mock private SwitchBar mSwitchBar;
+    @Mock private ToggleSwitch mToggleSwitch;
+    @Mock private View mView;
+    @Mock private ImsConfig mImsConfig;
+
+    @Before
+    public void setUp() throws NoSuchFieldException, ImsException {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        doReturn(mContext.getTheme()).when(mActivity).getTheme();
+
+        mFragment = spy(new TestFragment());
+        doReturn(mActivity).when(mFragment).getActivity();
+        doReturn(mContext).when(mFragment).getContext();
+        doReturn(mock(Intent.class)).when(mActivity).getIntent();
+        doReturn(mContext.getResources()).when(mFragment).getResources();
+        doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
+        doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
+        final Bundle bundle = new Bundle();
+        when(mFragment.getArguments()).thenReturn(bundle);
+        doNothing().when(mFragment).addPreferencesFromResource(anyInt());
+        doReturn(mock(ListPreference.class)).when(mFragment).findPreference(any());
+        doNothing().when(mFragment).finish();
+        doReturn(mView).when(mFragment).getView();
+
+        mEmptyView = new TextView(mContext);
+        doReturn(mEmptyView).when(mView).findViewById(android.R.id.empty);
+
+        ReflectionHelpers.setField(mSwitchBar, "mSwitch", mToggleSwitch);
+        doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
+
+        doReturn(mImsManager).when(mFragment).getImsManager();
+        doReturn(mImsConfig).when(mImsManager).getConfigInterface();
+        doReturn(true).when(mImsManager).isWfcProvisionedOnDevice();
+
+        mFragment.onAttach(mContext);
+        mFragment.onCreate(null);
+        mFragment.onActivityCreated(null);
+    }
 
     @Test
     public void getHelpResource_shouldReturn0() {
-        assertThat(new WifiCallingSettingsForSub().getHelpResource()).isEqualTo(0);
+        assertThat(mFragment.getHelpResource()).isEqualTo(0);
+    }
+
+    @Test
+    public void onResume_provisioningAllowed_shouldNotFinish() throws ImsException {
+        // Call onResume while provisioning is allowed.
+        mFragment.onResume();
+
+        // Verify that finish() is not called.
+        verify(mFragment, never()).finish();
+    }
+
+    @Test
+    public void onResume_provisioningDisallowed_shouldFinish() {
+        // Call onResume while provisioning is disallowed.
+        doReturn(false).when(mImsManager).isWfcProvisionedOnDevice();
+        mFragment.onResume();
+
+        // Verify that finish() is called
+        verify(mFragment).finish();
+    }
+
+    @Test
+    public void onResumeOnPause_provisioningCallbackRegistration() throws ImsException {
+        // Verify that provisioning callback is registered after call to onResume().
+        mFragment.onResume();
+        verify(mImsConfig).addConfigCallback(any(ProvisioningManager.Callback.class));
+
+        // Verify that provisioning callback is unregistered after call to onPause.
+        mFragment.onPause();
+        verify(mImsConfig).removeConfigCallback(any());
+    }
+
+    protected class TestFragment extends WifiCallingSettingsForSub {
+        @Override
+        protected Object getSystemService(final String name) {
+            if (Context.TELEPHONY_SERVICE.equals(name)) {
+                return mTelephonyManager;
+            }
+            return null;
+        }
     }
 }