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

Commit e1a67fab authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 6c4f2de9 6dfa25aa
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"