錯誤如下
| -- testSensorFeatures |
fail |
junit.framework.AssertionFailedError: PackageManager#hasSystemFeature(android.hardware.sensor.gyroscope) returns false but SensorManager#getSensorList(4) shows sensors [MPL Gyroscope, MPL Raw Gyroscope, Corrected Gyroscope Sensor] expected:<false> but was:<true>at android.app.cts.SystemFeaturesTest.assertFeatureForSensor(SystemFeaturesTest.java:300) |
分析:硬體和軟體上實際已經支援該sensor(gyroscope)。只是CTS報錯而已。看來應該什麼地方出現匹配問題了。
穀了一下歌,就明白了。
/system/etc/permissions/目錄中需要包含這些硬體對應的xml檔案。cts測試時會基於這些檔案檢查sensor list是否和這個匹配。
上述錯誤就是因為在/system/etc/permissions/目錄中沒有檢查到gyroscope的對應檔案,而在sensor list中卻發現有這個sensor存在。所以報錯!
解決,既然的確有這個sensor存在,那就在/system/etc/permissions/中加入這個sensor對應的xml檔案即可。
這些檔案都在 frameworks/native/data/etc/中。只要在base.mk檔案中加入這樣的拷貝動作即可。
diff --git a/aaxxxxbb/base.mk b/aaxxxxbb/base.mk
index 77cc195..0157f0e 100755
--- a/aaxxxxbb/base.mk
+++ b/aaxxxxbb/base.mk
@@ -117,6 +117,7 @@ PRODUCT_COPY_FILES := \
frameworks/native/data/etc/android.hardware.sensor.proximity.xml:system/etc/permissions/android.hardware.sensor.proximity.xml \
frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml \
frameworks/native/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.sensor.compass.xml \
+ frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:system/etc/permissions/android.hardware.sensor.gyroscope.xml \
frameworks/native/data/etc/android.hardware.touchscreen.multitouch.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.xml \
frameworks/native/data/etc/android.hardware.touchscreen.xml:system/etc/permissions/android.hardware.touchscreen.xml \
frameworks/native/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml \