標籤:android blog http io ar os 使用 sp java
Android的啟動預設是橫屏或者豎屏
我們的TV本來是橫屏顯示,但是有客戶竟然要豎屏顯示,昨天快下班收到的需求,竟然說7.19就要搞定。思路有2個,一個就是修改LCD的預設輸出,但是這個不是我這個水平能輕而易舉搞定的。另外一個就是底層應該給上層porting出介面。像這種系統性的介面一般在build.prop裡。
找到一個相關度比較大的屬性ro.sf.hwrotation=270,和旋轉有關的,聯想到0,90,180,270.試試吧,將其改為ro.sf.hwrotation=0,測試了一下,OK,滿足客戶要求了,就早點下班了。
/ device/samsung/smdk4x12/system.prop(ro.sf.hwrotation )
今天來了搜了一下相關的內容,還是發現了不少知識
1,可以在init.rc裡指定系統是橫屏還是豎屏
[普通] 鑒於普通副本
對應setProp ro.sf.hwrotation 0指定預設輸出不旋轉(我們預設輸出時豎屏)
#對應setProp ro.sf.hwrotation 270指定旋轉270度輸出
2。這個指定角度,Android預設只有0度和270度有效,180度無效,如果想使用180度,需要修改源碼
修改檔案的架構/基地/服務/的surfaceflinger / SurfaceFlinger.cpp
在方法
[CPP] 鑒於普通副本
無效 GraphicPlane :: setDisplayHardware(DisplayHardware * HW)裡加
案例 180:
displayOrientation = ISurfaceComposer :: eOrientation180;
打破;
這樣子就支援了180度了
3,還有更詳細的 - 安卓4.1預設表單旋轉180度
1)設定屬性值
在系統/ build.prop檔案中加入ro.sf.hwrotation = 180
2)設定表單預設顯示方向
在架構/本地/服務/的surfaceflinger / SurfaceFlinger.cpp檔案中找到方法
setDisplayHardware
在交換器中加入
[CPP] 鑒於普通副本
案例 180:
displayOrientation = ISurfaceComposer :: eOrientation180;
打破;
3)。設定表單動畫旋轉方向
一>在架構/底座/核心/ JAVA /機器人/視圖/ Surface.java加入方法
[CPP] 鑒於普通副本
/ **
* @隱藏
* /
公用 靜態 詮釋 getDefaultRotation(){
返回 android.os.SystemProperties.getInt(“ro.sf.hwrotation” ,0); / / 180
}
/ **
* @隱藏
* /
公用 靜態 詮釋 getDefaultRotationIndex(){
整型 旋轉= getDefaultRotation();
開關(旋轉){
情況下 0:
返回 ROTATION_0;
案例 90:
返回 ROTATION_90;
案例 180:
返回 ROTATION_180;
案例 270:
返回 ROTATION_270;
}
返回 ROTATION_0;
}
B>在架構/基地/服務/ JAVA / COM /機器人/伺服器/ VM / ScreenRotationAnimation.java檔案中找到(android4.1)方法setRotation
或(android4.2)方法setRotationInTransaction修改deltaRotation(旋轉,Surface.ROTATION_0);
為deltaRotation(旋轉,表面getDefaultRotationIndex());
4)修改最近程式視圖方向
在架構/底座/包/ systemui / SRC / COM /機器人/ systemui / RecentsPanelView.java檔案中修改如下
私人詮釋mThumbnailHeight ;/ /加
在方法中添加
[CPP] 鑒於普通副本
公用 無效 updateVoluesFromResources(){
........................................................
mThumbnailHeight = Math.round(res.getDimension(R.dimen.status_bar_recents_thumbnail_height)); / /添加
}
在方法中添加
[Java]中 查看純副本
私人 無效 updateThumbnail(...){
否則 {
矩陣scaleMatrix = 新的 矩陣();
浮 規模= mThumbnailWidth /(浮動)thumbnail.getWidth();
scaleMatrix.postScale(刻度,刻度); / / setScale
h.thumbnailViewImage.setScaleType(ScaleType.MATRIX);
h.thumbnailViewImage.setImageMatrix(scaleMatrix);
/ /添加
如果(Surface.getDefaultRotation()> 0 ){
矩陣rotateMatrix = 新的 矩陣();
rotateMatrix.setRotate(Surface.getDefaultRotation(),mThumbnailWidth / 2 ,mThumbnailHeight / 2 );
h.thumbnailViewImage.setImageMatrix(rotateMatrix);
}
/ /添加結束
}
5)。修改截屏圖片方向
在架構/底座/ pacikages / systemui / SRC / COM /機器人/ systemui / GlobalScreenshot.java檔案中找到takeScreenshot方法
修改浮度= getDegreesForRotation(mDisplay.getRotation());
為
[Java]中 查看純副本
整型 旋轉= mDisplay.getRotation();
如果(Surface.getDefaultRotation()> 0 ){
=旋轉(旋轉+ Surface.getDefaultRotationIndex())%4 ;
}
浮 度= getDegreesForRotation(旋轉);
確定這樣就完成旋轉螢幕180度
Android4.0強制橫屏豎屏