Page 1 of 1

Rotate Android 5.1 by code NOT by app

Posted: Sun Apr 02, 2017 3:56 pm
by fl0wtec
Dear Frendlyarm,

is there any way to change the screen orientation (portrait/landscape etc.) in your Android 5.1 system code?

I don't want to do it with a thied party app.
I want to do it in the source code or any other config file eg. build.prop.

I've added ro.sf.hwrotation to build.prop and it had no effect.

Changing user_rotation value via adb changed the orientation of apps only.

I want to rotate the whole system including the launcher.

BR

Re: Rotate Android 5.1 by code NOT by app

Posted: Mon May 29, 2017 2:41 am
by v8dave
Did you every find out how to do this?

The website for the HD702 LCD display shows this is a landscape display but I only seem to have a portrait display. I need to use this as landscape only.

Re: Rotate Android 5.1 by code NOT by app

Posted: Thu Jun 01, 2017 9:49 am
by fl0wtec
Hi @v8dave,

I´ve got a reply from jiameijiang via email:

You can refer to the following methods, but we can not guarantee that you can use it. First ,you must clone the latest Andorid5.1 source code , then according to the following steps to modify.
1. enter this path: framework/base/core/res/res/values/config.xml
config_lidOpenRotation = 0 ;----> config_lidOpenRotation = 90 ;
2.enter this path : framework/base/services/core/java/com/android/server/wm/WindowMangerService.java
int mRotation = 0 ;-----> int mRotation = 1 ;
3. and in this path : framework/base/services/surfaceflinger/DisplayDevice.cpp
setProjection(Displaystate::eOrientationDefault, mViewprot ,mFrame )------>
setProjection( Displaystate::eOrientation90 ,mViewprot , mFrame )

After compiling the source code, you need to refer to wiki to replace the file system which on board.
But it also has some problem on display, so you need to do some edits.

1. framework/base/cmds/bootanimation/BootAnimation.cpp
In this function : status_t BootAnimation::readyToRun
Modify the code: spcontrol=session()- >createsurface(String8("BootAnimation"),dinfo.w,dinfo.h.PIXEL_FORMAT_RGB_565);
as :
spcontrol=session()- >createsurface(String8"BootAnimation"),dinfo.h,dinfo.w.PIXEL_FORMAT_RGB_565);
2. /framework/native/services/surfaceflinger/DisplayDevice.cpp
Modify this function:


void DisplayDevice::setProjection(intorientation, conts Rect&newViewport,constRect&newFrame)中
if(!frame.isValid()){
frame = Rect(w,h);----->frame = Rect(h,w);
}
In Transform R, add this code:
orientation = DisplayState::eorientation90;

3. /framework/native/services/surfaceflinger/surfaceFlinger.cpp
Modify the function
voidSurfaceFlinger::onInitializeDisplay():
d.orientation = DisplayState::eOrientationDefault ;----->d.orientation=DisplayState::eOrientatio90;

Last ,compile the source code and replace it .


I didn´t try it yet, feel free to give it a shot and report back.

BR