blob: 5b22dbe6ca612a7f6860473be37087f7828ddc76 [file] [log] [blame]
Tomasz Wasilczyk6301e8f2021-10-18 16:53:40 -07001/*
2 * Copyright (C) 2021 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 <libradiocompat/RadioConfig.h>
18
Tomasz Wasilczyk6301e8f2021-10-18 16:53:40 -070019#include "commonStructs.h"
20#include "debug.h"
21#include "structs.h"
22
23#define RADIO_MODULE "Config"
24
25namespace android::hardware::radio::compat {
26
27using ::ndk::ScopedAStatus;
28namespace aidl = ::aidl::android::hardware::radio::config;
29constexpr auto ok = &ScopedAStatus::ok;
30
31RadioConfig::RadioConfig(sp<config::V1_1::IRadioConfig> hidlHal)
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080032 : mHal1_1(hidlHal),
33 mHal1_3(config::V1_3::IRadioConfig::castFrom(hidlHal)),
34 mRadioConfigResponse(sp<RadioConfigResponse>::make()),
35 mRadioConfigIndication(sp<RadioConfigIndication>::make()) {}
Tomasz Wasilczyk6301e8f2021-10-18 16:53:40 -070036
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080037std::shared_ptr<aidl::IRadioConfigResponse> RadioConfig::respond() {
38 return mRadioConfigResponse->respond();
Tomasz Wasilczyk6301e8f2021-10-18 16:53:40 -070039}
40
41ScopedAStatus RadioConfig::getHalDeviceCapabilities(int32_t serial) {
42 LOG_CALL << serial;
43 if (mHal1_3) {
44 mHal1_3->getHalDeviceCapabilities(serial);
45 } else {
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080046 respond()->getHalDeviceCapabilitiesResponse(notSupported(serial), false);
Tomasz Wasilczyk6301e8f2021-10-18 16:53:40 -070047 }
48 return ok();
49}
50
51ScopedAStatus RadioConfig::getNumOfLiveModems(int32_t serial) {
52 LOG_CALL << serial;
53 mHal1_1->getModemsConfig(serial);
54 return ok();
55}
56
57ScopedAStatus RadioConfig::getPhoneCapability(int32_t serial) {
58 LOG_CALL << serial;
59 mHal1_1->getPhoneCapability(serial);
60 return ok();
61}
62
63ScopedAStatus RadioConfig::getSimSlotsStatus(int32_t serial) {
64 LOG_CALL << serial;
65 mHal1_1->getSimSlotsStatus(serial);
66 return ok();
67}
68
69ScopedAStatus RadioConfig::setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) {
70 LOG_CALL << serial;
71 mHal1_1->setModemsConfig(serial, {static_cast<uint8_t>(numOfLiveModems)});
72 return ok();
73}
74
75ScopedAStatus RadioConfig::setPreferredDataModem(int32_t serial, int8_t modemId) {
76 LOG_CALL << serial;
77 mHal1_1->setPreferredDataModem(serial, modemId);
78 return ok();
79}
80
81ScopedAStatus RadioConfig::setResponseFunctions(
82 const std::shared_ptr<aidl::IRadioConfigResponse>& radioConfigResponse,
83 const std::shared_ptr<aidl::IRadioConfigIndication>& radioConfigIndication) {
84 LOG_CALL << radioConfigResponse << ' ' << radioConfigIndication;
85
86 CHECK(radioConfigResponse);
87 CHECK(radioConfigIndication);
88
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080089 mRadioConfigResponse->setResponseFunction(radioConfigResponse);
90 mRadioConfigIndication->setResponseFunction(radioConfigIndication);
Tomasz Wasilczyk8579f1d2021-12-16 12:19:09 -080091 mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication).assertOk();
Tomasz Wasilczyk6301e8f2021-10-18 16:53:40 -070092
93 return ok();
94}
95
96ScopedAStatus RadioConfig::setSimSlotsMapping( //
97 int32_t serial, const std::vector<aidl::SlotPortMapping>& slotMap) {
98 LOG_CALL << serial;
99 mHal1_1->setSimSlotsMapping(serial, toHidl(slotMap));
100 return ok();
101}
102
103} // namespace android::hardware::radio::compat