Merge "Only show no internet icons when no other network available" into sc-dev
This commit is contained in:
@@ -383,8 +383,15 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
int qsTypeIcon = 0;
|
||||
IconState qsIcon = null;
|
||||
CharSequence description = null;
|
||||
// Mobile icon will only be shown in the statusbar in 2 scenarios
|
||||
// 1. Mobile is the default network, and it is validated
|
||||
// 2. Mobile is the default network, it is not validated and there is no other
|
||||
// non-Carrier WiFi networks available.
|
||||
boolean maybeShowIcons = (mCurrentState.inetCondition == 1)
|
||||
|| (mCurrentState.inetCondition == 0
|
||||
&& !mNetworkController.isNonCarrierWifiNetworkAvailable());
|
||||
// Only send data sim callbacks to QS.
|
||||
if (mCurrentState.dataSim && mCurrentState.isDefault) {
|
||||
if (mCurrentState.dataSim && mCurrentState.isDefault && maybeShowIcons) {
|
||||
qsTypeIcon =
|
||||
(showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.qsDataType : 0;
|
||||
qsIcon = new IconState(mCurrentState.enabled
|
||||
@@ -397,7 +404,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
boolean activityOut = mCurrentState.dataConnected
|
||||
&& !mCurrentState.carrierNetworkChangeMode
|
||||
&& mCurrentState.activityOut;
|
||||
showDataIcon &= mCurrentState.dataSim && mCurrentState.isDefault;
|
||||
showDataIcon &= mCurrentState.dataSim && mCurrentState.isDefault && maybeShowIcons;
|
||||
boolean showTriangle = showDataIcon && !mCurrentState.airplaneMode;
|
||||
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
|
||||
showDataIcon |= mCurrentState.roaming;
|
||||
|
||||
@@ -547,6 +547,10 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
return mWifiSignalController.isCarrierMergedWifi(subId);
|
||||
}
|
||||
|
||||
boolean isNonCarrierWifiNetworkAvailable() {
|
||||
return !mNoNetworksAvailable;
|
||||
}
|
||||
|
||||
boolean isEthernetDefault() {
|
||||
return mConnectedTransports.get(NetworkCapabilities.TRANSPORT_ETHERNET);
|
||||
}
|
||||
@@ -908,6 +912,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
return true;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setNoNetworksAvailable(boolean noNetworksAvailable) {
|
||||
mNoNetworksAvailable = noNetworksAvailable;
|
||||
}
|
||||
|
||||
private void updateAirplaneMode(boolean force) {
|
||||
boolean airplaneMode = (Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.AIRPLANE_MODE_ON, 0) == 1);
|
||||
|
||||
@@ -106,10 +106,18 @@ public class WifiSignalController extends
|
||||
if (mCurrentState.inetCondition == 0) {
|
||||
contentDescription += ("," + mContext.getString(R.string.data_connection_no_internet));
|
||||
}
|
||||
IconState statusIcon = new IconState(wifiVisible, getCurrentIconId(), contentDescription);
|
||||
if (mProviderModel) {
|
||||
// WiFi icon will only be shown in the statusbar in 2 scenarios
|
||||
// 1. WiFi is the default network, and it is validated
|
||||
// 2. WiFi is the default network, it is not validated and there is no other
|
||||
// non-Carrier WiFi networks available.
|
||||
boolean maybeShowIcons = (mCurrentState.inetCondition == 1)
|
||||
|| (mCurrentState.inetCondition == 0
|
||||
&& !mNetworkController.isNonCarrierWifiNetworkAvailable());
|
||||
IconState statusIcon = new IconState(
|
||||
wifiVisible && maybeShowIcons, getCurrentIconId(), contentDescription);
|
||||
IconState qsIcon = null;
|
||||
if (mCurrentState.isDefault || (!mNetworkController.isRadioOn()
|
||||
if ((mCurrentState.isDefault && maybeShowIcons) || (!mNetworkController.isRadioOn()
|
||||
&& !mNetworkController.isEthernetDefault())) {
|
||||
qsIcon = new IconState(mCurrentState.connected,
|
||||
mWifiTracker.isCaptivePortal ? R.drawable.ic_qs_wifi_disconnected
|
||||
@@ -123,6 +131,8 @@ public class WifiSignalController extends
|
||||
);
|
||||
callback.setWifiIndicators(wifiIndicators);
|
||||
} else {
|
||||
IconState statusIcon = new IconState(
|
||||
wifiVisible, getCurrentIconId(), contentDescription);
|
||||
IconState qsIcon = new IconState(mCurrentState.connected,
|
||||
mWifiTracker.isCaptivePortal ? R.drawable.ic_qs_wifi_disconnected
|
||||
: getQsCurrentIconId(), contentDescription);
|
||||
@@ -146,15 +156,25 @@ public class WifiSignalController extends
|
||||
if (mCurrentState.inetCondition == 0) {
|
||||
dataContentDescription = mContext.getString(R.string.data_connection_no_internet);
|
||||
}
|
||||
boolean qsVisible = mCurrentState.enabled
|
||||
&& (mCurrentState.connected && mCurrentState.inetCondition == 1);
|
||||
|
||||
// Mobile icon will only be shown in the statusbar in 2 scenarios
|
||||
// 1. Mobile is the default network, and it is validated
|
||||
// 2. Mobile is the default network, it is not validated and there is no other
|
||||
// non-Carrier WiFi networks available.
|
||||
boolean maybeShowIcons = (mCurrentState.inetCondition == 1)
|
||||
|| (mCurrentState.inetCondition == 0
|
||||
&& !mNetworkController.isNonCarrierWifiNetworkAvailable());
|
||||
boolean sbVisible = mCurrentState.enabled && mCurrentState.connected
|
||||
&& maybeShowIcons && mCurrentState.isDefault;
|
||||
IconState statusIcon =
|
||||
new IconState(qsVisible, getCurrentIconIdForCarrierWifi(), contentDescription);
|
||||
int qsTypeIcon = mCurrentState.connected ? icons.qsDataType : 0;
|
||||
int typeIcon = mCurrentState.connected ? icons.dataType : 0;
|
||||
IconState qsIcon = new IconState(
|
||||
mCurrentState.connected, getQsCurrentIconIdForCarrierWifi(), contentDescription);
|
||||
new IconState(sbVisible, getCurrentIconIdForCarrierWifi(), contentDescription);
|
||||
int typeIcon = sbVisible ? icons.dataType : 0;
|
||||
int qsTypeIcon = 0;
|
||||
IconState qsIcon = null;
|
||||
if (sbVisible) {
|
||||
qsTypeIcon = icons.qsDataType;
|
||||
qsIcon = new IconState(mCurrentState.connected, getQsCurrentIconIdForCarrierWifi(),
|
||||
contentDescription);
|
||||
}
|
||||
CharSequence description =
|
||||
mNetworkController.getNetworkNameForCarrierWiFi(mCurrentState.subId);
|
||||
MobileDataIndicators mobileDataIndicators = new MobileDataIndicators(
|
||||
|
||||
@@ -372,6 +372,8 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
new NetworkCapabilities(mNetCapabilities), new LinkProperties(), false);
|
||||
mNetworkCallback.onCapabilitiesChanged(
|
||||
mock(Network.class), new NetworkCapabilities(mNetCapabilities));
|
||||
mDefaultCallbackInWifiTracker.onCapabilitiesChanged(
|
||||
mock(Network.class), new NetworkCapabilities(mNetCapabilities));
|
||||
} else {
|
||||
mNetworkCallback.onLost(mock(Network.class));
|
||||
}
|
||||
|
||||
@@ -223,13 +223,14 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
|
||||
setWifiEnabled(true);
|
||||
verifyLastWifiIcon(false, WifiIcons.WIFI_NO_NETWORK);
|
||||
|
||||
mNetworkController.setNoNetworksAvailable(false);
|
||||
setWifiStateForVcn(true, testSsid);
|
||||
setWifiLevelForVcn(0);
|
||||
|
||||
// Connected, but still not validated - does not show
|
||||
//verifyLastWifiIcon(false, WifiIcons.WIFI_SIGNAL_STRENGTH[0][0]);
|
||||
verifyLastMobileDataIndicatorsForVcn(false, 0, TelephonyIcons.ICON_CWF, false);
|
||||
verifyLastMobileDataIndicatorsForVcn(false, 0, 0, false);
|
||||
|
||||
mNetworkController.setNoNetworksAvailable(true);
|
||||
for (int testLevel = 0; testLevel < WifiIcons.WIFI_LEVEL_COUNT; testLevel++) {
|
||||
setWifiLevelForVcn(testLevel);
|
||||
|
||||
@@ -239,7 +240,7 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
|
||||
|
||||
setConnectivityViaBroadcastForVcn(
|
||||
NetworkCapabilities.TRANSPORT_CELLULAR, false, true, mVcnTransportInfo);
|
||||
verifyLastMobileDataIndicatorsForVcn(false, testLevel, TelephonyIcons.ICON_CWF, false);
|
||||
verifyLastMobileDataIndicatorsForVcn(true, testLevel, TelephonyIcons.ICON_CWF, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user