嵌入式爱好者

android5.1修改默认开机显示方向

2018-8-20 14:48| 发布者: 飞凌-chongzi| 查看: 1395| 评论: 0

类目: S5P4418/6818系列产品  >  Android     文档编号: 213

Android5.1的显示方向默认为0度,可以更改为90、180、270来修改其显示的方向,下面是更改为顺势针旋转90度的方法:

diff --git a/frameworks/base/cmds/bootanimation/BootAnimation.cpp b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
index b2474f2..8c133c7 100644
--- a/frameworks/base/cmds/bootanimation/BootAnimation.cpp
+++ b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
@@ -239,7 +239,7 @@ status_t BootAnimation::readyToRun() {
 
     // create the native su**ce
     sp<Su**ceControl> control = session()->createSu**ce(String8("BootAnimation"),
-            dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
+            dinfo.h, dinfo.w, PIXEL_FORMAT_RGB_565);
 
     Su**ceComposerClient::openGlobalTransaction();
     control->setLayer(0x40000000);
diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
index e23ca9a..eedf7ee 100755
--- a/frameworks/base/core/res/res/values/config.xml
+++ b/frameworks/base/core/res/res/values/config.xml
@@ -558,7 +558,7 @@
 
     <!-- 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>
+    <integer name="config_lidOpenRotation">90</integer>
 
     <!-- Indicate whether the lid state impacts the accessibility of
          the physical keyboard.  0 means it doesn't, 1 means it is accessible
diff --git a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
index 089d897..a928d64 100644
--- a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -478,7 +478,7 @@ public class WindowManagerService extends IWindowManager.Stub
     /** All DisplayContents in the world, kept here */
     SparseArray<DisplayContent> mDisplayContents = new SparseArray<DisplayContent>(2);
 
-    int mRotation = 0;
+    int mRotation = 1;
     int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
     boolean mAltOrientation = false;
 
diff --git a/frameworks/native/services/su**ceflinger/DisplayDevice.cpp b/frameworks/native/services/su**ceflinger/DisplayDevice.cpp
index 6ac1af0..f966a29 100644
--- a/frameworks/native/services/su**ceflinger/DisplayDevice.cpp
+++ b/frameworks/native/services/su**ceflinger/DisplayDevice.cpp
@@ -130,7 +130,7 @@ DisplayDevice::DisplayDevice(
     }
 
     // initialize the display orientation transform.
-    setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
+    setProjection(DisplayState::eOrientation90, mViewport, mFrame);
 }
 
 DisplayDevice::~DisplayDevice() {
@@ -434,12 +434,13 @@ void DisplayDevice::setProjection(int orientation,
     const int h = mDisplayHeight;
 
     Transform R;
+    orientation = DisplayState::eOrientation90;
     DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
 
     if (!frame.isValid()) {
         // 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);
+        frame = Rect(h, w);
     }
 
     if (viewport.isEmpty()) {
diff --git a/frameworks/native/services/su**ceflinger/Su**ceFlinger.cpp b/frameworks/native/services/su**ceflinger/Su**ceFlinger.cpp
index 04d7850..e672169 100644
--- a/frameworks/native/services/su**ceflinger/Su**ceFlinger.cpp
+++ b/frameworks/native/services/su**ceflinger/Su**ceFlinger.cpp
@@ -2331,7 +2331,7 @@ void Su**ceFlinger::onInitializeDisplays() {
              DisplayState::eLayerStackChanged;
     d.token = mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY];
     d.layerStack = 0;
-    d.orientation = DisplayState::eOrientationDefault;
+    d.orientation = DisplayState::eOrientation90;
     d.frame.makeInvalid();
     d.viewport.makeInvalid();
     d.width = 0;


1

已解决

未解决

只是看看

刚表态过的朋友 (1 人)

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-11-22 11:02

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部