named-data-mobile / ndn-photo-app

NDN Photo and File Sharing Application (npChat)
https://redmine.named-data.net/projects/npchat/issues
Other
27 stars 24 forks source link

App crashes when trying to add file from device #184

Open neel1998 opened 4 years ago

neel1998 commented 4 years ago

Summary:

In the files screen, after adding a file from local storage, app immediately crashed

Steps to reproduce:

  1. Go to Files option
  2. Select Share files option
  3. Select a file from device storage

System logs:

    Process: memphis.myapplication, PID: 27776
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65536, result=-1, data=Intent { dat=content://com.android.externalstorage.documents/document/primary:chess.jpg flg=0x43 }} to activity {memphis.myapplication/memphis.myapplication.IntroActivity}: java.lang.StringIndexOutOfBoundsException: String index out of range: -31
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4729)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4771)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1993)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7285)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
     Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -31
        at java.lang.String.substring(String.java:2036)
        at memphis.myapplication.utilities.FileManager.saveFileQR(FileManager.java:286)
        at memphis.myapplication.UI.FilesFragment.onActivityResult(FilesFragment.java:264)
        at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:170)
        at android.app.Activity.dispatchActivityResult(Activity.java:7814)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4722)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4771) 
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1993) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:216) 
        at android.app.ActivityThread.main(ActivityThread.java:7285) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975) 

Device and Android version: Samsung M30s (Android 9)

Screen-shots:

Would you like to work on the issue? Yes

jrandallclark commented 4 years ago

Honestly, while this bug needs to be fixed, the "Share Files" feature likely needs to be disabled until some sort of stream publishing is added to jNDN (or our app directly, if necessary). Right now the size of a file you can share is limited by your phone's memory. I was working on this some last summer, but got pulled away onto other projects and never finished.

jrandallclark commented 4 years ago

You can fix the problem, but I will likely be disabling the feature. I'll just remove the button, but keep all the code. That way we can reuse it when publishing is fixed.

neel1998 commented 4 years ago

Awesome. For now I think let's just make the button invisible, people don't get confused. Is that okay?