Merge "Fix the potential DOS issue for the Settings Apps page" into udc-dev
diff --git a/Android.bp b/Android.bp
index ea2c983..4d07913 100644
--- a/Android.bp
+++ b/Android.bp
@@ -81,6 +81,7 @@
         "jsr305",
         "net-utils-framework-common",
         "app-usage-event-protos-lite",
+        "battery-event-protos-lite",
         "settings-contextual-card-protos-lite",
         "settings-log-bridge-protos-lite",
         "settings-telephony-protos-lite",
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ccf002a..21b3fa4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3110,6 +3110,7 @@
             <intent-filter>
                 <action android:name="android.intent.action.BATTERY_LEVEL_CHANGED"/>
                 <action android:name="com.android.settings.battery.action.CLEAR_BATTERY_CACHE_DATA"/>
+                <action android:name="com.android.settings.battery.action.ACTION_BATTERY_PLUGGING"/>
                 <action android:name="com.android.settings.battery.action.ACTION_BATTERY_UNPLUGGING"/>
             </intent-filter>
         </receiver>
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 911a95b..2fd63fc 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -1573,6 +1573,22 @@
         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;color name=&quot;screen_flash_color_button_outer_circle_stroke_color&quot;>#FFFFFF&lt;/color>"
+        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/values-night/colors.xml"
+            line="73"
+            column="5"/>
+    </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;color name=&quot;switchbar_switch_track_tint&quot;>#BFFFFFFF&lt;/color>"
         errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -3701,6 +3717,38 @@
         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:color=&quot;#2E3192&quot;"
+        errorLine2="                    ~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable-night/flash_notifications_illustration.xml"
+            line="37"
+            column="21"/>
+    </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:color=&quot;#000000&quot;"
+        errorLine2="                    ~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable-night/flash_notifications_illustration.xml"
+            line="40"
+            column="21"/>
+    </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:color=&quot;@color/accessibility_feature_background&quot;/>"
         errorLine2="            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -4789,6 +4837,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_01_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_01&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -4869,6 +4933,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_02_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_02&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -4949,6 +5029,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_03_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_03&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5029,6 +5125,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_04_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_04&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5109,6 +5221,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_05_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_05&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5189,6 +5317,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_06_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_06&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5269,6 +5413,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_07_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_07&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5349,6 +5509,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_08_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_08&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5429,6 +5605,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_09_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_09&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5509,6 +5701,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_10_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_10&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5589,6 +5797,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_11_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_11&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -5669,6 +5893,22 @@
         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:color=&quot;@color/screen_flash_color_button_outer_circle_stroke_color&quot; />"
+        errorLine2="                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/drawable/screen_flash_color_12_checked_layer.xml"
+            line="41"
+            column="17"/>
+    </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;solid android:color=&quot;@color/screen_flash_preset_opaque_color_12&quot; />"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
diff --git a/res/drawable/ic_check_24dp.xml b/res/drawable/ic_check_24dp.xml
index 5801e70..5238901 100644
--- a/res/drawable/ic_check_24dp.xml
+++ b/res/drawable/ic_check_24dp.xml
@@ -18,7 +18,7 @@
         android:height="24dp"
         android:viewportWidth="24.0"
         android:viewportHeight="24.0"
-        android:tint="?androidprv:attr/colorAccentPrimaryVariant">
+        android:tint="?androidprv:attr/colorAccent">
     <path
         android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"
         android:fillColor="@android:color/white"/>
diff --git a/res/layout/locale_order_list.xml b/res/layout/locale_order_list.xml
index a1f93cd..acde145 100644
--- a/res/layout/locale_order_list.xml
+++ b/res/layout/locale_order_list.xml
@@ -36,7 +36,7 @@
         <Button
             android:id="@+id/add_language"
             android:layout_width="match_parent"
-            android:layout_height="?android:listPreferredItemHeight"
+            android:layout_height="wrap_content"
             android:paddingStart="?android:attr/listPreferredItemPaddingStart"
             android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
             android:drawableStart="@drawable/ic_add_24dp"
diff --git a/res/layout/preference_check_icon.xml b/res/layout/preference_check_icon.xml
index 5652ac6..1b759fc 100644
--- a/res/layout/preference_check_icon.xml
+++ b/res/layout/preference_check_icon.xml
@@ -15,7 +15,7 @@
 -->
 <ImageView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/keyboard_check_icon"
+    android:id="@+id/check_icon"
     android:src="@drawable/ic_check_24dp"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f593db9..94ba726 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1126,6 +1126,10 @@
     <string name="auto_pin_confirm_user_message">Auto-confirm correct PIN</string>
     <!-- Message shown to explain the security concern if a user opts-in to the auto-pin feature. [CHAR LIMIT=NONE] -->
     <string name="auto_pin_confirm_opt_in_security_message">Confirming your PIN by tapping Enter is more secure than using auto-confirm</string>
+    <!-- Description of pin confirmation screen when auto confirm setting is turned on. [CHAR LIMIT=NONE] -->
+    <string name="auto_confirm_on_pin_verify_description">Enter device PIN to enable auto-confirm</string>
+    <!-- Description of pin confirmation screen when auto confirm setting is turned off. [CHAR LIMIT=NONE] -->
+    <string name="auto_confirm_off_pin_verify_description">Enter device PIN to disable auto-confirm</string>
 
     <!--  Main Security lock settings --><skip />
     <!--  Title for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=22] -->
@@ -4210,10 +4214,10 @@
     <string name="accessibility_screen_magnification_follow_typing_title">Magnify typing</string>
     <!-- Summary for accessibility follow typing preference for magnification. [CHAR LIMIT=none] -->
     <string name="accessibility_screen_magnification_follow_typing_summary">Magnifier follows text as you type</string>
-    <!-- Title for accessibility magnifier preference where the magnifier never turns off on its own. [CHAR LIMIT=35] -->
-    <string name="accessibility_screen_magnification_always_on_title">Always On</string>
-    <!-- Summary for accessibility magnifier preference where the magnifier never turns off on its own. [CHAR LIMIT=none] -->
-    <string name="accessibility_screen_magnification_always_on_summary">Instead of deactivating magnification when changing apps, it simply zooms out to normal size. Pinch to zoom back in whenever you want.</string>
+    <!-- Title for accessibility magnifier preference where the magnifier never turns off while switching apps. [CHAR LIMIT=35] -->
+    <string name="accessibility_screen_magnification_always_on_title">Keep on while switching apps</string>
+    <!-- Summary for accessibility magnifier preference where the magnifier never turns off while switching apps. [CHAR LIMIT=none] -->
+    <string name="accessibility_screen_magnification_always_on_summary">Magnifier stays on and zooms out when you switch apps</string>
     <!-- Title for accessibility on-screen joystick controller preference that controls magnification position. [CHAR LIMIT=35] -->
     <string name="accessibility_screen_magnification_joystick_title">Joystick</string>
     <!-- Summary for accessibility on-screen joystick controller preference that controls magnification position. [CHAR LIMIT=none] -->
diff --git a/res/xml/keyboard_settings.xml b/res/xml/keyboard_settings.xml
index 9a3ac1a..bb1c3da 100644
--- a/res/xml/keyboard_settings.xml
+++ b/res/xml/keyboard_settings.xml
@@ -30,8 +30,7 @@
         <Preference
             android:key="physical_keyboard_pref"
             android:title="@string/physical_keyboard_title"
-            android:summary="@string/summary_placeholder"
-            android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
+            android:summary="@string/summary_placeholder"/>
     </PreferenceCategory>
 
     <PreferenceCategory
diff --git a/src/com/android/settings/SettingsDumpService.java b/src/com/android/settings/SettingsDumpService.java
index 38987f5..4feb6b2 100644
--- a/src/com/android/settings/SettingsDumpService.java
+++ b/src/com/android/settings/SettingsDumpService.java
@@ -31,12 +31,15 @@
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
+import android.util.IndentingPrintWriter;
+import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 
 import com.android.settings.applications.ProcStatsData;
 import com.android.settings.datausage.lib.DataUsageLib;
 import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
+import com.android.settings.network.MobileNetworkRepository;
 import com.android.settingslib.net.DataUsageController;
 
 import org.json.JSONArray;
@@ -48,6 +51,10 @@
 import java.io.PrintWriter;
 
 public class SettingsDumpService extends Service {
+
+    public static final String EXTRA_KEY_SHOW_NETWORK_DUMP = "show_network_dump";
+
+    private static final String TAG = "SettingsDumpService";
     @VisibleForTesting
     static final String KEY_SERVICE = "service";
     @VisibleForTesting
@@ -64,6 +71,16 @@
     static final Intent BROWSER_INTENT =
             new Intent("android.intent.action.VIEW", Uri.parse("http://"));
 
+    private boolean mShouldShowNetworkDump = false;
+
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+        if (intent != null) {
+            mShouldShowNetworkDump = intent.getBooleanExtra(EXTRA_KEY_SHOW_NETWORK_DUMP, false);
+        }
+        return Service.START_REDELIVER_INTENT;
+    }
+
     @Override
     public IBinder onBind(Intent intent) {
         return null;
@@ -71,20 +88,27 @@
 
     @Override
     protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
-        JSONObject dump = new JSONObject();
-
-        try {
-            dump.put(KEY_SERVICE, "Settings State");
-            dump.put(KEY_STORAGE, dumpStorage());
-            dump.put(KEY_DATAUSAGE, dumpDataUsage());
-            dump.put(KEY_MEMORY, dumpMemory());
-            dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
-            dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
-        } catch (Exception e) {
-            e.printStackTrace();
+        IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
+        if (!mShouldShowNetworkDump) {
+            JSONObject dump = new JSONObject();
+            pw.println(TAG + ": ");
+            pw.increaseIndent();
+            try {
+                dump.put(KEY_SERVICE, "Settings State");
+                dump.put(KEY_STORAGE, dumpStorage());
+                dump.put(KEY_DATAUSAGE, dumpDataUsage());
+                dump.put(KEY_MEMORY, dumpMemory());
+                dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
+                dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
+            } catch (Exception e) {
+                Log.w(TAG, "exception in dump: ", e);
+            }
+            pw.println(dump);
+            pw.flush();
+            pw.decreaseIndent();
+        } else {
+            dumpMobileNetworkSettings(pw);
         }
-
-        writer.println(dump);
     }
 
     private JSONObject dumpMemory() throws JSONException {
@@ -186,4 +210,8 @@
 
         return obj;
     }
+
+    private void dumpMobileNetworkSettings(IndentingPrintWriter writer) {
+        MobileNetworkRepository.getInstance(this).dump(writer);
+    }
 }
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
index 370392b..a0dac5a 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
@@ -23,6 +23,7 @@
 import android.util.Log;
 import android.util.TypedValue;
 
+import androidx.window.embedding.ActivityEmbeddingController;
 import androidx.window.embedding.SplitController;
 
 import com.android.settings.R;
@@ -81,4 +82,13 @@
         return dm.widthPixels >= (int) TypedValue.applyDimension(
                 TypedValue.COMPLEX_UNIT_DIP, MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP, dm);
     }
+
+    /**
+     * Check if activity is already embedded
+     */
+    public static boolean isAlreadyEmbedded(Activity activity) {
+        return ActivityEmbeddingController
+                .getInstance(activity)
+                .isActivityEmbedded(activity);
+    }
 }
diff --git a/src/com/android/settings/applications/manageapplications/CloneBackend.java b/src/com/android/settings/applications/manageapplications/CloneBackend.java
index 588d834..568631e 100644
--- a/src/com/android/settings/applications/manageapplications/CloneBackend.java
+++ b/src/com/android/settings/applications/manageapplications/CloneBackend.java
@@ -104,7 +104,7 @@
                         new HashSet<>());
             } catch (Exception e) {
                 if (ManageApplications.DEBUG) {
-                    Log.e("ankita", "Error occurred creating clone user" + e.getMessage());
+                    Log.e(TAG, "Error occurred creating clone user" + e.getMessage());
                 }
                 return ERROR_CREATING_CLONE_USER;
             }
@@ -125,7 +125,7 @@
             if (newlyCreated) {
                 IActivityManager am = ActivityManagerNative.getDefault();
                 try {
-                    am.startUserInBackground(mCloneUserId);
+                    am.startProfile(mCloneUserId);
                 } catch (RemoteException e) {
                     if (ManageApplications.DEBUG) {
                         Log.e(TAG, "Error starting clone user " + e.getMessage());
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index e63a754..af581b8 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -22,6 +22,8 @@
 import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_CONSENT_DENIED;
 import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_CONSENT_GRANTED;
 
+import static com.google.android.setupdesign.transition.TransitionHelper.TRANSITION_FADE_THROUGH;
+
 import android.annotation.NonNull;
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
@@ -55,6 +57,7 @@
 import com.android.settings.password.ChooseLockSettingsHelper;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
+import com.google.android.setupdesign.transition.TransitionHelper;
 
 import java.util.List;
 
@@ -457,6 +460,9 @@
                 final boolean isOk =
                         isSuccessfulConfirmOrChooseCredential(requestCode, resultCode);
                 if (isOk && (mHasFeatureFace || mHasFeatureFingerprint)) {
+                    // Apply forward animation during the transition from ChooseLock/ConfirmLock to
+                    // SetupFingerprintEnrollIntroduction/FingerprintEnrollmentActivity
+                    TransitionHelper.applyForwardTransition(this, TRANSITION_FADE_THROUGH);
                     updateGatekeeperPasswordHandle(data);
                     if (mHasFeatureFingerprint) {
                         launchFingerprintOnlyEnroll();
@@ -473,6 +479,10 @@
                 mIsSingleEnrolling = false;
                 if ((resultCode == BiometricEnrollBase.RESULT_SKIP
                         || resultCode == BiometricEnrollBase.RESULT_FINISHED) && mHasFeatureFace) {
+                    // Apply forward animation during the transition from
+                    // SetupFingerprintEnroll*/FingerprintEnrollmentActivity to
+                    // SetupFaceEnrollIntroduction
+                    TransitionHelper.applyForwardTransition(this, TRANSITION_FADE_THROUGH);
                     launchFaceOnlyEnroll();
                 } else {
                     finishOrLaunchHandToParent(resultCode);
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 2a1d049..7051b70 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -21,7 +21,6 @@
 import android.os.UserHandle;
 import android.view.View;
 
-import com.android.settings.R;
 import com.android.settings.password.ChooseLockSettingsHelper;
 
 /**
@@ -120,7 +119,6 @@
             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
         }
         startActivity(intent);
-        overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
         finish();
     }
 
diff --git a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
index 7f69b91..62928af 100644
--- a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
+++ b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
@@ -267,9 +267,11 @@
         } else {
             getSupportFragmentManager().beginTransaction()
                     .setReorderingAllowed(true)
+                    .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_open_exit,
+                            R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_close_exit)
                     .replace(R.id.fragment_container_view, fragmentClass, null, tag)
-                    .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
-                            R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
                     .addToBackStack(tag)
                     .commit();
         }
@@ -373,20 +375,24 @@
             // Replace enrolling page
             getSupportFragmentManager().beginTransaction()
                     .setReorderingAllowed(true)
+                    .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_open_exit,
+                            R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_close_exit)
                     .replace(R.id.fragment_container_view, FingerprintEnrollFinishFragment.class,
                             null, FINISH_TAG)
-                    .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
-                            R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
                     .commit();
         } else {
             // Remove Enrolling page from backstack, and add Finish page. Latest backstack will
             // be changed from Intro->FindSensor->Enrolling to Intro->FindSensor->Finish
             getSupportFragmentManager().beginTransaction()
                     .setReorderingAllowed(true)
+                    .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_open_exit,
+                            R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+                            R.anim.shared_x_axis_activity_close_exit)
                     .replace(R.id.fragment_container_view, FingerprintEnrollFinishFragment.class,
                             null, FINISH_TAG)
-                    .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
-                            R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
                     .addToBackStack(FINISH_TAG)
                     .commit();
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
index 3851753..182ada2 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
@@ -172,7 +172,7 @@
         }
         use(AdvancedBluetoothDetailsHeaderController.class).init(mCachedDevice);
         use(LeAudioBluetoothDetailsHeaderController.class).init(mCachedDevice, mManager);
-        use(KeyboardSettingsPreferenceController.class).init(mCachedDevice, getActivity());
+        use(KeyboardSettingsPreferenceController.class).init(mCachedDevice);
 
         final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(
                 context).getBluetoothFeatureProvider();
diff --git a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
index ac895df..c93a1c6 100644
--- a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
+++ b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
@@ -127,8 +127,9 @@
         pref.setTitle(mContext.getString(R.string.stylus_textfield_handwriting));
         pref.setIcon(R.drawable.ic_text_fields_alt);
         pref.setOnPreferenceClickListener(this);
-        pref.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 1);
+        pref.setChecked(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+                Secure.STYLUS_HANDWRITING_DEFAULT_VALUE) == 1);
         pref.setVisible(currentInputMethodSupportsHandwriting());
         return pref;
     }
@@ -157,8 +158,8 @@
                 mContext.startActivity(intent);
                 break;
             case KEY_HANDWRITING:
-                Settings.Global.putInt(mContext.getContentResolver(),
-                        Settings.Global.STYLUS_HANDWRITING_ENABLED,
+                Settings.Secure.putInt(mContext.getContentResolver(),
+                        Settings.Secure.STYLUS_HANDWRITING_ENABLED,
                         ((SwitchPreference) preference).isChecked() ? 1 : 0);
 
                 if (((SwitchPreference) preference).isChecked()) {
diff --git a/src/com/android/settings/development/StylusHandwritingPreferenceController.java b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
index 69b5bad..12cd781 100644
--- a/src/com/android/settings/development/StylusHandwritingPreferenceController.java
+++ b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
@@ -45,8 +45,8 @@
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         final boolean isEnabled = (Boolean) newValue;
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED,
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
                 isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
 
         return true;
@@ -54,16 +54,18 @@
 
     @Override
     public void updateState(Preference preference) {
-        final int enable = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+        final int enable = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+                Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
         ((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
     }
 
     @Override
     protected void onDeveloperOptionsSwitchDisabled() {
         super.onDeveloperOptionsSwitchDisabled();
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+                Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
         ((SwitchPreference) mPreference).setChecked(false);
     }
 }
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 274817e..73ec42b 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -22,9 +22,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.PowerManager;
-import android.provider.Settings;
 import android.provider.SettingsSlicesContract;
-import android.widget.Switch;
 
 import androidx.preference.PreferenceScreen;
 
@@ -36,15 +34,13 @@
 import com.android.settingslib.core.lifecycle.events.OnStop;
 import com.android.settingslib.fuelgauge.BatterySaverUtils;
 import com.android.settingslib.widget.MainSwitchPreference;
-import com.android.settingslib.widget.OnMainSwitchChangeListener;
-
 
 /**
  * Controller to update the battery saver button
  */
 public class BatterySaverButtonPreferenceController extends
-        TogglePreferenceController implements OnMainSwitchChangeListener, LifecycleObserver,
-        OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
+        TogglePreferenceController implements LifecycleObserver, OnStart, OnStop,
+        BatterySaverReceiver.BatterySaverListener {
     private static final long SWITCH_ANIMATION_DURATION = 350L;
 
     private final BatterySaverReceiver mBatterySaverReceiver;
@@ -96,21 +92,10 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
-        mPreference.addOnSwitchChangeListener(this);
         mPreference.updateStatus(isChecked());
     }
 
     @Override
-    public void onSwitchChanged(Switch switchView, boolean isChecked) {
-        // Cancel preference's check state once it's first time launch
-        if (isChecked && (Settings.Secure.getInt(mContext.getContentResolver(),
-                Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 0) == 0)) {
-            mPreference.setChecked(false);
-        }
-        setChecked(isChecked);
-    }
-
-    @Override
     public boolean isChecked() {
         return mPowerManager.isPowerSaveMode();
     }
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java
index a437877..07a97dc 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBroadcastReceiver.java
@@ -30,6 +30,8 @@
 import com.android.settingslib.fuelgauge.BatteryStatus;
 
 import java.time.Duration;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /** A {@link BatteryUsageBroadcastReceiver} for battery usage data requesting. */
 public final class BatteryUsageBroadcastReceiver extends BroadcastReceiver {
@@ -37,7 +39,10 @@
     /** An intent action to request Settings to clear cache data. */
     public static final String ACTION_CLEAR_BATTERY_CACHE_DATA =
             "com.android.settings.battery.action.CLEAR_BATTERY_CACHE_DATA";
-    /** An intent action to request Settings to clear cache data. */
+    /** An intent action for power is plugging. */
+    public static final String ACTION_BATTERY_PLUGGING =
+            "com.android.settings.battery.action.ACTION_BATTERY_PLUGGING";
+    /** An intent action for power is unplugging. */
     public static final String ACTION_BATTERY_UNPLUGGING =
             "com.android.settings.battery.action.ACTION_BATTERY_UNPLUGGING";
 
@@ -49,6 +54,8 @@
     @VisibleForTesting
     boolean mFetchBatteryUsageData = false;
 
+    private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
+
     @Override
     public void onReceive(Context context, Intent intent) {
         if (intent == null || intent.getAction() == null) {
@@ -70,7 +77,11 @@
                     tryToFetchUsageData(context);
                 }
                 break;
+            case ACTION_BATTERY_PLUGGING:
+                sendBatteryEventData(context, BatteryEventType.POWER_CONNECTED);
+                break;
             case ACTION_BATTERY_UNPLUGGING:
+                sendBatteryEventData(context, BatteryEventType.POWER_DISCONNECTED);
                 // Only when fullChargeIntentAction is ACTION_POWER_DISCONNECTED,
                 // ACTION_BATTERY_UNPLUGGING will be considered as the full charge event and then
                 // start usage events fetching.
@@ -106,4 +117,12 @@
         mFetchBatteryUsageData = true;
         BatteryUsageDataLoader.enqueueWork(context, /*isFullChargeStart=*/ true);
     }
+
+    private void sendBatteryEventData(Context context, BatteryEventType batteryEventType) {
+        final long timestamp = System.currentTimeMillis();
+        final Intent intent = BatteryUtils.getBatteryIntent(context);
+        final int batteryLevel = BatteryStatus.getBatteryLevel(intent);
+        mExecutor.execute(() -> DatabaseUtils.sendBatteryEventData(context,
+                ConvertUtils.convertToBatteryEvent(timestamp, batteryEventType, batteryLevel)));
+    }
 }
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java
index 42937e5..1b2d4cd 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProvider.java
@@ -31,6 +31,8 @@
 
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventDao;
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
+import com.android.settings.fuelgauge.batteryusage.db.BatteryEventDao;
+import com.android.settings.fuelgauge.batteryusage.db.BatteryEventEntity;
 import com.android.settings.fuelgauge.batteryusage.db.BatteryState;
 import com.android.settings.fuelgauge.batteryusage.db.BatteryStateDao;
 import com.android.settings.fuelgauge.batteryusage.db.BatteryStateDatabase;
@@ -52,6 +54,7 @@
     private static final int BATTERY_STATE_CODE = 1;
     private static final int APP_USAGE_LATEST_TIMESTAMP_CODE = 2;
     private static final int APP_USAGE_EVENT_CODE = 3;
+    private static final int BATTERY_EVENT_CODE = 4;
 
     private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
 
@@ -68,11 +71,16 @@
                 DatabaseUtils.AUTHORITY,
                 /*path=*/ DatabaseUtils.APP_USAGE_EVENT_TABLE,
                 /*code=*/ APP_USAGE_EVENT_CODE);
+        sUriMatcher.addURI(
+                DatabaseUtils.AUTHORITY,
+                /*path=*/ DatabaseUtils.BATTERY_EVENT_TABLE,
+                /*code=*/ BATTERY_EVENT_CODE);
     }
 
     private Clock mClock;
     private BatteryStateDao mBatteryStateDao;
     private AppUsageEventDao mAppUsageEventDao;
+    private BatteryEventDao mBatteryEventDao;
 
     @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
     public void setClock(Clock clock) {
@@ -88,6 +96,7 @@
         mClock = Clock.systemUTC();
         mBatteryStateDao = BatteryStateDatabase.getInstance(getContext()).batteryStateDao();
         mAppUsageEventDao = BatteryStateDatabase.getInstance(getContext()).appUsageEventDao();
+        mBatteryEventDao = BatteryStateDatabase.getInstance(getContext()).batteryEventDao();
         Log.w(TAG, "create content provider from " + getCallingPackage());
         return true;
     }
@@ -107,6 +116,8 @@
                 return getAppUsageEvents(uri);
             case APP_USAGE_LATEST_TIMESTAMP_CODE:
                 return getAppUsageLatestTimestamp(uri);
+            case BATTERY_EVENT_CODE:
+                return getBatteryEvents(uri);
             default:
                 throw new IllegalArgumentException("unknown URI: " + uri);
         }
@@ -138,6 +149,14 @@
                     Log.e(TAG, "insert() from:" + uri + " error:" + e);
                     return null;
                 }
+            case BATTERY_EVENT_CODE:
+                try {
+                    mBatteryEventDao.insert(BatteryEventEntity.create(contentValues));
+                    return uri;
+                } catch (RuntimeException e) {
+                    Log.e(TAG, "insert() from:" + uri + " error:" + e);
+                    return null;
+                }
             default:
                 throw new IllegalArgumentException("unknown URI: " + uri);
         }
@@ -190,7 +209,6 @@
         }
         Log.w(TAG, "query app usage events in " + (mClock.millis() - timestamp) + "/ms");
         return cursor;
-
     }
 
     private Cursor getAppUsageLatestTimestamp(Uri uri) {
@@ -210,6 +228,19 @@
         return cursor;
     }
 
+    private Cursor getBatteryEvents(Uri uri) {
+        final long queryTimestamp = getQueryTimestamp(uri);
+        final long timestamp = mClock.millis();
+        Cursor cursor = null;
+        try {
+            cursor = mBatteryEventDao.getAllAfter(queryTimestamp);
+        } catch (RuntimeException e) {
+            Log.e(TAG, "query() from:" + uri + " error:" + e);
+        }
+        Log.w(TAG, "query app usage events in " + (mClock.millis() - timestamp) + "/ms");
+        return cursor;
+    }
+
     // If URI contains query parameter QUERY_KEY_USERID, use the value directly.
     // Otherwise, return null.
     private List<Long> getQueryUserIds(Uri uri) {
diff --git a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
index fcf934f..c6c548f 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/ConvertUtils.java
@@ -38,6 +38,7 @@
 
 import com.android.settings.fuelgauge.BatteryUtils;
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
+import com.android.settings.fuelgauge.batteryusage.db.BatteryEventEntity;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
@@ -125,6 +126,15 @@
         return values;
     }
 
+    /** Converts {@link BatteryEvent} to content values */
+    public static ContentValues convertBatteryEventToContentValues(final BatteryEvent event) {
+        final ContentValues values = new ContentValues();
+        values.put(BatteryEventEntity.KEY_TIMESTAMP, event.getTimestamp());
+        values.put(BatteryEventEntity.KEY_BATTERY_EVENT_TYPE, event.getType().getNumber());
+        values.put(BatteryEventEntity.KEY_BATTERY_LEVEL, event.getBatteryLevel());
+        return values;
+    }
+
     /** Gets the encoded string from {@link BatteryInformation} instance. */
     public static String convertBatteryInformationToString(
             final BatteryInformation batteryInformation) {
@@ -237,6 +247,29 @@
         return eventBuilder.build();
     }
 
+    /** Converts to {@link BatteryEvent} from {@link BatteryEventType} */
+    public static BatteryEvent convertToBatteryEvent(
+            long timestamp, BatteryEventType type, int batteryLevel) {
+        final BatteryEvent.Builder eventBuilder = BatteryEvent.newBuilder();
+        eventBuilder.setTimestamp(timestamp);
+        eventBuilder.setType(type);
+        eventBuilder.setBatteryLevel(batteryLevel);
+        return eventBuilder.build();
+    }
+
+    /** Converts to {@link BatteryEvent} from {@link Cursor} */
+    public static BatteryEvent convertToBatteryEventFromCursor(final Cursor cursor) {
+        final BatteryEvent.Builder eventBuilder = BatteryEvent.newBuilder();
+        eventBuilder.setTimestamp(getLongFromCursor(cursor, BatteryEventEntity.KEY_TIMESTAMP));
+        eventBuilder.setType(
+                BatteryEventType.forNumber(
+                        getIntegerFromCursor(
+                                cursor, BatteryEventEntity.KEY_BATTERY_EVENT_TYPE)));
+        eventBuilder.setBatteryLevel(
+                getIntegerFromCursor(cursor, BatteryEventEntity.KEY_BATTERY_LEVEL));
+        return eventBuilder.build();
+    }
+
     /** Converts UTC timestamp to local time string for logging only, so use the US locale for
      *  better readability in debugging. */
     public static String utcToLocalTimeForLogging(long timestamp) {
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java
index 1f25ae0..6b007de 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessManager.java
@@ -72,6 +72,8 @@
 
     private final Handler mHandler;
     private final DataProcessor.UsageMapAsyncResponse mCallbackFunction;
+    private final List<AppUsageEvent> mAppUsageEventList = new ArrayList<>();
+    private final List<BatteryEvent> mBatteryEventList = new ArrayList<>();
 
     private Context mContext;
     private UserManager mUserManager;
@@ -84,12 +86,12 @@
     private boolean mIsCurrentBatteryHistoryLoaded = false;
     private boolean mIsCurrentAppUsageLoaded = false;
     private boolean mIsDatabaseAppUsageLoaded = false;
+    private boolean mIsBatteryEventLoaded = false;
     // Used to identify whether screen-on time data should be shown in the UI.
     private boolean mShowScreenOnTime = true;
     // Used to identify whether battery level data should be shown in the UI.
     private boolean mShowBatteryLevel = true;
 
-    private List<AppUsageEvent> mAppUsageEventList = new ArrayList<>();
     /**
      * The indexed {@link AppUsagePeriod} list data for each corresponding time slot.
      * <p>{@code Long} stands for the userId.</p>
@@ -146,6 +148,8 @@
             loadDatabaseAppUsageList();
             // Loads the latest app usage list from the service.
             loadCurrentAppUsageList();
+            // Loads the battery event list from database.
+            loadBatteryEventList();
         } else {
             // If there is no battery level data, only load the battery history data from service
             // and show it as the app list directly.
@@ -175,6 +179,11 @@
     }
 
     @VisibleForTesting
+    boolean getIsBatteryEventLoaded() {
+        return mIsBatteryEventLoaded;
+    }
+
+    @VisibleForTesting
     boolean getIsCurrentBatteryHistoryLoaded() {
         return mIsCurrentBatteryHistoryLoaded;
     }
@@ -290,7 +299,7 @@
                     return null;
                 }
                 final long startTime = System.currentTimeMillis();
-                // Loads the current battery usage data from the battery stats service.
+                // Loads the app usage data from the database.
                 final List<AppUsageEvent> appUsageEventList =
                         DatabaseUtils.getAppUsageEventForUsers(
                                 mContext, Calendar.getInstance(), getCurrentUserIds(),
@@ -314,6 +323,35 @@
         }.execute();
     }
 
+    private void loadBatteryEventList() {
+        new AsyncTask<Void, Void, List<BatteryEvent>>() {
+            @Override
+            protected List<BatteryEvent> doInBackground(Void... voids) {
+                final long startTime = System.currentTimeMillis();
+                // Loads the battery event data from the database.
+                final List<BatteryEvent> batteryEventList =
+                        DatabaseUtils.getBatteryEvents(
+                                mContext, Calendar.getInstance(), mRawStartTimestamp);
+                Log.d(TAG, String.format("execute loadBatteryEventList size=%d in %d/ms",
+                        batteryEventList.size(), (System.currentTimeMillis() - startTime)));
+                return batteryEventList;
+            }
+
+            @Override
+            protected void onPostExecute(
+                    final List<BatteryEvent> batteryEventList) {
+                if (batteryEventList == null || batteryEventList.isEmpty()) {
+                    Log.d(TAG, "batteryEventList is null or empty");
+                } else {
+                    mBatteryEventList.clear();
+                    mBatteryEventList.addAll(batteryEventList);
+                }
+                mIsBatteryEventLoaded = true;
+                tryToProcessAppUsageData();
+            }
+        }.execute();
+    }
+
     private void loadAndApplyBatteryMapFromServiceOnly() {
         new AsyncTask<Void, Void, BatteryCallbackData>() {
             @Override
@@ -344,9 +382,8 @@
     }
 
     private void tryToProcessAppUsageData() {
-        // Only when all app usage events has been loaded, start processing app usage data to an
-        // intermediate result for further use.
-        if (!mIsCurrentAppUsageLoaded || !mIsDatabaseAppUsageLoaded) {
+        // Ignore processing the data if any required data is not loaded.
+        if (!mIsCurrentAppUsageLoaded || !mIsDatabaseAppUsageLoaded || !mIsBatteryEventLoaded) {
             return;
         }
         processAppUsageData();
@@ -360,16 +397,16 @@
         }
         // Generates the indexed AppUsagePeriod list data for each corresponding time slot for
         // further use.
-        mAppUsagePeriodMap = DataProcessor.generateAppUsagePeriodMap(
-                mRawStartTimestamp, mHourlyBatteryLevelsPerDay, mAppUsageEventList);
+        mAppUsagePeriodMap = DataProcessor.generateAppUsagePeriodMap(mRawStartTimestamp,
+                mHourlyBatteryLevelsPerDay, mAppUsageEventList, mBatteryEventList);
     }
 
     private void tryToGenerateFinalDataAndApplyCallback() {
-        // Only when both battery history data and app usage events data has been loaded, start the
-        // final data processing.
+        // Ignore processing the data if any required data is not loaded.
         if (!mIsCurrentBatteryHistoryLoaded
                 || !mIsCurrentAppUsageLoaded
-                || !mIsDatabaseAppUsageLoaded) {
+                || !mIsDatabaseAppUsageLoaded
+                || !mIsBatteryEventLoaded) {
             return;
         }
         generateFinalDataAndApplyCallback();
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
index 38d4e69..6270eb3 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java
@@ -95,6 +95,14 @@
     static final int SELECTED_INDEX_ALL = BatteryChartViewModel.SELECTED_INDEX_ALL;
 
     @VisibleForTesting
+    static final Comparator<AppUsageEvent> APP_USAGE_EVENT_TIMESTAMP_COMPARATOR =
+            Comparator.comparing(AppUsageEvent::getTimestamp);
+
+    @VisibleForTesting
+    static final Comparator<BatteryEvent> BATTERY_EVENT_TIMESTAMP_COMPARATOR =
+            Comparator.comparing(BatteryEvent::getTimestamp);
+
+    @VisibleForTesting
     static boolean sDebug = false;
 
     @VisibleForTesting
@@ -110,8 +118,6 @@
 
     public static final String CURRENT_TIME_BATTERY_HISTORY_PLACEHOLDER =
             "CURRENT_TIME_BATTERY_HISTORY_PLACEHOLDER";
-    public static final Comparator<AppUsageEvent> TIMESTAMP_COMPARATOR =
-            Comparator.comparing(AppUsageEvent::getTimestamp);
 
     /** A callback listener when battery usage loading async task is executed. */
     public interface UsageMapAsyncResponse {
@@ -266,14 +272,16 @@
             generateAppUsagePeriodMap(
                     final long rawStartTimestamp,
                     final List<BatteryLevelData.PeriodBatteryLevelData> hourlyBatteryLevelsPerDay,
-                    final List<AppUsageEvent> appUsageEventList) {
+                    final List<AppUsageEvent> appUsageEventList,
+                    final List<BatteryEvent> batteryEventList) {
         if (appUsageEventList.isEmpty()) {
             Log.w(TAG, "appUsageEventList is empty");
             return null;
         }
-        // Sorts the appUsageEventList in ascending order based on the timestamp before
-        // distribution.
-        Collections.sort(appUsageEventList, TIMESTAMP_COMPARATOR);
+        // Sorts the appUsageEventList and batteryEventList in ascending order based on the
+        // timestamp before distribution.
+        Collections.sort(appUsageEventList, APP_USAGE_EVENT_TIMESTAMP_COMPARATOR);
+        Collections.sort(batteryEventList, BATTERY_EVENT_TIMESTAMP_COMPARATOR);
         final Map<Integer, Map<Integer, Map<Long, Map<String, List<AppUsagePeriod>>>>> resultMap =
                 new ArrayMap<>();
 
@@ -309,8 +317,8 @@
                 // The value could be null when there is no data in the hourly slot.
                 dailyMap.put(
                         hourlyIndex,
-                        buildAppUsagePeriodList(
-                                hourlyAppUsageEventList, startTimestamp, endTimestamp));
+                        buildAppUsagePeriodList(hourlyAppUsageEventList, batteryEventList,
+                                startTimestamp, endTimestamp));
             }
         }
         return resultMap;
@@ -717,7 +725,8 @@
     @VisibleForTesting
     @Nullable
     static Map<Long, Map<String, List<AppUsagePeriod>>> buildAppUsagePeriodList(
-            final List<AppUsageEvent> allAppUsageEvents, final long startTime, final long endTime) {
+            final List<AppUsageEvent> allAppUsageEvents, final List<BatteryEvent> batteryEventList,
+            final long startTime, final long endTime) {
         if (allAppUsageEvents.isEmpty()) {
             return null;
         }
@@ -763,12 +772,14 @@
             usageEvents.addAll(deviceEvents);
             // Sorts the usageEvents in ascending order based on the timestamp before computing the
             // period.
-            Collections.sort(usageEvents, TIMESTAMP_COMPARATOR);
+            Collections.sort(usageEvents, APP_USAGE_EVENT_TIMESTAMP_COMPARATOR);
 
             // A package might have multiple instances. Computes the usage period per instance id
             // and then merges them into the same user-package map.
             final List<AppUsagePeriod> usagePeriodList =
-                    buildAppUsagePeriodListPerInstance(usageEvents, startTime, endTime);
+                    excludePowerConnectedTimeFromAppUsagePeriodList(
+                            buildAppUsagePeriodListPerInstance(usageEvents, startTime, endTime),
+                            batteryEventList);
             if (!usagePeriodList.isEmpty()) {
                 addToUsagePeriodMap(allUsagePeriods, usagePeriodList, eventUserId, packageName);
             }
@@ -837,6 +848,53 @@
     }
 
     @VisibleForTesting
+    static List<AppUsagePeriod> excludePowerConnectedTimeFromAppUsagePeriodList(
+            final List<AppUsagePeriod> usagePeriodList,
+            final List<BatteryEvent> batteryEventList) {
+        final List<AppUsagePeriod> resultList = new ArrayList<>();
+        for (AppUsagePeriod inputPeriod : usagePeriodList) {
+            long lastStartTime = inputPeriod.getStartTime();
+            for (BatteryEvent batteryEvent : batteryEventList) {
+                if (batteryEvent.getTimestamp() < inputPeriod.getStartTime()) {
+                    // Because the batteryEventList has been sorted, here is to mark the power
+                    // connection state when the usage period starts. If power is connected when
+                    // the usage period starts, the starting period will be ignored; otherwise it
+                    // will be added.
+                    if (batteryEvent.getType() == BatteryEventType.POWER_CONNECTED) {
+                        lastStartTime = 0;
+                    } else if (batteryEvent.getType() == BatteryEventType.POWER_DISCONNECTED) {
+                        lastStartTime = inputPeriod.getStartTime();
+                    }
+                    continue;
+                }
+                if (batteryEvent.getTimestamp() > inputPeriod.getEndTime()) {
+                    // Because the batteryEventList has been sorted, if any event is already after
+                    // the end time, all the following events should be able to drop directly.
+                    break;
+                }
+
+                if (batteryEvent.getType() == BatteryEventType.POWER_CONNECTED
+                        && lastStartTime != 0) {
+                    resultList.add(AppUsagePeriod.newBuilder()
+                            .setStartTime(lastStartTime)
+                            .setEndTime(batteryEvent.getTimestamp())
+                            .build());
+                    lastStartTime = 0;
+                } else if (batteryEvent.getType() == BatteryEventType.POWER_DISCONNECTED) {
+                    lastStartTime = batteryEvent.getTimestamp();
+                }
+            }
+            if (lastStartTime != 0) {
+                resultList.add(AppUsagePeriod.newBuilder()
+                        .setStartTime(lastStartTime)
+                        .setEndTime(inputPeriod.getEndTime())
+                        .build());
+            }
+        }
+        return resultList;
+    }
+
+    @VisibleForTesting
     static long getScreenOnTime(
             final Map<Long, Map<String, List<AppUsagePeriod>>> appUsageMap,
             final long userId,
diff --git a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
index ef1434c..84a39bb 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtils.java
@@ -64,10 +64,12 @@
 
     /** An authority name of the battery content provider. */
     public static final String AUTHORITY = "com.android.settings.battery.usage.provider";
-    /** A table name for battery usage history. */
-    public static final String BATTERY_STATE_TABLE = "BatteryState";
     /** A table name for app usage events. */
     public static final String APP_USAGE_EVENT_TABLE = "AppUsageEvent";
+    /** A table name for battery events. */
+    public static final String BATTERY_EVENT_TABLE = "BatteryEvent";
+    /** A table name for battery usage history. */
+    public static final String BATTERY_STATE_TABLE = "BatteryState";
     /** A path name for app usage latest timestamp query. */
     public static final String APP_USAGE_LATEST_TIMESTAMP_PATH = "appUsageLatestTimestamp";
     /** A class name for battery usage data provider. */
@@ -84,13 +86,6 @@
      */
     public static final long USAGE_QUERY_BUFFER_HOURS = Duration.ofHours(3).toMillis();
 
-    /** A content URI to access battery usage states data. */
-    public static final Uri BATTERY_CONTENT_URI =
-            new Uri.Builder()
-                    .scheme(ContentResolver.SCHEME_CONTENT)
-                    .authority(AUTHORITY)
-                    .appendPath(BATTERY_STATE_TABLE)
-                    .build();
     /** A content URI to access app usage events data. */
     public static final Uri APP_USAGE_EVENT_URI =
             new Uri.Builder()
@@ -98,6 +93,20 @@
                     .authority(AUTHORITY)
                     .appendPath(APP_USAGE_EVENT_TABLE)
                     .build();
+    /** A content URI to access battery events data. */
+    public static final Uri BATTERY_EVENT_URI =
+            new Uri.Builder()
+                    .scheme(ContentResolver.SCHEME_CONTENT)
+                    .authority(AUTHORITY)
+                    .appendPath(BATTERY_EVENT_TABLE)
+                    .build();
+    /** A content URI to access battery usage states data. */
+    public static final Uri BATTERY_CONTENT_URI =
+            new Uri.Builder()
+                    .scheme(ContentResolver.SCHEME_CONTENT)
+                    .authority(AUTHORITY)
+                    .appendPath(BATTERY_STATE_TABLE)
+                    .build();
 
     // For testing only.
     @VisibleForTesting
@@ -106,6 +115,8 @@
     static Supplier<Cursor> sFakeAppUsageEventSupplier;
     @VisibleForTesting
     static Supplier<Cursor> sFakeAppUsageLatestTimestampSupplier;
+    @VisibleForTesting
+    static Supplier<Cursor> sFakeBatteryEventSupplier;
 
     private DatabaseUtils() {
     }
@@ -176,6 +187,32 @@
         return appUsageEventList;
     }
 
+    /** Returns the battery event data since the query timestamp in battery event table. */
+    public static List<BatteryEvent> getBatteryEvents(
+            Context context,
+            final Calendar calendar,
+            final long rawStartTimestamp) {
+        final long startTime = System.currentTimeMillis();
+        final long sixDaysAgoTimestamp = getTimestampSixDaysAgo(calendar);
+        final long queryTimestamp = Math.max(rawStartTimestamp, sixDaysAgoTimestamp);
+        Log.d(TAG, "getBatteryEvents for timestamp: " + queryTimestamp);
+        // Builds the content uri everytime to avoid cache.
+        final Uri batteryEventUri =
+                new Uri.Builder()
+                        .scheme(ContentResolver.SCHEME_CONTENT)
+                        .authority(AUTHORITY)
+                        .appendPath(BATTERY_EVENT_TABLE)
+                        .appendQueryParameter(
+                                QUERY_KEY_TIMESTAMP, Long.toString(queryTimestamp))
+                        .build();
+
+        final List<BatteryEvent> batteryEventList =
+                loadBatteryEventsFromContentProvider(context, batteryEventUri);
+        Log.d(TAG, String.format("getBatteryEvents size=%d in %d/ms", batteryEventList.size(),
+                (System.currentTimeMillis() - startTime)));
+        return batteryEventList;
+    }
+
     /** Long: for timestamp and String: for BatteryHistEntry.getKey() */
     public static Map<Long, Map<String, BatteryHistEntry>> getHistoryMapSinceLastFullCharge(
             Context context, Calendar calendar) {
@@ -210,8 +247,9 @@
             try {
                 final BatteryStateDatabase database = BatteryStateDatabase
                         .getInstance(context.getApplicationContext());
-                database.batteryStateDao().clearAll();
                 database.appUsageEventDao().clearAll();
+                database.batteryEventDao().clearAll();
+                database.batteryStateDao().clearAll();
             } catch (RuntimeException e) {
                 Log.e(TAG, "clearAll() failed", e);
             }
@@ -226,8 +264,9 @@
                         .getInstance(context.getApplicationContext());
                 final long earliestTimestamp = Clock.systemUTC().millis()
                         - Duration.ofDays(DATA_RETENTION_INTERVAL_DAY).toMillis();
-                database.batteryStateDao().clearAllBefore(earliestTimestamp);
                 database.appUsageEventDao().clearAllBefore(earliestTimestamp);
+                database.batteryEventDao().clearAllBefore(earliestTimestamp);
+                database.batteryStateDao().clearAllBefore(earliestTimestamp);
             } catch (RuntimeException e) {
                 Log.e(TAG, "clearAllBefore() failed", e);
             }
@@ -292,6 +331,23 @@
         return valuesList;
     }
 
+    static ContentValues sendBatteryEventData(
+            final Context context, final BatteryEvent batteryEvent) {
+        final long startTime = System.currentTimeMillis();
+        ContentValues contentValues = ConvertUtils.convertBatteryEventToContentValues(batteryEvent);
+        final ContentResolver resolver = context.getContentResolver();
+        try {
+            resolver.insert(BATTERY_EVENT_URI, contentValues);
+            Log.d(TAG, "insert() battery event data into database: " + batteryEvent.toString());
+        } catch (Exception e) {
+            Log.e(TAG, "insert() battery event data into database error:\n" + e);
+        }
+        Log.d(TAG, String.format("sendBatteryEventData() in %d/ms",
+                (System.currentTimeMillis() - startTime)));
+        clearMemory();
+        return contentValues;
+    }
+
     static List<ContentValues> sendBatteryEntryData(
             final Context context,
             final List<BatteryEntry> batteryEntryList,
@@ -392,6 +448,8 @@
     public static void dump(Context context, PrintWriter writer) {
         writeString(context, writer, "BatteryLevelChanged",
                 Intent.ACTION_BATTERY_LEVEL_CHANGED);
+        writeString(context, writer, "BatteryPlugging",
+                BatteryUsageBroadcastReceiver.ACTION_BATTERY_PLUGGING);
         writeString(context, writer, "BatteryUnplugging",
                 BatteryUsageBroadcastReceiver.ACTION_BATTERY_UNPLUGGING);
         writeString(context, writer, "ClearBatteryCacheData",
@@ -475,6 +533,32 @@
         return appUsageEventList;
     }
 
+    private static List<BatteryEvent> loadBatteryEventsFromContentProvider(
+            Context context, Uri batteryEventUri) {
+        final List<BatteryEvent> batteryEventList = new ArrayList<>();
+        context = getParentContext(context);
+        if (context == null) {
+            return batteryEventList;
+        }
+        try (Cursor cursor = sFakeBatteryEventSupplier != null
+                ? sFakeBatteryEventSupplier.get()
+                : context.getContentResolver().query(batteryEventUri, null, null, null)) {
+            if (cursor == null || cursor.getCount() == 0) {
+                return batteryEventList;
+            }
+            // Loads and recovers all AppUsageEvent data from cursor.
+            while (cursor.moveToNext()) {
+                batteryEventList.add(ConvertUtils.convertToBatteryEventFromCursor(cursor));
+            }
+            try {
+                cursor.close();
+            } catch (Exception e) {
+                Log.e(TAG, "cursor.close() failed", e);
+            }
+        }
+        return batteryEventList;
+    }
+
     private static Map<Long, Map<String, BatteryHistEntry>> loadHistoryMapFromContentProvider(
             Context context, Uri batteryStateUri) {
         context = DatabaseUtils.getParentContext(context);
diff --git a/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventDao.java b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventDao.java
new file mode 100644
index 0000000..a638d09
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventDao.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2023 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.batteryusage.db;
+
+import android.database.Cursor;
+
+import androidx.room.Dao;
+import androidx.room.Insert;
+import androidx.room.OnConflictStrategy;
+import androidx.room.Query;
+
+import java.util.List;
+
+/** Data access object for accessing {@link BatteryEventEntity} in the database. */
+@Dao
+public interface BatteryEventDao {
+    /** Inserts a {@link BatteryEventEntity} data into the database. */
+    @Insert(onConflict = OnConflictStrategy.REPLACE)
+    void insert(BatteryEventEntity event);
+
+    /** Gets all recorded data. */
+    @Query("SELECT * FROM BatteryEventEntity ORDER BY timestamp DESC")
+    List<BatteryEventEntity> getAll();
+
+    /** Gets the {@link Cursor} of all recorded data after a specific timestamp. */
+    @Query("SELECT * FROM BatteryEventEntity WHERE timestamp > :timestamp ORDER BY timestamp DESC")
+    Cursor getAllAfter(long timestamp);
+
+    /** Deletes all recorded data before a specific timestamp. */
+    @Query("DELETE FROM BatteryEventEntity WHERE timestamp <= :timestamp")
+    void clearAllBefore(long timestamp);
+
+    /** Clears all recorded data in the database. */
+    @Query("DELETE FROM BatteryEventEntity")
+    void clearAll();
+}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventEntity.java b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventEntity.java
new file mode 100644
index 0000000..66cadda
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventEntity.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2023 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.batteryusage.db;
+
+import android.content.ContentValues;
+
+import androidx.room.Entity;
+import androidx.room.PrimaryKey;
+
+import com.android.settings.fuelgauge.batteryusage.ConvertUtils;
+
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
+
+import java.util.Locale;
+
+/** A {@link Entity} class to save battery events into database. */
+@Entity
+public class BatteryEventEntity {
+    /** Keys for accessing {@link ContentValues}. */
+    public static final String KEY_TIMESTAMP = "timestamp";
+    public static final String KEY_BATTERY_EVENT_TYPE = "batteryEventType";
+    public static final String KEY_BATTERY_LEVEL = "batteryLevel";
+
+    @PrimaryKey(autoGenerate = true)
+    private long mId;
+
+    public final long timestamp;
+    public final int batteryEventType;
+    public final int batteryLevel;
+
+    public BatteryEventEntity(
+            final long timestamp,
+            final int batteryEventType,
+            final int batteryLevel) {
+        this.timestamp = timestamp;
+        this.batteryEventType = batteryEventType;
+        this.batteryLevel = batteryLevel;
+    }
+
+    /** Sets the auto-generated content ID. */
+    public void setId(long id) {
+        this.mId = id;
+    }
+
+    /** Gets the auto-generated content ID. */
+    public long getId() {
+        return mId;
+    }
+
+    @Override
+    public String toString() {
+        final String recordAtDateTime = ConvertUtils.utcToLocalTimeForLogging(timestamp);
+        final StringBuilder builder = new StringBuilder()
+                .append("\nBatteryEvent{")
+                .append(String.format(Locale.US,
+                        "\n\ttimestamp=%s|batteryEventType=%d|batteryLevel=%d",
+                        recordAtDateTime, batteryEventType, batteryLevel))
+                .append("\n}");
+        return builder.toString();
+    }
+
+    /** Creates new {@link BatteryEventEntity} from {@link ContentValues}. */
+    public static BatteryEventEntity create(ContentValues contentValues) {
+        Builder builder = BatteryEventEntity.newBuilder();
+        if (contentValues.containsKey(KEY_TIMESTAMP)) {
+            builder.setTimestamp(contentValues.getAsLong(KEY_TIMESTAMP));
+        }
+        if (contentValues.containsKey(KEY_BATTERY_EVENT_TYPE)) {
+            builder.setBatteryEventType(contentValues.getAsInteger(KEY_BATTERY_EVENT_TYPE));
+        }
+        if (contentValues.containsKey(KEY_BATTERY_LEVEL)) {
+            builder.setBatteryLevel(contentValues.getAsInteger(KEY_BATTERY_LEVEL));
+        }
+        return builder.build();
+    }
+
+    /** Creates a new {@link Builder} instance. */
+    public static Builder newBuilder() {
+        return new Builder();
+    }
+
+    /** A convenience builder class to improve readability. */
+    public static class Builder {
+        private long mTimestamp;
+        private int mBatteryEventType;
+        private int mBatteryLevel;
+
+        /** Sets the timestamp. */
+        @CanIgnoreReturnValue
+        public Builder setTimestamp(final long timestamp) {
+            mTimestamp = timestamp;
+            return this;
+        }
+
+        /** Sets the battery event type. */
+        @CanIgnoreReturnValue
+        public Builder setBatteryEventType(final int batteryEventType) {
+            mBatteryEventType = batteryEventType;
+            return this;
+        }
+
+        /** Sets the battery level. */
+        @CanIgnoreReturnValue
+        public Builder setBatteryLevel(final int batteryLevel) {
+            mBatteryLevel = batteryLevel;
+            return this;
+        }
+
+        /** Builds the {@link BatteryEventEntity}. */
+        public BatteryEventEntity build() {
+            return new BatteryEventEntity(
+                    mTimestamp,
+                    mBatteryEventType,
+                    mBatteryLevel);
+        }
+
+        private Builder() {}
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/db/BatteryStateDatabase.java b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryStateDatabase.java
index 4c8df7e..466a7ca 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/db/BatteryStateDatabase.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/db/BatteryStateDatabase.java
@@ -25,24 +25,26 @@
 
 /** A {@link RoomDatabase} for battery usage states history. */
 @Database(
-        entities = {BatteryState.class, AppUsageEventEntity.class},
+        entities = {AppUsageEventEntity.class, BatteryEventEntity.class, BatteryState.class},
         version = 1)
 public abstract class BatteryStateDatabase extends RoomDatabase {
     private static final String TAG = "BatteryStateDatabase";
 
     private static BatteryStateDatabase sBatteryStateDatabase;
 
-    /** Provides DAO for battery state table. */
-    public abstract BatteryStateDao batteryStateDao();
     /** Provides DAO for app usage event table. */
     public abstract AppUsageEventDao appUsageEventDao();
+    /** Provides DAO for battery event table. */
+    public abstract BatteryEventDao batteryEventDao();
+    /** Provides DAO for battery state table. */
+    public abstract BatteryStateDao batteryStateDao();
 
     /** Gets or creates an instance of {@link RoomDatabase}. */
     public static BatteryStateDatabase getInstance(Context context) {
         if (sBatteryStateDatabase == null) {
             sBatteryStateDatabase =
                     Room.databaseBuilder(
-                                    context, BatteryStateDatabase.class, "battery-usage-db-v7")
+                                    context, BatteryStateDatabase.class, "battery-usage-db-v8")
                             // Allows accessing data in the main thread for dumping bugreport.
                             .allowMainThreadQueries()
                             .fallbackToDestructiveMigration()
diff --git a/src/com/android/settings/fuelgauge/protos/Android.bp b/src/com/android/settings/fuelgauge/protos/Android.bp
index 2c63af4..3af2aef 100644
--- a/src/com/android/settings/fuelgauge/protos/Android.bp
+++ b/src/com/android/settings/fuelgauge/protos/Android.bp
@@ -8,17 +8,25 @@
 }
 
 java_library {
+    name: "app-usage-event-protos-lite",
+    proto: {
+        type: "lite",
+    },
+    srcs: ["app_usage_event.proto"],
+}
+
+java_library {
+    name: "battery-event-protos-lite",
+    proto: {
+        type: "lite",
+    },
+    srcs: ["battery_event.proto"],
+}
+
+java_library {
     name: "fuelgauge-usage-state-protos-lite",
     proto: {
         type: "lite",
     },
     srcs: ["fuelgauge_usage_state.proto"],
 }
-
-java_library {
-    name: "app-usage-event-protos-lite",
-    proto: {
-        type: "lite",
-    },
-    srcs: ["app_usage_event.proto"],
-}
\ No newline at end of file
diff --git a/src/com/android/settings/fuelgauge/protos/battery_event.proto b/src/com/android/settings/fuelgauge/protos/battery_event.proto
new file mode 100644
index 0000000..80ccb3b
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/protos/battery_event.proto
@@ -0,0 +1,17 @@
+syntax = "proto2";
+
+option java_multiple_files = true;
+option java_package = "com.android.settings.fuelgauge.batteryusage";
+option java_outer_classname = "BatteryEventProto";
+
+enum BatteryEventType {
+  UNKNOWN_EVENT = 0;
+  POWER_CONNECTED = 1;
+  POWER_DISCONNECTED = 2;
+}
+
+message BatteryEvent {
+  optional int64 timestamp = 1;
+  optional BatteryEventType type = 2;
+  optional int32 battery_level = 3;
+}
diff --git a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
index 85b67ea..03461af 100644
--- a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
+++ b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
@@ -16,16 +16,15 @@
 
 package com.android.settings.inputmethod;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.provider.Settings;
 import android.util.FeatureFlagUtils;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
 
-import com.android.settings.Settings.PhysicalKeyboardActivity;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -34,18 +33,14 @@
 
 public class KeyboardSettingsPreferenceController extends BasePreferenceController {
 
-    private Context mContext;
     private CachedBluetoothDevice mCachedDevice;
-    private Activity mActivity;
 
     public KeyboardSettingsPreferenceController(Context context, String key) {
         super(context, key);
-        mContext = context;
     }
 
-    public void init(@NonNull CachedBluetoothDevice cachedDevice, @NonNull Activity activity) {
+    public void init(@NonNull CachedBluetoothDevice cachedDevice) {
         mCachedDevice = cachedDevice;
-        mActivity = activity;
     }
 
     @Override
@@ -53,18 +48,26 @@
         if (!getPreferenceKey().equals(preference.getKey())) {
             return false;
         }
-
-        final Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
-        intent.setClass(mContext, PhysicalKeyboardActivity.class);
-        intent.putExtra(PhysicalKeyboardFragment.EXTRA_BT_ADDRESS, mCachedDevice.getAddress());
-        mActivity.startActivityForResult(intent, 0);
+        List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboardList();
+        for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
+            if (mCachedDevice.getAddress().equals(hardKeyboardDeviceInfo.mBluetoothAddress)) {
+                Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+                intent.putExtra(
+                        NewKeyboardSettingsUtils.EXTRA_INTENT_FROM,
+                        "com.android.settings.inputmethod.KeyboardSettingsPreferenceController");
+                intent.putExtra(
+                        Settings.EXTRA_INPUT_DEVICE_IDENTIFIER,
+                        hardKeyboardDeviceInfo.mDeviceIdentifier);
+                mContext.startActivity(intent);
+                break;
+            }
+        }
         return true;
     }
 
     @Override
     public int getAvailabilityStatus() {
-        final List<HardKeyboardDeviceInfo> newHardKeyboards =
-                PhysicalKeyboardFragment.getHardKeyboards(mContext);
+        List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboardList();
         if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI)
                 && !newHardKeyboards.isEmpty()) {
             for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
@@ -78,4 +81,9 @@
         }
         return CONDITIONALLY_UNAVAILABLE;
     }
+
+    @VisibleForTesting
+    List<HardKeyboardDeviceInfo> getHardKeyboardList() {
+        return PhysicalKeyboardFragment.getHardKeyboards(mContext);
+    }
 }
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
index 0f49ee1..3344f4e 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
@@ -23,6 +23,7 @@
 import android.hardware.input.KeyboardLayout;
 import android.os.Bundle;
 import android.os.UserHandle;
+import android.util.Log;
 import android.view.InputDevice;
 import android.view.inputmethod.InputMethodInfo;
 import android.view.inputmethod.InputMethodManager;
@@ -59,10 +60,19 @@
     public void onActivityCreated(final Bundle icicle) {
         super.onActivityCreated(icicle);
         Bundle arguments = getArguments();
-        final String title =
-                arguments.getString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_DEVICE_NAME);
         mInputDeviceIdentifier =
                 arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
+        if (mInputDeviceIdentifier == null) {
+            Log.e(TAG, "The inputDeviceIdentifier should not be null");
+            return;
+        }
+        InputDevice inputDevice =
+                NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
+        if (inputDevice == null) {
+            Log.e(TAG, "inputDevice is null");
+            return;
+        }
+        final String title = inputDevice.getName();
         getActivity().setTitle(title);
         updateCheckedState();
     }
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
index 761e95e..110147a 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
@@ -47,6 +47,7 @@
                 arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
         if (identifier == null
                 || NewKeyboardSettingsUtils.getInputDevice(inputManager, identifier) == null) {
+            getActivity().finish();
             return;
         }
         getActivity().setTitle(title);
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
index 893ad4c..8278be8 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
@@ -28,6 +28,7 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.core.BasePreferenceController;
+import com.android.settings.widget.TickButtonPreference;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -38,7 +39,7 @@
 public class NewKeyboardLayoutPickerController extends BasePreferenceController implements
         InputManager.InputDeviceListener, LifecycleObserver, OnStart, OnStop {
     private final InputManager mIm;
-    private final Map<KeyboardLayoutPreference, KeyboardLayout> mPreferenceMap;
+    private final Map<TickButtonPreference, KeyboardLayout> mPreferenceMap;
 
     private Fragment mParent;
     private int mInputDeviceId;
@@ -102,16 +103,15 @@
 
     @Override
     public boolean handlePreferenceTreeClick(Preference preference) {
-
-        if (!(preference instanceof KeyboardLayoutPreference)) {
+        if (!(preference instanceof TickButtonPreference)) {
             return false;
         }
 
-        final KeyboardLayoutPreference pref = (KeyboardLayoutPreference) preference;
-        pref.setCheckMark(true);
+        final TickButtonPreference pref = (TickButtonPreference) preference;
+        pref.setSelected(true);
         if (mPreviousSelection != null && !mPreviousSelection.equals(preference.getKey())) {
-            KeyboardLayoutPreference preSelectedPref = mScreen.findPreference(mPreviousSelection);
-            preSelectedPref.setCheckMark(false);
+            TickButtonPreference preSelectedPref = mScreen.findPreference(mPreviousSelection);
+            preSelectedPref.setSelected(false);
         }
         setLayout(pref);
         mPreviousSelection = preference.getKey();
@@ -140,12 +140,13 @@
             return;
         }
         for (KeyboardLayout layout : mKeyboardLayouts) {
-            final KeyboardLayoutPreference pref;
+            final TickButtonPreference pref;
+            pref = new TickButtonPreference(mScreen.getContext());
+            pref.setTitle(layout.getLabel());
+
             if (mLayout.equals(layout.getLabel())) {
-                pref = new KeyboardLayoutPreference(mScreen.getContext(), layout.getLabel(), true);
+                pref.setSelected(true);
                 mPreviousSelection = layout.getDescriptor();
-            } else {
-                pref = new KeyboardLayoutPreference(mScreen.getContext(), layout.getLabel(), false);
             }
             pref.setKey(layout.getDescriptor());
             mScreen.addPreference(pref);
@@ -153,7 +154,7 @@
         }
     }
 
-    private void setLayout(KeyboardLayoutPreference preference) {
+    private void setLayout(TickButtonPreference preference) {
         mIm.setKeyboardLayoutForInputDevice(
                 mInputDeviceIdentifier,
                 mUserId,
diff --git a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
index 506d1e7..fe0c9d4 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
@@ -32,7 +32,12 @@
  */
 public class NewKeyboardSettingsUtils {
 
-    static final String EXTRA_KEYBOARD_DEVICE_NAME = "extra_keyboard_device_name";
+    /**
+     * Record the class name of the intent sender for metrics.
+     */
+    public static final String EXTRA_INTENT_FROM =
+            "com.android.settings.inputmethod.EXTRA_INTENT_FROM";
+
     static final String EXTRA_TITLE = "keyboard_layout_picker_title";
     static final String EXTRA_KEYBOARD_LAYOUT = "keyboard_layout";
     static final String EXTRA_USER_ID = "user_id";
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index e9dba57..22f5b65 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -87,7 +87,6 @@
     @Override
     public void onCreatePreferences(Bundle bundle, String s) {
         Activity activity = Preconditions.checkNotNull(getActivity());
-        mBluetoothAddress = activity.getIntent().getStringExtra(EXTRA_BT_ADDRESS);
         addPreferencesFromResource(R.xml.physical_keyboard_settings);
         mIm = Preconditions.checkNotNull(activity.getSystemService(InputManager.class));
         mImm = Preconditions.checkNotNull(activity.getSystemService(InputMethodManager.class));
@@ -104,6 +103,19 @@
         if (!isModifierKeySettingsEnabled) {
             mKeyboardAssistanceCategory.removePreference(findPreference(MODIFIER_KEYS_SETTINGS));
         }
+        InputDeviceIdentifier inputDeviceIdentifier = activity.getIntent().getParcelableExtra(
+                KeyboardLayoutPickerFragment.EXTRA_INPUT_DEVICE_IDENTIFIER);
+        // TODO (b/271391879): The EXTRA_INTENT_FROM is used for the future metrics.
+        if (inputDeviceIdentifier != null) {
+            Bundle arguments = new Bundle();
+            arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
+                    inputDeviceIdentifier);
+            new SubSettingLauncher(getContext())
+                    .setSourceMetricsCategory(getMetricsCategory())
+                    .setDestination(NewKeyboardLayoutEnabledLocalesFragment.class.getName())
+                    .setArguments(arguments)
+                    .launch();
+        }
     }
 
     @Override
@@ -187,14 +199,6 @@
         preferenceScreen.addPreference(category);
 
         for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
-
-            // if user go into this page from Connected devices entry, we should distinguish the
-            // user-selected keyboard from all enabled keyboards.
-            if (mBluetoothAddress != null
-                    && !mBluetoothAddress.equals(hardKeyboardDeviceInfo.mBluetoothAddress)) {
-                continue;
-            }
-
             // TODO(yukawa): Consider using com.android.settings.widget.GearPreference
             final Preference pref = new Preference(getPrefContext());
             pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
@@ -247,7 +251,6 @@
         Bundle arguments = new Bundle();
         arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
                 inputDeviceIdentifier);
-        arguments.putString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_DEVICE_NAME, keyboardName);
         new SubSettingLauncher(getContext())
                 .setSourceMetricsCategory(getMetricsCategory())
                 .setDestination(NewKeyboardLayoutEnabledLocalesFragment.class.getName())
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
index 3dcae09..1f01b98 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
@@ -17,8 +17,10 @@
 package com.android.settings.inputmethod;
 
 import android.content.Context;
+import android.content.Intent;
 import android.hardware.input.InputManager;
 import android.icu.text.ListFormatter;
+import android.provider.Settings;
 
 import androidx.preference.Preference;
 
@@ -59,6 +61,19 @@
     }
 
     @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (!getPreferenceKey().equals(preference.getKey())) {
+            return false;
+        }
+        Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+        intent.putExtra(
+                NewKeyboardSettingsUtils.EXTRA_INTENT_FROM,
+                "com.android.settings.inputmethod.PhysicalKeyboardPreferenceController");
+        mContext.startActivity(intent);
+        return true;
+    }
+
+    @Override
     public void updateState(Preference preference) {
         mPreference = preference;
         updateEntry();
diff --git a/src/com/android/settings/network/DefaultSubscriptionReceiver.java b/src/com/android/settings/network/DefaultSubscriptionReceiver.java
new file mode 100644
index 0000000..cdaf48f
--- /dev/null
+++ b/src/com/android/settings/network/DefaultSubscriptionReceiver.java
@@ -0,0 +1,59 @@
+package com.android.settings.network;
+
+import static com.android.internal.telephony.TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+
+public class DefaultSubscriptionReceiver extends BroadcastReceiver {
+
+    private Context mContext;
+    private DefaultSubscriptionListener mListener;
+
+    public DefaultSubscriptionReceiver(Context context, DefaultSubscriptionListener listener) {
+        mContext = context;
+        mListener = listener;
+    }
+
+    public void registerReceiver() {
+        final IntentFilter filter = new IntentFilter();
+        filter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
+        filter.addAction(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
+        filter.addAction(ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED);
+        filter.addAction(SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED);
+        mContext.registerReceiver(this, filter);
+    }
+
+    public void unRegisterReceiver() {
+        mContext.unregisterReceiver(this);
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        String action = intent.getAction();
+        if (TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED.equals(action)) {
+            mListener.onDefaultDataChanged(SubscriptionManager.getDefaultDataSubscriptionId());
+        } else if (SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED.equals(action)) {
+            mListener.onDefaultSubInfoChanged(SubscriptionManager.getDefaultSubscriptionId());
+        } else if (TelephonyManager.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED.equals(action)) {
+            mListener.onDefaultVoiceChanged(SubscriptionManager.getDefaultVoiceSubscriptionId());
+        } else if (SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED.equals(action)) {
+            mListener.onDefaultSmsChanged(SubscriptionManager.getDefaultSmsSubscriptionId());
+        }
+    }
+
+    public interface DefaultSubscriptionListener {
+        default void onDefaultSubInfoChanged(int defaultSubId) {
+        }
+        default void onDefaultDataChanged(int defaultDataSubId) {
+        }
+        default void onDefaultVoiceChanged(int defaultVoiceSubId) {
+        }
+        default void onDefaultSmsChanged(int defaultSmsSubId) {
+        }
+    }
+}
diff --git a/src/com/android/settings/network/InternetPreferenceController.java b/src/com/android/settings/network/InternetPreferenceController.java
index 898585c..bc2e71e 100644
--- a/src/com/android/settings/network/InternetPreferenceController.java
+++ b/src/com/android/settings/network/InternetPreferenceController.java
@@ -27,9 +27,7 @@
 
 import android.content.Context;
 import android.graphics.drawable.Drawable;
-import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
-import android.util.Log;
 
 import androidx.annotation.IdRes;
 import androidx.annotation.VisibleForTesting;
@@ -45,9 +43,7 @@
 import com.android.settings.wifi.WifiSummaryUpdater;
 import com.android.settingslib.Utils;
 import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
 import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
 import com.android.settingslib.utils.ThreadUtils;
 
 import java.util.ArrayList;
@@ -60,7 +56,8 @@
  */
 public class InternetPreferenceController extends AbstractPreferenceController implements
         LifecycleObserver, SummaryUpdater.OnSummaryChangeListener,
-        InternetUpdater.InternetChangeListener, MobileNetworkRepository.MobileNetworkCallback  {
+        InternetUpdater.InternetChangeListener, MobileNetworkRepository.MobileNetworkCallback,
+        DefaultSubscriptionReceiver.DefaultSubscriptionListener {
 
     public static final String KEY = "internet_settings";
 
@@ -71,6 +68,8 @@
     private LifecycleOwner mLifecycleOwner;
     private MobileNetworkRepository mMobileNetworkRepository;
     private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
+    private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+    private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
 
     @VisibleForTesting
     static Map<Integer, Integer> sIconMap = new HashMap<>();
@@ -102,6 +101,7 @@
         mInternetType = mInternetUpdater.getInternetType();
         mLifecycleOwner = lifecycleOwner;
         mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+        mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
         lifecycle.addObserver(this);
     }
 
@@ -160,6 +160,8 @@
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
         mMobileNetworkRepository.updateEntity();
         mSummaryHelper.register(true);
+        mDataSubscriptionChangedReceiver.registerReceiver();
+        mDefaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
     }
 
     /** @OnLifecycleEvent(ON_PAUSE) */
@@ -167,6 +169,7 @@
     public void onPause() {
         mMobileNetworkRepository.removeRegister(this);
         mSummaryHelper.register(false);
+        mDataSubscriptionChangedReceiver.unRegisterReceiver();
     }
 
     /**
@@ -212,11 +215,11 @@
             if (subInfo.isActiveDataSubscriptionId) {
                 activeSubInfo = subInfo;
             }
-            if (subInfo.isDefaultDataSubscription) {
+            if (subInfo.getSubId() == getDefaultDataSubscriptionId()) {
                 defaultSubInfo = subInfo;
             }
         }
-        if (activeSubInfo == null) {
+        if (activeSubInfo == null || defaultSubInfo == null) {
             return;
         }
         activeSubInfo = activeSubInfo.isSubscriptionVisible ? activeSubInfo : defaultSubInfo;
@@ -237,9 +240,20 @@
         return mSubInfoEntityList;
     }
 
+    @VisibleForTesting
+    protected int getDefaultDataSubscriptionId() {
+        return mDefaultDataSubId;
+    }
+
     @Override
     public void onAvailableSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
         mSubInfoEntityList = subInfoEntityList;
         updateState(mPreference);
     }
+
+    @Override
+    public void onDefaultDataChanged(int defaultDataSubId) {
+        mDefaultDataSubId = defaultDataSubId;
+        updateState(mPreference);
+    }
 }
diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index bec65e2..170d921 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -18,14 +18,9 @@
 import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING;
 import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
 
-import static com.android.internal.telephony.TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED;
-
 import android.annotation.NonNull;
 import android.app.settings.SettingsEnums;
-import android.content.BroadcastReceiver;
 import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
 import android.database.ContentObserver;
 import android.net.Uri;
 import android.os.Handler;
@@ -39,6 +34,7 @@
 import android.telephony.UiccPortInfo;
 import android.telephony.UiccSlotInfo;
 import android.util.ArrayMap;
+import android.util.IndentingPrintWriter;
 import android.util.Log;
 
 import com.android.settings.network.telephony.MobileNetworkUtils;
@@ -98,7 +94,6 @@
     private AirplaneModeObserver mAirplaneModeObserver;
     private Uri mAirplaneModeSettingUri;
     private MetricsFeatureProvider mMetricsFeatureProvider;
-    private IntentFilter mFilter = new IntentFilter();
     private Map<Integer, MobileDataContentObserver> mDataContentObserverMap = new HashMap<>();
     private int mPhysicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
     private int mLogicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
@@ -111,12 +106,7 @@
     private Map<Integer, SubscriptionInfo> mSubscriptionInfoMap = new ArrayMap<>();
     private Map<Integer, TelephonyManager> mTelephonyManagerMap = new HashMap<>();
     private Map<Integer, PhoneCallStateTelephonyCallback> mTelephonyCallbackMap = new HashMap<>();
-    private BroadcastReceiver mDataSubscriptionChangedReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            onSubscriptionsChanged();
-        }
-    };
+
     @NonNull
     public static MobileNetworkRepository getInstance(Context context) {
         synchronized (sInstanceLock) {
@@ -142,10 +132,6 @@
         mMobileNetworkInfoDao = mMobileNetworkDatabase.mMobileNetworkInfoDao();
         mAirplaneModeObserver = new AirplaneModeObserver(new Handler(Looper.getMainLooper()));
         mAirplaneModeSettingUri = Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON);
-        mFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
-        mFilter.addAction(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
-        mFilter.addAction(ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED);
-        mFilter.addAction(SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED);
     }
 
     private class AirplaneModeObserver extends ContentObserver {
@@ -187,7 +173,6 @@
             mSubscriptionManager.addOnSubscriptionsChangedListener(mContext.getMainExecutor(),
                     this);
             mAirplaneModeObserver.register(mContext);
-            mContext.registerReceiver(mDataSubscriptionChangedReceiver, mFilter);
             if (DEBUG) {
                 Log.d(TAG, "addRegister done");
             }
@@ -270,7 +255,6 @@
         if (sCallbacks.isEmpty()) {
             mSubscriptionManager.removeOnSubscriptionsChangedListener(this);
             mAirplaneModeObserver.unRegister(mContext);
-            mContext.unregisterReceiver(mDataSubscriptionChangedReceiver);
             mDataContentObserverMap.forEach((id, observer) -> {
                 observer.unRegister(mContext);
             });
@@ -523,16 +507,11 @@
                     SubscriptionUtil.getFormattedPhoneNumber(context, subInfo),
                     firstRemovableSubInfo == null ? false
                             : firstRemovableSubInfo.getSubscriptionId() == subId,
-                    String.valueOf(SubscriptionUtil.getDefaultSimConfig(context, subId)),
                     SubscriptionUtil.isDefaultSubscription(context, subId),
                     mSubscriptionManager.isValidSubscriptionId(subId),
                     mSubscriptionManager.isUsableSubscriptionId(subId),
                     mSubscriptionManager.isActiveSubscriptionId(subId),
                     true /*availableSubInfo*/,
-                    mSubscriptionManager.getDefaultVoiceSubscriptionId() == subId,
-                    mSubscriptionManager.getDefaultSmsSubscriptionId() == subId,
-                    mSubscriptionManager.getDefaultDataSubscriptionId() == subId,
-                    mSubscriptionManager.getDefaultSubscriptionId() == subId,
                     mSubscriptionManager.getActiveDataSubscriptionId() == subId);
         }
     }
@@ -736,4 +715,17 @@
         default void onCallStateChanged(int state) {
         }
     }
+
+    public void dump(IndentingPrintWriter printwriter) {
+        printwriter.println(TAG + ": ");
+        printwriter.increaseIndent();
+        printwriter.println(" availableSubInfoEntityList= " + mAvailableSubInfoEntityList);
+        printwriter.println(" activeSubInfoEntityList=" + mActiveSubInfoEntityList);
+        printwriter.println(" mobileNetworkInfoEntityList= " + mMobileNetworkInfoEntityList);
+        printwriter.println(" uiccInfoEntityList= " + mUiccInfoEntityList);
+        printwriter.println(" CacheSubscriptionInfoEntityMap= " + sCacheSubscriptionInfoEntityMap);
+        printwriter.println(" SubscriptionInfoMap= " + mSubscriptionInfoMap);
+        printwriter.flush();
+        printwriter.decreaseIndent();
+    }
 }
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 39cf136..4ea3464 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -30,6 +30,7 @@
 import androidx.lifecycle.LifecycleOwner;
 
 import com.android.settings.R;
+import com.android.settings.SettingsDumpService;
 import com.android.settings.Utils;
 import com.android.settings.core.OnActivityResultListener;
 import com.android.settings.dashboard.DashboardFragment;
@@ -122,6 +123,11 @@
         }
         controllers.add(privateDnsPreferenceController);
         controllers.add(new NetworkProviderCallsSmsController(context, lifecycle, lifecycleOwner));
+
+        // Start SettingsDumpService after the MobileNetworkRepository is created.
+        Intent intent = new Intent(context, SettingsDumpService.class);
+        intent.putExtra(SettingsDumpService.EXTRA_KEY_SHOW_NETWORK_DUMP, true);
+        context.startService(intent);
         return controllers;
     }
 
diff --git a/src/com/android/settings/network/NetworkProviderCallsSmsController.java b/src/com/android/settings/network/NetworkProviderCallsSmsController.java
index 0c71aa7..5eec3d9 100644
--- a/src/com/android/settings/network/NetworkProviderCallsSmsController.java
+++ b/src/com/android/settings/network/NetworkProviderCallsSmsController.java
@@ -38,14 +38,13 @@
 import com.android.settingslib.Utils;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
 import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
 
 import java.util.List;
 
 public class NetworkProviderCallsSmsController extends AbstractPreferenceController implements
-        LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback {
+        LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback,
+        DefaultSubscriptionReceiver.DefaultSubscriptionListener {
 
     private static final String TAG = "NetworkProviderCallsSmsController";
     private static final String KEY = "calls_and_sms";
@@ -58,6 +57,9 @@
     private LifecycleOwner mLifecycleOwner;
     private MobileNetworkRepository mMobileNetworkRepository;
     private List<SubscriptionInfoEntity> mSubInfoEntityList;
+    private int mDefaultVoiceSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+    private int mDefaultSmsSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+    private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
 
     /**
      * The summary text and click behavior of the "Calls & SMS" item on the
@@ -73,6 +75,7 @@
                 == View.LAYOUT_DIRECTION_RTL;
         mLifecycleOwner = lifecycleOwner;
         mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+        mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
         if (lifecycle != null) {
             lifecycle.addObserver(this);
         }
@@ -83,11 +86,15 @@
         mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
         mMobileNetworkRepository.updateEntity();
+        mDataSubscriptionChangedReceiver.registerReceiver();
+        mDefaultVoiceSubId = SubscriptionManager.getDefaultVoiceSubscriptionId();
+        mDefaultSmsSubId = SubscriptionManager.getDefaultSmsSubscriptionId();
     }
 
     @OnLifecycleEvent(Event.ON_PAUSE)
     public void onPause() {
         mMobileNetworkRepository.removeRegister(this);
+        mDataSubscriptionChangedReceiver.unRegisterReceiver();
     }
 
     @Override
@@ -145,16 +152,16 @@
     protected CharSequence getPreferredStatus(SubscriptionInfoEntity subInfo, int subsSize,
             int subId) {
         String status = "";
-        boolean isDataPreferred = subInfo.isDefaultVoiceSubscription;
-        boolean isSmsPreferred = subInfo.isDefaultSmsSubscription;
+        boolean isCallPreferred = subInfo.getSubId() == getDefaultVoiceSubscriptionId();
+        boolean isSmsPreferred = subInfo.getSubId() == getDefaultSmsSubscriptionId();
 
         if (!subInfo.isValidSubscription || !isInService(subId)) {
             status = setSummaryResId(subsSize > 1 ? R.string.calls_sms_unavailable :
                     R.string.calls_sms_temp_unavailable);
         } else {
-            if (isDataPreferred && isSmsPreferred) {
+            if (isCallPreferred && isSmsPreferred) {
                 status = setSummaryResId(R.string.calls_sms_preferred);
-            } else if (isDataPreferred) {
+            } else if (isCallPreferred) {
                 status = setSummaryResId(R.string.calls_sms_calls_preferred);
             } else if (isSmsPreferred) {
                 status = setSummaryResId(R.string.calls_sms_sms_preferred);
@@ -226,4 +233,26 @@
         mSubInfoEntityList = activeSubInfoList;
         update();
     }
+
+    @VisibleForTesting
+    protected int getDefaultVoiceSubscriptionId() {
+        return mDefaultVoiceSubId;
+    }
+
+    @VisibleForTesting
+    protected int getDefaultSmsSubscriptionId() {
+        return mDefaultSmsSubId;
+    }
+
+    @Override
+    public void onDefaultVoiceChanged(int defaultVoiceSubId) {
+        mDefaultVoiceSubId = defaultVoiceSubId;
+        update();
+    }
+
+    @Override
+    public void onDefaultSmsChanged(int defaultSmsSubId) {
+        mDefaultSmsSubId = defaultSmsSubId;
+        update();
+    }
 }
diff --git a/src/com/android/settings/network/NetworkProviderSimListController.java b/src/com/android/settings/network/NetworkProviderSimListController.java
index db27291..89cb73c 100644
--- a/src/com/android/settings/network/NetworkProviderSimListController.java
+++ b/src/com/android/settings/network/NetworkProviderSimListController.java
@@ -23,7 +23,6 @@
 import android.graphics.drawable.Drawable;
 import android.telephony.SubscriptionManager;
 import android.util.ArrayMap;
-import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.lifecycle.LifecycleOwner;
@@ -38,16 +37,15 @@
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
 import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 public class NetworkProviderSimListController extends AbstractPreferenceController implements
-        LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback {
+        LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback,
+        DefaultSubscriptionReceiver.DefaultSubscriptionListener {
     private static final String TAG = "NetworkProviderSimListCtrl";
     private static final String KEY_PREFERENCE_CATEGORY_SIM = "provider_model_sim_category";
     private static final String KEY_PREFERENCE_SIM = "provider_model_sim_list";
@@ -58,6 +56,7 @@
     private LifecycleOwner mLifecycleOwner;
     private MobileNetworkRepository mMobileNetworkRepository;
     private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
+    private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
 
     public NetworkProviderSimListController(Context context, Lifecycle lifecycle,
             LifecycleOwner lifecycleOwner) {
@@ -66,6 +65,7 @@
         mPreferences = new ArrayMap<>();
         mLifecycleOwner = lifecycleOwner;
         mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+        mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
         lifecycle.addObserver(this);
     }
 
@@ -74,11 +74,13 @@
         mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
         mMobileNetworkRepository.updateEntity();
+        mDataSubscriptionChangedReceiver.registerReceiver();
     }
 
     @OnLifecycleEvent(ON_PAUSE)
     public void onPause() {
         mMobileNetworkRepository.removeRegister(this);
+        mDataSubscriptionChangedReceiver.unRegisterReceiver();
     }
 
     @Override
@@ -130,7 +132,8 @@
 
     public CharSequence getSummary(SubscriptionInfoEntity subInfo, CharSequence displayName) {
         if (subInfo.isActiveSubscriptionId) {
-            CharSequence config = subInfo.defaultSimConfig;
+            CharSequence config = SubscriptionUtil.getDefaultSimConfig(mContext,
+                    subInfo.getSubId());
             CharSequence summary = mContext.getResources().getString(
                     R.string.sim_category_active_sim);
             if (config == "") {
@@ -185,4 +188,22 @@
         refreshSummary(mPreferenceCategory);
         update();
     }
+
+    @Override
+    public void onDefaultDataChanged(int defaultDataSubId) {
+        refreshSummary(mPreferenceCategory);
+        update();
+    }
+
+    @Override
+    public void onDefaultVoiceChanged(int defaultVoiceSubId) {
+        refreshSummary(mPreferenceCategory);
+        update();
+    }
+
+    @Override
+    public void onDefaultSmsChanged(int defaultSmsSubId) {
+        refreshSummary(mPreferenceCategory);
+        update();
+    }
 }
diff --git a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
index de45e62..249c855 100644
--- a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
@@ -40,10 +40,12 @@
 
     @Override
     protected int getDefaultSubscriptionId() {
+        int defaultCallSubId = SubscriptionManager.getDefaultVoiceSubscriptionId();
         for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) {
-            if (subInfo.isActiveSubscriptionId && subInfo.isDefaultVoiceSubscription) {
+            int subId = subInfo.getSubId();
+            if (subInfo.isActiveSubscriptionId && subId == defaultCallSubId) {
                 mSubscriptionInfoEntity = subInfo;
-                return Integer.parseInt(subInfo.subId);
+                return subId;
             }
         }
         return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
diff --git a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
index c8f7acf..cb18b33 100644
--- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
@@ -36,11 +36,10 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
+import com.android.settings.network.DefaultSubscriptionReceiver;
 import com.android.settings.network.MobileNetworkRepository;
 import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
 import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -52,7 +51,8 @@
  */
 public abstract class DefaultSubscriptionController extends TelephonyBasePreferenceController
         implements LifecycleObserver, Preference.OnPreferenceChangeListener,
-        MobileNetworkRepository.MobileNetworkCallback {
+        MobileNetworkRepository.MobileNetworkCallback,
+        DefaultSubscriptionReceiver.DefaultSubscriptionListener {
     private static final String TAG = "DefaultSubController";
 
     protected ListPreference mPreference;
@@ -60,6 +60,7 @@
     protected TelecomManager mTelecomManager;
     protected MobileNetworkRepository mMobileNetworkRepository;
     protected LifecycleOwner mLifecycleOwner;
+    private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
 
     private static final String EMERGENCY_ACCOUNT_HANDLE_ID = "E";
     private static final ComponentName PSTN_CONNECTION_SERVICE_COMPONENT =
@@ -76,6 +77,7 @@
         mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
                 == View.LAYOUT_DIRECTION_RTL;
         mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+        mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
         mLifecycleOwner = lifecycleOwner;
         if (lifecycle != null) {
             lifecycle.addObserver(this);
@@ -110,12 +112,13 @@
         // Can not get default subId from database until get the callback, add register by subId
         // later.
         mMobileNetworkRepository.addRegisterBySubId(getDefaultSubscriptionId());
-
+        mDataSubscriptionChangedReceiver.registerReceiver();
     }
 
     @OnLifecycleEvent(ON_PAUSE)
     public void onPause() {
         mMobileNetworkRepository.removeRegister(this);
+        mDataSubscriptionChangedReceiver.unRegisterReceiver();
     }
 
     @Override
@@ -308,4 +311,16 @@
         updateEntries();
         refreshSummary(mPreference);
     }
+
+    @Override
+    public void onDefaultVoiceChanged(int defaultVoiceSubId) {
+        updateEntries();
+        refreshSummary(mPreference);
+    }
+
+    @Override
+    public void onDefaultSmsChanged(int defaultSmsSubId) {
+        updateEntries();
+        refreshSummary(mPreference);
+    }
 }
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index cf78942..4b6a728 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -20,8 +20,6 @@
 import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
 
 import android.content.Context;
-import android.os.Handler;
-import android.os.Looper;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -36,13 +34,11 @@
 import androidx.preference.SwitchPreference;
 
 import com.android.settings.R;
-import com.android.settings.network.MobileDataContentObserver;
 import com.android.settings.network.MobileNetworkRepository;
 import com.android.settings.wifi.WifiPickerTrackerHelper;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
 import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -234,13 +230,14 @@
     public void onActiveSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
         mSubscriptionInfoEntityList = subInfoEntityList;
         mSubscriptionInfoEntityList.forEach(entity -> {
-            if (Integer.parseInt(entity.subId) == mSubId) {
+            if (entity.getSubId() == mSubId) {
                 mSubscriptionInfoEntity = entity;
             }
         });
+        int subId = mSubscriptionInfoEntity.getSubId();
         if (mSubscriptionInfoEntity != null
-                && mSubscriptionInfoEntity.isDefaultDataSubscription) {
-            mDefaultSubId = Integer.parseInt(mSubscriptionInfoEntity.subId);
+                && subId == SubscriptionManager.getDefaultDataSubscriptionId()) {
+            mDefaultSubId = subId;
         }
         update();
         refreshSummary(mPreference);
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 265eb16..02455a1 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -1011,7 +1011,7 @@
     private static CharSequence getPreferredCallStatus(Context context,
             SubscriptionInfoEntity subInfo) {
         String status = "";
-        if (subInfo.isDefaultVoiceSubscription) {
+        if (subInfo.getSubId() == SubscriptionManager.getDefaultVoiceSubscriptionId()) {
             status = setSummaryResId(context, R.string.calls_sms_preferred);
         }
 
@@ -1021,7 +1021,7 @@
     private static CharSequence getPreferredSmsStatus(Context context,
             SubscriptionInfoEntity subInfo) {
         String status = "";
-        if (subInfo.isDefaultSmsSubscription) {
+        if (subInfo.getSubId() == SubscriptionManager.getDefaultSmsSubscriptionId()) {
             status = setSummaryResId(context, R.string.calls_sms_preferred);
         }
 
diff --git a/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java
index fddd358..be37513 100644
--- a/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java
@@ -44,10 +44,12 @@
 
     @Override
     protected int getDefaultSubscriptionId() {
+        int defaultSmsSubId = SubscriptionManager.getDefaultSmsSubscriptionId();
         for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) {
-            if (subInfo.isActiveSubscriptionId && subInfo.isDefaultSmsSubscription) {
+            int subId = subInfo.getSubId();
+            if (subInfo.isActiveSubscriptionId && subId == defaultSmsSubId) {
                 mSubscriptionInfoEntity = subInfo;
-                return Integer.parseInt(subInfo.subId);
+                return subId;
             }
         }
         return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index edd9188..2a30b42 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -911,6 +911,10 @@
                         mIsManagedProfile));
                 setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE);
                 mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0));
+
+                // Hide the pin_confirm option when we are just asking user to confirm the pwd.
+                mAutoPinConfirmOption.setVisibility(View.GONE);
+                mAutoConfirmSecurityMessage.setVisibility(View.GONE);
             }
             final int stage = getStageType();
             if (getStageType() != Stage.TYPE_NONE) {
@@ -1017,12 +1021,14 @@
                             profileCredential);
                 }
             }
-            mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
-                    mChosenPassword, mCurrentCredential, mUserId);
-            // update the pin_auto_confirm setting accordingly.
+            // update the setting before triggering the password save workflow,
+            // so that pinLength information is stored accordingly when setting is turned on.
             mLockPatternUtils.setAutoPinConfirm(
                     (mAutoPinConfirmOption != null && mAutoPinConfirmOption.isChecked()),
                     mUserId);
+
+            mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
+                    mChosenPassword, mCurrentCredential, mUserId);
         }
 
         @Override
diff --git a/src/com/android/settings/regionalpreferences/NumberingSystemItemController.java b/src/com/android/settings/regionalpreferences/NumberingSystemItemController.java
index 8e2d735..8b851b8 100644
--- a/src/com/android/settings/regionalpreferences/NumberingSystemItemController.java
+++ b/src/com/android/settings/regionalpreferences/NumberingSystemItemController.java
@@ -34,6 +34,7 @@
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.widget.TickButtonPreference;
 
 import java.util.Locale;
 
@@ -138,7 +139,7 @@
                 String key = supportedLocale.getUnicodeLocaleType(
                         ExtensionTypes.NUMBERING_SYSTEM);
                 pref.setKey(key == null ? RegionalPreferencesDataUtils.DEFAULT_VALUE : key);
-                pref.setTickEnable(isSameNumberingSystem(targetLocale, supportedLocale));
+                pref.setSelected(isSameNumberingSystem(targetLocale, supportedLocale));
                 screen.addPreference(pref);
             }
         }
@@ -162,7 +163,7 @@
             TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(i);
             Log.i(TAG, "[onPreferenceClick] key is " + pref.getKey());
             if (pref.getKey().equals(preference.getKey())) {
-                pref.setTickEnable(true);
+                pref.setSelected(true);
                 Locale updatedLocale =
                         saveNumberingSystemToLocale(
                                 Locale.forLanguageTag(mSelectedLanguage), pref.getKey());
@@ -176,7 +177,7 @@
                 mParentFragment.setArguments(bundle);
                 continue;
             }
-            pref.setTickEnable(false);
+            pref.setSelected(false);
         }
     }
 
diff --git a/src/com/android/settings/regionalpreferences/RegionalPreferencesFragment.java b/src/com/android/settings/regionalpreferences/RegionalPreferencesFragment.java
index 03bc8ac..ea9b7b3 100644
--- a/src/com/android/settings/regionalpreferences/RegionalPreferencesFragment.java
+++ b/src/com/android/settings/regionalpreferences/RegionalPreferencesFragment.java
@@ -29,6 +29,7 @@
 
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.widget.TickButtonPreference;
 
 /** A fragment to include each kind of regional preferences. */
 public class RegionalPreferencesFragment extends SettingsPreferenceFragment {
@@ -63,7 +64,7 @@
             TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(i);
             Log.i(TAG, "[onPreferenceClick] key is " + pref.getKey());
             if (pref.getKey().equals(preference.getKey())) {
-                pref.setTickEnable(true);
+                pref.setSelected(true);
                 RegionalPreferencesDataUtils.savePreference(
                         getPrefContext(),
                         mType,
@@ -72,7 +73,7 @@
                                 ? null : preference.getKey());
                 continue;
             }
-            pref.setTickEnable(false);
+            pref.setSelected(false);
         }
         return true;
     }
@@ -115,7 +116,7 @@
             String value = RegionalPreferencesDataUtils.getDefaultUnicodeExtensionData(
                     getPrefContext(), mType);
             pref.setKey(item);
-            pref.setTickEnable(!value.isEmpty() && item.equals(value));
+            pref.setSelected(!value.isEmpty() && item.equals(value));
             mPreferenceScreen.addPreference(pref);
         }
         return super.onCreateView(inflater, container, savedInstanceState);
diff --git a/src/com/android/settings/regionalpreferences/TickButtonPreference.java b/src/com/android/settings/regionalpreferences/TickButtonPreference.java
deleted file mode 100644
index c01521f..0000000
--- a/src/com/android/settings/regionalpreferences/TickButtonPreference.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.regionalpreferences;
-
-import android.content.Context;
-import android.view.View;
-
-import androidx.preference.PreferenceViewHolder;
-
-import com.android.settings.R;
-import com.android.settingslib.widget.TwoTargetPreference;
-
-/** A preference with tick button */
-public class TickButtonPreference extends TwoTargetPreference {
-    private static final String TAG = TickButtonPreference.class.getSimpleName();
-    private boolean mIsTickEnabled;
-    private View mWidgetFrame;
-    private View mDivider;
-
-    public TickButtonPreference(Context context) {
-        super(context, null);
-    }
-
-    /** Set this preference to be selected. */
-    public void setTickEnable(boolean isEnable) {
-        mIsTickEnabled = isEnable;
-        if (mWidgetFrame != null) {
-            mWidgetFrame.setVisibility(isEnable ? View.VISIBLE : View.INVISIBLE);
-        }
-    }
-
-    /** Check if this preference is selected. */
-    public boolean isTickEnabled() {
-        return mIsTickEnabled;
-    }
-
-    @Override
-    public void onBindViewHolder(PreferenceViewHolder holder) {
-        super.onBindViewHolder(holder);
-        mDivider = holder.findViewById(R.id.two_target_divider);
-        mWidgetFrame = holder.findViewById(android.R.id.widget_frame);
-        if (mDivider != null) {
-            mDivider.setVisibility(View.GONE);
-        }
-        if (mWidgetFrame != null) {
-            mWidgetFrame.setVisibility(mIsTickEnabled ? View.VISIBLE : View.INVISIBLE);
-        }
-    }
-
-    @Override
-    protected int getSecondTargetResId() {
-        super.getSecondTargetResId();
-        return R.layout.preference_widget_tick;
-    }
-}
diff --git a/src/com/android/settings/search/SearchResultTrampoline.java b/src/com/android/settings/search/SearchResultTrampoline.java
index bcd8ee0..6ba0338 100644
--- a/src/com/android/settings/search/SearchResultTrampoline.java
+++ b/src/com/android/settings/search/SearchResultTrampoline.java
@@ -102,7 +102,8 @@
 
         intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
 
-        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
+        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)
+                || ActivityEmbeddingUtils.isAlreadyEmbedded(this)) {
             startActivity(intent);
         } else if (isSettingsIntelligence(callingActivity)) {
             if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SETTINGS_SEARCH_ALWAYS_EXPAND)) {
diff --git a/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java b/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
index ff4a8b7..a41a0b2 100644
--- a/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
+++ b/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
@@ -16,14 +16,19 @@
 
 package com.android.settings.security.screenlock;
 
+import static com.android.internal.widget.LockPatternUtils.MIN_AUTO_PIN_REQUIREMENT_LENGTH;
+
 import android.content.Context;
 
 import androidx.preference.Preference;
 import androidx.preference.TwoStatePreference;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
 import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.password.ChooseLockSettingsHelper;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
 
 /**
  * Preference controller for the pin_auto_confirm setting.
@@ -32,21 +37,23 @@
         PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
 
     private static final String PREF_KEY_PIN_AUTO_CONFIRM = "auto_pin_confirm";
-    private static final long MIN_AUTO_PIN_REQUIREMENT_LENGTH = 6L;
 
     private final int mUserId;
     private final LockPatternUtils mLockPatternUtils;
+    private final ObservablePreferenceFragment mParentFragment;
 
     public AutoPinConfirmPreferenceController(Context context, int userId,
-            LockPatternUtils lockPatternUtils) {
+            LockPatternUtils lockPatternUtils,
+            ObservablePreferenceFragment parentFragment) {
         super(context);
         mUserId = userId;
         mLockPatternUtils = lockPatternUtils;
+        mParentFragment = parentFragment;
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
-        setPinAutoConfirmSettingState((boolean) newValue);
+        launchPinConfirmActivity((boolean) newValue);
         return true;
     }
 
@@ -82,4 +89,18 @@
     private void setPinAutoConfirmSettingState(boolean state) {
         mLockPatternUtils.setAutoPinConfirm(state, mUserId);
     }
+
+    private void launchPinConfirmActivity(boolean newState) {
+        new ChooseLockSettingsHelper.Builder(mParentFragment.getActivity(), mParentFragment)
+                .setUserId(mUserId)
+                .setRequestCode(newState
+                        ? ScreenLockSettings.AUTO_PIN_SETTING_ENABLING_REQUEST_CODE
+                        : ScreenLockSettings.AUTO_PIN_SETTING_DISABLING_REQUEST_CODE)
+                .setTitle(mContext.getString(R.string.lock_screen_auto_pin_confirm_title))
+                .setDescription(newState
+                        ? mContext.getString(R.string.auto_confirm_on_pin_verify_description)
+                        : mContext.getString(R.string.auto_confirm_off_pin_verify_description))
+                .setReturnCredentials(true)
+                .show();
+    }
 }
diff --git a/src/com/android/settings/security/screenlock/ScreenLockSettings.java b/src/com/android/settings/security/screenlock/ScreenLockSettings.java
index 78edb7f..b2ee76c 100644
--- a/src/com/android/settings/security/screenlock/ScreenLockSettings.java
+++ b/src/com/android/settings/security/screenlock/ScreenLockSettings.java
@@ -16,10 +16,14 @@
 
 package com.android.settings.security.screenlock;
 
+import android.app.Activity;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
+import android.content.Intent;
 import android.os.UserHandle;
 
+import androidx.annotation.Nullable;
+
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
@@ -38,6 +42,10 @@
     private static final String TAG = "ScreenLockSettings";
 
     private static final int MY_USER_ID = UserHandle.myUserId();
+
+    static final int AUTO_PIN_SETTING_ENABLING_REQUEST_CODE = 111;
+    static final int AUTO_PIN_SETTING_DISABLING_REQUEST_CODE = 112;
+
     private LockPatternUtils mLockPatternUtils;
 
     @Override
@@ -79,7 +87,7 @@
         controllers.add(new LockAfterTimeoutPreferenceController(
                 context, MY_USER_ID, lockPatternUtils));
         controllers.add(new AutoPinConfirmPreferenceController(
-                context, MY_USER_ID, lockPatternUtils));
+                context, MY_USER_ID, lockPatternUtils, parent));
         controllers.add(new OwnerInfoPreferenceController(context, parent));
         return controllers;
     }
@@ -94,4 +102,17 @@
                             new LockPatternUtils(context));
                 }
             };
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+        if (requestCode == AUTO_PIN_SETTING_ENABLING_REQUEST_CODE) {
+            if (resultCode == Activity.RESULT_OK) {
+                mLockPatternUtils.setAutoPinConfirm(/* enabled= */ true, MY_USER_ID);
+            }
+        } else if (requestCode == AUTO_PIN_SETTING_DISABLING_REQUEST_CODE) {
+            if (resultCode == Activity.RESULT_OK) {
+                mLockPatternUtils.setAutoPinConfirm(/* enabled= */ false, MY_USER_ID);
+            }
+        }
+    }
 }
diff --git a/src/com/android/settings/inputmethod/KeyboardLayoutPreference.java b/src/com/android/settings/widget/TickButtonPreference.java
similarity index 61%
rename from src/com/android/settings/inputmethod/KeyboardLayoutPreference.java
rename to src/com/android/settings/widget/TickButtonPreference.java
index f9f858b..c55da2c 100644
--- a/src/com/android/settings/inputmethod/KeyboardLayoutPreference.java
+++ b/src/com/android/settings/widget/TickButtonPreference.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2023 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.inputmethod;
+package com.android.settings.widget;
 
 import android.content.Context;
 import android.view.View;
@@ -25,29 +25,33 @@
 
 import com.android.settings.R;
 
-public class KeyboardLayoutPreference extends Preference {
-
+/** A preference with tick icon. */
+public class TickButtonPreference extends Preference {
     private ImageView mCheckIcon;
-    private boolean mIsMark;
+    private boolean mIsSelected = false;
 
-    public KeyboardLayoutPreference(Context context, String layoutName, boolean defaultMark) {
+    public TickButtonPreference(Context context) {
         super(context);
         setWidgetLayoutResource(R.layout.preference_check_icon);
-        setTitle(layoutName);
-        mIsMark = defaultMark;
     }
 
     @Override
     public void onBindViewHolder(PreferenceViewHolder holder) {
         super.onBindViewHolder(holder);
-        mCheckIcon = (ImageView) holder.findViewById(R.id.keyboard_check_icon);
-        setCheckMark(mIsMark);
+        mCheckIcon = (ImageView) holder.findViewById(R.id.check_icon);
+        setSelected(mIsSelected);
     }
 
-    public void setCheckMark(boolean isMark) {
+    /** Set icon state.*/
+    public void setSelected(boolean isSelected) {
         if (mCheckIcon != null) {
-            mCheckIcon.setVisibility(isMark ? View.VISIBLE : View.INVISIBLE);
-            mIsMark = isMark;
+            mCheckIcon.setVisibility(isSelected ? View.VISIBLE : View.INVISIBLE);
         }
+        mIsSelected = isSelected;
+    }
+
+    /** Return state of presenting icon. */
+    public boolean isSelected() {
+        return mIsSelected;
     }
 }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
index 56a8373..fc3e6c0 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
@@ -286,8 +286,8 @@
 
     @Test
     public void handwritingPreference_checkedWhenFlagTrue() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
 
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -297,8 +297,8 @@
 
     @Test
     public void handwritingPreference_uncheckedWhenFlagFalse() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
 
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -308,22 +308,22 @@
 
     @Test
     public void handwritingPreference_updatesFlagOnClick() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
         handwritingPref.performClick();
 
         assertThat(handwritingPref.isChecked()).isEqualTo(true);
-        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
     }
 
     @Test
     public void handwritingPreference_startsHandwritingSettingsOnClickIfChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
@@ -335,8 +335,8 @@
 
     @Test
     public void handwritingPreference_doesNotStartHandwritingSettingsOnClickIfNotChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
@@ -350,8 +350,8 @@
     public void handwritingPreference_doesNotStartHandwritingSettingsIfNoIntent() {
         when(mInputMethodInfo.createStylusHandwritingSettingsActivityIntent())
                 .thenReturn(null);
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
         showScreen(mController);
         SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
 
diff --git a/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
index 12b5fe9..51b83b3 100644
--- a/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
@@ -63,8 +63,8 @@
     public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
         mController.onPreferenceChange(mPreference, true /* new value */);
 
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+        final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
 
         assertThat(mode).isEqualTo(SETTING_VALUE_ON);
     }
@@ -73,16 +73,16 @@
     public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
         mController.onPreferenceChange(mPreference, false /* new value */);
 
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+        final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
 
         assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
     }
 
     @Test
     public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
         mController.updateState(mPreference);
 
         verify(mPreference).setChecked(false);
@@ -90,22 +90,11 @@
 
     @Test
     public void updateState_settingEnabled_preferenceShouldBeChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
         mController.updateState(mPreference);
 
         verify(mPreference).setChecked(true);
     }
 
-    @Test
-    public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
-        mController.onDeveloperOptionsSwitchDisabled();
-
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
-
-        assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
-        verify(mPreference).setChecked(false);
-        verify(mPreference).setEnabled(false);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
index 9a7ef40..7398e5c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
@@ -26,7 +26,6 @@
 
 import android.content.Context;
 import android.os.PowerManager;
-import android.provider.Settings;
 import android.provider.SettingsSlicesContract;
 
 import androidx.preference.PreferenceScreen;
@@ -73,24 +72,6 @@
     }
 
     @Test
-    public void onSwitchChanged_isCheckedButNotAcked_preferenceIsUnchecked() {
-        setLowPowerWarningAcked(/* acked= */ 0);
-
-        mController.onSwitchChanged(/* switchView= */ null, /* isChecked= */ true);
-
-        assertThat(mPreference.isChecked()).isFalse();
-    }
-
-    @Test
-    public void onSwitchChanged_isCheckedAndAcked_setPowerSaveMode() {
-        setLowPowerWarningAcked(/* acked= */ 1);
-
-        mController.onSwitchChanged(/* switchView= */ null, /* isChecked= */ true);
-
-        verify(mPowerManager).setPowerSaveModeEnabled(true);
-    }
-
-    @Test
     public void updateState_lowPowerOn_preferenceIsChecked() {
         when(mPowerManager.isPowerSaveMode()).thenReturn(true);
 
@@ -140,16 +121,4 @@
     public void isPublicSlice_returnsTrue() {
         assertThat(mController.isPublicSlice()).isTrue();
     }
-
-    // 0 means not acked, 1 means acked.
-    private void setLowPowerWarningAcked(int acked) {
-        Settings.Secure.putInt(
-                mContext.getContentResolver(),
-                Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED,
-                acked);
-        Settings.Secure.putInt(
-                mContext.getContentResolver(),
-                Settings.Secure.EXTRA_LOW_POWER_WARNING_ACKNOWLEDGED,
-                acked);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java
index e5547c5..05a6f2b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageContentProviderTest.java
@@ -31,6 +31,7 @@
 import androidx.test.core.app.ApplicationProvider;
 
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
+import com.android.settings.fuelgauge.batteryusage.db.BatteryEventEntity;
 import com.android.settings.fuelgauge.batteryusage.db.BatteryState;
 import com.android.settings.fuelgauge.batteryusage.db.BatteryStateDatabase;
 import com.android.settings.testutils.BatteryTestUtils;
@@ -354,6 +355,28 @@
     }
 
     @Test
+    public void insert_batteryEvent_returnsExpectedResult() {
+        mProvider.onCreate();
+        ContentValues values = new ContentValues();
+        values.put(BatteryEventEntity.KEY_TIMESTAMP, 10001L);
+        values.put(BatteryEventEntity.KEY_BATTERY_EVENT_TYPE,
+                BatteryEventType.POWER_CONNECTED.getNumber());
+        values.put(BatteryEventEntity.KEY_BATTERY_LEVEL, 66);
+
+        final Uri uri = mProvider.insert(DatabaseUtils.BATTERY_EVENT_URI, values);
+
+        assertThat(uri).isEqualTo(DatabaseUtils.BATTERY_EVENT_URI);
+        // Verifies the AppUsageEventEntity content.
+        final List<BatteryEventEntity> entities =
+                BatteryStateDatabase.getInstance(mContext).batteryEventDao().getAll();
+        assertThat(entities).hasSize(1);
+        assertThat(entities.get(0).timestamp).isEqualTo(10001L);
+        assertThat(entities.get(0).batteryEventType).isEqualTo(
+                BatteryEventType.POWER_CONNECTED.getNumber());
+        assertThat(entities.get(0).batteryLevel).isEqualTo(66);
+    }
+
+    @Test
     public void delete_throwsUnsupportedOperationException() {
         assertThrows(
                 UnsupportedOperationException.class,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java
index fe1bff6..6b8073b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/ConvertUtilsTest.java
@@ -39,6 +39,7 @@
 import android.os.UserHandle;
 
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
+import com.android.settings.fuelgauge.batteryusage.db.BatteryEventEntity;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -195,6 +196,22 @@
     }
 
     @Test
+    public void convertBatteryEventToContentValues_normalCase_returnsExpectedContentValues() {
+        final BatteryEvent batteryEvent =
+                BatteryEvent.newBuilder()
+                        .setTimestamp(10001L)
+                        .setType(BatteryEventType.POWER_CONNECTED)
+                        .setBatteryLevel(66)
+                        .build();
+        final ContentValues values =
+                ConvertUtils.convertBatteryEventToContentValues(batteryEvent);
+        assertThat(values.getAsLong(BatteryEventEntity.KEY_TIMESTAMP)).isEqualTo(10001L);
+        assertThat(values.getAsInteger(BatteryEventEntity.KEY_BATTERY_EVENT_TYPE)).isEqualTo(
+                BatteryEventType.POWER_CONNECTED.getNumber());
+        assertThat(values.getAsInteger(BatteryEventEntity.KEY_BATTERY_LEVEL)).isEqualTo(66);
+    }
+
+    @Test
     public void convertToBatteryHistEntry_returnsExpectedResult() {
         final int expectedType = 3;
         when(mMockBatteryEntry.getUid()).thenReturn(1001);
@@ -406,6 +423,15 @@
     }
 
     @Test
+    public void convertToBatteryEvent_normalCase_returnsExpectedResult() {
+        final BatteryEvent batteryEvent = ConvertUtils.convertToBatteryEvent(
+                666L, BatteryEventType.POWER_DISCONNECTED, 88);
+        assertThat(batteryEvent.getTimestamp()).isEqualTo(666L);
+        assertThat(batteryEvent.getType()).isEqualTo(BatteryEventType.POWER_DISCONNECTED);
+        assertThat(batteryEvent.getBatteryLevel()).isEqualTo(88);
+    }
+
+    @Test
     public void getLocale_nullContext_returnDefaultLocale() {
         assertThat(ConvertUtils.getLocale(/*context=*/ null))
                 .isEqualTo(Locale.getDefault());
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
index aab91e0..753a7f7 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java
@@ -183,7 +183,7 @@
         assertThat(dataProcessManager.getIsCurrentBatteryHistoryLoaded()).isTrue();
         assertThat(dataProcessManager.getShowScreenOnTime()).isTrue();
         final List<AppUsageEvent> appUsageEventList = dataProcessManager.getAppUsageEventList();
-        Collections.sort(appUsageEventList, DataProcessor.TIMESTAMP_COMPARATOR);
+        Collections.sort(appUsageEventList, DataProcessor.APP_USAGE_EVENT_TIMESTAMP_COMPARATOR);
         assertThat(appUsageEventList.size()).isEqualTo(6);
         assertAppUsageEvent(
                 appUsageEventList.get(0), AppUsageEventType.ACTIVITY_RESUMED, /*timestamp=*/ 1);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
index aa15472..66e48c0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java
@@ -250,7 +250,7 @@
 
         final Map<Integer, Map<Integer, Map<Long, Map<String, List<AppUsagePeriod>>>>> periodMap =
                 DataProcessor.generateAppUsagePeriodMap(
-                        14400000L, hourlyBatteryLevelsPerDay, appUsageEventList);
+                        14400000L, hourlyBatteryLevelsPerDay, appUsageEventList, new ArrayList<>());
 
         assertThat(periodMap).hasSize(3);
         // Day 1
@@ -288,7 +288,7 @@
         hourlyBatteryLevelsPerDay.add(
                 new BatteryLevelData.PeriodBatteryLevelData(new ArrayList<>(), new ArrayList<>()));
         assertThat(DataProcessor.generateAppUsagePeriodMap(
-                0L, hourlyBatteryLevelsPerDay, new ArrayList<>())).isNull();
+                0L, hourlyBatteryLevelsPerDay, new ArrayList<>(), new ArrayList<>())).isNull();
     }
 
     @Test
@@ -1669,7 +1669,8 @@
                 /*instanceId=*/ 4, packageName2));
 
         final Map<Long, Map<String, List<AppUsagePeriod>>> appUsagePeriodMap =
-                DataProcessor.buildAppUsagePeriodList(appUsageEvents, 0, 5);
+                DataProcessor.buildAppUsagePeriodList(
+                        appUsageEvents, new ArrayList<>(), 0, 5);
 
         assertThat(appUsagePeriodMap).hasSize(2);
         final Map<String, List<AppUsagePeriod>> userMap1 = appUsagePeriodMap.get(1L);
@@ -1693,7 +1694,7 @@
     @Test
     public void buildAppUsagePeriodList_emptyEventList_returnNull() {
         assertThat(DataProcessor.buildAppUsagePeriodList(
-                new ArrayList<>(), 0, 1)).isNull();
+                new ArrayList<>(), new ArrayList<>(), 0, 1)).isNull();
     }
 
     @Test
@@ -1705,7 +1706,7 @@
                 AppUsageEventType.DEVICE_SHUTDOWN, /*timestamp=*/ 2));
 
         assertThat(DataProcessor.buildAppUsagePeriodList(
-                appUsageEvents, 0, 3)).isNull();
+                appUsageEvents, new ArrayList<>(), 0, 3)).isNull();
     }
 
     @Test
@@ -1766,6 +1767,89 @@
     }
 
     @Test
+    public void excludePowerConnectedTime_startEndNotCharging_returnExpectedResult() {
+        final List<AppUsagePeriod> appUsagePeriodList = List.of(
+                AppUsagePeriod.newBuilder().setStartTime(100).setEndTime(200).build());
+        final List<BatteryEvent> batteryEventList = List.of(
+                BatteryEvent.newBuilder().setTimestamp(50).setType(
+                        BatteryEventType.POWER_DISCONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(166).setType(
+                        BatteryEventType.POWER_CONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(188).setType(
+                        BatteryEventType.POWER_DISCONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(280).setType(
+                        BatteryEventType.POWER_CONNECTED).build());
+
+        final List<AppUsagePeriod> resultList =
+                DataProcessor.excludePowerConnectedTimeFromAppUsagePeriodList(
+                        appUsagePeriodList, batteryEventList);
+
+        assertThat(resultList).hasSize(2);
+        assertAppUsagePeriod(resultList.get(0), 100, 166);
+        assertAppUsagePeriod(resultList.get(1), 188, 200);
+    }
+
+    @Test
+    public void excludePowerConnectedTime_startEndInCharging_returnExpectedResult() {
+        final List<AppUsagePeriod> appUsagePeriodList = List.of(
+                AppUsagePeriod.newBuilder().setStartTime(100).setEndTime(200).build());
+        final List<BatteryEvent> batteryEventList = List.of(
+                BatteryEvent.newBuilder().setTimestamp(50).setType(
+                        BatteryEventType.POWER_DISCONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(80).setType(
+                        BatteryEventType.POWER_CONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(120).setType(
+                        BatteryEventType.POWER_DISCONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(150).setType(
+                        BatteryEventType.POWER_CONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(160).setType(
+                        BatteryEventType.POWER_DISCONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(180).setType(
+                        BatteryEventType.POWER_CONNECTED).build());
+
+        final List<AppUsagePeriod> resultList =
+                DataProcessor.excludePowerConnectedTimeFromAppUsagePeriodList(
+                        appUsagePeriodList, batteryEventList);
+
+        assertThat(resultList).hasSize(2);
+        assertAppUsagePeriod(resultList.get(0), 120, 150);
+        assertAppUsagePeriod(resultList.get(1), 160, 180);
+    }
+
+    @Test
+    public void excludePowerConnectedTime_wholePeriodNotCharging_returnExpectedResult() {
+        final List<AppUsagePeriod> appUsagePeriodList = List.of(
+                AppUsagePeriod.newBuilder().setStartTime(100).setEndTime(200).build());
+        final List<BatteryEvent> batteryEventList = List.of(
+                BatteryEvent.newBuilder().setTimestamp(50).setType(
+                        BatteryEventType.POWER_DISCONNECTED).build(),
+                BatteryEvent.newBuilder().setTimestamp(80).setType(
+                        BatteryEventType.POWER_CONNECTED).build());
+
+        final List<AppUsagePeriod> resultList =
+                DataProcessor.excludePowerConnectedTimeFromAppUsagePeriodList(
+                        appUsagePeriodList, batteryEventList);
+
+        assertThat(resultList).isEmpty();
+    }
+
+    @Test
+    public void excludePowerConnectedTime_wholePeriodInCharging_returnExpectedResult() {
+        final List<AppUsagePeriod> appUsagePeriodList = List.of(
+                AppUsagePeriod.newBuilder().setStartTime(100).setEndTime(200).build());
+        final List<BatteryEvent> batteryEventList = List.of(
+                BatteryEvent.newBuilder().setTimestamp(50).setType(
+                        BatteryEventType.POWER_DISCONNECTED).build());
+
+        final List<AppUsagePeriod> resultList =
+                DataProcessor.excludePowerConnectedTimeFromAppUsagePeriodList(
+                        appUsagePeriodList, batteryEventList);
+
+        assertThat(resultList).hasSize(1);
+        assertAppUsagePeriod(resultList.get(0), 100, 200);
+    }
+
+    @Test
     public void getScreenOnTime_returnExpectedResult() {
         final long userId = 1;
         final String packageName = "com.android.settings";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
index 0cb3d1d..20799d4 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DatabaseUtilsTest.java
@@ -36,6 +36,7 @@
 import android.os.UserManager;
 
 import com.android.settings.fuelgauge.batteryusage.db.AppUsageEventEntity;
+import com.android.settings.fuelgauge.batteryusage.db.BatteryEventEntity;
 import com.android.settings.testutils.BatteryTestUtils;
 
 import org.junit.Before;
@@ -137,6 +138,28 @@
     }
 
     @Test
+    public void sendBatteryEventData_returnsExpectedList() {
+        final BatteryEvent batteryEvent =
+                BatteryEvent.newBuilder()
+                        .setTimestamp(10001L)
+                        .setType(BatteryEventType.POWER_CONNECTED)
+                        .setBatteryLevel(66)
+                        .build();
+
+        final ContentValues contentValues =
+                DatabaseUtils.sendBatteryEventData(mContext, batteryEvent);
+
+        assertThat(contentValues.getAsInteger(BatteryEventEntity.KEY_TIMESTAMP))
+                .isEqualTo(10001L);
+        assertThat(contentValues.getAsInteger(BatteryEventEntity.KEY_BATTERY_EVENT_TYPE))
+                .isEqualTo(BatteryEventType.POWER_CONNECTED.getNumber());
+        assertThat(contentValues.getAsInteger(BatteryEventEntity.KEY_BATTERY_LEVEL))
+                .isEqualTo(66);
+        // Verifies the inserted ContentValues into content provider.
+        verify(mMockContentResolver).insert(DatabaseUtils.BATTERY_EVENT_URI, contentValues);
+    }
+
+    @Test
     public void sendBatteryEntryData_nullBatteryIntent_returnsNullValue() {
         doReturn(null).when(mContext).registerReceiver(any(), any());
         assertThat(
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventDaoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventDaoTest.java
new file mode 100644
index 0000000..941f444
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventDaoTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge.batteryusage.db;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.database.Cursor;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.testutils.BatteryTestUtils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link BatteryEventDao}. */
+@RunWith(RobolectricTestRunner.class)
+public final class BatteryEventDaoTest {
+    private Context mContext;
+    private BatteryStateDatabase mDatabase;
+    private BatteryEventDao mBatteryEventDao;
+
+    @Before
+    public void setUp() {
+        mContext = ApplicationProvider.getApplicationContext();
+        mDatabase = BatteryTestUtils.setUpBatteryStateDatabase(mContext);
+        mBatteryEventDao = mDatabase.batteryEventDao();
+    }
+
+    @After
+    public void closeDb() {
+        mDatabase.close();
+        BatteryStateDatabase.setBatteryStateDatabase(/*database=*/ null);
+    }
+
+    @Test
+    public void getAllAfter_returnExpectedResult() {
+        mBatteryEventDao.insert(BatteryEventEntity.newBuilder()
+                .setTimestamp(100L)
+                .setBatteryEventType(1)
+                .setBatteryLevel(66)
+                .build());
+        mBatteryEventDao.insert(BatteryEventEntity.newBuilder()
+                .setTimestamp(200L)
+                .setBatteryEventType(2)
+                .setBatteryLevel(88)
+                .build());
+
+        final Cursor cursor = mBatteryEventDao.getAllAfter(160L);
+        assertThat(cursor.getCount()).isEqualTo(1);
+        cursor.moveToFirst();
+        assertThat(cursor.getLong(cursor.getColumnIndex(BatteryEventEntity.KEY_TIMESTAMP)))
+                .isEqualTo(200L);
+        assertThat(cursor.getInt(cursor.getColumnIndex(BatteryEventEntity.KEY_BATTERY_EVENT_TYPE)))
+                .isEqualTo(2);
+        assertThat(cursor.getInt(cursor.getColumnIndex(BatteryEventEntity.KEY_BATTERY_LEVEL)))
+                .isEqualTo(88);
+
+        mBatteryEventDao.clearAll();
+        assertThat(mBatteryEventDao.getAll()).isEmpty();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventEntityTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventEntityTest.java
new file mode 100644
index 0000000..a34d651
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/db/BatteryEventEntityTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2023 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.batteryusage.db;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link BatteryEventEntity}. */
+@RunWith(RobolectricTestRunner.class)
+public final class BatteryEventEntityTest {
+
+    @Test
+    public void testBuilder_returnsExpectedResult() {
+        final long timestamp = 10001L;
+        final int batteryEventType = 1;
+        final int batteryLevel = 66;
+
+        BatteryEventEntity entity = BatteryEventEntity
+                .newBuilder()
+                .setTimestamp(timestamp)
+                .setBatteryEventType(batteryEventType)
+                .setBatteryLevel(batteryLevel)
+                .build();
+
+        // Verifies the app relative information.
+        assertThat(entity.timestamp).isEqualTo(timestamp);
+        assertThat(entity.batteryEventType).isEqualTo(batteryEventType);
+        assertThat(entity.batteryLevel).isEqualTo(batteryLevel);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
index d1c21a4..1bf61a4 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
@@ -18,18 +18,21 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+import android.hardware.input.InputDeviceIdentifier;
 import android.provider.Settings;
 
 import androidx.preference.Preference;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 
 import org.junit.Before;
@@ -37,12 +40,14 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 import org.robolectric.RobolectricTestRunner;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /** Tests for {@link KeyboardSettingsPreferenceController} */
 @RunWith(RobolectricTestRunner.class)
 public class KeyboardSettingsPreferenceControllerTest {
@@ -53,31 +58,42 @@
     private static final String PREFERENCE_KEY = "keyboard_settings";
 
     @Mock
-    private Activity mActivity;
-    @Mock
     private CachedBluetoothDevice mCachedBluetoothDevice;
-    @Captor
-    private ArgumentCaptor<Intent> mIntentArgumentCaptor;
+    @Mock
+    private InputDeviceIdentifier mInputDeviceIdentifier;
+
     private Context mContext;
     private KeyboardSettingsPreferenceController mController;
 
     @Before
     public void setUp() {
         mContext = spy(ApplicationProvider.getApplicationContext());
-        mController = new KeyboardSettingsPreferenceController(mContext, PREFERENCE_KEY);
-        mController.init(mCachedBluetoothDevice, mActivity);
+        doNothing().when(mContext).startActivity(any());
+        mController = spy(new KeyboardSettingsPreferenceController(mContext, PREFERENCE_KEY));
+        mController.init(mCachedBluetoothDevice);
     }
 
     @Test
     public void handlePreferenceTreeClick_expected() {
         Preference mKeyboardPreference = new Preference(mContext);
         mKeyboardPreference.setKey(PREFERENCE_KEY);
+        final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+        String address = "BT_ADDRESS";
+        HardKeyboardDeviceInfo deviceInfo =
+                new HardKeyboardDeviceInfo(
+                        "TEST_DEVICE",
+                        mInputDeviceIdentifier,
+                        "TEST_DEVICE_LABEL",
+                        address);
+        List<HardKeyboardDeviceInfo> keyboards = new ArrayList<>();
+        keyboards.add(deviceInfo);
+        when(mController.getHardKeyboardList()).thenReturn(keyboards);
+        when(mCachedBluetoothDevice.getAddress()).thenReturn(address);
 
         mController.handlePreferenceTreeClick(mKeyboardPreference);
 
-        verify(mActivity).startActivityForResult(mIntentArgumentCaptor.capture(), eq(0));
-        Intent expectedIntent = mIntentArgumentCaptor.getValue();
-        assertThat(expectedIntent.getAction()).isEqualTo(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+        verify(mContext).startActivity(captor.capture());
+        assertThat(captor.getValue().getAction()).isEqualTo(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
index 15b2ae9..715913c 100644
--- a/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
@@ -22,7 +22,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -33,6 +32,7 @@
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -48,6 +48,8 @@
     private static final Integer TEST_USER_ID = 1;
     @Mock
     private LockPatternUtils mLockPatternUtils;
+    @Mock
+    private ObservablePreferenceFragment mParentFragment;
     private AutoPinConfirmPreferenceController mController;
     private SwitchPreference mPreference;
 
@@ -56,7 +58,8 @@
         MockitoAnnotations.initMocks(this);
         Context context = ApplicationProvider.getApplicationContext();
         mController =
-                new AutoPinConfirmPreferenceController(context, TEST_USER_ID, mLockPatternUtils);
+                new AutoPinConfirmPreferenceController(context, TEST_USER_ID, mLockPatternUtils,
+                        mParentFragment);
         mPreference = new SwitchPreference(context);
     }
 
@@ -128,12 +131,4 @@
         mController.updateState(mPreference);
         assertThat(mPreference.isChecked()).isTrue();
     }
-
-    @Test
-    public void onPreferenceChange_shouldUpdatePinAutoConfirmSetting() {
-        DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
-                "true", /* makeDefault */ false);
-        mController.onPreferenceChange(mPreference, /* newValue= */ true);
-        verify(mLockPatternUtils).setAutoPinConfirm(true, TEST_USER_ID);
-    }
 }
diff --git a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
index 8beeffb..4e9339f 100644
--- a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
@@ -129,6 +129,8 @@
 
     private class MockInternetPreferenceController extends
             com.android.settings.network.InternetPreferenceController {
+
+        private int mDefaultDataSubscriptionId;
         public MockInternetPreferenceController(Context context, Lifecycle lifecycle,
                 LifecycleOwner lifecycleOwner) {
             super(context, lifecycle, lifecycleOwner);
@@ -145,18 +147,26 @@
             mSubscriptionInfoEntity = list;
         }
 
+        @Override
+        protected int getDefaultDataSubscriptionId() {
+            return mDefaultDataSubscriptionId;
+        }
+
+        public void setDefaultDataSubscriptionId(int subscriptionId) {
+            mDefaultDataSubscriptionId = subscriptionId;
+        }
+
     }
 
     private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
             int carrierId, String displayName, String mcc, String mnc, String countryIso,
             int cardId, boolean isVisible, boolean isValid, boolean isActive, boolean isAvailable,
-            boolean isDefaultData, boolean isActiveData) {
+            boolean isActiveData) {
         return new SubscriptionInfoEntity(subId, slotId, carrierId,
                 displayName, displayName, 0, mcc, mnc, countryIso, false, cardId,
                 TelephonyManager.DEFAULT_PORT_INDEX, false, null,
                 SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, isVisible,
-                "1234567890", true, "default", false, isValid, true, isActive, isAvailable, false,
-                false, isDefaultData, false, isActiveData);
+                "1234567890", true, false, isValid, true, isActive, isAvailable, isActiveData);
     }
 
     @Test
@@ -183,7 +193,7 @@
         mController.onResume();
         mController.onPause();
 
-        verify(mContext).unregisterReceiver(any(BroadcastReceiver.class));
+        verify(mContext, times(2)).unregisterReceiver(any(BroadcastReceiver.class));
         verify(mConnectivityManager, times(2)).unregisterNetworkCallback(
                 any(ConnectivityManager.NetworkCallback.class));
     }
@@ -218,10 +228,11 @@
 
     @Test
     public void updateCellularSummary_getActiveSubscriptionInfo_cbrs() {
+        mController.setDefaultDataSubscriptionId(Integer.parseInt(SUB_ID_2));
         mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, false, true, true, true, false, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, false, true, true, true, true);
         mDefaultDataSubInfo = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, false, true, true, true, true, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, false, true, true, true, false);
         mSubscriptionInfoEntityList.add(mActiveSubInfo);
         mSubscriptionInfoEntityList.add(mDefaultDataSubInfo);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -231,7 +242,7 @@
         assertThat(mPreference.getSummary()).isEqualTo(DISPLAY_NAME_2);
 
         mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, false, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
         mSubscriptionInfoEntityList.add(mActiveSubInfo);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
         mController.onAvailableSubInfoChanged(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java b/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java
index 007251a..51aecc5 100644
--- a/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java
@@ -100,6 +100,8 @@
 
         private List<SubscriptionInfoEntity> mSubscriptionInfoEntity;
         private boolean mIsInService;
+        private int mDefaultVoiceSubscriptionId;
+        private int mDefaultSmsSubscriptionId;
 
         @Override
         protected List<SubscriptionInfoEntity> getSubscriptionInfoList() {
@@ -118,6 +120,24 @@
         public void setInService(boolean inService) {
             mIsInService = inService;
         }
+
+        @Override
+        protected int getDefaultVoiceSubscriptionId() {
+            return mDefaultVoiceSubscriptionId;
+        }
+
+        @Override
+        protected int getDefaultSmsSubscriptionId() {
+            return mDefaultSmsSubscriptionId;
+        }
+
+        public void setDefaultVoiceSubscriptionId(int subscriptionId) {
+            mDefaultVoiceSubscriptionId = subscriptionId;
+        }
+
+        public void setDefaultSmsSubscriptionId(int subscriptionId) {
+            mDefaultSmsSubscriptionId = subscriptionId;
+        }
     }
 
     @Before
@@ -163,15 +183,13 @@
 
     private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
             int carrierId, String displayName, String mcc, String mnc, String countryIso,
-            int cardId, boolean isValid, boolean isActive, boolean isAvailable,
-            boolean isDefaultCall, boolean isDefaultSms) {
+            int cardId, boolean isValid, boolean isActive, boolean isAvailable) {
         return new SubscriptionInfoEntity(subId, slotId, carrierId,
                 displayName, displayName, 0, mcc, mnc, countryIso, false, cardId,
                 TelephonyManager.DEFAULT_PORT_INDEX, false, null,
                 SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
-                "1234567890", true, "default", false, isValid,
-                true, isActive, isAvailable, isDefaultCall, isDefaultSms, false, false,
-                false);
+                "1234567890", true, false, isValid,
+                true, isActive, isAvailable, false);
     }
 
     @Test
@@ -181,7 +199,7 @@
         mSubInfo1 = setupSubscriptionInfoEntity(INVALID_SUB_ID,
                 SubscriptionManager.INVALID_SIM_SLOT_INDEX, TelephonyManager.UNKNOWN_CARRIER_ID,
                 DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1, SUB_COUNTRY_ISO_1,
-                TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true, false, false);
+                TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
         displayPreferenceWithLifecycle();
@@ -202,9 +220,9 @@
         mSubInfo1 = setupSubscriptionInfoEntity(INVALID_SUB_ID,
                 SubscriptionManager.INVALID_SIM_SLOT_INDEX, TelephonyManager.UNKNOWN_CARRIER_ID,
                 DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1, SUB_COUNTRY_ISO_1,
-                TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true, false, false);
+                TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -226,7 +244,7 @@
     public void getSummary_oneSubscription_returnDisplayName() {
 
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, false, false);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
         displayPreferenceWithLifecycle();
@@ -239,9 +257,9 @@
     public void getSummary_allSubscriptionsHaveNoPreferredStatus_returnDisplayName() {
 
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, false, false);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -257,10 +275,13 @@
     @UiThreadTest
     public void getSummary_oneSubscriptionsIsCallPreferredTwoIsSmsPreferred_returnStatus() {
 
+        mController.setDefaultVoiceSubscriptionId(Integer.parseInt(SUB_ID_1));
+        mController.setDefaultSmsSubscriptionId(Integer.parseInt(SUB_ID_2));
+
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, false);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, true);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -284,10 +305,13 @@
     @UiThreadTest
     public void getSummary_oneSubscriptionsIsSmsPreferredTwoIsCallPreferred_returnStatus() {
 
+        mController.setDefaultSmsSubscriptionId(Integer.parseInt(SUB_ID_1));
+        mController.setDefaultVoiceSubscriptionId(Integer.parseInt(SUB_ID_2));
+
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, false, true);
-        mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, true, false);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
+        mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 2, 2, DISPLAY_NAME_2, SUB_MCC_2,
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -311,10 +335,13 @@
     @UiThreadTest
     public void getSummary_oneSubscriptionsIsSmsPreferredAndIsCallPreferred_returnStatus() {
 
+        mController.setDefaultSmsSubscriptionId(Integer.parseInt(SUB_ID_1));
+        mController.setDefaultVoiceSubscriptionId(Integer.parseInt(SUB_ID_1));
+
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
index 1c4238a..c4e0f64 100644
--- a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
@@ -152,13 +152,11 @@
 
     private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
             int carrierId, String displayName, String mcc, String mnc, String countryIso,
-            int cardId, CharSequence defaultSimConfig, boolean isValid, boolean isActive,
-            boolean isAvailable, boolean isDefaultCall, boolean isDefaultSms) {
+            int cardId, boolean isValid, boolean isActive, boolean isAvailable) {
         return new SubscriptionInfoEntity(subId, slotId, carrierId, displayName, displayName, 0,
                 mcc, mnc, countryIso, false, cardId, TelephonyManager.DEFAULT_PORT_INDEX, false,
                 null, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
-                "1234567890", true, defaultSimConfig.toString(), false, isValid, true, isActive,
-                isAvailable, isDefaultCall, isDefaultSms, false, false, false);
+                "1234567890", true, false, isValid, true, isActive, isAvailable, false);
     }
 
     private String setSummaryResId(String resName, String value) {
@@ -173,7 +171,7 @@
     @UiThreadTest
     public void getSummary_tapToActivePSim() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, "", true, false, true, false, false);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, false, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
         displayPreferenceWithLifecycle();
@@ -186,7 +184,7 @@
     @UiThreadTest
     public void getSummary_inactivePSim() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, "", true, false, true, false, false);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, false, true);
         doReturn(true).when(mSubscriptionManager).canDisablePhysicalSubscription();
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -201,15 +199,13 @@
     @UiThreadTest
     public void getSummary_defaultCalls() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1,
-                setSummaryResId("sim_category_default_active_sim",
-                        setSummaryResId("default_active_sim_calls")), true, true, true, true,
-                false);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
 
         displayPreferenceWithLifecycle();
-        CharSequence defaultCall = mSubInfo1.defaultSimConfig;
+        CharSequence defaultCall = SubscriptionUtil.getDefaultSimConfig(mContext,
+                Integer.parseInt(SUB_ID_1));
         final StringBuilder summary = new StringBuilder();
         summary.append(setSummaryResId("sim_category_active_sim", null))
                 .append(defaultCall);
@@ -225,14 +221,13 @@
                 .append(", ")
                 .append(setSummaryResId("default_active_sim_sms"));
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1,
-                setSummaryResId("sim_category_default_active_sim", defaultConfig.toString()), true,
-                true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
 
         displayPreferenceWithLifecycle();
-        CharSequence defaultCall = mSubInfo1.defaultSimConfig;
+        CharSequence defaultCall = SubscriptionUtil.getDefaultSimConfig(mContext,
+                Integer.parseInt(SUB_ID_1));
         final StringBuilder summary = new StringBuilder();
         summary.append(setSummaryResId("sim_category_active_sim", null))
                 .append(defaultCall);
@@ -245,9 +240,9 @@
     @UiThreadTest
     public void getAvailablePhysicalSubscription_withTwoPhysicalSims_returnTwo() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, "", true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, "", true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
index ffc9f9b..bbec5bb 100644
--- a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
@@ -135,15 +135,12 @@
 
     private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
             int carrierId, String displayName, String mcc, String mnc, String countryIso,
-            int cardId, boolean isValid, boolean isActive, boolean isAvailable,
-            boolean isDefaultCall, boolean isDefaultSms) {
+            int cardId, boolean isValid, boolean isActive, boolean isAvailable) {
         return new SubscriptionInfoEntity(subId, slotId, carrierId,
                 displayName, displayName, 0, mcc, mnc, countryIso, false, cardId,
                 TelephonyManager.DEFAULT_PORT_INDEX, false, null,
                 SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
-                "1234567890", true, "default", false, isValid,
-                true, isActive, isAvailable, isDefaultCall,
-                isDefaultSms, false, false, false);
+                "1234567890", true, false, isValid, true, isActive, isAvailable, false);
     }
 
     @Test
@@ -164,9 +161,9 @@
     @Test
     public void onPreferenceChange_prefChangedToSub2_callbackCalledCorrectly() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -181,9 +178,9 @@
     @Test
     public void onPreferenceChange_prefChangedToAlwaysAsk_callbackCalledCorrectly() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -201,9 +198,9 @@
     public void onPreferenceChange_prefBecomesAvailable_onPreferenceChangeCallbackNotNull() {
         // Start with only one sub active, so the pref is not available
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
@@ -225,9 +222,9 @@
     @Test
     public void onSubscriptionsChanged_twoSubscriptionsDefaultChanges_selectedEntryGetsUpdated() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -246,9 +243,9 @@
     @Test
     public void onSubscriptionsChanged_goFromTwoSubscriptionsToOne_prefDisappears() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
@@ -273,9 +270,9 @@
     @UiThreadTest
     public void onSubscriptionsChanged_goFromOneSubscriptionToTwo_prefAppears() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
         mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -297,11 +294,11 @@
     @Test
     public void onSubscriptionsChanged_goFromTwoToThreeSubscriptions_listGetsUpdated() {
         mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
-                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+                SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
         mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
-                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+                SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
         mSubInfo3 = setupSubscriptionInfoEntity(SUB_ID_3, 1, 1, DISPLAY_NAME_3, SUB_MCC_3,
-                SUB_MNC_3, SUB_COUNTRY_ISO_3, 1, true, true, true, false, false);
+                SUB_MNC_3, SUB_COUNTRY_ISO_3, 1, true, true, true);
         mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
         mSubscriptionInfoEntityList.add(mSubInfo1);
         mSubscriptionInfoEntityList.add(mSubInfo2);
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index 16e3963..0373396 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -114,15 +114,13 @@
     }
 
     private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, String displayName,
-            boolean isOpportunistic, boolean isValid, boolean isActive, boolean isAvailable,
-            boolean isDefaultData) {
+            boolean isOpportunistic, boolean isValid, boolean isActive, boolean isAvailable) {
         int id = Integer.parseInt(subId);
         return new SubscriptionInfoEntity(subId, id, id,
                 displayName, displayName, 0, "mcc", "mnc", "countryIso", false, id,
                 TelephonyManager.DEFAULT_PORT_INDEX, isOpportunistic, null,
                 SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
-                "1234567890", true, "default", false, isValid, true, isActive, isAvailable, false,
-                false, isDefaultData, false, false);
+                "1234567890", true, false, isValid, true, isActive, isAvailable, false);
     }
 
     private MobileNetworkInfoEntity setupMobileNetworkInfoEntity(String subId,
@@ -141,8 +139,7 @@
 
     @Test
     public void isDialogNeeded_disableSingleSim_returnFalse() {
-        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true,
-                true);
+        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
         mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
         doReturn(1).when(mTelephonyManager).getActiveModemCount();
 
@@ -151,14 +148,12 @@
 
     @Test
     public void isDialogNeeded_enableNonDefaultSimInMultiSimMode_returnTrue() {
-        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true,
-                false);
+        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
         mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), false);
         doReturn(1).when(mTelephonyManager).getActiveModemCount();
         // Ideally, it would be better if we could set the default data subscription to
         // SUB_ID_OTHER, and set that as an active subscription id.
-        mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, false, true, true, true,
-                true);
+        mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, false, true, true, true);
         mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
         doReturn(2).when(mTelephonyManager).getActiveModemCount();
 
@@ -180,8 +175,7 @@
 
     @Test
     public void onPreferenceChange_singleSim_On_shouldEnableData() {
-        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true,
-                true);
+        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
         mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
         mController.setSubscriptionInfoEntity(mSubInfo1);
         mController.setMobileNetworkInfoEntity(mNetworkInfo1);
@@ -194,8 +188,7 @@
 
     @Test
     public void onPreferenceChange_multiSim_On_shouldEnableData() {
-        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true,
-                true);
+        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
         mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
         mController.setSubscriptionInfoEntity(mSubInfo1);
         mController.setMobileNetworkInfoEntity(mNetworkInfo1);
@@ -219,8 +212,7 @@
 
     @Test
     public void updateState_opportunistic_disabled() {
-        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true,
-                true);
+        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
         mController.init(mFragmentManager, SUB_ID, mSubInfo1, mNetworkInfo1);
         mController.updateState(mPreference);
 
@@ -232,8 +224,7 @@
 
     @Test
     public void updateState_notOpportunistic_enabled() {
-        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true,
-                true);
+        mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
         mController.init(mFragmentManager, SUB_ID, mSubInfo1, mNetworkInfo1);
         mController.updateState(mPreference);
 
diff --git a/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemItemControllerTest.java b/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemItemControllerTest.java
index 5ec33db..708987e 100644
--- a/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemItemControllerTest.java
+++ b/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemItemControllerTest.java
@@ -33,6 +33,8 @@
 import androidx.test.annotation.UiThreadTest;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.settings.widget.TickButtonPreference;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;