高通平台android7.1系统显示旋转180度

 

  1. 实现方法
    1. 内核层修改

kernel\msm-3.18\arch\arm\boot\dts\qcom\dsi-panel-lm215w-lvds-1080p-video.dtsi增加qcom,mdss-dsi-panel-orientation = "180";

从内核到进入系统旋转成功,但是存在一个问题,插入鼠标移动的时候蓝屏。初步测试晓龙相机预览方向是正常的,视频对讲、监控和app方向都正常

据观察,鼠标移动和显示的方向,没有相应对应起来

此方案大家如果大家知道怎么解决插入鼠标移动时显示蓝屏问题,麻烦告知,谢谢了。

下面是高通对我们这种解决方案的回复:

Your change is not suitable. The General solution is change SF init. 

diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp

index c166aaa..526feb6 100644

--- a/services/surfaceflinger/DisplayDevice.cpp

+++ b/services/surfaceflinger/DisplayDevice.cpp

@@ -134,6 +134,11 @@ DisplayDevice::DisplayDevice(

property_get("persist.panel.orientation", property, "0");

panelOrientation = atoi(property) / 90;

+ mPanelInverseMounted = false;

+ // Check if panel is inverse mounted (contents show up HV flipped)

+ property_get("persist.panel.inversemounted", property, "0");

+ mPanelInverseMounted = !!atoi(property);

+

// initialize the display orientation transform.

setProjection(panelOrientation, mViewport, mFrame);

}

@@ -408,6 +413,11 @@ status_t DisplayDevice::orientationToTransfrom(

default:

return BAD_VALUE;

}

+

+ if (DISPLAY_PRIMARY == mHwcDisplayId && isPanelInverseMounted()) {

+ flags = flags ^ Transform::ROT_180;

+ }

+

tr->set(flags, w, h);

return NO_ERROR;

}

但找不到mPanelInverseMounted 和isPanelInverseMounted定义,不知道是基于哪个android版本的,经修改验证,效果是竖向的,而不是我们想要的横向。

  1. 2系统修改
    1. 2.1 Lk阶段显示的开机图片是旋转的

我们简单的处理方式是直接把图片倒过来,所以lk阶段不做代码上的旋转。

1.2.2 persist.panel.orientation=180

device\qcom\msm8937_64\system.prop下增加persist.panel.orientation=180

#bootanimation daemon会读取这个字符串进行旋转操作。

 

1.2.3 frameworks\base\cmds\bootanimation\BootAnimation.cpp

status_t BootAnimation::readyToRun()函数增加下面的内容

char value[PROPERTY_VALUE_MAX];

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

   int orient= atoi(value) / 90;

       ALOGE("kandi BootAnimation::readyToRun111111,orient=%d\n",orient);  

    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);

       ALOGE("kandi BootAnimation::readyToRun22222222\n");

如果没有加这个,开机动画刚开始没有转过来,后面才转过来

1.2.4 frameworks\base\core\res\res\values\config.xml

!-- If true, enables auto-rotation features using the accelerometer.

         Otherwise, auto-rotation is disabled.  Applications may still request

         to use specific orientations but the sensor is ignored and sensor-based

         orientations are not available.  Furthermore, all auto-rotation related

         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>

Frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager

mSupportAutoRotation = mContext.getResources().getBoolean(

                com.android.internal.R.bool.config_supportAutoRotation);

改为false

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

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

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

改为180

我们设备没有传感器,初步测试不需要修改这两个地方也能够达到显示旋转180度的效果。

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

rotationForOrientationLw()函数修改

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

int mRotation = 2;//kandi change from 0 to 2 for rotate 180 by 2018.07.11

    public int getRotation() {

        return mRotation;

}

mmm frameworks/base/services

make snod,然后烧录验证,当然对于userdebug版本可以用push方式。

rotationForOrientationLw()

mRotation

 

ROTATION_180

2

转过来

ROTATION0

0

没有转

ROTATION_180

0

开机动画后半段没有转过来,进入系统后转过来

摄像头没有转的,退出后,系统也没有转过来

ROTATION0

2

开机动画阶段有转过来,但是进入系统后没有转过来

1.2.7 晓龙相机apk属性修改

AndroidManifest.xml文件android:screenOrientation=“landscape”的值改为"unspecified"activity就会跟随系统方向了,否则系统旋转过来后,晓龙相机也没有相应的旋转过来。

 

1.2.8 recovery界面也需要相应的旋转的

主要再bootable/recovery/minui/graphics_fbdev.cpp中实现旋转

1.2.9 手机app从设备得到的摄像头图像是倒过来的(视频监控)

kernel\msm-3.18\arch\arm\boot\dts\qcom\msm8937-camera-sensor-qrd.dtsi

qcom,mount-angle = <270>;改为90没效果,重新改回270

 

接着修改下面:

vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/configs/msm8937_camera.xml

<MountAngle>180</MountAngle>

我们项目的情况这里改为0,否则手机app得到的视频监控图像是倒过来的

编译mmm vendor/qcom/proprietary/mm-camera

升级包的方法:system\etc\camera\camera_config.xml

 

2 兼容性

通过基于device\qcom\msm8937_64\system.prop下persist.panel.orientation属性的值来兼容,此文件最终编译后汇总到system\build.prop文件中。

 

比如以

frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java的修改,根据persist.panel.orientation属性的值来做兼容

修改前:

public int getRotation() {

        return mRotation;

}

 

修改后:

public int getRotation() {

           String property = SystemProperties.get("persist.panel.orientation");

              int rotation = (Integer.parseInt(property))/90;

              Slog.i(TAG, "getRotation()--->property : " + property + "rotation:" +rotation);

             

           mRotation = rotation;//2;

        return mRotation;

}

 

3 升级包升级

涉及相关的部分

(1) build.prop

(2) system\etc\camera\camera_config.xml

(3) recovery.img

(4) splash.img

 

参考链接:

Android 7.1 竖屏转横屏全过程实现-基于高通平台

https://blog.csdn.net/eliot_shao/article/details/70766283

android不通过编译修改build.prop方法

https://blog.csdn.net/nbalichaoq/article/details/44241071

 

参考

猜你喜欢

转载自blog.csdn.net/loongembedded/article/details/81093087