在跑CTS时遇到如下问题:
run cts-on-gsi -m CtsAppTestCases -t android.app.cts.SystemFeaturesTest#testCameraFeatures
报错如下:
12-14 21:21:17 I/ModuleListener: [1/1] android.app.cts.SystemFeaturesTest#testCameraFeatures FAILURE: java.lang.AssertionError: PackageManager#hasSystemFeature should return true for android.hardware.camera.autofocus
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at android.app.cts.SystemFeaturesTest.assertAvailable(SystemFeaturesTest.java:640)
at android.app.cts.SystemFeaturesTest.checkRearCamera(SystemFeaturesTest.java:273)
at android.app.cts.SystemFeaturesTest.testCameraFeatures(SystemFeaturesTest.java:170)
at java.lang.reflect.Method.invoke(Native Method)
这个问题是hardware 支持autofocus的情况下,PMS判断自己不支持导致。
分析过程如下:
根据CTS app 代码逻辑。
检查后置摄像头支持自动对焦模式
这个错误表示后置摄像头应该支持自动对焦,但是通过packageManager hasSystemFeature接口却没有找到这个feature
以方案一是直接在/hardware/rockchip/camera/etc/camera/camera3_profiles.xml 中去掉auto配置,验证pass。
但是这种方法不符和需求。
方案二是添加上功能autofucus feature,PMS会去加载有那些feature,加载的结果可以通过adb shell pm list features 查看。通过命令没有发现feature:android.hardware.camera.autofocus
PMS主要是加载并解析设备目录下vendor/etc/permissions 的配置文件,解析后保存到到mAvailableFeatures,mAvailableFeatures本质上是个map。
/frameworks/base/core/java/com/android/server/SystemConfig.java
//加载xml文件
495 readPermissions(Environment.buildPath(
496 Environment.getOdmDirectory(), “etc”, “sysconfig”), odmPermissionFlag);
497 readPermissions(Environment.buildPath(
498 Environment.getOdmDirectory(), “etc”, “permissions”), odmPermissionFlag);
499
//解析feature标签
case “feature”: {
746 if (allowFeatures) {
747 String fname = parser.getAttributevalue(null, “name”);
748 int fversion = XmlUtils.readIntAttribute(parser, “version”, 0);
749 boolean allowed;
750 if (!lowRam) {
751 allowed = true;
752 } else {
753 String notLowRam = parser.getAttributevalue(null, “notLowRam”);
754 allowed = !“true”.equals(notLowRam);
755 }
756 if (fname == null) {
757 Slog.w(TAG, “<” + name + "> without name in " + permFile + " at "
758 + parser.getPositionDescription());
759 } else if (allowed) {
760 addFeature(fname, fversion);
761 }
762 } else {
763 logNotAllowedInPartition(name, permFile, parser);
764 }
765 XmlUtils.skipCurrentTag(parser);
766 } break;
//在map中添加这个feature
1228 private void addFeature(String name, int version) {
1229 FeatureInfo fi = mAvailableFeatures.get(name);
1230 if (fi == null) {
1231 fi = new FeatureInfo();
1232 fi.name = name;
1233 fi.version = version;
1234 mAvailableFeatures.put(name, fi);
1235 } else {
1236 fi.version = Math.max(fi.version, version);
1237 }
1238 }
1239
adb shell进去发现这个目录下不存在android.hardware.camera.autofocus.xml。
而代码路径下存在frameworks/native/data/etc/android.hardware.camera.autofocus.xml。
在devices下可以搜索“android.hardware.camera.autofocus.xml”,如下
device/rockchip/common/device_tab10_rk66.mk
463 # Camera Autofocus
464 ifeq (KaTeX parse error: Undefined control sequence: at position 61: …_COPY_FILES += ̲ ̲ 466 framewo…(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.autofocus.xml
467
468 endif
可以发现有拷贝这个xml文件的配置,所以只需要将CAMERA_SUPPORT_AUTOFOCUS 这个变量设置为true验证pass
这里需要和硬件及驱动同事确认设备所支持的硬件,如果不支持(如陀螺仪,、BLE 、NFC、Camera等),软件上一定
要移除。可以通过以下的宏控制,没有宏的,需要到 frameworks/native/data/etc/ 下将对应的
feature.xml 删除。



