Add a system to improve app foreground observation.

There was previously a crash that occurred when multiple threads tried to use ProcessLifecycleOwner, and this will hopefully resolve that.
This commit is contained in:
Greyson Parrelli
2021-02-08 15:37:45 -05:00
committed by GitHub
parent a160af2d11
commit 3bdf2e7e2c
13 changed files with 147 additions and 49 deletions

View File

@@ -226,7 +226,7 @@ public class KeyCachingService extends Service {
}
private static void startTimeoutIfAppropriate(@NonNull Context context) {
boolean appVisible = ApplicationContext.getInstance(context).isAppVisible();
boolean appVisible = ApplicationDependencies.getAppForegroundObserver().isForegrounded();
boolean secretSet = KeyCachingService.masterSecret != null;
boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(context);

View File

@@ -446,7 +446,7 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
}
public void setCallInProgressNotification(int type, @NonNull Recipient recipient) {
startForeground(CallNotificationBuilder.getNotificationId(getApplicationContext(), type),
startForeground(CallNotificationBuilder.getNotificationId(type),
CallNotificationBuilder.getCallInProgressNotification(this, type, recipient));
}
@@ -480,7 +480,7 @@ public class WebRtcCallService extends Service implements CallManager.Observer,
}
public void startCallCardActivityIfPossible() {
if (Build.VERSION.SDK_INT >= 29 && !ApplicationContext.getInstance(getApplicationContext()).isAppVisible()) {
if (Build.VERSION.SDK_INT >= 29 && !ApplicationDependencies.getAppForegroundObserver().isForegrounded()) {
return;
}