Location not detected when using fake position

45 views Asked by At

I am implementing a navigation app, and I take the positions update like this:

private fun checkSettingsAndStartLocationUpdates() {

        val request: LocationSettingsRequest =
            LocationSettingsRequest.Builder().addLocationRequest(locationRequest).build()
        val client: SettingsClient = LocationServices.getSettingsClient(requireContext())
        val locationSettingsResponseTask: Task<LocationSettingsResponse> =
            client.checkLocationSettings(request)
        locationSettingsResponseTask.addOnSuccessListener {
            startLocationUpdates()
        }
        locationSettingsResponseTask.addOnFailureListener { e ->
            if (e is ResolvableApiException) {
                try {
                    //e.startResolutionForResult(requireActivity(), 1001)
                    findNavController().navigate(
                        TutorFragmentDirections.toNoGpsSignalFragment(
                            locationRequest
                        )
                    )
                    val services = activity?.application as ApplicationServices?
                    viewModel.stopGeoTrigger(services = services, isGPS = false)
                } catch (ex: IntentSender.SendIntentException) {
                    ex.printStackTrace()
                }
            } else {
                e.printStackTrace()
            }
        }
    }

For testing purpose, I am using Lockito app, that helps me to simulate fake paths on map. The problem is that the method above works with real tests or with Lockito runnung on a Samsung galaxy Note10 Lite, but it doesn't on Huawei p20 pro or Oppo (i don't know the model the tester is using), it goes inside addOnFailureListener.

Are there any things to change on the settings of the phone? Or is a device setting that can't be edited.

0

There are 0 answers