Bug 932 - Crash on Android: java.lang.NumberFormatException: For input string: "ed72"
Summary: Crash on Android: java.lang.NumberFormatException: For input string: "ed72"
Status: RESOLVED FIXED
Alias: None
Product: PulseView
Classification: Unclassified
Component: Portability (show other bugs)
Version: unreleased development snapshot
Hardware: All Android
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-19 23:04 CEST by Uwe Hermann
Modified: 2017-05-13 15:31 CEST (History)
3 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Hermann 2017-04-19 23:04:09 CEST
There's an issue on Android apparently, log snippet below. This used to work a while ago, must be some recentish regression. I'll see if I can bisect it.

Log:
 D AndroidRuntime: Shutting down VM
 E AndroidRuntime: FATAL EXCEPTION: main
 E AndroidRuntime: Process: org.sigrok.pulseview, PID: 11898
 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.sigrok.pulseview/org.sigrok.pulseview.PulseViewActivity}: java.lang.NumberFormatException: For input string: "ed72"
 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
 E AndroidRuntime:        at android.app.ActivityThread.-wrap14(ActivityThread.java)
 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:102)
 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:154)
 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6688)
 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
 E AndroidRuntime: Caused by: java.lang.NumberFormatException: For input string: "ed72"
 E AndroidRuntime:        at java.lang.Integer.parseInt(Integer.java:521)
 E AndroidRuntime:        at java.lang.Integer.parseInt(Integer.java:556)
 E AndroidRuntime:        at org.sigrok.androidutils.UsbSupplicant$DeviceFilter.read(Unknown Source)
 E AndroidRuntime:        at org.sigrok.androidutils.UsbSupplicant.addDeviceFilters(Unknown Source)
 E AndroidRuntime:        at org.sigrok.androidutils.UsbSupplicant.<init>(Unknown Source)
 E AndroidRuntime:        at org.sigrok.pulseview.PulseViewActivity.onCreate(PulseViewActivity.java:35)
 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:6912)
 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
 E AndroidRuntime:        ... 9 more
 D Debug   : !@DumpState : SHIP
 D Debug   : !@DumpState : debug level:0x4f4c
 D Debug   : !@Dumpstate : Finally, system will skip dumpstate
Comment 1 majenko 2017-04-19 23:46:11 CEST
It seems to be coming from parsing of the device_filter.xml file - "ed72" is a USB product-id:

device_filter.xml: <usb-device vendor-id="0403" product-id="ed72" />

It's the first non-decimal one. I guess it's trying to parse it as decimal, which would be breaking all the others too, since they look decimal but are in fact hex.
Comment 2 Marcus Comstedt 2017-04-19 23:53:05 CEST
The regression was introduced by commit 358e7b42e070e78c986338bafa74ea786eb885bc in sigrok-androidutils, which replaced the numbers _which are supposed to be decimal_ with hex ones.
Comment 3 majenko 2017-04-20 00:41:05 CEST
Decimal VIDs and PIDs are very awkward. Maybe a source (hex) file and conversion script may be in order to generate the real (decimal) file from a list of VID/PID pairs in HEX format.
Comment 4 Uwe Hermann 2017-04-20 02:57:33 CEST
Oops, my bad. Sorry! Is there an easy way to have sigrok-androidutils accept the numbers as hex? Otherwise it should also be doable to have "make update-device-filter" perform a hex->decimal conversion, I guess.
Comment 5 Marcus Comstedt 2017-04-20 08:26:04 CEST
The <usb-device> tag is defined by Google^H^H^H^H^H^HAlphabet.  If we don't want to take over maintainership of Android we should not try to change it.  :-)

Having the make target do a conversion should be fine.
Comment 6 Uwe Hermann 2017-04-20 20:08:10 CEST
Yup, ok. Any volunteers for making "make update-device-filter" do the hex->decimal conversion? Should be doable with sed or awk or perl or such; not sure when I'll have the time to look into this.
Comment 7 majenko 2017-04-20 20:13:54 CEST
Here's some hints that could be of use:

http://stackoverflow.com/questions/4614775/converting-hex-to-decimal-in-awk-or-sed

Not sure about having it as a one-liner considering the format...
Comment 8 Uwe Hermann 2017-05-11 23:10:58 CEST
Fixed in sigrok-androidutils in 2606541de1a91657c0001c0ea573d537069e2332, thanks!

The fix is a even a bit nicer than having the Makefile target generate decimal numbers; it changes sigrok-androidutils to do the conversion in its Java code.

This means the XML file still lists the IDs in hex which makes it easier to compare them against lsusb output or the udev rules file from libsigrok.
Comment 9 Marcus Comstedt 2017-05-12 07:55:44 CEST
That is _not_ nicer.  I thought I explained this:  The <usb-device> tag is an official Android tag defined by Google.  Putting hex numbers in it is incorrect and incompatible use.  In addition to the confusion caused by using the same tag in an incompatibe way, it makes it impossible to use the XML as meta-data for the android.hardware.usb.action.USB_DEVICE_ATTACHED intent, which is also an intended use case...
Comment 10 Uwe Hermann 2017-05-13 15:31:35 CEST
Correct fix my marcus_c merged as 7156d3ec4d9e959d91b7627758dc9004d3a328b6, thanks a lot!