blob: d28b94041b4b836b814e92fe3830dbf84aff0a93 [file] [log] [blame]
Tomasz Wasilczyk535f30c2021-11-08 16:10:28 -08001/*
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/RadioModem.h>
18
19#include "debug.h"
20#include "structs.h"
21
22#define RADIO_MODULE "Modem"
23
24namespace android::hardware::radio::compat {
25
26using ::ndk::ScopedAStatus;
27namespace aidl = ::aidl::android::hardware::radio::modem;
28constexpr auto ok = &ScopedAStatus::ok;
29
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080030std::shared_ptr<aidl::IRadioModemResponse> RadioModem::respond() {
Tomasz Wasilczyk8579f1d2021-12-16 12:19:09 -080031 return mCallbackManager->response().modemCb();
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080032}
33
Tomasz Wasilczyk535f30c2021-11-08 16:10:28 -080034ScopedAStatus RadioModem::enableModem(int32_t serial, bool on) {
35 LOG_CALL << serial;
36 mHal1_5->enableModem(serial, on);
37 return ok();
38}
39
40ScopedAStatus RadioModem::getBasebandVersion(int32_t serial) {
41 LOG_CALL << serial;
42 mHal1_5->getBasebandVersion(serial);
43 return ok();
44}
45
46ScopedAStatus RadioModem::getDeviceIdentity(int32_t serial) {
47 LOG_CALL << serial;
48 mHal1_5->getDeviceIdentity(serial);
49 return ok();
50}
51
52ScopedAStatus RadioModem::getHardwareConfig(int32_t serial) {
53 LOG_CALL << serial;
54 mHal1_5->getHardwareConfig(serial);
55 return ok();
56}
57
58ScopedAStatus RadioModem::getModemActivityInfo(int32_t serial) {
59 LOG_CALL << serial;
60 mHal1_5->getModemActivityInfo(serial);
61 return ok();
62}
63
64ScopedAStatus RadioModem::getModemStackStatus(int32_t serial) {
65 LOG_CALL << serial;
66 mHal1_5->getModemStackStatus(serial);
67 return ok();
68}
69
70ScopedAStatus RadioModem::getRadioCapability(int32_t serial) {
71 LOG_CALL << serial;
72 mHal1_5->getRadioCapability(serial);
73 return ok();
74}
75
76ScopedAStatus RadioModem::nvReadItem(int32_t serial, aidl::NvItem itemId) {
77 LOG_CALL << serial;
78 mHal1_5->nvReadItem(serial, V1_0::NvItem(itemId));
79 return ok();
80}
81
82ScopedAStatus RadioModem::nvResetConfig(int32_t serial, aidl::ResetNvType resetType) {
83 LOG_CALL << serial;
84 mHal1_5->nvResetConfig(serial, V1_0::ResetNvType(resetType));
85 return ok();
86}
87
88ScopedAStatus RadioModem::nvWriteCdmaPrl(int32_t serial, const std::vector<uint8_t>& prl) {
89 LOG_CALL << serial;
90 mHal1_5->nvWriteCdmaPrl(serial, prl);
91 return ok();
92}
93
94ScopedAStatus RadioModem::nvWriteItem(int32_t serial, const aidl::NvWriteItem& item) {
95 LOG_CALL << serial;
96 mHal1_5->nvWriteItem(serial, toHidl(item));
97 return ok();
98}
99
100ScopedAStatus RadioModem::requestShutdown(int32_t serial) {
101 LOG_CALL << serial;
102 mHal1_5->requestShutdown(serial);
103 return ok();
104}
105
106ScopedAStatus RadioModem::responseAcknowledgement() {
107 LOG_CALL;
108 mHal1_5->responseAcknowledgement();
109 return ok();
110}
111
112ScopedAStatus RadioModem::sendDeviceState(int32_t serial, aidl::DeviceStateType type, bool state) {
113 LOG_CALL << serial;
114 mHal1_5->sendDeviceState(serial, V1_0::DeviceStateType(type), state);
115 return ok();
116}
117
118ScopedAStatus RadioModem::setRadioCapability(int32_t serial, const aidl::RadioCapability& rc) {
119 LOG_CALL << serial;
120 mHal1_5->setRadioCapability(serial, toHidl(rc));
121 return ok();
122}
123
124ScopedAStatus RadioModem::setRadioPower(int32_t serial, bool powerOn, bool forEmergencyCall,
125 bool preferredForEmergencyCall) {
126 LOG_CALL << serial;
127 if (mHal1_6) {
128 mHal1_6->setRadioPower_1_6(serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
129 } else {
130 mHal1_5->setRadioPower_1_5(serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
131 }
132 return ok();
133}
134
135ScopedAStatus RadioModem::setResponseFunctions(
Tomasz Wasilczyk8579f1d2021-12-16 12:19:09 -0800136 const std::shared_ptr<aidl::IRadioModemResponse>& response,
137 const std::shared_ptr<aidl::IRadioModemIndication>& indication) {
138 LOG_CALL << response << ' ' << indication;
139 mCallbackManager->setResponseFunctions(response, indication);
Tomasz Wasilczyk535f30c2021-11-08 16:10:28 -0800140 return ok();
141}
142
143} // namespace android::hardware::radio::compat