161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2022-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit NetworkKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback } from './@ohos.base'; 2261847f8eSopenharmony_ciimport type connection from './@ohos.net.connection'; 2361847f8eSopenharmony_ci 2461847f8eSopenharmony_ci/** 2561847f8eSopenharmony_ci * Provides network sharing related interfaces. 2661847f8eSopenharmony_ci * @namespace sharing 2761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2861847f8eSopenharmony_ci * @since 9 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_cideclare namespace sharing { 3161847f8eSopenharmony_ci /** 3261847f8eSopenharmony_ci * Get the handle of the data network. 3361847f8eSopenharmony_ci * @typedef { connection.NetHandle } 3461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 3561847f8eSopenharmony_ci * @since 9 3661847f8eSopenharmony_ci */ 3761847f8eSopenharmony_ci type NetHandle = connection.NetHandle; 3861847f8eSopenharmony_ci 3961847f8eSopenharmony_ci /** 4061847f8eSopenharmony_ci * Checks whether this device allows for network sharing. 4161847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 4261847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Returns {@code true} indicating network sharing is supported; 4361847f8eSopenharmony_ci * returns {@code false} otherwise. 4461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 4561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 4661847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 4761847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 4861847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 4961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 5061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 5161847f8eSopenharmony_ci * @since 9 5261847f8eSopenharmony_ci */ 5361847f8eSopenharmony_ci function isSharingSupported(callback: AsyncCallback<boolean>): void; 5461847f8eSopenharmony_ci 5561847f8eSopenharmony_ci /** 5661847f8eSopenharmony_ci * Checks whether this device allows for network sharing. 5761847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 5861847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 5961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 6061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 6161847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 6261847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 6361847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 6461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 6561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 6661847f8eSopenharmony_ci * @since 9 6761847f8eSopenharmony_ci */ 6861847f8eSopenharmony_ci function isSharingSupported(): Promise<boolean>; 6961847f8eSopenharmony_ci 7061847f8eSopenharmony_ci /** 7161847f8eSopenharmony_ci * Return the global network sharing state. 7261847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 7361847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Returns {@code true} indicating network sharing is running; 7461847f8eSopenharmony_ci * returns {@code false} otherwise. 7561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 7661847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 7761847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 7861847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 7961847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 8061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 8161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 8261847f8eSopenharmony_ci * @since 9 8361847f8eSopenharmony_ci */ 8461847f8eSopenharmony_ci function isSharing(callback: AsyncCallback<boolean>): void; 8561847f8eSopenharmony_ci 8661847f8eSopenharmony_ci /** 8761847f8eSopenharmony_ci * Return the global network sharing state. 8861847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 8961847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 9061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 9161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 9261847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 9361847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 9461847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 9561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 9661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 9761847f8eSopenharmony_ci * @since 9 9861847f8eSopenharmony_ci */ 9961847f8eSopenharmony_ci function isSharing(): Promise<boolean>; 10061847f8eSopenharmony_ci 10161847f8eSopenharmony_ci /** 10261847f8eSopenharmony_ci * Start network sharing for given type. 10361847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 10461847f8eSopenharmony_ci * @param { SharingIfaceType } type - Enumeration of shareable interface types. 10561847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of startSharing. 10661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 10761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 10861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 10961847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 11061847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 11161847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 11261847f8eSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 11361847f8eSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 11461847f8eSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 11561847f8eSopenharmony_ci * @throws { BusinessError } 2202009 - Failed to enable forwarding for network sharing. 11661847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 11761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 11861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 11961847f8eSopenharmony_ci * @since 9 12061847f8eSopenharmony_ci */ 12161847f8eSopenharmony_ci function startSharing(type: SharingIfaceType, callback: AsyncCallback<void>): void; 12261847f8eSopenharmony_ci 12361847f8eSopenharmony_ci /** 12461847f8eSopenharmony_ci * Start network sharing for given type. 12561847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 12661847f8eSopenharmony_ci * @param { SharingIfaceType } type - Enumeration of shareable interface types. 12761847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 12861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 12961847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 13061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 13161847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 13261847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 13361847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 13461847f8eSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 13561847f8eSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 13661847f8eSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 13761847f8eSopenharmony_ci * @throws { BusinessError } 2202009 - Failed to enable forwarding for network sharing. 13861847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 13961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 14061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 14161847f8eSopenharmony_ci * @since 9 14261847f8eSopenharmony_ci */ 14361847f8eSopenharmony_ci function startSharing(type: SharingIfaceType): Promise<void>; 14461847f8eSopenharmony_ci 14561847f8eSopenharmony_ci /** 14661847f8eSopenharmony_ci * Stop network sharing for given type. 14761847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 14861847f8eSopenharmony_ci * @param { SharingIfaceType } type - Enumeration of shareable interface types. 14961847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback of startSharing. 15061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 15161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 15261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 15361847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 15461847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 15561847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 15661847f8eSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 15761847f8eSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 15861847f8eSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 15961847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 16061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 16161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 16261847f8eSopenharmony_ci * @since 9 16361847f8eSopenharmony_ci */ 16461847f8eSopenharmony_ci function stopSharing(type: SharingIfaceType, callback: AsyncCallback<void>): void; 16561847f8eSopenharmony_ci 16661847f8eSopenharmony_ci /** 16761847f8eSopenharmony_ci * Stop network sharing for given type. 16861847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 16961847f8eSopenharmony_ci * @param { SharingIfaceType } type - Enumeration of shareable interface types. 17061847f8eSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 17161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 17261847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 17361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 17461847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 17561847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 17661847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 17761847f8eSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 17861847f8eSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 17961847f8eSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 18061847f8eSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 18161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 18261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 18361847f8eSopenharmony_ci * @since 9 18461847f8eSopenharmony_ci */ 18561847f8eSopenharmony_ci function stopSharing(type: SharingIfaceType): Promise<void>; 18661847f8eSopenharmony_ci 18761847f8eSopenharmony_ci /** 18861847f8eSopenharmony_ci * Obtains the number of downlink data bytes of the sharing network interfaces. 18961847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 19061847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the number of downlink data bytes of the sharing network interfaces. 19161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 19261847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 19361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 19461847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 19561847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 19661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 19761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 19861847f8eSopenharmony_ci * @since 9 19961847f8eSopenharmony_ci */ 20061847f8eSopenharmony_ci function getStatsRxBytes(callback: AsyncCallback<number>): void; 20161847f8eSopenharmony_ci 20261847f8eSopenharmony_ci /** 20361847f8eSopenharmony_ci * Obtains the number of downlink data bytes of the sharing network interfaces. 20461847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 20561847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 20661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 20761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 20861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 20961847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 21061847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 21161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 21261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 21361847f8eSopenharmony_ci * @since 9 21461847f8eSopenharmony_ci */ 21561847f8eSopenharmony_ci function getStatsRxBytes(): Promise<number>; 21661847f8eSopenharmony_ci 21761847f8eSopenharmony_ci /** 21861847f8eSopenharmony_ci * Obtains the number of uplink data bytes of the sharing network interfaces. 21961847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 22061847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the number of uplink data bytes of the sharing network interfaces. 22161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 22261847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 22361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 22461847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 22561847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 22661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 22761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 22861847f8eSopenharmony_ci * @since 9 22961847f8eSopenharmony_ci */ 23061847f8eSopenharmony_ci function getStatsTxBytes(callback: AsyncCallback<number>): void; 23161847f8eSopenharmony_ci 23261847f8eSopenharmony_ci /** 23361847f8eSopenharmony_ci * Obtains the number of uplink data bytes of the sharing network interfaces. 23461847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 23561847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 23661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 23761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 23861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 23961847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 24061847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 24161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 24261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 24361847f8eSopenharmony_ci * @since 9 24461847f8eSopenharmony_ci */ 24561847f8eSopenharmony_ci function getStatsTxBytes(): Promise<number>; 24661847f8eSopenharmony_ci 24761847f8eSopenharmony_ci /** 24861847f8eSopenharmony_ci * Obtains the number of total data bytes of the sharing network interfaces. 24961847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 25061847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - Returns the number of total data bytes of the sharing network interfaces. 25161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 25261847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 25361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 25461847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 25561847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 25661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 25761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 25861847f8eSopenharmony_ci * @since 9 25961847f8eSopenharmony_ci */ 26061847f8eSopenharmony_ci function getStatsTotalBytes(callback: AsyncCallback<number>): void; 26161847f8eSopenharmony_ci 26261847f8eSopenharmony_ci /** 26361847f8eSopenharmony_ci * Obtains the number of total data bytes of the sharing network interfaces. 26461847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 26561847f8eSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 26661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 26761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 26861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 26961847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 27061847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 27161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 27261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 27361847f8eSopenharmony_ci * @since 9 27461847f8eSopenharmony_ci */ 27561847f8eSopenharmony_ci function getStatsTotalBytes(): Promise<number>; 27661847f8eSopenharmony_ci 27761847f8eSopenharmony_ci /** 27861847f8eSopenharmony_ci * Obtains the names of interfaces in each sharing state. 27961847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 28061847f8eSopenharmony_ci * @param { SharingIfaceState } state - Is the network sharing state. 28161847f8eSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - Returns an array of interface names that meet this status. 28261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 28361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 28461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 28561847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 28661847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 28761847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 28861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 28961847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 29061847f8eSopenharmony_ci * @since 9 29161847f8eSopenharmony_ci */ 29261847f8eSopenharmony_ci function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback<Array<string>>): void; 29361847f8eSopenharmony_ci 29461847f8eSopenharmony_ci /** 29561847f8eSopenharmony_ci * Obtains the names of interfaces in each sharing state. 29661847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 29761847f8eSopenharmony_ci * @param { SharingIfaceState } state - Is the network sharing state. 29861847f8eSopenharmony_ci * @returns { Promise<Array<string>> } The promise returned by the function. 29961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 30061847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 30161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 30261847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 30361847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 30461847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 30561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 30661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 30761847f8eSopenharmony_ci * @since 9 30861847f8eSopenharmony_ci */ 30961847f8eSopenharmony_ci function getSharingIfaces(state: SharingIfaceState): Promise<Array<string>>; 31061847f8eSopenharmony_ci 31161847f8eSopenharmony_ci /** 31261847f8eSopenharmony_ci * Obtains the network sharing state for given type. 31361847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 31461847f8eSopenharmony_ci * @param { SharingIfaceType } type - Is the enumeration of shareable interface types. 31561847f8eSopenharmony_ci * @param { AsyncCallback<SharingIfaceState> } callback - the callback of getSharingState. {@code SharingIfaceState}. 31661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 31761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 31861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 31961847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 32061847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 32161847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 32261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 32361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 32461847f8eSopenharmony_ci * @since 9 32561847f8eSopenharmony_ci */ 32661847f8eSopenharmony_ci function getSharingState(type: SharingIfaceType, callback: AsyncCallback<SharingIfaceState>): void; 32761847f8eSopenharmony_ci 32861847f8eSopenharmony_ci /** 32961847f8eSopenharmony_ci * Obtains the network sharing state for given type. 33061847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 33161847f8eSopenharmony_ci * @param { SharingIfaceType } type - Is the enumeration of shareable interface types. 33261847f8eSopenharmony_ci * @returns { Promise<SharingIfaceState> } The promise returned by the function. 33361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 33461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 33561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 33661847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 33761847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 33861847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 33961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 34061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 34161847f8eSopenharmony_ci * @since 9 34261847f8eSopenharmony_ci */ 34361847f8eSopenharmony_ci function getSharingState(type: SharingIfaceType): Promise<SharingIfaceState>; 34461847f8eSopenharmony_ci 34561847f8eSopenharmony_ci /** 34661847f8eSopenharmony_ci * Get a list regular expression that defines any interface that can support network sharing. 34761847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 34861847f8eSopenharmony_ci * @param { SharingIfaceType } type - Is the enumeration of shareable interface types. 34961847f8eSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - the callback of getSharableRegexes. 35061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 35161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 35261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 35361847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 35461847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 35561847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 35661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 35761847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 35861847f8eSopenharmony_ci * @since 9 35961847f8eSopenharmony_ci */ 36061847f8eSopenharmony_ci function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback<Array<string>>): void; 36161847f8eSopenharmony_ci 36261847f8eSopenharmony_ci /** 36361847f8eSopenharmony_ci * Get a list regular expression that defines any interface that can support network sharing. 36461847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 36561847f8eSopenharmony_ci * @param { SharingIfaceType } type - Is the enumeration of shareable interface types. 36661847f8eSopenharmony_ci * @returns { Promise<Array<string>> } The promise returned by the function. 36761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 36861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 36961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 37061847f8eSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 37161847f8eSopenharmony_ci * @throws { BusinessError } 2200002 - Failed to connect to the service. 37261847f8eSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 37361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 37461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 37561847f8eSopenharmony_ci * @since 9 37661847f8eSopenharmony_ci */ 37761847f8eSopenharmony_ci function getSharableRegexes(type: SharingIfaceType): Promise<Array<string>>; 37861847f8eSopenharmony_ci 37961847f8eSopenharmony_ci /** 38061847f8eSopenharmony_ci * Register a callback for the global network sharing state change. 38161847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 38261847f8eSopenharmony_ci * @param { 'sharingStateChange' } type - Indicates Event name. 38361847f8eSopenharmony_ci * @param { Callback<boolean> } callback - the callback function that returns the status. 38461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 38561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 38661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 38761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 38861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 38961847f8eSopenharmony_ci * @since 9 39061847f8eSopenharmony_ci */ 39161847f8eSopenharmony_ci function on(type: 'sharingStateChange', callback: Callback<boolean>): void; 39261847f8eSopenharmony_ci 39361847f8eSopenharmony_ci /** 39461847f8eSopenharmony_ci * Unregister a callback for the global network sharing state change. 39561847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 39661847f8eSopenharmony_ci * @param { 'sharingStateChange' } type Indicates Event name. 39761847f8eSopenharmony_ci * @param { Callback<boolean> } callback - the callback function that returns the status. 39861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 39961847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 40061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 40161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 40261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 40361847f8eSopenharmony_ci * @since 9 40461847f8eSopenharmony_ci */ 40561847f8eSopenharmony_ci function off(type: 'sharingStateChange', callback?: Callback<boolean>): void; 40661847f8eSopenharmony_ci 40761847f8eSopenharmony_ci /** 40861847f8eSopenharmony_ci * Register a callback for the interface network sharing state change. 40961847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 41061847f8eSopenharmony_ci * @param { 'interfaceSharingStateChange' } type - Indicates Event name. 41161847f8eSopenharmony_ci * @param { Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }> } callback - the callback function that returns the message. 41261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 41361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 41461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 41561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 41661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 41761847f8eSopenharmony_ci * @since 9 41861847f8eSopenharmony_ci */ 41961847f8eSopenharmony_ci /** 42061847f8eSopenharmony_ci * Register a callback for the interface network sharing state change. 42161847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 42261847f8eSopenharmony_ci * @param { 'interfaceSharingStateChange' } type - Indicates Event name. 42361847f8eSopenharmony_ci * @param { Callback<InterfaceSharingStateInfo> } callback - the callback function that returns the message. 42461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 42561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 42661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 42761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 42861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 42961847f8eSopenharmony_ci * @since 11 43061847f8eSopenharmony_ci */ 43161847f8eSopenharmony_ci function on(type: 'interfaceSharingStateChange', callback: Callback<InterfaceSharingStateInfo>): void; 43261847f8eSopenharmony_ci 43361847f8eSopenharmony_ci /** 43461847f8eSopenharmony_ci * Unregister a callback for the interface network sharing state change. 43561847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 43661847f8eSopenharmony_ci * @param { 'interfaceSharingStateChange' } type - Indicates Event name. 43761847f8eSopenharmony_ci * @param { Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }> } callback - the callback function that returns the message. 43861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 43961847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 44061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 44161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 44261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 44361847f8eSopenharmony_ci * @since 9 44461847f8eSopenharmony_ci */ 44561847f8eSopenharmony_ci /** 44661847f8eSopenharmony_ci * Unregister a callback for the interface network sharing state change. 44761847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 44861847f8eSopenharmony_ci * @param { 'interfaceSharingStateChange' } type - Indicates Event name. 44961847f8eSopenharmony_ci * @param { Callback<InterfaceSharingStateInfo> } callback - the callback function that returns the message. 45061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 45161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 45261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 45361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 45461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 45561847f8eSopenharmony_ci * @since 11 45661847f8eSopenharmony_ci */ 45761847f8eSopenharmony_ci function off(type: 'interfaceSharingStateChange', callback?: Callback<InterfaceSharingStateInfo>): void; 45861847f8eSopenharmony_ci 45961847f8eSopenharmony_ci /** 46061847f8eSopenharmony_ci * Register a callback for the sharing upstream network change. 46161847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 46261847f8eSopenharmony_ci * @param { 'sharingUpstreamChange' } type - Indicates Event name. 46361847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback function that returns the network handle. 46461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 46561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 46661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 46761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 46861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 46961847f8eSopenharmony_ci * @since 9 47061847f8eSopenharmony_ci */ 47161847f8eSopenharmony_ci function on(type: 'sharingUpstreamChange', callback: Callback<NetHandle>): void; 47261847f8eSopenharmony_ci 47361847f8eSopenharmony_ci /** 47461847f8eSopenharmony_ci * Unregister a callback for the sharing upstream network change. 47561847f8eSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 47661847f8eSopenharmony_ci * @param { 'sharingUpstreamChange' } type - Indicates Event name. 47761847f8eSopenharmony_ci * @param { Callback<NetHandle> } callback - the callback function that returns the network handle. 47861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 47961847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 48061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 48161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 48261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 48361847f8eSopenharmony_ci * @since 9 48461847f8eSopenharmony_ci */ 48561847f8eSopenharmony_ci function off(type: 'sharingUpstreamChange', callback?: Callback<NetHandle>): void; 48661847f8eSopenharmony_ci 48761847f8eSopenharmony_ci /** 48861847f8eSopenharmony_ci * Enumerates the network sharing states of an NIC. 48961847f8eSopenharmony_ci * @enum {number} 49061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 49161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 49261847f8eSopenharmony_ci * @since 9 49361847f8eSopenharmony_ci */ 49461847f8eSopenharmony_ci export enum SharingIfaceState { 49561847f8eSopenharmony_ci /** 49661847f8eSopenharmony_ci * Indicates the names of the NICs that are serving as network sharing. 49761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 49861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 49961847f8eSopenharmony_ci * @since 9 50061847f8eSopenharmony_ci */ 50161847f8eSopenharmony_ci SHARING_NIC_SERVING = 1, 50261847f8eSopenharmony_ci 50361847f8eSopenharmony_ci /** 50461847f8eSopenharmony_ci * Indicates the names of the NICs that can serve as network sharing. 50561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 50661847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 50761847f8eSopenharmony_ci * @since 9 50861847f8eSopenharmony_ci */ 50961847f8eSopenharmony_ci SHARING_NIC_CAN_SERVER = 2, 51061847f8eSopenharmony_ci 51161847f8eSopenharmony_ci /** 51261847f8eSopenharmony_ci * Indicates the names of the NICs that serving error. 51361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 51461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 51561847f8eSopenharmony_ci * @since 9 51661847f8eSopenharmony_ci */ 51761847f8eSopenharmony_ci SHARING_NIC_ERROR = 3 51861847f8eSopenharmony_ci } 51961847f8eSopenharmony_ci 52061847f8eSopenharmony_ci /** 52161847f8eSopenharmony_ci * The interface is used to notify listeners of changes in shared interface status. 52261847f8eSopenharmony_ci * @interface InterfaceSharingStateInfo 52361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 52461847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 52561847f8eSopenharmony_ci * @since 11 52661847f8eSopenharmony_ci */ 52761847f8eSopenharmony_ci export interface InterfaceSharingStateInfo { 52861847f8eSopenharmony_ci /** 52961847f8eSopenharmony_ci * Enumerates the network sharing types of an NIC. 53061847f8eSopenharmony_ci * @type { SharingIfaceType } 53161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 53261847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 53361847f8eSopenharmony_ci * @since 11 53461847f8eSopenharmony_ci */ 53561847f8eSopenharmony_ci type: SharingIfaceType; 53661847f8eSopenharmony_ci /** 53761847f8eSopenharmony_ci * The specified network interface name. 53861847f8eSopenharmony_ci * @type { string } 53961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 54061847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 54161847f8eSopenharmony_ci * @since 11 54261847f8eSopenharmony_ci */ 54361847f8eSopenharmony_ci iface: string; 54461847f8eSopenharmony_ci /** 54561847f8eSopenharmony_ci * Network card sharing status. 54661847f8eSopenharmony_ci * @type { SharingIfaceState } 54761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 54861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 54961847f8eSopenharmony_ci * @since 11 55061847f8eSopenharmony_ci */ 55161847f8eSopenharmony_ci state: SharingIfaceState; 55261847f8eSopenharmony_ci } 55361847f8eSopenharmony_ci 55461847f8eSopenharmony_ci /** 55561847f8eSopenharmony_ci * Enumerates the network sharing types of an NIC. 55661847f8eSopenharmony_ci * @enum {number} 55761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 55861847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 55961847f8eSopenharmony_ci * @since 9 56061847f8eSopenharmony_ci */ 56161847f8eSopenharmony_ci export enum SharingIfaceType { 56261847f8eSopenharmony_ci /** 56361847f8eSopenharmony_ci * Network sharing type for Wi-Fi. 56461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 56561847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 56661847f8eSopenharmony_ci * @since 9 56761847f8eSopenharmony_ci */ 56861847f8eSopenharmony_ci SHARING_WIFI = 0, 56961847f8eSopenharmony_ci 57061847f8eSopenharmony_ci /** 57161847f8eSopenharmony_ci * Network sharing type for USB. 57261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 57361847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 57461847f8eSopenharmony_ci * @since 9 57561847f8eSopenharmony_ci */ 57661847f8eSopenharmony_ci SHARING_USB = 1, 57761847f8eSopenharmony_ci 57861847f8eSopenharmony_ci /** 57961847f8eSopenharmony_ci * Network sharing type for BLUETOOTH. 58061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 58161847f8eSopenharmony_ci * @systemapi Hide this for inner system use. 58261847f8eSopenharmony_ci * @since 9 58361847f8eSopenharmony_ci */ 58461847f8eSopenharmony_ci SHARING_BLUETOOTH = 2 58561847f8eSopenharmony_ci } 58661847f8eSopenharmony_ci} 58761847f8eSopenharmony_ci 58861847f8eSopenharmony_ciexport default sharing; 589