Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fab561f authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Fix potential exceptions in CallDiagnosticService and missing locks." into sc-dev

parents 7f626aed 07d3736f
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -294,6 +294,10 @@ public abstract class CallDiagnosticService extends Service {
        CallDiagnostics callDiagnostics;
        synchronized (mLock) {
            callDiagnostics = mDiagnosticCallByTelecomCallId.get(telecomCallId);
            if (callDiagnostics == null) {
                // Possible to get a call update after a call is removed.
                return;
            }
            mCallByTelecomCallId.put(telecomCallId, newCallDetails);
        }
        getExecutor().execute(() -> callDiagnostics.handleCallUpdated(newCallDetails));
@@ -306,12 +310,12 @@ public abstract class CallDiagnosticService extends Service {
    private void handleCallRemoved(@NonNull String telecomCallId) {
        Log.i(this, "handleCallRemoved: callId=%s - removed", telecomCallId);

        CallDiagnostics callDiagnostics;
        synchronized (mLock) {
            if (mCallByTelecomCallId.containsKey(telecomCallId)) {
                mCallByTelecomCallId.remove(telecomCallId);
            }

        CallDiagnostics callDiagnostics;
        synchronized (mLock) {
            if (mDiagnosticCallByTelecomCallId.containsKey(telecomCallId)) {
                callDiagnostics = mDiagnosticCallByTelecomCallId.remove(telecomCallId);
            } else {
@@ -353,7 +357,10 @@ public abstract class CallDiagnosticService extends Service {
    private void handleCallDisconnected(@NonNull String callId,
            @NonNull DisconnectCause disconnectCause) {
        Log.i(this, "handleCallDisconnected: call=%s; cause=%s", callId, disconnectCause);
        CallDiagnostics callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId);
        CallDiagnostics callDiagnostics;
        synchronized (mLock) {
            callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId);
        }
        CharSequence message;
        if (disconnectCause.getImsReasonInfo() != null) {
            message = callDiagnostics.onCallDisconnected(disconnectCause.getImsReasonInfo());
@@ -391,7 +398,9 @@ public abstract class CallDiagnosticService extends Service {
            @NonNull CallQuality callQuality) {
        Log.i(this, "handleCallQualityChanged; call=%s, cq=%s", callId, callQuality);
        CallDiagnostics callDiagnostics;
        synchronized(mLock) {
            callDiagnostics = mDiagnosticCallByTelecomCallId.get(callId);
        }
        if (callDiagnostics != null) {
            callDiagnostics.onCallQualityReceived(callQuality);
        }