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 #include "cellular_data_constant.h"
28 
29 namespace OHOS {
30 class IRemoteObject;
31 namespace Telephony {
32 class CellularDataServiceProxy : public IRemoteProxy<ICellularDataManager> {
33 public:
CellularDataServiceProxy(const sptr<IRemoteObject> & impl)34     explicit CellularDataServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<ICellularDataManager>(impl)
35     {}
36     ~CellularDataServiceProxy() = default;
37 
38     /**
39      * Whether the cellular data user switch is enabled
40      *
41      * @return return errorCode of is cellulardata enabled
42      */
43     virtual int32_t IsCellularDataEnabled(bool &dataEnabled);
44 
45     /**
46      * Whether to enable intelligence switch
47      *
48      * @param enable allow or not
49      * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail
50      */
51     int32_t EnableIntelligenceSwitch(bool enable);
52 
53     /**
54      * Whether to enable cellular data user switch
55      *
56      * @param enable allow or not
57      * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail
58      */
59     int32_t EnableCellularData(bool enable);
60 
61     /**
62      * Cellular data connection status
63      *
64      * @return 84082688 Indicates that a cellular data link is unknown
65      *         11 Indicates that a cellular data link is disconnected
66      *         12 Indicates that a cellular data link is being connected
67      *         13 Indicates that a cellular data link is connected
68      *         14 Indicates that a cellular data link is suspended
69      */
70     int32_t GetCellularDataState();
71 
72     /**
73      * Get the apn status based on slotId and apnType
74      *
75      * @param slotId card slot identification
76      * @param apnType apn type, eg."default"
77      * @return apnstate
78      */
79     int32_t GetApnState(int32_t slotId, const std::string &apnType);
80 
81     int32_t GetDataRecoveryState();
82 
83     /**
84      * Whether roaming is allowed
85      *
86      * @param slotId card slot identification
87      * @return return 84082688 invalid parameter, 0 roaming is not allowed, 1 roaming is allowed
88      */
89     int32_t IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled);
90 
91     /**
92      * Whether roaming switches are allowed
93      *
94      * @param slotId card slot identification
95      * @param enable Whether roaming switches are allowed
96      * @return Returns 0 on failure, 1 on failure. 84082688 invalid parameter
97      */
98     int32_t EnableCellularDataRoaming(int32_t slotId, bool enable);
99 
100     /**
101      * Processing of APN content changes
102      *
103      * @param slotId card slot identification
104      * @return the number of apns created else 84082688 invalid parameter
105      */
106     int32_t HandleApnChanged(int32_t slotId);
107 
108     /**
109      * Get the slotId that uses the data traffic by default
110      *
111      * @return default settings data card, -1 error code
112      */
113     int32_t GetDefaultCellularDataSlotId();
114 
115     /**
116      * Get the sim id that uses the data traffic by default
117      *
118      * @param simId Returns default settings data sim id
119      * @return Returns 0 on success, others on failure.
120      */
121     int32_t GetDefaultCellularDataSimId(int32_t &simId);
122 
123     /**
124       * set the slotId that uses the data traffic by default
125       *
126       * @param slotId card slot identification
127       * @return 1 set success, 0 set fail, 84082688 invalid parameter
128       */
129     int32_t SetDefaultCellularDataSlotId(int32_t slotId);
130 
131     /**
132      * get data packet type
133      *
134      * @return 0 Indicates that there is no uplink or down link data,
135      *         1 Indicates that there is only down link data,
136      *         2 Indicates that there is only uplink data,
137      *         3 Indicates that there is uplink and down link data
138      *         4 Indicates that there is no uplink or down link data,
139      *           and the bottom-layer link is in the dormant state
140      *         84082688 Indicates invalid parameter
141      */
142     int32_t GetCellularDataFlowType();
143 
144     /**
145      * Get the State Of Intelligence Switch
146      *
147      * @param switchState Returns switch state
148      * @return Returns 0 on success, others on failure.
149      */
150     int32_t GetIntelligenceSwitchState(bool &switchState);
151 
152     int32_t HasInternetCapability(int32_t slotId, int32_t cid);
153 
154     int32_t ClearCellularDataConnections(int32_t slotId);
155 
156     int32_t ClearAllConnections(int32_t slotId, DisConnectionReason reason);
157 
158     int32_t RegisterSimAccountCallback(const sptr<SimAccountCallback> callback);
159 
160     int32_t UnregisterSimAccountCallback();
161 
162     int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr);
163 
164     int32_t GetDataConnIpType(int32_t slotId, std::string &ipType);
165 
166     int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery);
167 
168     int32_t InitCellularDataController(int32_t slotId);
169 
170 private:
171     static inline BrokerDelegator<CellularDataServiceProxy> delegator_;
172 };
173 } // namespace Telephony
174 } // namespace OHOS
175 #endif // CELLULAR_DATA_SERVICE_PROXY_H
176