blob: 7f08f449267e6c910d7d180dd76546b23ae93a24 [file] [log] [blame]
Wei Wang61c2a332020-01-08 16:51:47 -08001/*
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
21namespace aidl {
22namespace android {
23namespace hardware {
24namespace power {
25namespace impl {
26namespace example {
27
Wei Wang05003412021-04-01 10:44:29 -070028const std::vector<Boost> BOOST_RANGE{ndk::enum_range<Boost>().begin(),
29 ndk::enum_range<Boost>().end()};
30const std::vector<Mode> MODE_RANGE{ndk::enum_range<Mode>().begin(), ndk::enum_range<Mode>().end()};
31
Wei Wang61c2a332020-01-08 16:51:47 -080032ndk::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
37ndk::ScopedAStatus Power::isModeSupported(Mode type, bool* _aidl_return) {
38 LOG(INFO) << "Power isModeSupported: " << static_cast<int32_t>(type);
Wei Wang05003412021-04-01 10:44:29 -070039 *_aidl_return = type >= MODE_RANGE.front() && type <= MODE_RANGE.back();
Wei Wang61c2a332020-01-08 16:51:47 -080040 return ndk::ScopedAStatus::ok();
41}
42
43ndk::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
49ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool* _aidl_return) {
50 LOG(INFO) << "Power isBoostSupported: " << static_cast<int32_t>(type);
Wei Wang05003412021-04-01 10:44:29 -070051 *_aidl_return = type >= BOOST_RANGE.front() && type <= BOOST_RANGE.back();
Wei Wang61c2a332020-01-08 16:51:47 -080052 return ndk::ScopedAStatus::ok();
53}
54
Wei Wang05003412021-04-01 10:44:29 -070055ndk::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
61ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t* outNanoseconds) {
62 *outNanoseconds = -1;
63 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
64}
65
Wei Wang61c2a332020-01-08 16:51:47 -080066} // namespace example
67} // namespace impl
68} // namespace power
69} // namespace hardware
70} // namespace android
71} // namespace aidl