mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-03 23:55:08 +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;
|
return;
|
||||||
String number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
|
String number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
|
||||||
|
|
||||||
final int finalIntState = intState;
|
if (intState != lastState) {
|
||||||
|
lastState = intState;
|
||||||
if (finalIntState != lastState) {
|
callBroadcastReceived(intState, number);
|
||||||
callBroadcastReceived(finalIntState, number);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,7 +212,7 @@ public class TelephonyPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Emit a missed call notification if needed
|
//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("event", "missedCall");
|
||||||
np.set("phoneNumber", lastPacket.getString("phoneNumber", null));
|
np.set("phoneNumber", lastPacket.getString("phoneNumber", null));
|
||||||
np.set("contactName", lastPacket.getString("contactName", null));
|
np.set("contactName", lastPacket.getString("contactName", null));
|
||||||
@@ -224,7 +223,6 @@ public class TelephonyPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastPacket = np;
|
lastPacket = np;
|
||||||
lastState = state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unmuteRinger() {
|
private void unmuteRinger() {
|
||||||
|
Reference in New Issue
Block a user