高通平台android9.0设置开机默认横屏显示,具体修改如下

1、修改frameworks/base/core/res/res/values/config.xml配置

--- a/LA.UM.7.6.2/LINUX/android/frameworks/base/core/res/res/values/config.xml+++ b/LA.UM.7.6.2/LINUX/android/frameworks/base/core/res/res/values/config.xml@@ -740,7 +740,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. -->-    true+    false      @@ -795,7 +795,7 @@      -    -1+    90      -    0+    1           -1diff --git a/LA.UM.7.6.2/LINUX/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/LA.UM.7.6.2/LINUX/android/frameindex 969076f..7cb57c0 100644--- a/LA.UM.7.6.2/LINUX/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java+++ b/LA.UM.7.6.2/LINUX/android/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java@@ -2336,6 +2336,7 @@ class DatabaseHelper extends SQLiteOpenHelper {             loadSetting(stmt, Settings.System.IDATA_INPUT_SWITCH_ENABLE,0);             loadSetting(stmt, Settings.System.SHUTDOWN_PASSWORD_CONFIRM_ENABLE,0);             loadSetting(stmt, Settings.System.SHUTDOWN_PASSWORD,"123456");+            loadIntegerSetting(stmt, Settings.System.USER_ROTATION, R.integer.def_user_rotation);              /*              * IMPORTANT: Do not add any more upgrade steps here as the global,

3、修改frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java中rotationForOrientationLw最后配置默认返回90度

+++ b/LA.UM.7.6.2/LINUX/android/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java@@ -7966,6 +7966,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {                     if (preferredRotation >= 0) {                         return preferredRotation;                     }+                    int orient = SystemProperties.getInt("persist.panel.orientation", 0);+                    if (orient == 90) {+                        return Surface.ROTATION_90;+                    }                     return Surface.ROTATION_0;             }         }

4、在你所需的项目的system.prop中添加默认配置控制旋转的角度,persist.panel.orientation=90

5、修改开机动画默认横屏显示

+++ b/LA.UM.7.6.2/LINUX/android/frameworks/base/cmds/bootanimation/BootAnimation.cpp@@ -259,6 +259,17 @@ status_t BootAnimation::readyToRun() {     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) {+        if (dinfo.h > dinfo.w) {+            int temp = dinfo.h;+            dinfo.h= dinfo.w;+            dinfo.w= temp;+        }+    }+     // create the native surface     sp control = session()->createSurface(String8("BootAnimation"),             dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);diff --git a/LA.UM.7.6.2/LINUX/android/frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java b/LA.UM.7.6.2/LINUX/android/frameworks/base/services/index cd8fdbf..043a56a 100644--- a/LA.UM.7.6.2/LINUX/android/frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java+++ b/LA.UM.7.6.2/LINUX/android/frameworks/base/services/core/java/com/android/server/wm/DisplayContent.java@@ -134,6 +134,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; import android.os.Trace;+import android.os.SystemProperties; import android.util.ArraySet; import android.util.DisplayMetrics; import android.util.Slog;@@ -744,6 +745,10 @@ class DisplayContent extends WindowContainer w) {+               frame = Rect(h, w);+            }+        } else {+            frame = Rect(w, h);+        }     }      if (viewport.isEmpty()) {diff --git a/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp b/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflingerindex 447afc0..cd20ba6 100644--- a/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp+++ b/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp@@ -3786,7 +3786,14 @@ void SurfaceFlinger::onInitializeDisplays() {              DisplayState::eLayerStackChanged;     d.token = mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY];     d.layerStack = 0;-    d.orientation = DisplayState::eOrientationDefault;+    char value[PROPERTY_VALUE_MAX];+    property_get("persist.panel.orientation", value,"0");+    int orient= atoi(value) / 90;+    if(orient== 1 || orient == 3) {+        d.orientation = DisplayState::eOrientation90;+    } else {+        d.orientation = DisplayState::eOrientationDefault;+    }     d.frame.makeInvalid();     d.viewport.makeInvalid();     d.width = 0;

6、配置recovery界面默认横屏显示

--- a/LA.UM.7.6.2/LINUX/android/bootable/recovery/minui/Android.mk+++ b/LA.UM.7.6.2/LINUX/android/bootable/recovery/minui/Android.mk@@ -26,6 +26,8 @@ LOCAL_SRC_FILES := \     graphics_fbdev.cpp \     resources.cpp \ +LOCAL_SRC_FILES += graphic_rotate.cpp+ LOCAL_WHOLE_STATIC_LIBRARIES := \     libadf \     libdrm \@@ -41,6 +43,10 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include  LOCAL_MODULE := libminui +#ifdef RECOVERY_LCM_PHYSICAL_ROTATION+    LOCAL_CFLAGS += -DRECOVERY_LCM_PHYSICAL_ROTATION=\"$(RECOVERY_LCM_PHYSICAL_ROTATION)\"+#endif++++ b/LA.UM.7.6.2/LINUX/android/bootable/recovery/minui/graphic_rotate.cpp@@ -0,0 +1,166 @@+#include +#include +#include +#include +#include ++#include +#include ++#include +#include +#include +#include ++#include +#include ++#include "minui/minui.h"+#include "graphics.h"++GRSurface __gr_canvas;++GRSurface* gr_canvas = NULL;+int rotate_index=-1;++static void print_surface_info(GRSurface *s, const char *name)+{+    printf("[graphics] %s > Height:%d, Width:%d, PixelBytes:%d, RowBytes:%d, Size:%d, Data: 0x%08" PRIxPTR "\n",+        name, s->height, s->width, s->pixel_bytes, s->row_bytes, s->height* s->row_bytes, (uintptr_t) s->data);+}++// Read configuration from RECOVERY_LCM_PHYSICAL_ROTATION+#ifndef RECOVERY_LCM_PHYSICAL_ROTATION+#define RECOVERY_LCM_PHYSICAL_ROTATION "undefined"+#endif+static int rotate_config(GRSurface *gr_draw)+{+    if (rotate_index<0)+    {+        if (gr_draw->pixel_bytes != 4) rotate_index=0; // support 4 bytes pixel only+        else if (0 == strncmp(RECOVERY_LCM_PHYSICAL_ROTATION, "90", 2)) rotate_index=1;+        else if (0 == strncmp(RECOVERY_LCM_PHYSICAL_ROTATION, "180", 3)) rotate_index=2;+        else if (0 == strncmp(RECOVERY_LCM_PHYSICAL_ROTATION, "270", 3)) rotate_index=3;+        else rotate_index=0;+        printf("[graphics] rotate_config %d %s\n", rotate_index, RECOVERY_LCM_PHYSICAL_ROTATION);+    }+    return rotate_index;+}++#define swap(x, y, type) {type z; z=x; x=y; y=z;}++// Allocate and setup the canvas object+void rotate_canvas_init(GRSurface *gr_draw)+{+    gr_canvas = &__gr_canvas;+    memcpy(gr_canvas, gr_draw, sizeof(GRSurface));++    // Swap canvas' height and width, if the rotate angle is 90" or 270"+    if (rotate_config(gr_draw)%2) {+        swap(gr_canvas->width, gr_canvas->height, int);+        gr_canvas->row_bytes = gr_canvas->width * gr_canvas->pixel_bytes;+    }++    gr_canvas->data = (unsigned char*) malloc(gr_canvas->height * gr_canvas->row_bytes);+    if (gr_canvas->data == NULL) {+        printf("[graphics] rotate_canvas_init() malloc gr_canvas->data failed\n");+        gr_canvas = NULL;+        return;+    }++    memset(gr_canvas->data,  0, gr_canvas->height * gr_canvas->row_bytes);++    print_surface_info(gr_draw, "gr_draw");+    print_surface_info(gr_canvas, "gr_canvas");+}++// Cleanup the canvas+void rotate_canvas_exit(void)+{+    if (gr_canvas) {+        if (gr_canvas->data)+            free(gr_canvas->data);+        free(gr_canvas);+    }+    gr_canvas=NULL;+}++// Return the canvas object+GRSurface *rotate_canvas_get(GRSurface *gr_draw)+{+    // Initialize the canvas, if it was not exist.+    if (gr_canvas==NULL)+        rotate_canvas_init(gr_draw);+    return gr_canvas;+}++// Surface Rotate Routines+static void rotate_surface_0(GRSurface *dst, GRSurface *src)+{+    memcpy(dst->data, src->data, src->height*src->row_bytes);+}++static void rotate_surface_270(GRSurface *dst, GRSurface *src)+{+    int v, w, h;+    unsigned int *src_pixel;+    unsigned int *dst_pixel;++    for (h=0, v=src->width-1; hheight; h++, v--) {+        for (w=0; wwidth; w++) {+            dst_pixel = (unsigned int *)(dst->data + dst->row_bytes*h);+            src_pixel = (unsigned int *)(src->data + src->row_bytes*w);+            *(dst_pixel+w)=*(src_pixel+v);+        }+    }+}++static void rotate_surface_180(GRSurface *dst, GRSurface *src)+{+    int v, w, k, h;+    unsigned int *src_pixel;+    unsigned int *dst_pixel;++    for (h=0, k=src->height-1; hheight && k>=0 ; h++, k--) {+        dst_pixel = (unsigned int *)(dst->data + dst->row_bytes*h);+        src_pixel = (unsigned int *)(src->data + src->row_bytes*k);+        for (w=0, v=src->width-1; wwidth && v>=0; w++, v--) {+            *(dst_pixel+w)=*(src_pixel+v);+        }+    }+}++static void rotate_surface_90(GRSurface *dst, GRSurface *src)+{+    int w, k, h;+    unsigned int *src_pixel;+    unsigned int *dst_pixel;++    for (h=0; hheight; h++) {+        for (w=0, k=src->height-1; wwidth; w++, k--) {+            dst_pixel = (unsigned int *)(dst->data + dst->row_bytes*h);+            src_pixel = (unsigned int *)(src->data + src->row_bytes*k);+            *(dst_pixel+w)=*(src_pixel+h);+        }+    }+}++typedef void (*rotate_surface_t) (GRSurface *, GRSurface *);++rotate_surface_t rotate_func[4]=+{+    rotate_surface_0,+    rotate_surface_90,+    rotate_surface_180,+    rotate_surface_270+};++// rotate and copy src* surface to dst surface+void rotate_surface(GRSurface *dst, GRSurface *src)+{+    rotate_surface_t rotate;+    rotate=rotate_func[rotate_config(dst)];+    rotate(dst, src);+}++--- /dev/null+++ b/LA.UM.7.6.2/LINUX/android/bootable/recovery/minui/graphic_rotate.h@@ -0,0 +1,11 @@+#ifndef GRAPHICS_ROTATE_H_+#define GRAPHICS_ROTATE_H_++#include "minui/minui.h"++void rotate_canvas_exit(void);+void rotate_canvas_init(GRSurface *gr_draw);+void rotate_surface(GRSurface *dst, GRSurface *src);+GRSurface *rotate_canvas_get(GRSurface *gr_draw);++#endif--- a/LA.UM.7.6.2/LINUX/android/bootable/recovery/minui/graphics_fbdev.cpp+++ b/LA.UM.7.6.2/LINUX/android/bootable/recovery/minui/graphics_fbdev.cpp@@ -27,6 +27,7 @@ #include   #include "minui/minui.h"+#include "graphic_rotate.h"  MinuiBackendFbdev::MinuiBackendFbdev() : gr_draw(nullptr), fb_fd(-1) {} @@ -135,13 +136,17 @@ GRSurface* MinuiBackendFbdev::Init() {    printf("framebuffer: %d (%d x %d)\n", fb_fd, gr_draw->width, gr_draw->height); +#if 0 // to avoid display blink due to display driver not disable backlight after kernel standardization, so that temp state between display suspend/resume is shown   Blank(true);   Blank(false);+#endif -  return gr_draw;+  //return gr_draw;+  return rotate_canvas_get(gr_draw); }  GRSurface* MinuiBackendFbdev::Flip() {+  rotate_surface(gr_draw, rotate_canvas_get(gr_draw));   if (double_buffered) {     // Change gr_draw to point to the buffer currently displayed,     // then flip the driver so we're displaying the other buffer@@ -152,13 +157,14 @@ GRSurface* MinuiBackendFbdev::Flip() {     // Copy from the in-memory surface to the framebuffer.     memcpy(gr_framebuffer[0].data, gr_draw->data, gr_draw->height * gr_draw->row_bytes);   }-  return gr_draw;+  //return gr_draw;+  return rotate_canvas_get(gr_draw); }  MinuiBackendFbdev::~MinuiBackendFbdev() {   close(fb_fd);   fb_fd = -1;-+    rotate_canvas_exit();   if (!double_buffered && gr_draw) {     free(gr_draw->data);     free(gr_draw);--- a/LA.UM.7.6.2/LINUX/android/device/qcom/$(project)/BoardConfig.mk+++ b/LA.UM.7.6.2/LINUX/android/device/qcom/$(project)/BoardConfig.mk@@ -293,3 +293,4 @@ ifneq ($(ENABLE_AB),true) endif  TARGET_ENABLE_MEDIADRM_64 := true+RECOVERY_LCM_PHYSICAL_ROTATION := 90

如需强制所有的应用界面都默认横屏显示,可在frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java中的updateOrientationFromAppTokensLocked修改

+++ b/LA.UM.7.6.2/LINUX/android/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java@@ -170,6 +170,7 @@ import android.os.SystemService; import android.os.Trace; import android.os.UserHandle; import android.os.WorkSource;+import android.os.SystemProperties; import android.provider.Settings; import android.text.format.DateUtils; import android.util.ArrayMap;@@ -2468,6 +2469,13 @@ public class WindowManagerService extends IWindowManager.Stub         try {             final DisplayContent dc = mRoot.getDisplayContent(displayId);             //final int req = dc.getOrientation();+            int req;+            int orient = SystemProperties.getInt("persist.panel.orientation", 0);+            if (orient == 90) {+                req = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;+            } else {+                req = dc.getOrientation();+            }             if (req != dc.getLastOrientation() || forceUpdate) {                 dc.setLastOrientation(req);                 //send a message to Policy indicating orientation change to take

 

更多相关文章

  1. Android中弹出输入法界面不影响app界面布局
  2. Android中要让一个程序的界面始终保持一个方向(禁止转屏)
  3. Android——界面布局
  4. 修改Android解锁界面
  5. Android 特殊界面效果之——透明界面
  6. android打开系统联系人界面
  7. 在Android中实现service动态更新UI界面
  8. Android中应用界面主题Theme使用方法和页面定时跳转应用

随机推荐

  1. Android自动弹出软键盘(输入键盘)
  2. ANDROID GreenDao 使用例子 Android Gree
  3. 谷歌Android系统版本无序发展反噬产业链
  4. linux android 下进入android shell
  5. Android rxjava实现倒计时功能
  6. android 转屏问题
  7. 图片切换
  8. Android SetWallpaper
  9. Android 设置边距总结
  10. Android(安卓)实现沉浸式体验