方法一:

/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);  }  

更多相关文章

  1. 删除android ScrollView边界阴影方法
  2. Android显示网络图片相关实现方法浅谈
  3. android 中Drawable跟Bitmap转换及常用于图片相关操作方法 - And
  4. Android屏幕自适应的四种方法
  5. Android中隐藏ActionBar的方法
  6. 在线升级android studio的方法
  7. Android View类属性及方法
  8. Android ListView getView()方法重复调用导致position错位
  9. 使用反射调用android API中的hide方法

随机推荐

  1. Eclipse移植Android(安卓)Studio Gradle
  2. Android 的一个简单界面介绍
  3. ADB简单调试技巧及Android(安卓)JNI cras
  4. Android中使用开源框架EventBus3.0实现Fr
  5. android 应用组件[通用 Intent---以视频
  6. Android中XML的命名空间、自定义属性
  7. GitHub优秀的Android(安卓)开源项目(一)
  8. Android listview 表格显示和自动循环显
  9. 从入门到进阶,移动开发架构师学习书单
  10. android sqlite3 show all tables