blob: f088b10b1986d2fbf38bd5f8550a1103c75f6af3 [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>
arunvoddud9bbd442022-11-15 08:39:26 +000018#include "commonStructs.h"
Tomasz Wasilczyk535f30c2021-11-08 16:10:28 -080019#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
arunvoddud9bbd442022-11-15 08:39:26 +000052ScopedAStatus RadioModem::getImei(int32_t serial) {
53 LOG_CALL << serial;
54 LOG(ERROR) << " getImei is unsupported by HIDL HALs";
55 respond()->getImeiResponse(notSupported(serial), {});
56 return ok();
57}
58
Tomasz Wasilczyk535f30c2021-11-08 16:10:28 -080059ScopedAStatus RadioModem::getHardwareConfig(int32_t serial) {
60 LOG_CALL << serial;
61 mHal1_5->getHardwareConfig(serial);
62 return ok();
63}
64
65ScopedAStatus RadioModem::getModemActivityInfo(int32_t serial) {
66 LOG_CALL << serial;
67 mHal1_5->getModemActivityInfo(serial);
68 return ok();
69}
70
71ScopedAStatus RadioModem::getModemStackStatus(int32_t serial) {
72 LOG_CALL << serial;
73 mHal1_5->getModemStackStatus(serial);
74 return ok();
75}
76
77ScopedAStatus RadioModem::getRadioCapability(int32_t serial) {
78 LOG_CALL << serial;
79 mHal1_5->getRadioCapability(serial);
80 return ok();
81}
82
83ScopedAStatus RadioModem::nvReadItem(int32_t serial, aidl::NvItem itemId) {
84 LOG_CALL << serial;
85 mHal1_5->nvReadItem(serial, V1_0::NvItem(itemId));
86 return ok();
87}
88
89ScopedAStatus RadioModem::nvResetConfig(int32_t serial, aidl::ResetNvType resetType) {
90 LOG_CALL << serial;
91 mHal1_5->nvResetConfig(serial, V1_0::ResetNvType(resetType));
92 return ok();
93}
94
95ScopedAStatus RadioModem::nvWriteCdmaPrl(int32_t serial, const std::vector<uint8_t>& prl) {
96 LOG_CALL << serial;
97 mHal1_5->nvWriteCdmaPrl(serial, prl);
98 return ok();
99}
100
101ScopedAStatus RadioModem::nvWriteItem(int32_t serial, const aidl::NvWriteItem& item) {
102 LOG_CALL << serial;
103 mHal1_5->nvWriteItem(serial, toHidl(item));
104 return ok();
105}
106
107ScopedAStatus RadioModem::requestShutdown(int32_t serial) {
108 LOG_CALL << serial;
109 mHal1_5->requestShutdown(serial);
110 return ok();
111}
112
113ScopedAStatus RadioModem::responseAcknowledgement() {
114 LOG_CALL;
115 mHal1_5->responseAcknowledgement();
116 return ok();
117}
118
119ScopedAStatus RadioModem::sendDeviceState(int32_t serial, aidl::DeviceStateType type, bool state) {
120 LOG_CALL << serial;
121 mHal1_5->sendDeviceState(serial, V1_0::DeviceStateType(type), state);
122 return ok();
123}
124
125ScopedAStatus RadioModem::setRadioCapability(int32_t serial, const aidl::RadioCapability& rc) {
126 LOG_CALL << serial;
127 mHal1_5->setRadioCapability(serial, toHidl(rc));
128 return ok();
129}
130
131ScopedAStatus RadioModem::setRadioPower(int32_t serial, bool powerOn, bool forEmergencyCall,
132 bool preferredForEmergencyCall) {
133 LOG_CALL << serial;
134 if (mHal1_6) {
135 mHal1_6->setRadioPower_1_6(serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
136 } else {
137 mHal1_5->setRadioPower_1_5(serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
138 }
139 return ok();
140}
141
142ScopedAStatus RadioModem::setResponseFunctions(
Tomasz Wasilczyk8579f1d2021-12-16 12:19:09 -0800143 const std::shared_ptr<aidl::IRadioModemResponse>& response,
144 const std::shared_ptr<aidl::IRadioModemIndication>& indication) {
145 LOG_CALL << response << ' ' << indication;
146 mCallbackManager->setResponseFunctions(response, indication);
Tomasz Wasilczyk535f30c2021-11-08 16:10:28 -0800147 return ok();
148}
149
150} // namespace android::hardware::radio::compat