Merge "Log clicks on the "Show System / Hide System" button in Location Settings recent accesses."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 92dfbe5..290f84e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2942,24 +2942,6 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name=".dream.DreamSetupActivity"
-                  android:exported="true"
-                  android:immersive="true"
-                  android:theme="@style/SudThemeGlif.DayNight"
-                  android:icon="@drawable/ic_settings_display">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-                <category android:name="com.android.settings.suggested.category.SCREEN_SAVER"/>
-            </intent-filter>
-            <meta-data android:name="com.android.settings.is_supported"
-                       android:resource="@bool/dream_setup_supported"/>
-            <meta-data android:name="com.android.settings.title"
-                       android:resource="@string/dream_setup_title"/>
-            <meta-data android:name="com.android.settings.summary"
-                       android:resource="@string/dream_setup_description"/>
-            <meta-data android:name="com.android.settings.icon_tintable" android:value="true"/>
-        </activity>
-
         <activity
             android:name="Settings$UserSettingsActivity"
             android:label="@string/user_settings_title"
diff --git a/res/layout/dream_setup_layout.xml b/res/layout/dream_setup_layout.xml
deleted file mode 100644
index 31a0fb1..0000000
--- a/res/layout/dream_setup_layout.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2022 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<com.google.android.setupdesign.GlifLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/setup_wizard_layout"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:icon="@drawable/ic_settings_display"
-    app:sucHeaderText="@string/dream_setup_title"
-    app:sudDescriptionText="@string/dream_setup_description">
-
-    <RelativeLayout
-        android:id="@+id/dream_container"
-        style="@style/SudContentFrame"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <androidx.recyclerview.widget.RecyclerView
-            android:id="@+id/dream_setup_list"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-    </RelativeLayout>
-
-</com.google.android.setupdesign.GlifLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 36e1193..5472a9d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -491,6 +491,12 @@
     <!-- Category for the app's locale picker activity. [CHAR LIMIT=50]-->
     <string name="all_supported_app_locales_title">All languages</string>
 
+    <!-- Title for preference of the system default locale. [CHAR LIMIT=50]-->
+    <string name="preference_of_system_locale_title">System language</string>
+
+    <!-- Summary for preference of the system default locale. [CHAR LIMIT=50]-->
+    <string name="preference_of_system_locale_summary">System default - <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g></string>
+
     <!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
     <string name="no_multiple_language_supported">The app is set to <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g> by default and doesn\u2019t support multiple languages.</string>
     <!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
@@ -597,7 +603,7 @@
     <string name="date_and_time_settings_title_setup_wizard">Set date and time</string>
     <!-- Main Settings screen setting option summary text for the item to go into the date and time settings. -->
     <string name="date_and_time_settings_summary">Set date, time, time zone, &amp; formats</string>
-    <!-- Date & time setting screen setting switch title: whether the system clock (UTC time) should be determined automatically [CHAR LIMIT=100] -->
+    <!-- Date & time setting screen setting switch title: whether the system clock (Unix epoch time) should be determined automatically [CHAR LIMIT=100] -->
     <string name="date_time_auto">Set time automatically</string>
     <!-- Date & time setting screen setting switch title: whether the time zone should be determined automatically [CHAR LIMIT=100]  -->
     <string name="zone_auto_title">Set time zone automatically</string>
@@ -5248,9 +5254,11 @@
     <string name="accessibility_screen_magnification_short_summary">Tap 3 times to zoom</string>
     <!-- Short summary for nav bar Magnification. Tells the user that this feature allows the user to magnify the screen using a button in the nav bar -->
     <string name="accessibility_screen_magnification_navbar_short_summary">Tap a button to zoom</string>
+    <!-- Intro for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
+    <string name="accessibility_screen_magnification_intro_text">Quickly zoom in on the screen to make content larger</string>
     <!-- Summary for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
     <string name="accessibility_screen_magnification_summary">
-        <![CDATA[Quickly zoom in on the screen to make content larger.<br/><br/>
+        <![CDATA[
         <b>To zoom in:</b><br/>
         {0,number,integer}. Use shortcut to start magnification<br/>
         {1,number,integer}. Tap the screen<br/>
@@ -5258,10 +5266,11 @@
         {3,number,integer}. Pinch with 2 fingers to adjust zoom<br/>
         {4,number,integer}. Use shortcut to stop magnification<br/><br/>
         <b>To zoom in temporarily:</b><br/>
-        {0,number,integer}. Use shortcut to start magnification<br/>
-        {1,number,integer}. Touch & hold anywhere on the screen<br/>
-        {2,number,integer}. Drag finger to move around screen<br/>
-        {3,number,integer}. Lift finger to stop magnification
+        {0,number,integer}. Make sure your magnification type is set to full screen<br/>
+        {1,number,integer}. Use shortcut to start magnification<br/>
+        {2,number,integer}. Touch & hold anywhere on the screen<br/>
+        {3,number,integer}. Drag finger to move around screen<br/>
+        {4,number,integer}. Lift finger to stop magnification
         ]]>
     </string>
     <!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
@@ -5386,6 +5395,8 @@
     <string name="accessibility_button_high_label">Non-transparent</string>
     <!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
     <string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
+    <!-- Summary for the accessibility preference to high contrast text. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_toggle_high_text_contrast_preference_summary">Change text color to black or white. Maximizes contrast with the background.</string>
     <!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->
     <string name="accessibility_toggle_screen_magnification_auto_update_preference_title">Auto
         update screen magnification</string>
@@ -5428,7 +5439,9 @@
     <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
     <string name="accessibility_control_timeout_preference_title">Time to take action</string>
     <!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
-    <string name="accessibility_control_timeout_preference_summary">Choose how long to show messages that ask you to take action, but are visible only temporarily.\n\nNot all apps support this setting.</string>
+    <string name="accessibility_control_timeout_preference_summary">This timing preference isn\u2019t supported by all apps</string>
+    <!-- Intro text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_control_timeout_preference_intro_text">Choose how long to show temporary messages that ask you to take action</string>
 
     <!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
     <string name="accessibility_long_press_timeout_preference_title">Touch &amp; hold delay</string>
@@ -5438,14 +5451,15 @@
     <string name="accessibility_display_inversion_switch_title">Use color inversion</string>
     <!-- Title for accessibility shortcut preference for color inversion. [CHAR LIMIT=60] -->
     <string name="accessibility_display_inversion_shortcut_title">Color inversion shortcut</string>
+    <!-- Intro for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_display_inversion_preference_intro_text">Color inversion turns light screens dark. It also turns dark screens light.</string>
     <!-- Subtitle for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
     <string name="accessibility_display_inversion_preference_subtitle">
-        <![CDATA[Color inversion turns light screens dark.<br/><br/>
-        Note:
+        <![CDATA[<b>Keep in mind</b><br/>
         <ol>
-            <li>\u00a0Color inversion also turns dark screens light.</li>
-            <li>\u00a0Colors will change in media and images.</li>
-            <li>\u00a0Dark theme can be used to display a dark background. Dark theme works with supported apps. Color inversion works on all apps.</li>
+            <li>\u00a0Colors will change in media and images</li>
+            <li>\u00a0Color inversion works on all apps</li>
+            <li>\u00a0To display a dark background, Dark theme can be used instead</li>
         </ol>
         ]]>
     </string>
@@ -5455,10 +5469,12 @@
     <string name="accessibility_autoclick_about_title">About autoclick (dwell timing)</string>
     <!-- Accessibility dwell timing footer link content description [CHAR LIMIT=NONE] -->
     <string name="accessibility_autoclick_footer_learn_more_content_description">Learn more about autoclick (dwell timing)</string>
-    <!-- Footer text to explain what autoclick does -->
-    <string name="accessibility_autoclick_description">Autoclick works with a connected mouse. You can set the mouse cursor to click automatically when the cursor stops moving for a certain amount of time.</string>
+    <!-- Intro text to explain what autoclick does. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_autoclick_intro_text">You can set a connected mouse to click automatically when the cursor stops moving for a certain amount of time</string>
+    <!-- Footer text to explain what autoclick does. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_autoclick_description">Autoclick can be helpful if clicking the mouse is difficult</string>
     <!-- Option heading to leave the auto click requirement for accessibility users at its default level. [CHAR LIMIT=50] -->
-    <string name="accessibility_autoclick_default_title">Off</string>
+    <string name="accessibility_autoclick_default_title">Autoclick off</string>
     <!-- Option heading to leave the auto click requirement for accessibility users at its short level. [CHAR LIMIT=35] -->
     <string name="accessibility_autoclick_short_title">Short</string>
     <!-- Option summary text for the auto click delay 0.2 seconds radio button. [CHAR LIMIT=35] -->
@@ -5511,6 +5527,10 @@
     <string name="accessibility_service_quick_settings_tooltips_content"><xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> added to Quick Settings. Swipe down to turn it on or off anytime.</string>
     <!-- Used in the accessibility action for accessibility quick settings tooltips to dismiss. [CHAR LIMIT=NONE] -->
     <string name="accessibility_quick_settings_tooltips_dismiss">Dismiss</string>
+    <!-- Intro for color correction settings screen to control turning on/off the feature entirely. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_daltonizer_about_intro_text" product="default">Adjust how colors display on your phone</string>
+    <!-- Intro for color correction settings screen to control turning on/off the feature entirely. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_daltonizer_about_intro_text" product="tablet">Adjust how colors display on your tablet</string>
     <!-- Used in the Color correction settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
     <string name="accessibility_daltonizer_primary_switch_title">Use color correction</string>
     <!-- Title for accessibility shortcut preference for color correction. [CHAR LIMIT=60] -->
@@ -5590,22 +5610,20 @@
 
     <!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
     <string name="enable_quick_setting">Show in Quick Settings</string>
-    <!-- Title for the preference to configure the type of color space correction to apply. [CHAR LIMIT=NONE] -->
-    <string name="daltonizer_type">Correction mode</string>
     <!-- Title shown for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
-    <string name="daltonizer_mode_deuteranomaly_title">Deuteranomaly</string>
+    <string name="daltonizer_mode_deuteranomaly_title">Red-green</string>
     <!-- Title shown for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
-    <string name="daltonizer_mode_protanomaly_title">Protanomaly</string>
+    <string name="daltonizer_mode_protanomaly_title">Red-green</string>
     <!-- Title shown for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
-    <string name="daltonizer_mode_tritanomaly_title">Tritanomaly</string>
+    <string name="daltonizer_mode_tritanomaly_title">Blue-yellow</string>
     <!-- Title shown for grayscale [CHAR LIMIT=45] -->
     <string name="daltonizer_mode_grayscale_title">Grayscale</string>
     <!-- Summary shown for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
-    <string name="daltonizer_mode_deuteranomaly_summary">Red-green</string>
+    <string name="daltonizer_mode_deuteranomaly_summary">Green weak, deuteranomaly</string>
     <!-- Summary shown for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
-    <string name="daltonizer_mode_protanomaly_summary">Red-green</string>
+    <string name="daltonizer_mode_protanomaly_summary">Red weak, protanomaly</string>
     <!-- Summary shown for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
-    <string name="daltonizer_mode_tritanomaly_summary">Blue-yellow</string>
+    <string name="daltonizer_mode_tritanomaly_summary">Tritanomaly</string>
 
     <!-- Title for the accessibility preference of the Extra Dim/Reduce Brightness feature that dims your screen. [CHAR LIMIT=NONE] -->
     <string name="reduce_bright_colors_preference_title">Extra dim</string>
@@ -5619,10 +5637,11 @@
     <string name="reduce_bright_colors_preference_summary" product="default">Dim screen beyond your phone\u2019s minimum brightness</string>
     <!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
     <string name="reduce_bright_colors_preference_summary" product="tablet">Dim screen beyond your tablet\u2019s minimum brightness</string>
+    <!-- Intro that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
+    <string name="reduce_bright_colors_preference_intro_text">Make your screen dimmer so it\u2019s more comfortable to read</string>
     <!-- Subtitle that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
     <string name="reduce_bright_colors_preference_subtitle" product="default">
-        <![CDATA[Make your screen dimmer so it\u2019s more comfortable to read.<br/><br/>
-        This can be helpful when:
+        <![CDATA[Extra dim can be helpful when:
         <ol>
             <li>\u00a0Your phone\u2019s default minimum brightness is still too bright</li>
             <li>\u00a0You\u2019re using your phone in dark situations, like at night or in a dark room before bed</li>
@@ -5631,8 +5650,7 @@
     </string>
     <!-- Subtitle that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
     <string name="reduce_bright_colors_preference_subtitle" product="tablet">
-        <![CDATA[Make your screen darker so it\u2019s more comfortable to read.<br/><br/>
-        This can be helpful when:
+        <![CDATA[Extra dim can be helpful when:
         <ol>
             <li>\u00a0Your tablet\u2019s default minimum brightness is still too bright</li>
             <li>\u00a0You\u2019re using your tablet in dark situations, like at night or in a dark room before bed</li>
diff --git a/res/xml/accessibility_autoclick_settings.xml b/res/xml/accessibility_autoclick_settings.xml
index 617f22a..943bc67 100644
--- a/res/xml/accessibility_autoclick_settings.xml
+++ b/res/xml/accessibility_autoclick_settings.xml
@@ -19,18 +19,21 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:title="@string/accessibility_autoclick_preference_title">
 
+    <com.android.settingslib.widget.TopIntroPreference
+        android:key="accessibility_autoclick_intro"
+        android:persistent="false"
+        android:title="@string/accessibility_autoclick_intro_text" />
+
     <com.android.settingslib.widget.IllustrationPreference
         android:key="accessibility_autoclick_banner"
         android:persistent="false"
         android:selectable="false"
-        settings:allowDividerBelow="true"
         settings:searchable="false"
         settings:lottie_rawRes="@drawable/accessibility_dwell" />
 
     <com.android.settingslib.widget.SelectorWithWidgetPreference
         android:key="accessibility_control_autoclick_default"
-        android:title="@string/accessibility_autoclick_default_title"
-        settings:allowDividerAbove="true" />
+        android:title="@string/accessibility_autoclick_default_title" />
 
     <com.android.settingslib.widget.SelectorWithWidgetPreference
         android:key="accessibility_control_autoclick_200ms"
@@ -56,7 +59,6 @@
         android:layout="@layout/accessibility_autoclick_custom_seekbar"
         android:selectable="false"
         android:visibility="gone"
-        settings:allowDividerBelow="true"
         settings:controller="com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController" />
 
     <com.android.settings.accessibility.AccessibilityFooterPreference
diff --git a/res/xml/accessibility_control_timeout_settings.xml b/res/xml/accessibility_control_timeout_settings.xml
index aaa2c06..3cd0dd6 100644
--- a/res/xml/accessibility_control_timeout_settings.xml
+++ b/res/xml/accessibility_control_timeout_settings.xml
@@ -21,6 +21,11 @@
     android:title="@string/accessibility_control_timeout_preference_title"
     android:persistent="false" >
 
+    <com.android.settingslib.widget.TopIntroPreference
+        android:key="accessibility_control_timeout_intro"
+        android:persistent="false"
+        android:title="@string/accessibility_control_timeout_preference_intro_text" />
+
     <com.android.settingslib.widget.IllustrationPreference
         android:key="accessibility_control_timeout_banner"
         settings:lottie_rawRes="@raw/accessibility_timeout_banner"/>
@@ -28,7 +33,6 @@
     <com.android.settingslib.widget.SelectorWithWidgetPreference
         android:key="accessibility_control_timeout_default"
         android:title="@string/accessibility_timeout_default"
-        settings:allowDividerAbove="true"
         android:persistent="false" />
 
     <com.android.settingslib.widget.SelectorWithWidgetPreference
diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml
index 1b69dc6..91b163b 100644
--- a/res/xml/accessibility_daltonizer_settings.xml
+++ b/res/xml/accessibility_daltonizer_settings.xml
@@ -28,32 +28,27 @@
         settings:allowDividerBelow="true"
         settings:searchable="false"/>
 
-    <PreferenceCategory
-        android:title="@string/daltonizer_type"
-        android:key="daltonizer_mode_category" >
+    <com.android.settingslib.widget.SelectorWithWidgetPreference
+        android:key="daltonizer_mode_deuteranomaly"
+        android:persistent="false"
+        android:summary="@string/daltonizer_mode_deuteranomaly_summary"
+        android:title="@string/daltonizer_mode_deuteranomaly_title" />
 
-        <com.android.settingslib.widget.SelectorWithWidgetPreference
-            android:key="daltonizer_mode_deuteranomaly"
-            android:persistent="false"
-            android:summary="@string/daltonizer_mode_deuteranomaly_summary"
-            android:title="@string/daltonizer_mode_deuteranomaly_title" />
+    <com.android.settingslib.widget.SelectorWithWidgetPreference
+        android:key="daltonizer_mode_protanomaly"
+        android:persistent="false"
+        android:summary="@string/daltonizer_mode_protanomaly_summary"
+        android:title="@string/daltonizer_mode_protanomaly_title" />
 
-        <com.android.settingslib.widget.SelectorWithWidgetPreference
-            android:key="daltonizer_mode_protanomaly"
-            android:persistent="false"
-            android:summary="@string/daltonizer_mode_protanomaly_summary"
-            android:title="@string/daltonizer_mode_protanomaly_title" />
+    <com.android.settingslib.widget.SelectorWithWidgetPreference
+        android:key="daltonizer_mode_tritanomaly"
+        android:persistent="false"
+        android:summary="@string/daltonizer_mode_tritanomaly_summary"
+        android:title="@string/daltonizer_mode_tritanomaly_title" />
 
-        <com.android.settingslib.widget.SelectorWithWidgetPreference
-            android:key="daltonizer_mode_tritanomaly"
-            android:persistent="false"
-            android:summary="@string/daltonizer_mode_tritanomaly_summary"
-            android:title="@string/daltonizer_mode_tritanomaly_title" />
-        <com.android.settingslib.widget.SelectorWithWidgetPreference
-            android:key="daltonizer_mode_grayscale"
-            android:persistent="false"
-            android:title="@string/daltonizer_mode_grayscale_title" />
-
-    </PreferenceCategory>
+    <com.android.settingslib.widget.SelectorWithWidgetPreference
+        android:key="daltonizer_mode_grayscale"
+        android:persistent="false"
+        android:title="@string/daltonizer_mode_grayscale_title" />
 
 </PreferenceScreen>
diff --git a/res/xml/accessibility_text_reading_options.xml b/res/xml/accessibility_text_reading_options.xml
index 7d81565..d55882d 100644
--- a/res/xml/accessibility_text_reading_options.xml
+++ b/res/xml/accessibility_text_reading_options.xml
@@ -54,6 +54,7 @@
     <SwitchPreference
         android:key="toggle_high_text_contrast_preference"
         android:persistent="false"
+        android:summary="@string/accessibility_toggle_high_text_contrast_preference_summary"
         android:title="@string/accessibility_toggle_high_text_contrast_preference_title" />
 
     <com.android.settingslib.widget.LayoutPreference
diff --git a/res/xml/app_locale_details.xml b/res/xml/app_locale_details.xml
index 8056cbf..40ca582 100644
--- a/res/xml/app_locale_details.xml
+++ b/res/xml/app_locale_details.xml
@@ -28,7 +28,14 @@
 
     <PreferenceCategory
         android:key="category_key_suggested_languages"
-        android:title="@string/suggested_app_locales_title" />
+        android:title="@string/suggested_app_locales_title" >
+
+        <com.android.settingslib.widget.RadioButtonPreference
+            android:key="system_default_locale"
+            android:title="@string/preference_of_system_locale_title"
+            android:order="-10000"/>
+
+    </PreferenceCategory>
 
     <PreferenceCategory
         android:key="category_key_all_languages"
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index c99d591..770a862 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -25,7 +25,6 @@
         <Preference
             android:key="phone_language"
             android:title="@string/phone_language"
-            android:icon="@drawable/ic_translate_24dp"
             android:fragment="com.android.settings.localepicker.LocaleListEditor" />
 
         <Preference
diff --git a/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java b/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
index 37d09a7..01ee249 100644
--- a/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
@@ -100,7 +100,10 @@
         extras.putInt(AccessibilitySettings.EXTRA_TITLE_RES,
                 R.string.accessibility_screen_magnification_gestures_title);
 
-        String summary =  context.getString(R.string.accessibility_screen_magnification_summary);
+        String intro = context.getString(R.string.accessibility_screen_magnification_intro_text);
+        extras.putCharSequence(AccessibilitySettings.EXTRA_INTRO, intro);
+
+        String summary = context.getString(R.string.accessibility_screen_magnification_summary);
         final Object[] numberArguments = {1, 2, 3, 4, 5};
         summary = MessageFormat.format(summary, numberArguments);
         extras.putCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION, summary);
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index 679e284..e421626 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -82,6 +82,7 @@
         mComponentName = COLOR_INVERSION_COMPONENT_NAME;
         mPackageName = getText(R.string.accessibility_display_inversion_preference_title);
         mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
+        mTopIntroTitle = getText(R.string.accessibility_display_inversion_preference_intro_text);
         mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
                 .authority(getPrefContext().getPackageName())
                 .appendPath(String.valueOf(R.raw.accessibility_color_inversion_banner))
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 5d9cbe5..b1b9f81 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -51,7 +51,10 @@
 
     private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
     private static final String KEY_PREVIEW = "daltonizer_preview";
-    private static final String KEY_CATEGORY_MODE = "daltonizer_mode_category";
+    private static final String KEY_DEUTERANOMALY = "daltonizer_mode_deuteranomaly";
+    private static final String KEY_PROTANOMALY = "daltonizer_mode_protanomaly";
+    private static final String KEY_TRITANOMEALY = "daltonizer_mode_tritanomaly";
+    private static final String KEY_GRAYSCALE = "daltonizer_mode_grayscale";
     private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
 
     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
@@ -82,6 +85,7 @@
         mComponentName = DALTONIZER_COMPONENT_NAME;
         mPackageName = getText(R.string.accessibility_display_daltonizer_preference_title);
         mHtmlDescription = getText(R.string.accessibility_display_daltonizer_preference_subtitle);
+        mTopIntroTitle = getText(R.string.accessibility_daltonizer_about_intro_text);
         final View view = super.onCreateView(inflater, container, savedInstanceState);
         updateFooterPreference();
         return view;
@@ -111,9 +115,13 @@
     /** Customizes the order by preference key. */
     protected List<String> getPreferenceOrderList() {
         final List<String> lists = new ArrayList<>();
+        lists.add(KEY_TOP_INTRO_PREFERENCE);
         lists.add(KEY_PREVIEW);
         lists.add(KEY_USE_SERVICE_PREFERENCE);
-        lists.add(KEY_CATEGORY_MODE);
+        lists.add(KEY_DEUTERANOMALY);
+        lists.add(KEY_PROTANOMALY);
+        lists.add(KEY_TRITANOMEALY);
+        lists.add(KEY_GRAYSCALE);
         lists.add(KEY_GENERAL_CATEGORY);
         lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
         return lists;
diff --git a/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java
index 973e27c..1e2e9e5 100644
--- a/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java
@@ -68,6 +68,7 @@
         mComponentName = REDUCE_BRIGHT_COLORS_COMPONENT_NAME;
         mPackageName = getText(R.string.reduce_bright_colors_preference_title);
         mHtmlDescription = getText(R.string.reduce_bright_colors_preference_subtitle);
+        mTopIntroTitle = getText(R.string.reduce_bright_colors_preference_intro_text);
         mRbcIntensityPreferenceController =
                 new ReduceBrightColorsIntensityPreferenceController(getContext(), KEY_INTENSITY);
         mRbcPersistencePreferenceController =
diff --git a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
index 164cfd9..8f1c212 100644
--- a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
+++ b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
@@ -38,8 +38,6 @@
 import androidx.preference.Preference;
 import androidx.preference.PreferenceGroup;
 
-import com.android.internal.app.LocalePicker;
-import com.android.internal.app.LocalePicker.LocaleInfo;
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.applications.AppInfoBase;
@@ -48,11 +46,8 @@
 import com.android.settingslib.widget.LayoutPreference;
 import com.android.settingslib.widget.RadioButtonPreference;
 
-import com.google.common.collect.Iterables;
-
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
 import java.util.Locale;
 
 /**
@@ -66,13 +61,17 @@
     private static final String CATEGORY_KEY_ALL_LANGUAGES =
             "category_key_all_languages";
     private static final String KEY_APP_DESCRIPTION = "app_locale_description";
+    @VisibleForTesting
+    static final String KEY_SYSTEM_DEFAULT_LOCALE = "system_default_locale";
 
     private boolean mCreated = false;
-    private AppLocaleDetailsHelper mAppLocaleDetailsHelper;
+    @VisibleForTesting
+    AppLocaleDetailsHelper mAppLocaleDetailsHelper;
 
     private PreferenceGroup mGroupOfSuggestedLocales;
     private PreferenceGroup mGroupOfSupportedLocales;
     private LayoutPreference mPrefOfDescription;
+    private RadioButtonPreference mDefaultPreference;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -85,6 +84,10 @@
         mGroupOfSupportedLocales =
                 getPreferenceScreen().findPreference(CATEGORY_KEY_ALL_LANGUAGES);
         mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
+
+        mDefaultPreference = (RadioButtonPreference) getPreferenceScreen()
+                .findPreference(KEY_SYSTEM_DEFAULT_LOCALE);
+        mDefaultPreference.setOnClickListener(this);
     }
 
     // Override here so we don't have an empty screen
@@ -104,30 +107,43 @@
         // Update Locales first, before refresh ui.
         mAppLocaleDetailsHelper.handleAllLocalesData();
         super.onResume();
+        mDefaultPreference.setSummary(Locale.getDefault().getDisplayName(Locale.getDefault()));
     }
 
     @Override
     protected boolean refreshUi() {
+        refreshUiInternal();
+        return true;
+    }
+
+    @VisibleForTesting
+    void refreshUiInternal() {
         if (mAppLocaleDetailsHelper.getSupportedLocales().isEmpty()) {
             Log.d(TAG, "No supported language.");
             mGroupOfSuggestedLocales.setVisible(false);
             mGroupOfSupportedLocales.setVisible(false);
             mPrefOfDescription.setVisible(true);
             TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
-            Locale locale = mAppLocaleDetailsHelper.getCurrentSystemLocales().get(0);
             description.setText(getContext().getString(R.string.no_multiple_language_supported,
-                    locale.getDisplayName(locale)));
-            return true;
+                    Locale.getDefault().getDisplayName(Locale.getDefault())));
+            return;
         }
-
-        mGroupOfSuggestedLocales.removeAll();
-        mGroupOfSupportedLocales.removeAll();
+        resetLocalePreferences();
         Locale appLocale = AppLocaleDetailsHelper.getAppDefaultLocale(getContext(), mPackageName);
+        // Sets up default locale preference.
+        mGroupOfSuggestedLocales.addPreference(mDefaultPreference);
+        mDefaultPreference.setChecked(appLocale == null);
+        // Sets up suggested locales of per app.
         setLanguagesPreference(mGroupOfSuggestedLocales,
                 mAppLocaleDetailsHelper.getSuggestedLocales(), appLocale);
+        // Sets up supported locales of per app.
         setLanguagesPreference(mGroupOfSupportedLocales,
                 mAppLocaleDetailsHelper.getSupportedLocales(), appLocale);
-        return true;
+    }
+
+    private void resetLocalePreferences() {
+        mGroupOfSuggestedLocales.removeAll();
+        mGroupOfSupportedLocales.removeAll();
     }
 
     @Override
@@ -142,7 +158,12 @@
 
     @Override
     public void onRadioButtonClicked(RadioButtonPreference pref) {
-        mAppLocaleDetailsHelper.setAppDefaultLocale(pref.getKey());
+        String key = pref.getKey();
+        if (KEY_SYSTEM_DEFAULT_LOCALE.equals(key)) {
+            mAppLocaleDetailsHelper.setAppDefaultLocale(LocaleList.forLanguageTags(""));
+        } else {
+            mAppLocaleDetailsHelper.setAppDefaultLocale(key);
+        }
         refreshUi();
     }
 
@@ -180,7 +201,13 @@
     public static CharSequence getSummary(Context context, String packageName) {
         Locale appLocale =
                 AppLocaleDetailsHelper.getAppDefaultLocale(context, packageName);
-        return appLocale == null ? "" : appLocale.getDisplayName(appLocale);
+        if (appLocale == null) {
+            Locale systemLocale = Locale.getDefault();
+            return context.getString(R.string.preference_of_system_locale_summary,
+                    systemLocale.getDisplayName(systemLocale));
+        } else {
+            return appLocale.getDisplayName(appLocale);
+        }
     }
 
     private void setLanguagesPreference(PreferenceGroup group,
@@ -190,9 +217,15 @@
         }
 
         for (Locale locale : locales) {
+            if (locale == null) {
+                continue;
+            }
+
             RadioButtonPreference pref = new RadioButtonPreference(getContext());
             pref.setTitle(locale.getDisplayName(locale));
             pref.setKey(locale.toLanguageTag());
+            // Will never be checked if appLocale is null
+            // aka if there is no per-app locale
             pref.setChecked(locale.equals(appLocale));
             pref.setOnClickListener(this);
             group.addPreference(pref);
@@ -206,14 +239,17 @@
         private TelephonyManager mTelephonyManager;
         private LocaleManager mLocaleManager;
 
-        private Collection<Locale> mSuggestedLocales = new ArrayList<>();
-        private Collection<Locale> mSupportedLocales = new ArrayList<>();
+        private Collection<Locale> mProcessedSuggestedLocales = new ArrayList<>();
+        private Collection<Locale> mProcessedSupportedLocales = new ArrayList<>();
+
+        private Collection<Locale> mAppSupportedLocales = new ArrayList<>();
 
         AppLocaleDetailsHelper(Context context, String packageName) {
             mContext = context;
             mPackageName = packageName;
             mTelephonyManager = context.getSystemService(TelephonyManager.class);
             mLocaleManager = context.getSystemService(LocaleManager.class);
+            mAppSupportedLocales = getAppSupportedLocales();
         }
 
         /** Handle suggested and supported locales for UI display. */
@@ -225,49 +261,47 @@
 
         /** Gets suggested locales in the app. */
         public Collection<Locale> getSuggestedLocales() {
-            return mSuggestedLocales;
+            return mProcessedSuggestedLocales;
         }
 
         /** Gets supported locales in the app. */
         public Collection<Locale> getSupportedLocales() {
-            return mSupportedLocales;
+            return mProcessedSupportedLocales;
         }
 
         @VisibleForTesting
         void handleSuggestedLocales() {
-            LocaleList currentSystemLocales = getCurrentSystemLocales();
             Locale appLocale = getAppDefaultLocale(mContext, mPackageName);
+            // 1st locale in suggested languages group.
+            for (Locale supportedlocale : mAppSupportedLocales) {
+                if (compareLocale(supportedlocale, appLocale)) {
+                    mProcessedSuggestedLocales.add(appLocale);
+                    break;
+                }
+            }
+
+            // 2nd and 3rd locale in suggested languages group.
             String simCountry = mTelephonyManager.getSimCountryIso().toUpperCase(Locale.US);
             String networkCountry = mTelephonyManager.getNetworkCountryIso().toUpperCase(Locale.US);
-            // 1st locale in suggested languages group.
-            if (appLocale != null) {
-                mSuggestedLocales.add(appLocale);
-            }
-            // 2nd locale in suggested languages group.
-            final List<LocaleInfo> localeInfos = LocalePicker.getAllAssetLocales(mContext, false);
-            for (LocaleInfo localeInfo : localeInfos) {
-                Locale locale = localeInfo.getLocale();
-                String localeCountry = locale.getCountry().toUpperCase(Locale.US);
-                if (!compareLocale(locale, appLocale)
+            mAppSupportedLocales.forEach(supportedlocale -> {
+                String localeCountry = supportedlocale.getCountry().toUpperCase(Locale.US);
+                if (!compareLocale(supportedlocale, appLocale)
                         && isCountrySuggestedLocale(localeCountry, simCountry, networkCountry)) {
-                    mSuggestedLocales.add(locale);
+                    mProcessedSuggestedLocales.add(supportedlocale);
                 }
-            }
+            });
+
             // Other locales in suggested languages group.
-            for (int i = 0; i < currentSystemLocales.size(); i++) {
-                Locale locale = currentSystemLocales.get(i);
-                boolean isInSuggestedLocales = false;
-                for (int j = 0; j < mSuggestedLocales.size(); j++) {
-                    Locale suggestedLocale = Iterables.get(mSuggestedLocales, j);
-                    if (compareLocale(locale, suggestedLocale)) {
-                        isInSuggestedLocales = true;
-                        break;
+            Collection<Locale> supportedSystemLocales = new ArrayList<>();
+            getCurrentSystemLocales().forEach(systemLocale -> {
+                mAppSupportedLocales.forEach(supportedLocale -> {
+                    if (compareLocale(systemLocale, supportedLocale)) {
+                        supportedSystemLocales.add(supportedLocale);
                     }
-                }
-                if (!isInSuggestedLocales) {
-                    mSuggestedLocales.add(locale);
-                }
-            }
+                });
+            });
+            supportedSystemLocales.removeAll(mProcessedSuggestedLocales);
+            mProcessedSuggestedLocales.addAll(supportedSystemLocales);
         }
 
         @VisibleForTesting
@@ -290,26 +324,34 @@
 
         @VisibleForTesting
         void handleSupportedLocales() {
-            LocaleList localeList = getPackageLocales();
-            if (localeList == null) {
-                String[] languages = getAssetSystemLocales();
-                for (String language : languages) {
-                    mSupportedLocales.add(Locale.forLanguageTag(language));
-                }
-            } else {
-                for (int i = 0; i < localeList.size(); i++) {
-                    mSupportedLocales.add(localeList.get(i));
-                }
-            }
+            mProcessedSupportedLocales.addAll(mAppSupportedLocales);
 
-            if (mSuggestedLocales != null || !mSuggestedLocales.isEmpty()) {
-                mSupportedLocales.removeAll(mSuggestedLocales);
+            if (mProcessedSuggestedLocales != null || !mProcessedSuggestedLocales.isEmpty()) {
+                mProcessedSuggestedLocales.retainAll(mProcessedSupportedLocales);
+                mProcessedSupportedLocales.removeAll(mProcessedSuggestedLocales);
             }
         }
 
         private void clearLocalesData() {
-            mSuggestedLocales.clear();
-            mSupportedLocales.clear();
+            mProcessedSuggestedLocales.clear();
+            mProcessedSupportedLocales.clear();
+        }
+
+        private Collection<Locale> getAppSupportedLocales() {
+            Collection<Locale> appSupportedLocales = new ArrayList<>();
+            LocaleList localeList = getPackageLocales();
+
+            if (localeList != null && localeList.size() > 0) {
+                for (int i = 0; i < localeList.size(); i++) {
+                    appSupportedLocales.add(localeList.get(i));
+                }
+            } else {
+                String[] languages = getAssetLocales();
+                for (String language : languages) {
+                    appSupportedLocales.add(Locale.forLanguageTag(language));
+                }
+            }
+            return appSupportedLocales;
         }
 
         /** Gets per app's default locale */
@@ -317,8 +359,8 @@
             LocaleManager localeManager = context.getSystemService(LocaleManager.class);
             try {
                 LocaleList localeList = (localeManager == null)
-                        ? new LocaleList() : localeManager.getApplicationLocales(packageName);
-                return localeList.isEmpty() ? null : localeList.get(0);
+                        ? null : localeManager.getApplicationLocales(packageName);
+                return localeList == null ? null : localeList.get(0);
             } catch (IllegalArgumentException e) {
                 Log.w(TAG, "package name : " + packageName + " is not correct. " + e);
             }
@@ -344,12 +386,17 @@
         }
 
         @VisibleForTesting
-        LocaleList getCurrentSystemLocales() {
-            return Resources.getSystem().getConfiguration().getLocales();
+        Collection<Locale> getCurrentSystemLocales() {
+            LocaleList localeList = Resources.getSystem().getConfiguration().getLocales();
+            Collection<Locale> systemLocales = new ArrayList<>();
+            for (int i = 0; i < localeList.size(); i++) {
+                systemLocales.add(localeList.get(i));
+            }
+            return systemLocales;
         }
 
         @VisibleForTesting
-        String[] getAssetSystemLocales() {
+        String[] getAssetLocales() {
             try {
                 PackageManager packageManager = mContext.getPackageManager();
                 return packageManager.getResourcesForApplication(
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index cdac3b9..8ad66d2 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -171,11 +171,13 @@
                     intent.setAction(action);
                 }
                 // Register the rule for injected apps.
-                ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
-                        mContext,
-                        new ComponentName(tile.getPackageName(), tile.getComponentName()),
-                        action,
-                        true /* clearTop */);
+                if (fragment instanceof TopLevelSettings) {
+                    ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
+                            mContext,
+                            new ComponentName(tile.getPackageName(), tile.getComponentName()),
+                            action,
+                            true /* clearTop */);
+                }
                 pref.setOnPreferenceClickListener(preference -> {
                     TopLevelHighlightMixin highlightMixin = null;
                     if (fragment instanceof TopLevelSettings
@@ -442,11 +444,6 @@
         ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
         mMetricsFeatureProvider.logStartedIntent(intent, sourceMetricCategory);
 
-        //TODO(b/201970810): Add test cases.
-        if (tile.isNewTask(mContext)) {
-            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        }
-
         if (tile.userHandle == null || tile.isPrimaryProfileOnly()) {
             activity.startActivity(intent);
         } else if (tile.userHandle.size() == 1) {
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java
index e0ba378..d3234dd 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java
@@ -97,7 +97,7 @@
     public void onClick(DialogInterface dialog, int which) {
         final UserHandle user = mSelectedTile.userHandle.get(which);
         // Show menu on top level items.
-        final Intent intent = mSelectedTile.getIntent();
+        final Intent intent = new Intent(mSelectedTile.getIntent());
         FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider()
                 .logStartedIntentWithProfile(intent, mSourceMetricCategory,
                         which == 1 /* isWorkProfile */);
diff --git a/src/com/android/settings/dream/AutoFitGridLayoutManager.java b/src/com/android/settings/dream/AutoFitGridLayoutManager.java
index 0e5d3e1..7de0eae 100644
--- a/src/com/android/settings/dream/AutoFitGridLayoutManager.java
+++ b/src/com/android/settings/dream/AutoFitGridLayoutManager.java
@@ -24,10 +24,10 @@
 import com.android.settings.R;
 
 /** Grid layout manager that calculates the number of columns for the screen size. */
-final class AutoFitGridLayoutManager extends GridLayoutManager {
+public final class AutoFitGridLayoutManager extends GridLayoutManager {
     private final float mColumnWidth;
 
-    AutoFitGridLayoutManager(Context context) {
+    public AutoFitGridLayoutManager(Context context) {
         super(context, /* spanCount= */ 1);
         this.mColumnWidth = context
                 .getResources()
diff --git a/src/com/android/settings/dream/DreamAdapter.java b/src/com/android/settings/dream/DreamAdapter.java
index e674546..8d0e9d5 100644
--- a/src/com/android/settings/dream/DreamAdapter.java
+++ b/src/com/android/settings/dream/DreamAdapter.java
@@ -37,7 +37,7 @@
 /**
  * RecyclerView adapter which displays list of items for the user to select.
  */
-class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
     private final List<IDreamItem> mItemList;
     private int mLastSelectedPos = -1;
 
@@ -103,7 +103,7 @@
         }
     }
 
-    DreamAdapter(List<IDreamItem> itemList) {
+    public DreamAdapter(List<IDreamItem> itemList) {
         mItemList = itemList;
     }
 
diff --git a/src/com/android/settings/dream/DreamSetupActivity.java b/src/com/android/settings/dream/DreamSetupActivity.java
deleted file mode 100644
index 6a12671..0000000
--- a/src/com/android/settings/dream/DreamSetupActivity.java
+++ /dev/null
@@ -1,177 +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.dream;
-
-import android.app.settings.SettingsEnums;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settingslib.dream.DreamBackend;
-
-import com.google.android.setupcompat.template.FooterBarMixin;
-import com.google.android.setupcompat.template.FooterButton;
-import com.google.android.setupcompat.util.WizardManagerHelper;
-import com.google.android.setupdesign.GlifLayout;
-import com.google.android.setupdesign.util.ThemeHelper;
-import com.google.android.setupdesign.util.ThemeResolver;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * The setup activity for dreams which is displayed during setup wizard.
- */
-public class DreamSetupActivity extends SettingsActivity {
-    @Override
-    public Intent getIntent() {
-        Intent modIntent = new Intent(super.getIntent());
-        modIntent.putExtra(EXTRA_SHOW_FRAGMENT, DreamSetupFragment.class.getName());
-        return modIntent;
-    }
-
-    @Override
-    protected boolean isValidFragment(String fragmentName) {
-        return DreamSetupFragment.class.getName().equals(fragmentName);
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstance) {
-        setTheme(ThemeResolver.getDefault().resolve(getIntent()));
-        ThemeHelper.trySetDynamicColor(this);
-        super.onCreate(savedInstance);
-    }
-
-    @Override
-    protected boolean isToolbarEnabled() {
-        return false;
-    }
-
-    /**
-     * Fragment used to control the active dream.
-     */
-    public static class DreamSetupFragment extends SettingsPreferenceFragment {
-        private DreamBackend mBackend;
-        private DreamBackend.DreamInfo mActiveDream;
-        private FooterButton mFooterButton;
-
-        @Override
-        public int getMetricsCategory() {
-            return SettingsEnums.DREAM;
-        }
-
-        @Override
-        public View onCreateView(LayoutInflater inflater, ViewGroup container,
-                Bundle savedInstanceState) {
-            return inflater.inflate(R.layout.dream_setup_layout, container, false);
-        }
-
-        @Override
-        public void onViewCreated(View view, Bundle savedInstanceState) {
-            super.onViewCreated(view, savedInstanceState);
-
-            mBackend = DreamBackend.getInstance(getContext());
-            final List<DreamBackend.DreamInfo> dreamInfos = mBackend.getDreamInfos();
-            mActiveDream = dreamInfos.stream().filter(d -> d.isActive).findFirst().orElse(null);
-            DreamAdapter dreamAdapter = new DreamAdapter(dreamInfos.stream()
-                    .map(DreamItem::new)
-                    .collect(Collectors.toList()));
-
-            final RecyclerView recyclerView = view.findViewById(R.id.dream_setup_list);
-            recyclerView.setLayoutManager(new AutoFitGridLayoutManager(getContext()));
-            recyclerView.setHasFixedSize(true);
-            recyclerView.setAdapter(dreamAdapter);
-
-            final GlifLayout layout = view.findViewById(R.id.setup_wizard_layout);
-            final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
-            mFooterButton = new FooterButton.Builder(getContext())
-                    .setListener(this::onPrimaryButtonClicked)
-                    .setButtonType(FooterButton.ButtonType.NEXT)
-                    .setTheme(R.style.SudGlifButton_Primary)
-                    .build();
-            updateFooterButtonText();
-            mixin.setPrimaryButton(mFooterButton);
-        }
-
-        private void updateFooterButtonText() {
-            final int res = canCustomizeDream() ? R.string.wizard_next : R.string.wizard_finish;
-            mFooterButton.setText(getContext().getString(res));
-        }
-
-        private boolean canCustomizeDream() {
-            return mActiveDream != null && mActiveDream.settingsComponentName != null;
-        }
-
-        private void onPrimaryButtonClicked(View view) {
-            if (canCustomizeDream()) {
-                final Intent intent = new Intent().setComponent(mActiveDream.settingsComponentName);
-                WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
-                startActivity(intent);
-            }
-
-            // Use RESULT_CANCELED here so that the user may go back and change this if they wish.
-            setResult(RESULT_CANCELED);
-            finish();
-        }
-
-        private class DreamItem implements IDreamItem {
-            private final DreamBackend.DreamInfo mDreamInfo;
-
-            private DreamItem(DreamBackend.DreamInfo dreamInfo) {
-                mDreamInfo = dreamInfo;
-            }
-
-            @Override
-            public CharSequence getTitle() {
-                return mDreamInfo.caption;
-            }
-
-            @Override
-            public Drawable getIcon() {
-                return mDreamInfo.icon;
-            }
-
-            @Override
-            public void onItemClicked() {
-                mActiveDream = mDreamInfo;
-                mBackend.setActiveDream(mDreamInfo.componentName);
-                updateFooterButtonText();
-            }
-
-            @Override
-            public Drawable getPreviewImage() {
-                return mDreamInfo.previewImage;
-            }
-
-            @Override
-            public boolean isActive() {
-                if (mActiveDream == null) {
-                    return false;
-                }
-                return mDreamInfo.componentName.equals(mActiveDream.componentName);
-            }
-        }
-    }
-}
diff --git a/src/com/android/settings/dream/IDreamItem.java b/src/com/android/settings/dream/IDreamItem.java
index 6652857..c462fe2 100644
--- a/src/com/android/settings/dream/IDreamItem.java
+++ b/src/com/android/settings/dream/IDreamItem.java
@@ -18,7 +18,10 @@
 
 import android.graphics.drawable.Drawable;
 
-interface IDreamItem {
+/**
+ * Interface representing a dream item to be displayed.
+ */
+public interface IDreamItem {
     CharSequence getTitle();
 
     Drawable getIcon();
diff --git a/src/com/android/settings/nfc/PaymentDefaultDialog.java b/src/com/android/settings/nfc/PaymentDefaultDialog.java
index a888167..75746ce 100644
--- a/src/com/android/settings/nfc/PaymentDefaultDialog.java
+++ b/src/com/android/settings/nfc/PaymentDefaultDialog.java
@@ -58,7 +58,11 @@
         ComponentName component = intent.getParcelableExtra(
                 CardEmulation.EXTRA_SERVICE_COMPONENT);
         String category = intent.getStringExtra(CardEmulation.EXTRA_CATEGORY);
-        int userId = intent.getIntExtra(CardEmulation.EXTRA_USERID, UserHandle.myUserId());
+        UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER);
+        if (userHandle == null) {
+            userHandle = UserHandle.CURRENT;
+        }
+        int userId = userHandle.getIdentifier();
 
         setResult(RESULT_CANCELED);
         if (!buildDialog(component, category, userId)) {
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
index e63dd80..64dbbb2 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
@@ -24,20 +24,26 @@
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 
+import android.app.Activity;
+import android.app.PendingIntent;
 import android.content.Context;
+import android.content.Intent;
 import android.net.Uri;
 
+import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
 import androidx.slice.SliceProvider;
 import androidx.slice.widget.SliceLiveData;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
 
+import com.android.settings.R;
 import com.android.settings.slices.CustomSliceRegistry;
-import com.android.settings.wifi.slice.ContextualWifiSlice;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 
@@ -48,6 +54,7 @@
 
     private Context mContext;
     private EligibleCardChecker mEligibleCardChecker;
+    private Activity mActivity;
 
     @Before
     public void setUp() {
@@ -55,22 +62,19 @@
         mEligibleCardChecker =
                 spy(new EligibleCardChecker(mContext, getContextualCard(TEST_SLICE_URI)));
         SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+        mActivity = Robolectric.buildActivity(Activity.class).create().get();
     }
 
     @Test
-    @Ignore
     public void isSliceToggleable_cardWithToggle_returnTrue() {
-        final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
-        final Slice slice = wifiSlice.getSlice();
+        final Slice slice = buildSlice();
 
         assertThat(mEligibleCardChecker.isSliceToggleable(slice)).isTrue();
     }
 
     @Test
-    @Ignore
     public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
-        final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
-        final Slice slice = wifiSlice.getSlice();
+        final Slice slice = buildSlice();
         doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
 
         mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
@@ -118,10 +122,8 @@
     }
 
     @Test
-    @Ignore
     public void isCardEligibleToDisplay_sliceNotNull_cacheSliceToCard() {
-        final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
-        final Slice slice = wifiSlice.getSlice();
+        final Slice slice = buildSlice();
         doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
 
         mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
@@ -137,4 +139,23 @@
                 .setSliceUri(sliceUri)
                 .build();
     }
+
+    private Slice buildSlice() {
+        final String title = "test_title";
+        final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
+        final PendingIntent pendingIntent = PendingIntent.getActivity(
+                mActivity,
+                title.hashCode() /* requestCode */,
+                new Intent("test action"),
+                PendingIntent.FLAG_IMMUTABLE);
+        final SliceAction action
+                = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
+        return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY)
+                .addRow(new ListBuilder.RowBuilder()
+                        .addEndItem(icon, ListBuilder.ICON_IMAGE)
+                        .setTitle(title)
+                        .setPrimaryAction(action))
+                .addAction(SliceAction.createToggle(pendingIntent, null /* actionTitle */, true))
+                .build();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
index fc6481b..dcf086c 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
@@ -44,6 +44,8 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.Settings.MobileNetworkActivity;
+import com.android.settings.network.helper.SubscriptionAnnotation;
+import com.android.settings.network.helper.SubscriptionGrouping;
 import com.android.settings.widget.AddPreference;
 import com.android.settingslib.RestrictedLockUtils;
 
@@ -123,7 +125,6 @@
 
 
     @Test
-    @Ignore
     public void getSummary_noSubscriptions_correctSummaryAndClickHandler() {
         mController.displayPreference(mPreferenceScreen);
         mController.onResume();
@@ -212,23 +213,6 @@
     }
 
     @Test
-    @Ignore
-    public void getSummary_providerModel_Enabled() {
-        final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
-        final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
-        when(sub1.getSubscriptionId()).thenReturn(1);
-        when(sub2.getSubscriptionId()).thenReturn(2);
-        when(sub1.getDisplayName()).thenReturn("sub1");
-        when(sub2.getDisplayName()).thenReturn("sub2");
-
-        SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
-        SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
-        mController.displayPreference(mPreferenceScreen);
-        mController.onResume();
-        assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
-    }
-
-    @Test
     public void addButton_noSubscriptionsNoEuiccMgr_noAddClickListener() {
         when(mEuiccManager.isEnabled()).thenReturn(false);
         mController.displayPreference(mPreferenceScreen);
@@ -319,7 +303,6 @@
     }
 
     @Test
-    @Ignore
     public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOn_isDisabled() {
         final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
         SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
index ed4c127..0f9d54b 100644
--- a/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
+++ b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
@@ -20,6 +20,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.LocaleManager;
@@ -32,7 +33,7 @@
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
-import com.google.common.collect.Iterables;
+import com.android.settingslib.widget.RadioButtonPreference;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -40,8 +41,14 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Locale;
 
+/**
+ * Unittest for ApplocaleDetails
+ * TODO Need to add a unittest for the UI preference component.
+ */
 @RunWith(AndroidJUnit4.class)
 public class AppLocaleDetailsTest {
     private static final String APP_PACKAGE_NAME = "app_package_name";
@@ -52,7 +59,7 @@
     private LocaleManager mLocaleManager;
 
     private Context mContext;
-    private LocaleList mSystemLocales;
+    private Collection<Locale> mSystemLocales;
     private LocaleList mAppLocale;
     private String[] mAssetLocales;
     private LocaleList mPackageLocales;
@@ -69,12 +76,48 @@
         when(mContext.getSystemService(LocaleManager.class)).thenReturn(mLocaleManager);
 
         setupInitialLocales(
-                /* appLocale= */ "en",
+                /* appLocale= */ "en-gb",
                 /* simCountry= */ "tw",
                 /* networkCountry= */ "jp",
-                /* systemLocales= */ "en, uk, jp, ne",
-                /* packageLocales= */ "pa, cn, tw, en",
-                /* assetLocales= */ new String[]{"en", "ne", "ms", "pa"});
+                /* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
+                /* packageLocales= */ "pa, cn, zh-tw, en-gb, ja-jp",
+                /* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "zh-tw", "ja-jp"});
+    }
+
+    @Test
+    @UiThreadTest
+    public void onRadioButtonClicked_setCurrentLocaleToSystem() {
+        AppLocaleDetails appLocaleDetails = new AppLocaleDetails() {
+            @Override
+            void refreshUiInternal() {}
+        };
+        DummyAppLocaleDetailsHelper helper =
+                spy(new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME));
+        appLocaleDetails.mAppLocaleDetailsHelper = helper;
+        RadioButtonPreference pref = new RadioButtonPreference(mContext);
+        pref.setKey(AppLocaleDetails.KEY_SYSTEM_DEFAULT_LOCALE);
+
+        appLocaleDetails.onRadioButtonClicked(pref);
+
+        verify(helper).setAppDefaultLocale(LocaleList.forLanguageTags(""));
+    }
+
+    @Test
+    @UiThreadTest
+    public void onRadioButtonClicked_setCurrentLocaleForUserSelected() {
+        AppLocaleDetails appLocaleDetails = new AppLocaleDetails() {
+            @Override
+            void refreshUiInternal() {}
+        };
+        DummyAppLocaleDetailsHelper helper =
+                spy(new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME));
+        appLocaleDetails.mAppLocaleDetailsHelper = helper;
+        RadioButtonPreference pref = new RadioButtonPreference(mContext);
+        pref.setKey("en");
+
+        appLocaleDetails.onRadioButtonClicked(pref);
+
+        verify(helper).setAppDefaultLocale("en");
     }
 
     @Test
@@ -90,7 +133,7 @@
 
     @Test
     @UiThreadTest
-    public void handleAllLocalesData_1stLocaleOfSuggestedLocaleListIsAppLocale() {
+    public void handleAllLocalesData_1stLocaleIsAppLocaleAndHasSimAndNetwork() {
         Locale simCountryLocale = new Locale("zh", "TW");
         Locale networkCountryLocale = new Locale("ja", "JP");
         DummyAppLocaleDetailsHelper helper =
@@ -98,36 +141,122 @@
 
         helper.handleAllLocalesData();
 
-        Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        Locale locale = suggestedLocales.iterator().next();
         assertTrue(locale.equals(mAppLocale.get(0)));
-        assertTrue(helper.getSuggestedLocales().contains(simCountryLocale));
-        assertTrue(helper.getSuggestedLocales().contains(networkCountryLocale));
+        assertTrue(suggestedLocales.contains(simCountryLocale));
+        assertTrue(suggestedLocales.contains(networkCountryLocale));
     }
 
     @Test
     @UiThreadTest
-    public void handleAllLocalesData_withoutAppLocale_1stSuggestedLocaleIsSimCountryLocale() {
-        Locale simCountryLocale = new Locale("zh", "TW");
+    public void
+            handleAllLocalesData_noAppAndNoSupportedSimLocale_1stSuggestedLocaleIsAssetLocale() {
+        Locale firstAssetLocale = new Locale("en", "GB");
         setupInitialLocales(
                 /* appLocale= */ "",
                 /* simCountry= */ "tw",
                 /* networkCountry= */ "",
-                /* systemLocales= */ "en, uk, jp, ne",
+                /* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
                 /* packageLocales= */ "",
-                /* assetLocales= */ new String[]{});
+                /* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "ja-jp"});
         DummyAppLocaleDetailsHelper helper =
                 new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
 
         helper.handleAllLocalesData();
 
-        Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
-        assertTrue(locale.equals(simCountryLocale));
-        assertFalse(helper.getSuggestedLocales().contains(mAppLocale.get(0)));
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        Locale locale = suggestedLocales.iterator().next();
+        assertTrue(locale.equals(firstAssetLocale));
     }
 
     @Test
     @UiThreadTest
-    public void handleAllLocalesData_withoutAppLocale_1stSuggestedLocaleIsNetworkCountryLocale() {
+    public void handleAllLocalesData_noAppButHasSupportedSimLocale_1stSuggestedLocaleIsSim() {
+        Locale simLocale = new Locale("zh", "tw");
+        setupInitialLocales(
+                /* appLocale= */ "",
+                /* simCountry= */ "tw",
+                /* networkCountry= */ "",
+                /* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
+                /* packageLocales= */ "",
+                /* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "ja-jp", "zh-tw"});
+        DummyAppLocaleDetailsHelper helper =
+                new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+        helper.handleAllLocalesData();
+
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        Locale locale = suggestedLocales.iterator().next();
+        assertTrue(locale.equals(simLocale));
+    }
+
+    @Test
+    @UiThreadTest
+    public void
+            handleAllLocalesData_noAppButHasSupportedNetworkLocale_1stSuggestedLocaleIsNetwork() {
+        Locale networkLocale = new Locale("ja", "JP");
+        setupInitialLocales(
+                /* appLocale= */ "",
+                /* simCountry= */ "",
+                /* networkCountry= */ "jp",
+                /* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
+                /* packageLocales= */ "",
+                /* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "ja-jp"});
+        DummyAppLocaleDetailsHelper helper =
+                new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+        helper.handleAllLocalesData();
+
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        Locale locale = suggestedLocales.iterator().next();
+        assertTrue(locale.equals(networkLocale));
+    }
+
+    @Test
+    @UiThreadTest
+    public void handleAllLocalesData_noAppSimOrNetworkLocale_suggestedLocalesHasSystemLocale() {
+        setupInitialLocales(
+                /* appLocale= */ "",
+                /* simCountry= */ "",
+                /* networkCountry= */ "",
+                /* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
+                /* packageLocales= */ "",
+                /* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "zh-tw", "ja-jp"});
+        DummyAppLocaleDetailsHelper helper =
+                new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+        helper.handleAllLocalesData();
+
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        assertTrue(suggestedLocales.contains(Locale.forLanguageTag("ne")));
+        // ru language is not present in the asset locales
+        assertFalse(suggestedLocales.contains(Locale.forLanguageTag("ru")));
+    }
+
+    @Test
+    @UiThreadTest
+    public void handleAllLocalesData_noAppButHasSimAndNetworkLocale_1stLocaleIsSimLocale() {
+        Locale simCountryLocale = new Locale("zh", "TW");
+        setupInitialLocales(
+                /* appLocale= */ "",
+                /* simCountry= */ "tw",
+                /* networkCountry= */ "jp",
+                /* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
+                /* packageLocales= */ "",
+                /* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "zh-tw", "ja-jp"});
+
+        DummyAppLocaleDetailsHelper helper =
+                new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+        helper.handleAllLocalesData();
+
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        Locale locale = suggestedLocales.iterator().next();
+        assertTrue(locale.equals(simCountryLocale));
+    }
+
+    @Test
+    @UiThreadTest
+    public void handleAllLocalesData_noSupportedLocale_noSuggestedLocales() {
         Locale networkCountryLocale = new Locale("en", "GB");
         setupInitialLocales(
                 /* appLocale= */ "",
@@ -141,28 +270,8 @@
 
         helper.handleAllLocalesData();
 
-        Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
-        assertTrue(locale.equals(networkCountryLocale));
-        assertFalse(helper.getSuggestedLocales().contains(mAppLocale.get(0)));
-    }
-
-    @Test
-    @UiThreadTest
-    public void handleAllLocalesData_noAppAndSimNetworkLocale_1stLocaleIsFirstOneInSystemLocales() {
-        setupInitialLocales(
-                /* appLocale= */ "",
-                /* simCountry= */ "",
-                /* networkCountry= */ "",
-                /* systemLocales= */ "en, uk, jp, ne",
-                /* packageLocales= */ "",
-                /* assetLocales= */ new String[]{});
-        DummyAppLocaleDetailsHelper helper =
-                new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
-
-        helper.handleAllLocalesData();
-
-        Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
-        assertTrue(locale.equals(mSystemLocales.get(0)));
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        assertTrue(suggestedLocales.size() == 0);
     }
 
     @Test
@@ -180,8 +289,10 @@
 
         helper.handleAllLocalesData();
 
-        Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
-        assertTrue(locale.equals(mSystemLocales.get(0)));
+        Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
+        Locale locale = suggestedLocales.iterator().next();
+        Locale systemLocale = mSystemLocales.iterator().next();
+        assertTrue(locale.equals(systemLocale));
     }
 
     @Test
@@ -248,15 +359,23 @@
             String packageLocales,
             String[] assetLocales) {
         mAppLocale = LocaleList.forLanguageTags(appLocale);
-        mSystemLocales = LocaleList.forLanguageTags(systemLocales);
+        // forLanguageTags does not filter space to the input string. If there is any space included
+        // in string, this will make locale fail to generate.
+        systemLocales = systemLocales.replaceAll("\\s+", "");
+        LocaleList listOfSystemLocales = LocaleList.forLanguageTags(systemLocales);
+        mSystemLocales = new ArrayList<>();
+        for (int i = 0; i < listOfSystemLocales.size(); i++) {
+            mSystemLocales.add(listOfSystemLocales.get(i));
+        }
         mAssetLocales = assetLocales;
+        packageLocales = packageLocales.replaceAll("\\s+", "");
         mPackageLocales = LocaleList.forLanguageTags(packageLocales);
         when(mTelephonyManager.getSimCountryIso()).thenReturn(simCountry);
         when(mTelephonyManager.getNetworkCountryIso()).thenReturn(networkCountry);
         when(mLocaleManager.getApplicationLocales(anyString())).thenReturn(mAppLocale);
     }
 
-    private class DummyAppLocaleDetailsHelper
+    public class DummyAppLocaleDetailsHelper
             extends AppLocaleDetails.AppLocaleDetailsHelper {
 
         DummyAppLocaleDetailsHelper(Context context, String packageName) {
@@ -264,12 +383,12 @@
         }
 
         @Override
-        String[] getAssetSystemLocales() {
+        String[] getAssetLocales() {
             return mAssetLocales;
         }
 
         @Override
-        LocaleList getCurrentSystemLocales() {
+        Collection<Locale> getCurrentSystemLocales() {
             return mSystemLocales;
         }