Android Start by default is a horizontal screen or vertical screen
Our TV is a horizontal screen display, but there are customers want vertical screen display, yesterday to get off work received demand, unexpectedly said 7.19 will be done. There are 2 ideas, one is to modify the LCD default output, but this is not my level can be easily done. The other one is that the bottom layer should give the upper porting interface. A systematic interface like this is usually in Build.prop.
Find a correlation ratio larger than the attribute ro.sf.hwrotation=270, and revolve about, Lenovo to 0,90,180,270. Try it, change it to ro.sf.hwrotation=0, test it, OK, meet the customer's requirements, and get off work early.
/Device/samsung/smdk4x12/system.prop (Ro.sf.hwrotation)
Today came to search the relevant content, or found a lot of knowledge
1, you can specify whether the system is a horizontal or vertical screen in the init.rc
[Ordinary] in view of the ordinary copy
Corresponds to SetProp ro.sf.hwrotation 0 specifies that the default output is not rotated (vertical screen when we output by default)
# corresponds to SetProp ro.sf.hwrotation 270 specifies rotation 270-degree output
2. This specified angle, android default only 0 degrees and 270 degrees effective, 180 degrees invalid, if you want to use 180 degrees, need to modify the source code
Modify the file frame/base/service/Surfaceflinger/surfaceflinger.cpp
In the method
[CPP] in view of the ordinary copy
Invalid Graphicplane:: Setdisplayhardware (Displayhardware * HW) riga
Case 180:
Displayorientation = Isurfacecomposer:: eOrientation180;
Break
That would support 180 degrees.
3, and more details-Android 4.1 default form rotation 180 degrees
1) Set the property value
Add ro.sf.hwrotation = 180 to the system/Build.prop file
2) Set the default display orientation for the form
Find a method in the framework/local/service/surfaceflinger/surfaceflinger.cpp file
Setdisplayhardware
Join in the switch
[CPP] in view of the ordinary copy
Case 180:
Displayorientation = Isurfacecomposer:: eOrientation180;
Break
3). Set the rotation direction of the form animation
One > in frame/base/CORE/JAVA/robotics/View/Surface.java Join method
[CPP] in view of the ordinary copy
/ **
* @ Hide
* /
public static Interpretation getdefaultrotation () {
Return to Android.os.SystemProperties.getInt ("Ro.sf.hwrotation", 0); //180
}
/ **
* @ Hide
* /
public static Interpretation Getdefaultrotationindex () {
Integral type rotation = getdefaultrotation ();
Switch (rotate) {
Case 0:
return to Rotation_0;
Case 90:
return to Rotation_90;
Case 180:
return to rotation_180;
Case 270:
return to rotation_270;
}
return to Rotation_0;
}
B> found in framework/base/service/java/com/robot/server/Vm/screenrotationanimation.java file (android4.1) method setrotation
or (android4.2) method setrotationintransaction Modify Deltarotation (rotation, surface.rotation_0);
For deltarotation (rotation, Surface getdefaultrotationindex ());
4) Modify the recent program view orientation
Modify the following in the frame/base/Package/systemui/src/com/robot/Systemui/recentspanelview.java file
private interpretation mthumbnailheight;//Plus
Add in method
[CPP] in view of the ordinary copy
Public Invalid updatevoluesfromresources () {
........................................................
Mthumbnailheight = Math.Round (res.getdimension (r.dimen.status_bar_recents_thumbnail_height)); //Add
}
Add in method
View pure copy in [Java]
Private Invalid Updatethumbnail (... ){
otherwise
Matrix Scalematrix = new Matrix ();
Floating scale = mthumbnailwidth/(floating) thumbnail.getwidth ();
Scalematrix.postscale (scale, scale); //Setscale
H.thumbnailviewimage.setscaletype (Scaletype.matrix);
H.thumbnailviewimage.setimagematrix (Scalematrix);
//Add
if (surface.getdefaultrotation () > 0) {
Matrix Rotatematrix = new Matrix ();
Rotatematrix.setrotate (Surface.getdefaultrotation (), MTHUMBNAILWIDTH/2, MTHUMBNAILHEIGHT/2);
H.thumbnailviewimage.setimagematrix (Rotatematrix);
}
//Add End
}
5). Modify the screenshot picture orientation
Find the Takescreenshot method in the frame/base/pacikages/systemui/src/com/robot/Systemui/globalscreenshot.java file
Modification of float = getdegreesforrotation (mdisplay.getrotation ());
For
View pure copy in [Java]
Integral type rotation = mdisplay.getrotation ();
if (surface.getdefaultrotation () > 0) {
= Rotation (rotation + surface.getdefaultrotationindex ())%4;
}
float = getdegreesforrotation (rotation);
Ok so finish the screen rotation 180 degrees
Android4.0 Force Horizontal Screen Vertical screen