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 #include "Power.h"
18 
19 #include <android-base/logging.h>
20 
21 namespace aidl {
22 namespace android {
23 namespace hardware {
24 namespace power {
25 namespace impl {
26 namespace example {
27 
28 const std::vector<Boost> BOOST_RANGE{ndk::enum_range<Boost>().begin(),
29                                      ndk::enum_range<Boost>().end()};
30 const std::vector<Mode> MODE_RANGE{ndk::enum_range<Mode>().begin(), ndk::enum_range<Mode>().end()};
31 
setMode(Mode type,bool enabled)32 ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
33     LOG(VERBOSE) << "Power setMode: " << static_cast<int32_t>(type) << " to: " << enabled;
34     return ndk::ScopedAStatus::ok();
35 }
36 
isModeSupported(Mode type,bool * _aidl_return)37 ndk::ScopedAStatus Power::isModeSupported(Mode type, bool* _aidl_return) {
38     LOG(INFO) << "Power isModeSupported: " << static_cast<int32_t>(type);
39     *_aidl_return = type >= MODE_RANGE.front() && type <= MODE_RANGE.back();
40     return ndk::ScopedAStatus::ok();
41 }
42 
setBoost(Boost type,int32_t durationMs)43 ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
44     LOG(VERBOSE) << "Power setBoost: " << static_cast<int32_t>(type)
45                  << ", duration: " << durationMs;
46     return ndk::ScopedAStatus::ok();
47 }
48 
isBoostSupported(Boost type,bool * _aidl_return)49 ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool* _aidl_return) {
50     LOG(INFO) << "Power isBoostSupported: " << static_cast<int32_t>(type);
51     *_aidl_return = type >= BOOST_RANGE.front() && type <= BOOST_RANGE.back();
52     return ndk::ScopedAStatus::ok();
53 }
54 
createHintSession(int32_t,int32_t,const std::vector<int32_t> &,int64_t,std::shared_ptr<IPowerHintSession> * _aidl_return)55 ndk::ScopedAStatus Power::createHintSession(int32_t, int32_t, const std::vector<int32_t>&, int64_t,
56                                             std::shared_ptr<IPowerHintSession>* _aidl_return) {
57     *_aidl_return = nullptr;
58     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
59 }
60 
getHintSessionPreferredRate(int64_t * outNanoseconds)61 ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t* outNanoseconds) {
62     *outNanoseconds = -1;
63     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
64 }
65 
66 }  // namespace example
67 }  // namespace impl
68 }  // namespace power
69 }  // namespace hardware
70 }  // namespace android
71 }  // namespace aidl
72