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

Commit ba3f276e authored by Parvathy Shanmugam's avatar Parvathy Shanmugam Committed by Gerrit Code Review
Browse files

Merge changes from topic "IMS Threading Refactoring"

* changes:
  (IMS Threading refactoring) Telephony IMS classes to schedule IMS callback on the main thread
  (IMS Threading refactoring) Telephony IMS classes to schedule IMS callback on the main thread
parents f7a91ba6 11e09593
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1123,7 +1123,7 @@ public class ImsCall implements ICall {
             mSession = session;

             try {
                 mSession.setListener(createCallSessionListener());
                 mSession.setListener(createCallSessionListener(), mContext.getMainExecutor());
             } catch (Throwable t) {
                 loge("attachSession :: ", t);
                 throwImsException(t, 0);
@@ -1147,7 +1147,7 @@ public class ImsCall implements ICall {
            mSession = session;

            try {
                session.setListener(createCallSessionListener());
                session.setListener(createCallSessionListener(), mContext.getMainExecutor());
                session.start(callee, mCallProfile);
            } catch (Throwable t) {
                loge("start(1) :: ", t);
@@ -1173,7 +1173,7 @@ public class ImsCall implements ICall {
            mIsConferenceHost = true;

            try {
                session.setListener(createCallSessionListener());
                session.setListener(createCallSessionListener(), mContext.getMainExecutor());
                session.start(participants, mCallProfile);
            } catch (Throwable t) {
                loge("start(n) :: ", t);
@@ -2097,9 +2097,9 @@ public class ImsCall implements ICall {

    private void setTransientSessionAsPrimary(ImsCallSession transientSession) {
        synchronized (ImsCall.this) {
            mSession.setListener(null);
            mSession.setListener(null, null);
            mSession = transientSession;
            mSession.setListener(createCallSessionListener());
            mSession.setListener(createCallSessionListener(), mContext.getMainExecutor());
        }
    }

@@ -2214,7 +2214,7 @@ public class ImsCall implements ICall {

                // Clear the listener for this transient session, we'll create a new listener
                // when it is attached to the final ImsCall that it should live on.
                transientConferenceSession.setListener(null);
                transientConferenceSession.setListener(null, null);

                // Determine which call the transient session should be moved to.  If the current
                // call session is still alive and the merge peer's session is not, we have a
@@ -2409,7 +2409,7 @@ public class ImsCall implements ICall {

            // Try to clean up the transient session if it exists.
            if (mTransientConferenceSession != null) {
                mTransientConferenceSession.setListener(null);
                mTransientConferenceSession.setListener(null, null);
                mTransientConferenceSession = null;
            }

+31 −5
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@

package com.android.ims;

import java.util.concurrent.Executor;

/**
 * Listener for receiving notifications about changes to the IMS connection.
 * It provides a state of IMS registration between UE and IMS network, the service
@@ -36,18 +38,42 @@ package com.android.ims;
 *
 * @hide
 */
public class ImsEcbmStateListener {
public abstract class ImsEcbmStateListener {
    protected Executor mListenerExecutor = Runnable::run;
    /**
     * constructor.
     *
     * @param executor the executor that will execute callbacks.
     */
    public ImsEcbmStateListener(Executor executor) {
        if (executor != null)
            mListenerExecutor = executor;
    }
    /**
     * Called when the device enters Emergency Callback Mode
     */
    public void onECBMEntered() {
        // no-op
    public final void onECBMEntered() {
        onECBMEntered(mListenerExecutor);
    }

    /**
     * Called when the device enters Emergency Callback Mode
     *
     * @param executor the executor that will execute callbacks.
     */
    public abstract void onECBMEntered(Executor executor);

    /**
     * Called when the device exits Emergency Callback Mode
     */
    public void onECBMExited() {
        // no-op
    public final void onECBMExited() {
        onECBMExited(mListenerExecutor);
    }

    /**
     * Called when the device exits Emergency Callback Mode
     *
     * @param executor the executor that will execute callbacks.
     */
    public abstract void onECBMExited(Executor executor);
}
+23 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.ims;
import android.telephony.ims.ImsExternalCallState;

import java.util.List;
import java.util.concurrent.Executor;

/**
 * Listener for receiving notifications about {@link ImsExternalCallState} information received
@@ -26,13 +27,32 @@ import java.util.List;
 *
 * @hide
 */
public class ImsExternalCallStateListener {
public abstract class ImsExternalCallStateListener {
    protected Executor mListenerExecutor = Runnable::run;
    /**
     * constructor.
     *
     * @param executor the executor that will execute callbacks.
     */
    public ImsExternalCallStateListener(Executor executor) {
        if (executor != null)
            mListenerExecutor = executor;
    }
    /**
     * Notifies client when Dialog Event Package update is received
     *
     * @param externalCallState the external call state.
     */
    public void onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallState) {
        // no-op
    public final void onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallState) {
        onImsExternalCallStateUpdate(externalCallState, mListenerExecutor);
    }
    /**
     * Notifies client when Dialog Event Package update is received
     *
     * @param externalCallState the external call state.
     *
     * @param executor the executor that will execute callbacks.
     */
    public abstract void onImsExternalCallStateUpdate(
        List<ImsExternalCallState> externalCallState, Executor executor);
}
+60 −38
Original line number Diff line number Diff line
@@ -33,9 +33,11 @@ import com.android.ims.internal.IImsUt;
import com.android.ims.internal.IImsUtListener;
import com.android.internal.annotations.VisibleForTesting;
import com.android.telephony.Rlog;
import com.android.internal.telephony.util.TelephonyUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;

/**
 * Provides APIs for the supplementary service settings using IMS (Ut interface).
@@ -85,9 +87,13 @@ public class ImsUt implements ImsUtInterface {
    private HashMap<Integer, Message> mPendingCmds =
            new HashMap<Integer, Message>();
    private Registrant mSsIndicationRegistrant;
    private Executor mExecutor = Runnable::run;

    public ImsUt(IImsUt iUt) {
    public ImsUt(IImsUt iUt, Executor executor) {
        miUt = iUt;
        if (executor != null) {
            mExecutor = executor;
        }

        if (miUt != null) {
            try {
@@ -664,22 +670,26 @@ public class ImsUt implements ImsUtInterface {
         */
        @Override
        public void utConfigurationUpdated(IImsUt ut, int id) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                Integer key = Integer.valueOf(id);

                synchronized(mLockObj) {
                    sendSuccessReport(mPendingCmds.get(key));
                    mPendingCmds.remove(key);
                }
            }, mExecutor);
        }

        @Override
        public void utConfigurationUpdateFailed(IImsUt ut, int id, ImsReasonInfo error) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                Integer key = Integer.valueOf(id);

                synchronized(mLockObj) {
                    sendFailureReport(mPendingCmds.get(key), error);
                    mPendingCmds.remove(key);
                }
            }, mExecutor);
        }

        /**
@@ -710,20 +720,24 @@ public class ImsUt implements ImsUtInterface {
         */
        @Override
        public void lineIdentificationSupplementaryServiceResponse(int id, ImsSsInfo config) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                synchronized(mLockObj) {
                    sendSuccessReport(mPendingCmds.get(id), config);
                    mPendingCmds.remove(id);
                }
            }, mExecutor);
        }

        @Override
        public void utConfigurationQueryFailed(IImsUt ut, int id, ImsReasonInfo error) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                Integer key = Integer.valueOf(id);

                synchronized(mLockObj) {
                    sendFailureReport(mPendingCmds.get(key), error);
                    mPendingCmds.remove(key);
                }
            }, mExecutor);
        }

        /**
@@ -732,12 +746,14 @@ public class ImsUt implements ImsUtInterface {
        @Override
        public void utConfigurationCallBarringQueried(IImsUt ut,
                int id, ImsSsInfo[] cbInfo) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                Integer key = Integer.valueOf(id);

                synchronized(mLockObj) {
                    sendSuccessReport(mPendingCmds.get(key), cbInfo);
                    mPendingCmds.remove(key);
                }
            }, mExecutor);
        }

        /**
@@ -746,12 +762,14 @@ public class ImsUt implements ImsUtInterface {
        @Override
        public void utConfigurationCallForwardQueried(IImsUt ut,
                int id, ImsCallForwardInfo[] cfInfo) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                Integer key = Integer.valueOf(id);

                synchronized(mLockObj) {
                    sendSuccessReport(mPendingCmds.get(key), cfInfo);
                    mPendingCmds.remove(key);
                }
            }, mExecutor);
        }

        /**
@@ -760,12 +778,14 @@ public class ImsUt implements ImsUtInterface {
        @Override
        public void utConfigurationCallWaitingQueried(IImsUt ut,
                int id, ImsSsInfo[] cwInfo) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                Integer key = Integer.valueOf(id);

                synchronized(mLockObj) {
                    sendSuccessReport(mPendingCmds.get(key), cwInfo);
                    mPendingCmds.remove(key);
                }
            }, mExecutor);
        }

        /**
@@ -773,9 +793,11 @@ public class ImsUt implements ImsUtInterface {
         */
        @Override
        public void onSupplementaryServiceIndication(ImsSsData ssData) {
            TelephonyUtils.runWithCleanCallingIdentity(()-> {
                if (mSsIndicationRegistrant != null) {
                    mSsIndicationRegistrant.notifyResult(ssData);
                }
            }, mExecutor);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -436,7 +436,7 @@ public class MmTelFeatureConnection extends FeatureConnection {
            // This will internally set up a listener on the ImsUtImplBase interface, and there is
            // a limitation that there can only be one. If multiple connections try to create this
            // UT interface, it will throw an IllegalStateException.
            mUt = (imsUt != null) ? new ImsUt(imsUt) : null;
            mUt = (imsUt != null) ? new ImsUt(imsUt, mContext.getMainExecutor()) : null;
            return mUt;
        }
    }
Loading