openharmony 鸿蒙 changelogs-access_token

2023-10-30 浏览 (384)

程序访问子系统变更说明

cl.access_token.1 requestPermissionsFromUser申请位置权限时行为变更

访问级别

公开接口

变更原因

该变更为非兼容性变更。根据安全隐私要求,位置权限申请使用时,申请精确/后台位置权限,要同时申请模糊权限。

变更影响

变更前,通过调用requestPermissionsFromUser接口申请位置权限,如下两种申请情况都可以顺利拉起弹窗:

1、在未申请模糊权限ohos.permission.APPROXIMATELY_LOCATION的情况下,请求后台位置权限ohos.permission.LOCATION_IN_BACKGROUND

2、在未申请模糊权限ohos.permission.APPROXIMATELY_LOCATION的情况下,同时请求后台位置权限ohos.permission.LOCATION_IN_BACKGROUND及精准权限ohos.permission.LOCATION

变更后,上述两种情况将无法拉起弹窗授予权限。应用在申请精准权限或后台权限时,必须同时申请模糊权限。

变更发生版本

从OpenHarmony SDK 4.1.1.5开始。

变更的接口/组件

@ohos.abilityAccessCtrl.d.ts中requestPermissionsFromUser接口,使用该接口申请位置权限的应用,在申请精准权限或后台权限时,必须同时申请模糊权限。

可能影响接口

文件方法
@ohos.geolocation.d.tsgeolocation.on('locationChange')
@ohos.geolocation.d.tsgeolocation.off('locationChange')
@ohos.geolocation.d.tsgeolocation.on('locationServiceState')
@ohos.geolocation.d.tsgeolocation.off('locationServiceState')
@ohos.geolocation.d.tsgeolocation.on('cachedGnssLocationsReporting')
@ohos.geolocation.d.tsgeolocation.off('cachedGnssLocationsReporting')
@ohos.geolocation.d.tsgeolocation.on('gnssStatusChange')
@ohos.geolocation.d.tsgeolocation.off('gnssStatusChange')
@ohos.geolocation.d.tsgeolocation.on('nmeaMessageChange')
@ohos.geolocation.d.tsgeolocation.off('nmeaMessageChange')
@ohos.geolocation.d.tsgeolocation.on('fenceStatusChange')
@ohos.geolocation.d.tsgeolocation.off('fenceStatusChange')
@ohos.geolocation.d.tsgeolocation.getCurrentLocation
@ohos.geolocation.d.tsgeolocation.getLastLocation
@ohos.geolocation.d.tsgeolocation.isLocationEnabled
@ohos.geolocation.d.tsgeolocation.requestEnableLocation
@ohos.geolocation.d.tsgeolocation.isGeoServiceAvailable
@ohos.geolocation.d.tsgeolocation.getAddressesFromLocation
@ohos.geolocation.d.tsgeolocation.getAddressesFromLocationName
@ohos.geolocation.d.tsgeolocation.getCachedGnssLocationsSize
@ohos.geolocation.d.tsgeolocation.flushCachedGnssLocations
@ohos.geolocation.d.tsgeolocation.sendCommand
@ohos.geolocation.d.tsSatelliteStatusInfo
@ohos.geolocation.d.tsCachedGnssLocationsRequest
@ohos.geolocation.d.tsGeofenceRequest
@ohos.geolocation.d.tsGeofence
@ohos.geolocation.d.tsReverseGeoCodeRequest
@ohos.geolocation.d.tsGeoCodeRequest
@ohos.geolocation.d.tsGeoAddress
@ohos.geolocation.d.tsLocationRequest
@ohos.geolocation.d.tsCurrentLocationRequest
@ohos.geolocation.d.tsLocation
@ohos.geoLocationManager.d.tsgeoLocationManager.on('nmeaMessage')
@ohos.geoLocationManager.d.tsgeoLocationManager.off('nmeaMessage')
@ohos.geoLocationManager.d.tsgeoLocationManager.on('locatingRequiredDataChange')
@ohos.geoLocationManager.d.tsgeoLocationManager.off('locatingRequiredDataChange')
@ohos.geoLocationManager.d.tsgeoLocationManager.getLocatingRequiredData
@ohos.bluetooth.d.tsbluetooth.startBluetoothDiscovery
@ohos.bluetooth.d.tsstartBLEScan
@ohos.bluetoothManager.d.tsbluetoothManager.startBluetoothDiscovery
@ohos.bluetoothManager.d.tsstartBLEScan
@ohos.telephony.observer.d.tsobserver.on('cellInfoChange')
@ohos.telephony.radio.d.tsradio.sendUpdateCellLocationRequest
@ohos.telephony.radio.d.tsradio.getCellInformation
@system.geolocation.d.tsGetLocationOption
@system.geolocation.d.tsSubscribeLocationOption
@system.geolocation.d.tsgeolocation.getLocation
@system.geolocation.d.tsgeolocation.subscribe
@system.geolocation.d.tsgeolocation.unsubscribe
@ohos.wifi.d.tswifi.scan
@ohos.wifi.d.tswifi.getScanInfos
@ohos.wifi.d.tswifi.getDeviceConfigs
@ohos.wifi.d.tswifi.getStations
@ohos.wifi.d.tswifi.getCurrentGroup
@ohos.wifi.d.tswifi.getP2pPeerDevices
@ohos.wifi.d.tswifi.p2pConnect
@ohos.wifi.d.tswifi.startDiscoverDevices
@ohos.wifi.d.tswifi.on('p2pDeviceChange')
@ohos.wifi.d.tswifi.off('p2pDeviceChange')
@ohos.wifi.d.tswifi.on('p2pPeerDeviceChange')
@ohos.wifi.d.tswifi.off('p2pPeerDeviceChange')
@ohos.wifiManager.d.tswifiManager.scan
@ohos.wifiManager.d.tswifiManager.getScanResults
@ohos.wifiManager.d.tswifiManager.getScanResultsSync
@ohos.wifiManager.d.tswifiManager.getCandidateConfigs
@ohos.wifiManager.d.tswifiManager.getDeviceConfigs
@ohos.wifiManager.d.tswifiManager.getStations
@ohos.wifiManager.d.tswifiManager.getCurrentGroup
@ohos.wifiManager.d.tswifiManager.getP2pPeerDevices
@ohos.wifiManager.d.tswifiManager.p2pConnect
@ohos.wifiManager.d.tswifiManager.startDiscoverDevices
@ohos.wifiManager.d.tswifiManager.getP2pGroups
@ohos.wifiManager.d.tswifiManager.on('p2pDeviceChange')
@ohos.wifiManager.d.tswifiManager.off('p2pDeviceChange')
@ohos.wifiManager.d.tswifiManager.on('p2pPeerDeviceChange')
@ohos.wifiManager.d.tswifiManager.off('p2pPeerDeviceChange')

适配指导

修改EntryAbility.ets和导入GlobalThis等步骤参考requestPermissionsFromUser

    let context: common.UIAbilityContext = GlobalThis.getInstance().getContext('context');
    atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION', 'ohos.permission.LOCATION_IN_BACKGROUND']).then((data) => {
        console.info('data:' + JSON.stringify(data));
    }).catch((err: BusinessError) => {
        console.info('data:' + JSON.stringify(err));
    })

你可能感兴趣的鸿蒙文章

harmony 鸿蒙包管理子系统ChangeLog

harmony 鸿蒙DFX子系统ChangeLog

harmony 鸿蒙网络子系统ChangeLog

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