Merge "Fold WiMAX state into the mobile RSSI." into ics-mr1

This commit is contained in:
Daniel Sandler
2011-11-10 20:16:47 -08:00
committed by Android (Google) Code Review
3 changed files with 166 additions and 144 deletions

View File

@@ -257,10 +257,16 @@
<string name="accessibility_wifi_three_bars">Wi-Fi three bars.</string>
<!-- Content description of the WIFI signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_wifi_signal_full">WiFi signal full.</string>
<!-- Content description of the WiMAX signal when no signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_no_wimax">No WiMAX.</string>
<!-- Content description of the WiMAX signal when it is one bar for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_wimax_one_bar">WiMAX one bar.</string>
<!-- Content description of the WiMAX signal when it is two bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_wimax_two_bars">WiMAX two bars.</string>
<!-- Content description of the WiMAX signal when it is three bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_wimax_three_bars">WiMAX three bars.</string>
<!-- Content description of the WiMAX signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_wimax_signal_full">WiMAX signal full.</string>
<!-- Content description of the data connection type GPRS for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->

View File

@@ -111,6 +111,7 @@ public class NetworkController extends BroadcastReceiver {
com.android.internal.R.drawable.stat_sys_tether_bluetooth;
//wimax
private boolean mWimaxSupported = false;
private boolean mIsWimaxEnabled = false;
private boolean mWimaxConnected = false;
private boolean mWimaxIdle = false;
@@ -213,9 +214,9 @@ public class NetworkController extends BroadcastReceiver {
filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
boolean isWimaxConfigEnabled = mContext.getResources().getBoolean(
mWimaxSupported = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_wimaxEnabled);
if(isWimaxConfigEnabled) {
if(mWimaxSupported) {
filter.addAction(WimaxManagerConstants.WIMAX_NETWORK_STATE_CHANGED_ACTION);
filter.addAction(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION);
filter.addAction(WimaxManagerConstants.NET_4G_STATE_CHANGED_ACTION);
@@ -262,19 +263,36 @@ public class NetworkController extends BroadcastReceiver {
public void addSignalCluster(SignalCluster cluster) {
mSignalClusters.add(cluster);
refreshSignalCluster(cluster);
}
public void refreshSignalCluster(SignalCluster cluster) {
cluster.setWifiIndicators(
mWifiConnected, // only show wifi in the cluster if connected
mWifiIconId,
mWifiActivityIconId,
mContentDescriptionWifi);
cluster.setMobileDataIndicators(
mHasMobileDataFeature,
mShowPhoneRSSIForData ? mPhoneSignalIconId : mDataSignalIconId,
mMobileActivityIconId,
mDataTypeIconId,
mContentDescriptionPhoneSignal,
mContentDescriptionDataType);
if (mIsWimaxEnabled && mWimaxConnected) {
// wimax is special
cluster.setMobileDataIndicators(
true,
mWimaxIconId,
mMobileActivityIconId,
mDataTypeIconId,
mContentDescriptionWimax,
mContentDescriptionDataType);
} else {
// normal mobile data
cluster.setMobileDataIndicators(
mHasMobileDataFeature,
mShowPhoneRSSIForData ? mPhoneSignalIconId : mDataSignalIconId,
mMobileActivityIconId,
mDataTypeIconId,
mContentDescriptionPhoneSignal,
mContentDescriptionDataType);
}
cluster.setIsAirplaneMode(mAirplaneMode);
}
public void setStackedMode(boolean stacked) {
@@ -311,7 +329,7 @@ public class NetworkController extends BroadcastReceiver {
} else if (action.equals(WimaxManagerConstants.NET_4G_STATE_CHANGED_ACTION) ||
action.equals(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION) ||
action.equals(WimaxManagerConstants.WIMAX_NETWORK_STATE_CHANGED_ACTION)) {
updateWimaxState(intent);
updateWimaxState(intent);
refreshViews();
}
}
@@ -466,91 +484,100 @@ public class NetworkController extends BroadcastReceiver {
}
private final void updateDataNetType() {
switch (mDataNetType) {
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_G[mInetCondition];
mDataTypeIconId = 0;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_gprs);
break;
} else {
// fall through
}
case TelephonyManager.NETWORK_TYPE_EDGE:
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_E[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_e;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_edge);
break;
} else {
// fall through
}
case TelephonyManager.NETWORK_TYPE_UMTS:
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
break;
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_HSPAP:
if (mHspaDataDistinguishable) {
mDataIconList = TelephonyIcons.DATA_H[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_h;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3_5g);
} else {
if (mIsWimaxEnabled && mWimaxConnected) {
// wimax is a special 4g network not handled by telephony
mDataIconList = TelephonyIcons.DATA_4G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_4g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_4g);
} else {
switch (mDataNetType) {
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_G[mInetCondition];
mDataTypeIconId = 0;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_gprs);
break;
} else {
// fall through
}
case TelephonyManager.NETWORK_TYPE_EDGE:
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_E[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_e;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_edge);
break;
} else {
// fall through
}
case TelephonyManager.NETWORK_TYPE_UMTS:
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
}
break;
case TelephonyManager.NETWORK_TYPE_CDMA:
// display 1xRTT for IS95A/B
mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_cdma);
break;
case TelephonyManager.NETWORK_TYPE_1xRTT:
mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_cdma);
break;
case TelephonyManager.NETWORK_TYPE_EVDO_0: //fall through
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_EVDO_B:
case TelephonyManager.NETWORK_TYPE_EHRPD:
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
break;
case TelephonyManager.NETWORK_TYPE_LTE:
mDataIconList = TelephonyIcons.DATA_4G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_4g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_4g);
break;
default:
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_g;
break;
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_HSPAP:
if (mHspaDataDistinguishable) {
mDataIconList = TelephonyIcons.DATA_H[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_h;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3_5g);
} else {
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
}
break;
case TelephonyManager.NETWORK_TYPE_CDMA:
// display 1xRTT for IS95A/B
mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_gprs);
} else {
R.string.accessibility_data_connection_cdma);
break;
case TelephonyManager.NETWORK_TYPE_1xRTT:
mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_cdma);
break;
case TelephonyManager.NETWORK_TYPE_EVDO_0: //fall through
case TelephonyManager.NETWORK_TYPE_EVDO_A:
case TelephonyManager.NETWORK_TYPE_EVDO_B:
case TelephonyManager.NETWORK_TYPE_EHRPD:
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
}
break;
break;
case TelephonyManager.NETWORK_TYPE_LTE:
mDataIconList = TelephonyIcons.DATA_4G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_4g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_4g);
break;
default:
if (!mShowAtLeastThreeGees) {
mDataIconList = TelephonyIcons.DATA_G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_gprs);
} else {
mDataIconList = TelephonyIcons.DATA_3G[mInetCondition];
mDataTypeIconId = R.drawable.stat_sys_data_connected_3g;
mContentDescriptionDataType = mContext.getString(
R.string.accessibility_data_connection_3g);
}
break;
}
}
if ((isCdma() && isCdmaEri()) || mPhone.isNetworkRoaming()) {
mDataTypeIconId = R.drawable.stat_sys_data_connected_roam;
}
@@ -763,8 +790,7 @@ public class NetworkController extends BroadcastReceiver {
}
// ===== Wimax ===================================================================
// ===== Wimax ===================================================================
private final void updateWimaxState(Intent intent) {
final String action = intent.getAction();
boolean wasConnected = mWimaxConnected;
@@ -772,42 +798,41 @@ public class NetworkController extends BroadcastReceiver {
int wimaxStatus = intent.getIntExtra(WimaxManagerConstants.EXTRA_4G_STATE,
WimaxManagerConstants.NET_4G_STATE_UNKNOWN);
mIsWimaxEnabled = (wimaxStatus ==
WimaxManagerConstants.NET_4G_STATE_ENABLED)? true : false;
WimaxManagerConstants.NET_4G_STATE_ENABLED);
} else if (action.equals(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION)) {
mWimaxSignal = intent.getIntExtra(WimaxManagerConstants.EXTRA_NEW_SIGNAL_LEVEL, 0);
} else if (action.equals(WimaxManagerConstants.WIMAX_NETWORK_STATE_CHANGED_ACTION)) {
mWimaxState = intent.getIntExtra(WimaxManagerConstants.EXTRA_WIMAX_STATE,
mWimaxState = intent.getIntExtra(WimaxManagerConstants.EXTRA_WIMAX_STATE,
WimaxManagerConstants.NET_4G_STATE_UNKNOWN);
mWimaxExtraState = intent.getIntExtra(
WimaxManagerConstants.EXTRA_WIMAX_STATE_DETAIL,
WimaxManagerConstants.NET_4G_STATE_UNKNOWN);
mWimaxConnected = (mWimaxState ==
WimaxManagerConstants.WIMAX_STATE_CONNECTED) ? true : false;
mWimaxIdle = (mWimaxExtraState == WimaxManagerConstants.WIMAX_IDLE)? true : false;
WimaxManagerConstants.WIMAX_STATE_CONNECTED);
mWimaxIdle = (mWimaxExtraState == WimaxManagerConstants.WIMAX_IDLE);
}
updateDataNetType();
updateWimaxIcons();
}
private void updateWimaxIcons() {
Slog.d(TAG, "in .... updateWimaxIcons function : "+mIsWimaxEnabled);
if (mIsWimaxEnabled) {
if (mWimaxConnected) {
Slog.d(TAG, "in .... updateWimaxIcons function WiMAX COnnected");
if (mWimaxIdle)
mWimaxIconId = WimaxIcons.WIMAX_IDLE;
else
mWimaxIconId = WimaxIcons.WIMAX_SIGNAL_STRENGTH[mInetCondition][mWimaxSignal];
mContentDescriptionWimax = mContext.getString(
AccessibilityContentDescriptions.WIMAX_CONNECTION_STRENGTH[mWimaxSignal]);
} else {
Slog.d(TAG, "in .... updateWimaxIcons function WiMAX Disconnected");
mWimaxIconId = WimaxIcons.WIMAX_DISCONNECTED;
mContentDescriptionWimax = mContext.getString(R.string.accessibility_no_wimax);
}
} else {
Slog.d(TAG, "in .... updateWimaxIcons function wimax icon id 0");
mWimaxIconId = 0;
}
private void updateWimaxIcons() {
if (mIsWimaxEnabled) {
if (mWimaxConnected) {
if (mWimaxIdle)
mWimaxIconId = WimaxIcons.WIMAX_IDLE;
else
mWimaxIconId = WimaxIcons.WIMAX_SIGNAL_STRENGTH[mInetCondition][mWimaxSignal];
mContentDescriptionWimax = mContext.getString(
AccessibilityContentDescriptions.WIMAX_CONNECTION_STRENGTH[mWimaxSignal]);
} else {
mWimaxIconId = WimaxIcons.WIMAX_DISCONNECTED;
mContentDescriptionWimax = mContext.getString(R.string.accessibility_no_wimax);
}
} else {
mWimaxIconId = 0;
}
}
// ===== Full or limited Internet connectivity ==================================
private void updateConnectivity(Intent intent) {
@@ -827,14 +852,14 @@ public class NetworkController extends BroadcastReceiver {
mInetCondition = (connectionStatus > INET_CONDITION_THRESHOLD ? 1 : 0);
if (info != null && info.getType() == ConnectivityManager.TYPE_BLUETOOTH) {
mBluetoothTethered = info.isConnected() ? true: false;
mBluetoothTethered = info.isConnected();
} else {
mBluetoothTethered = false;
}
// We want to update all the icons, all at once, for any condition change
updateDataNetType();
updateWimaxIcons();
updateWimaxIcons();
updateDataIcon();
updateTelephonySignalStrength();
updateWifiIcons();
@@ -921,7 +946,7 @@ public class NetworkController extends BroadcastReceiver {
combinedSignalIconId = mDataSignalIconId;
}
else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered) {
else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxConnected) {
// pretty much totally disconnected
label = context.getString(R.string.status_bar_settings_signal_meter_disconnected);
@@ -961,23 +986,12 @@ public class NetworkController extends BroadcastReceiver {
if (mLastPhoneSignalIconId != mPhoneSignalIconId
|| mLastDataDirectionOverlayIconId != combinedActivityIconId
|| mLastWifiIconId != mWifiIconId
|| mLastWimaxIconId != mWimaxIconId
|| mLastDataTypeIconId != mDataTypeIconId)
{
// NB: the mLast*s will be updated later
for (SignalCluster cluster : mSignalClusters) {
cluster.setWifiIndicators(
mWifiConnected, // only show wifi in the cluster if connected
mWifiIconId,
mWifiActivityIconId,
mContentDescriptionWifi);
cluster.setMobileDataIndicators(
mHasMobileDataFeature,
mShowPhoneRSSIForData ? mPhoneSignalIconId : mDataSignalIconId,
mMobileActivityIconId,
mDataTypeIconId,
mContentDescriptionPhoneSignal,
mContentDescriptionDataType);
cluster.setIsAirplaneMode(mAirplaneMode);
refreshSignalCluster(cluster);
}
}
@@ -1152,11 +1166,22 @@ public class NetworkController extends BroadcastReceiver {
pw.println(mWifiLevel);
pw.print(" mWifiSsid=");
pw.println(mWifiSsid);
pw.print(String.format(" mWifiIconId=0x%08x/%s",
pw.println(String.format(" mWifiIconId=0x%08x/%s",
mWifiIconId, getResourceName(mWifiIconId)));
pw.print(" mWifiActivity=");
pw.println(mWifiActivity);
if (mWimaxSupported) {
pw.println(" - wimax ------");
pw.print(" mIsWimaxEnabled="); pw.println(mIsWimaxEnabled);
pw.print(" mWimaxConnected="); pw.println(mWimaxConnected);
pw.print(" mWimaxIdle="); pw.println(mWimaxIdle);
pw.println(String.format(" mWimaxIconId=0x%08x/%s",
mWimaxIconId, getResourceName(mWimaxIconId)));
pw.println(String.format(" mWimaxSignal=%d", mWimaxSignal));
pw.println(String.format(" mWimaxState=%d", mWimaxState));
pw.println(String.format(" mWimaxExtraState=%d", mWimaxExtraState));
}
pw.println(" - Bluetooth ----");
pw.print(" mBtReverseTethered=");
@@ -1190,7 +1215,7 @@ public class NetworkController extends BroadcastReceiver {
pw.print(" mLastDataTypeIconId=0x");
pw.print(Integer.toHexString(mLastDataTypeIconId));
pw.print("/");
pw.println(getResourceName(mLastCombinedSignalIconId));
pw.println(getResourceName(mLastDataTypeIconId));
pw.print(" mLastLabel=");
pw.print(mLastLabel);
pw.println("");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,22 +16,13 @@
package com.android.systemui.statusbar.policy;
import com.android.systemui.statusbar.policy.TelephonyIcons;
import com.android.systemui.R;
class WimaxIcons {
static final int[][] WIMAX_SIGNAL_STRENGTH = {
{ R.drawable.stat_sys_data_wimax_signal_0,
R.drawable.stat_sys_data_wimax_signal_1,
R.drawable.stat_sys_data_wimax_signal_2,
R.drawable.stat_sys_data_wimax_signal_3 },
{ R.drawable.stat_sys_data_wimax_signal_0_fully,
R.drawable.stat_sys_data_wimax_signal_1_fully,
R.drawable.stat_sys_data_wimax_signal_2_fully,
R.drawable.stat_sys_data_wimax_signal_3_fully }
};
static final int[][] WIMAX_SIGNAL_STRENGTH = TelephonyIcons.DATA_SIGNAL_STRENGTH;
static final int WIMAX_DISCONNECTED =
R.drawable.stat_sys_data_wimax_signal_disconnected;
static final int WIMAX_IDLE = R.drawable.stat_sys_data_wimax_signal_idle;
static final int WIFI_LEVEL_COUNT = WIMAX_SIGNAL_STRENGTH[0].length;
static final int WIMAX_DISCONNECTED = WIMAX_SIGNAL_STRENGTH[0][0];
static final int WIMAX_IDLE = WIMAX_DISCONNECTED; // XXX: unclear if we need a different icon
}