1 /* 2 * Copyright (C) 2020 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 #pragma once 18 19 #include <atomic> 20 #include <memory> 21 #include <thread> 22 23 #include <aidl/android/hardware/power/BnPower.h> 24 #include <perfmgr/HintManager.h> 25 26 #include "disp-power/DisplayLowPower.h" 27 #include "disp-power/InteractionHandler.h" 28 29 namespace aidl { 30 namespace google { 31 namespace hardware { 32 namespace power { 33 namespace impl { 34 namespace pixel { 35 36 using ::InteractionHandler; 37 using ::aidl::android::hardware::power::Boost; 38 using ::aidl::android::hardware::power::Mode; 39 using ::android::perfmgr::HintManager; 40 41 class Power : public ::aidl::android::hardware::power::BnPower { 42 public: 43 Power(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw); 44 ndk::ScopedAStatus setMode(Mode type, bool enabled) override; 45 ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override; 46 ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override; 47 ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override; 48 binder_status_t dump(int fd, const char **args, uint32_t numArgs) override; 49 50 private: 51 std::shared_ptr<HintManager> mHintManager; 52 std::shared_ptr<DisplayLowPower> mDisplayLowPower; 53 std::unique_ptr<InteractionHandler> mInteractionHandler; 54 std::atomic<bool> mVRModeOn; 55 std::atomic<bool> mSustainedPerfModeOn; 56 }; 57 58 } // namespace pixel 59 } // namespace impl 60 } // namespace power 61 } // namespace hardware 62 } // namespace google 63 } // namespace aidl 64