diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-05-14 11:42:00 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-05-15 13:32:29 -0700 |
commit | cbefd8dd2befcb768f911a63becc427ec4c13250 (patch) | |
tree | 083c53ca606811b4ccfbda8d013f29497b7efbd0 /services/core/java/com/android/server/power | |
parent | e7db83426e9979a0b6ecf124a013dc944dd3ccce (diff) | |
download | frameworks_base-cbefd8dd2befcb768f911a63becc427ec4c13250.zip frameworks_base-cbefd8dd2befcb768f911a63becc427ec4c13250.tar.gz frameworks_base-cbefd8dd2befcb768f911a63becc427ec4c13250.tar.bz2 |
Battery stats more wake history, power save mode.
Add new option for battery stats to record the full wake
lock history, and recording the current power save mode.
Also add in some additional error constants when generating
Binder error exceptions.
And fix issue #14974572: Avoid repeating wakeup_reason at
the beginning of history
Change-Id: I7c1a2ab9569de216634f63d8ad69f1294ef1d235
Diffstat (limited to 'services/core/java/com/android/server/power')
-rw-r--r-- | services/core/java/com/android/server/power/Notifier.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/power/PowerManagerService.java | 40 |
2 files changed, 43 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/power/Notifier.java b/services/core/java/com/android/server/power/Notifier.java index 2d6cc7c..e244bde 100644 --- a/services/core/java/com/android/server/power/Notifier.java +++ b/services/core/java/com/android/server/power/Notifier.java @@ -190,14 +190,14 @@ final class Notifier { + ", workSource=" + newWorkSource); } try { - mBatteryStats.noteChangeWakelockFromSource(workSource, ownerPid, tag, monitorType, - newWorkSource, newOwnerPid, newTag, newHistoryTag, + mBatteryStats.noteChangeWakelockFromSource(workSource, ownerPid, tag, historyTag, + monitorType, newWorkSource, newOwnerPid, newTag, newHistoryTag, newMonitorType, unimportantForLogging); } catch (RemoteException ex) { // Ignore } } else { - onWakeLockReleased(flags, tag, packageName, ownerUid, ownerPid, workSource); + onWakeLockReleased(flags, tag, packageName, ownerUid, ownerPid, workSource, historyTag); onWakeLockAcquired(newFlags, newTag, newPackageName, newOwnerUid, newOwnerPid, newWorkSource, newHistoryTag); } @@ -207,7 +207,7 @@ final class Notifier { * Called when a wake lock is released. */ public void onWakeLockReleased(int flags, String tag, String packageName, - int ownerUid, int ownerPid, WorkSource workSource) { + int ownerUid, int ownerPid, WorkSource workSource, String historyTag) { if (DEBUG) { Slog.d(TAG, "onWakeLockReleased: flags=" + flags + ", tag=\"" + tag + "\", packageName=" + packageName @@ -218,9 +218,10 @@ final class Notifier { try { final int monitorType = getBatteryStatsWakeLockMonitorType(flags); if (workSource != null) { - mBatteryStats.noteStopWakelockFromSource(workSource, ownerPid, tag, monitorType); + mBatteryStats.noteStopWakelockFromSource(workSource, ownerPid, tag, historyTag, + monitorType); } else { - mBatteryStats.noteStopWakelock(ownerUid, ownerPid, tag, monitorType); + mBatteryStats.noteStopWakelock(ownerUid, ownerPid, tag, historyTag, monitorType); mAppOps.finishOperation(AppOpsManager.getToken(mAppOps), AppOpsManager.OP_WAKE_LOCK, ownerUid, packageName); } diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 03941c6..f0b7861 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -18,6 +18,7 @@ package com.android.server.power; import com.android.internal.app.IAppOpsService; import com.android.internal.app.IBatteryStats; +import com.android.internal.os.BackgroundThread; import com.android.server.BatteryService; import com.android.server.EventLogTags; import com.android.server.LocalServices; @@ -400,7 +401,10 @@ public final class PowerManagerService extends com.android.server.SystemService private long mLastWarningAboutUserActivityPermission = Long.MIN_VALUE; // If true, the device is in low power mode. - private static boolean mLowPowerModeEnabled; + private boolean mLowPowerModeEnabled; + + private final ArrayList<PowerManagerInternal.LowPowerModeListener> mLowPowerModeListeners + = new ArrayList<PowerManagerInternal.LowPowerModeListener>(); private native void nativeInit(); @@ -623,11 +627,24 @@ public final class PowerManagerService extends com.android.server.SystemService Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT); - boolean lowPowerModeEnabled = Settings.Global.getInt(resolver, + final boolean lowPowerModeEnabled = Settings.Global.getInt(resolver, Settings.Global.LOW_POWER_MODE, 0) != 0; if (lowPowerModeEnabled != mLowPowerModeEnabled) { powerHintInternal(POWER_HINT_LOW_POWER_MODE, lowPowerModeEnabled ? 1 : 0); mLowPowerModeEnabled = lowPowerModeEnabled; + BackgroundThread.getHandler().post(new Runnable() { + @Override + public void run() { + ArrayList<PowerManagerInternal.LowPowerModeListener> listeners; + synchronized (mLock) { + listeners = new ArrayList<PowerManagerInternal.LowPowerModeListener>( + mLowPowerModeListeners); + } + for (int i=0; i<listeners.size(); i++) { + listeners.get(i).onLowPowerModeChanged(lowPowerModeEnabled); + } + } + }); } mDirty |= DIRTY_SETTINGS; @@ -812,8 +829,9 @@ public final class PowerManagerService extends com.android.server.SystemService private void notifyWakeLockReleasedLocked(WakeLock wakeLock) { if (mSystemReady && wakeLock.mNotifiedAcquired) { wakeLock.mNotifiedAcquired = false; - mNotifier.onWakeLockReleased(wakeLock.mFlags, wakeLock.mTag, wakeLock.mPackageName, - wakeLock.mOwnerUid, wakeLock.mOwnerPid, wakeLock.mWorkSource); + mNotifier.onWakeLockReleased(wakeLock.mFlags, wakeLock.mTag, + wakeLock.mPackageName, wakeLock.mOwnerUid, wakeLock.mOwnerPid, + wakeLock.mWorkSource, wakeLock.mHistoryTag); } } @@ -2972,6 +2990,20 @@ public final class PowerManagerService extends com.android.server.SystemService } @Override + public boolean getLowPowerModeEnabled() { + synchronized (mLock) { + return mLowPowerModeEnabled; + } + } + + @Override + public void registerLowPowerModeObserver(LowPowerModeListener listener) { + synchronized (mLock) { + mLowPowerModeListeners.add(listener); + } + } + + @Override public void setPolicy(WindowManagerPolicy policy) { PowerManagerService.this.setPolicy(policy); } |