christianrowlands / android-network-survey

Cellular Survey Android App
https://www.networksurvey.app
Apache License 2.0
165 stars 28 forks source link

crash on startup #48

Closed edisondotme closed 3 months ago

edisondotme commented 3 months ago

Describe the bug App opens momentarily and then crashes

To Reproduce Steps to reproduce the behavior: Open app

Expected behavior A clear and concise description of what you expected to happen. Not crash on start

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Graphene OS, no Google Play services installed.

Additional context Log data:

type: crash
osVersion: google/redfin/redfin:14/UP1A.231105.001.B2/2024071600:user/release-keys
package: com.craxiom.networksurvey:77
process: com.craxiom.networksurvey
processUptime: 1621 + 504 ms
installer: com.looker.droidify

java.lang.NullPointerException: packageName can't be null
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3198)
    at android.os.Parcel.createException(Parcel.java:3176)
    at android.os.Parcel.readException(Parcel.java:3152)
    at android.os.Parcel.readException(Parcel.java:3094)
    at com.android.internal.telephony.ITelephony$Stub$Proxy.requestCellInfoUpdate(ITelephony.java:10064)
    at android.telephony.TelephonyManager.requestCellInfoUpdate(TelephonyManager.java:7154)
    at com.craxiom.networksurvey.services.controller.CellularController$5.run(CellularController.java:669)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.os.HandlerThread.run(HandlerThread.java:85)
christianrowlands commented 3 months ago

Hmm, that is an interesting crash. I am not sure how the packageName can be null, but I will dig into the TelephonyManager and see if I can set it a different way in this edge case.

Thanks for reporting the bug.

christianrowlands commented 3 months ago

I installed Graphene OS on an old Pixel 6 that I have, and I was able to run Network Survey just fine.

I have also dug into the app code as well as the Android OS code, and I am not seeing anything that jumps out at me.

One random (grasping at straws) thought is that it is a permissions problem. If the telephony service has not been granted the proper permissions then maybe it is unable to read the app's package name. Have you approved the proper permissions? You might need to reset the app by deleting all the app's data (via settings or by uninstalling and reinstalling).

I will keep looking into the code, but I am having a hard time reproducing the issue.

edisondotme commented 3 months ago

Thanks for the digging!

I did some further testing though and it seems that the app works correctly when I install it on the owner profile. It does not work when I open it in the other "Android user account" I have on the device.

Try creating a new user and running it from there.

christianrowlands commented 3 months ago

Hmm, it ran fine for me that way also. I simply created a new user called "Test User", switched to that account, and then installed the app from the source via CLI using the --user 10 option to specify the new account. Maybe it has to do with the way the app was installed? Which app store did you use to install Network survey?

christianrowlands commented 3 months ago

Ahh, I was able to reproduce it now. I had the app installed on the "Owner" account still. I uninstalled it there and the crash started happening. However, given this it seems to be an Android bug related to how the manage accounts and getting the package name for apps on the accounts. I will keep digging now that I can reproduce it to see if I can prevent the crash in the app, and I might submit a bug to the Android bug tracker.

edisondotme commented 3 months ago

I originally installed it from F-Droid using the IzzyOnDroid repo. On my owner profile, I downloaded the cdr release from Github.

I tried downloading the Github release on my user profile and installing it from the apk, but same crash result. Compared the SHA-1 of the apk downloaded via Github and F-Droid, they match.

I uninstalled and re-installed various times from both sources and for some reason it is working now. I did not change anything about my device setup, so very strange.

I seem to recall the "package name can't be null" problem happening to me with a different app a long time ago, but I've since forgotten which app.

Thank you anyways for looking into it, but it seems like you can call this issue closed as resolved or not reproducible.

christianrowlands commented 3 months ago

I am good with closing it as it seems to be a problem with Android and not my app. I did open an issue in the Android issue tracker here: https://issuetracker.google.com/issues/356176632

Hopefully they resolve the bug (my guess it is a really easy fix, but I can't say for sure without seeing all the ITelephony code), but for now it sounds like a workaround is to have the app installed on the owner profile as well.

christianrowlands commented 3 weeks ago

@edisondotme , good news. It appears that Google has fixed the issue in Android. I am unsure how long it will take for the fix to start showing up in Android releases, but hopefully this fixes the crash.

https://issuetracker.google.com/issues/356176632

edisondotme commented 3 weeks ago

Great news! Thank you for reporting that to the AOSP issue tracker