• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef POWER_LIBPERFMGR_POWER_H_
18 #define POWER_LIBPERFMGR_POWER_H_
19 
20 #include <atomic>
21 #include <memory>
22 #include <thread>
23 
24 #include <android/hardware/power/1.3/IPower.h>
25 #include <hidl/MQDescriptor.h>
26 #include <hidl/Status.h>
27 #include <perfmgr/HintManager.h>
28 
29 #include "CameraMode.h"
30 #include "InteractionHandler.h"
31 
32 namespace android {
33 namespace hardware {
34 namespace power {
35 namespace V1_3 {
36 namespace implementation {
37 
38 using ::InteractionHandler;
39 using ::android::hardware::Return;
40 using ::android::hardware::Void;
41 using ::android::hardware::power::V1_0::Feature;
42 using ::android::hardware::power::V1_3::IPower;
43 using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint;
44 using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint;
45 using PowerHint_1_3 = ::android::hardware::power::V1_3::PowerHint;
46 using ::android::perfmgr::HintManager;
47 
48 class Power : public IPower {
49   public:
50     // Methods from ::android::hardware::power::V1_0::IPower follow.
51 
52     Power();
53 
54     Return<void> setInteractive(bool /* interactive */) override;
55     Return<void> powerHint(PowerHint_1_0 hint, int32_t data) override;
56     Return<void> setFeature(Feature feature, bool activate) override;
57     Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override;
58 
59     // Methods from ::android::hardware::power::V1_1::IPower follow.
60     Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override;
61     Return<void> powerHintAsync(PowerHint_1_0 hint, int32_t data) override;
62 
63     // Methods from ::android::hardware::power::V1_2::IPower follow.
64     Return<void> powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override;
65 
66     // Methods from ::android::hardware::power::V1_3::IPower follow.
67     Return<void> powerHintAsync_1_3(PowerHint_1_3 hint, int32_t data) override;
68 
69     // Methods from ::android::hidl::base::V1_0::IBase follow.
70     Return<void> debug(const hidl_handle &fd, const hidl_vec<hidl_string> &args) override;
71 
72   private:
73     std::shared_ptr<HintManager> mHintManager;
74     std::unique_ptr<InteractionHandler> mInteractionHandler;
75     std::atomic<bool> mVRModeOn;
76     std::atomic<bool> mSustainedPerfModeOn;
77     std::atomic<enum CameraStreamingMode> mCameraStreamingMode;
78     std::atomic<bool> mReady;
79     std::thread mInitThread;
80 };
81 
82 }  // namespace implementation
83 }  // namespace V1_3
84 }  // namespace power
85 }  // namespace hardware
86 }  // namespace android
87 
88 #endif  // POWER_LIBPERFMGR_POWER_H_
89