Merge "thermal: Add pulled cooling device atom and a field to Temperature atom" into qt-dev
This commit is contained in:
@@ -340,6 +340,7 @@ message Atom {
|
||||
SystemIonHeapSize system_ion_heap_size = 10056;
|
||||
AppsOnExternalStorageInfo apps_on_external_storage_info = 10057;
|
||||
FaceSettings face_settings = 10058;
|
||||
CoolingDevice cooling_device = 10059;
|
||||
}
|
||||
|
||||
// DO NOT USE field numbers above 100,000 in AOSP.
|
||||
@@ -410,17 +411,25 @@ message KeyValuePairsAtom {
|
||||
* frameworks/base/services/core/java/com/android/server/stats/StatsCompanionService.java
|
||||
*/
|
||||
message ThermalThrottlingStateChanged {
|
||||
// The type of temperature being reported (CPU, GPU, SKIN, etc)
|
||||
optional android.os.TemperatureTypeEnum sensor_type = 1;
|
||||
|
||||
// Throttling state, this field is DEPRECATED
|
||||
enum State {
|
||||
UNKNOWN = 0;
|
||||
START = 1;
|
||||
STOP = 2;
|
||||
START = 1; // START indicated that throttling was triggered.
|
||||
STOP = 2; // STOP indicates that throttling was cleared.
|
||||
}
|
||||
|
||||
optional State state = 2;
|
||||
|
||||
// Temperature in deci degrees celsius
|
||||
optional float temperature = 3;
|
||||
|
||||
// Severity of throttling
|
||||
optional android.os.ThrottlingSeverityEnum severity = 4;
|
||||
|
||||
// Thermistor name
|
||||
optional string sensor_name = 5;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3957,8 +3966,7 @@ message BatteryLevel {
|
||||
* Pulls the temperature of various parts of the device.
|
||||
* The units are tenths of a degree Celsius. Eg: 30.3C is reported as 303.
|
||||
*
|
||||
* Pulled from:
|
||||
* frameworks/base/cmds/statsd/src/external/ResourceThermalManagerPuller.cpp
|
||||
* Pulled from StatsCompanionService.java
|
||||
*/
|
||||
message Temperature {
|
||||
// The type of temperature being reported. Eg. CPU, GPU, SKIN, BATTERY, BCL_.
|
||||
@@ -3970,6 +3978,9 @@ message Temperature {
|
||||
// Temperature in tenths of a degree C.
|
||||
// For BCL, it is decimillivolt, decimilliamps, and percentage * 10.
|
||||
optional int32 temperature_deci_celsius = 3;
|
||||
|
||||
// Relative severity of the throttling, see enum definition.
|
||||
optional android.os.ThrottlingSeverityEnum severity = 4;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5947,3 +5958,19 @@ message FaceSettings {
|
||||
// Whether or not a diverse set of poses are required during enrollment.
|
||||
optional bool unlock_diversity_required = 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs cooling devices maintained by the kernel.
|
||||
*
|
||||
* Pulled from StatsCompanionService.java
|
||||
*/
|
||||
message CoolingDevice {
|
||||
// The type of cooling device being reported. Eg. CPU, GPU...
|
||||
optional android.os.CoolingTypeEnum device_location = 1;
|
||||
// The name of the cooling device source. Eg. CPU0
|
||||
optional string device_name = 2;
|
||||
// Current throttle state of the cooling device. The value can any unsigned
|
||||
// integer between 0 and max_state defined in its driver. 0 means device is
|
||||
// not in throttling, higher value means deeper throttling.
|
||||
optional int32 state = 3;
|
||||
}
|
||||
|
||||
@@ -159,6 +159,9 @@ std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
|
||||
// temperature
|
||||
{android::util::TEMPERATURE,
|
||||
{.puller = new StatsCompanionServicePuller(android::util::TEMPERATURE)}},
|
||||
// cooling_device
|
||||
{android::util::COOLING_DEVICE,
|
||||
{.puller = new StatsCompanionServicePuller(android::util::COOLING_DEVICE)}},
|
||||
// binder_calls
|
||||
{android::util::BINDER_CALLS,
|
||||
{.additiveFields = {4, 5, 6, 8, 12},
|
||||
|
||||
@@ -78,6 +78,41 @@ enum TemperatureTypeEnum {
|
||||
TEMPERATURE_TYPE_NPU = 9;
|
||||
}
|
||||
|
||||
// Device throttling severity
|
||||
// These constants are defined in hardware/interfaces/thermal/2.0/types.hal.
|
||||
// Any change to the types in the thermal hal should be made here as well.
|
||||
enum ThrottlingSeverityEnum {
|
||||
// Not under throttling.
|
||||
NONE = 0;
|
||||
// Light throttling where UX is not impacted.
|
||||
LIGHT = 1;
|
||||
// Moderate throttling where UX is not largely impacted.
|
||||
MODERATE = 2;
|
||||
// Severe throttling where UX is largely impacted.
|
||||
// Similar to 1.0 throttlingThreshold.
|
||||
SEVERE = 3;
|
||||
// Platform has done everything to reduce power.
|
||||
CRITICAL = 4;
|
||||
// Key components in platform are shutting down due to thermal condition.
|
||||
// Device functionalities will be limited.
|
||||
EMERGENCY = 5;
|
||||
// Need shutdown immediately.
|
||||
SHUTDOWN = 6;
|
||||
};
|
||||
|
||||
// Device cooling device types.
|
||||
// These constants are defined in hardware/interfaces/thermal/2.0/types.hal.
|
||||
// Any change to the types in the thermal hal should be made here as well.
|
||||
enum CoolingTypeEnum {
|
||||
FAN = 0;
|
||||
BATTERY = 1;
|
||||
CPU = 2;
|
||||
GPU = 3;
|
||||
MODEM = 4;
|
||||
NPU = 5;
|
||||
COMPONENT = 6;
|
||||
};
|
||||
|
||||
// Wakelock types, primarily used by android/os/PowerManager.java.
|
||||
enum WakeLockLevelEnum {
|
||||
// NOTE: Wake lock levels were previously defined as a bit field, except
|
||||
|
||||
@@ -64,6 +64,7 @@ import android.os.BatteryStatsInternal;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CoolingDevice;
|
||||
import android.os.Environment;
|
||||
import android.os.FileUtils;
|
||||
import android.os.Handler;
|
||||
@@ -1798,6 +1799,28 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
e.writeInt(temp.getType());
|
||||
e.writeString(temp.getName());
|
||||
e.writeInt((int) (temp.getValue() * 10));
|
||||
e.writeInt(temp.getStatus());
|
||||
pulledData.add(e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
// Should not happen.
|
||||
Slog.e(TAG, "Disconnected from thermal service. Cannot pull temperatures.");
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(callingToken);
|
||||
}
|
||||
}
|
||||
|
||||
private void pullCoolingDevices(int tagId, long elapsedNanos, long wallClockNanos,
|
||||
List<StatsLogEventWrapper> pulledData) {
|
||||
long callingToken = Binder.clearCallingIdentity();
|
||||
try {
|
||||
List<CoolingDevice> devices = sThermalService.getCurrentCoolingDevices();
|
||||
for (CoolingDevice device : devices) {
|
||||
StatsLogEventWrapper e =
|
||||
new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
|
||||
e.writeInt(device.getType());
|
||||
e.writeString(device.getName());
|
||||
e.writeInt((int) (device.getValue()));
|
||||
pulledData.add(e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
@@ -2271,6 +2294,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
pullTemperature(tagId, elapsedNanos, wallClockNanos, ret);
|
||||
break;
|
||||
}
|
||||
case StatsLog.COOLING_DEVICE: {
|
||||
pullCoolingDevices(tagId, elapsedNanos, wallClockNanos, ret);
|
||||
break;
|
||||
}
|
||||
case StatsLog.DEBUG_ELAPSED_CLOCK: {
|
||||
pullDebugElapsedClock(tagId, elapsedNanos, wallClockNanos, ret);
|
||||
break;
|
||||
@@ -2535,12 +2562,9 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
|
||||
private static final class ThermalEventListener extends IThermalEventListener.Stub {
|
||||
@Override
|
||||
public void notifyThrottling(Temperature temp) {
|
||||
boolean isThrottling = temp.getStatus() >= Temperature.THROTTLING_SEVERE;
|
||||
StatsLog.write(StatsLog.THERMAL_THROTTLING, temp.getType(),
|
||||
isThrottling ?
|
||||
StatsLog.THERMAL_THROTTLING_STATE_CHANGED__STATE__START :
|
||||
StatsLog.THERMAL_THROTTLING_STATE_CHANGED__STATE__STOP,
|
||||
temp.getValue());
|
||||
StatsLog.THERMAL_THROTTLING_STATE_CHANGED__STATE__UNKNOWN,
|
||||
temp.getValue(), temp.getStatus(), temp.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user