blob: 765733716b2ed1855e3280b081e75c32e2031e8f [file] [log] [blame]
Eric Jeong8dae6e72020-12-03 16:39:53 -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 "PowerPolicyClient.h"
18#include "AudioControl.h"
19
20#include <android-base/logging.h>
21
22namespace aidl {
23namespace android {
24namespace hardware {
25namespace automotive {
26namespace audiocontrol {
27
28namespace aafap = aidl::android::frameworks::automotive::powerpolicy;
29
30using aafap::CarPowerPolicy;
31using aafap::CarPowerPolicyFilter;
32using aafap::PowerComponent;
33using ::android::frameworks::automotive::powerpolicy::hasComponent;
34using ::ndk::ScopedAStatus;
35
36namespace {
37
38constexpr PowerComponent kAudioComponent = PowerComponent::AUDIO;
39
40} // namespace
41
42PowerPolicyClient::PowerPolicyClient(std::shared_ptr<AudioControl> audioControl)
43 : mAudioControl(audioControl) {}
44
45void PowerPolicyClient::onInitFailed() {
46 LOG(ERROR) << "Initializing power policy client failed";
47}
48
49std::vector<PowerComponent> PowerPolicyClient::getComponentsOfInterest() {
50 std::vector<PowerComponent> components{kAudioComponent};
51 return components;
52}
53
54ScopedAStatus PowerPolicyClient::onPolicyChanged(const CarPowerPolicy& powerPolicy) {
55 if (hasComponent(powerPolicy.enabledComponents, kAudioComponent)) {
56 LOG(DEBUG) << "Power policy: Audio component is enabled";
57 // TODO(b/173719953): Do something when AUDIO is enabled.
58 } else if (hasComponent(powerPolicy.disabledComponents, kAudioComponent)) {
59 LOG(DEBUG) << "Power policy: Audio component is disabled";
60 // TODO(b/173719953): Do something when AUDIO is disabled.
61 }
62 return ScopedAStatus::ok();
63}
64
65} // namespace audiocontrol
66} // namespace automotive
67} // namespace hardware
68} // namespace android
69} // namespace aidl