• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021-2022 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
16import {AsyncCallback} from "./basic";
17
18/**
19 * Provides methods related to cellular data services.
20 *
21 * @since 7
22 * @syscap SystemCapability.Telephony.CellularData
23 */
24declare namespace data {
25  /**
26   * Checks whether cellular data services are enabled.
27   *
28   * <p>Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}.
29   *
30   * @return Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise.
31   * @permission ohos.permission.GET_NETWORK_INFO
32   */
33  function getDefaultCellularDataSlotId(callback: AsyncCallback<number>): void;
34  function getDefaultCellularDataSlotId(): Promise<number>;
35
36  /**
37   * Switches cellular data services to another card, without changing the default settings.
38   *
39   * @param slotId Indicates the ID of the target card slot.
40   *      The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
41   * @permission ohos.permission.SET_TELEPHONY_STATE
42   * @systemapi Hide this for inner system use.
43   */
44  function setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback<void>): void;
45  function setDefaultCellularDataSlotId(slotId: number): Promise<void>;
46
47  /**
48   * Indicates that there is no uplink or downlink data.
49   *
50   * <p>It is a return value of service state query of cellular data services.
51   */
52  function getCellularDataFlowType(callback: AsyncCallback<DataFlowType>): void;
53  function getCellularDataFlowType(): Promise<DataFlowType>;
54
55  /**
56   * Obtains the connection state of the PS domain.
57   *
58   * @param slotId Indicates the ID of a card slot.
59   *      The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
60   * @param callback Returns the connection state, which can be any of the following:
61   * <ul>
62   * <li>{@code DataConnectState#DATA_STATE_UNKNOWN}
63   * <li>{@code DataConnectState#DATA_STATE_DISCONNECTED}
64   * <li>{@code DataConnectState#DATA_STATE_CONNECTING}
65   * <li>{@code DataConnectState#DATA_STATE_CONNECTED}
66   * <li>{@code DataConnectState#DATA_STATE_SUSPENDED}
67   * </ul>
68   */
69  function getCellularDataState(callback: AsyncCallback<DataConnectState>): void;
70  function getCellularDataState(): Promise<DataConnectState>;
71
72  /**
73   * Checks whether cellular data services are enabled.
74   *
75   * <p>Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}.
76   *
77   * @param callback Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise.
78   */
79  function isCellularDataEnabled(callback: AsyncCallback<boolean>): void;
80  function isCellularDataEnabled(): Promise<boolean>;
81
82  /**
83   * Enables cellular data services.
84   *
85   * @permission ohos.permission.SET_TELEPHONY_STATE
86   * @systemapi Hide this for inner system use.
87   */
88  function enableCellularData(callback: AsyncCallback<void>): void;
89  function enableCellularData(): Promise<void>;
90
91  /**
92   * Diables cellular data services.
93   *
94   * @permission ohos.permission.SET_TELEPHONY_STATE
95   * @systemapi Hide this for inner system use.
96   */
97  function disableCellularData(callback: AsyncCallback<void>): void;
98  function disableCellularData(): Promise<void>;
99
100  /**
101   * Checks whether roaming is enabled for cellular data services.
102   *
103   * <p>Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}.
104   *
105   * @param slotId Indicates the ID of a card slot.
106   *      The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
107   * @param callback Returns {@code true} if roaming is enabled for cellular data services; returns {@code false} otherwise.
108   * @permission ohos.permission.GET_NETWORK_INFO
109   */
110  function isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback<boolean>): void;
111  function isCellularDataRoamingEnabled(slotId: number): Promise<boolean>;
112
113  /**
114   * Enables cellular data roaming.
115   *
116   * @param slotId Indicates the ID of a card slot.
117   *      The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
118   * @permission ohos.permission.SET_TELEPHONY_STATE
119   * @systemapi Hide this for inner system use.
120   */
121  function enableCellularDataRoaming(slotId: number, callback: AsyncCallback<void>): void;
122  function enableCellularDataRoaming(slotId: number): Promise<void>;
123
124  /**
125   * Disables cellular data roaming.
126   *
127   * @param slotId Indicates the ID of a card slot.
128   *      The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
129   * @permission ohos.permission.SET_TELEPHONY_STATE
130   * @systemapi Hide this for inner system use.
131   */
132  function disableCellularDataRoaming(slotId: number, callback: AsyncCallback<void>): void;
133  function disableCellularDataRoaming(slotId: number): Promise<void>;
134
135  /**
136   * Describes the cellular data flow type.
137   */
138  export enum DataFlowType {
139    /**
140     * Indicates that there is no uplink or downlink data.
141     */
142    DATA_FLOW_TYPE_NONE = 0,
143
144    /**
145     * Indicates that there is only downlink data.
146     */
147    DATA_FLOW_TYPE_DOWN = 1,
148
149    /**
150     * Indicates that there is only uplink data.
151     */
152    DATA_FLOW_TYPE_UP = 2,
153
154    /**
155     * Indicates that there is uplink and downlink data.
156     */
157    DATA_FLOW_TYPE_UP_DOWN = 3,
158
159    /**
160     * Indicates that there is no uplink or downlink data, and the bottom-layer link is in the dormant state.
161     */
162    DATA_FLOW_TYPE_DORMANT = 4
163  }
164
165  /**
166   * Describes the cellular data link connection state.
167   */
168  export enum DataConnectState {
169    /**
170     * Indicates that a cellular data link is unknown.
171     */
172    DATA_STATE_UNKNOWN = -1,
173
174    /**
175     * Indicates that a cellular data link is disconnected.
176     */
177    DATA_STATE_DISCONNECTED = 0,
178
179    /**
180     * Indicates that a cellular data link is being connected.
181     */
182    DATA_STATE_CONNECTING = 1,
183
184    /**
185     * Indicates that a cellular data link is connected.
186     */
187    DATA_STATE_CONNECTED = 2,
188
189    /**
190     * Indicates that a cellular data link is suspended.
191     */
192    DATA_STATE_SUSPENDED = 3
193  }
194}
195
196export default data;