强制系统横屏竖屏
16lz
2021-01-23
方法一:
/frameworks/base/services/java/com/android/server/wm/WindowManagerService.java
int computeForcedAppOrientationLocked() { int req = getOrientationFromWindowsLocked(); if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { req = getOrientationFromAppTokensLocked(); } // req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; //强制横屏0度 // req = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; //强制竖屏左转90度 return req; }
方法二:
/frameworks/base/services/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; char property[PROPERTY_VALUE_MAX]; if (property_get("ro.sf.hwrotation", property, NULL) > 0) { //displayOrientation switch (atoi(property)) { case 0: displayOrientation = ISurfaceComposer::eOrientationDefault; break; case 90: displayOrientation = ISurfaceComposer::eOrientation90; break; case 180: displayOrientation = ISurfaceComposer::eOrientation180; break; case 270: displayOrientation = ISurfaceComposer::eOrientation270; break; } } /* 强制旋转90度 */ displayOrientation = ISurfaceComposer::eOrientation90; const float w = hw->getWidth(); const float h = hw->getHeight(); GraphicPlane::orientationToTransfrom(displayOrientation, w, h, &mDisplayTransform); }
更多相关文章
- 删除android ScrollView边界阴影方法
- Android显示网络图片相关实现方法浅谈
- android 中Drawable跟Bitmap转换及常用于图片相关操作方法 - And
- Android屏幕自适应的四种方法
- Android中隐藏ActionBar的方法
- 在线升级android studio的方法
- Android View类属性及方法
- Android ListView getView()方法重复调用导致position错位
- 使用反射调用android API中的hide方法