android4.4如何开机横屏
来源:互联网 发布:mac安全控件下载官网 编辑:程序博客网 时间:2024/04/30 01:26
软件环境:android4.4
硬件平台:marvell
之前调试过在android4.0上将屏幕开机旋转90度,找到了契合点,调整起来还是相对简单,只需设置一个名称为ro.sf.hwrotation = 90即可,android的surface系统显示的时候会读取该系统属性的值,从而将显示界面旋转,但是android4.4的surfaceflinger机制做了调整,自始至终没有发现对该属性的处理判断,可能有其他的暗门,我暂时没发现,因此就把4.0判断属性的那一套移植了过来,具体改动如下:
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -384,6 +384,11 @@ status_t DisplayDevice::orientationToTransfrom(
int orientation, int w, int h, Transform* tr)
{
uint32_t flags = 0;
+ char property[PROPERTY_VALUE_MAX];
+ if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
+ if (atoi(property) == 90)
+ orientation = DisplayState::eOrientation90;
+ }
switch (orientation) {
case DisplayState::eOrientationDefault:
flags = Transform::ROT_0;
@@ -411,6 +416,7 @@ void DisplayDevice::setProjection(int orientation,
const int w = mDisplayWidth;
const int h = mDisplayHeight;
+ char property[PROPERTY_VALUE_MAX];
Transform R;
DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
@@ -418,7 +424,12 @@ void DisplayDevice::setProjection(int orientation,
if (!frame.isValid()) {
// the destination frame can be invalid if it has never been set,
// in that case we assume the whole display frame.
- frame = Rect(w, h);
+ if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
+ if (atoi(property) == 90)
+ frame = Rect(h, w);
+ } else {
+ frame = Rect(w, h);
+ }
}
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -674,6 +674,7 @@ status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo*
const HWComposer& hwc(getHwComposer());
float xdpi = hwc.getDpiX(type);
float ydpi = hwc.getDpiY(type);
+ char property[PROPERTY_VALUE_MAX];
// TODO: Not sure if display density should handled by SF any longer
class Density {
@@ -718,8 +719,15 @@ status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo*
info->orientation = 0;
}
- info->w = hwc.getWidth(type);
- info->h = hwc.getHeight(type);
+ if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
+ if (atoi(property) == 90) {
+ info->w = hwc.getHeight(type);
+ info->h = hwc.getWidth(type);
+ }
+ } else {
+ info->w = hwc.getWidth(type);
+ info->h = hwc.getHeight(type);
+ }
这两个文件做完相应的修改之后,问题来了,开机以及后续的一系列显示确实进入了横屏模式,但是触摸屏却依然没有旋转过来,上层对touch点位的处理还是按竖屏模式处理的。。。接着尝试修改了surface的不少地方企图扭转touch点位,均告失败,最终选择了一个能解决问题但未必最优的方案,修改Input系统的处理。改动如下:
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -42,6 +42,7 @@
#include "InputReader.h"
#include <cutils/log.h>
+#include <cutils/properties.h>
#include <input/Keyboard.h>
#include <input/VirtualKeyMap.h>
@@ -2954,6 +2955,12 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
int32_t naturalPhysicalWidth, naturalPhysicalHeight;
int32_t naturalPhysicalLeft, naturalPhysicalTop;
int32_t naturalDeviceWidth, naturalDeviceHeight;
+
+ char property[PROPERTY_VALUE_MAX];
+ if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
+ if (atoi(property) == 90)
+ mViewport.orientation = DISPLAY_ORIENTATION_90;
+ }
switch (mViewport.orientation) {
case DISPLAY_ORIENTATION_90:
naturalLogicalWidth = mViewport.logicalBottom - mViewport.logicalTop;
@@ -4246,6 +4253,11 @@ void TouchInputMapper::cookPointerData() {
// X, Y, and the bounding box for coverage information
// Adjust coords for surface orientation.
float x, y, left, top, right, bottom;
+ char property[PROPERTY_VALUE_MAX];
+ if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
+ if (atoi(property) == 90)
+ mSurfaceOrientation = DISPLAY_ORIENTATION_90;
+ }
switch (mSurfaceOrientation) {
case DISPLAY_ORIENTATION_90:
至此,触摸屏旋转成功。
本人是本着遇到问题解决问题的原则,也许4.4有类似4.0的关卡可以一步属性设置即可,只是本人没有发现这道关,上述提供的方案仅供参考以及笔者作为记录之用,稳定性还有待考究,本人未做全面的测试。有问题的同仁可以和我探讨,有更好方案的朋友还望不吝赐教。谢谢~~~
- android4.4如何开机横屏
- android4.4如何开机横屏
- Android4.4开机向导
- android4.0 开机启动
- android4.0.3,设置开机不自动进入锁屏状态
- Android4.2 在开机时去掉锁屏
- Android4.4 WIFI开机启动流程详析
- 修改Android4.0开机图片
- android4.04 修改开机动画
- android4.0.3 关掉开机声音
- Android4.4如何实现短信拦截
- Android4.4录屏命令
- 浅析android锁屏开机绘制流程(基于android4.0源码分析)
- 浅析android锁屏开机绘制流程(基于android4.0源码分析) .
- Android4.2上内置第三方锁屏(一)、锁屏开机加载流程
- Android4.4 Telephony流程分析——SIM卡开机时的初始化
- Android4.4 Telephony流程分析——SIM卡开机时的数据加载
- 九鼎创展s5p4418开发板-修改Android4.4系统开机LOGO
- mongoDB的读书笔记(04)_【Replica】(03)_关于选举,投票等等的啰里啰唆
- proguard混淆java web项目
- 安卓新浪微博登陆
- Android开发--仿微信语音对讲录音
- Android源码之ListView的适配器模式
- android4.4如何开机横屏
- rpm打包原理学习
- NSDictionary的遍历
- 单链表就地逆置(Java版),单链java版
- iOS开发中使用宏定义提高开发效率
- saving data - Saving Key-Value Sets
- 缓存学习点滴
- java 压缩解压文件 无乱码
- 在WebView中如何让JS与Java安全地互相调用