blob: d0d6f7af2809d02ab5a3892d3964731cc6690cad [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
19#include "RadioConfigIndication.h"
20#include "RadioConfigResponse.h"
21#include "commonStructs.h"
22#include "debug.h"
23#include "structs.h"
24
25#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)
34 : mHal1_1(hidlHal), mHal1_3(config::V1_3::IRadioConfig::castFrom(hidlHal)) {}
35
36config::V1_3::IRadioConfigResponse& RadioConfig::respond() {
37 CHECK(mRadioConfigResponse) << "setResponseFunctions was not called yet";
38 return *mRadioConfigResponse;
39}
40
41ScopedAStatus RadioConfig::getHalDeviceCapabilities(int32_t serial) {
42 LOG_CALL << serial;
43 if (mHal1_3) {
44 mHal1_3->getHalDeviceCapabilities(serial);
45 } else {
46 respond().getHalDeviceCapabilitiesResponse(notSupported(serial), false);
47 }
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
89 mRadioConfigResponse = sp<RadioConfigResponse>::make(radioConfigResponse);
90 mRadioConfigIndication = sp<RadioConfigIndication>::make(radioConfigIndication);
91 mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication);
92
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