1*d57664e9SAndroid Build Coastguard WorkerThis directory contains sample code to test the use of virtual 2*d57664e9SAndroid Build Coastguard Workerdisplays created over an Android Open Accessories Protocol link. 3*d57664e9SAndroid Build Coastguard Worker 4*d57664e9SAndroid Build Coastguard Worker--- DESCRIPTION --- 5*d57664e9SAndroid Build Coastguard Worker 6*d57664e9SAndroid Build Coastguard WorkerThere are two applications with two distinct roles: a sink 7*d57664e9SAndroid Build Coastguard Workerand a source. 8*d57664e9SAndroid Build Coastguard Worker 9*d57664e9SAndroid Build Coastguard Worker1. Sink Application 10*d57664e9SAndroid Build Coastguard Worker 11*d57664e9SAndroid Build Coastguard WorkerThe role of the sink is to emulate an external display that happens 12*d57664e9SAndroid Build Coastguard Workerto be connected using the USB accessory protocol. Think of it as 13*d57664e9SAndroid Build Coastguard Workera monitor or video dock that the user will want to plug a phone into. 14*d57664e9SAndroid Build Coastguard Worker 15*d57664e9SAndroid Build Coastguard WorkerThe sink application uses the UsbDevice APIs to receive connections 16*d57664e9SAndroid Build Coastguard Workerfrom the source device over USB. The sink acts as a USB host 17*d57664e9SAndroid Build Coastguard Workerin this arrangement and will provide power to the source. 18*d57664e9SAndroid Build Coastguard Worker 19*d57664e9SAndroid Build Coastguard WorkerThe sink application decodes encoded video from the source and 20*d57664e9SAndroid Build Coastguard Workerdisplays it in a SurfaceView. The sink also injects passes touch 21*d57664e9SAndroid Build Coastguard Workerevents to the source over USB HID. 22*d57664e9SAndroid Build Coastguard Worker 23*d57664e9SAndroid Build Coastguard Worker2. Source Application 24*d57664e9SAndroid Build Coastguard Worker 25*d57664e9SAndroid Build Coastguard WorkerThe role of the source is to present some content onto an external 26*d57664e9SAndroid Build Coastguard Workerdisplay that happens to be attached over USB. This is the typical 27*d57664e9SAndroid Build Coastguard Workerrole that a phone or tablet might have when the user is trying to 28*d57664e9SAndroid Build Coastguard Workerplay content to an external monitor. 29*d57664e9SAndroid Build Coastguard Worker 30*d57664e9SAndroid Build Coastguard WorkerThe source application uses the UsbAccessory APIs to connect 31*d57664e9SAndroid Build Coastguard Workerto the sink device over USB. The source acts as a USB peripheral 32*d57664e9SAndroid Build Coastguard Workerin this arrangement and will receive power from the sink. 33*d57664e9SAndroid Build Coastguard Worker 34*d57664e9SAndroid Build Coastguard WorkerThe source application uses the DisplayManager APIs to create 35*d57664e9SAndroid Build Coastguard Workera private virtual display which passes the framebuffer through 36*d57664e9SAndroid Build Coastguard Workeran encoder and streams the output to the sink over USB. Then 37*d57664e9SAndroid Build Coastguard Workerthe application opens a Presentation on the new virtual display 38*d57664e9SAndroid Build Coastguard Workerand shows a silly cube animation. 39*d57664e9SAndroid Build Coastguard Worker 40*d57664e9SAndroid Build Coastguard Worker--- USAGE --- 41*d57664e9SAndroid Build Coastguard Worker 42*d57664e9SAndroid Build Coastguard WorkerThese applications should be installed on two separate Android 43*d57664e9SAndroid Build Coastguard Workerdevices which are then connected using a USB OTG cable. 44*d57664e9SAndroid Build Coastguard WorkerRemember that the sink device is functioning as the USB host 45*d57664e9SAndroid Build Coastguard Workerso the USB OTG cable should be plugged directly into it. 46*d57664e9SAndroid Build Coastguard Worker 47*d57664e9SAndroid Build Coastguard WorkerWhen connected, the applications should automatically launch 48*d57664e9SAndroid Build Coastguard Workeron each device. The source will then begin to project display 49*d57664e9SAndroid Build Coastguard Workercontents to the sink. 50*d57664e9SAndroid Build Coastguard Worker 51