1 /* 2 * Copyright (C) 2021 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 "i_cellular_data_manager.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 class CellularDataServiceStub : public IRemoteStub<ICellularDataManager> { 29 public: 30 CellularDataServiceStub(); 31 ~CellularDataServiceStub(); 32 int32_t OnRemoteRequest( 33 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 34 int32_t OnRegisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); 35 int32_t OnUnregisterSimAccountCallback(MessageParcel &data, MessageParcel &reply); 36 37 private: 38 int32_t OnIsCellularDataEnabled(MessageParcel &data, MessageParcel &reply); 39 int32_t OnEnableCellularData(MessageParcel &data, MessageParcel &reply); 40 int32_t OnGetCellularDataState(MessageParcel &data, MessageParcel &reply); 41 int32_t OnIsCellularDataRoamingEnabled(MessageParcel &data, MessageParcel &reply); 42 int32_t OnEnableCellularDataRoaming(MessageParcel &data, MessageParcel &reply); 43 int32_t OnHandleApnChanged(MessageParcel &data, MessageParcel &reply); 44 int32_t OnGetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); 45 int32_t OnSetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply); 46 int32_t OnGetCellularDataFlowType(MessageParcel &data, MessageParcel &reply); 47 int32_t OnHasInternetCapability(MessageParcel &data, MessageParcel &reply); 48 int32_t OnClearCellularDataConnections(MessageParcel &data, MessageParcel &reply); 49 50 private: 51 using Fun = int32_t (CellularDataServiceStub::*)(MessageParcel &data, MessageParcel &reply); 52 std::map<uint32_t, Fun> eventIdFunMap_ { 53 { (uint32_t)ICellularDataManager::FuncCode::IS_CELLULAR_DATA_ENABLED, 54 &CellularDataServiceStub::OnIsCellularDataEnabled }, 55 { (uint32_t)ICellularDataManager::FuncCode::ENABLE_CELLULAR_DATA, 56 &CellularDataServiceStub::OnEnableCellularData }, 57 { (uint32_t)ICellularDataManager::FuncCode::GET_CELLULAR_DATA_STATE, 58 &CellularDataServiceStub::OnGetCellularDataState }, 59 { (uint32_t)ICellularDataManager::FuncCode::IS_DATA_ROAMING_ENABLED, 60 &CellularDataServiceStub::OnIsCellularDataRoamingEnabled }, 61 { (uint32_t)ICellularDataManager::FuncCode::ENABLE_DATA_ROAMING, 62 &CellularDataServiceStub::OnEnableCellularDataRoaming }, 63 { (uint32_t)ICellularDataManager::FuncCode::APN_DATA_CHANGED, &CellularDataServiceStub::OnHandleApnChanged }, 64 { (uint32_t)ICellularDataManager::FuncCode::GET_DEFAULT_SLOT_ID, 65 &CellularDataServiceStub::OnGetDefaultCellularDataSlotId }, 66 { (uint32_t)ICellularDataManager::FuncCode::SET_DEFAULT_SLOT_ID, 67 &CellularDataServiceStub::OnSetDefaultCellularDataSlotId }, 68 { (uint32_t)ICellularDataManager::FuncCode::GET_FLOW_TYPE_ID, 69 &CellularDataServiceStub::OnGetCellularDataFlowType }, 70 { (uint32_t)ICellularDataManager::FuncCode::HAS_CAPABILITY, &CellularDataServiceStub::OnHasInternetCapability }, 71 { (uint32_t)ICellularDataManager::FuncCode::CLEAR_ALL_CONNECTIONS, 72 &CellularDataServiceStub::OnClearCellularDataConnections }, 73 { (uint32_t)ICellularDataManager::FuncCode::REG_SIM_ACCOUNT_CALLBACK, 74 &CellularDataServiceStub::OnRegisterSimAccountCallback }, 75 { (uint32_t)ICellularDataManager::FuncCode::UN_REG_SIM_ACCOUNT_CALLBACK, 76 &CellularDataServiceStub::OnUnregisterSimAccountCallback }, 77 }; 78 }; 79 } // namespace Telephony 80 } // namespace OHOS 81 #endif // CELLULAR_DATA_SERVICE_STUB_H 82