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