方法一:

/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中隐藏ActionBar的方法
  5. Android屏幕自适应的四种方法
  6. Android中设置文本颜色的三种方法
  7. 在线升级android studio的方法
  8. Android(安卓)---js与java的相互调用
  9. Android(安卓)View类属性及方法

随机推荐

  1. android 自定义属性的使用
  2. Failed to fetch URL http://dl-ssl.goog
  3. checkbox 与listview 点击事件冲突
  4. CentOS7配置Android打包环境
  5. title上左右按钮
  6. Android xml 深入解析shape
  7. asasasa
  8. Android: Android Reboot流程
  9. android中的tab小结
  10. asss