18e745fdaSopenharmony_ci/* 28e745fdaSopenharmony_ci * Copyright (C) 2022-2023 Huawei Device Co., Ltd. 38e745fdaSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48e745fdaSopenharmony_ci * you may not use this file except in compliance with the License. 58e745fdaSopenharmony_ci * You may obtain a copy of the License at 68e745fdaSopenharmony_ci * 78e745fdaSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88e745fdaSopenharmony_ci * 98e745fdaSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108e745fdaSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118e745fdaSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128e745fdaSopenharmony_ci * See the License for the specific language governing permissions and 138e745fdaSopenharmony_ci * limitations under the License. 148e745fdaSopenharmony_ci */ 158e745fdaSopenharmony_ci 168e745fdaSopenharmony_ciimport { AsyncCallback, Callback } from "./@ohos.base"; 178e745fdaSopenharmony_ciimport connection from "./@ohos.net.connection"; 188e745fdaSopenharmony_ci 198e745fdaSopenharmony_ci/** 208e745fdaSopenharmony_ci * Provides network sharing related interfaces. 218e745fdaSopenharmony_ci * @namespace sharing 228e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 238e745fdaSopenharmony_ci * @since 9 248e745fdaSopenharmony_ci */ 258e745fdaSopenharmony_cideclare namespace sharing { 268e745fdaSopenharmony_ci type NetHandle = connection.NetHandle; 278e745fdaSopenharmony_ci /** 288e745fdaSopenharmony_ci * Checks whether this device allows for network sharing. 298e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 308e745fdaSopenharmony_ci * @param { AsyncCallback<boolean> } callback Returns {@code true} indicating network sharing is supported; 318e745fdaSopenharmony_ci * returns {@code false} otherwise. 328e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 338e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 348e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 358e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 368e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 378e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 388e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 398e745fdaSopenharmony_ci * @since 9 408e745fdaSopenharmony_ci */ 418e745fdaSopenharmony_ci function isSharingSupported(callback: AsyncCallback<boolean>): void; 428e745fdaSopenharmony_ci 438e745fdaSopenharmony_ci /** 448e745fdaSopenharmony_ci * Checks whether this device allows for network sharing. 458e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 468e745fdaSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 478e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 488e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 498e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 508e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 518e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 528e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 538e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 548e745fdaSopenharmony_ci * @since 9 558e745fdaSopenharmony_ci */ 568e745fdaSopenharmony_ci function isSharingSupported(): Promise<boolean>; 578e745fdaSopenharmony_ci 588e745fdaSopenharmony_ci /** 598e745fdaSopenharmony_ci * Return the global network sharing state. 608e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 618e745fdaSopenharmony_ci * @param { AsyncCallback<boolean> } callback Returns {@code true} indicating network sharing is running; 628e745fdaSopenharmony_ci * returns {@code false} otherwise. 638e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 648e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 658e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 668e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 678e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 688e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 698e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 708e745fdaSopenharmony_ci * @since 9 718e745fdaSopenharmony_ci */ 728e745fdaSopenharmony_ci function isSharing(callback: AsyncCallback<boolean>): void; 738e745fdaSopenharmony_ci 748e745fdaSopenharmony_ci /** 758e745fdaSopenharmony_ci * Return the global network sharing state. 768e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 778e745fdaSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 788e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 798e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 808e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 818e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 828e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 838e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 848e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 858e745fdaSopenharmony_ci * @since 9 868e745fdaSopenharmony_ci */ 878e745fdaSopenharmony_ci function isSharing(): Promise<boolean>; 888e745fdaSopenharmony_ci 898e745fdaSopenharmony_ci /** 908e745fdaSopenharmony_ci * Start network sharing for given type. 918e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 928e745fdaSopenharmony_ci * @param { SharingIfaceType } type Enumeration of shareable interface types. 938e745fdaSopenharmony_ci * @param { AsyncCallback<void> } callback Returns the result. 948e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 958e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 968e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 978e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 988e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 998e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 1008e745fdaSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 1018e745fdaSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 1028e745fdaSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 1038e745fdaSopenharmony_ci * @throws { BusinessError } 2202009 - Network share enable forwarding error. 1048e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 1058e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 1068e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 1078e745fdaSopenharmony_ci * @since 9 1088e745fdaSopenharmony_ci */ 1098e745fdaSopenharmony_ci function startSharing(type: SharingIfaceType, callback: AsyncCallback<void>): void; 1108e745fdaSopenharmony_ci 1118e745fdaSopenharmony_ci /** 1128e745fdaSopenharmony_ci * Start network sharing for given type. 1138e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 1148e745fdaSopenharmony_ci * @param { SharingIfaceType } type Enumeration of shareable interface types. 1158e745fdaSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 1168e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 1178e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 1188e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 1198e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 1208e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 1218e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 1228e745fdaSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 1238e745fdaSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 1248e745fdaSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 1258e745fdaSopenharmony_ci * @throws { BusinessError } 2202009 - Network share enable forwarding error. 1268e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 1278e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 1288e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 1298e745fdaSopenharmony_ci * @since 9 1308e745fdaSopenharmony_ci */ 1318e745fdaSopenharmony_ci function startSharing(type: SharingIfaceType): Promise<void>; 1328e745fdaSopenharmony_ci 1338e745fdaSopenharmony_ci /** 1348e745fdaSopenharmony_ci * Stop network sharing for given type. 1358e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 1368e745fdaSopenharmony_ci * @param { SharingIfaceType } type Enumeration of shareable interface types. 1378e745fdaSopenharmony_ci * @param { AsyncCallback<void> } callback Returns the result. 1388e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 1398e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 1408e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 1418e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 1428e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 1438e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 1448e745fdaSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 1458e745fdaSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 1468e745fdaSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 1478e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 1488e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 1498e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 1508e745fdaSopenharmony_ci * @since 9 1518e745fdaSopenharmony_ci */ 1528e745fdaSopenharmony_ci function stopSharing(type: SharingIfaceType, callback: AsyncCallback<void>): void; 1538e745fdaSopenharmony_ci 1548e745fdaSopenharmony_ci /** 1558e745fdaSopenharmony_ci * Stop network sharing for given type. 1568e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 1578e745fdaSopenharmony_ci * @param { SharingIfaceType } type Enumeration of shareable interface types. 1588e745fdaSopenharmony_ci * @returns { Promise<void> } The promise returned by the function. 1598e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 1608e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 1618e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 1628e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 1638e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 1648e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 1658e745fdaSopenharmony_ci * @throws { BusinessError } 2202004 - Try to share an unavailable iface. 1668e745fdaSopenharmony_ci * @throws { BusinessError } 2202005 - WiFi sharing failed. 1678e745fdaSopenharmony_ci * @throws { BusinessError } 2202006 - Bluetooth sharing failed. 1688e745fdaSopenharmony_ci * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. 1698e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 1708e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 1718e745fdaSopenharmony_ci * @since 9 1728e745fdaSopenharmony_ci */ 1738e745fdaSopenharmony_ci function stopSharing(type: SharingIfaceType): Promise<void>; 1748e745fdaSopenharmony_ci 1758e745fdaSopenharmony_ci /** 1768e745fdaSopenharmony_ci * Obtains the number of downlink data bytes of the sharing network interfaces. 1778e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 1788e745fdaSopenharmony_ci * @param { AsyncCallback<number> } callback Returns the number of downlink data bytes of the sharing network interfaces. 1798e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 1808e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 1818e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 1828e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 1838e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 1848e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 1858e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 1868e745fdaSopenharmony_ci * @since 9 1878e745fdaSopenharmony_ci */ 1888e745fdaSopenharmony_ci function getStatsRxBytes(callback: AsyncCallback<number>): void; 1898e745fdaSopenharmony_ci 1908e745fdaSopenharmony_ci /** 1918e745fdaSopenharmony_ci * Obtains the number of downlink data bytes of the sharing network interfaces. 1928e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 1938e745fdaSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 1948e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 1958e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 1968e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 1978e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 1988e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 1998e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2008e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 2018e745fdaSopenharmony_ci * @since 9 2028e745fdaSopenharmony_ci */ 2038e745fdaSopenharmony_ci function getStatsRxBytes(): Promise<number>; 2048e745fdaSopenharmony_ci 2058e745fdaSopenharmony_ci /** 2068e745fdaSopenharmony_ci * Obtains the number of uplink data bytes of the sharing network interfaces. 2078e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 2088e745fdaSopenharmony_ci * @param { AsyncCallback<number> } callback Returns the number of uplink data bytes of the sharing network interfaces. 2098e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 2108e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 2118e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 2128e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 2138e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 2148e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2158e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 2168e745fdaSopenharmony_ci * @since 9 2178e745fdaSopenharmony_ci */ 2188e745fdaSopenharmony_ci function getStatsTxBytes(callback: AsyncCallback<number>): void; 2198e745fdaSopenharmony_ci 2208e745fdaSopenharmony_ci /** 2218e745fdaSopenharmony_ci * Obtains the number of uplink data bytes of the sharing network interfaces. 2228e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 2238e745fdaSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 2248e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 2258e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 2268e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 2278e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 2288e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 2298e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2308e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 2318e745fdaSopenharmony_ci * @since 9 2328e745fdaSopenharmony_ci */ 2338e745fdaSopenharmony_ci function getStatsTxBytes(): Promise<number>; 2348e745fdaSopenharmony_ci 2358e745fdaSopenharmony_ci /** 2368e745fdaSopenharmony_ci * Obtains the number of total data bytes of the sharing network interfaces. 2378e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 2388e745fdaSopenharmony_ci * @param { AsyncCallback<number> } callback Returns the number of total data bytes of the sharing network interfaces. 2398e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 2408e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 2418e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 2428e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 2438e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 2448e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2458e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 2468e745fdaSopenharmony_ci * @since 9 2478e745fdaSopenharmony_ci */ 2488e745fdaSopenharmony_ci function getStatsTotalBytes(callback: AsyncCallback<number>): void; 2498e745fdaSopenharmony_ci 2508e745fdaSopenharmony_ci /** 2518e745fdaSopenharmony_ci * Obtains the number of total data bytes of the sharing network interfaces. 2528e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 2538e745fdaSopenharmony_ci * @returns { Promise<number> } The promise returned by the function. 2548e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 2558e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 2568e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 2578e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 2588e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 2598e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2608e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 2618e745fdaSopenharmony_ci * @since 9 2628e745fdaSopenharmony_ci */ 2638e745fdaSopenharmony_ci function getStatsTotalBytes(): Promise<number>; 2648e745fdaSopenharmony_ci 2658e745fdaSopenharmony_ci /** 2668e745fdaSopenharmony_ci * Obtains the names of interfaces in each sharing state. 2678e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 2688e745fdaSopenharmony_ci * @param { SharingIfaceState } state Is the network sharing state. 2698e745fdaSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback Returns an array of interface names that meet this status. 2708e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 2718e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 2728e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 2738e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 2748e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 2758e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 2768e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2778e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 2788e745fdaSopenharmony_ci * @since 9 2798e745fdaSopenharmony_ci */ 2808e745fdaSopenharmony_ci function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback<Array<string>>): void; 2818e745fdaSopenharmony_ci 2828e745fdaSopenharmony_ci /** 2838e745fdaSopenharmony_ci * Obtains the names of interfaces in each sharing state. 2848e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 2858e745fdaSopenharmony_ci * @param { SharingIfaceState } state Is the network sharing state. 2868e745fdaSopenharmony_ci * @returns { Promise<Array<string>> } The promise returned by the function. 2878e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 2888e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 2898e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 2908e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 2918e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 2928e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 2938e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 2948e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 2958e745fdaSopenharmony_ci * @since 9 2968e745fdaSopenharmony_ci */ 2978e745fdaSopenharmony_ci function getSharingIfaces(state: SharingIfaceState): Promise<Array<string>>; 2988e745fdaSopenharmony_ci 2998e745fdaSopenharmony_ci /** 3008e745fdaSopenharmony_ci * Obtains the network sharing state for given type. 3018e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 3028e745fdaSopenharmony_ci * @param { SharingIfaceType } type Is the enumeration of shareable interface types. 3038e745fdaSopenharmony_ci * @param { AsyncCallback<SharingIfaceState> } callback Returns {@code SharingIfaceState}. 3048e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 3058e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 3068e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 3078e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 3088e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 3098e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 3108e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 3118e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 3128e745fdaSopenharmony_ci * @since 9 3138e745fdaSopenharmony_ci */ 3148e745fdaSopenharmony_ci function getSharingState(type: SharingIfaceType, callback: AsyncCallback<SharingIfaceState>): void; 3158e745fdaSopenharmony_ci 3168e745fdaSopenharmony_ci /** 3178e745fdaSopenharmony_ci * Obtains the network sharing state for given type. 3188e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 3198e745fdaSopenharmony_ci * @param { SharingIfaceType } type Is the enumeration of shareable interface types. 3208e745fdaSopenharmony_ci * @returns { Promise<SharingIfaceState> } The promise returned by the function. 3218e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 3228e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 3238e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 3248e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 3258e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 3268e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 3278e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 3288e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 3298e745fdaSopenharmony_ci * @since 9 3308e745fdaSopenharmony_ci */ 3318e745fdaSopenharmony_ci function getSharingState(type: SharingIfaceType): Promise<SharingIfaceState>; 3328e745fdaSopenharmony_ci 3338e745fdaSopenharmony_ci /** 3348e745fdaSopenharmony_ci * Get a list regular expression that defines any interface that can support network sharing. 3358e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 3368e745fdaSopenharmony_ci * @param { SharingIfaceType } type Is the enumeration of shareable interface types. 3378e745fdaSopenharmony_ci * @param { AsyncCallback<Array<string>> } callback - the callback of getSharableRegexes. 3388e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 3398e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 3408e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 3418e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 3428e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 3438e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 3448e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 3458e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 3468e745fdaSopenharmony_ci * @since 9 3478e745fdaSopenharmony_ci */ 3488e745fdaSopenharmony_ci function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback<Array<string>>): void; 3498e745fdaSopenharmony_ci 3508e745fdaSopenharmony_ci /** 3518e745fdaSopenharmony_ci * Get a list regular expression that defines any interface that can support network sharing. 3528e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 3538e745fdaSopenharmony_ci * @param { SharingIfaceType } type Is the enumeration of shareable interface types. 3548e745fdaSopenharmony_ci * @returns { Promise<Array<string>> } The promise returned by the function. 3558e745fdaSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 3568e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 3578e745fdaSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 3588e745fdaSopenharmony_ci * @throws { BusinessError } 2200001 - Invalid parameter value. 3598e745fdaSopenharmony_ci * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. 3608e745fdaSopenharmony_ci * @throws { BusinessError } 2200003 - System internal error. 3618e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 3628e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 3638e745fdaSopenharmony_ci * @since 9 3648e745fdaSopenharmony_ci */ 3658e745fdaSopenharmony_ci function getSharableRegexes(type: SharingIfaceType): Promise<Array<string>>; 3668e745fdaSopenharmony_ci 3678e745fdaSopenharmony_ci /** 3688e745fdaSopenharmony_ci * Register a callback for the global network sharing state change. 3698e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 3708e745fdaSopenharmony_ci * @param { 'sharingStateChange' } type Indicates Event name. 3718e745fdaSopenharmony_ci * @param { Callback<boolean> } callback callback function that returns the status 3728e745fdaSopenharmony_ci * @throws { BusinessError } 201 Permission denied. 3738e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 3748e745fdaSopenharmony_ci * @throws { BusinessError } 401 Parameter error. 3758e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 3768e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 3778e745fdaSopenharmony_ci * @since 9 3788e745fdaSopenharmony_ci */ 3798e745fdaSopenharmony_ci function on(type: 'sharingStateChange', callback: Callback<boolean>): void; 3808e745fdaSopenharmony_ci 3818e745fdaSopenharmony_ci /** 3828e745fdaSopenharmony_ci * Unregister a callback for the global network sharing state change. 3838e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 3848e745fdaSopenharmony_ci * @param { 'sharingStateChange' } type Indicates Event name. 3858e745fdaSopenharmony_ci * @param { Callback<boolean> } callback callback function that returns the status 3868e745fdaSopenharmony_ci * @throws { BusinessError } 201 Permission denied. 3878e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 3888e745fdaSopenharmony_ci * @throws { BusinessError } 401 Parameter error. 3898e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 3908e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 3918e745fdaSopenharmony_ci * @since 9 3928e745fdaSopenharmony_ci */ 3938e745fdaSopenharmony_ci function off(type: 'sharingStateChange', callback?: Callback<boolean>): void; 3948e745fdaSopenharmony_ci 3958e745fdaSopenharmony_ci /** 3968e745fdaSopenharmony_ci * Register a callback for the interface network sharing state change. 3978e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 3988e745fdaSopenharmony_ci * @param { 'interfaceSharingStateChange' } type Indicates Event name. 3998e745fdaSopenharmony_ci * @param { Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }> } callback callback function that returns the message. 4008e745fdaSopenharmony_ci * @throws { BusinessError } 201 Permission denied. 4018e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 4028e745fdaSopenharmony_ci * @throws { BusinessError } 401 Parameter error. 4038e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4048e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4058e745fdaSopenharmony_ci * @since 9 4068e745fdaSopenharmony_ci */ 4078e745fdaSopenharmony_ci function on(type: 'interfaceSharingStateChange', callback: Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; 4088e745fdaSopenharmony_ci 4098e745fdaSopenharmony_ci /** 4108e745fdaSopenharmony_ci * Unregister a callback for the interface network sharing state change. 4118e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 4128e745fdaSopenharmony_ci * @param { 'interfaceSharingStateChange' } type Indicates Event name. 4138e745fdaSopenharmony_ci * @param { Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }> } callback callback function that returns the message. 4148e745fdaSopenharmony_ci * @throws { BusinessError } 201 Permission denied. 4158e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 4168e745fdaSopenharmony_ci * @throws { BusinessError } 401 Parameter error. 4178e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4188e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4198e745fdaSopenharmony_ci * @since 9 4208e745fdaSopenharmony_ci */ 4218e745fdaSopenharmony_ci function off(type: 'interfaceSharingStateChange', callback?: Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; 4228e745fdaSopenharmony_ci 4238e745fdaSopenharmony_ci /** 4248e745fdaSopenharmony_ci * Register a callback for the sharing upstream network change. 4258e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 4268e745fdaSopenharmony_ci * @param { 'sharingUpstreamChange' } type Indicates Event name. 4278e745fdaSopenharmony_ci * @param { Callback<NetHandle> } callback callback function that returns the network handle. 4288e745fdaSopenharmony_ci * @throws { BusinessError } 201 Permission denied. 4298e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 4308e745fdaSopenharmony_ci * @throws { BusinessError } 401 Parameter error. 4318e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4328e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4338e745fdaSopenharmony_ci * @since 9 4348e745fdaSopenharmony_ci */ 4358e745fdaSopenharmony_ci function on(type: 'sharingUpstreamChange', callback: Callback<NetHandle>): void; 4368e745fdaSopenharmony_ci 4378e745fdaSopenharmony_ci /** 4388e745fdaSopenharmony_ci * Unregister a callback for the sharing upstream network change. 4398e745fdaSopenharmony_ci * @permission ohos.permission.CONNECTIVITY_INTERNAL 4408e745fdaSopenharmony_ci * @param { 'sharingUpstreamChange' } type Indicates Event name. 4418e745fdaSopenharmony_ci * @param { Callback<NetHandle> } callback callback function that returns the network handle. 4428e745fdaSopenharmony_ci * @throws { BusinessError } 201 Permission denied. 4438e745fdaSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications use system APIs. 4448e745fdaSopenharmony_ci * @throws { BusinessError } 401 Parameter error. 4458e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4468e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4478e745fdaSopenharmony_ci * @since 9 4488e745fdaSopenharmony_ci */ 4498e745fdaSopenharmony_ci function off(type: 'sharingUpstreamChange', callback?: Callback<NetHandle>): void; 4508e745fdaSopenharmony_ci 4518e745fdaSopenharmony_ci /** 4528e745fdaSopenharmony_ci * Enumerates the network sharing states of an NIC. 4538e745fdaSopenharmony_ci * @enum {number} 4548e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4558e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4568e745fdaSopenharmony_ci * @since 9 4578e745fdaSopenharmony_ci */ 4588e745fdaSopenharmony_ci export enum SharingIfaceState { 4598e745fdaSopenharmony_ci /** 4608e745fdaSopenharmony_ci * Indicates the names of the NICs that are serving as network sharing. 4618e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4628e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4638e745fdaSopenharmony_ci * @since 9 4648e745fdaSopenharmony_ci */ 4658e745fdaSopenharmony_ci SHARING_NIC_SERVING = 1, 4668e745fdaSopenharmony_ci 4678e745fdaSopenharmony_ci /** 4688e745fdaSopenharmony_ci * Indicates the names of the NICs that can serve as network sharing. 4698e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4708e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4718e745fdaSopenharmony_ci * @since 9 4728e745fdaSopenharmony_ci */ 4738e745fdaSopenharmony_ci SHARING_NIC_CAN_SERVER = 2, 4748e745fdaSopenharmony_ci 4758e745fdaSopenharmony_ci /** 4768e745fdaSopenharmony_ci * Indicates the names of the NICs that serving error. 4778e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4788e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4798e745fdaSopenharmony_ci * @since 9 4808e745fdaSopenharmony_ci */ 4818e745fdaSopenharmony_ci SHARING_NIC_ERROR = 3 4828e745fdaSopenharmony_ci } 4838e745fdaSopenharmony_ci 4848e745fdaSopenharmony_ci /** 4858e745fdaSopenharmony_ci * Enumerates the network sharing types of an NIC. 4868e745fdaSopenharmony_ci * @enum {number} 4878e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4888e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4898e745fdaSopenharmony_ci * @since 9 4908e745fdaSopenharmony_ci */ 4918e745fdaSopenharmony_ci export enum SharingIfaceType { 4928e745fdaSopenharmony_ci /** 4938e745fdaSopenharmony_ci * Network sharing type for Wi-Fi. 4948e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 4958e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 4968e745fdaSopenharmony_ci * @since 9 4978e745fdaSopenharmony_ci */ 4988e745fdaSopenharmony_ci SHARING_WIFI = 0, 4998e745fdaSopenharmony_ci 5008e745fdaSopenharmony_ci /** 5018e745fdaSopenharmony_ci * Network sharing type for USB. 5028e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 5038e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 5048e745fdaSopenharmony_ci * @since 9 5058e745fdaSopenharmony_ci */ 5068e745fdaSopenharmony_ci SHARING_USB = 1, 5078e745fdaSopenharmony_ci 5088e745fdaSopenharmony_ci /** 5098e745fdaSopenharmony_ci * Network sharing type for BLUETOOTH. 5108e745fdaSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.NetSharing 5118e745fdaSopenharmony_ci * @systemapi Hide this for inner system use. 5128e745fdaSopenharmony_ci * @since 9 5138e745fdaSopenharmony_ci */ 5148e745fdaSopenharmony_ci SHARING_BLUETOOTH = 2 5158e745fdaSopenharmony_ci } 5168e745fdaSopenharmony_ci} 5178e745fdaSopenharmony_ci 5188e745fdaSopenharmony_ciexport default sharing;