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

Commit 17846472 authored by Hakjun Choi's avatar Hakjun Choi
Browse files

Unable to accept incoming call when using main Executor in MmTelFeature

Add new API notfyIncomingCall() which returns ImsCallSessionListener as blocking API to prevent deadlock

Bug: 257554011
Test: atest ImsPhoneCallTrackerTest
Test: cts ImsCallingTest, ImsServicetest
Test: e2e call regression test
Change-Id: Iff689dcd64311b609466f8b3f972d432a1346c49
parent f84dfac0
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -15705,7 +15705,8 @@ package android.telephony.ims.feature {
    method @NonNull public android.telephony.ims.stub.ImsSmsImplBase getSmsImplementation();
    method @NonNull public android.telephony.ims.stub.ImsSmsImplBase getSmsImplementation();
    method @NonNull public android.telephony.ims.stub.ImsUtImplBase getUt();
    method @NonNull public android.telephony.ims.stub.ImsUtImplBase getUt();
    method public final void notifyCapabilitiesStatusChanged(@NonNull android.telephony.ims.feature.MmTelFeature.MmTelCapabilities);
    method public final void notifyCapabilitiesStatusChanged(@NonNull android.telephony.ims.feature.MmTelFeature.MmTelCapabilities);
    method public final void notifyIncomingCall(@NonNull android.telephony.ims.stub.ImsCallSessionImplBase, @NonNull android.os.Bundle);
    method @Deprecated public final void notifyIncomingCall(@NonNull android.telephony.ims.stub.ImsCallSessionImplBase, @NonNull android.os.Bundle);
    method @Nullable public final android.telephony.ims.ImsCallSessionListener notifyIncomingCall(@NonNull android.telephony.ims.stub.ImsCallSessionImplBase, @NonNull String, @NonNull android.os.Bundle);
    method public final void notifyRejectedCall(@NonNull android.telephony.ims.ImsCallProfile, @NonNull android.telephony.ims.ImsReasonInfo);
    method public final void notifyRejectedCall(@NonNull android.telephony.ims.ImsCallProfile, @NonNull android.telephony.ims.ImsReasonInfo);
    method public void notifySrvccCanceled();
    method public void notifySrvccCanceled();
    method public void notifySrvccCompleted();
    method public void notifySrvccCompleted();
@@ -15812,7 +15813,7 @@ package android.telephony.ims.stub {
    method public void sendRttModifyRequest(android.telephony.ims.ImsCallProfile);
    method public void sendRttModifyRequest(android.telephony.ims.ImsCallProfile);
    method public void sendRttModifyResponse(boolean);
    method public void sendRttModifyResponse(boolean);
    method public void sendUssd(String);
    method public void sendUssd(String);
    method public void setListener(android.telephony.ims.ImsCallSessionListener);
    method @Deprecated public void setListener(android.telephony.ims.ImsCallSessionListener);
    method public void setMute(boolean);
    method public void setMute(boolean);
    method public void start(String, android.telephony.ims.ImsCallProfile);
    method public void start(String, android.telephony.ims.ImsCallProfile);
    method public void startConference(String[], android.telephony.ims.ImsCallProfile);
    method public void startConference(String[], android.telephony.ims.ImsCallProfile);
+34 −13
Original line number Original line Diff line number Diff line
@@ -18,10 +18,12 @@ package android.telephony.ims;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.os.Bundle;
import android.os.Message;
import android.os.Message;
import android.os.RemoteException;
import android.os.RemoteException;
import android.telephony.CallQuality;
import android.telephony.CallQuality;
import android.telephony.ims.aidl.IImsCallSessionListener;
import android.telephony.ims.aidl.IImsCallSessionListener;
import android.telephony.ims.stub.ImsCallSessionImplBase;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.Log;
import android.util.Log;


@@ -99,7 +101,6 @@ public class ImsCallSession {
     * Listener for events relating to an IMS session, such as when a session is being
     * Listener for events relating to an IMS session, such as when a session is being
     * recieved ("on ringing") or a call is outgoing ("on calling").
     * recieved ("on ringing") or a call is outgoing ("on calling").
     * <p>Many of these events are also received by {@link ImsCall.Listener}.</p>
     * <p>Many of these events are also received by {@link ImsCall.Listener}.</p>
     * @hide
     */
     */
    public static class Listener {
    public static class Listener {
        /**
        /**
@@ -523,16 +524,18 @@ public class ImsCallSession {


    private final IImsCallSession miSession;
    private final IImsCallSession miSession;
    private boolean mClosed = false;
    private boolean mClosed = false;
    private String mCallId = null;
    private Listener mListener;
    private Listener mListener;
    private Executor mListenerExecutor = Runnable::run;
    private Executor mListenerExecutor = Runnable::run;
    private IImsCallSessionListenerProxy mIImsCallSessionListenerProxy = null;


    /** @hide */
    public ImsCallSession(IImsCallSession iSession) {
    public ImsCallSession(IImsCallSession iSession) {
        miSession = iSession;
        miSession = iSession;
        mIImsCallSessionListenerProxy = new IImsCallSessionListenerProxy();


        if (iSession != null) {
        if (iSession != null) {
            try {
            try {
                iSession.setListener(new IImsCallSessionListenerProxy());
                iSession.setListener(mIImsCallSessionListenerProxy);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
            }
            }
        } else {
        } else {
@@ -540,12 +543,18 @@ public class ImsCallSession {
        }
        }
    }
    }


    /** @hide */
    public ImsCallSession(IImsCallSession iSession, Listener listener, Executor executor) {
    public ImsCallSession(IImsCallSession iSession, Listener listener, Executor executor) {
        this(iSession);
        this(iSession);
        setListener(listener, executor);
        setListener(listener, executor);
    }
    }


    /**
     * returns the IImsCallSessionListenerProxy for the ImsCallSession
     */
    public final IImsCallSessionListenerProxy getIImsCallSessionListenerProxy() {
        return mIImsCallSessionListenerProxy;
    }

    /**
    /**
     * Closes this object. This object is not usable after being closed.
     * Closes this object. This object is not usable after being closed.
     */
     */
@@ -573,12 +582,29 @@ public class ImsCallSession {
            return null;
            return null;
        }
        }


        if (mCallId != null) {
            return mCallId;
        } else {
            try {
            try {
            return miSession.getCallId();
                return mCallId = miSession.getCallId();
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                return null;
                return null;
            }
            }
        }
        }
    }

    /**
     * Sets the call ID of the session.
     *
     * @param callId Call ID of the session, which is transferred from
     * {@link android.telephony.ims.feature.MmTelFeature#notifyIncomingCall(
     * ImsCallSessionImplBase, String, Bundle)}
     */
    public void setCallId(String callId) {
        if (callId != null) {
            mCallId = callId;
        }
    }


    /**
    /**
     * Gets the call profile that this session is associated with
     * Gets the call profile that this session is associated with
@@ -635,7 +661,6 @@ public class ImsCallSession {
     * Gets the video call provider for the session.
     * Gets the video call provider for the session.
     *
     *
     * @return The video call provider.
     * @return The video call provider.
     * @hide
     */
     */
    public IImsVideoCallProvider getVideoCallProvider() {
    public IImsVideoCallProvider getVideoCallProvider() {
        if (mClosed) {
        if (mClosed) {
@@ -712,7 +737,6 @@ public class ImsCallSession {


    /**
    /**
     * Gets the native IMS call session.
     * Gets the native IMS call session.
     * @hide
     */
     */
    public IImsCallSession getSession() {
    public IImsCallSession getSession() {
        return miSession;
        return miSession;
@@ -742,7 +766,6 @@ public class ImsCallSession {
     *
     *
     * @param listener to listen to the session events of this object
     * @param listener to listen to the session events of this object
     * @param executor an Executor that will execute callbacks
     * @param executor an Executor that will execute callbacks
     * @hide
     */
     */
    public void setListener(Listener listener, Executor executor) {
    public void setListener(Listener listener, Executor executor) {
        mListener = listener;
        mListener = listener;
@@ -1706,8 +1729,6 @@ public class ImsCallSession {
        StringBuilder sb = new StringBuilder();
        StringBuilder sb = new StringBuilder();
        sb.append("[ImsCallSession objId:");
        sb.append("[ImsCallSession objId:");
        sb.append(System.identityHashCode(this));
        sb.append(System.identityHashCode(this));
        sb.append(" state:");
        sb.append(State.toString(getState()));
        sb.append(" callId:");
        sb.append(" callId:");
        sb.append(getCallId());
        sb.append(getCallId());
        sb.append("]");
        sb.append("]");
+2 −2
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ import android.os.Bundle;


import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsReasonInfo;

import android.telephony.ims.aidl.IImsCallSessionListener;
import com.android.ims.internal.IImsCallSession;
import com.android.ims.internal.IImsCallSession;


/**
/**
@@ -31,7 +31,7 @@ import com.android.ims.internal.IImsCallSession;
 // processed by telephony before the control flow returns to the ImsService to perform
 // processed by telephony before the control flow returns to the ImsService to perform
 // operations on the IImsCallSession.
 // operations on the IImsCallSession.
interface IImsMmTelListener {
interface IImsMmTelListener {
    void onIncomingCall(IImsCallSession c, in Bundle extras);
    IImsCallSessionListener onIncomingCall(in IImsCallSession c, in String callId, in Bundle extras);
    void onRejectedCall(in ImsCallProfile callProfile, in ImsReasonInfo reason);
    void onRejectedCall(in ImsCallProfile callProfile, in ImsReasonInfo reason);
    oneway void onVoiceMessageCountUpdate(int count);
    oneway void onVoiceMessageCountUpdate(int count);
}
}
+54 −5
Original line number Original line Diff line number Diff line
@@ -27,11 +27,13 @@ import android.os.ServiceSpecificException;
import android.telecom.TelecomManager;
import android.telecom.TelecomManager;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsCallSessionListener;
import android.telephony.ims.ImsException;
import android.telephony.ims.ImsException;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsService;
import android.telephony.ims.ImsService;
import android.telephony.ims.RtpHeaderExtensionType;
import android.telephony.ims.RtpHeaderExtensionType;
import android.telephony.ims.SrvccCall;
import android.telephony.ims.SrvccCall;
import android.telephony.ims.aidl.IImsCallSessionListener;
import android.telephony.ims.aidl.IImsCapabilityCallback;
import android.telephony.ims.aidl.IImsCapabilityCallback;
import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsMmTelListener;
import android.telephony.ims.aidl.IImsMmTelListener;
@@ -546,11 +548,19 @@ public class MmTelFeature extends ImsFeature {
        /**
        /**
         * Called when the IMS provider receives an incoming call.
         * Called when the IMS provider receives an incoming call.
         * @param c The {@link ImsCallSession} associated with the new call.
         * @param c The {@link ImsCallSession} associated with the new call.
         * @param callId The call ID of the session of the new incoming call.
         * @param extras A bundle containing extra parameters related to the call. See
         * {@link #EXTRA_IS_UNKNOWN_CALL} and {@link #EXTRA_IS_USSD} above.
         * @return the listener to listen to the session events. An {@link ImsCallSession} can only
         *         hold one listener at a time. see {@link ImsCallSessionListener}.
         *         If this method returns {@code null}, then the call could not be placed.
         * @hide
         * @hide
         */
         */
        @Override
        @Override
        public void onIncomingCall(IImsCallSession c, Bundle extras) {
        @Nullable

        public IImsCallSessionListener onIncomingCall(IImsCallSession c,
                String callId, Bundle extras) {
            return null;
        }
        }


        /**
        /**
@@ -687,7 +697,10 @@ public class MmTelFeature extends ImsFeature {
     * @param extras A bundle containing extra parameters related to the call. See
     * @param extras A bundle containing extra parameters related to the call. See
     * {@link #EXTRA_IS_UNKNOWN_CALL} and {@link #EXTRA_IS_USSD} above.
     * {@link #EXTRA_IS_UNKNOWN_CALL} and {@link #EXTRA_IS_USSD} above.
     * @hide
     * @hide
     *
     * @deprecated use {@link #notifyIncomingCall(ImsCallSessionImplBase, String, Bundle)} instead
     */
     */
    @Deprecated
    @SystemApi
    @SystemApi
    public final void notifyIncomingCall(@NonNull ImsCallSessionImplBase c,
    public final void notifyIncomingCall(@NonNull ImsCallSessionImplBase c,
            @NonNull Bundle extras) {
            @NonNull Bundle extras) {
@@ -699,9 +712,45 @@ public class MmTelFeature extends ImsFeature {
        if (listener == null) {
        if (listener == null) {
            throw new IllegalStateException("Session is not available.");
            throw new IllegalStateException("Session is not available.");
        }
        }
        try {
            listener.onIncomingCall(c.getServiceImpl(), null, extras);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Notify the framework of an incoming call.
     * @param c The {@link ImsCallSessionImplBase} of the new incoming call.
     * @param callId The call ID of the session of the new incoming call.
     * @param extras A bundle containing extra parameters related to the call. See
     * {@link #EXTRA_IS_UNKNOWN_CALL} and {@link #EXTRA_IS_USSD} above.
     * @return The listener used by the framework to listen to call session events created
     *         from the ImsService.
     *         If this method returns {@code null}, then the call could not be placed.
     * @hide
     */
    @SystemApi
    @Nullable
    public final ImsCallSessionListener notifyIncomingCall(
            @NonNull ImsCallSessionImplBase c, @NonNull String callId, @NonNull Bundle extras) {
        if (c == null || callId == null || extras == null) {
            throw new IllegalArgumentException("ImsCallSessionImplBase, callId, and Bundle can "
                    + "not be null.");
        }
        IImsMmTelListener listener = getListener();
        if (listener == null) {
            throw new IllegalStateException("Session is not available.");
        }
        try {
        try {
            c.setDefaultExecutor(MmTelFeature.this.mExecutor);
            c.setDefaultExecutor(MmTelFeature.this.mExecutor);
            listener.onIncomingCall(c.getServiceImpl(), extras);
            IImsCallSessionListener isl =
                    listener.onIncomingCall(c.getServiceImpl(), callId, extras);
            if (isl != null) {
                return new ImsCallSessionListener(isl);
            } else {
                return null;
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw new RuntimeException(e);
            throw new RuntimeException(e);
        }
        }
@@ -743,7 +792,7 @@ public class MmTelFeature extends ImsFeature {
            throw new IllegalStateException("Session is not available.");
            throw new IllegalStateException("Session is not available.");
        }
        }
        try {
        try {
            listener.onIncomingCall(c, extras);
            listener.onIncomingCall(c, null, extras);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw new RuntimeException(e);
            throw new RuntimeException(e);
        }
        }
+5 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.telephony.ims.stub;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.os.Bundle;
import android.os.Message;
import android.os.Message;
import android.os.RemoteException;
import android.os.RemoteException;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallProfile;
@@ -366,7 +367,11 @@ public class ImsCallSessionImplBase implements AutoCloseable {
     *
     *
     * @param listener {@link ImsCallSessionListener} used to notify the framework of updates
     * @param listener {@link ImsCallSessionListener} used to notify the framework of updates
     * to the ImsCallSession
     * to the ImsCallSession

     * @deprecated use {@link android.telephony.ims.feature.MmTelFeature#notifyIncomingCall(
     * ImsCallSessionImplBase, String, Bundle)} to get the listener instead
     */
     */
    @Deprecated
    public void setListener(ImsCallSessionListener listener) {
    public void setListener(ImsCallSessionListener listener) {
    }
    }


Loading