咨询下自启系统服务中如何申请权限?
柳翔天 2024-01-29 15:59:11
我在module.json中已经申请`ohos.permission.ACCESS_SCREEN_LOCK_INNER`权限,但运行时调用相关接口时仍然报错
01-29 15:50:31.626 4001 4001 I A03d00/JSAPP: [FakeLockService] registerCallback
01-29 15:50:31.626 4001 4001 I C01510/IPCObjectStub: 63: create, desc: OHOS.ScreenLock.ScreenLockSystemAbilityInterface
01-29 15:50:31.627 4001 4001 W C01510/IPCObjectStub: 68: destroy, desc: OHOS.ScreenLock.ScreenLockSystemAbilityInterface
01-29 15:50:31.627 3331 3953 I C01510/IPCObjectProxy: 58: handle = 166 create, descriptor: IPCObjectProxy166
01-29 15:50:31.627 3331 3953 I C01c00/SclockKit: [screenlock_system_ability.cpp(OnSystemEvent:442)]ScreenLockSystemAbility::OnSystemEvent started.
01-29 15:50:31.628 3331 3953 E C01c00/SclockKit: [screenlock_system_ability.cpp(CheckPermission:691)]check permission failed.
01-29 15:50:31.628 3331 3953 W C01510/IPCObjectProxy: 63: handle = 166 destroyed, descriptor: IPCObjectProxy166
01-29 15:50:31.628 4001 4001 E C03f00/ArkCompiler: [ecmascript] pending exception before jsnapi interface called, which is New in line: 1183
01-29 15:50:31.628 4001 4001 E C03f00/ArkCompiler: [ecmascript] print exception info:
01-29 15:50:31.628 4001 4001 E C03f00/ArkCompiler: Error: Permission verification failed.
01-29 15:50:31.628 4001 4001 E C03f00/ArkCompiler: at registerCallback (entry/src/main/ets/module/FakeLockService.ts:16:25)
01-29 15:50:31.628 4001 4001 E C03f00/ArkCompiler: at callback (entry/src/main/ets/module/FakeLockService.ts:32:17)
01-29 15:50:31.628 4001 4001 E C03f00/ArkCompiler: at anonymous (entry/src/main/ets/module/FakeLockService.ts:25:30)
01-29 15:50:31.628 4001 4001 E A03d00/JSAPP: [FakeLockService] on callback error -> {"code":201}
查询了下源码,在screenlock_system_ability.cpp 中在 ScreenLockSystemAbility::OnSystemEvent()中申请的权限确实是`ohos.permission.ACCESS_SCREEN_LOCK_INNER`
附件为完整项目文件
您需要先 登录 才能评论/回答
全部评论(13)
ACCESS_SCREEN_LOCK_INNER的权限级别是system_core,确保你的签名是这个级别的
赞
2024-01-29 16:45:59
引用:“我把文件下载后推送个install_list_capability.json后重启安装就成功了。。。啥也没改”
install_list_capability.json 以及获取、推送这个文件的bat脚本,都在压缩报里面。文件在压缩包根目录,脚本在script文件夹里,看起来都没问题啊。。
赞
引用:“试了下,把sdk从API9改成10就好了,怪了”
我把文件下载后推送个install_list_capability.json后重启安装就成功了。。。啥也没改
赞
引用:“签名可参考:https://laval.csdn.net/656adadeb2e09e652cbf377a.html?login=from_csdn#devmenu8”
看了下签名文件,确实没错
赞
查看全部12条回复
查看全部13条回答/评论