Merge "Remove BatteryTipPolicyTest first to avoid blocking presubmit" into sc-dev
diff --git a/res/drawable/ic_password.xml b/res/drawable/ic_password.xml
index 7d5f471..1924f6e 100644
--- a/res/drawable/ic_password.xml
+++ b/res/drawable/ic_password.xml
@@ -20,15 +20,15 @@
     android:viewportHeight="24.0"
     android:viewportWidth="24.0">
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M21.5,9.39l-1.63,0l0.81,-1.42l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0z" />
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M13.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M6.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M21,17.89H3c-0.28,0 -0.5,-0.22 -0.5,-0.5v-1c0,-0.28 0.22,-0.5 0.5,-0.5h18c0.28,0 0.5,0.22 0.5,0.5v1C21.5,17.66 21.28,17.89 21,17.89z" />
 </vector>
diff --git a/res/drawable/ic_pattern.xml b/res/drawable/ic_pattern.xml
index b41129f..3320aea 100644
--- a/res/drawable/ic_pattern.xml
+++ b/res/drawable/ic_pattern.xml
@@ -20,18 +20,18 @@
     android:viewportHeight="24.0"
     android:viewportWidth="24.0">
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M4,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M4,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M20,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M20,18c-0.93,0 -1.7,0.64 -1.93,1.5h-4.14c-0.22,-0.86 -1,-1.5 -1.93,-1.5s-1.7,0.64 -1.93,1.5H5.93c-0.05,-0.18 -0.12,-0.35 -0.21,-0.51l5.28,-5.28C11.29,13.89 11.63,14 12,14c1.1,0 2,-0.9 2,-2c0,-0.37 -0.11,-0.71 -0.28,-1.01l5.28,-5.28C19.29,5.89 19.63,6 20,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2s-2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C12.71,10.11 12.37,10 12,10c-1.1,0 -2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C4.71,18.11 4.37,18 4,18c-1.1,0 -2,0.9 -2,2s0.9,2 2,2c0.93,0 1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5s1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5c1.1,0 2,-0.9 2,-2S21.1,18 20,18z" />
 </vector>
diff --git a/res/drawable/ic_pin.xml b/res/drawable/ic_pin.xml
index 577e04f..d8c3ae3 100644
--- a/res/drawable/ic_pin.xml
+++ b/res/drawable/ic_pin.xml
@@ -20,6 +20,6 @@
     android:viewportHeight="24.0"
     android:viewportWidth="24.0">
     <path
-        android:fillColor="?attr/sudListItemIconColor"
+        android:fillColor="?attr/colorAccent"
         android:pathData="M20,4L4,4A2,2 0,0 0,2 6L2,18a2,2 0,0 0,2 2L20,20a2,2 0,0 0,2 -2L22,6A2,2 0,0 0,20 4ZM7.1,15L5.9,15L5.9,10.2L4.7,10.2L4.7,9L7.1,9v6ZM13.2,11.4A1.2,1.2 0,0 1,12 12.6L10.8,12.6v1.2h2.4L13.2,15L9.6,15L9.6,12.6a1.2,1.2 0,0 1,1.2 -1.2L12,11.4L12,10.2L9.6,10.2L9.6,9L12,9a1.2,1.2 0,0 1,1.2 1.2v1.2ZM19.3,11.1a0.9,0.9 0,0 1,-0.9 0.9,0.9 0.9,0 0,1 0.9,0.9v0.9A1.2,1.2 0,0 1,18.1 15L15.7,15L15.7,13.8h2.4L18.1,12.6L16.9,12.6L16.9,11.4h1.2L18.1,10.2L15.7,10.2L15.7,9h2.4a1.2,1.2 0,0 1,1.2 1.2v0.9Z" />
 </vector>
diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml
index 5ec3da9..856d146 100644
--- a/res/layout/data_usage_summary_preference.xml
+++ b/res/layout/data_usage_summary_preference.xml
@@ -20,7 +20,7 @@
     android:layout_height="wrap_content"
     android:paddingTop="22dp"
     android:paddingBottom="32dp"
-    android:paddingStart="@dimen/preference_no_icon_padding_start"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
     android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
     android:orientation="vertical"
     android:selectable="false"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 379443f..05d2b4f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5984,6 +5984,8 @@
     <string name="manager_battery_usage_unrestricted_title">Unrestricted</string>
     <!-- Title for the battery optimized settings [CHAR_LIMIT=40] -->
     <string name="manager_battery_usage_optimized_title">Optimized</string>
+    <!-- Title for the battery restricted settings [CHAR_LIMIT=40] -->
+    <string name="manager_battery_usage_restricted_title">Restricted</string>
     <!-- Summary for the battery unrestricted settings [CHAR_LIMIT=NONE] -->
     <string name="manager_battery_usage_unrestricted_summary">Allow battery usage in background without restrictions. May use more battery.</string>
     <!-- Summary for the battery optimized settings [CHAR_LIMIT=NONE] -->
@@ -13193,7 +13195,7 @@
     <!-- Provider Model: Calls and SMS controllers settings screen, item title to go into the Calls and SMS settings -->
     <string name="calls_and_sms">Calls &amp; SMS</string>
     <!-- Provider Model: Name for call settings category [CHAR LIMIT=NONE] -->
-    <string name="calls_and_sms_category">Wi\u2011Fi Calling</string>
+    <string name="calls_and_sms_category">Wi\u2011Fi calling</string>
     <!-- Provider Model: Summary for calling preference -->
     <string name="calls_sms_wfc_summary">Make and receive calls over Wi\u2011Fi</string>
     <!-- Provider Model: Label for footnote on calling preference -->
diff --git a/res/xml/network_provider_settings.xml b/res/xml/network_provider_settings.xml
index c6d2831..9e8befa 100644
--- a/res/xml/network_provider_settings.xml
+++ b/res/xml/network_provider_settings.xml
@@ -25,14 +25,16 @@
         android:key="resetting_your_internet"
         android:title="@string/resetting_internet_text"
         android:selectable="false"
-        android:layout="@layout/resetting_internet"/>
+        android:layout="@layout/resetting_internet"
+        settings:allowDividerBelow="true"/>
 
     <!-- Airplane mode message -->
     <com.android.settingslib.widget.LayoutPreference
         android:key="airplane_mode_message"
         android:title="@string/condition_airplane_title"
         android:selectable="false"
-        android:layout="@layout/airplane_mode_message_preference"/>
+        android:layout="@layout/airplane_mode_message_preference"
+        settings:allowDividerBelow="true"/>
 
     <Preference
         android:key="connected_ethernet_network"
@@ -41,15 +43,22 @@
         android:icon="@drawable/ic_settings_ethernet"/>
 
     <PreferenceCategory
-        android:key="connected_access_point"
-        android:layout="@layout/preference_category_no_label"/>
-
-    <PreferenceCategory
         android:key="provider_model_mobile_network"
         android:title="@string/summary_placeholder"
         android:layout="@layout/preference_category_no_label"
         settings:controller="com.android.settings.network.NetworkMobileProviderController"/>
 
+    <com.android.settingslib.RestrictedSwitchPreference
+        android:key="main_toggle_wifi"
+        android:title="@string/wifi"
+        android:summary="@string/wifi_switch_summary"
+        settings:keywords="@string/keywords_wifi"
+        settings:allowDividerAbove="true"/>
+
+    <PreferenceCategory
+        android:key="connected_access_point"
+        android:layout="@layout/preference_category_no_label"/>
+
     <PreferenceCategory
         android:key="first_access_points"
         android:layout="@layout/preference_category_no_label"/>
@@ -58,16 +67,11 @@
         android:key="access_points"
         android:layout="@layout/preference_category_no_label"/>
 
-    <com.android.settingslib.RestrictedSwitchPreference
-        android:key="main_toggle_wifi"
-        android:title="@string/wifi"
-        android:summary="@string/wifi_switch_summary"
-        settings:keywords="@string/keywords_wifi"/>
-
     <Preference
         android:key="configure_wifi_settings"
         android:title="@string/network_and_internet_preferences_title"
         android:summary="@string/network_and_internet_preferences_summary"
+        settings:allowDividerAbove="true"
         android:fragment="com.android.settings.wifi.ConfigureWifiSettings"/>
 
     <Preference
diff --git a/res/xml/power_usage_detail.xml b/res/xml/power_usage_detail.xml
index 3481c1e..f383284 100644
--- a/res/xml/power_usage_detail.xml
+++ b/res/xml/power_usage_detail.xml
@@ -45,7 +45,7 @@
         <com.android.settingslib.widget.RadioButtonPreference
             android:key="restricted_pref"
             android:summary="@string/manager_battery_usage_restricted_summary"
-            android:title="@string/restricted_true_label"
+            android:title="@string/manager_battery_usage_restricted_title"
             settings:controller="com.android.settings.fuelgauge.RestrictedPreferenceController"/>
 
     </PreferenceCategory>
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java
index 676ed20..3943ac5 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java
@@ -17,7 +17,6 @@
 package com.android.settings.fuelgauge.batterysaver;
 
 import android.app.settings.SettingsEnums;
-import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
 
 import androidx.annotation.VisibleForTesting;
@@ -36,7 +35,6 @@
 public class BatterySaverSettings extends DashboardFragment {
     private static final String TAG = "BatterySaverSettings";
     private static final String KEY_FOOTER_PREFERENCE = "battery_saver_footer_preference";
-    private SpannableStringBuilder mFooterText;
     private String mHelpUri;
 
     @Override
@@ -76,8 +74,6 @@
     void setupFooter() {
         mHelpUri = getString(R.string.help_url_battery_saver_settings);
         if (!TextUtils.isEmpty(mHelpUri)) {
-            mFooterText = new SpannableStringBuilder(getText(
-                    com.android.internal.R.string.battery_saver_description_with_learn_more));
             addHelpLink();
         }
     }
@@ -87,7 +83,6 @@
     void addHelpLink() {
         FooterPreference pref = getPreferenceScreen().findPreference(KEY_FOOTER_PREFERENCE);
         if (pref != null) {
-            pref.setTitle(mFooterText);
             pref.setSelectable(false);
             pref.setLearnMoreAction(v -> {
                 mMetricsFeatureProvider.action(getContext(),
diff --git a/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java b/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
index c16dbc9..3423ad8 100644
--- a/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
+++ b/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroup.java
@@ -31,7 +31,7 @@
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.util.ArrayMap;
-import android.util.ArraySet;
+import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.lifecycle.LifecycleObserver;
@@ -50,7 +50,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * Copied the logic of WiFi calling from {@link WifiCallingPreferenceController}.
@@ -72,8 +71,7 @@
     private Map<Integer, TelephonyManager> mTelephonyManagerList = new HashMap<>();
     private Map<Integer, PhoneAccountHandle> mSimCallManagerList = new HashMap<>();
     private Map<Integer, Preference> mWifiCallingForSubPreferences;
-    private Set<Integer> mSubIdList = new ArraySet<>();
-
+    private List<SubscriptionInfo> mSubInfoListForWfc;
 
     public NetworkProviderWifiCallingGroup(Context context, Lifecycle lifecycle,
             String preferenceGroupKey) {
@@ -83,18 +81,26 @@
 
         mPreferenceGroupKey = preferenceGroupKey;
         mWifiCallingForSubPreferences = new ArrayMap<>();
-        lifecycle.addObserver(this);
         setSubscriptionInfoList(context);
+        lifecycle.addObserver(this);
     }
 
-    private void setSubscriptionInfoList(Context context){
-        final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions(
-                mSubscriptionManager);
-        for (SubscriptionInfo info : subscriptions) {
-            final int subId = info.getSubscriptionId();
-            mSubIdList.add(subId);
-            setTelephonyManagerForSubscriptionId(context, subId);
-            setPhoneAccountHandleForSubscriptionId(context, subId);
+    private void setSubscriptionInfoList(Context context) {
+        mSubInfoListForWfc = SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager);
+        if (mSubInfoListForWfc != null) {
+            mSubInfoListForWfc.removeIf(info -> {
+                final int subId = info.getSubscriptionId();
+                setTelephonyManagerForSubscriptionId(context, subId);
+                setPhoneAccountHandleForSubscriptionId(context, subId);
+                boolean isExisted = mSubInfoListForWfc.contains(info);
+                boolean shouldShowWfcForSub = shouldShowWifiCallingForSub(subId);
+                if (!shouldShowWfcForSub && isExisted) {
+                    return true;
+                }
+                return false;
+            });
+        } else {
+            Log.d(TAG, "No active subscriptions");
         }
     }
 
@@ -110,12 +116,12 @@
         mSimCallManagerList.put(subId, phoneAccountHandle);
     }
 
-    private TelephonyManager getTelephonyManagerForSubscriptionId(int subId){
-       return mTelephonyManagerList.get(subId);
+    private TelephonyManager getTelephonyManagerForSubscriptionId(int subId) {
+        return mTelephonyManagerList.get(subId);
     }
 
     @VisibleForTesting
-    protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId){
+    protected PhoneAccountHandle getPhoneAccountHandleForSubscriptionId(int subId) {
         return mSimCallManagerList.get(subId);
     }
 
@@ -131,7 +137,12 @@
 
     @Override
     public boolean isAvailable() {
-        return mSubIdList.size() >= 1;
+        if (mSubInfoListForWfc == null) {
+            Log.d(TAG, "No active subscriptions, hide the controller");
+            return false;
+        } else {
+            return mSubInfoListForWfc.size() >= 1;
+        }
     }
 
     @Override
@@ -167,19 +178,15 @@
 
         final Map<Integer, Preference> toRemovePreferences = mWifiCallingForSubPreferences;
         mWifiCallingForSubPreferences = new ArrayMap<>();
-        final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions(
-                mSubscriptionManager);
-        setSubscriptionInfoForPreference(subscriptions, toRemovePreferences);
-
+        setSubscriptionInfoForPreference(toRemovePreferences);
         for (Preference pref : toRemovePreferences.values()) {
             mPreferenceGroup.removePreference(pref);
         }
     }
 
-    private void setSubscriptionInfoForPreference(List<SubscriptionInfo> subscriptions,
-                                                  Map<Integer, Preference> toRemovePreferences) {
+    private void setSubscriptionInfoForPreference(Map<Integer, Preference> toRemovePreferences) {
         int order = PREF_START_ORDER;
-        for (SubscriptionInfo info : subscriptions) {
+        for (SubscriptionInfo info : mSubInfoListForWfc) {
             final int subId = info.getSubscriptionId();
 
             if (!shouldShowWifiCallingForSub(subId)) {
@@ -192,9 +199,11 @@
                 mPreferenceGroup.addPreference(pref);
             }
 
-            CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info, mContext);
+            CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(info,
+                    mContext);
             if (getPhoneAccountHandleForSubscriptionId(subId) != null) {
-                final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
+                final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(
+                        mContext,
                         getPhoneAccountHandleForSubscriptionId(subId));
                 if (intent != null) {
                     final PackageManager pm = mContext.getPackageManager();
@@ -245,7 +254,7 @@
      * 1. Check the subscription is valid or not.
      * 2. Check whether Wi-Fi Calling can be perform or not on this subscription.
      * 3. Check the carrier's config (carrier_wfc_ims_available_bool). If true, the carrier
-     *    supports the Wi-Fi calling, otherwise false.
+     * supports the Wi-Fi calling, otherwise false.
      */
     @VisibleForTesting
     protected boolean shouldShowWifiCallingForSub(int subId) {