xseignard / cordovarduino

Cordova/Phonegap plugin for USB host serial communication from an Android device.
MIT License
166 stars 112 forks source link

fix StringIndexOutOfBoundsException in Serial.Java #114

Closed okhiroyuki closed 3 years ago

okhiroyuki commented 5 years ago

Proposed changes

fix StringIndexOutOfBoundsException in Serial.java

Details

An error will occur if 0 is assigned to the WriteHex method.

2019-10-26 13:46:05.473 11477-12566/? E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-3
    Process: com.okhiroyuki.redmobile, PID: 11477
    java.lang.StringIndexOutOfBoundsException: length=1; index=1
        at java.lang.String.charAt(Native Method)
        at fr.drangies.cordova.serial.Serial.hexStringToByteArray(Serial.java:342)
        at fr.drangies.cordova.serial.Serial.access$1300(Serial.java:42)
        at fr.drangies.cordova.serial.Serial$5.run(Serial.java:313)
        at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:784)

Results

add throws StringIndexOutOfBoundsException

update success message

Details

In the following method, callbackContext.success is Empty.

Results

add some message