openharmony 鸿蒙 changelogs-wifiManager

2023-02-17 浏览 (717)

Wi-Fi Subsystem ChangeLog

cl.location.1 Location Service Permission Change

From API version 9, the ohos.permission.APPROXIMATELY_LOCATION permission is added for obtaining the approximate location.

If you use API version 9 or later, you need to apply for both the ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION permissions. Applying for only the ohos.permission.LOCATION permission will fail.

Change Impacts

Applications using API versions earlier than 9 are not affected. For an application using API version 9 or later, the method for applying for the location permission is changed. The details are as follows:

Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user as described below.

The system provides the following location permissions:

  • ohos.permission.LOCATION

  • ohos.permission.APPROXIMATELY_LOCATION

  • ohos.permission.LOCATION_IN_BACKGROUND

If your application needs to access the device location information, it must first apply for required permissions. Specifically speaking:

API versions earlier than 9: Apply for ohos.permission.LOCATION.

API version 9 and later: Apply for ohos.permission.APPROXIMATELY_LOCATION, or apply for ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION. Note that ohos.permission.LOCATION cannot be applied for separately.

API VersionLocation PermissionPermission Application ResultLocation Accuracy
Earlier than 9ohos.permission.LOCATIONSuccessLocation accurate to meters
9 and laterohos.permission.LOCATIONFailureNo location obtained
9 and laterohos.permission.APPROXIMATELY_LOCATIONSuccessLocation accurate to 5 kilometers
9 and laterohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATIONSuccessLocation accurate to meters

If your application needs to access the device location information when running in the background, it must be configured to be able to run in the background and be granted the ohos.permission.LOCATION_IN_BACKGROUND permission. In this way, the system continues to report device location information after your application moves to the background.

You can declare the required permissions in your application's configuration file. For details, see the permission application guide.

Key API/Component Changes

ClassAPI TypeDeclarationChange Type
wifiManagermethodfunction scan(): void;The permission is changed to ohos.permission.SET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getScanResults(): Promise<Array<WifiScanInfo>>;The permission is changed to ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getScanResults(callback: AsyncCallback<Array<WifiScanInfo>>): void;The permission is changed to ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getScanResultsSync(): Array<WifiScanInfo>;The permission is changed to ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getCandidateConfigs(): Array<WifiDeviceConfig>;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getDeviceConfigs(): Array<WifiDeviceConfig>;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, ohos.permission.APPROXIMATELY_LOCATION, and ohos.permission.GET_WIFI_CONFIG.
wifiManagermethodfunction getStations(): Array<StationInfo>;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, ohos.permission.APPROXIMATELY_LOCATION, and ohos.permission.MANAGE_WIFI_HOTSPOT.
wifiManagermethodfunction getCurrentGroup(): Promise<WifiP2pGroupInfo>;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getP2pPeerDevices(): Promise<WifiP2pDevice[]>;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction p2pConnect(config: WifiP2PConfig): void;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction startDiscoverDevices(): void;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getP2pGroups(): Promise<Array<WifiP2pGroupInfo>>;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>>): void;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void;The permission is changed to ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void;The permission is changed to ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION.
wifiManagermethodfunction off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): void;The permission is changed to ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Location Subsystem ChangeLog

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/7452d7c72151420aab6263753ae3299b