Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit c8125e3

Browse files
author
Michael Farb
committed
messenger release 1.8.1.1
- Fixed #87 push registration update scenarios, refresh on install. - Added warning when registration id is out of sync from exchange.
1 parent 3a9aebb commit c8125e3

6 files changed

Lines changed: 41 additions & 11 deletions

File tree

safeslinger-messenger/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2727
package="edu.cmu.cylab.starslinger"
28-
android:versionCode="0x01080100"
29-
android:versionName="1.8.1" >
28+
android:versionCode="0x01080101"
29+
android:versionName="1.8.1.1" >
3030

3131
<!-- API 9 is the minimum required for password-based encryption PBKDF2WithHmacSHA1. -->
3232
<!-- API 8 is the minimum required to receive push messages. -->

safeslinger-messenger/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@
335335
<string name="label_Device">Device:</string>
336336
<!-- screen label (match English casing); used in many UIs to show that receiving push messages is not supported. -->
337337
<string name="label_DeviceInSendOnlyMode">Send-only mode</string>
338+
<!-- error message (sentence case, period); used to warn the user that the push registration ID in the Recipients list screen has been exchanged once before with a different push registration from this user. -->
339+
<string name="label_DisabledExchPushRegChange">Your device has changed: Sling Keys again.</string>
338340
<!-- error message (sentence case, period); used to warn the user that the key in the Recipients list screen has been exchanged once before with a different key from this user. -->
339341
<string name="label_DisabledExchSourceKeyChange">Your key has changed: Sling Keys again.</string>
340342
<!-- screen label (match English casing); used to remind users that an invite is only the beginning, and to Sling Keys before communicating. -->

safeslinger-messenger/src/edu/cmu/cylab/starslinger/SafeSlingerPrefs.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,15 @@ public static void setRemindBackupDelay(boolean remindBackupDelay) {
397397
}
398398

399399
public static String getPushRegistrationId() {
400-
return getString(pref.PUSH_REGISTRATION_ID_DIRECT, null, false);
400+
// add version to get updated push registration every new release
401+
return getString(pref.PUSH_REGISTRATION_ID_DIRECT + SafeSlingerConfig.getVersionName(),
402+
null, false);
401403
}
402404

403405
public static void setPushRegistrationIdWriteOnlyC2dm(String registrationId) {
404-
setString(pref.PUSH_REGISTRATION_ID_DIRECT, registrationId, false);
406+
// add version to get updated push registration every new release
407+
setString(pref.PUSH_REGISTRATION_ID_DIRECT + SafeSlingerConfig.getVersionName(),
408+
registrationId, false);
405409
}
406410

407411
public static long getBackupRequestDate() {

safeslinger-messenger/src/edu/cmu/cylab/starslinger/model/RecipientRow.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,24 @@ public static RecipientRow createKeyIdOnlyRecipient(String keyid) {
7676

7777
public boolean hasMyKeyChanged() {
7878
String myKeyId = SafeSlingerPrefs.getKeyIdString();
79-
return (myKeyId == null ? false : !(myKeyId.compareTo(mMyKeyId) == 0));
79+
if (myKeyId == null) {
80+
return false;
81+
} else if (mMyKeyId == null) {
82+
return myKeyId.equals(mMyKeyId);
83+
} else {
84+
return (myKeyId.compareTo(mMyKeyId) != 0);
85+
}
86+
}
87+
88+
public boolean hasMyPushRegChanged() {
89+
String myPushReg = SafeSlingerPrefs.getPushRegistrationId();
90+
if (myPushReg == null) {
91+
return false;
92+
} else if (mMyPushToken == null) {
93+
return myPushReg.equals(mMyPushToken);
94+
} else {
95+
return (myPushReg.compareTo(mMyPushToken) != 0);
96+
}
8097
}
8198

8299
public boolean isDeprecated() {
@@ -107,7 +124,7 @@ public boolean isRegistered() {
107124

108125
public boolean isSendable() {
109126
return (mActive && isRegistered() && isPushable() && !isDeprecated()
110-
&& isFromTrustedSource() && !hasMyKeyChanged());
127+
&& isFromTrustedSource() && !hasMyKeyChanged() && !hasMyPushRegChanged());
111128
}
112129

113130
public boolean isInvited() {

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/PickRecipientsActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,10 @@ public void doSlingKeys() {
386386
public void doRecipientSelection(RecipientRow recip) {
387387
boolean pushable = recip.isPushable();
388388
boolean fromExch = recip.isFromTrustedSource();
389-
boolean secretChanged = recip.hasMyKeyChanged();
389+
boolean keyChanged = recip.hasMyKeyChanged();
390+
boolean pushChanged = recip.hasMyPushRegChanged();
390391
boolean deprecated = recip.isDeprecated();
391-
boolean useableKey = pushable && !secretChanged && !deprecated && fromExch;
392+
boolean useableKey = pushable && !keyChanged && !pushChanged && !deprecated && fromExch;
392393
if (useableKey) {
393394
Intent data = new Intent();
394395
data.putExtra(extra.RECIPIENT_ROW_ID, recip.getRowId());

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/RecipientAdapter.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ private void drawRecipientRow(View convertView, RecipientRow recip) {
103103
// ensure only push-compatible recipients
104104
boolean pushable = recip.isPushable();
105105
boolean fromExch = recip.isFromTrustedSource();
106-
boolean secretChanged = recip.hasMyKeyChanged();
106+
boolean keyChanged = recip.hasMyKeyChanged();
107+
boolean pushChanged = recip.hasMyPushRegChanged();
107108
boolean deprecated = recip.isDeprecated();
108109
boolean registered = recip.isRegistered();
109-
boolean useableKey = pushable && !secretChanged && !deprecated && fromExch;
110+
boolean useableKey = pushable && !keyChanged && !pushChanged && !deprecated && fromExch;
110111
boolean invited = recip.isInvited();
111112
StringBuilder detailStr = new StringBuilder();
112113

@@ -200,7 +201,12 @@ private void drawRecipientRow(View convertView, RecipientRow recip) {
200201
err.append(" ");
201202
err.append(mContext.getText(R.string.label_TapToSlingKeys));
202203
tvError.setTextAppearance(mContext, R.style.fromDirectionAvailableText);
203-
} else if (secretChanged) { // error: their key out of date
204+
} else if (pushChanged) { // error: their push reg is out of date
205+
if (err.length() > 0)
206+
err.append("\n");
207+
err.append(mContext.getText(R.string.label_DisabledExchPushRegChange));
208+
tvError.setTextAppearance(mContext, R.style.fromFileExpiredText);
209+
} else if (keyChanged) { // error: their key out of date
204210
if (err.length() > 0)
205211
err.append("\n");
206212
err.append(mContext.getText(R.string.label_DisabledExchSourceKeyChange));

0 commit comments

Comments
 (0)