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

Commit b3e91983 authored by kumarashishg's avatar kumarashishg Committed by Ashish Gupta
Browse files

usb: fix serial number format

usb_device_get_string_ucs2 function is returning the wrong format. usb_device_get_string function to get the correct serial number.

Bug: 281925303
Test: Flash Pixel 5 device and connect Actilino. Actilino should be connected.
Test: Flash Pixel 7 device and connect gnubby. It should be connected
Change-Id: Iab348288d902c4d8e84870c0488713b8f0377bd2
parent 54b9225b
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -63,19 +63,13 @@ jstring JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_getD
        return NULL;
    }

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

    jstring j_str = NULL;

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

    usb_device_close(device);