Fix early get self crash when cycling KCS.

This commit is contained in:
Cody Henthorne
2025-01-24 15:25:47 -05:00
committed by Greyson Parrelli
parent fa692690a2
commit db9ae1c85b
2 changed files with 14 additions and 17 deletions

View File

@@ -125,6 +125,11 @@ class DefaultMessageNotifier(context: Application) : MessageNotifier {
) {
NotificationChannels.getInstance().ensureCustomChannelConsistency()
if (!Recipient.isSelfSet) {
Log.w(TAG, "Attempting to update notifications without local self, aborting")
return
}
val currentLockStatus: Boolean = KeyCachingService.isLocked(context)
val currentPrivacyPreference: NotificationPrivacyPreference = SignalStore.settings.messageNotificationsPrivacy
val notificationConfigurationChanged: Boolean = currentLockStatus != previousLockedStatus || currentPrivacyPreference != previousPrivacyPreference

View File

@@ -23,7 +23,6 @@ import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
@@ -34,6 +33,7 @@ import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.DummyActivity;
@@ -121,16 +121,12 @@ public class KeyCachingService extends Service {
foregroundService();
broadcastNewSecret();
startTimeoutIfAppropriate(this);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
if (!ApplicationMigrations.isUpdate(KeyCachingService.this)) {
AppDependencies.getMessageNotifier().updateNotification(KeyCachingService.this);
}
return null;
SignalExecutors.BOUNDED.execute(() -> {
if (!ApplicationMigrations.isUpdate(KeyCachingService.this)) {
AppDependencies.getMessageNotifier().updateNotification(KeyCachingService.this);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
});
}
}
@@ -196,13 +192,9 @@ public class KeyCachingService extends Service {
sendBroadcast(intent, KEY_PERMISSION);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
AppDependencies.getMessageNotifier().updateNotification(KeyCachingService.this);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
SignalExecutors.BOUNDED.execute(() -> {
AppDependencies.getMessageNotifier().updateNotification(KeyCachingService.this);
});
}
private void handleLockToggled() {