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
diff --git a/src/java/com/android/ims/ImsCall.java b/src/java/com/android/ims/ImsCall.java
index a5813d8..06230a1 100755
--- a/src/java/com/android/ims/ImsCall.java
+++ b/src/java/com/android/ims/ImsCall.java
@@ -1762,7 +1762,12 @@
     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 @@
 
         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 @@
         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.");