Debuging added
This commit is contained in:
parent
707e6e4221
commit
a4ca0d1913
@ -78,7 +78,12 @@ class DumonGeolocation : Plugin() {
|
|||||||
gpsManager = GpsStatusManager(
|
gpsManager = GpsStatusManager(
|
||||||
context,
|
context,
|
||||||
onSatelliteStatusUpdate = { satelliteStatus = it },
|
onSatelliteStatusUpdate = { satelliteStatus = it },
|
||||||
onLocationUpdate = { location, isMocked ->
|
onLocationUpdate = onLocationUpdate@{ location, isMocked ->
|
||||||
|
if (location.latitude == 0.0 && location.longitude == 0.0) {
|
||||||
|
Log.w("GPS_LOCATION", "Ignored location update: (0.0, 0.0)")
|
||||||
|
return@onLocationUpdate
|
||||||
|
}
|
||||||
|
|
||||||
latestLatitude = location.latitude
|
latestLatitude = location.latitude
|
||||||
latestLongitude = location.longitude
|
latestLongitude = location.longitude
|
||||||
latestAccuracy = location.accuracy.toDouble()
|
latestAccuracy = location.accuracy.toDouble()
|
||||||
|
|||||||
@ -80,6 +80,13 @@ class GpsStatusManager(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||||
|
Log.w("GPS_STATUS", "GPS Provider not enabled")
|
||||||
|
}
|
||||||
|
if (!locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
||||||
|
Log.w("GPS_STATUS", "Network Provider not enabled")
|
||||||
|
}
|
||||||
|
|
||||||
locationManager.registerGnssStatusCallback(gnssStatusCallback, null)
|
locationManager.registerGnssStatusCallback(gnssStatusCallback, null)
|
||||||
|
|
||||||
locationManager.requestLocationUpdates(
|
locationManager.requestLocationUpdates(
|
||||||
@ -97,6 +104,23 @@ class GpsStatusManager(
|
|||||||
)
|
)
|
||||||
|
|
||||||
Log.d("GPS_STATUS", "GPS + Network location tracking started")
|
Log.d("GPS_STATUS", "GPS + Network location tracking started")
|
||||||
|
|
||||||
|
// 🔥 Fallback: coba ambil lokasi terakhir
|
||||||
|
val lastKnown = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)
|
||||||
|
?: locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
|
||||||
|
|
||||||
|
lastKnown?.let { location ->
|
||||||
|
if (location.latitude != 0.0 && location.longitude != 0.0) {
|
||||||
|
val isMocked = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
location.isMock
|
||||||
|
} else {
|
||||||
|
location.isFromMockProvider
|
||||||
|
}
|
||||||
|
Log.d("GPS_STATUS", "Using last known location as fallback")
|
||||||
|
onLocationUpdate(location, isMocked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
Log.e("GPS_STATUS", "SecurityException", e)
|
Log.e("GPS_STATUS", "SecurityException", e)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user