diff options
| author | 2021-02-26 09:34:39 -0800 | |
|---|---|---|
| committer | 2021-02-26 17:25:01 -0800 | |
| commit | b6c918079e4c279996e6f7c5b874f7e2dd5337e7 (patch) | |
| tree | ec824a7db469db4dde3bf2757f2a71ff8fc6ce79 | |
| parent | be0734de31d4b03d0f71b51cfa953b2541796c4e (diff) | |
Only show no internet icons when no other network available
Bug: 181292680
Test: Unit tests, manual tests
Change-Id: I807a1d4618faa8a43fbe0f98df3d17697dd58bc0
5 files changed, 54 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java index 6c097bdb08d3..044f52fd689e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java index 8eb1e6487046..fbdaf9cdae20 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java index 8d72c9c8810e..b9b62b415c00 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java @@ -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( diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java index e52b92648670..b1b71ccba8ce 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java @@ -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)); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java index c6812a26c20b..847030e83115 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java @@ -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); } } |