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

Commit 216b3ce4 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Refactor ImsService to AIDL

The ImsService was originally designed as a flat
interface, all ImsFeatures would be forwarded
through ImsService. This has been refactored to
using AIDL interfaces for each feature, as it
is more straightforward.

Test: Manual, Telephony IMS Unit Tests
Change-Id: Ibe065ddec6f180eabda03cf06f842c642a11114f
parent a89f6150
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -519,10 +519,12 @@ LOCAL_SRC_FILES += \
	telephony/java/com/android/ims/internal/IImsEcbmListener.aidl \
        telephony/java/com/android/ims/internal/IImsExternalCallStateListener.aidl \
        telephony/java/com/android/ims/internal/IImsFeatureStatusCallback.aidl \
        telephony/java/com/android/ims/internal/IImsMMTelFeature.aidl \
        telephony/java/com/android/ims/internal/IImsMultiEndpoint.aidl \
	telephony/java/com/android/ims/internal/IImsRcsFeature.aidl \
	telephony/java/com/android/ims/internal/IImsService.aidl \
	telephony/java/com/android/ims/internal/IImsServiceController.aidl \
	telephony/java/com/android/ims/internal/IImsServiceFeatureListener.aidl \
	telephony/java/com/android/ims/internal/IImsServiceFeatureCallback.aidl \
	telephony/java/com/android/ims/internal/IImsStreamMediaSession.aidl \
	telephony/java/com/android/ims/internal/IImsUt.aidl \
	telephony/java/com/android/ims/internal/IImsUtListener.aidl \
+1 −1
Original line number Diff line number Diff line
@@ -5194,7 +5194,7 @@ com.android.ims.internal.IImsRegistrationListener$Stub
com.android.ims.internal.IImsService
com.android.ims.internal.IImsService$Stub
com.android.ims.internal.IImsServiceController
com.android.ims.internal.IImsServiceFeatureListener
com.android.ims.internal.IImsServiceFeatureCallback
com.android.ims.internal.IImsUt
com.android.ims.internal.IImsUt$Stub
com.android.ims.internal.IImsUtListener
+65 −13
Original line number Diff line number Diff line
@@ -52,8 +52,9 @@ import android.telephony.VisualVoicemailService.VisualVoicemailTask;
import android.telephony.ims.feature.ImsFeature;
import android.util.Log;

import com.android.ims.internal.IImsServiceController;
import com.android.ims.internal.IImsServiceFeatureListener;
import com.android.ims.internal.IImsMMTelFeature;
import com.android.ims.internal.IImsRcsFeature;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telecom.ITelecomService;
import com.android.internal.telephony.CellNetworkScanResult;
@@ -4584,27 +4585,78 @@ public class TelephonyManager {
    public @interface Feature {}

    /**
     * Returns the {@link IImsServiceController} that corresponds to the given slot Id and IMS
     * feature or {@link null} if the service is not available. If an ImsServiceController is
     * available, the {@link IImsServiceFeatureListener} callback is registered as a listener for
     * feature updates.
     * @param slotIndex The SIM slot that we are requesting the {@link IImsServiceController} for.
     * @param feature The IMS Feature we are requesting, corresponding to {@link ImsFeature}.
     * Returns the {@link IImsMMTelFeature} that corresponds to the given slot Id and MMTel
     * feature or {@link null} if the service is not available. If an MMTelFeature is available, the
     * {@link IImsServiceFeatureCallback} callback is registered as a listener for feature updates.
     * @param slotIndex The SIM slot that we are requesting the {@link IImsMMTelFeature} for.
     * @param callback Listener that will send updates to ImsManager when there are updates to
     * ImsServiceController.
     * @return {@link IImsServiceController} interface for the feature specified or {@link null} if
     * @return {@link IImsMMTelFeature} interface for the feature specified or {@code null} if
     * it is unavailable.
     * @hide
     */
    public IImsServiceController getImsServiceControllerAndListen(int slotIndex, @Feature int feature,
            IImsServiceFeatureListener callback) {
    public @Nullable IImsMMTelFeature getImsMMTelFeatureAndListen(int slotIndex,
            IImsServiceFeatureCallback callback) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.getImsServiceControllerAndListen(slotIndex, feature, callback);
                return telephony.getMMTelFeatureAndListen(slotIndex, callback);
            }
        } catch (RemoteException e) {
            Rlog.e(TAG, "getImsServiceControllerAndListen, RemoteException: " + e.getMessage());
            Rlog.e(TAG, "getImsMMTelFeatureAndListen, RemoteException: "
                    + e.getMessage());
        }
        return null;
    }

    /**
     * Returns the {@link IImsMMTelFeature} that corresponds to the given slot Id and MMTel
     * feature for emergency calling or {@link null} if the service is not available. If an
     * MMTelFeature is available, the {@link IImsServiceFeatureCallback} callback is registered as a
     * listener for feature updates.
     * @param slotIndex The SIM slot that we are requesting the {@link IImsMMTelFeature} for.
     * @param callback Listener that will send updates to ImsManager when there are updates to
     * ImsServiceController.
     * @return {@link IImsMMTelFeature} interface for the feature specified or {@code null} if
     * it is unavailable.
     * @hide
     */
    public @Nullable IImsMMTelFeature getImsEmergencyMMTelFeatureAndListen(int slotIndex,
            IImsServiceFeatureCallback callback) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.getEmergencyMMTelFeatureAndListen(slotIndex, callback);
            }
        } catch (RemoteException e) {
            Rlog.e(TAG, "getImsEmergencyMMTelFeatureAndListen, RemoteException: "
                    + e.getMessage());
        }
        return null;
    }

    /**
     * Returns the {@link IImsRcsFeature} that corresponds to the given slot Id and RCS
     * feature for emergency calling or {@link null} if the service is not available. If an
     * RcsFeature is available, the {@link IImsServiceFeatureCallback} callback is registered as a
     * listener for feature updates.
     * @param slotIndex The SIM slot that we are requesting the {@link IImsRcsFeature} for.
     * @param callback Listener that will send updates to ImsManager when there are updates to
     * ImsServiceController.
     * @return {@link IImsRcsFeature} interface for the feature specified or {@code null} if
     * it is unavailable.
     * @hide
     */
    public @Nullable IImsRcsFeature getImsRcsFeatureAndListen(int slotIndex,
            IImsServiceFeatureCallback callback) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.getRcsFeatureAndListen(slotIndex, callback);
            }
        } catch (RemoteException e) {
            Rlog.e(TAG, "getImsRcsFeatureAndListen, RemoteException: "
                    + e.getMessage());
        }
        return null;
    }
+82 −336

File changed.

Preview size limit exceeded, changes collapsed.

+6 −25
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.telephony.ims.feature;
import android.annotation.IntDef;
import android.content.Context;
import android.content.Intent;
import android.os.IInterface;
import android.os.RemoteException;
import android.telephony.SubscriptionManager;
import android.util.Log;
@@ -91,17 +92,12 @@ public abstract class ImsFeature {
    public static final int STATE_INITIALIZING = 1;
    public static final int STATE_READY = 2;

    private List<INotifyFeatureRemoved> mRemovedListeners = new ArrayList<>();
    private final Set<IImsFeatureStatusCallback> mStatusCallbacks = Collections.newSetFromMap(
            new WeakHashMap<IImsFeatureStatusCallback, Boolean>());
    private @ImsState int mState = STATE_NOT_AVAILABLE;
    private int mSlotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
    private Context mContext;

    public interface INotifyFeatureRemoved {
        void onFeatureRemoved(int slotId);
    }

    public void setContext(Context context) {
        mContext = context;
    }
@@ -110,26 +106,6 @@ public abstract class ImsFeature {
        mSlotId = slotId;
    }

    public void addFeatureRemovedListener(INotifyFeatureRemoved listener) {
        synchronized (mRemovedListeners) {
            mRemovedListeners.add(listener);
        }
    }

    public void removeFeatureRemovedListener(INotifyFeatureRemoved listener) {
        synchronized (mRemovedListeners) {
            mRemovedListeners.remove(listener);
        }
    }

    // Not final for testing.
    public void notifyFeatureRemoved(int slotId) {
        synchronized (mRemovedListeners) {
            mRemovedListeners.forEach(l -> l.onFeatureRemoved(slotId));
            onFeatureRemoved();
        }
    }

    public int getFeatureState() {
        return mState;
    }
@@ -215,4 +191,9 @@ public abstract class ImsFeature {
     * Called when the feature is being removed and must be cleaned up.
     */
    public abstract void onFeatureRemoved();

    /**
     * @return Binder instance
     */
    public abstract IInterface getBinder();
}
Loading