mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 04:25:18 +00:00
Fix false-positive outage detection.
Turns out that there's some weird quasi-state when you come out of airplane mode, that if you do an InetAdress lookup, it returns some weird IPv6-looking garbage address. Going to retry in that scenario instead of assuming an outage.
This commit is contained in:
parent
f8747748f9
commit
3a85c966d0
@ -44,16 +44,17 @@ public class ServiceOutageDetectionJob extends ContextJob {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
InetAddress address = InetAddress.getByName(BuildConfig.SIGNAL_SERVICE_STATUS_URL);
|
InetAddress address = InetAddress.getByName(BuildConfig.SIGNAL_SERVICE_STATUS_URL);
|
||||||
|
Log.i(TAG, "Received outage check address: " + address.getHostAddress());
|
||||||
|
|
||||||
if (IP_SUCCESS.equals(address.getHostAddress())) {
|
if (IP_SUCCESS.equals(address.getHostAddress())) {
|
||||||
Log.w(TAG, "Service is available.");
|
Log.i(TAG, "Service is available.");
|
||||||
TextSecurePreferences.setServiceOutage(context, false);
|
TextSecurePreferences.setServiceOutage(context, false);
|
||||||
} else if (IP_FAILURE.equals(address.getHostAddress())) {
|
} else if (IP_FAILURE.equals(address.getHostAddress())) {
|
||||||
Log.w(TAG, "Service is down.");
|
Log.w(TAG, "Service is down.");
|
||||||
TextSecurePreferences.setServiceOutage(context, true);
|
TextSecurePreferences.setServiceOutage(context, true);
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Service status check returned an unrecognized IP address. Assuming outage.");
|
Log.w(TAG, "Service status check returned an unrecognized IP address. Could be a weird network state. Prompting retry.");
|
||||||
TextSecurePreferences.setServiceOutage(context, true);
|
throw new RetryLaterException(new Exception("Unrecognized service outage IP address."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextSecurePreferences.setLastOutageCheckTime(context, System.currentTimeMillis());
|
TextSecurePreferences.setLastOutageCheckTime(context, System.currentTimeMillis());
|
||||||
@ -70,7 +71,7 @@ public class ServiceOutageDetectionJob extends ContextJob {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCanceled() {
|
public void onCanceled() {
|
||||||
Log.w(TAG, "Service status check could not complete. Assuming success to avoid false positives due to bad network.");
|
Log.i(TAG, "Service status check could not complete. Assuming success to avoid false positives due to bad network.");
|
||||||
TextSecurePreferences.setServiceOutage(context, false);
|
TextSecurePreferences.setServiceOutage(context, false);
|
||||||
TextSecurePreferences.setLastOutageCheckTime(context, System.currentTimeMillis());
|
TextSecurePreferences.setLastOutageCheckTime(context, System.currentTimeMillis());
|
||||||
EventBus.getDefault().post(new ReminderUpdateEvent());
|
EventBus.getDefault().post(new ReminderUpdateEvent());
|
||||||
|
Loading…
Reference in New Issue
Block a user