Fix race condition in alert service
This commit is contained in:
parent
437dee288e
commit
f0a2307517
1 changed files with 24 additions and 22 deletions
|
@ -79,9 +79,11 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ignore(AlertType alertType) {
|
public void ignore(AlertType alertType) {
|
||||||
|
synchronized ($alertLock) {
|
||||||
ignoreTimestamp = System.currentTimeMillis();
|
ignoreTimestamp = System.currentTimeMillis();
|
||||||
ignoreType = alertType;
|
ignoreType = alertType;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -132,7 +134,6 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
if (alertActivity != null && alert != null)
|
if (alertActivity != null && alert != null)
|
||||||
new Handler(Looper.getMainLooper()).post(() -> alertActivity.update(alert));
|
new Handler(Looper.getMainLooper()).post(() -> alertActivity.update(alert));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (alert == null) {
|
if (alert == null) {
|
||||||
stopAlerting();
|
stopAlerting();
|
||||||
if (connectionRequested) {
|
if (connectionRequested) {
|
||||||
|
@ -154,6 +155,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer
|
||||||
new Handler(Looper.getMainLooper()).post(() -> startActivity(intent));
|
new Handler(Looper.getMainLooper()).post(() -> startActivity(intent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
connectionService.withdrawConnectionRequest(thread);
|
connectionService.withdrawConnectionRequest(thread);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue