android2.2 android2.3.4 竖屏简单更改
设定 ro.sf.hwrotation
在根目录下的init.rc文件添加setprop ro.sf.hwrotation 270,更改这个 property 为 270,强制屏幕旋转 270 度。
android2.2解决触控屏幕异常
$(android_root_path)/frameworks/base/services/java/com/android/server/InputDevice.java
添加包
importandroid.os.SystemProperties;
添加成员变量
privatestaticfinalintHWROTATION=SystemProperties.getInt("ro.sf.hwrotation",0)/90;
在方法MotionEvent generateAbsMotion(InputDevice device, long curTime,
long curTimeNano, Display display, int orientation,
int metaState)中开始处添加
orientation = (orientation + HWROTATION) % 4;
android2.3.4解决触控屏幕异常
$(android_root_path)/frameworks/base/libs/ui/InputReader.cpp文件中函数
TouchInputMapper::configureSurfaceLocked()中(注:此方法只是可行,
更优方案请深入android输入子系统)原:
if (mAssociatedDisplayId >= 0) { // Note: getDisplayInfo is non-reentrant so we can continue holding the lock. if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, & width, & height, & orientation)) { return false; } } else { orientation = InputReaderPolicyInterface::ROTATION_0; width = mRawAxes.x.getRange(); height = mRawAxes.y.getRange(); }修改后:
if (mAssociatedDisplayId >= 0) { // Note: getDisplayInfo is non-reentrant so we can continue holding the lock. if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, & width, & height, & orientation)) { return false; } char property[4]; int tmpInt; if (property_get("ro.sf.hwrotation", property, NULL) > 0) { switch (atoi(property)) { case 90: tmpInt=width; width = height; height = tmpInt; orientation = (orientation + 1)%4; break; case 180: orientation = (orientation + 2)%4; break; case 270: tmpInt=width;width = height;height = tmpInt;orientation = (orientation + 3)%4; break; } } } else { orientation = InputReaderPolicyInterface::ROTATION_0; width = mRawAxes.x.getRange(); height = mRawAxes.y.getRange(); }
记得添加头文件#include <cutils/properties.h>
reference:
http://git.android-x86.org/?p=platform/frameworks/base.git;a=commitdiff;h=c5cc0d3bb650a219b8904a5bbb7f5674e53e1a6f
http://cwhuang.info/2010/11/fix-rotated-screen-issues
更多相关文章
- 一款常用的 Squid 日志分析工具
- GitHub 标星 8K+!一款开源替代 ls 的工具你值得拥有!
- RHEL 6 下 DHCP+TFTP+FTP+PXE+Kickstart 实现无人值守安装
- Linux 环境下实战 Rsync 备份工具及配置 rsync+inotify 实时同步
- 彩信
- AndroidManifest.xml反编译
- Android(安卓)HIDL学习(2) --- HelloWorld
- [置顶] Android(安卓)从硬件到应用:一步一步向上爬 2 -- 运行 C
- Android(安卓)Studio引入Lambda以及介绍和简单实用