Loading core/java/com/android/internal/app/IBatteryStats.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -81,7 +81,11 @@ interface IBatteryStats { void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type); void noteLongPartialWakelockStart(String name, String historyName, int uid); void noteLongPartialWakelockStartFromSource(String name, String historyName, in WorkSource workSource); void noteLongPartialWakelockFinish(String name, String historyName, int uid); void noteLongPartialWakelockFinishFromSource(String name, String historyName, in WorkSource workSource); void noteVibratorOn(int uid, long durationMillis); void noteVibratorOff(int uid); Loading core/java/com/android/internal/os/BatteryStatsImpl.java +57 −2 Original line number Diff line number Diff line Loading @@ -4321,6 +4321,34 @@ public class BatteryStatsImpl extends BatteryStats { public void noteLongPartialWakelockStart(String name, String historyName, int uid) { uid = mapUid(uid); noteLongPartialWakeLockStartInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } public void noteLongPartialWakelockStartFromSource(String name, String historyName, WorkSource workSource) { final int N = workSource.size(); for (int i = 0; i < N; ++i) { final int uid = mapUid(workSource.get(i)); noteLongPartialWakeLockStartInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } final ArrayList<WorkChain> workChains = workSource.getWorkChains(); if (workChains != null) { for (int i = 0; i < workChains.size(); ++i) { final WorkChain workChain = workChains.get(i); final int uid = workChain.getAttributionUid(); noteLongPartialWakeLockStartInternal(name, historyName, uid); // TODO(statsd): the Log WorkChain to statds, and not just the uid. StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } } } private void noteLongPartialWakeLockStartInternal(String name, String historyName, int uid) { final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { Loading @@ -4332,11 +4360,39 @@ public class BatteryStatsImpl extends BatteryStats { } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_START, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { uid = mapUid(uid); noteLongPartialWakeLockFinishInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } public void noteLongPartialWakelockFinishFromSource(String name, String historyName, WorkSource workSource) { final int N = workSource.size(); for (int i = 0; i < N; ++i) { final int uid = mapUid(workSource.get(i)); noteLongPartialWakeLockFinishInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } final ArrayList<WorkChain> workChains = workSource.getWorkChains(); if (workChains != null) { for (int i = 0; i < workChains.size(); ++i) { final WorkChain workChain = workChains.get(i); final int uid = workChain.getAttributionUid(); noteLongPartialWakeLockFinishInternal(name, historyName, uid); // TODO(statsd): the Log WorkChain to statds, and not just the uid. StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } } } private void noteLongPartialWakeLockFinishInternal(String name, String historyName, int uid) { final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { Loading @@ -4348,7 +4404,6 @@ public class BatteryStatsImpl extends BatteryStats { } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_FINISH, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } void aggregateLastWakeupUptimeLocked(long uptimeMs) { Loading services/core/java/com/android/server/am/BatteryStatsService.java +20 −0 Original line number Diff line number Diff line Loading @@ -514,6 +514,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } @Override public void noteLongPartialWakelockStart(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { Loading @@ -521,6 +522,16 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } @Override public void noteLongPartialWakelockStartFromSource(String name, String historyName, WorkSource workSource) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockStartFromSource(name, historyName, workSource); } } @Override public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { Loading @@ -528,6 +539,15 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } @Override public void noteLongPartialWakelockFinishFromSource(String name, String historyName, WorkSource workSource) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockFinishFromSource(name, historyName, workSource); } } public void noteStartSensor(int uid, int sensor) { enforceCallingPermission(); synchronized (mStats) { Loading services/core/java/com/android/server/power/Notifier.java +2 −8 Original line number Diff line number Diff line Loading @@ -209,10 +209,7 @@ final class Notifier { try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, workSource.get(i)); } mBatteryStats.noteLongPartialWakelockStartFromSource(tag, historyTag, workSource); } else { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, ownerUid); } Loading @@ -230,10 +227,7 @@ final class Notifier { try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, workSource.get(i)); } mBatteryStats.noteLongPartialWakelockFinishFromSource(tag, historyTag, workSource); } else { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, ownerUid); } Loading Loading
core/java/com/android/internal/app/IBatteryStats.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -81,7 +81,11 @@ interface IBatteryStats { void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type); void noteLongPartialWakelockStart(String name, String historyName, int uid); void noteLongPartialWakelockStartFromSource(String name, String historyName, in WorkSource workSource); void noteLongPartialWakelockFinish(String name, String historyName, int uid); void noteLongPartialWakelockFinishFromSource(String name, String historyName, in WorkSource workSource); void noteVibratorOn(int uid, long durationMillis); void noteVibratorOff(int uid); Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +57 −2 Original line number Diff line number Diff line Loading @@ -4321,6 +4321,34 @@ public class BatteryStatsImpl extends BatteryStats { public void noteLongPartialWakelockStart(String name, String historyName, int uid) { uid = mapUid(uid); noteLongPartialWakeLockStartInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } public void noteLongPartialWakelockStartFromSource(String name, String historyName, WorkSource workSource) { final int N = workSource.size(); for (int i = 0; i < N; ++i) { final int uid = mapUid(workSource.get(i)); noteLongPartialWakeLockStartInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } final ArrayList<WorkChain> workChains = workSource.getWorkChains(); if (workChains != null) { for (int i = 0; i < workChains.size(); ++i) { final WorkChain workChain = workChains.get(i); final int uid = workChain.getAttributionUid(); noteLongPartialWakeLockStartInternal(name, historyName, uid); // TODO(statsd): the Log WorkChain to statds, and not just the uid. StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } } } private void noteLongPartialWakeLockStartInternal(String name, String historyName, int uid) { final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { Loading @@ -4332,11 +4360,39 @@ public class BatteryStatsImpl extends BatteryStats { } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_START, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 1); } public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { uid = mapUid(uid); noteLongPartialWakeLockFinishInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } public void noteLongPartialWakelockFinishFromSource(String name, String historyName, WorkSource workSource) { final int N = workSource.size(); for (int i = 0; i < N; ++i) { final int uid = mapUid(workSource.get(i)); noteLongPartialWakeLockFinishInternal(name, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } final ArrayList<WorkChain> workChains = workSource.getWorkChains(); if (workChains != null) { for (int i = 0; i < workChains.size(); ++i) { final WorkChain workChain = workChains.get(i); final int uid = workChain.getAttributionUid(); noteLongPartialWakeLockFinishInternal(name, historyName, uid); // TODO(statsd): the Log WorkChain to statds, and not just the uid. StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } } } private void noteLongPartialWakeLockFinishInternal(String name, String historyName, int uid) { final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { Loading @@ -4348,7 +4404,6 @@ public class BatteryStatsImpl extends BatteryStats { } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_FINISH, historyName, uid); StatsLog.write(StatsLog.LONG_PARTIAL_WAKELOCK_STATE_CHANGED, uid, name, historyName, 0); } void aggregateLastWakeupUptimeLocked(long uptimeMs) { Loading
services/core/java/com/android/server/am/BatteryStatsService.java +20 −0 Original line number Diff line number Diff line Loading @@ -514,6 +514,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } @Override public void noteLongPartialWakelockStart(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { Loading @@ -521,6 +522,16 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } @Override public void noteLongPartialWakelockStartFromSource(String name, String historyName, WorkSource workSource) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockStartFromSource(name, historyName, workSource); } } @Override public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { Loading @@ -528,6 +539,15 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } @Override public void noteLongPartialWakelockFinishFromSource(String name, String historyName, WorkSource workSource) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockFinishFromSource(name, historyName, workSource); } } public void noteStartSensor(int uid, int sensor) { enforceCallingPermission(); synchronized (mStats) { Loading
services/core/java/com/android/server/power/Notifier.java +2 −8 Original line number Diff line number Diff line Loading @@ -209,10 +209,7 @@ final class Notifier { try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, workSource.get(i)); } mBatteryStats.noteLongPartialWakelockStartFromSource(tag, historyTag, workSource); } else { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, ownerUid); } Loading @@ -230,10 +227,7 @@ final class Notifier { try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, workSource.get(i)); } mBatteryStats.noteLongPartialWakelockFinishFromSource(tag, historyTag, workSource); } else { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, ownerUid); } Loading