• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PROXY_H
17 #define CELLULAR_DATA_SERVICE_PROXY_H
18 
19 #include <cstdint>
20 
21 #include "cellular_data_ipc_interface_code.h"
22 #include "functional"
23 #include "i_cellular_data_manager.h"
24 #include "iremote_broker.h"
25 #include "iremote_proxy.h"
26 #include "refbase.h"
27 
28 namespace OHOS {
29 class IRemoteObject;
30 namespace Telephony {
31 class CellularDataServiceProxy : public IRemoteProxy<ICellularDataManager> {
32 public:
CellularDataServiceProxy(const sptr<IRemoteObject> & impl)33     explicit CellularDataServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<ICellularDataManager>(impl)
34     {}
35     ~CellularDataServiceProxy() = default;
36 
37     /**
38      * Whether the cellular data user switch is enabled
39      *
40      * @return return errorCode of is cellulardata enabled
41      */
42     virtual int32_t IsCellularDataEnabled(bool &dataEnabled);
43 
44     /**
45      * Whether to enable cellular data user switch
46      *
47      * @param enable allow or not
48      * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail
49      */
50     int32_t EnableCellularData(bool enable);
51 
52     /**
53      * Cellular data connection status
54      *
55      * @return 84082688 Indicates that a cellular data link is unknown
56      *         11 Indicates that a cellular data link is disconnected
57      *         12 Indicates that a cellular data link is being connected
58      *         13 Indicates that a cellular data link is connected
59      *         14 Indicates that a cellular data link is suspended
60      */
61     int32_t GetCellularDataState();
62 
63     /**
64      * Whether roaming is allowed
65      *
66      * @param slotId card slot identification
67      * @return return 84082688 invalid parameter, 0 roaming is not allowed, 1 roaming is allowed
68      */
69     int32_t IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled);
70 
71     /**
72      * Whether roaming switches are allowed
73      *
74      * @param slotId card slot identification
75      * @param enable Whether roaming switches are allowed
76      * @return Returns 0 on failure, 1 on failure. 84082688 invalid parameter
77      */
78     int32_t EnableCellularDataRoaming(int32_t slotId, bool enable);
79 
80     /**
81      * Processing of APN content changes
82      *
83      * @param slotId card slot identification
84      * @return the number of apns created else 84082688 invalid parameter
85      */
86     int32_t HandleApnChanged(int32_t slotId);
87 
88     /**
89      * Get the slotId that uses the data traffic by default
90      *
91      * @return default settings data card, -1 error code
92      */
93     int32_t GetDefaultCellularDataSlotId();
94 
95     /**
96      * Get the sim id that uses the data traffic by default
97      *
98      * @param simId Returns default settings data sim id
99      * @return Returns 0 on success, others on failure.
100      */
101     int32_t GetDefaultCellularDataSimId(int32_t &simId);
102 
103     /**
104       * set the slotId that uses the data traffic by default
105       *
106       * @param slotId card slot identification
107       * @return 1 set success, 0 set fail, 84082688 invalid parameter
108       */
109     int32_t SetDefaultCellularDataSlotId(int32_t slotId);
110 
111     /**
112      * get data packet type
113      *
114      * @return 0 Indicates that there is no uplink or down link data,
115      *         1 Indicates that there is only down link data,
116      *         2 Indicates that there is only uplink data,
117      *         3 Indicates that there is uplink and down link data
118      *         4 Indicates that there is no uplink or down link data,
119      *           and the bottom-layer link is in the dormant state
120      *         84082688 Indicates invalid parameter
121      */
122     int32_t GetCellularDataFlowType();
123 
124     int32_t HasInternetCapability(int32_t slotId, int32_t cid);
125 
126     int32_t ClearCellularDataConnections(int32_t slotId);
127 
128     int32_t RegisterSimAccountCallback(const sptr<SimAccountCallback> &callback);
129 
130     int32_t UnregisterSimAccountCallback();
131 
132 private:
133     static inline BrokerDelegator<CellularDataServiceProxy> delegator_;
134 };
135 } // namespace Telephony
136 } // namespace OHOS
137 #endif // CELLULAR_DATA_SERVICE_PROXY_H
138