openharmony 鸿蒙 changelogs-access_token

2025-06-16 浏览 (1)

程序访问子系统变更说明

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

访问级别

公开接口

变更原因

根据安全隐私要求,地理位置支持使用期间允许的管控能力。位置权限申请使用时,禁止通过弹窗形式授予后台位置权限;

应用如需使用后台位置权限,需要在设置界面由用户手动授予,具体授权方式请参考下文【适配指导】

变更影响

涉及权限:

前台位置权限(用于管控应用前台获取位置信息行为):

精确位置权限:ohos.permission.LOCATION:允许应用获取设备精确位置信息;需要先申请模糊位置权限才可申请此权限。

模糊位置权限:ohos.permission.APPROXIMATELY_LOCATION:允许应用获取设备模糊位置信息。

后台位置权限(用于管控应用后台获取位置信息行为):

ohos.permission.LOCATION_IN_BACKGROUND:允许应用在后台运行时获取设备位置信息;需要先申请前台位置权限后,才可申请此权限。

具体受影响的弹窗场景见下文:

a) 应用仅申请后台位置权限(前台位置权限未弹窗申请)

变更前:弹出弹窗,点击允许可授予后台位置权限

变更后:不弹窗,不授予后台位置权限

b) 应用仅申请后台位置权限(前台位置权限已授予)

变更前:不弹窗,后台位置权限在第一次授予前台位置权限时同时授予

变更后:不弹窗,不授予后台位置权限

c) 应用同时申请前台位置和后台位置权限

变更前:弹窗展示允许和拒绝选项,选择允许则授予前台位置+后台位置权限

变更后:

API 10及以前:弹窗展示使用期间允许和拒绝选项,选择使用期间允许,仅授予前台位置权限;

API 11及以后:不弹窗,不授予前台位置和后台位置权限

API level

9

变更发生版本

从OpenHarmony SDK 4.1.5.3开始。

变更的接口/组件

@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')

适配指导

1、应用在requestPermissionsFromUser接口中同时申请前台、后台位置权限

a) 排查应用是否需要后台位置权限,如需要,将接口申请权限行为更改为单独申请前台位置权限

    由:atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION', 'ohos.permission.LOCATION_IN_BACKGROUND'], ......)
    更改为:atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION'], ......)

    或由:atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION_IN_BACKGROUND'], ......)
    更改为:atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION'], ......)

b) 当用户点击弹窗授予前台位置权限后,应用通过弹窗、提示窗等形式告知用户前往设置界面

c) 用户在设置界面选择【始终允许】选项,手动授予后台位置权限

2、应用仅在requestPermissionsFromUser接口中申请后台位置权限

a) 排查应用是否需要后台位置权限,如需要,需要先弹窗申请前台位置权限(后台位置权限仅在前台位置权限生效情况下才能够使用)

    由:atManager.requestPermissionsFromUser(context, ['ohos.permission.LOCATION_IN_BACKGROUND'], ......)
    更改为:atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION'], ......)

    或由:atManager.requestPermissionsFromUser(context, ['ohos.permission.LOCATION_IN_BACKGROUND'], ......)
    更改为:atManager.requestPermissionsFromUser(context, ['ohos.permission.APPROXIMATELY_LOCATION'], ......)

b) 参考情况1

接口使用的示例代码可参考requestPermissionsFromUser接口指导

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI子系统变更说明

harmony 鸿蒙安全子系统-密钥管理服务变更说明

harmony 鸿蒙测试子系统ChangeLog

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