Closed creswick closed 10 years ago
add more reproduction details
I tried sharing a photo, the transmission started w/o errors. Sharing a text file or photo from Andro File Manager did not list QRStream as an option :(.
This NPE is happening in TransmitFragment.transmitData(Job job), in the log message:
Log.i(Constants.APP_TAG, "transmitData title=" + title + " byte count=" + bytes.length);
bytes is apparently null, so the Job is being created with a null parameter (which should probably never happen). Digging into that, this appears to happen every time a file:/// uri is sent (or more generally, any time a dataUrl is shared that does /not/ have the "content" scheme.)
This should crash for any file-manager generated share action.
We should at least set some defensive practices in place:
Any file share from Astro will trigger this, because it sends file:/// urls, but we can't assume that that's the only other url scheme that will show up -- we should be handling them more robustly.
QRstream should crash with a NPE in com.galois.qrstream.lib.TransmitFragment.transmitData(TransmitFragment.java:163) (using master as of the current date).
Added a check for null data in Job, throws Invalid parameter exception. Added file:// URI, works the same as content://.
Could you add a debug log to the (missing) else branch in MainActivity line 204? I could see us being stumped later, and wondering why something is falling through these conditionals -- a log statement will help at runtime and serve as documentation in the source.
Other than that, looks good to merge.
if(dataUrl != null) {
name = getNameFromURI(dataUrl);
if (dataUrl.getScheme().equals("content") ||
dataUrl.getScheme().equals("file")) {
try {
bytes = readFileUri(dataUrl);
} catch (IOException e) {
e.printStackTrace();
}
} else {
// log here.
}
} else {
// fall back to content in extras (mime type dependent)
if(type.equals("text/plain")) {
String body = extras.getString(Intent.EXTRA_SUBJECT) +
extras.getString(Intent.EXTRA_TEXT);
bytes = body.getBytes();
}
}
log statement added, and branch merged with master.
I ran into this with some file transfers initiated on my Nexus 4, using branch #38. Creating a new ticket because I don't think it's related to the changes in #38, although I have not tested on Master.
Reproduction: