barbeau / gpstest

The #1 open-source Android GNSS/GPS test program
Apache License 2.0
1.78k stars 364 forks source link

Crash when device doesn't support GPS #651

Open barbeau opened 1 year ago

barbeau commented 1 year ago

Describe the bug From the Developer console for devices likes tablets that don't support GPS:

Exception java.lang.IllegalArgumentException: provider "gps" does not exist
  at android.os.Parcel.createExceptionOrNull (Parcel.java:2460)
  at android.os.Parcel.createException (Parcel.java:2440)
  at android.os.Parcel.readException (Parcel.java:2423)
  at android.os.Parcel.readException (Parcel.java:2365)
  at android.location.ILocationManager$Stub$Proxy.registerLocationListener (ILocationManager.java:1445)
  at android.location.LocationManager.requestLocationUpdates (LocationManager.java:1498)
  at android.location.LocationManager.requestLocationUpdates (LocationManager.java:1186)
  at android.location.LocationManager.requestLocationUpdates (LocationManager.java:1151)
  at com.android.gpstest.library.data.SharedLocationManager$_locationUpdates$1.invokeSuspend (SharedLocationManager.kt:71)
  at com.android.gpstest.library.data.SharedLocationManager$_locationUpdates$1.invoke
  at com.android.gpstest.library.data.SharedLocationManager$_locationUpdates$1.invoke
  at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo$suspendImpl (Builders.kt:322)
  at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo
  at kotlinx.coroutines.flow.CallbackFlowBuilder.collectTo (Builders.kt:336)
  at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend (ChannelFlow.kt:60)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:570)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:749)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:677)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:664)

To Reproduce Steps to reproduce the behavior:

  1. Start GPSTest on a tablet without GPS support

Expected behavior Show an error message that device doesn't support GPS

Observed behavior App crashes

App, Device and Android version:

Any devices without the GPS_PROVIDER (e.g., tablets)