Loading cmds/statsd/src/atoms.proto +21 −2 Original line number Diff line number Diff line Loading @@ -121,8 +121,7 @@ message Atom { ANROccurred anr_occurred = 79; WTFOccurred wtf_occurred = 80; LowMemReported low_mem_reported = 81; ThermalThrottlingStateChanged thermal_throttling = 86; } // Pulled events will start at field 10000. Loading Loading @@ -197,6 +196,26 @@ message AttributionNode { * ***************************************************************************** */ /** * Logs when the Thermal service HAL notifies the throttling start/stop events. * * Logged from: * frameworks/base/services/core/java/com/android/server/stats/StatsCompanionService.java */ message ThermalThrottlingStateChanged { optional android.os.TemperatureTypeEnum sensor_type = 1; enum State { UNKNOWN = 0; START = 1; STOP = 2; } optional State state = 2; optional float temperature = 3; } /** * Logs when the screen state changes. * Loading services/core/java/com/android/server/stats/StatsCompanionService.java +30 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import android.os.FileUtils; import android.os.IBinder; import android.os.IStatsCompanionService; import android.os.IStatsManager; import android.os.IThermalEventListener; import android.os.IThermalService; import android.os.Parcelable; import android.os.Process; import android.os.RemoteException; Loading @@ -52,6 +54,7 @@ import android.os.StatsDimensionsValue; import android.os.StatsLogEventWrapper; import android.os.SynchronousResultReceiver; import android.os.SystemClock; import android.os.Temperature; import android.os.UserHandle; import android.os.UserManager; import android.telephony.ModemActivityInfo; Loading Loading @@ -153,6 +156,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private KernelUidCpuClusterTimeReader mKernelUidCpuClusterTimeReader = new KernelUidCpuClusterTimeReader(); private static IThermalService sThermalService; public StatsCompanionService(Context context) { super(); mContext = context; Loading Loading @@ -203,6 +208,24 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { long[] freqs = mKernelUidCpuFreqTimeReader.readFreqs(powerProfile); mKernelUidCpuClusterTimeReader.setThrottleInterval(0); mKernelUidCpuActiveTimeReader.setThrottleInterval(0); // Enable push notifications of throttling from vendor thermal // management subsystem via thermalservice. IBinder b = ServiceManager.getService("thermalservice"); if (b != null) { sThermalService = IThermalService.Stub.asInterface(b); try { sThermalService.registerThermalEventListener( new ThermalEventListener()); Slog.i(TAG, "register thermal listener successfully"); } catch (RemoteException e) { // Should never happen. Slog.e(TAG, "register thermal listener error"); } } else { Slog.e(TAG, "cannot find thermalservice, no throttling push notifications"); } } @Override Loading Loading @@ -1181,4 +1204,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } // Thermal event received from vendor thermal management subsystem private static final class ThermalEventListener extends IThermalEventListener.Stub { @Override public void notifyThrottling(boolean isThrottling, Temperature temp) { StatsLog.write(StatsLog.THERMAL_THROTTLING, temp.getType(), isThrottling ? 1 : 0, temp.getValue()); } } } Loading
cmds/statsd/src/atoms.proto +21 −2 Original line number Diff line number Diff line Loading @@ -121,8 +121,7 @@ message Atom { ANROccurred anr_occurred = 79; WTFOccurred wtf_occurred = 80; LowMemReported low_mem_reported = 81; ThermalThrottlingStateChanged thermal_throttling = 86; } // Pulled events will start at field 10000. Loading Loading @@ -197,6 +196,26 @@ message AttributionNode { * ***************************************************************************** */ /** * Logs when the Thermal service HAL notifies the throttling start/stop events. * * Logged from: * frameworks/base/services/core/java/com/android/server/stats/StatsCompanionService.java */ message ThermalThrottlingStateChanged { optional android.os.TemperatureTypeEnum sensor_type = 1; enum State { UNKNOWN = 0; START = 1; STOP = 2; } optional State state = 2; optional float temperature = 3; } /** * Logs when the screen state changes. * Loading
services/core/java/com/android/server/stats/StatsCompanionService.java +30 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ import android.os.FileUtils; import android.os.IBinder; import android.os.IStatsCompanionService; import android.os.IStatsManager; import android.os.IThermalEventListener; import android.os.IThermalService; import android.os.Parcelable; import android.os.Process; import android.os.RemoteException; Loading @@ -52,6 +54,7 @@ import android.os.StatsDimensionsValue; import android.os.StatsLogEventWrapper; import android.os.SynchronousResultReceiver; import android.os.SystemClock; import android.os.Temperature; import android.os.UserHandle; import android.os.UserManager; import android.telephony.ModemActivityInfo; Loading Loading @@ -153,6 +156,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { private KernelUidCpuClusterTimeReader mKernelUidCpuClusterTimeReader = new KernelUidCpuClusterTimeReader(); private static IThermalService sThermalService; public StatsCompanionService(Context context) { super(); mContext = context; Loading Loading @@ -203,6 +208,24 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { long[] freqs = mKernelUidCpuFreqTimeReader.readFreqs(powerProfile); mKernelUidCpuClusterTimeReader.setThrottleInterval(0); mKernelUidCpuActiveTimeReader.setThrottleInterval(0); // Enable push notifications of throttling from vendor thermal // management subsystem via thermalservice. IBinder b = ServiceManager.getService("thermalservice"); if (b != null) { sThermalService = IThermalService.Stub.asInterface(b); try { sThermalService.registerThermalEventListener( new ThermalEventListener()); Slog.i(TAG, "register thermal listener successfully"); } catch (RemoteException e) { // Should never happen. Slog.e(TAG, "register thermal listener error"); } } else { Slog.e(TAG, "cannot find thermalservice, no throttling push notifications"); } } @Override Loading Loading @@ -1181,4 +1204,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } // Thermal event received from vendor thermal management subsystem private static final class ThermalEventListener extends IThermalEventListener.Stub { @Override public void notifyThrottling(boolean isThrottling, Temperature temp) { StatsLog.write(StatsLog.THERMAL_THROTTLING, temp.getType(), isThrottling ? 1 : 0, temp.getValue()); } } }