mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-25 13:17:20 +00:00
Post startService() in onResume() as a possible fix to an Android P bug.
Got confirmation that the crash we're seeing is a bug, and this might be a possible workaround.
This commit is contained in:
parent
92773b1a12
commit
7e485b8095
@ -17,6 +17,7 @@ import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
|||||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
import org.thoughtcrime.securesms.service.MessageRetrievalService;
|
import org.thoughtcrime.securesms.service.MessageRetrievalService;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -60,10 +61,14 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
Log.i(TAG, "onResume()");
|
Log.i(TAG, "onResume()");
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
// Android P has a bug in foreground timings where starting a service in onResume() can still crash
|
||||||
|
Util.postToMain(() -> {
|
||||||
KeyCachingService.registerPassphraseActivityStarted(this);
|
KeyCachingService.registerPassphraseActivityStarted(this);
|
||||||
|
|
||||||
if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this);
|
if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this);
|
||||||
else ApplicationContext.getInstance(this).getJobManager().add(new PushNotificationReceiveJob(this));
|
else ApplicationContext.getInstance(this).getJobManager().add(new PushNotificationReceiveJob(this));
|
||||||
|
});
|
||||||
|
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ import org.thoughtcrime.securesms.service.MessageRetrievalService;
|
|||||||
import org.thoughtcrime.securesms.service.WebRtcCallService;
|
import org.thoughtcrime.securesms.service.WebRtcCallService;
|
||||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
import org.whispersystems.libsignal.IdentityKey;
|
import org.whispersystems.libsignal.IdentityKey;
|
||||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||||
@ -88,7 +89,12 @@ public class WebRtcCallActivity extends Activity {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
Log.i(TAG, "onResume()");
|
Log.i(TAG, "onResume()");
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
// Android P has a bug in foreground timings where starting a service in onResume() can still crash
|
||||||
|
Util.postToMain(() -> {
|
||||||
if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this);
|
if (!networkAccess.isCensored(this)) MessageRetrievalService.registerActivityStarted(this);
|
||||||
|
});
|
||||||
|
|
||||||
initializeScreenshotSecurity();
|
initializeScreenshotSecurity();
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
}
|
}
|
||||||
|
@ -384,6 +384,10 @@ public class Util {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void postToMain(final @NonNull Runnable runnable) {
|
||||||
|
handler.post(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
public static void runOnMain(final @NonNull Runnable runnable) {
|
public static void runOnMain(final @NonNull Runnable runnable) {
|
||||||
if (isMainThread()) runnable.run();
|
if (isMainThread()) runnable.run();
|
||||||
else handler.post(runnable);
|
else handler.post(runnable);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user