Android 11 camera系统调试总结

本文详细介绍了Android11中新增的系统相机权限android.permission.SYSTEM_CAMERA及其使用方法,并探讨了如何通过白名单机制使应用获得该权限。此外,还讨论了另一权限CAMERA_OPEN_CLOSE_LISTENER的作用及其实现步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

camera2 debug

问题1

ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10134 pid=3155

原因
在搭载 Android 11 或更高版本的设备上,Android 框架支持系统相机,这些相机设备仅对具有 android.permission.SYSTEM_CAMERA 权限和常规相机权限的进程可见。Android 11 中引入了 android.permission.SYSTEM_CAMERA 权限,其保护级别为 system|signature。

如需创建有权访问系统相机的应用,必须在特定于设备的 privapp-permissions.xml 文件中将相应应用列入白名单,该文件用于指定必须向哪些应用授予 android.permission.SYSTEM_CAMERA 权限。

解决
frameworks/base/data/etc/privapp-permissions-platform.xml

+    <privapp-permissions package="com.android.camera2">
+               <permission name="android.permission.SYSTEM_CAMERA"/>
+       </privapp-permissions>

google官方介绍

问题2

 ServiceManager: Permission failure: android.permission.CAMERA_OPEN_CLOSE_LISTENER from uid=1010134 pid=5380

由来

 New system permissions to bypass audio recording restrictions and monitor camera openings
The tech company has added system-level permissions to the framework of Android 11 Developer Preview 3: EXEMPT_FROM_AUDIO_RECORD_RESTRICTIONS and CAMERA_OPEN_CLOSE_LISTENER.

The former requires a privileged or signature permission level. The latter, on the other hand, is strictly signature only.

The description for the former states that it is intended for systems app to bypass limitations of existing audio recording APIs. This will then be helpful in implementing Live Captions for phone calls.

Furthermore, the latter will allow the system apps to monitor when the camera session starts or ends. This setting may be used to implement new privacy features in future developments.

Google 在 Android 11 Developer Preview 3 的框架中添加了两个系统级限制:EXEMPT_FROM_AUDIO_RECORD_RESTRICTIONS 和 CAMERA_OPEN_CLOSE_LISTENER。 前者需要特权或签名权限级别,而后者只需要严格签名。 前者的描述指出,它旨在让系统应用程序绕过现有录音 API 的限制,我们认为这将有助于实现电话实时字幕。 后者将允许系统应用程序监控摄像头会话何时开始或结束,这可用于在未来版本中实现新的隐私功能。
解决:
需要增加系统签名,我们采用以下办法验证ok。

1. 在应用程序的AndroidManifest.xml中的manifest节点中加入android:sharedUserId="android.uid.system"这个属性。               

2. 修改Android.mk文件,加入LOCAL_CERTIFICATE := platform这一行
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值