2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 14:15:14 +00:00

Fix potential race condition

lastState was updated long after it was read
This commit is contained in:
Albert Vaca Cintora
2019-07-04 20:57:04 +02:00
parent 5609c8ebcc
commit 7db40ee20a

View File

@@ -123,10 +123,9 @@ public class TelephonyPlugin extends Plugin {
return;
String number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
final int finalIntState = intState;
if (finalIntState != lastState) {
callBroadcastReceived(finalIntState, number);
if (intState != lastState) {
lastState = intState;
callBroadcastReceived(intState, number);
}
}
}
@@ -213,7 +212,7 @@ public class TelephonyPlugin extends Plugin {
}
//Emit a missed call notification if needed
if (lastState == TelephonyManager.CALL_STATE_RINGING) {
if ("ringing".equals(lastPacket.getString("event", null))) {
np.set("event", "missedCall");
np.set("phoneNumber", lastPacket.getString("phoneNumber", null));
np.set("contactName", lastPacket.getString("contactName", null));
@@ -224,7 +223,6 @@ public class TelephonyPlugin extends Plugin {
}
lastPacket = np;
lastState = state;
}
private void unmuteRinger() {