• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/RadioModem.h>
18 #include "commonStructs.h"
19 #include "debug.h"
20 #include "structs.h"
21 
22 #define RADIO_MODULE "Modem"
23 
24 namespace android::hardware::radio::compat {
25 
26 using ::ndk::ScopedAStatus;
27 namespace aidl = ::aidl::android::hardware::radio::modem;
28 constexpr auto ok = &ScopedAStatus::ok;
29 
respond()30 std::shared_ptr<aidl::IRadioModemResponse> RadioModem::respond() {
31     return mCallbackManager->response().modemCb();
32 }
33 
enableModem(int32_t serial,bool on)34 ScopedAStatus RadioModem::enableModem(int32_t serial, bool on) {
35     LOG_CALL << serial;
36     mHal1_5->enableModem(serial, on);
37     return ok();
38 }
39 
getBasebandVersion(int32_t serial)40 ScopedAStatus RadioModem::getBasebandVersion(int32_t serial) {
41     LOG_CALL << serial;
42     mHal1_5->getBasebandVersion(serial);
43     return ok();
44 }
45 
getDeviceIdentity(int32_t serial)46 ScopedAStatus RadioModem::getDeviceIdentity(int32_t serial) {
47     LOG_CALL << serial;
48     mHal1_5->getDeviceIdentity(serial);
49     return ok();
50 }
51 
getImei(int32_t serial)52 ScopedAStatus 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 
getHardwareConfig(int32_t serial)59 ScopedAStatus RadioModem::getHardwareConfig(int32_t serial) {
60     LOG_CALL << serial;
61     mHal1_5->getHardwareConfig(serial);
62     return ok();
63 }
64 
getModemActivityInfo(int32_t serial)65 ScopedAStatus RadioModem::getModemActivityInfo(int32_t serial) {
66     LOG_CALL << serial;
67     mHal1_5->getModemActivityInfo(serial);
68     return ok();
69 }
70 
getModemStackStatus(int32_t serial)71 ScopedAStatus RadioModem::getModemStackStatus(int32_t serial) {
72     LOG_CALL << serial;
73     mHal1_5->getModemStackStatus(serial);
74     return ok();
75 }
76 
getRadioCapability(int32_t serial)77 ScopedAStatus RadioModem::getRadioCapability(int32_t serial) {
78     LOG_CALL << serial;
79     mHal1_5->getRadioCapability(serial);
80     return ok();
81 }
82 
nvReadItem(int32_t serial,aidl::NvItem itemId)83 ScopedAStatus 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 
nvResetConfig(int32_t serial,aidl::ResetNvType resetType)89 ScopedAStatus 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 
nvWriteCdmaPrl(int32_t serial,const std::vector<uint8_t> & prl)95 ScopedAStatus 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 
nvWriteItem(int32_t serial,const aidl::NvWriteItem & item)101 ScopedAStatus 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 
requestShutdown(int32_t serial)107 ScopedAStatus RadioModem::requestShutdown(int32_t serial) {
108     LOG_CALL << serial;
109     mHal1_5->requestShutdown(serial);
110     return ok();
111 }
112 
responseAcknowledgement()113 ScopedAStatus RadioModem::responseAcknowledgement() {
114     LOG_CALL;
115     mHal1_5->responseAcknowledgement();
116     return ok();
117 }
118 
sendDeviceState(int32_t serial,aidl::DeviceStateType type,bool state)119 ScopedAStatus 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 
setRadioCapability(int32_t serial,const aidl::RadioCapability & rc)125 ScopedAStatus 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 
setRadioPower(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)131 ScopedAStatus 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 
setResponseFunctions(const std::shared_ptr<aidl::IRadioModemResponse> & response,const std::shared_ptr<aidl::IRadioModemIndication> & indication)142 ScopedAStatus RadioModem::setResponseFunctions(
143         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);
147     return ok();
148 }
149 
150 }  // namespace android::hardware::radio::compat
151