blob: cc15ccb75d5561d142f2a651a69c94e5a02c804c [file] [log] [blame]
Hayden Gomesaeeb9b02020-10-27 13:08:34 -07001/*
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 "AudioControl.h"
Eric Jeong8dae6e72020-12-03 16:39:53 -080018#include "PowerPolicyClient.h"
Hayden Gomesaeeb9b02020-10-27 13:08:34 -070019
20#include <android-base/logging.h>
21#include <android/binder_manager.h>
22#include <android/binder_process.h>
23
24using aidl::android::hardware::automotive::audiocontrol::AudioControl;
Eric Jeong8dae6e72020-12-03 16:39:53 -080025using aidl::android::hardware::automotive::audiocontrol::PowerPolicyClient;
Hayden Gomesaeeb9b02020-10-27 13:08:34 -070026
27int main() {
28 ABinderProcess_setThreadPoolMaxThreadCount(0);
Eric Jeong8dae6e72020-12-03 16:39:53 -080029 std::shared_ptr<AudioControl> audioControl = ::ndk::SharedRefBase::make<AudioControl>();
Hayden Gomesaeeb9b02020-10-27 13:08:34 -070030
31 const std::string instance = std::string() + AudioControl::descriptor + "/default";
32 binder_status_t status =
33 AServiceManager_addService(audioControl->asBinder().get(), instance.c_str());
Steven Morelandffb03992021-12-14 01:45:47 +000034 CHECK_EQ(status, STATUS_OK);
Hayden Gomesaeeb9b02020-10-27 13:08:34 -070035
Eric Jeong8dae6e72020-12-03 16:39:53 -080036 std::shared_ptr<PowerPolicyClient> powerPolicyClient =
37 ::ndk::SharedRefBase::make<PowerPolicyClient>(audioControl);
38 powerPolicyClient->init();
39
Hayden Gomesaeeb9b02020-10-27 13:08:34 -070040 ABinderProcess_joinThreadPool();
41 return EXIT_FAILURE; // should not reach
42}