Android 7.1 竖屏转横屏
2022-12-28 20:08:16
ThanksView
  • 访问次数: 222
  • 注册日期: 2019-03-19
  • 最后登录: 2024-04-22

调试使用一款800x1280分辨率的屏,客户希望横屏使用(1280x800)。修改主要涉及几个方面,第一是开机logo的图片,第二是开机动画的显示(bootanimation),第三是最终进入系统后的显示,且所有的显示过程无缝连接。

涉及的文件路径:

开机动画的路径:BootAnimation

更换开机动画:

BootAnimation\bootanimation.zip /system/media/

surfaceflinger文件:

frameworks\native\services\surfaceflinger\DisplayDevice.cpp

frameworks\native\services\surfaceflinger\SurfaceFlinger.cpp

加载开机动画的代码:

frameworks\base\cmds\bootanimation\bootanimation_main.cpp

frameworks\base\cmds\bootanimation\BootAnimation.cpp

JAVA层代码:

frameworks/base/core/res/res/values/config.xml

frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java



1、  开机动画横屏,


/device/target/system.prop
+persist.panel.orientation=90


修改/system/bin/bootanimation(C++)

在frameworks\base\cmds\bootanimation\BootAnimation.cpp中添加:

@@ -286,7+286,22 @@ status_t BootAnimation::readyToRun() {

     status_t status =SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);

     if (status)

         return -1;

+   

+    char value[PROPERTY_VALUE_MAX];

+   property_get("persist.panel.orientation", value,"0");

+    int orient= atoi(value) / 90;

+

+    if(orient== 1 || orient == 3) {

+        int temp = dinfo.h;

+        dinfo.h= dinfo.w;

+        dinfo.w= temp;

+    }

 

+    Rect destRect(dinfo.w, dinfo.h);

+   mSession->setDisplayProjection(dtoken, orient, destRect, destRect);

+   

     // create the native surface

     sp<SurfaceControl> control =session()->createSurface(String8("BootAnimation"),

             dinfo.w, dinfo.h,PIXEL_FORMAT_RGB_565);

在device/system.prop添加:

persist.panel.orientation=90 #bootanimation daemon会读取这个字符串进行旋转操作。


2、  JAVA层修改默认方向

 

frameworks/base/core/res/res/values/config.xml

修改:

---a/frameworks/base/core/res/res/values/config.xml

+++b/frameworks/base/core/res/res/values/config.xml

@@ -619,7 +619,7 @@

         settings are omitted from the system UI. In certain situations we may

         still use the accelerometer to determine the orientation, such as when

         docked if the dock is configured to enable the accelerometer. -->

-    <bool name="config_supportAutoRotation">true</bool>

+    <boolname="config_supportAutoRotation">false</bool>

 

    <!-- If true, the screen can be rotated via the accelerometer in all4

         rotations as the default behavior. -->

@@ -674,7 +674,7 @@

 

    <!-- The number of degrees to rotate the display when the keyboard isopen.

         A value of -1 means no change in orientation by default. -->

-    <integername="config_lidOpenRotation">-1</integer>

+    <integername="config_lidOpenRotation">90</integer>

 

    <!-- Indicate whether the lid state impacts the accessibility of

         the physical keyboard.  0 means itdoesn't, 1 means it is accessible

 

修改

frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

+++b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

@@ -6924,7 +6924,7 @@ public classPhoneWindowManager implements WindowManagerPolicy{

                     if (preferredRotation >=0) {

                         returnpreferredRotation;

                     }

-                    return Surface.ROTATION_0;

+                    return Surface.ROTATION_90;

            }

        }

    }

 

修改

frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

---a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

+++b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

@@ -553,7 +553,7 @@ public classWindowManagerService extends IWindowManager.Stub

    /** All DisplayContents in the world, kept here */

    SparseArray<DisplayContent> mDisplayContents = newSparseArray<>(2);

 

-    int mRotation = 0;

+    int mRotation = 1;

    int mLastOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

    boolean mAltOrientation = false;

 

@@ -3857,7 +3857,7 @@ public classWindowManagerService extends IWindowManager.Stub

        long ident = Binder.clearCallingIdentity();

        try {

            int req = getOrientationLocked();

-                       req =ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; //add

+                       //req =ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; //add

            if (req != mLastOrientation) {

                 mLastOrientation = req;

                 //send a message to Policyindicating orientation change to take


ThanksView 最后编辑, 2024-01-26 13:31:02

三维半岛官网: http://www.thanksview.com

进入首页