microbit-foundation / microbit-android

micro:bit official Android application code. The application is free to download from https://play.google.com/store/apps/details?id=com.samsung.microbit
Apache License 2.0
16 stars 10 forks source link

Device name can be null in some circumstances #61

Closed microbit-matt-hillsdon closed 7 months ago

microbit-matt-hillsdon commented 7 months ago

We didn't reproduce this but based on this crash and similar guards elsewhere in the code this seems a reasonable fix.

https://play.google.com/console/u/0/developers/4695663865375895527/app/4975736116501095047/vitals/crashes/e9abff6694fe9443f6d3423bb5f7b44b/details?days=28&versionCode=57&isUserPerceived=true

martinwork commented 7 months ago

I can't see the link (presumably crash report). The change looks good.

microbit-matt-hillsdon commented 7 months ago

Sorry Martin. Trace from the crash report for context (Android 14):

Exception java.lang.RuntimeException:
  at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0 (LoadedApk.java:1876)
  at android.app.LoadedApk$ReceiverDispatcher$Args.$r8$lambda$gDuJqgxY6Zb-ifyeubKeivTLAwk
  at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run
  at android.os.Handler.handleCallback (Handler.java:958)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:222)
  at android.os.Looper.loop (Looper.java:314)
  at android.app.ActivityThread.main (ActivityThread.java:8706)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:565)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1081)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.isEmpty()' on a null object reference
  at com.samsung.microbit.utils.BLEPair$9.onReceive (BLEPair.java:646)
  at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0 (LoadedApk.java:1866)
martinwork commented 7 months ago

That proves it can happen! I haven't seen it on Android 8.1, 12, 13 or 14. If I had been thinking, I might have checked addr and action too.