Merge "Fix Wi-Fi QR code scanning icon disappears problem" into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6d3c207..dfbc02c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -534,6 +534,18 @@
         </activity>
 
         <activity
+            android:name="Settings$DataSaverSummaryActivity"
+            android:label="@string/data_saver_title"
+            android:parentActivityName="Settings">
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.DATA_SAVER_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.datausage.DataSaverSummary" />
+        </activity>
+
+        <activity
             android:name="Settings$DateTimeSettingsActivity"
             android:label="@string/date_and_time"
             android:icon="@drawable/ic_settings_date_time"
@@ -1590,10 +1602,6 @@
             android:permission="android.permission.MANAGE_FINGERPRINT"
             android:icon="@drawable/ic_suggestion_fingerprint"
             android:theme="@style/GlifTheme.Light">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="com.android.settings.suggested.category.FINGERPRINT_ENROLL" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.require_feature"
                 android:value="android.hardware.fingerprint" />
             <meta-data android:name="com.android.settings.title"
@@ -1602,6 +1610,22 @@
                 android:resource="@string/suggestion_additional_fingerprints_summary" />
         </activity>
 
+        <activity-alias android:name=".SetupFingerprintSuggestionActivity"
+            android:enabled="false"
+            android:exported="true"
+            android:targetActivity=".biometrics.fingerprint.FingerprintSuggestionActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.suggested.category.FINGERPRINT_ENROLL" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.require_feature"
+                       android:value="android.hardware.fingerprint" />
+            <meta-data android:name="com.android.settings.title"
+                       android:resource="@string/suggestion_additional_fingerprints" />
+            <meta-data android:name="com.android.settings.summary"
+                       android:resource="@string/suggestion_additional_fingerprints_summary" />
+        </activity-alias>
+
         <!-- Note this must not be exported since it returns the password in the intent -->
         <activity android:name=".password.ConfirmLockPattern$InternalActivity"
             android:exported="false"
@@ -2239,9 +2263,6 @@
             <intent-filter>
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
-            <meta-data android:name="com.android.settings.order" android:value="-6"/>
-            <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.ia.wireless" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.datausage.DataUsageSummary" />
         </activity>
@@ -2874,6 +2895,19 @@
                        android:value="com.android.settings.deletionhelper.AutomaticStorageManagerSettings" />
         </activity>
 
+        <!-- Show app-level advanced power usage details (app passed in as extras) -->
+        <activity
+            android:name=".fuelgauge.AdvancedPowerUsageDetailActivity"
+            android:excludeFromRecents="true"
+            android:launchMode="singleInstance"
+            android:theme="@android:style/Theme.NoDisplay">
+            <intent-filter>
+                <action android:name="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:scheme="package" />
+            </intent-filter>
+        </activity>
+
         <activity
             android:name=".Settings$AppAndNotificationDashboardActivity"
             android:label="@string/app_and_notification_dashboard_title"
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 3424e76..02b00e2 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -2277,6 +2277,102 @@
         priority="4"
         summary="Using hardcoded color"
         explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="                &lt;item android:color=&quot;#333E2723&quot; android:offset=&quot;0&quot;/>"
+        errorLine2="                      ~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/ic_accessibility_magnification.xml"
+            line="30"
+            column="23"/>
+    </issue>
+
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="                &lt;item android:color=&quot;#003E2723&quot; android:offset=&quot;1&quot;/>"
+        errorLine2="                      ~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/ic_accessibility_magnification.xml"
+            line="31"
+            column="23"/>
+    </issue>
+
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="                &lt;item android:color=&quot;#333E2723&quot; android:offset=&quot;0&quot;/>"
+        errorLine2="                      ~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/ic_accessibility_magnification.xml"
+            line="39"
+            column="23"/>
+    </issue>
+
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="                &lt;item android:color=&quot;#003E2723&quot; android:offset=&quot;1&quot;/>"
+        errorLine2="                      ~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/ic_accessibility_magnification.xml"
+            line="40"
+            column="23"/>
+    </issue>
+
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="                &lt;item android:color=&quot;#19FFFFFF&quot; android:offset=&quot;0&quot;/>"
+        errorLine2="                      ~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/ic_accessibility_magnification.xml"
+            line="60"
+            column="23"/>
+    </issue>
+
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="                &lt;item android:color=&quot;#00FFFFFF&quot; android:offset=&quot;1&quot;/>"
+        errorLine2="                      ~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/ic_accessibility_magnification.xml"
+            line="61"
+            column="23"/>
+    </issue>
+
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
         errorLine1="    android:background=&quot;#FF80CBC4&quot; >"
         errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
diff --git a/res/drawable/ic_accessibility_magnification.xml b/res/drawable/ic_accessibility_magnification.xml
new file mode 100644
index 0000000..0dd3e2e
--- /dev/null
+++ b/res/drawable/ic_accessibility_magnification.xml
@@ -0,0 +1,65 @@
+<!--
+  Copyright 2019 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<vector android:height="32dp" android:viewportHeight="192"
+    android:viewportWidth="192" android:width="32dp"
+    xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#F50057" android:pathData="M96,104m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0"/>
+    <path android:fillColor="#F50057" android:pathData="M178.57,70.06l-73.81,-58.94C99.6,7.01 92.35,6.96 87.15,11L13.59,68.14C8.87,71.8 6.9,78.02 8.61,83.77l28.53,89.97c1.83,6.09 7.39,10.26 13.7,10.26h90.38c6.28,0 11.82,-4.13 13.67,-10.19l0.69,-2.13l-34.94,-34.88v-4.7l-0.96,-0.99c-6.33,5.54 -14.61,8.9 -23.68,8.9c-19.89,0 -36.02,-16.12 -36.02,-36.01S76.11,68 96,68s36.01,16.12 36.01,36.01c0,8.68 -3.08,16.65 -8.2,22.87l1.05,1.01h4.7l30.34,30.39l23.47,-72.65C185.1,79.94 183.2,73.76 178.57,70.06z"/>
+    <path android:fillColor="#F50057" android:pathData="M65.25,73c0,0 -16.75,31.96 -9.25,45.1s21.02,29.15 40.01,32.65s32.99,10.5 39.99,14s19.58,6.93 19.58,6.93s-5.34,-9.49 4.32,-13.4c0.73,-3.53 -11.9,-42.35 -11.9,-42.35L127.92,73L81.79,62.25L65.25,73z"/>
+    <path android:fillAlpha="0.2" android:fillColor="#3E2723"
+        android:pathData="M155.33,171.43l-0.44,1.37c-1.85,6.06 -7.39,10.19 -13.67,10.19H50.84c-6.31,0 -11.87,-4.17 -13.7,-10.26L8.61,82.77c-0.36,-1.22 -0.55,-2.46 -0.59,-3.69c-0.06,1.56 0.13,3.14 0.59,4.69l28.53,89.97c1.83,6.09 7.39,10.26 13.7,10.26h90.38c6.28,0 11.82,-4.13 13.67,-10.19l0.69,-2.13L155.33,171.43z" android:strokeAlpha="0.2"/>
+    <path android:fillAlpha="0.2" android:fillColor="#3E2723"
+        android:pathData="M183.37,84.63l-23.71,73.41l0.24,0.24l23.47,-72.66c0.48,-1.57 0.67,-3.17 0.61,-4.75C183.94,82.13 183.74,83.39 183.37,84.63z" android:strokeAlpha="0.2"/>
+    <path android:pathData="M155.57,171.67l-34.93,-34.87v-4.7l-0.96,-0.99c-6.33,5.54 -14.61,8.9 -23.68,8.9c-9.81,0 -18.71,-3.93 -25.2,-10.29L125.07,184h16.14c6.28,0 11.81,-4.13 13.67,-10.19L155.57,171.67z">
+        <aapt:attr name="android:fillColor">
+            <gradient android:endX="138.7146" android:endY="173.8946"
+                android:startX="69.035" android:startY="104.215" android:type="linear">
+                <item android:color="#333E2723" android:offset="0"/>
+                <item android:color="#003E2723" android:offset="1"/>
+            </gradient>
+        </aapt:attr>
+    </path>
+    <path android:pathData="M132.01,104.01c0,8.68 -3.08,16.65 -8.2,22.87l1.05,1.01h4.7l30.34,30.39L170,127l-49,-49.03l-0.19,-0.04C127.71,84.49 132.01,93.74 132.01,104.01z">
+        <aapt:attr name="android:fillColor">
+            <gradient android:endX="157.0018" android:endY="137.0219"
+                android:startX="103.615" android:startY="83.635" android:type="linear">
+                <item android:color="#333E2723" android:offset="0"/>
+                <item android:color="#003E2723" android:offset="1"/>
+            </gradient>
+        </aapt:attr>
+    </path>
+    <path android:fillAlpha="0.2" android:fillColor="#3E2723"
+        android:pathData="M124.27,127.32c4.85,-6.13 7.75,-13.88 7.75,-22.3c0,-0.16 -0.01,-0.31 -0.01,-0.47c-0.12,8.47 -3.17,16.24 -8.19,22.34L124.27,127.32z" android:strokeAlpha="0.2"/>
+    <path android:fillAlpha="0.2" android:fillColor="#3E2723"
+        android:pathData="M96.01,80.01c-13.25,0 -24,10.75 -24,24c0,0.17 0.01,0.33 0.01,0.5c0.27,-13.02 10.91,-23.5 23.99,-23.5s23.72,10.48 23.99,23.5c0,-0.17 0.01,-0.33 0.01,-0.5C120.01,90.76 109.26,80.01 96.01,80.01z" android:strokeAlpha="0.2"/>
+    <path android:fillAlpha="0.2" android:fillColor="#3E2723"
+        android:pathData="M155.58,171.68l-34.93,-34.87l0,1l34.68,34.62z" android:strokeAlpha="0.2"/>
+    <path android:fillAlpha="0.2" android:fillColor="#3E2723"
+        android:pathData="M119.69,131.12c-6.33,5.54 -14.61,8.9 -23.68,8.9c-9.97,0 -19,-4.06 -25.52,-10.61h-0.01l5.59,5.59c5.71,3.8 12.57,6.03 19.94,6.03c9.07,0 17.35,-3.36 23.68,-8.9l0.96,0.99v-1L119.69,131.12z" android:strokeAlpha="0.2"/>
+    <path android:fillAlpha="0.2" android:fillColor="#FFFFFF"
+        android:pathData="M13.59,69.14L87.15,12c5.2,-4.04 12.45,-3.99 17.61,0.12l73.81,58.94c3.36,2.68 5.27,6.67 5.41,10.82c0.15,-4.51 -1.79,-8.93 -5.41,-11.82l-73.81,-58.94C99.6,7.01 92.35,6.96 87.15,11L13.59,68.14c-3.72,2.88 -5.72,7.36 -5.57,11.94C8.17,75.85 10.14,71.81 13.59,69.14z" android:strokeAlpha="0.2"/>
+    <path android:fillColor="#F8BBD0" android:pathData="M112,108h-12v12h-8v-12H80v-8h12V88h8v12h12V108z"/>
+    <path android:fillColor="#FFFFFF" android:pathData="M129.57,127.9h-4.7l-1.05,-1.01c5.12,-6.22 8.2,-14.19 8.2,-22.87c0,-19.89 -16.12,-36.01 -36.01,-36.01s-36.02,16.11 -36.02,36s16.13,36.01 36.02,36.01c9.07,0 17.35,-3.36 23.68,-8.9l0.96,0.99v4.7l34.93,34.87l4.33,-13.39L129.57,127.9zM96.01,128.01c-13.25,0 -24,-10.75 -24,-24s10.75,-24 24,-24s24,10.75 24,24S109.26,128.01 96.01,128.01z"/>
+    <path android:pathData="M37.14,173.74L8.61,83.77C6.9,78.02 8.87,71.8 13.59,68.14L87.15,11c5.2,-4.04 12.45,-3.99 17.61,0.12l73.81,58.94c4.63,3.7 6.53,9.88 4.8,15.57l-28.48,88.18c-1.85,6.06 -7.39,10.19 -13.67,10.19H50.84C44.53,184 38.97,179.83 37.14,173.74z">
+        <aapt:attr name="android:fillColor">
+            <gradient android:endX="163.5051" android:endY="178.712"
+                android:startX="38.1466" android:startY="53.3534" android:type="linear">
+                <item android:color="#19FFFFFF" android:offset="0"/>
+                <item android:color="#00FFFFFF" android:offset="1"/>
+            </gradient>
+        </aapt:attr>
+    </path>
+</vector>
diff --git a/res/drawable/ic_settings_sign_in.xml b/res/drawable/ic_settings_sign_in.xml
new file mode 100644
index 0000000..e2fa5d8
--- /dev/null
+++ b/res/drawable/ic_settings_sign_in.xml
@@ -0,0 +1,24 @@
+<!--
+    Copyright (C) 2019 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24.0dp"
+        android:height="24.0dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FFFFFFFF"
+        android:pathData="M11,7L9.6,8.4l2.6,2.6H2v2h10.2l-2.6,2.6L11,17l5-5L11,7z M20,19h-8v2h8c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-8v2h8V19z"/>
+</vector>
diff --git a/res/drawable/settings_panel_background.xml b/res/drawable/settings_panel_background.xml
index 36c58e0..adb4646 100644
--- a/res/drawable/settings_panel_background.xml
+++ b/res/drawable/settings_panel_background.xml
@@ -16,7 +16,7 @@
 
 <inset xmlns:android="http://schemas.android.com/apk/res/android" android:inset="4dp">
     <shape android:shape="rectangle">
-        <corners android:radius="8dp" />
+        <corners android:radius="?android:attr/dialogCornerRadius" />
         <solid android:color="?android:attr/colorBackground" />
     </shape>
 </inset>
\ No newline at end of file
diff --git a/res/layout/homepage_condition_footer.xml b/res/layout/conditional_card_footer.xml
similarity index 83%
rename from res/layout/homepage_condition_footer.xml
rename to res/layout/conditional_card_footer.xml
index 56687fe..bf5ea27 100644
--- a/res/layout/homepage_condition_footer.xml
+++ b/res/layout/conditional_card_footer.xml
@@ -18,12 +18,12 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="@dimen/homepage_condition_footer_height"
+    android:layout_height="@dimen/contextual_condition_footer_height"
     android:contentDescription="@string/homepage_condition_footer_content_description"
     android:gravity="end"
     android:orientation="horizontal"
-    android:paddingTop="@dimen/homepage_condition_footer_padding_top"
-    android:paddingEnd="@dimen/homepage_condition_footer_padding_end">
+    android:paddingTop="@dimen/contextual_condition_footer_padding_top"
+    android:paddingEnd="@dimen/contextual_condition_footer_padding_end">
 
     <ImageView
         android:id="@+id/collapse_button"
diff --git a/res/layout/homepage_condition_full_tile.xml b/res/layout/conditional_card_full_tile.xml
similarity index 79%
rename from res/layout/homepage_condition_full_tile.xml
rename to res/layout/conditional_card_full_tile.xml
index e90a0cb..ee23498 100644
--- a/res/layout/homepage_condition_full_tile.xml
+++ b/res/layout/conditional_card_full_tile.xml
@@ -30,32 +30,32 @@
             android:id="@+id/content"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="@dimen/homepage_card_icon_padding_start"
-            android:paddingEnd="@dimen/homepage_full_card_padding_end"
-            android:paddingTop="@dimen/homepage_condition_full_card_padding_top"
-            android:paddingBottom="@dimen/homepage_condition_full_card_padding_bottom"
+            android:paddingStart="@dimen/contextual_card_icon_padding_start"
+            android:paddingEnd="@dimen/contextual_full_card_padding_end"
+            android:paddingTop="@dimen/contextual_condition_full_card_padding_top"
+            android:paddingBottom="@dimen/contextual_condition_full_card_padding_bottom"
             android:orientation="horizontal"
             android:gravity="center_vertical">
 
             <ImageView
                 android:id="@android:id/icon"
-                android:layout_width="@dimen/homepage_card_icon_size"
-                android:layout_height="@dimen/homepage_card_icon_size"
+                android:layout_width="@dimen/contextual_card_icon_size"
+                android:layout_height="@dimen/contextual_card_icon_size"
                 android:tint="?android:attr/colorAccent"/>
 
             <LinearLayout
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
-                android:paddingStart="@dimen/homepage_condition_full_card_padding_start"
-                android:paddingEnd="@dimen/homepage_condition_full_card_padding_end"
+                android:paddingStart="@dimen/contextual_condition_full_card_padding_start"
+                android:paddingEnd="@dimen/contextual_condition_full_card_padding_end"
                 android:orientation="vertical">
 
                 <TextView
                     android:id="@android:id/title"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
+                    android:layout_marginBottom="@dimen/contextual_condition_card_title_margin_bottom"
                     android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
 
                 <TextView
diff --git a/res/layout/homepage_condition_half_tile.xml b/res/layout/conditional_card_half_tile.xml
similarity index 76%
rename from res/layout/homepage_condition_half_tile.xml
rename to res/layout/conditional_card_half_tile.xml
index 1086f2d..3e30409 100644
--- a/res/layout/homepage_condition_half_tile.xml
+++ b/res/layout/conditional_card_half_tile.xml
@@ -25,20 +25,20 @@
         android:id="@+id/content"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingTop="@dimen/homepage_condition_half_card_padding_top"
+        android:paddingTop="@dimen/contextual_condition_half_card_padding_top"
         android:orientation="vertical">
 
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingEnd="@dimen/homepage_card_padding_end"
+            android:paddingEnd="@dimen/contextual_card_padding_end"
             android:orientation="vertical">
 
             <ImageView
                 android:id="@android:id/icon"
-                android:layout_width="@dimen/homepage_card_icon_size"
-                android:layout_height="@dimen/homepage_card_icon_size"
-                android:layout_marginStart="@dimen/homepage_card_icon_padding_start"
+                android:layout_width="@dimen/contextual_card_icon_size"
+                android:layout_height="@dimen/contextual_card_icon_size"
+                android:layout_marginStart="@dimen/contextual_card_icon_padding_start"
                 android:tint="?android:attr/colorAccent"/>
 
             <TextView
@@ -47,9 +47,9 @@
                 android:layout_height="wrap_content"
                 android:maxLines="1"
                 android:ellipsize="end"
-                android:layout_marginStart="@dimen/homepage_card_text_padding_start"
-                android:layout_marginTop="@dimen/homepage_condition_half_card_title_margin_top"
-                android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
+                android:layout_marginStart="@dimen/contextual_card_text_padding_start"
+                android:layout_marginTop="@dimen/contextual_condition_half_card_title_margin_top"
+                android:layout_marginBottom="@dimen/contextual_condition_card_title_margin_bottom"
                 android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
 
             <TextView
@@ -58,8 +58,8 @@
                 android:layout_height="wrap_content"
                 android:lines="2"
                 android:ellipsize="end"
-                android:layout_marginStart="@dimen/homepage_card_text_padding_start"
-                android:layout_marginBottom="@dimen/homepage_condition_half_card_summary_margin_bottom"
+                android:layout_marginStart="@dimen/contextual_card_text_padding_start"
+                android:layout_marginBottom="@dimen/contextual_condition_half_card_summary_margin_bottom"
                 android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
 
         </LinearLayout>
diff --git a/res/layout/homepage_condition_header.xml b/res/layout/conditional_card_header.xml
similarity index 77%
rename from res/layout/homepage_condition_header.xml
rename to res/layout/conditional_card_header.xml
index 30b9033..219468a 100644
--- a/res/layout/homepage_condition_header.xml
+++ b/res/layout/conditional_card_header.xml
@@ -25,8 +25,8 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingTop="@dimen/homepage_condition_header_padding_top"
-        android:paddingBottom="@dimen/homepage_condition_header_padding_bottom"
+        android:paddingTop="@dimen/contextual_condition_header_padding_top"
+        android:paddingBottom="@dimen/contextual_condition_header_padding_bottom"
         android:orientation="horizontal"
         android:gravity="center_vertical">
 
@@ -35,7 +35,7 @@
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:layout_weight="1"
-            android:layout_marginStart="@dimen/homepage_condition_header_icons_margin_start"
+            android:layout_marginStart="@dimen/contextual_condition_header_icons_margin_start"
             android:orientation="horizontal"
             android:gravity="center_vertical"/>
 
@@ -43,9 +43,9 @@
             android:id="@+id/expand_indicator"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:paddingTop="@dimen/homepage_condition_header_indicator_padding_top"
-            android:paddingStart="@dimen/homepage_condition_header_indicator_padding_start"
-            android:paddingEnd="@dimen/homepage_condition_header_indicator_padding_end"
+            android:paddingTop="@dimen/contextual_condition_header_indicator_padding_top"
+            android:paddingStart="@dimen/contextual_condition_header_indicator_padding_start"
+            android:paddingEnd="@dimen/contextual_condition_header_indicator_padding_end"
             android:src="@drawable/ic_expand_more_inverse"
             android:tint="?android:attr/colorControlNormal"/>
 
diff --git a/res/layout/homepage_condition_header_icon.xml b/res/layout/conditional_card_header_icon.xml
similarity index 75%
rename from res/layout/homepage_condition_header_icon.xml
rename to res/layout/conditional_card_header_icon.xml
index ae75140..c8886a8 100644
--- a/res/layout/homepage_condition_header_icon.xml
+++ b/res/layout/conditional_card_header_icon.xml
@@ -17,7 +17,7 @@
 
 <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@android:id/icon"
-           android:layout_width="@dimen/homepage_condition_header_icon_width_height"
-           android:layout_height="@dimen/homepage_condition_header_icon_width_height"
-           android:layout_marginEnd="@dimen/homepage_condition_header_icon_margin_end"
+           android:layout_width="@dimen/contextual_condition_header_icon_width_height"
+           android:layout_height="@dimen/contextual_condition_header_icon_width_height"
+           android:layout_marginEnd="@dimen/contextual_condition_header_icon_margin_end"
            android:tint="?android:attr/colorAccent"/>
\ No newline at end of file
diff --git a/res/layout/homepage_dismissal_view.xml b/res/layout/contextual_card_dismissal_view.xml
similarity index 79%
rename from res/layout/homepage_dismissal_view.xml
rename to res/layout/contextual_card_dismissal_view.xml
index 20c657e..0406422 100644
--- a/res/layout/homepage_dismissal_view.xml
+++ b/res/layout/contextual_card_dismissal_view.xml
@@ -20,14 +20,15 @@
     android:id="@+id/dismissal_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/homepage_card_dismissal_background"
-    android:orientation="vertical">
+    android:background="@color/contextual_card_dismissal_background"
+    android:orientation="vertical"
+    android:visibility="gone">
 
     <TextView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginStart="@dimen/homepage_card_dismissal_side_margin"
-        android:layout_marginTop="@dimen/homepage_card_dismissal_margin_top"
+        android:layout_marginStart="@dimen/contextual_card_dismissal_side_margin"
+        android:layout_marginTop="@dimen/contextual_card_dismissal_margin_top"
         android:text="@string/contextual_card_dismiss_confirm_message"
         android:textAppearance="@style/TextAppearance.ContextualCardDismissalText"/>
 
@@ -48,8 +49,8 @@
             style="@style/ContextualCardDismissalButton"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginStart="@dimen/homepage_card_dismissal_button_margin_start"
-            android:layout_marginEnd="@dimen/homepage_card_dismissal_button_margin_end"
+            android:layout_marginStart="@dimen/contextual_card_dismissal_button_margin_start"
+            android:layout_marginEnd="@dimen/contextual_card_dismissal_button_margin_end"
             android:text="@string/contextual_card_dismiss_remove"/>
 
     </LinearLayout>
diff --git a/res/layout/homepage_slice_deferred_setup_tile.xml b/res/layout/contextual_slice_deferred_setup.xml
similarity index 68%
rename from res/layout/homepage_slice_deferred_setup_tile.xml
rename to res/layout/contextual_slice_deferred_setup.xml
index ed096b0..e695d1d 100644
--- a/res/layout/homepage_slice_deferred_setup_tile.xml
+++ b/res/layout/contextual_slice_deferred_setup.xml
@@ -27,22 +27,22 @@
         android:layout_height="match_parent"
         android:gravity="left"
         android:orientation="vertical"
-        android:paddingEnd="@dimen/homepage_card_padding_end"
-        android:paddingTop="@dimen/homepage_deferred_setup_card_padding_top"
-        android:paddingBottom="@dimen/homepage_deferred_setup_card_padding_bottom">
+        android:paddingEnd="@dimen/contextual_card_padding_end"
+        android:paddingTop="@dimen/contextual_deferred_setup_card_padding_top"
+        android:paddingBottom="@dimen/contextual_deferred_setup_card_padding_bottom">
 
         <ImageView
             android:id="@android:id/icon"
-            android:layout_width="@dimen/homepage_card_icon_size"
-            android:layout_height="@dimen/homepage_card_icon_size"
-            android:layout_marginStart="@dimen/homepage_card_icon_padding_start"/>
+            android:layout_width="@dimen/contextual_card_icon_size"
+            android:layout_height="@dimen/contextual_card_icon_size"
+            android:layout_marginStart="@dimen/contextual_card_icon_padding_start"/>
 
         <TextView
             android:id="@android:id/title"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginStart="@dimen/homepage_card_text_padding_start"
-            android:layout_marginTop="@dimen/homepage_deferred_setup_card_title_margin_top"
+            android:layout_marginStart="@dimen/contextual_card_text_padding_start"
+            android:layout_marginTop="@dimen/contextual_deferred_setup_card_title_margin_top"
             android:ellipsize="end"
             android:maxLines="2"
             android:minLines="1"
@@ -52,8 +52,8 @@
             android:id="@android:id/summary"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginStart="@dimen/homepage_card_text_padding_start"
-            android:layout_marginTop="@dimen/homepage_deferred_setup_card_summary_margin_top"
+            android:layout_marginStart="@dimen/contextual_card_text_padding_start"
+            android:layout_marginTop="@dimen/contextual_deferred_setup_card_summary_margin_top"
             android:ellipsize="end"
             android:maxLines="2"
             android:minLines="1"
@@ -64,8 +64,8 @@
             style="@style/DeferredSetupCardButton"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginStart="@dimen/homepage_card_text_padding_start"
-            android:layout_marginTop="@dimen/homepage_deferred_setup_card_button_margin_top"
+            android:layout_marginStart="@dimen/contextual_card_text_padding_start"
+            android:layout_marginTop="@dimen/contextual_deferred_setup_card_button_margin_top"
             android:text="@string/suggestion_button_text"/>
 
     </LinearLayout>
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/contextual_slice_full_tile.xml
similarity index 80%
rename from res/layout/homepage_slice_tile.xml
rename to res/layout/contextual_slice_full_tile.xml
index ca8791f..8b1ac58 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/contextual_slice_full_tile.xml
@@ -21,21 +21,22 @@
     android:layout_height="wrap_content"
     style="@style/ContextualCardStyle">
 
-    <ViewFlipper
-        android:id="@+id/view_flipper"
+    <FrameLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+        android:layout_height="match_parent">
+
+        <include layout="@layout/dismissal_swipe_background"/>
 
         <androidx.slice.widget.SliceView
             android:id="@+id/slice_view"
+            style="@style/SliceViewStyle"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical"
-            android:importantForAccessibility="no"
-            style="@style/SliceViewStyle"/>
+            android:importantForAccessibility="no"/>
 
         <!--dismissal view-->
-        <include layout="@layout/homepage_dismissal_view"/>
+        <include layout="@layout/contextual_card_dismissal_view"/>
 
-    </ViewFlipper>
+    </FrameLayout>
 </com.google.android.material.card.MaterialCardView>
\ No newline at end of file
diff --git a/res/layout/homepage_slice_half_tile.xml b/res/layout/contextual_slice_half_tile.xml
similarity index 66%
rename from res/layout/homepage_slice_half_tile.xml
rename to res/layout/contextual_slice_half_tile.xml
index 8b6d415..83b1df7 100644
--- a/res/layout/homepage_slice_half_tile.xml
+++ b/res/layout/contextual_slice_half_tile.xml
@@ -21,25 +21,27 @@
     android:layout_height="wrap_content"
     style="@style/ContextualCardStyle">
 
-    <ViewFlipper
-        android:id="@+id/view_flipper"
+    <FrameLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
+        <include layout="@layout/dismissal_swipe_background"/>
+
         <LinearLayout
             android:id="@+id/content"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:paddingEnd="@dimen/homepage_card_padding_end"
-            android:paddingTop="@dimen/homepage_half_card_padding_top"
-            android:paddingBottom="@dimen/homepage_half_card_padding_bottom"
+            android:paddingEnd="@dimen/contextual_card_padding_end"
+            android:paddingTop="@dimen/contextual_half_card_padding_top"
+            android:paddingBottom="@dimen/contextual_half_card_padding_bottom"
+            android:background="@color/contextual_card_background"
             android:orientation="vertical">
 
             <ImageView
                 android:id="@android:id/icon"
-                android:layout_width="@dimen/homepage_card_icon_size"
-                android:layout_height="@dimen/homepage_card_icon_size"
-                android:layout_marginStart="@dimen/homepage_card_icon_padding_start"/>
+                android:layout_width="@dimen/contextual_card_icon_size"
+                android:layout_height="@dimen/contextual_card_icon_size"
+                android:layout_marginStart="@dimen/contextual_card_icon_padding_start"/>
 
             <TextView
                 android:id="@android:id/title"
@@ -48,14 +50,14 @@
                 android:maxLines="2"
                 android:minLines="1"
                 android:ellipsize="end"
-                android:layout_marginStart="@dimen/homepage_card_text_padding_start"
-                android:layout_marginTop="@dimen/homepage_half_card_title_margin_top"
+                android:layout_marginStart="@dimen/contextual_card_text_padding_start"
+                android:layout_marginTop="@dimen/contextual_half_card_title_margin_top"
                 android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
 
         </LinearLayout>
 
         <!--dismissal view-->
-        <include layout="@layout/homepage_dismissal_view"/>
+        <include layout="@layout/contextual_card_dismissal_view"/>
 
-    </ViewFlipper>
+    </FrameLayout>
 </com.google.android.material.card.MaterialCardView>
\ No newline at end of file
diff --git a/res/layout/dismissal_swipe_background.xml b/res/layout/dismissal_swipe_background.xml
new file mode 100644
index 0000000..49f6266
--- /dev/null
+++ b/res/layout/dismissal_swipe_background.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2019 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/dismissal_swipe_background"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/contextual_card_dismissal_background">
+
+    <ImageView
+        android:id="@+id/dismissal_icon_start"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_delete"
+        android:layout_gravity="start|center_vertical"
+        android:layout_marginStart="@dimen/contextual_card_dismissal_side_margin"/>
+
+    <Space
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_weight="1"/>
+
+    <ImageView
+        android:id="@+id/dismissal_icon_end"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_delete"
+        android:layout_gravity="end|center_vertical"
+        android:layout_marginEnd="@dimen/contextual_card_dismissal_side_margin"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/homepage_suggestion_tile.xml b/res/layout/legacy_suggestion_tile.xml
similarity index 94%
rename from res/layout/homepage_suggestion_tile.xml
rename to res/layout/legacy_suggestion_tile.xml
index 5d3a79c..9af5b6b 100644
--- a/res/layout/homepage_suggestion_tile.xml
+++ b/res/layout/legacy_suggestion_tile.xml
@@ -36,8 +36,8 @@
 
             <ImageView
                 android:id="@android:id/icon"
-                android:layout_width="@dimen/homepage_card_icon_size"
-                android:layout_height="@dimen/homepage_card_icon_size"
+                android:layout_width="@dimen/contextual_card_icon_size"
+                android:layout_height="@dimen/contextual_card_icon_size"
                 style="@style/SuggestionCardIcon"
                 android:layout_marginTop="16dp"
                 android:layout_marginBottom="6dp"/>
diff --git a/res/layout/settings_homepage_container.xml b/res/layout/settings_homepage_container.xml
index 9332463..c86bccf 100644
--- a/res/layout/settings_homepage_container.xml
+++ b/res/layout/settings_homepage_container.xml
@@ -39,14 +39,15 @@
                 android:id="@+id/contextual_cards_content"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_marginStart="@dimen/homepage_card_side_margin"
-                android:layout_marginEnd="@dimen/homepage_card_side_margin"/>
+                android:layout_marginStart="@dimen/contextual_card_side_margin"
+                android:layout_marginEnd="@dimen/contextual_card_side_margin"/>
 
             <FrameLayout
                 android:id="@+id/main_content"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:animateLayoutChanges="true"/>
+                android:animateLayoutChanges="true"
+                android:background="?android:attr/windowBackground"/>
 
         </LinearLayout>
     </androidx.core.widget.NestedScrollView>
diff --git a/res/layout/time_zone_search_header.xml b/res/layout/time_zone_search_header.xml
index 5c4e0ee..0c867f56 100644
--- a/res/layout/time_zone_search_header.xml
+++ b/res/layout/time_zone_search_header.xml
@@ -18,7 +18,7 @@
 instead of an ImageView -->
 
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
-          android:id="@+android:id/title"
+          android:id="@android:id/title"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_marginBottom="16dp"
diff --git a/res/mipmap-hdpi/ic_accessibility_magnification.png b/res/mipmap-hdpi/ic_accessibility_magnification.png
deleted file mode 100755
index a91bc6e..0000000
--- a/res/mipmap-hdpi/ic_accessibility_magnification.png
+++ /dev/null
Binary files differ
diff --git a/res/mipmap-mdpi/ic_accessibility_magnification.png b/res/mipmap-mdpi/ic_accessibility_magnification.png
deleted file mode 100755
index 9ec5107..0000000
--- a/res/mipmap-mdpi/ic_accessibility_magnification.png
+++ /dev/null
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_accessibility_magnification.png b/res/mipmap-xhdpi/ic_accessibility_magnification.png
deleted file mode 100755
index 0b3a32e..0000000
--- a/res/mipmap-xhdpi/ic_accessibility_magnification.png
+++ /dev/null
Binary files differ
diff --git a/res/mipmap-xxhdpi/ic_accessibility_magnification.png b/res/mipmap-xxhdpi/ic_accessibility_magnification.png
deleted file mode 100755
index 3eeb1c9..0000000
--- a/res/mipmap-xxhdpi/ic_accessibility_magnification.png
+++ /dev/null
Binary files differ
diff --git a/res/mipmap-xxxhdpi/ic_accessibility_magnification.png b/res/mipmap-xxxhdpi/ic_accessibility_magnification.png
deleted file mode 100755
index 7d37612..0000000
--- a/res/mipmap-xxxhdpi/ic_accessibility_magnification.png
+++ /dev/null
Binary files differ
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 9f99755..5d681ca 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -98,8 +98,8 @@
     <color name="homepage_about_background">#6F86DA</color>
     <color name="homepage_privacy_background">#5E97F6</color>
 
-    <color name="homepage_card_stroke_color">#1f000000</color>
-    <color name="homepage_card_dismissal_background">@*android:color/material_grey_100</color>
+    <color name="contextual_card_stroke_color">#1f000000</color>
+    <color name="contextual_card_dismissal_background">@*android:color/material_grey_100</color>
     <color name="contextual_card_background">@*android:color/background_device_default_light</color>
     <!-- End of dashboard/homepage icon background colors -->
 
diff --git a/res/values/config.xml b/res/values/config.xml
index cdf2810..496b5d2 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -47,6 +47,8 @@
     <!-- Package name and fully-qualified class name for the wallpaper picker activity. -->
     <string name="config_wallpaper_picker_package" translatable="false">com.android.settings</string>
     <string name="config_wallpaper_picker_class" translatable="false">com.android.settings.Settings$WallpaperSettingsActivity</string>
+    <!-- Fully-qualified class name for the styles & wallpaper picker activity. -->
+    <string name="config_styles_and_wallpaper_picker_class" translatable="false"></string>
 
     <!-- Manufacturer backup settings to launch -->
     <string name="config_backup_settings_intent" translatable="false"></string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b07865c..0982855 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -327,32 +327,32 @@
     <dimen name="reset_checkbox_summary_text_size">14sp</dimen>
 
     <!-- Homepage cards size and padding -->
-    <dimen name="homepage_card_icon_size">24dp</dimen>
-    <dimen name="homepage_card_vertical_margin">8dp</dimen>
-    <dimen name="homepage_card_side_margin">4dp</dimen>
-    <dimen name="homepage_card_icon_padding_start">14dp</dimen>
-    <dimen name="homepage_card_text_padding_start">16dp</dimen>
-    <dimen name="homepage_card_padding_end">16dp</dimen>
-    <dimen name="homepage_card_corner_radius">@*android:dimen/config_dialogCornerRadius</dimen>
-    <dimen name="homepage_full_card_padding_end">12dp</dimen>
-    <dimen name="homepage_half_card_padding_top">12dp</dimen>
-    <dimen name="homepage_half_card_padding_bottom">16dp</dimen>
-    <dimen name="homepage_half_card_title_margin_top">12dp</dimen>
-    <dimen name="homepage_deferred_setup_card_padding_top">16dp</dimen>
-    <dimen name="homepage_deferred_setup_card_padding_bottom">12dp</dimen>
-    <dimen name="homepage_deferred_setup_card_title_margin_top">12dp</dimen>
-    <dimen name="homepage_deferred_setup_card_summary_margin_top">2dp</dimen>
-    <dimen name="homepage_deferred_setup_card_button_margin_top">8dp</dimen>
-    <dimen name="homepage_deferred_setup_card_button_padding_top">8dp</dimen>
-    <dimen name="homepage_deferred_setup_card_button_padding_bottom">8dp</dimen>
-    <dimen name="homepage_deferred_setup_card_button_padding_start">24dp</dimen>
-    <dimen name="homepage_deferred_setup_card_button_padding_end">24dp</dimen>
+    <dimen name="contextual_card_icon_size">24dp</dimen>
+    <dimen name="contextual_card_vertical_margin">8dp</dimen>
+    <dimen name="contextual_card_side_margin">4dp</dimen>
+    <dimen name="contextual_card_icon_padding_start">14dp</dimen>
+    <dimen name="contextual_card_text_padding_start">16dp</dimen>
+    <dimen name="contextual_card_padding_end">16dp</dimen>
+    <dimen name="contextual_card_corner_radius">@*android:dimen/config_dialogCornerRadius</dimen>
+    <dimen name="contextual_full_card_padding_end">12dp</dimen>
+    <dimen name="contextual_half_card_padding_top">12dp</dimen>
+    <dimen name="contextual_half_card_padding_bottom">16dp</dimen>
+    <dimen name="contextual_half_card_title_margin_top">12dp</dimen>
+    <dimen name="contextual_deferred_setup_card_padding_top">16dp</dimen>
+    <dimen name="contextual_deferred_setup_card_padding_bottom">12dp</dimen>
+    <dimen name="contextual_deferred_setup_card_title_margin_top">12dp</dimen>
+    <dimen name="contextual_deferred_setup_card_summary_margin_top">2dp</dimen>
+    <dimen name="contextual_deferred_setup_card_button_margin_top">8dp</dimen>
+    <dimen name="contextual_deferred_setup_card_button_padding_top">8dp</dimen>
+    <dimen name="contextual_deferred_setup_card_button_padding_bottom">8dp</dimen>
+    <dimen name="contextual_deferred_setup_card_button_padding_start">24dp</dimen>
+    <dimen name="contextual_deferred_setup_card_button_padding_end">24dp</dimen>
 
     <!-- Homepage dismissal cards size and padding -->
-    <dimen name="homepage_card_dismissal_margin_top">12dp</dimen>
-    <dimen name="homepage_card_dismissal_side_margin">16dp</dimen>
-    <dimen name="homepage_card_dismissal_button_margin_start">4dp</dimen>
-    <dimen name="homepage_card_dismissal_button_margin_end">6dp</dimen>
+    <dimen name="contextual_card_dismissal_margin_top">12dp</dimen>
+    <dimen name="contextual_card_dismissal_side_margin">16dp</dimen>
+    <dimen name="contextual_card_dismissal_button_margin_start">4dp</dimen>
+    <dimen name="contextual_card_dismissal_button_margin_end">6dp</dimen>
 
     <!-- Horizontal divider size and margin -->
     <dimen name="horizontal_divider_height">.75dp</dimen>
@@ -364,25 +364,25 @@
     <dimen name="signal_strength_icon_size">24dp</dimen>
 
     <!-- Condition cards size and padding -->
-    <dimen name="homepage_condition_card_title_margin_bottom">2dp</dimen>
-    <dimen name="homepage_condition_half_card_padding_top">12dp</dimen>
-    <dimen name="homepage_condition_half_card_title_margin_top">12dp</dimen>
-    <dimen name="homepage_condition_half_card_summary_margin_bottom">12dp</dimen>
-    <dimen name="homepage_condition_full_card_padding_start">24dp</dimen>
-    <dimen name="homepage_condition_full_card_padding_end">16dp</dimen>
-    <dimen name="homepage_condition_full_card_padding_top">12dp</dimen>
-    <dimen name="homepage_condition_full_card_padding_bottom">12dp</dimen>
-    <dimen name="homepage_condition_header_padding_top">10dp</dimen>
-    <dimen name="homepage_condition_header_padding_bottom">10dp</dimen>
-    <dimen name="homepage_condition_header_icons_margin_start">14dp</dimen>
-    <dimen name="homepage_condition_header_indicator_padding_top">4dp</dimen>
-    <dimen name="homepage_condition_header_indicator_padding_start">16dp</dimen>
-    <dimen name="homepage_condition_header_indicator_padding_end">16dp</dimen>
-    <dimen name="homepage_condition_footer_height">48dp</dimen>
-    <dimen name="homepage_condition_footer_padding_top">10dp</dimen>
-    <dimen name="homepage_condition_footer_padding_end">10dp</dimen>
-    <dimen name="homepage_condition_header_icon_width_height">24dp</dimen>
-    <dimen name="homepage_condition_header_icon_margin_end">24dp</dimen>
+    <dimen name="contextual_condition_card_title_margin_bottom">2dp</dimen>
+    <dimen name="contextual_condition_half_card_padding_top">12dp</dimen>
+    <dimen name="contextual_condition_half_card_title_margin_top">12dp</dimen>
+    <dimen name="contextual_condition_half_card_summary_margin_bottom">12dp</dimen>
+    <dimen name="contextual_condition_full_card_padding_start">24dp</dimen>
+    <dimen name="contextual_condition_full_card_padding_end">16dp</dimen>
+    <dimen name="contextual_condition_full_card_padding_top">12dp</dimen>
+    <dimen name="contextual_condition_full_card_padding_bottom">12dp</dimen>
+    <dimen name="contextual_condition_header_padding_top">10dp</dimen>
+    <dimen name="contextual_condition_header_padding_bottom">10dp</dimen>
+    <dimen name="contextual_condition_header_icons_margin_start">14dp</dimen>
+    <dimen name="contextual_condition_header_indicator_padding_top">4dp</dimen>
+    <dimen name="contextual_condition_header_indicator_padding_start">16dp</dimen>
+    <dimen name="contextual_condition_header_indicator_padding_end">16dp</dimen>
+    <dimen name="contextual_condition_footer_height">48dp</dimen>
+    <dimen name="contextual_condition_footer_padding_top">10dp</dimen>
+    <dimen name="contextual_condition_footer_padding_end">10dp</dimen>
+    <dimen name="contextual_condition_header_icon_width_height">24dp</dimen>
+    <dimen name="contextual_condition_header_icon_margin_end">24dp</dimen>
 
     <!-- QR code picture size -->
     <dimen name="qrcode_size">264dp</dimen>
@@ -395,4 +395,7 @@
     <dimen name="bt_icon_elevation">4dp</dimen>
 
     <dimen name="two_target_min_width">80dp</dimen>
+
+    <!-- Maximum height for SliceView, override on slices/view/src/main/res/values/dimens.xml -->
+    <dimen name="abc_slice_large_height">360dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 468eecd..1567c75 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1007,6 +1007,10 @@
     <string name="skip_anyway_button_label">Skip anyway</string>
     <!-- Button for going to the previous screen or step [CHAR LIMIT=20] -->
     <string name="go_back_button_label">Go back</string>
+    <!-- Button text to skip lock screen setup [CHAR LIMIT=20] -->
+    <string name="skip_lock_screen_dialog_button_label">Skip</string>
+    <!-- Button text to cancel lock screen skip dialog [CHAR LIMIT=20] -->
+    <string name="cancel_lock_screen_dialog_button_label">Cancel</string>
     <!-- Introduction title shown in fingerprint enrollment dialog to locate the sensor [CHAR LIMIT=29] -->
     <string name="security_settings_fingerprint_enroll_find_sensor_title">Touch the sensor</string>
     <!-- Message shown in fingerprint enrollment dialog to locate the sensor -->
@@ -1037,6 +1041,24 @@
     <string name="setup_fingerprint_enroll_enrolling_skip_title">Skip fingerprint setup?</string>
     <!-- Content of the dialog shown when the user tries to skip fingerprint setup, asking them to confirm the action [CHAR LIMIT=NONE] -->
     <string name="setup_fingerprint_enroll_enrolling_skip_message">You\u2019ve chosen to use your fingerprint as one way to unlock your phone. If you skip now, you\u2019ll need to set this up later. Setup takes only a minute or so.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (tablet) [CHAR LIMIT=NONE] -->
+    <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (device) [CHAR LIMIT=NONE] -->
+    <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set fingerprint. (default) [CHAR LIMIT=NONE] -->
+    <string name="fingerprint_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up fingerprint. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (tablet) [CHAR LIMIT=NONE] -->
+    <string name="face_lock_screen_setup_skip_dialog_text" product="tablet">Protect your tablet with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (device) [CHAR LIMIT=NONE] -->
+    <string name="face_lock_screen_setup_skip_dialog_text" product="device">Protect your device with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Dialog text shown when the user tries to skip setting up a screen lock, warning that they can't continue to set face authentication. (default) [CHAR LIMIT=NONE] -->
+    <string name="face_lock_screen_setup_skip_dialog_text" product="default">Protect your phone with a screen lock option so no one will be able to use it if it is lost or stolen. You also need a screen lock option to set up face authentication. Tap Cancel, then set a PIN or choose another screen lock option.</string>
+    <!-- Title of dialog shown when the user tries to skip setting up a PIN, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
+    <string name="lock_screen_pin_skip_title">Skip PIN Setup?</string>
+    <!-- Title of dialog shown when the user tries to skip setting up a password, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
+    <string name="lock_screen_password_skip_title">Skip Password Setup?</string>
+    <!-- Title of dialog shown when the user tries to skip setting up a pattern, warning them of potential consequences of not doing so [CHAR LIMIT=48]-->
+    <string name="lock_screen_pattern_skip_title">Skip Pattern Setup?</string>
 
     <!-- Button text to setup screen lock in onboard dialog [CHAR LIMIT=34] -->
     <string name="security_settings_fingerprint_enroll_setup_screen_lock">Set up screen lock</string>
@@ -2824,7 +2846,7 @@
     <string name="night_display_not_currently_on">Night Light not currently on</string>
 
     <!-- Sound & display settings screen, setting option name to change screen timeout -->
-    <string name="screen_timeout">Sleep</string>
+    <string name="screen_timeout">Screen timeout</string>
     <!-- Sound & display settings screen, setting option name to change screen timeout [CHAR LIMIT=30] -->
     <string name="screen_timeout_title">Screen turns off</string>
     <!-- Sound & display settings screen, setting option summary to change screen timeout -->
@@ -2832,7 +2854,7 @@
     <!-- Wallpaper settings title [CHAR LIMIT=30] -->
     <string name="wallpaper_settings_title">Wallpaper</string>
     <!-- Styles & Wallpapers settings title [CHAR LIMIT=30] -->
-    <string name="style_and_wallpaper_settings_title">Styles &amp; Wallpapers</string>
+    <string name="style_and_wallpaper_settings_title">Styles &amp; wallpapers</string>
     <!-- Wallpaper settings summary when default wallpaper is used [CHAR LIMIT=NONE] -->
     <string name="wallpaper_settings_summary_default">Default</string>
     <!-- Wallpaper settings summary when wallpaper has been updated [CHAR LIMIT=NONE] -->
@@ -3841,6 +3863,8 @@
     <string name="location_scanning_bluetooth_always_scanning_title">Bluetooth scanning</string>
     <!-- Description text for Bluetooth always scanning -->
     <string name="location_scanning_bluetooth_always_scanning_description">Allow apps and services to scan for nearby devices at any time, even when Bluetooth is off. This can be used, for example, to improve location-based features and services.</string>
+    <!-- [CHAR LIMIT=50] Location settings screen, sub category for location services for managed profile -->
+    <string name="managed_profile_location_services">Location services for work</string>
 
     <!-- [CHAR LIMIT=30] Security & location settings screen, setting check box label for Google location service (cell ID, wifi, etc.) -->
     <string name="location_network_based">Wi\u2011Fi &amp; mobile network location</string>
@@ -9298,7 +9322,7 @@
     <string name="display_dashboard_summary">Wallpaper, sleep, font size</string>
 
     <!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
-    <string name="display_dashboard_summary_with_style">Styles &amp; Wallpapers, sleep, font size</string>
+    <string name="display_dashboard_summary_with_style">Styles, wallpapers, screen timeout, font size</string>
 
     <!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
     <string name="display_dashboard_nowallpaper_summary">Sleep, font size</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8cd22fe..b51a45d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -414,13 +414,13 @@
     </style>
 
     <style name="ContextualCardStyle">
-        <item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
-        <item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
-        <item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
+        <item name="android:layout_marginBottom">@dimen/contextual_card_vertical_margin</item>
+        <item name="android:layout_marginStart">@dimen/contextual_card_side_margin</item>
+        <item name="android:layout_marginEnd">@dimen/contextual_card_side_margin</item>
         <item name="cardBackgroundColor">@color/contextual_card_background</item>
-        <item name="cardCornerRadius">@dimen/homepage_card_corner_radius</item>
+        <item name="cardCornerRadius">@dimen/contextual_card_corner_radius</item>
         <item name="cardElevation">0dp</item>
-        <item name="strokeColor">@color/homepage_card_stroke_color</item>
+        <item name="strokeColor">@color/contextual_card_stroke_color</item>
         <item name="strokeWidth">1dp</item>
     </style>
 
@@ -475,10 +475,10 @@
 
     <style name="DeferredSetupCardButton" parent="android:Widget.DeviceDefault.Button.Colored">
         <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
-        <item name="android:paddingBottom">@dimen/homepage_deferred_setup_card_button_padding_bottom</item>
-        <item name="android:paddingEnd">@dimen/homepage_deferred_setup_card_button_padding_end</item>
-        <item name="android:paddingStart">@dimen/homepage_deferred_setup_card_button_padding_start</item>
-        <item name="android:paddingTop">@dimen/homepage_deferred_setup_card_button_padding_top</item>
+        <item name="android:paddingBottom">@dimen/contextual_deferred_setup_card_button_padding_bottom</item>
+        <item name="android:paddingEnd">@dimen/contextual_deferred_setup_card_button_padding_end</item>
+        <item name="android:paddingStart">@dimen/contextual_deferred_setup_card_button_padding_start</item>
+        <item name="android:paddingTop">@dimen/contextual_deferred_setup_card_button_padding_top</item>
         <item name="android:textAllCaps">false</item>
         <item name="android:textSize">14sp</item>
     </style>
@@ -492,6 +492,7 @@
         <item name="android:paddingEnd">8dp</item>
 
         <item name="rowStyle">@style/SliceRowStyle</item>
+        <item name="android:background">@color/contextual_card_background</item>
     </style>
 
     <style name="SliceRowStyle">
@@ -536,6 +537,8 @@
     <style name="SetupWizardPartnerResource">
         <!-- Disable to use partner overlay theme for outside setupwizard flow. -->
         <item name="sucUsePartnerResource">false</item>
+        <!-- Enable heavy theme style inside setupwizard flow. -->
+        <item name="sudUsePartnerHeavyTheme">true</item>
     </style>
 
 </resources>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 0e417c9..26849d1 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -68,7 +68,7 @@
             android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
             android:key="magnification_preference_screen"
             android:title="@string/accessibility_screen_magnification_title"
-            android:icon="@mipmap/ic_accessibility_magnification" />
+            android:icon="@drawable/ic_accessibility_magnification" />
 
         <SwitchPreference
                 android:key="toggle_large_pointer_icon"
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 97a4182..cf25a15 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -19,13 +19,6 @@
                   android:title="@string/configure_notification_settings"
                   android:key="configure_notification_settings">
 
-    <com.android.settingslib.widget.apppreference.AppPreference
-        android:key="notification_assistant"
-        android:title="@string/notification_assistant_title"
-        android:summary="@string/summary_placeholder"
-        settings:fragment="com.android.settings.notification.NotificationAssistantPicker"
-        settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
-
     <SwitchPreference
         android:key="asst_capability_prioritizer"
         android:title="@string/asst_capability_prioritizer_title"
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 940e6de..a612a47 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -53,9 +53,6 @@
         settings:keywords="@string/keywords_display_wallpaper"
         settings:useAdminDisabledSummary="true"
         settings:controller="com.android.settings.display.WallpaperPreferenceController">
-        <intent
-            android:targetPackage="@string/config_wallpaper_picker_package"
-            android:targetClass="@string/config_wallpaper_picker_class" />
     </com.android.settingslib.RestrictedPreference>
 
 
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 29d4048..2f43ce8 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -55,6 +55,12 @@
 
             <PreferenceCategory
                 android:key="location_services" />
+
+            <!-- This preference gets removed if there is no managed profile -->
+            <PreferenceCategory
+                android:title="@string/managed_profile_location_services"
+                android:key="location_services_managed_profile" />
+
         </PreferenceCategory>
 
         <PreferenceCategory
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index 4c7de5a..e7cc1dc 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -68,6 +68,11 @@
         android:title="@string/mobile_data_usage_title"
         settings:controller="com.android.settings.network.telephony.DataUsagePreferenceController"/>
 
+    <com.android.settings.datausage.BillingCyclePreference
+        android:key="billing_preference"
+        android:title="@string/billing_cycle"
+        settings:controller="com.android.settings.datausage.BillingCyclePreferenceController" />
+
     <SwitchPreference
         android:key="enhanced_4g_lte"
         android:title="@string/enhanced_4g_lte_mode_title"
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index c218869..32b51d4 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -64,7 +64,7 @@
         settings:useAdminDisabledSummary="true" />
 
     <com.android.settingslib.RestrictedSwitchPreference
-        android:key="airplane_mode"
+        android:key="airplane_mode_old"
         android:title="@string/airplane_mode"
         android:icon="@drawable/ic_airplanemode_active"
         android:disableDependentsState="true"
diff --git a/res/xml/network_and_internet_v2.xml b/res/xml/network_and_internet_v2.xml
index 0d9e2ea..3604480 100644
--- a/res/xml/network_and_internet_v2.xml
+++ b/res/xml/network_and_internet_v2.xml
@@ -19,7 +19,7 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="network_and_internet_screen"
     android:title="@string/network_dashboard_title"
-    settings:initialExpandedChildrenCount="6">
+    settings:initialExpandedChildrenCount="5">
 
     <PreferenceCategory
         android:key="multi_network_header"
@@ -53,7 +53,7 @@
         settings:useAdminDisabledSummary="true" />
 
     <com.android.settingslib.RestrictedSwitchPreference
-        android:key="toggle_airplane"
+        android:key="airplane_mode"
         android:title="@string/airplane_mode"
         android:icon="@drawable/ic_airplanemode_active"
         android:disableDependentsState="true"
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index cb97fee..e8265b2 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -65,6 +65,13 @@
             android:value="com.android.settings.Settings$WriteSettingsActivity" />
     </Preference>
 
+    <com.android.settingslib.widget.apppreference.AppPreference
+        android:key="notification_assistant"
+        android:title="@string/notification_assistant_title"
+        android:summary="@string/summary_placeholder"
+        settings:fragment="com.android.settings.notification.NotificationAssistantPicker"
+        settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
+
     <Preference
         android:key="notification_access"
         android:title="@string/manage_notification_access_title"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 90ffc5a..4cc2f44 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -36,6 +36,7 @@
     public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
     public static class WifiTetherSettingsActivity extends SettingsActivity { /* empty */ }
     public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
+    public static class DataSaverSummaryActivity extends SettingsActivity{ /* empty */ }
     public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PrivateVolumeForgetActivity extends SettingsActivity { /* empty */ }
     public static class PrivateVolumeSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/applications/AppStateInstallAppsBridge.java b/src/com/android/settings/applications/AppStateInstallAppsBridge.java
index f852bca..8a3e5a2 100644
--- a/src/com/android/settings/applications/AppStateInstallAppsBridge.java
+++ b/src/com/android/settings/applications/AppStateInstallAppsBridge.java
@@ -93,8 +93,6 @@
         final InstallAppsState appState = new InstallAppsState();
         appState.permissionRequested = hasRequestedAppOpPermission(
                 Manifest.permission.REQUEST_INSTALL_PACKAGES, packageName);
-        appState.permissionGranted = hasPermission(Manifest.permission.REQUEST_INSTALL_PACKAGES,
-                uid);
         appState.appOpMode = getAppOpMode(AppOpsManager.OP_REQUEST_INSTALL_PACKAGES, uid,
                 packageName);
         return appState;
@@ -105,7 +103,6 @@
      */
     public static class InstallAppsState {
         boolean permissionRequested;
-        boolean permissionGranted;
         int appOpMode;
 
         public InstallAppsState() {
@@ -113,11 +110,7 @@
         }
 
         public boolean canInstallApps() {
-            if (appOpMode == AppOpsManager.MODE_DEFAULT) {
-                return permissionGranted;
-            } else {
-                return appOpMode == AppOpsManager.MODE_ALLOWED;
-            }
+            return appOpMode == AppOpsManager.MODE_ALLOWED;
         }
 
         public boolean isPotentialAppSource() {
@@ -126,8 +119,8 @@
 
         @Override
         public String toString() {
-            StringBuilder sb = new StringBuilder("[permissionGranted: " + permissionGranted);
-            sb.append(", permissionRequested: " + permissionRequested);
+            StringBuilder sb = new StringBuilder();
+            sb.append("[permissionRequested: " + permissionRequested);
             sb.append(", appOpMode: " + appOpMode);
             sb.append("]");
             return sb.toString();
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 766fa50..8274634 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -112,7 +112,8 @@
     private UserManager mUserManager;
     private PackageManager mPm;
 
-    private boolean mFinishing;
+    @VisibleForTesting
+    boolean mFinishing;
     private boolean mListeningToPackageRemove;
 
 
@@ -544,7 +545,7 @@
     @VisibleForTesting
     void retrieveAppEntry() {
         final Activity activity = getActivity();
-        if (activity == null) {
+        if (activity == null || mFinishing) {
             return;
         }
         if (mState == null) {
@@ -650,7 +651,7 @@
                     || TextUtils.equals(mAppEntry.info.packageName, packageName)) {
                 onPackageRemoved();
             } else if (mAppEntry.info.isResourceOverlay()
-                       && TextUtils.equals(mPackageInfo.overlayTarget, packageName)) {
+                    && TextUtils.equals(mPackageInfo.overlayTarget, packageName)) {
                 refreshUi();
             }
         }
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 3f02b6f..05ee7be 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -17,11 +17,15 @@
 package com.android.settings.biometrics.fingerprint;
 
 import android.app.settings.SettingsEnums;
+import android.content.ComponentName;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.hardware.fingerprint.FingerprintManager;
 import android.os.Bundle;
 import android.view.View;
 
+import androidx.annotation.VisibleForTesting;
+
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.biometrics.BiometricEnrollBase;
@@ -34,7 +38,11 @@
  */
 public class FingerprintEnrollFinish extends BiometricEnrollBase {
 
-    private static final int REQUEST_ADD_ANOTHER = 1;
+    @VisibleForTesting
+    static final int REQUEST_ADD_ANOTHER = 1;
+    @VisibleForTesting
+    static final String FINGERPRINT_SUGGESTION_ACTIVITY =
+            "com.android.settings.SetupFingerprintSuggestionActivity";
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -85,16 +93,37 @@
 
     @Override
     protected void onNextButtonClick(View view) {
+        setFingerprintSuggestionEnabled();
         setResult(RESULT_FINISHED);
         finish();
     }
 
+    private void setFingerprintSuggestionEnabled() {
+        final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
+        if (fpm != null) {
+            int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
+
+            // Only show "Add another fingerprint" if the user already enrolled one.
+            // "Add fingerprint" will be shown in the main flow if the user hasn't enrolled any
+            // fingerprints. If the user already added more than one fingerprint, they already know
+            // to add multiple fingerprints so we don't show the suggestion.
+            int flag = (enrolled == 1) ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
+                    : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
+
+            ComponentName componentName = new ComponentName(getApplicationContext(),
+                    FINGERPRINT_SUGGESTION_ACTIVITY);
+            getPackageManager().setComponentEnabledSetting(
+                    componentName, flag, PackageManager.DONT_KILL_APP);
+        }
+    }
+
     private void onAddAnotherButtonClick(View view) {
         startActivityForResult(getFingerprintEnrollingIntent(), REQUEST_ADD_ANOTHER);
     }
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        setFingerprintSuggestionEnabled();
         if (requestCode == REQUEST_ADD_ANOTHER && resultCode != RESULT_CANCELED) {
             setResult(resultCode, data);
             finish();
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 1d2d793..d6a668e 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -39,8 +39,10 @@
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.fuelgauge.BatteryMeterView;
+import com.android.settingslib.bluetooth.BluetoothUtils;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnDestroy;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
 import com.android.settingslib.utils.ThreadUtils;
@@ -54,7 +56,7 @@
  * This class adds a header with device name and status (connected/disconnected, etc.).
  */
 public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceController implements
-        LifecycleObserver, OnStart, OnStop, CachedBluetoothDevice.Callback {
+        LifecycleObserver, OnStart, OnStop, OnDestroy, CachedBluetoothDevice.Callback {
     private static final String TAG = "AdvancedBtHeaderCtrl";
 
     @VisibleForTesting
@@ -68,13 +70,12 @@
     @VisibleForTesting
     Handler mHandler = new Handler(Looper.getMainLooper());
     @VisibleForTesting
-    final BluetoothAdapter.MetadataListener mMetadataListener =
-            new BluetoothAdapter.MetadataListener() {
+    final BluetoothAdapter.OnMetadataChangedListener mMetadataListener =
+            new BluetoothAdapter.OnMetadataChangedListener() {
                 @Override
-                public void onMetadataChanged(BluetoothDevice device, int key, String value) {
-                    super.onMetadataChanged(device, key, value);
+                public void onMetadataChanged(BluetoothDevice device, int key, byte[] value) {
                     Log.i(TAG, String.format("Metadata updated in Device %s: %d = %s.", device, key,
-                            value));
+                            value == null ? null : new String(value)));
                     refresh();
                 }
             };
@@ -87,9 +88,9 @@
 
     @Override
     public int getAvailabilityStatus() {
-        final boolean unthetheredHeadset = Utils.getBooleanMetaData(mCachedDevice.getDevice(),
-                BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET);
-        return unthetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+        final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(
+                mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
+        return untetheredHeadset ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
     @Override
@@ -107,8 +108,8 @@
             return;
         }
         mCachedDevice.registerCallback(this::onDeviceAttributesChanged);
-        mBluetoothAdapter.registerMetadataListener(mCachedDevice.getDevice(), mMetadataListener,
-                mHandler);
+        mBluetoothAdapter.addOnMetadataChangedListener(mCachedDevice.getDevice(),
+                mContext.getMainExecutor(), mMetadataListener);
     }
 
     @Override
@@ -117,8 +118,15 @@
             return;
         }
         mCachedDevice.unregisterCallback(this::onDeviceAttributesChanged);
-        mBluetoothAdapter.unregisterMetadataListener(mCachedDevice.getDevice());
+        mBluetoothAdapter.removeOnMetadataChangedListener(mCachedDevice.getDevice(),
+                mMetadataListener);
+    }
 
+    @Override
+    public void onDestroy() {
+        if (!isAvailable()) {
+            return;
+        }
         // Destroy icon bitmap associated with this header
         for (Bitmap bitmap : mIconCache.values()) {
             if (bitmap != null) {
@@ -147,21 +155,21 @@
             }
 
             updateSubLayout(mLayoutPreference.findViewById(R.id.layout_left),
-                    BluetoothDevice.METADATA_UNTHETHERED_LEFT_ICON,
-                    BluetoothDevice.METADATA_UNTHETHERED_LEFT_BATTERY,
-                    BluetoothDevice.METADATA_UNTHETHERED_LEFT_CHARGING,
+                    BluetoothDevice.METADATA_UNTETHERED_LEFT_ICON,
+                    BluetoothDevice.METADATA_UNTETHERED_LEFT_BATTERY,
+                    BluetoothDevice.METADATA_UNTETHERED_LEFT_CHARGING,
                     R.string.bluetooth_left_name);
 
             updateSubLayout(mLayoutPreference.findViewById(R.id.layout_middle),
-                    BluetoothDevice.METADATA_UNTHETHERED_CASE_ICON,
-                    BluetoothDevice.METADATA_UNTHETHERED_CASE_BATTERY,
-                    BluetoothDevice.METADATA_UNTHETHERED_CASE_CHARGING,
+                    BluetoothDevice.METADATA_UNTETHERED_CASE_ICON,
+                    BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY,
+                    BluetoothDevice.METADATA_UNTETHERED_CASE_CHARGING,
                     R.string.bluetooth_middle_name);
 
             updateSubLayout(mLayoutPreference.findViewById(R.id.layout_right),
-                    BluetoothDevice.METADATA_UNTHETHERED_RIGHT_ICON,
-                    BluetoothDevice.METADATA_UNTHETHERED_RIGHT_BATTERY,
-                    BluetoothDevice.METADATA_UNTHETHERED_RIGHT_CHARGING,
+                    BluetoothDevice.METADATA_UNTETHERED_RIGHT_ICON,
+                    BluetoothDevice.METADATA_UNTETHERED_RIGHT_BATTERY,
+                    BluetoothDevice.METADATA_UNTETHERED_RIGHT_CHARGING,
                     R.string.bluetooth_right_name);
         }
     }
@@ -187,15 +195,15 @@
             return;
         }
         final BluetoothDevice bluetoothDevice = mCachedDevice.getDevice();
-        final String iconUri = Utils.getStringMetaData(bluetoothDevice, iconMetaKey);
+        final String iconUri = BluetoothUtils.getStringMetaData(bluetoothDevice, iconMetaKey);
         if (iconUri != null) {
             final ImageView imageView = linearLayout.findViewById(R.id.header_icon);
             updateIcon(imageView, iconUri);
         }
 
-        final int batteryLevel = Utils.getIntMetaData(bluetoothDevice, batteryMetaKey);
-        final boolean charging = Utils.getBooleanMetaData(bluetoothDevice, chargeMetaKey);
-        if (batteryLevel != Utils.META_INT_ERROR) {
+        final int batteryLevel = BluetoothUtils.getIntMetaData(bluetoothDevice, batteryMetaKey);
+        final boolean charging = BluetoothUtils.getBooleanMetaData(bluetoothDevice, chargeMetaKey);
+        if (batteryLevel != BluetoothUtils.META_INT_ERROR) {
             linearLayout.setVisibility(View.VISIBLE);
             final ImageView imageView = linearLayout.findViewById(R.id.bt_battery_icon);
             imageView.setImageDrawable(createBtBatteryIcon(mContext, batteryLevel, charging));
@@ -226,7 +234,7 @@
 
         // Only show bluetooth icon
         final BluetoothDevice bluetoothDevice = mCachedDevice.getDevice();
-        final String iconUri = Utils.getStringMetaData(bluetoothDevice,
+        final String iconUri = BluetoothUtils.getStringMetaData(bluetoothDevice,
                 BluetoothDevice.METADATA_MAIN_ICON);
         if (iconUri != null) {
             final ImageView imageView = linearLayout.findViewById(R.id.header_icon);
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
index 47d56bc..ee63045 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
@@ -53,8 +53,8 @@
 
     @Override
     public boolean isAvailable() {
-        return !Utils.getBooleanMetaData(mCachedDevice.getDevice(),
-                BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET);
+        return !BluetoothUtils.getBooleanMetaData(mCachedDevice.getDevice(),
+                BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java b/src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java
index e486b68..cd75951 100644
--- a/src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java
+++ b/src/com/android/settings/bluetooth/BluetoothFeatureProviderImpl.java
@@ -33,8 +33,8 @@
 
     @Override
     public Uri getBluetoothDeviceSettingsUri(BluetoothDevice bluetoothDevice) {
-        final String uriString = bluetoothDevice.getMetadata(
+        final byte[] uriByte = bluetoothDevice.getMetadata(
                 BluetoothDevice.METADATA_ENHANCED_SETTINGS_UI_URI);
-        return uriString != null ? Uri.parse(uriString) : null;
+        return uriByte == null ? null : Uri.parse(new String(uriByte));
     }
 }
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index a86e1d5..d6e395e 100755
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -47,8 +47,6 @@
     static final boolean V = BluetoothUtils.V; // verbose logging
     static final boolean D =  BluetoothUtils.D;  // regular logging
 
-    public static final int META_INT_ERROR = -1;
-
     private Utils() {
     }
 
@@ -154,30 +152,4 @@
         return Settings.Global.getInt(context.getContentResolver(),
                 Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1;
     }
-
-    public static boolean getBooleanMetaData(BluetoothDevice bluetoothDevice, int key) {
-        if (bluetoothDevice == null) {
-            return false;
-        }
-
-        return Boolean.parseBoolean(bluetoothDevice.getMetadata(key));
-    }
-
-    public static String getStringMetaData(BluetoothDevice bluetoothDevice, int key) {
-        if (bluetoothDevice == null) {
-            return null;
-        }
-        return bluetoothDevice.getMetadata(key);
-    }
-
-    public static int getIntMetaData(BluetoothDevice bluetoothDevice, int key) {
-        if (bluetoothDevice == null) {
-            return META_INT_ERROR;
-        }
-        try {
-            return Integer.parseInt(bluetoothDevice.getMetadata(key));
-        } catch (NumberFormatException e) {
-            return META_INT_ERROR;
-        }
-    }
 }
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 35a1627..19843a6 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -59,6 +59,7 @@
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
 import com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment;
 import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
+import com.android.settings.datausage.DataSaverSummary;
 import com.android.settings.datausage.DataUsageList;
 import com.android.settings.datausage.DataUsageSummary;
 import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
@@ -163,6 +164,7 @@
             WifiTetherSettings.class.getName(),
             BackgroundCheckSummary.class.getName(),
             VpnSettings.class.getName(),
+            DataSaverSummary.class.getName(),
             DateTimeSettings.class.getName(),
             LocaleListEditor.class.getName(),
             AvailableVirtualKeyboardFragment.class.getName(),
diff --git a/src/com/android/settings/datausage/BillingCyclePreferenceController.java b/src/com/android/settings/datausage/BillingCyclePreferenceController.java
new file mode 100644
index 0000000..0220a12
--- /dev/null
+++ b/src/com/android/settings/datausage/BillingCyclePreferenceController.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.datausage;
+
+import android.content.Context;
+import android.net.INetworkStatsService;
+import android.net.NetworkPolicyManager;
+import android.net.NetworkTemplate;
+import android.os.INetworkManagementService;
+import android.os.ServiceManager;
+import android.os.UserManager;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.NetworkPolicyEditor;
+
+import androidx.preference.PreferenceScreen;
+
+public class BillingCyclePreferenceController extends BasePreferenceController {
+    private int mSubscriptionId;
+
+    public BillingCyclePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    public void init(int subscriptionId) {
+        mSubscriptionId = subscriptionId;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        BillingCyclePreference preference = screen.findPreference(getPreferenceKey());
+
+        TemplatePreference.NetworkServices services = new TemplatePreference.NetworkServices();
+        services.mNetworkService = INetworkManagementService.Stub.asInterface(
+                ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE));
+        services.mStatsService = INetworkStatsService.Stub.asInterface(
+                ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
+        services.mPolicyManager = mContext.getSystemService(NetworkPolicyManager.class);
+        services.mPolicyEditor = new NetworkPolicyEditor(services.mPolicyManager);
+        services.mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
+        services.mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
+        services.mUserManager = mContext.getSystemService(UserManager.class);
+
+        NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
+                services.mTelephonyManager.getSubscriberId(mSubscriptionId));
+        NetworkTemplate template = NetworkTemplate.normalize(mobileAll,
+                services.mTelephonyManager.getMergedSubscriberIds());
+
+        preference.setTemplate(template, mSubscriptionId, services);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index a24f82b..e791168 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -150,8 +150,6 @@
 
         mInternalCategory.addPreference(mInternalSummary);
 
-        int privateCount = 0;
-
         final StorageManagerVolumeProvider smvp = new StorageManagerVolumeProvider(mStorageManager);
         final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(smvp);
         final long privateTotalBytes = info.totalBytes;
@@ -162,10 +160,16 @@
 
         for (VolumeInfo vol : volumes) {
             if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
-                final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol,
-                        sTotalInternalStorage);
-                mInternalCategory.addPreference(
-                        new StorageVolumePreference(context, vol, volumeTotalBytes));
+
+                if (vol.getState() == VolumeInfo.STATE_UNMOUNTABLE) {
+                    mInternalCategory.addPreference(
+                            new StorageVolumePreference(context, vol, 0));
+                } else {
+                    final long volumeTotalBytes = PrivateStorageInfo.getTotalSize(vol,
+                            sTotalInternalStorage);
+                    mInternalCategory.addPreference(
+                            new StorageVolumePreference(context, vol, volumeTotalBytes));
+                }
             } else if (vol.getType() == VolumeInfo.TYPE_PUBLIC
                     || vol.getType() == VolumeInfo.TYPE_STUB) {
                 mExternalCategory.addPreference(
diff --git a/src/com/android/settings/display/TopLevelDisplayPreferenceController.java b/src/com/android/settings/display/TopLevelDisplayPreferenceController.java
index ed85a4a..fbaea93 100644
--- a/src/com/android/settings/display/TopLevelDisplayPreferenceController.java
+++ b/src/com/android/settings/display/TopLevelDisplayPreferenceController.java
@@ -36,11 +36,15 @@
 
     @Override
     public CharSequence getSummary() {
-        if (new WallpaperPreferenceController(mContext, "dummy_key").isAvailable()) {
-            return mContext.getText(R.string.display_dashboard_summary);
+        final WallpaperPreferenceController controller =
+                new WallpaperPreferenceController(mContext, "dummy_key");
+        if (controller.isAvailable()) {
+            return mContext.getText(
+                    controller.areStylesAvailable()
+                    ? R.string.display_dashboard_summary_with_style
+                    : R.string.display_dashboard_summary);
         } else {
             return mContext.getText(R.string.display_dashboard_nowallpaper_summary);
         }
     }
-
 }
diff --git a/src/com/android/settings/display/WallpaperPreferenceController.java b/src/com/android/settings/display/WallpaperPreferenceController.java
index 0b09124..126be11 100644
--- a/src/com/android/settings/display/WallpaperPreferenceController.java
+++ b/src/com/android/settings/display/WallpaperPreferenceController.java
@@ -25,6 +25,7 @@
 import android.util.Log;
 
 import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
@@ -34,16 +35,26 @@
 import java.util.List;
 
 public class WallpaperPreferenceController extends BasePreferenceController {
-
     private static final String TAG = "WallpaperPrefController";
 
     private final String mWallpaperPackage;
     private final String mWallpaperClass;
+    private final String mStylesAndWallpaperClass;
 
     public WallpaperPreferenceController(Context context, String key) {
         super(context, key);
         mWallpaperPackage = mContext.getString(R.string.config_wallpaper_picker_package);
         mWallpaperClass = mContext.getString(R.string.config_wallpaper_picker_class);
+        mStylesAndWallpaperClass =
+                mContext.getString(R.string.config_styles_and_wallpaper_picker_class);
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        Preference preference = screen.findPreference(getPreferenceKey());
+        preference.setTitle(mContext.getString(areStylesAvailable()
+                ? R.string.style_and_wallpaper_settings_title : R.string.wallpaper_settings_title));
     }
 
     @Override
@@ -52,14 +63,7 @@
             Log.e(TAG, "No Wallpaper picker specified!");
             return UNSUPPORTED_ON_DEVICE;
         }
-        final ComponentName componentName =
-                new ComponentName(mWallpaperPackage, mWallpaperClass);
-        final PackageManager pm = mContext.getPackageManager();
-        final Intent intent = new Intent();
-        intent.setComponent(componentName);
-        final List<ResolveInfo> resolveInfos =
-                pm.queryIntentActivities(intent, 0 /* flags */);
-        return resolveInfos != null && !resolveInfos.isEmpty()
+        return canResolveWallpaperComponent(mWallpaperClass)
                 ? AVAILABLE_UNSEARCHABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
@@ -68,6 +72,31 @@
         disablePreferenceIfManaged((RestrictedPreference) preference);
     }
 
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (getPreferenceKey().equals(preference.getKey())) {
+            final ComponentName componentName = new ComponentName(mWallpaperPackage,
+                    areStylesAvailable() ? mStylesAndWallpaperClass : mWallpaperClass);
+            preference.getContext().startActivity(new Intent().setComponent(componentName));
+            return true;
+        }
+        return super.handlePreferenceTreeClick(preference);
+    }
+
+    /** Returns whether Styles & Wallpaper is enabled and available. */
+    public boolean areStylesAvailable() {
+        return !TextUtils.isEmpty(mStylesAndWallpaperClass)
+                && canResolveWallpaperComponent(mStylesAndWallpaperClass);
+    }
+
+    private boolean canResolveWallpaperComponent(String className) {
+        final ComponentName componentName = new ComponentName(mWallpaperPackage, className);
+        final PackageManager pm = mContext.getPackageManager();
+        final Intent intent = new Intent().setComponent(componentName);
+        final List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0 /* flags */);
+        return resolveInfos != null && !resolveInfos.isEmpty();
+    }
+
     private void disablePreferenceIfManaged(RestrictedPreference pref) {
         final String restriction = DISALLOW_SET_WALLPAPER;
         if (pref != null) {
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index e19cfb8..e8d5f33 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -169,7 +169,7 @@
         try {
             args.putInt(EXTRA_UID, packageManager.getPackageUid(packageName, 0 /* no flag */));
         } catch (PackageManager.NameNotFoundException e) {
-            Log.e(TAG, "Cannot find package: " + packageName, e);
+            Log.w(TAG, "Cannot find package: " + packageName, e);
         }
 
         new SubSettingLauncher(caller)
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailActivity.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailActivity.java
new file mode 100644
index 0000000..03ddde5
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailActivity.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge;
+
+import static com.android.settings.fuelgauge.AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME;
+import static com.android.settings.fuelgauge.AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT;
+import static com.android.settings.fuelgauge.AdvancedPowerUsageDetail.EXTRA_UID;
+
+import android.app.settings.SettingsEnums;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
+import com.android.settings.R;
+import com.android.settings.Utils;
+
+/**
+ * Trampoline activity for launching the {@link AdvancedPowerUsageDetail} fragment.
+ */
+public class AdvancedPowerUsageDetailActivity extends AppCompatActivity {
+
+    private static final String TAG = "AdvancedPowerDetailActivity";
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        final Intent intent = getIntent();
+        final Uri data = intent == null ? null : intent.getData();
+        final String packageName = data == null ? null : data.getSchemeSpecificPart();
+        if (packageName != null) {
+            final Bundle args = new Bundle(4);
+            final PackageManager packageManager = getPackageManager();
+            args.putString(EXTRA_PACKAGE_NAME, packageName);
+            args.putString(EXTRA_POWER_USAGE_PERCENT, Utils.formatPercentage(0));
+
+            if (intent.getBooleanExtra("request_ignore_background_restriction", false)) {
+                args.putString(":settings:fragment_args_key", "background_activity");
+            }
+
+            try {
+                args.putInt(EXTRA_UID, packageManager.getPackageUid(packageName, 0 /* no flag */));
+            } catch (PackageManager.NameNotFoundException e) {
+                Log.w(TAG, "Cannot find package: " + packageName, e);
+            }
+
+            new SubSettingLauncher(this)
+                    .setDestination(AdvancedPowerUsageDetail.class.getName())
+                    .setTitleRes(R.string.battery_details_title)
+                    .setArguments(args)
+                    .setSourceMetricsCategory(SettingsEnums.APPLICATIONS_INSTALLED_APP_DETAILS)
+                    .launch();
+        }
+
+        finish();
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/BatteryMeterView.java b/src/com/android/settings/fuelgauge/BatteryMeterView.java
index aa26ff4..4485508 100644
--- a/src/com/android/settings/fuelgauge/BatteryMeterView.java
+++ b/src/com/android/settings/fuelgauge/BatteryMeterView.java
@@ -61,7 +61,6 @@
         mDrawable = new BatteryMeterDrawable(context, frameColor);
         mDrawable.setColorFilter(mAccentColorFilter);
         setImageDrawable(mDrawable);
-        setLayerType(LAYER_TYPE_SOFTWARE, null);
     }
 
     public void setBatteryLevel(int level) {
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
index 57bae45..2cf2b6d 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
@@ -17,6 +17,7 @@
 
 import android.content.ContentResolver;
 import android.content.Context;
+import android.os.Bundle;
 import android.os.PowerManager;
 import android.provider.Settings;
 import android.provider.Settings.Global;
@@ -38,6 +39,7 @@
     public static final String KEY_NO_SCHEDULE = "key_battery_saver_no_schedule";
     public static final String KEY_ROUTINE = "key_battery_saver_routine";
     public static final String KEY_PERCENTAGE = "key_battery_saver_percentage";
+    public static final int TRIGGER_LEVEL_MIN = 5;
 
     private Context mContext;
     private BatterySaverScheduleSeekBarController mSeekBarController;
@@ -67,30 +69,43 @@
     }
 
     public boolean setDefaultKey(String key) {
+        if (key == null) {
+            return false;
+        }
+        
         final ContentResolver resolver = mContext.getContentResolver();
-
         int mode = PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE;
         int triggerLevel = 0;
-        if (!TextUtils.equals(key, KEY_NO_SCHEDULE)
-                && BatterySaverUtils.maybeShowBatterySaverConfirmation(
-                        mContext, true /* confirmOnly */)) {
-            return true;
-        } else {
-            switch (key) {
-                case KEY_NO_SCHEDULE:
-                    break;
-                case KEY_PERCENTAGE:
-                    triggerLevel = 5;
-                    break;
-                case KEY_ROUTINE:
-                    mode = PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC;
-                    break;
-                default:
-                    throw new IllegalStateException(
-                            "Not a valid key for " + this.getClass().getSimpleName());
-            }
+        final Bundle confirmationExtras = new Bundle(3);
+        switch (key) {
+            case KEY_NO_SCHEDULE:
+                break;
+            case KEY_PERCENTAGE:
+                triggerLevel = TRIGGER_LEVEL_MIN;
+                confirmationExtras.putBoolean(BatterySaverUtils.EXTRA_CONFIRM_TEXT_ONLY, true);
+                confirmationExtras.putInt(BatterySaverUtils.EXTRA_POWER_SAVE_MODE_TRIGGER,
+                        PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
+                confirmationExtras.putInt(BatterySaverUtils.EXTRA_POWER_SAVE_MODE_TRIGGER_LEVEL,
+                        triggerLevel);
+                break;
+            case KEY_ROUTINE:
+                mode = PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC;
+                confirmationExtras.putBoolean(BatterySaverUtils.EXTRA_CONFIRM_TEXT_ONLY, true);
+                confirmationExtras.putInt(BatterySaverUtils.EXTRA_POWER_SAVE_MODE_TRIGGER,
+                        PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
+                break;
+            default:
+                throw new IllegalStateException(
+                        "Not a valid key for " + this.getClass().getSimpleName());
         }
 
+        if (!TextUtils.equals(key, KEY_NO_SCHEDULE)
+                && BatterySaverUtils.maybeShowBatterySaverConfirmation(
+                mContext, confirmationExtras)) {
+            // reset this if we need to show the confirmation message
+            mode = PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE;
+            triggerLevel = 0;
+        }
         // Trigger level is intentionally left alone when going between dynamic and percentage modes
         // so that a users percentage based schedule is preserved when they toggle between the two.
         Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE, mode);
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
index c296c7a..bba7f53 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
@@ -20,17 +20,4 @@
 
 /** Feature provider for the contextual card feature. */
 public interface ContextualCardFeatureProvider {
-
-    /** Homepage displays. */
-    void logHomepageDisplay(long latency);
-
-    /** When user clicks dismiss in contextual card */
-    void logContextualCardDismiss(ContextualCard card);
-
-    /** After ContextualCardManager decides which cards will be displayed/hidden */
-    void logContextualCardDisplay(List<ContextualCard> showedCards,
-            List<ContextualCard> hiddenCards);
-
-    /** When user clicks toggle/title area of a contextual card. */
-    void logContextualCardClick(ContextualCard card, int sliceRow, int tapTarget, int uiPosition);
 }
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
index 793134f..03a1550 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
@@ -16,161 +16,12 @@
 
 package com.android.settings.homepage.contextualcards;
 
-import android.annotation.NonNull;
 import android.content.Context;
-import android.content.Intent;
-import android.os.UserHandle;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.slice.widget.EventInfo;
-
-import com.android.settings.R;
-import com.android.settings.intelligence.ContextualCardProto.ContextualCardList;
-
-import java.util.List;
 
 public class ContextualCardFeatureProviderImpl implements ContextualCardFeatureProvider {
-    private static final String TAG = "ContextualCardFeature";
-
-    // Contextual card interaction logs
-    // Settings Homepage shows
-    private static final int CONTEXTUAL_HOME_SHOW = 38;
-
-    // Contextual card shows, log card name and rank
-    private static final int CONTEXTUAL_CARD_SHOW = 39;
-
-    // Contextual card is dismissed, log card name
-    private static final int CONTEXTUAL_CARD_DISMISS = 41;
-
-    // Contextual card is clicked , log card name, score, tap area
-    private static final int CONTEXTUAL_CARD_CLICK = 42;
-
-    // SettingsLogBroadcastReceiver contracts
-    // contextual card name
-    private static final String EXTRA_CONTEXTUALCARD_NAME = "name";
-
-    // contextual card uri
-    private static final String EXTRA_CONTEXTUALCARD_URI = "uri";
-
-    // contextual card score
-    private static final String EXTRA_CONTEXTUALCARD_SCORE = "score";
-
-    // contextual card clicked row
-    private static final String EXTRA_CONTEXTUALCARD_ROW = "row";
-
-    // contextual card tap target
-    private static final String EXTRA_CONTEXTUALCARD_TAP_TARGET = "target";
-
-    // contextual card ui position
-    private static final String EXTRA_CONTEXTUALCARD_UI_POSTITION = "ui_position";
-
-    // contextual homepage display latency
-    private static final String EXTRA_LATENCY = "latency";
-
-    // log type
-    private static final String EXTRA_CONTEXTUALCARD_ACTION_TYPE = "type";
-
-    // displayed contextual cards
-    private static final String EXTRA_CONTEXTUALCARD_VISIBLE = "visible";
-
-    // hidden contextual cards
-    private static final String EXTRA_CONTEXTUALCARD_HIDDEN = "hidden";
-
-    // Contextual card tap target
-    private static final int TARGET_DEFAULT = 0;
-
-    // Click title area
-    private static final int TARGET_TITLE = 1;
-
-    // Click toggle
-    private static final int TARGET_TOGGLE = 2;
-
-    // Click slider
-    private static final int TARGET_SLIDER = 3;
-
     private final Context mContext;
 
     public ContextualCardFeatureProviderImpl(Context context) {
         mContext = context;
     }
-
-    @Override
-    public void logHomepageDisplay(long latency) {
-        sendBroadcast(new Intent()
-                .putExtra(EXTRA_CONTEXTUALCARD_ACTION_TYPE, CONTEXTUAL_HOME_SHOW)
-                .putExtra(EXTRA_LATENCY, latency));
-    }
-
-    @Override
-    public void logContextualCardDismiss(ContextualCard card) {
-        final Intent intent = new Intent();
-        intent.putExtra(EXTRA_CONTEXTUALCARD_ACTION_TYPE, CONTEXTUAL_CARD_DISMISS);
-        intent.putExtra(EXTRA_CONTEXTUALCARD_NAME, card.getName());
-        intent.putExtra(EXTRA_CONTEXTUALCARD_URI, card.getSliceUri().toString());
-        intent.putExtra(EXTRA_CONTEXTUALCARD_SCORE, card.getRankingScore());
-        sendBroadcast(intent);
-    }
-
-    @Override
-    public void logContextualCardDisplay(List<ContextualCard> visibleCards,
-            List<ContextualCard> hiddenCards) {
-        final Intent intent = new Intent();
-        intent.putExtra(EXTRA_CONTEXTUALCARD_ACTION_TYPE, CONTEXTUAL_CARD_SHOW);
-        intent.putExtra(EXTRA_CONTEXTUALCARD_VISIBLE, serialize(visibleCards));
-        intent.putExtra(EXTRA_CONTEXTUALCARD_HIDDEN, serialize(hiddenCards));
-        sendBroadcast(intent);
-    }
-
-    @Override
-    public void logContextualCardClick(ContextualCard card, int row,
-            int actionType, int uiPosition) {
-        final Intent intent = new Intent();
-        intent.putExtra(EXTRA_CONTEXTUALCARD_ACTION_TYPE, CONTEXTUAL_CARD_CLICK);
-        intent.putExtra(EXTRA_CONTEXTUALCARD_NAME, card.getName());
-        intent.putExtra(EXTRA_CONTEXTUALCARD_URI, card.getSliceUri().toString());
-        intent.putExtra(EXTRA_CONTEXTUALCARD_SCORE, card.getRankingScore());
-        intent.putExtra(EXTRA_CONTEXTUALCARD_ROW, row);
-        intent.putExtra(EXTRA_CONTEXTUALCARD_TAP_TARGET, actionTypeToTapTarget(actionType));
-        intent.putExtra(EXTRA_CONTEXTUALCARD_UI_POSTITION, uiPosition);
-        sendBroadcast(intent);
-    }
-
-    @VisibleForTesting
-    void sendBroadcast(final Intent intent) {
-        intent.setPackage(mContext.getString(R.string.config_settingsintelligence_package_name));
-        final String action = mContext.getString(R.string.config_settingsintelligence_log_action);
-        if (!TextUtils.isEmpty(action)) {
-            intent.setAction(action);
-            mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
-        }
-    }
-
-    private int actionTypeToTapTarget(int actionType) {
-        switch (actionType) {
-            case EventInfo.ACTION_TYPE_CONTENT:
-                return TARGET_TITLE;
-            case EventInfo.ACTION_TYPE_TOGGLE:
-                return TARGET_TOGGLE;
-            case EventInfo.ACTION_TYPE_SLIDER:
-                return TARGET_SLIDER;
-            default:
-                Log.w(TAG, "unknown type " + actionType);
-                return TARGET_DEFAULT;
-        }
-    }
-
-    @VisibleForTesting
-    @NonNull
-    byte[] serialize(List<ContextualCard> cards) {
-        final ContextualCardList.Builder builder = ContextualCardList.newBuilder();
-        cards.stream().forEach(card -> builder.addCard(
-                com.android.settings.intelligence.ContextualCardProto.ContextualCard.newBuilder()
-                        .setSliceUri(card.getSliceUri().toString())
-                        .setCardName(card.getName())
-                        .setCardScore(card.getRankingScore())
-                        .build()));
-        return builder.build().toByteArray();
-    }
 }
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 32f505e..74ff613 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -20,6 +20,7 @@
 import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI;
 import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.database.ContentObserver;
 import android.database.Cursor;
@@ -32,7 +33,9 @@
 import androidx.annotation.VisibleForTesting;
 
 import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.logging.ContextualCardLogUtils;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.utils.AsyncLoaderCompat;
 
 import java.util.ArrayList;
@@ -162,10 +165,16 @@
             return visibleCards;
         } finally {
             if (!CardContentProvider.DELETE_CARD_URI.equals(mNotifyUri)) {
-                final ContextualCardFeatureProvider contextualCardFeatureProvider =
-                        FeatureFactory.getFactory(mContext)
-                                .getContextualCardFeatureProvider(mContext);
-                contextualCardFeatureProvider.logContextualCardDisplay(visibleCards, hiddenCards);
+                final MetricsFeatureProvider metricsFeatureProvider =
+                        FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
+
+                metricsFeatureProvider.action(mContext,
+                        SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW,
+                        ContextualCardLogUtils.buildCardListLog(visibleCards));
+
+                metricsFeatureProvider.action(mContext,
+                        SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW,
+                        ContextualCardLogUtils.buildCardListLog(hiddenCards));
             }
         }
     }
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index d8361a9..b39058b 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -37,6 +37,7 @@
 import androidx.loader.app.LoaderManager;
 import androidx.loader.content.Loader;
 
+import com.android.settings.homepage.contextualcards.conditional.ConditionalCardController;
 import com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -82,12 +83,13 @@
             {ContextualCard.CardType.CONDITIONAL, ContextualCard.CardType.LEGACY_SUGGESTION};
 
     private final Context mContext;
-    private final ControllerRendererPool mControllerRendererPool;
     private final Lifecycle mLifecycle;
     private final List<LifecycleObserver> mLifecycleObservers;
     private ContextualCardUpdateListener mListener;
 
     @VisibleForTesting
+    final ControllerRendererPool mControllerRendererPool;
+    @VisibleForTesting
     final List<ContextualCard> mContextualCards;
     @VisibleForTesting
     long mStartTime;
@@ -228,8 +230,6 @@
         }
         //only log homepage display upon a fresh launch
         final long totalTime = System.currentTimeMillis() - mStartTime;
-        FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext)
-                .logHomepageDisplay(totalTime);
         metricsFeatureProvider.action(mContext,
                 SettingsEnums.ACTION_CONTEXTUAL_HOME_SHOW, (int) totalTime);
 
@@ -248,9 +248,25 @@
     public void onWindowFocusChanged(boolean hasWindowFocus) {
         // Duplicate a list to avoid java.util.ConcurrentModificationException.
         final List<ContextualCard> cards = new ArrayList<>(mContextualCards);
+        boolean hasConditionController = false;
         for (ContextualCard card : cards) {
-            final ContextualCardController controller = mControllerRendererPool
+            final ContextualCardController controller = getControllerRendererPool()
                     .getController(mContext, card.getCardType());
+            if (controller instanceof ConditionalCardController) {
+                hasConditionController = true;
+            }
+            if (hasWindowFocus && controller instanceof OnStart) {
+                ((OnStart) controller).onStart();
+            }
+            if (!hasWindowFocus && controller instanceof OnStop) {
+                ((OnStop) controller).onStop();
+            }
+        }
+        // Conditional cards will always be refreshed whether or not there are conditional cards
+        // in the homepage.
+        if (!hasConditionController) {
+            final ContextualCardController controller = getControllerRendererPool()
+                    .getController(mContext, ContextualCard.CardType.CONDITIONAL);
             if (hasWindowFocus && controller instanceof OnStart) {
                 ((OnStart) controller).onStart();
             }
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java b/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
index 0cf553c..0704ed8 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardsFragment.java
@@ -77,8 +77,7 @@
         mCardsContainer.setAdapter(mContextualCardsAdapter);
         mContextualCardManager.setListener(mContextualCardsAdapter);
         mCardsContainer.setListener(this);
-        mItemTouchHelper = new ItemTouchHelper(
-                new SwipeDismissalDelegate(context, mContextualCardsAdapter));
+        mItemTouchHelper = new ItemTouchHelper(new SwipeDismissalDelegate(mContextualCardsAdapter));
         mItemTouchHelper.attachToRecyclerView(mCardsContainer);
 
         return rootView;
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java
index 18019a6..91b2e97 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java
@@ -39,9 +39,9 @@
  */
 public class ConditionContextualCardRenderer implements ContextualCardRenderer {
     @LayoutRes
-    public static final int VIEW_TYPE_HALF_WIDTH = R.layout.homepage_condition_half_tile;
+    public static final int VIEW_TYPE_HALF_WIDTH = R.layout.conditional_card_half_tile;
     @LayoutRes
-    public static final int VIEW_TYPE_FULL_WIDTH = R.layout.homepage_condition_full_tile;
+    public static final int VIEW_TYPE_FULL_WIDTH = R.layout.conditional_card_full_tile;
 
     private final Context mContext;
     private final ControllerRendererPool mControllerRendererPool;
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java
index a516e13b..2944cc8 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionFooterContextualCardRenderer.java
@@ -31,7 +31,7 @@
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 public class ConditionFooterContextualCardRenderer implements ContextualCardRenderer {
-    public static final int VIEW_TYPE = R.layout.homepage_condition_footer;
+    public static final int VIEW_TYPE = R.layout.conditional_card_footer;
     private static final String TAG = "ConditionFooterRenderer";
 
     private final Context mContext;
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java
index 2aa8aca..c5e987a 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java
@@ -34,7 +34,7 @@
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 public class ConditionHeaderContextualCardRenderer implements ContextualCardRenderer {
-    public static final int VIEW_TYPE = R.layout.homepage_condition_header;
+    public static final int VIEW_TYPE = R.layout.conditional_card_header;
     private static final String TAG = "ConditionHeaderRenderer";
 
     private final Context mContext;
@@ -61,7 +61,7 @@
         view.icons.removeAllViews();
         headerCard.getConditionalCards().stream().forEach(card -> {
             final ImageView icon = (ImageView) LayoutInflater.from(mContext).inflate(
-                    R.layout.homepage_condition_header_icon, view.icons, false);
+                    R.layout.conditional_card_header_icon, view.icons, false);
             icon.setImageDrawable(card.getIconDrawable());
             view.icons.addView(icon);
         });
diff --git a/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardRenderer.java
index 20449f0..3bccabc 100644
--- a/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardRenderer.java
@@ -32,7 +32,7 @@
 public class LegacySuggestionContextualCardRenderer implements ContextualCardRenderer {
 
     @LayoutRes
-    public static final int VIEW_TYPE = R.layout.homepage_suggestion_tile;
+    public static final int VIEW_TYPE = R.layout.legacy_suggestion_tile;
 
     private final Context mContext;
     private final ControllerRendererPool mControllerRendererPool;
diff --git a/src/com/android/settings/homepage/contextualcards/logging/ContextualCardLogUtils.java b/src/com/android/settings/homepage/contextualcards/logging/ContextualCardLogUtils.java
new file mode 100644
index 0000000..585eca3
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/logging/ContextualCardLogUtils.java
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.homepage.contextualcards.logging;
+
+import android.util.Log;
+
+import androidx.slice.widget.EventInfo;
+
+import com.android.settings.homepage.contextualcards.ContextualCard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utils of building contextual card to string, and parse string back to {@link CardLog}
+ */
+public class ContextualCardLogUtils {
+
+    private static final String TAG = "ContextualCardLogUtils";
+
+    private static final class TapTarget {
+        static int TARGET_DEFAULT = 0;
+        static int TARGET_TITLE = 1;
+        static int TARGET_TOGGLE = 2;
+        static int TARGET_SLIDER = 3;
+    }
+
+    /**
+     * Log data for a general contextual card event
+     */
+    public static class CardLog {
+        private final String mSliceUri;
+        private final double mRankingScore;
+
+        public CardLog(Builder builder) {
+            mSliceUri = builder.mSliceUri;
+            mRankingScore = builder.mRankingScore;
+        }
+
+        public String getSliceUri() {
+            return mSliceUri;
+        }
+
+        public double getRankingScore() {
+            return mRankingScore;
+        }
+
+        public static class Builder {
+            private String mSliceUri;
+            private double mRankingScore;
+
+            public Builder setSliceUri(String sliceUri) {
+                mSliceUri = sliceUri;
+                return this;
+            }
+
+            public Builder setRankingScore(double rankingScore) {
+                mRankingScore = rankingScore;
+                return this;
+            }
+            public CardLog build() {
+                return new CardLog(this);
+            }
+        }
+    }
+
+    /**
+     * Log data for a contextual card click event
+     */
+    public static class CardClickLog extends CardLog {
+        private final int mSliceRow;
+        private final int mSliceTapTarget;
+        private final int mUiPosition;
+
+        public CardClickLog(Builder builder) {
+            super(builder);
+            mSliceRow = builder.mSliceRow;
+            mSliceTapTarget = builder.mSliceTapTarget;
+            mUiPosition = builder.mUiPosition;
+        }
+
+        public int getSliceRow() {
+            return mSliceRow;
+        }
+
+        public int getSliceTapTarget() {
+            return mSliceTapTarget;
+        }
+
+        public int getUiPosition() {
+            return mUiPosition;
+        }
+
+        public static class Builder extends CardLog.Builder {
+            private int mSliceRow;
+            private int mSliceTapTarget;
+            private int mUiPosition;
+
+            public Builder setSliceRow(int sliceRow) {
+                mSliceRow = sliceRow;
+                return this;
+            }
+
+            public Builder setSliceTapTarget(int sliceTapTarget) {
+                mSliceTapTarget = sliceTapTarget;
+                return this;
+            }
+
+            public Builder setUiPosition(int uiPosition) {
+                mUiPosition = uiPosition;
+                return this;
+            }
+            @Override
+            public CardClickLog build() {
+                return new CardClickLog(this);
+            }
+        }
+    }
+
+    /**
+     * Serialize {@link ContextualCard} click event to string
+     *
+     * @param card Clicked Contextual card.
+     * @param sliceRow A Slice can contains multiple row, which row are we clicked
+     * @param tapTarget Integer value of {@link TapTarget}
+     * @param uiPosition Contextual card position in Listview
+     */
+    public static String buildCardClickLog(ContextualCard card, int sliceRow, int tapTarget,
+            int uiPosition) {
+        final StringBuilder log = new StringBuilder();
+        log.append(card.getTextSliceUri()).append("|")
+                .append(card.getRankingScore()).append("|")
+                .append(sliceRow).append("|")
+                .append(actionTypeToTapTarget(tapTarget)).append("|")
+                .append(uiPosition);
+        return log.toString();
+    }
+
+    /**
+     * Parse string to a {@link CardClickLog}
+     */
+    public static CardClickLog parseCardClickLog(String clickLog) {
+        if (clickLog != null) {
+            final String[] parts = clickLog.split("\\|");
+            if (parts.length < 5) {
+                return null;
+            }
+            try {
+                final CardClickLog.Builder builder = new CardClickLog.Builder();
+                builder.setSliceRow(Integer.parseInt(parts[2]))
+                        .setSliceTapTarget(Integer.parseInt(parts[3]))
+                        .setUiPosition(Integer.parseInt(parts[4]))
+                        .setSliceUri(parts[0])
+                        .setRankingScore(Double.parseDouble(parts[1]));
+                return builder.build();
+            } catch (Exception e) {
+                Log.e(TAG, "error parsing log", e);
+                return null;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Serialize {@link ContextualCard} to string
+     *
+     * @param card Contextual card.
+     */
+    public static String buildCardDismissLog(ContextualCard card) {
+        final StringBuilder log = new StringBuilder();
+        log.append(card.getTextSliceUri())
+                .append("|")
+                .append(card.getRankingScore());
+        return log.toString();
+    }
+
+    /**
+     * Parse string to a {@link CardLog}
+     */
+    public static CardLog parseCardDismissLog(String dismissLog) {
+        if (dismissLog != null) {
+            final String[] parts = dismissLog.split("\\|");
+            if (parts.length < 2) {
+                return null;
+            }
+            try {
+                final CardLog.Builder builder = new CardLog.Builder();
+                builder.setSliceUri(parts[0])
+                        .setRankingScore(Double.parseDouble(parts[1]));
+                return builder.build();
+            } catch (Exception e) {
+                Log.e(TAG, "error parsing log", e);
+                return null;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Serialize List of {@link ContextualCard} to string
+     */
+    public static String buildCardListLog(List<ContextualCard> cards) {
+        final StringBuilder log = new StringBuilder();
+        log.append(cards.size());
+        for (ContextualCard card : cards) {
+            log.append("|").append(card.getTextSliceUri())
+                    .append("|").append(card.getRankingScore());
+        }
+        return log.toString();
+    }
+
+    /**
+     * Parse string to a List of {@link CardLog}
+     */
+    public static List<CardLog> parseCardListLog(String listLog) {
+        final List<CardLog> logList = new ArrayList<>();
+        try {
+            final String[] parts = listLog.split("\\|");
+            if (Integer.parseInt(parts[0]) < 0) {
+                return logList;
+            }
+            final int size = parts.length;
+            for (int i = 1; i < size; ) {
+                final CardLog.Builder builder = new CardLog.Builder();
+                builder.setSliceUri(parts[i++])
+                        .setRankingScore(Double.parseDouble(parts[i++]));
+                logList.add(builder.build());
+            }
+        } catch (Exception e) {
+            Log.e(TAG, "error parsing log", e);
+            return logList;
+        }
+        return logList;
+    }
+
+    public static int actionTypeToTapTarget(int actionType) {
+        switch (actionType) {
+            case EventInfo.ACTION_TYPE_CONTENT:
+                return TapTarget.TARGET_TITLE;
+            case EventInfo.ACTION_TYPE_TOGGLE:
+                return TapTarget.TARGET_TOGGLE;
+            case EventInfo.ACTION_TYPE_SLIDER:
+                return TapTarget.TARGET_SLIDER;
+            default:
+                Log.w(TAG, "unknown type " + actionType);
+                return TapTarget.TARGET_DEFAULT;
+        }
+    }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
index eb062e8..0551377 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
@@ -16,8 +16,10 @@
 
 package com.android.settings.homepage.contextualcards.slices;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Build;
 import android.text.TextUtils;
 
 import androidx.annotation.VisibleForTesting;
@@ -26,10 +28,11 @@
 import com.android.settings.homepage.contextualcards.CardDatabaseHelper;
 import com.android.settings.homepage.contextualcards.ContextualCard;
 import com.android.settings.homepage.contextualcards.ContextualCardController;
-import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
 import com.android.settings.homepage.contextualcards.ContextualCardFeedbackDialog;
+import com.android.settings.homepage.contextualcards.logging.ContextualCardLogUtils;
 import com.android.settings.homepage.contextualcards.ContextualCardUpdateListener;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.utils.ThreadUtils;
 
 /**
@@ -69,9 +72,13 @@
             dbHelper.markContextualCardAsDismissed(mContext, card.getName());
         });
         showFeedbackDialog(card);
-        final ContextualCardFeatureProvider contextualCardFeatureProvider =
-                FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
-        contextualCardFeatureProvider.logContextualCardDismiss(card);
+
+        final MetricsFeatureProvider metricsFeatureProvider =
+                FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
+
+        metricsFeatureProvider.action(mContext,
+                SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS,
+                ContextualCardLogUtils.buildCardDismissLog(card));
     }
 
     @Override
@@ -82,7 +89,7 @@
     @VisibleForTesting
     void showFeedbackDialog(ContextualCard card) {
         final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
-        if (TextUtils.isEmpty(email)) {
+        if (!isFeedbackEnabled(email)) {
             return;
         }
         final Intent feedbackIntent = new Intent(mContext, ContextualCardFeedbackDialog.class);
@@ -93,6 +100,11 @@
         mContext.startActivity(feedbackIntent);
     }
 
+    @VisibleForTesting
+    boolean isFeedbackEnabled(String email) {
+        return !TextUtils.isEmpty(email) && Build.IS_DEBUGGABLE;
+    }
+
     private String getSimpleCardName(ContextualCard card) {
         final String[] split = card.getName().split("/");
         return split[split.length - 1];
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index 590afd2..725f087 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -24,7 +24,6 @@
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
-import android.widget.ViewFlipper;
 
 import androidx.annotation.LayoutRes;
 import androidx.annotation.VisibleForTesting;
@@ -50,9 +49,9 @@
  * Card renderer for {@link ContextualCard} built as slice full card or slice half card.
  */
 public class SliceContextualCardRenderer implements ContextualCardRenderer, LifecycleObserver {
-    public static final int VIEW_TYPE_FULL_WIDTH = R.layout.homepage_slice_tile;
-    public static final int VIEW_TYPE_HALF_WIDTH = R.layout.homepage_slice_half_tile;
-    public static final int VIEW_TYPE_DEFERRED_SETUP = R.layout.homepage_slice_deferred_setup_tile;
+    public static final int VIEW_TYPE_FULL_WIDTH = R.layout.contextual_slice_full_tile;
+    public static final int VIEW_TYPE_HALF_WIDTH = R.layout.contextual_slice_half_tile;
+    public static final int VIEW_TYPE_DEFERRED_SETUP = R.layout.contextual_slice_deferred_setup;
 
     private static final String TAG = "SliceCardRenderer";
 
@@ -142,7 +141,7 @@
         }
 
         if (card.isPendingDismiss()) {
-            flipCardToDismissalView(holder);
+            showDismissalView(holder);
             mFlippedCardSet.add(holder);
         }
     }
@@ -170,12 +169,19 @@
     }
 
     private void resetCardView(RecyclerView.ViewHolder holder) {
-        final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
-        viewFlipper.setDisplayedChild(0 /* whichChild */);
+        holder.itemView.findViewById(R.id.dismissal_view).setVisibility(View.GONE);
+        getInitialView(holder).setVisibility(View.VISIBLE);
     }
 
-    private void flipCardToDismissalView(RecyclerView.ViewHolder holder) {
-        final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
-        viewFlipper.showNext();
+    private void showDismissalView(RecyclerView.ViewHolder holder) {
+        holder.itemView.findViewById(R.id.dismissal_view).setVisibility(View.VISIBLE);
+        getInitialView(holder).setVisibility(View.INVISIBLE);
+    }
+
+    private View getInitialView(RecyclerView.ViewHolder viewHolder) {
+        if (viewHolder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
+            return ((SliceHalfCardRendererHelper.HalfCardViewHolder) viewHolder).content;
+        }
+        return ((SliceFullCardRendererHelper.SliceViewHolder) viewHolder).sliceView;
     }
 }
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java
index 630839c..ea9e424 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceDeferredSetupCardRendererHelper.java
@@ -17,6 +17,7 @@
 package com.android.settings.homepage.contextualcards.slices;
 
 import android.app.PendingIntent;
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.util.Log;
 import android.view.View;
@@ -33,8 +34,9 @@
 
 import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.ContextualCard;
-import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.homepage.contextualcards.logging.ContextualCardLogUtils;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 /**
  * Card renderer helper for {@link ContextualCard} built as slice deferred setup card.
@@ -65,10 +67,14 @@
             } catch (PendingIntent.CanceledException e) {
                 Log.w(TAG, "Failed to start intent " + primaryAction.getTitle());
             }
-            final ContextualCardFeatureProvider contextualCardFeatureProvider =
-                    FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
-            contextualCardFeatureProvider.logContextualCardClick(card, 0 /* row */,
+            final String log = ContextualCardLogUtils.buildCardClickLog(card, 0 /* row */,
                     EventInfo.ACTION_TYPE_CONTENT, view.getAdapterPosition());
+
+            final MetricsFeatureProvider metricsFeatureProvider =
+                    FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
+
+            metricsFeatureProvider.action(mContext,
+                    SettingsEnums.ACTION_CONTEXTUAL_CARD_CLICK, log);
         });
     }
 
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
index 3584578..a9a8346 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -16,8 +16,10 @@
 
 package com.android.settings.homepage.contextualcards.slices;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.view.View;
+import android.widget.LinearLayout;
 
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.slice.Slice;
@@ -25,8 +27,9 @@
 
 import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.ContextualCard;
-import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.homepage.contextualcards.logging.ContextualCardLogUtils;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 /**
  * Card renderer helper for {@link ContextualCard} built as slice full card.
@@ -53,11 +56,14 @@
         // Set this listener so we can log the interaction users make on the slice
         cardHolder.sliceView.setOnSliceActionListener(
                 (eventInfo, sliceItem) -> {
-                    final ContextualCardFeatureProvider contextualCardFeatureProvider =
-                            FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(
-                                    mContext);
-                    contextualCardFeatureProvider.logContextualCardClick(card, eventInfo.rowIndex,
+                    final String log = ContextualCardLogUtils.buildCardClickLog(card, eventInfo.rowIndex,
                             eventInfo.actionType, cardHolder.getAdapterPosition());
+
+                    final MetricsFeatureProvider metricsFeatureProvider =
+                            FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
+
+                    metricsFeatureProvider.action(mContext,
+                            SettingsEnums.ACTION_CONTEXTUAL_CARD_CLICK, log);
                 });
 
         // Customize slice view for Settings
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
index 6bb2208..f774542 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
@@ -17,6 +17,7 @@
 package com.android.settings.homepage.contextualcards.slices;
 
 import android.app.PendingIntent;
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.util.Log;
 import android.view.View;
@@ -32,8 +33,9 @@
 
 import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.ContextualCard;
-import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.homepage.contextualcards.logging.ContextualCardLogUtils;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 /**
  * Card renderer helper for {@link ContextualCard} built as slice half card.
@@ -63,10 +65,14 @@
             } catch (PendingIntent.CanceledException e) {
                 Log.w(TAG, "Failed to start intent " + primaryAction.getTitle());
             }
-            final ContextualCardFeatureProvider contextualCardFeatureProvider =
-                    FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
-            contextualCardFeatureProvider.logContextualCardClick(card, 0 /* row */,
+            final String log = ContextualCardLogUtils.buildCardClickLog(card, 0 /* row */,
                     EventInfo.ACTION_TYPE_CONTENT, view.getAdapterPosition());
+
+            final MetricsFeatureProvider metricsFeatureProvider =
+                    FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
+
+            metricsFeatureProvider.action(mContext,
+                    SettingsEnums.ACTION_CONTEXTUAL_CARD_CLICK, log);
         });
     }
 
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegate.java b/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegate.java
index 3564189..0f78575 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegate.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegate.java
@@ -16,13 +16,8 @@
 
 package com.android.settings.homepage.contextualcards.slices;
 
-import android.content.Context;
 import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.graphics.drawable.Drawable;
 import android.view.View;
-import android.widget.ViewFlipper;
 
 import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.ItemTouchHelper;
@@ -39,20 +34,10 @@
         void onSwiped(int position);
     }
 
-    private final Context mContext;
     private final SwipeDismissalDelegate.Listener mListener;
-    private final Drawable mIconDelete;
-    private final Paint mBgPaint;
-    private final int mBgCornerRadius;
 
-    public SwipeDismissalDelegate(Context context, SwipeDismissalDelegate.Listener listener) {
-        mContext = context;
+    public SwipeDismissalDelegate(SwipeDismissalDelegate.Listener listener) {
         mListener = listener;
-        mIconDelete = mContext.getDrawable(R.drawable.ic_delete);
-        mBgPaint = new Paint();
-        mBgPaint.setColor(mContext.getColor(R.color.homepage_card_dismissal_background));
-        mBgCornerRadius = mContext.getResources()
-                .getDimensionPixelSize(R.dimen.homepage_card_corner_radius);
     }
 
     /**
@@ -70,14 +55,10 @@
         switch (viewHolder.getItemViewType()) {
             case SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH:
             case SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH:
-                //TODO(b/129438972): Convert this to a regular view.
-                final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
-
-                // As we are using ViewFlipper to switch between the initial view and
-                // dismissal view, here we are making sure the current displayed view is the
-                // initial view of either slice full card or half card, and only allow swipe on
-                // these two types.
-                if (viewFlipper.getCurrentView().getId() != getInitialViewId(viewHolder)) {
+                // Here we are making sure the current displayed view is the initial view of
+                // either slice full card or half card, and only allow swipe on these two types.
+                if (viewHolder.itemView.findViewById(R.id.dismissal_view).getVisibility()
+                        == View.VISIBLE) {
                     // Disable swiping when we are in the dismissal view
                     return 0;
                 }
@@ -101,40 +82,41 @@
     }
 
     @Override
+    public void clearView(@NonNull RecyclerView recyclerView,
+            @NonNull RecyclerView.ViewHolder viewHolder) {
+        final View view = getSwipeableView(viewHolder);
+        getDefaultUIUtil().clearView(view);
+    }
+
+    @Override
     public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView,
             @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState,
             boolean isCurrentlyActive) {
-        super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
+        final View view = getSwipeableView(viewHolder);
+        final View iconStart = viewHolder.itemView.findViewById(R.id.dismissal_icon_start);
+        final View iconEnd = viewHolder.itemView.findViewById(R.id.dismissal_icon_end);
 
-        final View itemView = viewHolder.itemView;
-        final int iconMargin = mContext.getResources()
-                .getDimensionPixelSize(R.dimen.homepage_card_dismissal_side_margin);
-        final int iconTop =
-                itemView.getTop() + (itemView.getHeight() - mIconDelete.getIntrinsicHeight()) / 2;
-        final int iconBottom = iconTop + mIconDelete.getIntrinsicHeight();
-
-        if (dX > 0) { //swipe to the right
-            final int iconLeft = itemView.getLeft() + iconMargin;
-            final int iconRight = iconLeft + mIconDelete.getIntrinsicWidth();
-            final RectF rect = new RectF(itemView.getLeft(), itemView.getTop(),
-                    itemView.getLeft() + ((int) dX) + mBgCornerRadius, itemView.getBottom());
-            mIconDelete.setBounds(iconLeft, iconTop, iconRight, iconBottom);
-            c.drawRoundRect(rect, mBgCornerRadius, mBgCornerRadius, mBgPaint);
+        if (dX > 0) {
+            iconStart.setVisibility(View.VISIBLE);
+            iconEnd.setVisibility(View.GONE);
         } else if (dX < 0) {
-            final int iconRight = itemView.getRight() - iconMargin;
-            final int iconLeft = iconRight - mIconDelete.getIntrinsicWidth();
-            final RectF rect = new RectF(itemView.getRight() + ((int) dX), itemView.getTop(),
-                    itemView.getRight(), itemView.getBottom());
-            mIconDelete.setBounds(iconLeft, iconTop, iconRight, iconBottom);
-            c.drawRoundRect(rect, mBgCornerRadius, mBgCornerRadius, mBgPaint);
+            iconStart.setVisibility(View.GONE);
+            iconEnd.setVisibility(View.VISIBLE);
         }
-        mIconDelete.draw(c);
+        getDefaultUIUtil().onDraw(c, recyclerView, view, dX, dY, actionState, isCurrentlyActive);
     }
 
-    private int getInitialViewId(RecyclerView.ViewHolder viewHolder) {
+    /**
+     * Get the foreground view from the {@link android.widget.FrameLayout} as we only swipe
+     * the foreground out in {@link SwipeDismissalDelegate#onChildDraw} and gets the view
+     * beneath revealed.
+     *
+     * @return The foreground view.
+     */
+    private View getSwipeableView(RecyclerView.ViewHolder viewHolder) {
         if (viewHolder.getItemViewType() == SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH) {
-            return R.id.content;
+            return ((SliceHalfCardRendererHelper.HalfCardViewHolder) viewHolder).content;
         }
-        return R.id.slice_view;
+        return ((SliceFullCardRendererHelper.SliceViewHolder) viewHolder).sliceView;
     }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/location/LocationServicePreferenceController.java b/src/com/android/settings/location/LocationServicePreferenceController.java
index e604261..70246cb 100644
--- a/src/com/android/settings/location/LocationServicePreferenceController.java
+++ b/src/com/android/settings/location/LocationServicePreferenceController.java
@@ -34,6 +34,7 @@
 import com.android.settingslib.core.lifecycle.events.OnResume;
 
 import java.util.List;
+import java.util.Map;
 
 public class LocationServicePreferenceController extends LocationBasePreferenceController
         implements LifecycleObserver, OnResume, OnPause {
@@ -41,14 +42,17 @@
     private static final String TAG = "LocationServicePrefCtrl";
     /** Key for preference category "Location services" */
     private static final String KEY_LOCATION_SERVICES = "location_services";
+    /** Key for preference category "Location services for work" */
+    private static final String KEY_LOCATION_SERVICES_MANAGED = "location_services_managed_profile";
     @VisibleForTesting
     static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED =
             new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
 
     private PreferenceCategory mCategoryLocationServices;
+    private PreferenceCategory mCategoryLocationServicesManaged;
     private final LocationSettings mFragment;
     private final AppSettingsInjector mInjector;
-    /** Receives UPDATE_INTENT  */
+    /** Receives UPDATE_INTENT */
     @VisibleForTesting
     BroadcastReceiver mInjectedSettingsReceiver;
 
@@ -74,29 +78,36 @@
     }
 
     @Override
-    public boolean isAvailable() {
-        // If managed profile has lock-down on location access then its injected location services
-        // must not be shown.
-        return mInjector.hasInjectedSettings(mLocationEnabler.isManagedProfileRestrictedByBase()
-                ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
-    }
-
-    @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES);
+        mCategoryLocationServicesManaged = screen.findPreference(KEY_LOCATION_SERVICES_MANAGED);
     }
 
     @Override
     public void updateState(Preference preference) {
         mCategoryLocationServices.removeAll();
-        final List<Preference> prefs = getLocationServices();
-        for (Preference pref : prefs) {
-            if (pref instanceof RestrictedAppPreference) {
-                ((RestrictedAppPreference) pref).checkRestrictionAndSetDisabled();
+        mCategoryLocationServicesManaged.removeAll();
+        final Map<Integer, List<Preference>> prefs = getLocationServices();
+        boolean showPrimary = false;
+        boolean showManaged = false;
+        for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
+            for (Preference pref : entry.getValue()) {
+                if (pref instanceof RestrictedAppPreference) {
+                    ((RestrictedAppPreference) pref).checkRestrictionAndSetDisabled();
+                }
+            }
+            if (entry.getKey() == UserHandle.myUserId()) {
+                LocationSettings.addPreferencesSorted(entry.getValue(), mCategoryLocationServices);
+                showPrimary = true;
+            } else {
+                LocationSettings.addPreferencesSorted(entry.getValue(),
+                        mCategoryLocationServicesManaged);
+                showManaged = true;
             }
         }
-        LocationSettings.addPreferencesSorted(prefs, mCategoryLocationServices);
+        mCategoryLocationServices.setVisible(showPrimary);
+        mCategoryLocationServicesManaged.setVisible(showManaged);
     }
 
     @Override
@@ -128,7 +139,7 @@
         mContext.unregisterReceiver(mInjectedSettingsReceiver);
     }
 
-    private List<Preference> getLocationServices() {
+    private Map<Integer, List<Preference>> getLocationServices() {
         // If location access is locked down by device policy then we only show injected settings
         // for the primary profile.
         final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
diff --git a/src/com/android/settings/network/ApnEditor.java b/src/com/android/settings/network/ApnEditor.java
index 4de4026..542a869 100644
--- a/src/com/android/settings/network/ApnEditor.java
+++ b/src/com/android/settings/network/ApnEditor.java
@@ -1164,7 +1164,8 @@
                 // add APN type if it is not read-only and is not wild-cardable
                 if (!readOnlyApnTypes.contains(apnType)
                         && !apnType.equals(PhoneConstants.APN_TYPE_IA)
-                        && !apnType.equals(PhoneConstants.APN_TYPE_EMERGENCY)) {
+                        && !apnType.equals(PhoneConstants.APN_TYPE_EMERGENCY)
+                        && !apnType.equals(PhoneConstants.APN_TYPE_MCX)) {
                     if (first) {
                         first = false;
                     } else {
diff --git a/src/com/android/settings/network/MobileNetworkListController.java b/src/com/android/settings/network/MobileNetworkListController.java
index 79715e3..a2e4116 100644
--- a/src/com/android/settings/network/MobileNetworkListController.java
+++ b/src/com/android/settings/network/MobileNetworkListController.java
@@ -24,12 +24,12 @@
 import android.provider.Settings;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
-import android.telephony.euicc.EuiccManager;
 import android.util.ArrayMap;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
 import com.android.settings.network.telephony.MobileNetworkActivity;
+import com.android.settings.network.telephony.MobileNetworkUtils;
 import com.android.settingslib.core.AbstractPreferenceController;
 
 import java.util.List;
@@ -81,8 +81,8 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreferenceScreen = screen;
-        final EuiccManager euiccManager = mContext.getSystemService(EuiccManager.class);
-        mPreferenceScreen.findPreference(KEY_ADD_MORE).setVisible(euiccManager.isEnabled());
+        mPreferenceScreen.findPreference(KEY_ADD_MORE).setVisible(
+                MobileNetworkUtils.showEuiccSettings(mContext));
         update();
     }
 
diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java
index 56735ab..463d7ae 100644
--- a/src/com/android/settings/network/MobileNetworkSummaryController.java
+++ b/src/com/android/settings/network/MobileNetworkSummaryController.java
@@ -28,6 +28,7 @@
 import com.android.settings.R;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settings.network.telephony.MobileNetworkActivity;
+import com.android.settings.network.telephony.MobileNetworkUtils;
 import com.android.settings.widget.AddPreference;
 import com.android.settingslib.Utils;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -49,7 +50,6 @@
 
     private SubscriptionManager mSubscriptionManager;
     private SubscriptionsChangeListener mChangeListener;
-    private EuiccManager mEuiccManager;
     private AddPreference mPreference;
 
     /**
@@ -70,7 +70,6 @@
     public MobileNetworkSummaryController(Context context, Lifecycle lifecycle) {
         super(context);
         mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
-        mEuiccManager = mContext.getSystemService(EuiccManager.class);
         if (lifecycle != null) {
           mChangeListener = new SubscriptionsChangeListener(context, this);
           lifecycle.addObserver(this);
@@ -99,7 +98,7 @@
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(
                 mSubscriptionManager);
         if (subs.isEmpty()) {
-            if (mEuiccManager.isEnabled()) {
+            if (MobileNetworkUtils.showEuiccSettings(mContext)) {
                 return mContext.getResources().getString(
                         R.string.mobile_network_summary_add_a_network);
             }
@@ -133,7 +132,7 @@
                 mSubscriptionManager);
 
         if (subs.isEmpty()) {
-            if (mEuiccManager.isEnabled()) {
+            if (MobileNetworkUtils.showEuiccSettings(mContext)) {
                 mPreference.setOnPreferenceClickListener((Preference pref) -> {
                     startAddSimFlow();
                     return true;
@@ -142,7 +141,7 @@
         } else {
             // We have one or more existing subscriptions, so we want the plus button if eSIM is
             // supported.
-            if (mEuiccManager.isEnabled()) {
+            if (MobileNetworkUtils.showEuiccSettings(mContext)) {
                 mPreference.setAddWidgetEnabled(!mChangeListener.isAirplaneModeOn());
                 mPreference.setOnAddClickListener(p -> startAddSimFlow());
             }
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 224fc41..5f1beca 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -27,16 +27,33 @@
 import java.util.List;
 
 public class SubscriptionUtil {
-    private static List<SubscriptionInfo> sResultsForTesting;
+    private static List<SubscriptionInfo> sAvailableResultsForTesting;
+    private static List<SubscriptionInfo> sActiveResultsForTesting;
 
     @VisibleForTesting
     public static void setAvailableSubscriptionsForTesting(List<SubscriptionInfo> results) {
-        sResultsForTesting = results;
+        sAvailableResultsForTesting = results;
+    }
+
+    @VisibleForTesting
+    public static void setActiveSubscriptionsForTesting(List<SubscriptionInfo> results) {
+        sActiveResultsForTesting = results;
+    }
+
+    public static List<SubscriptionInfo> getActiveSubscriptions(SubscriptionManager manager) {
+        if (sActiveResultsForTesting != null) {
+            return sActiveResultsForTesting;
+        }
+        List<SubscriptionInfo> subscriptions = manager.getActiveSubscriptionInfoList(true);
+        if (subscriptions == null) {
+            return new ArrayList<>();
+        }
+        return subscriptions;
     }
 
     public static List<SubscriptionInfo> getAvailableSubscriptions(SubscriptionManager manager) {
-        if (sResultsForTesting != null) {
-            return sResultsForTesting;
+        if (sAvailableResultsForTesting != null) {
+            return sAvailableResultsForTesting;
         }
         List<SubscriptionInfo> subscriptions = manager.getSelectableSubscriptionInfoList();
         if (subscriptions == null) {
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index 1ff67f8..88ff5cf 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -129,7 +129,7 @@
         mSubscriptionPreferences = new ArrayMap<>();
 
         int order = mStartOrder;
-        for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager)) {
+        for (SubscriptionInfo info : SubscriptionUtil.getActiveSubscriptions(mManager)) {
             final int subId = info.getSubscriptionId();
             Preference pref = existingPrefs.remove(subId);
             if (pref == null) {
@@ -216,7 +216,7 @@
         if (mSubscriptionsListener.isAirplaneModeOn()) {
             return false;
         }
-        return SubscriptionUtil.getAvailableSubscriptions(mManager).size() >= 2;
+        return SubscriptionUtil.getActiveSubscriptions(mManager).size() >= 2;
     }
 
     @Override
diff --git a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
index e982a6b..02a2d58 100644
--- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
@@ -75,7 +75,7 @@
 
     @Override
     public int getAvailabilityStatus() {
-        final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
+        final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mManager);
         if (subs.size() > 1) {
             return AVAILABLE;
         } else {
@@ -121,7 +121,7 @@
         }
         mPreference.setVisible(true);
 
-        final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
+        final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mManager);
 
         // We'll have one entry for each available subscription, plus one for a "ask me every
         // time" entry at the end.
diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java
index 5a5d6a2..28cb11e 100644
--- a/src/com/android/settings/network/telephony/MobileDataSlice.java
+++ b/src/com/android/settings/network/telephony/MobileDataSlice.java
@@ -46,6 +46,7 @@
 import com.google.common.annotations.VisibleForTesting;
 
 import java.io.IOException;
+import java.util.List;
 
 /**
  * Custom {@link Slice} for Mobile Data.
@@ -71,6 +72,11 @@
 
     @Override
     public Slice getSlice() {
+        // Mobile data not available, thus return no Slice.
+        if (!isMobileDataAvailable()) {
+            return null;
+        }
+
         final IconCompat icon = IconCompat.createWithResource(mContext,
                 R.drawable.ic_network_cell);
         final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
@@ -178,6 +184,16 @@
                 intent, 0 /* flags */);
     }
 
+    /**
+     * @return {@code true} when mobile data is not supported by the current device.
+     */
+    private boolean isMobileDataAvailable() {
+        final List<SubscriptionInfo> subInfoList =
+                mSubscriptionManager.getSelectableSubscriptionInfoList();
+
+        return !(subInfoList == null || subInfoList.isEmpty());
+    }
+
     @VisibleForTesting
     boolean isAirplaneModeEnabled() {
         // Generic key since we only want the method check - no UI.
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 9659548..3578792 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -36,6 +36,7 @@
 import com.android.settings.R;
 import com.android.settings.core.FeatureFlags;
 import com.android.settings.dashboard.RestrictedDashboardFragment;
+import com.android.settings.datausage.BillingCyclePreferenceController;
 import com.android.settings.datausage.DataUsageSummaryPreferenceController;
 import com.android.settings.development.featureflags.FeatureFlagPersistent;
 import com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController;
@@ -134,6 +135,7 @@
           use(SmsDefaultSubscriptionController.class).init(getLifecycle());
           use(MobileNetworkSwitchController.class).init(getLifecycle(), mSubId);
           use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
+          use(BillingCyclePreferenceController.class).init(mSubId);
         }
         use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId);
         use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId);
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 42c1b93..939598b 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -177,7 +177,7 @@
      */
     public static boolean showEuiccSettings(Context context) {
         EuiccManager euiccManager =
-                (EuiccManager) context.getSystemService(Context.EUICC_SERVICE);
+                (EuiccManager) context.getSystemService(EuiccManager.class);
         if (!euiccManager.isEnabled()) {
             return false;
         }
@@ -185,7 +185,7 @@
         final ContentResolver cr = context.getContentResolver();
 
         TelephonyManager tm =
-                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+                (TelephonyManager) context.getSystemService(TelephonyManager.class);
         String currentCountry = tm.getNetworkCountryIso().toLowerCase();
         String supportedCountries =
                 Settings.Global.getString(cr, Settings.Global.EUICC_SUPPORTED_COUNTRIES);
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index 488f930..7a131d7 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -99,7 +99,8 @@
                             mSubId);
                     String newName = mNameView.getText().toString();
                     if (currentInfo != null && !currentInfo.getDisplayName().equals(newName)) {
-                        mSubscriptionManager.setDisplayName(newName, mSubId);
+                        mSubscriptionManager.setDisplayName(newName, mSubId,
+                                SubscriptionManager.NAME_SOURCE_USER_INPUT);
                     }
                 })
                 .setNegativeButton(android.R.string.cancel, null);
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 574b7dd..946f741 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -22,6 +22,7 @@
 import android.content.pm.ResolveInfo;
 import android.os.Looper;
 import android.os.PersistableBundle;
+import android.provider.Settings;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
 import android.telephony.CarrierConfigManager;
@@ -96,6 +97,10 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
+        Intent intent = mPreference.getIntent();
+        if (intent != null) {
+            intent.putExtra(Settings.EXTRA_SUB_ID, mSubId);
+        }
         if (!isAvailable()) {
             // Set category as invisible
             final Preference preferenceCateogry = screen.findPreference(KEY_PREFERENCE_CATEGORY);
diff --git a/src/com/android/settings/nfc/OWNERS b/src/com/android/settings/nfc/OWNERS
index f11f74f..2017826 100644
--- a/src/com/android/settings/nfc/OWNERS
+++ b/src/com/android/settings/nfc/OWNERS
@@ -1,5 +1,5 @@
 # Default reviewers for this and subdirectories.
-eisenbach@google.com
-kandoiruchi@google.com
+rmojumder@google.com
 
-# Emergency approvers in case the above are not available
\ No newline at end of file
+# Emergency approvers in case the above are not available
+zachoverflow@google.com
diff --git a/src/com/android/settings/nfc/SecureNfcEnabler.java b/src/com/android/settings/nfc/SecureNfcEnabler.java
index 065dc8b..9acaf64 100644
--- a/src/com/android/settings/nfc/SecureNfcEnabler.java
+++ b/src/com/android/settings/nfc/SecureNfcEnabler.java
@@ -46,7 +46,8 @@
                 mPreference.setEnabled(false);
                 break;
             case NfcAdapter.STATE_ON:
-                mPreference.setChecked(mPreference.isEnabled());
+                mPreference.setSummary(R.string.nfc_secure_toggle_summary);
+                mPreference.setChecked(mPreference.isChecked());
                 mPreference.setEnabled(true);
                 break;
             case NfcAdapter.STATE_TURNING_ON:
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 24d85e2..e056d67 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -50,7 +50,7 @@
     private static String KEY_ADVANCED_CATEGORY = "app_advanced";
     private static String KEY_BADGE = "badge";
     private static String KEY_APP_LINK = "app_link";
-    private static String KEY_BUBBLE = "bubble";
+    private static String KEY_BUBBLE = "bubble_link_pref";
     private static String[] LEGACY_NON_ADVANCED_KEYS = {KEY_BADGE, KEY_APP_LINK, KEY_BUBBLE};
 
     private List<NotificationChannelGroup> mChannelGroupList;
diff --git a/src/com/android/settings/notification/AssistantCapabilityPreferenceController.java b/src/com/android/settings/notification/AssistantCapabilityPreferenceController.java
index be90a04..812bc65 100644
--- a/src/com/android/settings/notification/AssistantCapabilityPreferenceController.java
+++ b/src/com/android/settings/notification/AssistantCapabilityPreferenceController.java
@@ -17,7 +17,6 @@
 package com.android.settings.notification;
 
 import android.content.Context;
-import android.os.UserHandle;
 import android.service.notification.Adjustment;
 
 import com.android.settings.core.TogglePreferenceController;
@@ -44,7 +43,7 @@
 
     @Override
     public boolean isChecked() {
-        List<String> capabilities = mBackend.getAssistantCapabilities(mContext.getPackageName());
+        List<String> capabilities = mBackend.getAssistantAdjustments(mContext.getPackageName());
         if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
            return capabilities.contains(Adjustment.KEY_IMPORTANCE);
         } else if (SMART_KEY.equals(getPreferenceKey())) {
@@ -57,10 +56,10 @@
     @Override
     public boolean setChecked(boolean isChecked) {
         if (PRIORITIZER_KEY.equals(getPreferenceKey())) {
-            mBackend.allowAssistantCapability(Adjustment.KEY_IMPORTANCE, isChecked);
+            mBackend.allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, isChecked);
         } else if (SMART_KEY.equals(getPreferenceKey())) {
-            mBackend.allowAssistantCapability(Adjustment.KEY_CONTEXTUAL_ACTIONS, isChecked);
-            mBackend.allowAssistantCapability(Adjustment.KEY_TEXT_REPLIES, isChecked);
+            mBackend.allowAssistantAdjustment(Adjustment.KEY_CONTEXTUAL_ACTIONS, isChecked);
+            mBackend.allowAssistantAdjustment(Adjustment.KEY_TEXT_REPLIES, isChecked);
         }
         return true;
     }
diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java
index 0955571..94a268b 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -50,12 +50,18 @@
         if (mAppRow == null) {
             return false;
         }
+        if (mAppRow.banned) {
+            return false;
+        }
         if (mChannel == null) {
             return false;
         }
         if (isDefaultChannel()) {
             return false;
         }
+        if (mChannelGroup != null && mChannelGroup.isBlocked()) {
+            return false;
+        }
         return true;
     }
 
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 4227050..765193b 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -339,21 +339,21 @@
         }
     }
 
-    public void allowAssistantCapability(String capability, boolean allowed) {
+    public void allowAssistantAdjustment(String capability, boolean allowed) {
         try {
             if (allowed) {
-                sINM.allowAssistantCapability(capability);
+                sINM.allowAssistantAdjustment(capability);
             } else {
-                sINM.disallowAssistantCapability(capability);
+                sINM.disallowAssistantAdjustment(capability);
             }
         } catch (Exception e) {
             Log.w(TAG, "Error calling NoMan", e);
         }
     }
 
-    public List<String> getAssistantCapabilities(String pkg) {
+    public List<String> getAssistantAdjustments(String pkg) {
         try {
-            return sINM.getAllowedAssistantCapabilities(pkg);
+            return sINM.getAllowedAssistantAdjustments(pkg);
         } catch (Exception e) {
             Log.w(TAG, "Error calling NoMan", e);
         }
diff --git a/src/com/android/settings/notification/NotificationPreferenceController.java b/src/com/android/settings/notification/NotificationPreferenceController.java
index d2b7c43..99f7e20 100644
--- a/src/com/android/settings/notification/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/NotificationPreferenceController.java
@@ -73,12 +73,12 @@
         if (mAppRow.banned) {
             return false;
         }
-        if (mChannel != null) {
-            return mChannel.getImportance() != IMPORTANCE_NONE;
-        }
         if (mChannelGroup != null) {
             return !mChannelGroup.isBlocked();
         }
+        if (mChannel != null) {
+            return mChannel.getImportance() != IMPORTANCE_NONE;
+        }
         return true;
     }
 
diff --git a/src/com/android/settings/panel/WifiPanel.java b/src/com/android/settings/panel/WifiPanel.java
index 6d83742..f9be081c 100644
--- a/src/com/android/settings/panel/WifiPanel.java
+++ b/src/com/android/settings/panel/WifiPanel.java
@@ -23,9 +23,9 @@
 
 import com.android.settings.R;
 import com.android.settings.SubSettings;
-import com.android.settings.network.NetworkDashboardFragment;
 import com.android.settings.slices.CustomSliceRegistry;
 import com.android.settings.slices.SliceBuilderUtils;
+import com.android.settings.wifi.WifiSettings;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -60,12 +60,12 @@
     @Override
     public Intent getSeeMoreIntent() {
         final String screenTitle =
-                mContext.getText(R.string.network_dashboard_title).toString();
+                mContext.getText(R.string.wifi_settings).toString();
         final Intent intent = SliceBuilderUtils.buildSearchResultPageIntent(mContext,
-                NetworkDashboardFragment.class.getName(),
+                WifiSettings.class.getName(),
                 null /* key */,
                 screenTitle,
-                SettingsEnums.SETTINGS_NETWORK_CATEGORY);
+                SettingsEnums.WIFI);
         intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
         return intent;
     }
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
index baefa09..7f09071 100644
--- a/src/com/android/settings/password/BiometricFragment.java
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -16,19 +16,21 @@
 
 package com.android.settings.password;
 
+import android.app.Activity;
 import android.app.settings.SettingsEnums;
 import android.content.DialogInterface;
 import android.hardware.biometrics.BiometricConstants;
 import android.hardware.biometrics.BiometricPrompt;
 import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
 import android.hardware.biometrics.BiometricPrompt.AuthenticationResult;
+import android.hardware.biometrics.IBiometricConfirmDeviceCredentialCallback;
 import android.os.Bundle;
 import android.os.CancellationSignal;
 import android.os.Handler;
 import android.os.Looper;
+import android.util.Log;
 
 import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
 
 import com.android.settings.R;
 import com.android.settings.core.InstrumentedFragment;
@@ -40,6 +42,8 @@
  */
 public class BiometricFragment extends InstrumentedFragment {
 
+    private static final String TAG = "ConfirmDeviceCredential/BiometricFragment";
+
     // Re-set by the application. Should be done upon orientation changes, etc
     private Executor mClientExecutor;
     private AuthenticationCallback mClientCallback;
@@ -48,7 +52,6 @@
     private int mUserId;
 
     // Created/Initialized once and retained
-    private final Handler mHandler = new Handler(Looper.getMainLooper());
     private Bundle mBundle;
     private BiometricPrompt mBiometricPrompt;
     private CancellationSignal mCancellationSignal;
@@ -82,6 +85,20 @@
         }
     };
 
+    // TODO(b/123378871): Remove when moved.
+    private final IBiometricConfirmDeviceCredentialCallback mCancelCallback
+        = new IBiometricConfirmDeviceCredentialCallback.Stub() {
+        @Override
+        public void cancel() {
+            final Activity activity = getActivity();
+            if (activity != null) {
+                activity.finish();
+            } else {
+                Log.e(TAG, "Activity null!");
+            }
+        }
+    };
+
     /**
      * @param bundle Bundle passed from {@link BiometricPrompt.Builder#buildIntent()}
      * @return
@@ -123,6 +140,7 @@
         mBiometricPrompt = new BiometricPrompt.Builder(getContext())
             .setTitle(mBundle.getString(BiometricPrompt.KEY_TITLE))
             .setUseDefaultTitle() // use default title if title is null/empty
+            .setFromConfirmDeviceCredential()
             .setSubtitle(mBundle.getString(BiometricPrompt.KEY_SUBTITLE))
             .setDescription(mBundle.getString(BiometricPrompt.KEY_DESCRIPTION))
             .setConfirmationRequired(
@@ -135,7 +153,7 @@
 
         // TODO: CC doesn't use crypto for now
         mBiometricPrompt.authenticateUser(mCancellationSignal, mClientExecutor,
-                mAuthenticationCallback, mUserId);
+                mAuthenticationCallback, mUserId, mCancelCallback);
     }
 
     @Override
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index d3d5c49..53841e8 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -106,13 +106,11 @@
     private AuthenticationCallback mAuthenticationCallback = new AuthenticationCallback() {
         public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
             if (!mGoingToBackground) {
-                if (errorCode == BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED) {
+                if (errorCode == BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED
+                        || errorCode == BiometricPrompt.BIOMETRIC_ERROR_CANCELED) {
                     if (mIsFallback) {
                         mBiometricManager.onConfirmDeviceCredentialError(
-                                BiometricConstants.BIOMETRIC_ERROR_USER_CANCELED,
-                                getString(
-                                        com.android.internal.R.string
-                                                .biometric_error_user_canceled));
+                                errorCode, getStringForError(errorCode));
                     }
                     finish();
                 } else {
@@ -139,6 +137,17 @@
         }
     };
 
+    private String getStringForError(int errorCode) {
+        switch (errorCode) {
+            case BiometricConstants.BIOMETRIC_ERROR_USER_CANCELED:
+                return getString(com.android.internal.R.string.biometric_error_user_canceled);
+            case BiometricConstants.BIOMETRIC_ERROR_CANCELED:
+                return getString(com.android.internal.R.string.biometric_error_canceled);
+            default:
+                return null;
+        }
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -178,7 +187,6 @@
                 intent.getBundleExtra(KeyguardManager.EXTRA_BIOMETRIC_PROMPT_BUNDLE);
         if (bpBundle != null) {
             mIsFallback = true;
-            // TODO: CDC maybe should show description as well.
             mTitle = bpBundle.getString(BiometricPrompt.KEY_TITLE);
             mDetails = bpBundle.getString(BiometricPrompt.KEY_SUBTITLE);
         } else {
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
index 82883ca..aa40d27 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialBaseActivity.java
@@ -19,6 +19,7 @@
 import android.app.KeyguardManager;
 import android.hardware.biometrics.BiometricConstants;
 import android.hardware.biometrics.BiometricManager;
+import android.hardware.biometrics.IBiometricConfirmDeviceCredentialCallback;
 import android.os.Bundle;
 import android.os.UserManager;
 import android.util.Log;
@@ -51,6 +52,15 @@
     private ConfirmCredentialTheme mConfirmCredentialTheme;
     private BiometricManager mBiometricManager;
 
+    // TODO(b/123378871): Remove when moved.
+    private final IBiometricConfirmDeviceCredentialCallback mCancelCallback
+            = new IBiometricConfirmDeviceCredentialCallback.Stub() {
+        @Override
+        public void cancel() {
+            finish();
+        }
+    };
+
     private boolean isInternalActivity() {
         return (this instanceof ConfirmLockPassword.InternalActivity)
                 || (this instanceof ConfirmLockPattern.InternalActivity);
@@ -81,6 +91,7 @@
         super.onCreate(savedState);
 
         mBiometricManager = getSystemService(BiometricManager.class);
+        mBiometricManager.registerCancellationCallback(mCancelCallback);
 
         if (mConfirmCredentialTheme == ConfirmCredentialTheme.NORMAL) {
             // Prevent the content parent from consuming the window insets because GlifLayout uses
diff --git a/src/com/android/settings/security/CredentialStorage.java b/src/com/android/settings/security/CredentialStorage.java
index 99937ee..0ea37b5 100644
--- a/src/com/android/settings/security/CredentialStorage.java
+++ b/src/com/android/settings/security/CredentialStorage.java
@@ -242,14 +242,20 @@
 
         @Override
         public void onDismiss(DialogInterface dialog) {
-            if (mResetConfirmed) {
-                mResetConfirmed = false;
-                if (confirmKeyGuard(CONFIRM_CLEAR_SYSTEM_CREDENTIAL_REQUEST)) {
-                    // will return password value via onActivityResult
-                    return;
-                }
+            if (!mResetConfirmed) {
+                finish();
+                return;
             }
-            finish();
+
+            mResetConfirmed = false;
+            if (!mUtils.isSecure(UserHandle.myUserId())) {
+                // This task will call finish() in the end.
+                new ResetKeyStoreAndKeyChain().execute();
+            } else if (!confirmKeyGuard(CONFIRM_CLEAR_SYSTEM_CREDENTIAL_REQUEST)) {
+                Log.w(TAG, "Failed to launch credential confirmation for a secure user.");
+                finish();
+            }
+            // Confirmation result will be handled in onActivityResult if needed.
         }
     }
 
diff --git a/src/com/android/settings/slices/SliceDataConverter.java b/src/com/android/settings/slices/SliceDataConverter.java
index db46c26..14abd1b 100644
--- a/src/com/android/settings/slices/SliceDataConverter.java
+++ b/src/com/android/settings/slices/SliceDataConverter.java
@@ -78,11 +78,8 @@
 
     private Context mContext;
 
-    private List<SliceData> mSliceData;
-
     public SliceDataConverter(Context context) {
         mContext = context;
-        mSliceData = new ArrayList<>();
     }
 
     /**
@@ -96,9 +93,7 @@
      * {@link com.android.settings.core.BasePreferenceController}.
      */
     public List<SliceData> getSliceData() {
-        if (!mSliceData.isEmpty()) {
-            return mSliceData;
-        }
+        List<SliceData> sliceData = new ArrayList<>();
 
         final Collection<Class> indexableClasses = FeatureFactory.getFactory(mContext)
                 .getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
@@ -117,12 +112,12 @@
 
             final List<SliceData> providerSliceData = getSliceDataFromProvider(provider,
                     fragmentName);
-            mSliceData.addAll(providerSliceData);
+            sliceData.addAll(providerSliceData);
         }
 
         final List<SliceData> a11ySliceData = getAccessibilitySliceData();
-        mSliceData.addAll(a11ySliceData);
-        return mSliceData;
+        sliceData.addAll(a11ySliceData);
+        return sliceData;
     }
 
     private List<SliceData> getSliceDataFromProvider(SearchIndexProvider provider,
diff --git a/src/com/android/settings/system/SystemUpdatePreferenceController.java b/src/com/android/settings/system/SystemUpdatePreferenceController.java
index dd04409..38a88b9 100644
--- a/src/com/android/settings/system/SystemUpdatePreferenceController.java
+++ b/src/com/android/settings/system/SystemUpdatePreferenceController.java
@@ -139,7 +139,8 @@
             }
             Log.d(TAG, "ciActionOnSysUpdate: broadcasting intent " + intentStr +
                     " with extra " + extra + ", " + extraVal);
+            intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
             mContext.getApplicationContext().sendBroadcast(intent);
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/users/MultiUserSwitchBarController.java b/src/com/android/settings/users/MultiUserSwitchBarController.java
index 58de149..a5fdf9b 100644
--- a/src/com/android/settings/users/MultiUserSwitchBarController.java
+++ b/src/com/android/settings/users/MultiUserSwitchBarController.java
@@ -52,6 +52,8 @@
         mListener = listener;
         mUserCapabilities = UserCapabilities.create(context);
         mSwitchBar.setChecked(mUserCapabilities.mUserSwitcherEnabled);
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.USER_SWITCHER_ENABLED, mSwitchBar.isChecked() ? 1 : 0);
 
         if (mUserCapabilities.mDisallowSwitchUser) {
             mSwitchBar.setDisabledByAdmin(RestrictedLockUtilsInternal
diff --git a/src/com/android/settings/vpn2/OWNERS b/src/com/android/settings/vpn2/OWNERS
new file mode 100644
index 0000000..0419e24
--- /dev/null
+++ b/src/com/android/settings/vpn2/OWNERS
@@ -0,0 +1,9 @@
+# People who can approve changes for submission.
+jchalard@google.com
+lorenzo@google.com
+maze@google.com
+reminv@google.com
+xiaom@google.com
+
+# Emergency approvers in case the above are not available
+satk@google.com
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index 2d88673..ca3e5cc 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -220,11 +220,15 @@
     private void initMediaPlayer() {
         if (mMediaPlayer == null) {
             mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
-            mMediaPlayer.seekTo(0);
-            mMediaPlayer.setOnSeekCompleteListener(mp -> mVideoReady = true);
-            mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
-            if (mSurface != null) {
-                mMediaPlayer.setSurface(mSurface);
+            // when the playback res is invalid or others, MediaPlayer create may fail
+            // and return null, so need add the null judgement.
+            if (mMediaPlayer != null) {
+                mMediaPlayer.seekTo(0);
+                mMediaPlayer.setOnSeekCompleteListener(mp -> mVideoReady = true);
+                mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
+                if (mSurface != null) {
+                    mMediaPlayer.setSurface(mSurface);
+                }
             }
         }
     }
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettings.java b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
index bc24416..1644b39 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettings.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
@@ -17,7 +17,9 @@
 package com.android.settings.wifi.calling;
 
 import android.app.settings.SettingsEnums;
+import android.content.Intent;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.util.Log;
@@ -25,6 +27,7 @@
 import android.view.View;
 import android.view.ViewGroup;
 
+import androidx.annotation.VisibleForTesting;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentPagerAdapter;
@@ -33,6 +36,7 @@
 import com.android.internal.util.CollectionUtils;
 import com.android.settings.R;
 import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.network.SubscriptionUtil;
 import com.android.settings.search.actionbar.SearchMenuController;
 import com.android.settings.support.actionbar.HelpMenuController;
 import com.android.settings.support.actionbar.HelpResourceProvider;
@@ -88,10 +92,30 @@
         mPagerAdapter = new WifiCallingViewPagerAdapter(getChildFragmentManager(), mViewPager);
         mViewPager.setAdapter(mPagerAdapter);
         mViewPager.addOnPageChangeListener(new InternalViewPagerListener());
-
+        maybeSetViewForSubId();
         return view;
     }
 
+    private void maybeSetViewForSubId() {
+        if (mSil == null) {
+            return;
+        }
+        Intent intent = getActivity().getIntent();
+        if (intent == null) {
+            return;
+        }
+        int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
+                SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+        if (SubscriptionManager.isValidSubscriptionId(subId)) {
+            for (SubscriptionInfo subInfo : mSil) {
+                if (subId == subInfo.getSubscriptionId()) {
+                    mViewPager.setCurrentItem(mSil.indexOf(subInfo));
+                    break;
+                }
+            }
+        }
+    }
+
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -122,7 +146,8 @@
         return R.string.help_uri_wifi_calling;
     }
 
-    private final class WifiCallingViewPagerAdapter extends FragmentPagerAdapter {
+    @VisibleForTesting
+    final class WifiCallingViewPagerAdapter extends FragmentPagerAdapter {
         private final RtlCompatibleViewPager mViewPager;
 
         public WifiCallingViewPagerAdapter(FragmentManager fragmentManager,
@@ -168,17 +193,22 @@
         }
     }
 
+    @VisibleForTesting
+    boolean isWfcEnabledByPlatform(SubscriptionInfo info) {
+        ImsManager imsManager = ImsManager.getInstance(getActivity(), info.getSimSlotIndex());
+        return imsManager.isWfcEnabledByPlatform();
+    }
+
     private void updateSubList() {
-        mSil = SubscriptionManager.from(getActivity()).getActiveSubscriptionInfoList(true);
+        mSil = SubscriptionUtil.getActiveSubscriptions(
+                getContext().getSystemService(SubscriptionManager.class));
 
         // Only config Wfc if it's enabled by platform.
         if (mSil == null) {
             return;
         }
         for (int i = 0; i < mSil.size(); ) {
-            ImsManager imsManager = ImsManager.getInstance(getActivity(),
-                    mSil.get(i).getSimSlotIndex());
-            if (!imsManager.isWfcEnabledByPlatform()) {
+            if (!isWfcEnabledByPlatform(mSil.get(i))) {
                 mSil.remove(i);
             } else {
                 i++;
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 525b59b..252193d 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -122,7 +122,8 @@
             final CarrierConfigManager configManager = (CarrierConfigManager)
                     activity.getSystemService(Context.CARRIER_CONFIG_SERVICE);
             if (configManager != null) {
-                PersistableBundle b = configManager.getConfigForSubId(mSubId);
+                PersistableBundle b =
+                        configManager.getConfigForSubId(WifiCallingSettingsForSub.this.mSubId);
                 if (b != null) {
                     isWfcModeEditable = b.getBoolean(
                             CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL);
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index cbb91a2..79b6383 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -401,6 +401,7 @@
                 .setButton1Icon(R.drawable.ic_settings_delete)
                 .setButton1OnClickListener(view -> forgetNetwork())
                 .setButton2Text(R.string.wifi_sign_in_button_text)
+                .setButton2Icon(R.drawable.ic_settings_sign_in)
                 .setButton2OnClickListener(view -> signIntoNetwork())
                 .setButton3Text(R.string.wifi_connect)
                 .setButton3Icon(R.drawable.ic_settings_wireless)
@@ -450,8 +451,7 @@
                         headerPref.findViewById(R.id.entity_header));
 
         ImageView iconView = headerPref.findViewById(R.id.entity_header_icon);
-        iconView.setBackground(
-                mContext.getDrawable(R.drawable.ic_settings_widget_background));
+
         iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
 
         mEntityHeaderController.setLabel(mAccessPoint.getTitle());
@@ -603,10 +603,9 @@
         mRssiSignalLevel = signalLevel;
         Drawable wifiIcon = mIconInjector.getIcon(mRssiSignalLevel);
 
-        wifiIcon.setTintList(Utils.getColorAccent(mContext));
         if (mEntityHeaderController != null) {
             mEntityHeaderController
-                    .setIcon(rescaleIconForHeader(wifiIcon)).done(mFragment.getActivity(),
+                    .setIcon(redrawIconForHeader(wifiIcon)).done(mFragment.getActivity(),
                             true /* rebind */);
         }
 
@@ -618,7 +617,7 @@
         mSignalStrengthPref.setVisible(true);
     }
 
-    private Drawable rescaleIconForHeader(Drawable original) {
+    private Drawable redrawIconForHeader(Drawable original) {
         final int iconSize = mContext.getResources().getDimensionPixelSize(
                 R.dimen.wifi_detail_page_header_image_size);
         final int actualWidth = original.getMinimumWidth();
@@ -629,10 +628,19 @@
             return original;
         }
 
+        // clear tint list to make sure can set 87% black after enlarge
+        original.setTintList(null);
+
+        // enlarge icon size
         final Bitmap bitmap = Utils.createBitmap(original,
                 iconSize /*width*/,
                 iconSize /*height*/);
-        return new BitmapDrawable(null /*resource*/, bitmap);
+        Drawable newIcon = new BitmapDrawable(null /*resource*/, bitmap);
+
+        // config color for 87% black after enlarge
+        newIcon.setTintList(Utils.getColorAttr(mContext, android.R.attr.textColorPrimary));
+
+        return newIcon;
     }
 
     private void refreshFrequency() {
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
index fa17f07..d0322b7 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
@@ -47,6 +47,7 @@
 
 import androidx.annotation.StringRes;
 import androidx.annotation.UiThread;
+import androidx.annotation.VisibleForTesting;
 import androidx.lifecycle.ViewModelProviders;
 
 import com.android.settings.R;
@@ -262,6 +263,24 @@
     }
 
     @Override
+    public void onPause() {
+        if (mCamera != null) {
+            mCamera.stop();
+        }
+
+        super.onPause();
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+
+        if (!isGoingInitiator()) {
+            restartCamera();
+        }
+    }
+
+    @Override
     public int getMetricsCategory() {
         if (mIsConfiguratorMode) {
             return SettingsEnums.SETTINGS_WIFI_DPP_CONFIGURATOR;
@@ -702,4 +721,9 @@
     public void onAccessPointsChanged() {
         // Do nothing.
     }
+
+    @VisibleForTesting
+    protected boolean isDecodeTaskAlive() {
+        return mCamera != null && mCamera.isDecodeTaskAlive();
+    }
 }
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 695de76..98673d4 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -128,18 +128,26 @@
         return intent;
     }
 
-    private static String getPresharedKey(WifiManager wifiManager, WifiConfiguration config) {
-        String preSharedKey = config.preSharedKey;
+    private static String getPresharedKey(WifiManager wifiManager,
+            WifiConfiguration wifiConfiguration) {
+        final List<WifiConfiguration> privilegedWifiConfiguratios =
+                wifiManager.getPrivilegedConfiguredNetworks();
 
-        final List<WifiConfiguration> wifiConfigs = wifiManager.getPrivilegedConfiguredNetworks();
-        for (WifiConfiguration wifiConfig : wifiConfigs) {
-            if (wifiConfig.networkId == config.networkId) {
-                preSharedKey = wifiConfig.preSharedKey;
-                break;
+        for (WifiConfiguration privilegedWifiConfiguration : privilegedWifiConfiguratios) {
+            if (privilegedWifiConfiguration.networkId == wifiConfiguration.networkId) {
+                // WEP uses a shared key hence the AuthAlgorithm.SHARED is used
+                // to identify it.
+                if (wifiConfiguration.allowedKeyManagement.get(KeyMgmt.NONE)
+                        && wifiConfiguration.allowedAuthAlgorithms.get(
+                        WifiConfiguration.AuthAlgorithm.SHARED)) {
+                    return privilegedWifiConfiguration
+                            .wepKeys[privilegedWifiConfiguration.wepTxKeyIndex];
+                } else {
+                    return privilegedWifiConfiguration.preSharedKey;
+                }
             }
         }
-
-        return preSharedKey;
+        return wifiConfiguration.preSharedKey;
     }
 
     private static String removeFirstAndLastDoubleQuotes(String str) {
@@ -268,14 +276,11 @@
             WifiConfiguration wifiConfiguration) {
         final String ssid = removeFirstAndLastDoubleQuotes(wifiConfiguration.SSID);
         final String security = getSecurityString(wifiConfiguration);
-        String preSharedKey = wifiConfiguration.preSharedKey;
 
-        if (preSharedKey != null) {
-            // When the value of this key is read, the actual key is not returned, just a "*".
-            // Call privileged system API to obtain actual key.
-            preSharedKey = removeFirstAndLastDoubleQuotes(getPresharedKey(wifiManager,
-                    wifiConfiguration));
-        }
+        // When the value of this key is read, the actual key is not returned, just a "*".
+        // Call privileged system API to obtain actual key.
+        final String preSharedKey = removeFirstAndLastDoubleQuotes(getPresharedKey(wifiManager,
+                wifiConfiguration));
 
         if (!TextUtils.isEmpty(ssid)) {
             intent.putExtra(EXTRA_WIFI_SSID, ssid);
diff --git a/src/com/android/settings/wifi/qrcode/QrCamera.java b/src/com/android/settings/wifi/qrcode/QrCamera.java
index 45de6b5..b7d41ba 100644
--- a/src/com/android/settings/wifi/qrcode/QrCamera.java
+++ b/src/com/android/settings/wifi/qrcode/QrCamera.java
@@ -401,4 +401,14 @@
             mScannerCallback.handleSuccessfulResult(qrCode.getText());
         }
     }
+
+    /**
+     * After {@link #start(SurfaceTexture)}, DecodingTask runs continuously to capture images and
+     * decode QR code. DecodingTask become null After {@link #stop()}.
+     *
+     * Uses this method in test case to prevent power consumption problem.
+     */
+    public boolean isDecodeTaskAlive() {
+        return mDecodeTask != null;
+    }
 }
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index cacecd6..78c3c08 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -78,11 +78,6 @@
         <item>fake_package/fake_service</item>
     </string-array>
 
-    <!-- Settings intelligence interaction log intent action -->
-    <string name="config_settingsintelligence_log_action" translatable="false">
-        aaa.bbb.ccc
-    </string>
-
     <!-- List of packages that should be whitelisted for slice uri access. Do not translate -->
     <string-array name="slice_whitelist_package_names" translatable="false">
         <item>com.android.settings.slice_whitelist_package</item>
diff --git a/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java b/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java
index 304dfe9..277f63e 100644
--- a/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppStateInstallAppsBridgeTest.java
@@ -33,8 +33,10 @@
             new AppStateInstallAppsBridge.InstallAppsState();
         assertThat(appState.canInstallApps()).isFalse();
 
-        appState.permissionGranted = true;
         appState.permissionRequested = true;
+        assertThat(appState.canInstallApps()).isFalse();
+
+        appState.appOpMode = AppOpsManager.MODE_ALLOWED;
         assertThat(appState.canInstallApps()).isTrue();
 
         appState.appOpMode = AppOpsManager.MODE_ERRORED;
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
index 56e59f7..e46cd06 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
@@ -282,6 +282,13 @@
     }
 
     @Test
+    public void getPreferenceControllers_exiting_shouldReturnNull() {
+        mFragment.mFinishing = true;
+
+        assertThat(mFragment.createPreferenceControllers(mShadowContext)).isNull();
+    }
+
+    @Test
     public void getNumberOfUserWithPackageInstalled_twoUsersInstalled_shouldReturnTwo()
             throws PackageManager.NameNotFoundException {
         final String packageName = "Package1";
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinishTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinishTest.java
new file mode 100644
index 0000000..74b35c9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFinishTest.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2019 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.biometrics.fingerprint;
+
+import static com.android.settings.biometrics.fingerprint.FingerprintEnrollFinish.FINGERPRINT_SUGGESTION_ACTIVITY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.RuntimeEnvironment.application;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.FingerprintManager;
+
+import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowFingerprintManager;
+
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.FooterBarMixin;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowActivity;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowFingerprintManager.class})
+public class SetupFingerprintEnrollFinishTest {
+
+    private FingerprintEnrollFinish mActivity;
+    private ComponentName mComponentName;
+    private PartnerCustomizationLayout mLayout;
+    private FingerprintManager mFingerprintManager;
+
+    @Before
+    public void setUp() {
+        mActivity = Robolectric.buildActivity(FingerprintEnrollFinish.class).setup().get();
+        mLayout = mActivity.findViewById(R.id.setup_wizard_layout);
+        Shadows.shadowOf(application.getPackageManager())
+                .setSystemFeature(PackageManager.FEATURE_FINGERPRINT, true);
+
+        mFingerprintManager = (FingerprintManager) application.getSystemService(
+                Context.FINGERPRINT_SERVICE);
+        Shadows.shadowOf(mFingerprintManager).setIsHardwareDetected(true);
+
+        mComponentName = new ComponentName(
+                application, FINGERPRINT_SUGGESTION_ACTIVITY);
+    }
+
+    @Test
+    public void clickAddAnother_shouldLaunchEnrolling() {
+        final ComponentName enrollingComponent = new ComponentName(
+                application,
+                FingerprintEnrollEnrolling.class);
+
+        mLayout.getMixin(FooterBarMixin.class).getSecondaryButtonView().performClick();
+
+        ShadowActivity.IntentForResult startedActivity =
+                Shadows.shadowOf(mActivity).getNextStartedActivityForResult();
+        assertThat(startedActivity).named("Next activity").isNotNull();
+        assertThat(startedActivity.intent.getComponent())
+                .isEqualTo(enrollingComponent);
+    }
+
+    @Test
+    public void clickAddAnother_shouldPropagateResults() {
+        final ComponentName enrollingComponent = new ComponentName(
+                application,
+                FingerprintEnrollEnrolling.class);
+
+        mLayout.getMixin(FooterBarMixin.class).getSecondaryButtonView().performClick();
+
+        ShadowActivity.IntentForResult startedActivity =
+                Shadows.shadowOf(mActivity).getNextStartedActivityForResult();
+        assertThat(startedActivity).named("Next activity").isNotNull();
+        assertThat(startedActivity.intent.getComponent())
+                .isEqualTo(enrollingComponent);
+    }
+
+    @Test
+    public void clickNext_shouldFinish() {
+        mLayout.getMixin(FooterBarMixin.class).getPrimaryButtonView().performClick();
+
+        assertThat(mActivity.isFinishing()).isTrue();
+    }
+
+    @Test
+    public void onActivityResult_fingerprintCountIsNotOne_fingerprintSuggestionActivityDisabled() {
+        Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(0);
+
+        mActivity.onActivityResult(0, 0, null);
+
+        assertThat(application.getPackageManager().getComponentEnabledSetting(
+                mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
+    }
+
+    @Test
+    public void onActivityResult_fingerprintCountIsOne_fingerprintSuggestionActivityEnabled() {
+        Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(1);
+
+        mActivity.onActivityResult(0, 0, null);
+
+        assertThat(application.getPackageManager().getComponentEnabledSetting(
+                mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
+    }
+
+    @Test
+    public void clickNext_fingerprintCountIsNotOne_fingerprintSuggestionActivityDisabled() {
+        Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(2);
+
+        mLayout.getMixin(FooterBarMixin.class).getPrimaryButtonView().performClick();
+
+        assertThat(application.getPackageManager().getComponentEnabledSetting(
+                mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
+    }
+
+    @Test
+    public void clickNext_fingerprintCountIsOne_fngerprintSuggestionActivityEnabled() {
+        Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(1);
+
+        mLayout.getMixin(FooterBarMixin.class).getPrimaryButtonView().performClick();
+
+        assertThat(application.getPackageManager().getComponentEnabledSetting(
+                mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
+    }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index b961669..362b003 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -104,14 +104,14 @@
     @Test
     public void refresh_connected_updateCorrectInfo() {
         when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_UNTHETHERED_LEFT_BATTERY)).thenReturn(
-                String.valueOf(BATTERY_LEVEL_LEFT));
+                BluetoothDevice.METADATA_UNTETHERED_LEFT_BATTERY)).thenReturn(
+                String.valueOf(BATTERY_LEVEL_LEFT).getBytes());
         when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_UNTHETHERED_RIGHT_BATTERY)).thenReturn(
-                String.valueOf(BATTERY_LEVEL_RIGHT));
+                BluetoothDevice.METADATA_UNTETHERED_RIGHT_BATTERY)).thenReturn(
+                String.valueOf(BATTERY_LEVEL_RIGHT).getBytes());
         when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_UNTHETHERED_CASE_BATTERY)).thenReturn(
-                String.valueOf(BATTERY_LEVEL_MAIN));
+                BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY)).thenReturn(
+                String.valueOf(BATTERY_LEVEL_MAIN).getBytes());
         when(mCachedDevice.isConnected()).thenReturn(true);
         mController.refresh();
 
@@ -141,18 +141,18 @@
     }
 
     @Test
-    public void getAvailabilityStatus_unthetheredHeadset_returnAvailable() {
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
-                .thenReturn("true");
+    public void getAvailabilityStatus_untetheredHeadset_returnAvailable() {
+        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+                .thenReturn("true".getBytes());
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(
                 BasePreferenceController.AVAILABLE);
     }
 
     @Test
-    public void getAvailabilityStatus_notUnthetheredHeadset_returnUnavailable() {
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
-                .thenReturn("false");
+    public void getAvailabilityStatus_notUntetheredHeadset_returnUnavailable() {
+        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+                .thenReturn("false".getBytes());
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(
                 BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
@@ -169,44 +169,58 @@
 
     @Test
     public void onStart_isAvailable_registerCallback() {
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
-                .thenReturn("true");
+        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+                .thenReturn("true".getBytes());
 
         mController.onStart();
 
-        verify(mBluetoothAdapter).registerMetadataListener(mBluetoothDevice,
-                mController.mMetadataListener, mController.mHandler);
+        verify(mBluetoothAdapter).addOnMetadataChangedListener(mBluetoothDevice,
+                mContext.getMainExecutor() ,mController.mMetadataListener);
     }
 
     @Test
     public void onStop_isAvailable_unregisterCallback() {
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
-                .thenReturn("true");
+        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+                .thenReturn("true".getBytes());
 
         mController.onStop();
 
-        verify(mBluetoothAdapter).unregisterMetadataListener(mBluetoothDevice);
+        verify(mBluetoothAdapter).removeOnMetadataChangedListener(mBluetoothDevice,
+                mController.mMetadataListener);
     }
 
     @Test
     public void onStart_notAvailable_registerCallback() {
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
-                .thenReturn("false");
+        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+                .thenReturn("false".getBytes());
 
         mController.onStart();
 
-        verify(mBluetoothAdapter, never()).registerMetadataListener(mBluetoothDevice,
-                mController.mMetadataListener, mController.mHandler);
+        verify(mBluetoothAdapter, never()).addOnMetadataChangedListener(mBluetoothDevice,
+                mContext.getMainExecutor() ,mController.mMetadataListener);
     }
 
     @Test
     public void onStop_notAvailable_unregisterCallback() {
-        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
-                .thenReturn("false");
+        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+                .thenReturn("false".getBytes());
 
         mController.onStop();
 
-        verify(mBluetoothAdapter, never()).unregisterMetadataListener(mBluetoothDevice);
+        verify(mBluetoothAdapter, never()).removeOnMetadataChangedListener(mBluetoothDevice,
+                mController.mMetadataListener);
+    }
+
+    @Test
+    public void onDestroy_isAvailable_recycleBitmap() {
+        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
+                .thenReturn("true".getBytes());
+        mController.mIconCache.put(ICON_URI, mBitmap);
+
+        mController.onDestroy();
+
+        assertThat(mController.mIconCache).isEmpty();
+        verify(mBitmap).recycle();
     }
 
     private void assertBatteryLevel(LinearLayout linearLayout, int batteryLevel) {
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
index cf119ea..1ee1de6 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
@@ -123,9 +123,9 @@
     }
 
     @Test
-    public void isAvailable_unthetheredHeadset_returnFalse() {
+    public void isAvailable_untetheredHeadset_returnFalse() {
         when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET)).thenReturn("true");
+                BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn("true".getBytes());
 
         assertThat(mController.isAvailable()).isFalse();
     }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothFeatureProviderImplTest.java
index a921215..9ab1d87 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothFeatureProviderImplTest.java
@@ -49,7 +49,8 @@
     @Test
     public void getBluetoothDeviceSettingsUri_containCorrectMacAddress() {
         when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_ENHANCED_SETTINGS_UI_URI)).thenReturn(SETTINGS_URI);
+                BluetoothDevice.METADATA_ENHANCED_SETTINGS_UI_URI)).thenReturn(
+                SETTINGS_URI.getBytes());
         final Uri uri = mBluetoothFeatureProvider.getBluetoothDeviceSettingsUri(mBluetoothDevice);
         assertThat(uri.toString()).isEqualTo(SETTINGS_URI);
     }
diff --git a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
index ee79d61..1920019 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
@@ -43,14 +43,8 @@
 @RunWith(RobolectricTestRunner.class)
 public class UtilsTest {
 
-    private static final String STRING_METADATA = "string_metadata";
-    private static final String BOOL_METADATA = "true";
-    private static final String INT_METADATA = "25";
-
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Context mContext;
-    @Mock
-    private BluetoothDevice mBluetoothDevice;
 
     private MetricsFeatureProvider mMetricsFeatureProvider;
 
@@ -69,41 +63,4 @@
         verify(mMetricsFeatureProvider).visible(eq(mContext), anyInt(),
                 eq(MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT_ERROR));
     }
-
-    @Test
-    public void getStringMetaData_hasMetaData_getCorrectMetaData() {
-        when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_UNTHETHERED_LEFT_ICON)).thenReturn(STRING_METADATA);
-
-        assertThat(Utils.getStringMetaData(mBluetoothDevice,
-                BluetoothDevice.METADATA_UNTHETHERED_LEFT_ICON)).isEqualTo(STRING_METADATA);
-    }
-
-    @Test
-    public void getIntMetaData_hasMetaData_getCorrectMetaData() {
-        when(mBluetoothDevice.getMetadata(
-            BluetoothDevice.METADATA_UNTHETHERED_LEFT_BATTERY)).thenReturn(INT_METADATA);
-
-        assertThat(Utils.getIntMetaData(mBluetoothDevice,
-            BluetoothDevice.METADATA_UNTHETHERED_LEFT_BATTERY))
-            .isEqualTo(Integer.parseInt(INT_METADATA));
-    }
-
-    @Test
-    public void getIntMetaData_invalidMetaData_getErrorCode() {
-        when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_UNTHETHERED_LEFT_BATTERY)).thenReturn(STRING_METADATA);
-
-        assertThat(Utils.getIntMetaData(mBluetoothDevice,
-                BluetoothDevice.METADATA_UNTHETHERED_LEFT_ICON)).isEqualTo(Utils.META_INT_ERROR);
-    }
-
-    @Test
-    public void getBooleanMetaData_hasMetaData_getCorrectMetaData() {
-        when(mBluetoothDevice.getMetadata(
-                BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET)).thenReturn(BOOL_METADATA);
-
-        assertThat(Utils.getBooleanMetaData(mBluetoothDevice,
-                BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET)).isEqualTo(true);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java
index 23d794c..d16a6d2 100644
--- a/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java
@@ -39,14 +39,13 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.robolectric.annotation.Config;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
 @RunWith(RobolectricTestRunner.class)
 public class TopLevelDisplayPreferenceControllerTest {
     private Context mContext;
@@ -89,6 +88,19 @@
     }
 
     @Test
+    public void getSummary_hasWallpaperWithStyles_shouldReturnWallpaperSummary() {
+        when(mContext.getString(R.string.config_styles_and_wallpaper_picker_class))
+                .thenReturn("any.nonempty.class");
+        final List<ResolveInfo> resolveInfos = new ArrayList<>();
+        resolveInfos.add(mock(ResolveInfo.class));
+        when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
+                .thenReturn(resolveInfos);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.display_dashboard_summary_with_style));
+    }
+
+    @Test
     public void getSummary_hasWallpaper_shouldReturnNoWallpaperSummary() {
         final List<ResolveInfo> resolveInfos = new ArrayList<>();
         when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
diff --git a/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
index a641b19..ca9dfcc 100644
--- a/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/WallpaperPreferenceControllerTest.java
@@ -18,74 +18,132 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import android.content.Context;
+import android.content.ComponentName;
 import android.content.Intent;
-import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.Preference;
+
 import com.android.settings.R;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+
+import com.google.common.collect.Lists;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowPackageManager;
 
 @RunWith(RobolectricTestRunner.class)
+@Config(shadows = {SettingsShadowResources.class})
 public class WallpaperPreferenceControllerTest {
-
-    private static final String WALLPAPER_PACKAGE = "TestPkg";
-    private static final String WALLPAPER_CLASS = "TestCls";
     private static final String TEST_KEY = "test_key";
 
-    @Mock
-    private Context mContext;
-    @Mock
-    private PackageManager mPackageManager;
+    private Intent mWallpaperIntent;
+    private Intent mStylesAndWallpaperIntent;
+    private FragmentActivity mContext;
+    private ShadowPackageManager mShadowPackageManager;
 
     private WallpaperPreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        when(mContext.getString(R.string.config_wallpaper_picker_package))
-                .thenReturn(WALLPAPER_PACKAGE);
-        when(mContext.getString(R.string.config_wallpaper_picker_class))
-                .thenReturn(WALLPAPER_CLASS);
-        when(mContext.getPackageManager()).thenReturn(mPackageManager);
-
+        mContext = Robolectric.buildActivity(FragmentActivity.class).get();
+        SettingsShadowResources.overrideResource(
+                R.string.config_wallpaper_picker_package, "bogus.package.for.testing");
+        SettingsShadowResources.overrideResource(
+                R.string.config_styles_and_wallpaper_picker_class, "bogus.package.class");
+        mWallpaperIntent =  new Intent().setComponent(new ComponentName(
+                mContext.getString(R.string.config_wallpaper_picker_package),
+                mContext.getString(R.string.config_wallpaper_picker_class)));
+        mStylesAndWallpaperIntent = new Intent().setComponent(new ComponentName(
+                mContext.getString(R.string.config_wallpaper_picker_package),
+                mContext.getString(R.string.config_styles_and_wallpaper_picker_class)));
+        mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
         mController = new WallpaperPreferenceController(mContext, TEST_KEY);
     }
 
     @Test
     public void isAvailable_wallpaperPickerEnabled_shouldReturnTrue() {
-        final List<ResolveInfo> resolveInfos = new ArrayList<>();
-        resolveInfos.add(mock(ResolveInfo.class));
-        when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
-                .thenReturn(resolveInfos);
+        mShadowPackageManager.setResolveInfosForIntent(
+                mWallpaperIntent, Lists.newArrayList(mock(ResolveInfo.class)));
 
         assertThat(mController.isAvailable()).isTrue();
     }
 
     @Test
     public void isAvailable_wallpaperPickerDisabled_shouldReturnFalse() {
-        when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt())).thenReturn(null);
+        mShadowPackageManager.setResolveInfosForIntent(
+                mWallpaperIntent, Lists.newArrayList());
 
         assertThat(mController.isAvailable()).isFalse();
+    }
 
-        final List<ResolveInfo> resolveInfos = new ArrayList<>();
-        when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
-                .thenReturn(resolveInfos);
+    @Test
+    public void areStylesAvailable_noComponentSpecified() {
+        SettingsShadowResources.overrideResource(
+                R.string.config_styles_and_wallpaper_picker_class, "");
+        mShadowPackageManager.setResolveInfosForIntent(
+                mStylesAndWallpaperIntent, Lists.newArrayList());
 
-        assertThat(mController.isAvailable()).isFalse();
+        assertThat(mController.areStylesAvailable()).isFalse();
+    }
+
+    @Test
+    public void areStylesAvailable_componentUnresolveable() {
+        mShadowPackageManager.setResolveInfosForIntent(
+                mStylesAndWallpaperIntent, Lists.newArrayList());
+
+        assertThat(mController.areStylesAvailable()).isFalse();
+    }
+
+    @Test
+    public void areStylesAvailable_componentResolved() {
+        mShadowPackageManager.setResolveInfosForIntent(
+                mStylesAndWallpaperIntent,
+                Lists.newArrayList(mock(ResolveInfo.class)));
+
+        assertThat(mController.areStylesAvailable()).isTrue();
+    }
+
+    @Test
+    public void handlePreferenceTreeClick_wallpaperOnly() {
+        mShadowPackageManager.setResolveInfosForIntent(
+                mWallpaperIntent, Lists.newArrayList(mock(ResolveInfo.class)));
+        mShadowPackageManager.setResolveInfosForIntent(
+                mStylesAndWallpaperIntent, Lists.newArrayList());
+        Preference preference = new Preference(mContext);
+        preference.setKey(TEST_KEY);
+
+        mController.handlePreferenceTreeClick(preference);
+
+        assertThat(Shadows.shadowOf(mContext)
+                .getNextStartedActivityForResult().intent.getComponent().getClassName())
+                .isEqualTo(mContext.getString(R.string.config_wallpaper_picker_class));
+    }
+
+    @Test
+    public void handlePreferenceTreeClick_stylesAndWallpaper() {
+        mShadowPackageManager.setResolveInfosForIntent(
+                mWallpaperIntent, Lists.newArrayList());
+        mShadowPackageManager.setResolveInfosForIntent(
+                mStylesAndWallpaperIntent, Lists.newArrayList(mock(ResolveInfo.class)));
+        Preference preference = new Preference(mContext);
+        preference.setKey(TEST_KEY);
+
+        mController.handlePreferenceTreeClick(preference);
+
+        assertThat(Shadows.shadowOf(mContext)
+                .getNextStartedActivityForResult().intent.getComponent().getClassName())
+                .isEqualTo(mContext.getString(R.string.config_styles_and_wallpaper_picker_class));
     }
 }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java
deleted file mode 100644
index 0683bd8..0000000
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.homepage.contextualcards;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.UserHandle;
-
-import com.android.settings.intelligence.ContextualCardProto.ContextualCardList;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class ContextualCardFeatureProviderImplTest {
-
-    private Context mContext;
-    private ContextualCardFeatureProviderImpl mImpl;
-
-    @Before
-    public void setUp() {
-        mContext = spy(RuntimeEnvironment.application);
-        mImpl = new ContextualCardFeatureProviderImpl(mContext);
-    }
-
-    @Test
-    public void sendBroadcast_emptyAction_notSendBroadcast() {
-        final Intent intent = new Intent();
-        mImpl.sendBroadcast(intent);
-
-        verify(mContext, never()).sendBroadcastAsUser(intent, UserHandle.CURRENT);
-    }
-
-    @Test
-    @Config(qualifiers = "mcc999")
-    public void sendBroadcast_hasAction_sendBroadcast() {
-        final Intent intent = new Intent();
-        mImpl.sendBroadcast(intent);
-
-        verify(mContext).sendBroadcastAsUser(intent, UserHandle.CURRENT);
-    }
-
-    @Test
-    @Config(qualifiers = "mcc999")
-    public void logContextualCardDisplay_hasAction_sendBroadcast() {
-        mImpl.logContextualCardDisplay(new ArrayList<>(), new ArrayList<>());
-
-        verify(mContext).sendBroadcastAsUser(any(Intent.class), any());
-    }
-
-    @Test
-    public void serialize_hasSizeTwo_returnSizeTwo() {
-        final List<ContextualCard> cards = new ArrayList<>();
-        cards.add(new ContextualCard.Builder()
-                .setName("name1")
-                .setSliceUri(Uri.parse("uri1"))
-                .build());
-        cards.add(new ContextualCard.Builder()
-                .setName("name2")
-                .setSliceUri(Uri.parse("uri2"))
-                .build());
-
-
-        final byte[] data = mImpl.serialize(cards);
-
-        try {
-            assertThat(ContextualCardList
-                    .parseFrom(data).getCardCount()).isEqualTo(cards.size());
-        } catch (Exception e) {
-            throw new RuntimeException(e.getMessage());
-        }
-    }
-}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
index 40e6939..f025ee8 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
@@ -22,12 +22,15 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.eq;
 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 android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.net.Uri;
 
@@ -182,8 +185,10 @@
 
         mContextualCardLoader.getDisplayableCards(new ArrayList<>());
 
-        verify(mFakeFeatureFactory.mContextualCardFeatureProvider).logContextualCardDisplay(
-                anyList(), anyList());
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(any(),
+                eq(SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW), any(String.class));
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(any(),
+                eq(SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW), any(String.class));
     }
 
     @Test
@@ -192,8 +197,8 @@
 
         mContextualCardLoader.getDisplayableCards(new ArrayList<>());
 
-        verify(mFakeFeatureFactory.mContextualCardFeatureProvider, never())
-                .logContextualCardDisplay(anyList(), anyList());
+        verify(mFakeFeatureFactory.metricsFeatureProvider, never()).action(any(),
+                eq(SettingsEnums.ACTION_CONTEXTUAL_CARD_SHOW), any(String.class));
     }
 
     private ContextualCard getContextualCard(String sliceUri) {
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
index 9759f98..895492e 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
@@ -26,7 +26,9 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyMap;
 import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.atLeast;
 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.times;
@@ -38,6 +40,7 @@
 import android.provider.Settings;
 import android.util.ArrayMap;
 
+import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardController;
 import com.android.settings.homepage.contextualcards.conditional.ConditionFooterContextualCard;
 import com.android.settings.homepage.contextualcards.conditional.ConditionHeaderContextualCard;
 import com.android.settings.homepage.contextualcards.conditional.ConditionalContextualCard;
@@ -45,6 +48,8 @@
 import com.android.settings.slices.CustomSliceRegistry;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -312,6 +317,74 @@
     }
 
     @Test
+    public void onWindowFocusChanged_hasFocusAndNoConditional_startMonitoringConditionCard() {
+        final ContextualCardManager manager = spy(mManager);
+        final ControllerRendererPool pool = spy(mManager.mControllerRendererPool);
+        doReturn(pool).when(manager).getControllerRendererPool();
+        final ConditionContextualCardController conditionController =
+                pool.getController(mContext,
+                        ContextualCard.CardType.CONDITIONAL);
+        final OnStart controller = spy((OnStart)conditionController);
+        doReturn(controller).when(pool).getController(mContext, ContextualCard.CardType.CONDITIONAL);
+
+        manager.onWindowFocusChanged(true /* hasWindowFocus */);
+
+        verify(controller, atLeast(1)).onStart();
+    }
+
+    @Test
+    public void onWindowFocusChanged_hasFocusAndHasConditionals_startMonitoringConditionCard() {
+        mManager.mContextualCards.add(new ConditionalContextualCard.Builder().build());
+        mManager.mContextualCards.add(new ConditionFooterContextualCard.Builder().build());
+        final ContextualCardManager manager = spy(mManager);
+        final ControllerRendererPool pool = spy(mManager.mControllerRendererPool);
+        doReturn(pool).when(manager).getControllerRendererPool();
+        final ConditionContextualCardController conditionController =
+                pool.getController(mContext,
+                        ContextualCard.CardType.CONDITIONAL);
+        final OnStart controller = spy((OnStart)conditionController);
+        doReturn(controller).when(pool).getController(mContext, ContextualCard.CardType.CONDITIONAL);
+
+        manager.onWindowFocusChanged(true /* hasWindowFocus */);
+
+        verify(controller, atLeast(2)).onStart();
+    }
+
+    @Test
+    public void onWindowFocusChanged_loseFocusAndHasConditionals_stopMonitoringConditionCard() {
+        mManager.mContextualCards.add(new ConditionalContextualCard.Builder().build());
+        mManager.mContextualCards.add(new ConditionFooterContextualCard.Builder().build());
+        final ContextualCardManager manager = spy(mManager);
+        final ControllerRendererPool pool = spy(mManager.mControllerRendererPool);
+        doReturn(pool).when(manager).getControllerRendererPool();
+        final ConditionContextualCardController conditionController =
+                pool.getController(mContext,
+                        ContextualCard.CardType.CONDITIONAL);
+        final OnStop controller = spy((OnStop) conditionController);
+        doReturn(controller).when(pool).getController(mContext, ContextualCard.CardType.CONDITIONAL);
+
+        manager.onWindowFocusChanged(false /* hasWindowFocus */);
+
+        verify(controller, atLeast(2)).onStop();
+    }
+
+    @Test
+    public void onWindowFocusChanged_loseFocusAndNoConditional_stopMonitoringConditionCard() {
+        final ContextualCardManager manager = spy(mManager);
+        final ControllerRendererPool pool = spy(mManager.mControllerRendererPool);
+        doReturn(pool).when(manager).getControllerRendererPool();
+        final ConditionContextualCardController conditionController =
+                pool.getController(mContext,
+                        ContextualCard.CardType.CONDITIONAL);
+        final OnStop controller = spy((OnStop) conditionController);
+        doReturn(controller).when(pool).getController(mContext, ContextualCard.CardType.CONDITIONAL);
+
+        manager.onWindowFocusChanged(false /* hasWindowFocus */);
+
+        verify(controller, atLeast(1)).onStop();
+    }
+
+    @Test
     public void getCardsWithViewType_noSuggestionCards_shouldNotHaveHalfCards() {
         final List<Integer> categories = Arrays.asList(
                 ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/logging/ContextualCardLogUtilsTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/logging/ContextualCardLogUtilsTest.java
new file mode 100644
index 0000000..5207315
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/logging/ContextualCardLogUtilsTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.homepage.contextualcards.logging;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.net.Uri;
+
+import com.android.settings.homepage.contextualcards.ContextualCard;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class ContextualCardLogUtilsTest {
+
+    private static final String TEST_URI = "content://test/test2";
+    private static final double TEST_SCORE = 0.12345f;
+
+    private static final ContextualCard TEST_CARD =
+            new ContextualCard.Builder()
+                    .setSliceUri(Uri.parse(TEST_URI))
+                    .setRankingScore(TEST_SCORE)
+                    .build();
+
+    @Test
+    public void parseCardDismissLog_notValid_returnNull() {
+        assertThat(ContextualCardLogUtils.parseCardDismissLog(TEST_URI + "|" + TEST_URI)).isNull();
+    }
+
+    @Test
+    public void parseCardDismissLog_isValid_returnCorrectData() {
+        final String log = ContextualCardLogUtils.buildCardDismissLog(TEST_CARD);
+
+        final ContextualCardLogUtils.CardLog cardLog = ContextualCardLogUtils.parseCardDismissLog(
+                log);
+
+        assertThat(cardLog.getSliceUri()).isEqualTo(TEST_URI);
+        assertThat(cardLog.getRankingScore()).isEqualTo(TEST_SCORE);
+    }
+
+    @Test
+    public void parseCardClickLog_isValid_returnCorrectData() {
+        final int row = 1;
+        final int target = 2;
+        final int position = 3;
+        final String log = ContextualCardLogUtils.buildCardClickLog(TEST_CARD, row, target,
+                position);
+
+        final ContextualCardLogUtils.CardClickLog cardClickLog =
+                ContextualCardLogUtils.parseCardClickLog(log);
+
+        assertThat(cardClickLog.getSliceUri()).isEqualTo(TEST_URI);
+        assertThat(cardClickLog.getRankingScore()).isEqualTo(TEST_SCORE);
+        assertThat(cardClickLog.getSliceRow()).isEqualTo(row);
+        assertThat(cardClickLog.getSliceTapTarget()).isEqualTo(
+                ContextualCardLogUtils.actionTypeToTapTarget(target));
+        assertThat(cardClickLog.getUiPosition()).isEqualTo(position);
+    }
+
+    @Test
+    public void parseCardClickList_isValid_returnCorrectData() {
+        final ContextualCard testcard =
+                new ContextualCard.Builder()
+                        .setSliceUri(Uri.parse("testtest"))
+                        .setRankingScore(-1d)
+                        .build();
+        final List<ContextualCard> cardList = new ArrayList<>();
+        cardList.add(TEST_CARD);
+        cardList.add(testcard);
+        final String log = ContextualCardLogUtils.buildCardListLog(cardList);
+
+        final List<ContextualCardLogUtils.CardLog> cardClickLogList =
+                ContextualCardLogUtils.parseCardListLog(log);
+
+        assertThat(cardClickLogList.size()).isEqualTo(2);
+        assertThat(cardClickLogList.get(0).getSliceUri()).isEqualTo(TEST_URI);
+        assertThat(cardClickLogList.get(0).getRankingScore()).isEqualTo(TEST_SCORE);
+        assertThat(cardClickLogList.get(1).getSliceUri()).isEqualTo("testtest");
+        assertThat(cardClickLogList.get(1).getRankingScore()).isEqualTo(-1d);
+    }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
index e97e01e..51d2523 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
@@ -18,17 +18,23 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.settings.SettingsEnums;
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
+import android.os.Build;
 
+import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.CardContentProvider;
 import com.android.settings.homepage.contextualcards.CardDatabaseHelper;
 import com.android.settings.homepage.contextualcards.ContextualCard;
@@ -48,6 +54,7 @@
 import org.robolectric.shadows.ShadowActivity;
 import org.robolectric.shadows.ShadowContentResolver;
 import org.robolectric.shadows.androidx.fragment.FragmentController;
+import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
 public class SliceContextualCardControllerTest {
@@ -91,15 +98,17 @@
         cr.close();
 
         assertThat(qryDismissed).isEqualTo(1);
-        verify(mFeatureFactory.mContextualCardFeatureProvider).logContextualCardDismiss(card);
+        verify(mFeatureFactory.metricsFeatureProvider).action(any(),
+                eq(SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS), any(String.class));
     }
 
     @Test
-    public void onDismissed_noFeedbackEmail_shouldNotShowFeedbackDialog() {
+    public void onDismissed_feedbackDisabled_shouldNotShowFeedbackDialog() {
         mResolver.insert(CardContentProvider.REFRESH_CARD_URI, generateOneRow());
         final ContextualCardsFragment fragment =
                 FragmentController.of(new ContextualCardsFragment()).create().get();
         final ShadowActivity shadowActivity = Shadows.shadowOf(fragment.getActivity());
+        doReturn(false).when(mController).isFeedbackEnabled(anyString());
 
         mController.onDismissed(getTestSliceCard());
 
@@ -107,12 +116,12 @@
     }
 
     @Test
-    @Config(qualifiers = "mcc999")
-    public void onDismissed_hasFeedbackEmail_shouldShowFeedbackDialog() {
+    public void onDismissed_feedbackEnabled_shouldShowFeedbackDialog() {
         mResolver.insert(CardContentProvider.REFRESH_CARD_URI, generateOneRow());
         final ContextualCardsFragment fragment =
                 FragmentController.of(new ContextualCardsFragment()).create().get();
         final ShadowActivity shadowActivity = Shadows.shadowOf(fragment.getActivity());
+        doReturn(true).when(mController).isFeedbackEnabled(anyString());
 
         mController.onDismissed(getTestSliceCard());
 
@@ -120,6 +129,40 @@
                 .isEqualTo(ContextualCardFeedbackDialog.class.getName());
     }
 
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void isFeedbackEnabled_hasFeedbackEmail_debug_returnTrue() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isTrue();
+    }
+
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void isFeedbackEnabled_hasFeedbackEmail_user_returnFalse() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isFalse();
+    }
+
+    @Test
+    public void isFeedbackEnabled_noFeedbackEmail_debug_returnFalse() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isFalse();
+    }
+
+    @Test
+    public void isFeedbackEnabled_noFeedbackEmail_user_returnFalse() {
+        ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false);
+        final String email = mContext.getString(R.string.config_contextual_card_feedback_email);
+
+        assertThat(mController.isFeedbackEnabled(email)).isFalse();
+    }
+
     private ContentValues generateOneRow() {
         final ContentValues values = new ContentValues();
         values.put(CardDatabaseHelper.CardColumns.NAME, TEST_CARD_NAME);
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
index 706f238..fff1765 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
@@ -28,14 +28,12 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.Button;
-import android.widget.ViewFlipper;
 
 import androidx.lifecycle.LifecycleOwner;
 import androidx.lifecycle.LiveData;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.slice.Slice;
-import androidx.slice.widget.SliceView;
 
 import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.ContextualCard;
@@ -116,16 +114,15 @@
     }
 
     @Test
-    public void bindView_isPendingDismiss_shouldFlipToDismissalView() {
+    public void bindView_isPendingDismiss_shouldShowDismissalView() {
         final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
-        final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
         final View dismissalView = viewHolder.itemView.findViewById(R.id.dismissal_view);
         final ContextualCard card = buildContextualCard(
                 TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
 
         mRenderer.bindView(viewHolder, card);
 
-        assertThat(viewFlipper.getCurrentView()).isEqualTo(dismissalView);
+        assertThat(dismissalView.getVisibility()).isEqualTo(View.VISIBLE);
     }
 
     @Test
@@ -140,24 +137,29 @@
     }
 
     @Test
-    public void viewClick_keepCard_shouldFlipBackToSlice() {
+    public void viewClick_keepCard_shouldShowSlice() {
         final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+        final View sliceView = viewHolder.itemView.findViewById(R.id.slice_view);
+        final View dismissalView = viewHolder.itemView.findViewById(R.id.dismissal_view);
         final Button btnKeep = viewHolder.itemView.findViewById(R.id.keep);
-        final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
-        mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
-        viewFlipper.setDisplayedChild(1);
+        final ContextualCard card = buildContextualCard(
+                TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
+        mRenderer.bindView(viewHolder, card);
 
         btnKeep.performClick();
 
-        assertThat(viewFlipper.getCurrentView()).isInstanceOf(SliceView.class);
+        assertThat(dismissalView.getVisibility()).isEqualTo(View.GONE);
+        assertThat(sliceView.getVisibility()).isEqualTo(View.VISIBLE);
     }
 
     @Test
     public void viewClick_keepCard_shouldRemoveViewHolderFromSet() {
         final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
         final Button btnKeep = viewHolder.itemView.findViewById(R.id.keep);
-        mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
-        mRenderer.mFlippedCardSet.add(viewHolder);
+        final ContextualCard card = buildContextualCard(
+                TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
+        mRenderer.bindView(viewHolder, card);
+        assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
 
         btnKeep.performClick();
 
@@ -168,11 +170,12 @@
     public void viewClick_removeCard_shouldRemoveViewHolderFromSet() {
         final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
         final Button btnRemove = viewHolder.itemView.findViewById(R.id.remove);
-        final ContextualCard contextualCard = buildContextualCard(TEST_SLICE_URI);
-        mRenderer.bindView(viewHolder, contextualCard);
+        final ContextualCard card = buildContextualCard(
+                TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
+        mRenderer.bindView(viewHolder, card);
+        assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
         doReturn(mController).when(mControllerRendererPool).getController(mActivity,
                 ContextualCard.CardType.SLICE);
-        mRenderer.mFlippedCardSet.add(viewHolder);
 
         btnRemove.performClick();
 
@@ -195,16 +198,19 @@
     }
 
     @Test
-    public void onStop_cardIsFlipped_shouldFlipBack() {
+    public void onStop_cardIsInDismissalView_shouldResetToSliceView() {
         final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
-        final ViewFlipper viewFlipper = viewHolder.itemView.findViewById(R.id.view_flipper);
-        mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
-        viewFlipper.setDisplayedChild(1);
-        mRenderer.mFlippedCardSet.add(viewHolder);
+        final View sliceView = viewHolder.itemView.findViewById(R.id.slice_view);
+        final View dismissalView = viewHolder.itemView.findViewById(R.id.dismissal_view);
+        final ContextualCard card = buildContextualCard(
+                TEST_SLICE_URI).mutate().setIsPendingDismiss(true).build();
+        mRenderer.bindView(viewHolder, card);
+        assertThat(mRenderer.mFlippedCardSet).contains(viewHolder);
 
         mRenderer.onStop();
 
-        assertThat(viewFlipper.getCurrentView()).isInstanceOf(SliceView.class);
+        assertThat(sliceView.getVisibility()).isEqualTo(View.VISIBLE);
+        assertThat(dismissalView.getVisibility()).isEqualTo(View.GONE);
     }
 
     private RecyclerView.ViewHolder getSliceViewHolder() {
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegateTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegateTest.java
index 00b7815..8338ae4 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegateTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SwipeDismissalDelegateTest.java
@@ -28,7 +28,6 @@
 import android.app.Activity;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.widget.ViewFlipper;
 
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
@@ -68,7 +67,7 @@
         activityController.create();
         mRecyclerView = new RecyclerView(mActivity);
         mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
-        mDismissalDelegate = new SwipeDismissalDelegate(mActivity, mDismissalDelegateListener);
+        mDismissalDelegate = new SwipeDismissalDelegate(mDismissalDelegateListener);
     }
 
     @Test
@@ -86,22 +85,16 @@
     @Test
     public void getMovementFlags_dismissalView_shouldDisableSwipe() {
         final RecyclerView.ViewHolder holder = getSliceViewHolder();
-        final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
-        viewFlipper.showNext();
-        final View dismissalView = holder.itemView.findViewById(R.id.dismissal_view);
+        holder.itemView.findViewById(R.id.dismissal_view).setVisibility(View.VISIBLE);
 
-        assertThat(viewFlipper.getCurrentView()).isEqualTo(dismissalView);
         assertThat(mDismissalDelegate.getMovementFlags(mRecyclerView, holder)).isEqualTo(0);
     }
 
     @Test
     public void getMovementFlags_SliceViewHolder_shouldEnableSwipe() {
         final RecyclerView.ViewHolder holder = getSliceViewHolder();
-        final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
-        viewFlipper.setDisplayedChild(0);
-        final View sliceView = holder.itemView.findViewById(R.id.slice_view);
+        holder.itemView.findViewById(R.id.dismissal_view).setVisibility(View.GONE);
 
-        assertThat(viewFlipper.getCurrentView()).isEqualTo(sliceView);
         assertThat(mDismissalDelegate.getMovementFlags(mRecyclerView, getSliceViewHolder()))
                 .isNotEqualTo(0);
     }
diff --git a/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
index 75d6f82..c6709ed 100644
--- a/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java
@@ -31,6 +31,7 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.provider.Settings;
+import android.util.ArrayMap;
 
 import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.Preference;
@@ -53,15 +54,20 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @RunWith(RobolectricTestRunner.class)
 @Config(shadows = ShadowUserManager.class)
 public class LocationServicePreferenceControllerTest {
+    private static final String LOCATION_SERVICES_MANAGED_PROFILE_KEY =
+            "location_services_managed_profile";
 
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private LocationSettings mFragment;
     @Mock
-    private PreferenceCategory mCategory;
+    private PreferenceCategory mCategoryPrimary;
+    @Mock
+    private PreferenceCategory mCategoryManaged;
     @Mock
     private PreferenceScreen mScreen;
     @Mock
@@ -83,27 +89,16 @@
         mController = spy(new LocationServicePreferenceController(
                 mContext, mFragment, mLifecycle, mSettingsInjector));
         final String key = mController.getPreferenceKey();
-        when(mScreen.findPreference(key)).thenReturn(mCategory);
-        when(mCategory.getKey()).thenReturn(key);
+        when(mScreen.findPreference(key)).thenReturn(mCategoryPrimary);
+        when(mScreen.findPreference(LOCATION_SERVICES_MANAGED_PROFILE_KEY)).thenReturn(
+                mCategoryManaged);
+        when(mCategoryPrimary.getKey()).thenReturn(key);
+        when(mCategoryManaged.getKey()).thenReturn(LOCATION_SERVICES_MANAGED_PROFILE_KEY);
         when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
                 .thenReturn(mDevicePolicyManager);
     }
 
     @Test
-    public void isAvailable_noInjectedSettings_shouldReturnFalse() {
-        doReturn(false).when(mSettingsInjector).hasInjectedSettings(anyInt());
-
-        assertThat(mController.isAvailable()).isFalse();
-    }
-
-    @Test
-    public void isAvailable_hasInjectedSettings_shouldReturnFalse() {
-        doReturn(true).when(mSettingsInjector).hasInjectedSettings(anyInt());
-
-        assertThat(mController.isAvailable()).isTrue();
-    }
-
-    @Test
     public void onResume_shouldRegisterListener() {
         mController.onResume();
 
@@ -122,24 +117,26 @@
     @Test
     public void updateState_shouldRemoveAllAndAddInjectedSettings() {
         final List<Preference> preferences = new ArrayList<>();
+        final Map<Integer, List<Preference>> map = new ArrayMap<>();
         final Preference pref1 = new Preference(mContext);
         pref1.setTitle("Title1");
         final Preference pref2 = new Preference(mContext);
         pref2.setTitle("Title2");
         preferences.add(pref1);
         preferences.add(pref2);
-        doReturn(preferences)
-            .when(mSettingsInjector).getInjectedSettings(any(Context.class), anyInt());
+        map.put(UserHandle.myUserId(), preferences);
+        doReturn(map)
+                .when(mSettingsInjector).getInjectedSettings(any(Context.class), anyInt());
         when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
         ShadowUserManager.getShadow().setProfileIdsWithDisabled(new int[]{UserHandle.myUserId()});
 
         mController.displayPreference(mScreen);
 
-        mController.updateState(mCategory);
+        mController.updateState(mCategoryPrimary);
 
-        verify(mCategory).removeAll();
-        verify(mCategory).addPreference(pref1);
-        verify(mCategory).addPreference(pref2);
+        verify(mCategoryPrimary).removeAll();
+        verify(mCategoryPrimary).addPreference(pref1);
+        verify(mCategoryPrimary).addPreference(pref2);
     }
 
     @Test
@@ -161,7 +158,7 @@
         when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(componentName);
 
         mController.displayPreference(mScreen);
-        mController.updateState(mCategory);
+        mController.updateState(mCategoryPrimary);
         verify(mSettingsInjector).getInjectedSettings(
                 any(Context.class), eq(UserHandle.myUserId()));
     }
@@ -181,7 +178,7 @@
                 enforcingUsers);
 
         mController.displayPreference(mScreen);
-        mController.updateState(mCategory);
+        mController.updateState(mCategoryPrimary);
         verify(mSettingsInjector).getInjectedSettings(
                 any(Context.class), eq(UserHandle.USER_CURRENT));
     }
@@ -200,7 +197,9 @@
                 UserManager.DISALLOW_CONFIG_LOCATION);
         pref.setTitle("Location Accuracy");
         preferences.add(pref);
-        doReturn(preferences).when(mSettingsInjector)
+        final Map<Integer, List<Preference>> map = new ArrayMap<>();
+        map.put(UserHandle.myUserId(), preferences);
+        doReturn(map).when(mSettingsInjector)
                 .getInjectedSettings(any(Context.class), anyInt());
         ShadowUserManager.getShadow().setProfileIdsWithDisabled(new int[]{UserHandle.myUserId()});
 
@@ -217,7 +216,7 @@
         when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(componentName);
 
         mController.displayPreference(mScreen);
-        mController.updateState(mCategory);
+        mController.updateState(mCategoryPrimary);
 
         assertThat(pref.isEnabled()).isFalse();
         assertThat(pref.isDisabledByAdmin()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java
index 10264ab..342fed5 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkListControllerTest.java
@@ -21,7 +21,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
@@ -31,7 +30,9 @@
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+import android.provider.Settings;
 import android.telephony.SubscriptionInfo;
+import android.telephony.TelephonyManager;
 import android.telephony.euicc.EuiccManager;
 
 import org.junit.After;
@@ -53,6 +54,8 @@
 @RunWith(RobolectricTestRunner.class)
 public class MobileNetworkListControllerTest {
     @Mock
+    TelephonyManager mTelephonyManager;
+    @Mock
     EuiccManager mEuiccManager;
 
     @Mock
@@ -69,7 +72,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(Robolectric.setupActivity(Activity.class));
+        when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
         when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1);
         when(mPreferenceScreen.getContext()).thenReturn(mContext);
         mAddMorePreference = new Preference(mContext);
         when(mPreferenceScreen.findPreference(MobileNetworkListController.KEY_ADD_MORE)).thenReturn(
@@ -99,6 +104,7 @@
     @Test
     public void displayPreference_eSimSupported_addMoreLinkIsVisible() {
         when(mEuiccManager.isEnabled()).thenReturn(true);
+        when(mTelephonyManager.getNetworkCountryIso()).thenReturn("");
         mController.displayPreference(mPreferenceScreen);
         mController.onResume();
         assertThat(mAddMorePreference.isVisible()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
index 3404ca2..8bcf8b6 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
@@ -33,6 +33,7 @@
 import android.net.ConnectivityManager;
 import android.provider.Settings;
 import android.telephony.SubscriptionInfo;
+import android.telephony.TelephonyManager;
 import android.telephony.euicc.EuiccManager;
 import android.text.TextUtils;
 
@@ -59,6 +60,8 @@
     @Mock
     private Lifecycle mLifecycle;
     @Mock
+    private TelephonyManager mTelephonyManager;
+    @Mock
     private EuiccManager mEuiccManager;
     @Mock
     private PreferenceScreen mPreferenceScreen;
@@ -71,8 +74,11 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(Robolectric.setupActivity(Activity.class));
+        when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
         when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
+        when(mTelephonyManager.getNetworkCountryIso()).thenReturn("");
         when(mEuiccManager.isEnabled()).thenReturn(true);
+        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.EUICC_PROVISIONED, 1);
 
         mController = new MobileNetworkSummaryController(mContext, mLifecycle);
         mPreference = spy(new AddPreference(mContext, null));
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index dbc122a..c074466 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -18,6 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -108,4 +109,32 @@
         assertThat(subs.get(0).getSubscriptionId()).isEqualTo(1);
         assertThat(subs.get(1).getSubscriptionId()).isEqualTo(4);
     }
+
+    @Test
+    public void getActiveSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
+        when(mManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(null);
+        final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mManager);
+        assertThat(subs).isNotNull();
+        assertThat(subs).isEmpty();
+    }
+
+    @Test
+    public void getActiveSubscriptions_oneSubscription_oneResult() {
+        final SubscriptionInfo info = mock(SubscriptionInfo.class);
+        when(mManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(Arrays.asList(info));
+        final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mManager);
+        assertThat(subs).isNotNull();
+        assertThat(subs).hasSize(1);
+    }
+
+    @Test
+    public void getActiveSubscriptions_twoSubscriptions_twoResults() {
+        final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
+        final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
+        when(mManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(
+                Arrays.asList(info1, info2));
+        final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mManager);
+        assertThat(subs).isNotNull();
+        assertThat(subs).hasSize(2);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index 97966b3..26f26ff 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -103,19 +103,19 @@
 
     @After
     public void tearDown() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(null);
+        SubscriptionUtil.setActiveSubscriptionsForTesting(null);
     }
 
     @Test
     public void isAvailable_oneSubscription_availableFalse() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(
+        SubscriptionUtil.setActiveSubscriptionsForTesting(
                 Arrays.asList(mock(SubscriptionInfo.class)));
         assertThat(mController.isAvailable()).isFalse();
     }
 
     @Test
     public void isAvailable_twoSubscriptions_availableTrue() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(
+        SubscriptionUtil.setActiveSubscriptionsForTesting(
                 Arrays.asList(mock(SubscriptionInfo.class), mock(SubscriptionInfo.class)));
         assertThat(mController.isAvailable()).isTrue();
     }
@@ -126,13 +126,13 @@
         for (int i = 0; i < 5; i++) {
             subs.add(mock(SubscriptionInfo.class));
         }
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(subs);
+        SubscriptionUtil.setActiveSubscriptionsForTesting(subs);
         assertThat(mController.isAvailable()).isTrue();
     }
 
     @Test
     public void isAvailable_airplaneModeOn_availableFalse() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(
+        SubscriptionUtil.setActiveSubscriptionsForTesting(
                 Arrays.asList(mock(SubscriptionInfo.class), mock(SubscriptionInfo.class)));
         assertThat(mController.isAvailable()).isTrue();
         Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
@@ -141,7 +141,7 @@
 
     @Test
     public void onAirplaneModeChanged_airplaneModeTurnedOn_eventFired() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(
+        SubscriptionUtil.setActiveSubscriptionsForTesting(
                 Arrays.asList(mock(SubscriptionInfo.class), mock(SubscriptionInfo.class)));
         mController.onResume();
         mController.displayPreference(mScreen);
@@ -157,7 +157,7 @@
     @Test
     public void onAirplaneModeChanged_airplaneModeTurnedOff_eventFired() {
         Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(
+        SubscriptionUtil.setActiveSubscriptionsForTesting(
                 Arrays.asList(mock(SubscriptionInfo.class), mock(SubscriptionInfo.class)));
         mController.onResume();
         mController.displayPreference(mScreen);
@@ -174,13 +174,13 @@
     public void onSubscriptionsChanged_countBecameTwo_eventFired() {
         final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
         final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
         mController.onResume();
         mController.displayPreference(mScreen);
         assertThat(mController.isAvailable()).isFalse();
 
         final int updateCountBeforeSubscriptionChange = mOnChildUpdatedCount;
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         mController.onSubscriptionsChanged();
         assertThat(mController.isAvailable()).isTrue();
         assertThat(mOnChildUpdatedCount).isEqualTo(updateCountBeforeSubscriptionChange + 1);
@@ -192,14 +192,14 @@
         final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
         when(sub1.getSubscriptionId()).thenReturn(1);
         when(sub2.getSubscriptionId()).thenReturn(2);
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         mController.onResume();
         mController.displayPreference(mScreen);
         assertThat(mController.isAvailable()).isTrue();
         verify(mPreferenceCategory, times(2)).addPreference(any(Preference.class));
 
         final int updateCountBeforeSubscriptionChange = mOnChildUpdatedCount;
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
         mController.onSubscriptionsChanged();
         assertThat(mController.isAvailable()).isFalse();
         assertThat(mOnChildUpdatedCount).isEqualTo(updateCountBeforeSubscriptionChange + 1);
@@ -221,7 +221,7 @@
         when(sub3.getSubscriptionId()).thenReturn(3);
 
         // Start out with only sub1 and sub2.
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         mController.onResume();
         mController.displayPreference(mScreen);
         final ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -233,7 +233,7 @@
         // Now replace sub2 with sub3, and make sure the old preference was removed and the new
         // preference was added.
         final int updateCountBeforeSubscriptionChange = mOnChildUpdatedCount;
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub3));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub3));
         mController.onSubscriptionsChanged();
         assertThat(mController.isAvailable()).isTrue();
         assertThat(mOnChildUpdatedCount).isEqualTo(updateCountBeforeSubscriptionChange + 1);
@@ -259,7 +259,7 @@
             doReturn(i + 1).when(sub).getSubscriptionId();
             subscriptions.add(sub);
         }
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(subscriptions);
+        SubscriptionUtil.setActiveSubscriptionsForTesting(subscriptions);
         mController.displayPreference(mScreen);
         final ArgumentCaptor<Preference> prefCaptor = ArgumentCaptor.forClass(Preference.class);
         verify(mPreferenceCategory, times(subscriptionCount)).addPreference(prefCaptor.capture());
@@ -303,7 +303,7 @@
         final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
         when(sub1.getSubscriptionId()).thenReturn(11);
         when(sub2.getSubscriptionId()).thenReturn(22);
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
 
         ShadowSubscriptionManager.setDefaultDataSubscriptionId(11);
         ShadowSubscriptionManager.setDefaultSmsSubscriptionId(11);
@@ -324,7 +324,7 @@
         final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
         when(sub1.getSubscriptionId()).thenReturn(11);
         when(sub2.getSubscriptionId()).thenReturn(22);
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
 
         ShadowSubscriptionManager.setDefaultVoiceSubscriptionId(11);
         ShadowSubscriptionManager.setDefaultSmsSubscriptionId(11);
@@ -346,7 +346,7 @@
         final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
         when(sub1.getSubscriptionId()).thenReturn(11);
         when(sub2.getSubscriptionId()).thenReturn(22);
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
 
         ShadowSubscriptionManager.setDefaultDataSubscriptionId(11);
         ShadowSubscriptionManager.setDefaultSmsSubscriptionId(22);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
index e503d70..7dd636a 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
@@ -73,19 +73,19 @@
 
     @After
     public void tearDown() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(null);
+        SubscriptionUtil.setActiveSubscriptionsForTesting(null);
     }
 
     @Test
     public void getAvailabilityStatus_onlyOneSubscription_notAvailable() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(
                 createMockSub(1, "sub1")));
         assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
     }
 
     @Test
     public void getAvailabilityStatus_twoSubscriptions_isAvailable() {
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(
                 createMockSub(1, "sub1"),
                 createMockSub(2, "sub2")));
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
@@ -95,7 +95,7 @@
     public void displayPreference_twoSubscriptionsSub1Default_correctListPreferenceValues() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
@@ -123,7 +123,7 @@
     public void displayPreference_twoSubscriptionsSub2Default_correctListPreferenceValues() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         doReturn(sub2.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
@@ -156,7 +156,7 @@
         // Mark sub2 as opportunistic; then it should not appear in the list of entries/entryValues.
         when(sub2.isOpportunistic()).thenReturn(true);
 
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2, sub3));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2, sub3));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
@@ -179,7 +179,7 @@
     public void onPreferenceChange_prefChangedToSub2_callbackCalledCorrectly() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
@@ -192,7 +192,7 @@
     public void onPreferenceChange_prefChangedToAlwaysAsk_callbackCalledCorrectly() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
@@ -207,7 +207,7 @@
     public void onSubscriptionsChanged_twoSubscriptionsDefaultChanges_selectedEntryGetsUpdated() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
@@ -224,14 +224,14 @@
     public void onSubscriptionsChanged_goFromTwoSubscriptionsToOne_prefDisappears() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
         assertThat(mController.isAvailable()).isTrue();
         assertThat(mListPreference.isVisible()).isTrue();
 
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
         mController.onSubscriptionsChanged();
 
         assertThat(mController.isAvailable()).isFalse();
@@ -242,14 +242,14 @@
     public void onSubscriptionsChanged_goFromOneSubscriptionToTwo_prefAppears() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
         assertThat(mController.isAvailable()).isFalse();
         assertThat(mListPreference.isVisible()).isFalse();
 
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         mController.onSubscriptionsChanged();
 
         assertThat(mController.isAvailable()).isTrue();
@@ -261,13 +261,13 @@
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
         final SubscriptionInfo sub2 = createMockSub(222, "sub2");
         final SubscriptionInfo sub3 = createMockSub(333, "sub3");
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
         doReturn(sub1.getSubscriptionId()).when(mController).getDefaultSubscriptionId();
 
         mController.displayPreference(mScreen);
         assertThat(mListPreference.getEntries().length).isEqualTo(3);
 
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2, sub3));
+        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2, sub3));
         mController.onSubscriptionsChanged();
 
         assertThat(mController.isAvailable()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
index e488d0c..e59fbaf 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
@@ -49,6 +49,8 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
@@ -76,6 +78,9 @@
         doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
         doReturn(SUB_ID).when(mSubscriptionInfo).getSubscriptionId();
+        doReturn(new ArrayList<>(Arrays.asList(mSubscriptionInfo)))
+                .when(mSubscriptionManager).getSelectableSubscriptionInfoList();
+
 
         // Set-up specs for SliceMetadata.
         SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -165,6 +170,24 @@
     }
 
     @Test
+    public void isMobileDataAvailable_noSubscriptions_returnsNull() {
+        doReturn(new ArrayList<>()).when(mSubscriptionManager).getSelectableSubscriptionInfoList();
+
+        final Slice slice = mMobileDataSlice.getSlice();
+
+        assertThat(slice).isNull();
+    }
+
+    @Test
+    public void isMobileDataAvailable_nullSubscriptions_returnsNull() {
+        doReturn(null).when(mSubscriptionManager).getSelectableSubscriptionInfoList();
+
+        final Slice slice = mMobileDataSlice.getSlice();
+
+        assertThat(slice).isNull();
+    }
+
+    @Test
     public void airplaneModeEnabled_slicePrimaryActionIsEmpty() {
         doReturn(true).when(mMobileDataSlice).isAirplaneModeEnabled();
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
index df52302..70816ea 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
@@ -102,7 +102,7 @@
         final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
         negativeButton.performClick();
 
-        verify(mSubscriptionMgr, never()).setDisplayName(anyString(), anyInt());
+        verify(mSubscriptionMgr, never()).setDisplayName(anyString(), anyInt(), anyInt());
     }
 
     @Test
@@ -118,7 +118,8 @@
         positiveButton.performClick();
 
         final ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-        verify(mSubscriptionMgr).setDisplayName(captor.capture(), eq(mSubscriptionId));
+        verify(mSubscriptionMgr).setDisplayName(captor.capture(), eq(mSubscriptionId),
+                eq(SubscriptionManager.NAME_SOURCE_USER_INPUT));
         assertThat(captor.getValue()).isEqualTo("test2");
     }
 
diff --git a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
index 9eb62f6..1a0126e 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
@@ -24,7 +24,9 @@
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.content.Intent;
 import android.os.PersistableBundle;
+import android.provider.Settings;
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
@@ -88,6 +90,8 @@
         when(mPreferenceScreen.findPreference(
                 WifiCallingPreferenceController.KEY_PREFERENCE_CATEGORY)).thenReturn(
                 mPreferenceCategory);
+        when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+                mPreference);
     }
 
     @Test
@@ -159,6 +163,15 @@
     }
 
     @Test
+    public void displayPreference_available_setsSubscriptionIdOnIntent() {
+        Intent intent = new Intent();
+        mPreference.setIntent(intent);
+        mController.displayPreference(mPreferenceScreen);
+        assertThat(intent.getIntExtra(Settings.EXTRA_SUB_ID,
+                SubscriptionManager.INVALID_SUBSCRIPTION_ID)).isEqualTo(SUB_ID);
+    }
+
+    @Test
     public void getAvailabilityStatus_noWiFiCalling_shouldReturnUnsupported() {
         mController.init(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
 
diff --git a/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java
index 182ce8a..397b72e 100644
--- a/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/AssistantCapabilityPreferenceControllerTest.java
@@ -101,7 +101,7 @@
     public void isChecked_prioritizerSettingIsOff_false() {
         List<String> capabilities = new ArrayList<>();
         capabilities.add(Adjustment.KEY_USER_SENTIMENT);
-        when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
+        when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
         assertThat(mPrioritizerController.isChecked()).isFalse();
     }
 
@@ -109,7 +109,7 @@
     public void isChecked_prioritizerSettingIsOn_true() {
         List<String> capabilities = new ArrayList<>();
         capabilities.add(Adjustment.KEY_IMPORTANCE);
-        when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
+        when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
         assertThat(mPrioritizerController.isChecked()).isTrue();
     }
 
@@ -117,17 +117,17 @@
     public void isChecked_chipSettingIsOff_false() {
         List<String> capabilities = new ArrayList<>();
         capabilities.add(Adjustment.KEY_IMPORTANCE);
-        when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
+        when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
         assertThat(mChipController.isChecked()).isFalse();
 
         capabilities = new ArrayList<>();
         capabilities.add(Adjustment.KEY_CONTEXTUAL_ACTIONS);
-        when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
+        when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
         assertThat(mChipController.isChecked()).isFalse();
 
         capabilities = new ArrayList<>();
         capabilities.add(Adjustment.KEY_TEXT_REPLIES);
-        when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
+        when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
         assertThat(mChipController.isChecked()).isFalse();
     }
 
@@ -136,34 +136,34 @@
         List<String> capabilities = new ArrayList<>();
         capabilities.add(Adjustment.KEY_TEXT_REPLIES);
         capabilities.add(Adjustment.KEY_CONTEXTUAL_ACTIONS);
-        when(mBackend.getAssistantCapabilities(anyString())).thenReturn(capabilities);
+        when(mBackend.getAssistantAdjustments(anyString())).thenReturn(capabilities);
         assertThat(mChipController.isChecked()).isTrue();
     }
 
     @Test
     public void onPreferenceChange_prioritizerOn() {
         mPrioritizerController.onPreferenceChange(mPrioritizerPreference, true);
-        verify(mBackend).allowAssistantCapability(Adjustment.KEY_IMPORTANCE, true);
+        verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, true);
     }
 
     @Test
     public void onPreferenceChange_prioritizerOff() {
         mPrioritizerController.onPreferenceChange(mPrioritizerPreference, false);
-        verify(mBackend).allowAssistantCapability(Adjustment.KEY_IMPORTANCE, false);
+        verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_IMPORTANCE, false);
     }
 
     @Test
     public void onPreferenceChange_chipsOn() {
         mChipController.onPreferenceChange(mChipPreference, true);
-        verify(mBackend).allowAssistantCapability(Adjustment.KEY_CONTEXTUAL_ACTIONS, true);
-        verify(mBackend).allowAssistantCapability(Adjustment.KEY_TEXT_REPLIES, true);
+        verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_CONTEXTUAL_ACTIONS, true);
+        verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_TEXT_REPLIES, true);
     }
 
     @Test
     public void onPreferenceChange_chipsOff() {
         mChipController.onPreferenceChange(mChipPreference, false);
-        verify(mBackend).allowAssistantCapability(Adjustment.KEY_CONTEXTUAL_ACTIONS, false);
-        verify(mBackend).allowAssistantCapability(Adjustment.KEY_TEXT_REPLIES, false);
+        verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_CONTEXTUAL_ACTIONS, false);
+        verify(mBackend).allowAssistantAdjustment(Adjustment.KEY_TEXT_REPLIES, false);
     }
 }
 
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
index c180ace..cee7a06 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
@@ -17,6 +17,7 @@
 package com.android.settings.notification;
 
 import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
 import static android.app.NotificationManager.IMPORTANCE_HIGH;
 import static android.app.NotificationManager.IMPORTANCE_LOW;
 import static android.app.NotificationManager.IMPORTANCE_NONE;
@@ -36,6 +37,7 @@
 
 import android.app.Notification;
 import android.app.NotificationChannel;
+import android.app.NotificationChannelGroup;
 import android.app.NotificationManager;
 import android.content.Context;
 import android.os.UserManager;
@@ -100,7 +102,18 @@
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         appRow.banned = true;
         mController.onResume(appRow, mock(NotificationChannel.class), null, null);
-        assertTrue(mController.isAvailable());
+        assertFalse(mController.isAvailable());
+    }
+
+    @Test
+    public void testIsAvailable_isGroupBlocked() {
+        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+        NotificationChannel channel = mock(NotificationChannel.class);
+        when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
+        NotificationChannelGroup group = mock(NotificationChannelGroup.class);
+        when(group.isBlocked()).thenReturn(true);
+        mController.onResume(appRow, channel, group, null);
+        assertFalse(mController.isAvailable());
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
index 9c53a7b..626d2e3 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java
@@ -117,6 +117,7 @@
     public void isAvailable_notIfChannelGroupBlocked() {
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         NotificationChannel channel = mock(NotificationChannel.class);
+        when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
         NotificationChannelGroup group = mock(NotificationChannelGroup.class);
 
         mController.onResume(appRow, channel, group, null);
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
index b68a4ee..8ca577c 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
@@ -12,6 +12,7 @@
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 import org.robolectric.annotation.RealObject;
+import org.robolectric.annotation.Resetter;
 import org.robolectric.shadows.ShadowResources;
 import org.robolectric.util.ReflectionHelpers.ClassParameter;
 
@@ -40,6 +41,7 @@
         overrideResource(resId, value);
     }
 
+    @Resetter
     public static void reset() {
         sResourceOverrides.clear();
     }
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsTest.java
new file mode 100644
index 0000000..a87ac32
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsTest.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.wifi.calling;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Intent;
+import android.provider.Settings;
+import android.telephony.SubscriptionInfo;
+import android.view.View;
+
+import androidx.fragment.app.FragmentActivity;
+
+import com.android.settings.R;
+import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.widget.RtlCompatibleViewPager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiCallingSettingsTest {
+
+    private WifiCallingSettings mFragment;
+
+    @Before
+    public void setUp() {
+        mFragment = spy(new WifiCallingSettings());
+    }
+
+    @Test
+    public void setupFragment_noSubscriptions_noCrash() {
+        FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId*/,
+                null /* bundle */);
+    }
+
+    @Test
+    public void setupFragment_oneSubscription_noCrash() {
+        SubscriptionInfo info = mock(SubscriptionInfo.class);
+        when(info.getSubscriptionId()).thenReturn(111);
+
+        SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
+                Collections.singletonList(info)));
+        doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
+
+        Intent intent = new Intent();
+        intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
+        FragmentController.of(mFragment, intent).create(0 /* containerViewId*/,
+                null /* bundle */).start().resume().visible().get();
+
+        View view = mFragment.getView();
+        RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
+        WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
+                (WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter();
+        assertThat(adapter.getCount()).isEqualTo(1);
+    }
+
+    @Test
+    public void setupFragment_twoSubscriptions_correctSelection() {
+        SubscriptionInfo info1 = mock(SubscriptionInfo.class);
+        SubscriptionInfo info2 = mock(SubscriptionInfo.class);
+        when(info1.getSubscriptionId()).thenReturn(111);
+        when(info2.getSubscriptionId()).thenReturn(222);
+
+        SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
+                Arrays.asList(info1, info2)));
+        doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
+
+        Intent intent = new Intent();
+        intent.putExtra(Settings.EXTRA_SUB_ID, info2.getSubscriptionId());
+        FragmentController.of(mFragment, intent).create(0 /* containerViewId*/,
+                null /* bundle */).start().resume().visible().get();
+
+        View view = mFragment.getView();
+        RtlCompatibleViewPager pager = view.findViewById(R.id.view_pager);
+        assertThat(pager.getCurrentItem()).isEqualTo(1);
+
+        WifiCallingSettings.WifiCallingViewPagerAdapter adapter =
+                (WifiCallingSettings.WifiCallingViewPagerAdapter) pager.getAdapter();
+        assertThat(adapter.getCount()).isEqualTo(2);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 2166e97..223e81b 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -36,6 +36,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.net.ConnectivityManager;
@@ -69,6 +70,7 @@
 import com.android.settings.R;
 import com.android.settings.core.FeatureFlags;
 import com.android.settings.development.featureflags.FeatureFlagPersistent;
+import com.android.settings.Utils;
 import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
 import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
 import com.android.settings.widget.EntityHeaderController;
@@ -1458,6 +1460,36 @@
         verify(mockSignalStrengthPref, times(2)).setVisible(false);
     }
 
+    @Test
+    public void testRedrawIconForHeader_shouldEnlarge() {
+        ArgumentCaptor<BitmapDrawable> drawableCaptor =
+                ArgumentCaptor.forClass(BitmapDrawable.class);
+        Drawable original = mContext.getDrawable(Utils.getWifiIconResource(LEVEL)).mutate();
+        when(mockIconInjector.getIcon(anyInt())).thenReturn(original);
+
+        displayAndResume();
+
+        verify(mockHeaderController, times(1)).setIcon(drawableCaptor.capture());
+
+        int expectedSize = mContext.getResources().getDimensionPixelSize(
+                R.dimen.wifi_detail_page_header_image_size);
+        BitmapDrawable icon = drawableCaptor.getValue();
+        assertThat(icon.getMinimumWidth()).isEqualTo(expectedSize);
+        assertThat(icon.getMinimumHeight()).isEqualTo(expectedSize);
+    }
+
+    @Test
+    public void testRedrawIconForHeader_shouldNotEnlargeIfNotVectorDrawable() {
+        ArgumentCaptor<ColorDrawable> drawableCaptor =
+                ArgumentCaptor.forClass(ColorDrawable.class);
+
+        displayAndResume();
+
+        verify(mockHeaderController, times(1)).setIcon(drawableCaptor.capture());
+        ColorDrawable icon = drawableCaptor.getValue();
+        assertThat(icon).isNotNull();
+    }
+
     private ActionButtonsPreference createMock() {
         final ActionButtonsPreference pref = mock(ActionButtonsPreference.class);
         when(pref.setButton1Text(anyInt())).thenReturn(pref);
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
index 16be216..d633689 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
@@ -16,9 +16,16 @@
 
 package com.android.settings.wifi.dpp;
 
+import static com.android.settings.wifi.dpp.WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Instrumentation;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 
+import androidx.fragment.app.FragmentManager;
+import androidx.test.InstrumentationRegistry;
 import androidx.test.rule.ActivityTestRule;
 import androidx.test.runner.AndroidJUnit4;
 
@@ -38,6 +45,7 @@
         Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
         intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
         intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+        intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
         mActivityRule.launchActivity(intent);
     }
 
@@ -48,4 +56,21 @@
         mActivityRule.getActivity().setRequestedOrientation(
                 ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
     }
+
+    @Test
+    public void onPause_shouldNotDecodeQrCode() {
+        final WifiDppConfiguratorActivity hostActivity =
+                (WifiDppConfiguratorActivity) mActivityRule.getActivity();
+        final FragmentManager fragmentManager = hostActivity.getSupportFragmentManager();
+        final WifiDppQrCodeScannerFragment scannerFragment =
+                (WifiDppQrCodeScannerFragment) fragmentManager
+                .findFragmentByTag(TAG_FRAGMENT_QR_CODE_SCANNER);
+        final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
+
+        instrumentation.runOnMainSync(() -> {
+            instrumentation.callActivityOnPause(hostActivity);
+
+            assertThat(scannerFragment.isDecodeTaskAlive()).isEqualTo(false);
+        });
+    }
 }