Merge "Usage Settings: Fix NPE when subscriberId is Null." into sc-dev
diff --git a/res/drawable/fingerprint_enroll_introduction.xml b/res/drawable/fingerprint_enroll_introduction.xml
index 1ad4302..f48d426 100644
--- a/res/drawable/fingerprint_enroll_introduction.xml
+++ b/res/drawable/fingerprint_enroll_introduction.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
     Copyright (C) 2018 The Android Open Source Project
 
     Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,38 +15,42 @@
 -->
 
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="210dp"
-    android:height="210dp"
-    android:viewportHeight="210.0"
-    android:viewportWidth="210.0">
+    android:width="412dp"
+    android:height="300dp"
+    android:viewportHeight="300"
+    android:viewportWidth="412">
+
     <path
         android:fillColor="@color/biometric_enroll_intro_color_bar"
-        android:pathData="M73.79,58.17h-7V38.96c0,-15.39 9.16,-29.21 23.34,-35.21l2.73,6.45c-11.58,4.9 -19.06,16.19 -19.06,28.76V58.17z" />
+        android:pathData="M206,45.75a38,38,0,0,0-14.87,3h0A38.16,38.16,0,0,0,167.79,84v19.21h7V84A31.17,31.17,0,0,1,193.86,55.2h0a31.24,31.24,0,0,1,38.43,11.93l5.88-3.78A38.08,38.08,0,0,0,206,45.75Z" />
     <path
         android:fillColor="@color/biometric_enroll_intro_color_bar"
-        android:pathData="M131.29,22.13C125.51,13.12 115.68,7.75 105,7.75c-4.21,0 -8.3,0.82 -12.15,2.45l-2.73,-6.45c4.71,-1.99 9.72,-3 14.87,-3c13.08,0 25.11,6.58 32.18,17.6L131.29,22.13z" />
-    <path
-        android:fillColor="@color/biometric_enroll_intro_color_bar"
-        android:pathData="M143.21,62.11h-7V38.96c0,-5.99 -1.7,-11.81 -4.92,-16.83l5.89,-3.78c3.94,6.15 6.03,13.27 6.03,20.6V62.11z" />
-    <path
-        android:fillColor="@color/biometric_enroll_intro_color_bar"
-        android:pathData="M136.21,62.11h7v19.4h-7z" />
-    <path
-        android:fillColor="@color/biometric_enroll_intro_color_icon"
-        android:pathData="M125.03,118.78c-0.28,0 -0.55,-0.07 -0.79,-0.2c-6.61,-3.37 -12.33,-4.79 -19.19,-4.79c-6.82,0 -13.3,1.6 -19.19,4.79c-0.83,0.44 -1.86,0.14 -2.34,-0.68c-0.45,-0.82 -0.14,-1.87 0.69,-2.31c6.41,-3.43 13.44,-5.2 20.84,-5.2c7.34,0 13.75,1.6 20.77,5.17c0.86,0.44 1.17,1.46 0.72,2.28C126.24,118.44 125.65,118.78 125.03,118.78z" />
-    <path
-        android:fillColor="@color/biometric_enroll_intro_color_icon"
-        android:pathData="M75.73,136.63c-0.34,0 -0.69,-0.1 -1,-0.31c-0.79,-0.54 -0.96,-1.6 -0.41,-2.38c3.41,-4.76 7.75,-8.5 12.92,-11.12c10.82,-5.51 24.67,-5.54 35.52,-0.03c5.17,2.62 9.51,6.32 12.92,11.05c0.55,0.75 0.38,1.84 -0.41,2.38c-0.79,0.54 -1.86,0.37 -2.41,-0.41c-3.1,-4.28 -7.03,-7.65 -11.68,-10c-9.89,-5 -22.53,-5 -32.38,0.03c-4.69,2.38 -8.61,5.78 -11.71,10.06C76.8,136.39 76.28,136.63 75.73,136.63z" />
-    <path
-        android:fillColor="@color/biometric_enroll_intro_color_icon"
-        android:pathData="M97.27,177.67c-0.45,0 -0.9,-0.17 -1.21,-0.51c-3,-2.96 -4.62,-4.86 -6.92,-8.98c-2.38,-4.18 -3.62,-9.28 -3.62,-14.76c0,-10.1 8.75,-18.33 19.5,-18.33s19.5,8.23 19.5,18.33c0,0.95 -0.76,1.7 -1.72,1.7s-1.72,-0.75 -1.72,-1.7c0,-8.23 -7.2,-14.93 -16.05,-14.93s-16.05,6.7 -16.05,14.93c0,4.9 1.1,9.42 3.2,13.09c2.2,3.91 3.72,5.58 6.37,8.23c0.65,0.68 0.65,1.73 0,2.41C98.16,177.5 97.71,177.67 97.27,177.67z" />
-    <path
-        android:fillColor="@color/biometric_enroll_intro_color_icon"
-        android:pathData="M121.97,171.38c-4.1,0 -7.72,-1.02 -10.68,-3.03c-5.13,-3.43 -8.2,-9.01 -8.2,-14.93c0,-0.95 0.76,-1.7 1.72,-1.7s1.72,0.75 1.72,1.7c0,4.79 2.48,9.32 6.68,12.1c2.45,1.63 5.31,2.41 8.75,2.41c0.83,0 2.2,-0.1 3.58,-0.34c0.93,-0.17 1.83,0.44 2,1.39c0.17,0.92 -0.45,1.8 -1.41,1.97C124.17,171.34 122.45,171.38 121.97,171.38z" />
-    <path
-        android:fillColor="@color/biometric_enroll_intro_color_icon"
-        android:pathData="M115.04,178.38c-0.14,0 -0.31,-0.03 -0.45,-0.07c-5.48,-1.5 -9.06,-3.5 -12.82,-7.14c-4.82,-4.73 -7.48,-11.02 -7.48,-17.75c0,-5.51 4.75,-10 10.61,-10c5.86,0 10.61,4.49 10.61,10c0,3.64 3.2,6.6 7.17,6.6s7.17,-2.96 7.17,-6.6c0,-12.82 -11.2,-23.22 -24.98,-23.22c-9.78,0 -18.74,5.37 -22.77,13.7c-1.34,2.75 -2.03,5.98 -2.03,9.52c0,2.65 0.24,6.83 2.31,12.27c0.34,0.88 -0.1,1.87 -1,2.18c-0.9,0.34 -1.89,-0.14 -2.2,-0.99c-1.69,-4.45 -2.51,-8.87 -2.51,-13.46c0,-4.08 0.79,-7.79 2.34,-11.02c4.58,-9.49 14.75,-15.64 25.87,-15.64c15.68,0 28.42,11.93 28.42,26.62c0,5.51 -4.75,10 -10.61,10c-5.86,0 -10.61,-4.49 -10.61,-10c0,-3.64 -3.2,-6.6 -7.17,-6.6s-7.17,2.96 -7.17,6.6c0,5.81 2.27,11.25 6.44,15.33c3.27,3.2 6.41,4.96 11.27,6.29c0.93,0.24 1.45,1.19 1.21,2.07C116.49,177.87 115.77,178.38 115.04,178.38z" />
+        android:pathData="M238.18,63.35l-5.89,3.78A31.11,31.11,0,0,1,237.21,84v42.55h7V84A38.11,38.11,0,0,0,238.18,63.35Z" />
     <path
         android:fillColor="@color/biometric_enroll_intro_color_outline"
-        android:pathData="M170.77,209.25H39.23c-7.72,0 -14,-6.28 -14,-14V93.51c0,-7.72 6.28,-14 14,-14h131.54c7.72,0 14,6.28 14,14v101.74C184.77,202.97 178.49,209.25 170.77,209.25zM39.23,83.51c-5.51,0 -10,4.49 -10,10v101.74c0,5.51 4.49,10 10,10h131.54c5.51,0 10,-4.49 10,-10V93.51c0,-5.51 -4.49,-10 -10,-10H39.23z" />
-</vector>
+        android:pathData="M271.77,254.25H140.23a14,14,0,0,1-14-14V138.51a14,14,0,0,1,14-14H271.77a14,14,0,0,1,14,14V240.25A14,14,0,0,1,271.77,254.25ZM140.23,128.51a10,10,0,0,0-10,10V240.25a10,10,0,0,0,10,10H271.77a10,10,0,0,0,10-10V138.51a10,10,0,0,0-10-10Z" />
+    <path
+        android:pathData="M184.93,211.5a27.89,27.89,0,0,1-1.48-8.33c0-11.42,9.71-20.71,22.58-20.71s22.58,9.29,22.58,20.71v0.62a7.71,7.71,0,0,1-7.71,7.71,7.63,7.63,0,0,1-7.13-4.84l-2.58-6.45a7.69,7.69,0,0,0-14.84,2.87,17.57,17.57,0,0,0,6.58,13.71l1.49,1.16"
+        android:strokeColor="@color/biometric_enroll_intro_color_icon"
+        android:strokeLineCap="round"
+        android:strokeMiterLimit="10"
+        android:strokeWidth="4.93" />
+    <path
+        android:pathData="M186.67,161.49a41.14,41.14,0,0,1,38.72,0"
+        android:strokeColor="@color/biometric_enroll_intro_color_icon"
+        android:strokeLineCap="round"
+        android:strokeMiterLimit="10"
+        android:strokeWidth="4.93" />
+    <path
+        android:pathData="M180.22,182.46c4.58-7.61,14.42-12.9,25.81-12.9s21.23,5.29,25.81,12.9"
+        android:strokeColor="@color/biometric_enroll_intro_color_icon"
+        android:strokeLineCap="round"
+        android:strokeMiterLimit="10"
+        android:strokeWidth="4.93" />
+    <path
+        android:pathData="M222.16,221.18a23.39,23.39,0,0,1-32.26,0"
+        android:strokeColor="@color/biometric_enroll_intro_color_icon"
+        android:strokeLineCap="round"
+        android:strokeMiterLimit="10"
+        android:strokeWidth="4.93" />
+</vector>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fa6e95e..b9a600d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -908,8 +908,6 @@
     <string name="security_settings_fingerprint_enroll_introduction_footer_message_3" product="default">Your phone will occasionally use your recent fingerprint images to create improved fingerprint models.</string>
     <!-- Introduction detail message shown in fingerprint enrollment dialog, when fingerprint unlock is disabled by device admin [CHAR LIMIT=NONE]-->
     <string name="security_settings_fingerprint_enroll_introduction_message_unlock_disabled">Use your fingerprint to unlock your phone or approve purchases.\n\nNote: You can\u2019t use your fingerprint to unlock this device. For more information, contact your organization\u2019s admin.</string>
-    <!-- Introduction detail message shown in fingerprint enrollment screen in setup wizard. [CHAR LIMIT=NONE]-->
-    <string name="security_settings_fingerprint_enroll_introduction_message_setup">Use your fingerprint to unlock your phone or approve purchases.\n\nNote: Your fingerprint may be less secure than a strong pattern or PIN.</string>
     <!-- Button text to cancel enrollment from the introduction [CHAR LIMIT=22] -->
     <string name="security_settings_fingerprint_enroll_introduction_cancel">Cancel</string>
     <!-- Button text to cancel enrollment [CHAR LIMIT=30] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5fa2f56..6021a7c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -369,11 +369,11 @@
     </style>
 
     <style name="FingerprintLayoutTheme">
-        <item name="android:icon">@drawable/ic_fingerprint_header</item>
+        <item name="android:icon">@drawable/ic_lock</item>
     </style>
 
     <style name="FaceLayoutTheme">
-        <item name="android:icon">@drawable/ic_face_header</item>
+        <item name="android:icon">@drawable/ic_lock</item>
     </style>
 
     <style name="PreviewPagerPageIndicator">
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index dad5e0e..cce790b 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -159,6 +159,7 @@
             android:key="notification_assistant"
             android:order="23"
             android:title="@string/notification_assistant_title"
-            android:summary="@string/notification_assistant_summary"/>
+            android:summary="@string/notification_assistant_summary"
+            settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
     </PreferenceCategory>
 </PreferenceScreen>
diff --git a/res/xml/storage_category_fragment.xml b/res/xml/storage_category_fragment.xml
index 72623d7..fb62bee 100644
--- a/res/xml/storage_category_fragment.xml
+++ b/res/xml/storage_category_fragment.xml
@@ -24,8 +24,7 @@
         android:order="4"
         android:title="@string/storage_free_up_space_title"
         android:summary="@string/storage_free_up_space_summary"
-        android:icon="@drawable/ic_files_go_round"
-        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"
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index a8da7e2..fff3235 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -17,6 +17,7 @@
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="storage_dashboard_fragment"
     android:title="@string/storage_settings"
     settings:keywords="@string/keywords_storage">
     <com.android.settingslib.widget.SettingsSpinnerPreference
diff --git a/src/com/android/settings/applications/AppDashboardFragment.java b/src/com/android/settings/applications/AppDashboardFragment.java
index 65f2b61..ff12595 100644
--- a/src/com/android/settings/applications/AppDashboardFragment.java
+++ b/src/com/android/settings/applications/AppDashboardFragment.java
@@ -69,6 +69,10 @@
         use(SpecialAppAccessPreferenceController.class).setSession(getSettingsLifecycle());
         mAppsPreferenceController = use(AppsPreferenceController.class);
         mAppsPreferenceController.setFragment(this /* fragment */);
+
+        final HibernatedAppsPreferenceController hibernatedAppsPreferenceController =
+                use(HibernatedAppsPreferenceController.class);
+        getSettingsLifecycle().addObserver(hibernatedAppsPreferenceController);
     }
 
     @Override
diff --git a/src/com/android/settings/applications/HibernatedAppsPreferenceController.java b/src/com/android/settings/applications/HibernatedAppsPreferenceController.java
index 8d12811..bf12b86 100644
--- a/src/com/android/settings/applications/HibernatedAppsPreferenceController.java
+++ b/src/com/android/settings/applications/HibernatedAppsPreferenceController.java
@@ -30,40 +30,111 @@
 import android.provider.DeviceConfig;
 import android.util.ArrayMap;
 
+import androidx.annotation.NonNull;
+import androidx.annotation.WorkerThread;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 
+import com.google.common.annotations.VisibleForTesting;
+
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
 /**
  * A preference controller handling the logic for updating summary of hibernated apps.
  */
-public final class HibernatedAppsPreferenceController extends BasePreferenceController {
+public final class HibernatedAppsPreferenceController extends BasePreferenceController
+        implements LifecycleObserver {
     private static final String TAG = "HibernatedAppsPrefController";
     private static final String PROPERTY_HIBERNATION_UNUSED_THRESHOLD_MILLIS =
             "auto_revoke_unused_threshold_millis2";
     private static final long DEFAULT_UNUSED_THRESHOLD_MS = TimeUnit.DAYS.toMillis(90);
+    private PreferenceScreen mScreen;
+    private int mUnusedCount = 0;
+    private boolean mLoadingUnusedApps;
+    private final Executor mBackgroundExecutor;
+    private final Executor mMainExecutor;
 
     public HibernatedAppsPreferenceController(Context context, String preferenceKey) {
+        this(context, preferenceKey, Executors.newSingleThreadExecutor(),
+                context.getMainExecutor());
+    }
+
+    @VisibleForTesting
+    HibernatedAppsPreferenceController(Context context, String preferenceKey,
+            Executor bgExecutor, Executor mainExecutor) {
         super(context, preferenceKey);
+        mBackgroundExecutor = bgExecutor;
+        mMainExecutor = mainExecutor;
     }
 
     @Override
     public int getAvailabilityStatus() {
-        return isHibernationEnabled() && getNumHibernated() > 0
+        return isHibernationEnabled() && mUnusedCount > 0
                 ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
     @Override
     public CharSequence getSummary() {
-        final int numHibernated = getNumHibernated();
         return mContext.getResources().getQuantityString(
-                R.plurals.unused_apps_summary, numHibernated, numHibernated);
+                R.plurals.unused_apps_summary, mUnusedCount, mUnusedCount);
     }
 
-    private int getNumHibernated() {
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mScreen = screen;
+    }
+
+    /**
+     * On lifecycle resume event.
+     */
+    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
+    public void onResume() {
+        updatePreference();
+    }
+
+    private void updatePreference() {
+        if (mScreen == null) {
+            return;
+        }
+        if (!mLoadingUnusedApps) {
+            loadUnusedCount(unusedCount -> {
+                mUnusedCount = unusedCount;
+                mLoadingUnusedApps = false;
+                mMainExecutor.execute(() -> {
+                    super.displayPreference(mScreen);
+                    Preference pref = mScreen.findPreference(mPreferenceKey);
+                    refreshSummary(pref);
+                });
+            });
+            mLoadingUnusedApps = true;
+        }
+    }
+
+    /**
+     * Asynchronously load the count of unused apps.
+     *
+     * @param callback callback to call when the number of unused apps is calculated
+     */
+    private void loadUnusedCount(@NonNull UnusedCountLoadedCallback callback) {
+        mBackgroundExecutor.execute(() -> {
+            final int unusedCount = getUnusedCount();
+            callback.onUnusedCountLoaded(unusedCount);
+        });
+    }
+
+    @WorkerThread
+    private int getUnusedCount() {
         // TODO(b/187465752): Find a way to export this logic from PermissionController module
         final PackageManager pm = mContext.getPackageManager();
         final AppHibernationManager ahm = mContext.getSystemService(AppHibernationManager.class);
@@ -71,6 +142,7 @@
         int numHibernated = hibernatedPackages.size();
 
         // Also need to count packages that are auto revoked but not hibernated.
+        int numAutoRevoked = 0;
         final UsageStatsManager usm = mContext.getSystemService(UsageStatsManager.class);
         final long now = System.currentTimeMillis();
         final long unusedThreshold = DeviceConfig.getLong(DeviceConfig.NAMESPACE_PERMISSIONS,
@@ -97,17 +169,24 @@
                 for (String perm : pi.requestedPermissions) {
                     if ((pm.getPermissionFlags(perm, packageName, mContext.getUser())
                             & PackageManager.FLAG_PERMISSION_AUTO_REVOKED) != 0) {
-                        numHibernated++;
+                        numAutoRevoked++;
                         break;
                     }
                 }
             }
         }
-        return numHibernated;
+        return numHibernated + numAutoRevoked;
     }
 
     private static boolean isHibernationEnabled() {
         return DeviceConfig.getBoolean(
                 NAMESPACE_APP_HIBERNATION, PROPERTY_APP_HIBERNATION_ENABLED, false);
     }
+
+    /**
+     * Callback for when we've determined the number of unused apps.
+     */
+    private interface UnusedCountLoadedCallback {
+        void onUnusedCountLoaded(int unusedCount);
+    }
 }
diff --git a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
index 70f0baf..801dd03 100644
--- a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
@@ -30,7 +30,9 @@
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.Utils;
 import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.SettingsBaseActivity;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.transition.SettingsTransitionHelper;
 
 public abstract class BiometricStatusPreferenceController extends BasePreferenceController {
 
@@ -127,6 +129,8 @@
         }
         intent.putExtra(Intent.EXTRA_USER_ID, userId);
         intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
+        intent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
+                SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
         context.startActivity(intent);
         return true;
     }
diff --git a/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java b/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
index d8197c0..6847367 100644
--- a/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
+++ b/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
@@ -34,9 +34,11 @@
 import com.android.settings.Utils;
 import com.android.settings.biometrics.BiometricEnrollBase;
 import com.android.settings.biometrics.BiometricUtils;
+import com.android.settings.core.SettingsBaseActivity;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.password.ChooseLockGeneric;
 import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settingslib.transition.SettingsTransitionHelper;
 
 /**
  * Base fragment with the confirming credential functionality for combined biometrics settings.
@@ -203,6 +205,8 @@
                     true);
             intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
             intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, true);
+            intent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
+                    SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
 
             if (mUserId != UserHandle.USER_NULL) {
                 intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index a989eef..80a6f05 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -153,6 +153,7 @@
         intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
         intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
         startActivity(intent);
+        overridePendingTransition(R.anim.sud_slide_back_in, R.anim.sud_slide_back_out);
     }
 
     private void onAddAnotherButtonClick(View view) {
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
index d767d53..e105911 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroduction.java
@@ -82,9 +82,6 @@
     protected void initViews() {
         super.initViews();
 
-        setDescriptionText(
-                R.string.security_settings_fingerprint_enroll_introduction_message_setup);
-
         FooterButton nextButton = getNextButton();
         nextButton.setText(
                 this, R.string.security_settings_fingerprint_enroll_introduction_continue_setup);
diff --git a/src/com/android/settings/deviceinfo/StorageCategoryFragment.java b/src/com/android/settings/deviceinfo/StorageCategoryFragment.java
index 035c112..98736e3 100644
--- a/src/com/android/settings/deviceinfo/StorageCategoryFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageCategoryFragment.java
@@ -37,7 +37,6 @@
 import com.android.settings.Utils;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
-import com.android.settings.deviceinfo.storage.CachedStorageValuesHelper;
 import com.android.settings.deviceinfo.storage.SecondaryUserController;
 import com.android.settings.deviceinfo.storage.StorageAsyncLoader;
 import com.android.settings.deviceinfo.storage.StorageEntry;
@@ -54,6 +53,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * Storage Settings main UI is composed by 3 fragments:
@@ -85,7 +85,6 @@
     private StorageEntry mSelectedStorageEntry;
     private PrivateStorageInfo mStorageInfo;
     private SparseArray<StorageAsyncLoader.StorageResult> mAppsResult;
-    private CachedStorageValuesHelper mCachedStorageValuesHelper;
 
     private StorageItemPreferenceController mPreferenceController;
     private List<AbstractPreferenceController> mSecondaryUsers;
@@ -104,6 +103,10 @@
             return;
         }
 
+        // To prevent flicker, hides secondary users preference.
+        // onReceivedSizes will set it visible for private storage.
+        setSecondaryUsersVisible(false);
+
         if (!mSelectedStorageEntry.isMounted()) {
             // Set null volume to hide category stats.
             mPreferenceController.setVolume(null);
@@ -114,6 +117,10 @@
             mAppsResult = null;
             maybeSetLoading(isQuotaSupported());
 
+            // To prevent flicker, sets null volume to hide category preferences.
+            // onReceivedSizes will setVolume with the volume of selected storage.
+            mPreferenceController.setVolume(null);
+
             // Stats data is only available on private volumes.
             getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
             getLoaderManager()
@@ -157,7 +164,6 @@
     @Override
     public void onViewCreated(View v, Bundle savedInstanceState) {
         super.onViewCreated(v, savedInstanceState);
-        initializeCacheProvider();
 
         EntityHeaderController.newInstance(getActivity(), this /*fragment*/,
                 null /* header view */)
@@ -184,6 +190,10 @@
             return;
         }
 
+        if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
+            setLoading(false /* loading */, true /* animate */);
+        }
+
         final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
         mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
         mPreferenceController.setUsedSize(privateUsedBytes);
@@ -198,10 +208,7 @@
 
         mPreferenceController.onLoadFinished(mAppsResult, mUserId);
         updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
-
-        if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
-            setLoading(false, true);
-        }
+        setSecondaryUsersVisible(true);
     }
 
     @Override
@@ -263,7 +270,6 @@
     public void onLoadFinished(Loader<SparseArray<StorageAsyncLoader.StorageResult>> loader,
             SparseArray<StorageAsyncLoader.StorageResult> data) {
         mAppsResult = data;
-        maybeCacheFreshValues();
         onReceivedSizes();
     }
 
@@ -287,11 +293,6 @@
     }
 
     @VisibleForTesting
-    public void setCachedStorageValuesHelper(CachedStorageValuesHelper helper) {
-        mCachedStorageValuesHelper = helper;
-    }
-
-    @VisibleForTesting
     public PrivateStorageInfo getPrivateStorageInfo() {
         return mStorageInfo;
     }
@@ -311,19 +312,6 @@
         mAppsResult = info;
     }
 
-    @VisibleForTesting
-    void initializeCachedValues() {
-        final PrivateStorageInfo info = mCachedStorageValuesHelper.getCachedPrivateStorageInfo();
-        final SparseArray<StorageAsyncLoader.StorageResult> loaderResult =
-                mCachedStorageValuesHelper.getCachedStorageResult();
-        if (info == null || loaderResult == null) {
-            return;
-        }
-
-        mStorageInfo = info;
-        mAppsResult = loaderResult;
-    }
-
     /**
      * Activate loading UI and animation if it's necessary.
      */
@@ -337,24 +325,22 @@
         }
     }
 
-    private void initializeCacheProvider() {
-        mCachedStorageValuesHelper = new CachedStorageValuesHelper(getContext(), mUserId);
-        initializeCachedValues();
-        onReceivedSizes();
-    }
-
-    private void maybeCacheFreshValues() {
-        if (mStorageInfo != null && mAppsResult != null) {
-            mCachedStorageValuesHelper.cacheResult(mStorageInfo, mAppsResult.get(mUserId));
-        }
-    }
-
     private boolean isQuotaSupported() {
         return mSelectedStorageEntry.isMounted()
                 && getActivity().getSystemService(StorageStatsManager.class)
                         .isQuotaSupported(mSelectedStorageEntry.getFsUuid());
     }
 
+    private void setSecondaryUsersVisible(boolean visible) {
+        final Optional<SecondaryUserController> secondaryUserController = mSecondaryUsers.stream()
+                .filter(controller -> controller instanceof SecondaryUserController)
+                .map(controller -> (SecondaryUserController) controller)
+                .findAny();
+        if (secondaryUserController.isPresent()) {
+            secondaryUserController.get().setPreferenceGroupVisible(visible);
+        }
+    }
+
     /**
      * IconLoaderCallbacks exists because StorageCategoryFragment already implements
      * LoaderCallbacks for a different type.
@@ -414,7 +400,6 @@
             }
 
             mStorageInfo = privateStorageInfo;
-            maybeCacheFreshValues();
             onReceivedSizes();
         }
     }
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index b76d1cb..6dbc3aa 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -44,7 +44,6 @@
 import com.android.settings.Utils;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.deviceinfo.storage.AutomaticStorageManagementSwitchPreferenceController;
-import com.android.settings.deviceinfo.storage.CachedStorageValuesHelper;
 import com.android.settings.deviceinfo.storage.DiskInitFragment;
 import com.android.settings.deviceinfo.storage.SecondaryUserController;
 import com.android.settings.deviceinfo.storage.StorageAsyncLoader;
@@ -68,6 +67,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * Storage Settings main UI is composed by 3 fragments:
@@ -101,7 +101,6 @@
     private StorageEntry mSelectedStorageEntry;
     private PrivateStorageInfo mStorageInfo;
     private SparseArray<StorageAsyncLoader.StorageResult> mAppsResult;
-    private CachedStorageValuesHelper mCachedStorageValuesHelper;
 
     private StorageItemPreferenceController mPreferenceController;
     private VolumeOptionMenuController mOptionMenuController;
@@ -232,6 +231,10 @@
         mOptionMenuController.setSelectedStorageEntry(mSelectedStorageEntry);
         getActivity().invalidateOptionsMenu();
 
+        // To prevent flicker, hides secondary users preference.
+        // onReceivedSizes will set it visible for private storage.
+        setSecondaryUsersVisible(false);
+
         if (!mSelectedStorageEntry.isMounted()) {
             // Set null volume to hide category stats.
             mPreferenceController.setVolume(null);
@@ -242,6 +245,10 @@
             mAppsResult = null;
             maybeSetLoading(isQuotaSupported());
 
+            // To prevent flicker, sets null volume to hide category preferences.
+            // onReceivedSizes will setVolume with the volume of selected storage.
+            mPreferenceController.setVolume(null);
+
             // Stats data is only available on private volumes.
             getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
             getLoaderManager()
@@ -316,7 +323,6 @@
     @Override
     public void onViewCreated(View v, Bundle savedInstanceState) {
         super.onViewCreated(v, savedInstanceState);
-        initializeCacheProvider();
 
         EntityHeaderController.newInstance(getActivity(), this /*fragment*/,
                 null /* header view */)
@@ -355,6 +361,10 @@
             return;
         }
 
+        if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
+            setLoading(false /* loading */, true /* animate */);
+        }
+
         final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
         mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
         mPreferenceController.setUsedSize(privateUsedBytes);
@@ -369,10 +379,7 @@
 
         mPreferenceController.onLoadFinished(mAppsResult, mUserId);
         updateSecondaryUserControllers(mSecondaryUsers, mAppsResult);
-
-        if (getView().findViewById(R.id.loading_container).getVisibility() == View.VISIBLE) {
-            setLoading(false, true);
-        }
+        setSecondaryUsersVisible(true);
     }
 
     @Override
@@ -463,7 +470,6 @@
     public void onLoadFinished(Loader<SparseArray<StorageAsyncLoader.StorageResult>> loader,
             SparseArray<StorageAsyncLoader.StorageResult> data) {
         mAppsResult = data;
-        maybeCacheFreshValues();
         onReceivedSizes();
     }
 
@@ -487,11 +493,6 @@
     }
 
     @VisibleForTesting
-    public void setCachedStorageValuesHelper(CachedStorageValuesHelper helper) {
-        mCachedStorageValuesHelper = helper;
-    }
-
-    @VisibleForTesting
     public PrivateStorageInfo getPrivateStorageInfo() {
         return mStorageInfo;
     }
@@ -511,19 +512,6 @@
         mAppsResult = info;
     }
 
-    @VisibleForTesting
-    void initializeCachedValues() {
-        final PrivateStorageInfo info = mCachedStorageValuesHelper.getCachedPrivateStorageInfo();
-        final SparseArray<StorageAsyncLoader.StorageResult> loaderResult =
-                mCachedStorageValuesHelper.getCachedStorageResult();
-        if (info == null || loaderResult == null) {
-            return;
-        }
-
-        mStorageInfo = info;
-        mAppsResult = loaderResult;
-    }
-
     /**
      * Activate loading UI and animation if it's necessary.
      */
@@ -537,24 +525,22 @@
         }
     }
 
-    private void initializeCacheProvider() {
-        mCachedStorageValuesHelper = new CachedStorageValuesHelper(getContext(), mUserId);
-        initializeCachedValues();
-        onReceivedSizes();
-    }
-
-    private void maybeCacheFreshValues() {
-        if (mStorageInfo != null && mAppsResult != null) {
-            mCachedStorageValuesHelper.cacheResult(mStorageInfo, mAppsResult.get(mUserId));
-        }
-    }
-
     private boolean isQuotaSupported() {
         return mSelectedStorageEntry.isMounted()
                 && getActivity().getSystemService(StorageStatsManager.class)
                         .isQuotaSupported(mSelectedStorageEntry.getFsUuid());
     }
 
+    private void setSecondaryUsersVisible(boolean visible) {
+        final Optional<SecondaryUserController> secondaryUserController = mSecondaryUsers.stream()
+                .filter(controller -> controller instanceof SecondaryUserController)
+                .map(controller -> (SecondaryUserController) controller)
+                .findAny();
+        if (secondaryUserController.isPresent()) {
+            secondaryUserController.get().setPreferenceGroupVisible(visible);
+        }
+    }
+
     /**
      * IconLoaderCallbacks exists because StorageDashboardFragment already implements
      * LoaderCallbacks for a different type.
@@ -614,7 +600,6 @@
             }
 
             mStorageInfo = privateStorageInfo;
-            maybeCacheFreshValues();
             onReceivedSizes();
         }
     }
diff --git a/src/com/android/settings/deviceinfo/StorageItemPreference.java b/src/com/android/settings/deviceinfo/StorageItemPreference.java
index cdb9f9d..934ff3f 100644
--- a/src/com/android/settings/deviceinfo/StorageItemPreference.java
+++ b/src/com/android/settings/deviceinfo/StorageItemPreference.java
@@ -43,7 +43,6 @@
     public StorageItemPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
         setLayoutResource(R.layout.storage_item);
-        setSummary(R.string.memory_calculating_size);
     }
 
     public void setStorageSize(long size, long total) {
diff --git a/src/com/android/settings/deviceinfo/storage/CachedStorageValuesHelper.java b/src/com/android/settings/deviceinfo/storage/CachedStorageValuesHelper.java
deleted file mode 100644
index 4ca623d..0000000
--- a/src/com/android/settings/deviceinfo/storage/CachedStorageValuesHelper.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.deviceinfo.storage;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.provider.Settings;
-import android.util.SparseArray;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.settingslib.applications.StorageStatsSource;
-import com.android.settingslib.deviceinfo.PrivateStorageInfo;
-
-import java.util.concurrent.TimeUnit;
-
-public class CachedStorageValuesHelper {
-
-    @VisibleForTesting public static final String SHARED_PREFERENCES_NAME = "CachedStorageValues";
-    public static final String TIMESTAMP_KEY = "last_query_timestamp";
-    public static final String FREE_BYTES_KEY = "free_bytes";
-    public static final String TOTAL_BYTES_KEY = "total_bytes";
-    public static final String GAME_APPS_SIZE_KEY = "game_apps_size";
-    public static final String AUDIO_SIZE_KEY = "audio_size";
-    public static final String VIDEOS_SIZE_KEY = "videos_size";
-    public static final String IMAGES_SIZE_KEY = "images_size";
-    public static final String DOCUMENTS_AND_OTHER_SIZE_KEY = "documents_and_other_size";
-    public static final String TRASH_SIZE_KEY = "trash_size";
-    public static final String OTHER_APPS_SIZE_KEY = "other_apps_size";
-    public static final String CACHE_APPS_SIZE_KEY = "cache_apps_size";
-    public static final String EXTERNAL_TOTAL_BYTES = "external_total_bytes";
-    public static final String EXTERNAL_AUDIO_BYTES = "external_audio_bytes";
-    public static final String EXTERNAL_VIDEO_BYTES = "external_video_bytes";
-    public static final String EXTERNAL_IMAGE_BYTES = "external_image_bytes";
-    public static final String EXTERNAL_APP_BYTES = "external_apps_bytes";
-    public static final String USER_ID_KEY = "user_id";
-    private final Long mClobberThreshold;
-    private final SharedPreferences mSharedPreferences;
-    private final int mUserId;
-    // This clock is used to provide the time. By default, it uses the system clock, but can be
-    // replaced for test purposes.
-    protected Clock mClock;
-
-    public CachedStorageValuesHelper(Context context, int userId) {
-        mSharedPreferences =
-                context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
-        mClock = new Clock();
-        mUserId = userId;
-        mClobberThreshold =
-                Settings.Global.getLong(
-                        context.getContentResolver(),
-                        Settings.Global.STORAGE_SETTINGS_CLOBBER_THRESHOLD,
-                        TimeUnit.MINUTES.toMillis(5));
-    }
-
-    public PrivateStorageInfo getCachedPrivateStorageInfo() {
-        if (!isDataValid()) {
-            return null;
-        }
-        final long freeBytes = mSharedPreferences.getLong(FREE_BYTES_KEY, -1);
-        final long totalBytes = mSharedPreferences.getLong(TOTAL_BYTES_KEY, -1);
-        if (freeBytes < 0 || totalBytes < 0) {
-            return null;
-        }
-
-        return new PrivateStorageInfo(freeBytes, totalBytes);
-    }
-
-    /** Returns cached storage result or null if it's not available. */
-    public SparseArray<StorageAsyncLoader.StorageResult> getCachedStorageResult() {
-        if (!isDataValid()) {
-            return null;
-        }
-        final long gamesSize = mSharedPreferences.getLong(GAME_APPS_SIZE_KEY, -1);
-        final long audioSize = mSharedPreferences.getLong(AUDIO_SIZE_KEY, -1);
-        final long videosSize = mSharedPreferences.getLong(VIDEOS_SIZE_KEY, -1);
-        final long imagesSize = mSharedPreferences.getLong(IMAGES_SIZE_KEY, -1);
-        final long documentsAndOtherSize =
-                mSharedPreferences.getLong(DOCUMENTS_AND_OTHER_SIZE_KEY, -1);
-        final long trashSize = mSharedPreferences.getLong(TRASH_SIZE_KEY, -1);
-        final long allAppsExceptGamesSize = mSharedPreferences.getLong(OTHER_APPS_SIZE_KEY, -1);
-        final long cacheSize = mSharedPreferences.getLong(CACHE_APPS_SIZE_KEY, -1);
-        if (gamesSize < 0
-                || audioSize < 0
-                || videosSize < 0
-                || imagesSize < 0
-                || documentsAndOtherSize < 0
-                || trashSize < 0
-                || allAppsExceptGamesSize < 0
-                || cacheSize < 0) {
-            return null;
-        }
-
-        final long externalTotalBytes = mSharedPreferences.getLong(EXTERNAL_TOTAL_BYTES, -1);
-        final long externalAudioBytes = mSharedPreferences.getLong(EXTERNAL_AUDIO_BYTES, -1);
-        final long externalVideoBytes = mSharedPreferences.getLong(EXTERNAL_VIDEO_BYTES, -1);
-        final long externalImageBytes = mSharedPreferences.getLong(EXTERNAL_IMAGE_BYTES, -1);
-        final long externalAppBytes = mSharedPreferences.getLong(EXTERNAL_APP_BYTES, -1);
-        if (externalTotalBytes < 0
-                || externalAudioBytes < 0
-                || externalVideoBytes < 0
-                || externalImageBytes < 0
-                || externalAppBytes < 0) {
-            return null;
-        }
-
-        final StorageStatsSource.ExternalStorageStats externalStats =
-                new StorageStatsSource.ExternalStorageStats(
-                        externalTotalBytes,
-                        externalAudioBytes,
-                        externalVideoBytes,
-                        externalImageBytes,
-                        externalAppBytes);
-        final StorageAsyncLoader.StorageResult result = new StorageAsyncLoader.StorageResult();
-        result.gamesSize = gamesSize;
-        result.audioSize = audioSize;
-        result.videosSize = videosSize;
-        result.imagesSize = imagesSize;
-        result.documentsAndOtherSize = documentsAndOtherSize;
-        result.trashSize = trashSize;
-        result.allAppsExceptGamesSize = allAppsExceptGamesSize;
-        result.cacheSize = cacheSize;
-        result.externalStats = externalStats;
-        final SparseArray<StorageAsyncLoader.StorageResult> resultArray = new SparseArray<>();
-        resultArray.append(mUserId, result);
-        return resultArray;
-    }
-
-    public void cacheResult(
-            PrivateStorageInfo storageInfo, StorageAsyncLoader.StorageResult result) {
-        mSharedPreferences
-                .edit()
-                .putLong(FREE_BYTES_KEY, storageInfo.freeBytes)
-                .putLong(TOTAL_BYTES_KEY, storageInfo.totalBytes)
-                .putLong(GAME_APPS_SIZE_KEY, result.gamesSize)
-                .putLong(AUDIO_SIZE_KEY, result.audioSize)
-                .putLong(VIDEOS_SIZE_KEY, result.videosSize)
-                .putLong(IMAGES_SIZE_KEY, result.imagesSize)
-                .putLong(DOCUMENTS_AND_OTHER_SIZE_KEY, result.documentsAndOtherSize)
-                .putLong(TRASH_SIZE_KEY, result.trashSize)
-                .putLong(OTHER_APPS_SIZE_KEY, result.allAppsExceptGamesSize)
-                .putLong(CACHE_APPS_SIZE_KEY, result.cacheSize)
-                .putLong(EXTERNAL_TOTAL_BYTES, result.externalStats.totalBytes)
-                .putLong(EXTERNAL_AUDIO_BYTES, result.externalStats.audioBytes)
-                .putLong(EXTERNAL_VIDEO_BYTES, result.externalStats.videoBytes)
-                .putLong(EXTERNAL_IMAGE_BYTES, result.externalStats.imageBytes)
-                .putLong(EXTERNAL_APP_BYTES, result.externalStats.appBytes)
-                .putInt(USER_ID_KEY, mUserId)
-                .putLong(TIMESTAMP_KEY, mClock.getCurrentTime())
-                .apply();
-    }
-
-    private boolean isDataValid() {
-        final int cachedUserId = mSharedPreferences.getInt(USER_ID_KEY, -1);
-        if (cachedUserId != mUserId) {
-            return false;
-        }
-
-        final long lastQueryTime = mSharedPreferences.getLong(TIMESTAMP_KEY, Long.MAX_VALUE);
-        final long currentTime = mClock.getCurrentTime();
-        return currentTime - lastQueryTime < mClobberThreshold;
-    }
-
-    /** Clock provides the current time. */
-    static class Clock {
-        public long getCurrentTime() {
-            return System.currentTimeMillis();
-        }
-    }
-}
diff --git a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
index 6475029..f87a06a 100644
--- a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
+++ b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
@@ -53,9 +53,11 @@
     UserInfo mUser;
     private @Nullable
     StorageItemPreference mStoragePreference;
+    private PreferenceGroup mPreferenceGroup;
     private Drawable mUserIcon;
     private long mSize;
     private long mTotalSizeBytes;
+    private boolean mIsVisible;
 
     /**
      * Adds the appropriate controllers to a controller list for handling all secondary users on
@@ -115,16 +117,15 @@
         if (mStoragePreference == null) {
             mStoragePreference = new StorageItemPreference(screen.getContext());
 
-            PreferenceGroup group =
-                    screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
+            mPreferenceGroup = screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
             mStoragePreference.setTitle(mUser.name);
             mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
             if (mSize != SIZE_NOT_SET) {
                 mStoragePreference.setStorageSize(mSize, mTotalSizeBytes);
             }
 
-            group.setVisible(true);
-            group.addPreference(mStoragePreference);
+            mPreferenceGroup.setVisible(mIsVisible);
+            mPreferenceGroup.addPreference(mStoragePreference);
             maybeSetIcon();
         }
     }
@@ -168,6 +169,18 @@
         mTotalSizeBytes = totalSizeBytes;
     }
 
+    /**
+     * Sets visibility of the PreferenceGroup of secondary user.
+     *
+     * @param visible Visibility of the PreferenceGroup.
+     */
+    public void setPreferenceGroupVisible(boolean visible) {
+        mIsVisible = visible;
+        if (mPreferenceGroup != null) {
+            mPreferenceGroup.setVisible(mIsVisible);
+        }
+    }
+
     @Override
     public void handleResult(SparseArray<StorageAsyncLoader.StorageResult> stats) {
         final StorageAsyncLoader.StorageResult result = stats.get(getUser().id);
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 41e26ee..22ea98f 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -221,7 +221,15 @@
     public void setVolume(VolumeInfo volume) {
         mVolume = volume;
 
-        updateCategoryPreferencesVisibility();
+        if (mPublicStoragePreference != null) {
+            mPublicStoragePreference.setVisible(isValidPublicVolume());
+        }
+
+        // If isValidPrivateVolume() is true, these preferences will become visible at
+        // onLoadFinished.
+        if (!isValidPrivateVolume()) {
+            setPrivateStorageCategoryPreferencesVisibility(false);
+        }
     }
 
     // Stats data is only available on private volumes.
@@ -242,30 +250,28 @@
                 || mVolume.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
     }
 
-    private void updateCategoryPreferencesVisibility() {
+    @VisibleForTesting
+    void setPrivateStorageCategoryPreferencesVisibility(boolean visible) {
         if (mScreen == null) {
             return;
         }
 
-        mPublicStoragePreference.setVisible(isValidPublicVolume());
+        mImagesPreference.setVisible(visible);
+        mVideosPreference.setVisible(visible);
+        mAudioPreference.setVisible(visible);
+        mAppsPreference.setVisible(visible);
+        mGamesPreference.setVisible(visible);
+        mSystemPreference.setVisible(visible);
+        mTrashPreference.setVisible(visible);
 
-        final boolean privateStoragePreferencesVisible = isValidPrivateVolume();
-        mImagesPreference.setVisible(privateStoragePreferencesVisible);
-        mVideosPreference.setVisible(privateStoragePreferencesVisible);
-        mAudioPreference.setVisible(privateStoragePreferencesVisible);
-        mAppsPreference.setVisible(privateStoragePreferencesVisible);
-        mGamesPreference.setVisible(privateStoragePreferencesVisible);
-        mDocumentsAndOtherPreference.setVisible(privateStoragePreferencesVisible);
-        mSystemPreference.setVisible(privateStoragePreferencesVisible);
-        mTrashPreference.setVisible(privateStoragePreferencesVisible);
-
-        if (privateStoragePreferencesVisible) {
+        // 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.
+        if (visible) {
             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.
-            if (sharedVolume == null || !sharedVolume.isMountedReadable()) {
-                mDocumentsAndOtherPreference.setVisible(false);
-            }
+            mDocumentsAndOtherPreference.setVisible(sharedVolume != null
+                    && sharedVolume.isMountedReadable());
+        } else {
+            mDocumentsAndOtherPreference.setVisible(false);
         }
     }
 
@@ -390,6 +396,7 @@
         }
 
         updatePrivateStorageCategoryPreferencesOrder();
+        setPrivateStorageCategoryPreferencesVisibility(true);
     }
 
     public void setUsedSize(long usedSizeBytes) {
diff --git a/src/com/android/settings/display/SmartAutoRotateBatterySaverController.java b/src/com/android/settings/display/SmartAutoRotateBatterySaverController.java
index d135d4b..4e08302 100644
--- a/src/com/android/settings/display/SmartAutoRotateBatterySaverController.java
+++ b/src/com/android/settings/display/SmartAutoRotateBatterySaverController.java
@@ -25,12 +25,12 @@
 import android.os.PowerManager;
 
 import androidx.annotation.VisibleForTesting;
-import androidx.lifecycle.LifecycleObserver;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
 import com.android.settingslib.widget.BannerMessagePreference;
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index a41fab6..644d5cb 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -19,14 +19,11 @@
 import android.app.Activity;
 import android.app.Application;
 import android.app.settings.SettingsEnums;
-import android.app.usage.IUsageStatsManager;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
-import android.os.ServiceManager;
 import android.os.UserHandle;
-import android.os.UserManager;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.fragment.app.Fragment;
@@ -57,10 +54,11 @@
     private static final int REQUEST_CODE = 200;
     private static final String SELECTED_PREFERENCE_KEY = "selected_preference";
     private static final String KEY_ADVANCED_CATEGORY = "configure_notifications_advanced";
-    private static final String KEY_NAS = "notification_assistant";
 
     private RingtonePreference mRequestPreference;
 
+    private NotificationAssistantPreferenceController mNotificationAssistantPreferenceController;
+
     @Override
     public int getMetricsCategory() {
         return SettingsEnums.CONFIGURE_NOTIFICATION;
@@ -89,6 +87,16 @@
     }
 
     @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+
+        mNotificationAssistantPreferenceController =
+                use(NotificationAssistantPreferenceController.class);
+        mNotificationAssistantPreferenceController.setFragment(this);
+        mNotificationAssistantPreferenceController.setBackend(new NotificationBackend());
+    }
+
+    @Override
     protected boolean isParalleledControllers() {
         return true;
     }
@@ -105,9 +113,6 @@
             }
 
         });
-        controllers.add(new NotificationAssistantPreferenceController(context,
-                new NotificationBackend(), host, KEY_NAS));
-
         controllers.add(new EmergencyBroadcastPreferenceController(context,
                 "app_and_notif_cell_broadcast_settings"));
 
diff --git a/src/com/android/settings/notification/NotificationAssistantPreferenceController.java b/src/com/android/settings/notification/NotificationAssistantPreferenceController.java
index a46f164..bdbc478 100644
--- a/src/com/android/settings/notification/NotificationAssistantPreferenceController.java
+++ b/src/com/android/settings/notification/NotificationAssistantPreferenceController.java
@@ -30,6 +30,8 @@
 
 public class NotificationAssistantPreferenceController extends TogglePreferenceController {
     private static final String TAG = "NASPreferenceController";
+    private static final String KEY_NAS = "notification_assistant";
+
     private static final int AVAILABLE = 1;
     private final UserManager mUserManager;
     private Fragment mFragment;
@@ -38,11 +40,8 @@
     @VisibleForTesting
     protected NotificationBackend mNotificationBackend;
 
-    public NotificationAssistantPreferenceController(Context context, NotificationBackend backend,
-            Fragment fragment, String preferenceKey) {
-        super(context, preferenceKey);
-        mNotificationBackend = backend;
-        mFragment = fragment;
+    public NotificationAssistantPreferenceController(Context context) {
+        super(context, KEY_NAS);
         mUserManager = UserManager.get(context);
     }
 
@@ -87,4 +86,13 @@
                 NotificationAssistantDialogFragment.newInstance(mFragment, cn);
         dialogFragment.show(mFragment.getFragmentManager(), TAG);
     }
+
+    public void setFragment(Fragment fragment) {
+        mFragment = fragment;
+    }
+
+    @VisibleForTesting
+    void setBackend(NotificationBackend backend) {
+        mNotificationBackend = backend;
+    }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
index 54b78be..8e1a4f8 100644
--- a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
@@ -30,6 +30,7 @@
 import com.android.settings.Utils;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.password.ChooseLockGeneric;
+import com.android.settingslib.transition.SettingsTransitionHelper;
 
 public class ChangeProfileScreenLockPreferenceController extends
         ChangeScreenLockPreferenceController {
@@ -81,6 +82,7 @@
                 .setDestination(ChooseLockGeneric.ChooseLockGenericFragment.class.getName())
                 .setSourceMetricsCategory(mHost.getMetricsCategory())
                 .setArguments(extras)
+                .setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
                 .launch();
 
         return true;
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index 98a3c6f..b6e215c 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -26,6 +26,7 @@
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.os.UserManager;
+import android.util.Log;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
@@ -43,6 +44,7 @@
 import com.android.settingslib.RestrictedLockUtilsInternal;
 import com.android.settingslib.RestrictedSwitchPreference;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.transition.SettingsTransitionHelper;
 
 /**
  * Controller for password unification/un-unification flows.
@@ -173,6 +175,7 @@
                 .setDestination(ChooseLockGeneric.ChooseLockGenericFragment.class.getName())
                 .setSourceMetricsCategory(mHost.getMetricsCategory())
                 .setArguments(extras)
+                .setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
                 .launch();
     }
 
@@ -229,6 +232,7 @@
                 .setTitleRes(R.string.lock_settings_picker_title)
                 .setSourceMetricsCategory(mHost.getMetricsCategory())
                 .setArguments(extras)
+                .setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
                 .launch();
     }
 
diff --git a/src/com/android/settings/widget/SettingsMainSwitchPreference.java b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
index 7f349bc..de7d692 100644
--- a/src/com/android/settings/widget/SettingsMainSwitchPreference.java
+++ b/src/com/android/settings/widget/SettingsMainSwitchPreference.java
@@ -84,7 +84,9 @@
 
         mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
         mMainSwitchBar.show();
-        mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
+        if (mRestrictedHelper != null) {
+            mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
+        }
         updateStatus(isChecked());
         registerListenerToSwitchBar();
 
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java
index af1900a..411a3cf 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java
@@ -33,8 +33,6 @@
 
 import androidx.recyclerview.widget.RecyclerView;
 
-import com.android.settings.deviceinfo.storage.CachedStorageValuesHelper;
-import com.android.settings.deviceinfo.storage.StorageAsyncLoader;
 import com.android.settingslib.deviceinfo.PrivateStorageInfo;
 import com.android.settingslib.drawer.CategoryKey;
 
@@ -73,47 +71,6 @@
     }
 
     @Test
-    public void test_cacheProviderProvidesValuesIfBothCached() {
-        CachedStorageValuesHelper helper = mock(CachedStorageValuesHelper.class);
-        PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
-        when(helper.getCachedPrivateStorageInfo()).thenReturn(info);
-        SparseArray<StorageAsyncLoader.StorageResult> result = new SparseArray<>();
-        when(helper.getCachedStorageResult()).thenReturn(result);
-
-        mFragment.setCachedStorageValuesHelper(helper);
-        mFragment.initializeCachedValues();
-
-        assertThat(mFragment.getPrivateStorageInfo()).isEqualTo(info);
-        assertThat(mFragment.getStorageResult()).isEqualTo(result);
-    }
-
-    @Test
-    public void test_cacheProviderDoesntProvideValuesIfAppsMissing() {
-        CachedStorageValuesHelper helper = mock(CachedStorageValuesHelper.class);
-        PrivateStorageInfo info = new PrivateStorageInfo(0, 0);
-        when(helper.getCachedPrivateStorageInfo()).thenReturn(info);
-
-        mFragment.setCachedStorageValuesHelper(helper);
-        mFragment.initializeCachedValues();
-
-        assertThat(mFragment.getPrivateStorageInfo()).isNull();
-        assertThat(mFragment.getStorageResult()).isNull();
-    }
-
-    @Test
-    public void test_cacheProviderDoesntProvideValuesIfVolumeInfoMissing() {
-        CachedStorageValuesHelper helper = mock(CachedStorageValuesHelper.class);
-        SparseArray<StorageAsyncLoader.StorageResult> result = new SparseArray<>();
-        when(helper.getCachedStorageResult()).thenReturn(result);
-
-        mFragment.setCachedStorageValuesHelper(helper);
-        mFragment.initializeCachedValues();
-
-        assertThat(mFragment.getPrivateStorageInfo()).isNull();
-        assertThat(mFragment.getStorageResult()).isNull();
-    }
-
-    @Test
     public void test_loadWhenQuotaOffIfVolumeInfoNotLoaded() {
         View fakeView = mock(View.class, RETURNS_DEEP_STUBS);
         RecyclerView fakeRecyclerView = mock(RecyclerView.class, RETURNS_DEEP_STUBS);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
index 24543801..984d945 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageItemPreferenceTest.java
@@ -46,12 +46,6 @@
     }
 
     @Test
-    public void testBeforeLoad() {
-        assertThat(mPreference.getSummary())
-            .isEqualTo(mContext.getString(R.string.memory_calculating_size));
-    }
-
-    @Test
     public void testAfterLoad() {
         mPreference.setStorageSize(MEGABYTE_IN_BYTES * 10, MEGABYTE_IN_BYTES * 100);
         assertThat(mPreference.getSummary()).isEqualTo("10 MB");
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/CachedStorageValuesHelperTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/CachedStorageValuesHelperTest.java
deleted file mode 100644
index ccc9152..0000000
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/CachedStorageValuesHelperTest.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.deviceinfo.storage;
-
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.AUDIO_SIZE_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.CACHE_APPS_SIZE_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.DOCUMENTS_AND_OTHER_SIZE_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.EXTERNAL_APP_BYTES;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
-        .EXTERNAL_AUDIO_BYTES;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
-        .EXTERNAL_IMAGE_BYTES;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
-        .EXTERNAL_TOTAL_BYTES;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
-        .EXTERNAL_VIDEO_BYTES;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.FREE_BYTES_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.GAME_APPS_SIZE_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.IMAGES_SIZE_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.OTHER_APPS_SIZE_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper
-        .SHARED_PREFERENCES_NAME;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.TIMESTAMP_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.TOTAL_BYTES_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.TRASH_SIZE_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.USER_ID_KEY;
-import static com.android.settings.deviceinfo.storage.CachedStorageValuesHelper.VIDEOS_SIZE_KEY;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.util.SparseArray;
-
-import com.android.settingslib.applications.StorageStatsSource;
-import com.android.settingslib.deviceinfo.PrivateStorageInfo;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class CachedStorageValuesHelperTest {
-
-    private Context mContext;
-
-    @Mock private CachedStorageValuesHelper.Clock mMockClock;
-    private CachedStorageValuesHelper mCachedValuesHelper;
-    private SharedPreferences mSharedPreferences;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-        mSharedPreferences = mContext.getSharedPreferences(SHARED_PREFERENCES_NAME, 0);
-        mCachedValuesHelper = new CachedStorageValuesHelper(mContext, 0);
-        mCachedValuesHelper.mClock = mMockClock;
-    }
-
-    @Test
-    public void getCachedPrivateStorageInfo_cachedValuesAreLoaded() {
-        when(mMockClock.getCurrentTime()).thenReturn(10001L);
-        mSharedPreferences
-                .edit()
-                .putLong(GAME_APPS_SIZE_KEY, 0)
-                .putLong(AUDIO_SIZE_KEY, 10)
-                .putLong(VIDEOS_SIZE_KEY, 100)
-                .putLong(IMAGES_SIZE_KEY, 1000)
-                .putLong(OTHER_APPS_SIZE_KEY, 10000)
-                .putLong(CACHE_APPS_SIZE_KEY, 100000)
-                .putLong(EXTERNAL_TOTAL_BYTES, 2)
-                .putLong(EXTERNAL_AUDIO_BYTES, 22)
-                .putLong(EXTERNAL_VIDEO_BYTES, 222)
-                .putLong(EXTERNAL_IMAGE_BYTES, 2222)
-                .putLong(EXTERNAL_APP_BYTES, 22222)
-                .putLong(FREE_BYTES_KEY, 1000L)
-                .putLong(TOTAL_BYTES_KEY, 6000L)
-                .putInt(USER_ID_KEY, 0)
-                .putLong(TIMESTAMP_KEY, 10000L)
-                .apply();
-
-        final PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
-
-        assertThat(info.freeBytes).isEqualTo(1000L);
-        assertThat(info.totalBytes).isEqualTo(6000L);
-    }
-
-    @Test
-    public void getCachedStorageResult_cachedValuesAreLoaded() {
-        when(mMockClock.getCurrentTime()).thenReturn(10001L);
-        mSharedPreferences
-                .edit()
-                .putLong(GAME_APPS_SIZE_KEY, 1)
-                .putLong(AUDIO_SIZE_KEY, 10)
-                .putLong(VIDEOS_SIZE_KEY, 100)
-                .putLong(IMAGES_SIZE_KEY, 1000)
-                .putLong(DOCUMENTS_AND_OTHER_SIZE_KEY, 1001)
-                .putLong(TRASH_SIZE_KEY, 1002)
-                .putLong(OTHER_APPS_SIZE_KEY, 10000)
-                .putLong(CACHE_APPS_SIZE_KEY, 100000)
-                .putLong(EXTERNAL_TOTAL_BYTES, 222222)
-                .putLong(EXTERNAL_AUDIO_BYTES, 22)
-                .putLong(EXTERNAL_VIDEO_BYTES, 222)
-                .putLong(EXTERNAL_IMAGE_BYTES, 2222)
-                .putLong(EXTERNAL_APP_BYTES, 22222)
-                .putLong(FREE_BYTES_KEY, 1000L)
-                .putLong(TOTAL_BYTES_KEY, 5000L)
-                .putInt(USER_ID_KEY, 0)
-                .putLong(TIMESTAMP_KEY, 10000L)
-                .apply();
-
-        final SparseArray<StorageAsyncLoader.StorageResult> result =
-                mCachedValuesHelper.getCachedStorageResult();
-
-        StorageAsyncLoader.StorageResult primaryResult = result.get(0);
-        assertThat(primaryResult.gamesSize).isEqualTo(1L);
-        assertThat(primaryResult.audioSize).isEqualTo(10L);
-        assertThat(primaryResult.videosSize).isEqualTo(100L);
-        assertThat(primaryResult.imagesSize).isEqualTo(1000L);
-        assertThat(primaryResult.documentsAndOtherSize).isEqualTo(1001L);
-        assertThat(primaryResult.trashSize).isEqualTo(1002L);
-        assertThat(primaryResult.allAppsExceptGamesSize).isEqualTo(10000L);
-        assertThat(primaryResult.cacheSize).isEqualTo(100000L);
-        assertThat(primaryResult.externalStats.totalBytes).isEqualTo(222222L);
-        assertThat(primaryResult.externalStats.audioBytes).isEqualTo(22L);
-        assertThat(primaryResult.externalStats.videoBytes).isEqualTo(222L);
-        assertThat(primaryResult.externalStats.imageBytes).isEqualTo(2222L);
-        assertThat(primaryResult.externalStats.appBytes).isEqualTo(22222L);
-    }
-
-    @Test
-    public void getCachedPrivateStorageInfo_nullIfDataIsStale() {
-        when(mMockClock.getCurrentTime()).thenReturn(10000000L);
-        mSharedPreferences
-                .edit()
-                .putLong(GAME_APPS_SIZE_KEY, 0)
-                .putLong(AUDIO_SIZE_KEY, 10)
-                .putLong(VIDEOS_SIZE_KEY, 100)
-                .putLong(IMAGES_SIZE_KEY, 1000)
-                .putLong(OTHER_APPS_SIZE_KEY, 10000)
-                .putLong(CACHE_APPS_SIZE_KEY, 100000)
-                .putLong(EXTERNAL_TOTAL_BYTES, 2)
-                .putLong(EXTERNAL_AUDIO_BYTES, 22)
-                .putLong(EXTERNAL_VIDEO_BYTES, 222)
-                .putLong(EXTERNAL_IMAGE_BYTES, 2222)
-                .putLong(EXTERNAL_APP_BYTES, 22222)
-                .putLong(FREE_BYTES_KEY, 1000L)
-                .putLong(TOTAL_BYTES_KEY, 5000L)
-                .putInt(USER_ID_KEY, 0)
-                .putLong(TIMESTAMP_KEY, 10000L)
-                .apply();
-
-        final PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
-        assertThat(info).isNull();
-    }
-
-    @Test
-    public void getCachedStorageResult_nullIfDataIsStale() {
-        when(mMockClock.getCurrentTime()).thenReturn(10000000L);
-        mSharedPreferences
-                .edit()
-                .putLong(GAME_APPS_SIZE_KEY, 0)
-                .putLong(AUDIO_SIZE_KEY, 10)
-                .putLong(VIDEOS_SIZE_KEY, 100)
-                .putLong(IMAGES_SIZE_KEY, 1000)
-                .putLong(OTHER_APPS_SIZE_KEY, 10000)
-                .putLong(CACHE_APPS_SIZE_KEY, 100000)
-                .putLong(EXTERNAL_TOTAL_BYTES, 2)
-                .putLong(EXTERNAL_AUDIO_BYTES, 22)
-                .putLong(EXTERNAL_VIDEO_BYTES, 222)
-                .putLong(EXTERNAL_IMAGE_BYTES, 2222)
-                .putLong(EXTERNAL_APP_BYTES, 22222)
-                .putLong(FREE_BYTES_KEY, 1000L)
-                .putLong(TOTAL_BYTES_KEY, 5000L)
-                .putInt(USER_ID_KEY, 0)
-                .putLong(TIMESTAMP_KEY, 10000L)
-                .apply();
-
-        final SparseArray<StorageAsyncLoader.StorageResult> result =
-                mCachedValuesHelper.getCachedStorageResult();
-        assertThat(result).isNull();
-    }
-
-    @Test
-    public void getCachedPrivateStorageInfo_nullIfWrongUser() {
-        when(mMockClock.getCurrentTime()).thenReturn(10001L);
-        mSharedPreferences
-                .edit()
-                .putLong(GAME_APPS_SIZE_KEY, 0)
-                .putLong(AUDIO_SIZE_KEY, 10)
-                .putLong(VIDEOS_SIZE_KEY, 100)
-                .putLong(IMAGES_SIZE_KEY, 1000)
-                .putLong(OTHER_APPS_SIZE_KEY, 10000)
-                .putLong(CACHE_APPS_SIZE_KEY, 100000)
-                .putLong(EXTERNAL_TOTAL_BYTES, 2)
-                .putLong(EXTERNAL_AUDIO_BYTES, 22)
-                .putLong(EXTERNAL_VIDEO_BYTES, 222)
-                .putLong(EXTERNAL_IMAGE_BYTES, 2222)
-                .putLong(EXTERNAL_APP_BYTES, 22222)
-                .putLong(FREE_BYTES_KEY, 1000L)
-                .putLong(TOTAL_BYTES_KEY, 5000L)
-                .putInt(USER_ID_KEY, 1)
-                .putLong(TIMESTAMP_KEY, 10000L)
-                .apply();
-
-        final PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
-        assertThat(info).isNull();
-    }
-
-    @Test
-    public void getCachedStorageResult_nullIfWrongUser() {
-        when(mMockClock.getCurrentTime()).thenReturn(10001L);
-        mSharedPreferences
-                .edit()
-                .putLong(GAME_APPS_SIZE_KEY, 0)
-                .putLong(AUDIO_SIZE_KEY, 10)
-                .putLong(VIDEOS_SIZE_KEY, 100)
-                .putLong(IMAGES_SIZE_KEY, 1000)
-                .putLong(OTHER_APPS_SIZE_KEY, 10000)
-                .putLong(CACHE_APPS_SIZE_KEY, 100000)
-                .putLong(EXTERNAL_TOTAL_BYTES, 2)
-                .putLong(EXTERNAL_AUDIO_BYTES, 22)
-                .putLong(EXTERNAL_VIDEO_BYTES, 222)
-                .putLong(EXTERNAL_IMAGE_BYTES, 2222)
-                .putLong(EXTERNAL_APP_BYTES, 22222)
-                .putLong(FREE_BYTES_KEY, 1000L)
-                .putLong(TOTAL_BYTES_KEY, 5000L)
-                .putInt(USER_ID_KEY, 1)
-                .putLong(TIMESTAMP_KEY, 10000L)
-                .apply();
-
-        final SparseArray<StorageAsyncLoader.StorageResult> result =
-                mCachedValuesHelper.getCachedStorageResult();
-        assertThat(result).isNull();
-    }
-
-    @Test
-    public void getCachedPrivateStorageInfo_nullIfEmpty() {
-        final PrivateStorageInfo info = mCachedValuesHelper.getCachedPrivateStorageInfo();
-        assertThat(info).isNull();
-    }
-
-    @Test
-    public void getCachedStorageResult_nullIfEmpty() {
-        final SparseArray<StorageAsyncLoader.StorageResult> result =
-                mCachedValuesHelper.getCachedStorageResult();
-        assertThat(result).isNull();
-    }
-
-    @Test
-    public void cacheResult_succeeds() {
-        when(mMockClock.getCurrentTime()).thenReturn(10000L);
-        final StorageStatsSource.ExternalStorageStats externalStats =
-                new StorageStatsSource.ExternalStorageStats(22222L, 2L, 20L, 200L, 2000L);
-        final StorageAsyncLoader.StorageResult result =
-                new StorageAsyncLoader.StorageResult();
-        result.gamesSize = 1L;
-        result.audioSize = 10L;
-        result.videosSize = 100L;
-        result.imagesSize = 1000L;
-        result.allAppsExceptGamesSize = 10000L;
-        result.cacheSize = 100000L;
-        result.externalStats = externalStats;
-        final PrivateStorageInfo info = new PrivateStorageInfo(1000L, 6000L);
-
-        mCachedValuesHelper.cacheResult(info, result);
-
-        assertThat(mSharedPreferences.getLong(GAME_APPS_SIZE_KEY, -1)).isEqualTo(1L);
-        assertThat(mSharedPreferences.getLong(AUDIO_SIZE_KEY, -1)).isEqualTo(10L);
-        assertThat(mSharedPreferences.getLong(VIDEOS_SIZE_KEY, -1)).isEqualTo(100L);
-        assertThat(mSharedPreferences.getLong(IMAGES_SIZE_KEY, -1)).isEqualTo(1000L);
-        assertThat(mSharedPreferences.getLong(OTHER_APPS_SIZE_KEY, -1)).isEqualTo(10000L);
-        assertThat(mSharedPreferences.getLong(CACHE_APPS_SIZE_KEY, -1)).isEqualTo(100000L);
-        assertThat(mSharedPreferences.getLong(EXTERNAL_TOTAL_BYTES, -1)).isEqualTo(22222L);
-        assertThat(mSharedPreferences.getLong(EXTERNAL_AUDIO_BYTES, -1)).isEqualTo(2L);
-        assertThat(mSharedPreferences.getLong(EXTERNAL_VIDEO_BYTES, -1)).isEqualTo(20L);
-        assertThat(mSharedPreferences.getLong(EXTERNAL_IMAGE_BYTES, -1)).isEqualTo(200L);
-        assertThat(mSharedPreferences.getLong(EXTERNAL_APP_BYTES, -1)).isEqualTo(2000L);
-        assertThat(mSharedPreferences.getLong(FREE_BYTES_KEY, -1)).isEqualTo(1000L);
-        assertThat(mSharedPreferences.getLong(TOTAL_BYTES_KEY, -1)).isEqualTo(6000L);
-        assertThat(mSharedPreferences.getInt(USER_ID_KEY, -1)).isEqualTo(0);
-        assertThat(mSharedPreferences.getLong(TIMESTAMP_KEY, -1)).isEqualTo(10000L);
-    }
-}
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 cfc9e93..3eab600 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -151,12 +151,6 @@
     }
 
     @Test
-    public void testUpdateStateWithInitialState() {
-        assertThat(mPreference.getSummary().toString())
-            .isEqualTo(mContext.getString(R.string.memory_calculating_size));
-    }
-
-    @Test
     public void launchPublicStorageIntent_nonNullBrowseIntent_settingsIntent() {
         final String fakeBrowseAction = "FAKE_BROWSE_ACTION";
         final Intent fakeBrowseIntent = new Intent(fakeBrowseAction);
@@ -398,16 +392,17 @@
     }
 
     @Test
-    public void setVolume_updateFilePreferenceToHideAfterSettingVolume_hidePreference() {
+    public void setPrivateStorageCategoryPreferencesVisibility_updateFilePreferenceToHideAfterSettingVolume_hidePreference() {
         when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
         when(mVolume.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
         when(mVolume.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
         when(mVolume.isMountedReadable()).thenReturn(true);
-
         mController.displayPreference(mPreferenceScreen);
         when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(null);
         mController.setVolume(mVolume);
 
+        mController.setPrivateStorageCategoryPreferencesVisibility(true);
+
         assertThat(mController.mDocumentsAndOtherPreference.isVisible()).isFalse();
     }
 
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java
index fe36615..d130711 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java
@@ -79,8 +79,9 @@
         when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
         when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
         when(mBackend.getDefaultNotificationAssistant()).thenReturn(mNASComponent);
-        mPreferenceController = new NotificationAssistantPreferenceController(mContext,
-                mBackend, mFragment, KEY);
+        mPreferenceController = new NotificationAssistantPreferenceController(mContext);
+        mPreferenceController.setBackend(mBackend);
+        mPreferenceController.setFragment(mFragment);
         when(mUserManager.getProfileIds(eq(0), anyBoolean())).thenReturn(new int[] {0, 10});
         when(mUserManager.getProfileIds(eq(20), anyBoolean())).thenReturn(new int[] {20});
     }
diff --git a/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
index 39c966d..0682983 100644
--- a/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
@@ -41,9 +41,13 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ParceledListSlice;
 import android.content.res.Resources;
+import android.os.Looper;
 import android.os.RemoteException;
 import android.provider.DeviceConfig;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
@@ -67,12 +71,16 @@
     AppHibernationManager mAppHibernationManager;
     @Mock
     IUsageStatsManager mIUsageStatsManager;
+    PreferenceScreen mPreferenceScreen;
     private static final String KEY = "key";
     private Context mContext;
     private HibernatedAppsPreferenceController mController;
 
     @Before
     public void setUp() {
+        if (Looper.myLooper() == null) {
+            Looper.prepare();
+        }
         MockitoAnnotations.initMocks(this);
         DeviceConfig.setProperty(NAMESPACE_APP_HIBERNATION, PROPERTY_APP_HIBERNATION_ENABLED,
                 "true", false);
@@ -82,7 +90,15 @@
                 .thenReturn(mAppHibernationManager);
         when(mContext.getSystemService(UsageStatsManager.class)).thenReturn(
                 new UsageStatsManager(mContext, mIUsageStatsManager));
-        mController = new HibernatedAppsPreferenceController(mContext, KEY);
+
+        PreferenceManager manager = new PreferenceManager(mContext);
+        mPreferenceScreen = manager.createPreferenceScreen(mContext);
+        Preference preference = mock(Preference.class);
+        when(preference.getKey()).thenReturn(KEY);
+        mPreferenceScreen.addPreference(preference);
+
+        mController = new HibernatedAppsPreferenceController(mContext, KEY,
+                command -> command.run(), command -> command.run());
     }
 
     @Test
@@ -100,7 +116,9 @@
                 Arrays.asList(hibernatedPkg, new PackageInfo()));
         when(mContext.getResources()).thenReturn(mock(Resources.class));
 
-        mController.getSummary();
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+
         verify(mContext.getResources()).getQuantityString(anyInt(), eq(1), eq(1));
     }
 
@@ -111,7 +129,9 @@
                 Arrays.asList(autoRevokedPkg, new PackageInfo()));
         when(mContext.getResources()).thenReturn(mock(Resources.class));
 
-        mController.getSummary();
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+
         verify(mContext.getResources()).getQuantityString(anyInt(), eq(1), eq(1));
     }
 
@@ -123,7 +143,9 @@
                 Arrays.asList(usedAutoRevokedPkg, new PackageInfo()));
         when(mContext.getResources()).thenReturn(mock(Resources.class));
 
-        mController.getSummary();
+        mController.displayPreference(mPreferenceScreen);
+        mController.onResume();
+
         verify(mContext.getResources()).getQuantityString(anyInt(), eq(0), eq(0));
     }