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

全部博文(16)

文章存档

2012年(16)

我的朋友

分类: 嵌入式

2012-08-08 11:14:37


点击(此处)折叠或打开

  1. 1. 实现关闭hdmi功能。
  2. a. 在状态栏增加一下按键。
  3.  base/packages/SystemUI/res/layout-sw600dp/status_bar.xml
  4. + <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/power"
  5. + android:layout_width="80dip"
  6. + android:layout_height="match_parent"
  7. + android:src="@drawable/ic_sysbar_power"
  8. + android:contentDescription="@string/accessibility_power"
  9. + systemui:glowBackground="@drawable/ic_sysbar_highlight"
  10. + />

  11. b. 添加状态栏按键activity的监听事件
  12. base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java

  13.  import android.os.Handler;
  14. +import android.os.SystemProperties;
  15. +import android.os.SystemClock;

  16.      private int mMaxNotificationIcons = 5;
  17. + // cjcheng add for hdmi turn off, 2-> off, 1 -> on
  18. + private static final String HDMI_STATUS = "persist.sys.output_mode";

  19.      View mMenuButton;
  20. + View mPowerButton; // cjcheng add for hdmi off

  21.          mHomeButton = mNavigationArea.findViewById(R.id.home);
  22.          mMenuButton = mNavigationArea.findViewById(R.id.menu);
  23. + /* cjcheng add for hdmi off start */
  24. + mPowerButton = mNavigationArea.findViewById(R.id.power);
  25. + mPowerButton.setOnClickListener(mOnClickListener);
  26. + /* cjcheng add for hdmi off end */

  27.     private View.OnClickListener mOnClickListener = new View.OnClickListener() {
  28.         public void onClick(View v) {
  29.             if (v == mRecentButton) {
  30.                 onClickRecentButton();
  31.             } else if (v == mInputMethodSwitchButton) {
  32.                 onClickInputMethodSwitchButton();
  33.             } else if (v == mCompatModeButton) {
  34.                 onClickCompatModeButton();
  35.             }
  36.             /* cjcheng add for hdmi off start */
  37. + else if (v == mPowerButton){
  38. + if (!("2".equals(SystemProperties.get(HDMI_STATUS, "0")))){
  39. + SystemClock.sleep(500);
  40. + SystemProperties.set(HDMI_STATUS, "2");
  41. + SystemClock.sleep(500);
  42. + }
  43. + }
  44.             /* cjcheng add for hdmi off end */
  45.         }
  46.     };

  47. 2. USB鼠标和键盘唤醒HDMI
  48. base/services/input/InputReader.cpp
  49.  #include <cutils/log.h>
  50. +#include <cutils/properties.h>

  51.  namespace android {

  52. +/* cjcheng add for hdmi on start */
  53. +void hdmi_power_on(void)
  54. +{
  55. + char hdmi_status[4];
  56. + property_get("persist.sys.output_mode", hdmi_status, NULL);
  57. + if (strcmp(hdmi_status, "2") == 0)
  58. + property_set("persist.sys.output_mode", "1");
  59. +}
  60. +/* cjcheng add for hdmi on start */
  61. +

  62. // USB鼠标按键唤醒HDMI
  63. void CursorButtonAccumulator::process(const RawEvent* rawEvent) {
  64.     if (rawEvent->type == EV_KEY) {
  65.         switch (rawEvent->scanCode) {
  66.         case BTN_LEFT:
  67.             mBtnLeft = rawEvent->value;
  68.             break;
  69.         case BTN_RIGHT:
  70.             mBtnRight = rawEvent->value;
  71.             break;
  72.         case BTN_MIDDLE:
  73.             mBtnMiddle = rawEvent->value;
  74.             break;
  75.         case BTN_BACK:
  76.             mBtnBack = rawEvent->value;
  77.             break;
  78.         case BTN_SIDE:
  79.             mBtnSide = rawEvent->value;
  80.             break;
  81.         case BTN_FORWARD:
  82.             mBtnForward = rawEvent->value;
  83.             break;
  84.         case BTN_EXTRA:
  85.             mBtnExtra = rawEvent->value;
  86.             break;
  87.         case BTN_TASK:
  88.             mBtnTask = rawEvent->value;
  89.             break;
  90.         }
  91. + hdmi_power_on(); // cjcheng add for hdmi on
  92.     }
  93. }

  94. // USB鼠标移动唤醒HDMI
  95. void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
  96.     if (rawEvent->type == EV_REL) {
  97.         switch (rawEvent->scanCode) {
  98.         case REL_X:
  99.             mRelX = rawEvent->value;
  100.             break;
  101.         case REL_Y:
  102.             mRelY = rawEvent->value;
  103.             break;
  104.         }
  105. + hdmi_power_on(); // cjcheng add for hdmi on
  106.     }
  107. }

  108. // USB键盘唤醒HDMI
  109. void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
  110.         int32_t scanCode, uint32_t policyFlags) {

  111.     if (down) {
  112.         // Rotate key codes according to orientation if needed.
  113.         if (mParameters.orientationAware && mParameters.associatedDisplayId >= 0) {
  114.             keyCode = rotateKeyCode(keyCode, mOrientation);
  115.         }

  116. + hdmi_power_on(); // cjcheng add hdmi on

  117.     ……
  118.    }
  119. }

  120. }

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

houyizi3132013-03-16 15:44:17

博主:最近遇到了android hdmi相关的问题……想研究研究……android hdmi 从哪里入手??????

f8399030612013-02-26 10:40:31

博主我想问一下,android4.0的hdmi和vga兼容性问题
现在我遇到的问题是hdmi和vga两种显示屏同时插在开发板上面,我的系统就会不停的重启,进入不了系统界面
如果只插一个话,修改指定的显示屏是可以,如(disp=0             0:hdmi显示      1:vga显示)
两个同时插就会重启,即使成功的显示了,那么也只有一个能显示正常,别人说这事兼容性问题!
我不知道要修改什么地方!希望博主看到后能给个回复,谢谢
邮箱:839903061@qq.com