Merge "[Provider model] Show a string on internet picker when mobile data off" into sc-dev
This commit is contained in:
@@ -35,6 +35,7 @@ import android.telephony.SubscriptionInfo;
|
|||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyDisplayInfo;
|
import android.telephony.TelephonyDisplayInfo;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.Html;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -255,14 +256,17 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
|||||||
mUpdateListener.onChildrenUpdated();
|
mUpdateListener.onChildrenUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMobilePreferenceSummary(int subId) {
|
private CharSequence getMobilePreferenceSummary(int subId) {
|
||||||
String result = mSubsPrefCtrlInjector.getNetworkType(
|
String result = mSubsPrefCtrlInjector.getNetworkType(
|
||||||
mContext, mConfig, mTelephonyDisplayInfo, subId);
|
mContext, mConfig, mTelephonyDisplayInfo, subId);
|
||||||
|
if (!mTelephonyManager.isDataEnabled()) {
|
||||||
|
return mContext.getString(R.string.mobile_data_off_summary);
|
||||||
|
}
|
||||||
if (!result.isEmpty() && mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext)) {
|
if (!result.isEmpty() && mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext)) {
|
||||||
result = mContext.getString(R.string.preference_summary_default_combination,
|
result = mContext.getString(R.string.preference_summary_default_combination,
|
||||||
mContext.getString(R.string.mobile_data_connection_active), result);
|
mContext.getString(R.string.mobile_data_connection_active), result);
|
||||||
}
|
}
|
||||||
return result;
|
return Html.fromHtml(result, Html.FROM_HTML_MODE_LEGACY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getIcon(int subId) {
|
private Drawable getIcon(int subId) {
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.network;
|
package com.android.settings.network;
|
||||||
|
|
||||||
import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
|
|
||||||
import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GOOD;
|
import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GOOD;
|
||||||
import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GREAT;
|
import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GREAT;
|
||||||
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
@@ -24,6 +23,7 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;;
|
import static org.mockito.ArgumentMatchers.eq;;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
@@ -47,6 +47,7 @@ import android.telephony.SubscriptionInfo;
|
|||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyDisplayInfo;
|
import android.telephony.TelephonyDisplayInfo;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.Html;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
import androidx.lifecycle.LifecycleRegistry;
|
import androidx.lifecycle.LifecycleRegistry;
|
||||||
@@ -371,14 +372,14 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
final Preference pref = new Preference(mContext);
|
final Preference pref = new Preference(mContext);
|
||||||
final Drawable greatDrawWithoutCutOff = mock(Drawable.class);
|
final Drawable greatDrawWithoutCutOff = mock(Drawable.class);
|
||||||
doReturn(greatDrawWithoutCutOff).when(sInjector)
|
doReturn(greatDrawWithoutCutOff).when(sInjector)
|
||||||
.getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true);
|
.getIcon(any(), anyInt(), anyInt(), anyBoolean());
|
||||||
|
|
||||||
mController.setIcon(pref, 1, true /* isDefaultForData */);
|
mController.setIcon(pref, 1, true /* isDefaultForData */);
|
||||||
assertThat(pref.getIcon()).isEqualTo(greatDrawWithoutCutOff);
|
assertThat(pref.getIcon()).isEqualTo(greatDrawWithoutCutOff);
|
||||||
|
|
||||||
final Drawable greatDrawWithCutOff = mock(Drawable.class);
|
final Drawable greatDrawWithCutOff = mock(Drawable.class);
|
||||||
doReturn(greatDrawWithCutOff).when(sInjector)
|
doReturn(greatDrawWithCutOff).when(sInjector)
|
||||||
.getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true);
|
.getIcon(any(), anyInt(), anyInt(), anyBoolean());
|
||||||
mController.setIcon(pref, 2, false /* isDefaultForData */);
|
mController.setIcon(pref, 2, false /* isDefaultForData */);
|
||||||
assertThat(pref.getIcon()).isEqualTo(greatDrawWithCutOff);
|
assertThat(pref.getIcon()).isEqualTo(greatDrawWithCutOff);
|
||||||
}
|
}
|
||||||
@@ -416,7 +417,8 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void displayPreference_providerAndHasMultiSimAndActive_connectedAndRat() {
|
public void displayPreference_providerAndHasMultiSimAndActive_connectedAndRat() {
|
||||||
final String expectedSummary = "Connected / 5G";
|
final CharSequence expectedSummary =
|
||||||
|
Html.fromHtml("Connected / 5G", Html.FROM_HTML_MODE_LEGACY);
|
||||||
final String networkType = "5G";
|
final String networkType = "5G";
|
||||||
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
@@ -426,6 +428,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
|
||||||
|
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
@@ -435,8 +438,11 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() {
|
public void displayPreference_providerAndHasMultiSimButMobileDataOff_notAutoConnect() {
|
||||||
final String expectedSummary = "5G";
|
final String dataOffSummary =
|
||||||
|
ResourcesUtils.getResourcesString(mContext, "mobile_data_off_summary");
|
||||||
|
final CharSequence expectedSummary =
|
||||||
|
Html.fromHtml(dataOffSummary, Html.FROM_HTML_MODE_LEGACY);
|
||||||
final String networkType = "5G";
|
final String networkType = "5G";
|
||||||
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
@@ -449,6 +455,27 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
|
|
||||||
|
assertThat(mPreferenceCategory.getPreference(0).getSummary())
|
||||||
|
.isEqualTo(expectedSummary.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() {
|
||||||
|
final CharSequence expectedSummary = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
|
||||||
|
final String networkType = "5G";
|
||||||
|
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
||||||
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
|
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
||||||
|
doReturn(networkType)
|
||||||
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
|
||||||
|
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
||||||
|
|
||||||
|
mController.onResume();
|
||||||
|
mController.displayPreference(mPreferenceScreen);
|
||||||
|
|
||||||
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,7 +494,8 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndActive_connectedAndRat() {
|
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndActive_connectedAndRat() {
|
||||||
final String expectedSummary = "Connected / LTE";
|
final CharSequence expectedSummary =
|
||||||
|
Html.fromHtml("Connected / LTE", Html.FROM_HTML_MODE_LEGACY);
|
||||||
final String networkType = "LTE";
|
final String networkType = "LTE";
|
||||||
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
||||||
final TelephonyDisplayInfo telephonyDisplayInfo =
|
final TelephonyDisplayInfo telephonyDisplayInfo =
|
||||||
@@ -480,6 +508,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
|
||||||
|
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
@@ -491,7 +520,8 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() {
|
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() {
|
||||||
final String expectedSummary = "LTE";
|
final CharSequence expectedSummary =
|
||||||
|
Html.fromHtml("LTE", Html.FROM_HTML_MODE_LEGACY);
|
||||||
final String networkType = "LTE";
|
final String networkType = "LTE";
|
||||||
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
|
||||||
final TelephonyDisplayInfo telephonyDisplayInfo =
|
final TelephonyDisplayInfo telephonyDisplayInfo =
|
||||||
@@ -504,6 +534,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
|
||||||
|
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
|
Reference in New Issue
Block a user