Skip to content

Commit

Permalink
ThermalHAL: add dump into bugreport
Browse files Browse the repository at this point in the history
lshal-debug/[email protected]::IThermal_default.txt:
getTemperatures:
Name: usb_port_temp Type: UNKNOWN CurrentValue: 30.7 ThrottlingThreshold: nan ShutdownThreshold: nan VrThrottlingThreshold: nan
Name: back_therm Type: SKIN CurrentValue: 30 ThrottlingThreshold: 40 ShutdownThreshold: 56 VrThrottlingThreshold: 52
Name: tsens_tz_sensor4 Type: CPU CurrentValue: 42.7 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
Name: tsens_tz_sensor2 Type: CPU CurrentValue: 43 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
Name: battery Type: BATTERY CurrentValue: 28 ThrottlingThreshold: nan ShutdownThreshold: 60 VrThrottlingThreshold: nan
Name: tsens_tz_sensor13 Type: GPU CurrentValue: 40.8 ThrottlingThreshold: nan ShutdownThreshold: nan VrThrottlingThreshold: nan
Name: tsens_tz_sensor10 Type: CPU CurrentValue: 42.1 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
Name: tsens_tz_sensor9 Type: CPU CurrentValue: 42.4 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
Name: tsens_tz_sensor3 Type: CPU CurrentValue: 42.4 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
Name: tsens_tz_sensor8 Type: CPU CurrentValue: 41.7 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
Name: tsens_tz_sensor7 Type: CPU CurrentValue: 42.1 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
Name: tsens_tz_sensor1 Type: CPU CurrentValue: 43.3 ThrottlingThreshold: 95 ShutdownThreshold: 115 VrThrottlingThreshold: 95
getCpuUsages:
Name: CPU0 Active: 3144 Total: 6725 IsOnline: 1
Name: CPU1 Active: 3128 Total: 6943 IsOnline: 1
Name: CPU2 Active: 2128 Total: 6692 IsOnline: 1
Name: CPU3 Active: 1936 Total: 6893 IsOnline: 1
Name: CPU4 Active: 2165 Total: 7027 IsOnline: 1
Name: CPU5 Active: 2356 Total: 7046 IsOnline: 1
Name: CPU6 Active: 3757 Total: 7022 IsOnline: 1
Name: CPU7 Active: 3748 Total: 7049 IsOnline: 1

Test: take BR
Bug: 77301612
Bug: 72071908
Change-Id: Ib10ab86731df4cee3c7523c54c5dce51f2038156
  • Loading branch information
weivincewang committed Apr 2, 2018
1 parent 436d59a commit b67512b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
58 changes: 56 additions & 2 deletions thermal/Thermal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <cerrno>
#include <vector>

#include <android-base/file.h>
#include <android-base/logging.h>

#include "Thermal.h"
Expand Down Expand Up @@ -55,12 +56,11 @@ Return<void> Thermal::getTemperatures(getTemperatures_cb _hidl_cb) {
hidl_vec<Temperature> temperatures;
temperatures.resize(kTemperatureNum);

LOG(INFO) << "ThermalHAL enabled: " << enabled;

if (!enabled) {
status.code = ThermalStatusCode::FAILURE;
status.debugMessage = "Unsupported hardware";
_hidl_cb(status, temperatures);
LOG(ERROR) << "ThermalHAL not initialized properly.";
return Void();
}

Expand Down Expand Up @@ -93,6 +93,7 @@ Return<void> Thermal::getCpuUsages(getCpuUsages_cb _hidl_cb) {
status.code = ThermalStatusCode::FAILURE;
status.debugMessage = "Unsupported hardware";
_hidl_cb(status, cpuUsages);
LOG(ERROR) << "ThermalHAL not initialized properly.";
return Void();
}

Expand Down Expand Up @@ -123,6 +124,7 @@ Return<void> Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb) {
status.code = ThermalStatusCode::FAILURE;
status.debugMessage = "Unsupported hardware";
_hidl_cb(status, coolingDevices);
LOG(ERROR) << "ThermalHAL not initialized properly.";
return Void();
}

Expand Down Expand Up @@ -177,6 +179,58 @@ void Thermal::notifyThrottling(
}
}

Return<void> Thermal::debug(const hidl_handle& handle, const hidl_vec<hidl_string>&) {
if (handle != nullptr && handle->numFds >= 1) {
int fd = handle->data[0];
std::ostringstream dump_buf;

if (!enabled) {
dump_buf << "ThermalHAL not initialized properly." << std::endl;
} else {
hidl_vec<Temperature> temperatures;
hidl_vec<CpuUsage> cpu_usages;
cpu_usages.resize(kCpuNum);
temperatures.resize(kTemperatureNum);

dump_buf << "getTemperatures:" << std::endl;
if (fillTemperatures(&temperatures) != kTemperatureNum) {
dump_buf << "Failed to read thermal sensors." << std::endl;
} else {
for (const auto& t : temperatures) {
dump_buf << "Name: " << t.name
<< " Type: " << android::hardware::thermal::V1_0::toString(t.type)
<< " CurrentValue: " << t.currentValue
<< " ThrottlingThreshold: " << t.throttlingThreshold
<< " ShutdownThreshold: " << t.shutdownThreshold
<< " VrThrottlingThreshold: " << t.vrThrottlingThreshold
<< std::endl;
}
}

dump_buf << "getCpuUsages:" << std::endl;
ssize_t ret = fillCpuUsages(&cpu_usages);
if (ret < 0) {
dump_buf << "Failed to get CPU usages." << std::endl;
} else {
for (const auto& usage : cpu_usages) {
dump_buf << "Name: " << usage.name
<< " Active: " << usage.active
<< " Total: " << usage.total
<< " IsOnline: " << usage.isOnline
<< std::endl;
}
}

}
std::string buf = dump_buf.str();
if (!android::base::WriteStringToFd(buf, fd)) {
PLOG(ERROR) << "Failed to dump state to fd";
}
fsync(fd);
}
return Void();
}

} // namespace implementation
} // namespace V1_1
} // namespace thermal
Expand Down
2 changes: 2 additions & 0 deletions thermal/Thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct Thermal : public IThermal {
// Methods from ::android::hardware::thermal::V1_1::IThermal follow.
Return<void> registerThermalCallback(
const sp<IThermalCallback>& callback) override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override;
private:
bool enabled;
};
Expand Down

0 comments on commit b67512b

Please sign in to comment.