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

添加包

import android.os.SystemProperties;

添加成员变量

private static final int HWROTATION = 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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值