高通平台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]设置Activity为全屏显示的两种方法
  2. 修改android日期格式
  3. Android学习笔记35——ProgressBar进度控件详解
  4. Android(安卓)Dialog全屏显示
  5. android ListView没有数据时信息显示
  6. 浅入浅出Android(015):使用ImageView显示网络图片
  7. Android(安卓)修改U盘名称
  8. android selector下的设置背景属性值
  9. android的edittext怎么设置不默认被选中

随机推荐

  1. 终于找到一个类似wince 远程桌面控制andr
  2. Android之——Surface、SurfaceView与Sur
  3. 从源码看ANDROID中SQLITE是怎么通过CURSO
  4. android检查网络连接状态的变化,无网络时
  5. Introducing Quick Search Box for Andro
  6. Android具有粘性的小球,跌落反弹形成文字
  7. Android Studio安装后打不开
  8. Jenkins+Ant+Android+Robitium 实例详解(
  9. Android Studio svn检出项目一直报错
  10. Android设备唯一标识ID的获取