关于android2.3调试g-sensor
2012-02-16 15:59
495 查看
关于android2.3调试g-sensor
由于工作上的需要,特地写了这么一份关于调试g-sensor的内容.1.首先确定你要调试的设备的屏幕的横竖屏如何设置。
在代码中我们主要的流程如下:
os 启动后 :
WindowManagerService.java中ENABLE_SCREEN
–>performEnableScreen()
–>mPolicy.enableScreenAfterBoot()/setRotation()
–>setRotationUnchecked()
–>PhoneWindowManager.java中的rotationForOrientationLw()
–>Surface.setOrientation()
基本上流程就是如上,只要稍微跟踪一下就可以了。
下面大概对上面主要code进行注释说明:
?
在setRotationUncheckedLocked()中的 mPolicy.rotationForOrientationLw()如是:
?
主要流程如下:
–>WindowOrientationListener.java中的onSensorChanged()
–>computeNewOrientation()
–>filterOrientation()
–>calculateNewRotation()
calculateNewRotation()
–>mOrientationListener.onOrientationChanged()
PhoneWindowManager.java 中的onOrientationChanged()
–>mWindowManager.setRotation()
首先在android中的x,y,z定义如下摘自http://developer.android.com/reference/android/hardware/SensorEvent.html :
Class Overview
This class represents a Sensor event and holds informations such as the sensor’s type, the time-stamp, accuracy and of course the sensor’s data.
Definition of the coordinate system used by the SensorEvent API.
The coordinate-system is defined relative to the screen of the phone in its default orientation. The axes are not swapped when the device’s screen orientation changes.
The X axis is horizontal and points to the right, the Y axis is vertical and points up and the Z axis points towards the outside of the front face of the screen. In this system, coordinates behind the screen have negative Z values.
Sensors coordinate-system diagram.
Note: This coordinate system is different from the one used in the Android 2D APIs where the origin is in the top-left corner.
frameworks/base/core/java/android/view/WindowOrientationListener.java
WindowOrientationListener.java 是一个abstract class,它主要是把从gsensor获取到的数据转化为orientation.
每次sensor有进行改变时都会调用到以下函数进行计算Orientation。
?
?
?
?
转载时请注明出处和作者
文章出处:http://www.code007.org/
作者:Code007
---------------------------------------------------------------------------
相关文章推荐
- 关于android2.3调试g-sensor
- 关于android2.3调试g-sensor
- 关于android2.3调试g-sensor
- 关于 android RIL 调试
- Android 2.3 上Launcher2调试(Eclipse)
- 关于mac 里面的 android studio 2.3 里面的 android sdk manager 找不到问题
- ANDROID调试时关于IP地址
- 关于在Android2.3中mediarecoder.play 报start fail -22错误的原因
- 关于Android手机调试出现的链接不上的情况
- Android Studio升到2.3 关于gradle的问题
- 关于Appium远程调试bootstrap的方法(Android)
- Android 2.3 下面的音频调试技巧心得与大家分享
- 关于Android应用调试在小米手机安装程序时出现Installation failed with message INSTALL_CANCELED_BY_USER问题解决
- 关于Android 2.2与2.3 adb.exe版本更新问题(在安装android——SDK时候找不到相应的 /tools/adb.exe! )
- 关于mtk Android sensor 特效列表
- 关于Android Sensor的文章
- 关于android开发的调试错误
- Android 2.3 CTS测试修改测试结果和调试方法
- 关于使用NotificationComat导致android2.3及以下版本无法显示自定义布局的解决方法.