mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-14 15:38:34 +00:00
Fix crashing during start.
This commit is contained in:
parent
4af63f780c
commit
0b49d7ae0d
@ -81,6 +81,7 @@ import org.webrtc.PeerConnectionFactory;
|
|||||||
import org.webrtc.PeerConnectionFactory.InitializationOptions;
|
import org.webrtc.PeerConnectionFactory.InitializationOptions;
|
||||||
import org.webrtc.voiceengine.WebRtcAudioManager;
|
import org.webrtc.voiceengine.WebRtcAudioManager;
|
||||||
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
||||||
|
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||||
import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider;
|
import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
|
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
|
||||||
@ -160,7 +161,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
||||||
// Loki - Set up P2P API if needed
|
// Loki - Set up P2P API if needed
|
||||||
setUpP2PAPI();
|
setUpP2PAPI();
|
||||||
setUpStorageAPI();
|
|
||||||
// Loki - Set up beta analytics
|
// Loki - Set up beta analytics
|
||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG) {
|
||||||
Fabric.with(this, new Crashlytics());
|
Fabric.with(this, new Crashlytics());
|
||||||
@ -183,6 +183,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
KeyCachingService.onAppForegrounded(this);
|
KeyCachingService.onAppForegrounded(this);
|
||||||
// Loki - Start long polling if needed
|
// Loki - Start long polling if needed
|
||||||
startLongPollingIfNeeded();
|
startLongPollingIfNeeded();
|
||||||
|
setUpStorageAPIIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -411,12 +412,14 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// region Loki
|
// region Loki
|
||||||
public void setUpStorageAPI() {
|
public void setUpStorageAPIIfNeeded() {
|
||||||
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
||||||
|
if (userHexEncodedPublicKey != null && IdentityKeyUtil.hasIdentityKey(this)) {
|
||||||
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize();
|
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize();
|
||||||
LokiAPIDatabaseProtocol database = DatabaseFactory.getLokiAPIDatabase(this);
|
LokiAPIDatabaseProtocol database = DatabaseFactory.getLokiAPIDatabase(this);
|
||||||
LokiStorageAPI.Companion.configure(userHexEncodedPublicKey, userPrivateKey, database);
|
LokiStorageAPI.Companion.configure(userHexEncodedPublicKey, userPrivateKey, database);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setUpP2PAPI() {
|
public void setUpP2PAPI() {
|
||||||
String hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
String hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
||||||
|
@ -1078,7 +1078,8 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
TextSecurePreferences.setIsSecondaryDevice(context, true);
|
TextSecurePreferences.setIsSecondaryDevice(context, true);
|
||||||
|
|
||||||
// Propagate the updates to the file server
|
// Propagate the updates to the file server
|
||||||
LokiStorageAPI.shared.updateOurDeviceMappings();
|
LokiStorageAPI storageAPI = LokiStorageAPI.Companion.getShared();
|
||||||
|
if (storageAPI != null) { storageAPI.updateOurDeviceMappings(); }
|
||||||
|
|
||||||
// TODO: Trigger an event here?
|
// TODO: Trigger an event here?
|
||||||
|
|
||||||
@ -1104,10 +1105,12 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
private void acceptFriendRequestIfNeeded(@NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceContent content) {
|
private void acceptFriendRequestIfNeeded(@NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceContent content) {
|
||||||
LokiThreadDatabase lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
LokiThreadDatabase lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
|
||||||
if (envelope.isFriendRequest()) {
|
if (envelope.isFriendRequest()) {
|
||||||
|
LokiStorageAPI storageAPI = LokiStorageAPI.Companion.getShared();
|
||||||
|
if (storageAPI == null) { return; }
|
||||||
// If we get a friend request then we need to check if the sender is a secondary device.
|
// If we get a friend request then we need to check if the sender is a secondary device.
|
||||||
// If it is then we need to check if we have its primary device as our friend
|
// If it is then we need to check if we have its primary device as our friend
|
||||||
// If so then we add them automatically as a friend
|
// If so then we add them automatically as a friend
|
||||||
LokiStorageAPI.shared.getPrimaryDevice(content.getSender()).success(primaryDevicePubKey -> {
|
storageAPI.getPrimaryDevice(content.getSender()).success(primaryDevicePubKey -> {
|
||||||
// Make sure we have a primary device
|
// Make sure we have a primary device
|
||||||
if (primaryDevicePubKey == null) { return Unit.INSTANCE; }
|
if (primaryDevicePubKey == null) { return Unit.INSTANCE; }
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ class AccountDetailsActivity : BaseActionBarActivity() {
|
|||||||
val application = ApplicationContext.getInstance(this)
|
val application = ApplicationContext.getInstance(this)
|
||||||
application.setUpP2PAPI()
|
application.setUpP2PAPI()
|
||||||
application.startLongPollingIfNeeded()
|
application.startLongPollingIfNeeded()
|
||||||
|
application.setUpStorageAPIIfNeeded()
|
||||||
startActivity(Intent(this, ConversationListActivity::class.java))
|
startActivity(Intent(this, ConversationListActivity::class.java))
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user