blob: 28f096af1df1c2f3efc650e02c3ce51e4b0500d2 [file] [log] [blame]
John Stultzc1875b52018-11-20 16:15:20 -08001/*
2 * Copyright (C) 2017 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#define LOG_TAG "android.hardware.power@1.1-service.hikey-common"
18
19#include <android/log.h>
20#include <utils/Log.h>
21
22#include <android-base/properties.h>
23
24#include "Power.h"
25#include "power-helper.h"
26
27enum subsystem_type {
28 //Don't add any lines after that line
29 SUBSYSTEM_COUNT
30};
31
32
33namespace android {
34namespace hardware {
35namespace power {
36namespace V1_1 {
37namespace implementation {
38
39using ::android::hardware::power::V1_0::Feature;
40using ::android::hardware::power::V1_0::PowerHint;
41using ::android::hardware::power::V1_0::PowerStatePlatformSleepState;
42using ::android::hardware::power::V1_0::Status;
43using ::android::hardware::power::V1_1::PowerStateSubsystem;
44using ::android::hardware::hidl_vec;
45using ::android::hardware::Return;
46using ::android::hardware::Void;
47
48Power::Power() {
49 power_init();
50}
51
52// Methods from ::android::hardware::power::V1_0::IPower follow.
53Return<void> Power::setInteractive(bool interactive) {
54 power_set_interactive(interactive ? 1 : 0);
55 return Void();
56}
57
58Return<void> Power::powerHint(PowerHint hint, int32_t data) {
59 power_hint(static_cast<power_hint_t>(hint), data ? (&data) : NULL);
60 return Void();
61}
62
63Return<void> Power::setFeature(Feature /*feature*/, bool /*activate*/) {
64 return Void();
65}
66
67Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
68
69 hidl_vec<PowerStatePlatformSleepState> states;
70
71 _hidl_cb(states, Status::SUCCESS);
72 return Void();
73}
74
75
76Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) {
77
78 hidl_vec<PowerStateSubsystem> subsystems;
79 subsystems.resize(subsystem_type::SUBSYSTEM_COUNT);
80
81 //Add query for other subsystems here
82
83 _hidl_cb(subsystems, Status::SUCCESS);
84 return Void();
85}
86
87Return<void> Power::powerHintAsync(PowerHint hint, int32_t data) {
88 // just call the normal power hint in this oneway function
89 return powerHint(hint, data);
90 return Void();
91}
92
93} // namespace implementation
94} // namespace V1_1
95} // namespace power
96} // namespace hardware
97} // namespace android