Android Open Accessory (AOA)

Moderators: mdrjr, odroid

Android Open Accessory (AOA)

Unread postby some1 » Thu Jul 26, 2018 12:13 am

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?
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby some1 » Wed Aug 01, 2018 5:51 pm

Can I get some attention please? any help are welcome...
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby odroid » Thu Aug 02, 2018 8:47 am

We have no idea how to enable the AOAv1 in the current Android platform.
Which device do you want to connect to C2?
User avatar
odroid
Site Admin
 
Posts: 28510
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Android Open Accessory (AOA)

Unread postby some1 » Thu Aug 02, 2018 11:27 pm

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:

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>

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:
Code: Select all
adb shell find / -name *accessory* 2>/dev/null | grep accessory
on Odroid C2, give us the next result:
/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

Command:
Code: Select all
adb shell find / -name *accessory* 2>/dev/null | grep accessory
on Samsung J5, give us the next result:
/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

There is a couple of difference here, but the most interesting is that accessory jar sitting in different location on Odroid C2,
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby rooted » Fri Aug 03, 2018 2:35 am

Try copying it to the missing location
User avatar
rooted
 
Posts: 5316
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: Android Open Accessory (AOA)

Unread postby odroid » Fri Aug 03, 2018 8:11 am

We will check the AOAv2 functionality with our USB IO board on C2 Android 6.x image.
https://wiki.odroid.com/accessory/add-on_boards/usbioboard#example_host_software_source_code_for_android
User avatar
odroid
Site Admin
 
Posts: 28510
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Android Open Accessory (AOA)

Unread postby codewalker » Fri Aug 03, 2018 10:55 am

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
IMG_20180803_105012.jpg
IMG_20180803_105012.jpg (377.79 KiB) Viewed 692 times


Screenshot_20180803-104251.png
Screenshot_20180803-104251.png (55.71 KiB) Viewed 692 times

Screenshot_20180803-104309.png
Screenshot_20180803-104309.png (44.61 KiB) Viewed 692 times
User avatar
codewalker
 
Posts: 495
Joined: Mon Feb 25, 2013 11:03 am
languages_spoken: english
ODROIDs: all

Re: Android Open Accessory (AOA)

Unread postby some1 » Sun Aug 05, 2018 5:46 pm

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
IMG_20180803_105012.jpg

Screenshot_20180803-104251.png

Screenshot_20180803-104309.png

Thanks for the work done, but this application does not check operability of the AOAv2/AOAv1 protocols.
Communication through USB works well until the point we want to start communicate via AOAv2 protocol.
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby some1 » Sun Aug 05, 2018 6:46 pm

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-on_boards/usbioboard#example_host_software_source_code_for_android

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).
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
accessorypromt.png
USB Accessory promt
accessorypromt.png (54.4 KiB) Viewed 557 times
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby odroid » Mon Aug 06, 2018 10:11 am

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?
User avatar
odroid
Site Admin
 
Posts: 28510
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Android Open Accessory (AOA)

Unread postby some1 » Mon Aug 06, 2018 5:24 pm

Difference is in available modes:
AOAv1:
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

https://source.android.com/devices/accessories/aoa2

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.
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby codewalker » Mon Aug 06, 2018 6:18 pm

Hi, some1.
Could you swap jar between j5 and odroid-c2.
I wonder it of the result.


some1 wrote:Difference is in available modes:
AOAv1:
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

https://source.android.com/devices/accessories/aoa2

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.
User avatar
codewalker
 
Posts: 495
Joined: Mon Feb 25, 2013 11:03 am
languages_spoken: english
ODROIDs: all

Re: Android Open Accessory (AOA)

Unread postby tobetter » Tue Aug 07, 2018 11:40 am

@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: 2238
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Android Open Accessory (AOA)

Unread postby tobetter » Tue Aug 07, 2018 12:39 pm

@some1, would you be able to change the file init.odroidc2.usb.rc by adding accessary to every single line?
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


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.
tobetter
 
Posts: 2238
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Android Open Accessory (AOA)

Unread postby some1 » Tue Aug 07, 2018 5:32 pm

tobetter wrote:@some1, would you be able to change the file init.odroidc2.usb.rc by adding accessary to every single line?
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


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.

Hi tobetter. I will definitely try it today and let you know, thank you very much.
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.
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby some1 » Thu Aug 09, 2018 7:10 pm

tobetter wrote:@some1, would you be able to change the file init.odroidc2.usb.rc by adding accessary to every single line?
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


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.

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.
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.
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2

Re: Android Open Accessory (AOA)

Unread postby tobetter » Thu Aug 09, 2018 10:43 pm

@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.
tobetter
 
Posts: 2238
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Android Open Accessory (AOA)

Unread postby some1 » Thu Aug 16, 2018 7:03 pm

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).
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);
        }
    }

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.
Code: Select all
    mAccessoryStrings = nativeGetAccessoryStrings();
        mAccessoryStrings[UsbAccessory.MANUFACTURER_STRING] = "Android";
        mAccessoryStrings[UsbAccessory.MODEL_STRING] = "Android";
        mAccessoryStrings[UsbAccessory.VERSION_STRING] = "1.0";

Native methods for this class are located in:
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;
}

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.
some1
 
Posts: 9
Joined: Wed Jul 25, 2018 10:52 pm
languages_spoken: english
ODROIDs: C2


Return to Android

Who is online

Users browsing this forum: No registered users and 0 guests