From 0aa3cc57857d8b7fc3ac832b78bd1121983a28d7 Mon Sep 17 00:00:00 2001 From: liyufan Date: Thu, 24 Nov 2022 17:40:10 +0800 Subject: [PATCH 1/3] add netmanager sharing dts Signed-off-by: liyufan --- api/@ohos.net.sharing.d.ts | 221 +++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 api/@ohos.net.sharing.d.ts diff --git a/api/@ohos.net.sharing.d.ts b/api/@ohos.net.sharing.d.ts new file mode 100644 index 0000000000..722df165a0 --- /dev/null +++ b/api/@ohos.net.sharing.d.ts @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {AsyncCallback, Callback} from "./basic"; +import {NetHandle} from "./@ohos.net.connection"; + +/** + * Provides network sharing related interfaces. + * + * @since 9 + * @syscap SystemCapability.Communication.NetManager.Extension + */ +declare namespace sharing { + /** + * Checks whether this device allows for network sharing. + * + * @param callback Returns {@code true} indicating network sharing is supported; returns {@code false} otherwise. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function isSharingSupported(callback: AsyncCallback): void; + function isSharingSupported(): Promise; + + /** + * Return the global network sharing state. + * + * @param callback Returns {@code true} indicating network sharing is running; returns {@code false} otherwise. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function isSharing(callback: AsyncCallback): void; + function isSharing(): Promise; + + /** + * Start network sharing for given type. + * + * @param type Enumeration of shareable interface types. + * @param callback Returns the result. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function startSharing(type: SharingIfaceType, callback: AsyncCallback): void; + function startSharing(type: SharingIfaceType): Promise; + + /** + * Stop network sharing for given type. + * + * @param type Enumeration of shareable interface types. + * @param callback Returns the result. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function stopSharing(type: SharingIfaceType, callback: AsyncCallback): void; + function stopSharing(type: SharingIfaceType): Promise; + + /** + * Obtains the number of downlink data bytes of the sharing network interfaces. + * + * @param callback Returns the number of downlink data bytes of the sharing network interfaces. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function getStatsRxBytes(callback: AsyncCallback): void; + function getStatsRxBytes(): Promise; + + /** + * Obtains the number of uplink data bytes of the sharing network interfaces. + * + * @param callback Returns the number of uplink data bytes of the sharing network interfaces. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function getStatsTxBytes(callback: AsyncCallback): void; + function getStatsTxBytes(): Promise; + + /** + * Obtains the number of total data bytes of the sharing network interfaces. + * + * @param callback Returns the number of total data bytes of the sharing network interfaces. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function getStatsTotalBytes(callback: AsyncCallback): void; + function getStatsTotalBytes(): Promise; + + /** + * Obtains the names of interfaces in each sharing state. + * + * @param state Is the network sharing state, include serving, can server and servering error states. + * @param callback Returns an array of interface names that meet this status. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback>): void; + function getSharingIfaces(state: SharingIfaceState): Promise>; + + /** + * Obtains the network sharing state for given type. + * + * @param type Is the enumeration of shareable interface types. + * @param callback Returns {@code SharingIfaceState}. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function getSharingState(type: SharingIfaceType, callback: AsyncCallback): void; + function getSharingState(type: SharingIfaceType): Promise; + + /** + * Get a list regular expression that defines any interface that can support network sharing. + * + * @param type Is the enumeration of shareable interface types. + * @param callback Returns an array of regular expression strings that define which interfaces + * are considered to support network sharing. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback>): void; + function getSharableRegexes(type: SharingIfaceType): Promise>; + + /** + * Register a callback for the global network sharing state change. + * + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function on(type: 'sharingStateChange', callback: Callback): void; + + /** + * Unregister a callback for the global network sharing state change. + * + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function off(type: 'sharingStateChange', callback?: Callback): void; + + /** + * Register a callback for the interface network sharing state change. + * + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function on(type: 'interfaceSharingStateChange', callback: Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; + + /** + * Unregister a callback for the interface network sharing state change. + * + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function off(type: 'interfaceSharingStateChange', callback?: Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; + + /** + * Register a callback for the sharing upstream network change. + * + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function on(type: 'sharingUpstreamChange', callback: Callback): void; + + /** + * Unregister a callback for the sharing upstream network change. + * + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function off(type: 'sharingUpstreamChange', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + */ + export enum SharingIfaceState { + /** + * Indicates the names of the NICs that are serving as network sharing. + */ + SHARING_NIC_SERVING = 1, + + /** + * Indicates the names of the NICs that can serve as network sharing. + */ + SHARING_NIC_CAN_SERVER = 2, + + /** + * Indicates the names of the NICs that serving error. + */ + SHARING_NIC_ERROR = 3 + } + + /** + * @systemapi Hide this for inner system use. + */ + export enum SharingIfaceType { + /** + * Network sharing type for Wi-Fi. + */ + SHARING_WIFI = 0, + + /** + * this type is not supported temporarily + */ + SHARING_USB = 1, + + /** + * Network sharing type for BLUETOOTH. + */ + SHARING_BLUETOOTH = 2 + } +} + +export default sharing; \ No newline at end of file -- Gitee From cf29a73760662b316c455b439a1596bb68c546d2 Mon Sep 17 00:00:00 2001 From: liyufan123 Date: Mon, 28 Nov 2022 13:30:42 +0800 Subject: [PATCH 2/3] words check Signed-off-by: liyufan123 --- api/@ohos.net.sharing.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.net.sharing.d.ts b/api/@ohos.net.sharing.d.ts index 722df165a0..0a8ed092d9 100644 --- a/api/@ohos.net.sharing.d.ts +++ b/api/@ohos.net.sharing.d.ts @@ -207,7 +207,7 @@ declare namespace sharing { SHARING_WIFI = 0, /** - * this type is not supported temporarily + * This type is not supported temporarily */ SHARING_USB = 1, -- Gitee From 014efc858ff2e257f270287a1deb2bc235373fb1 Mon Sep 17 00:00:00 2001 From: liyufan123 Date: Mon, 28 Nov 2022 16:22:18 +0800 Subject: [PATCH 3/3] change syscap Signed-off-by: liyufan123 --- api/@ohos.net.sharing.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.net.sharing.d.ts b/api/@ohos.net.sharing.d.ts index 0a8ed092d9..f8b02d7c8e 100644 --- a/api/@ohos.net.sharing.d.ts +++ b/api/@ohos.net.sharing.d.ts @@ -20,7 +20,7 @@ import {NetHandle} from "./@ohos.net.connection"; * Provides network sharing related interfaces. * * @since 9 - * @syscap SystemCapability.Communication.NetManager.Extension + * @syscap SystemCapability.Communication.NetManager.NetSharing */ declare namespace sharing { /** -- Gitee