• 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 
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 
getHardwareConfig(int32_t serial)52 ScopedAStatus RadioModem::getHardwareConfig(int32_t serial) {
53     LOG_CALL << serial;
54     mHal1_5->getHardwareConfig(serial);
55     return ok();
56 }
57 
getModemActivityInfo(int32_t serial)58 ScopedAStatus RadioModem::getModemActivityInfo(int32_t serial) {
59     LOG_CALL << serial;
60     mHal1_5->getModemActivityInfo(serial);
61     return ok();
62 }
63 
getModemStackStatus(int32_t serial)64 ScopedAStatus RadioModem::getModemStackStatus(int32_t serial) {
65     LOG_CALL << serial;
66     mHal1_5->getModemStackStatus(serial);
67     return ok();
68 }
69 
getRadioCapability(int32_t serial)70 ScopedAStatus RadioModem::getRadioCapability(int32_t serial) {
71     LOG_CALL << serial;
72     mHal1_5->getRadioCapability(serial);
73     return ok();
74 }
75 
nvReadItem(int32_t serial,aidl::NvItem itemId)76 ScopedAStatus 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 
nvResetConfig(int32_t serial,aidl::ResetNvType resetType)82 ScopedAStatus 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 
nvWriteCdmaPrl(int32_t serial,const std::vector<uint8_t> & prl)88 ScopedAStatus 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 
nvWriteItem(int32_t serial,const aidl::NvWriteItem & item)94 ScopedAStatus 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 
requestShutdown(int32_t serial)100 ScopedAStatus RadioModem::requestShutdown(int32_t serial) {
101     LOG_CALL << serial;
102     mHal1_5->requestShutdown(serial);
103     return ok();
104 }
105 
responseAcknowledgement()106 ScopedAStatus RadioModem::responseAcknowledgement() {
107     LOG_CALL;
108     mHal1_5->responseAcknowledgement();
109     return ok();
110 }
111 
sendDeviceState(int32_t serial,aidl::DeviceStateType type,bool state)112 ScopedAStatus 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 
setRadioCapability(int32_t serial,const aidl::RadioCapability & rc)118 ScopedAStatus 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 
setRadioPower(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)124 ScopedAStatus 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 
setResponseFunctions(const std::shared_ptr<aidl::IRadioModemResponse> & response,const std::shared_ptr<aidl::IRadioModemIndication> & indication)135 ScopedAStatus RadioModem::setResponseFunctions(
136         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);
140     return ok();
141 }
142 
143 }  // namespace android::hardware::radio::compat
144