ICS中和HDMI相关的操作放在如下文件中:
硬件相关操作,包括图层混合等:
./hardware/ti/omap4xxx/hwc/hwc.c
有线设备的监听:
./frameworks/base/services/java/com/android/server/WiredAccessoryObserver.java
窗口管理:
./frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Android4.0 framework默认支持hdmi, 工作流程:
HDMI状态改变时driver通过UEvent "DEVPATH=/devices/virtual/switch/hdmi" 上报给系统
-->
系统在PhoneWindowManager中通过UEventObserver中获取状态,并发送
Intent intent = new Intent(ACTION_HDMI_PLUGGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged);
mContext.sendStickyBroadcast(intent);
给其他应用
-->
在应用中接收broadcast ACTION_HDMI_PLUGGED做相应处理
那么如何让你的Hdmi系统匹配android呢:
1) kernel
Hdmi driver中需要创建swtich节点:
/sys/class/switch/hdmi/name
/sys/class/switch/hdmi/state
static struct switch_dev sdev = { .name = "hdmi", }; // driver register switch_dev_register(&sdev); // hdmi plugin switch_set_state(&sdev, 1); // hdmi unplug switch_set_state(&sdev, 0);
处理模式切换,发送WindowManagerPolicy.ACTION_HDMI_PLUGGED
3) app中
处理broadcast WindowManagerPolicy.ACTION_HDMI_PLUGGED