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