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 I_CELLULAR_DATA_MANAGER_H
17#define I_CELLULAR_DATA_MANAGER_H
18
19#include "iremote_broker.h"
20#include "sim_account_callback.h"
21#include "apn_item.h"
22#include "cellular_data_constant.h"
23
24namespace OHOS {
25namespace Telephony {
26class ICellularDataManager : public IRemoteBroker {
27public:
28    /**
29     * Whether the cellular data user switch is enabled
30     *
31     * @return return errorCode of is cellulardata enabled
32     */
33    virtual int32_t IsCellularDataEnabled(bool &dataEnabled) = 0;
34
35    /**
36     * Whether to enable cellular data user switch
37     *
38     * @param enable allow or not
39     * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail
40     */
41    virtual int32_t EnableCellularData(bool enable) = 0;
42
43    /**
44     * Whether to enable intelligence switch
45     *
46     * @param enable allow or not
47     * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail
48     */
49    virtual int32_t EnableIntelligenceSwitch(bool enable) = 0;
50
51    /**
52     * Cellular data connection status
53     *
54     * @return 84082688 Indicates that a cellular data link is unknown
55     *         11 Indicates that a cellular data link is disconnected
56     *         12 Indicates that a cellular data link is being connected
57     *         13 Indicates that a cellular data link is connected
58     *         14 Indicates that a cellular data link is suspended
59     */
60    virtual int32_t GetCellularDataState() = 0;
61
62    /**
63     * Whether roaming is allowed
64     *
65     * @param slotId card slot identification
66     * @param dataRoamingEnabled result of data is enabled
67     * @return return errorCode of is cellulardata enabled
68     */
69    virtual int32_t IsCellularDataRoamingEnabled(int32_t slotId, bool &dataRoamingEnabled) = 0;
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    virtual int32_t EnableCellularDataRoaming(int32_t slotId, bool enable) = 0;
79
80    /**
81     * Processing of APN content changes
82     *
83     * @param slotId card slot identification
84     * @param apns changed apns
85     * @return the number of apns created else 84082688 invalid parameter
86     */
87    virtual int32_t HandleApnChanged(int32_t slotId) = 0;
88
89    /**
90     * Get the slotId that uses the data traffic by default
91     *
92     * @return default settings data card, -1 error code
93     */
94    virtual int32_t GetDefaultCellularDataSlotId() = 0;
95
96    /**
97     * Get the simId that uses the data traffic by default
98     *
99     * @param simId Returns default settings data sim id
100     * @return Returns 0 on success, others on failure.
101     */
102    virtual int32_t GetDefaultCellularDataSimId(int32_t &simId) = 0;
103
104    /**
105     * set the slotId that uses the data traffic by default
106     *
107     * @return 1 set success, 0 set fail, 84082688 invalid parameter
108     */
109    virtual int32_t SetDefaultCellularDataSlotId(int32_t slotId) = 0;
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    virtual int32_t GetCellularDataFlowType() = 0;
123
124    /**
125     * get intelligence switch state
126     *
127     * @param state the state of intelligence switch
128     * @return return 84082688 invalid parameter, 1 data enable success, 0 enable fail
129     */
130    virtual int32_t GetIntelligenceSwitchState(bool &state) = 0;
131
132    virtual int32_t HasInternetCapability(int32_t slotId, int32_t cid) = 0;
133
134    virtual int32_t ClearCellularDataConnections(int32_t slotId) = 0;
135
136    virtual int32_t ClearAllConnections(int32_t slotId, DisConnectionReason reason) = 0;
137
138    virtual int32_t RegisterSimAccountCallback(const sptr<SimAccountCallback> callback) = 0;
139
140    virtual int32_t UnregisterSimAccountCallback() = 0;
141
142    virtual int32_t GetDataConnApnAttr(int32_t slotId, ApnItem::Attribute &apnAttr) = 0;
143
144    virtual int32_t GetDataConnIpType(int32_t slotId, std::string &ipType) = 0;
145
146    virtual int32_t GetApnState(int32_t slotId, const std::string &apnType) = 0;
147
148    virtual int32_t GetDataRecoveryState() = 0;
149
150    virtual int32_t IsNeedDoRecovery(int32_t slotId, bool needDoRecovery) = 0;
151
152    virtual int32_t InitCellularDataController(int32_t slotId) = 0;
153
154    virtual int32_t EstablishAllApnsIfConnectable(int32_t slotId) = 0;
155
156    virtual int32_t ReleaseCellularDataConnection(int32_t slotId) = 0;
157
158    virtual int32_t GetCellularDataSupplierId(int32_t slotId, uint64_t capability, uint32_t &supplierId) = 0;
159
160    virtual int32_t CorrectNetSupplierNoAvailable(int32_t slotId) = 0;
161
162    virtual int32_t GetSupplierRegisterState(uint32_t supplierId, int32_t &regState) = 0;
163
164public:
165    DECLARE_INTERFACE_DESCRIPTOR(u"ohos.telephony.ICellularDataManager");
166};
167} // namespace Telephony
168} // namespace OHOS
169#endif // I_CELLULAR_DATA_MANAGER_H
170