summaryrefslogtreecommitdiff
path: root/include/powermanager/PowerHalLoader.h
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-04-20 17:37:27 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-04-20 17:37:27 +0000
commit103fb09b510d326a79160c727a97852be535354c (patch)
treeccab1a9b6b9ba561f256213a7f1c280d23fcd2cf /include/powermanager/PowerHalLoader.h
parentee5518e7705c492df397a9fd8d3c4c8449473c83 (diff)
parentc86c1d26220a7a69d3b0f7b9e97a6e5b95e6f40b (diff)
Merge "Create loader for Power HAL services"
Diffstat (limited to 'include/powermanager/PowerHalLoader.h')
-rw-r--r--include/powermanager/PowerHalLoader.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/powermanager/PowerHalLoader.h b/include/powermanager/PowerHalLoader.h
new file mode 100644
index 0000000000..487b95b298
--- /dev/null
+++ b/include/powermanager/PowerHalLoader.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#ifndef ANDROID_POWERHALLOADER_H
+#define ANDROID_POWERHALLOADER_H
+
+#include <android-base/thread_annotations.h>
+
+#include <android/hardware/power/1.1/IPower.h>
+#include <android/hardware/power/IPower.h>
+
+using IPowerV1_0 = android::hardware::power::V1_0::IPower;
+using IPowerV1_1 = android::hardware::power::V1_1::IPower;
+using IPowerAidl = android::hardware::power::IPower;
+
+namespace android {
+
+// Loads available Power HAL services.
+class PowerHalLoader {
+public:
+ static void unloadAll();
+ static sp<IPowerAidl> loadAidl();
+ static sp<IPowerV1_0> loadHidlV1_0();
+ static sp<IPowerV1_1> loadHidlV1_1();
+
+private:
+ static std::mutex gHalMutex;
+ static sp<IPowerAidl> gHalAidl GUARDED_BY(gHalMutex);
+ static sp<IPowerV1_0> gHalHidlV1_0 GUARDED_BY(gHalMutex);
+ static sp<IPowerV1_1> gHalHidlV1_1 GUARDED_BY(gHalMutex);
+
+ static sp<IPowerV1_0> loadHidlV1_0Locked() EXCLUSIVE_LOCKS_REQUIRED(gHalMutex);
+
+ PowerHalLoader() = default;
+};
+
+} // namespace android
+
+#endif // ANDROID_POWERHALLOADER_H