• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
35 private:
36     int32_t OnIsCellularDataEnabled(MessageParcel &data, MessageParcel &reply);
37     int32_t OnEnableCellularData(MessageParcel &data, MessageParcel &reply);
38     int32_t OnGetCellularDataState(MessageParcel &data, MessageParcel &reply);
39     int32_t OnIsCellularDataRoamingEnabled(MessageParcel &data, MessageParcel &reply);
40     int32_t OnEnableCellularDataRoaming(MessageParcel &data, MessageParcel &reply);
41     int32_t OnHandleApnChanged(MessageParcel &data, MessageParcel &reply);
42     int32_t OnGetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply);
43     int32_t OnSetDefaultCellularDataSlotId(MessageParcel &data, MessageParcel &reply);
44     int32_t OnGetCellularDataFlowType(MessageParcel &data, MessageParcel &reply);
45     int32_t OnHasInternetCapability(MessageParcel &data, MessageParcel &reply);
46     int32_t OnClearCellularDataConnections(MessageParcel &data, MessageParcel &reply);
47 
48 private:
49     using Fun = int32_t (CellularDataServiceStub::*)(MessageParcel &data, MessageParcel &reply);
50     std::map<uint32_t, Fun> eventIdFunMap_ {
51         {(uint32_t)ICellularDataManager::FuncCode::IS_CELLULAR_DATA_ENABLED,
52              &CellularDataServiceStub::OnIsCellularDataEnabled},
53         {(uint32_t)ICellularDataManager::FuncCode::ENABLE_CELLULAR_DATA,
54              &CellularDataServiceStub::OnEnableCellularData},
55         {(uint32_t)ICellularDataManager::FuncCode::GET_CELLULAR_DATA_STATE,
56              &CellularDataServiceStub::OnGetCellularDataState},
57         {(uint32_t)ICellularDataManager::FuncCode::IS_DATA_ROAMING_ENABLED,
58              &CellularDataServiceStub::OnIsCellularDataRoamingEnabled},
59         {(uint32_t)ICellularDataManager::FuncCode::ENABLE_DATA_ROAMING,
60              &CellularDataServiceStub::OnEnableCellularDataRoaming},
61         {(uint32_t)ICellularDataManager::FuncCode::APN_DATA_CHANGED,
62              &CellularDataServiceStub::OnHandleApnChanged},
63         {(uint32_t)ICellularDataManager::FuncCode::GET_DEFAULT_SLOT_ID,
64              &CellularDataServiceStub::OnGetDefaultCellularDataSlotId},
65         {(uint32_t)ICellularDataManager::FuncCode::SET_DEFAULT_SLOT_ID,
66              &CellularDataServiceStub::OnSetDefaultCellularDataSlotId},
67         {(uint32_t)ICellularDataManager::FuncCode::GET_FLOW_TYPE_ID,
68              &CellularDataServiceStub::OnGetCellularDataFlowType},
69         {(uint32_t)ICellularDataManager::FuncCode::HAS_CAPABILITY,
70              &CellularDataServiceStub::OnHasInternetCapability},
71         {(uint32_t)ICellularDataManager::FuncCode::CLEAR_ALL_CONNECTIONS,
72              &CellularDataServiceStub::OnClearCellularDataConnections}
73     };
74 };
75 } // namespace Telephony
76 } // namespace OHOS
77 #endif // CELLULAR_DATA_SERVICE_STUB_H
78