Commit 7db40ee2 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Fix potential race condition

lastState was updated long after it was read
parent 5609c8eb
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment