rk3288 android6.0 hdmi显示横竖屏切换方法
android hdmi显示横竖屏主要是通过persist.demo.hdmirotation和ro.sf.hwrotation这两个
属性值来控制的 。其中 persist.demo.hdmirotation这个属性值是rockchip平台添加的属性值。
persist.demo.hdmirotation可以赋值portrait(竖屏)或landscape(横屏)
如果persist.demo.hdmirotation=portrait,则ro.sf.hwrotation可以 取值 90或270
如果persist.demo.hdmirotation=landscape,则ro.sf.hwrotation可以 取值 0或180
这部分控制逻辑代码在:frameworks/base/services/core/java/com/android/server/display/LocalDisplayAdapter.java文件的getDisplayDeviceInfoLocked()函数中。
另外persist.demo.hdmirotation需要结合persist.display.portrait使用,ro.sf.hwrotation default为0,不需要改变,实际上改变的是persist.display.portrait
frameworks/base/services/core/java/com/android/server/display/LocalDisplayAdapter.java
final class LocalDisplayAdapter extends DisplayAdapter {
} else {
mInfo.type = Display.TYPE_HDMI;
mInfo.flags |= DisplayDeviceInfo.FLAG_PRESENTATION;
+boolean noRotate = "0".equals(SystemProperties.get("ro.sf.hwrotation"));
+if(noRotate && mBuiltInDisplayId == SurfaceControl.BUILT_IN_DISPLAY_ID_HDMI){
+if (SystemProperties.getBoolean("ro.rotation.external", false)) {
+mInfo.flags |= DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
+ }
+ String value = SystemProperties.get("ro.orientation.einit");
+if ("0".equals(value)) {
+ mInfo.rotation = Surface.ROTATION_0;
+} else if ("90".equals(value)) {
+mInfo.rotation = Surface.ROTATION_90;
+} else if ("180".equals(value)) {
+mInfo.rotation = Surface.ROTATION_180;
+} else if ("270".equals(value)) {
+mInfo.rotation = Surface.ROTATION_270;
+}
+}
mInfo.name = getContext().getResources().getString(
frameworks/native/services/surfaceflinger/DisplayDevice.cpp
void DisplayDevice::setProjection(int orientation,
mClientOrientation = orientation;
orientation = (mHardwareOrientation + orientation) % 4;
}
+ if (mType == DisplayDevice::DISPLAY_EXTERNAL) {
+ mClientOrientation = orientation;
+ if (orientation %2 == 1)
+ frame = Rect(0,0,getHeight(),getWidth());
+ }
device/rockchip/rk3288/system.prop
+ro.same.orientation=true
+ro.rotation.external=true
+ro.orientation.einit=90