• 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/RadioConfig.h>
18 
19 #include "commonStructs.h"
20 #include "debug.h"
21 #include "structs.h"
22 
23 #include "collections.h"
24 
25 #define RADIO_MODULE "Config"
26 
27 namespace android::hardware::radio::compat {
28 
29 using ::ndk::ScopedAStatus;
30 namespace aidl = ::aidl::android::hardware::radio::config;
31 constexpr auto ok = &ScopedAStatus::ok;
32 
RadioConfig(sp<config::V1_1::IRadioConfig> hidlHal)33 RadioConfig::RadioConfig(sp<config::V1_1::IRadioConfig> hidlHal)
34     : mHal1_1(hidlHal),
35       mHal1_3(config::V1_3::IRadioConfig::castFrom(hidlHal)),
36       mRadioConfigResponse(sp<RadioConfigResponse>::make()),
37       mRadioConfigIndication(sp<RadioConfigIndication>::make()) {}
38 
respond()39 std::shared_ptr<aidl::IRadioConfigResponse> RadioConfig::respond() {
40     return mRadioConfigResponse->respond();
41 }
42 
getHalDeviceCapabilities(int32_t serial)43 ScopedAStatus RadioConfig::getHalDeviceCapabilities(int32_t serial) {
44     LOG_CALL << serial;
45     if (mHal1_3) {
46         mHal1_3->getHalDeviceCapabilities(serial);
47     } else {
48         respond()->getHalDeviceCapabilitiesResponse(notSupported(serial), false);
49     }
50     return ok();
51 }
52 
getNumOfLiveModems(int32_t serial)53 ScopedAStatus RadioConfig::getNumOfLiveModems(int32_t serial) {
54     LOG_CALL << serial;
55     mHal1_1->getModemsConfig(serial);
56     return ok();
57 }
58 
getPhoneCapability(int32_t serial)59 ScopedAStatus RadioConfig::getPhoneCapability(int32_t serial) {
60     LOG_CALL << serial;
61     mHal1_1->getPhoneCapability(serial);
62     return ok();
63 }
64 
getSimSlotsStatus(int32_t serial)65 ScopedAStatus RadioConfig::getSimSlotsStatus(int32_t serial) {
66     LOG_CALL << serial;
67     mHal1_1->getSimSlotsStatus(serial);
68     return ok();
69 }
70 
setNumOfLiveModems(int32_t serial,int8_t numOfLiveModems)71 ScopedAStatus RadioConfig::setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) {
72     LOG_CALL << serial;
73     mHal1_1->setModemsConfig(serial, {static_cast<uint8_t>(numOfLiveModems)});
74     return ok();
75 }
76 
setPreferredDataModem(int32_t serial,int8_t modemId)77 ScopedAStatus RadioConfig::setPreferredDataModem(int32_t serial, int8_t modemId) {
78     LOG_CALL << serial;
79     mHal1_1->setPreferredDataModem(serial, modemId);
80     return ok();
81 }
82 
setResponseFunctions(const std::shared_ptr<aidl::IRadioConfigResponse> & radioConfigResponse,const std::shared_ptr<aidl::IRadioConfigIndication> & radioConfigIndication)83 ScopedAStatus RadioConfig::setResponseFunctions(
84         const std::shared_ptr<aidl::IRadioConfigResponse>& radioConfigResponse,
85         const std::shared_ptr<aidl::IRadioConfigIndication>& radioConfigIndication) {
86     LOG_CALL << radioConfigResponse << ' ' << radioConfigIndication;
87 
88     CHECK(radioConfigResponse);
89     CHECK(radioConfigIndication);
90 
91     mRadioConfigResponse->setResponseFunction(radioConfigResponse);
92     mRadioConfigIndication->setResponseFunction(radioConfigIndication);
93     mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication).assertOk();
94 
95     return ok();
96 }
97 
setSimSlotsMapping(int32_t serial,const std::vector<aidl::SlotPortMapping> & slotMap)98 ScopedAStatus RadioConfig::setSimSlotsMapping(  //
99         int32_t serial, const std::vector<aidl::SlotPortMapping>& slotMap) {
100     LOG_CALL << serial;
101     mHal1_1->setSimSlotsMapping(serial, toHidl(slotMap));
102     return ok();
103 }
104 
105 }  // namespace android::hardware::radio::compat
106