Merge "Fix broken test" into sc-dev
diff --git a/Android.bp b/Android.bp
index 2dfe3fd..2d4c42c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -110,3 +110,21 @@
     name: "contextualcards",
     aars: ["libs/contextualcards.aar"],
 }
+
+filegroup {
+    name: "Settings_proguard_flags",
+    srcs: ["proguard.flags"],
+}
+
+// The sources for Settings need to be exposed to SettingsGoogle, etc.
+// so they can run the com.android.settingslib.search.IndexableProcessor
+// over all the sources together.
+filegroup {
+    name: "Settings_srcs",
+    srcs: ["src/**/*.java"],
+}
+
+filegroup {
+    name: "Settings_manifest",
+    srcs: ["AndroidManifest.xml"],
+}
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/display_settings.xml b/res/xml/display_settings.xml
index 8df5696..27bf0ba 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -20,7 +20,7 @@
     android:key="display_settings_screen"
     android:title="@string/display_settings"
     settings:keywords="@string/keywords_display"
-    settings:initialExpandedChildrenCount="5">
+    settings:initialExpandedChildrenCount="6">
 
     <com.android.settingslib.RestrictedPreference
         android:key="brightness"
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/res/xml/transcode_settings.xml b/res/xml/transcode_settings.xml
index b142d31..c5a9763 100644
--- a/res/xml/transcode_settings.xml
+++ b/res/xml/transcode_settings.xml
@@ -35,4 +35,9 @@
         android:key="transcode_default"
         android:title="@string/transcode_default"
         settings:controller="com.android.settings.development.transcode.TranscodeDefaultOptionPreferenceController" />
+
+    <SwitchPreference
+        android:key="transcode_notification"
+        android:title="@string/transcode_notification"
+        settings:controller="com.android.settings.development.transcode.TranscodeNotificationPreferenceController" />
 </PreferenceScreen>
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/development/ForcePeakRefreshRatePreferenceController.java b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
index 78352d3..d5d4025 100644
--- a/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
+++ b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
@@ -122,7 +122,7 @@
     private float findPeakRefreshRate(Display.Mode[] modes) {
         float peakRefreshRate = DEFAULT_REFRESH_RATE;
         for (Display.Mode mode : modes) {
-            if (Math.round(mode.getRefreshRate()) > DEFAULT_REFRESH_RATE) {
+            if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
                 peakRefreshRate = mode.getRefreshRate();
             }
         }
diff --git a/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceController.java b/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceController.java
new file mode 100644
index 0000000..e51f8ad
--- /dev/null
+++ b/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceController.java
@@ -0,0 +1,53 @@
+/*
+ * 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.development.transcode;
+
+import android.content.Context;
+import android.os.SystemProperties;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * The controller (in the Media transcoding settings) indicating the user's preference to show
+ * or hide the transcoding notifications.
+ */
+public class TranscodeNotificationPreferenceController extends TogglePreferenceController {
+    @VisibleForTesting
+    static final String TRANSCODE_NOTIFICATION_SYS_PROP_KEY =
+            "persist.sys.fuse.transcode_notification";
+
+    public TranscodeNotificationPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public boolean isChecked() {
+        return SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, true);
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, String.valueOf(isChecked));
+        return true;
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
index 10cab1c..36e085a 100644
--- a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
+++ b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
@@ -129,10 +129,11 @@
         mDeviceConfigDisplaySettings.stopListening();
     }
 
-    private float findPeakRefreshRate(Display.Mode[] modes) {
+    @VisibleForTesting
+    float findPeakRefreshRate(Display.Mode[] modes) {
         float peakRefreshRate = DEFAULT_REFRESH_RATE;
         for (Display.Mode mode : modes) {
-            if (Math.round(mode.getRefreshRate()) > DEFAULT_REFRESH_RATE) {
+            if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
                 peakRefreshRate = mode.getRefreshRate();
             }
         }
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 257810c..122e13a 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -88,8 +88,8 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (MainSwitchPreference) screen.findPreference(getPreferenceKey());
-        mPreference.setTitle(mContext.getString(R.string.battery_saver_main_switch_title));
+        mPreference = screen.findPreference(getPreferenceKey());
+        mPreference.setTitle(mContext.getString(R.string.battery_saver_master_switch_title));
         mPreference.addOnSwitchChangeListener(this);
         mPreference.updateStatus(isChecked());
     }
diff --git a/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java b/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java
index e072b5c..e1e56a8 100644
--- a/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java
+++ b/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceController.java
@@ -17,6 +17,7 @@
 package com.android.settings.network;
 
 import android.content.Context;
+import android.net.wifi.WifiManager;
 import android.provider.Settings;
 
 import androidx.preference.PreferenceScreen;
@@ -28,8 +29,11 @@
  */
 public class AdaptiveConnectivityTogglePreferenceController extends TogglePreferenceController {
 
+    private final WifiManager mWifiManager;
+
     public AdaptiveConnectivityTogglePreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
+        mWifiManager = context.getSystemService(WifiManager.class);
     }
 
     @Override
@@ -53,6 +57,7 @@
         Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED,
                 isChecked ? 1 : 0);
+        mWifiManager.setWifiScoringEnabled(isChecked);
         return true;
     }
 }
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/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 9e7a3a8..5680bf6 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -35,6 +35,7 @@
 
 import com.android.settings.R;
 import com.android.settings.network.AllowedNetworkTypesListener;
+import com.android.settings.network.SubscriptionsChangeListener;
 import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
 
 import java.util.ArrayList;
@@ -47,7 +48,8 @@
  */
 public class EnabledNetworkModePreferenceController extends
         TelephonyBasePreferenceController implements
-        ListPreference.OnPreferenceChangeListener, LifecycleObserver {
+        ListPreference.OnPreferenceChangeListener, LifecycleObserver,
+        SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
 
     private static final String LOG_TAG = "EnabledNetworkMode";
     private AllowedNetworkTypesListener mAllowedNetworkTypesListener;
@@ -56,9 +58,11 @@
     private TelephonyManager mTelephonyManager;
     private CarrierConfigManager mCarrierConfigManager;
     private PreferenceEntriesBuilder mBuilder;
+    private SubscriptionsChangeListener mSubscriptionsListener;
 
     public EnabledNetworkModePreferenceController(Context context, String key) {
         super(context, key);
+        mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
     }
 
     @Override
@@ -85,6 +89,7 @@
 
     @OnLifecycleEvent(ON_START)
     public void onStart() {
+        mSubscriptionsListener.start();
         if (mAllowedNetworkTypesListener == null) {
             return;
         }
@@ -93,6 +98,7 @@
 
     @OnLifecycleEvent(ON_STOP)
     public void onStop() {
+        mSubscriptionsListener.stop();
         if (mAllowedNetworkTypesListener == null) {
             return;
         }
@@ -196,11 +202,14 @@
         PreferenceEntriesBuilder(Context context, int subId) {
             this.mContext = context;
             this.mSubId = subId;
-
             mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
             mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
                     .createForSubscriptionId(mSubId);
+            updateConfig();
+        }
 
+        public void updateConfig() {
+            mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
             final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
             mAllowed5gNetworkType = checkSupportedRadioBitmask(
                     mTelephonyManager.getAllowedNetworkTypesForReason(
@@ -214,6 +223,11 @@
                     && carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL);
             mShow4gForLTE = carrierConfig != null && carrierConfig.getBoolean(
                     CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
+            Log.d(LOG_TAG, "PreferenceEntriesBuilder: subId" + mSubId
+                    + ",Supported5gRadioAccessFamily :" + mSupported5gRadioAccessFamily
+                    + ",mAllowed5gNetworkType :" + mAllowed5gNetworkType
+                    + ",IsGlobalCdma :" + mIsGlobalCdma
+                    + ",Show4gForLTE :" + mShow4gForLTE);
         }
 
         void setPreferenceEntries() {
@@ -818,4 +832,13 @@
         }
 
     }
+
+    @Override
+    public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
+    }
+
+    @Override
+    public void onSubscriptionsChanged() {
+        mBuilder.updateConfig();
+    }
 }
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index a0e9820..337bad7 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -97,3 +97,15 @@
         "SettingsLib-search",
     ],
 }
+
+java_library {
+    name: "Settings-robo-testutils",
+    srcs: ["src/com/android/settings/testutils/**/*.java"],
+
+    libs: [
+        "Settings-core",
+        "Robolectric_all-target",
+        "mockito-robolectric-prebuilt",
+        "truth-prebuilt",
+    ],
+}
diff --git a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
index cae7d89..aaeeea4 100644
--- a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
@@ -24,6 +24,7 @@
 
 import android.content.Context;
 import android.provider.Settings;
+import android.view.Display;
 
 import androidx.preference.SwitchPreference;
 
@@ -102,6 +103,21 @@
         assertThat(mController.isChecked()).isFalse();
     }
 
+    @Test
+    public void findPeakRefreshRate_moreThanOneHigherThanDefault() {
+        Display.Mode lower = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE - 1);
+        Display.Mode def = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE);
+        Display.Mode higher = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 1);
+        Display.Mode higher1 = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 2);
+
+        assertThat(mController.findPeakRefreshRate(
+                new Display.Mode[] {lower, def, higher, higher1}))
+                .isEqualTo(DEFAULT_REFRESH_RATE + 2);
+        assertThat(mController.findPeakRefreshRate(
+                new Display.Mode[] {lower, def, higher1, higher}))
+                .isEqualTo(DEFAULT_REFRESH_RATE + 2);
+    }
+
     private void enableSmoothDisplayPreference() {
         mController.mPeakRefreshRate = 88f;
 
diff --git a/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java
index dfb9a8f..c95797f 100644
--- a/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/AdaptiveConnectivityTogglePreferenceControllerTest.java
@@ -19,8 +19,13 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.net.wifi.WifiManager;
 import android.provider.Settings;
 
 import org.junit.Before;
@@ -29,6 +34,7 @@
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
 
 @RunWith(RobolectricTestRunner.class)
 public class AdaptiveConnectivityTogglePreferenceControllerTest {
@@ -37,12 +43,16 @@
 
     @Mock(answer = RETURNS_DEEP_STUBS)
     private Context mContext;
+    @Mock
+    WifiManager mWifiManager;
 
     private AdaptiveConnectivityTogglePreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
         mController = new AdaptiveConnectivityTogglePreferenceController(mContext, PREF_KEY);
     }
 
@@ -61,6 +71,7 @@
         assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
                 Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1))
                 .isEqualTo(1);
+        verify(mWifiManager, atLeastOnce()).setWifiScoringEnabled(true);
     }
 
     @Test
@@ -73,5 +84,6 @@
         assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
                 Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1))
                 .isEqualTo(0);
+        verify(mWifiManager).setWifiScoringEnabled(false);
     }
 }
diff --git a/tests/unit/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceControllerTest.java b/tests/unit/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceControllerTest.java
new file mode 100644
index 0000000..0903c72
--- /dev/null
+++ b/tests/unit/src/com/android/settings/development/transcode/TranscodeNotificationPreferenceControllerTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.development.transcode;
+
+import static com.android.settings.development.transcode.TranscodeNotificationPreferenceController.TRANSCODE_NOTIFICATION_SYS_PROP_KEY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.SystemProperties;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class TranscodeNotificationPreferenceControllerTest {
+    private TranscodeNotificationPreferenceController mUnderTest;
+
+    @Before
+    public void setUp() {
+        Context context = ApplicationProvider.getApplicationContext();
+        mUnderTest = new TranscodeNotificationPreferenceController(context, "notification_key");
+    }
+
+    @Test
+    public void isChecked_whenSysPropSet_shouldReturnTrue() {
+        SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, "true");
+        assertThat(mUnderTest.isChecked()).isTrue();
+    }
+
+    @Test
+    public void isChecked_whenSysPropUnset_shouldReturnFalse() {
+        SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, "false");
+        assertThat(mUnderTest.isChecked()).isFalse();
+    }
+
+    @Test
+    public void setChecked_withTrue_shouldSetSysProp() {
+        mUnderTest.setChecked(true);
+        assertThat(
+                SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, false)).isTrue();
+    }
+
+    @Test
+    public void setChecked_withFalse_shouldUnsetSysProp() {
+        mUnderTest.setChecked(false);
+        assertThat(
+                SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, true)).isFalse();
+    }
+
+    @Test
+    public void getAvailabilityStatus_shouldReturn_isAvailable() {
+        assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
+                BasePreferenceController.AVAILABLE);
+    }
+}
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);
diff --git a/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java
index 9b9bb11..293a19d 100644
--- a/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/Enable2gPreferenceControllerTest.java
@@ -22,6 +22,8 @@
 
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -117,4 +119,27 @@
 
         assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
     }
+
+    @Test
+    public void onPreferenceChange_update() {
+        // Set "Enable 2G" flag to "on"
+        when(mTelephonyManager.getAllowedNetworkTypesForReason(
+                TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G)).thenReturn(
+                (long) (TelephonyManager.NETWORK_TYPE_BITMASK_GSM
+                        | TelephonyManager.NETWORK_TYPE_BITMASK_LTE));
+
+        // Setup state to allow disabling
+        doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
+                mTelephonyManager.CAPABILITY_ALLOWED_NETWORK_TYPES_USED);
+        mPersistableBundle.putBoolean(CarrierConfigManager.KEY_HIDE_ENABLE_2G,
+                false);
+
+        // Disable 2G
+        boolean changed = mController.setChecked(false);
+        assertThat(changed).isEqualTo(true);
+
+        verify(mTelephonyManager, times(1)).setAllowedNetworkTypesForReason(
+                TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G,
+                TelephonyManager.NETWORK_TYPE_BITMASK_LTE);
+    }
 }