diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-14 13:24:52 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-14 13:24:52 -0700 |
commit | 2a5cfe519298702ef71ff8755b14f8daf6a92b2a (patch) | |
tree | 51119ea6433cacc8b6b2b22c0bc8065005e01c58 /core/java/com | |
parent | 4a8fb93f5e320f5bd5c1dd272339ae499e4b4ec4 (diff) | |
parent | 5347bd4cda2b6afc18f8acab48e52131f35ed13c (diff) | |
download | frameworks_base-2a5cfe519298702ef71ff8755b14f8daf6a92b2a.zip frameworks_base-2a5cfe519298702ef71ff8755b14f8daf6a92b2a.tar.gz frameworks_base-2a5cfe519298702ef71ff8755b14f8daf6a92b2a.tar.bz2 |
Merge change 1590 into donut
* changes:
Add wifi multicast filter api (enable/disable). Fixes 1833432. Automatically re-disables any request when the app exits/crashes. Also hooked into Battery Stats for power managment analysis.
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/app/IBatteryStats.aidl | 2 | ||||
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 58 |
2 files changed, 55 insertions, 5 deletions
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl index 9ce532c..e1ff2a5 100644 --- a/core/java/com/android/internal/app/IBatteryStats.aidl +++ b/core/java/com/android/internal/app/IBatteryStats.aidl @@ -45,6 +45,8 @@ interface IBatteryStats { void noteFullWifiLockReleased(int uid); void noteScanWifiLockAcquired(int uid); void noteScanWifiLockReleased(int uid); + void noteWifiMulticastEnabled(int uid); + void noteWifiMulticastDisabled(int uid); void setOnBattery(boolean onBattery, int level); void recordCurrentLevel(int level); long getAwakeTimeBattery(); diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 1218fe3..e8356a2 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -1115,7 +1115,21 @@ public final class BatteryStatsImpl extends BatteryStats { u.noteScanWifiLockReleasedLocked(); } } - + + public void noteWifiMulticastEnabledLocked(int uid) { + Uid u = mUidStats.get(uid); + if (u != null) { + u.noteWifiMulticastEnabledLocked(); + } + } + + public void noteWifiMulticastDisabledLocked(int uid) { + Uid u = mUidStats.get(uid); + if (u != null) { + u.noteWifiMulticastDisabledLocked(); + } + } + @Override public long getScreenOnTime(long batteryRealtime, int which) { return mScreenOnTimer.getTotalTimeLocked(batteryRealtime, which); } @@ -1200,7 +1214,10 @@ public final class BatteryStatsImpl extends BatteryStats { boolean mScanWifiLockOut; StopwatchTimer mScanWifiLockTimer; - + + boolean mWifiMulticastEnabled; + StopwatchTimer mWifiMulticastTimer; + Counter[] mUserActivityCounters; /** @@ -1228,6 +1245,8 @@ public final class BatteryStatsImpl extends BatteryStats { mWifiTurnedOnTimer = new StopwatchTimer(WIFI_TURNED_ON, null, mUnpluggables); mFullWifiLockTimer = new StopwatchTimer(FULL_WIFI_LOCK, null, mUnpluggables); mScanWifiLockTimer = new StopwatchTimer(SCAN_WIFI_LOCK, null, mUnpluggables); + mWifiMulticastTimer = new StopwatchTimer(WIFI_MULTICAST_ENABLED, + null, mUnpluggables); } @Override @@ -1334,7 +1353,23 @@ public final class BatteryStatsImpl extends BatteryStats { mScanWifiLockTimer.stopRunningLocked(BatteryStatsImpl.this); } } - + + @Override + public void noteWifiMulticastEnabledLocked() { + if (!mWifiMulticastEnabled) { + mWifiMulticastEnabled = true; + mWifiMulticastTimer.startRunningLocked(BatteryStatsImpl.this); + } + } + + @Override + public void noteWifiMulticastDisabledLocked() { + if (mWifiMulticastEnabled) { + mWifiMulticastEnabled = false; + mWifiMulticastTimer.stopRunningLocked(BatteryStatsImpl.this); + } + } + @Override public long getWifiTurnedOnTime(long batteryRealtime, int which) { return mWifiTurnedOnTimer.getTotalTimeLocked(batteryRealtime, which); @@ -1349,7 +1384,13 @@ public final class BatteryStatsImpl extends BatteryStats { public long getScanWifiLockTime(long batteryRealtime, int which) { return mScanWifiLockTimer.getTotalTimeLocked(batteryRealtime, which); } - + + @Override + public long getWifiMulticastTime(long batteryRealtime, int which) { + return mWifiMulticastTimer.getTotalTimeLocked(batteryRealtime, + which); + } + @Override public void noteUserActivityLocked(int type) { if (mUserActivityCounters == null) { @@ -1423,6 +1464,7 @@ public final class BatteryStatsImpl extends BatteryStats { mWifiTurnedOnTimer.writeToParcel(out, batteryRealtime); mFullWifiLockTimer.writeToParcel(out, batteryRealtime); mScanWifiLockTimer.writeToParcel(out, batteryRealtime); + mWifiMulticastTimer.writeToParcel(out, batteryRealtime); if (mUserActivityCounters == null) { out.writeInt(0); } else { @@ -1482,6 +1524,9 @@ public final class BatteryStatsImpl extends BatteryStats { mFullWifiLockTimer = new StopwatchTimer(FULL_WIFI_LOCK, null, mUnpluggables, in); mScanWifiLockOut = false; mScanWifiLockTimer = new StopwatchTimer(SCAN_WIFI_LOCK, null, mUnpluggables, in); + mWifiMulticastEnabled = false; + mWifiMulticastTimer = new StopwatchTimer(WIFI_MULTICAST_ENABLED, + null, mUnpluggables, in); if (in.readInt() == 0) { mUserActivityCounters = null; } else { @@ -2709,7 +2754,9 @@ public final class BatteryStatsImpl extends BatteryStats { u.mFullWifiLockTimer.readSummaryFromParcelLocked(in); u.mScanWifiLockOut = false; u.mScanWifiLockTimer.readSummaryFromParcelLocked(in); - + u.mWifiMulticastEnabled = false; + u.mWifiMulticastTimer.readSummaryFromParcelLocked(in); + if (in.readInt() != 0) { if (u.mUserActivityCounters == null) { u.initUserActivityLocked(); @@ -2842,6 +2889,7 @@ public final class BatteryStatsImpl extends BatteryStats { u.mWifiTurnedOnTimer.writeSummaryFromParcelLocked(out, NOWREAL); u.mFullWifiLockTimer.writeSummaryFromParcelLocked(out, NOWREAL); u.mScanWifiLockTimer.writeSummaryFromParcelLocked(out, NOWREAL); + u.mWifiMulticastTimer.writeSummaryFromParcelLocked(out, NOWREAL); if (u.mUserActivityCounters == null) { out.writeInt(0); |