Merge "Update battery saver switch string" into sc-dev
diff --git a/res/layout/udfps_enroll_enrolling.xml b/res/layout/udfps_enroll_enrolling.xml
index 03b6528..6b3382c 100644
--- a/res/layout/udfps_enroll_enrolling.xml
+++ b/res/layout/udfps_enroll_enrolling.xml
@@ -20,7 +20,47 @@
     android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:layout="@layout/sud_glif_blank_template"
     style="?attr/fingerprint_layout_theme">
 
+    <LinearLayout
+        style="@style/SudContentFrame"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:clipToPadding="false"
+        android:clipChildren="false"
+        android:orientation="vertical">
+
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+
+            <TextView
+                android:id="@+id/sud_layout_description"
+                style="@style/SudDescription.Glif"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:minLines="3"
+                android:text="@string/security_settings_fingerprint_enroll_start_message" />
+
+            <TextView
+                android:id="@+id/repeat_message"
+                style="@style/SudDescription.Glif"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/security_settings_fingerprint_enroll_repeat_message"
+                android:visibility="invisible" />
+
+        </FrameLayout>
+
+        <TextView
+            android:id="@+id/error_text"
+            style="@style/TextAppearance.ErrorText"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal|bottom"
+            android:accessibilityLiveRegion="polite"
+            android:gravity="center_horizontal"
+            android:visibility="invisible" />
+    </LinearLayout>
+
 </com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/udfps_enroll_layout.xml b/res/layout/udfps_enroll_layout.xml
deleted file mode 100644
index 8338589..0000000
--- a/res/layout/udfps_enroll_layout.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
-  ~ Copyright (C) 2015 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.android.settings.biometrics.fingerprint.UdfpsEnrollLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/setup_wizard_layout"
-    style="?attr/fingerprint_layout_theme"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-    <ImageView
-        android:id="@+id/sud_layout_icon"
-        style="@style/SudGlifIcon"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="?attr/sudGlifHeaderGravity"
-        android:layout_marginEnd="0dp"
-        android:layout_marginStart="0dp"
-        android:src="@drawable/ic_fingerprint_header" />
-
-    <TextView
-        android:id="@+id/suc_layout_title"
-        style="@style/SudGlifHeaderTitle"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginEnd="0dp"
-        android:layout_marginStart="0dp" />
-
-    <FrameLayout
-        android:id="@+id/description_area"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-
-        <TextView
-            android:id="@+id/sud_layout_description"
-            style="@style/SudDescription.Glif"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/security_settings_fingerprint_enroll_start_message" />
-
-        <TextView
-            android:id="@+id/repeat_message"
-            style="@style/SudDescription.Glif"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/security_settings_fingerprint_enroll_repeat_message"
-            android:visibility="invisible" />
-
-    </FrameLayout>
-
-    <TextView
-        android:id="@+id/error_text"
-        style="@style/TextAppearance.ErrorText"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_horizontal|bottom"
-        android:layout_marginBottom="16dp"
-        android:accessibilityLiveRegion="polite"
-        android:gravity="center_horizontal"
-        android:paddingEnd="5dp"
-        android:paddingStart="5dp"
-        android:visibility="invisible" />
-</com.android.settings.biometrics.fingerprint.UdfpsEnrollLayout>
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
index b5dcebf..1b7b026 100644
--- a/res/xml/security_dashboard_settings.xml
+++ b/res/xml/security_dashboard_settings.xml
@@ -78,7 +78,6 @@
 
         <SwitchPreference
             android:key="visiblepattern_profile"
-            android:summary="@string/summary_placeholder"
             android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile"
             settings:controller="com.android.settings.security.VisiblePatternProfilePreferenceController" />
 
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 78abb58..1b2a6a5 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -144,12 +144,7 @@
         mCanAssumeUdfps = props.size() == 1 && props.get(0).isAnyUdfpsType();
 
         if (mCanAssumeUdfps) {
-            // Use a custom layout since animations, etc must be based off of the sensor's physical
-            // location.
             setContentView(R.layout.udfps_enroll_enrolling);
-            final UdfpsEnrollLayout udfpsEnrollLayout = (UdfpsEnrollLayout) getLayoutInflater()
-                    .inflate(R.layout.udfps_enroll_layout, null /* root */);
-            getLayout().addView(udfpsEnrollLayout);
         } else {
             setContentView(R.layout.fingerprint_enroll_enrolling);
         }
diff --git a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
index 8097adc..394b673 100644
--- a/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollFindSensor.java
@@ -37,11 +37,6 @@
 public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {
 
     @Override
-    protected int getContentView() {
-        return R.layout.fingerprint_enroll_find_sensor;
-    }
-
-    @Override
     protected Intent getFingerprintEnrollingIntent() {
         Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
diff --git a/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollLayout.java b/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollLayout.java
deleted file mode 100644
index 7923d27..0000000
--- a/src/com/android/settings/biometrics/fingerprint/UdfpsEnrollLayout.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2020 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.biometrics.fingerprint;
-
-import android.content.Context;
-import android.hardware.fingerprint.FingerprintManager;
-import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.WindowInsets;
-import android.view.WindowManager;
-import android.widget.LinearLayout;
-
-import com.android.settings.R;
-
-public class UdfpsEnrollLayout extends LinearLayout {
-
-    private static final String TAG = "UdfpsEnrollLayout";
-
-    public UdfpsEnrollLayout(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    @Override
-    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-    }
-}
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index d028c58..392ccc6 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -35,6 +35,7 @@
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyDisplayInfo;
 import android.telephony.TelephonyManager;
+import android.text.Html;
 import android.util.ArraySet;
 
 import androidx.annotation.VisibleForTesting;
@@ -255,14 +256,17 @@
         mUpdateListener.onChildrenUpdated();
     }
 
-    private String getMobilePreferenceSummary(int subId) {
+    private CharSequence getMobilePreferenceSummary(int subId) {
         String result = mSubsPrefCtrlInjector.getNetworkType(
                 mContext, mConfig, mTelephonyDisplayInfo, subId);
+        if (!mTelephonyManager.isDataEnabled()) {
+            return mContext.getString(R.string.mobile_data_off_summary);
+        }
         if (!result.isEmpty() && mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext)) {
             result = mContext.getString(R.string.preference_summary_default_combination,
                     mContext.getString(R.string.mobile_data_connection_active), result);
         }
-        return result;
+        return Html.fromHtml(result, Html.FROM_HTML_MODE_LEGACY);
     }
 
     private Drawable getIcon(int subId) {
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index ef3f130..6b31342 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -16,7 +16,6 @@
 
 package com.android.settings.network;
 
-import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
 import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GOOD;
 import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GREAT;
 import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -24,6 +23,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;;
 import static org.mockito.Mockito.doReturn;
@@ -47,6 +47,7 @@
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyDisplayInfo;
 import android.telephony.TelephonyManager;
+import android.text.Html;
 
 import androidx.lifecycle.LifecycleOwner;
 import androidx.lifecycle.LifecycleRegistry;
@@ -371,14 +372,14 @@
         final Preference pref = new Preference(mContext);
         final Drawable greatDrawWithoutCutOff = mock(Drawable.class);
         doReturn(greatDrawWithoutCutOff).when(sInjector)
-                .getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true);
+                .getIcon(any(), anyInt(), anyInt(), anyBoolean());
 
         mController.setIcon(pref, 1, true /* isDefaultForData */);
         assertThat(pref.getIcon()).isEqualTo(greatDrawWithoutCutOff);
 
         final Drawable greatDrawWithCutOff = mock(Drawable.class);
         doReturn(greatDrawWithCutOff).when(sInjector)
-                .getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true);
+                .getIcon(any(), anyInt(), anyInt(), anyBoolean());
         mController.setIcon(pref, 2, false /* isDefaultForData */);
         assertThat(pref.getIcon()).isEqualTo(greatDrawWithCutOff);
     }
@@ -416,7 +417,8 @@
     @Test
     @UiThreadTest
     public void displayPreference_providerAndHasMultiSimAndActive_connectedAndRat() {
-        final String expectedSummary = "Connected / 5G";
+        final CharSequence expectedSummary =
+                Html.fromHtml("Connected / 5G", Html.FROM_HTML_MODE_LEGACY);
         final String networkType = "5G";
         final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
         doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
@@ -426,6 +428,7 @@
         doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
         doReturn(networkType)
                 .when(sInjector).getNetworkType(any(), any(), any(), anyInt());
+        when(mTelephonyManager.isDataEnabled()).thenReturn(true);
 
         mController.onResume();
         mController.displayPreference(mPreferenceScreen);
@@ -435,8 +438,11 @@
 
     @Test
     @UiThreadTest
-    public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() {
-        final String expectedSummary = "5G";
+    public void displayPreference_providerAndHasMultiSimButMobileDataOff_notAutoConnect() {
+        final String dataOffSummary =
+                ResourcesUtils.getResourcesString(mContext, "mobile_data_off_summary");
+        final CharSequence expectedSummary =
+                Html.fromHtml(dataOffSummary, Html.FROM_HTML_MODE_LEGACY);
         final String networkType = "5G";
         final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
         doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
@@ -449,6 +455,27 @@
         mController.onResume();
         mController.displayPreference(mPreferenceScreen);
 
+        assertThat(mPreferenceCategory.getPreference(0).getSummary())
+            .isEqualTo(expectedSummary.toString());
+    }
+
+    @Test
+    @UiThreadTest
+    public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() {
+        final CharSequence expectedSummary = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
+        final String networkType = "5G";
+        final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
+        doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
+        doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
+        setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
+                TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
+        doReturn(networkType)
+                .when(sInjector).getNetworkType(any(), any(), any(), anyInt());
+        when(mTelephonyManager.isDataEnabled()).thenReturn(true);
+
+        mController.onResume();
+        mController.displayPreference(mPreferenceScreen);
+
         assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
     }
 
@@ -467,7 +494,8 @@
     @Test
     @UiThreadTest
     public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndActive_connectedAndRat() {
-        final String expectedSummary = "Connected / LTE";
+        final CharSequence expectedSummary =
+                Html.fromHtml("Connected / LTE", Html.FROM_HTML_MODE_LEGACY);
         final String networkType = "LTE";
         final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
         final TelephonyDisplayInfo telephonyDisplayInfo =
@@ -480,6 +508,7 @@
         doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
         doReturn(networkType)
                 .when(sInjector).getNetworkType(any(), any(), any(), anyInt());
+        when(mTelephonyManager.isDataEnabled()).thenReturn(true);
 
         mController.onResume();
         mController.displayPreference(mPreferenceScreen);
@@ -491,7 +520,8 @@
     @Test
     @UiThreadTest
     public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() {
-        final String expectedSummary = "LTE";
+        final CharSequence expectedSummary =
+                Html.fromHtml("LTE", Html.FROM_HTML_MODE_LEGACY);
         final String networkType = "LTE";
         final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
         final TelephonyDisplayInfo telephonyDisplayInfo =
@@ -504,6 +534,7 @@
         doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
         doReturn(networkType)
                 .when(sInjector).getNetworkType(any(), any(), any(), anyInt());
+        when(mTelephonyManager.isDataEnabled()).thenReturn(true);
 
         mController.onResume();
         mController.displayPreference(mPreferenceScreen);