Loading core/java/android/os/BatteryStats.java +9 −3 Original line number Diff line number Diff line Loading @@ -1302,9 +1302,11 @@ public abstract class BatteryStats implements Parcelable { // Event for the UID that woke up the application processor. // Used for wakeups coming from WiFi, modem, etc. public static final int EVENT_WAKEUP_AP = 0x0013; // Event for reporting that a specific partial wake lock has been held for a long duration. public static final int EVENT_LONG_WAKE_LOCK = 0x0014; // Number of event types. public static final int EVENT_COUNT = 0x0014; public static final int EVENT_COUNT = 0x0015; // Mask to extract out only the type part of the event. public static final int EVENT_TYPE_MASK = ~(EVENT_FLAG_START|EVENT_FLAG_FINISH); Loading Loading @@ -1332,6 +1334,10 @@ public abstract class BatteryStats implements Parcelable { EVENT_TEMP_WHITELIST | EVENT_FLAG_START; public static final int EVENT_TEMP_WHITELIST_FINISH = EVENT_TEMP_WHITELIST | EVENT_FLAG_FINISH; public static final int EVENT_LONG_WAKE_LOCK_START = EVENT_LONG_WAKE_LOCK | EVENT_FLAG_START; public static final int EVENT_LONG_WAKE_LOCK_FINISH = EVENT_LONG_WAKE_LOCK | EVENT_FLAG_FINISH; // For CMD_EVENT. public int eventCode; Loading Loading @@ -1996,13 +2002,13 @@ public abstract class BatteryStats implements Parcelable { public static final String[] HISTORY_EVENT_NAMES = new String[] { "null", "proc", "fg", "top", "sync", "wake_lock_in", "job", "user", "userfg", "conn", "active", "pkginst", "pkgunin", "alarm", "stats", "inactive", "active", "tmpwhitelist", "screenwake", "wakeupap" "screenwake", "wakeupap", "longwake" }; public static final String[] HISTORY_EVENT_CHECKIN_NAMES = new String[] { "Enl", "Epr", "Efg", "Etp", "Esy", "Ewl", "Ejb", "Eur", "Euf", "Ecn", "Eac", "Epi", "Epu", "Eal", "Est", "Eai", "Eaa", "Etw", "Esw", "Ewa" "Esw", "Ewa", "Elw" }; /** Loading core/java/com/android/internal/app/IBatteryStats.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,8 @@ interface IBatteryStats { String newHistoryName, int newType, boolean newUnimportantForLogging); void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type); void noteLongPartialWakelockStart(String name, String historyName, int uid); void noteLongPartialWakelockFinish(String name, String historyName, int uid); void noteVibratorOn(int uid, long durationMillis); void noteVibratorOff(int uid); Loading core/java/com/android/internal/os/BatteryStatsImpl.java +30 −0 Original line number Diff line number Diff line Loading @@ -3285,6 +3285,36 @@ public class BatteryStatsImpl extends BatteryStats { } } public void noteLongPartialWakelockStart(String name, String historyName, int uid) { uid = mapUid(uid); final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { historyName = name; } if (!mActiveEvents.updateState(HistoryItem.EVENT_LONG_WAKE_LOCK_START, historyName, uid, 0)) { return; } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_START, historyName, uid); } public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { uid = mapUid(uid); final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { historyName = name; } if (!mActiveEvents.updateState(HistoryItem.EVENT_LONG_WAKE_LOCK_FINISH, historyName, uid, 0)) { return; } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_FINISH, historyName, uid); } void aggregateLastWakeupUptimeLocked(long uptimeMs) { if (mLastWakeupReason != null) { long deltaUptime = uptimeMs - mLastWakeupUptimeMs; Loading services/core/java/com/android/server/am/BatteryStatsService.java +14 −0 Original line number Diff line number Diff line Loading @@ -484,6 +484,20 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } public void noteLongPartialWakelockStart(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockStart(name, historyName, uid); } } public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockFinish(name, historyName, uid); } } public void noteStartSensor(int uid, int sensor) { enforceCallingPermission(); synchronized (mStats) { Loading services/core/java/com/android/server/power/Notifier.java +42 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,48 @@ final class Notifier { } } public void onLongPartialWakeLockStart(String tag, int ownerUid, WorkSource workSource, String historyTag) { if (DEBUG) { Slog.d(TAG, "onLongPartialWakeLockStart: ownerUid=" + ownerUid + ", workSource=" + workSource); } try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, workSource.get(i)); } } else { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, ownerUid); } } catch (RemoteException ex) { // Ignore } } public void onLongPartialWakeLockFinish(String tag, int ownerUid, WorkSource workSource, String historyTag) { if (DEBUG) { Slog.d(TAG, "onLongPartialWakeLockFinish: ownerUid=" + ownerUid + ", workSource=" + workSource); } try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, workSource.get(i)); } } else { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, ownerUid); } } catch (RemoteException ex) { // Ignore } } /** * Called when a wake lock is changing. */ Loading Loading
core/java/android/os/BatteryStats.java +9 −3 Original line number Diff line number Diff line Loading @@ -1302,9 +1302,11 @@ public abstract class BatteryStats implements Parcelable { // Event for the UID that woke up the application processor. // Used for wakeups coming from WiFi, modem, etc. public static final int EVENT_WAKEUP_AP = 0x0013; // Event for reporting that a specific partial wake lock has been held for a long duration. public static final int EVENT_LONG_WAKE_LOCK = 0x0014; // Number of event types. public static final int EVENT_COUNT = 0x0014; public static final int EVENT_COUNT = 0x0015; // Mask to extract out only the type part of the event. public static final int EVENT_TYPE_MASK = ~(EVENT_FLAG_START|EVENT_FLAG_FINISH); Loading Loading @@ -1332,6 +1334,10 @@ public abstract class BatteryStats implements Parcelable { EVENT_TEMP_WHITELIST | EVENT_FLAG_START; public static final int EVENT_TEMP_WHITELIST_FINISH = EVENT_TEMP_WHITELIST | EVENT_FLAG_FINISH; public static final int EVENT_LONG_WAKE_LOCK_START = EVENT_LONG_WAKE_LOCK | EVENT_FLAG_START; public static final int EVENT_LONG_WAKE_LOCK_FINISH = EVENT_LONG_WAKE_LOCK | EVENT_FLAG_FINISH; // For CMD_EVENT. public int eventCode; Loading Loading @@ -1996,13 +2002,13 @@ public abstract class BatteryStats implements Parcelable { public static final String[] HISTORY_EVENT_NAMES = new String[] { "null", "proc", "fg", "top", "sync", "wake_lock_in", "job", "user", "userfg", "conn", "active", "pkginst", "pkgunin", "alarm", "stats", "inactive", "active", "tmpwhitelist", "screenwake", "wakeupap" "screenwake", "wakeupap", "longwake" }; public static final String[] HISTORY_EVENT_CHECKIN_NAMES = new String[] { "Enl", "Epr", "Efg", "Etp", "Esy", "Ewl", "Ejb", "Eur", "Euf", "Ecn", "Eac", "Epi", "Epu", "Eal", "Est", "Eai", "Eaa", "Etw", "Esw", "Ewa" "Esw", "Ewa", "Elw" }; /** Loading
core/java/com/android/internal/app/IBatteryStats.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,8 @@ interface IBatteryStats { String newHistoryName, int newType, boolean newUnimportantForLogging); void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type); void noteLongPartialWakelockStart(String name, String historyName, int uid); void noteLongPartialWakelockFinish(String name, String historyName, int uid); void noteVibratorOn(int uid, long durationMillis); void noteVibratorOff(int uid); Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +30 −0 Original line number Diff line number Diff line Loading @@ -3285,6 +3285,36 @@ public class BatteryStatsImpl extends BatteryStats { } } public void noteLongPartialWakelockStart(String name, String historyName, int uid) { uid = mapUid(uid); final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { historyName = name; } if (!mActiveEvents.updateState(HistoryItem.EVENT_LONG_WAKE_LOCK_START, historyName, uid, 0)) { return; } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_START, historyName, uid); } public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { uid = mapUid(uid); final long elapsedRealtime = mClocks.elapsedRealtime(); final long uptime = mClocks.uptimeMillis(); if (historyName == null) { historyName = name; } if (!mActiveEvents.updateState(HistoryItem.EVENT_LONG_WAKE_LOCK_FINISH, historyName, uid, 0)) { return; } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_LONG_WAKE_LOCK_FINISH, historyName, uid); } void aggregateLastWakeupUptimeLocked(long uptimeMs) { if (mLastWakeupReason != null) { long deltaUptime = uptimeMs - mLastWakeupUptimeMs; Loading
services/core/java/com/android/server/am/BatteryStatsService.java +14 −0 Original line number Diff line number Diff line Loading @@ -484,6 +484,20 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } public void noteLongPartialWakelockStart(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockStart(name, historyName, uid); } } public void noteLongPartialWakelockFinish(String name, String historyName, int uid) { enforceCallingPermission(); synchronized (mStats) { mStats.noteLongPartialWakelockFinish(name, historyName, uid); } } public void noteStartSensor(int uid, int sensor) { enforceCallingPermission(); synchronized (mStats) { Loading
services/core/java/com/android/server/power/Notifier.java +42 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,48 @@ final class Notifier { } } public void onLongPartialWakeLockStart(String tag, int ownerUid, WorkSource workSource, String historyTag) { if (DEBUG) { Slog.d(TAG, "onLongPartialWakeLockStart: ownerUid=" + ownerUid + ", workSource=" + workSource); } try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, workSource.get(i)); } } else { mBatteryStats.noteLongPartialWakelockStart(tag, historyTag, ownerUid); } } catch (RemoteException ex) { // Ignore } } public void onLongPartialWakeLockFinish(String tag, int ownerUid, WorkSource workSource, String historyTag) { if (DEBUG) { Slog.d(TAG, "onLongPartialWakeLockFinish: ownerUid=" + ownerUid + ", workSource=" + workSource); } try { if (workSource != null) { final int N = workSource.size(); for (int i=0; i<N; i++) { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, workSource.get(i)); } } else { mBatteryStats.noteLongPartialWakelockFinish(tag, historyTag, ownerUid); } } catch (RemoteException ex) { // Ignore } } /** * Called when a wake lock is changing. */ Loading