System bar improvements.

- Updated artwork for buttons and signal/battery meters.
- Layout change: meters on either side of clock
- RSSI for mobile data. The algorithm is more or less the
  same as the one used in the phone status bar. Note that
  mobile data is only shown if Wi-Fi is unavailable.

Bug: 2924643
Change-Id: Idaa0c52422db4a63616475bde96626d1953830b4
This commit is contained in:
Daniel Sandler
2010-08-24 16:24:35 -04:00
parent 3c1fbf7ad2
commit 764b4da4a8
43 changed files with 418 additions and 53 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 B

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View File

@@ -20,12 +20,8 @@
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="1" android:drawable="@drawable/battery_0" />
<item android:maxLevel="5">
<animation-list android:oneshot="false">
<item android:drawable="@drawable/battery_0" android:duration="250" />
<item android:drawable="@drawable/battery_25" android:duration="250" />
</animation-list>
</item>
<item android:maxLevel="5" android:drawable="@drawable/battery_5" />
<item android:maxLevel="10" android:drawable="@drawable/battery_10" />
<item android:maxLevel="25" android:drawable="@drawable/battery_25" />
<item android:maxLevel="50" android:drawable="@drawable/battery_50" />
<item android:maxLevel="75" android:drawable="@drawable/battery_75" />

View File

@@ -24,6 +24,5 @@
<item android:maxLevel="50" android:drawable="@drawable/signal_50" />
<item android:maxLevel="75" android:drawable="@drawable/signal_75" />
<item android:maxLevel="101" android:drawable="@drawable/signal_100" />
</level-list>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/drawable/stat_sys_battery.xml
**
** Copyright 2007, 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.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/signal_scan1" android:duration="500" />
<item android:drawable="@drawable/signal_scan2" android:duration="500" />
<item android:drawable="@drawable/signal_scan3" android:duration="500" />
<item android:drawable="@drawable/signal_scan4" android:duration="500" />
<item android:drawable="@drawable/signal_scan3" android:duration="500" />
<item android:drawable="@drawable/signal_scan2" android:duration="500" />
</animation-list>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/drawable/stat_sys_battery.xml
**
** Copyright 2007, 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.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="01" android:drawable="@drawable/wifi_0" />
<item android:maxLevel="25" android:drawable="@drawable/wifi_25" />
<item android:maxLevel="50" android:drawable="@drawable/wifi_50" />
<item android:maxLevel="75" android:drawable="@drawable/wifi_75" />
<item android:maxLevel="101" android:drawable="@drawable/wifi_100" />
</level-list>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/drawable/stat_sys_battery.xml
**
** Copyright 2007, 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.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/wifi_scan1" android:duration="500" />
<item android:drawable="@drawable/wifi_scan2" android:duration="500" />
<item android:drawable="@drawable/wifi_scan3" android:duration="500" />
<item android:drawable="@drawable/wifi_scan4" android:duration="500" />
<item android:drawable="@drawable/wifi_scan3" android:duration="500" />
<item android:drawable="@drawable/wifi_scan2" android:duration="500" />
</animation-list>

View File

@@ -101,8 +101,8 @@
</LinearLayout>
<include layout="@layout/status_bar_center"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_width="160dip"
android:layout_height="match_parent"
android:layout_centerInParent="true"
/>

View File

@@ -18,8 +18,8 @@
<RelativeLayout android:id="@+id/systemInfo"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_width="160dip"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:clickable="true"
android:onClick="systemInfoClicked"
@@ -27,8 +27,9 @@
<com.android.systemui.statusbar.Clock
style="@*android:style/TextAppearance.StatusBar.Icon"
android:id="@+id/clock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="64dip"
android:layout_height="48dip"
android:layout_centerInParent="true"
android:singleLine="true"
android:gravity="center"
android:textSize="16sp"
@@ -37,18 +38,16 @@
/>
<ImageView
android:id="@+id/battery"
android:layout_width="50dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/clock"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_toLeftOf="@id/clock"
android:src="@drawable/battery"
/>
<ImageView
android:id="@+id/signal"
android:layout_width="50dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/clock"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_toRightOf="@id/clock"
android:src="@drawable/signal"
/>
</RelativeLayout>

View File

@@ -92,8 +92,10 @@
android:layout_alignParentLeft="true"
>
<ImageView android:id="@+id/battery_meter"
android:layout_width="wrap_content"
android:layout_width="96dip"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
android:src="@drawable/battery"
/>
@@ -129,8 +131,10 @@
android:layout_alignParentRight="true"
>
<ImageView android:id="@+id/signal_meter"
android:layout_width="wrap_content"
android:layout_width="96dip"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
android:src="@drawable/signal"
/>

View File

@@ -20,4 +20,58 @@
<!-- The text for the button in the notification window-shade that clears
all of the currently visible notifications. -->
<string name="status_bar_clear_all_button">Clear all</string>
<!-- System panel ("Quick Settings") -->
<!-- Text to display underneath the graphical battery meter. Should
include the word for "battery" and a place for the percentage charge
available. [CHAR LIMIT=20] -->
<string name="system_panel_battery_meter_format">
Battery: <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g>
</string>
<!-- Text to display underneath the graphical signal strength meter when
no connection is available. [CHAR LIMIT=20] -->
<string name="system_panel_signal_meter_disconnected">
no internet connection
</string>
<!-- Text to display underneath the graphical signal strength meter when
it is displaying information about a connected, named Wi-Fi network.
Should include the word for "Wi-Fi" and a placeholder for the
wireless network's SSID. [CHAR LIMIT=20] -->
<string name="system_panel_signal_meter_wifi_ssid_format">
Wi-Fi: <xliff:g id="ssid">%s</xliff:g>
</string>
<!-- Text to display underneath the graphical signal strength meter when
it is displaying Wi-Fi status and Wi-Fi is connected to a network
whose SSID is not available.
[CHAR LIMIT=20] -->
<string name="system_panel_signal_meter_wifi_nossid">
Wi-Fi: connected
</string>
<!-- Text to display underneath the graphical signal strength meter when
it is displaying Wi-Fi status and Wi-Fi is in the process of
connecting to a network. [CHAR LIMIT=20] -->
<string name="system_panel_signal_meter_wifi_connecting">
Wi-Fi: connecting…
</string>
<!-- Text to display underneath the graphical signal strength meter when
it is displaying mobile data (3G) status and a network connection is
available.
[CHAR LIMIT=20] -->
<string name="system_panel_signal_meter_data_connected">
Mobile data: connected
</string>
<!-- Text to display underneath the graphical signal strength meter when
it is displaying mobile data (3G) status and a network connection is
unavailable.
[CHAR LIMIT=20] -->
<string name="system_panel_signal_meter_data_connecting">
Mobile data: connecting…
</string>
</resources>

View File

@@ -45,6 +45,7 @@ import android.os.ServiceManager;
import android.provider.Settings;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.util.AttributeSet;
import android.util.Slog;
@@ -66,11 +67,18 @@ import android.widget.Toast;
import java.util.List;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.internal.telephony.cdma.TtyIntent;
import com.android.systemui.statusbar.*;
import com.android.systemui.R;
public class SystemPanel extends LinearLayout {
private static final String TAG = "SystemPanel";
private static final boolean DEBUG = TabletStatusBarService.DEBUG;
private static final boolean DEBUG_SIGNAL = true;
private static final int MINIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_DIM + 5;
private static final int MAXIMUM_BACKLIGHT = android.os.Power.BRIGHTNESS_ON;
@@ -93,7 +101,22 @@ public class SystemPanel extends LinearLayout {
private final AudioManager mAudioManager;
private final WifiManager mWifiManager;
private final TelephonyManager mPhone;
// state trackers for telephony code
IccCard.State mSimState = IccCard.State.READY;
int mPhoneState = TelephonyManager.CALL_STATE_IDLE;
int mDataState = TelephonyManager.DATA_DISCONNECTED;
ServiceState mServiceState;
SignalStrength mSignalStrength;
// state for the meters
boolean mWifiEnabled, mWifiConnected;
int mWifiLevel;
String mWifiSsid;
boolean mDataEnabled, mDataConnected, mDataRoaming;
int mDataLevel;
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
@@ -107,18 +130,154 @@ public class SystemPanel extends LinearLayout {
|| action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)
|| action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)
|| action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
updateWifi(intent);
updateWifiState(intent);
} else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
updateSimState(intent);
}
}
};
boolean mWifiEnabled, mWifiConnected;
int mWifiLevel;
String mWifiSsid;
private final void updateSimState(Intent intent) {
String stateExtra = intent.getStringExtra(IccCard.INTENT_KEY_ICC_STATE);
if (IccCard.INTENT_VALUE_ICC_ABSENT.equals(stateExtra)) {
mSimState = IccCard.State.ABSENT;
}
else if (IccCard.INTENT_VALUE_ICC_READY.equals(stateExtra)) {
mSimState = IccCard.State.READY;
}
else if (IccCard.INTENT_VALUE_ICC_LOCKED.equals(stateExtra)) {
final String lockedReason = intent.getStringExtra(IccCard.INTENT_KEY_LOCKED_REASON);
if (IccCard.INTENT_VALUE_LOCKED_ON_PIN.equals(lockedReason)) {
mSimState = IccCard.State.PIN_REQUIRED;
}
else if (IccCard.INTENT_VALUE_LOCKED_ON_PUK.equals(lockedReason)) {
mSimState = IccCard.State.PUK_REQUIRED;
}
else {
mSimState = IccCard.State.NETWORK_LOCKED;
}
} else {
mSimState = IccCard.State.UNKNOWN;
}
updateDataState();
}
private void updateWifi(Intent intent) {
if (TabletStatusBarService.DEBUG)
Slog.d(TabletStatusBarService.TAG, "updateWifi: " + intent);
private boolean isCdma() {
return (mSignalStrength != null) && !mSignalStrength.isGsm();
}
private boolean isEvdo() {
return ( (mServiceState != null)
&& ((mServiceState.getRadioTechnology()
== ServiceState.RADIO_TECHNOLOGY_EVDO_0)
|| (mServiceState.getRadioTechnology()
== ServiceState.RADIO_TECHNOLOGY_EVDO_A)
|| (mServiceState.getRadioTechnology()
== ServiceState.RADIO_TECHNOLOGY_EVDO_B)));
}
private boolean hasService() {
if (mServiceState != null) {
switch (mServiceState.getState()) {
case ServiceState.STATE_OUT_OF_SERVICE:
case ServiceState.STATE_POWER_OFF:
return false;
default:
return true;
}
} else {
return false;
}
}
private int getCdmaLevel() {
if (mSignalStrength == null) return 0;
final int cdmaDbm = mSignalStrength.getCdmaDbm();
final int cdmaEcio = mSignalStrength.getCdmaEcio();
int levelDbm = 0;
int levelEcio = 0;
if (cdmaDbm >= -75) levelDbm = 4;
else if (cdmaDbm >= -85) levelDbm = 3;
else if (cdmaDbm >= -95) levelDbm = 2;
else if (cdmaDbm >= -100) levelDbm = 1;
else levelDbm = 0;
// Ec/Io are in dB*10
if (cdmaEcio >= -90) levelEcio = 4;
else if (cdmaEcio >= -110) levelEcio = 3;
else if (cdmaEcio >= -130) levelEcio = 2;
else if (cdmaEcio >= -150) levelEcio = 1;
else levelEcio = 0;
return (levelDbm < levelEcio) ? levelDbm : levelEcio;
}
private int getEvdoLevel() {
if (mSignalStrength == null) return 0;
int evdoDbm = mSignalStrength.getEvdoDbm();
int evdoSnr = mSignalStrength.getEvdoSnr();
int levelEvdoDbm = 0;
int levelEvdoSnr = 0;
if (evdoDbm >= -65) levelEvdoDbm = 4;
else if (evdoDbm >= -75) levelEvdoDbm = 3;
else if (evdoDbm >= -90) levelEvdoDbm = 2;
else if (evdoDbm >= -105) levelEvdoDbm = 1;
else levelEvdoDbm = 0;
if (evdoSnr >= 7) levelEvdoSnr = 4;
else if (evdoSnr >= 5) levelEvdoSnr = 3;
else if (evdoSnr >= 3) levelEvdoSnr = 2;
else if (evdoSnr >= 1) levelEvdoSnr = 1;
else levelEvdoSnr = 0;
return (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr;
}
private void updateDataState() {
mDataConnected = hasService() && (mDataState == TelephonyManager.DATA_CONNECTED);
if (isCdma()) {
// these functions return a value from 0 to 4, inclusive
if ((mPhoneState == TelephonyManager.CALL_STATE_IDLE) && isEvdo()){
mDataLevel = getEvdoLevel() * 25;
} else {
mDataLevel = getCdmaLevel() * 25;
}
} else {
// GSM
int asu = (mSignalStrength == null) ? 0 : mSignalStrength.getGsmSignalStrength();
// asu on [0,31]; 99 = unknown
// Android has historically shown anything >=12 as "full"
// XXX: tune this based on Industry Best Practices(TM)
if (asu <= 2 || asu == 99) mDataLevel = 0;
else mDataLevel = (int)(((float)Math.max(asu, 15) / 15) * 100);
mDataRoaming = mPhone.isNetworkRoaming();
mDataConnected = mDataConnected
&& (mSimState == IccCard.State.READY || mSimState == IccCard.State.UNKNOWN);
}
if (DEBUG_SIGNAL || DEBUG) {
Slog.d(TAG, "updateDataState: connected=" + mDataConnected
+ " level=" + mDataLevel
+ " isEvdo=" + isEvdo()
+ " isCdma=" + isCdma()
+ " mPhoneState=" + mPhoneState
+ " mDataState=" + mDataState
);
}
refreshSignalMeters();
}
private void updateWifiState(Intent intent) {
if (DEBUG)
Slog.d(TAG, "updateWifiState: " + intent);
final String action = intent.getAction();
final boolean wasConnected = mWifiConnected;
@@ -142,8 +301,8 @@ public class SystemPanel extends LinearLayout {
if (mWifiConnected && !wasConnected) {
WifiInfo info = mWifiManager.getConnectionInfo();
if (TabletStatusBarService.DEBUG)
Slog.d(TabletStatusBarService.TAG, "updateWifi: just connected: info=" + info);
if (DEBUG)
Slog.d(TAG, "updateWifiState: just connected: info=" + info);
if (info != null) {
// grab the initial signal strength
@@ -164,22 +323,40 @@ public class SystemPanel extends LinearLayout {
}
}
if (!mWifiEnabled) {
mWifiSsid = "disabled";
mWifiLevel = 0;
} else if (!mWifiConnected) {
mWifiSsid = "disconnected";
mWifiLevel = 0;
} else if (mWifiSsid == null) {
mWifiSsid = "unknown";
refreshSignalMeters();
}
// figure out what to show: first wifi, then 3G, then nothing
void refreshSignalMeters() {
if (mSignalMeter == null) return; // no UI yet
Context ctxt = getContext();
String text = null;
int level = 0;
if (mWifiConnected) {
if (mWifiSsid == null) {
text = ctxt.getString(R.string.system_panel_signal_meter_wifi_nossid);
} else {
text = ctxt.getString(R.string.system_panel_signal_meter_wifi_ssid_format,
mWifiSsid);
}
level = mWifiLevel;
} else if (mDataConnected) {
text = ctxt.getString(R.string.system_panel_signal_meter_data_connected);
level = mDataLevel;
} else {
text = ctxt.getString(R.string.system_panel_signal_meter_disconnected);
level = 0;
}
mSignalMeter.setImageResource(R.drawable.signal);
mSignalMeter.setImageLevel(mWifiLevel);
mSignalText.setText(String.format("Wi-Fi: %s", mWifiSsid)); // XXX: localize
mSignalMeter.setImageResource(mWifiConnected ? R.drawable.wifi : R.drawable.signal);
mSignalMeter.setImageLevel(level);
mSignalText.setText(text);
// hack for now
mBar.setWifiMeter(mWifiLevel);
mBar.setSignalMeter(level, mWifiConnected);
}
public void setBar(TabletStatusBarService bar) {
@@ -192,7 +369,8 @@ public class SystemPanel extends LinearLayout {
mBatteryMeter.setImageResource(plugged ? R.drawable.battery_charging : R.drawable.battery);
mBatteryMeter.setImageLevel(level);
mBatteryText.setText(String.format("Battery: %d%%", level));
mBatteryText.setText(getContext()
.getString(R.string.system_panel_battery_meter_format, level));
// hack for now
mBar.setBatteryMeter(level, plugged);
@@ -208,13 +386,21 @@ public class SystemPanel extends LinearLayout {
// get notified of phone state changes
TelephonyManager telephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
telephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
| PhoneStateListener.LISTEN_CALL_STATE
| PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
| PhoneStateListener.LISTEN_DATA_ACTIVITY);
// wifi status info
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
// audio status notifications
// audio status
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
// mobile data
mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
}
public void onAttachedToWindow() {
@@ -259,6 +445,7 @@ public class SystemPanel extends LinearLayout {
}
});
// register for broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
@@ -266,8 +453,9 @@ public class SystemPanel extends LinearLayout {
filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.RSSI_CHANGED_ACTION);
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
getContext().registerReceiver(mReceiver, filter);
mBatteryMeter = (ImageView)findViewById(R.id.battery_meter);
mBatteryMeter.setImageResource(R.drawable.battery);
mBatteryMeter.setImageLevel(0);
@@ -277,6 +465,8 @@ public class SystemPanel extends LinearLayout {
mBatteryText = (TextView)findViewById(R.id.battery_info);
mSignalText = (TextView)findViewById(R.id.signal_info);
refreshSignalMeters();
}
public void onDetachedFromWindow() {
@@ -362,11 +552,42 @@ public class SystemPanel extends LinearLayout {
PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
Slog.d(TAG, "phone service state changed: " + serviceState.getState());
if (DEBUG_SIGNAL || DEBUG) {
Slog.d(TAG, "phone service state changed: " + serviceState.getState());
}
mServiceState = serviceState;
mAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
if (mAirplaneButton != null) {
mAirplaneButton.setAlpha(mAirplaneMode ? 0xFF : 0x7F);
}
updateDataState();
}
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (DEBUG_SIGNAL || DEBUG) {
Slog.d(TAG, "onSignalStrengthsChanged: " + signalStrength);
}
mSignalStrength = signalStrength;
updateDataState();
}
@Override
public void onCallStateChanged(int state, String incomingNumber) {
mPhoneState = state;
// In cdma, if a voice call is made, RSSI should switch to 1x.
if (isCdma()) {
updateDataState();
}
}
@Override
public void onDataConnectionStateChanged(int state, int networkType) {
if (DEBUG_SIGNAL || DEBUG) {
Slog.d(TAG, "onDataConnectionStateChanged: state=" + state
+ " type=" + networkType);
}
mDataState = state;
// updateDataNetType(networkType);
updateDataState();
}
};

View File

@@ -212,10 +212,15 @@ public class TabletStatusBarService extends StatusBarService {
mBatteryMeter.setImageLevel(level);
}
public void setWifiMeter(int level) {
if (DEBUG) Slog.d(TAG, "wifi=" + level);
mSignalMeter.setImageResource(R.drawable.signal);
mSignalMeter.setImageLevel(level);
public void setSignalMeter(int level, boolean isWifi) {
if (DEBUG) Slog.d(TAG, "signal=" + level);
if (level < 0) {
mSignalMeter.setImageResource(isWifi ? R.drawable.wifi_scan : R.drawable.signal_scan);
mSignalMeter.setImageLevel(0);
} else {
mSignalMeter.setImageResource(isWifi ? R.drawable.wifi : R.drawable.signal);
mSignalMeter.setImageLevel(level);
}
}
public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) {