设定 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


更多相关文章

  1. 一款常用的 Squid 日志分析工具
  2. GitHub 标星 8K+!一款开源替代 ls 的工具你值得拥有!
  3. RHEL 6 下 DHCP+TFTP+FTP+PXE+Kickstart 实现无人值守安装
  4. Linux 环境下实战 Rsync 备份工具及配置 rsync+inotify 实时同步
  5. 彩信
  6. AndroidManifest.xml反编译
  7. Android(安卓)HIDL学习(2) --- HelloWorld
  8. [置顶] Android(安卓)从硬件到应用:一步一步向上爬 2 -- 运行 C
  9. Android(安卓)Studio引入Lambda以及介绍和简单实用

随机推荐

  1. Android 学习资源
  2. Android - 折线图
  3. Android Studio中配置代码和资源的路径
  4. Android v2.0 基本概念 - 浅谈
  5. 背景 透明 半透明
  6. android 自定义弹出窗口
  7. android 手机定位
  8. Ubuntu-18.04 LTS配置android系统源码编
  9. android5 sdk 下载地址大全
  10. Android Fresco图片处理库用法API英文原