From bb476280281b6acbb85c78d33571b75e5df486fb Mon Sep 17 00:00:00 2001 From: zhangfeng Date: Wed, 16 Feb 2022 06:40:49 +0000 Subject: [PATCH] add wifiext.d.ts and update wifi.d.ts file Signed-off-by: zhangfeng --- api/@ohos.wifi.d.ts | 183 +++++++++++++++++++++++++++++++++++++++-- api/@ohos.wifiext.d.ts | 101 +++++++++++++++++++++++ 2 files changed, 278 insertions(+), 6 deletions(-) create mode 100644 api/@ohos.wifiext.d.ts diff --git a/api/@ohos.wifi.d.ts b/api/@ohos.wifi.d.ts index b0301b8f43..f778a933ff 100644 --- a/api/@ohos.wifi.d.ts +++ b/api/@ohos.wifi.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { AsyncCallback, Callback } from "./basic"; +import { AsyncCallback, Callback } from './basic'; /** * Provides methods to operate or manage Wi-Fi. @@ -29,6 +29,7 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function enableWifi(): boolean; @@ -40,6 +41,7 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function disableWifi(): boolean; @@ -51,6 +53,7 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function isWifiActive(): boolean; @@ -63,6 +66,7 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.LOCATION */ function scan(): boolean; @@ -73,6 +77,8 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO, and at least one of the permissions of + * ohos.permission.GET_WIFI_PEERS_MAC and ohos.permission.LOCATION. */ function getScanInfos(): Promise>; function getScanInfos(callback: AsyncCallback>): void; @@ -87,11 +93,39 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.SET_WIFI_CONFIG * @systemapi Hide this for inner system use. */ function addDeviceConfig(config: WifiDeviceConfig): Promise; function addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; + /** + * Adds a specified untrusted hotspot configuration. + * + *

This method adds one configuration at a time. After this configuration is added, + * your device will determine whether to connect to the hotspot. + * + * @return Returns {@code true} if the untrusted hotspot configuration is added; returns {@code false} otherwise. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function addUntrustedConfig(config: WifiDeviceConfig): Promise; + function addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; + + /** + * Removes a specified untrusted hotspot configuration. + * + *

This method removes one configuration at a time. + * + * @return Returns {@code true} if the untrusted hotspot configuration is removed; returns {@code false} otherwise. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function removeUntrustedConfig(config: WifiDeviceConfig): Promise; + function removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; + /** * Connects to Wi-Fi network. * @@ -100,6 +134,7 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function connectToNetwork(networkId: number): boolean; @@ -112,6 +147,8 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.SET_WIFI_CONFIG, + * ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function connectToDevice(config: WifiDeviceConfig): boolean; @@ -123,6 +160,7 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function disconnect(): boolean; @@ -136,6 +174,7 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function getSignalLevel(rssi: number, band: number): number; @@ -145,6 +184,7 @@ declare namespace wifi { * @return Returns the Wi-Fi connection information. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function getLinkedInfo(): Promise; function getLinkedInfo(callback: AsyncCallback): void; @@ -155,6 +195,7 @@ declare namespace wifi { * @return Returns {@code true} if a Wi-Fi connection has been set up; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function isConnected(): boolean; @@ -166,6 +207,7 @@ declare namespace wifi { * @return Returns the features supported by this device. * @since 7 * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO * @systemapi Hide this for inner system use. */ function getSupportedFeatures(): number; @@ -177,6 +219,7 @@ declare namespace wifi { * @return Returns {@code true} if this device supports the specified feature; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO */ function isFeatureSupported(featureId: number): boolean; @@ -188,6 +231,7 @@ declare namespace wifi { * @return Returns the MAC address of the Wi-Fi device. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_LOCAL_MAC, ohos.permission.GET_WIFI_INFO * @systemapi Hide this for inner system use. */ function getDeviceMacAddress(): string[]; @@ -200,6 +244,7 @@ declare namespace wifi { * @return Returns the IP information of the Wi-Fi connection. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function getIpInfo(): IpInfo; @@ -209,6 +254,7 @@ declare namespace wifi { * @return Returns the country code of this device. * @since 7 * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO */ function getCountryCode(): string; @@ -218,6 +264,7 @@ declare namespace wifi { * @return {@code true} if the Wi-Fi network is re-associate successfully. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function reassociate(): boolean; @@ -228,6 +275,7 @@ declare namespace wifi { * @return {@code true} if the Wi-Fi network is re-connect successfully. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function reconnect(): boolean; @@ -240,6 +288,7 @@ declare namespace wifi { * @return Returns the list of all existing Wi-Fi configurations you created on your application. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, ohos.permission.GET_WIFI_CONFIG * @systemapi Hide this for inner system use. */ function getDeviceConfigs(): Array; @@ -253,6 +302,7 @@ declare namespace wifi { * returns {@code -1} if the specified Wi-Fi configuration is not contained in the list. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.SET_WIFI_CONFIG * @systemapi Hide this for inner system use. */ function updateNetwork(config: WifiDeviceConfig): number; @@ -266,6 +316,7 @@ declare namespace wifi { * @return Returns {@code true} if the specified network is disabled; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function disableNetwork(netId: number): boolean; @@ -277,6 +328,7 @@ declare namespace wifi { * returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function removeAllNetwork(): boolean; @@ -293,6 +345,7 @@ declare namespace wifi { * @return Returns {@code true} if the Wi-Fi network is deleted successfully; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. */ function removeDevice(id: number): boolean; @@ -305,6 +358,7 @@ declare namespace wifi { * @return Returns {@code true} if this method is called successfully; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. */ function enableHotspot(): boolean; @@ -317,16 +371,29 @@ declare namespace wifi { * @return Returns {@code true} if this method is called successfully; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. */ function disableHotspot(): boolean; + /** + * Checks whether a device serving as a Wi-Fi hotspot supports both the 2.4 GHz and 5 GHz Wi-Fi. + * + * @return Returns {@code true} if the method is called successfully; returns {@code false} otherwise. + * @since 7 + * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.GET_WIFI_INFO, ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function isHotspotDualBandSupported(): boolean; + /** * Checks whether Wi-Fi hotspot is active on a device. * * @return Returns {@code true} if Wi-Fi hotspot is enabled; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.GET_WIFI_INFO * @systemapi Hide this for inner system use. */ function isHotspotActive(): boolean; @@ -342,6 +409,7 @@ declare namespace wifi { * @return Returns {@code true} if the method is called successfully; returns {@code false} otherwise. * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.SET_WIFI_INFO, ohos.permission.GET_WIFI_CONFIG * @systemapi Hide this for inner system use. */ function setHotspotConfig(config: HotspotConfig): boolean; @@ -352,6 +420,7 @@ declare namespace wifi { * @return Returns the configuration of an existing or enabled Wi-Fi hotspot. * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_CONFIG * @systemapi Hide this for inner system use. */ function getHotspotConfig(): HotspotConfig; @@ -364,6 +433,7 @@ declare namespace wifi { * @return Returns the list of clients that are connected to the Wi-Fi hotspot. * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. */ function getStations(): Array; @@ -480,6 +550,7 @@ declare namespace wifi { * @return Returns 0: inactive, 1: active, 2: activating, 3: deactivating * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function on(type: "wifiStateChange", callback: Callback): void; @@ -490,6 +561,7 @@ declare namespace wifi { * * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function off(type: "wifiStateChange", callback?: Callback): void; @@ -499,6 +571,7 @@ declare namespace wifi { * @return Returns 0: disconnected, 1: connected * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function on(type: "wifiConnectionChange", callback: Callback): void; @@ -509,6 +582,7 @@ declare namespace wifi { * * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function off(type: "wifiConnectionChange", callback?: Callback): void; @@ -518,6 +592,7 @@ declare namespace wifi { * @return Returns 0: scan fail, 1: scan success * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function on(type: "wifiScanStateChange", callback: Callback): void; @@ -528,6 +603,7 @@ declare namespace wifi { * * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function off(type: "wifiScanStateChange", callback?: Callback): void; @@ -537,6 +613,7 @@ declare namespace wifi { * @return Returns RSSI value in dBm * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function on(type: "wifiRssiChange", callback: Callback): void; @@ -547,15 +624,40 @@ declare namespace wifi { * * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO */ function off(type: "wifiRssiChange", callback?: Callback): void; + /** + * Subscribe Wi-Fi stream change events. + * + * @return Returns 0: stream none, 1: stream down, 2: stream up, 3: stream bidirectional + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function on(type: "streamChange", callback: Callback): void; + + /** + * Unsubscribe Wi-Fi stream change events. + * + *

All callback functions will be deregistered If there is no specific callback parameter.

+ * + * @since 7 + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function off(type: "streamChange", callback?: Callback): void; + /** * Subscribe Wi-Fi hotspot state change events. * * @return Returns 0: inactive, 1: active, 2: activating, 3: deactivating * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.GET_WIFI_INFO */ function on(type: "hotspotStateChange", callback: Callback): void; @@ -566,6 +668,7 @@ declare namespace wifi { * * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.GET_WIFI_INFO */ function off(type: "hotspotStateChange", callback?: Callback): void; @@ -575,6 +678,7 @@ declare namespace wifi { * @return Returns StationInfo * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. */ function on(type: "hotspotStaJoin", callback: Callback): void; @@ -586,6 +690,7 @@ declare namespace wifi { * * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. */ function off(type: "hotspotStaJoin", callback?: Callback): void; @@ -596,6 +701,7 @@ declare namespace wifi { * @return Returns {@link #StationInfo} object * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. */ function on(type: "hotspotStaLeave", callback: Callback): void; @@ -606,6 +712,7 @@ declare namespace wifi { * @return Returns {@link #StationInfo} object * @since 7 * @syscap SystemCapability.Communication.WiFi.AP + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. */ function off(type: "hotspotStaLeave", callback?: Callback): void; @@ -733,7 +840,48 @@ declare namespace wifi { isHiddenSsid: boolean; /** Security type: reference definition of WifiSecurityType */ - securityType: number; + securityType: WifiSecurityType; + + /** The UID of the Wi-Fi configuration creator */ + /* @systemapi */ + creatorUid: number; + + /** Disable reason */ + /* @systemapi */ + disableReason: number; + + /** Allocated networkId */ + /* @systemapi */ + netId: number; + + /** Random mac type */ + /* @systemapi */ + randomMacType: number; + + /** Random mac address, the length is 6 */ + /* @systemapi */ + randomMacAddr: string; + + /** IP Type */ + /* @systemapi */ + ipType: IpType; + + /** IP config of static */ + /* @systemapi */ + staticIp: IpConfig; + } + + /** + * Wi-Fi IP configuration information. + * + * @since 7 + * @systemapi + */ + interface IpConfig { + ipAddress: number; + gateway: number; + dnsServers: number[]; + domains: Array; } /** @@ -748,8 +896,11 @@ declare namespace wifi { /** Wi-Fi bssid(MAC): the length is 6 */ bssid: string; + /** Hotspot capability */ + capabilities: string; + /** Security type: reference definition of WifiSecurityType */ - securityType: number; + securityType: WifiSecurityType; /** Received signal strength indicator (RSSI) */ rssi: number; @@ -760,6 +911,9 @@ declare namespace wifi { /** Frequency */ frequency: number; + /** Channel width */ + channelWidth: number; + /** Time stamp */ timestamp: number; } @@ -910,6 +1064,23 @@ declare namespace wifi { ipAddress: string; } + /** + * Wi-Fi IP type enumeration. + * + * @since 7 + * @systemapi + */ + enum IpType { + /** Use statically configured IP settings */ + STATIC, + + /** Use dynamically configured IP settings */ + DHCP, + + /** No IP details are assigned */ + UNKNOWN, + } + /** * The state of the supplicant enumeration. * @@ -1017,15 +1188,15 @@ declare namespace wifi { deviceAddress: string; /** - * Specifies whether the P2P group of this {@code WifiP2pConfig} instance is persistent - * -1: temporary, -2: persistent + * Group network ID. When creating a group, -1 indicates creates a temporary group, + * -2: indicates creates a persistent group */ netId: number; /* The passphrase of this {@code WifiP2pConfig} instance */ passphrase: string; - /** Group name */ + /** Group name */ groupName: string; /** Group owner band */ diff --git a/api/@ohos.wifiext.d.ts b/api/@ohos.wifiext.d.ts new file mode 100644 index 0000000000..eaad6e06a8 --- /dev/null +++ b/api/@ohos.wifiext.d.ts @@ -0,0 +1,101 @@ +/* + * 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'; + +/** + * Provides extended methods to operate or manage Wi-Fi. + * + *

The APIs involved in this file are non-general APIs. + * These extended APIs are only used by some product types, such as routers. + * Common products should not use these APIs.

+ * + * @since 8 + * @import import wifiext from '@ohos.wifiext'; + */ +declare namespace wifiext { + /** + * Enables a Wi-Fi hotspot. + * + * @return Returns {@code true} if this method is called successfully; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.HotspotExt + */ + function enableHotspot(): boolean; + + /** + * Disables a Wi-Fi hotspot. + * + * @return Returns {@code true} if this method is called successfully; returns {@code false} otherwise. + * @since 8 + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.HotspotExt + */ + function disableHotspot(): boolean; + + /** + * Obtains the supported power model. + * + * @return Returns the array of supported power model. + * + * @since 8 + * @permission ohos.permission.GET_WIFI_INFO + * @syscap SystemCapability.Communication.WiFi.HotspotExt + */ + function getSupportedPowerModel(): Promise>; + function getSupportedPowerModel(callback: AsyncCallback>): void; + + /** + * Obtains the current Wi-Fi power mode. + * + * @return Returns the current Wi-Fi power mode. If a value less than zero is returned, it indicates a failure. + * + * @since 8 + * @permission ohos.permission.GET_WIFI_INFO + * @syscap SystemCapability.Communication.WiFi.HotspotExt + */ + function getPowerModel (): Promise; + function getPowerModel (callback: AsyncCallback): void; + + /** + * Set the current Wi-Fi power mode. + * + * @return Returns {@code true} if the Wi-Fi is active; returns {@code false} otherwise. + * + * @since 8 + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.HotspotExt + */ + function setPowerModel(model: PowerModel) : boolean + + /** + * The power model enumeration. + * + * @since 8 + */ + export enum PowerModel { + /** Sleeping model. */ + SLEEPING = 0, + + /** General model. */ + GENERAL = 1, + + /** Through wall model. */ + THROUGH_WALL = 2, + } +} + +export default wifiext; -- Gitee