mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-04 20:34:14 +01:00
Potentially resolve bad service starts on BOOT_COMPLETED.
This commit is contained in:
@@ -18,12 +18,14 @@ package org.thoughtcrime.securesms.service;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.ForegroundServiceStartNotAllowedException;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
|
||||
@@ -285,7 +287,16 @@ public class KeyCachingService extends Service {
|
||||
builder.setContentIntent(buildLaunchIntent());
|
||||
|
||||
stopForeground(true);
|
||||
startForeground(SERVICE_RUNNING_ID, builder.build());
|
||||
|
||||
try {
|
||||
startForeground(SERVICE_RUNNING_ID, builder.build());
|
||||
} catch (Exception e) {
|
||||
if (Build.VERSION.SDK_INT >= 31 && e instanceof ForegroundServiceStartNotAllowedException) {
|
||||
Log.w(TAG, "Not allowed to start foreground service.", e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastNewSecret() {
|
||||
|
||||
Reference in New Issue
Block a user