CTS: testSensorFeatures FAIL 的解決

來源:互聯網
上載者:User

錯誤如下

-- 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 \

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.