手上的 vivo x9 手機感測器模式下的旋轉效果有誤,經查發現是 Gravity sensor 返回的數據有誤,和其他機型返回的數據相反的。 參考 Gravity 的說明: A three dimensional vector indicating the direction and magnit ...
手上的 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)