1 /* 2 * Copyright (C) 2024 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 <aidl/android/hardware/power/Boost.h> 20 #include <aidl/android/hardware/power/ChannelConfig.h> 21 #include <aidl/android/hardware/power/IPower.h> 22 #include <aidl/android/hardware/power/IPowerHintSession.h> 23 #include <aidl/android/hardware/power/Mode.h> 24 #include <aidl/android/hardware/power/SessionConfig.h> 25 #include <android-base/thread_annotations.h> 26 #include "HalResult.h" 27 28 namespace android::power { 29 30 // Wrapper for power hint sessions, which allows for better mocking, 31 // support checking, and failure handling than using hint sessions directly 32 class PowerHintSessionWrapper { 33 public: 34 virtual ~PowerHintSessionWrapper() = default; 35 PowerHintSessionWrapper( 36 std::shared_ptr<aidl::android::hardware::power::IPowerHintSession>&& session); 37 virtual HalResult<void> updateTargetWorkDuration(int64_t in_targetDurationNanos); 38 virtual HalResult<void> reportActualWorkDuration( 39 const std::vector<::aidl::android::hardware::power::WorkDuration>& in_durations); 40 virtual HalResult<void> pause(); 41 virtual HalResult<void> resume(); 42 virtual HalResult<void> close(); 43 virtual HalResult<void> sendHint(::aidl::android::hardware::power::SessionHint in_hint); 44 virtual HalResult<void> setThreads(const std::vector<int32_t>& in_threadIds); 45 virtual HalResult<void> setMode(::aidl::android::hardware::power::SessionMode in_type, 46 bool in_enabled); 47 virtual HalResult<aidl::android::hardware::power::SessionConfig> getSessionConfig(); 48 49 private: 50 std::shared_ptr<aidl::android::hardware::power::IPowerHintSession> mSession; 51 int32_t mInterfaceVersion; 52 }; 53 54 } // namespace android::power