Merge "[Wi-Fi] Add LinkifyUtilTest file to enlarge the test coverage in WiFi Settings."
diff --git a/res/drawable/ic_enterprise.xml b/res/drawable/ic_enterprise.xml
new file mode 100644
index 0000000..c2d9df6
--- /dev/null
+++ b/res/drawable/ic_enterprise.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+~ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:pathData="M20,6h-4L16,4c0,-1.11 -0.89,-2 -2,-2h-4c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -1.99,0.89 -1.99,2L2,19c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM12,15c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM14,6h-4L10,4h4v2z"
+        android:fillColor="?android:attr/colorPrimary"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout-land/confirm_lock_password.xml b/res/layout-land/confirm_lock_password.xml
index 544dd26..546ef67 100644
--- a/res/layout-land/confirm_lock_password.xml
+++ b/res/layout-land/confirm_lock_password.xml
@@ -13,81 +13,98 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<FrameLayout
+<com.google.android.setupdesign.GlifLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:importantForAutofill="noExcludeDescendants">
+    android:icon="@drawable/ic_enterprise"
+    android:layout="@layout/sud_glif_blank_template">
 
-    <include layout="@layout/confirm_lock_background_base" />
-
-    <LinearLayout
+    <!--common_typos_disable-->
+    <com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
         android:id="@+id/topLayout"
-        android:orientation="vertical"
+        android:orientation="horizontal"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
-        <TextView
-            style="@*android:style/TextAppearance.DeviceDefault.Title"
-            android:id="@+id/headerText"
-            android:layout_marginStart="24dp"
-            android:layout_marginEnd="24dp"
-            android:layout_marginTop="12dp"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textColor="?android:attr/colorAccent"/>
-
-        <TextView
-            style="@*android:style/TextAppearance.DeviceDefault.Body1"
-            android:id="@+id/sud_layout_description"
-            android:layout_marginStart="24dp"
-            android:layout_marginEnd="24dp"
-            android:layout_marginTop="8dp"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"/>
-
-        <FrameLayout
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1">
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
 
-            <Button
-                style="@android:style/Widget.Material.Button.Borderless"
-                android:id="@+id/cancelButton"
+            <ImageView
+                android:id="@+id/sud_layout_icon"
+                style="@style/SudGlifIcon"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_gravity="start|bottom"
-                android:text="@string/cancel"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:layout_marginBottom="14dp"/>
+                android:layout_gravity="?attr/sudGlifHeaderGravity"
+                android:src="@drawable/ic_enterprise" />
 
-            <LinearLayout
+            <TextView
+                android:id="@+id/headerText"
+                style="@style/SudGlifHeaderTitle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+            <TextView
+                android:id="@+id/sud_layout_description"
+                style="@style/SudDescription.Glif"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_gravity="center_vertical"
-                android:gravity="center_horizontal"
-                android:orientation="vertical">
+                android:layout_marginStart="?attr/sudMarginSides"
+                android:layout_marginEnd="?attr/sudMarginSides" />
+        </LinearLayout>
 
-                <com.android.settings.widget.ScrollToParentEditText
-                    android:id="@+id/password_entry"
-                    android:layout_width="208dp"
-                    android:layout_height="wrap_content"
-                    android:inputType="textPassword"
-                    android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii"
-                    android:gravity="center"
-                    style="@style/TextAppearance.PasswordEntry"/>
+        <Space
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1" />
 
-                <TextView style="@style/TextAppearance.ErrorText"
-                    android:accessibilityLiveRegion="polite"
-                    android:id="@+id/errorText"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginBottom="10dp"/>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center_horizontal"
+            android:orientation="vertical">
 
-            </LinearLayout>
+            <com.android.settings.widget.ScrollToParentEditText
+                android:id="@+id/password_entry"
+                android:layout_width="208dp"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:inputType="textPassword"
+                android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii"
+                android:gravity="center"
+                style="@style/TextAppearance.PasswordEntry"/>
 
-        </FrameLayout>
+            <TextView
+                style="@style/TextAppearance.ErrorText"
+                android:accessibilityLiveRegion="polite"
+                android:id="@+id/errorText"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="8dp"
+                android:layout_marginStart="12dp"
+                android:layout_marginEnd="12dp"/>
 
-    </LinearLayout>
-</FrameLayout>
\ No newline at end of file
+        </LinearLayout>
+
+        <Space
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1" />
+
+        <Button
+            android:id="@+id/cancelButton"
+            style="@style/SudGlifButton.Secondary"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="?attr/sudMarginSides"
+            android:layout_marginEnd="?attr/sudMarginSides"
+            android:layout_marginBottom="80dp"
+            android:layout_gravity="center_horizontal"
+            android:text="@string/cancel" />
+
+    <!--common_typos_disable-->
+    </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
+</com.google.android.setupdesign.GlifLayout>
\ No newline at end of file
diff --git a/res/layout-land/confirm_lock_pattern.xml b/res/layout-land/confirm_lock_pattern.xml
index 6ca9be4..9e6133b 100644
--- a/res/layout-land/confirm_lock_pattern.xml
+++ b/res/layout-land/confirm_lock_pattern.xml
@@ -13,83 +13,67 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<FrameLayout
+<com.google.android.setupdesign.GlifLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
-    android:layout_height="match_parent" >
-
-    <include layout="@layout/confirm_lock_background_base" />
+    android:layout_height="match_parent"
+    android:icon="@drawable/ic_enterprise"
+    android:layout="@layout/sud_glif_blank_template">
 
     <com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
-        xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/topLayout"
         android:orientation="horizontal"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:clipChildren="false"
-        android:clipToPadding="false">
+        android:layout_height="match_parent">
 
-        <LinearLayout
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:layout_weight="1"
-            android:orientation="vertical">
-
-            <TextView
-                style="@*android:style/TextAppearance.DeviceDefault.Headline"
-                android:id="@+id/headerText"
-                android:layout_marginStart="32dp"
-                android:layout_marginEnd="32dp"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textColor="?android:attr/colorAccent"/>
-
-            <TextView
-                style="@*android:style/TextAppearance.DeviceDefault.Body1"
-                android:id="@+id/sud_layout_description"
-                android:layout_marginStart="32dp"
-                android:layout_marginEnd="32dp"
-                android:layout_marginTop="12dp"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"/>
-
-            <Button
-                style="@android:style/Widget.Material.Button.Borderless"
-                android:id="@+id/cancelButton"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/cancel"
-                android:layout_marginStart="16dp"
-                android:layout_marginEnd="16dp"
-                android:layout_marginTop="16dp"/>
-        </LinearLayout>
-
-        <LinearLayout
+        <ScrollView
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:layout_weight="1"
-            android:orientation="horizontal"
-            android:clipChildren="false"
-            android:clipToPadding="false">
+            android:fillViewport="true">
 
-            <View
-                android:id="@+id/leftSpacer"
-                android:layout_width="0dp"
-                android:layout_height="match_parent"
-                android:layout_weight="0.4"/>
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:paddingBottom="24dp">
 
-            <FrameLayout
-                android:layout_width="wrap_content"
-                android:layout_height="match_parent"
-                android:clipChildren="false"
-                android:clipToPadding="false">
+                <ImageView
+                    android:id="@+id/sud_layout_icon"
+                    style="@style/SudGlifIcon"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="?attr/sudGlifHeaderGravity"
+                    android:src="@drawable/ic_enterprise" />
 
-                <com.android.internal.widget.LockPatternView
-                    android:id="@+id/lockPattern"
+                <TextView
+                    android:id="@+id/headerText"
+                    style="@style/SudGlifHeaderTitle"
                     android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:layout_gravity="center"/>
+                    android:layout_height="wrap_content" />
+
+                <TextView
+                    android:id="@+id/sud_layout_description"
+                    style="@style/SudDescription.Glif"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="?attr/sudMarginSides"
+                    android:layout_marginEnd="?attr/sudMarginSides" />x
+
+                <Button
+                    android:id="@+id/cancelButton"
+                    style="@style/SetupWizardButton.Negative"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="?attr/sudMarginSides"
+                    android:layout_marginEnd="?attr/sudMarginSides"
+                    android:text="@string/cancel" />
+
+                <Space
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1" />
 
                 <TextView
                     style="@style/TextAppearance.ErrorText"
@@ -97,16 +81,30 @@
                     android:id="@+id/errorText"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_gravity="bottom|center_horizontal"
-                    android:layout_marginBottom="24dp"/>
-            </FrameLayout>
+                    android:layout_marginStart="?attr/sudMarginSides"
+                    android:layout_marginEnd="?attr/sudMarginSides"
+                    android:layout_marginBottom="24dp"
+                    android:gravity="center_vertical"/>
 
-            <View
-                android:id="@+id/rightSpacer"
-                android:layout_width="0dp"
+            </LinearLayout>
+
+        </ScrollView>
+
+        <com.google.android.setupdesign.view.FillContentLayout
+            style="@style/LockPatternContainerStyle"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:paddingStart="0dp">
+
+            <com.android.internal.widget.LockPatternView
+                android:id="@+id/lockPattern"
+                android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:layout_weight="1"/>
-        </LinearLayout>
+                android:layout_gravity="center" />
+
+        </com.google.android.setupdesign.view.FillContentLayout>
 
     </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
-</FrameLayout>
+</com.google.android.setupdesign.GlifLayout>
+
diff --git a/res/layout-sw600dp/confirm_lock_password.xml b/res/layout-sw600dp/confirm_lock_password.xml
index 2bfc470..3925a69 100644
--- a/res/layout-sw600dp/confirm_lock_password.xml
+++ b/res/layout-sw600dp/confirm_lock_password.xml
@@ -14,15 +14,16 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License
   -->
-<FrameLayout
+<com.google.android.setupdesign.GlifLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:importantForAutofill="noExcludeDescendants">
+    android:layout="@layout/sud_glif_blank_template">
 
     <include
         layout="@layout/confirm_lock_password_base"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_gravity="center_horizontal" />
-</FrameLayout>
+</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout-sw600dp/confirm_lock_pattern.xml b/res/layout-sw600dp/confirm_lock_pattern.xml
index c9a3dfa..51af1f3 100644
--- a/res/layout-sw600dp/confirm_lock_pattern.xml
+++ b/res/layout-sw600dp/confirm_lock_pattern.xml
@@ -13,12 +13,16 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.google.android.setupdesign.GlifLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:layout="@layout/sud_glif_blank_template">
 
-    <include layout="@layout/confirm_lock_pattern_base"
+    <include
+        layout="@layout/confirm_lock_pattern_base"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_gravity="center_horizontal"/>
-</FrameLayout>
+        android:layout_gravity="center_horizontal" />
+</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/confirm_lock_password_base.xml b/res/layout/confirm_lock_password_base.xml
index 19a9fbb..bc0c81e 100644
--- a/res/layout/confirm_lock_password_base.xml
+++ b/res/layout/confirm_lock_password_base.xml
@@ -13,55 +13,52 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<FrameLayout
+<com.google.android.setupdesign.GlifLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:importantForAutofill="noExcludeDescendants">
-
-    <include layout="@layout/confirm_lock_background_base" />
+    android:icon="@drawable/ic_enterprise"
+    android:layout="@layout/sud_glif_blank_template">
 
     <com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
-        xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/topLayout"
         android:orientation="vertical"
-        android:layout_width="@dimen/confirm_credentials_layout_width"
-        android:layout_height="match_parent"
-        android:layout_gravity="top|center_horizontal"
-        android:paddingTop="@dimen/confirm_credentials_top_padding">
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
 
-        <TextView
-            style="@*android:style/TextAppearance.DeviceDefault.Headline"
-            android:id="@+id/headerText"
-            android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
-            android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
-            android:layout_marginTop="?attr/confirmDeviceCredentialsTopMargin"
-            android:layout_width="wrap_content"
+        <LinearLayout
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:textColor="?android:attr/colorAccent"/>
+            android:orientation="vertical">
 
-        <TextView
-            style="@*android:style/TextAppearance.DeviceDefault.Body1"
-            android:id="@+id/sud_layout_description"
-            android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
-            android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
-            android:layout_marginTop="12dp"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content" />
+            <ImageView
+                android:id="@+id/sud_layout_icon"
+                style="@style/SudGlifIcon"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="?attr/sudGlifHeaderGravity"
+                android:src="@drawable/ic_enterprise" />
 
-        <Button
-            style="@android:style/Widget.Material.Button.Borderless"
-            android:id="@+id/cancelButton"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/cancel"
-            android:layout_marginStart="16dp"
-            android:layout_marginEnd="16dp"
-            android:layout_marginTop="16dp"/>
+            <TextView
+                android:id="@+id/headerText"
+                style="@style/SudGlifHeaderTitle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
 
-        <View android:layout_width="match_parent"
-              android:layout_height="0dp"
-              android:layout_weight="1"/>
+            <TextView
+                android:id="@+id/sud_layout_description"
+                style="@style/SudDescription.Glif"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="?attr/sudMarginSides"
+                android:layout_marginEnd="?attr/sudMarginSides" />
+        </LinearLayout>
+
+        <Space
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1" />
 
         <LinearLayout
             android:layout_width="match_parent"
@@ -73,6 +70,7 @@
                 android:id="@+id/password_entry"
                 android:layout_width="208dp"
                 android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
                 android:inputType="textPassword"
                 android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii"
                 android:gravity="center"
@@ -90,5 +88,21 @@
 
         </LinearLayout>
 
+        <Space
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="1" />
+
+        <Button
+            android:id="@+id/cancelButton"
+            style="@style/SudGlifButton.Secondary"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="?attr/sudMarginSides"
+            android:layout_marginEnd="?attr/sudMarginSides"
+            android:layout_marginBottom="80dp"
+            android:layout_gravity="center_horizontal"
+            android:text="@string/cancel" />
+
     </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
-</FrameLayout>
+</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/confirm_lock_pattern_base.xml b/res/layout/confirm_lock_pattern_base.xml
index b02f9c0..3041852 100644
--- a/res/layout/confirm_lock_pattern_base.xml
+++ b/res/layout/confirm_lock_pattern_base.xml
@@ -13,91 +13,95 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<FrameLayout
+<com.google.android.setupdesign.GlifLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
-    android:layout_height="match_parent" >
-
-    <include layout="@layout/confirm_lock_background_base" />
+    android:layout_height="match_parent"
+    android:icon="@drawable/ic_enterprise"
+    android:layout="@layout/sud_glif_blank_template">
 
     <com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
-        xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/topLayout"
         android:orientation="vertical"
-        android:layout_width="@dimen/confirm_credentials_layout_width"
-        android:layout_height="match_parent"
-        android:layout_gravity="top|center_horizontal"
-        android:paddingTop="@dimen/confirm_credentials_top_padding">
-
-        <ScrollView
-            android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="2">
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:orientation="vertical">
-
-                <TextView
-                    style="@*android:style/TextAppearance.DeviceDefault.Headline"
-                    android:id="@+id/headerText"
-                    android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
-                    android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
-                    android:layout_marginTop="?attr/confirmDeviceCredentialsTopMargin"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:textColor="?android:attr/colorAccent"/>
-
-                <TextView
-                    style="@*android:style/TextAppearance.DeviceDefault.Body1"
-                    android:id="@+id/sud_layout_description"
-                    android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
-                    android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
-                    android:layout_marginTop="12dp"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"/>
-
-                <Button
-                    style="@android:style/Widget.Material.Button.Borderless"
-                    android:id="@+id/cancelButton"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/cancel"
-                    android:layout_marginStart="16dp"
-                    android:layout_marginEnd="16dp"
-                    android:layout_marginTop="16dp"/>
-            </LinearLayout>
-
-        </ScrollView>
-
-        <com.android.internal.widget.LockPatternView
-            android:id="@+id/lockPattern"
-            android:layout_width="312dp"
-            android:layout_height="0dp"
-            android:layout_weight="3"
-            android:layout_gravity="center_horizontal"/>
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
 
         <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1"
-            android:orientation="vertical">
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:paddingBottom="24dp">
+
+            <ImageView
+                android:id="@+id/sud_layout_icon"
+                style="@style/SudGlifIcon"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="?attr/sudGlifHeaderGravity"
+                android:src="@drawable/ic_enterprise" />
+
+            <TextView
+                android:id="@+id/headerText"
+                style="@style/SudGlifHeaderTitle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+            <TextView
+                android:id="@+id/sud_layout_description"
+                style="@style/SudDescription.Glif"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="?attr/sudMarginSides"
+                android:layout_marginEnd="?attr/sudMarginSides" />x
+
+            <Button
+                android:id="@+id/cancelButton"
+                style="@style/SudGlifButton.Secondary"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="?attr/sudMarginSides"
+                android:layout_marginEnd="?attr/sudMarginSides"
+                android:layout_marginBottom="80dp"
+                android:text="@string/cancel" />
+
+        </LinearLayout>
+
+        <LinearLayout
+            style="@style/SudContentFrame"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:gravity="center"
+            android:paddingLeft="0dp"
+            android:paddingRight="0dp">
+
+            <com.google.android.setupdesign.view.FillContentLayout
+                style="@style/LockPatternContainerStyle"
+                android:layout_width="wrap_content"
+                android:layout_height="0dp"
+                android:layout_weight="1">
+
+                <com.android.internal.widget.LockPatternView
+                    android:id="@+id/lockPattern"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:layout_gravity="center" />
+
+            </com.google.android.setupdesign.view.FillContentLayout>
 
             <TextView
                 style="@style/TextAppearance.ErrorText"
                 android:accessibilityLiveRegion="polite"
                 android:id="@+id/errorText"
                 android:layout_width="wrap_content"
-                android:layout_height="0dp"
-                android:layout_weight="1"
+                android:layout_height="wrap_content"
                 android:layout_gravity="center_horizontal"
+                android:layout_marginHorizontal="?attr/sudMarginSides"
                 android:layout_marginTop="12dp"
-                android:layout_marginStart="12dp"
-                android:layout_marginEnd="12dp"
                 android:gravity="center_vertical"/>
 
         </LinearLayout>
 
     </com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
-</FrameLayout>
+</com.google.android.setupdesign.GlifLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 885d57c..968f650 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2086,7 +2086,7 @@
     <!-- Title for the fragment to show that the QR code is for sharing Wi-Fi hotspot network [CHAR LIMIT=50] -->
     <string name="wifi_dpp_share_hotspot">Share hotspot</string>
     <!-- Title for Wi-Fi DPP lockscreen title [CHAR LIMIT=50] -->
-    <string name="wifi_dpp_lockscreen_title">Verify it\u0027s you</string>
+    <string name="wifi_dpp_lockscreen_title">Verify that it\u0027s you</string>
     <!-- Hint for Wi-Fi password [CHAR LIMIT=50]  -->
     <string name="wifi_dpp_wifi_password">Wi\u2011Fi password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
     <!-- Hint for Wi-Fi hotspot password [CHAR LIMIT=50]  -->
@@ -3969,10 +3969,16 @@
     <string name="lockpassword_choose_your_pattern_message">For security, set pattern</string>
     <!-- Header on password confirm screen [CHAR LIMIT=40] -->
     <string name="lockpassword_confirm_your_password_header">Re-enter your password</string>
+    <!-- Header on password confirm screen for the work profile [CHAR LIMIT=40] -->
+    <string name="lockpassword_confirm_your_work_password_header">Enter your work password</string>
     <!-- Header on pattern confirm screen [CHAR LIMIT=30] -->
     <string name="lockpassword_confirm_your_pattern_header">Confirm your pattern</string>
+    <!-- Header on pattern confirm screen for the work profile [CHAR LIMIT=30] -->
+    <string name="lockpassword_confirm_your_work_pattern_header">Enter your work pattern</string>
     <!-- Header on password confirm screen [CHAR LIMIT=40] -->
     <string name="lockpassword_confirm_your_pin_header">Re-enter your PIN</string>
+    <!-- Header on password confirm screen for the work profile [CHAR LIMIT=40] -->
+    <string name="lockpassword_confirm_your_work_pin_header">Enter your work PIN</string>
     <!-- Header on password confirm screen if second password doesn't match the first. [CHAR LIMIT=30] -->
     <string name="lockpassword_confirm_passwords_dont_match">Passwords don\u2019t match</string>
     <!-- Header on pin confirm screen if second pin doesn't match the first. [CHAR LIMIT=30]-->
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index e53154a..bb24833 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -51,13 +51,13 @@
 import com.android.settings.password.ConfirmDeviceCredentialActivity;
 import com.android.settings.widget.SwitchBar;
 import com.android.settings.widget.ToggleSwitch;
-import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
 import com.android.settingslib.accessibility.AccessibilityUtils;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 /** Fragment for providing toggle bar and basic accessibility service setup. */
 public class ToggleAccessibilityServicePreferenceFragment extends
@@ -75,7 +75,7 @@
     public static final int ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION = 1;
     private CharSequence mDialogTitle;
     private LockPatternUtils mLockPatternUtils;
-
+    private AtomicBoolean mIsDialogShown = new AtomicBoolean(/* initialValue= */ false);
 
     private final SettingsContentObserver mSettingsContentObserver =
             new SettingsContentObserver(new Handler()) {
@@ -87,27 +87,13 @@
 
     private Dialog mDialog;
 
-    private final View.OnClickListener mViewOnClickListener =
-            (View view) -> {
-                if (view.getId() == R.id.permission_enable_allow_button) {
-                    if (isFullDiskEncrypted()) {
-                        String title = createConfirmCredentialReasonMessage();
-                        Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, null);
-                        startActivityForResult(intent,
-                                ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION);
-                    } else {
-                        handleConfirmServiceEnabled(true);
-                        if (isServiceSupportAccessibilityButton()) {
-                            showDialog(DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL);
-                        }
-                    }
-                } else if (view.getId() == R.id.permission_enable_deny_button) {
-                    handleConfirmServiceEnabled(false);
-                } else {
-                    throw new IllegalArgumentException();
-                }
-                mDialog.dismiss();
-            };
+    @Retention(RetentionPolicy.SOURCE)
+    private @interface DialogType {
+        int ENABLE_WARNING_FROM_TOGGLE = 1;
+        int ENABLE_WARNING_FROM_SHORTCUT = 2;
+        int LAUNCH_ACCESSIBILITY_TUTORIAL = 3;
+        int EDIT_SHORTCUT = 4;
+    }
 
     @Override
     public int getMetricsCategory() {
@@ -182,13 +168,24 @@
     @Override
     public Dialog onCreateDialog(int dialogId) {
         switch (dialogId) {
-            case DialogType.ENABLE_WARNING: {
+            case DialogType.ENABLE_WARNING_FROM_TOGGLE: {
                 final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
                 if (info == null) {
                     return null;
                 }
                 mDialog = AccessibilityServiceWarning
-                        .createCapabilitiesDialog(getActivity(), info, mViewOnClickListener);
+                        .createCapabilitiesDialog(getActivity(), info,
+                                this::onDialogButtonFromToggleClicked);
+                break;
+            }
+            case DialogType.ENABLE_WARNING_FROM_SHORTCUT: {
+                final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+                if (info == null) {
+                    return null;
+                }
+                mDialog = AccessibilityServiceWarning
+                        .createCapabilitiesDialog(getActivity(), info,
+                                this::onDialogButtonFromShortcutClicked);
                 break;
             }
             case DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL: {
@@ -319,7 +316,8 @@
     @Override
     public int getDialogMetricsCategory(int dialogId) {
         switch (dialogId) {
-            case DialogType.ENABLE_WARNING:
+            case DialogType.ENABLE_WARNING_FROM_TOGGLE:
+            case DialogType.ENABLE_WARNING_FROM_SHORTCUT:
                 return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_ENABLE;
             case DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL:
                 return AccessibilityUtil.isGestureNavigateEnabled(getContext())
@@ -464,28 +462,21 @@
     @Override
     protected void onInstallSwitchBarToggleSwitch() {
         super.onInstallSwitchBarToggleSwitch();
-        mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
-            @Override
-            public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
-                if (checked) {
-                    mSwitchBar.setCheckedInternal(false);
-                    getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, false);
-                    showDialog(DialogType.ENABLE_WARNING);
-                } else {
-                    handleConfirmServiceEnabled(false);
-                }
-                return true;
-            }
-        });
+        mToggleSwitch.setOnBeforeCheckedChangeListener(this::onBeforeCheckedChanged);
     }
 
     @Override
     public void onCheckboxClicked(ShortcutPreference preference) {
         if (preference.getChecked()) {
-            // TODO(b/142531156): Replace PreferredShortcutType.SOFTWARE value with dialog shortcut
-            //  preferred key.
-            AccessibilityUtil.optInValueToSettings(getContext(), PreferredShortcutType.SOFTWARE,
-                    mComponentName);
+            if (!getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
+                preference.setChecked(false);
+                showPopupDialog(DialogType.ENABLE_WARNING_FROM_SHORTCUT);
+            } else {
+                // TODO(b/142531156): Replace PreferredShortcutType.SOFTWARE value with dialog
+                //  shortcut preferred key.
+                AccessibilityUtil.optInValueToSettings(getContext(), PreferredShortcutType.SOFTWARE,
+                        mComponentName);
+            }
         } else {
             // TODO(b/142531156): Replace PreferredShortcutType.SOFTWARE value with dialog shortcut
             //  preferred key.
@@ -497,7 +488,7 @@
     @Override
     public void onSettingsClicked(ShortcutPreference preference) {
         mPreferredShortcutType = getPreferredShortcutType(getPrefContext());
-        showDialog(DialogType.EDIT_SHORTCUT);
+        showPopupDialog(DialogType.EDIT_SHORTCUT);
     }
 
     @Override
@@ -534,10 +525,94 @@
                 getPackageManager());
     }
 
-    @Retention(RetentionPolicy.SOURCE)
-    private @interface DialogType {
-        int ENABLE_WARNING = 1;
-        int LAUNCH_ACCESSIBILITY_TUTORIAL = 2;
-        int EDIT_SHORTCUT = 3;
+    private void onDialogButtonFromToggleClicked(View view) {
+        if (view.getId() == R.id.permission_enable_allow_button) {
+            onAllowButtonFromToggleClicked();
+        } else if (view.getId() == R.id.permission_enable_deny_button) {
+            onDenyButtonFromToggleClicked();
+        } else {
+            throw new IllegalArgumentException("Unexpected view id");
+        }
+    }
+
+    private void onAllowButtonFromToggleClicked() {
+        if (isFullDiskEncrypted()) {
+            final String title = createConfirmCredentialReasonMessage();
+            final Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, /* details= */
+                    null);
+            startActivityForResult(intent,
+                    ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION);
+        } else {
+            handleConfirmServiceEnabled(/* confirmed= */ true);
+            if (isServiceSupportAccessibilityButton()) {
+                mIsDialogShown.set(false);
+                showPopupDialog(DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL);
+            }
+        }
+
+        mDialog.dismiss();
+    }
+
+    private void onDenyButtonFromToggleClicked() {
+        handleConfirmServiceEnabled(/* confirmed= */ false);
+        mDialog.dismiss();
+    }
+
+    private void onDialogButtonFromShortcutClicked(View view) {
+        if (view.getId() == R.id.permission_enable_allow_button) {
+            onAllowButtonFromShortcutClicked();
+        } else if (view.getId() == R.id.permission_enable_deny_button) {
+            onDenyButtonFromShortcutClicked();
+        } else {
+            throw new IllegalArgumentException("Unexpected view id");
+        }
+    }
+
+    private void onAllowButtonFromShortcutClicked() {
+        final ShortcutPreference shortcutPreference = findPreference(getShortcutPreferenceKey());
+        shortcutPreference.setChecked(true);
+        // TODO(b/142531156): Replace PreferredShortcutType.SOFTWARE value with dialog shortcut
+        //  preferred key.
+        AccessibilityUtil.optInValueToSettings(getContext(), PreferredShortcutType.SOFTWARE,
+                mComponentName);
+
+        mDialog.dismiss();
+    }
+
+    private void onDenyButtonFromShortcutClicked() {
+        final ShortcutPreference shortcutPreference = findPreference(getShortcutPreferenceKey());
+        shortcutPreference.setChecked(false);
+
+        mDialog.dismiss();
+    }
+
+    private boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
+        if (checked) {
+            mSwitchBar.setCheckedInternal(false);
+            getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, false);
+
+            final ShortcutPreference shortcutPreference = findPreference(
+                    getShortcutPreferenceKey());
+            if (!shortcutPreference.getChecked()) {
+                showPopupDialog(DialogType.ENABLE_WARNING_FROM_TOGGLE);
+            } else {
+                handleConfirmServiceEnabled(/* confirmed= */ true);
+                if (isServiceSupportAccessibilityButton()) {
+                    showPopupDialog(DialogType.LAUNCH_ACCESSIBILITY_TUTORIAL);
+                }
+            }
+        } else {
+            handleConfirmServiceEnabled(/* confirmed= */ false);
+        }
+        return true;
+    }
+
+    private void showPopupDialog(int dialogId) {
+        if (mIsDialogShown.compareAndSet(/* expect= */ false, /* update= */ true)) {
+            showDialog(dialogId);
+            setOnDismissListener(
+                    dialog -> mIsDialogShown.compareAndSet(/* expect= */ true, /* update= */
+                            false));
+        }
     }
 }
diff --git a/src/com/android/settings/network/BluetoothTetherPreferenceController.java b/src/com/android/settings/network/BluetoothTetherPreferenceController.java
new file mode 100644
index 0000000..10849a0
--- /dev/null
+++ b/src/com/android/settings/network/BluetoothTetherPreferenceController.java
@@ -0,0 +1,141 @@
+/*
+ * 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.network;
+
+import android.bluetooth.BluetoothAdapter;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.net.ConnectivityManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * This controller helps to manage the switch state and visibility of bluetooth tether switch
+ * preference. It stores preference value when preference changed.
+ * TODO(b/147272749): Extend BasePreferenceController.java instead.
+ */
+public final class BluetoothTetherPreferenceController extends AbstractPreferenceController
+        implements LifecycleObserver, Preference.OnPreferenceChangeListener {
+
+    private static final String TAG = "BluetoothTetherPreferenceController";
+    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    @VisibleForTesting
+    static final String PREF_KEY = "enable_bluetooth_tethering";
+    private final ConnectivityManager mCm;
+    private int mBluetoothState;
+    private Preference mPreference;
+    private final SharedPreferences mSharedPreferences;
+
+    public BluetoothTetherPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context);
+        mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mSharedPreferences =
+                context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @OnLifecycleEvent(Lifecycle.Event.ON_START)
+    public void onStart() {
+        mBluetoothState = BluetoothAdapter.getDefaultAdapter().getState();
+        mContext.registerReceiver(mBluetoothChangeReceiver,
+                new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
+    }
+
+    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
+    public void onStop() {
+        mContext.unregisterReceiver(mBluetoothChangeReceiver);
+    }
+
+    @Override
+    public boolean isAvailable() {
+        final String[] bluetoothRegexs = mCm.getTetherableBluetoothRegexs();
+        return bluetoothRegexs != null && bluetoothRegexs.length > 0;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(PREF_KEY);
+        if (mPreference != null && mPreference instanceof SwitchPreference) {
+            ((SwitchPreference) mPreference)
+                    .setChecked(mSharedPreferences.getBoolean(PREF_KEY, false));
+        }
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        switch (mBluetoothState) {
+            case BluetoothAdapter.STATE_ON:
+            case BluetoothAdapter.STATE_OFF:
+                // fall through.
+            case BluetoothAdapter.ERROR:
+                preference.setEnabled(true);
+                break;
+            case BluetoothAdapter.STATE_TURNING_OFF:
+            case BluetoothAdapter.STATE_TURNING_ON:
+                // fall through.
+            default:
+                preference.setEnabled(false);
+        }
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return PREF_KEY;
+    }
+
+    @VisibleForTesting
+    final BroadcastReceiver mBluetoothChangeReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (TextUtils.equals(BluetoothAdapter.ACTION_STATE_CHANGED, intent.getAction())) {
+                mBluetoothState =
+                        intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
+                updateState(mPreference);
+            }
+        }
+    };
+
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object o) {
+        if (DEBUG) {
+            Log.d(TAG, "preference changing to " + o);
+        }
+        final SharedPreferences.Editor editor = mSharedPreferences.edit();
+        editor.putBoolean(PREF_KEY, (Boolean) o);
+        editor.apply();
+        return true;
+    }
+}
diff --git a/src/com/android/settings/network/TetherEnabler.java b/src/com/android/settings/network/TetherEnabler.java
index 9106aa1..6c6c959 100644
--- a/src/com/android/settings/network/TetherEnabler.java
+++ b/src/com/android/settings/network/TetherEnabler.java
@@ -32,11 +32,11 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.text.TextUtils;
+import android.util.Log;
 
 import androidx.lifecycle.Lifecycle;
 import androidx.lifecycle.LifecycleObserver;
 import androidx.lifecycle.OnLifecycleEvent;
-import androidx.preference.PreferenceManager;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.datausage.DataSaverBackend;
@@ -52,13 +52,20 @@
  */
 
 public final class TetherEnabler implements SwitchWidgetController.OnSwitchChangeListener,
-        DataSaverBackend.Listener, LifecycleObserver {
+        DataSaverBackend.Listener, LifecycleObserver,
+        SharedPreferences.OnSharedPreferenceChangeListener {
+
+    private static final String TAG = "TetherEnabler";
+    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
+    public static final String SHARED_PREF = "tether_options";
+
     @VisibleForTesting
-    static final String WIFI_TETHER_KEY = "enable_wifi_tethering";
+    static final String WIFI_TETHER_KEY = WifiTetherDisablePreferenceController.PREF_KEY;
     @VisibleForTesting
-    static final String USB_TETHER_KEY = "enable_usb_tethering";
+    static final String USB_TETHER_KEY = UsbTetherPreferenceController.PREF_KEY;
     @VisibleForTesting
-    static final String BLUETOOTH_TETHER_KEY = "enable_bluetooth_tethering";
+    static final String BLUETOOTH_TETHER_KEY = BluetoothTetherPreferenceController.PREF_KEY;
 
     private final SwitchWidgetController mSwitchWidgetController;
     private final WifiManager mWifiManager;
@@ -76,7 +83,6 @@
                 public void onTetheringFailed() {
                     super.onTetheringFailed();
                     mSwitchWidgetController.setChecked(false);
-                    setSwitchWidgetEnabled(true);
                 }
             };
     private final AtomicReference<BluetoothPan> mBluetoothPan;
@@ -84,12 +90,12 @@
     private boolean mBluetoothEnableForTether;
     private final BluetoothAdapter mBluetoothAdapter;
 
-    TetherEnabler(Context context, SwitchWidgetController switchWidgetController,
+    public TetherEnabler(Context context, SwitchWidgetController switchWidgetController,
             AtomicReference<BluetoothPan> bluetoothPan) {
         mContext = context;
         mSwitchWidgetController = switchWidgetController;
         mDataSaverBackend = new DataSaverBackend(context);
-        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
+        mSharedPreferences = context.getSharedPreferences(SHARED_PREF, Context.MODE_PRIVATE);
         mConnectivityManager =
                 (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
         mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
@@ -110,6 +116,16 @@
         setSwitchWidgetEnabled(true);
     }
 
+    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
+    public void onResume() {
+        mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
+    }
+
+    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
+    public void onPause() {
+        mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
+    }
+
     @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
     public void onStop() {
         mDataSaverBackend.remListener(this);
@@ -148,19 +164,16 @@
 
     @VisibleForTesting
     void stopTether() {
-        setSwitchWidgetEnabled(false);
 
-        // Wi-Fi tether is selected by default
+        // Wi-Fi tether is selected by default.
         if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
             mConnectivityManager.stopTethering(TETHERING_WIFI);
         }
 
-        // USB tether is not selected by default
         if (mSharedPreferences.getBoolean(USB_TETHER_KEY, false)) {
             mConnectivityManager.stopTethering(TETHERING_USB);
         }
 
-        // Bluetooth tether is not selected by default
         if (mSharedPreferences.getBoolean(BLUETOOTH_TETHER_KEY, false)) {
             mConnectivityManager.stopTethering(TETHERING_BLUETOOTH);
         }
@@ -168,19 +181,16 @@
 
     @VisibleForTesting
     void startTether() {
-        setSwitchWidgetEnabled(false);
 
-        // Wi-Fi tether is selected by default
+        // Wi-Fi tether is selected by default.
         if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
             startTethering(TETHERING_WIFI);
         }
 
-        // USB tether is not selected by default
         if (mSharedPreferences.getBoolean(USB_TETHER_KEY, false)) {
             startTethering(TETHERING_USB);
         }
 
-        // Bluetooth tether is not selected by default
         if (mSharedPreferences.getBoolean(BLUETOOTH_TETHER_KEY, false)) {
             startTethering(TETHERING_BLUETOOTH);
         }
@@ -188,18 +198,24 @@
 
     @VisibleForTesting
     void startTethering(int choice) {
+        if (choice == TETHERING_WIFI && mWifiManager.isWifiApEnabled()) {
+            if (DEBUG) {
+                Log.d(TAG, "Wifi tether already active!");
+            }
+            return;
+        }
+
         if (choice == TETHERING_BLUETOOTH) {
-            // Turn on Bluetooth first.
             if (mBluetoothAdapter.getState() == BluetoothAdapter.STATE_OFF) {
+                if (DEBUG) {
+                    Log.d(TAG, "Turn on bluetooth first.");
+                }
                 mBluetoothEnableForTether = true;
                 mBluetoothAdapter.enable();
                 return;
             }
-        } else if (choice == TETHERING_WIFI && mWifiManager.isWifiApEnabled()) {
-            return;
         }
 
-
         mConnectivityManager.startTethering(choice, true /* showProvisioningUi */,
                 mOnStartTetheringCallback, new Handler(Looper.getMainLooper()));
     }
@@ -213,24 +229,21 @@
                         ConnectivityManager.EXTRA_ACTIVE_TETHER);
                 mSwitchWidgetController.setChecked(
                         isTethering(active.toArray(new String[active.size()])));
-                setSwitchWidgetEnabled(true);
             } else if (TextUtils.equals(BluetoothAdapter.ACTION_STATE_CHANGED, action)) {
-                if (mBluetoothEnableForTether) {
-                    switch (intent
-                            .getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) {
-                        case BluetoothAdapter.STATE_ON:
+                switch (intent
+                        .getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) {
+                    case BluetoothAdapter.STATE_ON:
+                        if (mBluetoothEnableForTether) {
                             startTethering(TETHERING_BLUETOOTH);
-                            mBluetoothEnableForTether = false;
-                            break;
-
-                        case BluetoothAdapter.STATE_OFF:
-                        case BluetoothAdapter.ERROR:
-                            mBluetoothEnableForTether = false;
-                            break;
-
-                        default:
-                            // ignore transition states
-                    }
+                        }
+                        // Fall through.
+                    case BluetoothAdapter.STATE_OFF:
+                        // Fall through.
+                    case BluetoothAdapter.ERROR:
+                        mBluetoothEnableForTether = false;
+                        break;
+                    default:
+                        // ignore transition states
                 }
             }
         }
@@ -251,4 +264,30 @@
     public void onBlacklistStatusChanged(int uid, boolean isBlacklisted) {
         // we don't care, since we just want to read the value
     }
+
+    @Override
+    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+        if (!mSwitchWidgetController.isChecked()) {
+            return;
+        }
+        if (TextUtils.equals(WIFI_TETHER_KEY, key)) {
+            if (sharedPreferences.getBoolean(key, true)) {
+                startTethering(TETHERING_WIFI);
+            } else {
+                mConnectivityManager.stopTethering(TETHERING_WIFI);
+            }
+        } else if (TextUtils.equals(USB_TETHER_KEY, key)) {
+            if (sharedPreferences.getBoolean(key, false)) {
+                startTethering(TETHERING_USB);
+            } else {
+                mConnectivityManager.stopTethering(TETHERING_USB);
+            }
+        } else if (TextUtils.equals(BLUETOOTH_TETHER_KEY, key)) {
+            if (sharedPreferences.getBoolean(key, false)) {
+                startTethering(TETHERING_BLUETOOTH);
+            } else {
+                mConnectivityManager.stopTethering(TETHERING_BLUETOOTH);
+            }
+        }
+    }
 }
diff --git a/src/com/android/settings/network/UsbTetherPreferenceController.java b/src/com/android/settings/network/UsbTetherPreferenceController.java
new file mode 100644
index 0000000..74e8be8
--- /dev/null
+++ b/src/com/android/settings/network/UsbTetherPreferenceController.java
@@ -0,0 +1,144 @@
+/*
+ * 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.network;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.hardware.usb.UsbManager;
+import android.net.ConnectivityManager;
+import android.os.Environment;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.Utils;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+/**
+ * This controller helps to manage the switch state and visibility of USB tether switch
+ * preference. It stores preference values when preference changed.
+ * TODO(b/147272749): Extend BasePreferenceController.java instead.
+ *
+ */
+public final class UsbTetherPreferenceController extends AbstractPreferenceController implements
+        LifecycleObserver, Preference.OnPreferenceChangeListener {
+
+    private static final String TAG = "UsbTetherPrefController";
+    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    @VisibleForTesting
+    static final String PREF_KEY = "enable_usb_tethering";
+
+    private final ConnectivityManager mCm;
+    private boolean mUsbConnected;
+    private boolean mMassStorageActive;
+    private Preference mPreference;
+    private final SharedPreferences mSharedPreferences;
+
+    public UsbTetherPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context);
+        mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mSharedPreferences =
+                context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @OnLifecycleEvent(Lifecycle.Event.ON_START)
+    public void onStart() {
+        mMassStorageActive = Environment.MEDIA_SHARED.equals(Environment.getExternalStorageState());
+        IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_STATE);
+        filter.addAction(Intent.ACTION_MEDIA_SHARED);
+        filter.addAction(Intent.ACTION_MEDIA_UNSHARED);
+        mContext.registerReceiver(mUsbChangeReceiver, filter);
+    }
+
+    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
+    public void onStop() {
+        mContext.unregisterReceiver(mUsbChangeReceiver);
+    }
+
+    @Override
+    public boolean isAvailable() {
+        String[] usbRegexs = mCm.getTetherableUsbRegexs();
+        return usbRegexs != null && usbRegexs.length > 0 && !Utils.isMonkeyRunning();
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return PREF_KEY;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(PREF_KEY);
+        if (mPreference != null && mPreference instanceof SwitchPreference) {
+            ((SwitchPreference) mPreference)
+                    .setChecked(mSharedPreferences.getBoolean(PREF_KEY, false));
+        }
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        if (preference != null) {
+            if (mUsbConnected && !mMassStorageActive) {
+                preference.setEnabled(true);
+            } else {
+                preference.setEnabled(false);
+            }
+        }
+    }
+
+    @VisibleForTesting
+    final BroadcastReceiver mUsbChangeReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (TextUtils.equals(Intent.ACTION_MEDIA_SHARED, action)) {
+                mMassStorageActive = true;
+            } else if (TextUtils.equals(Intent.ACTION_MEDIA_UNSHARED, action)) {
+                mMassStorageActive = false;
+            } else if (TextUtils.equals(UsbManager.ACTION_USB_STATE, action)) {
+                mUsbConnected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
+            }
+            updateState(mPreference);
+        }
+    };
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object o) {
+        if (DEBUG) {
+            Log.d(TAG, "preference changing to " + o);
+        }
+        final SharedPreferences.Editor editor = mSharedPreferences.edit();
+        editor.putBoolean(PREF_KEY, (Boolean) o);
+        editor.apply();
+        return true;
+    }
+}
diff --git a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
new file mode 100644
index 0000000..bf0e208
--- /dev/null
+++ b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
@@ -0,0 +1,166 @@
+/*
+ * 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.network;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.net.ConnectivityManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+/**
+ * This controller helps to manage the switch state and visibility of wifi tether disable switch
+ * preference. When the preference checked, wifi tether will be disabled.
+ * It stores preference value when preference changed and listens to usb tether and bluetooth tether
+ * preferences.
+ *
+ * @see BluetoothTetherPreferenceController
+ * @see UsbTetherPreferenceController
+ * TODO(b/147272749): Extend BasePreferenceController.java instead.
+ *
+ */
+public final class WifiTetherDisablePreferenceController extends AbstractPreferenceController
+        implements LifecycleObserver, Preference.OnPreferenceChangeListener,
+        SharedPreferences.OnSharedPreferenceChangeListener {
+
+    private static final String TAG = "WifiTetherDisablePreferenceController";
+    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    @VisibleForTesting
+    static final String PREF_KEY = "enable_wifi_tethering";
+    private final ConnectivityManager mCm;
+    private boolean mBluetoothTetherEnabled;
+    private boolean mUSBTetherEnabled;
+    private PreferenceScreen mScreen;
+    private Preference mPreference;
+    private final SharedPreferences mSharedPreferences;
+
+    public WifiTetherDisablePreferenceController(Context context, Lifecycle lifecycle) {
+        super(context);
+        mSharedPreferences =
+                context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
+        mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mUSBTetherEnabled = mSharedPreferences.getBoolean(
+                TetherEnabler.USB_TETHER_KEY, false);
+        mBluetoothTetherEnabled = mSharedPreferences.getBoolean(
+                TetherEnabler.BLUETOOTH_TETHER_KEY, false);
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
+    public void onResume() {
+        mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
+    }
+
+    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
+    public void onPause() {
+        mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
+    }
+
+    @Override
+    public boolean isAvailable() {
+        final String[] wifiRegexs = mCm.getTetherableWifiRegexs();
+        return wifiRegexs != null && wifiRegexs.length > 0 && shouldShow();
+    }
+
+    @VisibleForTesting
+    boolean shouldShow() {
+        return mBluetoothTetherEnabled || mUSBTetherEnabled;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return PREF_KEY;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        // TODO(b/146818850): Update summary accordingly.
+        return super.getSummary();
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mScreen = screen;
+        mPreference = screen.findPreference(PREF_KEY);
+        if (mPreference != null && mPreference instanceof SwitchPreference) {
+            ((SwitchPreference) mPreference)
+                    .setChecked(!mSharedPreferences.getBoolean(PREF_KEY, true));
+            mPreference.setOnPreferenceChangeListener(this);
+        }
+        updateState(mPreference);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        setVisible(mScreen, PREF_KEY, shouldShow());
+    }
+
+    @Override
+    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+            String key) {
+        if (TextUtils.equals(TetherEnabler.USB_TETHER_KEY, key)) {
+            mUSBTetherEnabled = sharedPreferences.getBoolean(key, false);
+        } else if (TextUtils.equals(TetherEnabler.BLUETOOTH_TETHER_KEY, key)) {
+            mBluetoothTetherEnabled = sharedPreferences.getBoolean(key, false);
+        }
+
+        // Check if we are hiding this preference. If so,  make sure the preference is set to
+        // unchecked to enable wifi tether.
+        if (mPreference != null && mPreference instanceof SwitchPreference && !shouldShow()) {
+            final SwitchPreference switchPreference = (SwitchPreference) mPreference;
+            if (switchPreference.isChecked()) {
+                if (DEBUG) {
+                    Log.d(TAG,
+                            "All other types are unchecked, wifi tether enabled automatically");
+                }
+                // Need to call this method before internal state set.
+                if (switchPreference.callChangeListener(false)) {
+                    switchPreference.setChecked(false);
+                }
+            }
+        }
+
+        updateState(mPreference);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object o) {
+        // The shared preference's value is in the opposite of this preference's value.
+        final boolean enableWifi = !(boolean) o;
+        if (true) {
+            Log.d(TAG, "check state changing to " + o);
+        }
+        final SharedPreferences.Editor editor = mSharedPreferences.edit();
+        editor.putBoolean(PREF_KEY, enableWifi);
+        editor.apply();
+        return true;
+    }
+}
diff --git a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
index 29b3374..97894b1 100644
--- a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
+++ b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
@@ -68,9 +68,7 @@
     public NetworkOperatorPreference(Context context, CellIdentity connectedCellId,
             List<String> forbiddenPlmns, boolean show4GForLTE) {
         this(context, forbiddenPlmns, show4GForLTE);
-        mCellInfo = null;
-        mCellId = connectedCellId;
-        refresh();
+        updateCell(null, connectedCellId);
     }
 
     private NetworkOperatorPreference(
@@ -86,8 +84,12 @@
      * Change cell information
      */
     public void updateCell(CellInfo cellinfo) {
+        updateCell(cellinfo, CellInfoUtil.getCellIdentity(cellinfo));
+    }
+
+    private void updateCell(CellInfo cellinfo, CellIdentity cellId) {
         mCellInfo = cellinfo;
-        mCellId = CellInfoUtil.getCellIdentity(cellinfo);
+        mCellId = cellId;
         refresh();
     }
 
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index 2835b6e..8b3e913 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -85,7 +85,6 @@
     private boolean mUseNewApi;
     private long mRequestIdManualNetworkSelect;
     private long mRequestIdManualNetworkScan;
-    private boolean mScreenIsOn;
     private long mWaitingForNumberOfScanResults;
 
     private static final int MIN_NUMBER_OF_SCAN_REQUIRED = 2;
@@ -138,7 +137,6 @@
         if (isProgressBarVisible()) {
             return;
         }
-        mScreenIsOn = true;
         if (mWaitingForNumberOfScanResults <= 0) {
             startNetworkQuery();
         }
@@ -158,7 +156,6 @@
     @Override
     public void onStop() {
         super.onStop();
-        mScreenIsOn = false;
         if (mWaitingForNumberOfScanResults <= 0) {
             stopNetworkQuery();
         }
@@ -241,7 +238,7 @@
                         break;
                     }
                     mWaitingForNumberOfScanResults--;
-                    if ((!mScreenIsOn) && (mWaitingForNumberOfScanResults <= 0)) {
+                    if ((mWaitingForNumberOfScanResults <= 0) && (!isResumed())) {
                         stopNetworkQuery();
                     }
 
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 912b600..cc30a92 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -186,8 +186,6 @@
         final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
 
         final Bundle bpBundle = new Bundle();
-        mTitle = bpBundle.getString(BiometricPrompt.KEY_TITLE);
-        mDetails = bpBundle.getString(BiometricPrompt.KEY_SUBTITLE);
         bpBundle.putString(BiometricPrompt.KEY_TITLE, mTitle);
         bpBundle.putString(BiometricPrompt.KEY_DESCRIPTION, mDetails);
         bpBundle.putBoolean(BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS,
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index a30d2e1..eaea2ea 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -17,7 +17,6 @@
 package com.android.settings.password;
 
 import android.app.KeyguardManager;
-import android.hardware.biometrics.BiometricManager;
 import android.os.Bundle;
 import android.os.UserManager;
 import android.util.Log;
@@ -65,7 +64,7 @@
             return;
         }
         if (UserManager.get(this).isManagedProfile(credentialOwnerUserId)) {
-            setTheme(R.style.Theme_ConfirmDeviceCredentialsWork);
+            setTheme(SetupWizardUtils.getTheme(getIntent()));
             mConfirmCredentialTheme = ConfirmCredentialTheme.WORK;
         } else if (getIntent().getBooleanExtra(
                 ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
index bb953a1..a1eb106 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseFragment.java
@@ -140,9 +140,6 @@
                 Utils.getUserIdFromBundle(
                         getActivity(),
                         getActivity().getIntent().getExtras(), isInternalActivity()));
-        if (mUserManager.isManagedProfile(credentialOwnerUserId)) {
-            setWorkChallengeBackground(view, credentialOwnerUserId);
-        }
     }
 
     // User could be locked while Effective user is unlocked even though the effective owns the
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 13d3749..a62f77f 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -56,16 +56,12 @@
 
 public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
 
-    // The index of the array is isStrongAuth << 2 + isProfile << 1 + isAlpha.
+    // The index of the array is isStrongAuth << 1 + isAlpha.
     private static final int[] DETAIL_TEXTS = new int[] {
         R.string.lockpassword_confirm_your_pin_generic,
         R.string.lockpassword_confirm_your_password_generic,
-        R.string.lockpassword_confirm_your_pin_generic_profile,
-        R.string.lockpassword_confirm_your_password_generic_profile,
         R.string.lockpassword_strong_auth_required_device_pin,
-        R.string.lockpassword_strong_auth_required_device_password,
-        R.string.lockpassword_strong_auth_required_work_pin,
-        R.string.lockpassword_strong_auth_required_work_password,
+        R.string.lockpassword_strong_auth_required_device_password
     };
 
     public static class InternalActivity extends ConfirmLockPassword {
@@ -109,6 +105,7 @@
         private InputMethodManager mImm;
         private AppearAnimationUtils mAppearAnimationUtils;
         private DisappearAnimationUtils mDisappearAnimationUtils;
+        private boolean mIsManagedProfile;
 
         // required constructor for fragments
         public ConfirmLockPasswordFragment() {
@@ -149,6 +146,8 @@
             mImm = (InputMethodManager) getActivity().getSystemService(
                     Context.INPUT_METHOD_SERVICE);
 
+            mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
+
             Intent intent = getActivity().getIntent();
             if (intent != null) {
                 CharSequence headerMessage = intent.getCharSequenceExtra(
@@ -205,6 +204,10 @@
                 return mIsAlpha ? R.string.lockpassword_confirm_your_password_header_frp
                         : R.string.lockpassword_confirm_your_pin_header_frp;
             }
+            if (mIsManagedProfile) {
+                return mIsAlpha ? R.string.lockpassword_confirm_your_work_password_header
+                        : R.string.lockpassword_confirm_your_work_pin_header;
+            }
             return mIsAlpha ? R.string.lockpassword_confirm_your_password_header
                     : R.string.lockpassword_confirm_your_pin_header;
         }
@@ -215,10 +218,8 @@
                         : R.string.lockpassword_confirm_your_pin_details_frp;
             }
             boolean isStrongAuthRequired = isStrongAuthRequired();
-            boolean isProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
-            // Map boolean flags to an index by isStrongAuth << 2 + isProfile << 1 + isAlpha.
-            int index = ((isStrongAuthRequired ? 1 : 0) << 2) + ((isProfile ? 1 : 0) << 1)
-                    + (mIsAlpha ? 1 : 0);
+            // Map boolean flags to an index by isStrongAuth << 1 + isAlpha.
+            int index = ((isStrongAuthRequired ? 1 : 0) << 1) + (mIsAlpha ? 1 : 0);
             return DETAIL_TEXTS[index];
         }
 
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index 2f7557e..557eae4 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -90,8 +90,6 @@
 
         private TextView mHeaderTextView;
         private TextView mDetailsTextView;
-        private View mLeftSpacerLandscape;
-        private View mRightSpacerLandscape;
 
         // caller-supplied text for various prompts
         private CharSequence mHeaderText;
@@ -100,6 +98,8 @@
         private AppearAnimationUtils mAppearAnimationUtils;
         private DisappearAnimationUtils mDisappearAnimationUtils;
 
+        private boolean mIsManagedProfile;
+
         // required constructor for fragments
         public ConfirmLockPatternFragment() {
 
@@ -119,8 +119,8 @@
             mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
             mDetailsTextView = (TextView) view.findViewById(R.id.sud_layout_description);
             mErrorTextView = (TextView) view.findViewById(R.id.errorText);
-            mLeftSpacerLandscape = view.findViewById(R.id.leftSpacer);
-            mRightSpacerLandscape = view.findViewById(R.id.rightSpacer);
+
+            mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
 
             // make it so unhandled touch events within the unlock screen go to the
             // lock pattern view.
@@ -325,7 +325,9 @@
         }
 
         private int getDefaultHeader() {
-            return mFrp ? R.string.lockpassword_confirm_your_pattern_header_frp
+            if (mFrp) return R.string.lockpassword_confirm_your_pattern_header_frp;
+            return mIsManagedProfile
+                    ? R.string.lockpassword_confirm_your_work_pattern_header
                     : R.string.lockpassword_confirm_your_pattern_header;
         }
 
diff --git a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
new file mode 100644
index 0000000..c76e234
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.network;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+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.content.Context;
+import android.net.ConnectivityManager;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class BluetoothTetherPreferenceControllerTest {
+
+    @Mock
+    private ConnectivityManager mConnectivityManager;
+
+    private BluetoothTetherPreferenceController mController;
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
+                mConnectivityManager);
+        when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
+        mController = new BluetoothTetherPreferenceController(mContext, mock(Lifecycle.class));
+    }
+
+    @Test
+    public void lifecycle_shouldRegisterReceiverOnStart() {
+        mController.onStart();
+
+        verify(mContext).registerReceiver(
+                eq(mController.mBluetoothChangeReceiver),
+                any());
+    }
+
+    @Test
+    public void lifecycle_shouldUnregisterReceiverOnStop() {
+        mController.onStart();
+        mController.onStop();
+
+        verify(mContext).unregisterReceiver(
+                eq(mController.mBluetoothChangeReceiver));
+    }
+
+    @Test
+    public void display_availableChangedCorrectly() {
+        when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
+        assertThat(mController.isAvailable()).isTrue();
+
+        when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
+        assertThat(mController.isAvailable()).isFalse();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
index 06f3893..9dcfa89 100644
--- a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
@@ -26,7 +26,6 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -83,10 +82,23 @@
                 mNetworkPolicyManager);
         when(mConnectivityManager.getTetherableIfaces()).thenReturn(new String[0]);
         panReference.set(mBluetoothPan);
+        when(context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE))
+                .thenReturn(mSharedPreferences);
         mEnabler = new TetherEnabler(context, new SwitchBarController(mSwitchBar), panReference);
     }
 
     @Test
+    public void lifecycle_onPause_unRegisterSharedPreferenceListener() {
+        mEnabler.onResume();
+        verify(mSharedPreferences).registerOnSharedPreferenceChangeListener(
+                eq(mEnabler));
+
+        mEnabler.onPause();
+        verify(mSharedPreferences).unregisterOnSharedPreferenceChangeListener(
+                eq(mEnabler));
+    }
+
+    @Test
     public void lifecycle_onStart_setCheckedCorrectly() {
         when(mConnectivityManager.getTetheredIfaces()).thenReturn(new String[]{""});
 
@@ -122,29 +134,27 @@
 
     @Test
     public void onSwitchToggled_onlyStartsWifiTetherWhenNeeded() {
+        when(mSharedPreferences.getBoolean(TetherEnabler.WIFI_TETHER_KEY, true)).thenReturn(true);
         when(mWifiManager.isWifiApEnabled()).thenReturn(true);
         mEnabler.onSwitchToggled(true);
-
         verify(mConnectivityManager, never()).startTethering(anyInt(), anyBoolean(), any(), any());
 
         doReturn(false).when(mWifiManager).isWifiApEnabled();
         mEnabler.onSwitchToggled(true);
-
-        verify(mConnectivityManager, times(1))
-                .startTethering(anyInt(), anyBoolean(), any(), any());
+        verify(mConnectivityManager).startTethering(anyInt(), anyBoolean(), any(), any());
     }
 
     @Test
     public void onSwitchToggled_shouldStartUSBTetherWhenSelected() {
         SharedPreferences preference = mock(SharedPreferences.class);
         ReflectionHelpers.setField(mEnabler, "mSharedPreferences", preference);
-        when(preference.getBoolean(mEnabler.WIFI_TETHER_KEY, true)).thenReturn(false);
-        when(preference.getBoolean(mEnabler.USB_TETHER_KEY, false)).thenReturn(true);
-        when(preference.getBoolean(mEnabler.BLUETOOTH_TETHER_KEY, true)).thenReturn(false);
+        when(preference.getBoolean(TetherEnabler.WIFI_TETHER_KEY, true)).thenReturn(false);
+        when(preference.getBoolean(TetherEnabler.USB_TETHER_KEY, false)).thenReturn(true);
+        when(preference.getBoolean(TetherEnabler.BLUETOOTH_TETHER_KEY, true)).thenReturn(false);
 
         mEnabler.startTether();
-        verify(mConnectivityManager, times(1))
-                .startTethering(eq(ConnectivityManager.TETHERING_USB), anyBoolean(), any(), any());
+        verify(mConnectivityManager).startTethering(
+                eq(ConnectivityManager.TETHERING_USB), anyBoolean(), any(), any());
         verify(mConnectivityManager, never())
                 .startTethering(eq(ConnectivityManager.TETHERING_WIFI), anyBoolean(), any(), any());
         verify(mConnectivityManager, never()).startTethering(
@@ -158,11 +168,11 @@
         when(adapter.getState()).thenReturn(BluetoothAdapter.STATE_OFF);
 
         mEnabler.startTethering(ConnectivityManager.TETHERING_BLUETOOTH);
-        verify(adapter, times(1)).enable();
+        verify(adapter).enable();
 
         when(adapter.getState()).thenReturn(BluetoothAdapter.STATE_ON);
         mEnabler.startTethering(ConnectivityManager.TETHERING_BLUETOOTH);
-        verify(mConnectivityManager, times(1)).startTethering(
+        verify(mConnectivityManager).startTethering(
                 eq(ConnectivityManager.TETHERING_BLUETOOTH), anyBoolean(), any(), any());
     }
 }
diff --git a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
new file mode 100644
index 0000000..9127e4b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.network;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+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.content.Context;
+import android.net.ConnectivityManager;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class UsbTetherPreferenceControllerTest {
+
+    @Mock
+    private ConnectivityManager mConnectivityManager;
+
+    private Context mContext;
+    private UsbTetherPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
+                mConnectivityManager);
+        when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[] {""});
+        mController = new UsbTetherPreferenceController(mContext, mock(Lifecycle.class));
+    }
+
+    @Test
+    public void lifecycle_shouldRegisterReceiverOnStart() {
+        mController.onStart();
+
+        verify(mContext).registerReceiver(eq(mController.mUsbChangeReceiver), any());
+    }
+
+    @Test
+    public void lifecycle_shouldUnregisterReceiverOnStop() {
+        mController.onStart();
+        mController.onStop();
+
+        verify(mContext).unregisterReceiver(eq(mController.mUsbChangeReceiver));
+    }
+
+    @Test
+    public void display_availableChangedCorrectly() {
+        when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[] {""});
+        assertThat(mController.isAvailable()).isTrue();
+
+        when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
+        assertThat(mController.isAvailable()).isFalse();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
new file mode 100644
index 0000000..e42c477
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.network;
+
+import static com.android.settings.network.WifiTetherDisablePreferenceController.PREF_KEY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.eq;
+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.content.Context;
+import android.content.SharedPreferences;
+import android.net.ConnectivityManager;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import androidx.test.core.app.ApplicationProvider;
+
+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.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiTetherDisablePreferenceControllerTest {
+
+    @Mock
+    private ConnectivityManager mConnectivityManager;
+    @Mock
+    private SharedPreferences mSharedPreferences;
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
+
+    private SwitchPreference mPreference;
+    private Context mContext;
+    private WifiTetherDisablePreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        mPreference = spy(SwitchPreference.class);
+        when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
+                mConnectivityManager);
+        when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
+        when(mContext.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE))
+                .thenReturn(mSharedPreferences);
+        mController = new WifiTetherDisablePreferenceController(mContext, mock(Lifecycle.class));
+        ReflectionHelpers.setField(mController, "mScreen", mPreferenceScreen);
+        ReflectionHelpers.setField(mController, "mPreference", mPreference);
+        when(mPreferenceScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
+    }
+
+    @Test
+
+    public void lifecycle_shouldRegisterReceiverOnResume() {
+        mController.onResume();
+
+        verify(mSharedPreferences).registerOnSharedPreferenceChangeListener(eq(mController));
+    }
+
+    @Test
+    public void lifecycle_shouldUnregisterReceiverOnStop() {
+        mController.onResume();
+        mController.onPause();
+
+        verify(mSharedPreferences).unregisterOnSharedPreferenceChangeListener(eq(mController));
+    }
+
+    @Test
+    public void display_availableChangedCorrectly() {
+        when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[0]);
+        assertThat(mController.isAvailable()).isFalse();
+
+        when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"test"});
+        ReflectionHelpers.setField(mController, "mBluetoothTetherEnabled", false);
+        ReflectionHelpers.setField(mController, "mUSBTetherEnabled", false);
+        assertThat(mController.isAvailable()).isFalse();
+    }
+
+    @Test
+    public void switch_shouldListenToUsbAndBluetooth() {
+        when(mSharedPreferences.getBoolean(
+                BluetoothTetherPreferenceController.PREF_KEY, false)).thenReturn(true);
+        mController.onSharedPreferenceChanged(mSharedPreferences,
+                BluetoothTetherPreferenceController.PREF_KEY);
+        verify(mPreference).setVisible(eq(true));
+
+        when(mSharedPreferences.getBoolean(
+                UsbTetherPreferenceController.PREF_KEY, false)).thenReturn(true);
+        mController.onSharedPreferenceChanged(mSharedPreferences,
+                UsbTetherPreferenceController.PREF_KEY);
+        assertThat(mController.shouldShow()).isTrue();
+
+        when(mSharedPreferences.getBoolean(
+                UsbTetherPreferenceController.PREF_KEY, false)).thenReturn(false);
+        mController.onSharedPreferenceChanged(mSharedPreferences,
+                UsbTetherPreferenceController.PREF_KEY);
+        assertThat(mController.shouldShow()).isTrue();
+
+        when(mSharedPreferences.getBoolean(
+                BluetoothTetherPreferenceController.PREF_KEY, false)).thenReturn(false);
+        when(mSharedPreferences.edit()).thenReturn(mock(SharedPreferences.Editor.class));
+        when(mPreference.isChecked()).thenReturn(true);
+        mController.onSharedPreferenceChanged(mSharedPreferences,
+                BluetoothTetherPreferenceController.PREF_KEY);
+        verify(mPreference).setChecked(eq(false));
+        verify(mPreference).setVisible(eq(false));
+    }
+}