Android 竖屏启动
1)kernel 竖屏
选中:
make menuconfig ---> Device Drivers ---> Graphics support ---> Console display driver support ---> Framebuffer Console Rotation
make menuconfig
---> Boot options 启动参数修改为:console=ttySAC2,115200 init=/linuxrc fbcon=rotate:1
2)Android OS 竖屏
文件:frameworks/base/libs/surfaceflinger/SurfaceFlinger.cpp
重要提示:在不同的android版本中,上面的路径可能有所不同,但都在framework/base这个路径下,可以搜索下,就能找到
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; // 加上这行
char property[PROPERTY_VALUE_MAX];
if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
//displayOrientation
switch (atoi(property)) {
case 90:
displayOrientation = ISurfaceComposer::eOrientation90;
break;
case 270:
displayOrientation = ISurfaceComposer::eOrientation270;
break;
}
}
const float w = hw->getWidth();
const float h = hw->getHeight();
GraphicPlane::orientationToTransfrom(displayOrientation, w, h,
&mDisplayTransform);
if (displayOrientation & ISurfaceComposer::eOrientationSwapMask) {
mDisplayWidth = h;
mDisplayHeight = w;
} else {
mDisplayWidth = w;
mDisplayHeight = h;
}
setOrientation(ISurfaceComposer::eOrientationDefault);
}
触摸:这块需要修改你的触摸屏驱动
#else /* !CONFIG_CPU_S5PV210_EVT1 */
ts->yp += S3C_ADCDAT0_XPDATA_MASK_12BIT - (data0 & S3C_ADCDAT0_XPDATA_MASK_12BIT);
#endif /* !CONFIG_CPU_S5PV210_EVT1 */
ts->xp += S3C_ADCDAT1_YPDATA_MASK_12BIT - (data1 & S3C_ADCDAT1_YPDATA_MASK_12BIT);
#endif /* CONFIG_TOUCHSCREEN_NEW */
下面的搞死我了,不知道怎么改,
----------------------------------------------------------------------------------------------------------------------------------------
平板电脑一般是默认横屏, 竖屏的APP程序, 会自动旋转90°, 由于是顺时针转90°, 需要改为逆时针转90°; 也就是要把portrait改逆时针转90°,修改点如下:
PhoneWindowManager.java(\\192.168.1.4\opt\android_froyo_smdk\frameworks\policies\base\phone\com\android\internal\policy\impl)
public int rotationForOrientationLw(int orientation, int lastRotation,
boolean displayEnabled) {
if (mPortraitRotation < 0) {
// Initialize the rotation angles for each orientation once.
Display d =((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
if (d.getWidth() > d.getHeight()) {
mPortraitRotation = Surface.ROTATION_270;//Surface.ROTATION_90;
mLandscapeRotation =Surface.ROTATION_0;
} else {
mPortraitRotation =Surface.ROTATION_0;
mLandscapeRotation =Surface.ROTATION_270;//Surface.ROTATION_90;
}
}
一下是参考文章------------------------------------------------------------------------------------------------------
本行实现以后才发现,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.txt2.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就这么简单的一修改,就可以全程竖屏显示了!