方法一,在内核层和frameworks同时修改,实现横屏操作。
参考文档 mtk6735(8735)LCD屏幕显示90°旋转_u012765781的博客-CSDN博客
可以实现横屏,但是boot和内核启动画面logo,显示变形,还是要更新图片,其实横屏可以不改boot和内核层,只从frameworks层修改,boot和内核层只需制作一个横屏的启动画面logo。
方法二,只改frameworks层,实现横屏操作。
参考文档 android5.1设置默认开机横屏_lwz的博客-CSDN博客
1、进入framework/base/core/res/res/values/config.xml
修改
2、进入framework/base/services/core/java/com/android/server/wm/WindowMangerService.java
修改int mRotation = 0 ; -----> int mRotation = 1 ;
3、进入/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
修改setProjection( Displaystate::eOrientationDefault, mViewprot , mframe )------>
setProjection( Displaystate::eOrientation90 , mViewprot , mframe )
4、进入frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java修改public int rotationForOrientationLw(int orientation, int lastRotation)函数
在if(DEBUG_ORIENTATION) 前,添加if(true)部分即可。
if (true)
{
return Surface.ROTATION_90;
}
//end zyd
if (DEBUG_ORIENTATION) {
Slog.v(TAG, "rotationForOrientationLw(appReqQrientation = "
+ orientation + ", lastOrientation = " + lastRotation
+ ", sensorRotation = " + sensorRotation
+ ", UserRotation = " + mUserRotation
+ ", LidState = " + mLidState
+ ", DockMode = " + mDockMode
+ ", DeskDockEnable = " + mDeskDockEnablesAccelerometer
+ ", CarDockEnable = " + mCarDockEnablesAccelerometer
+ ", HdmiPlugged = " + mHdmiPlugged
+ ", Accelerometer = " + mAccelerometerDefault
+ ", AllowAllRotations = " + mAllowAllRotations
+ ")");
}
编译成功刷入系统会出现开机动画部分只显示3/4解决方案如下:
1、进入framework/base/cmds/bootanimation/BootAnimation.cpp
修改status_t BootAnimation::readyToRun函数中的
spcontrol=session()- >createsurface(String8("BootAnimation"),dinfo.w,dinfo.h.PIXEL_FORMAT_RGB_565);
为:
spcontrol=session()- >createsurface(String8"BootAnimation"),dinfo.h,dinfo.w.PIXEL_FORMAT_RGB_565);
2、进入/framework/native/services/surfaceflinger/DisplayDevice.cpp
修改函数 void DisplayDevice::setProjection(int orientation, conts Rect&newViewport,const Rect&newframe)中
if(!frame.isValid()){
frame = Rect(w,h); ----->frame = Rect(h,w);
}
在Transform R; 下面添加
orientation = DisplayState::eOrientation90; //
3、进入/framework/native/services/surfaceflinger/surfaceFlinger.cpp
修改函数void SurfaceFlinger::onInitializeDisplay()中:
d.orientation = DisplayState::eOrientationDefault ; -->d.orientation=DisplayState::eOrientation90 ;
三,问题总结
按照方法二的方法更改后,实现横屏,存在的问题有
1,图标拖到右侧会出现如下情况。
2,拍照时,图像旋转了90°。



