【转】高通平台android9.0设置开机默认横屏显示

高通平台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. -->

  • <bool name="config_supportAutoRotation">true</bool>
  • <bool name="config_supportAutoRotation">false</bool>

@@ -795,7 +795,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>

  • <integer name="def_user_rotation">0</integer>
  • <integer name="def_user_rotation">1</integer>


    <integer name="def_download_manager_max_bytes_over_mobile">-1</integer>
    diff --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/frame
    index 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<SurfaceControl> 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<DisplayContent.DisplayChildWindowCo
    WallpaperController wallpaperController, DisplayWindowController controller) {
    super(service);
    setController(controller);
  •    int orient = SystemProperties.getInt("persist.panel.orientation", 0);
    
  •    if (orient == 90) {
    
  •        mRotation = Surface.ROTATION_90;
    
  •    }
       if (service.mRoot.getDisplayContent(display.getDisplayId()) != null) {
           throw new IllegalArgumentException("Display with ID=" + display.getDisplayId()
                   + " already exists=" + service.mRoot.getDisplayContent(display.getDisplayId())
    

diff --git a/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflinger/DisplayDevice.cpp b/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflinger/
index 4801ba0..2f0f7f7 100644
--- a/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
+++ b/LA.UM.7.6.2/LINUX/android/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
@@ -302,7 +302,14 @@ DisplayDevice::DisplayDevice(
mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance);

 // initialize the display orientation transform.
  • setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
  • char value[PROPERTY_VALUE_MAX];
  • property_get("persist.panel.orientation", value,"0");
  • int orient= atoi(value) / 90;
  • if(orient== 1 || orient == 3) {
  •    setProjection(DisplayState::eOrientation90, mViewport, mFrame);
    
  • } else {
  •    setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
    
  • }
    }

DisplayDevice::~DisplayDevice() = default;
@@ -583,7 +590,16 @@ void DisplayDevice::setProjection(int orientation,
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);
    
  •    char value[PROPERTY_VALUE_MAX];
    
  •    property_get("persist.panel.orientation", value,"0");
    
  •    int orient= atoi(value) / 90;
    
  •    if(orient== 1 || orient == 3) {
    
  •        if (h > 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/surfaceflinger
    index 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 <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <inttypes.h>

+#include <fcntl.h>
+#include <stdio.h>

+#include <sys/cdefs.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>

+#include <linux/fb.h>
+#include <linux/kd.h>

+#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; h<dst->height; h++, v--) {
  •    for (w=0; w<dst->width; 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; h<dst->height && 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; w<dst->width && 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; h<dst->height; h++) {
  •    for (w=0, k=src->height-1; w<dst->width; 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 <unistd.h>

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
    

————————————————
版权声明:本文为CSDN博主「NullException!!!!」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u010867436/article/details/100079568

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,240评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,328评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,182评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,121评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,135评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,093评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,013评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,854评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,295评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,513评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,678评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,398评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,989评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,636评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,801评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,657评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,558评论 2 352

推荐阅读更多精彩内容