[高通MSM8953][Android10]开机强制横屏以及第二帧动画横屏

开发平台基本信息

芯片: MSM8953
版本: Android 10.0
kernel: msm-4.9

问题描述

设备硬件的LCD屏幕是竖屏的,而实际产品是横屏设备,于是需要将设备强制横屏显示。我这套代码只用了一款产品,所以我这里就直接写死横屏了,如果有多产品的,要做好横竖屏适配。

解决方法

  • 开机动画横屏
--- a/frameworks/base/cmds/bootanimation/BootAnimation.cpp
+++ b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
@@ -279,6 +279,16 @@ status_t BootAnimation::readyToRun() {
     if (status)
         return -1;
 
 +    int orientation = 1; // landscape
 +    if (orientation) {
 +        if (dinfo.h > dinfo.w) {
 +            int temp = dinfo.h;
 +            dinfo.h= dinfo.w;
 +            dinfo.w= temp;
 +        }
 +    }
 +  +      // create the native surface
     sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
             dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
  • 系统横屏
--- a/frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1322,7 +1322,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
 
 
     private boolean updateOrientationFromAppTokens(boolean forceUpdate) {
 -        final int req = getOrientation();
 -        int req = getOrientation();
 -       req = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
         if (req != mLastOrientation || forceUpdate) {
             mLastOrientation = req;
             mDisplayRotation.setCurrentOrientation(req);
--- a/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
+++ b/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
@@ -90,7 +90,7 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args)
     setPowerMode(args.initialPowerMode);
 
     // initialize the display orientation transform.
 -    setProjection(DisplayState::eOrientationDefault, Rect::INVALID_RECT, Rect::INVALID_RECT);
 -    setProjection(DisplayState::eOrientation90, Rect::INVALID_RECT, Rect::INVALID_RECT);
 }
 
 DisplayDevice::~DisplayDevice() = default;
@@ -244,6 +244,12 @@ void DisplayDevice::setProjection(int orientation,
         // the destination frame can be invalid if it has never been set,
         // in that case we assume the whole display frame.
         frame = Rect(w, h);
 -       int orient = 1; // landscape
 -        if (orient) {
 -            if (h > w) {
 -                frame = Rect(h, w);
 -            }
 -        }
     }
--- a/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5229,7 +5229,7 @@ void SurfaceFlinger::onInitializeDisplays() {
              DisplayState::eLayerStackChanged;
     d.token = token;
     d.layerStack = 0;
 -    d.orientation = DisplayState::eOrientationDefault;
 -    d.orientation = DisplayState::eOrientation90;
     d.frame.makeInvalid();
     d.viewport.makeInvalid();
     d.width = 0;
  • 开机动画第二帧横屏

通过上面的修改,动画跟系统都能正常横屏显示了,但是,在动画快结束即将进入桌面的时候,最后一帧动画会变得异常,既不是横屏,也不是竖屏。增加以下修改即可解决问题。

--- a/frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java
@@ -361,7 +361,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
      *
      * @see #updateRotationUnchecked()
      */
-    private int mRotation = 0;
+    private int mRotation = 1;
 
     /**
      * Last applied orientation of the display.
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值