Chinaunix首页 | 论坛 | 博客
  • 博客访问: 128215
  • 博文数量: 16
  • 博客积分: 355
  • 博客等级: 一等列兵
  • 技术积分: 237
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-01 22:01
文章分类

全部博文(16)

文章存档

2012年(16)

我的朋友

分类: 嵌入式

2012-07-03 10:28:01


点击(此处)折叠或打开

  1. 方法一:
  2. android4.0/frameworks/base/services/java/com/android/server/wm/WindowManagerService.java

  3.  int computeForcedAppOrientationLocked() {
  4.         int req = getOrientationFromWindowsLocked();
  5.         if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
  6.             req = getOrientationFromAppTokensLocked();
  7.         }

  8.         // req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; //强制横屏0度

  9.     // req = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; //强制竖屏左转90度

  10.         return req;
  11.     }


  12. 方法二:
  13. android4.0/frameworks/base/services/surfaceflinger/SurfaceFlinger.cpp

  14. void GraphicPlane::setDisplayHardware(DisplayHardware *hw)
  15. {
  16.     mHw = hw;

  17.     // initialize the display orientation transform.

  18.     // it's a constant that should come from the display driver.

  19.     int displayOrientation = ISurfaceComposer::eOrientationDefault;
  20.     char property[PROPERTY_VALUE_MAX];
  21.     if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
  22.         //displayOrientation

  23.         switch (atoi(property)) {
  24.         case 0:
  25.             displayOrientation = ISurfaceComposer::eOrientationDefault;
  26.             break;
  27.         case 90:
  28.             displayOrientation = ISurfaceComposer::eOrientation90;
  29.             break;
  30.         case 180:
  31.             displayOrientation = ISurfaceComposer::eOrientation180;
  32.             break;
  33.         case 270:
  34.             displayOrientation = ISurfaceComposer::eOrientation270;
  35.             break;
  36.         }
  37.     }
  38.     /* 强制旋转90度 */
  39.     displayOrientation = ISurfaceComposer::eOrientation90;

  40.     const float w = hw->getWidth();
  41.     const float h = hw->getHeight();
  42.     GraphicPlane::orientationToTransfrom(displayOrientation, w, h,
  43.             &mDisplayTransform);
  44. }

阅读(9169) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

f8399030612012-12-07 15:10:23

您好我想问一下这两者有什么区别吗?
比如播放视频的时候第一种方法可以横屏,第二种连播放视频都是竖屏的?
希望您能指点一下!