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 27namespace OHOS { 28namespace Telephony { 29class CellularDataServiceStub : public IRemoteStub<ICellularDataManager> { 30public: 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 38private: 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 68private: 69 using Fun = std::function<int32_t(MessageParcel &data, MessageParcel &reply)>; 70 std::map<uint32_t, Fun> eventIdFunMap_ { 71 { (uint32_t)CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED, 72 [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataEnabled(data, reply); } }, 73 { (uint32_t)CellularDataInterfaceCode::ENABLE_CELLULAR_DATA, 74 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularData(data, reply); } }, 75 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE, 76 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataState(data, reply); } }, 77 { (uint32_t)CellularDataInterfaceCode::IS_DATA_ROAMING_ENABLED, 78 [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataRoamingEnabled(data, reply); } }, 79 { (uint32_t)CellularDataInterfaceCode::ENABLE_DATA_ROAMING, 80 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularDataRoaming(data, reply); } }, 81 { (uint32_t)CellularDataInterfaceCode::APN_DATA_CHANGED, 82 [this](MessageParcel &data, MessageParcel &reply) { return OnHandleApnChanged(data, reply); } }, 83 { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID, 84 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSlotId(data, reply); } }, 85 { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SIM_ID, 86 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSimId(data, reply); } }, 87 { (uint32_t)CellularDataInterfaceCode::SET_DEFAULT_SLOT_ID, 88 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDefaultCellularDataSlotId(data, reply); } }, 89 { (uint32_t)CellularDataInterfaceCode::GET_FLOW_TYPE_ID, 90 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataFlowType(data, reply); } }, 91 { (uint32_t)CellularDataInterfaceCode::HAS_CAPABILITY, 92 [this](MessageParcel &data, MessageParcel &reply) { return OnHasInternetCapability(data, reply); } }, 93 { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS, 94 [this](MessageParcel &data, MessageParcel &reply) { return OnClearCellularDataConnections(data, reply); } }, 95 { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS_USE_REASON, 96 [this](MessageParcel &data, MessageParcel &reply) { return OnClearAllConnections(data, reply); } }, 97 { (uint32_t)CellularDataInterfaceCode::REG_SIM_ACCOUNT_CALLBACK, 98 [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterSimAccountCallback(data, reply); } }, 99 { (uint32_t)CellularDataInterfaceCode::UN_REG_SIM_ACCOUNT_CALLBACK, 100 [this](MessageParcel &data, MessageParcel &reply) { return OnUnregisterSimAccountCallback(data, reply); } }, 101 { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_APN_ATTR, 102 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnApnAttr(data, reply); } }, 103 { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_IP_TYPE, 104 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnIpType(data, reply); } }, 105 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_APN_STATE, 106 [this](MessageParcel &data, MessageParcel &reply) { return OnGetApnState(data, reply); } }, 107 { (uint32_t)CellularDataInterfaceCode::GET_RECOVERY_STATE, 108 [this](MessageParcel &data, MessageParcel &reply) { return OnGetRecoveryState(data, reply); } }, 109 { (uint32_t)CellularDataInterfaceCode::IS_NEED_DO_RECOVERY, 110 [this](MessageParcel &data, MessageParcel &reply) { return OnIsNeedDoRecovery(data, reply); } }, 111 { (uint32_t)CellularDataInterfaceCode::ENABLE_INTELLIGENCE_SWITCH, 112 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableIntelligenceSwitch(data, reply); } }, 113 { (uint32_t)CellularDataInterfaceCode::INIT_CELLULAR_DATA_CONTROLLER, 114 [this](MessageParcel &data, MessageParcel &reply) { return OnInitCellularDataController(data, reply); } }, 115 { (uint32_t)CellularDataInterfaceCode::GET_INTELLIGENCE_SWITCH_STATE, 116 [this](MessageParcel &data, MessageParcel &reply) { return OnGetIntelligenceSwitchState(data, reply); } }, 117 { (uint32_t)CellularDataInterfaceCode::ESTABLISH_ALL_APNS_IF_CONNECTABLE, 118 [this](MessageParcel &data, MessageParcel &reply) { 119 return OnEstablishAllApnsIfConnectable(data, reply); } }, 120 { (uint32_t)CellularDataInterfaceCode::RELEASE_CELLULAR_DATA_CONNECTION, 121 [this](MessageParcel &data, MessageParcel &reply) { return OnReleaseCellularDataConnection(data, reply); }}, 122 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_SUPPLIERID, 123 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataSupplierId(data, reply); } }, 124 { (uint32_t)CellularDataInterfaceCode::CORRECT_NET_SUPPLIER_NO_AVAILABLE, 125 [this](MessageParcel &data, MessageParcel &reply) { 126 return OnCorrectNetSupplierNoAvailable(data, reply); } }, 127 { (uint32_t)CellularDataInterfaceCode::GET_SUPPLIER_REGISTER_STATE, 128 [this](MessageParcel &data, MessageParcel &reply) { return OnGetSupplierRegisterState(data, reply); } } 129 }; 130 std::map<uint32_t, std::string> collieCodeStringMap_ = { 131 { uint32_t(CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE), "GET_CELLULAR_DATA_STATE" }, 132 { uint32_t(CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED), "IS_CELLULAR_DATA_ENABLED" }, 133 { uint32_t(CellularDataInterfaceCode::ENABLE_CELLULAR_DATA), "ENABLE_CELLULAR_DATA" }, 134 { uint32_t(CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID), "GET_DEFAULT_SLOT_ID" }, 135 }; 136}; 137} // namespace Telephony 138} // namespace OHOS 139#endif // CELLULAR_DATA_SERVICE_STUB_H 140