转载自:http://m.blog.csdn.net/article/details?id=52593684
DESCRIPTION]
DESCRIPTION]
在分析NE时,可能会遇到SensorService部分的NE,NE log如下:
Abort message: 'VALUE& android::KeyedVector<KEY, VALUE>::editValueFor(const KEY&) [with KEY = int; VALUE = android::SensorDevice::Info]: key not found'
backtrace:
#00 pc 0003d480 /system/lib/libc.so (tgkill+12)
#01 pc 00016959 /system/lib/libc.so (pthread_kill+52)
#02 pc 0001756f /system/lib/libc.so (raise+10)
#03 pc 00013ea5 /system/lib/libc.so (__libc_android_abort+36)
#04 pc 00012524 /system/lib/libc.so (abort+4)
#05 pc 000083e9 /system/lib/libcutils.so (__android_log_assert+88)
#06 pc 00007a3b /system/lib/libsensorservice.so
#07 pc 00008087 /system/lib/libsensorservice.so
#00 pc 0003d480 /system/lib/libc.so (tgkill+12)
#01 pc 00016959 /system/lib/libc.so (pthread_kill+52)
#02 pc 0001756f /system/lib/libc.so (raise+10)
#03 pc 00013ea5 /system/lib/libc.so (__libc_android_abort+36)
#04 pc 00012524 /system/lib/libc.so (abort+4)
#05 pc 000083e9 /system/lib/libcutils.so (__android_log_assert+88)
#06 pc 00007a3b /system/lib/libsensorservice.so
#07 pc 00008087 /system/lib/libsensorservice.so
[ANALYSIS]
Google默认设计的sensorService中,判定当从hal层获取到的sensorlist中有gyrosensor时,就会注册虚拟的sensor type, (这里以RotationVectorSenso为例)
![](https://onlinesso.mediatek.com/FAQ%20PDF%20Picture%20Library/2015/0521//635677094804928647747371472%E6%97%A0%E6%A0%87%E9%A2%98.png)
虚拟的sensor type去使能的时候就会去使能acc sensor,mag sensor,gyro sensor 3个实体sensor。此时若acc sensor 或者mag sensor不在HAL的sensor list中,则就会出现NE (这里以RotationVectorSenso为例)
![](https://onlinesso.mediatek.com/FAQ%20PDF%20Picture%20Library/2015/0521//6356770983010365921220134708%E6%97%A0%E6%A0%87%E9%A2%98.png)
[ROOT CAUSE]
▪Case1:客户实际上没有gyro sensor,但却在ProjectConfig.mk文件中配置了gyro sensor
▪Case2:客户实际上有gyro sensor,没有mag sensor。配置也正确。
[SOLUTION]
对于case1:
正确配置ProjectConfig.mk文件中的gyro sensor即可。
对于case2:
请按照下面的方法修改:
修改alps\frameworks\native\services\sensorservice\SensorService.cpp的OnFisrtRef()方法
![](https://onlinesso.mediatek.com/FAQ%20PDF%20Picture%20Library/2015/0521//63567717131212141842355020%E6%97%A0%E6%A0%87%E9%A2%98.png)
备注:
这里的修改只是针对project中没有mag sensor的情况。