From fff67ce3fc506e6adb865c69d881b13f3cfed632 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Fri, 17 Jun 2022 12:07:19 -0700 Subject: Fix RTT NPE due to ImsCall#close being called When the IMS call is closed, in some cases, a pending RTT initialization request could still be in the queue to be processed. Since this depends on resources that have since been release, it can cause an NPE. Guard against this condition and return early if this condition is hit. Bug: 236279778 Test: atest FrameworksTelephonyTests:ImsCallTest Change-Id: I1c734eebd8135655752e646c5967e65cfe140c89 --- src/java/com/android/ims/ImsCall.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/com/android/ims/ImsCall.java b/src/java/com/android/ims/ImsCall.java index a5813d88..06230a16 100755 --- a/src/java/com/android/ims/ImsCall.java +++ b/src/java/com/android/ims/ImsCall.java @@ -1762,7 +1762,12 @@ public class ImsCall implements ICall { public void sendRttMessage(String rttMessage) { synchronized(mLockObj) { if (mSession == null) { - loge("sendRttMessage::no session"); + loge("sendRttMessage::no session, ignoring"); + return; + } + if (mCallProfile == null || mCallProfile.mMediaProfile == null) { + loge("sendRttMessage:: no valid call profile, ignoring"); + return; } if (!mCallProfile.mMediaProfile.isRttCall()) { logi("sendRttMessage::Not an rtt call, ignoring"); @@ -1781,7 +1786,12 @@ public class ImsCall implements ICall { synchronized(mLockObj) { if (mSession == null) { - loge("sendRttModifyRequest::no session"); + loge("sendRttModifyRequest::no session, ignoring"); + return; + } + if (mCallProfile == null || mCallProfile.mMediaProfile == null) { + loge("sendRttModifyRequest:: no valid call profile, ignoring"); + return; } if (rttOn && mCallProfile.mMediaProfile.isRttCall()) { logi("sendRttModifyRequest::Already RTT call, ignoring request to turn on."); @@ -1815,6 +1825,11 @@ public class ImsCall implements ICall { synchronized(mLockObj) { if (mSession == null) { loge("sendRttModifyResponse::no session"); + return; + } + if (mCallProfile == null || mCallProfile.mMediaProfile == null) { + loge("sendRttModifyResponse:: no valid call profile, ignoring"); + return; } if (mCallProfile.mMediaProfile.isRttCall()) { logi("sendRttModifyResponse::Already RTT call, ignoring."); -- cgit v1.2.3