Fix race condition in alert service

This commit is contained in:
TebbeUbben 2019-01-19 05:36:02 +01:00
parent 437dee288e
commit f0a2307517

View file

@ -79,9 +79,11 @@ public class InsightAlertService extends Service implements InsightConnectionSer
}
public void ignore(AlertType alertType) {
synchronized ($alertLock) {
ignoreTimestamp = System.currentTimeMillis();
ignoreType = alertType;
}
}
@Nullable
@Override
@ -132,7 +134,6 @@ public class InsightAlertService extends Service implements InsightConnectionSer
if (alertActivity != null && alert != null)
new Handler(Looper.getMainLooper()).post(() -> alertActivity.update(alert));
}
}
if (alert == null) {
stopAlerting();
if (connectionRequested) {
@ -154,6 +155,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer
new Handler(Looper.getMainLooper()).post(() -> startActivity(intent));
}
}
}
} catch (InterruptedException ignored) {
connectionService.withdrawConnectionRequest(thread);
break;