diff options
author | Daniel Sandler <dsandler@android.com> | 2012-06-15 13:17:39 -0400 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2012-06-15 13:21:16 -0400 |
commit | 67234c4b87f767a8d5ebbd1ab6bc803f7fe8504c (patch) | |
tree | e02b2646fbd26c17499598b251b68409b79fa6a7 /packages/SystemUI | |
parent | 734f0214ec04e6c734aeec78d15f6db478cfb55c (diff) | |
download | frameworks_base-67234c4b87f767a8d5ebbd1ab6bc803f7fe8504c.zip frameworks_base-67234c4b87f767a8d5ebbd1ab6bc803f7fe8504c.tar.gz frameworks_base-67234c4b87f767a8d5ebbd1ab6bc803f7fe8504c.tar.bz2 |
Hide "no internet connection" when connected some other way.
We now track whether the device is connected at all, and use
this to suppress the disconnected message in the mobile
status string (we previously just looked at wifi
connectivity).
So, if a device is attached via ethernet:
- On wifi-only devices, the combined label is shown in the
notification panel, so you'll see "ETHERNET" (this comes
straight from EthernetDataTracker; at some point we need
localized strings and icons).
- On mobile-data devices (phones), the notification panel
only shows the mobile data label, which will be
suppressed, so you'll see nothing at all.
Bug: 6648292
Change-Id: I9841eaeffe50a4f046afbdc09d80c5bd4d78a839
Diffstat (limited to 'packages/SystemUI')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java | 5 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java | 30 |
2 files changed, 30 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 9c99653..3c19ad2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -462,11 +462,12 @@ public class PhoneStatusBar extends BaseStatusBar { signalCluster.setNetworkController(mNetworkController); if (SHOW_CARRIER_LABEL) { - // for wifi-only devices, we show SSID; otherwise, we show PLMN + // for mobile devices, we always show mobile connection info here (SPN/PLMN) + // for other devices, we show whatever network is connected if (mNetworkController.hasMobileDataFeature()) { mNetworkController.addMobileLabelView(mCarrierLabel); } else { - mNetworkController.addWifiLabelView(mCarrierLabel); + mNetworkController.addCombinedLabelView(mCarrierLabel); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java index b8f6054..1068267 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -121,8 +121,12 @@ public class NetworkController extends BroadcastReceiver { private int mWimaxSignal = 0; private int mWimaxState = 0; private int mWimaxExtraState = 0; + // data connectivity (regardless of state, can we access the internet?) // state of inet connection - 0 not connected, 100 connected + private boolean mConnected = false; + private int mConnectedNetworkType = ConnectivityManager.TYPE_NONE; + private String mConnectedNetworkTypeName; private int mInetCondition = 0; private static final int INET_CONDITION_THRESHOLD = 50; @@ -868,6 +872,16 @@ public class NetworkController extends BroadcastReceiver { .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo info = connManager.getActiveNetworkInfo(); + // Are we connected at all, by any interface? + mConnected = info != null && info.isConnected(); + if (mConnected) { + mConnectedNetworkType = info.getType(); + mConnectedNetworkTypeName = info.getTypeName(); + } else { + mConnectedNetworkType = ConnectivityManager.TYPE_NONE; + mConnectedNetworkTypeName = null; + } + int connectionStatus = intent.getIntExtra(ConnectivityManager.EXTRA_INET_CONDITION, 0); if (CHATTY) { @@ -912,12 +926,13 @@ public class NetworkController extends BroadcastReceiver { // - We are connected to mobile data, or // - We are not connected to mobile data, as long as the *reason* packets are not // being routed over that link is that we have better connectivity via wifi. - // If data is disconnected for some other reason but wifi is connected, we show nothing. + // If data is disconnected for some other reason but wifi (or ethernet/bluetooth) + // is connected, we show nothing. // Otherwise (nothing connected) we show "No internet connection". if (mDataConnected) { mobileLabel = mNetworkName; - } else if (mWifiConnected) { + } else if (mConnected) { if (hasService()) { mobileLabel = mNetworkName; } else { @@ -997,6 +1012,12 @@ public class NetworkController extends BroadcastReceiver { R.string.accessibility_bluetooth_tether); } + final boolean ethernetConnected = (mConnectedNetworkType == ConnectivityManager.TYPE_ETHERNET); + if (ethernetConnected) { + // TODO: icons and strings for Ethernet connectivity + combinedLabel = mConnectedNetworkTypeName; + } + if (mAirplaneMode && (mServiceState == null || (!hasService() && !mServiceState.isEmergencyOnly()))) { // Only display the flight-mode icon if not in "emergency calls only" mode. @@ -1023,7 +1044,7 @@ public class NetworkController extends BroadcastReceiver { combinedSignalIconId = mDataSignalIconId; } } - else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxConnected) { + else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxConnected && !ethernetConnected) { // pretty much totally disconnected combinedLabel = context.getString(R.string.status_bar_settings_signal_meter_disconnected); @@ -1224,6 +1245,9 @@ public class NetworkController extends BroadcastReceiver { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("NetworkController state:"); + pw.println(String.format(" %s network type %d (%s)", + mConnected?"CONNECTED":"DISCONNECTED", + mConnectedNetworkType, mConnectedNetworkTypeName)); pw.println(" - telephony ------"); pw.print(" hasService()="); pw.println(hasService()); |