diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-05-25 23:16:31 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-05-25 23:16:31 +0000 |
commit | f11db2350f570aec39ddd09f7cf460c57abf1acf (patch) | |
tree | 2afbbf6a753f9ad0f4558d53f010e75eee6670b8 | |
parent | 626c6696a68e99c2d4facb849040b04f1a0d2aa3 (diff) | |
parent | f31589e53e7648027c3b5d94f2476f94ecefd5f0 (diff) | |
download | pixel-f11db2350f570aec39ddd09f7cf460c57abf1acf.tar.gz |
Snap for 5605988 from f31589e53e7648027c3b5d94f2476f94ecefd5f0 to qt-release
Change-Id: I6b98ee6dc1c1fa18ab7727c81d19f69d10562932
-rw-r--r-- | atrace/AtraceDevice.cpp | 9 | ||||
-rw-r--r-- | health/Android.bp | 5 | ||||
-rw-r--r-- | health/BatteryThermalControl.cpp | 52 | ||||
-rw-r--r-- | health/include/pixelhealth/BatteryThermalControl.h | 52 | ||||
-rw-r--r-- | power-libperfmgr/Power.cpp | 30 | ||||
-rw-r--r-- | power-libperfmgr/Power.h | 11 | ||||
-rw-r--r-- | power-libperfmgr/android.hardware.power@1.3-service.pixel-libperfmgr.rc | 4 |
7 files changed, 128 insertions, 35 deletions
diff --git a/atrace/AtraceDevice.cpp b/atrace/AtraceDevice.cpp index ba13cd21..26e56966 100644 --- a/atrace/AtraceDevice.cpp +++ b/atrace/AtraceDevice.cpp @@ -45,18 +45,19 @@ const std::map<std::string, TracingConfig> kTracingMap = { }, { "ion", - {"ION allocation", + {"ION Allocation", {{"/sys/kernel/debug/tracing/events/kmem/ion_alloc_buffer_start/enable", false}}}, }, { - "tz", - {"Trust zone", + "sched", + {"CPU Scheduling and Trustzone", {{"/sys/kernel/debug/tracing/events/scm/enable", false}, {"/sys/kernel/debug/tracing/events/systrace/enable", false}}}, }, { "freq", - {"Clocks", {{"/sys/kernel/debug/tracing/events/msm_bus/enable", false}}}, + {"CPU Frequency and System Clock", + {{"/sys/kernel/debug/tracing/events/msm_bus/enable", false}}}, }, }; 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 diff --git a/power-libperfmgr/Power.cpp b/power-libperfmgr/Power.cpp index e5a2ce52..aca64ca4 100644 --- a/power-libperfmgr/Power.cpp +++ b/power-libperfmgr/Power.cpp @@ -44,6 +44,12 @@ using ::android::hardware::Void; using ::android::hardware::power::V1_0::Feature; using ::android::hardware::power::V1_0::Status; +constexpr char kPowerHalStateProp[] = "vendor.powerhal.state"; +constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; +constexpr char kPowerHalInitProp[] = "vendor.powerhal.init"; +constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering"; +constexpr char kPowerHalConfigPath[] = "/vendor/etc/powerhint.json"; + static const std::map<enum CameraStreamingMode, std::string> kCamStreamingHint = { {CAMERA_STREAMING_OFF, "CAMERA_STREAMING_OFF"}, {CAMERA_STREAMING, "CAMERA_STREAMING"}, @@ -108,6 +114,7 @@ Power::Power() } // Now start to take powerhint mReady.store(true); + ALOGI("PowerHAL ready to process hints"); }); mInitThread.detach(); } @@ -118,7 +125,7 @@ Return<void> Power::setInteractive(bool /* interactive */) { } Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) { - if (!isSupportedGovernor() || !mReady) { + if (!mReady) { return Void(); } ATRACE_INT(android::hardware::power::V1_0::toString(hint).c_str(), data); @@ -213,21 +220,6 @@ Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl return Void(); } -bool Power::isSupportedGovernor() { - std::string buf; - if (android::base::ReadFileToString("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", - &buf)) { - buf = android::base::Trim(buf); - } - // Only support EAS 1.2, legacy EAS - if (buf == "schedutil" || buf == "sched") { - return true; - } else { - LOG(ERROR) << "Governor not supported by powerHAL, skipping"; - return false; - } -} - Return<void> Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) { // just call the normal power hint in this oneway function return powerHint(hint, data); @@ -235,7 +227,7 @@ Return<void> Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) { // Methods from ::android::hardware::power::V1_2::IPower follow. Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { - if (!isSupportedGovernor() || !mReady) { + if (!mReady) { return Void(); } @@ -277,8 +269,6 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { case PowerHint_1_2::CAMERA_LAUNCH: if (data > 0) { mHintManager->DoHint("CAMERA_LAUNCH"); - // boosts 2.5s for launching - mHintManager->DoHint("LAUNCH", std::chrono::milliseconds(2500)); } else if (data == 0) { mHintManager->EndHint("CAMERA_LAUNCH"); } else { @@ -334,7 +324,7 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { // Methods from ::android::hardware::power::V1_3::IPower follow. Return<void> Power::powerHintAsync_1_3(PowerHint_1_3 hint, int32_t data) { - if (!isSupportedGovernor() || !mReady) { + if (!mReady) { return Void(); } diff --git a/power-libperfmgr/Power.h b/power-libperfmgr/Power.h index 4b055bc2..b43fecd7 100644 --- a/power-libperfmgr/Power.h +++ b/power-libperfmgr/Power.h @@ -45,13 +45,8 @@ using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint; using PowerHint_1_3 = ::android::hardware::power::V1_3::PowerHint; using ::android::perfmgr::HintManager; -constexpr char kPowerHalStateProp[] = "vendor.powerhal.state"; -constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; -constexpr char kPowerHalInitProp[] = "vendor.powerhal.init"; -constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering"; -constexpr char kPowerHalConfigPath[] = "/vendor/etc/powerhint.json"; - -struct Power : public IPower { +class Power : public IPower { + public: // Methods from ::android::hardware::power::V1_0::IPower follow. Power(); @@ -75,8 +70,6 @@ struct Power : public IPower { Return<void> debug(const hidl_handle &fd, const hidl_vec<hidl_string> &args) override; private: - static bool isSupportedGovernor(); - std::shared_ptr<HintManager> mHintManager; std::unique_ptr<InteractionHandler> mInteractionHandler; std::atomic<bool> mVRModeOn; diff --git a/power-libperfmgr/android.hardware.power@1.3-service.pixel-libperfmgr.rc b/power-libperfmgr/android.hardware.power@1.3-service.pixel-libperfmgr.rc index fcfc5ee4..fa005870 100644 --- a/power-libperfmgr/android.hardware.power@1.3-service.pixel-libperfmgr.rc +++ b/power-libperfmgr/android.hardware.power@1.3-service.pixel-libperfmgr.rc @@ -2,6 +2,10 @@ service vendor.power-hal-1-3 /vendor/bin/hw/android.hardware.power@1.3-service.p class hal user root group system + interface android.hardware.power@1.0::IPower default + interface android.hardware.power@1.1::IPower default + interface android.hardware.power@1.2::IPower default + interface android.hardware.power@1.3::IPower default # restart powerHAL when framework died on property:init.svc.zygote=restarting && property:vendor.powerhal.state=* |