Android4.4系统增加LCD 屏幕旋转功能
来源:互联网 发布:父母 linux 编辑:程序博客网 时间:2024/05/21 19:49
转载自 http://blog.csdn.net/wlwl0071986/article/details/51225087 我以前修改是太后面了,导致开机logo 会部分不旋转,试试这个文章,感觉修改地方比较合理,试试看,感谢原作者。
由于Android4.4系统上去掉了ro.sf.hwrotation属性的支持,因为不能使用之前的方法进行屏幕旋转了。暂时没有找到相应的属性和后门,于是自己写了一个屏幕旋转的临时代码,后面找到更好的方法后再替换。具体代码如下:
~/framework/native/services/surfaceflinger/DisplayDevice.cpp
uint32_t DisplayDevice::getOrientationTransform() const {
...
if (property_get("persist.sys.hwrotation", property, NULL) > 0) {
switch (atoi(property)) {
case 90:
transform = Transform::ROT_90;
break;
case 270:
transform = Transform::ROT_270;
break;
}
}
return transform;
}
status_t DisplayDevice::orientationToTransfrom(
int orientation, int w, int h, Transform* tr)
{
...
if (property_get("persist.sys.hwrotation", property, NULL) > 0) {
switch (atoi(property)) {
case 90:
flags = Transform::ROT_90;
break;
case 270:
flags = Transform::ROT_270;
break;
}
}
tr->set(flags, w, h);
return NO_ERROR;
}
void DisplayDevice::setProjection(int orientation,
const Rect& newViewport, const Rect& newFrame) {
...
if (!frame.isValid()) {
if (property_get("persist.sys.hwrotation", property, NULL) > 0) {
switch (atoi(property)) {
case 90:
case 270:
frame = Rect(h, w);
break;
default:
frame = Rect(w, h);
break;
}
} else
frame = Rect(w, h);
} else {
...
}
}
~/framework/base/services/input/InputReader.cpp
void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
...
if (property_get("persist.sys.hwrotation", property, NULL) > 0) {
switch (atoi(property)) {
case 90:
mSurfaceOrientation = DISPLAY_ORIENTATION_90;
break;
case 270:
mSurfaceOrientation = DISPLAY_ORIENTATION_270;
break;
}
}
switch (mSurfaceOrientation) {
case DISPLAY_ORIENTATION_90:
case DISPLAY_ORIENTATION_270:
}
~/framework/native/services/surfaceflinger/SurfaceFlinger.cpp
status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
...
info->w = hwc.getWidth(type);
info->h = hwc.getHeight(type);
if (property_get("persist.sys.hwrotation", property, NULL) > 0) {
switch (atoi(property)) {
case 90:
case 270:
if (type != DisplayDevice::DISPLAY_EXTERNAL) {
info->w = hwc.getHeight(type);
info->h = hwc.getWidth(type);
}
break;
default:
break;
}
}
info->xdpi = xdpi;
info->ydpi = ydpi;
info->fps = float(1e9 / hwc.getRefreshPeriod(type));
...
}
void SurfaceFlinger::onInitializeDisplays() {
...
d.orientation = DisplayState::eOrientationDefault;
char property[PROPERTY_VALUE_MAX];
if (property_get("persist.sys.hwrotation", property, NULL) > 0){
switch (atoi(property)) {
case 0:
d.orientation = DisplayState::eOrientationDefault;
break;
case 90:
d.orientation = DisplayState::eOrientation90;
break;
case 180:
d.orientation = DisplayState::eOrientation180;
break;
case 270:
d.orientation = DisplayState::eOrientation270;
break;
default:
d.orientation = DisplayState::eOrientationDefault;
break;
}
} else {
d.orientation = DisplayState::eOrientationDefault;
}
d.frame.makeInvalid();
d.viewport.makeInvalid();
}
~/framework/base/services/Java/com/Android/server/wm/WindowManagerService.java
boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
...
if (req != mForcedAppOrientation) {
if ("0".equals(SystemProperties.get("persist.sys.hwrotation", "0")))
req = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
else if ("90".equals(SystemProperties.get("persist.sys.hwrotation", "0")))
req = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
else if ("180".equals(SystemProperties.get("persist.sys.hwrotation", "0")))
req = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
else if ("270".equals(SystemProperties.get("persist.sys.hwrotation", "0")))
req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
else
req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}
...
}
- Android4.4系统增加LCD 屏幕旋转功能
- Android4.4 增加屏幕旋转功能
- android4.2 lcd 旋转180度
- win7电脑开启屏幕旋转功能吗 Win7系统屏幕的旋转功能如何使用
- AM3517 VRFB LCD屏幕旋转详解
- android4.4增加ethernet
- 【原】qt embedded 4.5 实现屏幕旋转 ,lcd旋转 transform
- redboot mini2440 qemu 增加LCD功能
- Settings添加屏幕旋转功能
- MTK平台LCD屏幕旋转90度修改
- imx6 android4.4增加ethernet
- Android4: 旋转屏幕时禁止Activity重启
- Android4: 旋转屏幕时禁止Activity重启
- android4.0屏幕启动时默认180度旋转
- 实现Android4.4系统设置分页滑动浏览功能
- 实现Android4.4系统设置分页滑动浏览功能
- android4.4 系统时间同步,添加NTP备份地址功能
- 滑动屏幕旋转模型功能实现
- ManualResetEvent和AutoResetEvent 区别
- Scala入门:类
- 1.计算蔬菜总价
- Hi3518e安装第三步
- QT SQLITE 判断表是否存在
- Android4.4系统增加LCD 屏幕旋转功能
- Java 社区平台 Sym 2.0.0 发布
- javascript中的split()和join()方法
- C/C++ 文件读写操作总结
- Spark 配置整理
- git客户端TortoiseGit的安装和使用
- 2.计算行程
- 多线程之原子性,可见性,有序性,并发问题解决
- Struts基础入门教程实例