Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6dfa25aa authored by Paul McLean's avatar Paul McLean
Browse files

Using new usbhost function usb_device_get_string_ucs2() to get USB descriptor strings.

Bug: 70163357
Test: Manual - Connect NuForce (micro) DAC. Examine device name descriptor string.
Note also that it doesn't reboot the device on connection. Verify that audio
plays correctly.

Change-Id: I4b607c51a951cf503fde0b485793dfc9e593f932
parent 04c17bec
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -81,16 +81,20 @@ jstring JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_getD
        return NULL;
    }

    char* c_str = usb_device_get_string(device, stringId, 0 /*timeout*/);

    jstring j_str = env->NewStringUTF(c_str);

    free(c_str);
    usb_device_close(device);

    // Get Raw UCS2 Bytes
    jbyte* byteBuffer = NULL;
    size_t numUSC2Bytes = 0;
    int retVal =
            usb_device_get_string_ucs2(device, stringId, 0 /*timeout*/,
                                     (void**)&byteBuffer, &numUSC2Bytes);

    jstring j_str = NULL;

    if (retVal == 0) {
        j_str = env->NewString((jchar*)byteBuffer, numUSC2Bytes/2);
        free(byteBuffer);
    }
    return j_str;
}

} // extern "C"