From 3f46c5f685447b750cbd8515fe12085a95739c84 Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Tue, 31 Aug 2021 20:28:41 +0800 Subject: [PATCH 1/3] [Provider Model] Add cutout for signal icon if the mobile data is disabled Bug: 198233143 Test: manual, atest ProviderModelSliceHelperTest and SubscriptionsPreferenceControllerTest Change-Id: I8714c9ff4c0c3aa5bad51ad5d41207d50ccca8ef Merged-In: I3caefc7e1ca10dadcad114273edf35d9309502e1 --- .../android/settings/network/ProviderModelSliceHelper.java | 2 +- .../network/SubscriptionsPreferenceController.java | 3 ++- .../settings/network/ProviderModelSliceHelperTest.java | 7 +++++-- .../network/SubscriptionsPreferenceControllerTest.java | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/network/ProviderModelSliceHelper.java b/src/com/android/settings/network/ProviderModelSliceHelper.java index 32a475a7d00..d264fd69d3b 100644 --- a/src/com/android/settings/network/ProviderModelSliceHelper.java +++ b/src/com/android/settings/network/ProviderModelSliceHelper.java @@ -140,7 +140,7 @@ public class ProviderModelSliceHelper { numLevels += 1; } return MobileNetworkUtils.getSignalStrengthIcon(mContext, level, numLevels, - NO_CELL_DATA_TYPE_ICON, false); + NO_CELL_DATA_TYPE_ICON, !mTelephonyManager.isDataEnabled()); } /** diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java index 8e9e946820c..36c55e2805e 100644 --- a/src/com/android/settings/network/SubscriptionsPreferenceController.java +++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java @@ -311,7 +311,8 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl numLevels += 1; } - Drawable icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels, false); + Drawable icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels, + !mTelephonyManager.isDataEnabled()); final boolean isActiveCellularNetwork = mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext); if (isActiveCellularNetwork || (mWifiPickerTrackerHelper != null) diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java index 7d4323051c3..d06426d43b4 100644 --- a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java +++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java @@ -224,8 +224,9 @@ public class ProviderModelSliceHelperTest { public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable { mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "", false, true); - when(mConnectivityManager.getActiveNetwork()).thenReturn(null); Drawable expectDrawable = mock(Drawable.class); + when(mConnectivityManager.getActiveNetwork()).thenReturn(null); + when(mTelephonyManager.isDataEnabled()).thenReturn(false); assertThat(mProviderModelSliceHelper.getMobileDrawable(expectDrawable)).isEqualTo( expectDrawable); @@ -236,8 +237,9 @@ public class ProviderModelSliceHelperTest { throws Throwable { mockConnections(true, ServiceState.STATE_IN_SERVICE, "", true, true); - addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR); Drawable drawable = mock(Drawable.class); + addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); assertThat(mProviderModelSliceHelper.getMobileDrawable(drawable)).isEqualTo( mDrawableWithSignalStrength); @@ -252,6 +254,7 @@ public class ProviderModelSliceHelperTest { true); Drawable drawable = mock(Drawable.class); addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); assertThat(mProviderModelSliceHelper.getMobileDrawable(drawable)).isEqualTo( mDrawableWithSignalStrength); diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java index cb78d19714c..7cffb76f983 100644 --- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java @@ -665,6 +665,7 @@ public class SubscriptionsPreferenceControllerTest { doReturn(true).when(sInjector).isProviderModelEnabled(mContext); doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo(); Drawable icon = mock(Drawable.class); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false)); setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true, true, ServiceState.STATE_IN_SERVICE); @@ -683,6 +684,7 @@ public class SubscriptionsPreferenceControllerTest { doReturn(true).when(sInjector).isProviderModelEnabled(mContext); doReturn(subs.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo(); Drawable icon = mock(Drawable.class); + when(mTelephonyManager.isDataEnabled()).thenReturn(true); doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false)); setupGetIconConditions(subId, false, true, true, ServiceState.STATE_IN_SERVICE); @@ -701,7 +703,8 @@ public class SubscriptionsPreferenceControllerTest { doReturn(true).when(sInjector).isProviderModelEnabled(mContext); doReturn(subs.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo(); Drawable icon = mock(Drawable.class); - doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false)); + when(mTelephonyManager.isDataEnabled()).thenReturn(false); + doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(true)); setupGetIconConditions(subId, false, false, false, ServiceState.STATE_IN_SERVICE); From 6a8cbc9fac99e7161ba7cff53158e393ab718ee3 Mon Sep 17 00:00:00 2001 From: Alex Johnston Date: Mon, 2 Aug 2021 14:16:49 +0100 Subject: [PATCH 2/3] Fix USB tether option * USB tether option will be grayed out before USB cable is plugged in. Bug: 192225597 Test: manual testing Change-Id: Ibc87416b9aecb03f1ddd3df0d9f11a935f3a290e Merged-In: Ibc87416b9aecb03f1ddd3df0d9f11a935f3a290e (cherry picked from commit 685cacb54068bedaface37de1ce706ca4ab11cfd) --- src/com/android/settings/TetherSettings.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java index ab1c437271f..1a21b5582a9 100644 --- a/src/com/android/settings/TetherSettings.java +++ b/src/com/android/settings/TetherSettings.java @@ -55,6 +55,7 @@ import com.android.settings.core.FeatureFlags; import com.android.settings.datausage.DataSaverBackend; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.wifi.tether.WifiTetherPreferenceController; +import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedSwitchPreference; import com.android.settingslib.TetherUtil; import com.android.settingslib.search.SearchIndexable; @@ -425,14 +426,16 @@ public class TetherSettings extends RestrictedSettingsFragment private void updateUsbPreference() { boolean usbAvailable = mUsbConnected && !mMassStorageActive; + final RestrictedLockUtils.EnforcedAdmin enforcedAdmin = + checkIfUsbDataSignalingIsDisabled(mContext, UserHandle.myUserId()); - if (usbAvailable) { + if (enforcedAdmin != null) { + mUsbTether.setDisabledByAdmin(enforcedAdmin); + } else if (usbAvailable) { mUsbTether.setEnabled(!mDataSaverEnabled); } else { mUsbTether.setEnabled(false); } - mUsbTether.setDisabledByAdmin( - checkIfUsbDataSignalingIsDisabled(mContext, UserHandle.myUserId())); } @VisibleForTesting From 446f6dd886124f3df21f33cd74124b8b1ed48a24 Mon Sep 17 00:00:00 2001 From: Stanley Wang Date: Tue, 21 Dec 2021 17:25:38 +0800 Subject: [PATCH 3/3] Restore the style of the screen saver widget from switch style to button style. The operation of the Switch is not suitable for previewing the screen saver and will make the user confused. So we change the style of the screen saver widget back to the button style. Fix: 189505023 Test: manually test the screen saver Change-Id: I4a97d91cc0b76111d4cb7b6aa202f2207ee0ca5d --- res/layout/dream_start_button.xml | 36 +++++++++++++++++ res/values/strings.xml | 4 +- res/xml/dream_fragment_overview.xml | 13 +++--- .../dream/StartNowPreferenceController.java | 40 +++++++++---------- .../StartNowPreferenceControllerTest.java | 32 +++++++-------- 5 files changed, 78 insertions(+), 47 deletions(-) create mode 100644 res/layout/dream_start_button.xml diff --git a/res/layout/dream_start_button.xml b/res/layout/dream_start_button.xml new file mode 100644 index 00000000000..17ba78dbb7a --- /dev/null +++ b/res/layout/dream_start_button.xml @@ -0,0 +1,36 @@ + + + + + +