summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Lee <geolee@google.com>2019-05-23 21:19:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-05-23 21:19:20 +0000
commit8f4ddcc99e4817ad17ca145c469ed937e6cee128 (patch)
tree5791b59c53496e1d5c7aa191d3f5a96f3e6f9555
parent67c728531893127e052a67675fc2846eb97ab5fd (diff)
parenta6949e1ac32c5f54b0cb47dcef9ff5fdb856e8f1 (diff)
downloadpixel-8f4ddcc99e4817ad17ca145c469ed937e6cee128.tar.gz
Merge "Thermal: Disable SoC throttling when Charging" into qt-dev
-rw-r--r--health/Android.bp5
-rw-r--r--health/BatteryThermalControl.cpp52
-rw-r--r--health/include/pixelhealth/BatteryThermalControl.h52
3 files changed, 107 insertions, 2 deletions
diff --git a/health/Android.bp b/health/Android.bp
index 99d65826..256bf126 100644
--- a/health/Android.bp
+++ b/health/Android.bp
@@ -4,10 +4,11 @@ cc_library {
export_include_dirs: ["include"],
srcs: [
- "LowBatteryShutdownMetrics.cpp",
+ "BatteryMetricsLogger.cpp",
+ "BatteryThermalControl.cpp",
"CycleCountBackupRestore.cpp",
"DeviceHealth.cpp",
- "BatteryMetricsLogger.cpp",
+ "LowBatteryShutdownMetrics.cpp",
],
cflags: [
diff --git a/health/BatteryThermalControl.cpp b/health/BatteryThermalControl.cpp
new file mode 100644
index 00000000..d119b34c
--- /dev/null
+++ b/health/BatteryThermalControl.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "pixelhealth/BatteryThermalControl.h"
+
+namespace hardware {
+namespace google {
+namespace pixel {
+namespace health {
+
+BatteryThermalControl::BatteryThermalControl(const std::string &path) : mThermalSocMode(path) {
+ mStatus = true;
+}
+
+void BatteryThermalControl::setThermalMode(bool isEnable, bool isWeakCharger) {
+ std::string action = (isEnable) ? "enabled" : "disabled";
+
+ if (mStatus != isEnable) {
+ if (!isEnable && isWeakCharger)
+ return;
+ if (android::base::WriteStringToFile(action, mThermalSocMode)) {
+ mStatus = isEnable;
+ } else {
+ LOG(ERROR) << "Error Write: \"" << action << "\" to " << mThermalSocMode
+ << " error:" << strerror(errno);
+ }
+ }
+}
+
+void BatteryThermalControl::updateThermalState(const struct android::BatteryProperties *props) {
+ setThermalMode(props->batteryStatus != android::BATTERY_STATUS_CHARGING &&
+ props->batteryStatus != android::BATTERY_STATUS_FULL,
+ props->maxChargingCurrent * props->maxChargingVoltage < 37500000);
+}
+
+} // namespace health
+} // namespace pixel
+} // namespace google
+} // namespace hardware
diff --git a/health/include/pixelhealth/BatteryThermalControl.h b/health/include/pixelhealth/BatteryThermalControl.h
new file mode 100644
index 00000000..4b15220d
--- /dev/null
+++ b/health/include/pixelhealth/BatteryThermalControl.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/strings.h>
+#include <batteryservice/BatteryService.h>
+
+#include <string>
+
+namespace hardware {
+namespace google {
+namespace pixel {
+namespace health {
+
+/**
+ * updateThermalState is called per battery status update.
+ * BatteryThermalControl monitors thermal framework and when device is charging
+ * or battery is full, it then disable SOC throtting by setting disabled in
+ * SOC thermal zone's mode.
+ */
+class BatteryThermalControl {
+ public:
+ BatteryThermalControl(const std::string &path);
+ void updateThermalState(const struct android::BatteryProperties *props);
+
+ private:
+ void setThermalMode(bool isEnable, bool isWeakCharger);
+
+ const std::string mThermalSocMode;
+ bool mStatus;
+};
+
+} // namespace health
+} // namespace pixel
+} // namespace google
+} // namespace hardware