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 "PowerPolicyClient.h" 18 #include "AudioControl.h" 19 20 #include <android-base/logging.h> 21 22 namespace aidl { 23 namespace android { 24 namespace hardware { 25 namespace automotive { 26 namespace audiocontrol { 27 28 namespace aafap = aidl::android::frameworks::automotive::powerpolicy; 29 30 using aafap::CarPowerPolicy; 31 using aafap::CarPowerPolicyFilter; 32 using aafap::PowerComponent; 33 using ::android::frameworks::automotive::powerpolicy::hasComponent; 34 using ::ndk::ScopedAStatus; 35 36 namespace { 37 38 constexpr PowerComponent kAudioComponent = PowerComponent::AUDIO; 39 40 } // namespace 41 PowerPolicyClient(std::shared_ptr<AudioControl> audioControl)42PowerPolicyClient::PowerPolicyClient(std::shared_ptr<AudioControl> audioControl) 43 : mAudioControl(audioControl) {} 44 onInitFailed()45void PowerPolicyClient::onInitFailed() { 46 LOG(ERROR) << "Initializing power policy client failed"; 47 } 48 getComponentsOfInterest()49std::vector<PowerComponent> PowerPolicyClient::getComponentsOfInterest() { 50 std::vector<PowerComponent> components{kAudioComponent}; 51 return components; 52 } 53 onPolicyChanged(const CarPowerPolicy & powerPolicy)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 70