Merge "UserCredentialsSettings: remove unneeded checks for locksettings keys"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1735a51..9704f21 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2486,33 +2486,41 @@
 
         <!-- Exported for SystemUI to launch into -->
         <activity android:name=".deviceinfo.StorageWizardInit"
-                android:theme="@style/GlifV3Theme.Light"
+                android:theme="@style/GlifTheme.Light"
                 android:exported="true"
+                android:configChanges="keyboardHidden|orientation|screenSize"
                 android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
         <activity android:name=".deviceinfo.StorageWizardFormatProgress"
-                android:theme="@style/GlifV3Theme.Light"
-                android:exported="false" />
+                android:theme="@style/GlifTheme.Light"
+                android:exported="false"
+                android:configChanges="keyboardHidden|orientation|screenSize"/>
         <activity android:name=".deviceinfo.StorageWizardFormatSlow"
-                android:theme="@style/GlifV3Theme.Light"
-                android:exported="false" />
+                android:theme="@style/GlifTheme.Light"
+                android:exported="false"
+                android:configChanges="keyboardHidden|orientation|screenSize"/>
         <activity android:name=".deviceinfo.StorageWizardMigrateConfirm"
-                android:theme="@style/GlifV3Theme.Light"
-                android:exported="false" />
+                android:theme="@style/GlifTheme.Light"
+                android:exported="false"
+                android:configChanges="keyboardHidden|orientation|screenSize"/>
         <activity android:name=".deviceinfo.StorageWizardMigrateProgress"
-                android:theme="@style/GlifV3Theme.Light"
+                android:theme="@style/GlifTheme.Light"
                 android:exported="true"
+                android:configChanges="keyboardHidden|orientation|screenSize"
                 android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
         <activity android:name=".deviceinfo.StorageWizardReady"
-                android:theme="@style/GlifV3Theme.Light"
+                android:theme="@style/GlifTheme.Light"
                 android:exported="true"
+                android:configChanges="keyboardHidden|orientation|screenSize"
                 android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
 
         <activity android:name=".deviceinfo.StorageWizardMoveConfirm"
-                android:theme="@style/GlifV3Theme.Light"
-                android:exported="false" />
+                android:theme="@style/GlifTheme.Light"
+                android:exported="false"
+                android:configChanges="keyboardHidden|orientation|screenSize"/>
         <activity android:name=".deviceinfo.StorageWizardMoveProgress"
-                android:theme="@style/GlifV3Theme.Light"
+                android:theme="@style/GlifTheme.Light"
                 android:exported="true"
+                android:configChanges="keyboardHidden|orientation|screenSize"
                 android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
 
         <!-- Exported for SystemUI to trigger -->
@@ -4389,14 +4397,6 @@
         </receiver>
 
         <receiver
-            android:name=".sim.receivers.SuwFinishReceiver"
-            android:exported="true">
-            <intent-filter>
-                <action android:name="com.google.android.setupwizard.SETUP_WIZARD_FINISHED" />
-            </intent-filter>
-        </receiver>
-
-        <receiver
             android:name=".sim.receivers.SimCompleteBootReceiver"
             android:exported="true">
             <intent-filter>
diff --git a/res/drawable/ic_storage_wizard_external.xml b/res/drawable/ic_storage_wizard_external.xml
index 99e2698..c6fefa1 100644
--- a/res/drawable/ic_storage_wizard_external.xml
+++ b/res/drawable/ic_storage_wizard_external.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
 <!--
     Copyright (C) 2018 The Android Open Source Project
 
@@ -14,80 +15,101 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="144dp"
-        android:height="144dp"
-        android:viewportWidth="144.0"
-        android:viewportHeight="144.0">
+    android:width="360dp"
+    android:height="262dp"
+    android:viewportWidth="360"
+    android:viewportHeight="262">
+
     <path
-        android:pathData="M64,64m-64,0a64,64 0,1 1,128 0a64,64 0,1 1,-128 0"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#FFFFFF"
-        android:strokeWidth="1"/>
+        android:fillColor="@android:color/transparent"
+        android:pathData="M335.709 262H24.2913C10.9223 262 0 250.821 0 237.11V24.89C0 11.1787 10.9223 0 24.2913 0H335.796C349.078 0 360 11.1787 360 24.89V237.285C360 250.821 349.078 262 335.709 262Z" />
     <path
-        android:pathData="M18.98,95C17.88,95 17,94.12 17,93.03L17,34.97C17,33.88 17.88,33 18.98,33L47.02,33C48.12,33 49,33.88 49,34.97L49,93.03C49,94.12 48.12,95 47.02,95L18.98,95Z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#FFFFFF"
-        android:strokeWidth="1"/>
+        android:fillColor="@android:color/transparent"
+        android:pathData="M153.786 66.0239H319.806C322.777 66.0239 325.223 68.4693 325.311 71.4386V183.575H148.282V71.4386C148.282 68.4693 150.728 66.0239 153.786 66.0239Z"
+        android:strokeWidth="5"
+        android:strokeColor="#E8EAED"/>
     <path
-        android:pathData="M18.98,96C17.33,96 16,94.68 16,93.03L16,34.97C16,33.32 17.33,32 18.98,32L47.02,32C48.67,32 50,33.32 50,34.97L50,93.03C50,94.68 48.67,96 47.02,96L18.98,96Z"
-        android:fillType="nonZero"
-        android:strokeColor="#DADCE0"
-        android:fillColor="#00000000"
-        android:strokeWidth="2"/>
+        android:fillColor="#BDC1C6"
+        android:pathData="M182.272 180.605H171.961V183.4H182.272V180.605Z" />
     <path
-        android:pathData="M18.98,94L47.02,94C47.57,94 48,93.57 48,93.03L48,34.97C48,34.43 47.57,34 47.02,34L18.98,34C18.43,34 18,34.43 18,34.97L18,93.03C18,93.57 18.43,94 18.98,94Z"
-        android:fillType="nonZero"
-        android:strokeColor="#F1F3F4"
-        android:fillColor="#00000000"
-        android:strokeWidth="2"/>
+        android:fillColor="#BDC1C6"
+        android:pathData="M195.204 180.605H184.893V183.4H195.204V180.605Z" />
     <path
-        android:pathData="M73,87L123.02,87L118.03,97L73,97C72.45,97 72,96.55 72,96L72,88C72,87.45 72.45,87 73,87Z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#F1F3F4"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M74,89L74,95L119.11,95L121.99,89L74,89ZM73,87L122.59,87C122.26,87.73 120.83,90.87 118.29,96.42C118.13,96.77 117.77,97 117.38,97L73,97C72.45,97 72,96.55 72,96L72,88C72,87.45 72.45,87 73,87Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
         android:fillColor="#DADCE0"
-        android:strokeWidth="1"/>
+        android:pathData="M78.8155 104.538V100.521C78.8155 99.9967 78.3786 99.5601 77.8544 99.5601V78.6001C77.8544 75.8054 75.5825 73.6221 72.8738 73.6221H26.8252C24.0291 73.6221 21.8447 75.8054 21.8447 78.6001V174.492C21.8447 177.287 24.1165 179.47 26.8252 179.47H72.7864C75.5825 179.47 77.767 177.199 77.767 174.492V125.585C78.2913 125.585 78.7282 125.149 78.7282 124.625V114.581C78.7282 114.057 78.2913 113.621 77.767 113.621V105.586C78.3786 105.499 78.8155 105.062 78.8155 104.538ZM76.8058 174.492C76.8058 176.675 74.9709 178.509 72.7864 178.509H26.8252C24.6408 178.509 22.8058 176.675 22.8058 174.492V78.6001C22.8058 76.4167 24.5534 74.5827 26.8252 74.5827H72.7864C74.9709 74.5827 76.8058 76.3294 76.8058 78.6001V174.492Z" />
     <path
-        android:pathData="M89,27L115.06,27C116.17,27 127.49,47.66 127.49,60.45C127.49,75.69 123.39,87.18 122.57,89L87,89L87,29C87,27.9 87.9,27 89,27Z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#F1F3F4"
-        android:strokeWidth="1"/>
+        android:fillColor="#81C995"
+        android:pathData="M35.2136 102.18H47.534V89.8658H35.2136V102.18ZM35.2136 103.926C34.2524 103.926 33.466 103.14 33.466 102.18V89.8658C33.466 88.9051 34.2524 88.1191 35.2136 88.1191H47.534C47.9709 88.1191 48.4077 88.2938 48.7573 88.6431C49.1068 88.9925 49.2815 89.4291 49.2815 89.8658V102.18C49.2815 103.14 48.4951 103.926 47.534 103.926H35.2136ZM36.0874 100.433H46.5728L43.2524 96.0665L40.6311 99.5598L38.6213 96.9398L36.0874 100.433ZM35.2136 89.8658V102.18V89.8658Z" />
     <path
-        android:pathData="M89,87L122.96,87C126.83,74.93 128.26,64.56 127.26,55.89C126.26,47.22 122.76,38.26 116.78,29L89,29L89,87ZM89,27L115.53,27C116.63,27 128.29,48.2 127.36,60.95C125.65,84.63 123.1,89 122,89L87,89L87,29C87,27.9 87.9,27 89,27Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
+        android:fillColor="#F28B82"
+        android:pathData="M44.5631 111.787H42.0291L43.6893 115.105H41.2427L39.5825 111.787H37.9223L39.5825 115.105H37.1359L35.4757 111.787H33.8155L35.4757 115.105H33.0291L31.3689 111.787C30.4951 111.787 29.7087 112.485 29.7087 113.359V123.227C29.7087 124.101 30.4078 124.887 31.3689 124.887H44.5631C45.4369 124.887 46.2233 124.101 46.2233 123.227V113.359C46.2233 112.485 45.4369 111.787 44.5631 111.787Z" />
+    <path
+        android:fillColor="#FDD663"
+        android:pathData="M69.9903 122.965H58.9806V121.568C58.9806 121.044 58.5437 120.607 58.0194 120.607H54.7864C54.2622 120.607 53.8253 121.044 53.8253 121.568V134.319C53.8253 135.367 54.699 136.24 55.7476 136.24H69.0291C70.0777 136.24 70.9515 135.367 70.9515 134.319V123.839C70.9515 123.315 70.5146 122.878 69.9903 122.965Z" />
+    <path
+        android:fillColor="#8AB4F8"
+        android:pathData="M69.2912 98.8613H56.8835V107.769H55.398C53.9126 107.769 52.7767 108.992 52.7767 110.389C52.7767 111.874 54 113.009 55.398 113.009H56.0097C57.4077 113.009 58.4563 111.961 58.5437 110.564V101.481H65.8835V107.769H64.398C62.9126 107.769 61.7767 108.992 61.7767 110.389C61.7767 111.874 63 113.009 64.398 113.009H65.0097C66.4077 113.009 67.4563 111.961 67.5437 110.564V101.219C68.5922 100.87 69.2912 99.9093 69.2912 98.8613Z" />
+    <path
+        android:fillColor="#81C995"
+        android:pathData="M65.0097 144.449C64.7476 144.187 64.4854 144.1 64.1359 144.1H55.2233C54.5242 144.1 53.9126 144.711 53.9126 145.41V154.318C53.9126 154.667 54.0874 154.929 54.2621 155.191C54.5242 155.453 54.7864 155.541 55.1359 155.541H62.2136L65.4466 152.309V145.323C65.4466 145.061 65.2718 144.711 65.0097 144.449ZM64.1359 151.785H62.8252C62.1262 151.785 61.5145 152.397 61.5145 153.095V154.405H55.1359V145.497H64.0485L64.1359 151.785Z" />
+    <path
+        android:fillColor="#F28B82"
+        android:pathData="M55.5728 162.964L48.233 158.772C47.7961 158.51 47.2718 158.685 47.0097 159.034C47.0097 159.034 47.0097 159.121 46.9223 159.121C46.7476 159.209 46.7476 159.383 46.7476 159.645V167.942C46.7476 168.466 47.0971 168.815 47.6213 168.815C47.7961 168.815 47.9709 168.815 48.1456 168.728L55.3107 164.536C55.7476 164.361 55.9223 163.837 55.7476 163.401C55.7476 163.401 55.7476 163.313 55.6602 163.313C55.8349 163.139 55.7476 163.051 55.5728 162.964Z" />
+    <path
+        android:fillColor="#8AB4F8"
+        android:pathData="M42.3787 133.445H35.9126C35.0389 133.445 34.3398 134.144 34.3398 135.017V137.725H32.3301C31.4563 137.725 30.7573 138.423 30.7573 139.297L30.6699 151.698C30.6699 152.135 30.8447 152.484 31.1068 152.833C31.369 153.095 31.8058 153.27 32.1554 153.27L41.4175 153.357C41.8544 153.357 42.2039 153.183 42.5534 152.921C42.8156 152.659 42.9903 152.222 42.9903 151.873V149.689H45.4369C46.3107 149.689 47.0971 148.991 47.0971 148.117C47.0971 148.117 47.0971 148.117 47.0971 148.03V138.336L42.3787 133.445ZM41.5049 151.698L32.2427 151.611L32.3301 139.209H34.3398V147.855C34.3398 148.729 35.0389 149.427 35.9126 149.427H41.5049V151.698ZM43.9515 146.371H37.5728V144.711H44.0389L43.9515 146.371ZM43.9515 143.139H37.5728V141.48H44.0389L43.9515 143.139ZM45.5243 139.035H41.5049V135.017L45.5243 139.035Z" />
+    <path
+        android:fillColor="#BDC1C6"
+        android:pathData="M276.728 180.605H197.738V183.4H276.728V180.605Z" />
+    <path
+        android:fillColor="@android:color/transparent"
+        android:pathData="M317.184 74.3208H156.32V171.697H317.184V74.3208Z" />
+    <path
+        android:fillColor="#BDC1C6"
+        android:pathData="M289.136 180.605H278.825V183.4H289.136V180.605Z" />
+    <path
         android:fillColor="#DADCE0"
-        android:strokeWidth="1"/>
+        android:pathData="M134.65 182.09H338.854V184.186C338.854 185.758 337.631 186.981 336.058 186.981H137.447C135.874 186.981 134.65 185.758 134.65 184.186V182.09Z" />
     <path
-        android:pathData="M94,33L119.52,33C119.9,33 120.26,33.23 120.42,33.58C125.14,43.7 127.67,51.84 128,58C128.33,64.11 127.47,72.18 125.4,82.2L125.4,82.2C125.3,82.67 124.9,83 124.42,83L94,83C93.45,83 93,82.55 93,82L93,34C93,33.45 93.45,33 94,33C94,33 94,33 94,33Z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#FFFFFF"
-        android:strokeWidth="1"/>
+        android:fillColor="#81C995"
+        android:pathData="M177.204 129.69H193.456V113.446H177.204V129.69ZM177.204 132.048C175.893 132.048 174.845 131 174.845 129.69V113.446C174.845 112.136 175.893 111.088 177.204 111.088H193.456C194.767 111.088 195.816 112.136 195.816 113.446V129.69C195.816 131 194.767 132.048 193.456 132.048H177.204ZM178.34 127.332H192.32L187.951 121.481L184.456 126.109L181.835 122.616L178.34 127.332ZM177.204 113.359V129.69V113.359Z" />
     <path
-        android:pathData="M73.63,41L68.13,41L64.01,45.2L64,53.6C64,54.37 64.62,55 65.38,55L73.63,55C74.38,55 75,54.37 75,53.6L75,42.4C75,41.63 74.38,41 73.63,41ZM69.5,45.2L68.13,45.2L68.13,42.4L69.5,42.4L69.5,45.2ZM71.56,45.2L70.19,45.2L70.19,42.4L71.56,42.4L71.56,45.2ZM73.63,45.2L72.25,45.2L72.25,42.4L73.63,42.4L73.63,45.2Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
+        android:fillColor="#F28B82"
+        android:pathData="M266.68 129.865H262.485L265.282 135.454H261.087L258.291 129.865H255.495L258.291 135.454H254.097L251.301 129.865H248.505L251.301 135.454H247.107L244.311 129.865C242.738 129.865 241.515 131.087 241.515 132.659V149.34C241.515 150.912 242.738 152.135 244.311 152.135H266.68C268.252 152.135 269.476 150.912 269.476 149.34V132.659C269.476 131.087 268.252 129.865 266.68 129.865Z" />
+    <path
+        android:fillColor="#FDD663"
+        android:pathData="M257.155 98.9488H240.204V96.8528C240.204 96.0668 239.592 95.3682 238.718 95.3682H233.825C233.039 95.3682 232.34 95.9795 232.34 96.8528V116.416C232.34 118.075 233.65 119.385 235.223 119.385H255.67C257.33 119.385 258.641 118.075 258.641 116.503V100.434C258.553 99.5602 257.854 98.9488 257.155 98.9488Z" />
+    <path
+        android:fillColor="#8AB4F8"
+        android:pathData="M295.34 97.4639H274.631V112.311H272.184C269.738 112.223 267.641 114.057 267.553 116.503C267.466 118.948 269.301 121.044 271.748 121.131C271.835 121.131 272.01 121.131 272.184 121.131H273.146C275.417 121.131 277.34 119.385 277.427 117.114V102.005H289.748V112.398H287.301C284.854 112.398 282.845 114.407 282.845 116.852C282.845 119.297 284.854 121.306 287.301 121.306H288.262C290.534 121.306 292.456 119.559 292.544 117.289V101.743C294.204 100.957 295.252 99.2979 295.34 97.4639Z" />
+    <path
+        android:fillColor="#81C995"
+        android:pathData="M293.854 146.196H283.282C282.233 146.196 281.359 145.322 281.359 144.274V130.825C281.359 129.777 282.233 128.904 283.282 128.904H296.738C297.786 128.904 298.66 129.777 298.66 130.825V141.392L293.854 146.196Z" />
+    <path
+        android:fillColor="#81C995"
+        android:pathData="M292.893 144.275V142.353C292.893 141.305 293.767 140.432 294.816 140.432H296.738V130.825H283.282V144.275H292.893Z" />
+    <path
+        android:fillColor="#81C995"
+        android:pathData="M292.893 144.275L296.738 140.432H294.816C293.767 140.432 292.893 141.305 292.893 142.353V144.275Z" />
+    <path
+        android:fillColor="@android:color/transparent"
+        android:pathData="M292.893 144.275H283.282V130.825H296.738V140.432H294.816C293.767 140.432 292.893 141.305 292.893 142.353V144.275Z" />
+    <path
+        android:fillColor="#F28B82"
+        android:pathData="M219.146 103.49L206.651 96.4158C205.951 95.9791 205.078 96.1538 204.641 96.8525C204.641 96.9398 204.553 96.9398 204.553 97.0271C204.379 97.2018 204.379 97.4638 204.379 97.9005V112.048C204.379 112.834 204.99 113.533 205.777 113.533H205.864C206.214 113.533 206.476 113.533 206.738 113.358L218.971 106.284C219.757 105.935 220.019 105.062 219.67 104.276C219.67 104.188 219.583 104.188 219.583 104.101C219.583 103.926 219.408 103.664 219.146 103.49Z" />
+    <path
+        android:fillColor="#8AB4F8"
+        android:pathData="M222.116 123.053H211.893C210.495 123.053 209.359 124.188 209.359 125.585V129.865H206.126C204.728 129.865 203.68 130.913 203.68 132.31L203.592 151.96C203.592 152.659 203.854 153.27 204.291 153.707C204.728 154.143 205.34 154.405 206.039 154.405L220.806 154.493C221.505 154.493 222.116 154.231 222.553 153.794C222.99 153.357 223.252 152.746 223.252 152.047V148.554H227.184C228.583 148.554 229.806 147.419 229.806 146.021C229.806 146.021 229.806 146.021 229.806 145.934V130.563L222.116 123.053ZM220.718 152.135L205.951 152.047L206.039 132.397H209.272V146.109C209.272 146.807 209.534 147.419 210.058 147.943C210.495 148.467 211.194 148.729 211.893 148.729H220.806L220.718 152.135ZM224.65 143.576H214.427V141.043H224.65V143.576ZM224.65 138.423H214.427V135.891H224.65V138.423ZM227.184 132.048H220.806V125.673L227.184 132.048Z" />
+    <path
         android:fillColor="?android:attr/colorAccent"
-        android:strokeWidth="1"/>
+        android:pathData="M107.126 114.669H109.66V112.136H107.126V114.669ZM117.087 114.669H119.621V112.136H117.087V114.669ZM107.126 109.691H109.66V104.713H107.126V109.691ZM112.107 114.669H114.641V109.691H112.107V114.669ZM112.107 107.158H114.641V104.626H112.107V107.158ZM117.087 109.691H119.621V104.713H117.087V109.691ZM105.903 118.424C105.204 118.424 104.592 118.162 104.155 117.726C103.718 117.289 103.456 116.678 103.456 115.979V101.045L110.971 93.5342H120.932C121.631 93.5342 122.243 93.7962 122.68 94.2328C123.204 94.7568 123.379 95.2808 123.379 95.9795V115.892C123.379 116.59 123.116 117.202 122.68 117.638C122.155 118.162 121.631 118.337 120.932 118.337L105.903 118.424ZM105.903 115.892H120.845V95.9795H111.932L105.903 102.006V115.892ZM105.903 115.892V102.006L111.932 95.9795H120.845V115.892H105.903Z" />
     <path
-        android:pathData="M63.99,69L60,73L63.99,77L63.99,74L71,74L71,72L63.99,72L63.99,69ZM78,67L74.01,63L74.01,66L67,66L67,68L74.01,68L74.01,71L78,67Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
         android:fillColor="?android:attr/colorAccent"
-        android:strokeWidth="1"/>
+        android:pathData="M96.7281 150.388L101.447 145.672L98.8252 143.052L89.7379 152.222L98.8252 161.305L101.447 158.772L96.7281 154.056H137.01V150.388H96.7281Z" />
     <path
-        android:pathData="M64,126.08C98.29,126.08 126.08,98.29 126.08,64C126.08,29.71 98.29,1.92 64,1.92C29.71,1.92 1.92,29.71 1.92,64C1.92,98.29 29.71,126.08 64,126.08ZM64,128C28.65,128 0,99.35 0,64C0,28.65 28.65,0 64,0C99.35,0 128,28.65 128,64C128,99.35 99.35,128 64,128Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
-        android:fillColor="#DADCE0"
-        android:strokeWidth="1"/>
-</vector>
+        android:fillColor="?android:attr/colorAccent"
+        android:pathData="M130.019 137.026L125.301 141.742L127.922 144.362L137.01 135.192L127.922 126.109L125.301 128.642L130.019 133.358H89.7379V137.026H130.019Z" />
+    <path
+        android:fillColor="#BDC1C6"
+        android:pathData="M237.67 71.1767C238.201 71.1767 238.631 70.7466 238.631 70.216C238.631 69.6855 238.201 69.2554 237.67 69.2554C237.139 69.2554 236.709 69.6855 236.709 70.216C236.709 70.7466 237.139 71.1767 237.67 71.1767Z" />
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_storage_wizard_internal.xml b/res/drawable/ic_storage_wizard_internal.xml
index 41768f7..70bafa9 100644
--- a/res/drawable/ic_storage_wizard_internal.xml
+++ b/res/drawable/ic_storage_wizard_internal.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
 <!--
     Copyright (C) 2018 The Android Open Source Project
 
@@ -14,62 +15,48 @@
     limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="144dp"
-        android:height="144dp"
-        android:viewportWidth="144.0"
-        android:viewportHeight="144.0">
+    android:width="360dp"
+    android:height="262dp"
+    android:viewportWidth="360"
+    android:viewportHeight="262">
+
     <path
-        android:pathData="M28,4h72v140h-72z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#FFFFFF"
-        android:strokeWidth="1"/>
+        android:fillColor="@android:color/transparent"
+        android:pathData="M335.691 262H24.3087C10.9485 262 0 250.795 0 237.127V24.9075C0 11.2049 10.9485 0 24.3087 0H335.787C349.051 0 360 11.2049 360 24.8725V237.224C360 250.795 349.051 262 335.691 262Z" />
     <path
-        android:pathData="M65,62L68,62L68,64L65,64L65,67L63,67L63,64L60,64L60,62L63,62L63,59L65,59L65,62Z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
+        android:fillColor="#DADCE0"
+        android:pathData="M239.199 85.3246V77.0192C239.199 76.4695 238.981 75.9421 238.593 75.5526C238.205 75.163 237.678 74.943 237.128 74.9407V31.3439C237.126 28.5906 236.031 25.9508 234.083 24.0039C232.135 22.057 229.494 20.9623 226.739 20.96H131.182C128.428 20.9646 125.789 22.0604 123.843 24.007C121.897 25.9536 120.803 28.5921 120.801 31.3439V230.656C120.803 233.408 121.897 236.046 123.843 237.993C125.789 239.94 128.428 241.035 131.182 241.04H226.739C229.494 241.038 232.135 239.943 234.083 237.996C236.031 236.049 237.126 233.409 237.128 230.656V128.921C237.677 128.921 238.204 128.703 238.592 128.315C238.981 127.927 239.199 127.401 239.199 126.852V106.084C239.199 105.534 238.981 105.007 238.593 104.617C238.205 104.228 237.678 104.008 237.128 104.005V87.4119C237.401 87.4108 237.671 87.3559 237.923 87.2503C238.175 87.1448 238.404 86.9908 238.596 86.7969C238.788 86.6031 238.941 86.3733 239.044 86.1207C239.148 85.8681 239.2 85.5976 239.199 85.3246ZM235.049 230.656C235.046 232.858 234.17 234.969 232.612 236.526C231.054 238.083 228.942 238.959 226.739 238.961H131.182C128.978 238.959 126.866 238.083 125.308 236.526C123.75 234.969 122.874 232.858 122.872 230.656V31.3439C122.874 29.1419 123.75 27.0307 125.308 25.4736C126.866 23.9166 128.978 23.0408 131.182 23.0385H226.739C228.942 23.0408 231.054 23.9166 232.612 25.4736C234.17 27.0307 235.046 29.1419 235.049 31.3439V230.656Z" />
+    <path
+        android:fillColor="#81C995"
+        android:pathData="M209.91 52.243H226.424V35.737H209.91V52.243ZM209.91 54.601C209.599 54.6045 209.29 54.5443 209.003 54.4242C208.716 54.304 208.457 54.1264 208.241 53.9023C208.018 53.6879 207.842 53.4299 207.723 53.1444C207.604 52.8589 207.545 52.5521 207.55 52.243V35.737C207.55 35.1116 207.799 34.5118 208.241 34.0696C208.684 33.6274 209.284 33.379 209.91 33.379H226.424C226.729 33.3764 227.03 33.4355 227.311 33.5526C227.592 33.6696 227.846 33.8423 228.058 34.0602C228.282 34.2758 228.46 34.5351 228.58 34.822C228.701 35.1088 228.761 35.4173 228.757 35.7283V52.2343C228.75 52.8575 228.5 53.4533 228.059 53.8941C227.618 54.3348 227.022 54.5854 226.398 54.5923L209.91 54.601ZM211.089 49.885H225.245L220.815 43.99L217.319 48.706L214.698 45.169L211.089 49.885ZM209.91 35.737V52.243V35.737Z" />
+    <path
+        android:fillColor="#8AB4F8"
+        android:pathData="M176.208 36.1475H148.247V56.2341H144.97C144.185 56.2341 143.408 56.3886 142.683 56.6888C141.958 56.989 141.299 57.429 140.744 57.9837C140.189 58.5384 139.749 59.197 139.448 59.9217C139.148 60.6465 138.993 61.4233 138.993 62.2077C138.993 62.9922 139.148 63.769 139.448 64.4937C139.749 65.2185 140.189 65.877 140.744 66.4317C141.299 66.9864 141.958 67.4264 142.683 67.7266C143.408 68.0268 144.185 68.1813 144.97 68.1813H146.316C147.789 68.1973 149.212 67.6454 150.289 66.6404C151.366 65.6354 152.015 64.2544 152.1 62.7841V42.3132H168.702V56.3826H165.425C163.84 56.3826 162.32 57.012 161.199 58.1322C160.078 59.2525 159.449 60.7719 159.449 62.3562C159.449 63.9405 160.078 65.4599 161.199 66.5802C162.32 67.7004 163.84 68.3298 165.425 68.3298H166.771C168.244 68.3457 169.667 67.7939 170.744 66.7889C171.822 65.7839 172.47 64.4029 172.555 62.9326V41.9202C173.622 41.3688 174.523 40.5434 175.165 39.5288C175.807 38.5143 176.167 37.3472 176.208 36.1475Z" />
+    <path
+        android:fillColor="#F28B82"
+        android:pathData="M160.96 79.0195H156.958L159.623 84.3556H155.621L152.913 79.0195H150.291L152.913 84.3556H148.911L146.237 79.0195H143.572L146.237 84.3556H142.235L139.561 79.0195C138.866 79.0195 138.199 79.2956 137.708 79.7869C137.216 80.2783 136.94 80.9447 136.94 81.6395V97.6565C136.94 98.3562 137.214 99.0282 137.704 99.5278C138.194 100.028 138.861 100.315 139.561 100.329H160.925C161.634 100.327 162.312 100.044 162.813 99.5436C163.314 99.0429 163.597 98.3645 163.599 97.6565V81.6832C163.597 80.982 163.319 80.3097 162.825 79.8114C162.332 79.3131 161.662 79.0287 160.96 79.0195Z" />
+    <path
+        android:fillColor="#8AB4F8"
+        android:pathData="M220.544 165.934H208.957C208.19 165.934 207.455 166.238 206.912 166.78C206.37 167.322 206.065 168.058 206.065 168.824V173.706H202.413C202.047 173.701 201.684 173.77 201.346 173.91C201.008 174.05 200.702 174.257 200.447 174.518C200.17 174.766 199.949 175.069 199.799 175.407C199.648 175.746 199.571 176.113 199.573 176.483L199.468 198.78C199.466 199.146 199.535 199.508 199.673 199.847C199.811 200.186 200.015 200.494 200.272 200.755C200.529 201.015 200.835 201.222 201.172 201.364C201.51 201.506 201.872 201.581 202.238 201.583L218.971 201.662C219.71 201.662 220.42 201.37 220.945 200.85C221.47 200.33 221.769 199.623 221.776 198.884V194.928H226.311C227.079 194.926 227.816 194.62 228.359 194.076C228.903 193.533 229.209 192.797 229.212 192.029V174.58L220.544 165.934ZM219.032 198.858L202.299 198.78L202.404 176.475H206.065V191.994C206.064 192.374 206.138 192.751 206.283 193.103C206.428 193.455 206.64 193.774 206.909 194.044C207.178 194.313 207.497 194.527 207.848 194.672C208.2 194.818 208.577 194.893 208.957 194.893H219.05L219.032 198.858ZM223.401 189.112H211.858V186.221H223.436L223.401 189.112ZM223.401 183.322H211.858V180.422H223.436L223.401 183.322ZM226.293 176.073H219.058V168.824L226.311 176.073H226.293Z" />
+    <path
+        android:fillColor="#CEEAD6"
+        android:pathData="M149.068 201.827C158.908 201.827 166.884 193.855 166.884 184.02C166.884 174.185 158.908 166.213 149.068 166.213C139.228 166.213 131.251 174.185 131.251 184.02C131.251 193.855 139.228 201.827 149.068 201.827Z" />
+    <path
+        android:fillColor="#5BB974"
+        android:pathData="M141.125 191.479C140.725 191.499 140.326 191.423 139.961 191.257C139.596 191.092 139.276 190.841 139.028 190.527C138.778 190.205 138.598 189.834 138.502 189.438C138.406 189.042 138.394 188.63 138.469 188.23L139.587 180.239C139.726 179.221 140.233 178.289 141.012 177.619C141.775 176.936 142.766 176.565 143.79 176.58H154.346C155.37 176.565 156.361 176.936 157.124 177.619C157.903 178.289 158.41 179.221 158.549 180.239L159.667 188.23C159.742 188.63 159.73 189.042 159.634 189.438C159.537 189.834 159.358 190.205 159.108 190.527C158.859 190.842 158.538 191.094 158.171 191.26C157.805 191.425 157.404 191.5 157.002 191.479C156.648 191.48 156.298 191.412 155.971 191.278C155.641 191.14 155.343 190.935 155.097 190.675L152.703 188.282H145.45L143.056 190.675C142.809 190.933 142.512 191.139 142.183 191.278C141.847 191.415 141.488 191.483 141.125 191.479ZM141.553 189.182L144.594 186.151H153.542L156.583 189.182C156.71 189.264 156.853 189.321 157.002 189.348C157.088 189.352 157.175 189.339 157.256 189.309C157.337 189.279 157.411 189.233 157.474 189.173C157.531 189.112 157.573 189.038 157.594 188.957C157.616 188.876 157.616 188.791 157.596 188.71L156.408 180.51C156.34 180.008 156.093 179.548 155.713 179.214C155.332 178.88 154.843 178.695 154.337 178.693H143.79C143.284 178.695 142.795 178.88 142.414 179.214C142.034 179.548 141.787 180.008 141.719 180.51L140.54 188.71C140.52 188.791 140.52 188.876 140.542 188.957C140.563 189.038 140.604 189.112 140.662 189.173C140.723 189.232 140.796 189.278 140.876 189.308C140.955 189.338 141.04 189.351 141.125 189.348C141.274 189.311 141.418 189.255 141.553 189.182ZM154.398 185.086C154.539 185.087 154.678 185.061 154.809 185.009C154.939 184.956 155.058 184.879 155.158 184.78C155.258 184.681 155.337 184.563 155.39 184.432C155.443 184.301 155.468 184.161 155.464 184.02C155.466 183.88 155.44 183.74 155.388 183.61C155.335 183.479 155.257 183.361 155.157 183.262C155.058 183.162 154.939 183.084 154.809 183.031C154.678 182.978 154.539 182.952 154.398 182.955C154.257 182.952 154.118 182.978 153.987 183.031C153.857 183.084 153.738 183.162 153.639 183.262C153.54 183.361 153.461 183.479 153.408 183.61C153.356 183.74 153.33 183.88 153.332 184.02C153.327 184.161 153.351 184.302 153.404 184.433C153.457 184.564 153.536 184.682 153.638 184.78C153.737 184.88 153.856 184.959 153.986 185.012C154.117 185.064 154.257 185.089 154.398 185.086ZM152.266 181.889C152.407 181.891 152.546 181.865 152.677 181.812C152.807 181.76 152.926 181.682 153.026 181.584C153.126 181.485 153.205 181.366 153.258 181.235C153.31 181.105 153.336 180.965 153.332 180.824C153.334 180.683 153.308 180.544 153.256 180.413C153.203 180.283 153.125 180.165 153.025 180.065C152.926 179.966 152.807 179.887 152.677 179.835C152.546 179.782 152.407 179.756 152.266 179.758C152.125 179.755 151.985 179.78 151.854 179.833C151.723 179.885 151.605 179.964 151.506 180.064C151.407 180.164 151.329 180.283 151.277 180.413C151.224 180.544 151.198 180.683 151.2 180.824C151.198 180.964 151.224 181.104 151.276 181.234C151.329 181.365 151.407 181.483 151.507 181.583C151.606 181.682 151.725 181.76 151.855 181.813C151.986 181.866 152.125 181.892 152.266 181.889ZM144.542 185.086H146.141V183.226H148.002V181.654H146.141V179.785H144.542V181.654H142.672V183.252H144.542V185.086ZM141.553 189.182C141.504 189.238 141.441 189.28 141.37 189.304C141.292 189.333 141.209 189.348 141.125 189.348C141.04 189.351 140.955 189.338 140.876 189.308C140.796 189.278 140.723 189.232 140.662 189.173C140.604 189.112 140.563 189.038 140.542 188.957C140.52 188.876 140.52 188.791 140.54 188.71L141.719 180.51C141.787 180.008 142.034 179.548 142.414 179.214C142.795 178.88 143.284 178.695 143.79 178.693H154.346C154.852 178.695 155.341 178.88 155.721 179.214C156.102 179.548 156.349 180.008 156.417 180.51L157.596 188.71C157.616 188.791 157.616 188.876 157.594 188.957C157.573 189.038 157.531 189.112 157.474 189.173C157.411 189.233 157.337 189.279 157.256 189.309C157.175 189.339 157.088 189.352 157.002 189.348C156.921 189.348 156.841 189.333 156.766 189.304C156.695 189.28 156.632 189.238 156.583 189.182L153.542 186.151H144.594L141.553 189.182Z" />
+    <path
+        android:fillColor="#FEEFC3"
+        android:pathData="M197.301 94.1194C207.141 94.1194 215.117 86.1468 215.117 76.3121C215.117 66.4775 207.141 58.5049 197.301 58.5049C187.461 58.5049 179.484 66.4775 179.484 76.3121C179.484 86.1468 187.461 94.1194 197.301 94.1194Z" />
+    <path
+        android:fillColor="#FBBC04"
+        android:pathData="M202.22 85.2464V78.1025H199.538V71.8407C199.537 71.2536 199.652 70.672 199.876 70.1295C200.101 69.587 200.43 69.0941 200.846 68.6794C201.262 68.2646 201.756 67.9362 202.299 67.7128C202.842 67.4895 203.424 67.3757 204.012 67.378V85.2464H202.22ZM193.282 85.2464V77.072C192.524 76.871 191.851 76.4334 191.359 75.8231C190.849 75.2077 190.576 74.4301 190.59 73.631V67.378H192.338V73.631H193.212V67.378H194.959V73.631H195.833V67.378H197.581V73.631C197.594 74.4301 197.322 75.2077 196.812 75.8231C196.323 76.4319 195.652 76.8693 194.898 77.072V85.2464H193.282Z" />
+    <path
+        android:fillColor="#FAD2CF"
+        android:pathData="M179.38 231.914C189.219 231.914 197.196 223.941 197.196 214.107C197.196 204.272 189.219 196.299 179.38 196.299C169.54 196.299 161.563 204.272 161.563 214.107C161.563 223.941 169.54 231.914 179.38 231.914Z" />
+    <path
+        android:fillColor="#EE675C"
+        android:pathData="M187.611 212.814L176.077 206.255C175.911 206.151 175.724 206.082 175.53 206.056C175.335 206.029 175.138 206.044 174.95 206.101C174.762 206.157 174.588 206.253 174.44 206.382C174.292 206.511 174.174 206.671 174.093 206.849C173.892 207.05 173.892 207.251 173.892 207.653V220.753C173.887 220.936 173.92 221.119 173.988 221.29C174.056 221.46 174.158 221.615 174.288 221.745C174.418 221.875 174.574 221.977 174.744 222.045C174.915 222.113 175.098 222.146 175.282 222.141C175.561 222.171 175.842 222.103 176.077 221.949L187.436 215.39C187.615 215.308 187.774 215.189 187.903 215.041C188.033 214.893 188.129 214.719 188.186 214.531C188.243 214.342 188.26 214.144 188.234 213.949C188.209 213.754 188.142 213.567 188.039 213.399C188.013 213.216 187.812 213.015 187.611 212.814Z" />
+    <path
         android:fillColor="?android:attr/colorAccent"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M81.63,56L76.13,56L72.01,60.2L72,68.6C72,69.37 72.62,70 73.38,70L81.63,70C82.38,70 83,69.37 83,68.6L83,57.4C83,56.63 82.38,56 81.63,56ZM77.5,60.2L76.13,60.2L76.13,57.4L77.5,57.4L77.5,60.2ZM79.56,60.2L78.19,60.2L78.19,57.4L79.56,57.4L79.56,60.2ZM81.63,60.2L80.25,60.2L80.25,57.4L81.63,57.4L81.63,60.2Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
-        android:fillColor="?android:attr/colorAccent"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M39,77L87,77A4,4 0,0 1,91 81L91,81A4,4 0,0 1,87 85L39,85A4,4 0,0 1,35 81L35,81A4,4 0,0 1,39 77z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="?android:attr/colorAccent"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M32,77h31v8h-31z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#DADCE0"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M29,144L97,144L97,6L29,6L29,144ZM27.95,150C25.21,150 23,147.88 23,145.24L23,4.76C23,2.12 25.21,0 27.95,0L98.05,0C100.79,0 103,2.12 103,4.76L103,145.24C103,147.88 100.79,150 98.05,150L27.95,150Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
-        android:fillColor="#F1F3F4"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M27.95,148L98.05,148C99.7,148 101,146.75 101,145.24L101,4.76C101,3.25 99.7,2 98.05,2L27.95,2C26.3,2 25,3.25 25,4.76L25,145.24C25,146.75 26.3,148 27.95,148ZM27.95,150C25.21,150 23,147.88 23,145.24L23,4.76C23,2.12 25.21,0 27.95,0L98.05,0C100.79,0 103,2.12 103,4.76L103,145.24C103,147.88 100.79,150 98.05,150L27.95,150Z"
-        android:strokeColor="#00000000"
-        android:fillType="nonZero"
-        android:fillColor="#DADCE0"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M103,58L103,58C104.1,58 105,58.9 105,60L105,76C105,77.1 104.1,78 103,78L103,58Z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#DADCE0"
-        android:strokeWidth="1"/>
-    <path
-        android:pathData="M103,32L103,32C104.1,32 105,32.9 105,34L105,40C105,41.1 104.1,42 103,42L103,32Z"
-        android:strokeColor="#00000000"
-        android:fillType="evenOdd"
-        android:fillColor="#DADCE0"
-        android:strokeWidth="1"/>
-</vector>
+        android:pathData="M164.604 152.545H170.764V146.432H164.604V152.545ZM189.236 152.545H195.396V146.432H189.236V152.545ZM164.604 140.231H170.764V127.926H164.604V140.231ZM176.924 152.545H183.041V140.231H176.924V152.545ZM176.924 134.074H183.041V127.961H176.924V134.074ZM189.236 140.187H195.396V127.926H189.236V140.187ZM161.528 161.733C159.896 161.728 158.332 161.078 157.177 159.924C156.023 158.77 155.373 157.207 155.368 155.576V118.695L173.883 100.224H198.516C200.14 100.228 201.698 100.872 202.851 102.017C204.004 103.161 204.66 104.713 204.676 106.337V155.576C204.671 157.207 204.021 158.77 202.866 159.924C201.712 161.078 200.148 161.728 198.516 161.733H161.528ZM161.528 155.576H198.472V106.381H176.505L161.528 121.306V155.619V155.576ZM161.528 155.576V121.306L176.505 106.381H198.516V155.619H161.528V155.576Z" />
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_storage_wizard_ready.xml b/res/drawable/ic_storage_wizard_ready.xml
new file mode 100644
index 0000000..c09c9ec
--- /dev/null
+++ b/res/drawable/ic_storage_wizard_ready.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2022 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="360dp"
+    android:height="262dp"
+    android:viewportWidth="360"
+    android:viewportHeight="262">
+
+ <path
+     android:fillColor="?android:attr/colorBackground"
+     android:pathData="M335.709 262H24.2913C10.9223 262 0 250.821 0 237.11V24.89C0 11.1787 10.9223 0 24.2913 0H335.796C349.078 0 360 11.1787 360 24.89V237.285C360 250.821 349.078 262 335.709 262Z" />
+ <path
+     android:fillColor="?android:attr/colorAccent"
+     android:pathData="M157.282 160.169H165.67V151.785H157.282V160.169ZM190.835 160.169H199.223V151.785H190.835V160.169ZM157.282 143.401H165.67V126.633H157.282V143.401ZM174.058 160.169H182.447V143.401H174.058V160.169ZM174.058 135.017H182.447V126.633H174.058V135.017ZM190.835 143.401H199.223V126.633H190.835V143.401ZM153.087 172.745C148.456 172.745 144.699 168.99 144.699 164.361V114.057L169.864 88.9053H203.417C208.049 88.9053 211.806 92.6606 211.806 97.2893V164.449C211.806 169.077 208.049 172.833 203.417 172.833L153.087 172.745ZM153.087 164.361H203.417V97.2019H173.359L153 117.551L153.087 164.361ZM153.087 164.361V117.551L173.447 97.2019H203.417V164.361H153.087Z" />
+ <path
+     android:fillColor="?android:attr/colorAccent"
+     android:pathData="M273.233 130.825C273.146 79.386 231.466 37.728 180 37.728C128.534 37.728 86.8544 79.4734 86.8544 130.913C86.8544 182.352 128.534 223.923 180 223.923C231.466 223.923 273.233 182.265 273.233 130.825ZM180 215.189C133.34 215.189 95.5922 177.374 95.5922 130.738C95.5922 84.102 133.427 46.374 180.087 46.374C226.748 46.374 264.495 84.1894 264.495 130.738C264.408 177.374 226.66 215.189 180 215.189Z" />
+ <path
+     android:fillColor="?android:attr/colorBackground"
+     android:pathData="M264.043 194.685C265.976 182.783 257.889 171.568 245.98 169.636C234.071 167.704 222.85 175.787 220.917 187.69C218.985 199.593 227.072 210.808 238.981 212.739C250.89 214.671 262.11 206.588 264.043 194.685Z" />
+ <path
+     android:fillColor="?android:attr/colorAccent"
+     android:pathData="M242.476 166.981C229.107 166.981 218.184 177.811 218.184 191.26C218.184 204.709 229.019 215.539 242.476 215.539C255.845 215.539 266.68 204.709 266.767 191.347C266.68 177.898 255.845 166.981 242.476 166.981ZM242.476 210.648C231.728 210.648 223.078 202.002 223.078 191.26C223.078 180.518 231.728 171.872 242.476 171.872C253.223 171.872 261.874 180.518 261.874 191.26C261.786 201.915 253.136 210.648 242.476 210.648ZM237.582 196.587L231.291 190.299L227.883 193.705L237.582 203.399L256.981 184.011L253.573 180.605L237.582 196.587Z" />
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_swap_horiz.xml b/res/drawable/ic_swap_horiz.xml
index a38833b..c41c9a3 100644
--- a/res/drawable/ic_swap_horiz.xml
+++ b/res/drawable/ic_swap_horiz.xml
@@ -20,5 +20,5 @@
         android:viewportHeight="24.0">
     <path
         android:pathData="M6.99,11L3,15l3.99,4v-3H14v-2H6.99v-3zM21,9l-3.99,-4v3H10v2h7.01v3L21,9z"
-        android:fillColor="#000000"/>
+        android:fillColor="?android:attr/textColorPrimary"/>
 </vector>
diff --git a/res/drawable/ic_test_tick.xml b/res/drawable/ic_test_tick.xml
new file mode 100644
index 0000000..9585806
--- /dev/null
+++ b/res/drawable/ic_test_tick.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright 2022 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="48dp"
+    android:height="48dp"
+    android:viewportWidth="48"
+    android:viewportHeight="48">
+
+  <path
+      android:fillColor="?android:attr/colorAccent"
+      android:pathData="M7.99999 14.6L2.39999 8.99999L0.533325 10.8667L7.99999 18.3333L24 2.33333L22.1333 0.46666L7.99999 14.6Z" />
+</vector>
\ No newline at end of file
diff --git a/res/layout-land/udfps_enroll_enrolling_land.xml b/res/layout-land/udfps_enroll_enrolling.xml
similarity index 93%
rename from res/layout-land/udfps_enroll_enrolling_land.xml
rename to res/layout-land/udfps_enroll_enrolling.xml
index 776f8a9..f323788 100644
--- a/res/layout-land/udfps_enroll_enrolling_land.xml
+++ b/res/layout-land/udfps_enroll_enrolling.xml
@@ -33,11 +33,15 @@
         <!-- Both texts are kept as separate text views so it doesn't jump around in portrait.
             See layouts/fingerprint_enroll_enrolling_base.xml. -->
         <LinearLayout
+            android:id="@+id/layout_container"
             android:layout_width="0dp"
             android:layout_weight="1"
             android:layout_height="match_parent"
             android:layout_marginStart="?attr/sudMarginStart"
+            android:layout_marginEnd="@dimen/enroll_margin_end"
             android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
+            android:paddingStart="@dimen/enroll_padding_start"
+            android:paddingEnd="@dimen/enroll_padding_end"
             android:clipChildren="false"
             android:clipToPadding="false"
             android:orientation="vertical">
diff --git a/res/layout/storage_internal_format.xml b/res/layout/storage_internal_format.xml
index 0b49d7e..f8224c4 100644
--- a/res/layout/storage_internal_format.xml
+++ b/res/layout/storage_internal_format.xml
@@ -14,16 +14,16 @@
      limitations under the License.
 -->
 
-<LinearLayout
+<androidx.core.widget.NestedScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
+    android:layout_height="wrap_content"
+    android:fillViewport="true">
 
-    <androidx.core.widget.NestedScrollView
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1">
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
         <TextView
             android:id="@+id/body"
             android:layout_width="match_parent"
@@ -35,19 +35,21 @@
             android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
             android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
             android:textColor="?android:attr/textColorPrimary" />
-    </androidx.core.widget.NestedScrollView>
 
-    <FrameLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:padding="4dp">
-        <Button
-            android:id="@+id/confirm"
+        <FrameLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="@string/storage_menu_format"
-            android:textColor="@android:color/white"
-            android:backgroundTint="@color/storage_wizard_button_red" />
-    </FrameLayout>
+            android:padding="4dp">
+            <Button
+                style="@style/ActionPrimaryButton"
+                android:id="@+id/confirm"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:text="@string/storage_menu_format_button"
+                android:textColor="@android:color/white"
+                android:backgroundTint="@color/storage_wizard_button_red" />
+        </FrameLayout>
+  </LinearLayout>
 
-</LinearLayout>
+</androidx.core.widget.NestedScrollView>
diff --git a/res/layout/storage_wizard_generic.xml b/res/layout/storage_wizard_generic.xml
index e7881d3..fc0bab1 100644
--- a/res/layout/storage_wizard_generic.xml
+++ b/res/layout/storage_wizard_generic.xml
@@ -14,32 +14,52 @@
      limitations under the License.
 -->
 
-<com.google.android.setupdesign.GlifLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/setup_wizard_layout"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/storage_wizard_container"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="wrap_content"
+    android:fitsSystemWindows="true">
 
-    <LinearLayout
-        style="@style/SudContentFrame"
+   <com.google.android.setupdesign.GlifLayout
+        android:id="@+id/setup_wizard_layout"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+        android:layout_height="match_parent">
 
-        <TextView
-            android:id="@+id/storage_wizard_body"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/sud_description_margin_top"
-            android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
-            android:textColor="?android:attr/textColorPrimary" />
+      <LinearLayout
+          style="@style/SudContentFrame"
+          android:layout_width="match_parent"
+          android:layout_height="match_parent"
+          android:orientation="vertical">
 
-        <FrameLayout
-            android:id="@+id/storage_wizard_aux"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:visibility="gone" />
+          <TextView
+              android:id="@+id/storage_wizard_body"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:layout_marginTop="@dimen/sud_description_margin_top"
+              android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
+              android:textSize="18sp"
+              android:textColor="?android:attr/textColorSecondary" />
 
-    </LinearLayout>
+          <FrameLayout
+              android:id="@+id/storage_wizard_aux"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:visibility="gone" />
 
-</com.google.android.setupdesign.GlifLayout>
+          <LinearLayout
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:layout_marginTop="@dimen/setup_completion_margin_top"
+              android:orientation="vertical"
+              android:gravity="center_horizontal">
+              <ImageView
+                  android:id="@+id/storage_wizard_body_image"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:scaleType="centerInside"/>
+          </LinearLayout>
+
+      </LinearLayout>
+
+  </com.google.android.setupdesign.GlifLayout>
+</RelativeLayout>
diff --git a/res/layout/storage_wizard_init.xml b/res/layout/storage_wizard_init.xml
index e1e78331..2d21e0e 100644
--- a/res/layout/storage_wizard_init.xml
+++ b/res/layout/storage_wizard_init.xml
@@ -14,124 +14,30 @@
      limitations under the License.
 -->
 
-<com.google.android.setupdesign.GlifLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/setup_wizard_layout"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/storage_wizard_container"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="wrap_content"
+    android:fitsSystemWindows="true">
 
-    <LinearLayout
-        style="@style/SudContentFrame"
+   <com.google.android.setupdesign.GlifLayout
+        android:id="@+id/setup_wizard_layout"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+        android:layout_height="match_parent">
+      <LinearLayout
+          style="@style/SudContentFrame"
+          android:id="@+id/storage_wizard_init"
+          android:layout_width="match_parent"
+          android:layout_height="match_parent"
+          android:orientation="vertical">
+          <ViewFlipper
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+              android:id="@+id/viewFlipper">
+              <include layout = "@layout/storage_wizard_init_external" />
+              <include layout = "@layout/storage_wizard_init_internal" />
+          </ViewFlipper>
+      </LinearLayout>
 
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/sud_description_margin_top"
-            android:orientation="horizontal"
-            android:gravity="center_vertical">
-            <ImageView
-                android:layout_width="144dp"
-                android:layout_height="144dp"
-                android:scaleType="centerInside"
-                android:src="@drawable/ic_storage_wizard_internal" />
-            <LinearLayout
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:layout_marginStart="@dimen/sud_glif_margin_start"
-                android:orientation="vertical">
-                <TextView
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginBottom="@dimen/sud_description_margin_bottom"
-                    android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
-                    android:text="@string/storage_wizard_init_v2_internal_title" />
-                <TextView
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginBottom="@dimen/sud_description_margin_bottom"
-                    android:textColor="?android:attr/textColorSecondary"
-                    android:text="@string/storage_wizard_init_v2_internal_summary" />
-                <Button
-                    android:id="@+id/storage_wizard_init_internal"
-                    style="@style/SudGlifButton.Primary"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/storage_wizard_init_v2_internal_action"
-                    android:onClick="onNavigateInternal" />
-            </LinearLayout>
-        </LinearLayout>
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/sud_description_margin_top"
-            android:orientation="horizontal"
-            android:gravity="center_vertical">
-            <View
-                android:layout_width="0dp"
-                android:layout_height="1dp"
-                android:layout_weight="1"
-                android:background="@android:color/black"
-                android:backgroundTint="?android:attr/textColorTertiary" />
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="8dp"
-                android:layout_marginEnd="8dp"
-                android:text="@string/storage_wizard_init_v2_or"
-                android:textColor="?android:attr/textColorTertiary"
-                android:textAllCaps="true" />
-            <View
-                android:layout_width="0dp"
-                android:layout_height="1dp"
-                android:layout_weight="1"
-                android:background="@android:color/black"
-                android:backgroundTint="?android:attr/textColorTertiary" />
-        </LinearLayout>
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/sud_description_margin_top"
-            android:orientation="horizontal"
-            android:gravity="center_vertical">
-            <ImageView
-                android:layout_width="144dp"
-                android:layout_height="144dp"
-                android:scaleType="centerInside"
-                android:src="@drawable/ic_storage_wizard_external" />
-            <LinearLayout
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:layout_marginStart="@dimen/sud_glif_margin_start"
-                android:orientation="vertical">
-                <TextView
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginBottom="@dimen/sud_description_margin_bottom"
-                    android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
-                    android:text="@string/storage_wizard_init_v2_external_title" />
-                <TextView
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginBottom="@dimen/sud_description_margin_bottom"
-                    android:textColor="?android:attr/textColorSecondary"
-                    android:text="@string/storage_wizard_init_v2_external_summary" />
-                <Button
-                    android:id="@+id/storage_wizard_init_external"
-                    style="@style/SudGlifButton.Primary"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/storage_wizard_init_v2_external_action"
-                    android:onClick="onNavigateExternal" />
-            </LinearLayout>
-        </LinearLayout>
-
-    </LinearLayout>
-
-</com.google.android.setupdesign.GlifLayout>
+  </com.google.android.setupdesign.GlifLayout>
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/storage_wizard_init_external.xml b/res/layout/storage_wizard_init_external.xml
new file mode 100644
index 0000000..38df28b
--- /dev/null
+++ b/res/layout/storage_wizard_init_external.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginTop="@dimen/sud_description_margin_top"
+    android:orientation="vertical">
+    <TextView
+       android:id="@+id/storage_wizard_init_external_text"
+       android:layout_width="wrap_content"
+       android:layout_height="wrap_content"
+       android:layout_marginBottom="32dp"
+       android:textColor="?android:attr/textColorSecondary"
+       android:textSize="18sp"
+       android:text="@string/storage_wizard_init_v2_external_summary" />
+    <ImageView
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:scaleType="centerInside"
+          android:src="@drawable/ic_storage_wizard_external" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/storage_wizard_init_internal.xml b/res/layout/storage_wizard_init_internal.xml
new file mode 100644
index 0000000..0a18070
--- /dev/null
+++ b/res/layout/storage_wizard_init_internal.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
+     android:layout_width="match_parent"
+     android:layout_height="wrap_content"
+     android:layout_marginTop="@dimen/sud_description_margin_top"
+     android:orientation="vertical">
+     <TextView
+        android:id="@+id/storage_wizard_init_internal_text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="32dp"
+        android:textColor="?android:attr/textColorSecondary"
+        android:textSize="18sp"
+        android:text="@string/storage_wizard_init_v2_internal_summary" />
+     <ImageView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:scaleType="centerInside"
+        android:src="@drawable/ic_storage_wizard_internal" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/storage_wizard_progress.xml b/res/layout/storage_wizard_progress.xml
index 577ec3c..890be70 100644
--- a/res/layout/storage_wizard_progress.xml
+++ b/res/layout/storage_wizard_progress.xml
@@ -14,47 +14,55 @@
      limitations under the License.
 -->
 
-<com.google.android.setupdesign.GlifLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/setup_wizard_layout"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/storage_wizard_container"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="wrap_content"
+    android:fitsSystemWindows="true">
 
-    <LinearLayout
-        style="@style/SudContentFrame"
+   <com.google.android.setupdesign.GlifLayout
+        android:id="@+id/setup_wizard_layout"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
+        android:layout_height="match_parent">
 
-        <ProgressBar
-            android:id="@+id/storage_wizard_progress"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/sud_description_margin_top"
-            android:indeterminate="false"
-            style="?android:attr/progressBarStyleHorizontal" />
-        <TextView
-            android:id="@+id/storage_wizard_progress_summary"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
-            android:textColor="?android:attr/textColorSecondary" />
+      <LinearLayout
+          style="@style/SudContentFrame"
+          android:layout_width="match_parent"
+          android:layout_height="match_parent"
+          android:orientation="vertical">
 
-        <TextView
-            android:id="@+id/storage_wizard_body"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/sud_description_margin_top"
-            android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
-            android:textColor="?android:attr/textColorPrimary"
-            android:visibility="gone" />
+          <ProgressBar
+              android:id="@+id/storage_wizard_progress"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:layout_marginTop="@dimen/sud_description_margin_top"
+              android:indeterminate="false"
+              style="?android:attr/progressBarStyleHorizontal" />
+          <TextView
+              android:id="@+id/storage_wizard_progress_summary"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
+              android:textSize="18sp"
+              android:textColor="?android:attr/textColorSecondary" />
 
-        <FrameLayout
-            android:id="@+id/storage_wizard_aux"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:visibility="gone" />
+          <TextView
+              android:id="@+id/storage_wizard_body"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:layout_marginTop="@dimen/sud_description_margin_top"
+              android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
+              android:textColor="?android:attr/textColorPrimary"
+              android:textSize="18sp"
+              android:visibility="gone" />
 
-    </LinearLayout>
+          <FrameLayout
+              android:id="@+id/storage_wizard_aux"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:visibility="gone" />
 
-</com.google.android.setupdesign.GlifLayout>
+      </LinearLayout>
+
+  </com.google.android.setupdesign.GlifLayout>
+</RelativeLayout>
diff --git a/res/menu/storage_volume.xml b/res/menu/storage_volume.xml
index 422355d..b8725fb 100644
--- a/res/menu/storage_volume.xml
+++ b/res/menu/storage_volume.xml
@@ -29,10 +29,10 @@
         android:title="@string/storage_menu_format" />
     <item
         android:id="@+id/storage_format_as_portable"
-        android:title="@string/storage_menu_format_public" />
+        android:title="@string/storage_menu_format_option" />
     <item
         android:id="@+id/storage_format_as_internal"
-        android:title="@string/storage_menu_format_private" />
+        android:title="@string/storage_menu_format_option" />
     <item
         android:id="@+id/storage_migrate"
         android:title="@string/storage_menu_migrate" />
diff --git a/res/values-ldltr/dimens.xml b/res/values-ldltr/dimens.xml
new file mode 100755
index 0000000..11d5b33
--- /dev/null
+++ b/res/values-ldltr/dimens.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+
+<resources>
+    <!-- Biometrics UDFPS enroll landscape dimensions-->
+    <dimen name="enroll_padding_start">0dp</dimen>
+    <dimen name="enroll_padding_end">0dp</dimen>
+    <dimen name="enroll_margin_end">0dp</dimen>
+
+    <dimen name="rotation_90_enroll_padding_start">-290dp</dimen>
+    <dimen name="rotation_90_enroll_padding_end">108dp</dimen>
+    <dimen name="rotation_90_enroll_margin_end">150dp</dimen>
+</resources>
diff --git a/res/values-ldrtl/dimens.xml b/res/values-ldrtl/dimens.xml
new file mode 100755
index 0000000..cbe7eb5
--- /dev/null
+++ b/res/values-ldrtl/dimens.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+
+<resources>
+    <!-- Biometrics UDFPS enroll landscape RTL dimensions-->
+    <dimen name="enroll_padding_start">-440dp</dimen>
+    <dimen name="enroll_padding_end">320dp</dimen>
+    <dimen name="enroll_margin_end">150dp</dimen>
+
+    <dimen name="rotation_90_enroll_padding_start">20dp</dimen>
+    <dimen name="rotation_90_enroll_padding_end">0dp</dimen>
+    <dimen name="rotation_90_enroll_margin_end">20dp</dimen>
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 00117d7..efde863 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -596,6 +596,9 @@
     <!-- Whether to aggregate for network selection list-->
     <bool name="config_network_selection_list_aggregation_enabled">false</bool>
 
+    <!-- Max network scan search time in seconds -->
+    <integer name="config_network_scan_helper_max_search_time_sec">300</integer>
+
     <!-- Whether to give option to add restricted profiles -->
     <bool name="config_offer_restricted_profiles">false</bool>
 
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 26ebbf6..c035320 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -494,8 +494,18 @@
     <dimen name="sims_select_margin_bottom">24dp</dimen>
     <dimen name="sims_select_margin_top">8dp</dimen>
 
+    <!-- Biometrics UDFPS enroll default dimensions-->
+    <dimen name="enroll_padding_start">0dp</dimen>
+    <dimen name="enroll_padding_end">0dp</dimen>
+    <dimen name="enroll_margin_end">0dp</dimen>
+    <dimen name="rotation_90_enroll_padding_start">0dp</dimen>
+    <dimen name="rotation_90_enroll_padding_end">0dp</dimen>
+    <dimen name="rotation_90_enroll_margin_end">0dp</dimen>
+
     <!-- QR code picture size -->
     <dimen name="qrcode_preview_margin">40dp</dimen>
     <dimen name="qrcode_preview_radius">30dp</dimen>
     <dimen name="qrcode_icon_size">27dp</dimen>
+    <!-- Margin for SD card setup completion Image -->
+    <dimen name="setup_completion_margin_top">88dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index eb5bdde..067e43d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3512,12 +3512,14 @@
     <string name="storage_menu_mount">Mount</string>
     <!-- Storage setting.  Menu option for unmounting a storage device [CHAR LIMIT=30]-->
     <string name="storage_menu_unmount">Eject</string>
-    <!-- Storage setting.  Menu option for erasing and formatting a storage device [CHAR LIMIT=30]-->
-    <string name="storage_menu_format">Format</string>
+    <!-- Storage setting.  Menu option for erasing and formatting a storage device [CHAR LIMIT=50]-->
+    <string name="storage_menu_format">Format SD card for portable storage</string>
+    <!-- Storage setting.  Button option for erasing and formatting a storage device [CHAR LIMIT=30]-->
+    <string name="storage_menu_format_button">Format card</string>
     <!-- Storage setting.  Menu option for erasing and formatting a storage device [CHAR LIMIT=30]-->
     <string name="storage_menu_format_public">Format as portable</string>
-    <!-- Storage setting.  Menu option for erasing and formatting a storage device [CHAR LIMIT=30]-->
-    <string name="storage_menu_format_private">Format as internal</string>
+    <!-- Storage setting.  Menu option for erasing and formatting a storage device [CHAR LIMIT=20]-->
+    <string name="storage_menu_format_option">Format</string>
     <!-- Storage setting.  Menu option for migrating data to a storage device [CHAR LIMIT=30]-->
     <string name="storage_menu_migrate">Migrate data</string>
     <!-- Storage setting.  Menu option for forgetting a storage device [CHAR LIMIT=30]-->
@@ -3590,8 +3592,10 @@
 \n\nTo use this <xliff:g id="name" example="SD card">^1</xliff:g>, you have to set it up first.</string>
 
     <!-- Body of dialog informing user about consequences of formatting an internal storage device [CHAR LIMIT=NONE]-->
-    <string name="storage_internal_format_details">After formatting, you can use this <xliff:g id="name" example="SD card">^1</xliff:g> in other devices.
-\n\nAll data on this <xliff:g id="name" example="SD card">^1</xliff:g> will be erased. Consider backing up first.
+    <string name="storage_internal_format_details">You can format this SD card to store photos, videos, music,
+        and more and access them on other devices.
+        \n\n<b>All data on this SD card will be erased.</b>
+        \n\n<b>Before formatting</b>
 \n\n<b>Back up photos &amp; other media</b>
 \nMove your media files to alternative storage on this device, or transfer them to a computer using a USB cable.
 \n\n<b>Back up apps</b>
@@ -3615,16 +3619,19 @@
     <!-- Body of dialog informing user about the storage used by the Android System [CHAR LIMIT=NONE]-->
     <string name="storage_detail_dialog_system">System includes files used to run Android version <xliff:g id="version" example="8.0">%s</xliff:g></string>
 
-    <!-- Title of wizard step prompting user to setup a storage device [CHAR LIMIT=32] -->
+  <!-- Message to notify guest users as to why they can't set up the storage device [CHAR LIMIT=50]-->
+  <string name="storage_wizard_guest">Guest mode users cannot format SD cards</string>
+
+  <!-- Title of wizard step prompting user to setup a storage device [CHAR LIMIT=32] -->
     <string name="storage_wizard_init_title">Set up your <xliff:g id="name" example="SD card">^1</xliff:g></string>
     <!-- Title of wizard choice to use storage device as external storage [CHAR LIMIT=64] -->
-    <string name="storage_wizard_init_external_title">Use as portable storage</string>
+    <string name="storage_wizard_init_external_title">Format SD card for portable storage</string>
     <!-- Summary of wizard choice to use storage device as external storage [CHAR LIMIT=NONE] -->
-    <string name="storage_wizard_init_external_summary">For moving photos and other media between devices.</string>
+    <string name="storage_wizard_init_external_summary">Save photos, videos, music, and more and access them from other devices</string>
     <!-- Title of wizard choice to use storage device as internal storage [CHAR LIMIT=64] -->
-    <string name="storage_wizard_init_internal_title">Use as internal storage</string>
+    <string name="storage_wizard_init_internal_title">Format SD card for internal storage</string>
     <!-- Summary of wizard choice to use storage device as internal storage [CHAR LIMIT=NONE] -->
-    <string name="storage_wizard_init_internal_summary">For storing anything on this device only, including apps and photos. Requires formatting that prevents it from working with other devices.</string>
+    <string name="storage_wizard_init_internal_summary">Save apps \u0026 media to use on this phone only</string>
 
     <!-- Title of wizard step prompting user to format a storage device [CHAR LIMIT=32] -->
     <string name="storage_wizard_format_confirm_title">Format as internal storage</string>
@@ -3679,13 +3686,11 @@
     </string>
 
     <!-- Title of a full-screen message. This string lets the user know that their storage device is ready to use. They can tap a button at the bottom of the screen to complete the setup process. The placeholder is for the specific device (e.g. SD card, USB drive, etc.). [CHAR LIMIT=32] -->
-    <string name="storage_wizard_ready_title">Your <xliff:g id="name" example="SD card">^1</xliff:g> is ready to use</string>
+    <string name="storage_wizard_ready_title"><xliff:g id="name" example="SD card">^1</xliff:g> formatted</string>
     <!-- Body of wizard step indicating that external storage is ready [CHAR LIMIT=NONE] -->
-    <string name="storage_wizard_ready_external_body">Your <xliff:g id="name" example="SD card">^1</xliff:g> is all set to use with photos and other media.</string>
+    <string name="storage_wizard_ready_external_body">You can start using your <xliff:g id="name" example="SD card">^1</xliff:g></string>
     <!-- Body of wizard step indicating that internal storage is ready [CHAR LIMIT=NONE] -->
-    <string name="storage_wizard_ready_internal_body">Your new <xliff:g id="name" example="SD card">^1</xliff:g> is working.
-\n\nTo move photos, files, and app data to this device, go to Settings > Storage.
-    </string>
+    <string name="storage_wizard_ready_internal_body">You can start using your <xliff:g id="name" example="SD card">^1</xliff:g></string>
 
     <!-- Title of wizard step prompting user to move an app [CHAR LIMIT=32] -->
     <string name="storage_wizard_move_confirm_title">Move <xliff:g id="app" example="Calculator">^1</xliff:g></string>
@@ -3715,26 +3720,26 @@
     <!-- This is the title of a full-screen message. After this question, the user will get to choose how they want to use the storage device that they have in their phone. The placeholder is for the specific device (e.g. SD card, USB drive, etc.). [CHAR LIMIT=32] -->
     <string name="storage_wizard_init_v2_title">How will you use this <xliff:g id="name" example="SD card">^1</xliff:g>?</string>
 
-    <!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=32] -->
-    <string name="storage_wizard_init_v2_internal_title" product="tablet">Use for extra tablet storage</string>
-    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=64] -->
-    <string name="storage_wizard_init_v2_internal_summary" product="tablet">For apps, files, and media on this tablet only</string>
+    <!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=50] -->
+    <string name="storage_wizard_init_v2_internal_title" product="tablet">Format SD card for internal storage</string>
+    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=NONE] -->
+    <string name="storage_wizard_init_v2_internal_summary" product="tablet">Store apps \u0026 media to use on this tablet only. &lt;a href="https://support.google.com/android/answer/12153449"&gt;Learn more about setting up an SD card&lt;/a&gt;</string>
     <!-- Button text. A user can tap this button if they want to use their SD card as extra device storage. [CHAR LIMIT=32] -->
-    <string name="storage_wizard_init_v2_internal_action" product="tablet">Tablet storage</string>
-    <!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=32] -->
-    <string name="storage_wizard_init_v2_internal_title" product="default">Use for extra phone storage</string>
-    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=64] -->
-    <string name="storage_wizard_init_v2_internal_summary" product="default">For apps, files, and media on this phone only</string>
+    <string name="storage_wizard_init_v2_internal_action" product="tablet">Format</string>
+    <!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=50] -->
+    <string name="storage_wizard_init_v2_internal_title" product="default">Format SD card for internal storage</string>
+    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as extra device storage. [CHAR LIMIT=NONE] -->
+    <string name="storage_wizard_init_v2_internal_summary" product="default">Store apps \u0026 media to use on this phone only. &lt;a href="https://support.google.com/android/answer/12153449"&gt;Learn more about setting up an SD card&lt;/a&gt;</string>
     <!-- Button text. A user can tap this button if they want to use their SD card as extra device storage. [CHAR LIMIT=32] -->
-    <string name="storage_wizard_init_v2_internal_action" product="default">Phone storage</string>
+    <string name="storage_wizard_init_v2_internal_action" product="default">Format</string>
     <!-- This text separates two options in a full-screen message. It's used to indicate a user can choose one option or the other. [CHAR LIMIT=16] -->
     <string name="storage_wizard_init_v2_or">Or</string>
-    <!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as portable device storage. [CHAR LIMIT=32] -->
-    <string name="storage_wizard_init_v2_external_title">Use for portable storage</string>
-    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as portable device storage. [CHAR LIMIT=64] -->
-    <string name="storage_wizard_init_v2_external_summary">For transferring files and media between devices</string>
+    <!-- Title of a line item. Below this title, a user can tap a button to select this option if they want to use their SD card as portable device storage. [CHAR LIMIT=50] -->
+    <string name="storage_wizard_init_v2_external_title">Format SD card for portable storage</string>
+    <!-- Subtext for a line item. Below this subtext, a user can tap a button to select this option if they want to use their SD card as portable device storage. [CHAR LIMIT=NONE] -->
+    <string name="storage_wizard_init_v2_external_summary">Store photos, videos, music, and more and access them from other devices. &lt;a href="https://support.google.com/android/answer/12153449"&gt;Learn more about setting up an SD card&lt;/a&gt;</string>
     <!-- Button text. A user can tap this button if they want to use their SD card as portable device storage. [CHAR LIMIT=32] -->
-    <string name="storage_wizard_init_v2_external_action">Portable storage</string>
+    <string name="storage_wizard_init_v2_external_action">Format</string>
     <!-- Button text. A user can tap this button if they want to delay setting up their SD card until a later time. [CHAR LIMIT=32] -->
     <string name="storage_wizard_init_v2_later">Set up later</string>
 
@@ -3743,6 +3748,9 @@
     <!-- Body of a dialog. This text is confirming that the user wants to use their SD card as extra phone storage, but the formatting process will erase existing content on the card. The first placeholder is for the name of the device (e.g. a brand name of the SD card or USB drive). The second and third placeholders are for the general references (e.g. SD card, USB drive). [CHAR LIMIT=NONE] -->
     <string name="storage_wizard_format_confirm_v2_body">This <xliff:g id="name" example="SanDisk SD card">^1</xliff:g> needs to be formatted to store apps, files, and media.
 \n\nFormatting will erase existing content on the <xliff:g id="name" example="SD card">^2</xliff:g>. To avoid losing content, back it up to another <xliff:g id="name" example="SD card">^3</xliff:g> or device.</string>
+  <!-- Body of a dialog. This text is confirming that the user wants to use their SD card as portable storage, but the formatting process will erase existing content on the card. The first placeholder is for the name of the device (e.g. a brand name of the SD card or USB drive). The second and third placeholders are for the general references (e.g. SD card, USB drive). [CHAR LIMIT=NONE] -->
+    <string name="storage_wizard_format_confirm_v2_body_external">This <xliff:g id="name" example="SanDisk SD card">^1</xliff:g> needs to be formatted to store photos, videos, music, and more.
+        \n\nFormatting will erase existing content on the <xliff:g id="name" example="SD card">^2</xliff:g>. To avoid losing content, back it up to another <xliff:g id="name" example="SD card">^3</xliff:g> or device.</string>
     <!-- Button text. If a user taps this button, their SD card or USB device will be formatted and used as extra phone storage. The placeholder is for the specific device (e.g. SD card, USB drive, etc.). [CHAR LIMIT=16] -->
     <string name="storage_wizard_format_confirm_v2_action">Format <xliff:g id="name" example="SD card">^1</xliff:g></string>
 
@@ -3786,12 +3794,11 @@
     <string name="storage_wizard_slow_v2_continue">Continue</string>
 
     <!-- Title of a full-screen message. This text lets the user know how to manage the storage device moving forward. The placeholder is for the name of the device (e.g. brand name of the SD card). [CHAR LIMIT=NONE] -->
-    <string name="storage_wizard_ready_v2_external_body">You can move content to <xliff:g id="name" example="SanDisk SD card">^1</xliff:g></string>
+    <string name="storage_wizard_ready_v2_external_body">You can start using your <xliff:g id="name" example="SD card">^1</xliff:g></string>
     <!-- Title of a full-screen message. This text lets the user know that their content was moved to their storage device and how to manage the storage device moving forward. The placeholder is for the name of the device (e.g. brand name of the SD card). [CHAR LIMIT=NONE] -->
-    <string name="storage_wizard_ready_v2_internal_body">To move content to <xliff:g id="name" example="SanDisk SD card">^1</xliff:g>, go to <b>Settings > Storage</b></string>
+    <string name="storage_wizard_ready_v2_internal_body">You can start using your <xliff:g id="name" example="SD card">^1</xliff:g></string>
     <!-- Title of a full-screen message. This text lets the user know that their content was moved to their storage device and how to manage the storage device moving forward. The placeholder is for the name of the device (e.g. brand name of the SD card). [CHAR LIMIT=NONE] -->
-    <string name="storage_wizard_ready_v2_internal_moved_body">Your content was moved to <xliff:g id="name" example="SanDisk SD card">^1</xliff:g>.
-\n\nTo manage this <xliff:g id="name" example="SD card">^2</xliff:g>, go to <b>Settings > Storage</b>.</string>
+    <string name="storage_wizard_ready_v2_internal_moved_body">You can start using your <xliff:g id="name" example="SD card">^1</xliff:g></string>
 
     <!-- Phone info screen, section titles: -->
     <string name="battery_status_title">Battery status</string>
@@ -4914,12 +4921,6 @@
     <!-- Languages Settings --> <skip />
     <!-- Title of Language, input & gestures setting on main settings screen. -->
     <string name="language_input_gesture_title">Languages, input &amp; gestures</string>
-    <!-- Summary of Language, input & gestures setting on main settings screen when both gesture setting and assistant feature is on. -->
-    <string name="language_input_gesture_summary_on_with_assist"></string>
-    <!-- Summary of Language, input & gestures setting on main settings screen when both gesture setting and non-assistant feature is on. -->
-    <string name="language_input_gesture_summary_on_non_assist"></string>
-    <!-- Summary of Language, input & gestures setting on main settings screen when gesture setting is off. -->
-    <string name="language_input_gesture_summary_off"></string>
 
     <!-- Title of setting on main settings screen.  This item will take the user to the screen to tweak settings realted to locale and text -->
     <string name="language_settings">Languages&#160;&amp; input</string>
@@ -6093,42 +6094,6 @@
     <string name="power_usage_enhanced_debug" translatable="false"><xliff:g id="time">%1$s</xliff:g> left (New ML est)</string>
     <!-- Temp string used to debug old battery estimates [DO NOT TRANSLATE] -->
     <string name="power_usage_old_debug" translatable="false"><xliff:g id="time">%1$s</xliff:g> left (Old est)</string>
-    <!-- Description for the screen usage item [CHAR_LIMIT=120] -->
-    <string name="screen_usage_summary">Amount of time screen has been on since full charge</string>
-    <!-- Label for list of different types using battery in power use UI [CHAR_LIMIT=60] -->
-    <string name="device_usage_list_summary">Device usage since full charge</string>
-    <!-- Battery usage since unplugged -->
-    <string name="battery_since_unplugged">Battery use since unplugged</string>
-    <!-- Battery usage since user reset the stats -->
-    <string name="battery_since_reset">Battery use since reset</string>
-    <!-- Battery usage on battery duration -->
-    <string name="battery_stats_on_battery"><xliff:g id="time">%1$s</xliff:g> on battery</string>
-    <!-- Battery usage duration -->
-    <string name="battery_stats_duration"><xliff:g id="time">%1$s</xliff:g> since unplugged</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats charging state graph -->
-    <string name="battery_stats_charging_label">Charging</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats screen on state graph -->
-    <string name="battery_stats_screen_on_label">Screen on</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats gps on state graph -->
-    <string name="battery_stats_gps_on_label">GPS on</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats camera on state graph -->
-    <string name="battery_stats_camera_on_label">Camera on</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats flashlight on state graph -->
-    <string name="battery_stats_flashlight_on_label">Flashlight on</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats wifi running state graph -->
-    <string name="battery_stats_wifi_running_label">Wi\u2011Fi</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats wake lock state graph -->
-    <string name="battery_stats_wake_lock_label">Awake</string>
-    <!-- [CHAR LIMIT=25] Label for battery stats phone signal strength graph -->
-    <string name="battery_stats_phone_signal_label">Mobile network signal</string>
-    <!-- Battery usage during last unplugged period -->
-    <string name="battery_stats_last_duration">@string/menu_stats_last_unplugged</string>
-    <!-- CPU awake time title -->
-    <string name="awake">Device awake time</string>
-    <!-- Wifi on time -->
-    <string name="wifi_on_time">Wi\u2011Fi on time</string>
-    <!-- Bluetooth on time -->
-    <string name="bluetooth_on_time">Wi\u2011Fi on time</string>
 
     <!-- Activity title for advanced battery usage page [CHAR LIMIT=25] -->
     <string name="advanced_battery_title">Battery usage</string>
@@ -6280,8 +6245,6 @@
     <!-- Summary for battery manager when it is on. [CHAR LIMIT=NONE] -->
     <string name="battery_manager_summary_unsupported">Detecting when apps drain battery</string>
 
-    <!-- Summary for battery manager when it is off -->
-    <string name="battery_manager_off">Off</string>
     <!-- Summary for battery manager, showing app restricted -->
     <plurals name="battery_manager_app_restricted">
         <item quantity="one">%1$d app restricted</item>
@@ -6298,48 +6261,6 @@
     <!-- Accessibility description for battery missing link. [CHAR LIMIT=NONE] -->
     <string name="battery_missing_link_a11y_message">Tap to learn more about this error</string>
 
-    <!-- Title for force stop dialog [CHAR LIMIT=30] -->
-    <string name="dialog_stop_title">Stop app?</string>
-    <!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_stop_message" product="default">Your phone can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> is keeping your phone awake.\n\nTo try to fix this issue, you can stop the app.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance.</string>
-    <!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_stop_message" product="tablet">Your tablet can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> is keeping your tablet awake.\n\nTo try to fix this issue, you can stop the app.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance.</string>
-    <!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_stop_message" product="device">Your device can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> is keeping your device awake.\n\nTo try to fix this issue, you can stop the app.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance.</string>
-
-    <!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_stop_message_wakeup_alarm" product="default">Your phone can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps waking up your phone.\n\nTo try to fix this issue, you can stop <xliff:g id="app">%1$s</xliff:g>.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance.</string>
-    <!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_stop_message_wakeup_alarm" product="tablet">Your tablet can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps waking up your tablet.\n\nTo try to fix this issue, you can stop <xliff:g id="app">%1$s</xliff:g>.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance.</string>
-    <!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_stop_message_wakeup_alarm" product="device">Your device can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps waking up your device.\n\nTo try to fix this issue, you can stop <xliff:g id="app">%1$s</xliff:g>.\n\nIf this keeps happening, you may need to uninstall the app to improve battery performance.</string>
-
-    <!-- Text for OK button in force stop dialog [CHAR LIMIT=30] -->
-    <string name="dialog_stop_ok">Stop app</string>
-
-    <!-- Title for background usage dialog [CHAR LIMIT=70] -->
-    <string name="dialog_background_check_title">Turn off background usage &amp; stop app?</string>
-    <!-- Message body for background usage dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_background_check_message" product="default">Your phone can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps waking up your phone.\n\nTo try to fix this issue, you can stop <xliff:g id="app">%1$s</xliff:g> and prevent it from running in the background.</string>
-    <!-- Message body for background usage dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_background_check_message" product="tablet">Your tablet can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps waking up your tablet.\n\nTo try to fix this issue, you can stop <xliff:g id="app">%1$s</xliff:g> and prevent it from running in the background.</string>
-    <!-- Message body for background usage dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_background_check_message" product="device">Your device can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps waking up your device.\n\nTo try to fix this issue, you can stop <xliff:g id="app">%1$s</xliff:g> and prevent it from running in the background.</string>
-    <!-- Text for OK button in background usage dialog [CHAR LIMIT=30] -->
-    <string name="dialog_background_check_ok">Turn off</string>
-
-    <!-- Title for location dialog [CHAR LIMIT=60] -->
-    <string name="dialog_location_title">Turn off location?</string>
-    <!-- Message body for location dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_location_message" product="default">Your phone can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps requesting your location when you\'re not using the app.\n\nTo fix this issue, you can turn off location for this app.</string>
-    <!-- Message body for location dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_location_message" product="tablet">Your tablet can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps requesting your location when you\'re not using the app.\n\nTo fix this issue, you can turn off location for this app.</string>
-    <!-- Message body for location dialog [CHAR LIMIT=NONE] -->
-    <string name="dialog_location_message" product="device">Your device can\'t manage battery normally because <xliff:g id="app">%1$s</xliff:g> keeps requesting your location when you\'re not using the app.\n\nTo fix this issue, you can turn off location for this app.</string>
-
-    <!-- Text for OK button in location dialog [CHAR LIMIT=30] -->
-    <string name="dialog_location_ok">Turn off</string>
-
     <!-- Label for power consumed by the screen -->
     <string name="power_screen">Screen</string>
     <!-- Label for power consumed by the flashlight -->
@@ -6358,126 +6279,6 @@
     <string name="power_idle" product="tablet">Tablet idle</string>
     <!-- Label for power consumed when Idle -->
     <string name="power_idle" product="default">Phone idle</string>
-    <!-- Label for power that we aren't able to account for -->
-    <string name="power_unaccounted">Miscellaneous</string>
-    <!-- Label for power that we computed too much for -->
-    <string name="power_overcounted">Over-counted</string>
-
-    <!-- Label for CPU usage time -->
-    <string name="usage_type_cpu">CPU total</string>
-    <!-- Label for CPU usage in foreground -->
-    <string name="usage_type_cpu_foreground">CPU foreground</string>
-    <!-- [CHAR LIMIT=25] Label for keeping device from sleeping -->
-    <string name="usage_type_wake_lock">Keep awake</string>
-    <!-- Label for GPS usage time -->
-    <string name="usage_type_gps">GPS</string>
-    <!-- [CHAR LIMIT=25] Label for WIFI usage time -->
-    <string name="usage_type_wifi_running">Wi\u2011Fi running</string>
-    <!-- Label for Phone usage time -->
-    <string name="usage_type_phone" product="tablet">Tablet</string>
-    <!-- Label for Phone usage time -->
-    <string name="usage_type_phone" product="default">Phone</string>
-    <!-- Label for mobile network data sent [CHAR LIMIT=32] -->
-    <string name="usage_type_data_send">Mobile packets sent</string>
-    <!-- Label for mobile network data received [CHAR LIMIT=32] -->
-    <string name="usage_type_data_recv">Mobile packets received</string>
-    <!-- Label for mobile network radio active time [CHAR LIMIT=32] -->
-    <string name="usage_type_radio_active">Mobile radio active</string>
-    <!-- Label for Wi-Fi network data sent [CHAR LIMIT=32] -->
-    <string name="usage_type_data_wifi_send">Wi\u2011Fi packets sent</string>
-    <!-- Label for Wi-Fi network data received [CHAR LIMIT=32] -->
-    <string name="usage_type_data_wifi_recv">Wi\u2011Fi packets received</string>
-    <!-- Label for Audio usage time -->
-    <string name="usage_type_audio">Audio</string>
-    <!-- Label for Video usage time -->
-    <string name="usage_type_video">Video</string>
-    <!-- Label for Camera usage time -->
-    <string name="usage_type_camera">Camera</string>
-    <!-- Label for Flashlight usage time -->
-    <string name="usage_type_flashlight">Flashlight</string>
-    <!-- Label for time that a feature has been on -->
-    <string name="usage_type_on_time">Time on</string>
-    <!-- Label for time that there was no cell coverage -->
-    <string name="usage_type_no_coverage">Time without a signal</string>
-    <!-- Label for the total power capacity of the device's battery -->
-    <string name="usage_type_total_battery_capacity">Total battery capacity</string>
-    <!-- [CHAR_LIMIT=NONE] Label for amount of power use that was computed -->
-    <string name="usage_type_computed_power">Computed power use</string>
-    <!-- [CHAR_LIMIT=NONE] Label for amount of power use that was actually observed (though
-         the change in battery level) -->
-    <string name="usage_type_actual_power">Observed power use</string>
-    <!-- Label for force stop action -->
-    <string name="battery_action_stop">Force stop</string>
-    <!-- Label for app details action -->
-    <string name="battery_action_app_details">App info</string>
-    <!-- Label for app settings action -->
-    <string name="battery_action_app_settings">App settings</string>
-    <!-- Label for display settings -->
-    <string name="battery_action_display">Screen settings</string>
-    <!-- Label for wifi settings -->
-    <string name="battery_action_wifi">Wi\u2011Fi settings</string>
-    <!-- Label for bluetooth settings -->
-    <string name="battery_action_bluetooth">Bluetooth settings</string>
-
-    <!-- Description for voice call detail -->
-    <string name="battery_desc_voice">Battery used by voice calls</string>
-
-    <!-- Description for standby detail -->
-    <string name="battery_desc_standby" product="tablet">Battery used when tablet is idle</string>
-    <!-- Description for standby detail -->
-    <string name="battery_desc_standby" product="default">Battery used when phone is idle</string>
-
-    <!-- Description for cell radio detail -->
-    <string name="battery_desc_radio">Battery used by cell radio</string>
-    <!-- Suggestion to switch to airplane mode to save power -->
-    <string name="battery_sugg_radio">Switch to airplane mode to save power in areas with no cell coverage</string>
-
-    <!-- [CHAR_LIMIT=NONE] Description for power consumed by the flashlight -->
-    <string name="battery_desc_flashlight">Battery used by the flashlight</string>
-
-    <!-- [CHAR_LIMIT=NONE] Description for power consumed by the camera -->
-    <string name="battery_desc_camera">Battery used by the camera</string>
-
-    <!-- Description for power consumed by display -->
-    <string name="battery_desc_display">Battery used by the display and backlight</string>
-    <!-- Suggestion for reducing display power -->
-    <string name="battery_sugg_display">Reduce the screen brightness and/or screen timeout</string>
-
-    <!-- Description for wifi connectivity -->
-    <string name="battery_desc_wifi">Battery used by Wi\u2011Fi</string>
-    <!-- Suggestion for wifi connectivity power drain -->
-    <string name="battery_sugg_wifi">Turn off Wi\u2011Fi when not using it or when it isn\u2019t available</string>
-
-    <!-- Description for bluetooth power consumption detail -->
-    <string name="battery_desc_bluetooth">Battery used by Bluetooth</string>
-    <!-- Suggestion for bluetooth -->
-    <string name="battery_sugg_bluetooth_basic">Turn off Bluetooth when you aren\u2019t using it</string>
-    <!-- Suggestion for bluetooth headset -->
-    <string name="battery_sugg_bluetooth_headset">Try connecting to a different Bluetooth device</string>
-
-    <!-- [CHAR LIMIT=50] Description for power consumed by applications -->
-    <string name="battery_desc_apps">Battery used by app</string>
-    <!-- Suggestion for exploring application info to stop or uninstall -->
-    <string name="battery_sugg_apps_info">Stop or uninstall the app</string>
-    <!-- [CHAR LIMIT=100] Suggestion for getting apps to consume less power due to GPS-->
-    <string name="battery_sugg_apps_gps">Select battery-saving mode</string>
-    <!-- Suggestion for getting apps to consume less power -->
-    <string name="battery_sugg_apps_settings">The app may offer settings to reduce battery use</string>
-
-    <!-- [CHAR LIMIT=50] Description for power consumed by users -->
-    <string name="battery_desc_users">Battery used by user</string>
-
-    <!-- [CHAR LIMIT=50] Description for unaccounted power use -->
-    <string name="battery_desc_unaccounted">Miscellaneous power use</string>
-    <!-- [CHAR LIMIT=NONE] Description for unaccounted power use -->
-    <string name="battery_msg_unaccounted">Battery use is an approximation of power
-        use and does not include every source of battery drain.  Miscellaneous is the difference
-        between the computed approximate power use and the actual drain observed on the
-        battery.</string>
-    <!-- [CHAR LIMIT=50] Description for over-counted power use -->
-    <string name="battery_desc_overcounted">Over-counted power use</string>
-    <!-- Representation of a mAh value. [CHAR LIMIT=NONE] -->
-    <string name="mah"><xliff:g id="number" example="30">%d</xliff:g> mAh</string>
 
     <!-- Description for battery usage time for an app, i.e. Used for 30min. Note: ^1 should be used in all translations [CHAR LIMIT=60] -->
     <string name="battery_used_for">Used for <xliff:g id="time">^1</xliff:g></string>
@@ -6563,15 +6364,6 @@
     <!-- Description for estimated time. [CHAR LIMIT=80]-->
     <string name="estimated_time_description">Estimate may change based on usage</string>
 
-    <!-- Menu label for viewing battery usage since unplugged -->
-    <string name="menu_stats_unplugged"><xliff:g id="unplugged">%1$s</xliff:g> since unplugged</string>
-    <!-- Menu label for viewing battery usage since unplugged -->
-    <string name="menu_stats_last_unplugged">While last unplugged for <xliff:g id="unplugged">%1$s</xliff:g></string>
-    <!-- Menu label for viewing battery usage total -->
-    <string name="menu_stats_total">Usage totals</string>
-    <!-- Menu label for refreshing with latest usage numbers -->
-    <string name="menu_stats_refresh">Refresh</string>
-
     <!-- Label for mediaserver process in battery usage [CHAR_LIMIT=NONE] -->
     <string name="process_mediaserver_label">Mediaserver</string>
     <!-- Label for dex2oat process in battery usage used for the optimization of one or more apps -->
@@ -7136,12 +6928,6 @@
     <!-- the following are for Settings Storage screen -->
     <!-- Menu item/button 'delete' -->
     <string name="delete">Delete</string>
-    <!-- Misc files [CHAR LIMIT=25] -->
-    <string name="misc_files">Misc files</string>
-    <!-- number of misc files selected [CHAR LIMIT=40] -->
-    <string name="misc_files_selected_count">selected <xliff:g id="number" example="3">%1$d</xliff:g> out of <xliff:g id="total" example="15">%2$d</xliff:g></string>
-    <!-- number of bytes represented by the selected misc files [CHAR LIMIT=40] -->
-    <string name="misc_files_selected_count_bytes"><xliff:g id="number" example="3.25MB">%1$s</xliff:g> out of <xliff:g id="total" example="15.25MB">%2$s</xliff:g></string>
     <!--  action to select all [CHAR LIMIT=30] -->
     <string name="select_all">Select all</string>
 
@@ -7149,44 +6935,6 @@
     <string name="data_usage_summary_title">Data usage</string>
     <!-- Activity title Mobile data & WI-FI summary. [CHAR LIMIT=40] -->
     <string name="data_usage_app_summary_title">Mobile data &amp; Wi\u2011Fi</string>
-    <!-- Message about carrier data accounting.  [CHAR LIMIT=100] -->
-    <string name="data_usage_accounting">Carrier data accounting may differ from your device.</string>
-    <!-- Title for app usage. [CHAR LIMIT=40] -->
-    <string name="data_usage_app">App usage</string>
-    <!-- Title for app usage. [CHAR LIMIT=40] -->
-    <string name="data_usage_app_info_label">APP INFO</string>
-    <!-- Title for cellular data usage. [CHAR LIMIT=40] -->
-    <string name="data_usage_cellular_data">Mobile data</string>
-    <!-- Title for setting data limit. [CHAR LIMIT=40] -->
-    <string name="data_usage_data_limit">Set data limit</string>
-    <!-- Title for option to pick visible time range from a list available usage periods. [CHAR LIMIT=25] -->
-    <string name="data_usage_cycle">Data usage cycle</string>
-    <!-- Title for application data usage separator in data usage list. [CHAR LIMIT=25] -->
-    <string name="data_usage_app_items_header_text">App usage</string>
-    <!-- Title for menu option to enable mobile data when roaming. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_roaming">Data roaming</string>
-    <!-- Title for menu option to restrict background data usage. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_restrict_background">Restrict background data</string>
-    <!-- Title for menu option to allow background data usage. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_allow_background">Allow background data</string>
-    <!-- Title for menu option to show 4G mobile data usage separate from other mobile data usage. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_split_4g">Separate 4G usage</string>
-    <!-- Title for menu option to show Wi-Fi data usage. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_show_wifi">Show Wi\u2011Fi</string>
-    <!-- Title for menu option to hide Wi-Fi data usage. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_hide_wifi">Hide Wi\u2011Fi</string>
-    <!-- Title for menu option to show Ethernet data usage. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_show_ethernet">Show Ethernet usage</string>
-    <!-- Title for menu option to hide Ethernet data usage. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_hide_ethernet">Hide Ethernet usage</string>
-    <!-- Title for menu option to configure metered networks. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_metered">Network restrictions</string>
-    <!-- Title for menu option to enable global auto-sync of account data -->
-    <string name="data_usage_menu_auto_sync">Auto-sync data</string>
-    <!-- Title for menu option to show details for all SIM cards. [CHAR LIMIT=26] -->
-    <string name="data_usage_menu_sim_cards">SIM cards</string>
-    <!-- Summary String for Cellular data enable toggle. [CHAR LIMIT=33] -->
-    <string name="data_usage_cellular_data_summary">Paused at limit</string>
 
     <!--  Title for menu option to enable global auto-sync of personal account data [CHAR LIMIT=30] -->
     <string name="account_settings_menu_auto_sync">Auto-sync data</string>
@@ -8095,6 +7843,10 @@
     <string name="wizard_back">Back</string>
     <!-- Wizard next button label [CHAR LIMIT=25] -->
     <string name="wizard_next">Next</string>
+    <!-- Wizard next button label for portable [CHAR LIMIT=25] -->
+    <string name="wizard_back_portable">Switch to portable</string>
+    <!-- Wizard next button label for adoptable [CHAR LIMIT=25] -->
+    <string name="wizard_back_adoptable">Format another way</string>
     <!-- Wizard finish button label [CHAR LIMIT=25] -->
     <string name="wizard_finish">Finish</string>
 
@@ -8259,8 +8011,6 @@
     <string name="keywords_wifi_data_usage">data usage</string>
     <!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
     <string name="keywords_time_format">Use 24-hour format</string>
-    <!-- Search keyword for "Files" settings under Settings > Storage. [CHAR_LIMIT=NONE]-->
-    <string name="keywords_storage_files">Download</string>
     <!-- Search keyword for "Default Apps" settings [CHAR_LIMIT=NONE]-->
     <string name="keywords_app_default">Open with</string>
     <!-- Search keyword for "App info" settings [CHAR_LIMIT=NONE]-->
@@ -12201,18 +11951,9 @@
     <!-- Storage Settings dropdown option of default internal storage [CHAR LIMIT=30] -->
     <string name="storage_default_internal_storage">This device</string>
 
-    <!-- Preference label for the Photos & Videos storage section. [CHAR LIMIT=50] -->
-    <string name="storage_photos_videos">Photos &amp; videos</string>
-
-    <!-- Preference label for the Music & Audio storage section. [CHAR LIMIT=50] -->
-    <string name="storage_music_audio">Music &amp; audio</string>
-
     <!-- Preference label for the Games storage section. [CHAR LIMIT=50] -->
     <string name="storage_games">Games</string>
 
-    <!-- Preference label for the Other apps storage section. [CHAR LIMIT=50] -->
-    <string name="storage_other_apps">Other apps</string>
-
     <!-- Preference label for the Files storage section. [CHAR LIMIT=50] -->
     <string name="storage_files">Files</string>
 
@@ -12250,13 +11991,6 @@
     <string name="storage_trash_dialog_confirm">Empty trash</string>
 
     <!-- Summary of a single storage volume used space. [CHAR LIMIT=24] -->
-    <string name="storage_size_large_alternate"><xliff:g id="number" example="128">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="KB">^2</xliff:g></font></small></string>
-    <!-- Summary of a single storage volume total space. [CHAR LIMIT=48]-->
-    <string name="storage_volume_total">Used of <xliff:g id="total" example="32GB">%1$s</xliff:g></string>
-    <!-- Follows the percent of storage used by a storage volume. Exposed inside of a donut graph. [CHAR LIMIT=7]-->
-    <string name="storage_percent_full">used</string>
-
-    <!-- Summary of a single storage volume used space. [CHAR LIMIT=24] -->
     <string name="storage_usage_summary"><xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g> used</string>
     <!-- Summary of a single storage volume total space. [CHAR LIMIT=24] -->
     <string name="storage_total_summary"><xliff:g id="number" example="128">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g> total</string>
@@ -12359,29 +12093,12 @@
     <!-- Switch summary to show operator name in the status bar [CHAR LIMIT=NONE] -->
     <string name="show_operator_name_summary">Display network name in status bar</string>
 
-    <!-- Indicates if the automatic storage manager is enabled or not. [CHAR_LIMIT=40] -->
-    <string name="storage_manager_indicator">Storage Manager: <xliff:g id="status" example="on">^1</xliff:g></string>
-
-    <!-- Off status for the automatic storage manager. [CHAR_LIMIT=10] -->
-    <string name="storage_manager_indicator_off">Off</string>
-
-    <!-- On status for the automatic storage manager. [CHAR_LIMIT=10] -->
-    <string name="storage_manager_indicator_on">On</string>
-
     <!-- Added as the value of a header field indicating this is an instant app (as opposed to installed normally) -->
     <string name="install_type_instant">Instant app</string>
 
     <!-- Warning for when the automatic storage manager is turned off. [CHAR LIMIT=NONE] -->
     <string name="automatic_storage_manager_deactivation_warning">Turn off the storage manager?</string>
 
-    <!-- Preference label for the Movies & TV apps section [CHAR LIMIT=50] -->
-    <string name="storage_movies_tv">Movie &amp; TV apps</string>
-
-    <!-- Carrier Provisioning Info [CHAR LIMIT=NONE] -->
-    <string name="carrier_provisioning">Carrier Provisioning Info</string>
-    <!-- Trigger Carrier Provisioning [CHAR LIMIT=NONE] -->
-    <string name="trigger_carrier_provisioning">Trigger Carrier Provisioning</string>
-
     <!-- Help URI, USB Audio [DO NOT TRANSLATE] -->
     <string name="help_url_audio_accessory_not_supported" translatable="false"></string>
 
@@ -12548,51 +12265,15 @@
     <!-- Summary for media output default settings. (this device) [CHAR LIMIT=30] -->
     <string name="media_output_default_summary">This device</string>
 
-    <!-- Summary for media output settings. (phone) -->
-    <string name="media_output_summary" product="default">Phone</string>
-
-    <!-- Summary for media output settings. (tablet) -->
-    <string name="media_output_summary" product="tablet">Tablet</string>
-
-    <!-- Summary for media output settings. (device) -->
-    <string name="media_output_summary" product="device">Device</string>
-
     <!-- Summary for media output settings when device is in ongoing call state. -->
     <string name="media_out_summary_ongoing_call_state">Unavailable during calls</string>
 
-    <!-- Summary for media output settings when the media stream is being captured by something else. -->
-    <string name="media_output_summary_unavailable">Unavailable</string>
-
-    <!-- Title for the media output group dialog with media related devices [CHAR LIMIT=50] -->
-    <string name="media_output_group_panel_title">Add outputs</string>
-
-    <!-- Title for the media output slice with group devices [CHAR LIMIT=50] -->
-    <string name="media_output_group">Group</string>
-
-    <!-- Summary for media output group with only one device which is active [CHAR LIMIT=NONE] -->
-    <string name="media_output_group_panel_single_device_summary">1 device selected</string>
-
-    <!-- Summary for media output group with the active device count [CHAR LIMIT=NONE] -->
-    <string name="media_output_group_panel_multiple_devices_summary"><xliff:g id="count" example="2">%1$d</xliff:g> devices selected</string>
-
-    <!-- Summary for media output switching output [CHAR LIMIT=50] -->
-    <string name="media_output_switching">Switching\u2026</string>
-
     <!-- Title for HFP(hands free profile) output switch button in settings. -->
     <string name="take_call_on_title">Take call on</string>
 
     <!-- Toast that appears when users tap an APN for which parameters cannot be viewed. [CHAR LIMIT=NONE] -->
     <string name="cannot_change_apn_toast">This APN cannot be changed.</string>
 
-    <!--  Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
-    <string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
-    <!--  Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
-    <string name="battery_suggestion_title" product="device" >Improve device\'s battery life</string>
-    <!--  Title for battery Suggestion. (phone) [CHAR LIMIT=46] -->
-    <string name="battery_suggestion_title" product="default" >Improve phone\'s battery life</string>
-    <!--  Summary for battery Suggestion. [CHAR LIMIT=55] -->
-    <string name="battery_suggestion_summary"></string>
-
     <!-- Title for prevent ringing gesture screen [CHAR LIMIT=60]-->
     <string name="gesture_prevent_ringing_screen_title">Prevent ringing</string>
     <!-- Title for prevent ringing setting [CHAR LIMIT=60]-->
@@ -13265,8 +12946,6 @@
     <!-- Message for forget passpoint dialog [CHAR LIMIT=none] -->
     <string name="forget_passpoint_dialog_message">You may lose access to any remaining time or data. Check with your provider before removing.</string>
 
-    <!-- Keywords for Content Capture feature [CHAR_LIMIT=none] -->
-    <string name="keywords_content_capture">content capture, app content</string>
     <!-- Title of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=none]-->
     <string name="content_capture">App content</string>
     <!-- Description of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=NONE]-->
@@ -13360,15 +13039,6 @@
     <!-- Developer settings: text for the bug report handler selection toast shown if an invalid bug report handler was chosen. [CHAR LIMIT=NONE] -->
     <string name="select_invalid_bug_report_handler_toast_text">This choice is no longer valid. Try again.</string>
 
-    <!-- Device controls name lower case [CHAR LIMIT=40] -->
-    <string name="quick_controls_lower">device controls</string>
-
-    <!-- Cards and passes name sentence case [CHAR LIMIT=40] -->
-    <string name="cards_passes_sentence">Cards &amp; passes</string>
-
-    <!-- Cards and passes name lower case [CHAR LIMIT=40] -->
-    <string name="cards_passes_lower">cards &amp; passes</string>
-
     <!-- Power menu setting name [CHAR LIMIT=60] -->
     <string name="power_menu_setting_name">Press &amp; hold power button</string>
 
@@ -13506,9 +13176,6 @@
     <string name="calls_and_sms_category">Wi\u2011Fi calling</string>
     <!-- Provider Model: Summary for calling preference -->
     <string name="calls_sms_wfc_summary">Make and receive calls over Wi\u2011Fi</string>
-    <!-- Provider Model: Label for footnote on calling preference -->
-    <string name="calls_sms_footnote">With Wi\u2011Fi calling, calls are made and received over non\u2011carrier Wi\u2011Fi networks.
-        <annotation id="url">Learn more</annotation></string>
     <!-- Provider Model: Calls preference title -->
     <string name="calls_preference_title">Calls</string>
     <!-- Provider Model: SMS preference title -->
diff --git a/res/xml/captioning_more_options.xml b/res/xml/captioning_more_options.xml
index c4fc529..e1fd002 100644
--- a/res/xml/captioning_more_options.xml
+++ b/res/xml/captioning_more_options.xml
@@ -22,6 +22,7 @@
 
     <com.android.settings.accessibility.LocalePreference
         android:key="captioning_locale"
+        android:summary="%s"
         android:title="@string/captioning_locale"
         settings:controller="com.android.settings.accessibility.CaptionLocalePreferenceController"/>
 
diff --git a/src/com/android/settings/accessibility/CaptionCustomController.java b/src/com/android/settings/accessibility/CaptionCustomController.java
index e1674a2..23ef738 100644
--- a/src/com/android/settings/accessibility/CaptionCustomController.java
+++ b/src/com/android/settings/accessibility/CaptionCustomController.java
@@ -42,7 +42,6 @@
     private Preference mCustom;
     private final CaptionHelper mCaptionHelper;
     private final ContentResolver mContentResolver;
-    private final Handler mHandler = new Handler(Looper.getMainLooper());
     @VisibleForTesting
     AccessibilitySettingsContentObserver mSettingsContentObserver;
     @VisibleForTesting
@@ -54,7 +53,8 @@
         super(context, preferenceKey);
         mCaptionHelper = new CaptionHelper(context);
         mContentResolver = context.getContentResolver();
-        mSettingsContentObserver = new AccessibilitySettingsContentObserver(mHandler);
+        mSettingsContentObserver = new AccessibilitySettingsContentObserver(
+                new Handler(Looper.getMainLooper()));
         mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS,
                 key -> refreshShowingCustom());
     }
diff --git a/src/com/android/settings/accessibility/CaptionFontSizeController.java b/src/com/android/settings/accessibility/CaptionFontSizeController.java
index a8cdce5..a8fee38 100644
--- a/src/com/android/settings/accessibility/CaptionFontSizeController.java
+++ b/src/com/android/settings/accessibility/CaptionFontSizeController.java
@@ -33,7 +33,6 @@
 
     private final CaptioningManager mCaptioningManager;
     private final CaptionHelper mCaptionHelper;
-    private ListPreference mPreference;
 
     public CaptionFontSizeController(Context context, String preferenceKey) {
         super(context, preferenceKey);
@@ -49,19 +48,19 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = screen.findPreference(getPreferenceKey());
-
+        final ListPreference listPreference = screen.findPreference(getPreferenceKey());
         final float fontSize = mCaptioningManager.getFontScale();
-        mPreference.setValue(Float.toString(fontSize));
+        listPreference.setValue(Float.toString(fontSize));
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
+        final ListPreference listPreference = (ListPreference) preference;
         final ContentResolver cr = mContext.getContentResolver();
         Settings.Secure.putFloat(
                 cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
                 Float.parseFloat((String) newValue));
-        mPreference.setValue((String) newValue);
+        listPreference.setValue((String) newValue);
         mCaptionHelper.setEnabled(true);
         return false;
     }
diff --git a/src/com/android/settings/accessibility/CaptionHelper.java b/src/com/android/settings/accessibility/CaptionHelper.java
index eb76b6d..4530493 100644
--- a/src/com/android/settings/accessibility/CaptionHelper.java
+++ b/src/com/android/settings/accessibility/CaptionHelper.java
@@ -188,17 +188,27 @@
     }
 
     /**
-     * Sets the caption raw user style.
+     * Sets the captioning raw user style.
      *
-     * @param type The caption raw user style
+     * @param type The captioning raw user style
      */
     public void setRawUserStyle(int type) {
         Settings.Secure.putInt(mContentResolver,
                 Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, type);
     }
 
-    /** Returns the caption raw user style.*/
+    /** Returns the captioning raw preset number.*/
     public int getRawUserStyle() {
         return mCaptioningManager.getRawUserStyle();
     }
+
+    /** Returns the captioning visual properties.*/
+    public CaptionStyle getUserStyle() {
+        return mCaptioningManager.getUserStyle();
+    }
+
+    /** Returns the captioning locale language.*/
+    public Locale getLocale() {
+        return mCaptioningManager.getLocale();
+    }
 }
diff --git a/src/com/android/settings/accessibility/CaptionLocalePreferenceController.java b/src/com/android/settings/accessibility/CaptionLocalePreferenceController.java
index 1b1179d..7566282 100644
--- a/src/com/android/settings/accessibility/CaptionLocalePreferenceController.java
+++ b/src/com/android/settings/accessibility/CaptionLocalePreferenceController.java
@@ -30,7 +30,6 @@
         implements Preference.OnPreferenceChangeListener {
 
     private final CaptioningManager mCaptioningManager;
-    private LocalePreference mPreference;
 
     public CaptionLocalePreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
@@ -45,22 +44,17 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = screen.findPreference(getPreferenceKey());
+        final LocalePreference localePreference = screen.findPreference(getPreferenceKey());
         final String rawLocale = mCaptioningManager.getRawLocale();
-        mPreference.setValue(rawLocale == null ? "" : rawLocale);
-    }
-
-    @Override
-    public CharSequence getSummary() {
-        return mPreference.getEntry();
+        localePreference.setValue(rawLocale == null ? "" : rawLocale);
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
+        final LocalePreference localePreference = (LocalePreference) preference;
         Settings.Secure.putString(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE, (String) newValue);
-        mPreference.setValue((String) newValue);
-        mPreference.setSummary(mPreference.getEntry());
+        localePreference.setValue((String) newValue);
         return true;
     }
 }
diff --git a/src/com/android/settings/accessibility/CaptionPreviewPreferenceController.java b/src/com/android/settings/accessibility/CaptionPreviewPreferenceController.java
index a8187f1..793eaa3 100644
--- a/src/com/android/settings/accessibility/CaptionPreviewPreferenceController.java
+++ b/src/com/android/settings/accessibility/CaptionPreviewPreferenceController.java
@@ -21,7 +21,7 @@
 import android.os.Looper;
 import android.provider.Settings;
 import android.view.View;
-import android.view.accessibility.CaptioningManager;
+import android.view.accessibility.CaptioningManager.CaptionStyle;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.PreferenceScreen;
@@ -57,16 +57,11 @@
     private final Handler mHandler = new Handler(Looper.getMainLooper());
     @VisibleForTesting
     AccessibilitySettingsContentObserver mSettingsContentObserver;
-    private CaptioningManager mCaptioningManager;
     private CaptionHelper mCaptionHelper;
     private LayoutPreference mPreference;
-    private SubtitleView mPreviewText;
-    private View mPreviewWindow;
-    private View mPreviewViewport;
 
     public CaptionPreviewPreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
-        mCaptioningManager = context.getSystemService(CaptioningManager.class);
         mCaptionHelper = new CaptionHelper(context);
         mSettingsContentObserver = new AccessibilitySettingsContentObserver(mHandler);
         mSettingsContentObserver.registerKeysToObserverCallback(CAPTIONING_FEATURE_KEYS,
@@ -92,16 +87,14 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
-        mPreviewText = mPreference.findViewById(R.id.preview_text);
-        mPreviewWindow = mPreference.findViewById(R.id.preview_window);
-        mPreviewViewport = mPreference.findViewById(R.id.preview_viewport);
-        mPreviewViewport.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+        final View previewViewport = mPreference.findViewById(R.id.preview_viewport);
+        previewViewport.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
             @Override
             public void onLayoutChange(View v, int left, int top, int right,
                     int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                 if ((oldRight - oldLeft) != (right - left)) {
                     // Remove the listener once the callback is triggered.
-                    mPreviewViewport.removeOnLayoutChangeListener(this);
+                    previewViewport.removeOnLayoutChangeListener(this);
                     mHandler.post(() -> refreshPreviewText());
                 }
             }
@@ -109,26 +102,28 @@
     }
 
     private void refreshPreviewText() {
-        if (mPreviewText != null) {
-            final int styleId = mCaptioningManager.getRawUserStyle();
-            mCaptionHelper.applyCaptionProperties(mPreviewText, mPreviewViewport, styleId);
+        final SubtitleView previewText = mPreference.findViewById(R.id.preview_text);
+        if (previewText != null) {
+            final View previewViewport = mPreference.findViewById(R.id.preview_viewport);
+            final int styleId = mCaptionHelper.getRawUserStyle();
+            mCaptionHelper.applyCaptionProperties(previewText, previewViewport, styleId);
 
-            final Locale locale = mCaptioningManager.getLocale();
+            final Locale locale = mCaptionHelper.getLocale();
             if (locale != null) {
                 final CharSequence localizedText = AccessibilityUtils.getTextForLocale(
                         mContext, locale, R.string.captioning_preview_text);
-                mPreviewText.setText(localizedText);
+                previewText.setText(localizedText);
             } else {
-                mPreviewText.setText(R.string.captioning_preview_text);
+                previewText.setText(R.string.captioning_preview_text);
             }
 
-            final CaptioningManager.CaptionStyle style = mCaptioningManager.getUserStyle();
+            final View previewWindow = mPreference.findViewById(R.id.preview_window);
+            final CaptionStyle style = mCaptionHelper.getUserStyle();
             if (style.hasWindowColor()) {
-                mPreviewWindow.setBackgroundColor(style.windowColor);
+                previewWindow.setBackgroundColor(style.windowColor);
             } else {
-                final CaptioningManager.CaptionStyle defStyle =
-                        CaptioningManager.CaptionStyle.DEFAULT;
-                mPreviewWindow.setBackgroundColor(defStyle.windowColor);
+                final CaptionStyle defStyle = CaptionStyle.DEFAULT;
+                previewWindow.setBackgroundColor(defStyle.windowColor);
             }
         }
     }
diff --git a/src/com/android/settings/accessibility/CaptionTogglePreferenceController.java b/src/com/android/settings/accessibility/CaptionTogglePreferenceController.java
index bc305c1..b852002 100644
--- a/src/com/android/settings/accessibility/CaptionTogglePreferenceController.java
+++ b/src/com/android/settings/accessibility/CaptionTogglePreferenceController.java
@@ -57,9 +57,9 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        SettingsMainSwitchPreference pref = screen.findPreference(getPreferenceKey());
-        pref.addOnSwitchChangeListener(this);
-        pref.setChecked(isChecked());
+        SettingsMainSwitchPreference preference = screen.findPreference(getPreferenceKey());
+        preference.addOnSwitchChangeListener(this);
+        preference.setChecked(isChecked());
     }
 
     @Override
diff --git a/src/com/android/settings/accessibility/CaptionTypefaceController.java b/src/com/android/settings/accessibility/CaptionTypefaceController.java
index 44049b0..5e452d9 100644
--- a/src/com/android/settings/accessibility/CaptionTypefaceController.java
+++ b/src/com/android/settings/accessibility/CaptionTypefaceController.java
@@ -32,7 +32,6 @@
         implements Preference.OnPreferenceChangeListener {
 
     private final CaptionHelper mCaptionHelper;
-    private ListPreference mPreference;
 
     public CaptionTypefaceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
@@ -47,20 +46,20 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = screen.findPreference(getPreferenceKey());
-
+        final ListPreference listPreference = screen.findPreference(getPreferenceKey());
         final ContentResolver cr = mContext.getContentResolver();
         final CaptionStyle attrs = CaptionStyle.getCustomStyle(cr);
         final String rawTypeface = attrs.mRawTypeface;
-        mPreference.setValue(rawTypeface == null ? "" : rawTypeface);
+        listPreference.setValue(rawTypeface == null ? "" : rawTypeface);
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
+        final ListPreference listPreference = (ListPreference) preference;
         final ContentResolver cr = mContext.getContentResolver();
         Settings.Secure.putString(
                 cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE, (String) newValue);
-        mPreference.setValue((String) newValue);
+        listPreference.setValue((String) newValue);
         mCaptionHelper.setEnabled(true);
         return false;
     }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollBase.java b/src/com/android/settings/biometrics/BiometricEnrollBase.java
index eea1bad..75e4098 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollBase.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollBase.java
@@ -181,16 +181,6 @@
         getWindow().setStatusBarColor(getBackgroundColor());
     }
 
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
-                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
-            setResult(RESULT_TIMEOUT);
-            finish();
-        }
-    }
-
     protected boolean shouldFinishWhenBackgrounded() {
         return !WizardManagerHelper.isAnySetupWizard(getIntent());
     }
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index acfe5a1..d9f8bd1 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -242,6 +242,16 @@
     }
 
     @Override
+    protected void onStop() {
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
+                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
+        super.onStop();
+    }
+
+    @Override
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         outState.putBoolean(KEY_CONFIRMING_CREDENTIALS, mConfirmingCredentials);
diff --git a/src/com/android/settings/biometrics/BiometricHandoffActivity.java b/src/com/android/settings/biometrics/BiometricHandoffActivity.java
index 7f28ced..2b8d89b 100644
--- a/src/com/android/settings/biometrics/BiometricHandoffActivity.java
+++ b/src/com/android/settings/biometrics/BiometricHandoffActivity.java
@@ -49,6 +49,16 @@
         mFooterBarMixin.setPrimaryButton(getPrimaryFooterButton());
     }
 
+    @Override
+    protected void onStop() {
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
+                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
+        super.onStop();
+    }
+
     @NonNull
     protected FooterButton getPrimaryFooterButton() {
         if (mPrimaryFooterButton == null) {
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 3a61d5e..6f68f51 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -62,7 +62,11 @@
 
     @Override
     protected void onStop() {
-        super.onStop();
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
+                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
 
         if (mSidecar != null) {
             mSidecar.setListener(null);
@@ -80,6 +84,7 @@
             }
             finish();
         }
+        super.onStop();
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index d2d356b..cdd99a2 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -171,6 +171,16 @@
     }
 
     @Override
+    protected void onStop() {
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
+                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
+        super.onStop();
+    }
+
+    @Override
     protected boolean shouldFinishWhenBackgrounded() {
         return super.shouldFinishWhenBackgrounded() && !mNextClicked;
     }
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
index 6e99cdb..1351794 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
@@ -22,6 +22,7 @@
 
 import com.android.settings.R;
 import com.android.settings.biometrics.BiometricEnrollBase;
+import com.android.settings.biometrics.BiometricUtils;
 
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
@@ -49,6 +50,16 @@
     }
 
     @Override
+    protected void onStop() {
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
+                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
+        super.onStop();
+    }
+
+    @Override
     public int getMetricsCategory() {
         return SettingsEnums.FACE_ENROLL_FINISHED;
     }
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index ca79a24..5f9a74f 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -47,6 +47,7 @@
 import android.view.accessibility.AccessibilityManager;
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
+import android.widget.LinearLayout;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
@@ -64,10 +65,12 @@
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
 import com.google.android.setupcompat.util.WizardManagerHelper;
+import com.google.android.setupdesign.GlifLayout;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * Activity which handles the actual enrolling for fingerprint.
@@ -168,13 +171,37 @@
         mAccessibilityManager = getSystemService(AccessibilityManager.class);
         mIsAccessibilityEnabled = mAccessibilityManager.isEnabled();
 
+        final boolean isLayoutRtl = (TextUtils.getLayoutDirectionFromLocale(
+                Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL);
         listenOrientationEvent();
 
         if (mCanAssumeUdfps) {
-            if (BiometricUtils.isReverseLandscape(getApplicationContext())) {
-                setContentView(R.layout.udfps_enroll_enrolling_land);
-            } else {
-                setContentView(R.layout.udfps_enroll_enrolling);
+            switch(getApplicationContext().getDisplay().getRotation()) {
+                case Surface.ROTATION_90:
+                    final GlifLayout layout = (GlifLayout) getLayoutInflater().inflate(
+                            R.layout.udfps_enroll_enrolling, null, false);
+                    final LinearLayout layoutContainer = layout.findViewById(
+                            R.id.layout_container);
+                    final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
+                            LinearLayout.LayoutParams.MATCH_PARENT,
+                            LinearLayout.LayoutParams.MATCH_PARENT);
+
+                    lp.setMarginEnd((int) getResources().getDimension(
+                            R.dimen.rotation_90_enroll_margin_end));
+                    layoutContainer.setPaddingRelative((int) getResources().getDimension(
+                            R.dimen.rotation_90_enroll_padding_start), 0, isLayoutRtl
+                            ? 0 : (int) getResources().getDimension(
+                                    R.dimen.rotation_90_enroll_padding_end), 0);
+                    layoutContainer.setLayoutParams(lp);
+                    setContentView(layout, lp);
+                    break;
+
+                case Surface.ROTATION_0:
+                case Surface.ROTATION_180:
+                case Surface.ROTATION_270:
+                default:
+                    setContentView(R.layout.udfps_enroll_enrolling);
+                    break;
             }
             setDescriptionText(R.string.security_settings_udfps_enroll_start_message);
         } else {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 627a514..79a1065 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -249,10 +249,15 @@
 
     @Override
     protected void onStop() {
-        super.onStop();
         if (mAnimation != null) {
             mAnimation.pauseAnimation();
         }
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
+                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
+        super.onStop();
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 16773d3..05ca39c 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -109,6 +109,16 @@
     }
 
     @Override
+    protected void onStop() {
+        if (!isChangingConfigurations() && shouldFinishWhenBackgrounded()
+                && !BiometricUtils.isAnyMultiBiometricFlow(this)) {
+            setResult(RESULT_TIMEOUT);
+            finish();
+        }
+        super.onStop();
+    }
+
+    @Override
     protected void onNextButtonClick(View view) {
         updateFingerprintSuggestionEnableState();
         setResult(RESULT_FINISHED);
diff --git a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
index f7dd85a..d43b254 100644
--- a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java
@@ -19,6 +19,7 @@
 import android.app.ActivityManager;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
+import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.UserManager;
@@ -57,15 +58,34 @@
 
     private String mVolumeId;
     private VolumeInfo mVolume;
+    private final View.OnClickListener mUnmountListener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            new UnmountTask(getActivity(), mVolume).execute();
+        }
+    };
     private DiskInfo mDisk;
-
     private UsageProgressBarPreference mSummary;
-
     private Preference mMount;
     private Preference mFormatPublic;
-    private Preference mFormatPrivate;
     private Button mUnmount;
+    private final StorageEventListener mStorageListener = new StorageEventListener() {
+        @Override
+        public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
+            if (Objects.equals(mVolume.getId(), vol.getId())) {
+                mVolume = vol;
+                update();
+            }
+        }
 
+        @Override
+        public void onVolumeRecordChanged(VolumeRecord rec) {
+            if (Objects.equals(mVolume.getFsUuid(), rec.getFsUuid())) {
+                mVolume = mStorageManager.findVolumeById(mVolumeId);
+                update();
+            }
+        }
+    };
     private boolean mIsPermittedToAdopt;
 
     private boolean isVolumeValid() {
@@ -120,10 +140,7 @@
         mUnmount = new Button(getActivity());
         mUnmount.setText(R.string.storage_menu_unmount);
         mUnmount.setOnClickListener(mUnmountListener);
-        mFormatPublic = buildAction(R.string.storage_menu_format);
-        if (mIsPermittedToAdopt) {
-            mFormatPrivate = buildAction(R.string.storage_menu_format_private);
-        }
+        mFormatPublic = buildAction(R.string.storage_menu_format_option);
     }
 
     @Override
@@ -176,9 +193,6 @@
             mUnmount.setVisibility(View.GONE);
         }
         addPreference(mFormatPublic);
-        if (mDisk.isAdoptable() && mIsPermittedToAdopt) {
-            addPreference(mFormatPrivate);
-        }
     }
 
     private void addPreference(Preference pref) {
@@ -215,39 +229,14 @@
 
     @Override
     public boolean onPreferenceTreeClick(Preference pref) {
+        final Intent intent = new Intent(getActivity(), StorageWizardInit.class);
+        intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
         if (pref == mMount) {
             new MountTask(getActivity(), mVolume).execute();
         } else if (pref == mFormatPublic) {
-            StorageWizardFormatConfirm.showPublic(getActivity(), mDisk.getId());
-        } else if (pref == mFormatPrivate) {
-            StorageWizardFormatConfirm.showPrivate(getActivity(), mDisk.getId());
+            startActivity(intent);
         }
 
         return super.onPreferenceTreeClick(pref);
     }
-
-    private final View.OnClickListener mUnmountListener = new View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            new UnmountTask(getActivity(), mVolume).execute();
-        }
-    };
-
-    private final StorageEventListener mStorageListener = new StorageEventListener() {
-        @Override
-        public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
-            if (Objects.equals(mVolume.getId(), vol.getId())) {
-                mVolume = vol;
-                update();
-            }
-        }
-
-        @Override
-        public void onVolumeRecordChanged(VolumeRecord rec) {
-            if (Objects.equals(mVolume.getFsUuid(), rec.getFsUuid())) {
-                mVolume = mStorageManager.findVolumeById(mVolumeId);
-                update();
-            }
-        }
-    };
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java
index b1b956e..801baec 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardBase.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java
@@ -41,17 +41,19 @@
 import androidx.fragment.app.FragmentActivity;
 
 import com.android.settings.R;
-import com.android.settingslib.Utils;
+import com.android.settings.SetupWizardUtils;
 
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
 import com.google.android.setupdesign.GlifLayout;
+import com.google.android.setupdesign.util.ThemeHelper;
 
 import java.text.NumberFormat;
 import java.util.List;
 import java.util.Objects;
 
 public abstract class StorageWizardBase extends FragmentActivity {
+
     private static final String TAG = "StorageWizardBase";
 
     protected static final String EXTRA_FORMAT_FORGET_UUID = "format_forget_uuid";
@@ -70,6 +72,8 @@
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
+        setTheme(SetupWizardUtils.getTheme(this, getIntent()));
+        ThemeHelper.trySetDynamicColor(this);
         super.onCreate(savedInstanceState);
 
         mStorage = getSystemService(StorageManager.class);
@@ -97,20 +101,20 @@
 
         mFooterBarMixin = getGlifLayout().getMixin(FooterBarMixin.class);
         mFooterBarMixin.setSecondaryButton(
-                new FooterButton.Builder(this)
-                        .setText(R.string.wizard_back)
-                        .setListener(this::onNavigateBack)
-                        .setButtonType(FooterButton.ButtonType.OTHER)
-                        .setTheme(R.style.SudGlifButton_Secondary)
-                        .build()
+            new FooterButton.Builder(this)
+                .setText(R.string.wizard_back)
+                .setListener(this::onNavigateBack)
+                .setButtonType(FooterButton.ButtonType.OTHER)
+                .setTheme(R.style.SudGlifButton_Secondary)
+                .build()
         );
         mFooterBarMixin.setPrimaryButton(
-                new FooterButton.Builder(this)
-                        .setText(R.string.wizard_next)
-                        .setListener(this::onNavigateNext)
-                        .setButtonType(FooterButton.ButtonType.NEXT)
-                        .setTheme(R.style.SudGlifButton_Primary)
-                        .build()
+            new FooterButton.Builder(this)
+                .setText(R.string.wizard_next)
+                .setListener(this::onNavigateNext)
+                .setButtonType(FooterButton.ButtonType.NEXT)
+                .setTheme(R.style.SudGlifButton_Primary)
+                .build()
         );
         mBack = mFooterBarMixin.getSecondaryButton();
         mNext = mFooterBarMixin.getPrimaryButton();
@@ -149,7 +153,7 @@
     protected void setCurrentProgress(int progress) {
         getProgressBar().setProgress(progress);
         ((TextView) requireViewById(R.id.storage_wizard_progress_summary)).setText(
-                NumberFormat.getPercentInstance().format((double) progress / 100));
+            NumberFormat.getPercentInstance().format((double) progress / 100));
     }
 
     protected void setHeaderText(int resId, CharSequence... args) {
@@ -167,14 +171,14 @@
     protected void setAuxChecklist() {
         final FrameLayout aux = requireViewById(R.id.storage_wizard_aux);
         aux.addView(LayoutInflater.from(aux.getContext())
-                .inflate(R.layout.storage_wizard_checklist, aux, false));
+            .inflate(R.layout.storage_wizard_checklist, aux, false));
         aux.setVisibility(View.VISIBLE);
 
         // Customize string based on disk
         ((TextView) aux.requireViewById(R.id.storage_wizard_migrate_v2_checklist_media))
-                .setText(TextUtils.expandTemplate(
-                        getText(R.string.storage_wizard_migrate_v2_checklist_media),
-                        getDiskShortDescription()));
+            .setText(TextUtils.expandTemplate(
+                getText(R.string.storage_wizard_migrate_v2_checklist_media),
+                getDiskShortDescription()));
     }
 
     protected void setBackButtonText(int resId, CharSequence... args) {
@@ -198,7 +202,6 @@
     protected void setIcon(int resId) {
         final GlifLayout layout = getGlifLayout();
         final Drawable icon = getDrawable(resId).mutate();
-        icon.setTintList(Utils.getColorAccent(layout.getContext()));
         layout.setIcon(icon);
     }
 
@@ -250,14 +253,14 @@
             final List<VolumeInfo> vols = mStorage.getVolumes();
             for (VolumeInfo vol : vols) {
                 if (Objects.equals(mDisk.getId(), vol.getDiskId()) && (vol.getType() == type)
-                        && (vol.getState() == VolumeInfo.STATE_MOUNTED)) {
+                    && (vol.getState() == VolumeInfo.STATE_MOUNTED)) {
                     return vol;
                 }
             }
 
             if (--attempts > 0) {
                 Log.w(TAG, "Missing mounted volume of type " + type + " hosted by disk "
-                        + mDisk.getId() + "; trying again");
+                    + mDisk.getId() + "; trying again");
                 SystemClock.sleep(250);
             } else {
                 return null;
@@ -265,7 +268,8 @@
         }
     }
 
-    protected @NonNull CharSequence getDiskDescription() {
+    protected @NonNull
+    CharSequence getDiskDescription() {
         if (mDisk != null) {
             return mDisk.getDescription();
         } else if (mVolume != null) {
@@ -275,7 +279,8 @@
         }
     }
 
-    protected @NonNull CharSequence getDiskShortDescription() {
+    protected @NonNull
+    CharSequence getDiskShortDescription() {
         if (mDisk != null) {
             return mDisk.getShortDescription();
         } else if (mVolume != null) {
@@ -294,4 +299,4 @@
             }
         }
     };
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
index 9c18a0d..e2d8c7e 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
@@ -84,15 +84,23 @@
         builder.setTitle(TextUtils.expandTemplate(
                 getText(R.string.storage_wizard_format_confirm_v2_title),
                 disk.getShortDescription()));
-        builder.setMessage(TextUtils.expandTemplate(
-                getText(R.string.storage_wizard_format_confirm_v2_body),
+        if (formatPrivate) {
+            builder.setMessage(TextUtils.expandTemplate(
+                    getText(R.string.storage_wizard_format_confirm_v2_body),
+                    disk.getDescription(),
+                    disk.getShortDescription(),
+                    disk.getShortDescription()));
+        } else {
+            builder.setMessage(TextUtils.expandTemplate(
+                getText(R.string.storage_wizard_format_confirm_v2_body_external),
                 disk.getDescription(),
                 disk.getShortDescription(),
                 disk.getShortDescription()));
+        }
 
         builder.setNegativeButton(android.R.string.cancel, null);
         builder.setPositiveButton(
-                TextUtils.expandTemplate(getText(R.string.storage_wizard_format_confirm_v2_action),
+                TextUtils.expandTemplate(getText(R.string.storage_menu_format_option),
                         disk.getShortDescription()),
                 (dialog, which) -> {
                     final Intent intent = new Intent(context, StorageWizardFormatProgress.class);
@@ -104,4 +112,4 @@
 
         return builder.create();
     }
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
index ea4a2fd..c97d5c9 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatProgress.java
@@ -36,6 +36,7 @@
 import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
+import android.view.WindowManager;
 
 public class StorageWizardFormatProgress extends StorageWizardBase {
     private static final String TAG = "StorageWizardFormatProgress";
@@ -54,6 +55,16 @@
             return;
         }
         setContentView(R.layout.storage_wizard_progress);
+
+        // hide the navigation bar for this activity only. So that user can not press back button accidentally.
+        View decorView = getWindow().getDecorView();
+        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+        decorView.setSystemUiVisibility(uiOptions);
+
+        //disable touch in activity so user can not make the hidden navigation bar visible.
+        getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
+                     WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
+
         setKeepScreenOn(true);
 
         mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java
index 426395c..3a0f7e6 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardInit.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java
@@ -18,21 +18,27 @@
 
 import android.app.ActivityManager;
 import android.app.settings.SettingsEnums;
-import android.content.Intent;
 import android.os.Bundle;
 import android.os.UserManager;
-import android.os.storage.DiskInfo;
-import android.os.storage.VolumeInfo;
+import android.text.Html;
+import android.text.Spannable;
+import android.text.method.LinkMovementMethod;
+import android.text.style.TypefaceSpan;
+import android.text.style.URLSpan;
 import android.view.View;
-import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.ViewFlipper;
 
 import com.android.settings.R;
 import com.android.settings.overlay.FeatureFactory;
 
 public class StorageWizardInit extends StorageWizardBase {
-    private Button mInternal;
 
     private boolean mIsPermittedToAdopt;
+    private boolean mPortable;
+
+    private ViewFlipper mFlipper;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -41,63 +47,119 @@
             finish();
             return;
         }
-        setContentView(R.layout.storage_wizard_init);
 
         mIsPermittedToAdopt = UserManager.get(this).isAdminUser()
-                && !ActivityManager.isUserAMonkey();
+            && !ActivityManager.isUserAMonkey();
 
-        setHeaderText(R.string.storage_wizard_init_v2_title, getDiskShortDescription());
+        if (!mIsPermittedToAdopt) {
+            //Notify guest users as to why formatting is disallowed
+            Toast.makeText(getApplicationContext(),
+                R.string.storage_wizard_guest, Toast.LENGTH_LONG).show();
+            finish();
+            return;
+        }
 
-        mInternal = requireViewById(R.id.storage_wizard_init_internal);
+        setContentView(R.layout.storage_wizard_init);
+        setupHyperlink();
+        mPortable = true;
 
-        setBackButtonText(R.string.storage_wizard_init_v2_later);
-        setNextButtonVisibility(View.INVISIBLE);
+        mFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
+        mFlipper.setDisplayedChild(0);
+        setHeaderText(R.string.storage_wizard_init_v2_external_title,
+            getDiskShortDescription());
+
+        setNextButtonText(R.string.storage_wizard_init_v2_external_action);
+        setBackButtonText(R.string.wizard_back_adoptable);
+        setNextButtonVisibility(View.VISIBLE);
         if (!mDisk.isAdoptable()) {
-            // If not adoptable, we only have one choice
-            mInternal.setEnabled(false);
-            onNavigateExternal(null);
-        } else if (!mIsPermittedToAdopt) {
-            // TODO: Show a message about why this is disabled for guest and
-            // that only an admin user can adopt an sd card.
-            mInternal.setEnabled(false);
+            setBackButtonVisibility(View.GONE);
         }
     }
 
     @Override
-    public void onNavigateBack(View view) {
-        finish();
+    public void onBackPressed() {
+        if (mPortable) {
+            super.onBackPressed();
+        } else {
+            mFlipper.showPrevious();
+            setBackButtonText(R.string.wizard_back_adoptable);
+            setHeaderText(R.string.storage_wizard_init_v2_external_title,
+                getDiskShortDescription());
+            setNextButtonText(R.string.storage_wizard_init_v2_external_action);
+            mPortable = true;
+        }
+    }
+
+    @Override
+    public void onNavigateBack(View v) {
+        if (mPortable == false) {
+            return;
+        }
+        if (!mIsPermittedToAdopt) {
+            // TODO: Show a message about why this is disabled for guest and
+            // that only an admin user can adopt an sd card.
+
+            v.setEnabled(false);
+        } else {
+            mFlipper.showNext();
+            setHeaderText(R.string.storage_wizard_init_v2_internal_title,
+                getDiskShortDescription());
+            setNextButtonText(R.string.storage_wizard_init_v2_internal_action);
+            setBackButtonVisibility(View.INVISIBLE);
+            mPortable = false;
+        }
+    }
+
+    @Override
+    public void onNavigateNext(View v) {
+        if (mPortable) {
+            onNavigateExternal(v);
+        } else {
+            onNavigateInternal(v);
+        }
     }
 
     public void onNavigateExternal(View view) {
         if (view != null) {
             // User made an explicit choice for external
             FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
-                    SettingsEnums.ACTION_STORAGE_INIT_EXTERNAL);
+                SettingsEnums.ACTION_STORAGE_INIT_EXTERNAL);
         }
-
-        if (mVolume != null && mVolume.getType() == VolumeInfo.TYPE_PUBLIC
-                && mVolume.getState() != VolumeInfo.STATE_UNMOUNTABLE) {
-            // Remember that user made decision
-            mStorage.setVolumeInited(mVolume.getFsUuid(), true);
-
-            final Intent intent = new Intent(this, StorageWizardReady.class);
-            intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
-            startActivity(intent);
-            finish();
-
-        } else {
-            // Gotta format to get there
-            StorageWizardFormatConfirm.showPublic(this, mDisk.getId());
-        }
+        StorageWizardFormatConfirm.showPublic(this, mDisk.getId());
     }
 
     public void onNavigateInternal(View view) {
         if (view != null) {
             // User made an explicit choice for internal
             FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
-                    SettingsEnums.ACTION_STORAGE_INIT_INTERNAL);
+                SettingsEnums.ACTION_STORAGE_INIT_INTERNAL);
         }
-
         StorageWizardFormatConfirm.showPrivate(this, mDisk.getId());
     }
+
+    private void setupHyperlink() {
+        TextView external_storage_textview = findViewById(R.id.storage_wizard_init_external_text);
+        TextView internal_storage_textview = findViewById(R.id.storage_wizard_init_internal_text);
+        String external_storage_text = getResources().getString(R.string.
+            storage_wizard_init_v2_external_summary);
+        String internal_storage_text = getResources().getString(R.string.
+            storage_wizard_init_v2_internal_summary);
+
+        Spannable external_storage_spannable = styleFont(external_storage_text);
+        Spannable internal_storage_spannable = styleFont(internal_storage_text);
+        external_storage_textview.setText(external_storage_spannable);
+        internal_storage_textview.setText(internal_storage_spannable);
+
+        external_storage_textview.setMovementMethod(LinkMovementMethod.getInstance());
+        internal_storage_textview.setMovementMethod(LinkMovementMethod.getInstance());
+    }
+
+    private Spannable styleFont(String text) {
+        Spannable s = (Spannable) Html.fromHtml(text);
+        for (URLSpan span : s.getSpans(0, s.length(), URLSpan.class)) {
+            TypefaceSpan typefaceSpan = new TypefaceSpan("sans-serif-medium");
+            s.setSpan(typefaceSpan, s.getSpanStart(span), s.getSpanEnd(span), 0);
+        }
+        return s;
+    }
 }
diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
index 7e042c1..a4b29af 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateProgress.java
@@ -31,6 +31,8 @@
 
 import com.android.settings.R;
 
+import android.view.WindowManager;
+
 public class StorageWizardMigrateProgress extends StorageWizardBase {
     private static final String TAG = "StorageWizardMigrateProgress";
 
@@ -46,7 +48,16 @@
             return;
         }
         setContentView(R.layout.storage_wizard_progress);
+        
+        // hide the navigation bar for this activity only. So that user can not press back button accidentally.
+        View decorView = getWindow().getDecorView();    
+        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+        decorView.setSystemUiVisibility(uiOptions);
 
+        //disable touch in activity so user can not make the hidden navigation bar visible.
+        getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
+                     WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);         
+      
         mMoveId = getIntent().getIntExtra(EXTRA_MOVE_ID, -1);
 
         setIcon(R.drawable.ic_swap_horiz);
diff --git a/src/com/android/settings/deviceinfo/StorageWizardReady.java b/src/com/android/settings/deviceinfo/StorageWizardReady.java
index 813bcc6..8de9472 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardReady.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardReady.java
@@ -19,6 +19,7 @@
 import android.os.Bundle;
 import android.os.storage.VolumeInfo;
 import android.view.View;
+import android.widget.ImageView;
 
 import com.android.settings.R;
 
@@ -48,7 +49,9 @@
             setBodyText(R.string.storage_wizard_ready_v2_external_body,
                     getDiskDescription());
         }
-
+        ImageView img = (ImageView) findViewById(R.id.storage_wizard_body_image);
+        img.setImageResource(R.drawable.ic_storage_wizard_ready);
+        setIcon(R.drawable.ic_test_tick);
         setNextButtonText(R.string.done);
         setBackButtonVisibility(View.INVISIBLE);
     }
diff --git a/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
index 4b87e42..289db52 100644
--- a/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
+++ b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
@@ -30,6 +30,7 @@
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
+import android.widget.Toast;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.fragment.app.Fragment;
@@ -55,7 +56,9 @@
         OnPrepareOptionsMenu, OnOptionsItemSelected {
 
     private static final String TAG = "VolumeOptionMenuController";
-
+    private final Context mContext;
+    private final Fragment mFragment;
+    private final PackageManager mPackageManager;
     @VisibleForTesting
     MenuItem mRename;
     @VisibleForTesting
@@ -74,18 +77,12 @@
     MenuItem mFree;
     @VisibleForTesting
     MenuItem mForget;
-
-    private final Context mContext;
-    private final Fragment mFragment;
-    private final PackageManager mPackageManager;
-    private final StorageManager mStorageManager;
     private StorageEntry mStorageEntry;
 
     public VolumeOptionMenuController(Context context, Fragment parent, StorageEntry storageEntry) {
         mContext = context;
         mFragment = parent;
         mPackageManager = context.getPackageManager();
-        mStorageManager = context.getSystemService(StorageManager.class);
         mStorageEntry = storageEntry;
     }
 
@@ -162,12 +159,7 @@
         if (mStorageEntry.isPublic()) {
             mRename.setVisible(true);
             mUnmount.setVisible(true);
-            mFormat.setVisible(true);
-            final DiskInfo diskInfo = mStorageManager.findDiskById(mStorageEntry.getDiskId());
-            mFormatAsInternal.setVisible(diskInfo != null
-                    && diskInfo.isAdoptable()
-                    && UserManager.get(mContext).isAdminUser()
-                    && !ActivityManager.isUserAMonkey());
+            mFormatAsInternal.setVisible(true);
             return;
         }
     }
@@ -225,6 +217,16 @@
         }
         if (menuId == R.id.storage_format_as_portable) {
             if (mStorageEntry.isPrivate()) {
+                boolean mIsPermittedToAdopt = UserManager.get(mContext).isAdminUser()
+                    && !ActivityManager.isUserAMonkey();
+
+                if(!mIsPermittedToAdopt){
+                    //Notify guest users as to why formatting is disallowed
+                    Toast.makeText(mFragment.getActivity(),
+                                 R.string.storage_wizard_guest,Toast.LENGTH_LONG).show();
+                    (mFragment.getActivity()).finish();
+                    return false;
+                }
                 final Bundle args = new Bundle();
                 args.putString(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
                 new SubSettingLauncher(mContext)
@@ -239,8 +241,9 @@
         }
         if (menuId == R.id.storage_format_as_internal) {
             if (mStorageEntry.isPublic()) {
-                StorageWizardFormatConfirm.showPrivate(mFragment.getActivity(),
-                        mStorageEntry.getDiskId());
+                final Intent intent = new Intent(mFragment.getActivity(), StorageWizardInit.class);
+                intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
+                mContext.startActivity(intent);
                 return true;
             }
             return false;
@@ -269,4 +272,4 @@
 
         updateOptionsMenu();
     }
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2.java
index 6fd5f58..2932984 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2.java
@@ -20,7 +20,6 @@
 import android.content.Context;
 import android.content.res.Configuration;
 import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
@@ -28,6 +27,7 @@
 import android.text.format.DateFormat;
 import android.text.format.DateUtils;
 import android.util.Log;
+import android.view.View;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
@@ -62,22 +62,19 @@
 /** Controls the update for chart graph and the list items. */
 public class BatteryChartPreferenceControllerV2 extends AbstractPreferenceController
         implements PreferenceControllerMixin, LifecycleObserver, OnCreate, OnDestroy,
-        OnSaveInstanceState, BatteryChartViewV2.OnSelectListener, OnResume,
-        ExpandDividerPreference.OnExpandListener {
+        OnSaveInstanceState, OnResume, ExpandDividerPreference.OnExpandListener {
     private static final String TAG = "BatteryChartPreferenceControllerV2";
     private static final String KEY_FOOTER_PREF = "battery_graph_footer";
     private static final String PACKAGE_NAME_NONE = "none";
 
-    /** Desired battery history size for timestamp slots. */
-    public static final int DESIRED_HISTORY_SIZE = 25;
-    private static final int CHART_LEVEL_ARRAY_SIZE = 13;
-    private static final int CHART_KEY_ARRAY_SIZE = DESIRED_HISTORY_SIZE;
+    private static final int TWENTY_FOUR_HOURS_TIME_SLOT_SIZE = 12;
     private static final long VALID_USAGE_TIME_DURATION = DateUtils.HOUR_IN_MILLIS * 2;
     private static final long VALID_DIFF_DURATION = DateUtils.MINUTE_IN_MILLIS * 3;
 
     // Keys for bundle instance to restore configurations.
     private static final String KEY_EXPAND_SYSTEM_INFO = "expand_system_info";
-    private static final String KEY_CURRENT_TIME_SLOT = "current_time_slot";
+    private static final String KEY_DAILY_CHART_INDEX = "daily_chart_index";
+    private static final String KEY_HOURLY_CHART_INDEX = "hourly_chart_index";
 
     private static int sUiMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
 
@@ -91,23 +88,26 @@
     @VisibleForTesting
     PreferenceGroup mAppListPrefGroup;
     @VisibleForTesting
-    BatteryChartViewV2 mBatteryChartView;
-    @VisibleForTesting
     ExpandDividerPreference mExpandDividerPreference;
-
     @VisibleForTesting
     boolean mIsExpanded = false;
+
     @VisibleForTesting
-    long[] mBatteryHistoryKeys;
+    BatteryChartViewV2 mDailyChartView;
     @VisibleForTesting
-    BatteryChartViewModel mViewModel;
+    BatteryChartViewV2 mHourlyChartView;
+
     @VisibleForTesting
-    int mTrapezoidIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
+    int mDailyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
+    @VisibleForTesting
+    int mHourlyChartIndex = BatteryChartViewModel.SELECTED_INDEX_ALL;
 
     private boolean mIs24HourFormat;
     private boolean mIsFooterPrefAdded = false;
     private PreferenceScreen mPreferenceScreen;
     private FooterPreference mFooterPreference;
+    private BatteryChartViewModel mDailyViewModel;
+    private List<BatteryChartViewModel> mHourlyViewModels;
 
     private final String mPreferenceKey;
     private final SettingsActivity mActivity;
@@ -152,12 +152,14 @@
         if (savedInstanceState == null) {
             return;
         }
-        mTrapezoidIndex =
-                savedInstanceState.getInt(KEY_CURRENT_TIME_SLOT, mTrapezoidIndex);
+        mDailyChartIndex =
+                savedInstanceState.getInt(KEY_DAILY_CHART_INDEX, mDailyChartIndex);
+        mHourlyChartIndex =
+                savedInstanceState.getInt(KEY_HOURLY_CHART_INDEX, mHourlyChartIndex);
         mIsExpanded =
                 savedInstanceState.getBoolean(KEY_EXPAND_SYSTEM_INFO, mIsExpanded);
-        Log.d(TAG, String.format("onCreate() slotIndex=%d isExpanded=%b",
-                mTrapezoidIndex, mIsExpanded));
+        Log.d(TAG, String.format("onCreate() dailyIndex=%d hourlyIndex=%d isExpanded=%b",
+                mDailyChartIndex, mHourlyChartIndex, mIsExpanded));
     }
 
     @Override
@@ -179,10 +181,11 @@
         if (savedInstance == null) {
             return;
         }
-        savedInstance.putInt(KEY_CURRENT_TIME_SLOT, mTrapezoidIndex);
+        savedInstance.putInt(KEY_DAILY_CHART_INDEX, mDailyChartIndex);
+        savedInstance.putInt(KEY_HOURLY_CHART_INDEX, mHourlyChartIndex);
         savedInstance.putBoolean(KEY_EXPAND_SYSTEM_INFO, mIsExpanded);
-        Log.d(TAG, String.format("onSaveInstanceState() slotIndex=%d isExpanded=%b",
-                mTrapezoidIndex, mIsExpanded));
+        Log.d(TAG, String.format("onSaveInstanceState() dailyIndex=%d hourlyIndex=%d isExpanded=%b",
+                mDailyChartIndex, mHourlyChartIndex, mIsExpanded));
     }
 
     @Override
@@ -250,18 +253,6 @@
     }
 
     @Override
-    public void onSelect(int trapezoidIndex) {
-        Log.d(TAG, "onChartSelect:" + trapezoidIndex);
-        mTrapezoidIndex = trapezoidIndex;
-        refreshUi();
-        mMetricsFeatureProvider.action(
-                mPrefContext,
-                trapezoidIndex == BatteryChartViewModel.SELECTED_INDEX_ALL
-                        ? SettingsEnums.ACTION_BATTERY_USAGE_SHOW_ALL
-                        : SettingsEnums.ACTION_BATTERY_USAGE_TIME_SLOT);
-    }
-
-    @Override
     public void onExpand(boolean isExpanded) {
         mIsExpanded = isExpanded;
         mMetricsFeatureProvider.action(
@@ -273,68 +264,107 @@
 
     void setBatteryHistoryMap(
             final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
-        // Resets all battery history data relative variables.
-        if (batteryHistoryMap == null || batteryHistoryMap.isEmpty()) {
-            mBatteryIndexedMap = null;
-            mBatteryHistoryKeys = null;
-            mViewModel = null;
+        Log.d(TAG, "setBatteryHistoryMap() " + (batteryHistoryMap == null ? "null"
+                : ("size=" + batteryHistoryMap.size())));
+        // TODO: implement the callback function.
+        final BatteryLevelData batteryLevelData =
+                DataProcessor.getBatteryLevelData(mContext, mHandler, batteryHistoryMap, null);
+        Log.d(TAG, "getBatteryLevelData: " + batteryLevelData);
+        if (batteryLevelData == null) {
+            mDailyViewModel = null;
+            mHourlyViewModels = null;
             addFooterPreferenceIfNeeded(false);
             return;
         }
-        mBatteryHistoryKeys = getBatteryHistoryKeys(batteryHistoryMap);
-        List<Integer> levels = new ArrayList<Integer>();
-        for (int index = 0; index < CHART_LEVEL_ARRAY_SIZE; index++) {
-            final long timestamp = mBatteryHistoryKeys[index * 2];
-            final Map<String, BatteryHistEntry> entryMap = batteryHistoryMap.get(timestamp);
-            if (entryMap == null || entryMap.isEmpty()) {
-                Log.e(TAG, "abnormal entry list in the timestamp:"
-                        + ConvertUtils.utcToLocalTime(mPrefContext, timestamp));
-                levels.add(0);
-                continue;
-            }
-            // Averages the battery level in each time slot to avoid corner conditions.
-            float batteryLevelCounter = 0;
-            for (BatteryHistEntry entry : entryMap.values()) {
-                batteryLevelCounter += entry.mBatteryLevel;
-            }
-            levels.add(Math.round(batteryLevelCounter / entryMap.size()));
+        mDailyViewModel = new BatteryChartViewModel(
+                batteryLevelData.getDailyBatteryLevels().getLevels(),
+                generateTimestampDayOfWeekTexts(
+                        mContext, batteryLevelData.getDailyBatteryLevels().getTimestamps()),
+                mDailyChartIndex,
+                BatteryChartViewModel.AxisLabelPosition.CENTER_OF_TRAPEZOIDS);
+        mHourlyViewModels = new ArrayList<>();
+        for (BatteryLevelData.PeriodBatteryLevelData hourlyBatteryLevelsPerDay :
+                batteryLevelData.getHourlyBatteryLevelsPerDay()) {
+            mHourlyViewModels.add(new BatteryChartViewModel(
+                    hourlyBatteryLevelsPerDay.getLevels(),
+                    generateTimestampHourTexts(
+                            mContext, hourlyBatteryLevelsPerDay.getTimestamps()),
+                    mHourlyChartIndex,
+                    BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS));
         }
-        final List<String> texts = generateTimestampTexts(mBatteryHistoryKeys, mContext);
-        mViewModel = new BatteryChartViewModel(levels, texts, mTrapezoidIndex);
         refreshUi();
-        Log.d(TAG, String.format(
-                "setBatteryHistoryMap() size=%d key=%s\nview model=%s",
-                batteryHistoryMap.size(),
-                ConvertUtils.utcToLocalTime(mPrefContext,
-                        mBatteryHistoryKeys[mBatteryHistoryKeys.length - 1]),
-                mViewModel));
-
-        // Loads item icon and label in the background.
-        new LoadAllItemsInfoTask(batteryHistoryMap).execute();
+        // TODO: Loads item icon and label and build mBatteryIndexedMap.
     }
 
-    void setBatteryChartView(final BatteryChartViewV2 batteryChartView) {
-        if (mBatteryChartView != batteryChartView) {
-            mHandler.post(() -> setBatteryChartViewInner(batteryChartView));
+    void setBatteryChartView(@NonNull final BatteryChartViewV2 dailyChartView,
+            @NonNull final BatteryChartViewV2 hourlyChartView) {
+        if (mDailyChartView != dailyChartView || mHourlyChartView != hourlyChartView) {
+            mHandler.post(() -> setBatteryChartViewInner(dailyChartView, hourlyChartView));
         }
     }
 
-    private void setBatteryChartViewInner(final BatteryChartViewV2 batteryChartView) {
-        mBatteryChartView = batteryChartView;
-        mBatteryChartView.setOnSelectListener(this);
+    private void setBatteryChartViewInner(@NonNull final BatteryChartViewV2 dailyChartView,
+            @NonNull final BatteryChartViewV2 hourlyChartView) {
+        mDailyChartView = dailyChartView;
+        mDailyChartView.setOnSelectListener(trapezoidIndex -> {
+            if (mDailyChartIndex == trapezoidIndex) {
+                return;
+            }
+            Log.d(TAG, "onDailyChartSelect:" + trapezoidIndex);
+            mDailyChartIndex = trapezoidIndex;
+            mHourlyChartIndex = BatteryChartView.SELECTED_INDEX_ALL;
+            refreshUi();
+            // TODO: Change to log daily data.
+        });
+        mHourlyChartView = hourlyChartView;
+        mHourlyChartView.setOnSelectListener(trapezoidIndex -> {
+            if (mHourlyChartIndex == trapezoidIndex) {
+                return;
+            }
+            Log.d(TAG, "onHourlyChartSelect:" + trapezoidIndex);
+            mHourlyChartIndex = trapezoidIndex;
+            refreshUi();
+            mMetricsFeatureProvider.action(
+                    mPrefContext,
+                    trapezoidIndex == BatteryChartViewModel.SELECTED_INDEX_ALL
+                            ? SettingsEnums.ACTION_BATTERY_USAGE_SHOW_ALL
+                            : SettingsEnums.ACTION_BATTERY_USAGE_TIME_SLOT);
+        });
         refreshUi();
     }
 
     @VisibleForTesting
     boolean refreshUi() {
-        // Invalid refresh condition.
-        if (mBatteryIndexedMap == null || mBatteryChartView == null) {
+        if (mBatteryIndexedMap == null || mDailyChartView == null || mHourlyChartView == null) {
             return false;
         }
-        if (mViewModel != null) {
-            mViewModel.setSelectedIndex(mTrapezoidIndex);
+
+        if (mDailyViewModel == null || mHourlyViewModels == null) {
+            // Fail to get battery level data, show an empty hourly chart view.
+            mDailyChartView.setVisibility(View.GONE);
+            mHourlyChartView.setViewModel(null);
+            return false;
         }
-        mBatteryChartView.setViewModel(mViewModel);
+
+        if (isBatteryLevelDataInOneDay()) {
+            // Only 1 day data, hide the daily chart view.
+            mDailyChartView.setVisibility(View.GONE);
+            mDailyChartIndex = 0;
+        } else {
+            mDailyChartView.setVisibility(View.VISIBLE);
+            mDailyViewModel.setSelectedIndex(mDailyChartIndex);
+            mDailyChartView.setViewModel(mDailyViewModel);
+        }
+
+        if (mDailyChartIndex == BatteryChartViewModel.SELECTED_INDEX_ALL) {
+            // Multiple days are selected, hide the hourly chart view.
+            mHourlyChartView.setVisibility(View.GONE);
+        } else {
+            mHourlyChartView.setVisibility(View.VISIBLE);
+            final BatteryChartViewModel hourlyViewModel = mHourlyViewModels.get(mDailyChartIndex);
+            hourlyViewModel.setSelectedIndex(mHourlyChartIndex);
+            mHourlyChartView.setViewModel(hourlyViewModel);
+        }
 
         mHandler.post(() -> {
             final long start = System.currentTimeMillis();
@@ -348,11 +378,13 @@
     }
 
     private void addAllPreferences() {
+        // TODO: Get the right diff entry according to daily and hourly chart selection.
+        final int index = mDailyChartIndex;
         final List<BatteryDiffEntry> entries =
-                mBatteryIndexedMap.get(Integer.valueOf(mTrapezoidIndex));
+                mBatteryIndexedMap.get(Integer.valueOf(index));
         addFooterPreferenceIfNeeded(entries != null && !entries.isEmpty());
         if (entries == null) {
-            Log.w(TAG, "cannot find BatteryDiffEntry for:" + mTrapezoidIndex);
+            Log.w(TAG, "cannot find BatteryDiffEntry for:" + index);
             return;
         }
         // Separates data into two groups and sort them individually.
@@ -370,7 +402,7 @@
                 appEntries.add(entry);
             }
             // Validates the usage time if users click a specific slot.
-            if (mTrapezoidIndex >= 0) {
+            if (index >= 0) {
                 validateUsageTime(entry);
             }
         });
@@ -488,6 +520,7 @@
     }
 
     private String getSlotInformation(boolean isApp, String slotInformation) {
+        // TODO: Updates the right slot information from daily and hourly chart selection.
         // Null means we show all information without a specific time slot.
         if (slotInformation == null) {
             return isApp
@@ -501,16 +534,8 @@
     }
 
     private String getSlotInformation() {
-        if (mTrapezoidIndex < 0) {
-            return null;
-        }
-        final String fromHour = ConvertUtils.utcToLocalTimeHour(mPrefContext,
-                mBatteryHistoryKeys[mTrapezoidIndex * 2], mIs24HourFormat);
-        final String toHour = ConvertUtils.utcToLocalTimeHour(mPrefContext,
-                mBatteryHistoryKeys[(mTrapezoidIndex + 1) * 2], mIs24HourFormat);
-        return mIs24HourFormat
-                ? String.format("%s–%s", fromHour, toHour)
-                : String.format("%s – %s", fromHour, toHour);
+        // TODO: Generate the right slot information from daily and hourly chart selection.
+        return null;
     }
 
     @VisibleForTesting
@@ -584,13 +609,25 @@
         mHandler.post(() -> mPreferenceScreen.addPreference(mFooterPreference));
     }
 
-    private static List<String> generateTimestampTexts(
-            @NonNull long[] timestamps, Context context) {
+    private boolean isBatteryLevelDataInOneDay() {
+        return mHourlyViewModels.size() == 1;
+    }
+
+    private static List<String> generateTimestampDayOfWeekTexts(
+            @NonNull final Context context, @NonNull final List<Long> timestamps) {
+        final ArrayList<String> texts = new ArrayList<>();
+        for (Long timestamp : timestamps) {
+            texts.add(ConvertUtils.utcToLocalTimeDayOfWeek(context, timestamp));
+        }
+        return texts;
+    }
+
+    private static List<String> generateTimestampHourTexts(
+            @NonNull final Context context, @NonNull final List<Long> timestamps) {
         final boolean is24HourFormat = DateFormat.is24HourFormat(context);
-        final List<String> texts = new ArrayList<String>();
-        for (int index = 0; index < CHART_LEVEL_ARRAY_SIZE; index++) {
-            texts.add(ConvertUtils.utcToLocalTimeHour(context, timestamps[index * 2],
-                    is24HourFormat));
+        final ArrayList<String> texts = new ArrayList<>();
+        for (Long timestamp : timestamps) {
+            texts.add(ConvertUtils.utcToLocalTimeHour(context, timestamp, is24HourFormat));
         }
         return texts;
     }
@@ -620,6 +657,8 @@
         return true;
     }
 
+    // TODO: Change this method to fromLastFullCharged.
+
     /** Used for {@link AppBatteryPreferenceController}. */
     public static List<BatteryDiffEntry> getBatteryLast24HrUsageData(Context context) {
         final long start = System.currentTimeMillis();
@@ -632,16 +671,27 @@
         }
         Log.d(TAG, String.format("getBatteryLast24HrData() size=%d time=%d/ms",
                 batteryHistoryMap.size(), (System.currentTimeMillis() - start)));
+
+        final List<Long> batteryHistoryKeyList =
+                new ArrayList<>(batteryHistoryMap.keySet());
+        Collections.sort(batteryHistoryKeyList);
+        final long[] batteryHistoryKeys = new long[TWENTY_FOUR_HOURS_TIME_SLOT_SIZE + 1];
+        for (int index = 0; index < batteryHistoryKeys.length; index++) {
+            batteryHistoryKeys[index] = batteryHistoryKeyList.get(index);
+        }
+
         final Map<Integer, List<BatteryDiffEntry>> batteryIndexedMap =
                 ConvertUtils.getIndexedUsageMap(
                         context,
-                        /*timeSlotSize=*/ CHART_LEVEL_ARRAY_SIZE - 1,
-                        getBatteryHistoryKeys(batteryHistoryMap),
+                        /*timeSlotSize=*/ TWENTY_FOUR_HOURS_TIME_SLOT_SIZE,
+                        batteryHistoryKeys,
                         batteryHistoryMap,
                         /*purgeLowPercentageAndFakeData=*/ true);
         return batteryIndexedMap.get(BatteryChartViewModel.SELECTED_INDEX_ALL);
     }
 
+    // TODO: Change this method to fromLastFullCharged.
+
     /** Used for {@link AppBatteryPreferenceController}. */
     public static BatteryDiffEntry getBatteryLast24HrUsageData(
             Context context, String packageName, int userId) {
@@ -663,65 +713,4 @@
         }
         return null;
     }
-
-    private static long[] getBatteryHistoryKeys(
-            final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
-        final List<Long> batteryHistoryKeyList =
-                new ArrayList<>(batteryHistoryMap.keySet());
-        Collections.sort(batteryHistoryKeyList);
-        final long[] batteryHistoryKeys = new long[CHART_KEY_ARRAY_SIZE];
-        for (int index = 0; index < CHART_KEY_ARRAY_SIZE; index++) {
-            batteryHistoryKeys[index] = batteryHistoryKeyList.get(index);
-        }
-        return batteryHistoryKeys;
-    }
-
-    // Loads all items icon and label in the background.
-    private final class LoadAllItemsInfoTask
-            extends AsyncTask<Void, Void, Map<Integer, List<BatteryDiffEntry>>> {
-
-        private long[] mBatteryHistoryKeysCache;
-        private Map<Long, Map<String, BatteryHistEntry>> mBatteryHistoryMap;
-
-        private LoadAllItemsInfoTask(
-                Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
-            this.mBatteryHistoryMap = batteryHistoryMap;
-            this.mBatteryHistoryKeysCache = mBatteryHistoryKeys;
-        }
-
-        @Override
-        protected Map<Integer, List<BatteryDiffEntry>> doInBackground(Void... voids) {
-            if (mPrefContext == null || mBatteryHistoryKeysCache == null) {
-                return null;
-            }
-            final long startTime = System.currentTimeMillis();
-            final Map<Integer, List<BatteryDiffEntry>> indexedUsageMap =
-                    ConvertUtils.getIndexedUsageMap(
-                            mPrefContext, /*timeSlotSize=*/ CHART_LEVEL_ARRAY_SIZE - 1,
-                            mBatteryHistoryKeysCache, mBatteryHistoryMap,
-                            /*purgeLowPercentageAndFakeData=*/ true);
-            // Pre-loads each BatteryDiffEntry relative icon and label for all slots.
-            for (List<BatteryDiffEntry> entries : indexedUsageMap.values()) {
-                entries.forEach(entry -> entry.loadLabelAndIcon());
-            }
-            Log.d(TAG, String.format("execute LoadAllItemsInfoTask in %d/ms",
-                    (System.currentTimeMillis() - startTime)));
-            return indexedUsageMap;
-        }
-
-        @Override
-        protected void onPostExecute(
-                Map<Integer, List<BatteryDiffEntry>> indexedUsageMap) {
-            mBatteryHistoryMap = null;
-            mBatteryHistoryKeysCache = null;
-            if (indexedUsageMap == null) {
-                return;
-            }
-            // Posts results back to main thread to refresh UI.
-            mHandler.post(() -> {
-                mBatteryIndexedMap = indexedUsageMap;
-                refreshUi();
-            });
-        }
-    }
 }
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewModel.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewModel.java
index 74f87fd..493891f 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewModel.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewModel.java
@@ -33,23 +33,31 @@
     // We need at least 2 levels to draw a trapezoid.
     private static final int MIN_LEVELS_DATA_SIZE = 2;
 
+    enum AxisLabelPosition {
+        BETWEEN_TRAPEZOIDS,
+        CENTER_OF_TRAPEZOIDS,
+    }
+
     private final List<Integer> mLevels;
     private final List<String> mTexts;
+    private final AxisLabelPosition mAxisLabelPosition;
     private int mSelectedIndex;
 
     BatteryChartViewModel(
-            @NonNull List<Integer> levels, @NonNull List<String> texts, int selectedIndex) {
+            @NonNull List<Integer> levels, @NonNull List<String> texts, int selectedIndex,
+            @NonNull AxisLabelPosition axisLabelPosition) {
         Preconditions.checkArgument(
                 levels.size() == texts.size()
                         && levels.size() >= MIN_LEVELS_DATA_SIZE
                         && selectedIndex >= SELECTED_INDEX_ALL
                         && selectedIndex < levels.size(),
-                String.format(Locale.getDefault(), "Invalid BatteryChartViewModel"
+                String.format(Locale.ENGLISH, "Invalid BatteryChartViewModel"
                                 + "  levels.size: %d\ntexts.size: %d\nselectedIndex: %d.",
                         levels.size(), texts.size(), selectedIndex));
         mLevels = levels;
         mTexts = texts;
         mSelectedIndex = selectedIndex;
+        mAxisLabelPosition = axisLabelPosition;
     }
 
     public int size() {
@@ -72,9 +80,13 @@
         mSelectedIndex = index;
     }
 
+    public AxisLabelPosition axisLabelPosition() {
+        return mAxisLabelPosition;
+    }
+
     @Override
     public int hashCode() {
-        return Objects.hash(mLevels, mTexts, mSelectedIndex);
+        return Objects.hash(mLevels, mTexts, mSelectedIndex, mAxisLabelPosition);
     }
 
     @Override
@@ -87,12 +99,15 @@
         final BatteryChartViewModel batteryChartViewModel = (BatteryChartViewModel) other;
         return Objects.equals(mLevels, batteryChartViewModel.mLevels)
                 && Objects.equals(mTexts, batteryChartViewModel.mTexts)
-                && mSelectedIndex == batteryChartViewModel.mSelectedIndex;
+                && mSelectedIndex == batteryChartViewModel.mSelectedIndex
+                && mAxisLabelPosition == batteryChartViewModel.mAxisLabelPosition;
     }
 
     @Override
     public String toString() {
-        return String.format(Locale.getDefault(), "levels: %s\ntexts: %s\nselectedIndex: %d",
-                Objects.toString(mLevels), Objects.toString(mTexts), mSelectedIndex);
+        return String.format(Locale.ENGLISH,
+                "levels: %s\ntexts: %s\nselectedIndex: %d, axisLabelPosition: %s",
+                Objects.toString(mLevels), Objects.toString(mTexts), mSelectedIndex,
+                mAxisLabelPosition);
     }
 }
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2.java
index 0995a08..bbe1a8f 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2.java
@@ -47,8 +47,11 @@
 import com.android.settingslib.Utils;
 
 import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
 /** A widget component to draw chart graph. */
 public class BatteryChartViewV2 extends AppCompatImageView implements View.OnClickListener,
@@ -57,10 +60,10 @@
     private static final List<String> ACCESSIBILITY_SERVICE_NAMES =
             Arrays.asList("SwitchAccessService", "TalkBackService", "JustSpeakService");
 
-    private static final int DEFAULT_AXIS_LABEL_COUNT = 4;
-    private static final int AXIS_LABEL_GAPS_COUNT = DEFAULT_AXIS_LABEL_COUNT - 1;
     private static final int DIVIDER_COLOR = Color.parseColor("#CDCCC5");
     private static final long UPDATE_STATE_DELAYED_TIME = 500L;
+    private static final Map<Integer, Integer[]> MODEL_SIZE_TO_LABEL_INDEXES_MAP =
+            buildModelSizeToLabelIndexesMap();
 
     /** A callback listener for selected group index is updated. */
     public interface OnSelectListener {
@@ -76,11 +79,10 @@
     private float mTrapezoidHOffset;
     private boolean mIsSlotsClickabled;
     private String[] mPercentages = getPercentages();
+    private Integer[] mLabelsIndexes;
 
     @VisibleForTesting
     int mHoveredIndex = BatteryChartViewModel.SELECTED_INDEX_INVALID;
-    @VisibleForTesting
-    String[] mAxisLabels;
 
     // Colors for drawing the trapezoid shape and dividers.
     private int mTrapezoidColor;
@@ -92,8 +94,7 @@
     private final Rect[] mPercentageBounds =
             new Rect[]{new Rect(), new Rect(), new Rect()};
     // For drawing the axis label information.
-    private final Rect[] mAxisLabelsBounds =
-            new Rect[]{new Rect(), new Rect(), new Rect(), new Rect()};
+    private final Rect[] mAxisLabelsBounds = initializeAxisLabelsBounds();
 
     @VisibleForTesting
     Handler mHandler = new Handler();
@@ -137,9 +138,8 @@
         Log.d(TAG, String.format("setViewModel(): size: %d, selectedIndex: %d.",
                 viewModel.size(), viewModel.selectedIndex()));
         mViewModel = viewModel;
-
+        mLabelsIndexes = MODEL_SIZE_TO_LABEL_INDEXES_MAP.get(mViewModel.size());
         initializeTrapezoidSlots(viewModel.size() - 1);
-        initializeAxisLabels(viewModel.texts());
         setClickable(hasAnyValidTrapezoid(viewModel));
         requestLayout();
     }
@@ -176,12 +176,11 @@
             mIndent.top = mPercentageBounds[0].height();
             mIndent.right = mPercentageBounds[0].width() + mTextPadding;
 
-            if (mAxisLabels != null) {
+            if (mViewModel != null) {
                 int maxHeight = 0;
-                for (int index = 0; index < DEFAULT_AXIS_LABEL_COUNT; index++) {
-                    mTextPaint.getTextBounds(
-                            mAxisLabels[index], 0, mAxisLabels[index].length(),
-                            mAxisLabelsBounds[index]);
+                for (int index = 0; index < mLabelsIndexes.length; index++) {
+                    final String text = getAxisLabelText(index);
+                    mTextPaint.getTextBounds(text, 0, text.length(), mAxisLabelsBounds[index]);
                     maxHeight = Math.max(maxHeight, mAxisLabelsBounds[index].height());
                 }
                 mIndent.bottom = maxHeight + round(mTextPadding * 1.5f);
@@ -333,21 +332,6 @@
         }
     }
 
-    /**
-     * Initializes the displayed X-axis labels list selected from the model all texts list.
-     */
-    private void initializeAxisLabels(@NonNull List<String> allTexts) {
-        if (mAxisLabels == null) {
-            mAxisLabels = new String[DEFAULT_AXIS_LABEL_COUNT];
-        }
-        // Current logic is always showing {@code AXIS_LABEL_GAPS_COUNT} labels.
-        // TODO: Support different count of labels for different levels sizes.
-        final int step = (allTexts.size() - 1) / AXIS_LABEL_GAPS_COUNT;
-        for (int index = 0; index < DEFAULT_AXIS_LABEL_COUNT; index++) {
-            mAxisLabels[index] = allTexts.get(index * step);
-        }
-    }
-
     private void initializeColors(Context context) {
         setBackgroundColor(Color.TRANSPARENT);
         mTrapezoidSolidColor = Utils.getColorAccentDefaultColor(context);
@@ -432,37 +416,43 @@
             startX = nextX;
         }
         // Draws the axis label slot information.
-        if (mAxisLabels != null) {
-            final float[] xOffsets = new float[DEFAULT_AXIS_LABEL_COUNT];
+        if (mViewModel != null) {
+            final float[] xOffsets = new float[mLabelsIndexes.length];
             final float baselineX = mDividerWidth * .5f;
             final float offsetX = mDividerWidth + unitWidth;
-            // TODO: Support different count of labels for different levels sizes.
-            final int slotBarOffset = (/*total 12 bars*/ 12) / AXIS_LABEL_GAPS_COUNT;
-            for (int index = 0; index < DEFAULT_AXIS_LABEL_COUNT; index++) {
-                xOffsets[index] = baselineX + index * offsetX * slotBarOffset;
+            for (int index = 0; index < mLabelsIndexes.length; index++) {
+                xOffsets[index] = baselineX + mLabelsIndexes[index] * offsetX;
             }
-            drawAxisLabel(canvas, xOffsets);
+            switch (mViewModel.axisLabelPosition()) {
+                case CENTER_OF_TRAPEZOIDS:
+                    drawAxisLabelsCenterOfTrapezoids(canvas, xOffsets, unitWidth);
+                    break;
+                case BETWEEN_TRAPEZOIDS:
+                default:
+                    drawAxisLabelsBetweenTrapezoids(canvas, xOffsets);
+                    break;
+            }
         }
     }
 
-    private void drawAxisLabel(Canvas canvas, float[] xOffsets) {
+    private void drawAxisLabelsBetweenTrapezoids(Canvas canvas, float[] xOffsets) {
         // Draws the 1st axis label info.
         canvas.drawText(
-                mAxisLabels[0], xOffsets[0] - mAxisLabelsBounds[0].left, getAxisLabelY(0),
+                getAxisLabelText(0), xOffsets[0] - mAxisLabelsBounds[0].left, getAxisLabelY(0),
                 mTextPaint);
-        final int latestIndex = DEFAULT_AXIS_LABEL_COUNT - 1;
+        final int latestIndex = mLabelsIndexes.length - 1;
         // Draws the last axis label info.
         canvas.drawText(
-                mAxisLabels[latestIndex],
+                getAxisLabelText(latestIndex),
                 xOffsets[latestIndex]
                         - mAxisLabelsBounds[latestIndex].width()
                         - mAxisLabelsBounds[latestIndex].left,
                 getAxisLabelY(latestIndex),
                 mTextPaint);
         // Draws the rest of axis label info since it is located in the center.
-        for (int index = 1; index <= DEFAULT_AXIS_LABEL_COUNT - 2; index++) {
+        for (int index = 1; index <= mLabelsIndexes.length - 2; index++) {
             canvas.drawText(
-                    mAxisLabels[index],
+                    getAxisLabelText(index),
                     xOffsets[index]
                             - (mAxisLabelsBounds[index].width() - mAxisLabelsBounds[index].left)
                             * .5f,
@@ -471,6 +461,18 @@
         }
     }
 
+    private void drawAxisLabelsCenterOfTrapezoids(
+            Canvas canvas, float[] xOffsets, float unitWidth) {
+        for (int index = 0; index < mLabelsIndexes.length - 1; index++) {
+            canvas.drawText(
+                    getAxisLabelText(index),
+                    xOffsets[index] + (unitWidth - (mAxisLabelsBounds[index].width()
+                            - mAxisLabelsBounds[index].left)) * .5f,
+                    getAxisLabelY(index),
+                    mTextPaint);
+        }
+    }
+
     private int getAxisLabelY(int index) {
         return getHeight()
                 - mAxisLabelsBounds[index].height()
@@ -554,6 +556,10 @@
         return BatteryChartViewModel.SELECTED_INDEX_INVALID;
     }
 
+    private String getAxisLabelText(int labelIndex) {
+        return mViewModel.texts().get(mLabelsIndexes[labelIndex]);
+    }
+
     private static boolean isTrapezoidValid(
             @NonNull BatteryChartViewModel viewModel, int trapezoidIndex) {
         return viewModel.levels().get(trapezoidIndex) != null
@@ -607,6 +613,33 @@
         return false;
     }
 
+    private static Map<Integer, Integer[]> buildModelSizeToLabelIndexesMap() {
+        final Map<Integer, Integer[]> result = new HashMap<>();
+        result.put(2, new Integer[]{0, 1});
+        result.put(3, new Integer[]{0, 1, 2});
+        result.put(4, new Integer[]{0, 1, 2, 3});
+        result.put(5, new Integer[]{0, 1, 2, 3, 4});
+        result.put(6, new Integer[]{0, 1, 2, 3, 4, 5});
+        result.put(7, new Integer[]{0, 1, 2, 3, 4, 5, 6});
+        result.put(8, new Integer[]{0, 1, 2, 3, 4, 5, 6, 7});
+        result.put(9, new Integer[]{0, 2, 4, 6, 8});
+        result.put(10, new Integer[]{0, 3, 6, 9});
+        result.put(11, new Integer[]{0, 5, 10});
+        result.put(12, new Integer[]{0, 4, 7, 11});
+        result.put(13, new Integer[]{0, 4, 8, 12});
+        return result;
+    }
+
+    private static Rect[] initializeAxisLabelsBounds() {
+        final int maxLabelsLength = MODEL_SIZE_TO_LABEL_INDEXES_MAP.values().stream().max(
+                Comparator.comparingInt(indexes -> indexes.length)).get().length;
+        final Rect[] bounds = new Rect[maxLabelsLength];
+        for (int i = 0; i < maxLabelsLength; i++) {
+            bounds[i] = new Rect();
+        }
+        return bounds;
+    }
+
     // A container class for each trapezoid left and right location.
     @VisibleForTesting
     static final class TrapezoidSlot {
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffData.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffData.java
index 5743cac..b5d4dde 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffData.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryDiffData.java
@@ -16,7 +16,9 @@
 
 package com.android.settings.fuelgauge.batteryusage;
 
-import java.util.ArrayList;
+import androidx.annotation.NonNull;
+
+import java.util.Collections;
 import java.util.List;
 
 /** Wraps the battery usage diff data for each entry used for battery usage app list. */
@@ -24,10 +26,24 @@
     private final List<BatteryDiffEntry> mAppEntries;
     private final List<BatteryDiffEntry> mSystemEntries;
 
+    /** Constructor for the diff entries which already have totalConsumePower value. */
     public BatteryDiffData(
-            List<BatteryDiffEntry> appDiffEntries, List<BatteryDiffEntry> systemDiffEntries) {
-        mAppEntries = appDiffEntries == null ? new ArrayList<>() : appDiffEntries;
-        mSystemEntries = systemDiffEntries == null ? new ArrayList<>() : systemDiffEntries;
+            @NonNull List<BatteryDiffEntry> appDiffEntries,
+            @NonNull List<BatteryDiffEntry> systemDiffEntries) {
+        mAppEntries = appDiffEntries;
+        mSystemEntries = systemDiffEntries;
+        sortEntries();
+    }
+
+    /** Constructor for the diff entries which have not set totalConsumePower value. */
+    public BatteryDiffData(
+            @NonNull List<BatteryDiffEntry> appDiffEntries,
+            @NonNull List<BatteryDiffEntry> systemDiffEntries,
+            final double totalConsumePower) {
+        mAppEntries = appDiffEntries;
+        mSystemEntries = systemDiffEntries;
+        setTotalConsumePowerForAllEntries(totalConsumePower);
+        sortEntries();
     }
 
     public List<BatteryDiffEntry> getAppDiffEntryList() {
@@ -38,9 +54,15 @@
         return mSystemEntries;
     }
 
-    /** Sets total consume power for each entry. */
-    public void setTotalConsumePowerForAllEntries(double totalConsumePower) {
+    // Sets total consume power for each entry.
+    private void setTotalConsumePowerForAllEntries(final double totalConsumePower) {
         mAppEntries.forEach(diffEntry -> diffEntry.setTotalConsumePower(totalConsumePower));
         mSystemEntries.forEach(diffEntry -> diffEntry.setTotalConsumePower(totalConsumePower));
     }
+
+    // Sorts entries based on consumed percentage.
+    private void sortEntries() {
+        Collections.sort(mAppEntries, BatteryDiffEntry.COMPARATOR);
+        Collections.sort(mSystemEntries, BatteryDiffEntry.COMPARATOR);
+    }
 }
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryLevelData.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryLevelData.java
index 64f519a..4ff9eeb 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryLevelData.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryLevelData.java
@@ -20,6 +20,8 @@
 import androidx.core.util.Preconditions;
 
 import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
 
 /** Wraps the battery timestamp and level data used for battery usage chart. */
 public final class BatteryLevelData {
@@ -46,6 +48,12 @@
         public List<Integer> getLevels() {
             return mLevels;
         }
+
+        @Override
+        public String toString() {
+            return String.format(Locale.ENGLISH, "timestamps: %s; levels: %s",
+                    Objects.toString(mTimestamps), Objects.toString(mLevels));
+        }
     }
 
     /**
@@ -78,4 +86,13 @@
     public List<PeriodBatteryLevelData> getHourlyBatteryLevelsPerDay() {
         return mHourlyBatteryLevelsPerDay;
     }
-}
\ No newline at end of file
+
+    @Override
+    public String toString() {
+        return String.format(Locale.ENGLISH,
+                "dailyBatteryLevels: %s; hourlyBatteryLevelsPerDay: %s",
+                Objects.toString(mDailyBatteryLevels),
+                Objects.toString(mHourlyBatteryLevelsPerDay));
+    }
+}
+
diff --git a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
index 168fe0f..b89bfe6 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
@@ -140,7 +140,7 @@
 
     /** Converts UTC timestamp to local time hour data. */
     public static String utcToLocalTimeHour(
-            Context context, long timestamp, boolean is24HourFormat) {
+            final Context context, final long timestamp, final boolean is24HourFormat) {
         final Locale locale = getLocale(context);
         // e.g. for 12-hour format: 9 pm
         // e.g. for 24-hour format: 09:00
@@ -149,6 +149,13 @@
         return DateFormat.format(pattern, timestamp).toString().toLowerCase(locale);
     }
 
+    /** Converts UTC timestamp to local time day of week data. */
+    public static String utcToLocalTimeDayOfWeek(final Context context, final long timestamp) {
+        final Locale locale = getLocale(context);
+        final String pattern = DateFormat.getBestDateTimePattern(locale, "E");
+        return DateFormat.format(pattern, timestamp).toString().toUpperCase(locale);
+    }
+
     /** Gets indexed battery usage data for each corresponding time slot. */
     public static Map<Integer, List<BatteryDiffEntry>> getIndexedUsageMap(
             final Context context,
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
index d8650a6..a004a51 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
@@ -18,21 +18,36 @@
 
 import static com.android.settings.fuelgauge.batteryusage.ConvertUtils.utcToLocalTime;
 
+import android.content.ContentValues;
 import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.text.TextUtils;
 import android.text.format.DateUtils;
+import android.util.ArraySet;
 import android.util.Log;
 
 import androidx.annotation.Nullable;
 
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.Utils;
+import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.fuelgauge.BatteryStatus;
 
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * A utility class to process data loaded from database and make the data easy to use for battery
@@ -43,10 +58,27 @@
     private static final String TAG = "DataProcessor";
     private static final int MIN_DAILY_DATA_SIZE = 2;
     private static final int MIN_TIMESTAMP_DATA_SIZE = 2;
+    // Maximum total time value for each hourly slot cumulative data at most 2 hours.
+    private static final float TOTAL_HOURLY_TIME_THRESHOLD = DateUtils.HOUR_IN_MILLIS * 2;
+    private static final Map<String, BatteryHistEntry> EMPTY_BATTERY_MAP = new HashMap<>();
+    private static final BatteryHistEntry EMPTY_BATTERY_HIST_ENTRY =
+            new BatteryHistEntry(new ContentValues());
+
+    @VisibleForTesting
+    static final double PERCENTAGE_OF_TOTAL_THRESHOLD = 1f;
+    @VisibleForTesting
+    static final int SELECTED_INDEX_ALL = BatteryChartViewModel.SELECTED_INDEX_ALL;
 
     /** A fake package name to represent no BatteryEntry data. */
     public static final String FAKE_PACKAGE_NAME = "fake_package";
 
+    /** A callback listener when battery usage loading async task is executed. */
+    public interface UsageMapAsyncResponse {
+        /** The callback function when batteryUsageMap is loaded. */
+        void onBatteryUsageMapLoaded(
+                Map<Integer, Map<Integer, BatteryDiffData>> batteryUsageMap);
+    }
+
     private DataProcessor() {
     }
 
@@ -58,11 +90,14 @@
     @Nullable
     public static BatteryLevelData getBatteryLevelData(
             Context context,
-            @Nullable final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
+            @Nullable Handler handler,
+            @Nullable final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap,
+            final UsageMapAsyncResponse asyncResponseDelegate) {
         if (batteryHistoryMap == null || batteryHistoryMap.isEmpty()) {
             Log.d(TAG, "getBatteryLevelData() returns null");
             return null;
         }
+        handler = handler != null ? handler : new Handler(Looper.getMainLooper());
         // Process raw history map data into hourly timestamps.
         final Map<Long, Map<String, BatteryHistEntry>> processedBatteryHistoryMap =
                 getHistoryMapWithExpectedTimestamps(context, batteryHistoryMap);
@@ -70,12 +105,34 @@
         final BatteryLevelData batteryLevelData =
                 getLevelDataThroughProcessedHistoryMap(context, processedBatteryHistoryMap);
 
-        //TODO: Add the async task to compute diff usage data and load labels and icons.
+        // Start the async task to compute diff usage data and load labels and icons.
+        if (batteryLevelData != null) {
+            new ComputeUsageMapAndLoadItemsTask(
+                    context,
+                    handler,
+                    asyncResponseDelegate,
+                    batteryLevelData.getHourlyBatteryLevelsPerDay(),
+                    processedBatteryHistoryMap).execute();
+        }
 
         return batteryLevelData;
     }
 
     /**
+     * @return Returns whether the target is in the CharSequence array.
+     */
+    public static boolean contains(String target, CharSequence[] packageNames) {
+        if (target != null && packageNames != null) {
+            for (CharSequence packageName : packageNames) {
+                if (TextUtils.equals(target, packageName)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
      * @return Returns the processed history map which has interpolated to every hour data.
      * The start and end timestamp must be the even hours.
      * The keys of processed history map should contain every hour between the start and end
@@ -187,7 +244,7 @@
     @VisibleForTesting
     static boolean isFromFullCharge(@Nullable final Map<String, BatteryHistEntry> entryList) {
         if (entryList == null) {
-            Log.d(TAG, "entryList is nul in isFromFullCharge()");
+            Log.d(TAG, "entryList is null in isFromFullCharge()");
             return false;
         }
         final List<String> entryKeys = new ArrayList<>(entryList.keySet());
@@ -205,14 +262,14 @@
     static long[] findNearestTimestamp(final List<Long> timestamps, final long target) {
         final long[] results = new long[] {Long.MIN_VALUE, Long.MAX_VALUE};
         // Searches the nearest lower and upper timestamp value.
-        for (long timestamp : timestamps) {
+        timestamps.forEach(timestamp -> {
             if (timestamp <= target && timestamp > results[0]) {
                 results[0] = timestamp;
             }
             if (timestamp >= target && timestamp < results[1]) {
                 results[1] = timestamp;
             }
-        }
+        });
         // Uses zero value to represent invalid searching result.
         results[0] = results[0] == Long.MIN_VALUE ? 0 : results[0];
         results[1] = results[1] == Long.MAX_VALUE ? 0 : results[1];
@@ -224,7 +281,7 @@
      * timezone.
      */
     @VisibleForTesting
-     static long getTimestampOfNextDay(long timestamp) {
+    static long getTimestampOfNextDay(long timestamp) {
         final Calendar nextDayCalendar = Calendar.getInstance();
         nextDayCalendar.setTimeInMillis(timestamp);
         nextDayCalendar.add(Calendar.DAY_OF_YEAR, 1);
@@ -235,6 +292,40 @@
     }
 
     /**
+     * @return Returns the indexed battery usage data for each corresponding time slot.
+     *
+     * There could be 2 cases of the returned value:
+     * 1) null: empty or invalid data.
+     * 2) non-null: must be a 2d map and composed by 3 parts:
+     *    1 - [SELECTED_INDEX_ALL][SELECTED_INDEX_ALL]
+     *    2 - [0][SELECTED_INDEX_ALL] ~ [maxDailyIndex][SELECTED_INDEX_ALL]
+     *    3 - [0][0] ~ [maxDailyIndex][maxHourlyIndex]
+     */
+    @VisibleForTesting
+    @Nullable
+    static Map<Integer, Map<Integer, BatteryDiffData>> getBatteryUsageMap(
+            final Context context,
+            final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay,
+            final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
+        if (batteryHistoryMap.isEmpty()) {
+            return null;
+        }
+        final Map<Integer, Map<Integer, BatteryDiffData>> resultMap = new HashMap<>();
+        // Insert diff data from [0][0] to [maxDailyIndex][maxHourlyIndex].
+        insertHourlyUsageDiffData(
+                context, hourlyBatteryLevelsPerDay, batteryHistoryMap, resultMap);
+        // Insert diff data from [0][SELECTED_INDEX_ALL] to [maxDailyIndex][SELECTED_INDEX_ALL].
+        insertDailyUsageDiffData(hourlyBatteryLevelsPerDay, resultMap);
+        // Insert diff data [SELECTED_INDEX_ALL][SELECTED_INDEX_ALL].
+        insertAllUsageDiffData(resultMap);
+        purgeLowPercentageAndFakeData(context, resultMap);
+        if (!isUsageMapValid(resultMap, hourlyBatteryLevelsPerDay)) {
+            return null;
+        }
+        return resultMap;
+    }
+
+    /**
      * Interpolates history map based on expected timestamp slots and processes the corner case when
      * the expected start timestamp is earlier than what we have.
      */
@@ -458,11 +549,454 @@
         return Math.round(batteryLevelCounter / entryMap.size());
     }
 
-    private static void log(Context context, String content, long timestamp,
-            BatteryHistEntry entry) {
+    private static void insertHourlyUsageDiffData(
+            Context context,
+            final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay,
+            final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap,
+            final Map<Integer, Map<Integer, BatteryDiffData>> resultMap) {
+        final int currentUserId = context.getUserId();
+        final UserHandle userHandle =
+                Utils.getManagedProfile(context.getSystemService(UserManager.class));
+        final int workProfileUserId =
+                userHandle != null ? userHandle.getIdentifier() : Integer.MIN_VALUE;
+        // Each time slot usage diff data =
+        //     Math.abs(timestamp[i+2] data - timestamp[i+1] data) +
+        //     Math.abs(timestamp[i+1] data - timestamp[i] data);
+        // since we want to aggregate every two hours data into a single time slot.
+        for (int dailyIndex = 0; dailyIndex < hourlyBatteryLevelsPerDay.size(); dailyIndex++) {
+            final Map<Integer, BatteryDiffData> dailyDiffMap = new HashMap<>();
+            resultMap.put(dailyIndex, dailyDiffMap);
+            if (hourlyBatteryLevelsPerDay.get(dailyIndex) == null) {
+                continue;
+            }
+            final List<Long> timestamps = hourlyBatteryLevelsPerDay.get(dailyIndex).getTimestamps();
+            for (int hourlyIndex = 0; hourlyIndex < timestamps.size() - 1; hourlyIndex++) {
+                final BatteryDiffData hourlyBatteryDiffData =
+                        insertHourlyUsageDiffDataPerSlot(
+                                context,
+                                currentUserId,
+                                workProfileUserId,
+                                hourlyIndex,
+                                timestamps,
+                                batteryHistoryMap);
+                dailyDiffMap.put(hourlyIndex, hourlyBatteryDiffData);
+            }
+        }
+    }
+
+    private static void insertDailyUsageDiffData(
+            final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay,
+            final Map<Integer, Map<Integer, BatteryDiffData>> resultMap) {
+        for (int index = 0; index < hourlyBatteryLevelsPerDay.size(); index++) {
+            Map<Integer, BatteryDiffData> dailyUsageMap = resultMap.get(index);
+            if (dailyUsageMap == null) {
+                dailyUsageMap = new HashMap<>();
+                resultMap.put(index, dailyUsageMap);
+            }
+            dailyUsageMap.put(
+                    SELECTED_INDEX_ALL,
+                    getAccumulatedUsageDiffData(dailyUsageMap.values()));
+        }
+    }
+
+    private static void insertAllUsageDiffData(
+            final Map<Integer, Map<Integer, BatteryDiffData>> resultMap) {
+        final List<BatteryDiffData> diffDataList = new ArrayList<>();
+        resultMap.keySet().forEach(
+                key -> diffDataList.add(resultMap.get(key).get(SELECTED_INDEX_ALL)));
+        final Map<Integer, BatteryDiffData> allUsageMap = new HashMap<>();
+        allUsageMap.put(SELECTED_INDEX_ALL, getAccumulatedUsageDiffData(diffDataList));
+        resultMap.put(SELECTED_INDEX_ALL, allUsageMap);
+    }
+
+    @Nullable
+    private static BatteryDiffData insertHourlyUsageDiffDataPerSlot(
+            Context context,
+            final int currentUserId,
+            final int workProfileUserId,
+            final int currentIndex,
+            final List<Long> timestamps,
+            final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
+        final List<BatteryDiffEntry> appEntries = new ArrayList<>();
+        final List<BatteryDiffEntry> systemEntries = new ArrayList<>();
+
+        final Long currentTimestamp = timestamps.get(currentIndex);
+        final Long nextTimestamp = currentTimestamp + DateUtils.HOUR_IN_MILLIS;
+        final Long nextTwoTimestamp = nextTimestamp + DateUtils.HOUR_IN_MILLIS;
+        // Fetches BatteryHistEntry data from corresponding time slot.
+        final Map<String, BatteryHistEntry> currentBatteryHistMap =
+                batteryHistoryMap.getOrDefault(currentTimestamp, EMPTY_BATTERY_MAP);
+        final Map<String, BatteryHistEntry> nextBatteryHistMap =
+                batteryHistoryMap.getOrDefault(nextTimestamp, EMPTY_BATTERY_MAP);
+        final Map<String, BatteryHistEntry> nextTwoBatteryHistMap =
+                batteryHistoryMap.getOrDefault(nextTwoTimestamp, EMPTY_BATTERY_MAP);
+        // We should not get the empty list since we have at least one fake data to record
+        // the battery level and status in each time slot, the empty list is used to
+        // represent there is no enough data to apply interpolation arithmetic.
+        if (currentBatteryHistMap.isEmpty()
+                || nextBatteryHistMap.isEmpty()
+                || nextTwoBatteryHistMap.isEmpty()) {
+            return null;
+        }
+
+        // Collects all keys in these three time slot records as all populations.
+        final Set<String> allBatteryHistEntryKeys = new ArraySet<>();
+        allBatteryHistEntryKeys.addAll(currentBatteryHistMap.keySet());
+        allBatteryHistEntryKeys.addAll(nextBatteryHistMap.keySet());
+        allBatteryHistEntryKeys.addAll(nextTwoBatteryHistMap.keySet());
+
+        double totalConsumePower = 0.0;
+        double consumePowerFromOtherUsers = 0f;
+        // Calculates all packages diff usage data in a specific time slot.
+        for (String key : allBatteryHistEntryKeys) {
+            final BatteryHistEntry currentEntry =
+                    currentBatteryHistMap.getOrDefault(key, EMPTY_BATTERY_HIST_ENTRY);
+            final BatteryHistEntry nextEntry =
+                    nextBatteryHistMap.getOrDefault(key, EMPTY_BATTERY_HIST_ENTRY);
+            final BatteryHistEntry nextTwoEntry =
+                    nextTwoBatteryHistMap.getOrDefault(key, EMPTY_BATTERY_HIST_ENTRY);
+            // Cumulative values is a specific time slot for a specific app.
+            long foregroundUsageTimeInMs =
+                    getDiffValue(
+                            currentEntry.mForegroundUsageTimeInMs,
+                            nextEntry.mForegroundUsageTimeInMs,
+                            nextTwoEntry.mForegroundUsageTimeInMs);
+            long backgroundUsageTimeInMs =
+                    getDiffValue(
+                            currentEntry.mBackgroundUsageTimeInMs,
+                            nextEntry.mBackgroundUsageTimeInMs,
+                            nextTwoEntry.mBackgroundUsageTimeInMs);
+            double consumePower =
+                    getDiffValue(
+                            currentEntry.mConsumePower,
+                            nextEntry.mConsumePower,
+                            nextTwoEntry.mConsumePower);
+            // Excludes entry since we don't have enough data to calculate.
+            if (foregroundUsageTimeInMs == 0
+                    && backgroundUsageTimeInMs == 0
+                    && consumePower == 0) {
+                continue;
+            }
+            final BatteryHistEntry selectedBatteryEntry =
+                    selectBatteryHistEntry(currentEntry, nextEntry, nextTwoEntry);
+            if (selectedBatteryEntry == null) {
+                continue;
+            }
+            // Forces refine the cumulative value since it may introduce deviation error since we
+            // will apply the interpolation arithmetic.
+            final float totalUsageTimeInMs =
+                    foregroundUsageTimeInMs + backgroundUsageTimeInMs;
+            if (totalUsageTimeInMs > TOTAL_HOURLY_TIME_THRESHOLD) {
+                final float ratio = TOTAL_HOURLY_TIME_THRESHOLD / totalUsageTimeInMs;
+                if (DEBUG) {
+                    Log.w(TAG, String.format("abnormal usage time %d|%d for:\n%s",
+                            Duration.ofMillis(foregroundUsageTimeInMs).getSeconds(),
+                            Duration.ofMillis(backgroundUsageTimeInMs).getSeconds(),
+                            currentEntry));
+                }
+                foregroundUsageTimeInMs =
+                        Math.round(foregroundUsageTimeInMs * ratio);
+                backgroundUsageTimeInMs =
+                        Math.round(backgroundUsageTimeInMs * ratio);
+                consumePower = consumePower * ratio;
+            }
+            totalConsumePower += consumePower;
+
+            final boolean isFromOtherUsers = isConsumedFromOtherUsers(
+                    currentUserId, workProfileUserId, selectedBatteryEntry);
+            if (isFromOtherUsers) {
+                consumePowerFromOtherUsers += consumePower;
+            } else {
+                final BatteryDiffEntry currentBatteryDiffEntry = new BatteryDiffEntry(
+                        context,
+                        foregroundUsageTimeInMs,
+                        backgroundUsageTimeInMs,
+                        consumePower,
+                        selectedBatteryEntry);
+                if (currentBatteryDiffEntry.isSystemEntry()) {
+                    systemEntries.add(currentBatteryDiffEntry);
+                } else {
+                    appEntries.add(currentBatteryDiffEntry);
+                }
+            }
+        }
+        if (consumePowerFromOtherUsers != 0) {
+            systemEntries.add(createOtherUsersEntry(context, consumePowerFromOtherUsers));
+        }
+
+        // If there is no data, return null instead of empty item.
+        if (appEntries.isEmpty() && systemEntries.isEmpty()) {
+            return null;
+        }
+
+        final BatteryDiffData resultDiffData =
+                new BatteryDiffData(appEntries, systemEntries, totalConsumePower);
+        return resultDiffData;
+    }
+
+    private static boolean isConsumedFromOtherUsers(
+            final int currentUserId,
+            final int workProfileUserId,
+            final BatteryHistEntry batteryHistEntry) {
+        return batteryHistEntry.mConsumerType == ConvertUtils.CONSUMER_TYPE_UID_BATTERY
+                && batteryHistEntry.mUserId != currentUserId
+                && batteryHistEntry.mUserId != workProfileUserId;
+    }
+
+    @Nullable
+    private static BatteryDiffData getAccumulatedUsageDiffData(
+            final Collection<BatteryDiffData> diffEntryListData) {
+        double totalConsumePower = 0f;
+        final Map<String, BatteryDiffEntry> diffEntryMap = new HashMap<>();
+        final List<BatteryDiffEntry> appEntries = new ArrayList<>();
+        final List<BatteryDiffEntry> systemEntries = new ArrayList<>();
+
+        for (BatteryDiffData diffEntryList : diffEntryListData) {
+            if (diffEntryList == null) {
+                continue;
+            }
+            for (BatteryDiffEntry entry : diffEntryList.getAppDiffEntryList()) {
+                computeUsageDiffDataPerEntry(entry, diffEntryMap);
+                totalConsumePower += entry.mConsumePower;
+            }
+            for (BatteryDiffEntry entry : diffEntryList.getSystemDiffEntryList()) {
+                computeUsageDiffDataPerEntry(entry, diffEntryMap);
+                totalConsumePower += entry.mConsumePower;
+            }
+        }
+
+        final Collection<BatteryDiffEntry> diffEntryList = diffEntryMap.values();
+        for (BatteryDiffEntry entry : diffEntryList) {
+            // Sets total daily consume power data into all BatteryDiffEntry.
+            entry.setTotalConsumePower(totalConsumePower);
+            if (entry.isSystemEntry()) {
+                systemEntries.add(entry);
+            } else {
+                appEntries.add(entry);
+            }
+        }
+
+        return diffEntryList.isEmpty() ? null : new BatteryDiffData(appEntries, systemEntries);
+    }
+
+    private static void computeUsageDiffDataPerEntry(
+            final BatteryDiffEntry entry,
+            final Map<String, BatteryDiffEntry> diffEntryMap) {
+        final String key = entry.mBatteryHistEntry.getKey();
+        final BatteryDiffEntry oldBatteryDiffEntry = diffEntryMap.get(key);
+        // Creates new BatteryDiffEntry if we don't have it.
+        if (oldBatteryDiffEntry == null) {
+            diffEntryMap.put(key, entry.clone());
+        } else {
+            // Sums up some field data into the existing one.
+            oldBatteryDiffEntry.mForegroundUsageTimeInMs +=
+                    entry.mForegroundUsageTimeInMs;
+            oldBatteryDiffEntry.mBackgroundUsageTimeInMs +=
+                    entry.mBackgroundUsageTimeInMs;
+            oldBatteryDiffEntry.mConsumePower += entry.mConsumePower;
+        }
+    }
+
+    // Removes low percentage data and fake usage data, which will be zero value.
+    private static void purgeLowPercentageAndFakeData(
+            final Context context,
+            final Map<Integer, Map<Integer, BatteryDiffData>> resultMap) {
+        final Set<CharSequence> backgroundUsageTimeHideList =
+                FeatureFactory.getFactory(context)
+                        .getPowerUsageFeatureProvider(context)
+                        .getHideBackgroundUsageTimeSet(context);
+        final CharSequence[] notAllowShowEntryPackages =
+                FeatureFactory.getFactory(context)
+                        .getPowerUsageFeatureProvider(context)
+                        .getHideApplicationEntries(context);
+        resultMap.keySet().forEach(dailyKey -> {
+            final Map<Integer, BatteryDiffData> dailyUsageMap = resultMap.get(dailyKey);
+            dailyUsageMap.values().forEach(diffEntryLists -> {
+                if (diffEntryLists == null) {
+                    return;
+                }
+                purgeLowPercentageAndFakeData(
+                        diffEntryLists.getAppDiffEntryList(), backgroundUsageTimeHideList,
+                        notAllowShowEntryPackages);
+                purgeLowPercentageAndFakeData(
+                        diffEntryLists.getSystemDiffEntryList(), backgroundUsageTimeHideList,
+                        notAllowShowEntryPackages);
+            });
+        });
+    }
+
+    private static void purgeLowPercentageAndFakeData(
+            final List<BatteryDiffEntry> entries,
+            final Set<CharSequence> backgroundUsageTimeHideList,
+            final CharSequence[] notAllowShowEntryPackages) {
+        final Iterator<BatteryDiffEntry> iterator = entries.iterator();
+        while (iterator.hasNext()) {
+            final BatteryDiffEntry entry = iterator.next();
+            final String packageName = entry.getPackageName();
+            if (entry.getPercentOfTotal() < PERCENTAGE_OF_TOTAL_THRESHOLD
+                    || FAKE_PACKAGE_NAME.equals(packageName)
+                    || contains(packageName, notAllowShowEntryPackages)) {
+                iterator.remove();
+            }
+            if (packageName != null
+                    && !backgroundUsageTimeHideList.isEmpty()
+                    && contains(packageName, backgroundUsageTimeHideList)) {
+                entry.mBackgroundUsageTimeInMs = 0;
+            }
+        }
+    }
+
+    private static boolean isUsageMapValid(
+            final Map<Integer, Map<Integer, BatteryDiffData>> batteryUsageMap,
+            final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay) {
+        if (batteryUsageMap.get(SELECTED_INDEX_ALL) == null
+                || batteryUsageMap.get(SELECTED_INDEX_ALL).get(SELECTED_INDEX_ALL) == null) {
+            Log.e(TAG, "no [SELECTED_INDEX_ALL][SELECTED_INDEX_ALL] in batteryUsageMap");
+            return false;
+        }
+        for (int dailyIndex = 0; dailyIndex < hourlyBatteryLevelsPerDay.size(); dailyIndex++) {
+            if (batteryUsageMap.get(dailyIndex) == null
+                    || !batteryUsageMap.get(dailyIndex).containsKey(SELECTED_INDEX_ALL)) {
+                Log.e(TAG, "no [" + dailyIndex + "][SELECTED_INDEX_ALL] in batteryUsageMap, "
+                        + "daily size is: " + hourlyBatteryLevelsPerDay.size());
+                return false;
+            }
+            if (hourlyBatteryLevelsPerDay.get(dailyIndex) == null) {
+                continue;
+            }
+            final List<Long> timestamps = hourlyBatteryLevelsPerDay.get(dailyIndex).getTimestamps();
+            // Length of hourly usage map should be the length of hourly level data - 1.
+            for (int hourlyIndex = 0; hourlyIndex < timestamps.size() - 1; hourlyIndex++) {
+                if (!batteryUsageMap.get(dailyIndex).containsKey(hourlyIndex)) {
+                    Log.e(TAG, "no [" + dailyIndex + "][" + hourlyIndex + "] in batteryUsageMap, "
+                            + "hourly size is: " + (timestamps.size() - 1));
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    private static boolean contains(String target, Set<CharSequence> packageNames) {
+        if (target != null && packageNames != null) {
+            for (CharSequence packageName : packageNames) {
+                if (TextUtils.equals(target, packageName)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private static long getDiffValue(long v1, long v2, long v3) {
+        return (v2 > v1 ? v2 - v1 : 0) + (v3 > v2 ? v3 - v2 : 0);
+    }
+
+    private static double getDiffValue(double v1, double v2, double v3) {
+        return (v2 > v1 ? v2 - v1 : 0) + (v3 > v2 ? v3 - v2 : 0);
+    }
+
+    @Nullable
+    private static BatteryHistEntry selectBatteryHistEntry(
+            final BatteryHistEntry... batteryHistEntries) {
+        for (BatteryHistEntry entry : batteryHistEntries) {
+            if (entry != null && entry != EMPTY_BATTERY_HIST_ENTRY) {
+                return entry;
+            }
+        }
+        return null;
+    }
+
+    private static BatteryDiffEntry createOtherUsersEntry(
+            Context context, final double consumePower) {
+        final ContentValues values = new ContentValues();
+        values.put(BatteryHistEntry.KEY_UID, BatteryUtils.UID_OTHER_USERS);
+        values.put(BatteryHistEntry.KEY_USER_ID, BatteryUtils.UID_OTHER_USERS);
+        values.put(BatteryHistEntry.KEY_CONSUMER_TYPE, ConvertUtils.CONSUMER_TYPE_UID_BATTERY);
+        // We will show the percentage for the "other users" item only, the aggregated
+        // running time information is useless for users to identify individual apps.
+        final BatteryDiffEntry batteryDiffEntry = new BatteryDiffEntry(
+                context,
+                /*foregroundUsageTimeInMs=*/ 0,
+                /*backgroundUsageTimeInMs=*/ 0,
+                consumePower,
+                new BatteryHistEntry(values));
+        return batteryDiffEntry;
+    }
+
+    private static void log(Context context, final String content, final long timestamp,
+            final BatteryHistEntry entry) {
         if (DEBUG) {
             Log.d(TAG, String.format(entry != null ? "%s %s:\n%s" : "%s %s:%s",
                     utcToLocalTime(context, timestamp), content, entry));
         }
     }
+
+    // Compute diff map and loads all items (icon and label) in the background.
+    private static final class ComputeUsageMapAndLoadItemsTask
+            extends AsyncTask<Void, Void, Map<Integer, Map<Integer, BatteryDiffData>>> {
+
+        private Context mApplicationContext;
+        private Handler mHandler;
+        private UsageMapAsyncResponse mAsyncResponseDelegate;
+        private List<BatteryLevelData.PeriodBatteryLevelData> mHourlyBatteryLevelsPerDay;
+        private Map<Long, Map<String, BatteryHistEntry>> mBatteryHistoryMap;
+
+        private ComputeUsageMapAndLoadItemsTask(
+                Context context,
+                Handler handler,
+                final UsageMapAsyncResponse asyncResponseDelegate,
+                final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay,
+                final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
+            mApplicationContext = context.getApplicationContext();
+            mHandler = handler;
+            mAsyncResponseDelegate = asyncResponseDelegate;
+            mHourlyBatteryLevelsPerDay = hourlyBatteryLevelsPerDay;
+            mBatteryHistoryMap = batteryHistoryMap;
+        }
+
+        @Override
+        protected Map<Integer, Map<Integer, BatteryDiffData>> doInBackground(Void... voids) {
+            if (mApplicationContext == null
+                    || mHandler == null
+                    || mAsyncResponseDelegate == null
+                    || mBatteryHistoryMap == null
+                    || mHourlyBatteryLevelsPerDay == null) {
+                Log.e(TAG, "invalid input for ComputeUsageMapAndLoadItemsTask()");
+                return null;
+            }
+            final long startTime = System.currentTimeMillis();
+            final Map<Integer, Map<Integer, BatteryDiffData>> batteryUsageMap =
+                    getBatteryUsageMap(
+                            mApplicationContext, mHourlyBatteryLevelsPerDay, mBatteryHistoryMap);
+            if (batteryUsageMap != null) {
+                // Pre-loads each BatteryDiffEntry relative icon and label for all slots.
+                final BatteryDiffData batteryUsageMapForAll =
+                        batteryUsageMap.get(SELECTED_INDEX_ALL).get(SELECTED_INDEX_ALL);
+                if (batteryUsageMapForAll != null) {
+                    batteryUsageMapForAll.getAppDiffEntryList().forEach(
+                            entry -> entry.loadLabelAndIcon());
+                    batteryUsageMapForAll.getSystemDiffEntryList().forEach(
+                            entry -> entry.loadLabelAndIcon());
+                }
+            }
+            Log.d(TAG, String.format("execute ComputeUsageMapAndLoadItemsTask in %d/ms",
+                    (System.currentTimeMillis() - startTime)));
+            return batteryUsageMap;
+        }
+
+        @Override
+        protected void onPostExecute(
+                final Map<Integer, Map<Integer, BatteryDiffData>> batteryUsageMap) {
+            mApplicationContext = null;
+            mHourlyBatteryLevelsPerDay = null;
+            mBatteryHistoryMap = null;
+            // Post results back to main thread to refresh UI.
+            if (mHandler != null && mAsyncResponseDelegate != null) {
+                mHandler.post(() -> {
+                    mAsyncResponseDelegate.onBatteryUsageMapLoaded(batteryUsageMap);
+                });
+            }
+        }
+    }
 }
diff --git a/src/com/android/settings/network/telephony/NetworkScanHelper.java b/src/com/android/settings/network/telephony/NetworkScanHelper.java
index e0a9c5e..1961329 100644
--- a/src/com/android/settings/network/telephony/NetworkScanHelper.java
+++ b/src/com/android/settings/network/telephony/NetworkScanHelper.java
@@ -17,6 +17,7 @@
 package com.android.settings.network.telephony;
 
 import android.annotation.IntDef;
+import android.content.Context;
 import android.telephony.AccessNetworkConstants.AccessNetworkType;
 import android.telephony.CellInfo;
 import android.telephony.NetworkScan;
@@ -31,6 +32,8 @@
 
 import com.android.internal.telephony.CellNetworkScanResult;
 
+import com.android.settings.R;
+
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -129,6 +132,7 @@
     private final TelephonyScanManager.NetworkScanCallback mInternalNetworkScanCallback;
     private final Executor mExecutor;
 
+    private int mMaxSearchTimeSec = MAX_SEARCH_TIME_SEC;
     private NetworkScan mNetworkScanRequester;
 
     /** Callbacks for sync network scan */
@@ -141,6 +145,13 @@
         mExecutor = executor;
     }
 
+    public NetworkScanHelper(Context context, TelephonyManager tm, NetworkScanCallback callback,
+            Executor executor) {
+        this(tm, callback, executor);
+        mMaxSearchTimeSec = context.getResources().getInteger(
+                R.integer.config_network_scan_helper_max_search_time_sec);
+    }
+
     @VisibleForTesting
     NetworkScanRequest createNetworkScanForPreferredAccessNetworks() {
         long networkTypeBitmap3gpp = mTelephonyManager.getPreferredNetworkTypeBitmask()
@@ -183,7 +194,7 @@
                 radioAccessSpecifiers.toArray(
                         new RadioAccessSpecifier[radioAccessSpecifiers.size()]),
                 SEARCH_PERIODICITY_SEC,
-                MAX_SEARCH_TIME_SEC,
+                mMaxSearchTimeSec,
                 INCREMENTAL_RESULTS,
                 INCREMENTAL_RESULTS_PERIODICITY_SEC,
                 null /* List of PLMN ids (MCC-MNC) */);
diff --git a/src/com/android/settings/vpn2/AdvancedVpnFeatureProvider.java b/src/com/android/settings/vpn2/AdvancedVpnFeatureProvider.java
index cb56c35..962b6c2 100644
--- a/src/com/android/settings/vpn2/AdvancedVpnFeatureProvider.java
+++ b/src/com/android/settings/vpn2/AdvancedVpnFeatureProvider.java
@@ -47,4 +47,9 @@
      * Returns {@code true} advanced vpn is removable.
      */
     boolean isAdvancedVpnRemovable();
+
+    /**
+     * Returns {@code true} if the disconnect dialog is enabled when advanced vpn is connected.
+     */
+    boolean isDisconnectDialogEnabled();
 }
diff --git a/src/com/android/settings/vpn2/AdvancedVpnFeatureProviderImpl.java b/src/com/android/settings/vpn2/AdvancedVpnFeatureProviderImpl.java
index c5bc69c..b8f58a9 100644
--- a/src/com/android/settings/vpn2/AdvancedVpnFeatureProviderImpl.java
+++ b/src/com/android/settings/vpn2/AdvancedVpnFeatureProviderImpl.java
@@ -46,4 +46,9 @@
     public boolean isAdvancedVpnRemovable() {
         return true;
     }
+
+    @Override
+    public boolean isDisconnectDialogEnabled() {
+        return true;
+    }
 }
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 4380595..a91bb6c 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -26,6 +26,7 @@
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.net.ConnectivityManager;
@@ -365,7 +366,7 @@
     public void setShownPreferences(final Collection<Preference> updates) {
         retainAllPreference(updates);
 
-        final PreferenceGroup vpnGroup = getPreferenceScreen();
+        final PreferenceGroup vpnGroup = mPreferenceScreen;
         updatePreferenceGroup(vpnGroup, updates);
 
         // Show all new preferences on the screen
@@ -447,14 +448,16 @@
         } else if (preference instanceof AppPreference) {
             AppPreference pref = (AppPreference) preference;
             boolean connected = (pref.getState() == AppPreference.STATE_CONNECTED);
+            String vpnPackageName = pref.getPackageName();
 
-            if (!connected) {
+            if ((!connected) || (isAdvancedVpn(mFeatureProvider, vpnPackageName, getContext())
+                    && !mFeatureProvider.isDisconnectDialogEnabled())) {
                 try {
                     UserHandle user = UserHandle.of(pref.getUserId());
-                    Context userContext = getActivity().createPackageContextAsUser(
-                            getActivity().getPackageName(), 0 /* flags */, user);
+                    Context userContext = getContext().createPackageContextAsUser(
+                            getContext().getPackageName(), 0 /* flags */, user);
                     PackageManager pm = userContext.getPackageManager();
-                    Intent appIntent = pm.getLaunchIntentForPackage(pref.getPackageName());
+                    Intent appIntent = pm.getLaunchIntentForPackage(vpnPackageName);
                     if (appIntent != null) {
                         userContext.startActivityAsUser(appIntent, user);
                         return true;
@@ -534,9 +537,32 @@
             pref.setOnPreferenceClickListener(this);
             mAppPreferences.put(app, pref);
         }
+        enableAdvancedVpnGearIconIfNecessary(pref);
         return pref;
     }
 
+    private void enableAdvancedVpnGearIconIfNecessary(AppPreference pref) {
+        Context context = getContext();
+        if (!isAdvancedVpn(mFeatureProvider, pref.getPackageName(), context)) {
+            return;
+        }
+
+        boolean isEnabled = false;
+        AppOpsManager appOpsManager = getContext().getSystemService(AppOpsManager.class);
+        List<AppOpsManager.PackageOps> apps =
+                appOpsManager.getPackagesForOps(
+                        new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
+        if (apps != null) {
+            for (AppOpsManager.PackageOps pkg : apps) {
+                if (isAdvancedVpn(mFeatureProvider, pkg.getPackageName(), context)) {
+                    isEnabled = true;
+                    break;
+                }
+            }
+        }
+        pref.setOnGearClickListener(isEnabled ? mGearListener : null);
+    }
+
     @WorkerThread
     private Map<String, LegacyVpnInfo> getConnectedLegacyVpns() {
         mConnectedLegacyVpn = mVpnManager.getLegacyVpnInfo(UserHandle.myUserId());
@@ -593,6 +619,19 @@
             profileIds = Collections.singleton(UserHandle.myUserId());
         }
 
+        if (featureProvider.isAdvancedVpnSupported(context)) {
+            PackageManager pm = context.getPackageManager();
+            try {
+                ApplicationInfo appInfo =
+                        pm.getApplicationInfo(
+                                featureProvider.getAdvancedVpnPackageName(), /* flags= */ 0);
+                int userId = UserHandle.getUserId(appInfo.uid);
+                result.add(new AppVpnInfo(userId, featureProvider.getAdvancedVpnPackageName()));
+            } catch (PackageManager.NameNotFoundException e) {
+                Log.e(LOG_TAG, "Advanced VPN package name not found.", e);
+            }
+        }
+
         List<AppOpsManager.PackageOps> apps =
                 aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
         if (apps != null) {
@@ -602,6 +641,9 @@
                     // Skip packages for users outside of our profile group.
                     continue;
                 }
+                if (isAdvancedVpn(featureProvider, pkg.getPackageName(), context)) {
+                    continue;
+                }
                 // Look for a MODE_ALLOWED permission to activate VPN.
                 boolean allowed = false;
                 for (AppOpsManager.OpEntry op : pkg.getOps()) {
@@ -610,7 +652,7 @@
                         allowed = true;
                     }
                 }
-                if (allowed || isAdvancedVpn(featureProvider, pkg.getPackageName(), context)) {
+                if (allowed) {
                     result.add(new AppVpnInfo(userId, pkg.getPackageName()));
                 }
             }
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptionLocalePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptionLocalePreferenceControllerTest.java
index 5602588..cb0d67c 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptionLocalePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptionLocalePreferenceControllerTest.java
@@ -64,21 +64,21 @@
     }
 
     @Test
-    public void getSummary_byDefault_shouldReturnDefault() {
+    public void displayPreference_byDefault_shouldReturnDefault() {
         mController.displayPreference(mScreen);
 
-        assertThat(mController.getSummary().toString()).isEqualTo(
+        assertThat(mPreference.getEntry().toString()).isEqualTo(
                 mContext.getResources().getString(R.string.locale_default));
     }
 
     @Test
-    public void getSummary_byArabicLocale_shouldReturnArabic() {
+    public void displayPreference_byArabicLocale_shouldReturnArabic() {
         Settings.Secure.putString(mContext.getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE, "af_ZA");
 
         mController.displayPreference(mScreen);
 
-        assertThat(mController.getSummary().toString()).isEqualTo("Afrikaans");
+        assertThat(mPreference.getEntry().toString()).isEqualTo("Afrikaans");
     }
 
     @Test
@@ -87,6 +87,6 @@
 
         mController.onPreferenceChange(mPreference, "af_ZA");
 
-        assertThat(mPreference.getSummary().toString()).isEqualTo("Afrikaans");
+        assertThat(mPreference.getEntry().toString()).isEqualTo("Afrikaans");
     }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptionPreviewPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptionPreviewPreferenceControllerTest.java
index 2ca755c..dda4886 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptionPreviewPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptionPreviewPreferenceControllerTest.java
@@ -84,7 +84,7 @@
     }
 
     @Test
-    public void onPause_unregisterContentObserver() {
+    public void onStop_unregisterContentObserver() {
         mController.onStop();
 
         verify(mContentResolver).unregisterContentObserver(mController.mSettingsContentObserver);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2Test.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2Test.java
index a25afed..a5f193b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2Test.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerV2Test.java
@@ -21,6 +21,7 @@
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
@@ -32,6 +33,7 @@
 import android.os.Bundle;
 import android.os.LocaleList;
 import android.text.format.DateUtils;
+import android.view.View;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
@@ -64,8 +66,6 @@
 public final class BatteryChartPreferenceControllerV2Test {
     private static final String PREF_KEY = "pref_key";
     private static final String PREF_SUMMARY = "fake preference summary";
-    private static final int DESIRED_HISTORY_SIZE =
-            BatteryChartPreferenceControllerV2.DESIRED_HISTORY_SIZE;
 
     @Mock
     private InstrumentedPreferenceFragment mFragment;
@@ -78,7 +78,9 @@
     @Mock
     private BatteryHistEntry mBatteryHistEntry;
     @Mock
-    private BatteryChartViewV2 mBatteryChartView;
+    private BatteryChartViewV2 mDailyChartView;
+    @Mock
+    private BatteryChartViewV2 mHourlyChartView;
     @Mock
     private PowerGaugePreference mPowerGaugePreference;
     @Mock
@@ -111,7 +113,8 @@
         mBatteryChartPreferenceController = createController();
         mBatteryChartPreferenceController.mPrefContext = mContext;
         mBatteryChartPreferenceController.mAppListPrefGroup = mAppListGroup;
-        mBatteryChartPreferenceController.mBatteryChartView = mBatteryChartView;
+        mBatteryChartPreferenceController.mDailyChartView = mDailyChartView;
+        mBatteryChartPreferenceController.mHourlyChartView = mHourlyChartView;
         mBatteryDiffEntry = new BatteryDiffEntry(
                 mContext,
                 /*foregroundUsageTimeInMs=*/ 1,
@@ -123,12 +126,10 @@
         BatteryDiffEntry.sResourceCache.put(
                 "fakeBatteryDiffEntryKey",
                 new BatteryEntry.NameAndIcon("fakeName", /*icon=*/ null, /*iconId=*/ 1));
-        mBatteryChartPreferenceController.setBatteryHistoryMap(
-                createBatteryHistoryMap());
     }
 
     @Test
-    public void testOnDestroy_activityIsChanging_clearBatteryEntryCache() {
+    public void onDestroy_activityIsChanging_clearBatteryEntryCache() {
         doReturn(true).when(mSettingsActivity).isChangingConfigurations();
         // Ensures the testing environment is correct.
         assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
@@ -138,7 +139,7 @@
     }
 
     @Test
-    public void testOnDestroy_activityIsNotChanging_notClearBatteryEntryCache() {
+    public void onDestroy_activityIsNotChanging_notClearBatteryEntryCache() {
         doReturn(false).when(mSettingsActivity).isChangingConfigurations();
         // Ensures the testing environment is correct.
         assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
@@ -148,7 +149,7 @@
     }
 
     @Test
-    public void testOnDestroy_clearPreferenceCache() {
+    public void onDestroy_clearPreferenceCache() {
         // Ensures the testing environment is correct.
         mBatteryChartPreferenceController.mPreferenceCache.put(
                 PREF_KEY, mPowerGaugePreference);
@@ -160,81 +161,121 @@
     }
 
     @Test
-    public void testOnDestroy_removeAllPreferenceFromPreferenceGroup() {
+    public void onDestroy_removeAllPreferenceFromPreferenceGroup() {
         mBatteryChartPreferenceController.onDestroy();
         verify(mAppListGroup).removeAll();
     }
 
     @Test
-    public void testSetBatteryHistoryMap_createExpectedKeysAndLevels() {
-        mBatteryChartPreferenceController.setBatteryHistoryMap(
-                createBatteryHistoryMap());
+    public void setBatteryChartViewModel_6Hours() {
+        // TODO: Removes the following line after loading mBatteryIndexedMap is supported.
+        mBatteryChartPreferenceController.mBatteryIndexedMap = new HashMap<>();
 
-        // Verifies the created battery keys array.
-        for (int index = 0; index < DESIRED_HISTORY_SIZE; index++) {
-            assertThat(mBatteryChartPreferenceController.mBatteryHistoryKeys[index])
-                    // These values is are calculated by hand from createBatteryHistoryMap().
-                    .isEqualTo(generateTimestamp(index));
-        }
-        // Verifies the created battery levels array.
-        for (int index = 0; index < 13; index++) {
-            assertThat(mBatteryChartPreferenceController.mViewModel.levels().get(index))
-                    // These values is are calculated by hand from createBatteryHistoryMap().
-                    .isEqualTo(100 - index * 2);
-        }
-        assertThat(mBatteryChartPreferenceController.mBatteryIndexedMap).hasSize(13);
+        mBatteryChartPreferenceController.setBatteryHistoryMap(createBatteryHistoryMap(6));
+
+        verify(mDailyChartView).setVisibility(View.GONE);
+        verify(mHourlyChartView).setVisibility(View.VISIBLE);
+        verify(mHourlyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(100, 97, 95),
+                List.of("8 am", "10 am", "12 pm"),
+                BatteryChartViewModel.SELECTED_INDEX_ALL,
+                BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS));
     }
 
     @Test
-    public void testSetBatteryHistoryMap_largeSize_createExpectedKeysAndLevels() {
-        mBatteryChartPreferenceController.setBatteryHistoryMap(
-                createBatteryHistoryMap());
+    public void setBatteryChartViewModel_60Hours() {
+        // TODO: Removes the following line after loading mBatteryIndexedMap is supported.
+        mBatteryChartPreferenceController.mBatteryIndexedMap = new HashMap<>();
 
-        // Verifies the created battery keys array.
-        for (int index = 0; index < DESIRED_HISTORY_SIZE; index++) {
-            assertThat(mBatteryChartPreferenceController.mBatteryHistoryKeys[index])
-                    // These values is are calculated by hand from createBatteryHistoryMap().
-                    .isEqualTo(generateTimestamp(index));
-        }
-        // Verifies the created battery levels array.
-        for (int index = 0; index < 13; index++) {
-            assertThat(mBatteryChartPreferenceController.mViewModel.levels().get(index))
-                    // These values is are calculated by hand from createBatteryHistoryMap().
-                    .isEqualTo(100 - index * 2);
-        }
-        assertThat(mBatteryChartPreferenceController.mBatteryIndexedMap).hasSize(13);
+        mBatteryChartPreferenceController.setBatteryHistoryMap(createBatteryHistoryMap(60));
+
+        verify(mDailyChartView).setVisibility(View.VISIBLE);
+        verify(mHourlyChartView).setVisibility(View.GONE);
+        verify(mDailyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(100, 83, 59, 41),
+                List.of("SAT", "SUN", "MON", "MON"),
+                BatteryChartViewModel.SELECTED_INDEX_ALL,
+                BatteryChartViewModel.AxisLabelPosition.CENTER_OF_TRAPEZOIDS));
+
+        reset(mDailyChartView);
+        reset(mHourlyChartView);
+        mBatteryChartPreferenceController.mDailyChartIndex = 0;
+        mBatteryChartPreferenceController.refreshUi();
+        verify(mDailyChartView).setVisibility(View.VISIBLE);
+        verify(mHourlyChartView).setVisibility(View.VISIBLE);
+        verify(mDailyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(100, 83, 59, 41),
+                List.of("SAT", "SUN", "MON", "MON"),
+                0,
+                BatteryChartViewModel.AxisLabelPosition.CENTER_OF_TRAPEZOIDS));
+        verify(mHourlyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(100, 97, 95, 93, 91, 89, 87, 85, 83),
+                List.of("8 am", "10 am", "12 pm", "2 pm", "4 pm", "6 pm", "8 pm", "10 pm",
+                        "12 am"),
+                BatteryChartViewModel.SELECTED_INDEX_ALL,
+                BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS));
+
+        reset(mDailyChartView);
+        reset(mHourlyChartView);
+        mBatteryChartPreferenceController.mDailyChartIndex = 1;
+        mBatteryChartPreferenceController.mHourlyChartIndex = 6;
+        mBatteryChartPreferenceController.refreshUi();
+        verify(mDailyChartView).setVisibility(View.VISIBLE);
+        verify(mHourlyChartView).setVisibility(View.VISIBLE);
+        verify(mDailyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(100, 83, 59, 41),
+                List.of("SAT", "SUN", "MON", "MON"),
+                1,
+                BatteryChartViewModel.AxisLabelPosition.CENTER_OF_TRAPEZOIDS));
+        verify(mHourlyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59),
+                List.of("12 am", "2 am", "4 am", "6 am", "8 am", "10 am", "12 pm", "2 pm",
+                        "4 pm", "6 pm", "8 pm", "10 pm", "12 am"),
+                6,
+                BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS));
+
+        reset(mDailyChartView);
+        reset(mHourlyChartView);
+        mBatteryChartPreferenceController.mDailyChartIndex = 2;
+        mBatteryChartPreferenceController.mHourlyChartIndex =
+                BatteryChartViewModel.SELECTED_INDEX_ALL;
+        mBatteryChartPreferenceController.refreshUi();
+        verify(mDailyChartView).setVisibility(View.VISIBLE);
+        verify(mHourlyChartView).setVisibility(View.VISIBLE);
+        verify(mDailyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(100, 83, 59, 41),
+                List.of("SAT", "SUN", "MON", "MON"),
+                2,
+                BatteryChartViewModel.AxisLabelPosition.CENTER_OF_TRAPEZOIDS));
+        verify(mHourlyChartView).setViewModel(new BatteryChartViewModel(
+                List.of(59, 57, 55, 53, 51, 49, 47, 45, 43, 41),
+                List.of("12 am", "2 am", "4 am", "6 am", "8 am", "10 am", "12 pm", "2 pm",
+                        "4 pm", "6 pm"),
+                BatteryChartViewModel.SELECTED_INDEX_ALL,
+                BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS));
     }
 
     @Test
-    public void testSetBatteryChartViewModel() {
-        verify(mBatteryChartPreferenceController.mBatteryChartView)
-                .setViewModel(new BatteryChartViewModel(
-                        List.of(100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76),
-                        List.of("7 am", "9 am", "11 am", "1 pm", "3 pm", "5 pm", "7 pm",
-                                "9 pm", "11 pm", "1 am", "3 am", "5 am", "7 am"),
-                        BatteryChartViewModel.SELECTED_INDEX_ALL));
-    }
-
-    @Test
-    public void testRefreshUi_refresh() {
-        assertThat(mBatteryChartPreferenceController.refreshUi()).isTrue();
-    }
-
-    @Test
-    public void testRefreshUi_batteryIndexedMapIsNull_ignoreRefresh() {
+    public void refreshUi_batteryIndexedMapIsNull_ignoreRefresh() {
         mBatteryChartPreferenceController.setBatteryHistoryMap(null);
         assertThat(mBatteryChartPreferenceController.refreshUi()).isFalse();
     }
 
     @Test
-    public void testRefreshUi_batteryChartViewIsNull_ignoreRefresh() {
-        mBatteryChartPreferenceController.mBatteryChartView = null;
+    public void refreshUi_dailyChartViewIsNull_ignoreRefresh() {
+        mBatteryChartPreferenceController.mDailyChartView = null;
         assertThat(mBatteryChartPreferenceController.refreshUi()).isFalse();
     }
 
     @Test
-    public void testRemoveAndCacheAllPrefs_emptyContent_ignoreRemoveAll() {
-        mBatteryChartPreferenceController.mTrapezoidIndex = 1;
+    public void refreshUi_hourlyChartViewIsNull_ignoreRefresh() {
+        mBatteryChartPreferenceController.mHourlyChartView = null;
+        assertThat(mBatteryChartPreferenceController.refreshUi()).isFalse();
+    }
+
+    @Test
+    public void removeAndCacheAllPrefs_emptyContent_ignoreRemoveAll() {
+        mBatteryChartPreferenceController.mHourlyChartIndex = 1;
         doReturn(0).when(mAppListGroup).getPreferenceCount();
 
         mBatteryChartPreferenceController.refreshUi();
@@ -242,30 +283,14 @@
     }
 
     @Test
-    public void testRemoveAndCacheAllPrefs_buildCacheAndRemoveAllPreference() {
-        mBatteryChartPreferenceController.mTrapezoidIndex = 1;
-        doReturn(1).when(mAppListGroup).getPreferenceCount();
-        doReturn(mPowerGaugePreference).when(mAppListGroup).getPreference(0);
-        doReturn(PREF_KEY).when(mPowerGaugePreference).getKey();
-        // Ensures the testing data is correct.
-        assertThat(mBatteryChartPreferenceController.mPreferenceCache).isEmpty();
-
-        mBatteryChartPreferenceController.refreshUi();
-
-        assertThat(mBatteryChartPreferenceController.mPreferenceCache.get(PREF_KEY))
-                .isEqualTo(mPowerGaugePreference);
-        verify(mAppListGroup).removeAll();
-    }
-
-    @Test
-    public void testAddPreferenceToScreen_emptyContent_ignoreAddPreference() {
+    public void addPreferenceToScreen_emptyContent_ignoreAddPreference() {
         mBatteryChartPreferenceController.addPreferenceToScreen(
                 new ArrayList<BatteryDiffEntry>());
         verify(mAppListGroup, never()).addPreference(any());
     }
 
     @Test
-    public void testAddPreferenceToScreen_addPreferenceIntoScreen() {
+    public void addPreferenceToScreen_addPreferenceIntoScreen() {
         final String appLabel = "fake app label";
         doReturn(1).when(mAppListGroup).getPreferenceCount();
         doReturn(mDrawable).when(mBatteryDiffEntry).getAppIcon();
@@ -294,7 +319,7 @@
     }
 
     @Test
-    public void testAddPreferenceToScreen_alreadyInScreen_notAddPreferenceAgain() {
+    public void addPreferenceToScreen_alreadyInScreen_notAddPreferenceAgain() {
         final String appLabel = "fake app label";
         doReturn(1).when(mAppListGroup).getPreferenceCount();
         doReturn(mDrawable).when(mBatteryDiffEntry).getAppIcon();
@@ -309,7 +334,7 @@
     }
 
     @Test
-    public void testHandlePreferenceTreeiClick_notPowerGaugePreference_returnFalse() {
+    public void handlePreferenceTreeiClick_notPowerGaugePreference_returnFalse() {
         assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(mAppListGroup))
                 .isFalse();
 
@@ -320,7 +345,7 @@
     }
 
     @Test
-    public void testHandlePreferenceTreeClick_forAppEntry_returnTrue() {
+    public void handlePreferenceTreeClick_forAppEntry_returnTrue() {
         doReturn(false).when(mBatteryHistEntry).isAppEntry();
         doReturn(mBatteryDiffEntry).when(mPowerGaugePreference).getBatteryDiffEntry();
 
@@ -336,7 +361,7 @@
     }
 
     @Test
-    public void testHandlePreferenceTreeClick_forSystemEntry_returnTrue() {
+    public void handlePreferenceTreeClick_forSystemEntry_returnTrue() {
         mBatteryChartPreferenceController.mBatteryUtils = mBatteryUtils;
         doReturn(true).when(mBatteryHistEntry).isAppEntry();
         doReturn(mBatteryDiffEntry).when(mPowerGaugePreference).getBatteryDiffEntry();
@@ -353,7 +378,7 @@
     }
 
     @Test
-    public void testSetPreferenceSummary_setNullContentIfTotalUsageTimeIsZero() {
+    public void setPreferenceSummary_setNullContentIfTotalUsageTimeIsZero() {
         final PowerGaugePreference pref = new PowerGaugePreference(mContext);
         pref.setSummary(PREF_SUMMARY);
 
@@ -365,7 +390,7 @@
     }
 
     @Test
-    public void testSetPreferenceSummary_setBackgroundUsageTimeOnly() {
+    public void setPreferenceSummary_setBackgroundUsageTimeOnly() {
         final PowerGaugePreference pref = new PowerGaugePreference(mContext);
         pref.setSummary(PREF_SUMMARY);
 
@@ -377,7 +402,7 @@
     }
 
     @Test
-    public void testSetPreferenceSummary_setTotalUsageTimeLessThanAMinute() {
+    public void setPreferenceSummary_setTotalUsageTimeLessThanAMinute() {
         final PowerGaugePreference pref = new PowerGaugePreference(mContext);
         pref.setSummary(PREF_SUMMARY);
 
@@ -389,7 +414,7 @@
     }
 
     @Test
-    public void testSetPreferenceSummary_setTotalTimeIfBackgroundTimeLessThanAMinute() {
+    public void setPreferenceSummary_setTotalTimeIfBackgroundTimeLessThanAMinute() {
         final PowerGaugePreference pref = new PowerGaugePreference(mContext);
         pref.setSummary(PREF_SUMMARY);
 
@@ -402,7 +427,7 @@
     }
 
     @Test
-    public void testSetPreferenceSummary_setTotalAndBackgroundUsageTime() {
+    public void setPreferenceSummary_setTotalAndBackgroundUsageTime() {
         final PowerGaugePreference pref = new PowerGaugePreference(mContext);
         pref.setSummary(PREF_SUMMARY);
 
@@ -414,7 +439,7 @@
     }
 
     @Test
-    public void testSetPreferenceSummary_notAllowShownPackage_setSummayAsNull() {
+    public void setPreferenceSummary_notAllowShownPackage_setSummayAsNull() {
         final PowerGaugePreference pref = new PowerGaugePreference(mContext);
         pref.setSummary(PREF_SUMMARY);
         final BatteryDiffEntry batteryDiffEntry =
@@ -429,7 +454,7 @@
     }
 
     @Test
-    public void testValidateUsageTime_returnTrueIfBatteryDiffEntryIsValid() {
+    public void validateUsageTime_returnTrueIfBatteryDiffEntryIsValid() {
         assertThat(BatteryChartPreferenceControllerV2.validateUsageTime(
                 createBatteryDiffEntry(
                         /*foregroundUsageTimeInMs=*/ DateUtils.MINUTE_IN_MILLIS,
@@ -438,7 +463,7 @@
     }
 
     @Test
-    public void testValidateUsageTime_foregroundTimeExceedThreshold_returnFalse() {
+    public void validateUsageTime_foregroundTimeExceedThreshold_returnFalse() {
         assertThat(BatteryChartPreferenceControllerV2.validateUsageTime(
                 createBatteryDiffEntry(
                         /*foregroundUsageTimeInMs=*/ DateUtils.HOUR_IN_MILLIS * 3,
@@ -447,7 +472,7 @@
     }
 
     @Test
-    public void testValidateUsageTime_backgroundTimeExceedThreshold_returnFalse() {
+    public void validateUsageTime_backgroundTimeExceedThreshold_returnFalse() {
         assertThat(BatteryChartPreferenceControllerV2.validateUsageTime(
                 createBatteryDiffEntry(
                         /*foregroundUsageTimeInMs=*/ 0,
@@ -456,7 +481,7 @@
     }
 
     @Test
-    public void testOnExpand_expandedIsTrue_addSystemEntriesToPreferenceGroup() {
+    public void onExpand_expandedIsTrue_addSystemEntriesToPreferenceGroup() {
         doReturn(1).when(mAppListGroup).getPreferenceCount();
         mBatteryChartPreferenceController.mSystemEntries.add(mBatteryDiffEntry);
         doReturn("label").when(mBatteryDiffEntry).getAppLabel();
@@ -477,7 +502,7 @@
     }
 
     @Test
-    public void testOnExpand_expandedIsFalse_removeSystemEntriesFromPreferenceGroup() {
+    public void onExpand_expandedIsFalse_removeSystemEntriesFromPreferenceGroup() {
         doReturn(PREF_KEY).when(mBatteryHistEntry).getKey();
         doReturn(mPowerGaugePreference).when(mAppListGroup).findPreference(PREF_KEY);
         mBatteryChartPreferenceController.mSystemEntries.add(mBatteryDiffEntry);
@@ -497,56 +522,14 @@
     }
 
     @Test
-    public void testOnSelect_selectSpecificTimeSlot_logMetric() {
-        mBatteryChartPreferenceController.onSelect(1 /*slot index*/);
-
-        verify(mMetricsFeatureProvider)
-                .action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_TIME_SLOT);
-    }
-
-    @Test
-    public void testOnSelect_selectAll_logMetric() {
-        mBatteryChartPreferenceController.onSelect(
-                BatteryChartViewModel.SELECTED_INDEX_ALL /*slot index*/);
-
-        verify(mMetricsFeatureProvider)
-                .action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_SHOW_ALL);
-    }
-
-    @Test
-    public void testRefreshCategoryTitle_setHourIntoBothTitleTextView() {
-        mBatteryChartPreferenceController = createController();
-        setUpBatteryHistoryKeys();
-        mBatteryChartPreferenceController.mAppListPrefGroup =
-                spy(new PreferenceCategory(mContext));
-        mBatteryChartPreferenceController.mExpandDividerPreference =
-                spy(new ExpandDividerPreference(mContext));
-        // Simulates select the first slot.
-        mBatteryChartPreferenceController.mTrapezoidIndex = 0;
-
-        mBatteryChartPreferenceController.refreshCategoryTitle();
-
-        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-        // Verifies the title in the preference group.
-        verify(mBatteryChartPreferenceController.mAppListPrefGroup)
-                .setTitle(captor.capture());
-        assertThat(captor.getValue()).isNotEqualTo("App usage for past 24 hr");
-        // Verifies the title in the expandable divider.
-        captor = ArgumentCaptor.forClass(String.class);
-        verify(mBatteryChartPreferenceController.mExpandDividerPreference)
-                .setTitle(captor.capture());
-        assertThat(captor.getValue()).isNotEqualTo("System usage for past 24 hr");
-    }
-
-    @Test
-    public void testRefreshCategoryTitle_setLast24HrIntoBothTitleTextView() {
+    public void refreshCategoryTitle_setLast24HrIntoBothTitleTextView() {
         mBatteryChartPreferenceController = createController();
         mBatteryChartPreferenceController.mAppListPrefGroup =
                 spy(new PreferenceCategory(mContext));
         mBatteryChartPreferenceController.mExpandDividerPreference =
                 spy(new ExpandDividerPreference(mContext));
         // Simulates select all condition.
-        mBatteryChartPreferenceController.mTrapezoidIndex =
+        mBatteryChartPreferenceController.mHourlyChartIndex =
                 BatteryChartViewModel.SELECTED_INDEX_ALL;
 
         mBatteryChartPreferenceController.refreshCategoryTitle();
@@ -566,28 +549,27 @@
     }
 
     @Test
-    public void testOnSaveInstanceState_restoreSelectedIndexAndExpandState() {
+    public void onSaveInstanceState_restoreSelectedIndexAndExpandState() {
         final int expectedIndex = 1;
         final boolean isExpanded = true;
         final Bundle bundle = new Bundle();
-        mBatteryChartPreferenceController.mTrapezoidIndex = expectedIndex;
+        mBatteryChartPreferenceController.mHourlyChartIndex = expectedIndex;
         mBatteryChartPreferenceController.mIsExpanded = isExpanded;
         mBatteryChartPreferenceController.onSaveInstanceState(bundle);
         // Replaces the original controller with other values.
-        mBatteryChartPreferenceController.mTrapezoidIndex = -1;
+        mBatteryChartPreferenceController.mHourlyChartIndex = -1;
         mBatteryChartPreferenceController.mIsExpanded = false;
 
         mBatteryChartPreferenceController.onCreate(bundle);
-        mBatteryChartPreferenceController.setBatteryHistoryMap(
-                createBatteryHistoryMap());
+        mBatteryChartPreferenceController.setBatteryHistoryMap(createBatteryHistoryMap(25));
 
-        assertThat(mBatteryChartPreferenceController.mTrapezoidIndex)
+        assertThat(mBatteryChartPreferenceController.mHourlyChartIndex)
                 .isEqualTo(expectedIndex);
         assertThat(mBatteryChartPreferenceController.mIsExpanded).isTrue();
     }
 
     @Test
-    public void testIsValidToShowSummary_returnExpectedResult() {
+    public void isValidToShowSummary_returnExpectedResult() {
         assertThat(mBatteryChartPreferenceController
                 .isValidToShowSummary("com.google.android.apps.scone"))
                 .isTrue();
@@ -599,7 +581,7 @@
     }
 
     @Test
-    public void testIsValidToShowEntry_returnExpectedResult() {
+    public void isValidToShowEntry_returnExpectedResult() {
         assertThat(mBatteryChartPreferenceController
                 .isValidToShowEntry("com.google.android.apps.scone"))
                 .isTrue();
@@ -615,9 +597,10 @@
         return 1619247600000L + index * DateUtils.HOUR_IN_MILLIS;
     }
 
-    private static Map<Long, Map<String, BatteryHistEntry>> createBatteryHistoryMap() {
+    private static Map<Long, Map<String, BatteryHistEntry>> createBatteryHistoryMap(
+            int numOfHours) {
         final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = new HashMap<>();
-        for (int index = 0; index < DESIRED_HISTORY_SIZE; index++) {
+        for (int index = 0; index < numOfHours; index++) {
             final ContentValues values = new ContentValues();
             values.put("batteryLevel", Integer.valueOf(100 - index));
             final BatteryHistEntry entry = new BatteryHistEntry(values);
@@ -635,14 +618,6 @@
                 /*consumePower=*/ 0, mBatteryHistEntry);
     }
 
-    private void setUpBatteryHistoryKeys() {
-        mBatteryChartPreferenceController.mBatteryHistoryKeys =
-                // "2021-04-23 16:53:06 UTC", "1970-01-01 00:00:00 UTC", "2021-04-23 07:00:36 UTC"
-                new long[]{1619196786769L, 0L, 1619247636826L};
-        ConvertUtils.utcToLocalTimeHour(
-                mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
-    }
-
     private BatteryChartPreferenceControllerV2 createController() {
         final BatteryChartPreferenceControllerV2 controller =
                 new BatteryChartPreferenceControllerV2(
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2Test.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2Test.java
index a8b8d10..1747335 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2Test.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartViewV2Test.java
@@ -104,7 +104,8 @@
         final int originalSelectedIndex = 2;
         mBatteryChartView.setViewModel(
                 new BatteryChartViewModel(List.of(90, 80, 70, 60), List.of("", "", "", ""),
-                        originalSelectedIndex));
+                        originalSelectedIndex,
+                        BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS));
         for (int i = 0; i < mBatteryChartView.mTrapezoidSlots.length; i++) {
             mBatteryChartView.mTrapezoidSlots[i] = new BatteryChartViewV2.TrapezoidSlot();
             mBatteryChartView.mTrapezoidSlots[i].mLeft = i;
@@ -136,6 +137,7 @@
                 .thenReturn(false);
 
         mBatteryChartView.onAttachedToWindow();
+
         assertThat(mBatteryChartView.isClickable()).isFalse();
         assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNotNull();
     }
@@ -148,6 +150,7 @@
         doReturn(false).when(mMockAccessibilityManager).isEnabled();
 
         mBatteryChartView.onAttachedToWindow();
+
         assertThat(mBatteryChartView.isClickable()).isTrue();
         assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNull();
     }
@@ -163,6 +166,7 @@
                 .getEnabledAccessibilityServiceList(anyInt());
 
         mBatteryChartView.onAttachedToWindow();
+
         assertThat(mBatteryChartView.isClickable()).isTrue();
         assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNull();
     }
@@ -175,6 +179,7 @@
         doReturn(true).when(mMockAccessibilityManager).isEnabled();
 
         mBatteryChartView.onAttachedToWindow();
+
         assertThat(mBatteryChartView.isClickable()).isFalse();
         assertThat(mBatteryChartView.mTrapezoidCurvePaint).isNotNull();
     }
@@ -188,7 +193,8 @@
             texts.add("");
         }
         mBatteryChartView.setViewModel(new BatteryChartViewModel(
-                levels, texts, BatteryChartViewModel.SELECTED_INDEX_ALL));
+                levels, texts, BatteryChartViewModel.SELECTED_INDEX_ALL,
+                BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS));
         mBatteryChartView.setClickableForce(true);
         when(mPowerUsageFeatureProvider.isChartGraphSlotsEnabled(mContext))
                 .thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
index 0306c4b..1b1e469 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
@@ -19,11 +19,16 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
 import android.content.ContentValues;
 import android.content.Context;
 import android.text.format.DateUtils;
 
+import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
+import com.android.settings.testutils.FakeFeatureFactory;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -35,6 +40,7 @@
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
@@ -45,18 +51,30 @@
 
     private Context mContext;
 
+    private FakeFeatureFactory mFeatureFactory;
+    private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
 
         mContext = spy(RuntimeEnvironment.application);
+        mFeatureFactory = FakeFeatureFactory.setupForTest();
+        mPowerUsageFeatureProvider = mFeatureFactory.powerUsageFeatureProvider;
     }
 
     @Test
     public void getBatteryLevelData_emptyHistoryMap_returnNull() {
-        assertThat(DataProcessor.getBatteryLevelData(mContext, null)).isNull();
-        assertThat(DataProcessor.getBatteryLevelData(mContext, new HashMap<>())).isNull();
+        assertThat(DataProcessor.getBatteryLevelData(
+                mContext,
+                /*handler=*/ null,
+                /*batteryHistoryMap=*/ null,
+                /*asyncResponseDelegate=*/ null))
+                .isNull();
+        assertThat(DataProcessor.getBatteryLevelData(
+                mContext, /*handler=*/ null, new HashMap<>(), /*asyncResponseDelegate=*/ null))
+                .isNull();
     }
 
     @Test
@@ -67,7 +85,9 @@
         final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap =
                 createHistoryMap(timestamps, levels);
 
-        assertThat(DataProcessor.getBatteryLevelData(mContext, batteryHistoryMap)).isNull();
+        assertThat(DataProcessor.getBatteryLevelData(
+                mContext, /*handler=*/ null, batteryHistoryMap, /*asyncResponseDelegate=*/ null))
+                .isNull();
     }
 
     @Test
@@ -79,7 +99,11 @@
                 createHistoryMap(timestamps, levels);
 
         final BatteryLevelData resultData =
-                DataProcessor.getBatteryLevelData(mContext, batteryHistoryMap);
+                DataProcessor.getBatteryLevelData(
+                        mContext,
+                        /*handler=*/ null,
+                        batteryHistoryMap,
+                        /*asyncResponseDelegate=*/ null);
 
         final List<Long> expectedDailyTimestamps = List.of(timestamps[0], timestamps[2]);
         final List<Integer> expectedDailyLevels = List.of(levels[0], levels[2]);
@@ -377,6 +401,450 @@
                 .isEqualTo(1640966400000L);
     }
 
+    @Test
+    public void getBatteryUsageMap_emptyHistoryMap_returnNull() {
+        final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+                new ArrayList<>();
+        hourlyBatteryLevelsPerDay.add(
+                new BatteryLevelData.PeriodBatteryLevelData(new ArrayList<>(), new ArrayList<>()));
+
+        assertThat(DataProcessor.getBatteryUsageMap(
+                mContext, hourlyBatteryLevelsPerDay, new HashMap<>())).isNull();
+    }
+
+    @Test
+    public void getBatteryUsageMap_emptyHourlyData_returnNull() {
+        final long[] timestamps = {1000000L, 2000000L};
+        final int[] levels = {100, 99};
+        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap =
+                createHistoryMap(timestamps, levels);
+
+        assertThat(DataProcessor.getBatteryUsageMap(
+                mContext, new ArrayList<>(), batteryHistoryMap)).isNull();
+    }
+
+    @Test
+    public void getBatteryUsageMap_returnsExpectedResult() {
+        final long[] batteryHistoryKeys = new long[]{
+                1641045600000L, // 2022-01-01 22:00:00
+                1641049200000L, // 2022-01-01 23:00:00
+                1641052800000L, // 2022-01-02 00:00:00
+                1641056400000L, // 2022-01-02 01:00:00
+                1641060000000L, // 2022-01-02 02:00:00
+        };
+        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = new HashMap<>();
+        final int currentUserId = mContext.getUserId();
+        final BatteryHistEntry fakeEntry = createBatteryHistEntry(
+                ConvertUtils.FAKE_PACKAGE_NAME, "fake_label", /*consumePower=*/ 0, /*uid=*/ 0L,
+                currentUserId, ConvertUtils.CONSUMER_TYPE_UID_BATTERY,
+                /*foregroundUsageTimeInMs=*/ 0L, /*backgroundUsageTimeInMs=*/ 0L);
+        // Adds the index = 0 data.
+        Map<String, BatteryHistEntry> entryMap = new HashMap<>();
+        BatteryHistEntry entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 5.0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        entryMap.put(fakeEntry.getKey(), fakeEntry);
+        batteryHistoryMap.put(batteryHistoryKeys[0], entryMap);
+        // Adds the index = 1 data.
+        entryMap = new HashMap<>();
+        entryMap.put(fakeEntry.getKey(), fakeEntry);
+        batteryHistoryMap.put(batteryHistoryKeys[1], entryMap);
+        // Adds the index = 2 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 20.0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 15L,
+                25L);
+        entryMap.put(entry.getKey(), entry);
+        entryMap.put(fakeEntry.getKey(), fakeEntry);
+        batteryHistoryMap.put(batteryHistoryKeys[2], entryMap);
+        // Adds the index = 3 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 40.0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 25L,
+                /*backgroundUsageTimeInMs=*/ 35L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 10.0, /*uid=*/ 3L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY, /*foregroundUsageTimeInMs=*/ 40L,
+                /*backgroundUsageTimeInMs=*/ 50L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package3", "label3", /*consumePower=*/ 15.0, /*uid=*/ 4L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 5L,
+                /*backgroundUsageTimeInMs=*/ 5L);
+        entryMap.put(entry.getKey(), entry);
+        entryMap.put(fakeEntry.getKey(), fakeEntry);
+        batteryHistoryMap.put(batteryHistoryKeys[3], entryMap);
+        // Adds the index = 4 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 40.0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 30L,
+                /*backgroundUsageTimeInMs=*/ 40L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 20.0, /*uid=*/ 3L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY, /*foregroundUsageTimeInMs=*/ 50L,
+                /*backgroundUsageTimeInMs=*/ 60L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package3", "label3", /*consumePower=*/ 40.0, /*uid=*/ 4L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 5L,
+                /*backgroundUsageTimeInMs=*/ 5L);
+        entryMap.put(entry.getKey(), entry);
+        entryMap.put(fakeEntry.getKey(), fakeEntry);
+        batteryHistoryMap.put(batteryHistoryKeys[4], entryMap);
+        final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+                new ArrayList<>();
+        // Adds the day 1 data.
+        List<Long> timestamps =
+                List.of(batteryHistoryKeys[0], batteryHistoryKeys[2]);
+        final List<Integer> levels = List.of(100, 100);
+        hourlyBatteryLevelsPerDay.add(
+                new BatteryLevelData.PeriodBatteryLevelData(timestamps, levels));
+        // Adds the day 2 data.
+        timestamps = List.of(batteryHistoryKeys[2], batteryHistoryKeys[4]);
+        hourlyBatteryLevelsPerDay.add(
+                new BatteryLevelData.PeriodBatteryLevelData(timestamps, levels));
+
+        final Map<Integer, Map<Integer, BatteryDiffData>> resultMap =
+                DataProcessor.getBatteryUsageMap(
+                        mContext, hourlyBatteryLevelsPerDay, batteryHistoryMap);
+
+        BatteryDiffData resultDiffData =
+                resultMap
+                        .get(DataProcessor.SELECTED_INDEX_ALL)
+                        .get(DataProcessor.SELECTED_INDEX_ALL);
+        assertBatteryDiffEntry(
+                resultDiffData.getAppDiffEntryList().get(0), currentUserId, /*uid=*/ 2L,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*consumePercentage=*/ 40.0,
+                /*foregroundUsageTimeInMs=*/ 30, /*backgroundUsageTimeInMs=*/ 40);
+        assertBatteryDiffEntry(
+                resultDiffData.getAppDiffEntryList().get(1), currentUserId, /*uid=*/ 4L,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*consumePercentage=*/ 40.0,
+                /*foregroundUsageTimeInMs=*/ 5, /*backgroundUsageTimeInMs=*/ 5);
+        assertBatteryDiffEntry(
+                resultDiffData.getSystemDiffEntryList().get(0), currentUserId, /*uid=*/ 3L,
+                ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY, /*consumePercentage=*/ 20.0,
+                /*foregroundUsageTimeInMs=*/ 50, /*backgroundUsageTimeInMs=*/ 60);
+        resultDiffData = resultMap.get(0).get(DataProcessor.SELECTED_INDEX_ALL);
+        assertBatteryDiffEntry(
+                resultDiffData.getAppDiffEntryList().get(0), currentUserId, /*uid=*/ 2L,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*consumePercentage=*/ 100.0,
+                /*foregroundUsageTimeInMs=*/ 15, /*backgroundUsageTimeInMs=*/ 25);
+        resultDiffData = resultMap.get(1).get(DataProcessor.SELECTED_INDEX_ALL);
+        assertBatteryDiffEntry(
+                resultDiffData.getAppDiffEntryList().get(0), currentUserId, /*uid=*/ 4L,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*consumePercentage=*/ 50.0,
+                /*foregroundUsageTimeInMs=*/ 5, /*backgroundUsageTimeInMs=*/ 5);
+        assertBatteryDiffEntry(
+                resultDiffData.getAppDiffEntryList().get(1), currentUserId, /*uid=*/ 2L,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*consumePercentage=*/ 25.0,
+                /*foregroundUsageTimeInMs=*/ 15, /*backgroundUsageTimeInMs=*/ 15);
+        assertBatteryDiffEntry(
+                resultDiffData.getSystemDiffEntryList().get(0), currentUserId, /*uid=*/ 3L,
+                ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY, /*consumePercentage=*/ 25.0,
+                /*foregroundUsageTimeInMs=*/ 50, /*backgroundUsageTimeInMs=*/ 60);
+    }
+
+    @Test
+    public void getBatteryUsageMap_multipleUsers_returnsExpectedResult() {
+        final long[] batteryHistoryKeys = new long[]{
+                1641052800000L, // 2022-01-02 00:00:00
+                1641056400000L, // 2022-01-02 01:00:00
+                1641060000000L  // 2022-01-02 02:00:00
+        };
+        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = new HashMap<>();
+        final int currentUserId = mContext.getUserId();
+        // Adds the index = 0 data.
+        Map<String, BatteryHistEntry> entryMap = new HashMap<>();
+        BatteryHistEntry entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 5.0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 10.0, /*uid=*/ 2L, currentUserId + 1,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 5.0, /*uid=*/ 3L, currentUserId + 2,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 20L,
+                /*backgroundUsageTimeInMs=*/ 30L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[0], entryMap);
+        // Adds the index = 1 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 15.0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 20L,
+                /*backgroundUsageTimeInMs=*/ 30L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 30.0, /*uid=*/ 2L, currentUserId + 1,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 15.0, /*uid=*/ 3L, currentUserId + 2,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 30L,
+                /*backgroundUsageTimeInMs=*/ 30L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[1], entryMap);
+        // Adds the index = 2 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 25.0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 20L,
+                /*backgroundUsageTimeInMs=*/ 30L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 50.0, /*uid=*/ 2L, currentUserId + 1,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 20L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 25.0, /*uid=*/ 3L, currentUserId + 2,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 30L,
+                /*backgroundUsageTimeInMs=*/ 30L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[2], entryMap);
+        final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+                new ArrayList<>();
+        List<Long> timestamps = List.of(batteryHistoryKeys[0], batteryHistoryKeys[2]);
+        final List<Integer> levels = List.of(100, 100);
+        hourlyBatteryLevelsPerDay.add(
+                new BatteryLevelData.PeriodBatteryLevelData(timestamps, levels));
+
+        final Map<Integer, Map<Integer, BatteryDiffData>> resultMap =
+                DataProcessor.getBatteryUsageMap(
+                        mContext, hourlyBatteryLevelsPerDay, batteryHistoryMap);
+
+        final BatteryDiffData resultDiffData =
+                resultMap
+                        .get(DataProcessor.SELECTED_INDEX_ALL)
+                        .get(DataProcessor.SELECTED_INDEX_ALL);
+        assertBatteryDiffEntry(
+                resultDiffData.getAppDiffEntryList().get(0), currentUserId, /*uid=*/ 1L,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*consumePercentage=*/ 25.0,
+                /*foregroundUsageTimeInMs=*/ 10, /*backgroundUsageTimeInMs=*/ 10);
+        assertBatteryDiffEntry(
+                resultDiffData.getSystemDiffEntryList().get(0), BatteryUtils.UID_OTHER_USERS,
+                /*uid=*/ BatteryUtils.UID_OTHER_USERS, ConvertUtils.CONSUMER_TYPE_UID_BATTERY,
+                /*consumePercentage=*/ 75.0, /*foregroundUsageTimeInMs=*/ 0,
+                /*backgroundUsageTimeInMs=*/ 0);
+        assertThat(resultMap.get(0).get(0)).isNotNull();
+        assertThat(resultMap.get(0).get(DataProcessor.SELECTED_INDEX_ALL)).isNotNull();
+    }
+
+    @Test
+    public void getBatteryUsageMap_usageTimeExceed_returnsExpectedResult() {
+        final long[] batteryHistoryKeys = new long[]{
+                1641052800000L, // 2022-01-02 00:00:00
+                1641056400000L, // 2022-01-02 01:00:00
+                1641060000000L  // 2022-01-02 02:00:00
+        };
+        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = new HashMap<>();
+        final int currentUserId = mContext.getUserId();
+        // Adds the index = 0 data.
+        Map<String, BatteryHistEntry> entryMap = new HashMap<>();
+        BatteryHistEntry entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[0], entryMap);
+        // Adds the index = 1 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[1], entryMap);
+        // Adds the index = 2 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 500.0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 3600000L,
+                /*backgroundUsageTimeInMs=*/ 7200000L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[2], entryMap);
+        final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+                new ArrayList<>();
+        List<Long> timestamps = List.of(batteryHistoryKeys[0], batteryHistoryKeys[2]);
+        final List<Integer> levels = List.of(100, 100);
+        hourlyBatteryLevelsPerDay.add(
+                new BatteryLevelData.PeriodBatteryLevelData(timestamps, levels));
+
+        final Map<Integer, Map<Integer, BatteryDiffData>> resultMap =
+                DataProcessor.getBatteryUsageMap(
+                        mContext, hourlyBatteryLevelsPerDay, batteryHistoryMap);
+
+        final BatteryDiffData resultDiffData =
+                resultMap
+                        .get(DataProcessor.SELECTED_INDEX_ALL)
+                        .get(DataProcessor.SELECTED_INDEX_ALL);
+        // Verifies the clipped usage time.
+        final float ratio = (float) (7200) / (float) (3600 + 7200);
+        final BatteryDiffEntry resultEntry = resultDiffData.getAppDiffEntryList().get(0);
+        assertThat(resultEntry.mForegroundUsageTimeInMs)
+                .isEqualTo(Math.round(entry.mForegroundUsageTimeInMs * ratio));
+        assertThat(resultEntry.mBackgroundUsageTimeInMs)
+                .isEqualTo(Math.round(entry.mBackgroundUsageTimeInMs * ratio));
+        assertThat(resultEntry.mConsumePower)
+                .isEqualTo(entry.mConsumePower * ratio);
+        assertThat(resultMap.get(0).get(0)).isNotNull();
+        assertThat(resultMap.get(0).get(DataProcessor.SELECTED_INDEX_ALL)).isNotNull();
+    }
+
+    @Test
+    public void getBatteryUsageMap_hideApplicationEntries_returnsExpectedResult() {
+        final long[] batteryHistoryKeys = new long[]{
+                1641052800000L, // 2022-01-02 00:00:00
+                1641056400000L, // 2022-01-02 01:00:00
+                1641060000000L  // 2022-01-02 02:00:00
+        };
+        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = new HashMap<>();
+        final int currentUserId = mContext.getUserId();
+        // Adds the index = 0 data.
+        Map<String, BatteryHistEntry> entryMap = new HashMap<>();
+        BatteryHistEntry entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[0], entryMap);
+        // Adds the index = 1 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[1], entryMap);
+        // Adds the index = 2 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 10.0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 10.0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[2], entryMap);
+        final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+                new ArrayList<>();
+        List<Long> timestamps = List.of(batteryHistoryKeys[0], batteryHistoryKeys[2]);
+        final List<Integer> levels = List.of(100, 100);
+        hourlyBatteryLevelsPerDay.add(
+                new BatteryLevelData.PeriodBatteryLevelData(timestamps, levels));
+        when(mPowerUsageFeatureProvider.getHideApplicationEntries(mContext))
+                .thenReturn(new CharSequence[]{"package1"});
+
+        final Map<Integer, Map<Integer, BatteryDiffData>> resultMap =
+                DataProcessor.getBatteryUsageMap(
+                        mContext, hourlyBatteryLevelsPerDay, batteryHistoryMap);
+
+        final BatteryDiffData resultDiffData =
+                resultMap
+                        .get(DataProcessor.SELECTED_INDEX_ALL)
+                        .get(DataProcessor.SELECTED_INDEX_ALL);
+        assertBatteryDiffEntry(
+                resultDiffData.getAppDiffEntryList().get(0), currentUserId, /*uid=*/ 2L,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*consumePercentage=*/ 50.0,
+                /*foregroundUsageTimeInMs=*/ 10, /*backgroundUsageTimeInMs=*/ 20);
+    }
+
+    @Test
+    public void getBatteryUsageMap_hideBackgroundUsageTime_returnsExpectedResult() {
+        final long[] batteryHistoryKeys = new long[]{
+                1641052800000L, // 2022-01-02 00:00:00
+                1641056400000L, // 2022-01-02 01:00:00
+                1641060000000L  // 2022-01-02 02:00:00
+        };
+        final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = new HashMap<>();
+        final int currentUserId = mContext.getUserId();
+        // Adds the index = 0 data.
+        Map<String, BatteryHistEntry> entryMap = new HashMap<>();
+        BatteryHistEntry entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[0], entryMap);
+        // Adds the index = 1 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 0L,
+                /*backgroundUsageTimeInMs=*/ 0L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[1], entryMap);
+        // Adds the index = 2 data.
+        entryMap = new HashMap<>();
+        entry = createBatteryHistEntry(
+                "package1", "label1", /*consumePower=*/ 10.0, /*uid=*/ 1L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        entry = createBatteryHistEntry(
+                "package2", "label2", /*consumePower=*/ 10.0, /*uid=*/ 2L, currentUserId,
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY, /*foregroundUsageTimeInMs=*/ 10L,
+                /*backgroundUsageTimeInMs=*/ 20L);
+        entryMap.put(entry.getKey(), entry);
+        batteryHistoryMap.put(batteryHistoryKeys[2], entryMap);
+        final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay =
+                new ArrayList<>();
+        List<Long> timestamps = List.of(batteryHistoryKeys[0], batteryHistoryKeys[2]);
+        final List<Integer> levels = List.of(100, 100);
+        hourlyBatteryLevelsPerDay.add(
+                new BatteryLevelData.PeriodBatteryLevelData(timestamps, levels));
+        when(mPowerUsageFeatureProvider.getHideBackgroundUsageTimeSet(mContext))
+                .thenReturn(new HashSet(Arrays.asList((CharSequence) "package2")));
+
+        final Map<Integer, Map<Integer, BatteryDiffData>> resultMap =
+                DataProcessor.getBatteryUsageMap(
+                        mContext, hourlyBatteryLevelsPerDay, batteryHistoryMap);
+
+        final BatteryDiffData resultDiffData =
+                resultMap
+                        .get(DataProcessor.SELECTED_INDEX_ALL)
+                        .get(DataProcessor.SELECTED_INDEX_ALL);
+        BatteryDiffEntry resultEntry = resultDiffData.getAppDiffEntryList().get(0);
+        assertThat(resultEntry.mBackgroundUsageTimeInMs).isEqualTo(20);
+        resultEntry = resultDiffData.getAppDiffEntryList().get(1);
+        assertThat(resultEntry.mBackgroundUsageTimeInMs).isEqualTo(0);
+    }
+
     private static Map<Long, Map<String, BatteryHistEntry>> createHistoryMap(
             final long[] timestamps, final int[] levels) {
         final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = new HashMap<>();
@@ -391,6 +859,23 @@
         return batteryHistoryMap;
     }
 
+    private static BatteryHistEntry createBatteryHistEntry(
+            final String packageName, final String appLabel, final double consumePower,
+            final long uid, final long userId, final int consumerType,
+            final long foregroundUsageTimeInMs, final long backgroundUsageTimeInMs) {
+        // Only insert required fields.
+        final ContentValues values = new ContentValues();
+        values.put(BatteryHistEntry.KEY_PACKAGE_NAME, packageName);
+        values.put(BatteryHistEntry.KEY_APP_LABEL, appLabel);
+        values.put(BatteryHistEntry.KEY_UID, uid);
+        values.put(BatteryHistEntry.KEY_USER_ID, userId);
+        values.put(BatteryHistEntry.KEY_CONSUMER_TYPE, consumerType);
+        values.put(BatteryHistEntry.KEY_CONSUME_POWER, consumePower);
+        values.put(BatteryHistEntry.KEY_FOREGROUND_USAGE_TIME, foregroundUsageTimeInMs);
+        values.put(BatteryHistEntry.KEY_BACKGROUND_USAGE_TIME, backgroundUsageTimeInMs);
+        return new BatteryHistEntry(values);
+    }
+
     private static void verifyExpectedBatteryLevelData(
             final BatteryLevelData resultData,
             final List<Long> expectedDailyTimestamps,
@@ -451,4 +936,15 @@
                 .isEqualTo(expectedEnd.getTimeInMillis());
     }
 
+    private static void assertBatteryDiffEntry(
+            final BatteryDiffEntry entry, final long userId, final long uid,
+            final int consumerType, final double consumePercentage,
+            final long foregroundUsageTimeInMs, final long backgroundUsageTimeInMs) {
+        assertThat(entry.mBatteryHistEntry.mUserId).isEqualTo(userId);
+        assertThat(entry.mBatteryHistEntry.mUid).isEqualTo(uid);
+        assertThat(entry.mBatteryHistEntry.mConsumerType).isEqualTo(consumerType);
+        assertThat(entry.getPercentOfTotal()).isEqualTo(consumePercentage);
+        assertThat(entry.mForegroundUsageTimeInMs).isEqualTo(foregroundUsageTimeInMs);
+        assertThat(entry.mBackgroundUsageTimeInMs).isEqualTo(backgroundUsageTimeInMs);
+    }
 }
diff --git a/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
index 8bd9b01..d347f91 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
@@ -55,7 +55,6 @@
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Menu mMenu;
     @Mock private PackageManager mPackageManager;
-    @Mock private StorageManager mStorageManager;
     @Mock private VolumeInfo mExternalVolumeInfo;
     @Mock private VolumeInfo mInternalVolumeInfo;
 
@@ -68,7 +67,6 @@
 
         mContext = spy(ApplicationProvider.getApplicationContext());
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
-        when(mContext.getSystemService(StorageManager.class)).thenReturn(mStorageManager);
 
         when(mInternalVolumeInfo.getId()).thenReturn(INTERNAL_VOLUME_ID);
         when(mInternalVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
@@ -173,17 +171,16 @@
         when(mExternalVolumeInfo.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
         when(mExternalVolumeInfo.getDiskId()).thenReturn(DISK_ID);
         final DiskInfo externalDiskInfo = mock(DiskInfo.class);
-        when(mStorageManager.findDiskById(DISK_ID)).thenReturn(externalDiskInfo);
         mController.setSelectedStorageEntry(new StorageEntry(mContext, mExternalVolumeInfo));
 
         mController.onPrepareOptionsMenu(mMenu);
 
         verify(mController.mRename, atLeastOnce()).setVisible(true);
         verify(mController.mUnmount, atLeastOnce()).setVisible(true);
-        verify(mController.mFormat, atLeastOnce()).setVisible(true);
-        verify(mController.mMount, never()).setVisible(true);
+        verify(mController.mFormatAsInternal, atLeastOnce()).setVisible(true);
         verify(mController.mFormatAsPortable, never()).setVisible(true);
-        verify(mController.mFormatAsInternal, never()).setVisible(true);
+        verify(mController.mFormat, never()).setVisible(true);
+        verify(mController.mMount, never()).setVisible(true);
         verify(mController.mFree, never()).setVisible(true);
         verify(mController.mForget, never()).setVisible(true);
     }
diff --git a/tests/unit/src/com/android/settings/vpn2/VpnSettingsTest.java b/tests/unit/src/com/android/settings/vpn2/VpnSettingsTest.java
index 86bd1e7..953a524 100644
--- a/tests/unit/src/com/android/settings/vpn2/VpnSettingsTest.java
+++ b/tests/unit/src/com/android/settings/vpn2/VpnSettingsTest.java
@@ -20,15 +20,22 @@
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.AppOpsManager;
 import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.os.Looper;
 import android.os.UserHandle;
+import android.text.TextUtils;
 import android.util.ArraySet;
 
 import androidx.preference.Preference;
@@ -46,6 +53,7 @@
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
@@ -56,19 +64,26 @@
 
 @RunWith(AndroidJUnit4.class)
 public class VpnSettingsTest {
-    private static final String ADVANCED_VPN_GROUP_KEY = "advanced_vpn_group";
-    private static final String VPN_GROUP_KEY = "vpn_group";
-    private static final String ADVANCED_VPN_GROUP_TITLE = "advanced_vpn_group_title";
-    private static final String VPN_GROUP_TITLE = "vpn_group_title";
-    private static final String FAKE_PACKAGE_NAME = "com.fake.package.name";
-    private static final String ADVANCED_VPN_GROUP_PACKAGE_NAME = "com.advanced.package.name";
     private static final int USER_ID_1 = UserHandle.USER_NULL;
+    private static final String VPN_GROUP_KEY = "vpn_group";
+    private static final String VPN_GROUP_TITLE = "vpn_group_title";
+    private static final String VPN_PACKAGE_NAME = "vpn.package.name";
+    private static final String VPN_LAUNCH_INTENT = "vpn.action";
+    private static final String ADVANCED_VPN_GROUP_KEY = "advanced_vpn_group";
+    private static final String ADVANCED_VPN_GROUP_TITLE = "advanced_vpn_group_title";
+    private static final String ADVANCED_VPN_PACKAGE_NAME = "advanced.vpn.package.name";
+    private static final String ADVANCED_VPN_LAUNCH_INTENT = "advanced.vpn.action";
+
+    private final Intent mVpnIntent = new Intent().setAction(VPN_LAUNCH_INTENT);
+    private final Intent mAdvancedVpnIntent = new Intent().setAction(ADVANCED_VPN_LAUNCH_INTENT);
 
     @Rule
     public final MockitoRule mMockitoRule = MockitoJUnit.rule();
 
     @Mock
     private AppOpsManager mAppOpsManager;
+    @Mock
+    private PackageManager mPackageManager;
 
     private VpnSettings mVpnSettings;
     private Context mContext;
@@ -104,9 +119,10 @@
         when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.getVpnPreferenceGroupTitle(mContext))
                 .thenReturn(VPN_GROUP_TITLE);
         when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.getAdvancedVpnPackageName())
-                .thenReturn(ADVANCED_VPN_GROUP_PACKAGE_NAME);
+                .thenReturn(ADVANCED_VPN_PACKAGE_NAME);
         when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnSupported(any()))
                 .thenReturn(true);
+        when(mContext.getPackageManager()).thenReturn(mPackageManager);
         doReturn(mContext).when(mContext).createContextAsUser(any(), anyInt());
         doReturn(mContext).when(mContext).createPackageContextAsUser(any(), anyInt(), any());
         doReturn(mPreferenceManager).when(mVpnGroup).getPreferenceManager();
@@ -117,7 +133,7 @@
     public void setShownAdvancedPreferences_hasGeneralVpn_returnsVpnCountAs1() {
         Set<Preference> updates = new ArraySet<>();
         AppPreference pref =
-                spy(new AppPreference(mContext, USER_ID_1, FAKE_PACKAGE_NAME));
+                spy(new AppPreference(mContext, USER_ID_1, VPN_PACKAGE_NAME));
         updates.add(pref);
 
         mVpnSettings.setShownAdvancedPreferences(updates);
@@ -131,7 +147,7 @@
     public void setShownAdvancedPreferences_hasAdvancedVpn_returnsAdvancedVpnCountAs1() {
         Set<Preference> updates = new ArraySet<>();
         AppPreference pref =
-                spy(new AppPreference(mContext, USER_ID_1, ADVANCED_VPN_GROUP_PACKAGE_NAME));
+                spy(new AppPreference(mContext, USER_ID_1, ADVANCED_VPN_PACKAGE_NAME));
         updates.add(pref);
 
         mVpnSettings.setShownAdvancedPreferences(updates);
@@ -154,14 +170,10 @@
     }
 
     @Test
-    public void getVpnApps_isAdvancedVpn_returnsOne() {
-        int uid = 1111;
-        List<AppOpsManager.OpEntry> opEntries = new ArrayList<>();
-        List<AppOpsManager.PackageOps> apps = new ArrayList<>();
-        AppOpsManager.PackageOps packageOps =
-                new AppOpsManager.PackageOps(ADVANCED_VPN_GROUP_PACKAGE_NAME, uid, opEntries);
-        apps.add(packageOps);
-        when(mAppOpsManager.getPackagesForOps((int[]) any())).thenReturn(apps);
+    public void getVpnApps_isAdvancedVpn_returnsOne() throws Exception {
+        ApplicationInfo info = new ApplicationInfo();
+        info.uid = 1111;
+        when(mPackageManager.getApplicationInfo(anyString(), anyInt())).thenReturn(info);
 
         assertThat(VpnSettings.getVpnApps(mContext, /* includeProfiles= */ false,
                 mFakeFeatureFactory.getAdvancedVpnFeatureProvider(),
@@ -174,12 +186,100 @@
         List<AppOpsManager.OpEntry> opEntries = new ArrayList<>();
         List<AppOpsManager.PackageOps> apps = new ArrayList<>();
         AppOpsManager.PackageOps packageOps =
-                new AppOpsManager.PackageOps(FAKE_PACKAGE_NAME, uid, opEntries);
+                new AppOpsManager.PackageOps(VPN_PACKAGE_NAME, uid, opEntries);
         apps.add(packageOps);
         when(mAppOpsManager.getPackagesForOps((int[]) any())).thenReturn(apps);
+        when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnSupported(any()))
+                .thenReturn(false);
 
         assertThat(VpnSettings.getVpnApps(mContext, /* includeProfiles= */ false,
                 mFakeFeatureFactory.getAdvancedVpnFeatureProvider(),
                 mAppOpsManager)).isEmpty();
     }
+
+    @Test
+    public void clickVpn_VpnConnected_doesNotStartVpnLaunchIntent()
+            throws PackageManager.NameNotFoundException {
+        Set<Preference> updates = new ArraySet<>();
+        AppPreference pref = spy(new AppPreference(mContext, USER_ID_1, VPN_PACKAGE_NAME));
+        pref.setState(AppPreference.STATE_CONNECTED);
+        updates.add(pref);
+        when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
+        when(mContext.getPackageManager()).thenReturn(mPackageManager);
+        when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mVpnIntent);
+        ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+        doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
+        mVpnSettings.setShownPreferences(updates);
+
+        mVpnSettings.onPreferenceClick(pref);
+
+        verify(mContext, never()).startActivityAsUser(any(), any());
+    }
+
+    @Test
+    public void clickVpn_VpnDisconnected_startsVpnLaunchIntent()
+            throws PackageManager.NameNotFoundException {
+        Set<Preference> updates = new ArraySet<>();
+        AppPreference pref = spy(new AppPreference(mContext, USER_ID_1, VPN_PACKAGE_NAME));
+        pref.setState(AppPreference.STATE_DISCONNECTED);
+        updates.add(pref);
+        when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
+        when(mContext.getPackageManager()).thenReturn(mPackageManager);
+        when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mVpnIntent);
+        ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+        doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
+        mVpnSettings.setShownPreferences(updates);
+
+        mVpnSettings.onPreferenceClick(pref);
+
+        verify(mContext).startActivityAsUser(captor.capture(), any());
+        assertThat(TextUtils.equals(captor.getValue().getAction(),
+                VPN_LAUNCH_INTENT)).isTrue();
+    }
+
+    @Test
+    public void clickAdvancedVpn_VpnConnectedDisconnectDialogDisabled_startsAppLaunchIntent()
+            throws PackageManager.NameNotFoundException {
+        Set<Preference> updates = new ArraySet<>();
+        AppPreference pref =
+                spy(new AppPreference(mContext, USER_ID_1, ADVANCED_VPN_PACKAGE_NAME));
+        pref.setState(AppPreference.STATE_CONNECTED);
+        updates.add(pref);
+        when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isDisconnectDialogEnabled())
+                .thenReturn(false);
+        when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
+        when(mContext.getPackageManager()).thenReturn(mPackageManager);
+        when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mAdvancedVpnIntent);
+        ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+        doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
+        mVpnSettings.setShownAdvancedPreferences(updates);
+
+        mVpnSettings.onPreferenceClick(pref);
+
+        verify(mContext).startActivityAsUser(captor.capture(), any());
+        assertThat(TextUtils.equals(captor.getValue().getAction(),
+                ADVANCED_VPN_LAUNCH_INTENT)).isTrue();
+    }
+
+    @Test
+    public void clickAdvancedVpn_VpnConnectedDisconnectDialogEnabled_doesNotStartAppLaunchIntent()
+            throws PackageManager.NameNotFoundException {
+        Set<Preference> updates = new ArraySet<>();
+        AppPreference pref =
+                spy(new AppPreference(mContext, USER_ID_1, ADVANCED_VPN_PACKAGE_NAME));
+        pref.setState(AppPreference.STATE_CONNECTED);
+        updates.add(pref);
+        when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isDisconnectDialogEnabled())
+                .thenReturn(true);
+        when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
+        when(mContext.getPackageManager()).thenReturn(mPackageManager);
+        when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mAdvancedVpnIntent);
+        ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+        doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
+        mVpnSettings.setShownAdvancedPreferences(updates);
+
+        mVpnSettings.onPreferenceClick(pref);
+
+        verify(mContext, never()).startActivityAsUser(any(), any());
+    }
 }