Fix code review feedback: improve error handling and service logic

Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-24 20:12:34 +00:00
parent c9af561868
commit 8675f816de
2 changed files with 5 additions and 4 deletions
@@ -65,7 +65,7 @@ public class DcLocationManager implements Observer {
}
public void stopLocationEngine() {
if (serviceBinder == null && !serviceBound) {
if (serviceBinder == null || !serviceBound) {
return;
}
try {
@@ -53,15 +53,16 @@ public class LocationBackgroundService extends Service {
// Create notification channel if needed
createNotificationChannel();
// Start foreground service with notification
startForeground(NotificationCenter.ID_LOCATION, createNotification());
locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
if (locationManager == null) {
Log.e(TAG, "Unable to initialize location service");
stopSelf();
return;
}
// Start foreground service with notification after successful initialization
startForeground(NotificationCenter.ID_LOCATION, createNotification());
locationListener = new ServiceLocationListener();
Location lastLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (lastLocation != null) {