Merge "[Provider Model] Add cutout for signal icon if the mobile data is disabled" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-12-22 02:43:04 +00:00
committed by Android (Google) Code Review
4 changed files with 12 additions and 5 deletions

View File

@@ -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());
}
/**

View File

@@ -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)

View File

@@ -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);

View File

@@ -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);