power: Allow device specific hooks for setMode, isModeSupported
* Some devices may want to implement custom hooks
Change-Id: Icb2d66471ec649a69b1e69849fd86282775052cb
diff --git a/power-libperfmgr/Android.bp b/power-libperfmgr/Android.bp
index f82ae2d..0839ddd 100644
--- a/power-libperfmgr/Android.bp
+++ b/power-libperfmgr/Android.bp
@@ -13,6 +13,9 @@
cc_binary {
name: "android.hardware.power-service.lineage-libperfmgr",
+ defaults: [
+ "power_libperfmgr_defaults",
+ ],
relative_install_path: "hw",
init_rc: ["aidl/android.hardware.power-service.lineage-libperfmgr.rc"],
vintf_fragments: ["aidl/android.hardware.power-service.lineage.xml"],
@@ -42,3 +45,14 @@
"aidl/PowerSessionManager.cpp",
],
}
+
+cc_library_static {
+ name: "libperfmgr-ext",
+ vendor: true,
+ srcs: [
+ "aidl/PowerModeExtension.cpp",
+ ],
+ shared_libs: [
+ "android.hardware.power-V4-ndk",
+ ],
+}
diff --git a/power-libperfmgr/aidl/Power.cpp b/power-libperfmgr/aidl/Power.cpp
index ffa03f1..f1f4a1e 100644
--- a/power-libperfmgr/aidl/Power.cpp
+++ b/power-libperfmgr/aidl/Power.cpp
@@ -45,6 +45,9 @@
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
+extern bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return);
+extern bool setDeviceSpecificMode(Mode type, bool enabled);
+
Power::Power()
: mInteractionHandler(nullptr),
mSustainedPerfModeOn(false) {
@@ -79,6 +82,10 @@
HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
PowerSessionManager::getInstance()->updateHintMode(toString(type), enabled);
}
+ if (setDeviceSpecificMode(type, enabled)) {
+ return ndk::ScopedAStatus::ok();
+ }
+
switch (type) {
case Mode::SUSTAINED_PERFORMANCE:
if (enabled) {
@@ -120,6 +127,10 @@
}
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
+ if (isDeviceSpecificModeSupported(type, _aidl_return)) {
+ return ndk::ScopedAStatus::ok();
+ }
+
bool supported = HintManager::GetInstance()->IsHintSupported(toString(type));
LOG(INFO) << "Power mode " << toString(type) << " isModeSupported: " << supported;
*_aidl_return = supported;
diff --git a/power-libperfmgr/aidl/PowerModeExtension.cpp b/power-libperfmgr/aidl/PowerModeExtension.cpp
new file mode 100644
index 0000000..50c5a70
--- /dev/null
+++ b/power-libperfmgr/aidl/PowerModeExtension.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 The LineageOS 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 <aidl/android/hardware/power/BnPower.h>
+
+namespace aidl {
+namespace google {
+namespace hardware {
+namespace power {
+namespace impl {
+namespace pixel {
+
+using ::aidl::android::hardware::power::Mode;
+
+bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) {
+ (void) type;
+ (void) _aidl_return;
+ return false;
+}
+
+bool setDeviceSpecificMode(Mode type, bool enabled) {
+ (void) type;
+ (void) enabled;
+ return false;
+}
+
+} // namespace pixel
+} // namespace impl
+} // namespace power
+} // namespace hardware
+} // namespace google
+} // namespace aidl