OpenArchive / Save-app-android-old

This is the Save app for Android
https://open-archive.org
GNU General Public License v3.0
94 stars 26 forks source link

crash on app start when tor/onion routing enabled (ANR) #534

Open uniqx opened 5 months ago

uniqx commented 5 months ago

To Reproduce Steps to reproduce the behavior:

(On android 14)

  1. install Orbot
  2. Start Save app and go to settings and enable onion routing setting
  3. force stop Save app in android settings
  4. launch Save app

Expected behavior App staring

Observed behavior App crashing instead of launching

Environment (please complete the following information):

Additional context

Here's the fatal exception:

FATAL EXCEPTION: main
Process: net.opendasharchive.openarchive.release, PID: 8921
    java.lang.RuntimeException: Unable to create application net.opendasharchive.openarchive.SaveApp: java.lang.SecurityException: net.opendasharchive.openarchive.release: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7003)
    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8177)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.SecurityException: net.opendasharchive.openarchive.release: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
    at android.os.Parcel.createException(Parcel.java:3041)
    at android.os.Parcel.readException(Parcel.java:3024)
    at android.os.Parcel.readException(Parcel.java:2966)
    at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684)
    at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1852)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1780)
    at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
    at info.guardianproject.netcipher.proxy.OrbotHelper.init(OrbotHelper.java:665)
    at net.opendasharchive.openarchive.SaveApp.initNetCipher(SaveApp.kt:52)
    at net.opendasharchive.openarchive.SaveApp.onCreate(SaveApp.kt:32)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998)
    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loopOnce(Looper.java:205) 
    at android.os.Looper.loop(Looper.java:294) 
    at android.app.ActivityThread.main(ActivityThread.java:8177) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 
Caused by: android.os.RemoteException: Remote stack trace:
    at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
    at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
    at android.os.Binder.execTransactInternal(Binder.java:1339)
    at android.os.Binder.execTransact(Binder.java:1275)

This might also help: https://stackoverflow.com/questions/77235063/one-of-receiver-exported-or-receiver-not-exported-should-be-specified-when-a-rec

foundscapes commented 5 months ago

@purvi-ranawat please test

purvi-ranawat commented 5 months ago

@foundscapes / @uniqx : Save App is not crashing for me after following the mentioned steps.

This is working fine for me on Android 13

Environment :

OS : Android 13 Device : Samsung Galaxy A13 Build : 0.3.0

uniqx commented 5 months ago

This issue is specific to Android 14 and above. It will not occur on older Android version.

purvi-ranawat commented 5 months ago

@uniqx / @foundscapes : I have tested on Android 14 and I am able to reproduce the issue.

Environment :

OS : Android 14 Device : OnePlus Nord 3 CE Lite Build Version : 0.3.0

ryjen commented 4 months ago

Don't know if your working on this @uniqx but this PR could help.

https://github.com/OpenArchive/Save-app-android/pull/552

ryjen commented 4 months ago

Don't know if your working on this @uniqx but this PR could help.

552

Doing my testing now, the quick fix did not help. More investigation needed to keep secure.

uniqx commented 4 months ago

I've tried to fix it, but NetCipher is in pretty bad shape. I've tried a couple of things without success:

So to get rid of the Crash I think the best route for now is to disable the feature on Android 14 and above. Especially since we might be switching to TorServices at some point. (Users that absolutely need run Save over the Tor network can use Orbot VPN to accomplish that, that'll always work without any integrations on our end.)

foundscapes commented 4 months ago

@tladesignz will the updates in Orbot or integrating Tor resolve this issue for android? we need to make sure it's working for all OS versions, including 14+ any ideas?

tladesignz commented 4 months ago

@tladesignz will the updates in Orbot or integrating Tor resolve this issue for android? we need to make sure it's working for all OS versions, including 14+ any ideas?

We talked about this yesterday, so just for documentation purposes:

Tor/Orbot on Android is a completely different thing than Tor/Orbot on iOS. Save will stay exclusively on Orbot support. It's tried and tested on Android. This is just a minor issue about a library dependency, which @uniqx will replace with a inlined fixed version.