SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
1Gary Bisson - ABS2013
Leveraging the Android Open
Accessory Protocol
Gary Bisson
Adeneo Embedded
gbisson@adeneo-embedded.com
Android Builders Summit 2013
2Gary Bisson - ABS2013
Session Overview
• Introduction to Android Open Accessory
• Protocol specifications
• Accessory Development Kit
• Software implementation
• Demonstrations
3Gary Bisson - ABS2013
Who am I?
• Software engineer at Adeneo Embedded
(Bellevue, WA)
– Linux, Android
– Main activities:
• BSP adaptation
• Driver development
• System integration
4Gary Bisson - ABS2013
Introduction to AOA
• Allows USB hardware to interact with an
Android-powered device
– No need for the Android device to act as USB Host
– Standard API
• Introduced in Android 3.1 (API level 12)
– Backported to Android 2.3.4 (API level 10)
• Version 2.0 released with Android 4.1
5Gary Bisson - ABS2013
Introduction to AOA
Accessory
USB
Android Device
USB Connection
USB
Device
USB
Host
ADK Hardware
6Gary Bisson - ABS2013
AOA 1.0 Protocol
• Android Open Accessory 1.0 is a protocol that
allows an Android device to interact with an
Android USB accessory in a special accessory
mode.
• Basically there are four steps to initiate the
communication.
7Gary Bisson - ABS2013
AOA 1.0 Protocol
1. Wait for and detect connected devices
Accessory
Android Device
USB Enumeration
Vendor ID
Product ID
8Gary Bisson - ABS2013
AOA 1.0 Protocol
2. Determine the device’s accessory mode support
Accessory
Android Device
Get Protocol
#51
AOA 1.0/2.0
9Gary Bisson - ABS2013
AOA 1.0 Protocol
• The accessory must check the Vendor &
Product ID’s of the connected device
– Possibility to target some devices
– Detection of devices already in Accessory mode
• If it is already in accessory mode then:
– Vendor ID = 0x18D1 (Google)
– Product ID = 0x2D00 | | 0x2D01
10Gary Bisson - ABS2013
AOA 1.0 Protocol
• Accessory mode product IDs
– 0x2D00 – Supports Accessory Mode
• 1 interface with 2 bulk endpoints
– 0x2D01 – Supports Accessory Mode + ADB
• 2 interfaces with 2 bulk endpoints each
• If it is not in accessory mode then Accessory
mode support can be asked:
– Send a “Get Protocol” request (51) on endpoint 0
• AOA Version (1.0 or 2.0) is returned by Android device
11Gary Bisson - ABS2013
AOA 1.0 Protocol
3. Attempt to start the device in accessory mode
Accessory
Android Device
Identity Strings #52
Start Accessory #53
12Gary Bisson - ABS2013
AOA 1.0 Protocol
• If the AOA Version # is okay, then send string’s
identifying our ADK to the device
– Send “Identity” request (52) for each identifier:
• Manufacturer
• Model Name
• Description
• Version
• URL
• Serial Number
– Send “Start Accessory” request (53) to request the
Android device re-introduce itself on the bus in
accessory mode
13Gary Bisson - ABS2013
AOA 1.0 Protocol
4. Establish communications
Accessory
Android Device
CMD / RESPONSE
14Gary Bisson - ABS2013
AOA 1.0 Protocol
• The accessory must obtain the Bulk endpoints
and be prepared to initiate communication
with the device.
From this point the communication is defined by
the ADK Developer
15Gary Bisson - ABS2013
AOA 2.0 Protocol
• AOA 2.0 was released at Google I/O end of
June 2012 alongside Jelly Bean
• Two new features:
– Audio Output
– Accessory as HID
16Gary Bisson - ABS2013
AOA Protocol version 2.0
• Audio output:
– From an Android device to an accessory
– Standard USB audio class interface (ISO)
– Only supports 2 Channel, 16-bit PCM @ 44100KHz
• To enable the audio support, the accessory
must send a new USB control request:
– “Audio Support” request (58)
17Gary Bisson - ABS2013
AOA Protocol version 2.0
• HID support:
– Registers one or more USB HID with to the
Android device.
– Reverses the direction of communication for
typical USB HID (Host <-> Device).
– Uses USB control requests:
• ACCESSORY_REGISTER_HID
• ACCESSORY_UNREGISTER_HID
• ACCESSORY_SET_HID_REPORT_DESC
• ACCESSORY_SEND_HID_EVENT
18Gary Bisson - ABS2013
AOA Protocol version 2.0
• Compatible with original AOA 1.0 protocol
• Also adds Bluetooth support
– Not the focus of this presentation…
– Example available in ADK source code
19Gary Bisson - ABS2013
AOA 2.0 Protocol
• New Product ID’s
– 0x2D02 – Supports Audio
• 2 Audio interfaces (control + streaming)
– 0x2D03 – Supports Audio + ADB
• 3 interfaces: 2 Audio + 1 Bulk
– 0x2D04 – Supports AOA 1.0 + Audio
• 3 interfaces: 2 Audio + 1 Bulk
– 0x2D05 – Supports AOA 1.0 + Audio + ADB
• 4 interfaces: 2 Audio + 2 Bulk
20Gary Bisson - ABS2013
Accessory Development Kit
• Hardware for ADK 2011 is based on a Arduino
Mega2560
• Hardware for the ADK 2012 is based on an
ARM Cortex M3
• ADK 2012 Guide
21Gary Bisson - ABS2013
What part of AOA do you Control?
• ADK HW
– Schematics provided for the alarm clock
22Gary Bisson - ABS2013
ADK Hardware
• Other solutions?
– Any USB Host capable device that can provide
power to the Android device.
– This is what makes it easy to port the ADK SW to
any ARM-based board
• e.g. Raspberry Pi
• Brings more capabilities (video control…)
23Gary Bisson - ABS2013
What part of AOA do you Control?
• ADK SW
– Developer controls what runs on the ADK HW and
what runs on the Android device
• Google provides sample software:
– Source code repo:
• http://android.googlesource.com/accessories/manifest
– Android device application can apply on any
device with API level > 10
• Android Application presents UI for control, and
communication
24Gary Bisson - ABS2013
ADK Software
• Accessory side:
– Full-featured:
• Accessory
– Basic controls (LEDs, GPIOs)
• Audio
• Bluetooth
– Code is Arduino-specific
• For other solutions, need for a “portable” Accessory
sample code
25Gary Bisson - ABS2013
ADK Software
• Android device side:
– Hardware control
26Gary Bisson - ABS2013
Software implementation
1. Software on the ADK HW
– Handles communication with Android device
– Controls sensors, displays, etc. on the ADK HW
2. Software on the Android device
– Can be installed automatically via pop-up URL on
connection
– Handles communication with ADK HW
– Presents a GUI for control, data input/output from
ADK
27Gary Bisson - ABS2013
Software implementation
In case the software is not already installed:
28Gary Bisson - ABS2013
Software implementation
Otherwise the user must authorize the
execution of the Accessory app:
29Gary Bisson - ABS2013
Application on the Android Device
• Must discover the accessory when it is
attached
• Communicate with the accessory via ADK
Developer defined commands over USB
• Utilizes the USB API in Android
30Gary Bisson - ABS2013
Application on the Android Device
• Android contains two different packages to
support AOA protocol:
– android.hardware.usb
• Works with no add-on library for Android 3.1 or higher
– com.android.future.usb
• From Google API add-on library for Android 2.3.4 or
higher
• Wrapper around android.hardware.usb
• Better choice to support the widest range of devices
31Gary Bisson - ABS2013
Discovering the Accessory
• First add an intent-filter to the application’s
manifest
(AndroidManifest.xml)
32Gary Bisson - ABS2013
Discovering the Accessory
• Then define a resource file that details which
USB Accessory this Application communicates
with
(accessory_filter.xml)
33Gary Bisson - ABS2013
Communication with the Accessory
• Grab the UsbAccessory handle from the Intent
received
• Open up input/output file streams with the
Accessory
(myactivity.java)
34Gary Bisson - ABS2013
Accessory software
• Accessory transfers
– Bulk transfers:
35Gary Bisson - ABS2013
Accessory software
• Audio streaming
– Arduino ADK:
• DMA to DAC
• Simple solution
– Linux implementation?
• ALSA
36Gary Bisson - ABS2013
Accessory software
Circular Buffer
Isochronous USB
Transfer Callback
Audio write()
Thread
Audio
Track API
Audio
Hardware
37Gary Bisson - ABS2013
Accessory software
• HID support:
– 4-step process:
• Register HID device
• Set HID report
– Defines capabilities of the Human Interface
• Send HID reports
• Unregister HID device
38Gary Bisson - ABS2013
Accessory software
• Tool to create your HID report structure:
– HID Descriptor Tool
39Gary Bisson - ABS2013
Demonstrations
• Android Device:
– Stock Nexus 7 Tablet running Android Jellybean
(v4.2.1)
• Custom ARM-based accessory
– Raspberry Pi model B
– Running Linux
40Gary Bisson - ABS2013
Demonstrations
• Why were these particular platforms chosen?
– Raspberry Pi is a very cheap & popular board
nowadays
– Wanted to show ease of using libusb-based code
– Nexus 7 is a recent stock device that needs no
modification
• Any Jellybean device would work the same
41Gary Bisson - ABS2013
Demonstration #1
• Create an accessory device that:
– Displays pictures
– Allows control of the slideshow from Android
• Shows AOA v1.0 capabilities
42Gary Bisson - ABS2013
Demonstration #2
• Create an accessory device that:
– Get ADK app data
– Plays audio
• Shows AOA v2.0 capabilities
– Audio streaming
43Gary Bisson - ABS2013
Demonstration #3
• Create an accessory device that:
– Runs Android as well!
• From Jesse Dannenbring’s presentation:
https://github.com/jdannenbring/android-arm-accessory
• Shows AOA v2.0 capabilities
– Audio streaming
44Gary Bisson - ABS2013
Conclusion
• Interesting standard
– Great flexibility
– Can overcome HW access issues
– Compatibility v2.0 / v1.0
• Limitations
• Full code sources soon available at:
http://github.com/gibsson
45Gary Bisson - ABS2013
Questions?
46Gary Bisson - ABS2013
References
• Based on Jesse Dannenbring’s presentation:
– https://speakerdeck.com/jdannenbring/ad-
2002slides-dannenbring
– https://github.com/jdannenbring/android-arm-
accessory
– https://github.com/jdannenbring/android-arm-
accessory-app
• “Android Developers”.
http://developer.android.com/index.html. 1
February 2013.
47Gary Bisson - ABS2013
References
• Di Cerbo, Manuel. “Turn your Linux computer into a
huge Android USB Accessory” Using Android in
Industrial Automation. 5-13-2011.
http://android.serverbox.ch/?p=262
• “libusb”. http://www.libusb.org/. 1 February 2013.
• “monaka / libusb-android / overview”.
https://bitbucket.org/monaka/libusb-android/. 1
February 2013.
Portions of these slides are reproduced from work created and shared by the Android Open Source Project and used according to
terms described in the Creative Commons 2.5 Attribution License.
48Gary Bisson - ABS2013

Weitere ähnliche Inhalte

Was ist angesagt?

Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security InternalsOpersys inc.
 
Attacking SCADA systems: Story Of SCADASTRANGELOVE
Attacking SCADA systems: Story Of SCADASTRANGELOVEAttacking SCADA systems: Story Of SCADASTRANGELOVE
Attacking SCADA systems: Story Of SCADASTRANGELOVEAleksandr Timorin
 
Controlling USB Flash Drive Controllers: Expose of Hidden Features
Controlling USB Flash Drive Controllers: Expose of Hidden FeaturesControlling USB Flash Drive Controllers: Expose of Hidden Features
Controlling USB Flash Drive Controllers: Expose of Hidden Featuresxabean
 
ESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started GuideESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started Guidehandson28
 
Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Linaro
 
Industrial protocols for pentesters
Industrial protocols for pentestersIndustrial protocols for pentesters
Industrial protocols for pentestersPositive Hack Days
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to ArduinoOmer Kilic
 
Single board computer options
Single board computer optionsSingle board computer options
Single board computer optionsALTANAI BISHT
 
Embedded Development on ESP32 - FEKT VUT - UREL
Embedded Development on ESP32 - FEKT VUT - URELEmbedded Development on ESP32 - FEKT VUT - UREL
Embedded Development on ESP32 - FEKT VUT - URELJuraj Michálek
 
Introduction to Optee (26 may 2016)
Introduction to Optee (26 may 2016)Introduction to Optee (26 may 2016)
Introduction to Optee (26 may 2016)Yannick Gicquel
 
Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...
Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...
Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...Philip Polstra
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelSUSE Labs Taipei
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
 
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)Anne Nicolas
 
Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Egor Elizarov
 

Was ist angesagt? (20)

Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 
Attacking SCADA systems: Story Of SCADASTRANGELOVE
Attacking SCADA systems: Story Of SCADASTRANGELOVEAttacking SCADA systems: Story Of SCADASTRANGELOVE
Attacking SCADA systems: Story Of SCADASTRANGELOVE
 
Aurdino presentation
Aurdino presentationAurdino presentation
Aurdino presentation
 
Controlling USB Flash Drive Controllers: Expose of Hidden Features
Controlling USB Flash Drive Controllers: Expose of Hidden FeaturesControlling USB Flash Drive Controllers: Expose of Hidden Features
Controlling USB Flash Drive Controllers: Expose of Hidden Features
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
How To Build Android for ARM Chip boards
How To Build Android for ARM Chip boardsHow To Build Android for ARM Chip boards
How To Build Android for ARM Chip boards
 
ESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started GuideESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started Guide
 
Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_
 
Industrial protocols for pentesters
Industrial protocols for pentestersIndustrial protocols for pentesters
Industrial protocols for pentesters
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Single board computer options
Single board computer optionsSingle board computer options
Single board computer options
 
Embedded Development on ESP32 - FEKT VUT - UREL
Embedded Development on ESP32 - FEKT VUT - URELEmbedded Development on ESP32 - FEKT VUT - UREL
Embedded Development on ESP32 - FEKT VUT - UREL
 
Introduction to Optee (26 may 2016)
Introduction to Optee (26 may 2016)Introduction to Optee (26 may 2016)
Introduction to Optee (26 may 2016)
 
Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...
Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...
Am I being spied on: Low-tech ways of detecting high-tech surveillance (DEFCO...
 
PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux Kernel
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
Kernel Recipes 2019 - Marvels of Memory Auto-configuration (SPD)
 
Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)Android internals 07 - Android graphics (rev_1.1)
Android internals 07 - Android graphics (rev_1.1)
 
Autism Certificate
Autism CertificateAutism Certificate
Autism Certificate
 

Andere mochten auch

Introduction of Android Auto
Introduction of Android AutoIntroduction of Android Auto
Introduction of Android AutoZaicheng Qi
 
Development, debug and deploy hardware/software solutions based on Android an...
Development, debug and deploy hardware/software solutions based on Android an...Development, debug and deploy hardware/software solutions based on Android an...
Development, debug and deploy hardware/software solutions based on Android an...Илья Родин
 
Seminar on Android Auto
Seminar on Android AutoSeminar on Android Auto
Seminar on Android AutoKiran Krishna
 
Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...Dhruvilkumar patel
 
Headless Android Strikes Back!
Headless Android Strikes Back!Headless Android Strikes Back!
Headless Android Strikes Back!Gary Bisson
 
Google IO 2014 overview
Google IO 2014 overviewGoogle IO 2014 overview
Google IO 2014 overviewBin Yang
 
Useful USB Gadgets on Linux
Useful USB Gadgets on LinuxUseful USB Gadgets on Linux
Useful USB Gadgets on LinuxGary Bisson
 
Quickboot on i.MX6
Quickboot on i.MX6Quickboot on i.MX6
Quickboot on i.MX6Gary Bisson
 
Experience protocol buffer on android
Experience protocol buffer on androidExperience protocol buffer on android
Experience protocol buffer on androidRichard Chang
 
Android OTA updates
Android OTA updatesAndroid OTA updates
Android OTA updatesGary Bisson
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on AndroidGary Bisson
 
[NEXT] Android Profiler 사용법
[NEXT] Android Profiler 사용법 [NEXT] Android Profiler 사용법
[NEXT] Android Profiler 사용법 YoungSu Son
 

Andere mochten auch (18)

Introduction of Android Auto
Introduction of Android AutoIntroduction of Android Auto
Introduction of Android Auto
 
Development, debug and deploy hardware/software solutions based on Android an...
Development, debug and deploy hardware/software solutions based on Android an...Development, debug and deploy hardware/software solutions based on Android an...
Development, debug and deploy hardware/software solutions based on Android an...
 
Seminar on Android Auto
Seminar on Android AutoSeminar on Android Auto
Seminar on Android Auto
 
Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...
 
Headless Android Strikes Back!
Headless Android Strikes Back!Headless Android Strikes Back!
Headless Android Strikes Back!
 
Hacktime for adk
Hacktime for adkHacktime for adk
Hacktime for adk
 
Google IO 2014 overview
Google IO 2014 overviewGoogle IO 2014 overview
Google IO 2014 overview
 
Useful USB Gadgets on Linux
Useful USB Gadgets on LinuxUseful USB Gadgets on Linux
Useful USB Gadgets on Linux
 
Quickboot on i.MX6
Quickboot on i.MX6Quickboot on i.MX6
Quickboot on i.MX6
 
Experience protocol buffer on android
Experience protocol buffer on androidExperience protocol buffer on android
Experience protocol buffer on android
 
Android OTA updates
Android OTA updatesAndroid OTA updates
Android OTA updates
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
 
[NEXT] Android Profiler 사용법
[NEXT] Android Profiler 사용법 [NEXT] Android Profiler 사용법
[NEXT] Android Profiler 사용법
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
MTP & PTP
MTP & PTPMTP & PTP
MTP & PTP
 
Android - ADB
Android - ADBAndroid - ADB
Android - ADB
 

Ähnlich wie Leveraging the Android Open Accessory Protocol

FTF2014 - Android Accessory Protocol
FTF2014 - Android Accessory ProtocolFTF2014 - Android Accessory Protocol
FTF2014 - Android Accessory ProtocolGary Bisson
 
aoa-adk-osidays-rajeshsola
aoa-adk-osidays-rajeshsolaaoa-adk-osidays-rajeshsola
aoa-adk-osidays-rajeshsolaRajesh Sola
 
Android Things, Alexey Rybakov, Technical Evangelist, DataArt
Android Things, Alexey Rybakov, Technical Evangelist, DataArtAndroid Things, Alexey Rybakov, Technical Evangelist, DataArt
Android Things, Alexey Rybakov, Technical Evangelist, DataArtAlina Vilk
 
Lund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & Weave
Lund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & WeaveLund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & Weave
Lund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & WeaveConstantin Musca
 
Brillo/Weave Part 1: High Level Introduction
Brillo/Weave Part 1: High Level IntroductionBrillo/Weave Part 1: High Level Introduction
Brillo/Weave Part 1: High Level IntroductionJalal Rohani
 
Better With Friends: Android+NFC+Arduino
Better With Friends: Android+NFC+ArduinoBetter With Friends: Android+NFC+Arduino
Better With Friends: Android+NFC+ArduinoPearl Chen
 
Embedded System and IoT - ALTEN Calsoft Labs
Embedded System and IoT - ALTEN Calsoft LabsEmbedded System and IoT - ALTEN Calsoft Labs
Embedded System and IoT - ALTEN Calsoft LabsALTEN Calsoft Labs
 
3. Android Architecture.pptx
3. Android Architecture.pptx3. Android Architecture.pptx
3. Android Architecture.pptxHarshiniB11
 
BOX of Illusion MOSEC'17
BOX of Illusion MOSEC'17BOX of Illusion MOSEC'17
BOX of Illusion MOSEC'17Python0x0
 
Bw13 session2 app_dev_presenter_final
Bw13 session2 app_dev_presenter_finalBw13 session2 app_dev_presenter_final
Bw13 session2 app_dev_presenter_finalBlair Poloskey
 
Bring Your Android Apps to BlackBerry 10 in minutes
Bring Your Android Apps to BlackBerry 10 in minutesBring Your Android Apps to BlackBerry 10 in minutes
Bring Your Android Apps to BlackBerry 10 in minutesDr. Ranbijay Kumar
 
Programming objects with android
Programming objects with androidProgramming objects with android
Programming objects with androidfirenze-gtug
 
POLARIS App Player Introduction
POLARIS App Player Introduction POLARIS App Player Introduction
POLARIS App Player Introduction Hyeokgon Ryu
 
Smart home automation
Smart home automationSmart home automation
Smart home automationVikas Rathod
 

Ähnlich wie Leveraging the Android Open Accessory Protocol (20)

FTF2014 - Android Accessory Protocol
FTF2014 - Android Accessory ProtocolFTF2014 - Android Accessory Protocol
FTF2014 - Android Accessory Protocol
 
Android のusb support
Android のusb supportAndroid のusb support
Android のusb support
 
aoa-adk-osidays-rajeshsola
aoa-adk-osidays-rajeshsolaaoa-adk-osidays-rajeshsola
aoa-adk-osidays-rajeshsola
 
Android Things, Alexey Rybakov, Technical Evangelist, DataArt
Android Things, Alexey Rybakov, Technical Evangelist, DataArtAndroid Things, Alexey Rybakov, Technical Evangelist, DataArt
Android Things, Alexey Rybakov, Technical Evangelist, DataArt
 
Lund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & Weave
Lund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & WeaveLund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & Weave
Lund Linux Conference 2016, Lund, Sweden - Introduction to Brillo OS & Weave
 
Brillo/Weave Part 1: High Level Introduction
Brillo/Weave Part 1: High Level IntroductionBrillo/Weave Part 1: High Level Introduction
Brillo/Weave Part 1: High Level Introduction
 
Better With Friends: Android+NFC+Arduino
Better With Friends: Android+NFC+ArduinoBetter With Friends: Android+NFC+Arduino
Better With Friends: Android+NFC+Arduino
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
 
Embedded System and IoT - ALTEN Calsoft Labs
Embedded System and IoT - ALTEN Calsoft LabsEmbedded System and IoT - ALTEN Calsoft Labs
Embedded System and IoT - ALTEN Calsoft Labs
 
JAM805 - Beyond the Device
JAM805 -  Beyond the DeviceJAM805 -  Beyond the Device
JAM805 - Beyond the Device
 
3. Android Architecture.pptx
3. Android Architecture.pptx3. Android Architecture.pptx
3. Android Architecture.pptx
 
BOX of Illusion MOSEC'17
BOX of Illusion MOSEC'17BOX of Illusion MOSEC'17
BOX of Illusion MOSEC'17
 
Android 10-cdd
Android 10-cddAndroid 10-cdd
Android 10-cdd
 
Bw13 session2 app_dev_presenter_final
Bw13 session2 app_dev_presenter_finalBw13 session2 app_dev_presenter_final
Bw13 session2 app_dev_presenter_final
 
Bring Your Android Apps to BlackBerry 10 in minutes
Bring Your Android Apps to BlackBerry 10 in minutesBring Your Android Apps to BlackBerry 10 in minutes
Bring Your Android Apps to BlackBerry 10 in minutes
 
Programming objects with android
Programming objects with androidProgramming objects with android
Programming objects with android
 
POLARIS App Player Introduction
POLARIS App Player Introduction POLARIS App Player Introduction
POLARIS App Player Introduction
 
Android zensar
Android zensarAndroid zensar
Android zensar
 
Smart home automation
Smart home automationSmart home automation
Smart home automation
 
Bt4 0 for_apple
Bt4 0 for_appleBt4 0 for_apple
Bt4 0 for_apple
 

Kürzlich hochgeladen

INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringJuanCarlosMorales19600
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Kürzlich hochgeladen (20)

INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineering
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

Leveraging the Android Open Accessory Protocol

  • 1. 1Gary Bisson - ABS2013 Leveraging the Android Open Accessory Protocol Gary Bisson Adeneo Embedded gbisson@adeneo-embedded.com Android Builders Summit 2013
  • 2. 2Gary Bisson - ABS2013 Session Overview • Introduction to Android Open Accessory • Protocol specifications • Accessory Development Kit • Software implementation • Demonstrations
  • 3. 3Gary Bisson - ABS2013 Who am I? • Software engineer at Adeneo Embedded (Bellevue, WA) – Linux, Android – Main activities: • BSP adaptation • Driver development • System integration
  • 4. 4Gary Bisson - ABS2013 Introduction to AOA • Allows USB hardware to interact with an Android-powered device – No need for the Android device to act as USB Host – Standard API • Introduced in Android 3.1 (API level 12) – Backported to Android 2.3.4 (API level 10) • Version 2.0 released with Android 4.1
  • 5. 5Gary Bisson - ABS2013 Introduction to AOA Accessory USB Android Device USB Connection USB Device USB Host ADK Hardware
  • 6. 6Gary Bisson - ABS2013 AOA 1.0 Protocol • Android Open Accessory 1.0 is a protocol that allows an Android device to interact with an Android USB accessory in a special accessory mode. • Basically there are four steps to initiate the communication.
  • 7. 7Gary Bisson - ABS2013 AOA 1.0 Protocol 1. Wait for and detect connected devices Accessory Android Device USB Enumeration Vendor ID Product ID
  • 8. 8Gary Bisson - ABS2013 AOA 1.0 Protocol 2. Determine the device’s accessory mode support Accessory Android Device Get Protocol #51 AOA 1.0/2.0
  • 9. 9Gary Bisson - ABS2013 AOA 1.0 Protocol • The accessory must check the Vendor & Product ID’s of the connected device – Possibility to target some devices – Detection of devices already in Accessory mode • If it is already in accessory mode then: – Vendor ID = 0x18D1 (Google) – Product ID = 0x2D00 | | 0x2D01
  • 10. 10Gary Bisson - ABS2013 AOA 1.0 Protocol • Accessory mode product IDs – 0x2D00 – Supports Accessory Mode • 1 interface with 2 bulk endpoints – 0x2D01 – Supports Accessory Mode + ADB • 2 interfaces with 2 bulk endpoints each • If it is not in accessory mode then Accessory mode support can be asked: – Send a “Get Protocol” request (51) on endpoint 0 • AOA Version (1.0 or 2.0) is returned by Android device
  • 11. 11Gary Bisson - ABS2013 AOA 1.0 Protocol 3. Attempt to start the device in accessory mode Accessory Android Device Identity Strings #52 Start Accessory #53
  • 12. 12Gary Bisson - ABS2013 AOA 1.0 Protocol • If the AOA Version # is okay, then send string’s identifying our ADK to the device – Send “Identity” request (52) for each identifier: • Manufacturer • Model Name • Description • Version • URL • Serial Number – Send “Start Accessory” request (53) to request the Android device re-introduce itself on the bus in accessory mode
  • 13. 13Gary Bisson - ABS2013 AOA 1.0 Protocol 4. Establish communications Accessory Android Device CMD / RESPONSE
  • 14. 14Gary Bisson - ABS2013 AOA 1.0 Protocol • The accessory must obtain the Bulk endpoints and be prepared to initiate communication with the device. From this point the communication is defined by the ADK Developer
  • 15. 15Gary Bisson - ABS2013 AOA 2.0 Protocol • AOA 2.0 was released at Google I/O end of June 2012 alongside Jelly Bean • Two new features: – Audio Output – Accessory as HID
  • 16. 16Gary Bisson - ABS2013 AOA Protocol version 2.0 • Audio output: – From an Android device to an accessory – Standard USB audio class interface (ISO) – Only supports 2 Channel, 16-bit PCM @ 44100KHz • To enable the audio support, the accessory must send a new USB control request: – “Audio Support” request (58)
  • 17. 17Gary Bisson - ABS2013 AOA Protocol version 2.0 • HID support: – Registers one or more USB HID with to the Android device. – Reverses the direction of communication for typical USB HID (Host <-> Device). – Uses USB control requests: • ACCESSORY_REGISTER_HID • ACCESSORY_UNREGISTER_HID • ACCESSORY_SET_HID_REPORT_DESC • ACCESSORY_SEND_HID_EVENT
  • 18. 18Gary Bisson - ABS2013 AOA Protocol version 2.0 • Compatible with original AOA 1.0 protocol • Also adds Bluetooth support – Not the focus of this presentation… – Example available in ADK source code
  • 19. 19Gary Bisson - ABS2013 AOA 2.0 Protocol • New Product ID’s – 0x2D02 – Supports Audio • 2 Audio interfaces (control + streaming) – 0x2D03 – Supports Audio + ADB • 3 interfaces: 2 Audio + 1 Bulk – 0x2D04 – Supports AOA 1.0 + Audio • 3 interfaces: 2 Audio + 1 Bulk – 0x2D05 – Supports AOA 1.0 + Audio + ADB • 4 interfaces: 2 Audio + 2 Bulk
  • 20. 20Gary Bisson - ABS2013 Accessory Development Kit • Hardware for ADK 2011 is based on a Arduino Mega2560 • Hardware for the ADK 2012 is based on an ARM Cortex M3 • ADK 2012 Guide
  • 21. 21Gary Bisson - ABS2013 What part of AOA do you Control? • ADK HW – Schematics provided for the alarm clock
  • 22. 22Gary Bisson - ABS2013 ADK Hardware • Other solutions? – Any USB Host capable device that can provide power to the Android device. – This is what makes it easy to port the ADK SW to any ARM-based board • e.g. Raspberry Pi • Brings more capabilities (video control…)
  • 23. 23Gary Bisson - ABS2013 What part of AOA do you Control? • ADK SW – Developer controls what runs on the ADK HW and what runs on the Android device • Google provides sample software: – Source code repo: • http://android.googlesource.com/accessories/manifest – Android device application can apply on any device with API level > 10 • Android Application presents UI for control, and communication
  • 24. 24Gary Bisson - ABS2013 ADK Software • Accessory side: – Full-featured: • Accessory – Basic controls (LEDs, GPIOs) • Audio • Bluetooth – Code is Arduino-specific • For other solutions, need for a “portable” Accessory sample code
  • 25. 25Gary Bisson - ABS2013 ADK Software • Android device side: – Hardware control
  • 26. 26Gary Bisson - ABS2013 Software implementation 1. Software on the ADK HW – Handles communication with Android device – Controls sensors, displays, etc. on the ADK HW 2. Software on the Android device – Can be installed automatically via pop-up URL on connection – Handles communication with ADK HW – Presents a GUI for control, data input/output from ADK
  • 27. 27Gary Bisson - ABS2013 Software implementation In case the software is not already installed:
  • 28. 28Gary Bisson - ABS2013 Software implementation Otherwise the user must authorize the execution of the Accessory app:
  • 29. 29Gary Bisson - ABS2013 Application on the Android Device • Must discover the accessory when it is attached • Communicate with the accessory via ADK Developer defined commands over USB • Utilizes the USB API in Android
  • 30. 30Gary Bisson - ABS2013 Application on the Android Device • Android contains two different packages to support AOA protocol: – android.hardware.usb • Works with no add-on library for Android 3.1 or higher – com.android.future.usb • From Google API add-on library for Android 2.3.4 or higher • Wrapper around android.hardware.usb • Better choice to support the widest range of devices
  • 31. 31Gary Bisson - ABS2013 Discovering the Accessory • First add an intent-filter to the application’s manifest (AndroidManifest.xml)
  • 32. 32Gary Bisson - ABS2013 Discovering the Accessory • Then define a resource file that details which USB Accessory this Application communicates with (accessory_filter.xml)
  • 33. 33Gary Bisson - ABS2013 Communication with the Accessory • Grab the UsbAccessory handle from the Intent received • Open up input/output file streams with the Accessory (myactivity.java)
  • 34. 34Gary Bisson - ABS2013 Accessory software • Accessory transfers – Bulk transfers:
  • 35. 35Gary Bisson - ABS2013 Accessory software • Audio streaming – Arduino ADK: • DMA to DAC • Simple solution – Linux implementation? • ALSA
  • 36. 36Gary Bisson - ABS2013 Accessory software Circular Buffer Isochronous USB Transfer Callback Audio write() Thread Audio Track API Audio Hardware
  • 37. 37Gary Bisson - ABS2013 Accessory software • HID support: – 4-step process: • Register HID device • Set HID report – Defines capabilities of the Human Interface • Send HID reports • Unregister HID device
  • 38. 38Gary Bisson - ABS2013 Accessory software • Tool to create your HID report structure: – HID Descriptor Tool
  • 39. 39Gary Bisson - ABS2013 Demonstrations • Android Device: – Stock Nexus 7 Tablet running Android Jellybean (v4.2.1) • Custom ARM-based accessory – Raspberry Pi model B – Running Linux
  • 40. 40Gary Bisson - ABS2013 Demonstrations • Why were these particular platforms chosen? – Raspberry Pi is a very cheap & popular board nowadays – Wanted to show ease of using libusb-based code – Nexus 7 is a recent stock device that needs no modification • Any Jellybean device would work the same
  • 41. 41Gary Bisson - ABS2013 Demonstration #1 • Create an accessory device that: – Displays pictures – Allows control of the slideshow from Android • Shows AOA v1.0 capabilities
  • 42. 42Gary Bisson - ABS2013 Demonstration #2 • Create an accessory device that: – Get ADK app data – Plays audio • Shows AOA v2.0 capabilities – Audio streaming
  • 43. 43Gary Bisson - ABS2013 Demonstration #3 • Create an accessory device that: – Runs Android as well! • From Jesse Dannenbring’s presentation: https://github.com/jdannenbring/android-arm-accessory • Shows AOA v2.0 capabilities – Audio streaming
  • 44. 44Gary Bisson - ABS2013 Conclusion • Interesting standard – Great flexibility – Can overcome HW access issues – Compatibility v2.0 / v1.0 • Limitations • Full code sources soon available at: http://github.com/gibsson
  • 45. 45Gary Bisson - ABS2013 Questions?
  • 46. 46Gary Bisson - ABS2013 References • Based on Jesse Dannenbring’s presentation: – https://speakerdeck.com/jdannenbring/ad- 2002slides-dannenbring – https://github.com/jdannenbring/android-arm- accessory – https://github.com/jdannenbring/android-arm- accessory-app • “Android Developers”. http://developer.android.com/index.html. 1 February 2013.
  • 47. 47Gary Bisson - ABS2013 References • Di Cerbo, Manuel. “Turn your Linux computer into a huge Android USB Accessory” Using Android in Industrial Automation. 5-13-2011. http://android.serverbox.ch/?p=262 • “libusb”. http://www.libusb.org/. 1 February 2013. • “monaka / libusb-android / overview”. https://bitbucket.org/monaka/libusb-android/. 1 February 2013. Portions of these slides are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
  • 48. 48Gary Bisson - ABS2013