Android Open Accessory (AOA)
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Android Open Accessory (AOA)
Hello, i am tying to use the C2 board as client and connect it to device that supports AOA and acts like a host.
When i connect both devices, host device asks the C2 if it supports AOA protocol and C2 respond that it is support AOAv2,
after that Host device send a command to C2 to enter accessory mode but its not happen.
I tried both versions of Android you provide for C2 and since Android version (AOSP) by default supports AOAv2,
my guess that there is something missing or disabled in the Kernel.
Can you please help me with this or point me in the right direction?
When i connect both devices, host device asks the C2 if it supports AOA protocol and C2 respond that it is support AOAv2,
after that Host device send a command to C2 to enter accessory mode but its not happen.
I tried both versions of Android you provide for C2 and since Android version (AOSP) by default supports AOAv2,
my guess that there is something missing or disabled in the Kernel.
Can you please help me with this or point me in the right direction?
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Can I get some attention please? any help are welcome...
- odroid
- Site Admin
- Posts: 29750
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English
- ODROIDs: ODROID
- Contact:
Re: Android Open Accessory (AOA)
We have no idea how to enable the AOAv1 in the current Android platform.
Which device do you want to connect to C2?
Which device do you want to connect to C2?
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
We are working with custom device (Host) that support AOAv2.
Everything works fine and tested on LG, Samsung and AndroidOne (unmodified Android operating system) phones.
C2 board also working fine, until the moment when Host asks him to enter accessory mode and nothing happens.
It looks like C2 just missing something, one think i notice for example:
C2 and manufactured phones both has xml file android.hardware.usb.accessory.xml with next content:
The xml content are exactly the same on C2 and Samsung J5 phone for example, note the jar path:
file="/system/framework/com.android.future.usb.accessory.jar"
Lets find the actual jars paths:
Command: on Odroid C2, give us the next result:
on Samsung J5, give us the next result:
Everything works fine and tested on LG, Samsung and AndroidOne (unmodified Android operating system) phones.
C2 board also working fine, until the moment when Host asks him to enter accessory mode and nothing happens.
It looks like C2 just missing something, one think i notice for example:
C2 and manufactured phones both has xml file android.hardware.usb.accessory.xml with next content:
Code: Select all
<!-- This is the standard feature indicating that the device supports USB accessories. -->
<permissions>
<feature name="android.hardware.usb.accessory" />
<library name="com.android.future.usb.accessory"
file="/system/framework/com.android.future.usb.accessory.jar" />
</permissions>
file="/system/framework/com.android.future.usb.accessory.jar"
Lets find the actual jars paths:
Command:
Code: Select all
adb shell find / -name *accessory* 2>/dev/null | grep accessory
Command:/dev/usb_accessory
/etc/permissions/android.hardware.usb.accessory.xml
/framework/com.android.future.usb.accessory.jar
/framework/oat/arm/com.android.future.usb.accessory.odex
/sys/devices/virtual/misc/usb_accessory
/sys/devices/virtual/android_usb/android0/f_accessory
/sys/class/misc/usb_accessory
/sys/class/android_usb/f_accessory
Code: Select all
adb shell find / -name *accessory* 2>/dev/null | grep accessory
There is a couple of difference here, but the most interesting is that accessory jar sitting in different location on Odroid C2,/system/etc/permissions/android.hardware.usb.accessory.xml
/system/framework/arm/com.android.future.usb.accessory.odex
/system/framework/com.android.future.usb.accessory.jar
/sys/devices/soc0/accessory_chip
/sys/devices/virtual/misc/usb_accessory
/sys/devices/virtual/android_usb/android0/f_accessory
/sys/class/misc/usb_accessory
/sys/class/android_usb/f_accessory
/dev/usb_accessory
- rooted
- Posts: 6355
- Joined: Fri Dec 19, 2014 9:12 am
- languages_spoken: english
- Location: Gulf of Mexico, US
- Contact:
Re: Android Open Accessory (AOA)
Try copying it to the missing location
- odroid
- Site Admin
- Posts: 29750
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English
- ODROIDs: ODROID
- Contact:
Re: Android Open Accessory (AOA)
We will check the AOAv2 functionality with our USB IO board on C2 Android 6.x image.
https://wiki.odroid.com/accessory/add-o ... or_android
https://wiki.odroid.com/accessory/add-o ... or_android
- codewalker
- Posts: 517
- Joined: Mon Feb 25, 2013 11:03 am
- languages_spoken: english
- ODROIDs: all
- Contact:
Re: Android Open Accessory (AOA)
I install this app.
https://play.google.com/store/apps/deta ... DeviceDemo
I connect USB IO Board via USB Host port.
https://www.hardkernel.com/main/product ... 5390529643
https://play.google.com/store/apps/deta ... DeviceDemo
I connect USB IO Board via USB Host port.
https://www.hardkernel.com/main/product ... 5390529643
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Thanks for the work done, but this application does not check operability of the AOAv2/AOAv1 protocols.codewalker wrote:I install this app.
https://play.google.com/store/apps/deta ... DeviceDemo
I connect USB IO Board via USB Host port.
https://www.hardkernel.com/main/product ... 5390529643
Communication through USB works well until the point we want to start communicate via AOAv2 protocol.
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Thank you very much, here is the Android promt that notify the user that he is going to connect to accessory (Never seen on Odroid C2).odroid wrote:We will check the AOAv2 functionality with our USB IO board on C2 Android 6.x image.
https://wiki.odroid.com/accessory/add-o ... or_android
Note: the promt says USB Accessory not USB Device.
This screen shows what happen on manufactured phones when we connect them to custom device (Host) that support AOAv2.
This screen never appear on Odroid C2.
- Attachments
-
- USB Accessory promt
- accessorypromt.png (54.4 KiB) Viewed 1970 times
- odroid
- Site Admin
- Posts: 29750
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English
- ODROIDs: ODROID
- Contact:
Re: Android Open Accessory (AOA)
What is the main difference between V1 and V2?
Our USB IO board was tested by codewalker and it worked in V2 mode correctly.
We don't know how to enable the pop-up since we couldn't find the V1 API in the current Android framework source code.
Did you have a chance to search the Android source code?
Our USB IO board was tested by codewalker and it worked in V2 mode correctly.
We don't know how to enable the pop-up since we couldn't find the V1 API in the current Android framework source code.
Did you have a chance to search the Android source code?
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Difference is in available modes:
codewalker user, does not check operability of the AOA protocols,
the usb communication works well until the point we want to start communicate via AOA protocol.
The popup is just a "flag" that it works, and has nothing to do with the version of the protocol,
just like the codewalker user popup that says "USB Device is connected" has nothing to do with the USB version.
The popup asking for user permission to handle the connection, and asks what application should handle the connection,
his absence simply says that no protocol connection is established and there is nothing to ask or notify the user.
Important note: before we start the AOA communication, we communicate via USB "normally" and it works well, we asks Odroid C2 for its protocol version and he respond, so we have USB communication. The problem starts when we asking the C2 to enter accessory mode, C2 should drop existing usb communication and enter accessory mode and establish communication via AOA protocol.
https://source.android.com/devices/accessories/aoa2AOAv1:
0x2D00 accessory Provides two bulk endpoints for communicating with an Android application.
0x2D01 accessory + adb For debugging purposes during accessory development. Available only if the user has enabled USB Debugging in the Anddroid device settings.
AOAv2:
0x2D02 audio For streaming audio from an Android device to an accessory.
0x2D03 audio + adb
0x2D04 accessory + audio
0x2D05 accessory + audio + adb
codewalker user, does not check operability of the AOA protocols,
the usb communication works well until the point we want to start communicate via AOA protocol.
The popup is just a "flag" that it works, and has nothing to do with the version of the protocol,
just like the codewalker user popup that says "USB Device is connected" has nothing to do with the USB version.
The popup asking for user permission to handle the connection, and asks what application should handle the connection,
his absence simply says that no protocol connection is established and there is nothing to ask or notify the user.
Important note: before we start the AOA communication, we communicate via USB "normally" and it works well, we asks Odroid C2 for its protocol version and he respond, so we have USB communication. The problem starts when we asking the C2 to enter accessory mode, C2 should drop existing usb communication and enter accessory mode and establish communication via AOA protocol.
- codewalker
- Posts: 517
- Joined: Mon Feb 25, 2013 11:03 am
- languages_spoken: english
- ODROIDs: all
- Contact:
Re: Android Open Accessory (AOA)
Hi, some1.
Could you swap jar between j5 and odroid-c2.
I wonder it of the result.
Could you swap jar between j5 and odroid-c2.
I wonder it of the result.
some1 wrote:Difference is in available modes:https://source.android.com/devices/accessories/aoa2AOAv1:
0x2D00 accessory Provides two bulk endpoints for communicating with an Android application.
0x2D01 accessory + adb For debugging purposes during accessory development. Available only if the user has enabled USB Debugging in the Anddroid device settings.
AOAv2:
0x2D02 audio For streaming audio from an Android device to an accessory.
0x2D03 audio + adb
0x2D04 accessory + audio
0x2D05 accessory + audio + adb
codewalker user, does not check operability of the AOA protocols,
the usb communication works well until the point we want to start communicate via AOA protocol.
The popup is just a "flag" that it works, and has nothing to do with the version of the protocol,
just like the codewalker user popup that says "USB Device is connected" has nothing to do with the USB version.
The popup asking for user permission to handle the connection, and asks what application should handle the connection,
his absence simply says that no protocol connection is established and there is nothing to ask or notify the user.
Important note: before we start the AOA communication, we communicate via USB "normally" and it works well, we asks Odroid C2 for its protocol version and he respond, so we have USB communication. The problem starts when we asking the C2 to enter accessory mode, C2 should drop existing usb communication and enter accessory mode and establish communication via AOA protocol.
- tobetter
- Posts: 2691
- Joined: Mon Feb 25, 2013 10:55 am
- languages_spoken: Korean, English
- ODROIDs: X, X2, U2, U3, XU3, C1
- Location: Paju, South Korea
- Contact:
Re: Android Open Accessory (AOA)
@some1, I think the feature is missing in the current Android C2 release. Please let HK team have some time to review it and get back to you. By the way, what ODROID-C2 supposed to be if it can be switched into device mode with your custom hardware? Like HID or Audio?
- tobetter
- Posts: 2691
- Joined: Mon Feb 25, 2013 10:55 am
- languages_spoken: Korean, English
- ODROIDs: X, X2, U2, U3, XU3, C1
- Location: Paju, South Korea
- Contact:
Re: Android Open Accessory (AOA)
@some1, would you be able to change the file init.odroidc2.usb.rc by adding accessary to every single line?
Also you must change the key persist.sys.usb.config in the file /system/default.prop to have accessory whichever you have currently, such that Android Accessory gadget can be activated in the kernel space. For sure, you must reboot your ODROID-C2.
Code: Select all
diff --git a/init.odroidc2.usb.rc b/init.odroidc2.usb.rc
index 9ad2e4c..916c325 100644
--- a/init.odroidc2.usb.rc
+++ b/init.odroidc2.usb.rc
@@ -15,7 +15,7 @@ on boot
write /sys/class/android_usb/android0/f_mass_storage/vendor_string ${ro.usb.vendor.string}
write /sys/class/android_usb/android0/f_mass_storage/product_string ${ro.usb.product.string}
-on property:sys.usb.config=mass_storage
+on property:sys.usb.config=mass_storage,accessory
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
@@ -24,7 +24,7 @@ on property:sys.usb.config=mass_storage
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state ${sys.usb.config}
-on property:sys.usb.config=mass_storage,adb
+on property:sys.usb.config=mass_storage,adb,accessory
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
@@ -34,7 +34,7 @@ on property:sys.usb.config=mass_storage,adb
start adbd
setprop sys.usb.state ${sys.usb.config}
-on property:sys.usb.config=mtp
+on property:sys.usb.config=mtp,accessory
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
@@ -43,7 +43,7 @@ on property:sys.usb.config=mtp
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state ${sys.usb.config}
-on property:sys.usb.config=mtp,adb
+on property:sys.usb.config=mtp,adb,accessory
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
@@ -53,7 +53,7 @@ on property:sys.usb.config=mtp,adb
start adbd
setprop sys.usb.state ${sys.usb.config}
-on property:sys.usb.config=ptp
+on property:sys.usb.config=ptp,accessory
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
@@ -62,7 +62,7 @@ on property:sys.usb.config=ptp
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state ${sys.usb.config}
-on property:sys.usb.config=ptp,adb
+on property:sys.usb.config=ptp,adb,accessory
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Hi tobetter. I will definitely try it today and let you know, thank you very much.tobetter wrote:@some1, would you be able to change the file init.odroidc2.usb.rc by adding accessary to every single line?Also you must change the key persist.sys.usb.config in the file /system/default.prop to have accessory whichever you have currently, such that Android Accessory gadget can be activated in the kernel space. For sure, you must reboot your ODROID-C2.Code: Select all
diff --git a/init.odroidc2.usb.rc b/init.odroidc2.usb.rc index 9ad2e4c..916c325 100644 --- a/init.odroidc2.usb.rc +++ b/init.odroidc2.usb.rc @@ -15,7 +15,7 @@ on boot write /sys/class/android_usb/android0/f_mass_storage/vendor_string ${ro.usb.vendor.string} write /sys/class/android_usb/android0/f_mass_storage/product_string ${ro.usb.product.string} -on property:sys.usb.config=mass_storage +on property:sys.usb.config=mass_storage,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -24,7 +24,7 @@ on property:sys.usb.config=mass_storage write /sys/class/android_usb/android0/enable 1 setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=mass_storage,adb +on property:sys.usb.config=mass_storage,adb,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -34,7 +34,7 @@ on property:sys.usb.config=mass_storage,adb start adbd setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=mtp +on property:sys.usb.config=mtp,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -43,7 +43,7 @@ on property:sys.usb.config=mtp write /sys/class/android_usb/android0/enable 1 setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=mtp,adb +on property:sys.usb.config=mtp,adb,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -53,7 +53,7 @@ on property:sys.usb.config=mtp,adb start adbd setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=ptp +on property:sys.usb.config=ptp,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -62,7 +62,7 @@ on property:sys.usb.config=ptp write /sys/class/android_usb/android0/enable 1 setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=ptp,adb +on property:sys.usb.config=ptp,adb,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1
For your question, what ODROID-C2 supposed to be, well I develop a concept for the customer, in which one of the features is the AndroidAuto.
You can try it by your self by installing Gapps and AndroidAuto apk on C2 and connect it to a car that supports AndroidAuto.
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Sorry for keep you waiting, it doesn't worked, i also tried to add separate "on property" blocks with correct vendor and product ids for each accessory modes that match Google documentation, nothing.tobetter wrote:@some1, would you be able to change the file init.odroidc2.usb.rc by adding accessary to every single line?Also you must change the key persist.sys.usb.config in the file /system/default.prop to have accessory whichever you have currently, such that Android Accessory gadget can be activated in the kernel space. For sure, you must reboot your ODROID-C2.Code: Select all
diff --git a/init.odroidc2.usb.rc b/init.odroidc2.usb.rc index 9ad2e4c..916c325 100644 --- a/init.odroidc2.usb.rc +++ b/init.odroidc2.usb.rc @@ -15,7 +15,7 @@ on boot write /sys/class/android_usb/android0/f_mass_storage/vendor_string ${ro.usb.vendor.string} write /sys/class/android_usb/android0/f_mass_storage/product_string ${ro.usb.product.string} -on property:sys.usb.config=mass_storage +on property:sys.usb.config=mass_storage,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -24,7 +24,7 @@ on property:sys.usb.config=mass_storage write /sys/class/android_usb/android0/enable 1 setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=mass_storage,adb +on property:sys.usb.config=mass_storage,adb,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -34,7 +34,7 @@ on property:sys.usb.config=mass_storage,adb start adbd setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=mtp +on property:sys.usb.config=mtp,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -43,7 +43,7 @@ on property:sys.usb.config=mtp write /sys/class/android_usb/android0/enable 1 setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=mtp,adb +on property:sys.usb.config=mtp,adb,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -53,7 +53,7 @@ on property:sys.usb.config=mtp,adb start adbd setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=ptp +on property:sys.usb.config=ptp,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1 @@ -62,7 +62,7 @@ on property:sys.usb.config=ptp write /sys/class/android_usb/android0/enable 1 setprop sys.usb.state ${sys.usb.config} -on property:sys.usb.config=ptp,adb +on property:sys.usb.config=ptp,adb,accessory stop adbd write /sys/class/android_usb/android0/enable 0 write /sys/class/android_usb/android0/idVendor 18d1
A quick glance you can tell that everything is in place, there is lots of accessory code inside the droid build, odroid even has /dev/usb_accessory ready and waiting for its moment to shine but something is just missing, something in Kernel config maybe, even there are mentions of accessories, moreover they are included. This protocol getting more and more popularity and possibilities with boards like C2 are huge.
- tobetter
- Posts: 2691
- Joined: Mon Feb 25, 2013 10:55 am
- languages_spoken: Korean, English
- ODROIDs: X, X2, U2, U3, XU3, C1
- Location: Paju, South Korea
- Contact:
Re: Android Open Accessory (AOA)
@some1, sorry to hear that it doesn't help you. Would you please have a little bit of patient for some time?
Let me try more carefully and get back to you.
Let me try more carefully and get back to you.
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Hi all, I finally got to find the problem which did not allow to C2 to enter the accessory mode.
I had to assemble several android builds from source (Marshmallow) with a thorough debug
and trace what happened when C2 is connected to a host accessory.
Thank for such a good wiki which made this possible.
At the moment I do not know how to solve the problem itself, but I know how to get around it.
I'm sure that you can fix the faulty code, and everything will work well without the workaround.
Method where the code stopped located in UsbDeviceManager.java class (path below).
Take a look on method nativeGetAccessoryStrings for some reason always returns an array of nulls.
Because of this enableAccessory boolean is always false and the functions string remains null and setCurrentFunctions method is never called here.
If we set hard coded values to mAccessoryStrings after nativeGetAccessoryStrings call, the code continues to run,
and eventually the applications on the phone will get the accessory connected event and will be able to handle the connection via the protocol.
Native methods for this class are located in:
I hope that you will be able to fix the reason why native methods return incorrect values (this native methods communicate with the kernel and the driver).
by the way when you connect C2 to the accessory host sometimes C2 freezes and you need to restart it, I think it's interconnected.
I had to assemble several android builds from source (Marshmallow) with a thorough debug
and trace what happened when C2 is connected to a host accessory.
Thank for such a good wiki which made this possible.
At the moment I do not know how to solve the problem itself, but I know how to get around it.
I'm sure that you can fix the faulty code, and everything will work well without the workaround.
Method where the code stopped located in UsbDeviceManager.java class (path below).
marshmallow/frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java
Code: Select all
private void startAccessoryMode() {
if (!mHasUsbAccessory) return;
mAccessoryStrings = nativeGetAccessoryStrings();
boolean enableAudio = (nativeGetAudioMode() == AUDIO_MODE_SOURCE);
// don't start accessory mode if our mandatory strings have not been set
boolean enableAccessory = (mAccessoryStrings != null &&
mAccessoryStrings[UsbAccessory.MANUFACTURER_STRING] != null &&
mAccessoryStrings[UsbAccessory.MODEL_STRING] != null);
String functions = null;
if (enableAccessory && enableAudio) {
functions = UsbManager.USB_FUNCTION_ACCESSORY + ","
+ UsbManager.USB_FUNCTION_AUDIO_SOURCE;
} else if (enableAccessory) {
functions = UsbManager.USB_FUNCTION_ACCESSORY;
} else if (enableAudio) {
functions = UsbManager.USB_FUNCTION_AUDIO_SOURCE;
}
if (functions != null) {
mAccessoryModeRequestTime = SystemClock.elapsedRealtime();
setCurrentFunctions(functions);
}
}
Because of this enableAccessory boolean is always false and the functions string remains null and setCurrentFunctions method is never called here.
If we set hard coded values to mAccessoryStrings after nativeGetAccessoryStrings call, the code continues to run,
and eventually the applications on the phone will get the accessory connected event and will be able to handle the connection via the protocol.
Code: Select all
mAccessoryStrings = nativeGetAccessoryStrings();
mAccessoryStrings[UsbAccessory.MANUFACTURER_STRING] = "Android";
mAccessoryStrings[UsbAccessory.MODEL_STRING] = "Android";
mAccessoryStrings[UsbAccessory.VERSION_STRING] = "1.0";
marshmallow/frameworks/base/services/core/jni/com_android_server_UsbDeviceManager.cpp
Code: Select all
static jobjectArray android_server_UsbDeviceManager_getAccessoryStrings(JNIEnv *env,
jobject /* thiz */)
{
int fd = open(DRIVER_NAME, O_RDWR);
if (fd < 0) {
ALOGE("could not open %s", DRIVER_NAME);
return NULL;
}
jclass stringClass = env->FindClass("java/lang/String");
jobjectArray strArray = env->NewObjectArray(6, stringClass, NULL);
if (!strArray) goto out;
set_accessory_string(env, fd, ACCESSORY_GET_STRING_MANUFACTURER, strArray, 0);
set_accessory_string(env, fd, ACCESSORY_GET_STRING_MODEL, strArray, 1);
set_accessory_string(env, fd, ACCESSORY_GET_STRING_DESCRIPTION, strArray, 2);
set_accessory_string(env, fd, ACCESSORY_GET_STRING_VERSION, strArray, 3);
set_accessory_string(env, fd, ACCESSORY_GET_STRING_URI, strArray, 4);
set_accessory_string(env, fd, ACCESSORY_GET_STRING_SERIAL, strArray, 5);
out:
close(fd);
return strArray;
}
by the way when you connect C2 to the accessory host sometimes C2 freezes and you need to restart it, I think it's interconnected.
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Hello, can you please express your opinion on my previous post?
By the way the problem with freezing is quite serious since it happens very often.
When C2 freezes, the last events I can see in log:
Please guys I need your opinion and help.
By the way the problem with freezing is quite serious since it happens very often.
When C2 freezes, the last events I can see in log:
When it not freezes I also got the configured event and accessory start event:UsbDeviceManager: USB UEVENT: {USB_STATE=CONNECTED, SUBSYSTEM=android_usb, SEQNUM=2782, ACTION=change, DEVPATH=/devices/virtual/android_usb/android0}
UsbDeviceManager: broadcasting Intent { act=android.hardware.usb.action.USB_STATE flg=0x30000000 (has extras) } connected: true configured: false
In this case everything works great.UsbDeviceManager: USB UEVENT: {USB_STATE=CONNECTED, SUBSYSTEM=android_usb, SEQNUM=2778, ACTION=change, DEVPATH=/devices/virtual/android_usb/android0}
UsbDeviceManager: broadcasting Intent { act=android.hardware.usb.action.USB_STATE flg=0x30000000 (has extras) } connected: true configured: false
UsbDeviceManager: USB UEVENT: {USB_STATE=CONFIGURED, SUBSYSTEM=android_usb, SEQNUM=2779, ACTION=change, DEVPATH=/devices/virtual/android_usb/android0}
UsbDeviceManager: broadcasting Intent { act=android.hardware.usb.action.USB_STATE flg=0x30000000 (has extras) } connected: true configured: true
UsbDeviceManager: USB UEVENT: {DEVNAME=usb_accessory, SUBSYSTEM=misc, SEQNUM=2780, MAJOR=10, ACTION=change, MINOR=46, DEVPATH=/devices/virtual/misc/usb_accessory, ACCESSORY=START}
Please guys I need your opinion and help.
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
Can you express your opinion on my latest posts please?
I think I found all the important places and it will be easy for you to fix this for everyone
who will buy your board in the future for projects with AOA protocol... but you simply ignore me.
I think I found all the important places and it will be easy for you to fix this for everyone
who will buy your board in the future for projects with AOA protocol... but you simply ignore me.
- tobetter
- Posts: 2691
- Joined: Mon Feb 25, 2013 10:55 am
- languages_spoken: Korean, English
- ODROIDs: X, X2, U2, U3, XU3, C1
- Location: Paju, South Korea
- Contact:
Re: Android Open Accessory (AOA)
Sorry, I've tried to fix the issue based on your information whenever I have a time but no success yet. Myself needs a little bit more investigation to resolve it.some1 wrote:Can you express your opinion on my latest posts please?
I think I found all the important places and it will be easy for you to fix this for everyone
who will buy your board in the future for projects with AOA protocol... but you simply ignore me.
-
- Posts: 12
- Joined: Wed Jul 25, 2018 10:52 pm
- languages_spoken: english
- ODROIDs: C2
- Contact:
Re: Android Open Accessory (AOA)
OK, the issue when C2 board stuck/freeze from time to time when connected to accessory is pretty serious.
My thoughts that the problem is with power management, when board switching from 1 power mode to another.
I think the problem laying under ./kernel/drivers/amlogic/usb/dwc_otg/310/ on classes that handle power
C2 and current kernel knowns how to handle the power switch but sometimes the timing is failed and kernel possibly crashed.
From https://source.android.com/devices/accessories/custom
EDIT
Interesting that when connection succeeded once, you can continue connect and disconnect the C2 from the accessory 100 times and will never stack/freeze again
My thoughts that the problem is with power management, when board switching from 1 power mode to another.
I think the problem laying under ./kernel/drivers/amlogic/usb/dwc_otg/310/ on classes that handle power
C2 and current kernel knowns how to handle the power switch but sometimes the timing is failed and kernel possibly crashed.
From https://source.android.com/devices/accessories/custom
Note: Due to the low power output of Android devices, AOA requires accessories to act as a USB host, meaning the connecting accessory must power the bus.
EDIT
Interesting that when connection succeeded once, you can continue connect and disconnect the C2 from the accessory 100 times and will never stack/freeze again
Who is online
Users browsing this forum: No registered users and 8 guests