Merge "Ui show "No connection" when WiFi is turned on and no available network" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
03fbae7fc5
@@ -24,7 +24,6 @@ import android.graphics.Color;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -75,8 +74,79 @@ public class ProviderModelSliceHelper {
|
|||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void log(String s) {
|
/**
|
||||||
Log.d(TAG, s);
|
* @return whether there is the carrier item in the slice.
|
||||||
|
*/
|
||||||
|
public boolean hasCarrier() {
|
||||||
|
if (isAirplaneModeEnabled()
|
||||||
|
|| mSubscriptionManager == null || mTelephonyManager == null
|
||||||
|
|| mSubscriptionManager.getDefaultDataSubscriptionId()
|
||||||
|
== mSubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return whether the MobileData's is enabled.
|
||||||
|
*/
|
||||||
|
public boolean isMobileDataEnabled() {
|
||||||
|
return mTelephonyManager.isDataEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To check the carrier data status.
|
||||||
|
*
|
||||||
|
* @return whether the carrier data is active.
|
||||||
|
*/
|
||||||
|
public boolean isDataSimActive() {
|
||||||
|
return MobileNetworkUtils.activeNetworkIsCellular(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return whether the ServiceState's data state is in-service.
|
||||||
|
*/
|
||||||
|
public boolean isDataStateInService() {
|
||||||
|
return mTelephonyManager.getDataState() == mTelephonyManager.DATA_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return whether the ServiceState's voice state is in-service.
|
||||||
|
*/
|
||||||
|
public boolean isVoiceStateInService() {
|
||||||
|
final ServiceState serviceState = mTelephonyManager.getServiceState();
|
||||||
|
return serviceState != null
|
||||||
|
&& serviceState.getState() == serviceState.STATE_IN_SERVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To get the signal bar icon with level.
|
||||||
|
*
|
||||||
|
* @return The Drawable which is a signal bar icon with level.
|
||||||
|
*/
|
||||||
|
public Drawable getDrawableWithSignalStrength() {
|
||||||
|
final SignalStrength strength = mTelephonyManager.getSignalStrength();
|
||||||
|
int level = (strength == null) ? 0 : strength.getLevel();
|
||||||
|
int numLevels = SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
|
||||||
|
if (mSubscriptionManager != null && shouldInflateSignalStrength(
|
||||||
|
mSubscriptionManager.getDefaultDataSubscriptionId())) {
|
||||||
|
level += 1;
|
||||||
|
numLevels += 1;
|
||||||
|
}
|
||||||
|
return MobileNetworkUtils.getSignalStrengthIcon(mContext, level, numLevels,
|
||||||
|
NO_CELL_DATA_TYPE_ICON, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To update the telephony with subid.
|
||||||
|
*/
|
||||||
|
public void updateTelephony() {
|
||||||
|
if (mSubscriptionManager == null || mSubscriptionManager.getDefaultDataSubscriptionId()
|
||||||
|
== mSubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mTelephonyManager = mTelephonyManager.createForSubscriptionId(
|
||||||
|
mSubscriptionManager.getDefaultDataSubscriptionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ListBuilder createListBuilder(Uri uri) {
|
protected ListBuilder createListBuilder(Uri uri) {
|
||||||
@@ -97,19 +167,6 @@ public class ProviderModelSliceHelper {
|
|||||||
return item.isPresent() ? item.get() : null;
|
return item.isPresent() ? item.get() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return whether there is the carrier item in the slice.
|
|
||||||
*/
|
|
||||||
public boolean hasCarrier() {
|
|
||||||
if (isAirplaneModeEnabled()
|
|
||||||
|| mSubscriptionManager == null || mTelephonyManager == null
|
|
||||||
|| mSubscriptionManager.getDefaultDataSubscriptionId()
|
|
||||||
== mSubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ListBuilder.RowBuilder createCarrierRow(String networkTypeDescription) {
|
protected ListBuilder.RowBuilder createCarrierRow(String networkTypeDescription) {
|
||||||
final String title = getMobileTitle();
|
final String title = getMobileTitle();
|
||||||
final String summary = getMobileSummary(networkTypeDescription);
|
final String summary = getMobileSummary(networkTypeDescription);
|
||||||
@@ -142,6 +199,18 @@ public class ProviderModelSliceHelper {
|
|||||||
ListBuilder.ICON_IMAGE, mContext.getText(R.string.summary_placeholder));
|
ListBuilder.ICON_IMAGE, mContext.getText(R.string.summary_placeholder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isAirplaneModeEnabled() {
|
||||||
|
return WirelessUtils.isAirplaneModeOn(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SubscriptionManager getSubscriptionManager() {
|
||||||
|
return mSubscriptionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void log(String s) {
|
||||||
|
Log.d(TAG, s);
|
||||||
|
}
|
||||||
|
|
||||||
private PendingIntent getPrimaryAction(String intentAction) {
|
private PendingIntent getPrimaryAction(String intentAction) {
|
||||||
final Intent intent = new Intent(intentAction)
|
final Intent intent = new Intent(intentAction)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
@@ -153,40 +222,6 @@ public class ProviderModelSliceHelper {
|
|||||||
return SignalStrengthUtil.shouldInflateSignalStrength(mContext, subId);
|
return SignalStrengthUtil.shouldInflateSignalStrength(mContext, subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAirplaneModeEnabled() {
|
|
||||||
return WirelessUtils.isAirplaneModeOn(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isMobileDataEnabled() {
|
|
||||||
if (mTelephonyManager == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return mTelephonyManager.isDataEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To check the carrier data status.
|
|
||||||
*
|
|
||||||
* @return whether the carrier data is active.
|
|
||||||
*/
|
|
||||||
public boolean isDataSimActive() {
|
|
||||||
return isNoCarrierData() ? false : MobileNetworkUtils.activeNetworkIsCellular(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isNoCarrierData() {
|
|
||||||
if (mTelephonyManager == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
boolean mobileDataOnAndNoData = isMobileDataEnabled()
|
|
||||||
&& mTelephonyManager.getDataState() != mTelephonyManager.DATA_CONNECTED;
|
|
||||||
ServiceState serviceState = mTelephonyManager.getServiceState();
|
|
||||||
boolean mobileDataOffAndOutOfService = !isMobileDataEnabled() && serviceState != null
|
|
||||||
&& serviceState.getState() == serviceState.STATE_OUT_OF_SERVICE;
|
|
||||||
log("mobileDataOnAndNoData: " + mobileDataOnAndNoData
|
|
||||||
+ ",mobileDataOffAndOutOfService: " + mobileDataOffAndOutOfService);
|
|
||||||
return mobileDataOnAndNoData || mobileDataOffAndOutOfService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Drawable getMobileDrawable(Drawable drawable) throws Throwable {
|
Drawable getMobileDrawable(Drawable drawable) throws Throwable {
|
||||||
// set color and drawable
|
// set color and drawable
|
||||||
@@ -194,7 +229,7 @@ public class ProviderModelSliceHelper {
|
|||||||
log("mTelephonyManager == null");
|
log("mTelephonyManager == null");
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
if (!isNoCarrierData()) {
|
if (isDataStateInService() || isVoiceStateInService()) {
|
||||||
Semaphore lock = new Semaphore(0);
|
Semaphore lock = new Semaphore(0);
|
||||||
AtomicReference<Drawable> shared = new AtomicReference<>();
|
AtomicReference<Drawable> shared = new AtomicReference<>();
|
||||||
ThreadUtils.postOnMainThread(() -> {
|
ThreadUtils.postOnMainThread(() -> {
|
||||||
@@ -213,35 +248,18 @@ public class ProviderModelSliceHelper {
|
|||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To get the signal bar icon with level.
|
|
||||||
*
|
|
||||||
* @return The Drawable which is a signal bar icon with level.
|
|
||||||
*/
|
|
||||||
public Drawable getDrawableWithSignalStrength() {
|
|
||||||
final SignalStrength strength = mTelephonyManager.getSignalStrength();
|
|
||||||
int level = (strength == null) ? 0 : strength.getLevel();
|
|
||||||
int numLevels = SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
|
|
||||||
if (mSubscriptionManager != null && shouldInflateSignalStrength(
|
|
||||||
mSubscriptionManager.getDefaultDataSubscriptionId())) {
|
|
||||||
level += 1;
|
|
||||||
numLevels += 1;
|
|
||||||
}
|
|
||||||
return MobileNetworkUtils.getSignalStrengthIcon(mContext, level, numLevels,
|
|
||||||
NO_CELL_DATA_TYPE_ICON, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMobileSummary(String networkTypeDescription) {
|
private String getMobileSummary(String networkTypeDescription) {
|
||||||
final WifiManager wifiManager = mContext.getSystemService(WifiManager.class);
|
if (!isMobileDataEnabled()) {
|
||||||
|
return mContext.getString(R.string.mobile_data_off_summary);
|
||||||
|
}
|
||||||
|
if (!isDataStateInService()) {
|
||||||
|
return mContext.getString(R.string.mobile_data_no_connection);
|
||||||
|
}
|
||||||
String summary = networkTypeDescription;
|
String summary = networkTypeDescription;
|
||||||
if (isDataSimActive()) {
|
if (isDataSimActive()) {
|
||||||
summary = mContext.getString(R.string.preference_summary_default_combination,
|
summary = mContext.getString(R.string.preference_summary_default_combination,
|
||||||
mContext.getString(R.string.mobile_data_connection_active),
|
mContext.getString(R.string.mobile_data_connection_active),
|
||||||
networkTypeDescription);
|
networkTypeDescription);
|
||||||
} else if (!isMobileDataEnabled()) {
|
|
||||||
summary = mContext.getString(R.string.mobile_data_off_summary);
|
|
||||||
} else if (!wifiManager.isWifiEnabled() && !isDataSimActive()) {
|
|
||||||
summary = mContext.getString(R.string.mobile_data_no_connection);
|
|
||||||
}
|
}
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
@@ -260,26 +278,10 @@ public class ProviderModelSliceHelper {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SubscriptionManager getSubscriptionManager() {
|
|
||||||
return mSubscriptionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> getKeywords() {
|
private Set<String> getKeywords() {
|
||||||
final String keywords = mContext.getString(R.string.keywords_internet);
|
final String keywords = mContext.getString(R.string.keywords_internet);
|
||||||
return Arrays.stream(TextUtils.split(keywords, ","))
|
return Arrays.stream(TextUtils.split(keywords, ","))
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To update the telephony with subid.
|
|
||||||
*/
|
|
||||||
public void updateTelephony() {
|
|
||||||
if (mSubscriptionManager == null || mSubscriptionManager.getDefaultDataSubscriptionId()
|
|
||||||
== mSubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(
|
|
||||||
mSubscriptionManager.getDefaultDataSubscriptionId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -301,21 +301,37 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
||||||
if (wifiList != null && wifiList.size() == 0) {
|
if (wifiList != null && wifiList.size() != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Sub-Title:
|
// Sub-Title:
|
||||||
// show non_carrier_network_unavailable
|
// show non_carrier_network_unavailable
|
||||||
// - while Wi-Fi on + no Wi-Fi item
|
// - while Wi-Fi on + no Wi-Fi item
|
||||||
|
// - while Wi-Fi on + no Wi-Fi item + mobile data off
|
||||||
// show all_network_unavailable:
|
// show all_network_unavailable:
|
||||||
// - while Wi-Fi on + no Wi-Fi item + no carrier
|
// - while Wi-Fi on + no Wi-Fi item + no carrier item
|
||||||
// - while Wi-Fi on + no Wi-Fi item + no data capability
|
// - while Wi-Fi on + no Wi-Fi item + service is out of service
|
||||||
|
// - while Wi-Fi on + no Wi-Fi item + mobile data on + no carrier data.
|
||||||
log("No Wi-Fi item.");
|
log("No Wi-Fi item.");
|
||||||
mSubtitle = SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE;
|
|
||||||
if (!mProviderModelSliceHelper.hasCarrier()
|
if (!mProviderModelSliceHelper.hasCarrier()
|
||||||
|| !mProviderModelSliceHelper.isDataSimActive()) {
|
|| (!mProviderModelSliceHelper.isVoiceStateInService()
|
||||||
log("No carrier item or no carrier data.");
|
&& !mProviderModelSliceHelper.isDataStateInService())) {
|
||||||
|
log("no carrier or service is out of service.");
|
||||||
mSubtitle = SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE;
|
mSubtitle = SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (!mProviderModelSliceHelper.isMobileDataEnabled()) {
|
||||||
|
log("mobile data off");
|
||||||
|
mSubtitle = SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (!mProviderModelSliceHelper.isDataSimActive()) {
|
||||||
|
log("no carrier data.");
|
||||||
|
mSubtitle = SUBTITLE_TEXT_ALL_CARRIER_NETWORK_UNAVAILABLE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mSubtitle = SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NetworkProviderTelephonyCallback extends TelephonyCallback implements
|
private class NetworkProviderTelephonyCallback extends TelephonyCallback implements
|
||||||
|
@@ -218,38 +218,6 @@ public class ProviderModelSliceHelperTest {
|
|||||||
assertThat(testRowBuild.getSubtitle()).isEqualTo(expectedSubtitle);
|
assertThat(testRowBuild.getSubtitle()).isEqualTo(expectedSubtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isNoCarrierData_mobileDataOnAndNoData_returnTrue() {
|
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, "",
|
|
||||||
mTelephonyManager.DATA_DISCONNECTED, true);
|
|
||||||
|
|
||||||
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isNoCarrierData_mobileDataOffAndOutOfService_returnTrue() {
|
|
||||||
mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
|
|
||||||
mTelephonyManager.DATA_DISCONNECTED, true);
|
|
||||||
|
|
||||||
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isNoCarrierData_mobileDataOnAndDataConnected_returnFalse() {
|
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
|
|
||||||
true);
|
|
||||||
|
|
||||||
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isNoCarrierData_mobileDataOffAndVoiceIsInService_returnFalse() {
|
|
||||||
mockConnections(false, ServiceState.STATE_IN_SERVICE, "",
|
|
||||||
mTelephonyManager.DATA_DISCONNECTED, true);
|
|
||||||
|
|
||||||
assertThat(mProviderModelSliceHelper.isNoCarrierData()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
|
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
|
||||||
mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
|
mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
|
||||||
|
@@ -129,7 +129,7 @@ public class InternetConnectivityPanelTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSubTitle_apmOffWifiOnNoWifiListHasCarrierData_NonCarrierNetworkUnavailable() {
|
public void getSubTitle_apmOffWifiOnNoWifiListHasCarrierData_NonCarrierNetworkUnavailable() {
|
||||||
List wifiList = new ArrayList<ScanResult>();
|
List wifiList = new ArrayList<ScanResult>();
|
||||||
mockCondition(false, true, true, true, wifiList);
|
mockCondition(false, true, true, true, true, true, wifiList);
|
||||||
|
|
||||||
mPanel.updatePanelTitle();
|
mPanel.updatePanelTitle();
|
||||||
|
|
||||||
@@ -137,9 +137,29 @@ public class InternetConnectivityPanelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubTitle_apmOffWifiOnNoWifiListNoCarrierData_AllNetworkUnavailable() {
|
public void getSubTitle_apmOffWifiOnNoWifiListNoCarrierItem_AllNetworkUnavailable() {
|
||||||
List wifiList = new ArrayList<ScanResult>();
|
List wifiList = new ArrayList<ScanResult>();
|
||||||
mockCondition(false, true, false, true, wifiList);
|
mockCondition(false, false, false, false, false, true, wifiList);
|
||||||
|
|
||||||
|
mPanel.updatePanelTitle();
|
||||||
|
|
||||||
|
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_ALL_NETWORK_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSubTitle_apmOffWifiOnNoWifiListNoDataSimActive_AllNetworkUnavailable() {
|
||||||
|
List wifiList = new ArrayList<ScanResult>();
|
||||||
|
mockCondition(false, true, false, true, true, true, wifiList);
|
||||||
|
|
||||||
|
mPanel.updatePanelTitle();
|
||||||
|
|
||||||
|
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_ALL_NETWORK_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSubTitle_apmOffWifiOnNoWifiListNoService_AllNetworkUnavailable() {
|
||||||
|
List wifiList = new ArrayList<ScanResult>();
|
||||||
|
mockCondition(false, true, false, true, false, true, wifiList);
|
||||||
|
|
||||||
mPanel.updatePanelTitle();
|
mPanel.updatePanelTitle();
|
||||||
|
|
||||||
@@ -151,7 +171,7 @@ public class InternetConnectivityPanelTest {
|
|||||||
List wifiList = new ArrayList<ScanResult>();
|
List wifiList = new ArrayList<ScanResult>();
|
||||||
wifiList.add(new ScanResult());
|
wifiList.add(new ScanResult());
|
||||||
wifiList.add(new ScanResult());
|
wifiList.add(new ScanResult());
|
||||||
mockCondition(false, true, false, true, wifiList);
|
mockCondition(false, true, false, true, true, true, wifiList);
|
||||||
|
|
||||||
mPanel.updatePanelTitle();
|
mPanel.updatePanelTitle();
|
||||||
|
|
||||||
@@ -184,7 +204,7 @@ public class InternetConnectivityPanelTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getSlices_providerModelDisabled_containsNecessarySlices() {
|
public void getSlices_providerModelDisabled_containsNecessarySlices() {
|
||||||
mPanel.mIsProviderModelEnabled = false;
|
mPanel.mIsProviderModelEnabled = false;
|
||||||
final List<Uri> uris = mPanel.getSlices();
|
List<Uri> uris = mPanel.getSlices();
|
||||||
|
|
||||||
assertThat(uris).containsExactly(
|
assertThat(uris).containsExactly(
|
||||||
AirplaneModePreferenceController.SLICE_URI,
|
AirplaneModePreferenceController.SLICE_URI,
|
||||||
@@ -194,7 +214,7 @@ public class InternetConnectivityPanelTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSlices_providerModelEnabled_containsNecessarySlices() {
|
public void getSlices_providerModelEnabled_containsNecessarySlices() {
|
||||||
final List<Uri> uris = mPanel.getSlices();
|
List<Uri> uris = mPanel.getSlices();
|
||||||
|
|
||||||
assertThat(uris).containsExactly(
|
assertThat(uris).containsExactly(
|
||||||
CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI,
|
CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI,
|
||||||
@@ -291,10 +311,14 @@ public class InternetConnectivityPanelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mockCondition(boolean airplaneMode, boolean hasCarrier,
|
private void mockCondition(boolean airplaneMode, boolean hasCarrier,
|
||||||
boolean isDataSimActive, boolean isWifiEnabled, List<ScanResult> wifiItems) {
|
boolean isDataSimActive, boolean isMobileDataEnabled, boolean isServiceInService,
|
||||||
|
boolean isWifiEnabled, List<ScanResult> wifiItems) {
|
||||||
doReturn(airplaneMode).when(mInternetUpdater).isAirplaneModeOn();
|
doReturn(airplaneMode).when(mInternetUpdater).isAirplaneModeOn();
|
||||||
when(mProviderModelSliceHelper.hasCarrier()).thenReturn(hasCarrier);
|
when(mProviderModelSliceHelper.hasCarrier()).thenReturn(hasCarrier);
|
||||||
when(mProviderModelSliceHelper.isDataSimActive()).thenReturn(isDataSimActive);
|
when(mProviderModelSliceHelper.isDataSimActive()).thenReturn(isDataSimActive);
|
||||||
|
when(mProviderModelSliceHelper.isMobileDataEnabled()).thenReturn(isMobileDataEnabled);
|
||||||
|
when(mProviderModelSliceHelper.isDataStateInService()).thenReturn(isServiceInService);
|
||||||
|
when(mProviderModelSliceHelper.isVoiceStateInService()).thenReturn(isServiceInService);
|
||||||
doReturn(isWifiEnabled).when(mInternetUpdater).isWifiEnabled();
|
doReturn(isWifiEnabled).when(mInternetUpdater).isWifiEnabled();
|
||||||
doReturn(wifiItems).when(mWifiManager).getScanResults();
|
doReturn(wifiItems).when(mWifiManager).getScanResults();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user