mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Migrate local account data into SignalStore.
This commit is contained in:
committed by
Cody Henthorne
parent
87f175a96b
commit
8aea20f147
@@ -49,7 +49,7 @@ public class BackgroundMessageRetriever {
|
||||
*/
|
||||
@WorkerThread
|
||||
public boolean retrieveMessages(@NonNull Context context, long showNotificationAfterMs, MessageRetrievalStrategy... strategies) {
|
||||
if (shouldIgnoreFetch(context)) {
|
||||
if (shouldIgnoreFetch()) {
|
||||
Log.i(TAG, "Skipping retrieval -- app is in the foreground.");
|
||||
return true;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class BackgroundMessageRetriever {
|
||||
boolean success = false;
|
||||
|
||||
for (MessageRetrievalStrategy strategy : strategies) {
|
||||
if (shouldIgnoreFetch(context)) {
|
||||
if (shouldIgnoreFetch()) {
|
||||
Log.i(TAG, "Stopping further strategy attempts -- app is in the foreground." + logSuffix(startTime));
|
||||
success = true;
|
||||
break;
|
||||
@@ -121,9 +121,9 @@ public class BackgroundMessageRetriever {
|
||||
* @return True if there is no need to execute a message fetch, because the websocket will take
|
||||
* care of it.
|
||||
*/
|
||||
public static boolean shouldIgnoreFetch(@NonNull Context context) {
|
||||
public static boolean shouldIgnoreFetch() {
|
||||
return ApplicationDependencies.getAppForegroundObserver().isForegrounded() &&
|
||||
!ApplicationDependencies.getSignalServiceNetworkAccess().isCensored(context);
|
||||
!ApplicationDependencies.getSignalServiceNetworkAccess().isCensored();
|
||||
}
|
||||
|
||||
private static String logSuffix(long startTime) {
|
||||
|
||||
@@ -40,6 +40,11 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* The application-level manager of our websocket connection.
|
||||
*
|
||||
* This class is responsible for opening/closing the websocket based on the app's state and observing new inbound messages received on the websocket.
|
||||
*/
|
||||
public class IncomingMessageObserver {
|
||||
|
||||
private static final String TAG = Log.tag(IncomingMessageObserver.class);
|
||||
@@ -71,7 +76,7 @@ public class IncomingMessageObserver {
|
||||
|
||||
new MessageRetrievalThread().start();
|
||||
|
||||
if (TextSecurePreferences.isFcmDisabled(context)) {
|
||||
if (!SignalStore.account().isFcmEnabled()) {
|
||||
ContextCompat.startForegroundService(context, new Intent(context, ForegroundService.class));
|
||||
}
|
||||
|
||||
@@ -117,7 +122,7 @@ public class IncomingMessageObserver {
|
||||
}
|
||||
|
||||
public boolean isDecryptionDrained() {
|
||||
return decryptionDrained || networkAccess.isCensored(context);
|
||||
return decryptionDrained || networkAccess.isCensored();
|
||||
}
|
||||
|
||||
public void notifyDecryptionsDrained() {
|
||||
@@ -147,20 +152,18 @@ public class IncomingMessageObserver {
|
||||
}
|
||||
|
||||
private synchronized boolean isConnectionNecessary() {
|
||||
boolean registered = TextSecurePreferences.isPushRegistered(context);
|
||||
boolean websocketRegistered = TextSecurePreferences.isWebsocketRegistered(context);
|
||||
boolean isGcmDisabled = TextSecurePreferences.isFcmDisabled(context);
|
||||
boolean hasNetwork = NetworkConstraint.isMet(context);
|
||||
boolean hasProxy = SignalStore.proxy().isProxyEnabled();
|
||||
boolean registered = SignalStore.account().isRegistered();
|
||||
boolean fcmEnabled = SignalStore.account().isFcmEnabled();
|
||||
boolean hasNetwork = NetworkConstraint.isMet(context);
|
||||
boolean hasProxy = SignalStore.proxy().isProxyEnabled();
|
||||
|
||||
Log.d(TAG, String.format("Network: %s, Foreground: %s, FCM: %s, Censored: %s, Registered: %s, Websocket Registered: %s, Proxy: %s",
|
||||
hasNetwork, appVisible, !isGcmDisabled, networkAccess.isCensored(context), registered, websocketRegistered, hasProxy));
|
||||
Log.d(TAG, String.format("Network: %s, Foreground: %s, FCM: %s, Censored: %s, Registered: %s, Proxy: %s",
|
||||
hasNetwork, appVisible, fcmEnabled, networkAccess.isCensored(), registered, hasProxy));
|
||||
|
||||
return registered &&
|
||||
websocketRegistered &&
|
||||
(appVisible || isGcmDisabled) &&
|
||||
hasNetwork &&
|
||||
!networkAccess.isCensored(context);
|
||||
return registered &&
|
||||
(appVisible || !fcmEnabled) &&
|
||||
hasNetwork &&
|
||||
!networkAccess.isCensored();
|
||||
}
|
||||
|
||||
private synchronized void waitForConnectionNecessary() {
|
||||
|
||||
@@ -78,7 +78,7 @@ public final class MessageDecryptionUtil {
|
||||
*/
|
||||
public static @NonNull DecryptionResult decrypt(@NonNull Context context, @NonNull SignalServiceEnvelope envelope) {
|
||||
SignalProtocolStore axolotlStore = new SignalProtocolStoreImpl(context);
|
||||
SignalServiceAddress localAddress = new SignalServiceAddress(TextSecurePreferences.getLocalAci(context), Optional.of(TextSecurePreferences.getLocalNumber(context)));
|
||||
SignalServiceAddress localAddress = new SignalServiceAddress(Recipient.self().requireAci(), Recipient.self().requireE164());
|
||||
SignalServiceCipher cipher = new SignalServiceCipher(localAddress, axolotlStore, ReentrantSessionLock.INSTANCE, UnidentifiedAccessUtil.getCertificateValidator());
|
||||
List<Job> jobs = new LinkedList<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user