1 /* 2 * Copyright (C) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CELLULAR_DATA_SERVICE_STUB_H 17 #define CELLULAR_DATA_SERVICE_STUB_H 18 19 #include <map> 20 21 #include "iremote_object.h" 22 #include "iremote_stub.h" 23 24 #include "cellular_data_ipc_interface_code.h" 25 #include "i_cellular_data_manager.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 class CellularDataServiceStub : public IRemoteStub<ICellularDataManager> { 30 public: 31 CellularDataServiceStub(); 32 ~CellularDataServiceStub(); 33 int32_t OnRemoteRequest( 34 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 35 int32_t OnRegisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); 36 int32_t OnUnregisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); 37 38 private: 39 int32_t OnIsCellularDataEnabled(MessageParcel &data, MessageParcel &reply); 40 int32_t OnEnableCellularData(MessageParcel &data, MessageParcel &reply); 41 int32_t OnGetCellularDataState(MessageParcel &data, MessageParcel &reply); 42 int32_t OnIsCellularDataRoamingEnabled(MessageParcel &data, MessageParcel &reply); 43 int32_t OnEnableCellularDataRoaming(MessageParcel &data, MessageParcel &reply); 44 int32_t OnHandleApnChanged(MessageParcel &data, MessageParcel &reply); 45 int32_t OnGetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); 46 int32_t OnGetDefaultCellularDataSimId(MessageParcel &data, MessageParcel &reply); 47 int32_t OnSetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); 48 int32_t OnGetCellularDataFlowType(MessageParcel &data, MessageParcel &reply); 49 int32_t OnHasInternetCapability(MessageParcel &data, MessageParcel &reply); 50 int32_t OnClearCellularDataConnections(MessageParcel &data, MessageParcel &reply); 51 int32_t OnGetDataConnApnAttr(MessageParcel &data, MessageParcel &reply); 52 int32_t OnGetDataConnIpType(MessageParcel &data, MessageParcel &reply); 53 int32_t OnClearAllConnections(MessageParcel &data, MessageParcel &reply); 54 int32_t OnGetApnState(MessageParcel &data, MessageParcel &reply); 55 int32_t OnGetRecoveryState(MessageParcel &data, MessageParcel &reply); 56 int32_t OnIsNeedDoRecovery(MessageParcel &data, MessageParcel &reply); 57 int32_t OnEnableIntelligenceSwitch(MessageParcel &data, MessageParcel &reply); 58 int32_t OnInitCellularDataController(MessageParcel &data, MessageParcel &reply); 59 int32_t OnGetIntelligenceSwitchState(MessageParcel &data, MessageParcel &reply); 60 int32_t OnEstablishAllApnsIfConnectable(MessageParcel &data, MessageParcel &reply); 61 int32_t OnReleaseCellularDataConnection(MessageParcel &data, MessageParcel &reply); 62 int32_t OnGetCellularDataSupplierId(MessageParcel &data, MessageParcel &reply); 63 int32_t OnCorrectNetSupplierNoAvailable(MessageParcel &data, MessageParcel &reply); 64 int32_t OnGetSupplierRegisterState(MessageParcel &data, MessageParcel &reply); 65 int32_t SetTimer(uint32_t code); 66 void CancelTimer(int32_t id); 67 int32_t OnIsSupportDunApn(MessageParcel &data, MessageParcel &reply); 68 int32_t OnGetDefaultActReportInfo(MessageParcel &data, MessageParcel &reply); 69 int32_t OnGetInternalActReportInfo(MessageParcel &data, MessageParcel &reply); 70 int32_t OnQueryApnInfo(MessageParcel &data, MessageParcel &reply); 71 int32_t OnSetPreferApn(MessageParcel &data, MessageParcel &reply); 72 int32_t OnQueryAllApnInfo(MessageParcel &data, MessageParcel &reply); 73 74 private: 75 using Fun = std::function<int32_t(MessageParcel &data, MessageParcel &reply)>; 76 std::map<uint32_t, Fun> eventIdFunMap_ { 77 { (uint32_t)CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED, 78 [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataEnabled(data, reply); } }, 79 { (uint32_t)CellularDataInterfaceCode::ENABLE_CELLULAR_DATA, 80 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularData(data, reply); } }, 81 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE, 82 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataState(data, reply); } }, 83 { (uint32_t)CellularDataInterfaceCode::IS_DATA_ROAMING_ENABLED, 84 [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataRoamingEnabled(data, reply); } }, 85 { (uint32_t)CellularDataInterfaceCode::ENABLE_DATA_ROAMING, 86 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularDataRoaming(data, reply); } }, 87 { (uint32_t)CellularDataInterfaceCode::APN_DATA_CHANGED, 88 [this](MessageParcel &data, MessageParcel &reply) { return OnHandleApnChanged(data, reply); } }, 89 { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID, 90 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSlotId(data, reply); } }, 91 { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SIM_ID, 92 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSimId(data, reply); } }, 93 { (uint32_t)CellularDataInterfaceCode::SET_DEFAULT_SLOT_ID, 94 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDefaultCellularDataSlotId(data, reply); } }, 95 { (uint32_t)CellularDataInterfaceCode::GET_FLOW_TYPE_ID, 96 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataFlowType(data, reply); } }, 97 { (uint32_t)CellularDataInterfaceCode::HAS_CAPABILITY, 98 [this](MessageParcel &data, MessageParcel &reply) { return OnHasInternetCapability(data, reply); } }, 99 { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS, 100 [this](MessageParcel &data, MessageParcel &reply) { return OnClearCellularDataConnections(data, reply); } }, 101 { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS_USE_REASON, 102 [this](MessageParcel &data, MessageParcel &reply) { return OnClearAllConnections(data, reply); } }, 103 { (uint32_t)CellularDataInterfaceCode::REG_SIM_ACCOUNT_CALLBACK, 104 [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterSimAccountCallback(data, reply); } }, 105 { (uint32_t)CellularDataInterfaceCode::UN_REG_SIM_ACCOUNT_CALLBACK, 106 [this](MessageParcel &data, MessageParcel &reply) { return OnUnregisterSimAccountCallback(data, reply); } }, 107 { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_APN_ATTR, 108 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnApnAttr(data, reply); } }, 109 { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_IP_TYPE, 110 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnIpType(data, reply); } }, 111 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_APN_STATE, 112 [this](MessageParcel &data, MessageParcel &reply) { return OnGetApnState(data, reply); } }, 113 { (uint32_t)CellularDataInterfaceCode::GET_RECOVERY_STATE, 114 [this](MessageParcel &data, MessageParcel &reply) { return OnGetRecoveryState(data, reply); } }, 115 { (uint32_t)CellularDataInterfaceCode::IS_NEED_DO_RECOVERY, 116 [this](MessageParcel &data, MessageParcel &reply) { return OnIsNeedDoRecovery(data, reply); } }, 117 { (uint32_t)CellularDataInterfaceCode::ENABLE_INTELLIGENCE_SWITCH, 118 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableIntelligenceSwitch(data, reply); } }, 119 { (uint32_t)CellularDataInterfaceCode::INIT_CELLULAR_DATA_CONTROLLER, 120 [this](MessageParcel &data, MessageParcel &reply) { return OnInitCellularDataController(data, reply); } }, 121 { (uint32_t)CellularDataInterfaceCode::GET_INTELLIGENCE_SWITCH_STATE, 122 [this](MessageParcel &data, MessageParcel &reply) { return OnGetIntelligenceSwitchState(data, reply); } }, 123 { (uint32_t)CellularDataInterfaceCode::ESTABLISH_ALL_APNS_IF_CONNECTABLE, 124 [this](MessageParcel &data, MessageParcel &reply) { 125 return OnEstablishAllApnsIfConnectable(data, reply); } }, 126 { (uint32_t)CellularDataInterfaceCode::RELEASE_CELLULAR_DATA_CONNECTION, 127 [this](MessageParcel &data, MessageParcel &reply) { return OnReleaseCellularDataConnection(data, reply); }}, 128 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_SUPPLIERID, 129 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataSupplierId(data, reply); } }, 130 { (uint32_t)CellularDataInterfaceCode::CORRECT_NET_SUPPLIER_NO_AVAILABLE, 131 [this](MessageParcel &data, MessageParcel &reply) { 132 return OnCorrectNetSupplierNoAvailable(data, reply); } }, 133 { (uint32_t)CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE, 134 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSupplierRegisterState(data, reply); } }, 135 { (uint32_t)CellularDataInterfaceCode::GET_IF_SUPPORT_DUN_APN, 136 [this](MessageParcel &data, MessageParcel &reply) { return OnIsSupportDunApn(data, reply); } }, 137 { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_ACT_REPORT_INFO, 138 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultActReportInfo(data, reply); } }, 139 { (uint32_t)CellularDataInterfaceCode::GET_INTERNAL_ACT_REPORT_INFO, 140 [this](MessageParcel &data, MessageParcel &reply) { return OnGetInternalActReportInfo(data, reply); } }, 141 { (uint32_t)CellularDataInterfaceCode::QUERY_APN_INFO, 142 [this](MessageParcel &data, MessageParcel &reply) { return OnQueryApnInfo(data, reply); } }, 143 { (uint32_t)CellularDataInterfaceCode::SET_PREFER_APN, 144 [this](MessageParcel &data, MessageParcel &reply) { return OnSetPreferApn(data, reply); } }, 145 { (uint32_t)CellularDataInterfaceCode::QUERY_ALL_APN_INFO, 146 [this](MessageParcel &data, MessageParcel &reply) { return OnQueryAllApnInfo(data, reply); } } 147 }; 148 std::map<uint32_t, std::string> collieCodeStringMap_ = { 149 { uint32_t(CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE), "GET_CELLULAR_DATA_STATE" }, 150 { uint32_t(CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED), "IS_CELLULAR_DATA_ENABLED" }, 151 { uint32_t(CellularDataInterfaceCode::ENABLE_CELLULAR_DATA), "ENABLE_CELLULAR_DATA" }, 152 { uint32_t(CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID), "GET_DEFAULT_SLOT_ID" }, 153 }; 154 }; 155 } // namespace Telephony 156 } // namespace OHOS 157 #endif // CELLULAR_DATA_SERVICE_STUB_H 158