• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022-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/**
17 * @file
18 * @kit NetworkKit
19 */
20
21import type { AsyncCallback, Callback } from './@ohos.base';
22import type connection from './@ohos.net.connection';
23
24/**
25 * Provides network sharing related interfaces.
26 * @namespace sharing
27 * @syscap SystemCapability.Communication.NetManager.NetSharing
28 * @since 9
29 */
30declare namespace sharing {
31  /**
32   * Get the handle of the data network.
33   * @typedef { connection.NetHandle }
34   * @syscap SystemCapability.Communication.NetManager.Core
35   * @since 9
36   */
37  type NetHandle = connection.NetHandle;
38
39  /**
40   * Checks whether this device allows for network sharing.
41   * @permission ohos.permission.CONNECTIVITY_INTERNAL
42   * @param { AsyncCallback<boolean> } callback - Returns {@code true} indicating network sharing is supported;
43   * returns {@code false} otherwise.
44   * @throws { BusinessError } 201 - Permission denied.
45   * @throws { BusinessError } 202 - Non-system applications use system APIs.
46   * @throws { BusinessError } 2200002 - Failed to connect to the service.
47   * @throws { BusinessError } 2200003 - System internal error.
48   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
49   * @syscap SystemCapability.Communication.NetManager.NetSharing
50   * @systemapi Hide this for inner system use.
51   * @since 9
52  */
53  function isSharingSupported(callback: AsyncCallback<boolean>): void;
54
55  /**
56   * Checks whether this device allows for network sharing.
57   * @permission ohos.permission.CONNECTIVITY_INTERNAL
58   * @returns { Promise<boolean> } The promise returned by the function.
59   * @throws { BusinessError } 201 - Permission denied.
60   * @throws { BusinessError } 202 - Non-system applications use system APIs.
61   * @throws { BusinessError } 2200002 - Failed to connect to the service.
62   * @throws { BusinessError } 2200003 - System internal error.
63   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
64   * @syscap SystemCapability.Communication.NetManager.NetSharing
65   * @systemapi Hide this for inner system use.
66   * @since 9
67   */
68  function isSharingSupported(): Promise<boolean>;
69
70  /**
71   * Return the global network sharing state.
72   * @permission ohos.permission.CONNECTIVITY_INTERNAL
73   * @param { AsyncCallback<boolean> } callback - Returns {@code true} indicating network sharing is running;
74   * returns {@code false} otherwise.
75   * @throws { BusinessError } 201 - Permission denied.
76   * @throws { BusinessError } 202 - Non-system applications use system APIs.
77   * @throws { BusinessError } 2200002 - Failed to connect to the service.
78   * @throws { BusinessError } 2200003 - System internal error.
79   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
80   * @syscap SystemCapability.Communication.NetManager.NetSharing
81   * @systemapi Hide this for inner system use.
82   * @since 9
83   */
84  function isSharing(callback: AsyncCallback<boolean>): void;
85
86  /**
87   * Return the global network sharing state.
88   * @permission ohos.permission.CONNECTIVITY_INTERNAL
89   * @returns { Promise<boolean> } The promise returned by the function.
90   * @throws { BusinessError } 201 - Permission denied.
91   * @throws { BusinessError } 202 - Non-system applications use system APIs.
92   * @throws { BusinessError } 2200002 - Failed to connect to the service.
93   * @throws { BusinessError } 2200003 - System internal error.
94   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
95   * @syscap SystemCapability.Communication.NetManager.NetSharing
96   * @systemapi Hide this for inner system use.
97   * @since 9
98   */
99  function isSharing(): Promise<boolean>;
100
101  /**
102   * Start network sharing for given type.
103   * @permission ohos.permission.CONNECTIVITY_INTERNAL
104   * @param { SharingIfaceType } type - Enumeration of shareable interface types.
105   * @param { AsyncCallback<void> } callback - the callback of startSharing.
106   * @throws { BusinessError } 201 - Permission denied.
107   * @throws { BusinessError } 202 - Non-system applications use system APIs.
108   * @throws { BusinessError } 401 - Parameter error.
109   * @throws { BusinessError } 2200001 - Invalid parameter value.
110   * @throws { BusinessError } 2200002 - Failed to connect to the service.
111   * @throws { BusinessError } 2200003 - System internal error.
112   * @throws { BusinessError } 2202004 - Try to share an unavailable iface.
113   * @throws { BusinessError } 2202005 - WiFi sharing failed.
114   * @throws { BusinessError } 2202006 - Bluetooth sharing failed.
115   * @throws { BusinessError } 2202009 - Failed to enable forwarding for network sharing.
116   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
117   * @syscap SystemCapability.Communication.NetManager.NetSharing
118   * @systemapi Hide this for inner system use.
119   * @since 9
120   */
121  function startSharing(type: SharingIfaceType, callback: AsyncCallback<void>): void;
122
123  /**
124   * Start network sharing for given type.
125   * @permission ohos.permission.CONNECTIVITY_INTERNAL
126   * @param { SharingIfaceType } type - Enumeration of shareable interface types.
127   * @returns { Promise<void> } The promise returned by the function.
128   * @throws { BusinessError } 201 - Permission denied.
129   * @throws { BusinessError } 202 - Non-system applications use system APIs.
130   * @throws { BusinessError } 401 - Parameter error.
131   * @throws { BusinessError } 2200001 - Invalid parameter value.
132   * @throws { BusinessError } 2200002 - Failed to connect to the service.
133   * @throws { BusinessError } 2200003 - System internal error.
134   * @throws { BusinessError } 2202004 - Try to share an unavailable iface.
135   * @throws { BusinessError } 2202005 - WiFi sharing failed.
136   * @throws { BusinessError } 2202006 - Bluetooth sharing failed.
137   * @throws { BusinessError } 2202009 - Failed to enable forwarding for network sharing.
138   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
139   * @syscap SystemCapability.Communication.NetManager.NetSharing
140   * @systemapi Hide this for inner system use.
141   * @since 9
142   */
143  function startSharing(type: SharingIfaceType): Promise<void>;
144
145  /**
146   * Stop network sharing for given type.
147   * @permission ohos.permission.CONNECTIVITY_INTERNAL
148   * @param { SharingIfaceType } type - Enumeration of shareable interface types.
149   * @param { AsyncCallback<void> } callback - the callback of startSharing.
150   * @throws { BusinessError } 201 - Permission denied.
151   * @throws { BusinessError } 202 - Non-system applications use system APIs.
152   * @throws { BusinessError } 401 - Parameter error.
153   * @throws { BusinessError } 2200001 - Invalid parameter value.
154   * @throws { BusinessError } 2200002 - Failed to connect to the service.
155   * @throws { BusinessError } 2200003 - System internal error.
156   * @throws { BusinessError } 2202004 - Try to share an unavailable iface.
157   * @throws { BusinessError } 2202005 - WiFi sharing failed.
158   * @throws { BusinessError } 2202006 - Bluetooth sharing failed.
159   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
160   * @syscap SystemCapability.Communication.NetManager.NetSharing
161   * @systemapi Hide this for inner system use.
162   * @since 9
163   */
164  function stopSharing(type: SharingIfaceType, callback: AsyncCallback<void>): void;
165
166  /**
167   * Stop network sharing for given type.
168   * @permission ohos.permission.CONNECTIVITY_INTERNAL
169   * @param { SharingIfaceType } type - Enumeration of shareable interface types.
170   * @returns { Promise<void> } The promise returned by the function.
171   * @throws { BusinessError } 201 - Permission denied.
172   * @throws { BusinessError } 202 - Non-system applications use system APIs.
173   * @throws { BusinessError } 401 - Parameter error.
174   * @throws { BusinessError } 2200001 - Invalid parameter value.
175   * @throws { BusinessError } 2200002 - Failed to connect to the service.
176   * @throws { BusinessError } 2200003 - System internal error.
177   * @throws { BusinessError } 2202004 - Try to share an unavailable iface.
178   * @throws { BusinessError } 2202005 - WiFi sharing failed.
179   * @throws { BusinessError } 2202006 - Bluetooth sharing failed.
180   * @throws { BusinessError } 2202011 - Cannot get network sharing configuration.
181   * @syscap SystemCapability.Communication.NetManager.NetSharing
182   * @systemapi Hide this for inner system use.
183   * @since 9
184   */
185  function stopSharing(type: SharingIfaceType): Promise<void>;
186
187  /**
188   * Obtains the number of downlink data bytes of the sharing network interfaces.
189   * @permission ohos.permission.CONNECTIVITY_INTERNAL
190   * @param { AsyncCallback<number> } callback - Returns the number of downlink data bytes of the sharing network interfaces.
191   * @throws { BusinessError } 201 - Permission denied.
192   * @throws { BusinessError } 202 - Non-system applications use system APIs.
193   * @throws { BusinessError } 401 - Parameter error.
194   * @throws { BusinessError } 2200002 - Failed to connect to the service.
195   * @throws { BusinessError } 2200003 - System internal error.
196   * @syscap SystemCapability.Communication.NetManager.NetSharing
197   * @systemapi Hide this for inner system use.
198   * @since 9
199   */
200  function getStatsRxBytes(callback: AsyncCallback<number>): void;
201
202  /**
203   * Obtains the number of downlink data bytes of the sharing network interfaces.
204   * @permission ohos.permission.CONNECTIVITY_INTERNAL
205   * @returns { Promise<number> } The promise returned by the function.
206   * @throws { BusinessError } 201 - Permission denied.
207   * @throws { BusinessError } 202 - Non-system applications use system APIs.
208   * @throws { BusinessError } 401 - Parameter error.
209   * @throws { BusinessError } 2200002 - Failed to connect to the service.
210   * @throws { BusinessError } 2200003 - System internal error.
211   * @syscap SystemCapability.Communication.NetManager.NetSharing
212   * @systemapi Hide this for inner system use.
213   * @since 9
214   */
215  function getStatsRxBytes(): Promise<number>;
216
217  /**
218   * Obtains the number of uplink data bytes of the sharing network interfaces.
219   * @permission ohos.permission.CONNECTIVITY_INTERNAL
220   * @param { AsyncCallback<number> } callback - Returns the number of uplink data bytes of the sharing network interfaces.
221   * @throws { BusinessError } 201 - Permission denied.
222   * @throws { BusinessError } 202 - Non-system applications use system APIs.
223   * @throws { BusinessError } 401 - Parameter error.
224   * @throws { BusinessError } 2200002 - Failed to connect to the service.
225   * @throws { BusinessError } 2200003 - System internal error.
226   * @syscap SystemCapability.Communication.NetManager.NetSharing
227   * @systemapi Hide this for inner system use.
228   * @since 9
229   */
230  function getStatsTxBytes(callback: AsyncCallback<number>): void;
231
232  /**
233   * Obtains the number of uplink data bytes of the sharing network interfaces.
234   * @permission ohos.permission.CONNECTIVITY_INTERNAL
235   * @returns { Promise<number> } The promise returned by the function.
236   * @throws { BusinessError } 201 - Permission denied.
237   * @throws { BusinessError } 202 - Non-system applications use system APIs.
238   * @throws { BusinessError } 401 - Parameter error.
239   * @throws { BusinessError } 2200002 - Failed to connect to the service.
240   * @throws { BusinessError } 2200003 - System internal error.
241   * @syscap SystemCapability.Communication.NetManager.NetSharing
242   * @systemapi Hide this for inner system use.
243   * @since 9
244   */
245  function getStatsTxBytes(): Promise<number>;
246
247  /**
248   * Obtains the number of total data bytes of the sharing network interfaces.
249   * @permission ohos.permission.CONNECTIVITY_INTERNAL
250   * @param { AsyncCallback<number> } callback - Returns the number of total data bytes of the sharing network interfaces.
251   * @throws { BusinessError } 201 - Permission denied.
252   * @throws { BusinessError } 202 - Non-system applications use system APIs.
253   * @throws { BusinessError } 401 - Parameter error.
254   * @throws { BusinessError } 2200002 - Failed to connect to the service.
255   * @throws { BusinessError } 2200003 - System internal error.
256   * @syscap SystemCapability.Communication.NetManager.NetSharing
257   * @systemapi Hide this for inner system use.
258   * @since 9
259   */
260  function getStatsTotalBytes(callback: AsyncCallback<number>): void;
261
262  /**
263   * Obtains the number of total data bytes of the sharing network interfaces.
264   * @permission ohos.permission.CONNECTIVITY_INTERNAL
265   * @returns { Promise<number> } The promise returned by the function.
266   * @throws { BusinessError } 201 - Permission denied.
267   * @throws { BusinessError } 202 - Non-system applications use system APIs.
268   * @throws { BusinessError } 401 - Parameter error.
269   * @throws { BusinessError } 2200002 - Failed to connect to the service.
270   * @throws { BusinessError } 2200003 - System internal error.
271   * @syscap SystemCapability.Communication.NetManager.NetSharing
272   * @systemapi Hide this for inner system use.
273   * @since 9
274   */
275  function getStatsTotalBytes(): Promise<number>;
276
277  /**
278   * Obtains the names of interfaces in each sharing state.
279   * @permission ohos.permission.CONNECTIVITY_INTERNAL
280   * @param { SharingIfaceState } state - Is the network sharing state.
281   * @param { AsyncCallback<Array<string>> } callback - Returns an array of interface names that meet this status.
282   * @throws { BusinessError } 201 - Permission denied.
283   * @throws { BusinessError } 202 - Non-system applications use system APIs.
284   * @throws { BusinessError } 401 - Parameter error.
285   * @throws { BusinessError } 2200001 - Invalid parameter value.
286   * @throws { BusinessError } 2200002 - Failed to connect to the service.
287   * @throws { BusinessError } 2200003 - System internal error.
288   * @syscap SystemCapability.Communication.NetManager.NetSharing
289   * @systemapi Hide this for inner system use.
290   * @since 9
291   */
292  function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback<Array<string>>): void;
293
294  /**
295   * Obtains the names of interfaces in each sharing state.
296   * @permission ohos.permission.CONNECTIVITY_INTERNAL
297   * @param { SharingIfaceState } state - Is the network sharing state.
298   * @returns { Promise<Array<string>> } The promise returned by the function.
299   * @throws { BusinessError } 201 - Permission denied.
300   * @throws { BusinessError } 202 - Non-system applications use system APIs.
301   * @throws { BusinessError } 401 - Parameter error.
302   * @throws { BusinessError } 2200001 - Invalid parameter value.
303   * @throws { BusinessError } 2200002 - Failed to connect to the service.
304   * @throws { BusinessError } 2200003 - System internal error.
305   * @syscap SystemCapability.Communication.NetManager.NetSharing
306   * @systemapi Hide this for inner system use.
307   * @since 9
308   */
309  function getSharingIfaces(state: SharingIfaceState): Promise<Array<string>>;
310
311  /**
312   * Obtains the network sharing state for given type.
313   * @permission ohos.permission.CONNECTIVITY_INTERNAL
314   * @param { SharingIfaceType } type - Is the enumeration of shareable interface types.
315   * @param { AsyncCallback<SharingIfaceState> } callback - the callback of getSharingState. {@code SharingIfaceState}.
316   * @throws { BusinessError } 201 - Permission denied.
317   * @throws { BusinessError } 202 - Non-system applications use system APIs.
318   * @throws { BusinessError } 401 - Parameter error.
319   * @throws { BusinessError } 2200001 - Invalid parameter value.
320   * @throws { BusinessError } 2200002 - Failed to connect to the service.
321   * @throws { BusinessError } 2200003 - System internal error.
322   * @syscap SystemCapability.Communication.NetManager.NetSharing
323   * @systemapi Hide this for inner system use.
324   * @since 9
325   */
326  function getSharingState(type: SharingIfaceType, callback: AsyncCallback<SharingIfaceState>): void;
327
328  /**
329   * Obtains the network sharing state for given type.
330   * @permission ohos.permission.CONNECTIVITY_INTERNAL
331   * @param { SharingIfaceType } type - Is the enumeration of shareable interface types.
332   * @returns { Promise<SharingIfaceState> } The promise returned by the function.
333   * @throws { BusinessError } 201 - Permission denied.
334   * @throws { BusinessError } 202 - Non-system applications use system APIs.
335   * @throws { BusinessError } 401 - Parameter error.
336   * @throws { BusinessError } 2200001 - Invalid parameter value.
337   * @throws { BusinessError } 2200002 - Failed to connect to the service.
338   * @throws { BusinessError } 2200003 - System internal error.
339   * @syscap SystemCapability.Communication.NetManager.NetSharing
340   * @systemapi Hide this for inner system use.
341   * @since 9
342   */
343  function getSharingState(type: SharingIfaceType): Promise<SharingIfaceState>;
344
345  /**
346   * Get a list regular expression that defines any interface that can support network sharing.
347   * @permission ohos.permission.CONNECTIVITY_INTERNAL
348   * @param { SharingIfaceType } type - Is the enumeration of shareable interface types.
349   * @param { AsyncCallback<Array<string>> } callback - the callback of getSharableRegexes.
350   * @throws { BusinessError } 201 - Permission denied.
351   * @throws { BusinessError } 202 - Non-system applications use system APIs.
352   * @throws { BusinessError } 401 - Parameter error.
353   * @throws { BusinessError } 2200001 - Invalid parameter value.
354   * @throws { BusinessError } 2200002 - Failed to connect to the service.
355   * @throws { BusinessError } 2200003 - System internal error.
356   * @syscap SystemCapability.Communication.NetManager.NetSharing
357   * @systemapi Hide this for inner system use.
358   * @since 9
359   */
360  function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback<Array<string>>): void;
361
362  /**
363   * Get a list regular expression that defines any interface that can support network sharing.
364   * @permission ohos.permission.CONNECTIVITY_INTERNAL
365   * @param { SharingIfaceType } type - Is the enumeration of shareable interface types.
366   * @returns { Promise<Array<string>> } The promise returned by the function.
367   * @throws { BusinessError } 201 - Permission denied.
368   * @throws { BusinessError } 202 - Non-system applications use system APIs.
369   * @throws { BusinessError } 401 - Parameter error.
370   * @throws { BusinessError } 2200001 - Invalid parameter value.
371   * @throws { BusinessError } 2200002 - Failed to connect to the service.
372   * @throws { BusinessError } 2200003 - System internal error.
373   * @syscap SystemCapability.Communication.NetManager.NetSharing
374   * @systemapi Hide this for inner system use.
375   * @since 9
376   */
377  function getSharableRegexes(type: SharingIfaceType): Promise<Array<string>>;
378
379  /**
380   * Register a callback for the global network sharing state change.
381   * @permission ohos.permission.CONNECTIVITY_INTERNAL
382   * @param { 'sharingStateChange' } type - Indicates Event name.
383   * @param { Callback<boolean> } callback - the callback function that returns the status.
384   * @throws { BusinessError } 201 - Permission denied.
385   * @throws { BusinessError } 202 - Non-system applications use system APIs.
386   * @throws { BusinessError } 401 - Parameter error.
387   * @syscap SystemCapability.Communication.NetManager.NetSharing
388   * @systemapi Hide this for inner system use.
389   * @since 9
390   */
391  function on(type: 'sharingStateChange', callback: Callback<boolean>): void;
392
393  /**
394   * Unregister a callback for the global network sharing state change.
395   * @permission ohos.permission.CONNECTIVITY_INTERNAL
396   * @param { 'sharingStateChange' } type Indicates Event name.
397   * @param { Callback<boolean> } callback - the callback function that returns the status.
398   * @throws { BusinessError } 201 - Permission denied.
399   * @throws { BusinessError } 202 - Non-system applications use system APIs.
400   * @throws { BusinessError } 401 - Parameter error.
401   * @syscap SystemCapability.Communication.NetManager.NetSharing
402   * @systemapi Hide this for inner system use.
403   * @since 9
404   */
405  function off(type: 'sharingStateChange', callback?: Callback<boolean>): void;
406
407  /**
408   * Register a callback for the interface network sharing state change.
409   * @permission ohos.permission.CONNECTIVITY_INTERNAL
410   * @param { 'interfaceSharingStateChange' } type - Indicates Event name.
411   * @param { Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }> } callback - the callback function that returns the message.
412   * @throws { BusinessError } 201 - Permission denied.
413   * @throws { BusinessError } 202 - Non-system applications use system APIs.
414   * @throws { BusinessError } 401 - Parameter error.
415   * @syscap SystemCapability.Communication.NetManager.NetSharing
416   * @systemapi Hide this for inner system use.
417   * @since 9
418   */
419  /**
420   * Register a callback for the interface network sharing state change.
421   * @permission ohos.permission.CONNECTIVITY_INTERNAL
422   * @param { 'interfaceSharingStateChange' } type - Indicates Event name.
423   * @param { Callback<InterfaceSharingStateInfo> } callback - the callback function that returns the message.
424   * @throws { BusinessError } 201 - Permission denied.
425   * @throws { BusinessError } 202 - Non-system applications use system APIs.
426   * @throws { BusinessError } 401 - Parameter error.
427   * @syscap SystemCapability.Communication.NetManager.NetSharing
428   * @systemapi Hide this for inner system use.
429   * @since 11
430   */
431  function on(type: 'interfaceSharingStateChange', callback: Callback<InterfaceSharingStateInfo>): void;
432
433  /**
434   * Unregister a callback for the interface network sharing state change.
435   * @permission ohos.permission.CONNECTIVITY_INTERNAL
436   * @param { 'interfaceSharingStateChange' } type - Indicates Event name.
437   * @param { Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }> } callback - the callback function that returns the message.
438   * @throws { BusinessError } 201 - Permission denied.
439   * @throws { BusinessError } 202 - Non-system applications use system APIs.
440   * @throws { BusinessError } 401 - Parameter error.
441   * @syscap SystemCapability.Communication.NetManager.NetSharing
442   * @systemapi Hide this for inner system use.
443   * @since 9
444   */
445  /**
446   * Unregister a callback for the interface network sharing state change.
447   * @permission ohos.permission.CONNECTIVITY_INTERNAL
448   * @param { 'interfaceSharingStateChange' } type - Indicates Event name.
449   * @param { Callback<InterfaceSharingStateInfo> } callback - the callback function that returns the message.
450   * @throws { BusinessError } 201 - Permission denied.
451   * @throws { BusinessError } 202 - Non-system applications use system APIs.
452   * @throws { BusinessError } 401 - Parameter error.
453   * @syscap SystemCapability.Communication.NetManager.NetSharing
454   * @systemapi Hide this for inner system use.
455   * @since 11
456   */
457  function off(type: 'interfaceSharingStateChange', callback?: Callback<InterfaceSharingStateInfo>): void;
458
459  /**
460   * Register a callback for the sharing upstream network change.
461   * @permission ohos.permission.CONNECTIVITY_INTERNAL
462   * @param { 'sharingUpstreamChange' } type - Indicates Event name.
463   * @param { Callback<NetHandle> } callback - the callback function that returns the network handle.
464   * @throws { BusinessError } 201 - Permission denied.
465   * @throws { BusinessError } 202 - Non-system applications use system APIs.
466   * @throws { BusinessError } 401 - Parameter error.
467   * @syscap SystemCapability.Communication.NetManager.NetSharing
468   * @systemapi Hide this for inner system use.
469   * @since 9
470   */
471  function on(type: 'sharingUpstreamChange', callback: Callback<NetHandle>): void;
472
473  /**
474   * Unregister a callback for the sharing upstream network change.
475   * @permission ohos.permission.CONNECTIVITY_INTERNAL
476   * @param { 'sharingUpstreamChange' } type - Indicates Event name.
477   * @param { Callback<NetHandle> } callback - the callback function that returns the network handle.
478   * @throws { BusinessError } 201 - Permission denied.
479   * @throws { BusinessError } 202 - Non-system applications use system APIs.
480   * @throws { BusinessError } 401 - Parameter error.
481   * @syscap SystemCapability.Communication.NetManager.NetSharing
482   * @systemapi Hide this for inner system use.
483   * @since 9
484   */
485  function off(type: 'sharingUpstreamChange', callback?: Callback<NetHandle>): void;
486
487  /**
488   * Enumerates the network sharing states of an NIC.
489   * @enum {number}
490   * @syscap SystemCapability.Communication.NetManager.NetSharing
491   * @systemapi Hide this for inner system use.
492   * @since 9
493   */
494  export enum SharingIfaceState {
495    /**
496     * Indicates the names of the NICs that are serving as network sharing.
497     * @syscap SystemCapability.Communication.NetManager.NetSharing
498     * @systemapi Hide this for inner system use.
499     * @since 9
500     */
501    SHARING_NIC_SERVING = 1,
502
503    /**
504     * Indicates the names of the NICs that can serve as network sharing.
505     * @syscap SystemCapability.Communication.NetManager.NetSharing
506     * @systemapi Hide this for inner system use.
507     * @since 9
508     */
509    SHARING_NIC_CAN_SERVER = 2,
510
511    /**
512     * Indicates the names of the NICs that serving error.
513     * @syscap SystemCapability.Communication.NetManager.NetSharing
514     * @systemapi Hide this for inner system use.
515     * @since 9
516     */
517    SHARING_NIC_ERROR = 3
518  }
519
520  /**
521   * The interface is used to notify listeners of changes in shared interface status.
522   * @interface InterfaceSharingStateInfo
523   * @syscap SystemCapability.Communication.NetManager.NetSharing
524   * @systemapi Hide this for inner system use.
525   * @since 11
526   */
527  export interface InterfaceSharingStateInfo {
528    /**
529     * Enumerates the network sharing types of an NIC.
530     * @type { SharingIfaceType }
531     * @syscap SystemCapability.Communication.NetManager.NetSharing
532     * @systemapi Hide this for inner system use.
533     * @since 11
534     */
535    type: SharingIfaceType;
536    /**
537     * The specified network interface name.
538     * @type { string }
539     * @syscap SystemCapability.Communication.NetManager.NetSharing
540     * @systemapi Hide this for inner system use.
541     * @since 11
542     */
543    iface: string;
544    /**
545     * Network card sharing status.
546     * @type { SharingIfaceState }
547     * @syscap SystemCapability.Communication.NetManager.NetSharing
548     * @systemapi Hide this for inner system use.
549     * @since 11
550     */
551    state: SharingIfaceState;
552  }
553
554  /**
555   * Enumerates the network sharing types of an NIC.
556   * @enum {number}
557   * @syscap SystemCapability.Communication.NetManager.NetSharing
558   * @systemapi Hide this for inner system use.
559   * @since 9
560   */
561  export enum SharingIfaceType {
562    /**
563     * Network sharing type for Wi-Fi.
564     * @syscap SystemCapability.Communication.NetManager.NetSharing
565     * @systemapi Hide this for inner system use.
566     * @since 9
567     */
568    SHARING_WIFI = 0,
569
570    /**
571     * Network sharing type for USB.
572     * @syscap SystemCapability.Communication.NetManager.NetSharing
573     * @systemapi Hide this for inner system use.
574     * @since 9
575     */
576    SHARING_USB = 1,
577
578    /**
579     * Network sharing type for BLUETOOTH.
580     * @syscap SystemCapability.Communication.NetManager.NetSharing
581     * @systemapi Hide this for inner system use.
582     * @since 9
583     */
584    SHARING_BLUETOOTH = 2
585  }
586}
587
588export default sharing;
589