mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 11:15:44 +00:00
Fix stopForegroundTask crash.
This commit is contained in:
@@ -187,13 +187,13 @@ public final class GenericForegroundService extends Service {
|
||||
return new NotificationController(context, id);
|
||||
}
|
||||
|
||||
public static void stopForegroundTask(@NonNull Context context, int id) {
|
||||
public static void stopForegroundTask(@NonNull Context context, int id) throws UnableToStartException, IllegalStateException {
|
||||
Intent intent = new Intent(context, GenericForegroundService.class);
|
||||
intent.setAction(ACTION_STOP);
|
||||
intent.putExtra(EXTRA_ID, id);
|
||||
|
||||
Log.i(TAG, String.format(Locale.US, "Stopping foreground service id=%d", id));
|
||||
ForegroundServiceUtil.startWhenCapableOrThrow(context, intent);
|
||||
ForegroundServiceUtil.startWhenCapable(context, intent);
|
||||
}
|
||||
|
||||
synchronized void replaceTitle(int id, @NonNull String title) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.os.IBinder;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.jobs.UnableToStartException;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -54,7 +55,7 @@ public final class NotificationController implements AutoCloseable,
|
||||
}
|
||||
|
||||
GenericForegroundService.stopForegroundTask(context, id);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalStateException | UnableToStartException e) {
|
||||
Log.w(TAG, "Failed to unbind service...", e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user