mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user