VIVO 手机重力传感器踩坑记录

手上的 vivo-x9 手机传感器模式下的旋转效果有误,经查发现是 Gravity sensor 返回的数据有误,和其他机型返回的数据相反的。

参考 Gravity 的说明:

A three dimensional vector indicating the direction and magnitude of gravity. Units are m/s^2. The coordinate system is the same as is used by the acceleration sensor.

Note: When the device is at rest, the output of the gravity sensor should be identical to that of the accelerometer.

正常来说,当手机竖着拿着,屏幕与地球引力差不多平行時,获取到的重力分量主要集中在 y 分量,接近重力加速度 g = 9.80665 m/s2. 当手机保持屏幕和引力平行,但是横置,头朝左,navigation bar 在右侧的时候,在 iOS 的逻辑里面是称为 DEVICE_LANDSCAPE_LEFT 自然另一种横置的方式就叫做 DEVICE_LANDSCAPE_RIGHT. 在 LEFT 模式下,重力加速度主要体现在 x 分量,但是在这个 VIVO 手机上,虽说也是体现在 x 分量,但是却是相反的,x 分量接近 -9.8 m/s2. 同样,z 分量也有一样问题, y 分量正常。

解决方案只能针对性修改了,根据 log 可知硬件传感器型号:

I/InteractControl: Gravity sensor akm Version 2
I/InteractControl: Game rotation sensor vendor: AOSP Version: 3

见了这个绕着走就是了。(垃圾 vivo)

posted @ 2018-02-07 16:45  皮斯卡略夫  阅读(1026)  评论(0编辑  收藏  举报