summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <>2009-03-24 22:40:29 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-24 22:40:29 -0700
commit4840e143df9804e3399a4e0341c0601f80d65d6e (patch)
tree02aedc5409c721f27aa34395d130a91da89f7364
parent9f4be9572d6e8709af0860bb719cafa107c7286b (diff)
downloadframeworks_base-4840e143df9804e3399a4e0341c0601f80d65d6e.zip
frameworks_base-4840e143df9804e3399a4e0341c0601f80d65d6e.tar.gz
frameworks_base-4840e143df9804e3399a4e0341c0601f80d65d6e.tar.bz2
Automated import from //branches/master/...@142348,142348
-rw-r--r--core/java/android/os/BatteryStats.java115
-rw-r--r--core/java/com/android/internal/app/IBatteryStats.aidl2
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java133
-rw-r--r--services/java/com/android/server/TelephonyRegistry.java11
-rw-r--r--services/java/com/android/server/am/BatteryStatsService.java15
-rw-r--r--services/java/com/android/server/status/StatusBarPolicy.java24
6 files changed, 270 insertions, 30 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index d492b6a..c72b828 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -4,8 +4,6 @@ import java.io.PrintWriter;
import java.util.Formatter;
import java.util.Map;
-import com.android.internal.os.BatteryStatsImpl.Timer;
-
import android.util.Log;
import android.util.Printer;
import android.util.SparseArray;
@@ -92,6 +90,8 @@ public abstract class BatteryStats implements Parcelable {
private static final String BATTERY_DATA = "battery";
private static final String WIFI_LOCK_DATA = "wifilock";
private static final String MISC_DATA = "misc";
+ private static final String SIGNAL_STRENGTH_DATA = "signal";
+ private static final String DATA_CONNECTION_DATA = "dataconn";
private final StringBuilder mFormatBuilder = new StringBuilder(8);
private final Formatter mFormatter = new Formatter(mFormatBuilder);
@@ -122,7 +122,7 @@ public abstract class BatteryStats implements Parcelable {
/**
* Temporary for debugging.
*/
- public abstract void logState();
+ public abstract void logState(Printer pw, String prefix);
}
/**
@@ -293,6 +293,48 @@ public abstract class BatteryStats implements Parcelable {
*/
public abstract long getPhoneOnTime(long batteryRealtime, int which);
+ public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
+ public static final int SIGNAL_STRENGTH_POOR = 1;
+ public static final int SIGNAL_STRENGTH_MODERATE = 2;
+ public static final int SIGNAL_STRENGTH_GOOD = 3;
+ public static final int SIGNAL_STRENGTH_GREAT = 4;
+
+ static final String[] SIGNAL_STRENGTH_NAMES = {
+ "none", "poor", "moderate", "good", "great"
+ };
+
+ public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
+
+ /**
+ * Returns the time in milliseconds that the phone has been running with
+ * the given signal strength.
+ *
+ * {@hide}
+ */
+ public abstract long getPhoneSignalStrengthTime(int strengthBin,
+ long batteryRealtime, int which);
+
+ public static final int DATA_CONNECTION_NONE = 0;
+ public static final int DATA_CONNECTION_GPRS = 1;
+ public static final int DATA_CONNECTION_EDGE = 2;
+ public static final int DATA_CONNECTION_UMTS = 3;
+ public static final int DATA_CONNECTION_OTHER = 4;
+
+ static final String[] DATA_CONNECTION_NAMES = {
+ "none", "gprs", "edge", "umts", "other"
+ };
+
+ public static final int NUM_DATA_CONNECTION_TYPES = 5;
+
+ /**
+ * Returns the time in milliseconds that the phone has been running with
+ * the given data connection.
+ *
+ * {@hide}
+ */
+ public abstract long getPhoneDataConnectionTime(int dataType,
+ long batteryRealtime, int which);
+
/**
* Returns the time in milliseconds that wifi has been on while the device was
* running on battery.
@@ -561,6 +603,20 @@ public abstract class BatteryStats implements Parcelable {
screenOnTime / 1000, phoneOnTime / 1000, wifiOnTime / 1000,
wifiRunningTime / 1000, bluetoothOnTime / 1000);
+ // Dump signal strength stats
+ Object[] args = new Object[NUM_SIGNAL_STRENGTH_BINS];
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ args[i] = getPhoneSignalStrengthTime(i, batteryRealtime, which) / 1000;
+ }
+ dumpLine(pw, 0 /* uid */, category, SIGNAL_STRENGTH_DATA, args);
+
+ // Dump network type stats
+ args = new Object[NUM_DATA_CONNECTION_TYPES];
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ args[i] = getPhoneDataConnectionTime(i, batteryRealtime, which) / 1000;
+ }
+ dumpLine(pw, 0 /* uid */, category, DATA_CONNECTION_DATA, args);
+
if (which == STATS_UNPLUGGED) {
dumpLine(pw, 0 /* uid */, category, BATTERY_DATA, getUnpluggedStartLevel(),
getPluggedStartLevel());
@@ -706,17 +762,58 @@ public abstract class BatteryStats implements Parcelable {
final long wifiOnTime = getWifiOnTime(batteryRealtime, which);
final long bluetoothOnTime = getBluetoothOnTime(batteryRealtime, which);
pw.println(prefix
- + " Time with screen on: " + formatTimeMs(screenOnTime / 1000)
+ + " Screen on: " + formatTimeMs(screenOnTime / 1000)
+ "(" + formatRatioLocked(screenOnTime, whichBatteryRealtime)
- + "), time with phone on: " + formatTimeMs(phoneOnTime / 1000)
- + "(" + formatRatioLocked(phoneOnTime, whichBatteryRealtime)
- + "), time with wifi on: " + formatTimeMs(wifiOnTime / 1000)
+ + "), Phone on: " + formatTimeMs(phoneOnTime / 1000)
+ + "(" + formatRatioLocked(phoneOnTime, whichBatteryRealtime));
+ pw.println(prefix
+ + " Wifi on: " + formatTimeMs(wifiOnTime / 1000)
+ "(" + formatRatioLocked(wifiOnTime, whichBatteryRealtime)
- + "), time with wifi running: " + formatTimeMs(wifiRunningTime / 1000)
+ + "), Wifi running: " + formatTimeMs(wifiRunningTime / 1000)
+ "(" + formatRatioLocked(wifiRunningTime, whichBatteryRealtime)
- + "), time with bluetooth on: " + formatTimeMs(bluetoothOnTime / 1000)
+ + "), Bluetooth on: " + formatTimeMs(bluetoothOnTime / 1000)
+ "(" + formatRatioLocked(bluetoothOnTime, whichBatteryRealtime)+ ")");
+ sb.setLength(0);
+ sb.append(" Signal strengths: ");
+ boolean didOne = false;
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ final long time = getPhoneSignalStrengthTime(i, batteryRealtime, which);
+ if (time == 0) {
+ continue;
+ }
+ if (didOne) sb.append(", ");
+ didOne = true;
+ sb.append(SIGNAL_STRENGTH_NAMES[i]);
+ sb.append(" ");
+ sb.append(formatTimeMs(time/1000));
+ sb.append("(");
+ sb.append(formatRatioLocked(time, whichBatteryRealtime));
+ sb.append(")");
+ }
+ if (!didOne) sb.append("No activity");
+ pw.println(sb.toString());
+
+ sb.setLength(0);
+ sb.append(" Data types: ");
+ didOne = false;
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ final long time = getPhoneDataConnectionTime(i, batteryRealtime, which);
+ if (time == 0) {
+ continue;
+ }
+ if (didOne) sb.append(", ");
+ didOne = true;
+ sb.append(DATA_CONNECTION_NAMES[i]);
+ sb.append(" ");
+ sb.append(formatTimeMs(time/1000));
+ sb.append("(");
+ sb.append(formatRatioLocked(time, whichBatteryRealtime));
+ sb.append(")");
+ }
+ if (!didOne) sb.append("No activity");
+ pw.println(sb.toString());
+
pw.println(" ");
if (which == STATS_UNPLUGGED) {
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index e0de421..fff8dcf 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -30,6 +30,8 @@ interface IBatteryStats {
void noteScreenOff();
void notePhoneOn();
void notePhoneOff();
+ void notePhoneSignalStrength(int asu);
+ void notePhoneDataConnectionState(int dataType, boolean hasData);
void noteWifiOn();
void noteWifiOff();
void noteWifiRunning();
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 38335b5..9e07fd8 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -22,6 +22,7 @@ import android.os.Parcel;
import android.os.ParcelFormatException;
import android.os.Parcelable;
import android.os.SystemClock;
+import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Printer;
import android.util.SparseArray;
@@ -47,7 +48,7 @@ public final class BatteryStatsImpl extends BatteryStats {
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 28;
+ private static final int VERSION = 29;
private final File mFile;
private final File mBackupFile;
@@ -92,6 +93,12 @@ public final class BatteryStatsImpl extends BatteryStats {
boolean mPhoneOn;
Timer mPhoneOnTimer;
+ int mPhoneSignalStrengthBin = -1;
+ final Timer[] mPhoneSignalStrengthsTimer = new Timer[NUM_SIGNAL_STRENGTH_BINS];
+
+ int mPhoneDataConnectionType = -1;
+ final Timer[] mPhoneDataConnectionsTimer = new Timer[NUM_DATA_CONNECTION_TYPES];
+
boolean mWifiOn;
Timer mWifiOnTimer;
@@ -307,15 +314,15 @@ public final class BatteryStatsImpl extends BatteryStats {
return val;
}
- public void logState() {
- Log.i("foo", "mNesting=" + mNesting + " mCount=" + mCount
+ public void logState(Printer pw, String prefix) {
+ pw.println(prefix + "mNesting=" + mNesting + " mCount=" + mCount
+ " mLoadedCount=" + mLoadedCount + " mLastCount=" + mLastCount
+ " mUnpluggedCount=" + mUnpluggedCount);
- Log.i("foo", "mTotalTime=" + mTotalTime
+ pw.println(prefix + "mTotalTime=" + mTotalTime
+ " mLoadedTime=" + mLoadedTime);
- Log.i("foo", "mLastTime=" + mLastTime
+ pw.println(prefix + "mLastTime=" + mLastTime
+ " mUnpluggedTime=" + mUnpluggedTime);
- Log.i("foo", "mUpdateTime=" + mUpdateTime
+ pw.println(prefix + "mUpdateTime=" + mUpdateTime
+ " mAcquireTime=" + mAcquireTime);
}
@@ -486,6 +493,50 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
+ public void notePhoneSignalStrengthLocked(int asu) {
+ // Bin the strength.
+ int bin;
+ if (asu < 0 || asu >= 99) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
+ else if (asu >= 16) bin = SIGNAL_STRENGTH_GREAT;
+ else if (asu >= 8) bin = SIGNAL_STRENGTH_GOOD;
+ else if (asu >= 4) bin = SIGNAL_STRENGTH_MODERATE;
+ else bin = SIGNAL_STRENGTH_POOR;
+ if (mPhoneSignalStrengthBin != bin) {
+ if (mPhoneSignalStrengthBin >= 0) {
+ mPhoneSignalStrengthsTimer[mPhoneSignalStrengthBin].stopRunningLocked(this);
+ }
+ mPhoneSignalStrengthBin = bin;
+ mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
+ }
+ }
+
+ public void notePhoneDataConnectionStateLocked(int dataType, boolean hasData) {
+ int bin = DATA_CONNECTION_NONE;
+ if (hasData) {
+ switch (dataType) {
+ case TelephonyManager.NETWORK_TYPE_EDGE:
+ bin = DATA_CONNECTION_EDGE;
+ break;
+ case TelephonyManager.NETWORK_TYPE_GPRS:
+ bin = DATA_CONNECTION_GPRS;
+ break;
+ case TelephonyManager.NETWORK_TYPE_UMTS:
+ bin = DATA_CONNECTION_UMTS;
+ break;
+ default:
+ bin = DATA_CONNECTION_OTHER;
+ break;
+ }
+ }
+ if (mPhoneDataConnectionType != bin) {
+ if (mPhoneDataConnectionType >= 0) {
+ mPhoneDataConnectionsTimer[mPhoneDataConnectionType].stopRunningLocked(this);
+ }
+ mPhoneDataConnectionType = bin;
+ mPhoneDataConnectionsTimer[bin].startRunningLocked(this);
+ }
+ }
+
public void noteWifiOnLocked() {
if (!mWifiOn) {
mWifiOn = true;
@@ -564,6 +615,18 @@ public final class BatteryStatsImpl extends BatteryStats {
return mPhoneOnTimer.getTotalTime(batteryRealtime, which);
}
+ @Override public long getPhoneSignalStrengthTime(int strengthBin,
+ long batteryRealtime, int which) {
+ return mPhoneSignalStrengthsTimer[strengthBin].getTotalTime(
+ batteryRealtime, which);
+ }
+
+ @Override public long getPhoneDataConnectionTime(int dataType,
+ long batteryRealtime, int which) {
+ return mPhoneDataConnectionsTimer[dataType].getTotalTime(
+ batteryRealtime, which);
+ }
+
@Override public long getWifiOnTime(long batteryRealtime, int which) {
return mWifiOnTimer.getTotalTime(batteryRealtime, which);
}
@@ -1617,6 +1680,12 @@ public final class BatteryStatsImpl extends BatteryStats {
mStartCount++;
mScreenOnTimer = new Timer(-1, null, mUnpluggables);
mPhoneOnTimer = new Timer(-2, null, mUnpluggables);
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ mPhoneSignalStrengthsTimer[i] = new Timer(-100-i, null, mUnpluggables);
+ }
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ mPhoneDataConnectionsTimer[i] = new Timer(-200-i, null, mUnpluggables);
+ }
mWifiOnTimer = new Timer(-3, null, mUnpluggables);
mWifiRunningTimer = new Timer(-4, null, mUnpluggables);
mBluetoothOnTimer = new Timer(-5, null, mUnpluggables);
@@ -1955,6 +2024,12 @@ public final class BatteryStatsImpl extends BatteryStats {
mScreenOnTimer.readSummaryFromParcelLocked(in);
mPhoneOn = false;
mPhoneOnTimer.readSummaryFromParcelLocked(in);
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ mPhoneSignalStrengthsTimer[i].readSummaryFromParcelLocked(in);
+ }
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ mPhoneDataConnectionsTimer[i].readSummaryFromParcelLocked(in);
+ }
mWifiOn = false;
mWifiOnTimer.readSummaryFromParcelLocked(in);
mWifiRunning = false;
@@ -2061,6 +2136,12 @@ public final class BatteryStatsImpl extends BatteryStats {
mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
mPhoneOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ mPhoneSignalStrengthsTimer[i].writeSummaryFromParcelLocked(out, NOWREAL);
+ }
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ mPhoneDataConnectionsTimer[i].writeSummaryFromParcelLocked(out, NOWREAL);
+ }
mWifiOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
mWifiRunningTimer.writeSummaryFromParcelLocked(out, NOWREAL);
mBluetoothOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
@@ -2186,6 +2267,12 @@ public final class BatteryStatsImpl extends BatteryStats {
mScreenOnTimer = new Timer(-1, null, mUnpluggables, in);
mPhoneOn = false;
mPhoneOnTimer = new Timer(-2, null, mUnpluggables, in);
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ mPhoneSignalStrengthsTimer[i] = new Timer(-100-i, null, mUnpluggables, in);
+ }
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ mPhoneDataConnectionsTimer[i] = new Timer(-200-i, null, mUnpluggables, in);
+ }
mWifiOn = false;
mWifiOnTimer = new Timer(-2, null, mUnpluggables, in);
mWifiRunning = false;
@@ -2243,6 +2330,12 @@ public final class BatteryStatsImpl extends BatteryStats {
out.writeLong(mBatteryLastRealtime);
mScreenOnTimer.writeToParcel(out, batteryRealtime);
mPhoneOnTimer.writeToParcel(out, batteryRealtime);
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ mPhoneSignalStrengthsTimer[i].writeToParcel(out, batteryRealtime);
+ }
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ mPhoneDataConnectionsTimer[i].writeToParcel(out, batteryRealtime);
+ }
mWifiOnTimer.writeToParcel(out, batteryRealtime);
mWifiRunningTimer.writeToParcel(out, batteryRealtime);
mBluetoothOnTimer.writeToParcel(out, batteryRealtime);
@@ -2286,16 +2379,24 @@ public final class BatteryStatsImpl extends BatteryStats {
public void dumpLocked(Printer pw) {
if (DEBUG) {
- Log.i(TAG, "*** Screen timer:");
- mScreenOnTimer.logState();
- Log.i(TAG, "*** Phone timer:");
- mPhoneOnTimer.logState();
- Log.i(TAG, "*** Wifi timer:");
- mWifiOnTimer.logState();
- Log.i(TAG, "*** WifiRunning timer:");
- mWifiRunningTimer.logState();
- Log.i(TAG, "*** Bluetooth timer:");
- mBluetoothOnTimer.logState();
+ pw.println("*** Screen timer:");
+ mScreenOnTimer.logState(pw, " ");
+ pw.println("*** Phone timer:");
+ mPhoneOnTimer.logState(pw, " ");
+ for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
+ pw.println("*** Signal strength #" + i + ":");
+ mPhoneSignalStrengthsTimer[i].logState(pw, " ");
+ }
+ for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
+ pw.println("*** Data connection type #" + i + ":");
+ mPhoneDataConnectionsTimer[i].logState(pw, " ");
+ }
+ pw.println("*** Wifi timer:");
+ mWifiOnTimer.logState(pw, " ");
+ pw.println("*** WifiRunning timer:");
+ mWifiRunningTimer.logState(pw, " ");
+ pw.println("*** Bluetooth timer:");
+ mBluetoothOnTimer.logState(pw, " ");
}
super.dumpLocked(pw);
}
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index a74915c..fa54421 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -440,6 +440,14 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
private void broadcastSignalStrengthChanged(int asu) {
+ long ident = Binder.clearCallingIdentity();
+ try {
+ mBatteryStats.notePhoneSignalStrength(asu);
+ } catch (RemoteException e) {
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+
Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
intent.putExtra(PhoneStateIntentReceiver.INTENT_KEY_ASU, asu);
mContext.sendStickyBroadcast(intent);
@@ -469,6 +477,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
private void broadcastDataConnectionStateChanged(int state, boolean isDataConnectivityPossible,
String reason, String apn, String interfaceName) {
+ // Note: not reporting to the battery stats service here, because the
+ // status bar takes care of that after taking into account all of the
+ // required info.
Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString());
if (!isDataConnectivityPossible) {
diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java
index ee89c09..2192e06 100644
--- a/services/java/com/android/server/am/BatteryStatsService.java
+++ b/services/java/com/android/server/am/BatteryStatsService.java
@@ -25,6 +25,7 @@ import android.os.IBinder;
import android.os.Parcel;
import android.os.Process;
import android.os.ServiceManager;
+import android.telephony.TelephonyManager;
import android.util.PrintWriterPrinter;
import java.io.FileDescriptor;
@@ -149,6 +150,20 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
}
}
+ public void notePhoneSignalStrength(int asu) {
+ enforceCallingPermission();
+ synchronized (mStats) {
+ mStats.notePhoneSignalStrengthLocked(asu);
+ }
+ }
+
+ public void notePhoneDataConnectionState(int dataType, boolean hasData) {
+ enforceCallingPermission();
+ synchronized (mStats) {
+ mStats.notePhoneDataConnectionStateLocked(dataType, hasData);
+ }
+ }
+
public void noteWifiOn() {
enforceCallingPermission();
synchronized (mStats) {
diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java
index 36d1465..713cd13 100644
--- a/services/java/com/android/server/status/StatusBarPolicy.java
+++ b/services/java/com/android/server/status/StatusBarPolicy.java
@@ -17,9 +17,11 @@
package com.android.server.status;
import com.android.internal.R;
+import com.android.internal.app.IBatteryStats;
import com.android.internal.location.GpsLocationProvider;
import com.android.internal.telephony.SimCard;
import com.android.internal.telephony.TelephonyIntents;
+import com.android.server.am.BatteryStatsService;
import android.app.AlertDialog;
import android.bluetooth.BluetoothA2dp;
@@ -38,9 +40,11 @@ import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
+import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
+import android.os.RemoteException;
import android.provider.Settings;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
@@ -78,9 +82,10 @@ public class StatusBarPolicy {
private static final int BATTERY_THRESHOLD_WARNING = 1;
private static final int BATTERY_THRESHOLD_EMPTY = 2;
- private Context mContext;
- private StatusBarService mService;
- private Handler mHandler = new StatusBarHandler();
+ private final Context mContext;
+ private final StatusBarService mService;
+ private final Handler mHandler = new StatusBarHandler();
+ private final IBatteryStats mBatteryStats;
// clock
private Calendar mCalendar;
@@ -144,6 +149,7 @@ public class StatusBarPolicy {
SimCard.State mSimState = SimCard.State.READY;
int mPhoneState = TelephonyManager.CALL_STATE_IDLE;
int mDataState = TelephonyManager.DATA_DISCONNECTED;
+ int mDataNetType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
int mDataActivity = TelephonyManager.DATA_ACTIVITY_NONE;
ServiceState mServiceState;
int mSignalAsu = -1;
@@ -250,6 +256,7 @@ public class StatusBarPolicy {
private StatusBarPolicy(Context context, StatusBarService service) {
mContext = context;
mService = service;
+ mBatteryStats = BatteryStatsService.getService();
// clock
mCalendar = Calendar.getInstance(TimeZone.getDefault());
@@ -711,8 +718,8 @@ public class StatusBarPolicy {
}
private final void updateDataNetType() {
- int net = mPhone.getNetworkType();
- switch (net) {
+ mDataNetType = mPhone.getNetworkType();
+ switch (mDataNetType) {
case TelephonyManager.NETWORK_TYPE_EDGE:
mDataIconList = sDataNetType_e;
break;
@@ -766,6 +773,13 @@ public class StatusBarPolicy {
mDataData.iconId = com.android.internal.R.drawable.stat_sys_no_sim;
mService.updateIcon(mDataIcon, mDataData, null);
}
+ long ident = Binder.clearCallingIdentity();
+ try {
+ mBatteryStats.notePhoneDataConnectionState(mDataNetType, visible);
+ } catch (RemoteException e) {
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
if (mDataIconVisible != visible) {
mService.setIconVisibility(mDataIcon, visible);
mDataIconVisible = visible;