Don't prompt for auto-initiate if push registered (or active V2).

This commit is contained in:
Moxie Marlinspike 2014-02-20 12:55:02 -08:00
parent 5b22a7bdcb
commit c5821f770a

View File

@ -26,12 +26,15 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import org.thoughtcrime.securesms.crypto.KeyExchangeInitiator; import org.thoughtcrime.securesms.crypto.KeyExchangeInitiator;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.textsecure.crypto.MasterSecret; import org.whispersystems.textsecure.crypto.MasterSecret;
import org.whispersystems.textsecure.storage.LocalKeyRecord; import org.whispersystems.textsecure.storage.LocalKeyRecord;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.textsecure.storage.RemoteKeyRecord; import org.whispersystems.textsecure.storage.RemoteKeyRecord;
import org.thoughtcrime.securesms.protocol.Tag; import org.thoughtcrime.securesms.protocol.Tag;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.MemoryCleaner; import org.thoughtcrime.securesms.util.MemoryCleaner;
import org.whispersystems.textsecure.storage.SessionRecordV2;
/** /**
* Activity which prompts the user to initiate a secure * Activity which prompts the user to initiate a secure
@ -101,6 +104,7 @@ public class AutoInitiateActivity extends Activity {
{ {
return return
Tag.isTagged(message) && Tag.isTagged(message) &&
TextSecurePreferences.isPushRegistered(context) &&
isThreadQualified(context, threadId) && isThreadQualified(context, threadId) &&
isExchangeQualified(context, masterSecret, recipient); isExchangeQualified(context, masterSecret, recipient);
} }
@ -113,6 +117,7 @@ public class AutoInitiateActivity extends Activity {
private static boolean isExchangeQualified(Context context, MasterSecret masterSecret, Recipient recipient) { private static boolean isExchangeQualified(Context context, MasterSecret masterSecret, Recipient recipient) {
return return
(new RemoteKeyRecord(context,recipient).getCurrentRemoteKey() == null) && (new RemoteKeyRecord(context,recipient).getCurrentRemoteKey() == null) &&
(new LocalKeyRecord(context, masterSecret, recipient).getCurrentKeyPair() == null); (new LocalKeyRecord(context, masterSecret, recipient).getCurrentKeyPair() == null) &&
!SessionRecordV2.hasSession(context, masterSecret, recipient.getRecipientId(), RecipientDevice.DEFAULT_DEVICE_ID);
} }
} }