• Android 11 设置开机默认系统横屏显示


     Android系统默认是竖屏显示的,想要完成横屏显示,按以下步骤配置即可实现功能:

    1.在目录frameworks/base/cmds/bootanimation/BootAnimation.cpp中修改

    1. // create the native surface
    2. sp control = session()->createSurface(String8("BootAnimation"),
    3. - resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565);
    4. + resolution.getHeight(), resolution.getWidth(), PIXEL_FORMAT_RGB_565);
    5. SurfaceComposerClient::Transaction t;
    6. + Rect destRect(resolution.getHeight(), resolution.getWidth());
    7. + t.setDisplayProjection(mDisplayToken, ui::ROTATION_90, destRect, destRect);
    8. // this guest property specifies multi-display IDs to show the boot animation

    2.在目录frameworks/base/core/java/com/android/internal/view/RotationPolicy.java修改

    1. public final class RotationPolicy {
    2. private static final String TAG = "RotationPolicy";
    3. private static final int CURRENT_ROTATION = -1;
    4. - public static final int NATURAL_ROTATION = Surface.ROTATION_0;
    5. + public static final int NATURAL_ROTATION = Surface.ROTATION_90;
    6. private RotationPolicy() {
    7. }

    3.在目录frameworks/base/services/core/java/com/android/server/wm/DisplayRotation.java修改

    1. public class DisplayRotation {
    2. - private int mRotation;
    3. + private int mRotation = 1;
    4. int mLandscapeRotation; // default landscape
    5. if (preferredRotation >= 0) {
    6. return preferredRotation;}
    7. - return Surface.ROTATION_0;
    8. + return Surface.ROTATION_90;

    4.其次修改native层代码,frameworks/native/services/surfaceflinger/DisplayDevice.cpp

    1. setPowerMode(args.initialPowerMode);
    2. // initialize the display orientation transform.
    3. - setProjection(ui::ROTATION_0, Rect::INVALID_RECT, Rect::INVALID_RECT);
    4. + setProjection(ui::ROTATION_90, Rect::INVALID_RECT, Rect::INVALID_RECT);
    5. }
    6. DisplayDevice::~DisplayDevice() = default;
    7. void DisplayDevice::setProjection(ui::Rotation orientation, Rect viewport, Rect
    8. if (!frame.isValid()) {
    9. // the destination frame can be invalid if it has never been set,
    10. // in that case we assume the whole display frame.
    11. + if( displayWidth < displayHeight)
    12. + frame = Rect(displayHeight, displayWidth);
    13. + else
    14. frame = Rect(displayWidth, displayHeight);
    15. }

    5.然后再在frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp

    void SurfaceFlinger::onInitializeDisplays() {

    DisplayState::eLayerStackChanged;

    d.token = token;

    d.layerStack = 0;

    - d.orientation = ui::ROTATION_0;

    + d.orientation = ui::ROTATION_90;

    d.frame.makeInvalid();

    d.viewport.makeInvalid();

    d.width = 0;

    说明:文中修改部分+号代表增加 -代表删除  

    至此 开机默认开机横屏功能已经配置完成 !!!

    觉得我写的号的兄弟给个赞!!!谢谢 

  • 相关阅读:
    数字颠倒输出
    Pr:音频和视频的同步
    面向Web开发人员的Linux实用入门
    多核 ARM Server 性能调优
    java基于springboot房产门户房屋出租销售网站—计算机毕业设计
    证件照电子版怎么做?这几个软件能帮你
    LabVIEW开发光学相干断层扫描系统
    《安富莱嵌入式周报》第270期:2022.06.13--2022.06.19
    C指针之初始化(三)
    20%的业务代码的Spring声明式事务,可能都没处理正确
  • 原文地址:https://blog.csdn.net/a546036242/article/details/125620567