diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java | 48 |
1 files changed, 38 insertions, 10 deletions
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 6a823fa..5966890 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -95,6 +95,7 @@ public class NetworkController extends BroadcastReceiver { String mContentDescriptionWimax; String mContentDescriptionCombinedSignal; String mContentDescriptionDataType; + String mContentDescriptionEther; // wifi final WifiManager mWifiManager; @@ -133,6 +134,12 @@ public class NetworkController extends BroadcastReceiver { private boolean mAirplaneMode = false; private boolean mLastAirplaneMode = true; + //ethernet + private boolean mEtherConnected = false; + private int mEtherIconId = 0; + private int mLastEtherIconId = 0; + + // our ui Context mContext; ArrayList<ImageView> mPhoneSignalIconViews = new ArrayList<ImageView>(); @@ -171,6 +178,7 @@ public class NetworkController extends BroadcastReceiver { void setMobileDataIndicators(boolean visible, int strengthIcon, int activityIcon, int typeIcon, String contentDescription, String typeContentDescription); void setIsAirplaneMode(boolean is, int airplaneIcon); + void setEtherIndicators(boolean visible, int etherIcon, String contentDescription); } public interface NetworkSignalChangedCallback { @@ -203,7 +211,7 @@ public class NetworkController extends BroadcastReceiver { updateWimaxIcons(); // telephony - mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); + mPhone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mPhone.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS @@ -218,7 +226,7 @@ public class NetworkController extends BroadcastReceiver { mNetworkName = mNetworkNameDefault; // wifi - mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); Handler handler = new WifiHandler(); mWifiChannel = new AsyncChannel(); Messenger wifiMessenger = mWifiManager.getWifiServiceMessenger(); @@ -244,7 +252,7 @@ public class NetworkController extends BroadcastReceiver { filter.addAction(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION); filter.addAction(WimaxManagerConstants.NET_4G_STATE_CHANGED_ACTION); } - context.registerReceiver(this, filter); + mContext.registerReceiver(this, filter); // AIRPLANE_MODE_CHANGED is sent at boot; we've probably already missed it updateAirplaneMode(); @@ -326,6 +334,12 @@ public class NetworkController extends BroadcastReceiver { mWifiActivityIconId, mContentDescriptionWifi); + cluster.setEtherIndicators( + // only show ethernet in the cluster if connected + mEtherConnected, + mEtherIconId, + mContentDescriptionEther); + if (mIsWimaxEnabled && mWimaxConnected) { // wimax is special cluster.setMobileDataIndicators( @@ -995,6 +1009,16 @@ public class NetworkController extends BroadcastReceiver { mBluetoothTethered = false; } + if (info != null && info.getType() == ConnectivityManager.TYPE_ETHERNET) { + mEtherConnected = info.isConnected(); + mEtherIconId = (mInetCondition == 1 + ? R.drawable.stat_sys_ether_fully + : R.drawable.stat_sys_ether); + } else { + mEtherConnected = false; + mEtherIconId = 0; + } + // We want to update all the icons, all at once, for any condition change updateDataNetType(); updateWimaxIcons(); @@ -1007,8 +1031,6 @@ public class NetworkController extends BroadcastReceiver { // ===== Update the views ======================================================= void refreshViews() { - Context context = mContext; - int combinedSignalIconId = 0; int combinedActivityIconId = 0; String combinedLabel = ""; @@ -1116,9 +1138,9 @@ public class NetworkController extends BroadcastReceiver { R.string.accessibility_bluetooth_tether); } - final boolean ethernetConnected = (mConnectedNetworkType == ConnectivityManager.TYPE_ETHERNET); - if (ethernetConnected) { - combinedLabel = context.getString(R.string.ethernet_label); + mEtherConnected = (mConnectedNetworkType == ConnectivityManager.TYPE_ETHERNET); + if (mEtherConnected) { + mContentDescriptionEther = combinedLabel = mContext.getString(R.string.ethernet_label); } if (mAirplaneMode && @@ -1147,8 +1169,8 @@ public class NetworkController extends BroadcastReceiver { mContentDescriptionCombinedSignal = mContentDescriptionPhoneSignal; combinedSignalIconId = mDataSignalIconId; } - } - else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxConnected && !ethernetConnected) { + } else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered + && !mWimaxConnected && !mEtherConnected) { // pretty much totally disconnected combinedLabel = context.getString(R.string.status_bar_settings_signal_meter_disconnected); @@ -1203,6 +1225,7 @@ public class NetworkController extends BroadcastReceiver { || mLastWifiIconId != mWifiIconId || mLastWimaxIconId != mWimaxIconId || mLastDataTypeIconId != mDataTypeIconId + || mLastEtherIconId != mEtherIconId || mLastAirplaneMode != mAirplaneMode) { // NB: the mLast*s will be updated later @@ -1287,6 +1310,11 @@ public class NetworkController extends BroadcastReceiver { } } + // the ethernet icon + if (mLastEtherIconId != mEtherIconId) { + mLastEtherIconId = mEtherIconId; + } + // the data network type overlay if (mLastDataTypeIconId != mDataTypeIconId) { mLastDataTypeIconId = mDataTypeIconId; |