summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/init.pixel.rc7
-rw-r--r--thermal/Thermal.cpp43
-rw-r--r--thermal/Thermal.h21
-rw-r--r--thermal/thermal-helper.cpp4
-rw-r--r--vibrator/cs40l25/Stats.h2
-rw-r--r--vibrator/cs40l26/Stats.h2
6 files changed, 63 insertions, 16 deletions
diff --git a/common/init.pixel.rc b/common/init.pixel.rc
index 1296e73..640212c 100644
--- a/common/init.pixel.rc
+++ b/common/init.pixel.rc
@@ -8,3 +8,10 @@ on property:ota.warm_reset=1
on property:ota.warm_reset=0
write /sys/module/msm_poweroff/parameters/warm_reset 0
+
+on init
+ copy_per_line /dev/cpuctl/tasks /dev/cpuctl/system/tasks
+
+# Migrate tasks again in case kernel threads are created during boot
+on property:sys.boot_completed=1
+ copy_per_line /dev/cpuctl/tasks /dev/cpuctl/system/tasks
diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp
index c78c910..caab2b5 100644
--- a/thermal/Thermal.cpp
+++ b/thermal/Thermal.cpp
@@ -163,8 +163,6 @@ ndk::ScopedAStatus Thermal::unregisterThermalChangedCallback(
ndk::ScopedAStatus Thermal::registerThermalChangedCallback(
const std::shared_ptr<IThermalChangedCallback> &callback, bool filterType,
TemperatureType type) {
- std::vector<Temperature> temperatures;
-
ATRACE_CALL();
if (callback == nullptr) {
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
@@ -184,17 +182,21 @@ ndk::ScopedAStatus Thermal::registerThermalChangedCallback(
LOG(INFO) << "a callback has been registered to ThermalHAL, isFilter: " << c.is_filter_type
<< " Type: " << toString(c.type);
// Send notification right away after successful thermal callback registration
- if (thermal_helper_.fillCurrentTemperatures(filterType, true, type, &temperatures)) {
- for (const auto &t : temperatures) {
- if (!filterType || t.type == type) {
- LOG(INFO) << "Sending notification: "
- << " Type: " << toString(t.type) << " Name: " << t.name
- << " CurrentValue: " << t.value
- << " ThrottlingStatus: " << toString(t.throttlingStatus);
- c.callback->notifyThrottling(t);
+ std::function<void()> handler = [this, c, filterType, type]() {
+ std::vector<Temperature> temperatures;
+ if (thermal_helper_.fillCurrentTemperatures(filterType, true, type, &temperatures)) {
+ for (const auto &t : temperatures) {
+ if (!filterType || t.type == type) {
+ LOG(INFO) << "Sending notification: "
+ << " Type: " << toString(t.type) << " Name: " << t.name
+ << " CurrentValue: " << t.value
+ << " ThrottlingStatus: " << toString(t.throttlingStatus);
+ c.callback->notifyThrottling(t);
+ }
}
}
- }
+ };
+ looper_.addEvent(Looper::Event{handler});
return ndk::ScopedAStatus::ok();
}
@@ -742,7 +744,7 @@ void Thermal::dumpThermalData(int fd) {
}
binder_status_t Thermal::dump(int fd, const char **args, uint32_t numArgs) {
- if (numArgs == 0) {
+ if (numArgs == 0 || std::string(args[0]) == "-a") {
dumpThermalData(fd);
return STATUS_OK;
}
@@ -763,6 +765,23 @@ binder_status_t Thermal::dump(int fd, const char **args, uint32_t numArgs) {
return STATUS_BAD_VALUE;
}
+void Thermal::Looper::addEvent(const Thermal::Looper::Event &e) {
+ std::unique_lock<std::mutex> lock(mutex_);
+ events_.push(e);
+ cv_.notify_all();
+}
+
+void Thermal::Looper::loop() {
+ while (true) {
+ std::unique_lock<std::mutex> lock(mutex_);
+ cv_.wait(lock, [&] { return !events_.empty(); });
+ Event event = events_.front();
+ events_.pop();
+ lock.unlock();
+ event.handler();
+ }
+}
+
} // namespace implementation
} // namespace thermal
} // namespace hardware
diff --git a/thermal/Thermal.h b/thermal/Thermal.h
index e41bf05..74449c4 100644
--- a/thermal/Thermal.h
+++ b/thermal/Thermal.h
@@ -68,9 +68,30 @@ class Thermal : public BnThermal {
void sendThermalChangedCallback(const Temperature &t);
private:
+ class Looper {
+ public:
+ struct Event {
+ std::function<void()> handler;
+ };
+
+ Looper() {
+ thread_ = std::thread([&] { loop(); });
+ }
+ void addEvent(const Event &e);
+
+ private:
+ std::condition_variable cv_;
+ std::queue<Event> events_;
+ std::mutex mutex_;
+ std::thread thread_;
+
+ void loop();
+ };
+
ThermalHelper thermal_helper_;
std::mutex thermal_callback_mutex_;
std::vector<CallbackSetting> callbacks_;
+ Looper looper_;
ndk::ScopedAStatus getFilteredTemperatures(bool filterType, TemperatureType type,
std::vector<Temperature> *_aidl_return);
diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp
index 796da4e..d8883a4 100644
--- a/thermal/thermal-helper.cpp
+++ b/thermal/thermal-helper.cpp
@@ -944,8 +944,8 @@ bool ThermalHelper::readThermalSensor(std::string_view sensor_name, float *temp,
sensor_status.thermal_cached.temp = *temp;
sensor_status.thermal_cached.timestamp = now;
}
-
- thermal_stats_helper_.updateSensorTempStatsByThreshold(sensor_name, *temp);
+ auto real_temp = (*temp) * sensor_info.multiplier;
+ thermal_stats_helper_.updateSensorTempStatsByThreshold(sensor_name, real_temp);
return true;
}
diff --git a/vibrator/cs40l25/Stats.h b/vibrator/cs40l25/Stats.h
index 0181d21..f6a7a34 100644
--- a/vibrator/cs40l25/Stats.h
+++ b/vibrator/cs40l25/Stats.h
@@ -269,7 +269,7 @@ class StatsApi : public Vibrator::StatsApi, private StatsBase {
mMinLatencies[mCurrentLatencyIndex] = latency;
}
if (latency > mMaxLatencies[mCurrentLatencyIndex]) {
- mMinLatencies[mCurrentLatencyIndex] = latency;
+ mMaxLatencies[mCurrentLatencyIndex] = latency;
}
mLatencyTotals[mCurrentLatencyIndex] += latency;
mLatencyCounts[mCurrentLatencyIndex]++;
diff --git a/vibrator/cs40l26/Stats.h b/vibrator/cs40l26/Stats.h
index b76e1b8..3948006 100644
--- a/vibrator/cs40l26/Stats.h
+++ b/vibrator/cs40l26/Stats.h
@@ -237,7 +237,7 @@ class StatsApi : public Vibrator::StatsApi, private StatsBase {
mMinLatencies[mCurrentLatencyIndex] = latency;
}
if (latency > mMaxLatencies[mCurrentLatencyIndex]) {
- mMinLatencies[mCurrentLatencyIndex] = latency;
+ mMaxLatencies[mCurrentLatencyIndex] = latency;
}
mLatencyTotals[mCurrentLatencyIndex] += latency;
mLatencyCounts[mCurrentLatencyIndex]++;