blob: b45041811d4de0615ab80e992ff3ee1e719f1a34 [file] [log] [blame]
Tomasz Wasilczykbff3b5b2021-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 Wasilczykbff3b5b2021-10-18 16:53:40 -070019#include "commonStructs.h"
20#include "debug.h"
21#include "structs.h"
22
Tomasz Wasilczyke807d372022-01-05 13:15:39 -080023#include "collections.h"
24
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -070025#define RADIO_MODULE "Config"
26
27namespace android::hardware::radio::compat {
28
29using ::ndk::ScopedAStatus;
30namespace aidl = ::aidl::android::hardware::radio::config;
31constexpr auto ok = &ScopedAStatus::ok;
32
33RadioConfig::RadioConfig(sp<config::V1_1::IRadioConfig> hidlHal)
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080034 : mHal1_1(hidlHal),
35 mHal1_3(config::V1_3::IRadioConfig::castFrom(hidlHal)),
36 mRadioConfigResponse(sp<RadioConfigResponse>::make()),
37 mRadioConfigIndication(sp<RadioConfigIndication>::make()) {}
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -070038
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080039std::shared_ptr<aidl::IRadioConfigResponse> RadioConfig::respond() {
40 return mRadioConfigResponse->respond();
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -070041}
42
43ScopedAStatus RadioConfig::getHalDeviceCapabilities(int32_t serial) {
44 LOG_CALL << serial;
45 if (mHal1_3) {
46 mHal1_3->getHalDeviceCapabilities(serial);
47 } else {
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080048 respond()->getHalDeviceCapabilitiesResponse(notSupported(serial), false);
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -070049 }
50 return ok();
51}
52
53ScopedAStatus RadioConfig::getNumOfLiveModems(int32_t serial) {
54 LOG_CALL << serial;
55 mHal1_1->getModemsConfig(serial);
56 return ok();
57}
58
59ScopedAStatus RadioConfig::getPhoneCapability(int32_t serial) {
60 LOG_CALL << serial;
61 mHal1_1->getPhoneCapability(serial);
62 return ok();
63}
64
65ScopedAStatus RadioConfig::getSimSlotsStatus(int32_t serial) {
66 LOG_CALL << serial;
67 mHal1_1->getSimSlotsStatus(serial);
68 return ok();
69}
70
71ScopedAStatus RadioConfig::setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) {
72 LOG_CALL << serial;
73 mHal1_1->setModemsConfig(serial, {static_cast<uint8_t>(numOfLiveModems)});
74 return ok();
75}
76
77ScopedAStatus RadioConfig::setPreferredDataModem(int32_t serial, int8_t modemId) {
78 LOG_CALL << serial;
79 mHal1_1->setPreferredDataModem(serial, modemId);
80 return ok();
81}
82
83ScopedAStatus RadioConfig::setResponseFunctions(
84 const std::shared_ptr<aidl::IRadioConfigResponse>& radioConfigResponse,
85 const std::shared_ptr<aidl::IRadioConfigIndication>& radioConfigIndication) {
86 LOG_CALL << radioConfigResponse << ' ' << radioConfigIndication;
87
88 CHECK(radioConfigResponse);
89 CHECK(radioConfigIndication);
90
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080091 mRadioConfigResponse->setResponseFunction(radioConfigResponse);
92 mRadioConfigIndication->setResponseFunction(radioConfigIndication);
Tomasz Wasilczyk963a56f2021-12-16 12:19:09 -080093 mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication).assertOk();
Tomasz Wasilczykbff3b5b2021-10-18 16:53:40 -070094
95 return ok();
96}
97
98ScopedAStatus RadioConfig::setSimSlotsMapping( //
99 int32_t serial, const std::vector<aidl::SlotPortMapping>& slotMap) {
100 LOG_CALL << serial;
101 mHal1_1->setSimSlotsMapping(serial, toHidl(slotMap));
102 return ok();
103}
104
105} // namespace android::hardware::radio::compat