Merge "Create a provider for querying if embedding activity is enabled" into sc-v2-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2227a25..1d85a8d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1680,6 +1680,10 @@
         </activity-alias>
 
         <activity
+            android:name=".accessibility.AccessibilityScreenSizeForSetupWizardActivity"
+            android:exported="false"/>
+
+        <activity
             android:name="Settings$AccessibilityDaltonizerSettingsActivity"
             android:exported="true"
             android:label="@string/accessibility_display_daltonizer_preference_title">
diff --git a/libs/window_ext_lib.aar b/libs/window_ext_lib.aar
index 301ff96..c576270 100644
--- a/libs/window_ext_lib.aar
+++ b/libs/window_ext_lib.aar
Binary files differ
diff --git a/res/layout/accessibility_screen_size_setup_wizard.xml b/res/layout/accessibility_screen_size_setup_wizard.xml
new file mode 100644
index 0000000..e4bc55b
--- /dev/null
+++ b/res/layout/accessibility_screen_size_setup_wizard.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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_accessibility_visibility"
+    app:sucHeaderText="@string/title_font_size"
+    app:sudDescriptionText="@string/short_summary_font_size">
+
+    <FrameLayout
+        android:id="@+id/content_frame"
+        android:layout_marginTop="@dimen/preview_size_top_margin"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+</com.google.android.setupdesign.GlifLayout>
\ No newline at end of file
diff --git a/res/layout/preference_balance_slider.xml b/res/layout/preference_balance_slider.xml
index b84afbd..7f1e809 100644
--- a/res/layout/preference_balance_slider.xml
+++ b/res/layout/preference_balance_slider.xml
@@ -64,7 +64,7 @@
                 android:id="@*android:id/seekbar"
                 android:minHeight="?android:attr/listPreferredItemHeightSmall"
                 android:paddingStart="0dp"
-                android:paddingEnd="12dp"
+                android:paddingEnd="0dp"
                 android:layout_gravity="center_vertical"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"/>
diff --git a/res/layout/suw_font_size_fragment.xml b/res/layout/suw_font_size_fragment.xml
new file mode 100644
index 0000000..0e03a69
--- /dev/null
+++ b/res/layout/suw_font_size_fragment.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<androidx.core.widget.NestedScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:fillViewport="true">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <include layout="@layout/suw_preview_seek_bar_view_pager"/>
+
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+            android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+
+            <com.android.settings.widget.DotsPageIndicator
+                android:id="@+id/page_indicator"
+                style="@style/PreviewPagerPageIndicator"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:padding="3dp"/>
+
+            <TextView
+                android:id="@+id/current_label"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:padding="6dp"
+                android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
+                android:elevation="2dp"/>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical"
+                android:paddingTop="8dp">
+
+                <ImageView
+                    android:id="@+id/smaller"
+                    android:src="@drawable/ic_font_size_16dp"
+                    android:contentDescription="@string/font_size_make_smaller_desc"
+                    style="@style/screen_size_imageview_style"/>
+
+                <com.android.settings.widget.LabeledSeekBar
+                    android:id="@+id/seek_bar"
+                    android:layout_width="0dp"
+                    android:layout_height="48dp"
+                    android:layout_weight="1"
+                    style="@android:style/Widget.Material.SeekBar.Discrete"/>
+
+                <ImageView
+                    android:id="@+id/larger"
+                    android:src="@drawable/ic_font_size_24dp"
+                    android:contentDescription="@string/font_size_make_larger_desc"
+                    style="@style/screen_size_imageview_style"/>
+            </LinearLayout>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/font_size_summary"
+                android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"/>
+        </LinearLayout>
+    </LinearLayout>
+</androidx.core.widget.NestedScrollView>
diff --git a/res/layout/suw_preview_seek_bar_view_pager.xml b/res/layout/suw_preview_seek_bar_view_pager.xml
new file mode 100644
index 0000000..71ec5f0
--- /dev/null
+++ b/res/layout/suw_preview_seek_bar_view_pager.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="0dp"
+    android:layout_weight="1"
+    android:orientation="vertical"
+    android:paddingStart="@dimen/preview_pager_padding"
+    android:paddingEnd="@dimen/preview_pager_padding"
+    android:background="@drawable/preview_seek_bar_outline" >
+
+    <androidx.viewpager.widget.ViewPager
+        android:id="@+id/preview_pager"
+        android:layout_width="match_parent"
+        android:layout_height="200dp"
+        android:layout_weight="1"
+        android:background="?android:attr/colorBackground"
+        android:contentDescription="@string/preview_pager_content_description" />
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="36dp"
+        android:paddingStart="32dp"
+        android:gravity="start|center"
+        android:text="@string/screen_zoom_preview_title"
+        android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title"
+        android:importantForAccessibility="no" />
+</LinearLayout>
+
diff --git a/res/layout/suw_screen_zoom_fragment.xml b/res/layout/suw_screen_zoom_fragment.xml
new file mode 100644
index 0000000..0747381
--- /dev/null
+++ b/res/layout/suw_screen_zoom_fragment.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<androidx.core.widget.NestedScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:fillViewport="true">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <include layout="@layout/suw_preview_seek_bar_view_pager"/>
+
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+            android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+
+            <com.android.settings.widget.DotsPageIndicator
+                android:id="@+id/page_indicator"
+                style="@style/PreviewPagerPageIndicator"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:padding="3dp"/>
+
+            <TextView
+                android:id="@+id/current_label"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:padding="6dp"
+                android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
+                android:elevation="2dp"/>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_vertical">
+
+                <ImageView
+                    android:id="@+id/smaller"
+                    android:src="@drawable/ic_remove_24dp"
+                    android:contentDescription="@string/screen_zoom_make_smaller_desc"
+                    style="@style/screen_size_imageview_style"/>
+
+                <com.android.settings.widget.LabeledSeekBar
+                    android:id="@+id/seek_bar"
+                    android:layout_width="0dp"
+                    android:layout_height="48dp"
+                    android:layout_weight="1"
+                    style="@android:style/Widget.Material.SeekBar.Discrete"/>
+
+                <ImageView
+                    android:id="@+id/larger"
+                    android:src="@drawable/ic_add_24dp"
+                    android:contentDescription="@string/screen_zoom_make_larger_desc"
+                    style="@style/screen_size_imageview_style"/>
+            </LinearLayout>
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/screen_zoom_summary"
+                android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"/>
+        </LinearLayout>
+    </LinearLayout>
+</androidx.core.widget.NestedScrollView>
diff --git a/res/values-sw300dp-land-v31/dimens.xml b/res/values-sw300dp-land-v31/dimens.xml
new file mode 100644
index 0000000..fa7d2bf
--- /dev/null
+++ b/res/values-sw300dp-land-v31/dimens.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources>
+    <!-- Top margin for preview view pager -->
+    <dimen name="preview_size_top_margin">0dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2cd944a..e1d7584 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -434,6 +434,9 @@
     <!--  Choose SIM Activity dimens  -->
     <dimen name="subtitle_bottom_padding">24dp</dimen>
 
+    <!-- Top margin for preview view pager -->
+    <dimen name="preview_size_top_margin">-12dp</dimen>
+
     <!-- Battery usage chart view component -->
     <dimen name="chartview_text_padding">6dp</dimen>
     <dimen name="chartview_divider_width">1dp</dimen>
diff --git a/res/values/integers.xml b/res/values/integers.xml
index 3d73f64..5354388 100644
--- a/res/values/integers.xml
+++ b/res/values/integers.xml
@@ -21,4 +21,9 @@
     <integer name="job_anomaly_detection">102</integer>
     <integer name="device_index_update">103</integer>
     <integer name="sim_notification_send">104</integer>
+
+    <!-- Define the font/display size fragment id in the
+    accessibility_settings_for_setup_wizard.xml. -->
+    <integer name="suw_font_size_fragment_no">0</integer>
+    <integer name="suw_display_size_fragment_no">1</integer>
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8b0b7a2..5b3b1c8 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -237,6 +237,16 @@
         <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Small</item>
     </style>
 
+    <style name="screen_size_imageview_style">
+        <item name="android:layout_width">48dp</item>
+        <item name="android:layout_height">48dp</item>
+        <item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
+        <item name="android:tint">?android:attr/textColorPrimary</item>
+        <item name="android:tintMode">src_in</item>
+        <item name="android:scaleType">center</item>
+        <item name="android:focusable">true</item>
+    </style>
+
     <style name="TextAppearance" parent="android:TextAppearance.DeviceDefault"/>
 
     <style name="TextAppearance.info_label">
diff --git a/res/xml/accessibility_settings_for_setup_wizard.xml b/res/xml/accessibility_settings_for_setup_wizard.xml
index a3f56b5..d1b4f4a 100644
--- a/res/xml/accessibility_settings_for_setup_wizard.xml
+++ b/res/xml/accessibility_settings_for_setup_wizard.xml
@@ -21,18 +21,28 @@
     android:title="@string/vision_settings_title">
 
     <Preference
-        android:fragment="com.android.settings.display.FontSizePreferenceFragmentForSetupWizard"
         android:key="font_size_preference"
         android:icon="@drawable/ic_font_size"
         android:summary="@string/short_summary_font_size"
-        android:title="@string/title_font_size"/>
+        android:title="@string/title_font_size">
+        <intent
+            android:targetPackage="com.android.settings"
+            android:targetClass="com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity">
+            <extra android:name="vision_fragment_no" android:value="@integer/suw_font_size_fragment_no"/>
+        </intent>
+    </Preference>
 
     <com.android.settings.display.ScreenZoomPreference
-        android:fragment="com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard"
         android:key="force_density_preference"
         android:icon="@drawable/ic_screen_zoom"
         android:summary="@string/screen_zoom_short_summary"
-        android:title="@string/screen_zoom_title"/>
+        android:title="@string/screen_zoom_title">
+        <intent
+            android:targetPackage="com.android.settings"
+            android:targetClass="com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity">
+            <extra android:name="vision_fragment_no" android:value="@integer/suw_display_size_fragment_no"/>
+        </intent>
+    </com.android.settings.display.ScreenZoomPreference>
 
     <Preference
         android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index 818069b..35082fd 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -84,9 +84,7 @@
         <Preference
             android:key="safety_info"
             android:order="17"
-            android:title="@string/safety_and_regulatory_info">
-            <intent android:action="android.settings.SHOW_SAFETY_AND_REGULATORY_INFO"/>
-        </Preference>
+            android:title="@string/safety_and_regulatory_info"/>
     </PreferenceCategory>
 
     <PreferenceCategory
diff --git a/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivity.java
new file mode 100644
index 0000000..8a60e5f
--- /dev/null
+++ b/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivity.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2021 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.accessibility;
+
+import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceFragmentCompat;
+
+import com.android.settings.R;
+import com.android.settings.core.InstrumentedActivity;
+import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
+import com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard;
+
+import com.google.android.setupcompat.template.FooterBarMixin;
+import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupdesign.GlifLayout;
+import com.google.android.setupdesign.util.ThemeHelper;
+
+/** Settings font/display size activity for SUW. */
+public class AccessibilityScreenSizeForSetupWizardActivity extends InstrumentedActivity {
+    private static final String TAG = "ScreenSizeForSetup";
+
+    // A parameter decides which fragment ({@link FontSizePreferenceFragmentForSetupWizard} or
+    // {@link ScreenZoomPreferenceFragmentForSetupWizard}) will be visioned.
+    static final String VISION_FRAGMENT_NO = "vision_fragment_no";
+
+    private int mFragmentNo;
+    private int mFontSizeFragmentNo;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mFontSizeFragmentNo = getResources().getInteger(R.integer.suw_font_size_fragment_no);
+        final int appliedTheme = ThemeHelper.trySetDynamicColor(this)
+                ? R.style.SudDynamicColorThemeGlifV3_DayNight : R.style.SudThemeGlifV3_DayNight;
+        setTheme(appliedTheme);
+        setContentView(R.layout.accessibility_screen_size_setup_wizard);
+        mFragmentNo = getIntent().getExtras().getInt(VISION_FRAGMENT_NO);
+        Log.d(TAG, "onCreate: fragment no: " + mFragmentNo);
+        generateHeader(mFragmentNo);
+        scrollToBottom();
+        initFooterButton();
+        if (savedInstanceState == null) {
+            final PreferenceFragmentCompat fragment =
+                    (mFragmentNo == mFontSizeFragmentNo)
+                            ? new FontSizePreferenceFragmentForSetupWizard()
+                            : new ScreenZoomPreferenceFragmentForSetupWizard();
+            getSupportFragmentManager()
+                    .beginTransaction()
+                    .replace(R.id.content_frame, fragment)
+                    .commit();
+        }
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return mFragmentNo == mFontSizeFragmentNo ? SettingsEnums.SUW_ACCESSIBILITY_FONT_SIZE
+                : SettingsEnums.SUW_ACCESSIBILITY_DISPLAY_SIZE;
+    }
+
+    @VisibleForTesting
+    void generateHeader(int fragmentNo) {
+        ((TextView) findViewById(R.id.suc_layout_title)).setText(
+                fragmentNo == mFontSizeFragmentNo ? R.string.title_font_size
+                        : R.string.screen_zoom_title);
+        ((TextView) findViewById(R.id.sud_layout_subtitle)).setText(
+                fragmentNo == mFontSizeFragmentNo ? R.string.short_summary_font_size
+                        : R.string.screen_zoom_short_summary);
+    }
+
+    @VisibleForTesting
+    void initFooterButton() {
+        final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
+        final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
+        final View.OnClickListener nextButtonListener =
+                v -> {
+                    onBackPressed();
+                };
+        final FooterButton primaryButton =
+                new FooterButton.Builder(this)
+                        .setText(R.string.done)
+                        .setListener(nextButtonListener)
+                        .setButtonType(FooterButton.ButtonType.NEXT)
+                        .setTheme(R.style.SudGlifButton_Primary)
+                        .build();
+        mixin.setPrimaryButton(primaryButton);
+    }
+
+    /**
+     * Scrolls to bottom while {@link ScrollView} layout changed.
+     */
+    private void scrollToBottom() {
+        final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
+        final ScrollView scrollView = layout.getScrollView();
+        scrollView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
+            final int scrollViewHeight = scrollView.getHeight();
+            if (scrollViewHeight > 0) {
+                scrollView.post(() -> {
+                    // Here is no need to show the scrolling animation. So disabled first and
+                    // then enabled it after scrolling finished.
+                    scrollView.setSmoothScrollingEnabled(false);
+                    scrollView.fullScroll(View.FOCUS_DOWN);
+                    scrollView.setSmoothScrollingEnabled(true);
+                });
+            }
+        });
+    }
+}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index b65b349..0625fd2 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -16,7 +16,10 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
+
 import android.content.ComponentName;
+import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.Menu;
@@ -30,7 +33,6 @@
 import com.android.settings.SettingsActivity;
 import com.android.settings.SetupWizardUtils;
 import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
 import com.android.settings.search.actionbar.SearchMenuController;
 import com.android.settings.support.actionbar.HelpResourceProvider;
 import com.android.settingslib.core.instrumentation.Instrumentable;
@@ -123,19 +125,12 @@
                 && new ComponentName(getPackageName(),
                 CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW).equals(
                 getIntent().getComponent())) {
-            final Bundle args = new Bundle();
-            args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
-            args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
-            final SubSettingLauncher subSettingLauncher = new SubSettingLauncher(this)
-                    .setDestination(FontSizePreferenceFragmentForSetupWizard.class.getName())
-                    .setArguments(args)
-                    .setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN)
-                    .setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(),
-                            new Bundle()))
-                    .setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_FADE);
-
+            final Intent intent = new Intent(this,
+                    AccessibilityScreenSizeForSetupWizardActivity.class);
+            intent.putExtra(VISION_FRAGMENT_NO,
+                    getResources().getInteger(R.integer.suw_font_size_fragment_no));
+            startActivity(intent);
             Log.d(LOG_TAG, "Launch font size settings");
-            subSettingLauncher.launch();
             finish();
         }
     }
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 4581f6c..27b20cf 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -421,6 +421,11 @@
         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/deviceinfo/SafetyInfoPreferenceController.java b/src/com/android/settings/deviceinfo/SafetyInfoPreferenceController.java
index 10dbd19..92e4576 100644
--- a/src/com/android/settings/deviceinfo/SafetyInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/SafetyInfoPreferenceController.java
@@ -18,6 +18,9 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.text.TextUtils;
+
+import androidx.preference.Preference;
 
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -44,4 +47,16 @@
     public String getPreferenceKey() {
         return "safety_info";
     }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+            return false;
+        }
+
+        final Intent intent = new Intent(INTENT_PROBE);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(intent);
+        return true;
+    }
 }
diff --git a/src/com/android/settings/display/FontSizePreferenceFragmentForSetupWizard.java b/src/com/android/settings/display/FontSizePreferenceFragmentForSetupWizard.java
index 04b6dc3..627f107 100644
--- a/src/com/android/settings/display/FontSizePreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/display/FontSizePreferenceFragmentForSetupWizard.java
@@ -18,10 +18,17 @@
 
 import android.app.settings.SettingsEnums;
 
+import com.android.settings.R;
+
 public class FontSizePreferenceFragmentForSetupWizard
         extends ToggleFontSizePreferenceFragment {
 
     @Override
+    protected int getActivityLayoutResId() {
+        return R.layout.suw_font_size_fragment;
+    }
+
+    @Override
     public int getMetricsCategory() {
         return SettingsEnums.SUW_ACCESSIBILITY_FONT_SIZE;
     }
diff --git a/src/com/android/settings/display/PreviewPagerAdapter.java b/src/com/android/settings/display/PreviewPagerAdapter.java
index 018be32..a424b1d 100644
--- a/src/com/android/settings/display/PreviewPagerAdapter.java
+++ b/src/com/android/settings/display/PreviewPagerAdapter.java
@@ -109,6 +109,10 @@
         return (view == object);
     }
 
+    FrameLayout[] getPreviewFrames() {
+        return mPreviewFrames;
+    }
+
     boolean isAnimating() {
         return mAnimationCounter > 0;
     }
diff --git a/src/com/android/settings/display/PreviewSeekBarPreferenceFragment.java b/src/com/android/settings/display/PreviewSeekBarPreferenceFragment.java
index abd14d2..c6d5b8b 100644
--- a/src/com/android/settings/display/PreviewSeekBarPreferenceFragment.java
+++ b/src/com/android/settings/display/PreviewSeekBarPreferenceFragment.java
@@ -264,6 +264,12 @@
         @Override
         public void onPageSelected(int position) {
             mPreviewPager.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT);
+            // To avoid displaying previous page on the left side in SUW landscape mode for
+            // large size.
+            if (position > 0) {
+                mPreviewPagerAdapter.getPreviewFrames()[position - 1].setVisibility(View.INVISIBLE);
+            }
+            mPreviewPagerAdapter.getPreviewFrames()[position].setVisibility(View.VISIBLE);
         }
     };
 
diff --git a/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java b/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java
index cfa7b5d..7185c63 100644
--- a/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/display/ScreenZoomPreferenceFragmentForSetupWizard.java
@@ -18,9 +18,16 @@
 
 import android.app.settings.SettingsEnums;
 
+import com.android.settings.R;
+
 public class ScreenZoomPreferenceFragmentForSetupWizard extends ScreenZoomSettings {
 
     @Override
+    protected int getActivityLayoutResId() {
+        return R.layout.suw_screen_zoom_fragment;
+    }
+
+    @Override
     public int getMetricsCategory() {
         return SettingsEnums.SUW_ACCESSIBILITY_DISPLAY_SIZE;
     }
diff --git a/src/com/android/settings/fuelgauge/BatteryChartView.java b/src/com/android/settings/fuelgauge/BatteryChartView.java
index 7bc60b2..5336fd5 100644
--- a/src/com/android/settings/fuelgauge/BatteryChartView.java
+++ b/src/com/android/settings/fuelgauge/BatteryChartView.java
@@ -108,7 +108,7 @@
     Paint mTrapezoidCurvePaint = null;
     private TrapezoidSlot[] mTrapezoidSlots;
     // Records the location to calculate selected index.
-    private MotionEvent mTouchUpEvent;
+    private float mTouchUpEventX = Float.MIN_VALUE;
     private BatteryChartView.OnSelectListener mOnSelectListener;
 
     public BatteryChartView(Context context) {
@@ -255,20 +255,20 @@
         // Caches the location to calculate selected trapezoid index.
         final int action = event.getAction();
         if (action == MotionEvent.ACTION_UP) {
-            mTouchUpEvent = MotionEvent.obtain(event);
+            mTouchUpEventX = event.getX();
         } else if (action == MotionEvent.ACTION_CANCEL) {
-            mTouchUpEvent = null; // reset
+            mTouchUpEventX = Float.MIN_VALUE; // reset
         }
         return super.onTouchEvent(event);
     }
 
     @Override
     public void onClick(View view) {
-        if (mTouchUpEvent == null) {
+        if (mTouchUpEventX == Float.MIN_VALUE) {
             Log.w(TAG, "invalid motion event for onClick() callback");
             return;
         }
-        final int trapezoidIndex = getTrapezoidIndex(mTouchUpEvent.getX());
+        final int trapezoidIndex = getTrapezoidIndex(mTouchUpEventX);
         // Ignores the click event if the level is zero.
         if (trapezoidIndex == SELECTED_INDEX_INVALID
                 || !isValidToDraw(trapezoidIndex)) {
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 59a592c..1a7fa38 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -19,6 +19,8 @@
 import android.content.ContentResolver;
 import android.content.Context;
 import android.net.Uri;
+import android.os.Handler;
+import android.os.Looper;
 import android.os.PowerManager;
 import android.provider.SettingsSlicesContract;
 import android.widget.Switch;
@@ -42,10 +44,12 @@
 public class BatterySaverButtonPreferenceController extends
         TogglePreferenceController implements OnMainSwitchChangeListener, LifecycleObserver,
         OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
+    private static final long SWITCH_ANIMATION_DURATION = 350L;
 
     private final BatterySaverReceiver mBatterySaverReceiver;
     private final PowerManager mPowerManager;
 
+    private Handler mHandler;
     private MainSwitchPreference mPreference;
 
     public BatterySaverButtonPreferenceController(Context context, String key) {
@@ -53,6 +57,7 @@
         mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
         mBatterySaverReceiver = new BatterySaverReceiver(context);
         mBatterySaverReceiver.setBatterySaverListener(this);
+        mHandler = new Handler(Looper.getMainLooper());
     }
 
     @Override
@@ -83,6 +88,7 @@
     @Override
     public void onStop() {
         mBatterySaverReceiver.setListening(false);
+        mHandler.removeCallbacksAndMessages(null /* token */);
     }
 
     @Override
@@ -114,6 +120,11 @@
 
     @Override
     public void onPowerSaveModeChanged() {
+        mHandler.postDelayed(() -> onPowerSaveModeChangedInternal(),
+                SWITCH_ANIMATION_DURATION);
+    }
+
+    private void onPowerSaveModeChangedInternal() {
         final boolean isChecked = isChecked();
         if (mPreference != null && mPreference.isChecked() != isChecked) {
             mPreference.setChecked(isChecked);
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivityTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivityTest.java
new file mode 100644
index 0000000..05e5b32
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivityTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2021 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.accessibility;
+
+import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.content.Intent;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+
+import com.google.android.setupcompat.template.FooterBarMixin;
+import com.google.android.setupdesign.GlifLayout;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link AccessibilityScreenSizeForSetupWizardActivity} */
+@RunWith(RobolectricTestRunner.class)
+public class AccessibilityScreenSizeForSetupWizardActivityTest {
+    private static final int DISPLAY_SIZE_FRAGMENT_NO = 1;
+
+    private Context mContext = ApplicationProvider.getApplicationContext();
+    private AccessibilityScreenSizeForSetupWizardActivity mActivity;
+
+    @Before
+    public void setup() {
+        final Intent intent = new Intent();
+        intent.putExtra(VISION_FRAGMENT_NO,
+                mContext.getResources().getInteger(R.integer.suw_font_size_fragment_no));
+        mActivity = Robolectric.buildActivity(AccessibilityScreenSizeForSetupWizardActivity.class,
+                intent).create().get();
+    }
+
+    @Test
+    public void generateHeader_setPageNoAsFontSize_returnFontSizeTitle() {
+        mActivity.generateHeader(
+                mActivity.getResources().getInteger(R.integer.suw_font_size_fragment_no));
+
+        final GlifLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
+
+        assertThat(layout.getHeaderText()).isEqualTo(mContext.getText(R.string.title_font_size));
+    }
+
+    @Test
+    public void generateHeader_setPageNoAsDisplaySize_returnDisplaySizeTitle() {
+        mActivity.generateHeader(DISPLAY_SIZE_FRAGMENT_NO);
+
+        final GlifLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
+
+        assertThat(layout.getHeaderText()).isEqualTo(mContext.getText(R.string.screen_zoom_title));
+    }
+
+    @Test
+    public void initFooterButton_generateDoneButton() {
+        mActivity.initFooterButton();
+
+        final GlifLayout layout = mActivity.findViewById(R.id.setup_wizard_layout);
+        final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
+
+        assertThat(mixin.getPrimaryButton().getText()).isEqualTo(mContext.getText(R.string.done));
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
index c3a630b..4d9668a 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivityTest.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
 import static com.android.settings.accessibility.AccessibilitySettingsForSetupWizardActivity.CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW;
 
 import static com.google.common.truth.Truth.assertThat;
@@ -26,8 +27,6 @@
 import androidx.test.filters.SmallTest;
 
 import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
 
@@ -42,45 +41,47 @@
 @SmallTest
 public class AccessibilitySettingsForSetupWizardActivityTest {
 
-  @Test
-  public void createSetupAccessibilityActivity_shouldBeSUWTheme() {
-    final Intent intent = new Intent();
-    AccessibilitySettingsForSetupWizardActivity activity =
-        Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class, intent).get();
+    @Test
+    public void createSetupAccessibilityActivity_shouldBeSUWTheme() {
+        final Intent intent = new Intent();
+        AccessibilitySettingsForSetupWizardActivity activity =
+                Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
+                        intent).get();
 
-    assertThat(activity.getThemeResId()).isEqualTo(R.style.GlifV3Theme_Light);
-  }
+        assertThat(activity.getThemeResId()).isEqualTo(R.style.GlifV3Theme_Light);
+    }
 
-  @Test
-  public void onCreate_hasFontSizeComponent_shouldGoToFontSizePreferenceDirectly() {
-    AccessibilitySettingsForSetupWizardActivity activity =
-            Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
-                    new Intent(Intent.ACTION_MAIN).setComponent(new ComponentName(
-                            RuntimeEnvironment.application, CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW)).
-                            putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
-                            putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
+    @Test
+    public void onCreate_hasFontSizeComponent_shouldGoToFontSizePreferenceDirectly() {
+        AccessibilitySettingsForSetupWizardActivity activity =
+                Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
+                        new Intent(Intent.ACTION_MAIN).setComponent(new ComponentName(
+                                RuntimeEnvironment.application,
+                                CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW))
+                                .putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true)
+                                .putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
 
-    activity.tryLaunchFontSizeSettings();
+        activity.tryLaunchFontSizeSettings();
 
-    final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
-    assertThat(launchIntent).isNotNull();
-    assertThat(launchIntent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT)).isEqualTo(
-            FontSizePreferenceFragmentForSetupWizard.class.getName());
-    assertThat(activity.isFinishing()).isTrue();
-  }
+        final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
+        assertThat(launchIntent).isNotNull();
+        assertThat(launchIntent.getIntExtra(VISION_FRAGMENT_NO, -1)).isEqualTo(
+                activity.getResources().getInteger(R.integer.suw_font_size_fragment_no));
+        assertThat(activity.isFinishing()).isTrue();
+    }
 
-  @Test
-  public void onCreate_noFontSizeComponent_shouldNotFinishCurrentActivity() {
-    AccessibilitySettingsForSetupWizardActivity activity =
-            Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
-                    new Intent(Intent.ACTION_MAIN).
-                            putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true).
-                            putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
+    @Test
+    public void onCreate_noFontSizeComponent_shouldNotFinishCurrentActivity() {
+        AccessibilitySettingsForSetupWizardActivity activity =
+                Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
+                        new Intent(Intent.ACTION_MAIN)
+                                .putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true)
+                                .putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
 
-    activity.tryLaunchFontSizeSettings();
+        activity.tryLaunchFontSizeSettings();
 
-    final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
-    assertThat(launchIntent).isNull();
-    assertThat(activity.isFinishing()).isFalse();
-  }
+        final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
+        assertThat(launchIntent).isNull();
+        assertThat(activity.isFinishing()).isFalse();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
index 4948986..c2de510 100644
--- a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
@@ -152,7 +152,8 @@
                 System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
 
         when(mDisplay.getBrightnessInfo()).thenReturn(
-                new BrightnessInfo(0.1f, 0.0f, 1.0f, BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF));
+                new BrightnessInfo(0.1f, 0.0f, 1.0f, BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF,
+                    0.5f));
 
         mController.updateState(mPreference);
 
@@ -166,7 +167,8 @@
                 System.SCREEN_BRIGHTNESS_MODE_MANUAL);
 
         when(mDisplay.getBrightnessInfo()).thenReturn(
-                new BrightnessInfo(0.5f, 0.0f, 1.0f, BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF));
+                new BrightnessInfo(0.5f, 0.0f, 1.0f, BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF,
+                    0.5f));
 
         mController.updateState(mPreference);