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

Commit d037c269 authored by Grace Jia's avatar Grace Jia
Browse files

Fix NPE when try to process call redirection requests.

Canceled call redirection requests may cause NPE when trying to process
it. Catch that and ignore it to avoid crash.

Bug: 241202750
Test: CallRedirectionProcessorTest
Change-Id: Icf1a7e918aec9ee33341bafe276da94a9441617b
parent 3bd95958
Loading
Loading
Loading
Loading
+30 −10
Original line number Diff line number Diff line
@@ -2287,17 +2287,37 @@ public class CallsManager extends Call.ListenerBase
                mPendingRedirectedOutgoingCallInfo.remove(pendingCallId);
                mPendingUnredirectedOutgoingCallInfo.remove(pendingCallId);
            }

            if (action.equals(TelecomBroadcastIntentProcessor.ACTION_PLACE_REDIRECTED_CALL)) {
                mHandler.post(mPendingRedirectedOutgoingCallInfo.get(callId).prepare());
            } else if (action.equals(
                    TelecomBroadcastIntentProcessor.ACTION_PLACE_UNREDIRECTED_CALL)) {
                mHandler.post(mPendingUnredirectedOutgoingCallInfo.get(callId).prepare());
            } else if (action.equals(
                    TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL)) {
            switch (action) {
                case TelecomBroadcastIntentProcessor.ACTION_PLACE_REDIRECTED_CALL: {
                    Runnable r = mPendingRedirectedOutgoingCallInfo.get(callId);
                    if (r != null) {
                        mHandler.post(r.prepare());
                    } else {
                        Log.w(this, "Processing %s for canceled Call ID %s",
                                action, callId);
                    }
                    break;
                }
                case TelecomBroadcastIntentProcessor.ACTION_PLACE_UNREDIRECTED_CALL: {
                    Runnable r = mPendingUnredirectedOutgoingCallInfo.get(callId);
                    if (r != null) {
                        mHandler.post(r.prepare());
                    } else {
                        Log.w(this, "Processing %s for canceled Call ID %s",
                                action, callId);
                    }
                    break;
                }
                case TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL: {
                    Log.addEvent(mPendingRedirectedOutgoingCall,
                            LogUtils.Events.REDIRECTION_USER_CANCELLED);
                    mPendingRedirectedOutgoingCall.disconnect("User canceled the redirected call.");
                    break;
                }
                default: {
                    // Unexpected, ignore
                }

            }
            mPendingRedirectedOutgoingCall = null;
            mPendingRedirectedOutgoingCallInfo.remove(callId);