fix(driver-app): remove silent stopSelf on location permission warning so background tracking thread always executes
Some checks failed
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Has been cancelled
Some checks failed
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Has been cancelled
This commit is contained in:
@@ -183,15 +183,22 @@ public class TrackingService extends Service {
|
|||||||
try {
|
try {
|
||||||
if (locationManager != null) {
|
if (locationManager != null) {
|
||||||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||||
|
try {
|
||||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 0.0f, locationListener);
|
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 0.0f, locationListener);
|
||||||
|
} catch (SecurityException ignored) {}
|
||||||
}
|
}
|
||||||
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
|
||||||
|
try {
|
||||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000, 0.0f, locationListener);
|
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000, 0.0f, locationListener);
|
||||||
|
} catch (SecurityException ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SecurityException e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "SecurityException: Location permissions not granted", e);
|
Log.e(TAG, "Location permission warning", e);
|
||||||
stopSelf();
|
Intent statusIntent = new Intent(ACTION_LOCATION_BROADCAST);
|
||||||
|
statusIntent.setPackage(getPackageName());
|
||||||
|
statusIntent.putExtra(EXTRA_STATUS, "Location Warning: " + e.getMessage());
|
||||||
|
sendBroadcast(statusIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Start periodic 5-second uploader
|
// 4. Start periodic 5-second uploader
|
||||||
|
|||||||
Reference in New Issue
Block a user