Merge "Fix NPE in UserSettingsTest" into sc-dev
diff --git a/res/drawable/ic_files_go_round.xml b/res/drawable/ic_files_go_round.xml
new file mode 100644
index 0000000..2025b00
--- /dev/null
+++ b/res/drawable/ic_files_go_round.xml
@@ -0,0 +1,121 @@
+<!--
+    Copyright (C) 2021 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"
+    xmlns:aapt="http://schemas.android.com/aapt"
+    android:width="32dp"
+    android:height="32dp"
+    android:viewportWidth="192"
+    android:viewportHeight="192">
+  <path
+      android:pathData="M96,96m-88,0a88,88 0,1 1,176 0a88,88 0,1 1,-176 0"
+      android:fillColor="#FFFFFF"/>
+  <path
+      android:pathData="M96,183c-48.43,0 -87.72,-39.13 -87.99,-87.5C8.01,95.67 8,95.83 8,96c0,48.6 39.4,88 88,88s88,-39.4 88,-88c0,-0.17 -0.01,-0.33 -0.01,-0.5C183.72,143.87 144.43,183 96,183z"
+      android:fillColor="#263238"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M96,9c48.43,0 87.72,39.13 87.99,87.5c0,-0.17 0.01,-0.33 0.01,-0.5c0,-48.6 -39.4,-88 -88,-88S8,47.4 8,96c0,0.17 0.01,0.33 0.01,0.5C8.28,48.13 47.57,9 96,9z"
+      android:fillColor="#FFFFFF"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M85.09,59.18H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v40.91v2.05v-0.35c0,-1.08 0.43,-2.13 1.2,-2.89L85.09,59.18z"
+      android:fillColor="#0F9D58"/>
+  <path
+      android:pathData="M85.09,59.18H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v40.91v2.05v-0.35c0,-1.08 0.43,-2.13 1.2,-2.89L85.09,59.18z">
+    <aapt:attr name="android:fillColor">
+      <gradient
+          android:startY="110.3181"
+          android:startX="60.5458"
+          android:endY="59.182"
+          android:endX="60.5458"
+          android:type="linear">
+        <item android:offset="0" android:color="#33263238"/>
+        <item android:offset="1" android:color="#00263238"/>
+      </gradient>
+    </aapt:attr>
+  </path>
+  <path
+      android:pathData="M37.2,106.39c-0.77,0.77 -1.2,1.81 -1.2,2.89v0.35v0.33c0,-1.08 0.43,-2.13 1.2,-2.89l47.89,-47.89h-0.68L37.2,106.39z"
+      android:fillColor="#263238"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M44.18,59.86h39.55l0.68,-0.68H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v0.68C36,63.53 39.66,59.86 44.18,59.86z"
+      android:fillColor="#FFFFFF"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M147.82,143.73H44.18c-4.52,0 -8.18,-3.66 -8.18,-8.18v-25.58c0,-1.08 0.43,-2.13 1.2,-2.89l57.6,-57.6c0.77,-0.77 1.81,-1.2 2.89,-1.2h50.12c4.52,0 8.18,3.66 8.18,8.18v79.09C156,140.06 152.34,143.73 147.82,143.73z"
+      android:fillColor="#4285F4"/>
+  <path
+      android:pathData="M156,135.55l0,-29.32L98.05,48.27l-0.31,0c-1.11,0 -2.17,0.45 -2.94,1.25L37.2,107.07c-0.77,0.77 -1.2,1.81 -1.2,2.89v0.35l33.41,33.41l78.41,0C152.34,143.73 156,140.06 156,135.55z">
+    <aapt:attr name="android:fillColor">
+      <gradient
+          android:startY="78.2732"
+          android:startX="66.0008"
+          android:endY="153.6034"
+          android:endX="141.331"
+          android:type="linear">
+        <item android:offset="0" android:color="#281A237E"/>
+        <item android:offset="1" android:color="#051A237E"/>
+      </gradient>
+    </aapt:attr>
+  </path>
+  <path
+      android:pathData="M147.82,143.05H44.18c-4.52,0 -8.18,-3.66 -8.18,-8.18v0.68c0,4.52 3.66,8.18 8.18,8.18h103.64c4.52,0 8.18,-3.66 8.18,-8.18v-0.68C156,139.38 152.34,143.05 147.82,143.05z"
+      android:fillColor="#1A237E"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M147.82,48.27H98.05c-0.6,0 -1.14,0.27 -1.51,0.68h51.29c4.52,0 8.18,3.66 8.18,8.18v-0.68C156,51.94 152.34,48.27 147.82,48.27z"
+      android:fillColor="#FFFFFF"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M94.8,49.47l-57.6,57.6c-0.77,0.77 -1.2,1.81 -1.2,2.89v0.35v0c0,-1.13 0.92,-2.05 2.05,-2.05h49.77c4.52,0 8.18,-3.66 8.18,-8.18l0,-49.77c0,-1.13 0.92,-2.05 2.05,-2.05l0,0l-0.35,0C96.61,48.27 95.57,48.7 94.8,49.47z"
+      android:fillColor="#DB4437"/>
+  <path
+      android:pathData="M97.69,48.27c-0.27,0 -0.54,0.03 -0.8,0.08C97.15,48.3 97.42,48.27 97.69,48.27l0.35,0c-1.34,0 -2.55,0.72 -3.21,1.85c0.43,-0.42 0.95,-0.73 1.5,-0.93c0.37,-0.55 0.99,-0.92 1.7,-0.92L97.69,48.27z"
+      android:strokeAlpha="0.2"
+      android:fillColor="#3E2723"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M96,99.41c0,4.52 -3.66,8.18 -8.18,8.18H38.05c-0.85,0 -1.57,0.51 -1.88,1.25c-0.1,0.36 -0.16,0.74 -0.16,1.13v0.35c0,-1.13 0.92,-2.05 2.05,-2.05h49.77c4.52,0 8.18,-3.66 8.18,-8.18"
+      android:fillColor="#3E2723"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M36,110.32L36,110.32c0,-1.62 1.05,-3.06 2.6,-3.55L74.95,95.2c3.79,-1.21 6.77,-4.18 7.97,-7.97l11.57,-36.35c0.49,-1.55 1.93,-2.6 3.55,-2.6l0,0h-0.35c-1.08,0 -2.13,0.43 -2.89,1.2l-57.6,57.6c-0.77,0.77 -1.2,1.81 -1.2,2.89L36,110.32z"
+      android:fillColor="#F4B400"/>
+  <path
+      android:pathData="M94.84,49.44c-0.14,0.24 -0.26,0.48 -0.35,0.75L82.92,86.54c-1.21,3.79 -4.18,6.77 -7.97,7.97L38.6,106.08c-0.27,0.09 -0.52,0.21 -0.76,0.35l-0.64,0.64c-0.77,0.77 -1.2,1.81 -1.2,2.89l0,0.35c0,-1.62 1.05,-3.06 2.6,-3.55L74.95,95.2c3.79,-1.21 6.77,-4.18 7.97,-7.97l11.57,-36.35c0.49,-1.55 1.93,-2.6 3.55,-2.6h-0.35C96.63,48.27 95.6,48.69 94.84,49.44z"
+      android:fillColor="#BF360C"
+      android:fillAlpha="0.3"/>
+  <path
+      android:pathData="M39,105.95l55.36,-55.36l0.13,-0.4c0.09,-0.27 0.21,-0.52 0.35,-0.75c-0.01,0.01 -0.03,0.02 -0.04,0.03l-56.96,56.96c0.24,-0.14 0.49,-0.27 0.76,-0.35L39,105.95z"
+      android:strokeAlpha="0.2"
+      android:fillColor="#FFFFFF"
+      android:fillAlpha="0.2"/>
+  <path
+      android:pathData="M36,109.97v25.58c0,4.52 3.66,8.18 8.18,8.18h103.64c4.52,0 8.18,-3.66 8.18,-8.18V56.45c0,-4.52 -3.66,-8.18 -8.18,-8.18H97.69c-1.08,0 -2.13,0.43 -2.89,1.2l-9.71,9.71H44.18c-4.52,0 -8.18,3.66 -8.18,8.18v40.91L36,109.97">
+    <aapt:attr name="android:fillColor">
+      <gradient
+          android:gradientRadius="115.3882"
+          android:centerX="72.364"
+          android:centerY="59.4093"
+          android:type="radial">
+        <item android:offset="0.0029046" android:color="#19FFFFFF"/>
+        <item android:offset="1" android:color="#00FFFFFF"/>
+      </gradient>
+    </aapt:attr>
+  </path>
+</vector>
diff --git a/res/layout-land/confirm_lock_pattern.xml b/res/layout-land/confirm_lock_pattern.xml
index 1fd6824..1126052 100644
--- a/res/layout-land/confirm_lock_pattern.xml
+++ b/res/layout-land/confirm_lock_pattern.xml
@@ -48,13 +48,13 @@
                     android:src="@drawable/ic_enterprise" />
 
                 <TextView
-                    android:id="@+id/headerText"
+                    android:id="@+id/suc_layout_title"
                     style="@style/SudGlifHeaderTitle"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content" />
 
                 <TextView
-                    android:id="@+id/sud_layout_description"
+                    android:id="@+id/sud_layout_subtitle"
                     style="@style/SudDescription.Glif"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
diff --git a/res/layout-land/confirm_lock_pattern_normal.xml b/res/layout-land/confirm_lock_pattern_normal.xml
index 7a59894..2a9103f 100644
--- a/res/layout-land/confirm_lock_pattern_normal.xml
+++ b/res/layout-land/confirm_lock_pattern_normal.xml
@@ -48,14 +48,14 @@
                     android:src="@drawable/ic_lock" />
 
                 <TextView
-                    android:id="@+id/headerText"
+                    android:id="@+id/suc_layout_title"
                     style="@style/SudGlifHeaderTitle"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content" />
 
                 <TextView
                     style="@style/SudDescription.Glif"
-                    android:id="@+id/sud_layout_description"
+                    android:id="@+id/sud_layout_subtitle"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginStart="?attr/sudMarginStart"
diff --git a/res/layout/app_authentication_item.xml b/res/layout/app_authentication_item.xml
index 423722e..16d6fbd 100644
--- a/res/layout/app_authentication_item.xml
+++ b/res/layout/app_authentication_item.xml
@@ -26,7 +26,8 @@
         android:layout_width="24dp"
         android:layout_height="24dp"/>
 
-    <LinearLayout
+    <RelativeLayout
+        android:id="@+id/app_details"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_toRightOf="@id/app_icon"
@@ -44,16 +45,18 @@
         <TextView
             android:id="@+id/number_of_uris"
             style="@style/AppAuthenticationPolicyNumberOfUrisText"
+            android:layout_below="@id/app_name"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:visibility="gone"/>
 
         <androidx.recyclerview.widget.RecyclerView
             android:id="@+id/uris"
+            android:layout_below="@id/app_name"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"/>
 
-    </LinearLayout>
+    </RelativeLayout>
 
     <ImageView
         android:id="@+id/expand"
diff --git a/res/layout/confirm_lock_pattern_base.xml b/res/layout/confirm_lock_pattern_base.xml
index 895bb8a..bac2689 100644
--- a/res/layout/confirm_lock_pattern_base.xml
+++ b/res/layout/confirm_lock_pattern_base.xml
@@ -42,13 +42,13 @@
                 android:src="@drawable/ic_enterprise" />
 
             <TextView
-                android:id="@+id/headerText"
+                android:id="@+id/suc_layout_title"
                 style="@style/SudGlifHeaderTitle"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
 
             <TextView
-                android:id="@+id/sud_layout_description"
+                android:id="@+id/sud_layout_subtitle"
                 style="@style/SudDescription.Glif"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
diff --git a/res/layout/confirm_lock_pattern_normal_base.xml b/res/layout/confirm_lock_pattern_normal_base.xml
index 7c1502d..29783dd 100644
--- a/res/layout/confirm_lock_pattern_normal_base.xml
+++ b/res/layout/confirm_lock_pattern_normal_base.xml
@@ -41,14 +41,14 @@
                 android:src="@drawable/ic_lock" />
 
             <TextView
-                android:id="@+id/headerText"
+                android:id="@+id/suc_layout_title"
                 style="@style/SudGlifHeaderTitle"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" />
 
             <TextView
                 style="@style/SudDescription.Glif"
-                android:id="@+id/sud_layout_description"
+                android:id="@+id/sud_layout_subtitle"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginStart="?attr/sudMarginStart"
diff --git a/res/values/config.xml b/res/values/config.xml
index 2546d8d..5a8f636 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -522,4 +522,7 @@
 
     <!-- Media Uri to view documents & other storage category. -->
     <string name="config_documents_and_other_storage_category_uri" translatable="false">content://com.android.providers.media.documents/root/documents_root</string>
+
+    <!-- Whether to show Smart Storage toggle -->
+    <bool name="config_show_smart_storage_toggle">true</bool>
 </resources>
diff --git a/res/xml/smart_battery_detail.xml b/res/xml/smart_battery_detail.xml
index 2d36119..c2b3d1f 100644
--- a/res/xml/smart_battery_detail.xml
+++ b/res/xml/smart_battery_detail.xml
@@ -22,11 +22,6 @@
     android:title="@string/smart_battery_manager_title"
     settings:searchable="false">
 
-    <com.android.settingslib.widget.MainSwitchPreference
-        android:key="smart_battery"
-        android:title="@string/adaptive_battery_main_switch_title"
-        settings:controller="com.android.settings.fuelgauge.SmartBatteryPreferenceController"/>
-
     <com.android.settings.widget.VideoPreference
         android:key="auto_awesome_battery"
         android:title="@string/summary_placeholder"
@@ -35,6 +30,13 @@
         settings:controller="com.android.settings.widget.VideoPreferenceController"/>
 
     <SwitchPreference
+        android:key="smart_battery"
+        android:title="@string/smart_battery_title"
+        android:summary="@string/smart_battery_summary"
+        settings:controller="com.android.settings.fuelgauge.SmartBatteryPreferenceController"
+        settings:allowDividerAbove="true"/>
+
+    <SwitchPreference
         android:key="auto_restriction"
         android:title="@string/battery_auto_restriction_title"
         android:summary="@string/battery_auto_restriction_summary"
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index 076405f..9bca65a 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -42,40 +42,55 @@
         android:key="free_up_space"
         android:order="4"
         android:title="@string/storage_free_up_space_title"
-        android:summary="@string/storage_free_up_space_summary"/>
+        android:summary="@string/storage_free_up_space_summary"
+        settings:allowDividerAbove="true"
+        android:icon="@drawable/ic_files_go_round"/>
     <!-- Preference order 100~200 are 'ONLY' for storage category preferences below. -->
+    <Preference
+        android:key="pref_public_storage"
+        android:title="@string/storage_files"
+        android:icon="@drawable/ic_folder_vd_theme_24"
+        android:order="100"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_images"
         android:title="@string/storage_images"
-        android:icon="@drawable/ic_photo_library"/>
+        android:icon="@drawable/ic_photo_library"
+        android:order="101"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_videos"
         android:title="@string/storage_videos"
-        android:icon="@drawable/ic_local_movies"/>
+        android:icon="@drawable/ic_local_movies"
+        android:order="102"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_audios"
         android:title="@string/storage_audios"
-        android:icon="@drawable/ic_media_stream"/>
+        android:icon="@drawable/ic_media_stream"
+        android:order="103"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_apps"
         android:title="@string/storage_apps"
-        android:icon="@drawable/ic_storage_apps"/>
+        android:icon="@drawable/ic_storage_apps"
+        android:order="104"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_games"
         android:title="@string/storage_games"
-        android:icon="@drawable/ic_videogame_vd_theme_24"/>
+        android:icon="@drawable/ic_videogame_vd_theme_24"
+        android:order="105"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_documents_and_other"
         android:title="@string/storage_documents_and_other"
-        android:icon="@drawable/ic_folder_vd_theme_24"/>
+        android:icon="@drawable/ic_folder_vd_theme_24"
+        android:order="106"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_system"
         android:title="@string/storage_system"
-        android:icon="@drawable/ic_system_update"/>
+        android:icon="@drawable/ic_system_update"
+        android:order="107"/>
     <com.android.settings.deviceinfo.StorageItemPreference
         android:key="pref_trash"
         android:title="@string/storage_trash"
-        android:icon="@drawable/ic_trash_can"/>
+        android:icon="@drawable/ic_trash_can"
+        android:order="108"/>
     <!-- Preference order 100~200 are 'ONLY' for storage category preferences above. -->
     <PreferenceCategory
         android:key="pref_secondary_users"
diff --git a/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java b/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java
index 7d6abe7..a277169 100644
--- a/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java
+++ b/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java
@@ -86,6 +86,7 @@
 
     private ClearDefaultsPreference mClearDefaultsPreference;
     private MainSwitchPreference mMainSwitchPreference;
+    private Preference mAddLinkPreference;
     private PreferenceCategory mMainPreferenceCategory;
     private PreferenceCategory mSelectedLinksPreferenceCategory;
     private PreferenceCategory mOtherDefaultsPreferenceCategory;
@@ -155,6 +156,7 @@
             }
             setDomainVerificationUserSelection(userState.getIdentifier(), domainSet, /* enabled= */
                     false);
+            mAddLinkPreference.setEnabled(isAddLinksNotEmpty());
         }
         return true;
     }
@@ -209,8 +211,8 @@
         initMainSwitchAndCategories();
         if (canUpdateMainSwitchAndCategories()) {
             initVerifiedLinksPreference();
-            addSelectedLinksPreference();
             initAddLinkPreference();
+            addSelectedLinksPreference();
             initFooter();
         }
     }
@@ -293,7 +295,7 @@
     }
 
     /** Add selected links items */
-    public void addSelectedLinksPreference() {
+    void addSelectedLinksPreference() {
         if (getLinksNumber(DOMAIN_STATE_SELECTED) == 0) {
             return;
         }
@@ -303,22 +305,25 @@
         for (String host : selectedLinks) {
             generateCheckBoxPreference(mSelectedLinksPreferenceCategory, host);
         }
+        mAddLinkPreference.setEnabled(isAddLinksNotEmpty());
     }
 
     /** Initialize add link preference */
     private void initAddLinkPreference() {
-        final Preference addLinkPreference = findPreference(ADD_LINK_PREF_KEY);
-        if (addLinkPreference != null) {
-            addLinkPreference.setEnabled(getLinksNumber(DOMAIN_STATE_NONE) > 0);
-            addLinkPreference.setOnPreferenceClickListener(preference -> {
-                final int stateNoneLinksNo = getLinksNumber(DOMAIN_STATE_NONE);
-                IntentPickerUtils.logd("The number of the state none links: " + stateNoneLinksNo);
-                if (stateNoneLinksNo > 0) {
-                    showProgressDialogFragment();
-                }
-                return true;
-            });
-        }
+        mAddLinkPreference = findPreference(ADD_LINK_PREF_KEY);
+        mAddLinkPreference.setEnabled(isAddLinksNotEmpty());
+        mAddLinkPreference.setOnPreferenceClickListener(preference -> {
+            final int stateNoneLinksNo = getLinksNumber(DOMAIN_STATE_NONE);
+            IntentPickerUtils.logd("The number of the state none links: " + stateNoneLinksNo);
+            if (stateNoneLinksNo > 0) {
+                showProgressDialogFragment();
+            }
+            return true;
+        });
+    }
+
+    private boolean isAddLinksNotEmpty() {
+        return getLinksNumber(DOMAIN_STATE_NONE) > 0;
     }
 
     private void showProgressDialogFragment() {
diff --git a/src/com/android/settings/datetime/timezone/RegionSearchPicker.java b/src/com/android/settings/datetime/timezone/RegionSearchPicker.java
index 07986e2..85d5d70 100644
--- a/src/com/android/settings/datetime/timezone/RegionSearchPicker.java
+++ b/src/com/android/settings/datetime/timezone/RegionSearchPicker.java
@@ -71,14 +71,14 @@
         final FilteredCountryTimeZones countryTimeZones = mTimeZoneData.lookupCountryTimeZones(
                 regionId);
         final Activity activity = getActivity();
-        if (countryTimeZones == null || countryTimeZones.getTimeZoneIds().isEmpty()) {
+        if (countryTimeZones == null || countryTimeZones.getPreferredTimeZoneIds().isEmpty()) {
             Log.e(TAG, "Region has no time zones: " + regionId);
             activity.setResult(Activity.RESULT_CANCELED);
             activity.finish();
             return;
         }
 
-        List<String> timeZoneIds = countryTimeZones.getTimeZoneIds();
+        List<String> timeZoneIds = countryTimeZones.getPreferredTimeZoneIds();
         // Choose the time zone associated the region if there is only one time zone in that region
         if (timeZoneIds.size() == 1) {
             final Intent resultData = new Intent()
diff --git a/src/com/android/settings/datetime/timezone/RegionZonePicker.java b/src/com/android/settings/datetime/timezone/RegionZonePicker.java
index 8e4aa05..7f988cd 100644
--- a/src/com/android/settings/datetime/timezone/RegionZonePicker.java
+++ b/src/com/android/settings/datetime/timezone/RegionZonePicker.java
@@ -103,7 +103,7 @@
         // It could be a timely operations if there are many time zones. A region in time zone data
         // contains a maximum of 29 time zones currently. It may change in the future, but it's
         // unlikely to be changed drastically.
-        return getRegionTimeZoneInfo(filteredCountryTimeZones.getTimeZoneIds());
+        return getRegionTimeZoneInfo(filteredCountryTimeZones.getPreferredTimeZoneIds());
     }
 
     /**
diff --git a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
index 60cd636..6c779b5 100644
--- a/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
+++ b/src/com/android/settings/datetime/timezone/TimeZoneSettings.java
@@ -214,10 +214,11 @@
                 mTimeZoneData.lookupCountryTimeZones(regionId);
 
         use(RegionZonePreferenceController.class).setTimeZoneInfo(tzInfo);
-        // Only clickable when the region has more than 1 time zones or no time zone is selected.
 
+        // Only clickable when the region has more than 1 time zones or no time zone is selected.
         use(RegionZonePreferenceController.class).setClickable(tzInfo == null ||
-                (countryTimeZones != null && countryTimeZones.getTimeZoneIds().size() > 1));
+                (countryTimeZones != null
+                        && countryTimeZones.getPreferredTimeZoneIds().size() > 1));
         use(TimeZoneInfoPreferenceController.class).setTimeZoneInfo(tzInfo);
 
         updatePreferenceStates();
@@ -244,7 +245,8 @@
 
         FilteredCountryTimeZones countryTimeZones =
                 timeZoneData.lookupCountryTimeZones(regionId);
-        if (countryTimeZones == null || !countryTimeZones.getTimeZoneIds().contains(tzId)) {
+        if (countryTimeZones == null
+                || !countryTimeZones.getPreferredTimeZoneIds().contains(tzId)) {
             Log.e(TAG, "Unknown time zone id is selected: " + tzId);
             return;
         }
diff --git a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
index 7a38853..05a542d 100644
--- a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
+++ b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
@@ -16,11 +16,15 @@
 
 package com.android.settings.datetime.timezone.model;
 
+import android.util.ArraySet;
+
 import com.android.i18n.timezone.CountryTimeZones;
 
+import java.time.Instant;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.stream.Collectors;
+import java.util.Set;
 
 /**
  * Wrap {@class CountryTimeZones} to filter time zone that are shown in the picker.
@@ -39,31 +43,46 @@
      * a timestamp known to be in the recent past is used. This should be updated occasionally but
      * it doesn't have to be very often.
      */
-    private static final long MIN_USE_DATE_OF_TIMEZONE = 1546300800000L; // 1/1/2019 00:00 UTC
+    private static final Instant MIN_USE_DATE_OF_TIMEZONE =
+            Instant.ofEpochMilli(1546300800000L); // 1/1/2019 00:00 UTC
 
     private final CountryTimeZones mCountryTimeZones;
-    private final List<String> mTimeZoneIds;
+    private final List<String> mPreferredTimeZoneIds;
+    private final Set<String> mAlternativeTimeZoneIds;
 
     public FilteredCountryTimeZones(CountryTimeZones countryTimeZones) {
         mCountryTimeZones = countryTimeZones;
-        List<String> timeZoneIds = countryTimeZones.getTimeZoneMappings().stream()
-                .filter(timeZoneMapping ->
-                        timeZoneMapping.isShownInPicker()
-                                && (timeZoneMapping.getNotUsedAfter() == null
-                                || timeZoneMapping.getNotUsedAfter() >= MIN_USE_DATE_OF_TIMEZONE))
-                .map(timeZoneMapping -> timeZoneMapping.getTimeZoneId())
-                .collect(Collectors.toList());
-        mTimeZoneIds = Collections.unmodifiableList(timeZoneIds);
+        List<String> timeZoneIds = new ArrayList<>();
+        Set<String> alternativeTimeZoneIds = new ArraySet<>();
+        for (CountryTimeZones.TimeZoneMapping timeZoneMapping :
+                countryTimeZones.getTimeZoneMappings()) {
+            if (timeZoneMapping.isShownInPickerAt(MIN_USE_DATE_OF_TIMEZONE)) {
+                String timeZoneId = timeZoneMapping.getTimeZoneId();
+                timeZoneIds.add(timeZoneId);
+                alternativeTimeZoneIds.addAll(timeZoneMapping.getAlternativeIds());
+            }
+        }
+        mPreferredTimeZoneIds = Collections.unmodifiableList(timeZoneIds);
+        mAlternativeTimeZoneIds = Collections.unmodifiableSet(alternativeTimeZoneIds);
     }
 
-    public List<String> getTimeZoneIds() {
-        return mTimeZoneIds;
+    public List<String> getPreferredTimeZoneIds() {
+        return mPreferredTimeZoneIds;
     }
 
     public CountryTimeZones getCountryTimeZones() {
         return mCountryTimeZones;
     }
 
+    /**
+     * Returns whether {@code timeZoneId} is currently used in the country or is an alternative
+     * name of a currently used time zone.
+     */
+    public boolean matches(String timeZoneId) {
+        return mPreferredTimeZoneIds.contains(timeZoneId)
+                || mAlternativeTimeZoneIds.contains(timeZoneId);
+    }
+
     public String getRegionId() {
         return TimeZoneData.normalizeRegionId(mCountryTimeZones.getCountryIso());
     }
diff --git a/src/com/android/settings/datetime/timezone/model/TimeZoneData.java b/src/com/android/settings/datetime/timezone/model/TimeZoneData.java
index 335e6e2..06f2de0 100644
--- a/src/com/android/settings/datetime/timezone/model/TimeZoneData.java
+++ b/src/com/android/settings/datetime/timezone/model/TimeZoneData.java
@@ -71,7 +71,7 @@
         Set<String> regionIds = new ArraySet<>();
         for (CountryTimeZones countryTimeZone : countryTimeZones) {
             FilteredCountryTimeZones filteredZones = new FilteredCountryTimeZones(countryTimeZone);
-            if (filteredZones.getTimeZoneIds().contains(tzId)) {
+            if (filteredZones.matches(tzId)) {
                 regionIds.add(filteredZones.getRegionId());
             }
         }
diff --git a/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java b/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
index 536f699..e6d9dfd 100644
--- a/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
+++ b/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java
@@ -58,7 +58,7 @@
     public DeviceNamePreferenceController(Context context, String key) {
         super(context, key);
 
-        mWifiManager = context.getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mWifiDeviceNameTextValidator = new WifiDeviceNameTextValidator();
         mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
 
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index b8c4e28..03a7b97 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -248,15 +248,19 @@
 
         mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
 
-        if (mSelectedStorageEntry.isPrivate() && mSelectedStorageEntry.isMounted()) {
+        if (!mSelectedStorageEntry.isMounted()) {
+            // Set null volume to hide category stats.
+            mPreferenceController.setVolume(null);
+            return;
+        }
+        if (mSelectedStorageEntry.isPrivate()) {
             // Stats data is only available on private volumes.
             getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
             getLoaderManager()
                  .restartLoader(VOLUME_SIZE_JOB_ID, Bundle.EMPTY, new VolumeSizeCallbacks());
             getLoaderManager().restartLoader(ICON_JOB_ID, Bundle.EMPTY, new IconLoaderCallbacks());
         } else {
-            // Set null volume to hide category stats.
-            mPreferenceController.setVolume(null);
+            mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
         }
     }
 
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
index 9e969a8..7d20aa7 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java
@@ -121,7 +121,7 @@
         try {
             moveId = getPackageManager().movePrimaryStorage(mVolume);
         } catch (IllegalArgumentException e) {
-            StorageManager sm = getSystemService(StorageManager.class);
+            StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
 
             if (Objects.equals(mVolume.getFsUuid(), sm.getPrimaryStorageVolume().getUuid())) {
                 final Intent intent = new Intent(this, StorageWizardReady.class);
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index fcbd5d3..4af5d79 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -146,8 +146,8 @@
         // TODO: There may be an avatar setting action we can use here.
         final int iconId = bundle.getInt("icon_id", 0);
         if (iconId == 0) {
-            final UserManager userManager = getActivity().getSystemService(
-                    UserManager.class);
+            final UserManager userManager = (UserManager) getActivity().getSystemService(
+                    Context.USER_SERVICE);
             final UserInfo info = Utils.getExistingUser(userManager,
                     android.os.Process.myUserHandle());
             controller.setLabel(info.name);
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
index 14e86b4..d6cf442 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
@@ -49,7 +49,7 @@
 
     public FirmwareVersionDetailPreferenceController(Context context, String key) {
         super(context, key);
-        mUserManager = mContext.getSystemService(UserManager.class);
+        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
         initializeAdminPermissions();
     }
 
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index fbb29a7..967eea6 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -49,7 +49,7 @@
 
     public ImeiInfoPreferenceController(Context context, String key) {
         super(context, key);
-        mTelephonyManager = context.getSystemService(TelephonyManager.class);
+        mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
         mIsMultiSim = mTelephonyManager.getPhoneCount() > 1;
     }
 
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java
index c391750..02c1916 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusPreferenceController.java
@@ -46,9 +46,9 @@
     public SimStatusPreferenceController(Context context, Fragment fragment) {
         super(context);
 
-        mTelephonyManager = context.getSystemService(TelephonyManager.class);
-        mSubscriptionManager = context.getSystemService(
-                SubscriptionManager.class);
+        mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        mSubscriptionManager = (SubscriptionManager) context.getSystemService(
+                Context.TELEPHONY_SUBSCRIPTION_SERVICE);
         mFragment = fragment;
     }
 
diff --git a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
index f733c72..f753868 100644
--- a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
@@ -26,6 +26,7 @@
 import androidx.fragment.app.FragmentManager;
 import androidx.preference.PreferenceScreen;
 
+import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.deletionhelper.ActivationWarningFragment;
 import com.android.settings.overlay.FeatureFactory;
@@ -66,6 +67,9 @@
 
     @Override
     public int getAvailabilityStatus() {
+        if (!mContext.getResources().getBoolean(R.bool.config_show_smart_storage_toggle)) {
+            return UNSUPPORTED_ON_DEVICE;
+        }
         return !ActivityManager.isLowRamDeviceStatic() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
     }
 
@@ -108,4 +112,4 @@
 
         return true;
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageEntry.java b/src/com/android/settings/deviceinfo/storage/StorageEntry.java
index f718116..9ea0292 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageEntry.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageEntry.java
@@ -236,6 +236,14 @@
         return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_PUBLIC;
     }
 
+    /**
+     * Stub volume is a volume that is maintained by external party such as the ChromeOS processes
+     * in ARC++.
+     */
+    public boolean isStub() {
+        return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_STUB;
+    }
+
     /** Returns description. */
     public String getDescription() {
         if (isVolumeInfo()) {
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 7d77687..e5259f9 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -70,6 +70,8 @@
     private static final String SYSTEM_FRAGMENT_TAG = "SystemInfo";
 
     @VisibleForTesting
+    static final String PUBLIC_STORAGE_KEY = "pref_public_storage";
+    @VisibleForTesting
     static final String IMAGES_KEY = "pref_images";
     @VisibleForTesting
     static final String VIDEOS_KEY = "pref_videos";
@@ -103,9 +105,11 @@
     private long mUsedBytes;
     private long mTotalSize;
 
-    private List<StorageItemPreference> mStorageItemPreferences;
+    private List<StorageItemPreference> mPrivateStorageItemPreferences;
     private PreferenceScreen mScreen;
     @VisibleForTesting
+    Preference mPublicStoragePreference;
+    @VisibleForTesting
     StorageItemPreference mImagesPreference;
     @VisibleForTesting
     StorageItemPreference mVideosPreference;
@@ -167,6 +171,9 @@
             return false;
         }
         switch (preference.getKey()) {
+            case PUBLIC_STORAGE_KEY:
+                launchPublicStorageIntent();
+                return true;
             case IMAGES_KEY:
                 launchImagesIntent();
                 return true;
@@ -210,37 +217,45 @@
     public void setVolume(VolumeInfo volume) {
         mVolume = volume;
 
-        final boolean isValidVolume = isValidVolume();
-        setCategoryPreferencesVisibility(isValidVolume);
-        if (isValidVolume) {
-            updateCategoryPreferencesOrder();
-        }
+        updateCategoryPreferencesVisibility();
+        updatePrivateStorageCategoryPreferencesOrder();
     }
 
     // Stats data is only available on private volumes.
-    private boolean isValidVolume() {
+    private boolean isValidPrivateVolume() {
         return mVolume != null
                 && mVolume.getType() == VolumeInfo.TYPE_PRIVATE
                 && (mVolume.getState() == VolumeInfo.STATE_MOUNTED
                 || mVolume.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
     }
 
-    private void setCategoryPreferencesVisibility(boolean visible) {
+    private boolean isValidPublicVolume() {
+        return mVolume != null
+                && (mVolume.getType() == VolumeInfo.TYPE_PUBLIC
+                || mVolume.getType() == VolumeInfo.TYPE_STUB)
+                && (mVolume.getState() == VolumeInfo.STATE_MOUNTED
+                || mVolume.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
+    }
+
+    private void updateCategoryPreferencesVisibility() {
         if (mScreen == null) {
             return;
         }
 
-        mImagesPreference.setVisible(visible);
-        mVideosPreference.setVisible(visible);
-        mAudiosPreference.setVisible(visible);
-        mAppsPreference.setVisible(visible);
-        mGamesPreference.setVisible(visible);
-        mDocumentsAndOtherPreference.setVisible(visible);
-        mSystemPreference.setVisible(visible);
+        mPublicStoragePreference.setVisible(isValidPublicVolume());
+
+        final boolean privateStoragePreferencesVisible = isValidPrivateVolume();
+        mImagesPreference.setVisible(privateStoragePreferencesVisible);
+        mVideosPreference.setVisible(privateStoragePreferencesVisible);
+        mAudiosPreference.setVisible(privateStoragePreferencesVisible);
+        mAppsPreference.setVisible(privateStoragePreferencesVisible);
+        mGamesPreference.setVisible(privateStoragePreferencesVisible);
+        mDocumentsAndOtherPreference.setVisible(privateStoragePreferencesVisible);
+        mSystemPreference.setVisible(privateStoragePreferencesVisible);
         // TODO(b/170918505): Shows trash category after trash category feature complete.
         mTrashPreference.setVisible(false);
 
-        if (visible) {
+        if (privateStoragePreferencesVisible) {
             final VolumeInfo sharedVolume = mSvp.findEmulatedForPrivate(mVolume);
             // If we don't have a shared volume for our internal storage (or the shared volume isn't
             // mounted as readable for whatever reason), we should hide the File preference.
@@ -250,22 +265,22 @@
         }
     }
 
-    private void updateCategoryPreferencesOrder() {
-        if (mScreen == null) {
+    private void updatePrivateStorageCategoryPreferencesOrder() {
+        if (mScreen == null || !isValidPrivateVolume()) {
             return;
         }
 
-        if (mStorageItemPreferences == null) {
-            mStorageItemPreferences = new ArrayList<>();
+        if (mPrivateStorageItemPreferences == null) {
+            mPrivateStorageItemPreferences = new ArrayList<>();
 
-            mStorageItemPreferences.add(mImagesPreference);
-            mStorageItemPreferences.add(mVideosPreference);
-            mStorageItemPreferences.add(mAudiosPreference);
-            mStorageItemPreferences.add(mAppsPreference);
-            mStorageItemPreferences.add(mGamesPreference);
-            mStorageItemPreferences.add(mDocumentsAndOtherPreference);
-            mStorageItemPreferences.add(mSystemPreference);
-            mStorageItemPreferences.add(mTrashPreference);
+            mPrivateStorageItemPreferences.add(mImagesPreference);
+            mPrivateStorageItemPreferences.add(mVideosPreference);
+            mPrivateStorageItemPreferences.add(mAudiosPreference);
+            mPrivateStorageItemPreferences.add(mAppsPreference);
+            mPrivateStorageItemPreferences.add(mGamesPreference);
+            mPrivateStorageItemPreferences.add(mDocumentsAndOtherPreference);
+            mPrivateStorageItemPreferences.add(mSystemPreference);
+            mPrivateStorageItemPreferences.add(mTrashPreference);
         }
         mScreen.removePreference(mImagesPreference);
         mScreen.removePreference(mVideosPreference);
@@ -277,10 +292,10 @@
         mScreen.removePreference(mTrashPreference);
 
         // Sort display order by size.
-        Collections.sort(mStorageItemPreferences,
+        Collections.sort(mPrivateStorageItemPreferences,
                 Comparator.comparingLong(StorageItemPreference::getStorageSize));
         int orderIndex = LAST_STORAGE_CATEGORY_PREFERENCE_ORDER;
-        for (StorageItemPreference preference : mStorageItemPreferences) {
+        for (StorageItemPreference preference : mPrivateStorageItemPreferences) {
             preference.setOrder(orderIndex--);
             mScreen.addPreference(preference);
         }
@@ -292,6 +307,7 @@
     public void setUserId(UserHandle userHandle) {
         mUserId = userHandle.getIdentifier();
 
+        tintPreference(mPublicStoragePreference);
         tintPreference(mImagesPreference);
         tintPreference(mVideosPreference);
         tintPreference(mAudiosPreference);
@@ -320,6 +336,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         mScreen = screen;
+        mPublicStoragePreference = screen.findPreference(PUBLIC_STORAGE_KEY);
         mImagesPreference = screen.findPreference(IMAGES_KEY);
         mVideosPreference = screen.findPreference(VIDEOS_KEY);
         mAudiosPreference = screen.findPreference(AUDIOS_KEY);
@@ -329,11 +346,8 @@
         mSystemPreference = screen.findPreference(SYSTEM_KEY);
         mTrashPreference = screen.findPreference(TRASH_KEY);
 
-        final boolean isValidVolume = isValidVolume();
-        setCategoryPreferencesVisibility(isValidVolume);
-        if (isValidVolume) {
-            updateCategoryPreferencesOrder();
-        }
+        updateCategoryPreferencesVisibility();
+        updatePrivateStorageCategoryPreferencesOrder();
     }
 
     public void onLoadFinished(SparseArray<StorageAsyncLoader.AppsStorageResult> result,
@@ -371,7 +385,7 @@
             mSystemPreference.setStorageSize(systemSize, mTotalSize);
         }
 
-        updateCategoryPreferencesOrder();
+        updatePrivateStorageCategoryPreferencesOrder();
     }
 
     public void setUsedSize(long usedSizeBytes) {
@@ -382,6 +396,13 @@
         mTotalSize = totalSizeBytes;
     }
 
+    private void launchPublicStorageIntent() {
+        final Intent intent = mVolume.buildBrowseIntent();
+        if (intent != null) {
+            mContext.startActivity(intent);
+        }
+    }
+
     // TODO(b/183078080): To simplify StorageItemPreferenceController, move launchxxxIntent to a
     //                    utility object.
     private void launchImagesIntent() {
diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java
index 09380ff..ed52f48 100644
--- a/src/com/android/settings/fuelgauge/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryEntry.java
@@ -52,6 +52,19 @@
  * and icon image.
  */
 public class BatteryEntry {
+
+    public static final class NameAndIcon {
+        public final String name;
+        public final Drawable icon;
+        public final int iconId;
+
+        public NameAndIcon(String name, Drawable icon, int iconId) {
+            this.name = name;
+            this.icon = icon;
+            this.iconId = iconId;
+        }
+    }
+
     public static final int MSG_UPDATE_NAME_ICON = 1;
     public static final int MSG_REPORT_FULLY_DRAWN = 2;
 
@@ -186,22 +199,16 @@
         } else if (batteryConsumer instanceof SystemBatteryConsumer) {
             mConsumedPower = batteryConsumer.getConsumedPower()
                     - ((SystemBatteryConsumer) batteryConsumer).getPowerConsumedByApps();
-            final Pair<Integer, String> resourcePair = getResourcePairFromDrainType(
+            final NameAndIcon nameAndIcon = getNameAndIconFromDrainType(
                     context, ((SystemBatteryConsumer) batteryConsumer).getDrainType());
-            iconId = resourcePair.first;
-            name = resourcePair.second;
+            iconId = nameAndIcon.iconId;
+            name = nameAndIcon.name;
         } else if (batteryConsumer instanceof UserBatteryConsumer) {
             mConsumedPower = batteryConsumer.getConsumedPower();
-
-            UserInfo info = um.getUserInfo(((UserBatteryConsumer) batteryConsumer).getUserId());
-            if (info != null) {
-                icon = Utils.getUserIcon(context, um, info);
-                name = Utils.getUserLabel(context, info);
-            } else {
-                icon = null;
-                name = context.getResources().getString(
-                        R.string.running_process_item_removed_user_label);
-            }
+            final NameAndIcon nameAndIcon = getNameAndIconFromUserId(
+                    context, ((UserBatteryConsumer) batteryConsumer).getUserId());
+            icon = nameAndIcon.icon;
+            name = nameAndIcon.name;
         }
 
         if (iconId != 0) {
@@ -238,15 +245,9 @@
         }
 
         if (packages == null || packages.length == 0) {
-            if (uid == 0) {
-                name = mContext.getResources().getString(R.string.process_kernel_label);
-            } else if ("mediaserver".equals(name)) {
-                name = mContext.getResources().getString(R.string.process_mediaserver_label);
-            } else if ("dex2oat".equals(name)) {
-                name = mContext.getResources().getString(R.string.process_dex2oat_label);
-            }
-            iconId = R.drawable.ic_power_system;
-            icon = mContext.getDrawable(iconId);
+            final NameAndIcon nameAndIcon = getNameAndIconFromUid(mContext, name, uid);
+            icon = nameAndIcon.icon;
+            name = nameAndIcon.name;
         } else {
             icon = mContext.getPackageManager().getDefaultActivityIcon();
         }
@@ -419,6 +420,13 @@
     }
 
     /**
+     * Returns the BatteryConsumer of the app described by this entry.
+     */
+    public BatteryConsumer getBatteryConsumer() {
+        return mBatteryConsumer;
+    }
+
+    /**
      * Returns foreground foreground time (in milliseconds) that is attributed to this entry.
      */
     public long getTimeInForegroundMs() {
@@ -462,10 +470,46 @@
     }
 
     /**
-     * Gets icon ID and name from system battery consumer drain type.
+     * Gets name and icon resource from UserBatteryConsumer userId.
      */
-    public static Pair<Integer, String> getResourcePairFromDrainType(
-            Context context, int drainType) {
+    public static NameAndIcon getNameAndIconFromUserId(
+            Context context, final int userId) {
+        UserManager um = context.getSystemService(UserManager.class);
+        UserInfo info = um.getUserInfo(userId);
+
+        Drawable icon = null;
+        String name = null;
+        if (info != null) {
+            icon = Utils.getUserIcon(context, um, info);
+            name = Utils.getUserLabel(context, info);
+        } else {
+            name = context.getResources().getString(
+                    R.string.running_process_item_removed_user_label);
+        }
+        return new NameAndIcon(name, icon, 0 /* iconId */);
+    }
+
+    /**
+     * Gets name and icon resource from UidBatteryConsumer uid.
+     */
+    public static NameAndIcon getNameAndIconFromUid(
+            Context context, String name, final int uid) {
+        Drawable icon = context.getDrawable(R.drawable.ic_power_system);
+        if (uid == 0) {
+            name = context.getResources().getString(R.string.process_kernel_label);
+        } else if ("mediaserver".equals(name)) {
+            name = context.getResources().getString(R.string.process_mediaserver_label);
+        } else if ("dex2oat".equals(name)) {
+            name = context.getResources().getString(R.string.process_dex2oat_label);
+        }
+        return new NameAndIcon(name, icon, 0 /* iconId */);
+    }
+
+    /**
+     * Gets name annd icon resource from SystemBatteryConsumer drain type.
+     */
+    public static NameAndIcon getNameAndIconFromDrainType(
+            Context context, final int drainType) {
         String name = null;
         int iconId = 0;
         switch (drainType) {
@@ -511,6 +555,6 @@
                 iconId = R.drawable.ic_power_system;
                 break;
         }
-        return new Pair<>(Integer.valueOf(iconId), name);
+        return new NameAndIcon(name, null /* icon */, iconId);
     }
 }
diff --git a/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java
index ea277a1..27b70cb 100644
--- a/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/SmartBatteryPreferenceController.java
@@ -20,27 +20,23 @@
 import android.content.Context;
 import android.provider.Settings;
 import android.text.TextUtils;
-import android.widget.Switch;
 
 import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
 
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.widget.MainSwitchPreference;
-import com.android.settingslib.widget.OnMainSwitchChangeListener;
 
 /**
  * Controller to change and update the smart battery toggle
  */
 public class SmartBatteryPreferenceController extends BasePreferenceController implements
-        OnMainSwitchChangeListener {
+        Preference.OnPreferenceChangeListener {
 
     private static final String KEY_SMART_BATTERY = "smart_battery";
     private static final int ON = 1;
     private static final int OFF = 0;
     private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
-    private MainSwitchPreference mPreference;
 
     public SmartBatteryPreferenceController(Context context) {
         super(context, KEY_SMART_BATTERY);
@@ -70,19 +66,14 @@
         super.updateState(preference);
         final boolean smartBatteryOn = Settings.Global.getInt(mContext.getContentResolver(),
                 Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, ON) == ON;
-        ((MainSwitchPreference) preference).updateStatus(smartBatteryOn);
+        ((SwitchPreference) preference).setChecked(smartBatteryOn);
     }
 
     @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mPreference = (MainSwitchPreference) screen.findPreference(getPreferenceKey());
-        mPreference.addOnSwitchChangeListener(this);
-    }
-
-    @Override
-    public void onSwitchChanged(Switch switchView, boolean isChecked) {
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        final boolean smartBatteryOn = (Boolean) newValue;
         Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, isChecked ? ON : OFF);
+                Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, smartBatteryOn ? ON : OFF);
+        return true;
     }
 }
diff --git a/src/com/android/settings/network/EthernetTetherPreferenceController.java b/src/com/android/settings/network/EthernetTetherPreferenceController.java
index 3559edb..06cd6a7 100644
--- a/src/com/android/settings/network/EthernetTetherPreferenceController.java
+++ b/src/com/android/settings/network/EthernetTetherPreferenceController.java
@@ -43,7 +43,7 @@
         super(context, preferenceKey);
         mEthernetRegex = context.getString(
                 com.android.internal.R.string.config_ethernet_iface_regex);
-        mEthernetManager = context.getSystemService(EthernetManager.class);
+        mEthernetManager = (EthernetManager) context.getSystemService(Context.ETHERNET_SERVICE);
     }
 
     @OnLifecycleEvent(Lifecycle.Event.ON_START)
diff --git a/src/com/android/settings/network/InternetUpdater.java b/src/com/android/settings/network/InternetUpdater.java
index 3967276..dd70cef 100644
--- a/src/com/android/settings/network/InternetUpdater.java
+++ b/src/com/android/settings/network/InternetUpdater.java
@@ -142,13 +142,13 @@
     private NetworkCallback mNetworkCallback = new NetworkCallback() {
         public void onCapabilitiesChanged(@NonNull Network network,
                 @NonNull NetworkCapabilities networkCapabilities) {
-            checkNetworkCapabilities(networkCapabilities);
+            updateInternetAvailable(networkCapabilities);
         }
 
         @Override
         public void onLost(@NonNull Network network) {
             mInternetAvailable = false;
-            update();
+            updateInternetType();
         }
     };
 
@@ -203,7 +203,7 @@
         Network activeNetwork = mConnectivityManager.getActiveNetwork();
         if (activeNetwork == null) {
             mInternetAvailable = false;
-            update();
+            updateInternetType();
             return;
         }
 
@@ -211,36 +211,34 @@
                 mConnectivityManager.getNetworkCapabilities(activeNetwork);
         if (activeNetworkCapabilities == null) {
             mInternetAvailable = false;
-            update();
+            updateInternetType();
             return;
         }
 
-        checkNetworkCapabilities(activeNetworkCapabilities);
-    }
-
-    private void checkNetworkCapabilities(@NonNull NetworkCapabilities networkCapabilities) {
-        if (!networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
-            mInternetAvailable = false;
-            update();
-            return;
-        }
-
-        boolean internetAvailable = false;
-        for (int transport : networkCapabilities.getTransportTypes()) {
-            if (sTransportMap.containsKey(transport)) {
-                mTransport = transport;
-                internetAvailable = true;
-                Log.i(TAG, "Detect an internet capability network with transport type: "
-                        + mTransport);
-                break;
-            }
-        }
-        mInternetAvailable = internetAvailable;
-        update();
+        updateInternetAvailable(activeNetworkCapabilities);
     }
 
     @VisibleForTesting
-    void update() {
+    void updateInternetAvailable(@NonNull NetworkCapabilities capabilities) {
+        boolean internetAvailable = false;
+        if (capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
+                && capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
+            for (int transport : capabilities.getTransportTypes()) {
+                if (sTransportMap.containsKey(transport)) {
+                    mTransport = transport;
+                    internetAvailable = true;
+                    Log.i(TAG, "Detect an internet available network with transport type: "
+                            + mTransport);
+                    break;
+                }
+            }
+        }
+        mInternetAvailable = internetAvailable;
+        updateInternetType();
+    }
+
+    @VisibleForTesting
+    void updateInternetType() {
         @InternetType int internetType = INTERNET_NETWORKS_AVAILABLE;
         if (mInternetAvailable) {
             internetType = sTransportMap.get(mTransport);
diff --git a/src/com/android/settings/network/MobilePlanPreferenceController.java b/src/com/android/settings/network/MobilePlanPreferenceController.java
index 65439bc..d8963ad 100644
--- a/src/com/android/settings/network/MobilePlanPreferenceController.java
+++ b/src/com/android/settings/network/MobilePlanPreferenceController.java
@@ -73,9 +73,9 @@
             MobilePlanPreferenceHost host) {
         super(context);
         mHost = host;
-        mCm = context.getSystemService(ConnectivityManager.class);
-        mTm = context.getSystemService(TelephonyManager.class);
-        mUserManager = context.getSystemService(UserManager.class);
+        mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mTm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
         mIsSecondaryUser = !mUserManager.isAdminUser();
     }
 
diff --git a/src/com/android/settings/network/NetworkResetRestrictionChecker.java b/src/com/android/settings/network/NetworkResetRestrictionChecker.java
index c873f9d..46227f9 100644
--- a/src/com/android/settings/network/NetworkResetRestrictionChecker.java
+++ b/src/com/android/settings/network/NetworkResetRestrictionChecker.java
@@ -31,7 +31,7 @@
 
     public NetworkResetRestrictionChecker(Context context) {
         mContext = context;
-        mUserManager = context.getSystemService(UserManager.class);
+        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
     }
 
     @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
diff --git a/src/com/android/settings/network/NetworkScorerPicker.java b/src/com/android/settings/network/NetworkScorerPicker.java
index 011cf05..9ecab3b 100644
--- a/src/com/android/settings/network/NetworkScorerPicker.java
+++ b/src/com/android/settings/network/NetworkScorerPicker.java
@@ -140,6 +140,6 @@
 
     @VisibleForTesting
     NetworkScoreManager createNetworkScorerManager(Context context) {
-        return context.getSystemService(NetworkScoreManager.class);
+        return (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
     }
 }
diff --git a/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java b/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java
index 2abe390..4b452c0 100644
--- a/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java
+++ b/src/com/android/settings/network/NetworkScorerPickerPreferenceController.java
@@ -37,7 +37,7 @@
     public NetworkScorerPickerPreferenceController(Context context, String key) {
         super(context, key);
         mNetworkScoreManager =
-                mContext.getSystemService(NetworkScoreManager.class);
+                (NetworkScoreManager) mContext.getSystemService(Context.NETWORK_SCORE_SERVICE);
     }
 
     @Override
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index 18765a8..beb7489 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -21,6 +21,7 @@
 
 import static com.android.settings.slices.CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI;
 
+import android.annotation.ColorInt;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
@@ -30,6 +31,7 @@
 import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
+import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.builders.ListBuilder;
 
@@ -83,9 +85,10 @@
         // Second section:  Add a carrier item.
         // Third section:  Add the Wi-Fi items which are not connected.
         // Fourth section:  If device has connection problem, this row show the message for user.
-        boolean hasEthernet = isEthernetConnected();
+        @InternetUpdater.InternetType int internetType = getInternetType();
         final ListBuilder listBuilder = mHelper.createListBuilder(getUri());
-        if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled() && !hasEthernet) {
+        if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled()
+                && internetType != InternetUpdater.INTERNET_ETHERNET) {
             log("Airplane mode is enabled.");
             return listBuilder.build();
         }
@@ -105,15 +108,17 @@
         log("hasCarrier: " + hasCarrier);
 
         // First section:  Add a Ethernet or Wi-Fi item which state is connected.
+        boolean isConnectedWifiAddedTop = false;
         final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
-        if (hasEthernet) {
+        if (internetType == InternetUpdater.INTERNET_ETHERNET) {
             log("get Ethernet item which is connected");
             listBuilder.addRow(createEthernetRow());
             maxListSize--;
         } else {
-            if (connectedWifiItem != null) {
-                log("get Wi-Fi item which is connected");
+            if (connectedWifiItem != null && internetType == InternetUpdater.INTERNET_WIFI) {
+                log("get Wi-Fi item which is connected to internet");
                 listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
+                isConnectedWifiAddedTop = true;
                 maxListSize--;
             }
         }
@@ -128,7 +133,7 @@
         }
 
         // Third section:  Add the connected Wi-Fi item to Wi-Fi list if the Ethernet is connected.
-        if (connectedWifiItem != null && hasEthernet) {
+        if (connectedWifiItem != null && !isConnectedWifiAddedTop) {
             log("get Wi-Fi item which is connected");
             listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
             maxListSize--;
@@ -222,12 +227,12 @@
         return SliceBackgroundWorker.getInstance(getUri());
     }
 
-    private boolean isEthernetConnected() {
+    private @InternetUpdater.InternetType int getInternetType() {
         final NetworkProviderWorker worker = getWorker();
         if (worker == null) {
-            return false;
+            return InternetUpdater.INTERNET_NETWORKS_AVAILABLE;
         }
-        return worker.isEthernetConnected();
+        return worker.getInternetType();
     }
 
     @VisibleForTesting
@@ -243,6 +248,20 @@
                 .setSubtitle(mContext.getText(R.string.to_switch_networks_disconnect_ethernet));
     }
 
+    @Override
+    protected IconCompat getWifiSliceItemLevelIcon(WifiSliceItem wifiSliceItem) {
+        if (wifiSliceItem.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
+                && getInternetType() != InternetUpdater.INTERNET_WIFI) {
+            final @ColorInt int tint = Utils.getColorAttrDefaultColor(mContext,
+                    android.R.attr.colorControlNormal);
+            final Drawable drawable = mContext.getDrawable(
+                    Utils.getWifiIconResource(wifiSliceItem.getLevel()));
+            drawable.setTint(tint);
+            return Utils.createIconWithDrawable(drawable);
+        }
+        return super.getWifiSliceItemLevelIcon(wifiSliceItem);
+    }
+
     /**
      * Wrap the subscriptionManager call for test mocking.
      */
diff --git a/src/com/android/settings/network/TetherEnabler.java b/src/com/android/settings/network/TetherEnabler.java
index 550d324..ef031f6 100644
--- a/src/com/android/settings/network/TetherEnabler.java
+++ b/src/com/android/settings/network/TetherEnabler.java
@@ -128,10 +128,10 @@
         mSwitchWidgetController = switchWidgetController;
         mDataSaverBackend = new DataSaverBackend(context);
         mConnectivityManager =
-                context.getSystemService(ConnectivityManager.class);
-        mTetheringManager = context.getSystemService(TetheringManager.class);
-        mWifiManager = context.getSystemService(WifiManager.class);
-        mUserManager = context.getSystemService(UserManager.class);
+                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mTetheringManager = (TetheringManager) context.getSystemService(Context.TETHERING_SERVICE);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
         mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
         mBluetoothPan = bluetoothPan;
         mEthernetRegex =
diff --git a/src/com/android/settings/network/apn/ApnEditor.java b/src/com/android/settings/network/apn/ApnEditor.java
index 78b7ccc..afc68d5 100644
--- a/src/com/android/settings/network/apn/ApnEditor.java
+++ b/src/com/android/settings/network/apn/ApnEditor.java
@@ -1291,8 +1291,8 @@
         mReadOnlyApnTypes = null;
         mReadOnlyApnFields = null;
 
-        final CarrierConfigManager configManager =
-                getSystemService(CarrierConfigManager.class);
+        final CarrierConfigManager configManager = (CarrierConfigManager)
+                getSystemService(Context.CARRIER_CONFIG_SERVICE);
         if (configManager != null) {
             final PersistableBundle b = configManager.getConfigForSubId(mSubId);
             if (b != null) {
diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java
index 3ba667c..02d9b3d 100755
--- a/src/com/android/settings/network/apn/ApnSettings.java
+++ b/src/com/android/settings/network/apn/ApnSettings.java
@@ -209,8 +209,8 @@
         mSubscriptionInfo = getSubscriptionInfo(mSubId);
         mTelephonyManager = activity.getSystemService(TelephonyManager.class);
 
-        final CarrierConfigManager configManager =
-                getSystemService(CarrierConfigManager.class);
+        final CarrierConfigManager configManager = (CarrierConfigManager)
+                getSystemService(Context.CARRIER_CONFIG_SERVICE);
         final PersistableBundle b = configManager.getConfigForSubId(mSubId);
         mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
         mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 7eb53b9..9a4cb40 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -202,7 +202,7 @@
 
         super.onCreate(icicle);
         final Context context = getContext();
-        mUserManager = context.getSystemService(UserManager.class);
+        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
         mTelephonyManager = context.getSystemService(TelephonyManager.class)
                 .createForSubscriptionId(mSubId);
 
diff --git a/src/com/android/settings/network/telephony/NetworkProviderWorker.java b/src/com/android/settings/network/telephony/NetworkProviderWorker.java
index 57f17b5..698e779 100644
--- a/src/com/android/settings/network/telephony/NetworkProviderWorker.java
+++ b/src/com/android/settings/network/telephony/NetworkProviderWorker.java
@@ -288,9 +288,9 @@
     }
 
     /**
-     * Returns true, if the ethernet network is connected.
+     * Returns the internet type.
      */
-    public boolean isEthernetConnected() {
-        return mInternetType == INTERNET_ETHERNET;
+    public @InternetUpdater.InternetType int getInternetType() {
+        return mInternetType;
     }
 }
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index 588d828..c8121c4 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -106,8 +106,8 @@
                 .createForSubscriptionId(mSubId);
         mNetworkScanHelper = new NetworkScanHelper(
                 mTelephonyManager, mCallback, mNetworkScanExecutor);
-        PersistableBundle bundle = (getContext().getSystemService(
-                CarrierConfigManager.class)).getConfigForSubId(mSubId);
+        PersistableBundle bundle = ((CarrierConfigManager) getContext().getSystemService(
+                Context.CARRIER_CONFIG_SERVICE)).getConfigForSubId(mSubId);
         if (bundle != null) {
             mShow4GForLTE = bundle.getBoolean(
                     CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index 6cb627b..c782b66 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -212,8 +212,8 @@
 
         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
-            final LayoutInflater inflater =
-                    mContext.getSystemService(LayoutInflater.class);
+            final LayoutInflater inflater = (LayoutInflater)
+                    mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
             if (convertView == null) {
                 convertView = inflater.inflate(mItemResId, null);
diff --git a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
index 8be6016..d4ad994 100644
--- a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
@@ -72,7 +72,7 @@
         return true;
     }
 
-    Preference getClearAll(PreferenceGroup parent) {
+    LayoutPreference getClearAll(PreferenceGroup parent) {
         LayoutPreference pref = new LayoutPreference(
                 mContext, R.layout.conversations_clear_recents);
         pref.setOrder(1);
@@ -80,10 +80,21 @@
         button.setOnClickListener(v -> {
             try {
                 mPs.removeAllRecentConversations();
+                // Removing recents is asynchronous, so we can't immediately reload the list from
+                // the backend. Instead, proactively remove all of items that were marked as
+                // clearable, so long as we didn't get an error
+
+                for (int i = parent.getPreferenceCount() - 1; i >= 0; i--) {
+                    Preference p = parent.getPreference(i);
+                    if (p instanceof RecentConversationPreference) {
+                        if (((RecentConversationPreference) p).hasClearListener()) {
+                            parent.removePreference(p);
+                        }
+                    }
+                }
             } catch (RemoteException e) {
                 Slog.w(TAG, "Could not clear recents", e);
             }
-            updateState(parent);
         });
         return pref;
     }
@@ -118,36 +129,45 @@
     protected void populateList(List<ConversationChannel> conversations,
             PreferenceGroup containerGroup) {
         containerGroup.removeAll();
+        boolean hasClearable = false;
         if (conversations != null) {
-            populateConversations(conversations, containerGroup);
+            hasClearable = populateConversations(conversations, containerGroup);
         }
 
         if (containerGroup.getPreferenceCount() == 0) {
             containerGroup.setVisible(false);
         } else {
             containerGroup.setVisible(true);
-            Preference clearAll = getClearAll(containerGroup);
-            if (clearAll != null) {
-                containerGroup.addPreference(clearAll);
+            if (hasClearable) {
+                Preference clearAll = getClearAll(containerGroup);
+                if (clearAll != null) {
+                    containerGroup.addPreference(clearAll);
+                }
             }
         }
     }
 
-    protected void populateConversations(List<ConversationChannel> conversations,
+    protected boolean populateConversations(List<ConversationChannel> conversations,
             PreferenceGroup containerGroup) {
         int order = 100;
+        boolean hasClearable = false;
         for (ConversationChannel conversation : conversations) {
             if (conversation.getParentNotificationChannel().getImportance() == IMPORTANCE_NONE
                     || (conversation.getParentNotificationChannelGroup() != null
                     && conversation.getParentNotificationChannelGroup().isBlocked())) {
                 continue;
             }
-            containerGroup.addPreference(
-                    createConversationPref(containerGroup, conversation, order++));
+            RecentConversationPreference pref =
+                    createConversationPref(containerGroup, conversation, order++);
+            containerGroup.addPreference(pref);
+            if (pref.hasClearListener()) {
+                hasClearable = true;
+            }
         }
+        return hasClearable;
     }
 
-    protected Preference createConversationPref(PreferenceGroup parent,
+    protected RecentConversationPreference createConversationPref(PreferenceGroup parent,
             final ConversationChannel conversation, int order) {
         final String pkg = conversation.getShortcutInfo().getPackage();
         final int uid = conversation.getUid();
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index c52b410..4b9883a 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -32,6 +32,7 @@
 import android.util.TypedValue;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
+import android.view.Surface;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ScrollView;
@@ -508,6 +509,12 @@
                 Bundle savedInstanceState) {
             final GlifLayout layout = (GlifLayout) inflater.inflate(
                     R.layout.choose_lock_pattern, container, false);
+            switch(getContext().getDisplay().getRotation()) {
+                case Surface.ROTATION_90:
+                case Surface.ROTATION_270:
+                    layout.setLandscapeHeaderAreaVisible(false /* visible */);
+                    break;
+            }
             layout.setHeaderText(getActivity().getTitle());
             if (getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
                 View iconView = layout.findViewById(R.id.sud_layout_icon);
diff --git a/src/com/android/settings/password/ConfirmLockPattern.java b/src/com/android/settings/password/ConfirmLockPattern.java
index 598e09a..0e18436 100644
--- a/src/com/android/settings/password/ConfirmLockPattern.java
+++ b/src/com/android/settings/password/ConfirmLockPattern.java
@@ -28,6 +28,7 @@
 import android.os.storage.StorageManager;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
+import android.view.Surface;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.AnimationUtils;
@@ -45,6 +46,8 @@
 import com.android.settingslib.animation.AppearAnimationUtils;
 import com.android.settingslib.animation.DisappearAnimationUtils;
 
+import com.google.android.setupdesign.GlifLayout;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -90,8 +93,7 @@
         private boolean mDisappearing = false;
         private CountDownTimer mCountdownTimer;
 
-        private TextView mHeaderTextView;
-        private TextView mDetailsTextView;
+        private GlifLayout mGlifLayout;
 
         // caller-supplied text for various prompts
         private CharSequence mHeaderText;
@@ -117,9 +119,14 @@
                             : R.layout.confirm_lock_pattern,
                     container,
                     false);
-            mHeaderTextView = (TextView) view.findViewById(R.id.headerText);
+            mGlifLayout = view.findViewById(R.id.setup_wizard_layout);
+            switch(getContext().getDisplay().getRotation()) {
+                case Surface.ROTATION_90:
+                case Surface.ROTATION_270:
+                    mGlifLayout.setLandscapeHeaderAreaVisible(false /* visible */);
+                    break;
+            }
             mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
-            mDetailsTextView = (TextView) view.findViewById(R.id.sud_layout_description);
             mErrorTextView = (TextView) view.findViewById(R.id.errorText);
 
             mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
@@ -177,7 +184,7 @@
                             return (float)(numRows - row) / numRows;
                         }
                     });
-            setAccessibilityTitle(mHeaderTextView.getText());
+            setAccessibilityTitle(mGlifLayout.getHeaderText());
 
             mCredentialCheckResultTracker = (CredentialCheckResultTracker) getFragmentManager()
                     .findFragmentByTag(FRAGMENT_TAG_CHECK_LOCK_RESULT);
@@ -242,13 +249,13 @@
         @Override
         public void prepareEnterAnimation() {
             super.prepareEnterAnimation();
-            mHeaderTextView.setAlpha(0f);
+            mGlifLayout.getHeaderTextView().setAlpha(0f);
             mCancelButton.setAlpha(0f);
             if (mForgotButton != null) {
                 mForgotButton.setAlpha(0f);
             }
             mLockPatternView.setAlpha(0f);
-            mDetailsTextView.setAlpha(0f);
+            mGlifLayout.getDescriptionTextView().setAlpha(0f);
         }
 
         private int getDefaultDetails() {
@@ -269,8 +276,9 @@
 
         private Object[][] getActiveViews() {
             ArrayList<ArrayList<Object>> result = new ArrayList<>();
-            result.add(new ArrayList<>(Collections.singletonList(mHeaderTextView)));
-            result.add(new ArrayList<>(Collections.singletonList(mDetailsTextView)));
+            result.add(new ArrayList<>(Collections.singletonList(mGlifLayout.getHeaderTextView())));
+            result.add(new ArrayList<>(
+                    Collections.singletonList(mGlifLayout.getDescriptionTextView())));
             if (mCancelButton.getVisibility() == View.VISIBLE) {
                 result.add(new ArrayList<>(Collections.singletonList(mCancelButton)));
             }
@@ -306,14 +314,14 @@
             switch (stage) {
                 case NeedToUnlock:
                     if (mHeaderText != null) {
-                        mHeaderTextView.setText(mHeaderText);
+                        mGlifLayout.setHeaderText(mHeaderText);
                     } else {
-                        mHeaderTextView.setText(getDefaultHeader());
+                        mGlifLayout.setHeaderText(getDefaultHeader());
                     }
                     if (mDetailsText != null) {
-                        mDetailsTextView.setText(mDetailsText);
+                        mGlifLayout.setDescriptionText(mDetailsText);
                     } else {
-                        mDetailsTextView.setText(getDefaultDetails());
+                        mGlifLayout.setDescriptionText(getDefaultDetails());
                     }
                     mErrorTextView.setText("");
                     updateErrorMessage(
@@ -341,7 +349,7 @@
 
             // Always announce the header for accessibility. This is a no-op
             // when accessibility is disabled.
-            mHeaderTextView.announceForAccessibility(mHeaderTextView.getText());
+            mGlifLayout.getHeaderTextView().announceForAccessibility(mGlifLayout.getHeaderText());
         }
 
         private int getDefaultHeader() {
diff --git a/src/com/android/settings/security/CredentialManagementAppAdapter.java b/src/com/android/settings/security/CredentialManagementAppAdapter.java
index e56fc63..6b37f7f 100644
--- a/src/com/android/settings/security/CredentialManagementAppAdapter.java
+++ b/src/com/android/settings/security/CredentialManagementAppAdapter.java
@@ -25,6 +25,7 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
+import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
@@ -61,6 +62,7 @@
 
     private final boolean mIncludeHeader;
     private final boolean mIncludeExpander;
+    private final boolean mIsLayoutRtl;
 
     /**
      * View holder for the header in the request manage credentials screen.
@@ -113,6 +115,15 @@
             mChildRecyclerView = view.findViewById(R.id.uris);
             mExpandedApps = new ArrayList<>();
 
+            if (mIsLayoutRtl) {
+                RelativeLayout appDetails = view.findViewById(R.id.app_details);
+                RelativeLayout.LayoutParams params =
+                        (RelativeLayout.LayoutParams) appDetails.getLayoutParams();
+                params.addRule(RelativeLayout.LEFT_OF, R.id.app_icon);
+                params.addRule(RelativeLayout.RIGHT_OF, R.id.expand);
+                view.setLayoutParams(params);
+            }
+
             mExpanderIconView.setOnClickListener(view1 -> {
                 final String appName = mSortedAppNames.get(getBindingAdapterPosition());
                 if (mExpandedApps.contains(appName)) {
@@ -195,6 +206,8 @@
         mViewPool = new RecyclerView.RecycledViewPool();
         mIncludeHeader = includeHeader;
         mIncludeExpander = includeExpander;
+        mIsLayoutRtl = context.getResources().getConfiguration().getLayoutDirection()
+                == View.LAYOUT_DIRECTION_RTL;
     }
 
     /**
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 3051b92..7dab4c0 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -104,8 +104,8 @@
             subId = SubscriptionManager.getDefaultSmsSubscriptionId();
         }
 
-        SubscriptionManager subscriptionManager = (context.getSystemService(
-                SubscriptionManager.class));
+        SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
+                Context.TELEPHONY_SUBSCRIPTION_SERVICE));
         if (!subscriptionManager.isActiveSubscriptionId(subId)) {
             Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
             return;
@@ -130,8 +130,8 @@
             return;
         }
 
-        TelephonyManager tm = (context.getSystemService(
-                TelephonyManager.class)).createForSubscriptionId(subId);
+        TelephonyManager tm = ((TelephonyManager) context.getSystemService(
+                Context.TELEPHONY_SERVICE)).createForSubscriptionId(subId);
 
         if (tm.isDataEnabledForApn(TYPE_MMS)) {
             Log.w(TAG, "onEnableMmsDataRequest MMS data already enabled on sub ID " + subId);
@@ -230,14 +230,14 @@
                 PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
         builder.setContentIntent(resultPendingIntent);
         NotificationManager notificationManager =
-                context.getSystemService(NotificationManager.class);
+                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
         notificationManager.createNotificationChannel(notificationChannel);
         notificationManager.notify(SIM_SELECT_NOTIFICATION_ID, builder.build());
     }
 
     public static void cancelSimSelectNotification(Context context) {
         NotificationManager notificationManager =
-                context.getSystemService(NotificationManager.class);
+                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
         notificationManager.cancel(SIM_SELECT_NOTIFICATION_ID);
     }
 
@@ -270,14 +270,14 @@
 
         // Notify the notification.
         NotificationManager notificationManager =
-                context.getSystemService(NotificationManager.class);
+                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
         notificationManager.createNotificationChannel(notificationChannel);
         notificationManager.notify(ENABLE_MMS_NOTIFICATION_ID, builder.build());
     }
 
     private void cancelEnableMmsNotification(Context context) {
         NotificationManager notificationManager =
-                context.getSystemService(NotificationManager.class);
+                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
         notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
     }
 
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 4543f3f..0543fee 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -319,7 +319,7 @@
     @VisibleForTesting
     static boolean appHasVpnPermission(Context context, @NonNull ApplicationInfo application) {
         final AppOpsManager service =
-                context.getSystemService(AppOpsManager.class);
+                (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
         final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
                 application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
         return !ArrayUtils.isEmpty(ops);
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 2620426..cdc6537 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -116,9 +116,9 @@
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
 
-        mUserManager = getSystemService(UserManager.class);
-        mConnectivityManager = getSystemService(ConnectivityManager.class);
-        mVpnManager = getSystemService(VpnManager.class);
+        mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
+        mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+        mVpnManager = (VpnManager) getSystemService(Context.VPN_MANAGEMENT_SERVICE);
 
         mUnavailable = isUiRestricted();
         setHasOptionsMenu(!mUnavailable);
@@ -511,7 +511,7 @@
         }
 
         // Fetch VPN-enabled apps from AppOps.
-        AppOpsManager aom = context.getSystemService(AppOpsManager.class);
+        AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
         List<AppOpsManager.PackageOps> apps =
                 aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
         if (apps != null) {
diff --git a/src/com/android/settings/wifi/ChangeWifiStateDetails.java b/src/com/android/settings/wifi/ChangeWifiStateDetails.java
index 4e3e62e..9841615 100644
--- a/src/com/android/settings/wifi/ChangeWifiStateDetails.java
+++ b/src/com/android/settings/wifi/ChangeWifiStateDetails.java
@@ -49,7 +49,7 @@
         super.onCreate(savedInstanceState);
         final Context context = getActivity();
         mAppBridge = new AppStateChangeWifiStateBridge(context, mState, null);
-        mAppOpsManager = context.getSystemService(AppOpsManager.class);
+        mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
 
         // find preferences
         addPreferencesFromResource(R.xml.change_wifi_state_details);
diff --git a/src/com/android/settings/wifi/ConfigureWifiSettings.java b/src/com/android/settings/wifi/ConfigureWifiSettings.java
index 484d3cc..ff313c7 100644
--- a/src/com/android/settings/wifi/ConfigureWifiSettings.java
+++ b/src/com/android/settings/wifi/ConfigureWifiSettings.java
@@ -69,7 +69,7 @@
 
     @Override
     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        final WifiManager wifiManager = getSystemService(WifiManager.class);
+        final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
         controllers.add(new WifiP2pPreferenceController(context, getSettingsLifecycle(),
                 wifiManager));
diff --git a/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java b/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
index 5fa4dfb..44114e5 100644
--- a/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
+++ b/src/com/android/settings/wifi/UseOpenWifiPreferenceController.java
@@ -51,7 +51,7 @@
         super(context, KEY_USE_OPEN_WIFI_AUTOMATICALLY);
         mContentResolver = context.getContentResolver();
         mNetworkScoreManager =
-                context.getSystemService(NetworkScoreManager.class);
+                (NetworkScoreManager) context.getSystemService(Context.NETWORK_SCORE_SERVICE);
         mSettingObserver = new SettingObserver();
         updateEnableUseWifiComponentName();
         checkForFeatureSupportedScorers();
diff --git a/src/com/android/settings/wifi/WifiAPITest.java b/src/com/android/settings/wifi/WifiAPITest.java
index 498539d..15465ed 100644
--- a/src/com/android/settings/wifi/WifiAPITest.java
+++ b/src/com/android/settings/wifi/WifiAPITest.java
@@ -64,7 +64,7 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mWifiManager = getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/WifiConfigInfo.java b/src/com/android/settings/wifi/WifiConfigInfo.java
index 18ac2e5..0de3063 100644
--- a/src/com/android/settings/wifi/WifiConfigInfo.java
+++ b/src/com/android/settings/wifi/WifiConfigInfo.java
@@ -38,7 +38,7 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mWifiManager = getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
         setContentView(R.layout.wifi_config_info);
         mConfigList = (TextView) findViewById(R.id.config_list);
     }
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index ba1ee3c..dc5be42 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -75,7 +75,7 @@
     public WifiEnabler(Context context, SwitchWidgetController switchWidget,
         MetricsFeatureProvider metricsFeatureProvider) {
         this(context, switchWidget, metricsFeatureProvider,
-            context.getSystemService(ConnectivityManager.class));
+            (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
     }
 
     @VisibleForTesting
@@ -86,7 +86,7 @@
         mSwitchWidget = switchWidget;
         mSwitchWidget.setListener(this);
         mMetricsFeatureProvider = metricsFeatureProvider;
-        mWifiManager = context.getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mConnectivityManager = connectivityManager;
 
         mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
diff --git a/src/com/android/settings/wifi/WifiNoInternetDialog.java b/src/com/android/settings/wifi/WifiNoInternetDialog.java
index 3cd8a8a..57e42f8 100644
--- a/src/com/android/settings/wifi/WifiNoInternetDialog.java
+++ b/src/com/android/settings/wifi/WifiNoInternetDialog.java
@@ -107,7 +107,7 @@
             }
         };
 
-        mCM = getSystemService(ConnectivityManager.class);
+        mCM = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
         mCM.registerNetworkCallback(request, mNetworkCallback);
 
         final NetworkInfo ni = mCM.getNetworkInfo(mNetwork);
diff --git a/src/com/android/settings/wifi/WifiStatusTest.java b/src/com/android/settings/wifi/WifiStatusTest.java
index 06242e3..249cd71 100644
--- a/src/com/android/settings/wifi/WifiStatusTest.java
+++ b/src/com/android/settings/wifi/WifiStatusTest.java
@@ -116,7 +116,7 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mWifiManager = getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
 
         mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
         mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index e576851..d05260a 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -83,7 +83,7 @@
         final DevicePolicyManager dpm =
                 (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
         final PackageManager pm = context.getPackageManager();
-        final UserManager um = context.getSystemService(UserManager.class);
+        final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
 
         // Check if device has DPM capability. If it has and dpm is still null, then we
         // treat this case with suspicion and bail out.
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index 3aa62b9..e9fd350 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -73,7 +73,7 @@
 
     public WifiWakeupPreferenceController(Context context) {
         super(context, KEY_ENABLE_WIFI_WAKEUP);
-        mLocationManager = context.getSystemService(LocationManager.class);
+        mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
         mWifiManager = context.getSystemService(WifiManager.class);
     }
 
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 3cfe514..de64b91 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -128,8 +128,8 @@
 
             boolean isWfcModeEditable = true;
             boolean isWfcRoamingModeEditable = false;
-            final CarrierConfigManager configManager =
-                    activity.getSystemService(CarrierConfigManager.class);
+            final CarrierConfigManager configManager = (CarrierConfigManager)
+                    activity.getSystemService(Context.CARRIER_CONFIG_SERVICE);
             if (configManager != null) {
                 PersistableBundle b =
                         configManager.getConfigForSubId(WifiCallingSettingsForSub.this.mSubId);
@@ -343,8 +343,8 @@
             return;
         }
 
-        final CarrierConfigManager configManager =
-                getSystemService(CarrierConfigManager.class);
+        final CarrierConfigManager configManager = (CarrierConfigManager)
+                getSystemService(Context.CARRIER_CONFIG_SERVICE);
         boolean isWifiOnlySupported = true;
 
         if (configManager != null) {
diff --git a/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java b/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java
index 9ab64c7..8f9741a 100644
--- a/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/AddDevicePreferenceController2.java
@@ -42,7 +42,7 @@
     public AddDevicePreferenceController2(Context context) {
         super(context, KEY_ADD_DEVICE);
 
-        mWifiManager = context.getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
     }
 
     public void setWifiEntry(WifiEntry wifiEntry) {
diff --git a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
index 488ffcb..104761f 100644
--- a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
+++ b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
@@ -143,8 +143,8 @@
                     if (admin == null) {
                         final DevicePolicyManager dpm = (DevicePolicyManager)
                                 getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
-                        final UserManager um =
-                                getContext().getSystemService(UserManager.class);
+                        final UserManager um = (UserManager)
+                                getContext().getSystemService(Context.USER_SERVICE);
                         final int profileOwnerUserId = Utils.getManagedProfileId(
                                 um, UserHandle.myUserId());
                         if (profileOwnerUserId != UserHandle.USER_NULL) {
diff --git a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
index 72a2361..c484922 100644
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
@@ -45,7 +45,7 @@
     public WifiPrivacyPreferenceController2(Context context) {
         super(context, KEY_WIFI_PRIVACY);
 
-        mWifiManager = context.getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
     }
 
     public void setWifiEntry(WifiEntry wifiEntry) {
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 081e160..abf5bec 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -373,8 +373,8 @@
      *                        device security or if lock screen is unlocked
      */
     public static void showLockScreen(Context context, Runnable successRunnable) {
-        final KeyguardManager keyguardManager = context.getSystemService(
-                KeyguardManager.class);
+        final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(
+                Context.KEYGUARD_SERVICE);
 
         if (keyguardManager.isKeyguardSecure()) {
             final BiometricPrompt.AuthenticationCallback authenticationCallback =
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java b/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
index 8696bef..9604410 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
@@ -71,7 +71,7 @@
         super(context);
         mWifiManager = wifiManager;
         lifecycle.addObserver(this);
-        mLocationManager = context.getSystemService(LocationManager.class);
+        mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
index 0aac0bb..9578c80 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
@@ -200,7 +200,7 @@
     public void onActivityCreated(Bundle savedInstanceState) {
         final Activity activity = getActivity();
         if (mWifiP2pManager == null) {
-            mWifiP2pManager = getSystemService(WifiP2pManager.class);
+            mWifiP2pManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
         }
 
         if (mWifiP2pManager != null) {
diff --git a/src/com/android/settings/wifi/qrcode/QrCamera.java b/src/com/android/settings/wifi/qrcode/QrCamera.java
index 274655d..3865eb1 100644
--- a/src/com/android/settings/wifi/qrcode/QrCamera.java
+++ b/src/com/android/settings/wifi/qrcode/QrCamera.java
@@ -202,7 +202,7 @@
         }
 
         final WindowManager winManager =
-                mContext.get().getSystemService(WindowManager.class);
+                (WindowManager) mContext.get().getSystemService(Context.WINDOW_SERVICE);
         final int rotation = winManager.getDefaultDisplay().getRotation();
         int degrees = 0;
         switch (rotation) {
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 898de56..e4a571d 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -164,7 +164,7 @@
         return rowBuilder;
     }
 
-    private IconCompat getWifiSliceItemLevelIcon(WifiSliceItem wifiSliceItem) {
+    protected IconCompat getWifiSliceItemLevelIcon(WifiSliceItem wifiSliceItem) {
         final @ColorInt int tint;
         if (wifiSliceItem.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED) {
             tint = Utils.getColorAccentDefaultColor(mContext);
diff --git a/src/com/android/settings/wifi/tether/TetherService.java b/src/com/android/settings/wifi/tether/TetherService.java
index a3321bb..5902719 100644
--- a/src/com/android/settings/wifi/tether/TetherService.java
+++ b/src/com/android/settings/wifi/tether/TetherService.java
@@ -255,7 +255,7 @@
     }
 
     private void disableTethering(final int tetheringType) {
-        final TetheringManager tm = getSystemService(TetheringManager.class);
+        final TetheringManager tm = (TetheringManager) getSystemService(Context.TETHERING_SERVICE);
         tm.stopTethering(tetheringType);
     }
 
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
index 1fa41b2..70b6a45 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPreferenceController.java
@@ -63,7 +63,7 @@
             boolean initSoftApManager) {
         super(context);
         mTetheringManager = context.getSystemService(TetheringManager.class);
-        mWifiManager = context.getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mWifiRegexs = mTetheringManager.getTetherableWifiRegexs();
         mLifecycle = lifecycle;
         if (lifecycle != null) {
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index 41b439b..e342550 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -110,7 +110,7 @@
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
-        mWifiManager = context.getSystemService(WifiManager.class);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mTetherChangeReceiver = new TetherChangeReceiver();
 
         mSSIDPreferenceController = use(WifiTetherSSIDPreferenceController.class);
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java
index 379bf6d..3d8cd3e 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java
@@ -73,8 +73,8 @@
         mSwitch = mSwitchBar.getSwitch();
         mDataSaverBackend = new DataSaverBackend(context);
         mConnectivityManager =
-                context.getSystemService(ConnectivityManager.class);
-        mWifiManager = context.getSystemService(WifiManager.class);
+                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mSwitchBar.setChecked(mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED);
         updateWifiSwitch();
     }
diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
index d21aa04..784b3bb 100644
--- a/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java
@@ -92,4 +92,23 @@
                 .containsExactly("US", "GB");
         assertThat(timeZoneData.lookupCountryCodesForZoneId("Unknown/Secret_City2")).isEmpty();
     }
+
+    @Test
+    public void lookupCountryCodesForNonCanonicalZoneId_returnsCurrentZone() {
+        TimeZoneData timeZoneData = new TimeZoneData(mCountryZonesFinder);
+
+        CountryTimeZones greenland = mock(CountryTimeZones.class);
+        when(greenland.getCountryIso()).thenReturn("gl");
+        when(greenland.getTimeZoneMappings()).thenReturn(Arrays.asList(
+                TimeZoneMapping.createForTests(
+                        "America/Nuuk",
+                        true /* showInPicker */,
+                        null /* notUsedAfter */,
+                        Arrays.asList("America/Godthab"))));
+        when(mCountryZonesFinder.lookupCountryTimeZonesForZoneId("America/Godthab"))
+                .thenReturn(Arrays.asList(greenland));
+
+        assertThat(timeZoneData.lookupCountryCodesForZoneId("America/Godthab"))
+                .containsExactly("GL");
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
index 60eab12..997c35e 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
@@ -181,8 +181,8 @@
 
         mController.copy();
 
-        final ClipboardManager clipboard = mContext.getSystemService(
-                ClipboardManager.class);
+        final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
+                CLIPBOARD_SERVICE);
         final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
         assertThat(data.toString()).isEqualTo(meid);
     }
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
index d1371a2..384ddc3 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
@@ -22,12 +22,14 @@
 import static org.mockito.ArgumentMatchers.eq;
 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;
 
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.res.Resources;
 import android.os.SystemProperties;
 import android.provider.Settings;
 
@@ -38,6 +40,7 @@
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.os.RoSystemProperties;
+import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.deletionhelper.ActivationWarningFragment;
 import com.android.settings.overlay.FeatureFactory;
@@ -67,13 +70,16 @@
     private FragmentManager mFragmentManager;
 
     private Context mContext;
+    private Resources mResources;
     private AutomaticStorageManagementSwitchPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application.getApplicationContext();
+        mContext = spy(RuntimeEnvironment.application.getApplicationContext());
         FeatureFactory.getFactory(mContext);
+        mResources = spy(mContext.getResources());
+        when(mContext.getResources()).thenReturn(mResources);
 
         mController = new AutomaticStorageManagementSwitchPreferenceController(mContext, "testkey");
         mController.setFragmentManager(mFragmentManager);
@@ -81,14 +87,27 @@
     }
 
     @Test
-    public void isAvailable_shouldReturnTrue_forHighRamDevice() {
+    public void getAvailabilityStatus_configFalse_shouldUnsupportedOnDevice() {
+        when(mResources.getBoolean(R.bool.config_show_smart_storage_toggle)).thenReturn(false);
+
+        assertThat(mController.isAvailable()).isFalse();
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(
+                BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_forHighRamDevice_shouldAvailable() {
+        when(mResources.getBoolean(R.bool.config_show_smart_storage_toggle)).thenReturn(true);
+
         assertThat(mController.isAvailable()).isTrue();
         assertThat(mController.getAvailabilityStatus()).isEqualTo(
                 BasePreferenceController.AVAILABLE);
     }
 
     @Test
-    public void isAvailable_shouldAlwaysReturnFalse_forLowRamDevice() {
+    public void getAvailabilityStatus_forLowRamDevice_shouldUnsupportedOnDevice() {
+        when(mResources.getBoolean(R.bool.config_show_smart_storage_toggle)).thenReturn(true);
+
         ReflectionHelpers.setStaticField(RoSystemProperties.class, "CONFIG_LOW_RAM", true);
         assertThat(mController.isAvailable()).isFalse();
         assertThat(mController.getAvailabilityStatus()).isEqualTo(
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 6f9c451..b7bf7f5 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -104,6 +104,8 @@
     }
 
     private PreferenceScreen getPreferenceScreen() {
+        final StorageItemPreference publicStorage = spy(new StorageItemPreference(mContext));
+        publicStorage.setIcon(R.drawable.ic_folder_vd_theme_24);
         final StorageItemPreference images = spy(new StorageItemPreference(mContext));
         images.setIcon(R.drawable.ic_photo_library);
         final StorageItemPreference videos = spy(new StorageItemPreference(mContext));
@@ -122,6 +124,8 @@
         trash.setIcon(R.drawable.ic_trash_can);
 
         final PreferenceScreen screen = mock(PreferenceScreen.class);
+        when(screen.findPreference(eq(StorageItemPreferenceController.PUBLIC_STORAGE_KEY)))
+                .thenReturn(publicStorage);
         when(screen.findPreference(eq(StorageItemPreferenceController.IMAGES_KEY)))
                 .thenReturn(images);
         when(screen.findPreference(eq(StorageItemPreferenceController.VIDEOS_KEY)))
@@ -149,6 +153,24 @@
     }
 
     @Test
+    public void launchPublicStorageIntent_nonNullBrowseIntent_settingsIntent() {
+        final String fakeBrowseAction = "FAKE_BROWSE_ACTION";
+        final Intent fakeBrowseIntent = new Intent(fakeBrowseAction);
+        // mContext is not the activity, add FLAG_ACTIVITY_NEW_TASK to avoid AndroidRuntimeException
+        // during this test.
+        fakeBrowseIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        when(mVolume.buildBrowseIntent()).thenReturn(fakeBrowseIntent);
+        mPreference.setKey(StorageItemPreferenceController.PUBLIC_STORAGE_KEY);
+        mController.handlePreferenceTreeClick(mPreference);
+
+        final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
+        verify(mContext).startActivity(argumentCaptor.capture());
+
+        final Intent intent = argumentCaptor.getValue();
+        assertThat(intent.getAction()).isEqualTo(fakeBrowseAction);
+    }
+
+    @Test
     public void launchImagesIntent_resolveActionViewNull_settingsIntent() {
         mPreference.setKey(StorageItemPreferenceController.IMAGES_KEY);
         mController.handlePreferenceTreeClick(mPreference);
@@ -191,6 +213,7 @@
 
         mController.setVolume(null);
 
+        assertThat(mController.mPublicStoragePreference.isVisible()).isFalse();
         assertThat(mController.mImagesPreference.isVisible()).isFalse();
         assertThat(mController.mVideosPreference.isVisible()).isFalse();
         assertThat(mController.mAudiosPreference.isVisible()).isFalse();
@@ -347,6 +370,7 @@
 
         mController.setUserId(new UserHandle(10));
 
+        verify(mController.mPublicStoragePreference, times(2)).setIcon(nullable(Drawable.class));
         verify(mController.mImagesPreference, times(2)).setIcon(nullable(Drawable.class));
         verify(mController.mVideosPreference, times(2)).setIcon(nullable(Drawable.class));
         verify(mController.mAudiosPreference, times(2)).setIcon(nullable(Drawable.class));
@@ -418,4 +442,26 @@
 
         assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isTrue();
     }
+
+    @Test
+    public void setVolume_publicStorage_showFilePreference() {
+        // This will hide it initially.
+        mController.displayPreference(mPreferenceScreen);
+        when(mVolume.getType()).thenReturn(VolumeInfo.TYPE_PUBLIC);
+        when(mVolume.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
+        when(mVolume.isMountedReadable()).thenReturn(true);
+
+        // And we bring it back.
+        mController.setVolume(mVolume);
+
+        assertThat(mController.mPublicStoragePreference.isVisible()).isTrue();
+        assertThat(mController.mImagesPreference.isVisible()).isFalse();
+        assertThat(mController.mVideosPreference.isVisible()).isFalse();
+        assertThat(mController.mAudiosPreference.isVisible()).isFalse();
+        assertThat(mController.mAppsPreference.isVisible()).isFalse();
+        assertThat(mController.mGamesPreference.isVisible()).isFalse();
+        assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
+        assertThat(mController.mSystemPreference.isVisible()).isFalse();
+        assertThat(mController.mTrashPreference.isVisible()).isFalse();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
index a1f3bda..b132a97 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
@@ -21,9 +21,10 @@
 import static org.mockito.Mockito.doReturn;
 
 import android.content.ContentResolver;
-import android.content.Context;
 import android.provider.Settings;
 
+import androidx.preference.SwitchPreference;
+
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settingslib.widget.MainSwitchPreference;
@@ -42,50 +43,48 @@
     private static final int OFF = 0;
 
     private SmartBatteryPreferenceController mController;
+    private SwitchPreference mPreference;
     private ContentResolver mContentResolver;
     private FakeFeatureFactory mFeatureFactory;
-    private Context mContext;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = RuntimeEnvironment.application;
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         mController = new SmartBatteryPreferenceController(RuntimeEnvironment.application);
+        mPreference = new SwitchPreference(RuntimeEnvironment.application);
     }
 
     @Test
     public void testUpdateState_smartBatteryOn_preferenceChecked() {
         putSmartBatteryValue(ON);
-        final MainSwitchPreference preference = new MainSwitchPreference(mContext);
 
-        mController.updateState(preference);
+        mController.updateState(mPreference);
 
-        assertThat(preference.isChecked()).isTrue();
+        assertThat(mPreference.isChecked()).isTrue();
     }
 
     @Test
     public void testUpdateState_smartBatteryOff_preferenceUnchecked() {
         putSmartBatteryValue(OFF);
-        final MainSwitchPreference preference = new MainSwitchPreference(mContext);
 
-        mController.updateState(preference);
+        mController.updateState(mPreference);
 
-        assertThat(preference.isChecked()).isFalse();
+        assertThat(mPreference.isChecked()).isFalse();
     }
 
     @Test
     public void testUpdateState_checkPreference_smartBatteryOn() {
-        mController.onSwitchChanged(null, true);
+        mController.onPreferenceChange(mPreference, true);
 
         assertThat(getSmartBatteryValue()).isEqualTo(ON);
     }
 
     @Test
     public void testUpdateState_unCheckPreference_smartBatteryOff() {
-        mController.onSwitchChanged(null, false);
+        mController.onPreferenceChange(mPreference, false);
 
         assertThat(getSmartBatteryValue()).isEqualTo(OFF);
     }
diff --git a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
index 53dd959..d3a3129 100644
--- a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
@@ -57,7 +57,7 @@
 
         mContext = spy(ApplicationProvider.getApplicationContext());
         mSwitchPreference = spy(SwitchPreference.class);
-        when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
+        when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
         when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
         mController = new BluetoothTetherPreferenceController(mContext, "BLUETOOTH");
         mController.setTetherEnabler(mTetherEnabler);
diff --git a/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
index de642f6..8a81908 100644
--- a/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/EthernetTetherPreferenceControllerTest.java
@@ -62,9 +62,9 @@
     public void setUp() {
         mContext = spy(ApplicationProvider.getApplicationContext());
         mPreference = spy(SwitchPreference.class);
-        when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
+        when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
         when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[]{ETHERNET_REGEX});
-        when(mContext.getSystemService(EthernetManager.class)).thenReturn(mEthernetManager);
+        when(mContext.getSystemService(Context.ETHERNET_SERVICE)).thenReturn(mEthernetManager);
         mController = new EthernetTetherPreferenceController(mContext, "ethernet");
         mController.setTetherEnabler(mTetherEnabler);
         ReflectionHelpers.setField(mController, "mEthernetRegex", ETHERNET_REGEX);
diff --git a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
index d7c0ffe..c1377ff 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
@@ -44,6 +44,7 @@
 import android.os.PowerManager;
 import android.os.UserManager;
 import android.provider.Settings;
+import android.util.FeatureFlagUtils;
 import android.view.ContextMenu;
 import android.view.MenuItem;
 import android.view.View;
@@ -131,6 +132,7 @@
         mNetworkProviderSettings.mResetInternetPreference = mResetInternetPreference;
         mNetworkProviderSettings.mAirplaneModeMsgPreference = mAirplaneModeMsgPreference;
         mNetworkProviderSettings.mAirplaneModeEnabler = mAirplaneModeEnabler;
+        FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java b/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
index 293b649..8996c1d 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkResetRestrictionCheckerTest.java
@@ -45,14 +45,14 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
+        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
         mRestrictionChecker = spy(new NetworkResetRestrictionChecker(mContext));
     }
 
     @Test
     public void testHasRestriction_notAdmin_shouldReturnTrue() {
         final Context context = mock(Context.class);
-        when(context.getSystemService(UserManager.class)).thenReturn(mUserManager);
+        when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
         when(mUserManager.isAdminUser()).thenReturn(false);
 
         assertThat(mRestrictionChecker.hasRestriction()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
index fce9517..390a674 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
@@ -125,7 +125,7 @@
         mContext = spy(RuntimeEnvironment.application);
         mContentResolver = mContext.getContentResolver();
         mShadowContentResolver = Shadow.extract(mContentResolver);
-        when(mContext.getSystemService(ConnectivityManager.class))
+        when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
                 .thenReturn(mConnectivityManager);
         doNothing().when(mConnectivityManager).registerDefaultNetworkCallback(
                 mCallbackCaptor.capture(), nullable(Handler.class));
diff --git a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
index cd93865..bb4b0c4 100644
--- a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
@@ -95,10 +95,10 @@
         AtomicReference<BluetoothPan> panReference = spy(AtomicReference.class);
         mSwitchBar = spy(new SwitchBar(context));
         mSwitchWidgetController = spy(new SwitchBarController(mSwitchBar));
-        when(context.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
-        when(context.getSystemService(ConnectivityManager.class)).thenReturn(
+        when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+        when(context.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
                 mConnectivityManager);
-        when(context.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
+        when(context.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
         when(context.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(
                 mNetworkPolicyManager);
         when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
@@ -311,4 +311,4 @@
         assertThat(TetherEnabler.isTethering(TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isTrue();
         assertThat(TetherEnabler.isTethering(~TETHERING_ETHERNET_ON, TETHERING_ETHERNET)).isFalse();
     }
-}
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
index 0639ef3..e02da90 100644
--- a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
@@ -55,7 +55,7 @@
         MockitoAnnotations.initMocks(this);
 
         mContext = spy(ApplicationProvider.getApplicationContext());
-        when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
+        when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
         when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
         mController = new UsbTetherPreferenceController(mContext, "USB");
         mController.setTetherEnabler(mTetherEnabler);
diff --git a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
index 22ed55c..a82a71f 100644
--- a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
@@ -100,7 +100,7 @@
 
         mContext = spy(ApplicationProvider.getApplicationContext());
         mPreference = spy(SwitchPreference.class);
-        when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
+        when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
         when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
         mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
         mController.setTetherEnabler(mTetherEnabler);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
index acc6b1a..ba37c30 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
@@ -74,7 +74,7 @@
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
 
-        doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
+        doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
         doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
         doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(anyInt());
diff --git a/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java b/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
index 0d86408..6bee38f 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
@@ -77,7 +77,7 @@
         MockitoAnnotations.initMocks(this);
 
         mContext = spy(RuntimeEnvironment.application);
-        when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
+        when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
         when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
         when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);
 
diff --git a/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
index 660b4e1..15bc598 100644
--- a/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
@@ -47,8 +47,10 @@
 import androidx.preference.PreferenceScreen;
 import androidx.preference.PreferenceViewHolder;
 
+import com.android.settings.R;
 import com.android.settings.applications.AppInfoBase;
 import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.widget.LayoutPreference;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -105,9 +107,9 @@
         ps.addPreference(outerContainer);
 
         ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6,
-        new NotificationChannel("hi", "hi", 4),
-        new NotificationChannelGroup("hi", "hi"), 7,
-        true);
+                new NotificationChannel("hi", "hi", 4),
+                new NotificationChannelGroup("hi", "hi"), 7,
+                false);
 
         ArrayList<ConversationChannel> list = new ArrayList<>();
         list.add(ccw);
@@ -124,19 +126,19 @@
         ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6,
                 new NotificationChannel("hi", "hi", 4),
                 new NotificationChannelGroup("hi", "hi"), 7,
-                true);
+                false);
 
         ConversationChannel ccw2 = new ConversationChannel(mock(ShortcutInfo.class), 6,
                 new NotificationChannel("hi", "hi", 0),
                 new NotificationChannelGroup("hi", "hi"), 7,
-                true);
+                false);
 
         NotificationChannelGroup blockedGroup = new NotificationChannelGroup("hi", "hi");
         blockedGroup.setBlocked(true);
         ConversationChannel ccw3 = new ConversationChannel(mock(ShortcutInfo.class), 6,
                 new NotificationChannel("hi", "hi", 4),
                 blockedGroup, 7,
-                true);
+                false);
 
         ArrayList<ConversationChannel> list = new ArrayList<>();
         list.add(ccw);
@@ -198,7 +200,6 @@
                 new NotificationChannelGroup("hi", "group"), 7,
                 true);
 
-
         Intent intent = mController.getSubSettingLauncher(ccw, "title").toIntent();
 
         Bundle extras = intent.getExtras();
@@ -258,6 +259,51 @@
     }
 
     @Test
+    public void testRemoveConversations() throws Exception {
+        ShortcutInfo si = mock(ShortcutInfo.class);
+        when(si.getId()).thenReturn("person");
+        when(si.getPackage()).thenReturn("pkg");
+        ConversationChannel ccw = new ConversationChannel(si, 6,
+                new NotificationChannel("hi", "hi", 4),
+                new NotificationChannelGroup("hi", "group"), 7,
+                false);
+
+        ConversationChannel ccw2 = new ConversationChannel(si, 6,
+                new NotificationChannel("bye", "bye", 4),
+                new NotificationChannelGroup("hi", "group"), 7,
+                true);
+
+        PreferenceCategory group = new PreferenceCategory(mContext);
+        PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
+        screen.addPreference(group);
+
+        RecentConversationPreference pref = mController.createConversationPref(
+                        new PreferenceCategory(mContext), ccw, 100);
+        final View view = View.inflate(mContext, pref.getLayoutResource(), null);
+        PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
+        View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
+        when(holder.findViewById(pref.getClearId())).thenReturn(delete);
+        group.addPreference(pref);
+
+        RecentConversationPreference pref2 = mController.createConversationPref(
+                        new PreferenceCategory(mContext), ccw2, 100);
+        final View view2 = View.inflate(mContext, pref2.getLayoutResource(), null);
+        PreferenceViewHolder holder2 = spy(PreferenceViewHolder.createInstanceForTests(view2));
+        View delete2 = View.inflate(mContext, pref2.getSecondTargetResId(), null);
+        when(holder2.findViewById(pref.getClearId())).thenReturn(delete2);
+        group.addPreference(pref2);
+
+        LayoutPreference clearAll = mController.getClearAll(group);
+        group.addPreference(clearAll);
+
+        clearAll.findViewById(R.id.conversation_settings_clear_recents).performClick();
+
+        verify(mPs).removeAllRecentConversations();
+        assertThat((Preference) group.findPreference("hi:person")).isNull();
+        assertThat((Preference) group.findPreference("bye:person")).isNotNull();
+    }
+
+    @Test
     public void testNonremoveableConversation() throws Exception {
         ShortcutInfo si = mock(ShortcutInfo.class);
         when(si.getId()).thenReturn("person");
@@ -272,4 +318,24 @@
                         new PreferenceCategory(mContext), ccw, 100);
         assertThat(pref.hasClearListener()).isFalse();
     }
+
+    @Test
+    public void testPopulateList_onlyNonremoveableConversations() {
+        final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+        PreferenceScreen ps = preferenceManager.createPreferenceScreen(mContext);
+        PreferenceCategory outerContainer = spy(new PreferenceCategory(mContext));
+        ps.addPreference(outerContainer);
+
+        ConversationChannel ccw = new ConversationChannel(mock(ShortcutInfo.class), 6,
+                new NotificationChannel("hi", "hi", 4),
+                new NotificationChannelGroup("hi", "hi"), 7,
+                true /* hasactivenotifs */);
+
+        ArrayList<ConversationChannel> list = new ArrayList<>();
+        list.add(ccw);
+
+        mController.populateList(list, outerContainer);
+        // one for the preference, none for 'clear all'
+        verify(outerContainer, times(1)).addPreference(any());
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
index be3267e..094e282 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
@@ -78,7 +78,7 @@
         mActivity = spy(activity);
 
         mWifiManager = mock(WifiManager.class);
-        when(mActivity.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
+        when(mActivity.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
index 2475d80..65cc811 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
@@ -53,7 +53,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
+        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
         mEnabler = new WifiEnabler(mContext, mock(SwitchWidgetController.class),
                 mock(MetricsFeatureProvider.class), mConnectivityManager);
     }
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java b/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java
index dc5ccb4..6cbb19d 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiNoInternetDialogTest.java
@@ -44,6 +44,7 @@
 import com.android.settings.R;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -87,6 +88,7 @@
                 Robolectric.setupActivity(WifiNoInternetDialog.class);
     }
 
+    @Ignore
     @Test
     public void setupPromptUnvalidated_shouldShowNoInternetAccessRemember() {
         setupActivityWithAction(ACTION_PROMPT_UNVALIDATED, FAKE_URL);
@@ -98,6 +100,7 @@
                 mActivity.getString(R.string.no_internet_access_remember));
     }
 
+    @Ignore
     @Test
     public void setupPromptPartialConnectivity_shouldShowNoInternetAccessRemember() {
         setupActivityWithAction(ACTION_PROMPT_PARTIAL_CONNECTIVITY, FAKE_URL);
@@ -109,6 +112,7 @@
                 mActivity.getString(R.string.no_internet_access_remember));
     }
 
+    @Ignore
     @Test
     public void setupPromptLostValidationAction_shouldShowLostInternetAccessPersist() {
         setupActivityWithAction(ACTION_PROMPT_LOST_VALIDATION, FAKE_URL);
@@ -120,6 +124,7 @@
                 mActivity.getString(R.string.lost_internet_access_persist));
     }
 
+    @Ignore
     @Test
     public void clickPositiveButton_whenPromptUnvalidated_shouldCallSetAcceptUnvalidated() {
         setupActivityWithAction(ACTION_PROMPT_UNVALIDATED, FAKE_URL);
@@ -131,6 +136,7 @@
         verify(mConnectivityManager).setAcceptUnvalidated(any(Network.class), eq(true), eq(false));
     }
 
+    @Ignore
     @Test
     public void positiveButton_withPartialConnectivity_shouldCallSetAcceptPartialConnectivity() {
         setupActivityWithAction(ACTION_PROMPT_PARTIAL_CONNECTIVITY, FAKE_URL);
@@ -143,6 +149,7 @@
                 eq(false));
     }
 
+    @Ignore
     @Test
     public void positiveButton_withLostValidation_shouldCallSetAvoidUnvalidated() {
         setupActivityWithAction(ACTION_PROMPT_LOST_VALIDATION, FAKE_URL);
@@ -154,6 +161,7 @@
         verify(mConnectivityManager).setAvoidUnvalidated(any(Network.class));
     }
 
+    @Ignore
     @Test
     public void destroyWithNoClick_inPartialConnectivity_shouldCallSetAcceptPartialConnectivity() {
         setupActivityWithAction(ACTION_PROMPT_PARTIAL_CONNECTIVITY, FAKE_URL);
@@ -167,6 +175,7 @@
                 eq(false));
     }
 
+    @Ignore
     @Test
     public void destroyWithNoClick_whenUnvalidated_shouldCallSetAcceptUnvalidated() {
         setupActivityWithAction(ACTION_PROMPT_UNVALIDATED, FAKE_URL);
@@ -179,6 +188,7 @@
         verify(mConnectivityManager).setAcceptUnvalidated(any(Network.class), eq(false), eq(false));
     }
 
+    @Ignore
     @Test
     public void networkCallbackOnLost_shouldFinish() {
         setupActivityWithAction(ACTION_PROMPT_UNVALIDATED, FAKE_URL);
@@ -192,6 +202,7 @@
         verify(mActivity).finish();
     }
 
+    @Ignore
     @Test
     public void networkCallbackOnCapabilitiesChanged_shouldFinish() {
         setupActivityWithAction(ACTION_PROMPT_UNVALIDATED, FAKE_URL);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
index 4100d05..b94df29 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiPrimarySwitchPreferenceControllerTest.java
@@ -78,7 +78,7 @@
         when(mContext.getSystemService(NetworkScoreManager.class)).thenReturn(mNetworkScoreManager);
         mController = new WifiPrimarySwitchPreferenceController(mContext, mMetricsFeatureProvider);
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
-        when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
+        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
         when(mWifiManager.getWifiState()).thenReturn(WifiManager.WIFI_STATE_DISABLED);
     }
 
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index 428a360..1f5abd3 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -43,6 +43,7 @@
 import android.os.PowerManager;
 import android.os.UserManager;
 import android.provider.Settings;
+import android.util.FeatureFlagUtils;
 import android.view.ContextMenu;
 import android.view.View;
 
@@ -105,6 +106,7 @@
         mWifiSettings.mConfigureWifiSettingsPreference = new Preference(mContext);
         mWifiSettings.mWifiPickerTracker = mMockWifiPickerTracker;
         mWifiSettings.mWifiManager = mWifiManager;
+        FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
     }
 
     @Test
@@ -209,7 +211,7 @@
         final Resources.Theme theme = mContext.getTheme();
         when(activity.getTheme()).thenReturn(theme);
         UserManager userManager = mock(UserManager.class);
-        when(activity.getSystemService(UserManager.class))
+        when(activity.getSystemService(Context.USER_SERVICE))
                 .thenReturn(userManager);
 
         when(mWifiSettings.findPreference(WifiSettings.PREF_KEY_DATA_USAGE))
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java b/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java
index 3e15348..8478a54 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/DisclaimerItemListAdapterTest.java
@@ -77,7 +77,7 @@
 
         when(mLayoutInflater.inflate(anyInt(), anyObject(), anyBoolean())).thenReturn(mView);
         when(mViewGroup.getContext()).thenReturn(mContext);
-        when(mViewGroup.getContext().getSystemService(LayoutInflater.class)).thenReturn(
+        when(mViewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).thenReturn(
                 mLayoutInflater);
         when(mView.findViewById(ID_DISCLAIMER_ITEM_TITLE)).thenReturn(mTestView);
         when(mView.findViewById(ID_DISCLAIMER_ITEM_DESCRIPTION)).thenReturn(mDescView);
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java b/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java
index c15e850..985edda 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/EmergencyCallLimitationDisclaimerTest.java
@@ -54,7 +54,7 @@
         mContext = spy(RuntimeEnvironment.application);
 
         doReturn(mCarrierConfigManager).when(mContext).getSystemService(
-                CarrierConfigManager.class);
+                Context.CARRIER_CONFIG_SERVICE);
         when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
 
         doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java b/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java
index 108acf8..3fe9678 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/LocationPolicyDisclaimerTest.java
@@ -54,7 +54,7 @@
         mContext = spy(RuntimeEnvironment.application);
 
         doReturn(mCarrierConfigManager).when(mContext).getSystemService(
-                CarrierConfigManager.class);
+                Context.CARRIER_CONFIG_SERVICE);
         when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(mBundle);
         doReturn(getSharedPreferences()).when(mContext).getSharedPreferences(anyString(), anyInt());
     }
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
index 252d876..d777a59 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
@@ -73,8 +73,8 @@
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
         mPreference = new ListPreference(RuntimeEnvironment.application);
-        when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
-        when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
+        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+        when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
         when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
         when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
         when(mScreen.findPreference(anyString())).thenReturn(mPreference);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java
index a423071..c1d6c16 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java
@@ -17,6 +17,7 @@
 package com.android.settings.wifi.tether;
 
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -57,7 +58,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+        doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
+        doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
         when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
         when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
         mController = new WifiTetherFooterPreferenceController(mContext);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
index 8f8477f..bb61eb9 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
@@ -19,6 +19,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
@@ -75,9 +76,9 @@
                 .setPassphrase(INITIAL_PASSWORD, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)
                 .build();
 
-        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
+        doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
         when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
-        when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+        doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
         when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
         when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
         when(mScreen.findPreference(anyString())).thenReturn(mPreference);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
index 147cd64..2d88722 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
@@ -19,6 +19,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
@@ -67,8 +68,8 @@
         MockitoAnnotations.initMocks(this);
         mPreference = new WifiTetherSsidPreference(RuntimeEnvironment.application);
 
-        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
-        when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
+        doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
+        doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
         when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
         when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
         when(mScreen.findPreference(anyString())).thenReturn(mPreference);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
index 9a34323..2ecc7d2 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
@@ -80,10 +80,10 @@
 
         MockitoAnnotations.initMocks(this);
         doReturn(mConnectivityManager)
-                .when(mContext).getSystemService(ConnectivityManager.class);
-        doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
+                .when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
+        doReturn(mTetheringManager).when(mContext).getSystemService(Context.TETHERING_SERVICE);
         doReturn(WIFI_REGEXS).when(mTetheringManager).getTetherableWifiRegexs();
-        doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
+        doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
 
         mWifiTetherSettings = new WifiTetherSettings();
     }
@@ -133,7 +133,7 @@
         when(settings.getContext()).thenReturn(mContext);
         final Resources.Theme theme = mContext.getTheme();
         when(activity.getTheme()).thenReturn(theme);
-        when(activity.getSystemService(UserManager.class)).thenReturn(mUserManager);
+        when(activity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
         doNothing().when(settings)
             .onCreatePreferences(any(Bundle.class), nullable(String.class));
         final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageEntryTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageEntryTest.java
index cf1b6b2..3cd3539 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageEntryTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageEntryTest.java
@@ -209,6 +209,24 @@
     }
 
     @Test
+    public void isPublic_prublicVolume_shouldReturnTrue() {
+        final VolumeInfo publicVolumeInfo = mock(VolumeInfo.class);
+        final StorageEntry publicStorage = new StorageEntry(mContext, publicVolumeInfo);
+        when(publicVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PUBLIC);
+
+        assertThat(publicStorage.isPublic()).isTrue();
+    }
+
+    @Test
+    public void isStub_stubVolume_shouldReturnTrue() {
+        final VolumeInfo stubVolumeInfo = mock(VolumeInfo.class);
+        final StorageEntry stubStorage = new StorageEntry(mContext, stubVolumeInfo);
+        when(stubVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_STUB);
+
+        assertThat(stubStorage.isStub()).isTrue();
+    }
+
+    @Test
     public void isPrivate_nonVolumeInfo_shouldReturnFalse() {
         final DiskInfo diskInfo = mock(DiskInfo.class);
         final StorageEntry diskStorage = new StorageEntry(diskInfo);
diff --git a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
index 94456fe..3e9cdc7 100644
--- a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
@@ -38,6 +38,7 @@
 import android.content.Context;
 import android.content.IntentFilter;
 import android.net.ConnectivityManager;
+import android.net.NetworkCapabilities;
 import android.net.wifi.WifiManager;
 
 import androidx.lifecycle.Lifecycle;
@@ -107,57 +108,80 @@
     }
 
     @Test
-    public void update_apmOnWifiOff_getInternetApm() {
+    public void updateInternetAvailable_wifiConnectedAndNoValidated_internetUnavailable() {
+        final NetworkCapabilities networkCapabilities = new NetworkCapabilities();
+        networkCapabilities.addTransportType(TRANSPORT_WIFI);
+        networkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
+
+        mInternetUpdater.updateInternetAvailable(networkCapabilities);
+
+        assertThat(mInternetUpdater.mInternetAvailable).isEqualTo(false);
+    }
+
+    @Test
+    public void updateInternetAvailable_wifiConnectedAndValidated_internetAvailable() {
+        final NetworkCapabilities networkCapabilities = new NetworkCapabilities();
+        networkCapabilities.addTransportType(TRANSPORT_WIFI);
+        networkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
+        networkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
+
+        mInternetUpdater.updateInternetAvailable(networkCapabilities);
+
+        assertThat(mInternetUpdater.mInternetAvailable).isEqualTo(true);
+    }
+
+    @Test
+    public void updateInternetType_apmOnWifiOff_getInternetApm() {
         doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
         doReturn(WifiManager.WIFI_STATE_DISABLED).when(mWifiManager).getWifiState();
         mInternetUpdater.mInternetAvailable = false;
 
-        mInternetUpdater.update();
+        mInternetUpdater.updateInternetType();
 
         assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_OFF);
     }
 
     @Test
-    public void update_apmOnWifiOnNotConnected_getInternetNetworksAvailable() {
+    public void updateInternetType_apmOnWifiOnNotConnected_getInternetNetworksAvailable() {
         doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
         doReturn(WifiManager.WIFI_STATE_ENABLED).when(mWifiManager).getWifiState();
         mInternetUpdater.mInternetAvailable = false;
 
-        mInternetUpdater.update();
+        mInternetUpdater.updateInternetType();
 
         assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_NETWORKS_AVAILABLE);
     }
 
     @Test
-    public void update_apmOnWifiConnected_getInternetWifi() {
+    public void updateInternetType_apmOnWifiConnected_getInternetWifi() {
         doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
         doReturn(true).when(mWifiManager).isWifiEnabled();
         mInternetUpdater.mInternetAvailable = true;
         mInternetUpdater.mTransport = TRANSPORT_WIFI;
 
-        mInternetUpdater.update();
+        mInternetUpdater.updateInternetType();
 
         assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_WIFI);
     }
 
     @Test
-    public void update_apmOnCellularConnected_getInternetCellular() {
+    public void updateInternetType_apmOnCellularConnected_getInternetCellular() {
         doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
         mInternetUpdater.mInternetAvailable = true;
         mInternetUpdater.mTransport = TRANSPORT_CELLULAR;
 
-        mInternetUpdater.update();
+        mInternetUpdater.updateInternetType();
 
         assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_CELLULAR);
     }
 
     @Test
-    public void update_apmOnEthernetConnected_getInternetEthernet() {
+    public void updateInternetType_apmOnEthernetConnected_getInternetEthernet() {
         doReturn(true).when(mAirplaneModeEnabler).isAirplaneModeOn();
         mInternetUpdater.mInternetAvailable = true;
         mInternetUpdater.mTransport = TRANSPORT_ETHERNET;
 
-        mInternetUpdater.update();
+        mInternetUpdater.updateInternetType();
 
         assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_ETHERNET);
     }
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
index 4760daa..a323ed6 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
@@ -236,7 +236,8 @@
         mWifiList.add(mMockWifiSliceItem2);
         mMockNetworkProviderWorker.updateSelfResults(mWifiList);
         mockHelperCondition(false, true, true, null);
-        when(mMockNetworkProviderWorker.isEthernetConnected()).thenReturn(true);
+        when(mMockNetworkProviderWorker.getInternetType())
+                .thenReturn(InternetUpdater.INTERNET_ETHERNET);
 
         final Slice slice = mMockProviderModelSlice.getSlice();
 
@@ -258,7 +259,8 @@
         mWifiList.add(mMockWifiSliceItem2);
         mMockNetworkProviderWorker.updateSelfResults(mWifiList);
         mockHelperCondition(false, true, true, mWifiList.get(0));
-        when(mMockNetworkProviderWorker.isEthernetConnected()).thenReturn(true);
+        when(mMockNetworkProviderWorker.getInternetType())
+                .thenReturn(InternetUpdater.INTERNET_ETHERNET);
 
         final Slice slice = mMockProviderModelSlice.getSlice();
 
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index 0c8ffb9..45f3693 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -74,7 +74,7 @@
         MockitoAnnotations.initMocks(this);
 
         mContext = spy(ApplicationProvider.getApplicationContext());
-        doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
+        doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
 
         when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
         doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java
index 97f8e11..d052f31 100644
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWorkerTest.java
@@ -261,24 +261,24 @@
     }
 
     @Test
-    public void isEthernetConnected_connectedEthernet_shouldBeTrue() {
+    public void getInternetType_connectedEthernet_returnInternetEthernet() {
         mMockNetworkProviderWorker.onInternetTypeChanged(INTERNET_ETHERNET);
 
-        assertThat(mMockNetworkProviderWorker.isEthernetConnected()).isTrue();
+        assertThat(mMockNetworkProviderWorker.getInternetType()).isEqualTo(INTERNET_ETHERNET);
     }
 
     @Test
-    public void isEthernetConnected_connectedWifi_shouldBeFalse() {
+    public void getInternetType_connectedWifi_returnInternetWifi() {
         mMockNetworkProviderWorker.onInternetTypeChanged(INTERNET_WIFI);
 
-        assertThat(mMockNetworkProviderWorker.isEthernetConnected()).isFalse();
+        assertThat(mMockNetworkProviderWorker.getInternetType()).isEqualTo(INTERNET_WIFI);
     }
 
     @Test
-    public void isEthernetConnected_connectedCarrier_shouldBeFalse() {
+    public void getInternetType__connectedCarrier_returnInternetCellular() {
         mMockNetworkProviderWorker.onInternetTypeChanged(INTERNET_CELLULAR);
 
-        assertThat(mMockNetworkProviderWorker.isEthernetConnected()).isFalse();
+        assertThat(mMockNetworkProviderWorker.getInternetType()).isEqualTo(INTERNET_CELLULAR);
     }
 
     public class MockNetworkProviderWorker extends NetworkProviderWorker {