高通安卓Q显示屏不同角度旋转竖屏横屏切换
由于项目需要,使用了竖屏当横屏用,所以需要将系统显示旋转90度,我们目前平台是基于高通QCM6125安卓10.0系统。为了方便以后其他角度的旋转,添加了persist.panel.orientation 属性来控制角度。
- 开机动画
frameworks/base/cmds/bootanimation/BootAnimation.cpp@@ -279,11 +279,36 @@ status_t BootAnimation::readyToRun() {if (status)return -1;+ char rAngleValue[PROPERTY_VALUE_MAX];
+ property_get("persist.panel.orientation", rAngleValue, "0");
+ int rAngle = atoi(rAngleValue);
+ SurfaceComposerClient::Transaction t;
+
+ if ( rAngle == 90) {
+ int temp = dinfo.h;
+ dinfo.h= dinfo.w;
+ dinfo.w= temp;
+ Rect destRect(dinfo.w, dinfo.h);
+ t.setDisplayProjection(mDisplayToken, 1, destRect, destRect);//orient=1
+ ALOGD("BootAnimation default set rotation to be 90...");
+ } else if (rAngle == 180) {
+ Rect destRect(dinfo.w, dinfo.h);
+ t.setDisplayProjection(mDisplayToken, 2, destRect, destRect);//orient=2
+ ALOGD("BootAnimation default set rotation to be 180...");
+ } else if (rAngle == 270) {
+ int temp = dinfo.h;
+ dinfo.h= dinfo.w;
+ dinfo.w= temp;
+ Rect destRect(dinfo.w, dinfo.h);
+ t.setDisplayProjection(mDisplayToken, 3, destRect, destRect);//orient=3
+ ALOGD("BootAnimation default set rotation to be 270...");
+ }
+// create the native surfacesp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);- SurfaceComposerClient::Transaction t;
+ //SurfaceComposerClient::Transaction t;t.setLayer(control, 0x40000000).apply();
- 进入桌面后
frameworks/base/core/java/com/android/internal/view/RotationPolicy.java
import android.os.UserHandle;
+import android.os.SystemProperties;import android.provider.Settings;import android.util.Log;import android.view.Display;
@@ -42,7 +43,7 @@ public final class RotationPolicy {private static final String TAG = "RotationPolicy";private static final int CURRENT_ROTATION = -1;- public static final int NATURAL_ROTATION = Surface.ROTATION_0;
+ public static final int NATURAL_ROTATION = SystemProperties.getInt("persist.panel.orientation", 0) / 90;
private RotationPolicy() {
frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java
+import android.os.SystemProperties;import android.util.ArraySet;import android.util.DisplayMetrics;import android.util.Slog;
@@ -361,7 +362,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo** @see #updateRotationUnchecked()*/
- private int mRotation = 0;
+ private int mRotation = SystemProperties.getInt("persist.panel.orientation", 0) / 90;/*** Last applied orientation of the display.
@@ -1370,6 +1371,10 @@ class DisplayContent extends WindowContainerboolean updateRotationUnchecked(boolean forceUpdate) {
+
+ if(true){
+ return true;
+ }ScreenRotationAnimation screenRotationAnimation;if (!forceUpdate) {if (mDeferredRotationPauseCount > 0) {
updateRotationUnchecked方法里不直接返回true,会出现进入桌面一瞬间竖屏再转横屏。
3. 系统导航栏位置
将系统导航栏位置固定在底部,如果不需要这里不用修改。
frameworks\base\services\core\java\com\android\server\wm\DisplayPolicy.java
@NavigationBarPositionint navigationBarPosition(int displayWidth, int displayHeight, int displayRotation) {
- if (navigationBarCanMove() && displayWidth > displayHeight) {
+ /*if (navigationBarCanMove() && displayWidth > displayHeight) {if (displayRotation == Surface.ROTATION_270) {return NAV_BAR_LEFT;} else if (displayRotation == Surface.ROTATION_90) {return NAV_BAR_RIGHT;}
- }
+ }*/return NAV_BAR_BOTTOM;}
- recovery ui
bootable/recovery/minui/graphics.cpp
@@ -401,6 +401,19 @@ int gr_init() {
} else { // "ROTATION_NONE" or unknown stringgr_rotate(GRRotation::NONE);}
+
+ int rotation_user =
+ android::base::GetIntProperty("persist.panel.orientation", 0);
+ if(90 == rotation_user){
+ rotation = GRRotation::RIGHT;
+ }else if(180 == rotation_user){
+ rotation = GRRotation::DOWN;
+ }else if(270 == rotation_user){
+ rotation = GRRotation::LEFT;
+ }else{
+ rotation = GRRotation::NONE;
+ }
+
if (gr_draw->pixel_bytes != 4) {
- mk文件里设置persist.panel.orientation默认值,选配0/90/180/270
- LK阶段开机图片
高通使用splash.img存储LK的开机动画,在device/qcom/common/display/logo/logo.png
添加对应分辨率的图片,手动旋转相应的角度后,重新打包编译splash.img下载进去。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
