android2.2 froyo豎屏顯示

本文原創,來自http://blog.csdn.net/knock,轉載請保留本行

 

實現以後才發現,google在1.5到2.2這個過程中改進了很多,1.5修改豎屏比較麻煩,而2.2是相

當的容易!
其實基本上google將之前版本的默認爲豎屏的做法進行了改進,不需要再花費更多力氣在屏幕的

默認橫豎切換上面。

1.還是kernel豎屏,可以顯示到屏幕出現"A N D R O I D"字樣
  啓動參數里加入fbcon=rotate:1    (0:正常屏; 1:順時鐘轉90度; 2:轉180度; 3:順時鐘轉270

度;)
最後生成的autoconf.h裏有類似項:
#define CONFIG_CMDLINE "console=ttySAC0,115200 fbcon=rotate:1"

此項的解析在$(kernel)/drivers/video/console/fbcon.c
static int __init fb_console_setup(char *this_opt);
只是去初始化變量initial_rotation,然後initial_rotation會傳遞給其他需要的結構。
要選上:Device Drivers -> Graphics support -> Console display driver support ->

Framebuffer Console support -> Framebuffer Console Rotation
注意:參考$(kernel)/documentation/fb/fbcon.txt

2.android OS旋轉屏幕
froyo中已經相當容易,僅修改一處:
frameworks/base/libs/surfaceflinger/SurfaceFlinger.cpp
void GraphicPlane::setDisplayHardware(DisplayHardware *hw)
{
    mHw = hw;

    // initialize the display orientation transform.
    // it's a constant that should come from the display driver.
//    int displayOrientation = ISurfaceComposer::eOrientationDefault;
    int displayOrientation = ISurfaceComposer::eOrientation90; //jeff.
    。。。
}


或者只在init.rc中增加一項:
setprop ro.sf.hwrotation 90

就這麼簡單的一修改,就可以全程豎屏顯示了!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章