mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 06:05:12 +00:00
Fix potential race condition
lastState was updated long after it was read
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user