Correctly store destination SMS state.

This commit is contained in:
Moxie Marlinspike 2013-10-20 12:15:36 -07:00
parent 51b9affe90
commit 44d59d0fd1
4 changed files with 10 additions and 9 deletions

View File

@ -109,7 +109,7 @@ public class Directory {
values.put(TOKEN, token.getToken());
values.put(RELAY, token.getRelay());
values.put(REGISTERED, active ? 1 : 0);
values.put(SUPPORTS_SMS, token.isSupportsSms());
values.put(SUPPORTS_SMS, token.isSupportsSms() ? 1 : 0);
values.put(TIMESTAMP, System.currentTimeMillis());
db.replace(TABLE_NAME, null, values);
}
@ -127,6 +127,7 @@ public class Directory {
values.put(REGISTERED, 1);
values.put(TIMESTAMP, timestamp);
values.put(RELAY, token.getRelay());
values.put(SUPPORTS_SMS, token.isSupportsSms() ? 1 : 0);
db.replace(TABLE_NAME, null, values);
}

View File

@ -23,9 +23,9 @@ public class PushDestination {
return relay;
}
public static PushDestination getInstance(Context context,
PushServiceSocket.PushCredentials credentials,
String destinationNumber)
public static PushDestination create(Context context,
PushServiceSocket.PushCredentials credentials,
String destinationNumber)
{
String e164destination = PhoneNumberFormatter.formatNumber(destinationNumber, credentials.getLocalNumber(context));
String relay = Directory.getInstance(context).getRelay(e164destination);

View File

@ -59,8 +59,8 @@ public class PushTransport extends BaseTransport {
TextSecurePushCredentials credentials = TextSecurePushCredentials.getInstance();
Recipient recipient = message.getIndividualRecipient();
PushServiceSocket socket = new PushServiceSocket(context, credentials);
PushDestination destination = PushDestination.getInstance(context, credentials,
recipient.getNumber());
PushDestination destination = PushDestination.create(context, credentials,
recipient.getNumber());
String plaintextBody = message.getBody().getBody();
byte[] plaintext = PushMessageContent.newBuilder()

View File

@ -104,19 +104,19 @@ public class UniversalTransport {
if (mediaMessage.getTo() != null) {
for (EncodedStringValue to : mediaMessage.getTo()) {
destinations.add(PushDestination.getInstance(context, credentials, to.getString()));
destinations.add(PushDestination.create(context, credentials, to.getString()));
}
}
if (mediaMessage.getCc() != null) {
for (EncodedStringValue cc : mediaMessage.getCc()) {
destinations.add(PushDestination.getInstance(context, credentials, cc.getString()));
destinations.add(PushDestination.create(context, credentials, cc.getString()));
}
}
if (mediaMessage.getBcc() != null) {
for (EncodedStringValue bcc : mediaMessage.getBcc()) {
destinations.add(PushDestination.getInstance(context, credentials, bcc.getString()));
destinations.add(PushDestination.create(context, credentials, bcc.getString()));
}
}