Android4.0 Force Horizontal Screen Vertical screen

Source: Internet
Author: User

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

    1. Corresponds to SetProp ro.sf.hwrotation 0 specifies that the default output is not rotated (vertical screen when we output by default)

    2. # 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

    1. Invalid Graphicplane:: Setdisplayhardware (Displayhardware * HW) riga

    2. Case 180:

    3. Displayorientation = Isurfacecomposer:: eOrientation180;

    4. 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

    1. Case 180:

    2. Displayorientation = Isurfacecomposer:: eOrientation180;

    3. 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

  1. / **

  2. * @ Hide

  3. * /

  4. public static Interpretation getdefaultrotation () {

  5. Return to Android.os.SystemProperties.getInt ("Ro.sf.hwrotation", 0); //180

  6. }

  7. / **

  8. * @ Hide

  9. * /

  10. public static Interpretation Getdefaultrotationindex () {

  11. Integral type rotation = getdefaultrotation ();

  12. Switch (rotate) {

  13. Case 0:

  14. return to Rotation_0;

  15. Case 90:

  16. return to Rotation_90;

  17. Case 180:

  18. return to rotation_180;

  19. Case 270:

  20. return to rotation_270;

  21. }

  22. return to Rotation_0;

  23. }


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

    1. Public Invalid updatevoluesfromresources () {

    2. ........................................................

    3. Mthumbnailheight = Math.Round (res.getdimension (r.dimen.status_bar_recents_thumbnail_height)); //Add

    4. }


Add in method

View pure copy in [Java]

  1. Private Invalid Updatethumbnail (... ){

  2. otherwise

  3. Matrix Scalematrix = new Matrix ();

  4. Floating scale = mthumbnailwidth/(floating) thumbnail.getwidth ();

  5. Scalematrix.postscale (scale, scale); //Setscale

  6. H.thumbnailviewimage.setscaletype (Scaletype.matrix);

  7. H.thumbnailviewimage.setimagematrix (Scalematrix);

  8. //Add

  9. if (surface.getdefaultrotation () > 0) {

  10. Matrix Rotatematrix = new Matrix ();

  11. Rotatematrix.setrotate (Surface.getdefaultrotation (), MTHUMBNAILWIDTH/2, MTHUMBNAILHEIGHT/2);

  12. H.thumbnailviewimage.setimagematrix (Rotatematrix);

  13. }

  14. //Add End

  15. }

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]

    1. Integral type rotation = mdisplay.getrotation ();

    2. if (surface.getdefaultrotation () > 0) {

    3. = Rotation (rotation + surface.getdefaultrotationindex ())%4;

    4. }

    5. float = getdegreesforrotation (rotation);

Ok so finish the screen rotation 180 degrees

Android4.0 Force Horizontal Screen Vertical screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.