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 SetTimer(uint32_t code); 61 void CancelTimer(int32_t id); 62 63 private: 64 using Fun = std::function<int32_t(MessageParcel &data, MessageParcel &reply)>; 65 std::map<uint32_t, Fun> eventIdFunMap_ { 66 { (uint32_t)CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED, 67 [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataEnabled(data, reply); } }, 68 { (uint32_t)CellularDataInterfaceCode::ENABLE_CELLULAR_DATA, 69 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularData(data, reply); } }, 70 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE, 71 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataState(data, reply); } }, 72 { (uint32_t)CellularDataInterfaceCode::IS_DATA_ROAMING_ENABLED, 73 [this](MessageParcel &data, MessageParcel &reply) { return OnIsCellularDataRoamingEnabled(data, reply); } }, 74 { (uint32_t)CellularDataInterfaceCode::ENABLE_DATA_ROAMING, 75 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableCellularDataRoaming(data, reply); } }, 76 { (uint32_t)CellularDataInterfaceCode::APN_DATA_CHANGED, 77 [this](MessageParcel &data, MessageParcel &reply) { return OnHandleApnChanged(data, reply); } }, 78 { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID, 79 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSlotId(data, reply); } }, 80 { (uint32_t)CellularDataInterfaceCode::GET_DEFAULT_SIM_ID, 81 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDefaultCellularDataSimId(data, reply); } }, 82 { (uint32_t)CellularDataInterfaceCode::SET_DEFAULT_SLOT_ID, 83 [this](MessageParcel &data, MessageParcel &reply) { return OnSetDefaultCellularDataSlotId(data, reply); } }, 84 { (uint32_t)CellularDataInterfaceCode::GET_FLOW_TYPE_ID, 85 [this](MessageParcel &data, MessageParcel &reply) { return OnGetCellularDataFlowType(data, reply); } }, 86 { (uint32_t)CellularDataInterfaceCode::HAS_CAPABILITY, 87 [this](MessageParcel &data, MessageParcel &reply) { return OnHasInternetCapability(data, reply); } }, 88 { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS, 89 [this](MessageParcel &data, MessageParcel &reply) { return OnClearCellularDataConnections(data, reply); } }, 90 { (uint32_t)CellularDataInterfaceCode::CLEAR_ALL_CONNECTIONS_USE_REASON, 91 [this](MessageParcel &data, MessageParcel &reply) { return OnClearAllConnections(data, reply); } }, 92 { (uint32_t)CellularDataInterfaceCode::REG_SIM_ACCOUNT_CALLBACK, 93 [this](MessageParcel &data, MessageParcel &reply) { return OnRegisterSimAccountCallback(data, reply); } }, 94 { (uint32_t)CellularDataInterfaceCode::UN_REG_SIM_ACCOUNT_CALLBACK, 95 [this](MessageParcel &data, MessageParcel &reply) { return OnUnregisterSimAccountCallback(data, reply); } }, 96 { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_APN_ATTR, 97 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnApnAttr(data, reply); } }, 98 { (uint32_t)CellularDataInterfaceCode::GET_DATA_CONN_IP_TYPE, 99 [this](MessageParcel &data, MessageParcel &reply) { return OnGetDataConnIpType(data, reply); } }, 100 { (uint32_t)CellularDataInterfaceCode::GET_CELLULAR_DATA_APN_STATE, 101 [this](MessageParcel &data, MessageParcel &reply) { return OnGetApnState(data, reply); } }, 102 { (uint32_t)CellularDataInterfaceCode::GET_RECOVERY_STATE, 103 [this](MessageParcel &data, MessageParcel &reply) { return OnGetRecoveryState(data, reply); } }, 104 { (uint32_t)CellularDataInterfaceCode::IS_NEED_DO_RECOVERY, 105 [this](MessageParcel &data, MessageParcel &reply) { return OnIsNeedDoRecovery(data, reply); } }, 106 { (uint32_t)CellularDataInterfaceCode::ENABLE_INTELLIGENCE_SWITCH, 107 [this](MessageParcel &data, MessageParcel &reply) { return OnEnableIntelligenceSwitch(data, reply); } }, 108 { (uint32_t)CellularDataInterfaceCode::INIT_CELLULAR_DATA_CONTROLLER, 109 [this](MessageParcel &data, MessageParcel &reply) { return OnInitCellularDataController(data, reply); } }, 110 { (uint32_t)CellularDataInterfaceCode::GET_INTELLIGENCE_SWITCH_STATE, 111 [this](MessageParcel &data, MessageParcel &reply) { return OnGetIntelligenceSwitchState(data, reply); } }, 112 }; 113 std::map<uint32_t, std::string> collieCodeStringMap_ = { 114 { uint32_t(CellularDataInterfaceCode::GET_CELLULAR_DATA_STATE), "GET_CELLULAR_DATA_STATE" }, 115 { uint32_t(CellularDataInterfaceCode::IS_CELLULAR_DATA_ENABLED), "IS_CELLULAR_DATA_ENABLED" }, 116 { uint32_t(CellularDataInterfaceCode::ENABLE_CELLULAR_DATA), "ENABLE_CELLULAR_DATA" }, 117 { uint32_t(CellularDataInterfaceCode::GET_DEFAULT_SLOT_ID), "GET_DEFAULT_SLOT_ID" }, 118 }; 119 }; 120 } // namespace Telephony 121 } // namespace OHOS 122 #endif // CELLULAR_DATA_SERVICE_STUB_H 123