Merge "Add entry point to global actions panel settings" into qt-dev
diff --git a/res/layout/profile_owner_add.xml b/res/layout/profile_owner_add.xml
index 84c51fd..2ee5dfc 100644
--- a/res/layout/profile_owner_add.xml
+++ b/res/layout/profile_owner_add.xml
@@ -27,12 +27,17 @@
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars = "vertical"
- android:padding="?dialogPreferredPadding"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:paddingTop="12dp"
+ android:paddingBottom="6dp"
android:gravity="center_vertical"/>
<TextView android:id="@+id/admin_warning_simplified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="?dialogPreferredPadding"
- android:paddingEnd="?dialogPreferredPadding"/>
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:paddingTop="6dp"
+ android:paddingBottom="12dp"/>
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 83cb116..5384cac 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10249,8 +10249,6 @@
<string name="global_actions_panel_title" translatable="false">Show global actions</string>
<!-- Short title text for global actions panel [CHAR LIMIT=40] [DO NOT TRANSLATE]-->
<string name="global_actions_panel_short_title" translatable="false">Global actions</string>
- <!-- Footer text for global actions panel [CHAR LIMIT=NONE] [DO NOT TRANSLATE]-->
- <string name="global_actions_panel_footer" translatable="false">The global actions panel can be accessed even when the device is locked.</string>
<!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
<string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
diff --git a/res/xml/global_actions_panel_settings.xml b/res/xml/global_actions_panel_settings.xml
index af155bc..2dc0fe9 100644
--- a/res/xml/global_actions_panel_settings.xml
+++ b/res/xml/global_actions_panel_settings.xml
@@ -33,8 +33,4 @@
app:controller="com.android.settings.gestures.GlobalActionsPanelPreferenceController"
app:allowDividerAbove="true" />
- <com.android.settingslib.widget.FooterPreference
- android:key="footer_preference"
- android:title="@string/global_actions_panel_footer" />
-
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index 0d0bd20..8b06975 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -312,7 +312,7 @@
addAndFinish();
}
})
- .setNeutralButton(R.string.cancel, null)
+ .setNegativeButton(R.string.cancel, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialogInterface) {
finish();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index ce5c768..9b12309 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -49,6 +49,7 @@
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupdesign.util.DescriptionStyler;
/**
* Activity which handles the actual enrolling for fingerprint.
@@ -137,6 +138,7 @@
mProgressBar = (ProgressBar) findViewById(R.id.fingerprint_progress_bar);
mVibrator = getSystemService(Vibrator.class);
+ DescriptionStyler.applyPartnerCustomizationStyle(mRepeatMessage);
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
new FooterButton.Builder(this)
diff --git a/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
index 4aaa490..81efaa6 100644
--- a/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
+++ b/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceController.java
@@ -82,10 +82,10 @@
private boolean isDefaultEnabled() {
// The default in the absence of user preference is settable via DeviceConfig.
- // Note that the default default is enabled.
+ // Note that the default default is disabled.
return DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED,
- /*defaultValue*/ true);
+ /*defaultValue*/ false);
}
}
diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index ddc3ad6..537c705 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -120,7 +120,7 @@
private CharSequence getFirstPhoneNumber() {
final List<SubscriptionInfo> subscriptionInfoList =
mSubscriptionManager.getActiveSubscriptionInfoList(true);
- if (subscriptionInfoList == null) {
+ if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
return mContext.getText(R.string.device_info_default);
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 0c099ca..c0b4590 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -277,8 +277,7 @@
return true;
}
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
- && !isTdscdmaSupported(context, telephonyManager)) {
+ if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
return true;
}
}
@@ -296,16 +295,15 @@
if (isGsmBasicOptions(context, subId)) {
return true;
}
- final int settingsNetworkMode = android.provider.Settings.Global.getInt(
+ final int networkMode = android.provider.Settings.Global.getInt(
context.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
Phone.PREFERRED_NT_MODE);
if (isWorldMode(context, subId)) {
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
- || settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
- } else if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
- && !MobileNetworkUtils.isTdscdmaSupported(context, subId)) {
+ } else if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
return true;
}
}
@@ -362,16 +360,24 @@
return false;
}
+ final int networkMode = android.provider.Settings.Global.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ Phone.PREFERRED_NT_MODE);
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
+ && isWorldMode(context, subId)) {
+ return false;
+ }
+ if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
+ return false;
+ }
+
if (isGsmBasicOptions(context, subId)) {
return true;
}
- final int settingsNetworkMode = android.provider.Settings.Global.getInt(
- context.getContentResolver(),
- android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
- Phone.PREFERRED_NT_MODE);
if (isWorldMode(context, subId)) {
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
}
}
@@ -414,7 +420,6 @@
return false;
}
-
/**
* Return subId that supported by search. If there are more than one, return first one,
* otherwise return {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}
@@ -461,4 +466,33 @@
}
}
}
+
+ /**
+ * This method is migrated from {@link com.android.phone.MobileNetworkSettings} and we should
+ * use it carefully. This code snippet doesn't have very clear meaning however we should
+ * update GSM or CDMA differently based on what it returns.
+ *
+ * 1. For all CDMA settings, make them visible if it return {@code true}
+ * 2. For GSM settings, make them visible if it return {@code true} unless 3
+ * 3. For network select settings, make it invisible if it return {@code true}
+ */
+ @VisibleForTesting
+ static boolean shouldSpeciallyUpdateGsmCdma(Context context, int subId) {
+ final int networkMode = android.provider.Settings.Global.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ Phone.PREFERRED_NT_MODE);
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) {
+ if (!isTdscdmaSupported(context, subId) && isWorldMode(context, subId)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/src/com/android/settings/notification/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
index f55c262..2517573 100644
--- a/src/com/android/settings/notification/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
@@ -61,7 +61,10 @@
Context context, AppBubbleNotificationSettings fragment) {
List<NotificationPreferenceController> controllers = new ArrayList<>();
controllers.add(new HeaderPreferenceController(context, fragment));
- controllers.add(new BubblePreferenceController(context, new NotificationBackend()));
+ controllers.add(new BubblePreferenceController(context, fragment != null
+ ? fragment.getChildFragmentManager()
+ : null,
+ new NotificationBackend(), true /* isAppPage */));
return controllers;
}
diff --git a/src/com/android/settings/notification/BubblePreferenceController.java b/src/com/android/settings/notification/BubblePreferenceController.java
index 200c4b2..b68f11d 100644
--- a/src/com/android/settings/notification/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/BubblePreferenceController.java
@@ -18,6 +18,7 @@
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+import android.annotation.Nullable;
import android.content.Context;
import android.provider.Settings;
@@ -40,15 +41,13 @@
static final int SYSTEM_WIDE_OFF = 0;
private FragmentManager mFragmentManager;
+ private boolean mIsAppPage;
- public BubblePreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
- }
-
- public BubblePreferenceController(Context context, FragmentManager fragmentManager,
- NotificationBackend backend) {
+ public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
+ NotificationBackend backend, boolean isAppPage) {
super(context, backend);
mFragmentManager = fragmentManager;
+ mIsAppPage = isAppPage;
}
@Override
@@ -61,7 +60,7 @@
if (!super.isAvailable()) {
return false;
}
- if (!isGloballyEnabled()) {
+ if (!mIsAppPage && !isGloballyEnabled()) {
return false;
}
if (mChannel != null) {
@@ -96,7 +95,7 @@
mChannel.setAllowBubbles(value);
saveChannel();
return true;
- } else if (mAppRow != null) {
+ } else if (mAppRow != null && mFragmentManager != null) {
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
// if the global setting is off, toggling app level permission requires extra
// confirmation
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 9f9d438..8399a49 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -114,7 +114,8 @@
mControllers.add(new BadgePreferenceController(context, mBackend));
mControllers.add(new DndPreferenceController(context, mBackend));
mControllers.add(new NotificationsOffPreferenceController(context));
- mControllers.add(new BubblePreferenceController(context, mBackend));
+ mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
+ mBackend, false /* isAppPage */));
return new ArrayList<>(mControllers);
}
}
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 32d8e91..fdd71e5 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -53,6 +53,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
@@ -279,6 +280,12 @@
return null;
}
+ private Drawable getAlertingIcon() {
+ Drawable icon = getContext().getDrawable(R.drawable.ic_notifications);
+ icon.setTintList(Utils.getColorAccent(getContext()));
+ return icon;
+ }
+
protected Preference populateSingleChannelPrefs(PreferenceGroup parent,
final NotificationChannel channel, final boolean groupBlocked) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
@@ -286,8 +293,10 @@
&& isChannelBlockable(channel)
&& isChannelConfigurable(channel)
&& !groupBlocked);
- channelPref.setIcon(channel.getImportance() > IMPORTANCE_LOW
- ? R.drawable.ic_notification_alert : R.drawable.ic_notification_silence);
+ channelPref.setIcon(null);
+ if (channel.getImportance() > IMPORTANCE_LOW) {
+ channelPref.setIcon(getAlertingIcon());
+ }
channelPref.setIconSize(MasterSwitchPreference.ICON_SIZE_SMALL);
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
@@ -314,9 +323,10 @@
channel.lockFields(
NotificationChannel.USER_LOCKED_IMPORTANCE);
MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference;
- channelPref1.setIcon(channel.getImportance() > IMPORTANCE_LOW
- ? R.drawable.ic_notification_alert
- : R.drawable.ic_notification_silence);
+ channelPref1.setIcon(null);
+ if (channel.getImportance() > IMPORTANCE_LOW) {
+ channelPref1.setIcon(getAlertingIcon());
+ }
toggleBehaviorIconState(channelPref1.getIcon(),
importance != IMPORTANCE_NONE);
mBackend.updateChannel(mPkg, mUid, channel);
@@ -330,9 +340,14 @@
}
private void toggleBehaviorIconState(Drawable icon, boolean enabled) {
+ if (icon == null) return;
+
LayerDrawable layerDrawable = (LayerDrawable) icon;
GradientDrawable background =
(GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.back);
+
+ if (background == null) return;
+
if (enabled) {
background.clearColorFilter();
} else {
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index cf45d57..0e51032 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -300,6 +300,10 @@
private static Slice buildSliderSlice(Context context, SliceData sliceData,
BasePreferenceController controller) {
final SliderPreferenceController sliderController = (SliderPreferenceController) controller;
+ if (sliderController.getMax() <= sliderController.getMin()) {
+ Log.e(TAG, "Invalid sliderController: " + sliderController.getPreferenceKey());
+ return null;
+ }
final PendingIntent actionIntent = getSliderAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 5f3cbb2..5e49b2e 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -54,7 +54,6 @@
import androidx.annotation.VisibleForTesting;
import androidx.core.text.BidiFormatter;
-import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
@@ -151,7 +150,7 @@
private AccessPoint mAccessPoint;
private final ConnectivityManager mConnectivityManager;
- private final Fragment mFragment;
+ private final PreferenceFragmentCompat mFragment;
private final Handler mHandler;
private LinkProperties mLinkProperties;
private Network mNetwork;
@@ -296,7 +295,7 @@
AccessPoint accessPoint,
ConnectivityManager connectivityManager,
Context context,
- Fragment fragment,
+ PreferenceFragmentCompat fragment,
Handler handler,
Lifecycle lifecycle,
WifiManager wifiManager,
@@ -311,7 +310,7 @@
AccessPoint accessPoint,
ConnectivityManager connectivityManager,
Context context,
- Fragment fragment,
+ PreferenceFragmentCompat fragment,
Handler handler,
Lifecycle lifecycle,
WifiManager wifiManager,
@@ -441,9 +440,11 @@
if (usingDataUsageHeader(mContext)) {
mSummaryHeaderController.updateState(mDataUsageSummaryPref);
} else {
- mEntityHeaderController.setSummary(
- mAccessPoint.getSettingsSummary(true /*convertSavedAsDisconnected*/))
- .done(mFragment.getActivity(), true /* rebind */);
+ mEntityHeaderController
+ .setSummary(
+ mAccessPoint.getSettingsSummary(true /*convertSavedAsDisconnected*/))
+ .setRecyclerView(mFragment.getListView(), mLifecycle)
+ .done(mFragment.getActivity(), true /* rebind */);
}
}
diff --git a/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
index afe0848..8165862 100644
--- a/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AllowBackgroundActivityStartsPreferenceControllerTest.java
@@ -115,7 +115,7 @@
public void onDeveloperOptionsSwitchDisabled_noDefault_shouldResetPreference() {
mController.onDeveloperOptionsSwitchDisabled();
- verify(mPreference).setChecked(true);
+ verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false);
assertThat(getModeFroMSettings()).isEqualTo(-1);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
index 023135d..3e6e436 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
@@ -150,6 +150,16 @@
}
@Test
+ public void getSummary_getEmptySubscriptionInfo_shouldShowUnknown() {
+ List<SubscriptionInfo> infos = new ArrayList<>();
+ when(mSubscriptionManager.getActiveSubscriptionInfoList(eq(true))).thenReturn(infos);
+
+ CharSequence primaryNumber = mController.getSummary();
+
+ assertThat(primaryNumber).isEqualTo(mContext.getString(R.string.device_info_default));
+ }
+
+ @Test
public void isSliceable_shouldBeTrue() {
assertThat(mController.isSliceable()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
index 61599e6..2bfaeca 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
@@ -219,4 +219,86 @@
assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
.isTrue();
}
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_notWorldMode_returnFalse() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, false);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_supportTdscdma_returnFalse() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, true);
+
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsm_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaCdmaEvdoGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteCdmaEvdoGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
index 67324e9..aafefb51 100644
--- a/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BubblePreferenceControllerTest.java
@@ -78,6 +78,7 @@
private FragmentManager mFragmentManager;
private BubblePreferenceController mController;
+ private BubblePreferenceController mAppPageController;
@Before
public void setUp() {
@@ -87,7 +88,10 @@
shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
mContext = RuntimeEnvironment.application;
when(mFragmentManager.beginTransaction()).thenReturn(mock(FragmentTransaction.class));
- mController = spy(new BubblePreferenceController(mContext, mFragmentManager, mBackend));
+ mController = spy(new BubblePreferenceController(mContext, mFragmentManager, mBackend,
+ false /* isAppPage */));
+ mAppPageController = spy(new BubblePreferenceController(mContext, mFragmentManager,
+ mBackend, true /* isAppPage */));
}
@Test
@@ -151,6 +155,16 @@
}
@Test
+ public void testIsAvailable_app_evenIfOffGlobally() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ mAppPageController.onResume(appRow, null, null, null);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
+
+ assertTrue(mAppPageController.isAvailable());
+ }
+
+ @Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
mController.onResume(appRow, null, null, null);
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index 2e47930..1db7c8d 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -43,6 +43,7 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeCopyableController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.FakeInvalidSliderController;
import com.android.settings.testutils.FakeSliderController;
import com.android.settings.testutils.FakeToggleController;
import com.android.settings.testutils.FakeUnavailablePreferenceController;
@@ -67,6 +68,7 @@
private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private final Class TOGGLE_CONTROLLER = FakeToggleController.class;
private final Class SLIDER_CONTROLLER = FakeSliderController.class;
+ private final Class INVALID_SLIDER_CONTROLLER = FakeInvalidSliderController.class;
private final Class COPYABLE_CONTROLLER = FakeCopyableController.class;
private final Class CONTEXT_CONTROLLER = FakeContextOnlyPreferenceController.class;
@@ -471,6 +473,14 @@
}
@Test
+ public void buildSliderSlice_invalidSlider_returnNull() {
+ final SliceData data = getDummyData(INVALID_SLIDER_CONTROLLER, SliceData.SliceType.SLIDER,
+ 0x0 /* icon */);
+
+ assertThat(SliceBuilderUtils.buildSlice(mContext, data)).isNull();
+ }
+
+ @Test
public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
final int settingsIcon = R.drawable.ic_settings_accent;
final int zeroIcon = 0x0;
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeInvalidSliderController.java b/tests/robotests/src/com/android/settings/testutils/FakeInvalidSliderController.java
new file mode 100644
index 0000000..cb49f65
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/FakeInvalidSliderController.java
@@ -0,0 +1,31 @@
+/*
+ * 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.testutils;
+
+import android.content.Context;
+
+public class FakeInvalidSliderController extends FakeSliderController {
+
+ public FakeInvalidSliderController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getMax() {
+ // Return 0 to make it invalid
+ return 0;
+ }
+}