Merge "Add bubbles animation" into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c112115..8fd0769 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1276,6 +1276,8 @@
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.privacy.PrivacyDashboardFragment" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
</activity>
<activity android:name="SetFullBackupPassword"
@@ -1629,6 +1631,7 @@
android:resource="@string/suggestion_additional_fingerprints" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/suggestion_additional_fingerprints_summary" />
+ <meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity-alias>
<!-- Note this must not be exported since it returns the password in the intent -->
diff --git a/res/drawable-hdpi/ic_live_help.png b/res/drawable-hdpi/ic_live_help.png
deleted file mode 100644
index f3548f6..0000000
--- a/res/drawable-hdpi/ic_live_help.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_live_help.png b/res/drawable-mdpi/ic_live_help.png
deleted file mode 100644
index e958662..0000000
--- a/res/drawable-mdpi/ic_live_help.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_live_help.png b/res/drawable-xhdpi/ic_live_help.png
deleted file mode 100644
index dbbbfed..0000000
--- a/res/drawable-xhdpi/ic_live_help.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_live_help.png b/res/drawable-xxhdpi/ic_live_help.png
deleted file mode 100644
index f2a01fe..0000000
--- a/res/drawable-xxhdpi/ic_live_help.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_live_help.png b/res/drawable-xxxhdpi/ic_live_help.png
deleted file mode 100644
index 00338a0..0000000
--- a/res/drawable-xxxhdpi/ic_live_help.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/ic_feedback_24dp.xml b/res/drawable/ic_feedback_24dp.xml
new file mode 100644
index 0000000..a65f444
--- /dev/null
+++ b/res/drawable/ic_feedback_24dp.xml
@@ -0,0 +1,30 @@
+<!--
+ ~ Copyright (C) 2019 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
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M20,2H4C2.9,2 2.01,2.9 2.01,4L2,22l4,-4h14c1.1,0 2,-0.9 2,-2V4C22,2.9 21.1,2 20,2zM20,16H6H5.17l-0.59,0.59L4,17.17V4h16V16z"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M11,12h2v2h-2z"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M11,6h2v4h-2z"/>
+</vector>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index f6f86f0..b7b30f5 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -24,5 +24,7 @@
<color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
<color name="contextual_card_background">@*android:color/material_grey_900</color>
<color name="search_bar_background">@*android:color/material_grey_800</color>
+ <!-- Dialog background color -->
+ <color name="dialog_background">@*android:color/material_grey_800</color>
</resources>
diff --git a/res/values-night/themes.xml b/res/values-night/themes.xml
index 2227b88..782f482 100644
--- a/res/values-night/themes.xml
+++ b/res/values-night/themes.xml
@@ -33,6 +33,7 @@
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
<item name="colorAccent">@*android:color/accent_device_default_dark</item>
+ <item name="android:background">@color/dialog_background</item>
</style>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index d4363b1..1245b37 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -143,4 +143,7 @@
<!-- Search bar background color -->
<color name="search_bar_background">@android:color/white</color>
+ <!-- Dialog background color -->
+ <color name="dialog_background">@*android:color/background_device_default_light</color>
+
</resources>
\ No newline at end of file
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 5db5f2f..d29d78b 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -117,6 +117,7 @@
<style name="Theme.AlertDialog.Base" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">
<item name="colorAccent">@*android:color/accent_device_default_light</item>
+ <item name="android:background">@color/dialog_background</item>
</style>
<style name="Theme.AlertDialog" parent="Theme.AlertDialog.Base">
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index 6682437..6890a41 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -24,162 +24,170 @@
android:layout="@layout/styled_switch_bar"
settings:controller="com.android.settings.network.telephony.MobileNetworkSwitchController"/>
- <com.android.settings.datausage.DataUsageSummaryPreference
- android:key="status_header"
- android:visibility="gone"
- android:selectable="false" />
-
- <ListPreference
- android:key="calls_preference"
- android:title="@string/calls_preference"
- settings:controller="com.android.settings.network.telephony.CallsDefaultSubscriptionController"
- settings:allowDividerAbove="true" />
-
- <ListPreference
- android:key="sms_preference"
- android:title="@string/sms_preference"
- settings:controller="com.android.settings.network.telephony.SmsDefaultSubscriptionController" />
-
- <Preference
- android:key="cdma_lte_data_service_key"
- android:title="@string/cdma_lte_data_service"
- settings:controller="com.android.settings.network.telephony.DataServiceSetupPreferenceController"
- settings:allowDividerAbove="true"
- settings:allowDividerBelow="false" />
-
- <SwitchPreference
- android:key="mobile_data_enable"
- android:title="@string/mobile_data_settings_title"
- android:summary="@string/mobile_data_settings_summary"
- settings:controller="com.android.settings.network.telephony.MobileDataPreferenceController"
- settings:allowDividerAbove="true"/>
-
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="button_roaming_key"
- android:title="@string/roaming"
- android:persistent="false"
- android:summaryOn="@string/roaming_enable"
- android:summaryOff="@string/roaming_disable"
- settings:userRestriction="no_data_roaming"
- settings:controller="com.android.settings.network.telephony.RoamingPreferenceController"/>
-
- <Preference
- android:key="data_usage_summary"
- android:title="@string/mobile_data_usage_title"
- settings:controller="com.android.settings.network.telephony.DataUsagePreferenceController"/>
-
- <com.android.settings.datausage.BillingCyclePreference
- android:key="billing_preference"
- android:title="@string/billing_cycle"
- settings:controller="com.android.settings.datausage.BillingCyclePreferenceController" />
-
- <SwitchPreference
- android:key="mms_message"
- android:title="@string/mms_message_title"
- android:summary="@string/mms_message_summary"
- settings:controller="com.android.settings.network.telephony.MmsMessagePreferenceController" />
-
- <SwitchPreference
- android:key="enhanced_4g_lte"
- android:title="@string/enhanced_4g_lte_mode_title"
- android:persistent="false"
- android:summary="@string/enhanced_4g_lte_mode_summary"
- settings:controller="com.android.settings.network.telephony.Enhanced4gLtePreferenceController"/>
-
- <ListPreference
- android:key="preferred_network_mode_key"
- android:title="@string/preferred_network_mode_title"
- android:summary="@string/preferred_network_mode_summary"
- android:entries="@array/preferred_network_mode_choices"
- android:entryValues="@array/preferred_network_mode_values"
- android:dialogTitle="@string/preferred_network_mode_dialogtitle"
- settings:controller="com.android.settings.network.telephony.PreferredNetworkModePreferenceController"/>
-
- <ListPreference
- android:key="enabled_networks_key"
- android:title="@string/preferred_network_mode_title"
- android:summary="@string/preferred_network_mode_summary"
- android:entries="@array/enabled_networks_choices"
- android:entryValues="@array/enabled_networks_values"
- android:dialogTitle="@string/preferred_network_mode_dialogtitle"
- settings:controller="com.android.settings.network.telephony.EnabledNetworkModePreferenceController"/>
-
- <Preference
- android:key="carrier_settings_version_key"
- android:title="@string/carrier_settings_version"
- settings:controller="com.android.settings.network.telephony.CarrierSettingsVersionPreferenceController"
- settings:enableCopying="true" />
-
<PreferenceCategory
- android:key="calling_category"
- android:title="@string/call_category">
+ android:key="enabled_state_container"
+ android:title="@string/summary_placeholder"
+ settings:controller="com.android.settings.network.telephony.DisabledSubscriptionController"
+ android:layout="@layout/preference_category_no_label">
- <PreferenceScreen
- android:key="wifi_calling_key"
- android:title="@string/wifi_calling_settings_title"
- settings:controller="com.android.settings.network.telephony.WifiCallingPreferenceController" >
- <intent android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.settings"
- android:targetClass="com.android.settings.Settings$WifiCallingSettingsActivity">
- <extra android:name="show_drawer_menu" android:value="true" />
- </intent>
- </PreferenceScreen>
+ <com.android.settings.datausage.DataUsageSummaryPreference
+ android:key="status_header"
+ android:visibility="gone"
+ android:selectable="false" />
- <SwitchPreference
- android:key="video_calling_key"
- android:title="@string/video_calling_settings_title"
- android:persistent="true"
- settings:controller="com.android.settings.network.telephony.VideoCallingPreferenceController" />
+ <ListPreference
+ android:key="calls_preference"
+ android:title="@string/calls_preference"
+ settings:controller="com.android.settings.network.telephony.CallsDefaultSubscriptionController"
+ settings:allowDividerAbove="true"/>
- </PreferenceCategory>
-
- <com.android.settings.network.telephony.cdma.CdmaListPreference
- android:key="cdma_system_select_key"
- android:title="@string/cdma_system_select_title"
- android:summary="@string/cdma_system_select_summary"
- android:entries="@array/cdma_system_select_choices"
- android:entryValues="@array/cdma_system_select_values"
- android:dialogTitle="@string/cdma_system_select_dialogtitle"
- settings:controller="com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController"/>
-
- <com.android.settings.network.telephony.cdma.CdmaListPreference
- android:key="cdma_subscription_key"
- android:title="@string/cdma_subscription_title"
- android:summary="@string/cdma_subscription_summary"
- android:entries="@array/cdma_subscription_choices"
- android:entryValues="@array/cdma_subscription_values"
- android:dialogTitle="@string/cdma_subscription_dialogtitle"
- settings:controller="com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController"/>
-
- <PreferenceCategory
- android:key="network_operators_category_key"
- android:title="@string/network_operator_category"
- settings:controller="com.android.settings.widget.PreferenceCategoryController">
-
- <SwitchPreference
- android:key="auto_select_key"
- android:title="@string/select_automatically"
- settings:controller="com.android.settings.network.telephony.gsm.AutoSelectPreferenceController"/>
+ <ListPreference
+ android:key="sms_preference"
+ android:title="@string/sms_preference"
+ settings:controller="com.android.settings.network.telephony.SmsDefaultSubscriptionController"/>
<Preference
- android:key="choose_network_key"
- android:title="@string/choose_network_title"
- android:fragment="com.android.phone.NetworkSelectSetting"
- settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
+ android:key="cdma_lte_data_service_key"
+ android:title="@string/cdma_lte_data_service"
+ settings:controller="com.android.settings.network.telephony.DataServiceSetupPreferenceController"
+ settings:allowDividerAbove="true"
+ settings:allowDividerBelow="false"/>
+
+ <SwitchPreference
+ android:key="mobile_data_enable"
+ android:title="@string/mobile_data_settings_title"
+ android:summary="@string/mobile_data_settings_summary"
+ settings:controller="com.android.settings.network.telephony.MobileDataPreferenceController"
+ settings:allowDividerAbove="true"/>
+
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="button_roaming_key"
+ android:title="@string/roaming"
+ android:persistent="false"
+ android:summaryOn="@string/roaming_enable"
+ android:summaryOff="@string/roaming_disable"
+ settings:userRestriction="no_data_roaming"
+ settings:controller="com.android.settings.network.telephony.RoamingPreferenceController"/>
+
+ <Preference
+ android:key="data_usage_summary"
+ android:title="@string/mobile_data_usage_title"
+ settings:controller="com.android.settings.network.telephony.DataUsagePreferenceController"/>
+
+ <com.android.settings.datausage.BillingCyclePreference
+ android:key="billing_preference"
+ android:title="@string/billing_cycle"
+ settings:controller="com.android.settings.datausage.BillingCyclePreferenceController"/>
+
+ <SwitchPreference
+ android:key="mms_message"
+ android:title="@string/mms_message_title"
+ android:summary="@string/mms_message_summary"
+ settings:controller="com.android.settings.network.telephony.MmsMessagePreferenceController"/>
+
+ <SwitchPreference
+ android:key="enhanced_4g_lte"
+ android:title="@string/enhanced_4g_lte_mode_title"
+ android:persistent="false"
+ android:summary="@string/enhanced_4g_lte_mode_summary"
+ settings:controller="com.android.settings.network.telephony.Enhanced4gLtePreferenceController"/>
+
+ <ListPreference
+ android:key="preferred_network_mode_key"
+ android:title="@string/preferred_network_mode_title"
+ android:summary="@string/preferred_network_mode_summary"
+ android:entries="@array/preferred_network_mode_choices"
+ android:entryValues="@array/preferred_network_mode_values"
+ android:dialogTitle="@string/preferred_network_mode_dialogtitle"
+ settings:controller="com.android.settings.network.telephony.PreferredNetworkModePreferenceController"/>
+
+ <ListPreference
+ android:key="enabled_networks_key"
+ android:title="@string/preferred_network_mode_title"
+ android:summary="@string/preferred_network_mode_summary"
+ android:entries="@array/enabled_networks_choices"
+ android:entryValues="@array/enabled_networks_values"
+ android:dialogTitle="@string/preferred_network_mode_dialogtitle"
+ settings:controller="com.android.settings.network.telephony.EnabledNetworkModePreferenceController"/>
+
+ <Preference
+ android:key="carrier_settings_version_key"
+ android:title="@string/carrier_settings_version"
+ settings:controller="com.android.settings.network.telephony.CarrierSettingsVersionPreferenceController"
+ settings:enableCopying="true"/>
+
+ <PreferenceCategory
+ android:key="calling_category"
+ android:title="@string/call_category">
+
+ <PreferenceScreen
+ android:key="wifi_calling_key"
+ android:title="@string/wifi_calling_settings_title"
+ settings:controller="com.android.settings.network.telephony.WifiCallingPreferenceController">
+ <intent android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.settings"
+ android:targetClass="com.android.settings.Settings$WifiCallingSettingsActivity">
+ <extra android:name="show_drawer_menu" android:value="true"/>
+ </intent>
+ </PreferenceScreen>
+
+ <SwitchPreference
+ android:key="video_calling_key"
+ android:title="@string/video_calling_settings_title"
+ android:persistent="true"
+ settings:controller="com.android.settings.network.telephony.VideoCallingPreferenceController"/>
+
+ </PreferenceCategory>
+
+ <com.android.settings.network.telephony.cdma.CdmaListPreference
+ android:key="cdma_system_select_key"
+ android:title="@string/cdma_system_select_title"
+ android:summary="@string/cdma_system_select_summary"
+ android:entries="@array/cdma_system_select_choices"
+ android:entryValues="@array/cdma_system_select_values"
+ android:dialogTitle="@string/cdma_system_select_dialogtitle"
+ settings:controller="com.android.settings.network.telephony.cdma.CdmaSystemSelectPreferenceController"/>
+
+ <com.android.settings.network.telephony.cdma.CdmaListPreference
+ android:key="cdma_subscription_key"
+ android:title="@string/cdma_subscription_title"
+ android:summary="@string/cdma_subscription_summary"
+ android:entries="@array/cdma_subscription_choices"
+ android:entryValues="@array/cdma_subscription_values"
+ android:dialogTitle="@string/cdma_subscription_dialogtitle"
+ settings:controller="com.android.settings.network.telephony.cdma.CdmaSubscriptionPreferenceController"/>
+
+ <PreferenceCategory
+ android:key="network_operators_category_key"
+ android:title="@string/network_operator_category"
+ settings:controller="com.android.settings.widget.PreferenceCategoryController">
+
+ <SwitchPreference
+ android:key="auto_select_key"
+ android:title="@string/select_automatically"
+ settings:controller="com.android.settings.network.telephony.gsm.AutoSelectPreferenceController"/>
+
+ <Preference
+ android:key="choose_network_key"
+ android:title="@string/choose_network_title"
+ android:fragment="com.android.phone.NetworkSelectSetting"
+ settings:controller="com.android.settings.network.telephony.gsm.OpenNetworkSelectPagePreferenceController"/>
+ </PreferenceCategory>
+
+ <!--We want separate APN setting from reset of settings because we want user to change it with caution-->
+ <com.android.settingslib.RestrictedPreference
+ android:key="telephony_apn_key"
+ android:persistent="false"
+ android:title="@string/mobile_network_apn_title"
+ settings:allowDividerAbove="true"
+ settings:controller="com.android.settings.network.telephony.ApnPreferenceController"/>
+
+ <Preference
+ android:key="carrier_settings_key"
+ android:title="@string/carrier_settings_title"
+ settings:controller="com.android.settings.network.telephony.CarrierPreferenceController">
+ </Preference>
+
</PreferenceCategory>
- <!--We want separate APN setting from reset of settings because we want user to change it with caution-->
- <com.android.settingslib.RestrictedPreference
- android:key="telephony_apn_key"
- android:persistent="false"
- android:title="@string/mobile_network_apn_title"
- settings:allowDividerAbove="true"
- settings:controller="com.android.settings.network.telephony.ApnPreferenceController"/>
-
- <Preference
- android:key="carrier_settings_key"
- android:title="@string/carrier_settings_title"
- settings:controller="com.android.settings.network.telephony.CarrierPreferenceController">
- </Preference>
-
</PreferenceScreen>
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index f5216d8..48370d9 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -54,7 +54,7 @@
public class FaceSettings extends DashboardFragment {
private static final String TAG = "FaceSettings";
- private static final String KEY_TOKEN = "key_token";
+ private static final String KEY_TOKEN = "hw_auth_token";
private UserManager mUserManager;
private FaceManager mFaceManager;
@@ -111,6 +111,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
mUserManager = getPrefContext().getSystemService(UserManager.class);
mFaceManager = getPrefContext().getSystemService(FaceManager.class);
mUserId = getActivity().getIntent().getIntExtra(
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index a014c29..95f913e 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -406,13 +406,7 @@
}
private SubscriptionInfo getPhoneSubscriptionInfo(int slotId) {
- final List<SubscriptionInfo> subscriptionInfoList = SubscriptionManager.from(
- mContext).getActiveSubscriptionInfoList(true);
- if (subscriptionInfoList != null && subscriptionInfoList.size() > slotId) {
- return subscriptionInfoList.get(slotId);
- } else {
- return null;
- }
+ return SubscriptionManager.from(mContext).getActiveSubscriptionInfoForSimSlotIndex(slotId);
}
@VisibleForTesting
diff --git a/src/com/android/settings/network/telephony/DisabledSubscriptionController.java b/src/com/android/settings/network/telephony/DisabledSubscriptionController.java
new file mode 100644
index 0000000..22cbb13
--- /dev/null
+++ b/src/com/android/settings/network/telephony/DisabledSubscriptionController.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2019 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.network.telephony;
+
+import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
+import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
+
+import android.content.Context;
+import android.telephony.SubscriptionManager;
+
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.network.SubscriptionsChangeListener;
+
+public class DisabledSubscriptionController extends BasePreferenceController implements
+ SubscriptionsChangeListener.SubscriptionsChangeListenerClient, LifecycleObserver {
+ private PreferenceCategory mCategory;
+ private int mSubId;
+ private SubscriptionsChangeListener mChangeListener;
+ private SubscriptionManager mSubscriptionManager;
+
+ public DisabledSubscriptionController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
+ mChangeListener = new SubscriptionsChangeListener(context, this);
+ }
+
+ public void init(Lifecycle lifecycle, int subId) {
+ lifecycle.addObserver(this);
+ mSubId = subId;
+ }
+
+ @OnLifecycleEvent(ON_RESUME)
+ public void onResume() {
+ mChangeListener.start();
+ update();
+ }
+
+ @OnLifecycleEvent(ON_PAUSE)
+ public void onPause() {
+ mChangeListener.stop();
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mCategory = screen.findPreference(getPreferenceKey());
+ update();
+ }
+
+ private void update() {
+ if (mCategory == null || mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return;
+ }
+ mCategory.setVisible(mSubscriptionManager.isSubscriptionEnabled(mSubId));
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE_UNSEARCHABLE;
+ }
+
+ @Override
+ public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
+ }
+
+ @Override
+ public void onSubscriptionsChanged() {
+ update();
+ }
+}
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index a0e50fc..0a39bfd 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -17,27 +17,24 @@
package com.android.settings.network.telephony;
import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
-import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import com.android.settings.network.MobileDataContentObserver;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.core.lifecycle.events.OnStop;
-
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
+import com.android.settings.network.MobileDataContentObserver;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
/**
* Preference controller for "Mobile data"
*/
@@ -60,7 +57,7 @@
super(context, key);
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
mDataContentObserver = new MobileDataContentObserver(new Handler(Looper.getMainLooper()));
- mDataContentObserver.setOnMobileDataChangedListener(()-> updateState(mPreference));
+ mDataContentObserver.setOnMobileDataChangedListener(() -> updateState(mPreference));
}
@Override
@@ -144,18 +141,10 @@
final int defaultSubId = mSubscriptionManager.getDefaultDataSubscriptionId();
final boolean needToDisableOthers = mSubscriptionManager
.isActiveSubscriptionId(defaultSubId) && defaultSubId != mSubId;
- if (enableData) {
- if (isMultiSim && needToDisableOthers) {
- mDialogType = MobileDataDialogFragment.TYPE_MULTI_SIM_DIALOG;
- return true;
- }
- } else {
- if (!isMultiSim) {
- mDialogType = MobileDataDialogFragment.TYPE_DISABLE_DIALOG;
- return true;
- }
+ if (enableData && isMultiSim && needToDisableOthers) {
+ mDialogType = MobileDataDialogFragment.TYPE_MULTI_SIM_DIALOG;
+ return true;
}
-
return false;
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index db99258..eb00b9f 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -131,12 +131,13 @@
super.onAttach(context);
if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
- use(CallsDefaultSubscriptionController.class).init(getLifecycle());
- use(SmsDefaultSubscriptionController.class).init(getLifecycle());
- use(MobileNetworkSwitchController.class).init(getLifecycle(), mSubId);
- use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
- use(BillingCyclePreferenceController.class).init(mSubId);
- use(MmsMessagePreferenceController.class).init(mSubId);
+ use(CallsDefaultSubscriptionController.class).init(getLifecycle());
+ use(SmsDefaultSubscriptionController.class).init(getLifecycle());
+ use(MobileNetworkSwitchController.class).init(getLifecycle(), mSubId);
+ use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
+ use(BillingCyclePreferenceController.class).init(mSubId);
+ use(MmsMessagePreferenceController.class).init(mSubId);
+ use(DisabledSubscriptionController.class).init(getLifecycle(), mSubId);
}
use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId);
use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId);
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index dcd878e..0f525cc 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -33,6 +33,7 @@
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
+
import com.google.android.setupdesign.DividerItemDecoration;
import java.util.ArrayList;
@@ -128,7 +129,8 @@
.action(0 /* attribution */,
SettingsEnums.ACTION_PANEL_INTERACTION,
mMetricsCategory,
- sliceLiveData.toString() /* log key */,
+ sliceLiveData.getValue().getUri().getLastPathSegment()
+ /* log key */,
eventInfo.actionType /* value */);
})
);
diff --git a/src/com/android/settings/sim/SimListDialogFragment.java b/src/com/android/settings/sim/SimListDialogFragment.java
index 1802d65..3b78927 100644
--- a/src/com/android/settings/sim/SimListDialogFragment.java
+++ b/src/com/android/settings/sim/SimListDialogFragment.java
@@ -174,7 +174,7 @@
if (sub == null) {
title.setText(R.string.sim_calls_ask_first_prefs_title);
summary.setText("");
- icon.setImageDrawable(mContext.getDrawable(R.drawable.ic_help));
+ icon.setImageDrawable(mContext.getDrawable(R.drawable.ic_feedback_24dp));
icon.setImageTintList(
Utils.getColorAttr(mContext, android.R.attr.textColorSecondary));
} else {
diff --git a/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java
new file mode 100644
index 0000000..c1004fa
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/telephony/DisabledSubscriptionControllerTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2019 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.network.telephony;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.telephony.SubscriptionManager;
+
+import androidx.lifecycle.LifecycleOwner;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class DisabledSubscriptionControllerTest {
+
+ private static final String KEY = "disabled_subscription_category";
+ private static final int SUB_ID = 111;
+
+ @Mock
+ private SubscriptionManager mSubscriptionManager;
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private PreferenceCategory mCategory;
+ private Context mContext;
+ private Lifecycle mLifecycle;
+ private DisabledSubscriptionController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ LifecycleOwner lifecycleOwner = () -> mLifecycle;
+ mLifecycle = new Lifecycle(lifecycleOwner);
+ doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
+ mCategory = new PreferenceCategory(mContext);
+ doReturn(mCategory).when(mScreen).findPreference(KEY);
+ mController = new DisabledSubscriptionController(mContext, KEY);
+ mController.init(mLifecycle, SUB_ID);
+ }
+
+ @Test
+ public void displayPreference_subscriptionEnabled_categoryIsVisible() {
+ doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
+ mController.displayPreference(mScreen);
+ assertThat(mCategory.isVisible()).isTrue();
+ }
+
+ @Test
+ public void displayPreference_subscriptionDisabled_categoryIsNotVisible() {
+ doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
+ mController.displayPreference(mScreen);
+ assertThat(mCategory.isVisible()).isFalse();
+ }
+
+ @Test
+ public void onSubscriptionsChanged_subscriptionBecomesDisabled_categoryIsNotVisible() {
+ doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
+ mController.displayPreference(mScreen);
+ doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
+ mController.onSubscriptionsChanged();
+ assertThat(mCategory.isVisible()).isFalse();
+ }
+
+ @Test
+ public void onSubscriptionsChanged_subscriptionBecomesEnabled_categoryIsVisible() {
+ doReturn(false).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
+ mController.displayPreference(mScreen);
+ doReturn(true).when(mSubscriptionManager).isSubscriptionEnabled(SUB_ID);
+ mController.onSubscriptionsChanged();
+ assertThat(mCategory.isVisible()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index 1b7b4b4..e853c47 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -21,7 +21,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -30,6 +29,10 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+import androidx.preference.SwitchPreference;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,10 +43,6 @@
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowSubscriptionManager;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.preference.SwitchPreference;
-
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowSubscriptionManager.class)
public class MobileDataPreferenceControllerTest {
@@ -94,14 +93,13 @@
}
@Test
- public void isDialogNeeded_disableSingleSim_returnTrue() {
+ public void isDialogNeeded_disableSingleSim_returnFalse() {
doReturn(true).when(mTelephonyManager).isDataEnabled();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
doReturn(1).when(mTelephonyManager).getSimCount();
- assertThat(mController.isDialogNeeded()).isTrue();
- assertThat(mController.mDialogType).isEqualTo(MobileDataDialogFragment.TYPE_DISABLE_DIALOG);
+ assertThat(mController.isDialogNeeded()).isFalse();
}
@Test
@@ -127,7 +125,7 @@
}
@Test
- public void onPreferenceChange_needDialog_doNothing() {
+ public void onPreferenceChange_singleSim_On_shouldEnableData() {
doReturn(true).when(mTelephonyManager).isDataEnabled();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
@@ -135,11 +133,11 @@
mController.onPreferenceChange(mPreference, true);
- verify(mTelephonyManager, never()).setDataEnabled(true);
+ verify(mTelephonyManager).setDataEnabled(true);
}
@Test
- public void onPreferenceChange_notNeedDialog_update() {
+ public void onPreferenceChange_multiSim_On_shouldEnableData() {
doReturn(true).when(mTelephonyManager).isDataEnabled();
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();