1 /*
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/RadioResponse.h>
18
19 #include "commonStructs.h"
20 #include "debug.h"
21 #include "structs.h"
22
23 #include "collections.h"
24
25 #define RADIO_MODULE "ModemResponse"
26
27 namespace android::hardware::radio::compat {
28
29 namespace aidl = ::aidl::android::hardware::radio::modem;
30
setResponseFunction(std::shared_ptr<aidl::IRadioModemResponse> modemCb)31 void RadioResponse::setResponseFunction(std::shared_ptr<aidl::IRadioModemResponse> modemCb) {
32 mModemCb = modemCb;
33 }
34
modemCb()35 std::shared_ptr<aidl::IRadioModemResponse> RadioResponse::modemCb() {
36 return mModemCb.get();
37 }
38
enableModemResponse(const V1_0::RadioResponseInfo & info)39 Return<void> RadioResponse::enableModemResponse(const V1_0::RadioResponseInfo& info) {
40 LOG_CALL << info.serial;
41 modemCb()->enableModemResponse(toAidl(info));
42 return {};
43 }
44
getBasebandVersionResponse(const V1_0::RadioResponseInfo & info,const hidl_string & version)45 Return<void> RadioResponse::getBasebandVersionResponse(const V1_0::RadioResponseInfo& info,
46 const hidl_string& version) {
47 LOG_CALL << info.serial;
48 modemCb()->getBasebandVersionResponse(toAidl(info), version);
49 return {};
50 }
51
getDeviceIdentityResponse(const V1_0::RadioResponseInfo & info,const hidl_string & imei,const hidl_string & imeisv,const hidl_string & esn,const hidl_string & meid)52 Return<void> RadioResponse::getDeviceIdentityResponse( //
53 const V1_0::RadioResponseInfo& info, const hidl_string& imei, const hidl_string& imeisv,
54 const hidl_string& esn, const hidl_string& meid) {
55 LOG_CALL << info.serial;
56 modemCb()->getDeviceIdentityResponse(toAidl(info), imei, imeisv, esn, meid);
57 return {};
58 }
59
getHardwareConfigResponse(const V1_0::RadioResponseInfo & info,const hidl_vec<V1_0::HardwareConfig> & config)60 Return<void> RadioResponse::getHardwareConfigResponse(
61 const V1_0::RadioResponseInfo& info, const hidl_vec<V1_0::HardwareConfig>& config) {
62 LOG_CALL << info.serial;
63 modemCb()->getHardwareConfigResponse(toAidl(info), toAidl(config));
64 return {};
65 }
66
getModemActivityInfoResponse(const V1_0::RadioResponseInfo & info,const V1_0::ActivityStatsInfo & activityInfo)67 Return<void> RadioResponse::getModemActivityInfoResponse(
68 const V1_0::RadioResponseInfo& info, const V1_0::ActivityStatsInfo& activityInfo) {
69 LOG_CALL << info.serial;
70 modemCb()->getModemActivityInfoResponse(toAidl(info), toAidl(activityInfo));
71 return {};
72 }
73
getModemStackStatusResponse(const V1_0::RadioResponseInfo & info,bool isEnabled)74 Return<void> RadioResponse::getModemStackStatusResponse(const V1_0::RadioResponseInfo& info,
75 bool isEnabled) {
76 LOG_CALL << info.serial;
77 modemCb()->getModemStackStatusResponse(toAidl(info), isEnabled);
78 return {};
79 }
80
getRadioCapabilityResponse(const V1_0::RadioResponseInfo & info,const V1_0::RadioCapability & rc)81 Return<void> RadioResponse::getRadioCapabilityResponse(const V1_0::RadioResponseInfo& info,
82 const V1_0::RadioCapability& rc) {
83 LOG_CALL << info.serial;
84 modemCb()->getRadioCapabilityResponse(toAidl(info), toAidl(rc));
85 return {};
86 }
87
nvReadItemResponse(const V1_0::RadioResponseInfo & info,const hidl_string & result)88 Return<void> RadioResponse::nvReadItemResponse(const V1_0::RadioResponseInfo& info,
89 const hidl_string& result) {
90 LOG_CALL << info.serial;
91 modemCb()->nvReadItemResponse(toAidl(info), result);
92 return {};
93 }
94
nvResetConfigResponse(const V1_0::RadioResponseInfo & info)95 Return<void> RadioResponse::nvResetConfigResponse(const V1_0::RadioResponseInfo& info) {
96 LOG_CALL << info.serial;
97 modemCb()->nvResetConfigResponse(toAidl(info));
98 return {};
99 }
100
nvWriteCdmaPrlResponse(const V1_0::RadioResponseInfo & info)101 Return<void> RadioResponse::nvWriteCdmaPrlResponse(const V1_0::RadioResponseInfo& info) {
102 LOG_CALL << info.serial;
103 modemCb()->nvWriteCdmaPrlResponse(toAidl(info));
104 return {};
105 }
106
nvWriteItemResponse(const V1_0::RadioResponseInfo & info)107 Return<void> RadioResponse::nvWriteItemResponse(const V1_0::RadioResponseInfo& info) {
108 LOG_CALL << info.serial;
109 modemCb()->nvWriteItemResponse(toAidl(info));
110 return {};
111 }
112
requestShutdownResponse(const V1_0::RadioResponseInfo & info)113 Return<void> RadioResponse::requestShutdownResponse(const V1_0::RadioResponseInfo& info) {
114 LOG_CALL << info.serial;
115 modemCb()->requestShutdownResponse(toAidl(info));
116 return {};
117 }
118
sendDeviceStateResponse(const V1_0::RadioResponseInfo & info)119 Return<void> RadioResponse::sendDeviceStateResponse(const V1_0::RadioResponseInfo& info) {
120 LOG_CALL << info.serial;
121 modemCb()->sendDeviceStateResponse(toAidl(info));
122 return {};
123 }
124
setRadioCapabilityResponse(const V1_0::RadioResponseInfo & info,const V1_0::RadioCapability & rc)125 Return<void> RadioResponse::setRadioCapabilityResponse(const V1_0::RadioResponseInfo& info,
126 const V1_0::RadioCapability& rc) {
127 LOG_CALL << info.serial;
128 modemCb()->setRadioCapabilityResponse(toAidl(info), toAidl(rc));
129 return {};
130 }
131
setRadioPowerResponse(const V1_0::RadioResponseInfo & info)132 Return<void> RadioResponse::setRadioPowerResponse(const V1_0::RadioResponseInfo& info) {
133 LOG_CALL << info.serial;
134 modemCb()->setRadioPowerResponse(toAidl(info));
135 return {};
136 }
137
setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo & info)138 Return<void> RadioResponse::setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) {
139 LOG_CALL << info.serial;
140 modemCb()->setRadioPowerResponse(toAidl(info));
141 return {};
142 }
143
setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo & info)144 Return<void> RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo& info) {
145 LOG_CALL << info.serial;
146 modemCb()->setRadioPowerResponse(toAidl(info));
147 return {};
148 }
149
150 } // namespace android::hardware::radio::compat
151