do not attempt endpoint renewal when account is disabled. renew on bind
This commit is contained in:
parent
b1f95d2e39
commit
4ee5c167be
|
@ -84,13 +84,14 @@ public class UnifiedPushDatabase extends SQLiteOpenHelper {
|
|||
|
||||
public List<PushTarget> getRenewals(final String account, final String transport) {
|
||||
final ImmutableList.Builder<PushTarget> renewalBuilder = ImmutableList.builder();
|
||||
// TODO use a date somewhat in the future to account for period renewal triggers
|
||||
final long expiration = System.currentTimeMillis();
|
||||
final SQLiteDatabase sqLiteDatabase = getReadableDatabase();
|
||||
try (final Cursor cursor =
|
||||
sqLiteDatabase.query(
|
||||
"push",
|
||||
new String[] {"application", "instance"},
|
||||
"account <> ? OR transport <> ? OR expiration < "
|
||||
+ System.currentTimeMillis(),
|
||||
"account <> ? OR transport <> ? OR expiration < " + expiration,
|
||||
new String[] {account, transport},
|
||||
null,
|
||||
null,
|
||||
|
@ -112,7 +113,8 @@ public class UnifiedPushDatabase extends SQLiteOpenHelper {
|
|||
sqLiteDatabase.query(
|
||||
"push",
|
||||
new String[] {"application", "endpoint"},
|
||||
"account = ? AND transport = ? AND instance = ? ",
|
||||
"account = ? AND transport = ? AND instance = ? AND endpoint IS NOT NULL AND expiration >= "
|
||||
+ System.currentTimeMillis(),
|
||||
new String[] {account, transport, instance},
|
||||
null,
|
||||
null,
|
||||
|
|
|
@ -34,10 +34,28 @@ public class UnifiedPushBroker {
|
|||
this.service = xmppConnectionService;
|
||||
}
|
||||
|
||||
public void renewUnifiedPushEndpointsOnBind(final Account account) {
|
||||
final Optional<Transport> transport = getTransport();
|
||||
if (transport.isPresent()) {
|
||||
final Account transportAccount = transport.get().account;
|
||||
if (transportAccount != null && transportAccount.getUuid().equals(account.getUuid())) {
|
||||
Log.d(
|
||||
Config.LOGTAG,
|
||||
account.getJid().asBareJid() + ": trigger endpoint renewal on bind");
|
||||
renewUnifiedEndpoint(transport.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<Transport> renewUnifiedPushEndpoints() {
|
||||
final Optional<Transport> transportOptional = getTransport();
|
||||
if (transportOptional.isPresent()) {
|
||||
final Transport transport = transportOptional.get();
|
||||
if (transport.account.isEnabled()) {
|
||||
renewUnifiedEndpoint(transportOptional.get());
|
||||
} else {
|
||||
Log.d(Config.LOGTAG, "skipping UnifiedPush endpoint renewal. Account is disabled");
|
||||
}
|
||||
} else {
|
||||
Log.d(Config.LOGTAG, "skipping UnifiedPush endpoint renewal. No transport selected");
|
||||
}
|
||||
|
|
|
@ -381,6 +381,7 @@ public class XmppConnectionService extends Service {
|
|||
connectMultiModeConversations(account);
|
||||
syncDirtyContacts(account);
|
||||
|
||||
unifiedPushBroker.renewUnifiedPushEndpointsOnBind(account);
|
||||
}
|
||||
};
|
||||
private final AtomicLong mLastExpiryRun = new AtomicLong(0);
|
||||
|
|
Loading…
Reference in a new issue