Add a method to note waking network packets to BatteryStats

This will be used to attribute CPU wakeups to the correct subsystem and
uids when possible.

Test: Builds, boots.

Bug: 265742148
Change-Id: I1a29fc7cbe74990e317f0d62d3894523387bdde1
Merged-In: I1a29fc7cbe74990e317f0d62d3894523387bdde1
This commit is contained in:
Suprabh Shukla
2023-01-25 13:22:31 -08:00
parent 83eb599a8f
commit 53b10b22d1
2 changed files with 15 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ package android.os;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.net.Network;
import com.android.internal.os.BinderCallsStats; import com.android.internal.os.BinderCallsStats;
import com.android.server.power.stats.SystemServerCpuThreadReader.SystemServiceCpuThreadTimes; import com.android.server.power.stats.SystemServerCpuThreadReader.SystemServiceCpuThreadTimes;
@@ -81,6 +82,15 @@ public abstract class BatteryStatsInternal {
*/ */
public abstract void noteJobsDeferred(int uid, int numDeferred, long sinceLast); public abstract void noteJobsDeferred(int uid, int numDeferred, long sinceLast);
/**
* Informs battery stats of a data packet that woke up the CPU.
*
* @param network The network over which the packet arrived.
* @param elapsedMillis The time of the packet's arrival in elapsed timebase.
* @param uid The uid that received the packet.
*/
public abstract void noteCpuWakingNetworkPacket(Network network, long elapsedMillis, int uid);
/** /**
* Informs battery stats of binder stats for the given work source UID. * Informs battery stats of binder stats for the given work source UID.
*/ */

View File

@@ -456,6 +456,11 @@ public final class BatteryStatsService extends IBatteryStats.Stub
BatteryStatsService.this.noteJobsDeferred(uid, numDeferred, sinceLast); BatteryStatsService.this.noteJobsDeferred(uid, numDeferred, sinceLast);
} }
@Override
public void noteCpuWakingNetworkPacket(Network network, long elapsedMillis, int uid) {
Slog.d(TAG, "Wakeup due to incoming packet on network " + network + " to uid " + uid);
}
@Override @Override
public void noteBinderCallStats(int workSourceUid, long incrementatCallCount, public void noteBinderCallStats(int workSourceUid, long incrementatCallCount,
Collection<BinderCallsStats.CallStat> callStats) { Collection<BinderCallsStats.CallStat> callStats) {