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

Commit a210f340 authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Integrate new MMTel APIs into the framework am: 5b1883b5

am: e904f408

Change-Id: I3e6276418b2c6330bce65289f589980d4666de6a
parents 2c5dc6b6 e904f408
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -463,15 +463,17 @@ java_library {
        "telephony/java/android/telephony/data/IDataService.aidl",
        "telephony/java/android/telephony/data/IDataServiceCallback.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsCallSessionListener.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsCapabilityCallback.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsConfig.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsConfigCallback.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsMmTelFeature.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsMmTelListener.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsRcsFeature.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsServiceController.aidl",
        "telephony/java/android/telephony/ims/internal/aidl/IImsServiceControllerListener.aidl",
	    "telephony/java/android/telephony/ims/internal/aidl/IImsSmsListener.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsCapabilityCallback.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsConfig.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsConfigCallback.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsMmTelFeature.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsMmTelListener.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsRegistration.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsRegistrationCallback.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsRcsFeature.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsServiceController.aidl",
        "telephony/java/android/telephony/ims/aidl/IImsServiceControllerListener.aidl",
	    "telephony/java/android/telephony/ims/aidl/IImsSmsListener.aidl",
        "telephony/java/android/telephony/mbms/IMbmsDownloadSessionCallback.aidl",
        "telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl",
        "telephony/java/android/telephony/mbms/IDownloadStateCallback.aidl",
@@ -490,13 +492,10 @@ java_library {
        "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/IImsRegistration.aidl",
        "telephony/java/com/android/ims/internal/IImsRegistrationCallback.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/IImsServiceFeatureCallback.aidl",
	    "telephony/java/com/android/ims/internal/IImsSmsListener.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",
+52 −29
Original line number Diff line number Diff line
@@ -47,12 +47,13 @@ import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.VisualVoicemailService.VisualVoicemailTask;
import android.telephony.ims.aidl.IImsConfig;
import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsRcsFeature;
import android.telephony.ims.aidl.IImsRegistration;
import android.telephony.ims.feature.ImsFeature;
import android.util.Log;

import com.android.ims.internal.IImsMMTelFeature;
import com.android.ims.internal.IImsRcsFeature;
import com.android.ims.internal.IImsRegistration;
import com.android.ims.internal.IImsServiceFeatureCallback;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telecom.ITelecomService;
@@ -4900,57 +4901,60 @@ public class TelephonyManager {
        }
    }

    /** @hide */
    @IntDef({ImsFeature.EMERGENCY_MMTEL, ImsFeature.MMTEL, ImsFeature.RCS})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Feature {}
    /**
     * Enables IMS for the framework. This will trigger IMS registration and ImsFeature capability
     * status updates, if not already enabled.
     * @hide
     */
    public void enableIms(int slotId) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                telephony.enableIms(slotId);
            }
        } catch (RemoteException e) {
            Rlog.e(TAG, "enableIms, RemoteException: "
                    + e.getMessage());
        }
    }

    /**
     * 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 IImsMMTelFeature} interface for the feature specified or {@code null} if
     * it is unavailable.
     * Disables IMS for the framework. This will trigger IMS de-registration and trigger ImsFeature
     * status updates to disabled.
     * @hide
     */
    public @Nullable IImsMMTelFeature getImsMMTelFeatureAndListen(int slotIndex,
            IImsServiceFeatureCallback callback) {
    public void disableIms(int slotId) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.getMMTelFeatureAndListen(slotIndex, callback);
                telephony.disableIms(slotId);
            }
        } catch (RemoteException e) {
            Rlog.e(TAG, "getImsMMTelFeatureAndListen, RemoteException: "
            Rlog.e(TAG, "disableIms, 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.
     * 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 IImsMMTelFeature} interface for the feature specified or {@code null} if
     * @return {@link IImsMmTelFeature} interface for the feature specified or {@code null} if
     * it is unavailable.
     * @hide
     */
    public @Nullable IImsMMTelFeature getImsEmergencyMMTelFeatureAndListen(int slotIndex,
    public @Nullable IImsMmTelFeature getImsMmTelFeatureAndListen(int slotIndex,
            IImsServiceFeatureCallback callback) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.getEmergencyMMTelFeatureAndListen(slotIndex, callback);
                return telephony.getMmTelFeatureAndListen(slotIndex, callback);
            }
        } catch (RemoteException e) {
            Rlog.e(TAG, "getImsEmergencyMMTelFeatureAndListen, RemoteException: "
            Rlog.e(TAG, "getImsMmTelFeatureAndListen, RemoteException: "
                    + e.getMessage());
        }
        return null;
@@ -5001,6 +5005,25 @@ public class TelephonyManager {
        return null;
    }

    /**
     * @return the {@IImsConfig} interface that corresponds with the slot index and feature.
     * @param slotIndex The SIM slot corresponding to the ImsService ImsConfig is active for.
     * @param feature An integer indicating the feature that we wish to get the ImsConfig for.
     * Corresponds to features defined in ImsFeature.
     * @hide
     */
    public @Nullable IImsConfig getImsConfig(int slotIndex, int feature) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                return telephony.getImsConfig(slotIndex, feature);
            }
        } catch (RemoteException e) {
            Rlog.e(TAG, "getImsRegistration, RemoteException: " + e.getMessage());
        }
        return null;
    }

    /**
     * Set IMS registration state
     *
+166 −47
Original line number Diff line number Diff line
@@ -16,25 +16,28 @@

package android.telephony.ims;

import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.telephony.CarrierConfigManager;
import android.telephony.ims.aidl.IImsConfig;
import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsRcsFeature;
import android.telephony.ims.aidl.IImsRegistration;
import android.telephony.ims.aidl.IImsServiceController;
import android.telephony.ims.aidl.IImsServiceControllerListener;
import android.telephony.ims.feature.ImsFeature;
import android.telephony.ims.feature.MMTelFeature;
import android.telephony.ims.feature.MmTelFeature;
import android.telephony.ims.feature.RcsFeature;
import android.telephony.ims.stub.ImsConfigImplBase;
import android.telephony.ims.stub.ImsFeatureConfiguration;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import android.util.SparseArray;

import com.android.ims.internal.IImsFeatureStatusCallback;
import com.android.ims.internal.IImsMMTelFeature;
import com.android.ims.internal.IImsRcsFeature;
import com.android.ims.internal.IImsRegistration;
import com.android.ims.internal.IImsServiceController;
import com.android.internal.annotations.VisibleForTesting;

import static android.Manifest.permission.MODIFY_PHONE_STATE;
@@ -62,14 +65,11 @@ import static android.Manifest.permission.MODIFY_PHONE_STATE;
 * 1) Defined as the default ImsService for the device in the device overlay using
 *    "config_ims_package".
 * 2) Defined as a Carrier Provided ImsService in the Carrier Configuration using
 *    {@link CarrierConfigManager#KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING}.
 *    {@link CarrierConfigManager#KEY_CTONFIG_IMS_PACKAGE_OVERRIDE_STRING}.
 *
 * The features that are currently supported in an ImsService are:
 * - RCS_FEATURE: This ImsService implements the RcsFeature class.
 * - MMTEL_FEATURE: This ImsService implements the MMTelFeature class.
 * - EMERGENCY_MMTEL_FEATURE: This ImsService implements the MMTelFeature class and will be
 *   available to place emergency calls at all times. This MUST be implemented by the default
 *   ImsService provided in the device overlay.
 * - MMTEL_FEATURE: This ImsService implements the MmTelFeature class.
 *   @hide
 */
@SystemApi
@@ -89,20 +89,36 @@ public class ImsService extends Service {
    // call ImsFeature#onFeatureRemoved.
    private final SparseArray<SparseArray<ImsFeature>> mFeaturesBySlot = new SparseArray<>();

    private IImsServiceControllerListener mListener;


    /**
     * Listener that notifies the framework of ImsService changes.
     * @hide
     */
    protected final IBinder mImsServiceController = new IImsServiceController.Stub() {
    public static class Listener extends IImsServiceControllerListener.Stub {
        /**
         * The IMS features that this ImsService supports has changed.
         * @param c a new {@link ImsFeatureConfiguration} containing {@link ImsFeature.FeatureType}s
         *   that this ImsService supports. This may trigger the addition/removal of feature
         *   in this service.
         */
        public void onUpdateSupportedImsFeatures(ImsFeatureConfiguration c) {
        }
    }

    /**
     * @hide
     */
    protected final IBinder mImsServiceController = new IImsServiceController.Stub() {
        @Override
        public IImsMMTelFeature createEmergencyMMTelFeature(int slotId,
                IImsFeatureStatusCallback c) {
            return createEmergencyMMTelFeatureInternal(slotId, c);
        public void setListener(IImsServiceControllerListener l) {
            mListener = l;
        }

        @Override
        public IImsMMTelFeature createMMTelFeature(int slotId, IImsFeatureStatusCallback c) {
            return createMMTelFeatureInternal(slotId, c);
        public IImsMmTelFeature createMmTelFeature(int slotId, IImsFeatureStatusCallback c) {
            return createMmTelFeatureInternal(slotId, c);
        }

        @Override
@@ -116,11 +132,43 @@ public class ImsService extends Service {
            ImsService.this.removeImsFeature(slotId, featureType, c);
        }

        @Override
        public ImsFeatureConfiguration querySupportedImsFeatures() {
            return ImsService.this.querySupportedImsFeatures();
        }

        @Override
        public void notifyImsServiceReadyForFeatureCreation() {
            ImsService.this.readyForFeatureCreation();
        }

        @Override
        public void notifyImsFeatureReady(int slotId, int featureType)
                throws RemoteException {
            ImsService.this.notifyImsFeatureReady(slotId, featureType);
        }

        @Override
        public IImsConfig getConfig(int slotId) throws RemoteException {
            ImsConfigImplBase c = ImsService.this.getConfig(slotId);
            return c != null ? c.getIImsConfig() : null;
        }

        @Override
        public IImsRegistration getRegistration(int slotId) throws RemoteException {
            ImsRegistrationImplBase r = ImsService.this.getRegistration(slotId);
            return r != null ? r.getBinder() : null;
        }

        @Override
        public void enableIms(int slotId) {
            ImsService.this.enableIms(slotId);
        }

        @Override
        public void disableIms(int slotId) {
            ImsService.this.disableIms(slotId);
        }
    };

    /**
@@ -143,47 +191,35 @@ public class ImsService extends Service {
        return mFeaturesBySlot.get(slotId);
    }

    private IImsMMTelFeature createEmergencyMMTelFeatureInternal(int slotId,
    private IImsMmTelFeature createMmTelFeatureInternal(int slotId,
            IImsFeatureStatusCallback c) {
        MMTelFeature f = onCreateEmergencyMMTelImsFeature(slotId);
        MmTelFeature f = createMmTelFeature(slotId);
        if (f != null) {
            setupFeature(f, slotId, ImsFeature.EMERGENCY_MMTEL, c);
            return f.getBinder();
        } else {
            return null;
        }
    }

    private IImsMMTelFeature createMMTelFeatureInternal(int slotId,
            IImsFeatureStatusCallback c) {
        MMTelFeature f = onCreateMMTelImsFeature(slotId);
        if (f != null) {
            setupFeature(f, slotId, ImsFeature.MMTEL, c);
            setupFeature(f, slotId, ImsFeature.FEATURE_MMTEL, c);
            return f.getBinder();
        } else {
            Log.e(LOG_TAG, "createMmTelFeatureInternal: null feature returned.");
            return null;
        }
    }

    private IImsRcsFeature createRcsFeatureInternal(int slotId,
            IImsFeatureStatusCallback c) {
        RcsFeature f = onCreateRcsFeature(slotId);
        RcsFeature f = createRcsFeature(slotId);
        if (f != null) {
            setupFeature(f, slotId, ImsFeature.RCS, c);
            setupFeature(f, slotId, ImsFeature.FEATURE_RCS, c);
            return f.getBinder();
        } else {
            Log.e(LOG_TAG, "createRcsFeatureInternal: null feature returned.");
            return null;
        }
    }

    private void setupFeature(ImsFeature f, int slotId, int featureType,
            IImsFeatureStatusCallback c) {
        f.setContext(this);
        f.setSlotId(slotId);
        f.addImsFeatureStatusCallback(c);
        f.initialize(this, slotId);
        addImsFeature(slotId, featureType, f);
        // TODO: Remove once new onFeatureReady AIDL is merged in.
        f.onFeatureReady();
    }

    private void addImsFeature(int slotId, int featureType, ImsFeature f) {
@@ -221,32 +257,115 @@ public class ImsService extends Service {
        }
    }

    private void notifyImsFeatureReady(int slotId, int featureType) {
        synchronized (mFeaturesBySlot) {
            // get ImsFeature associated with the slot/feature
            SparseArray<ImsFeature> features = mFeaturesBySlot.get(slotId);
            if (features == null) {
                Log.w(LOG_TAG, "Can not notify ImsFeature ready. No ImsFeatures exist on " +
                        "slot " + slotId);
                return;
            }
            ImsFeature f = features.get(featureType);
            if (f == null) {
                Log.w(LOG_TAG, "Can not notify ImsFeature ready. No feature with type "
                        + featureType + " exists on slot " + slotId);
                return;
            }
            f.onFeatureReady();
        }
    }

    /**
     * @return An implementation of MMTelFeature that will be used by the system for MMTel
     * functionality. Must be able to handle emergency calls at any time as well.
     * When called, provide the {@link ImsFeatureConfiguration} that this ImsService currently
     * supports. This will trigger the framework to set up the {@link ImsFeature}s that correspond
     * to the {@link ImsFeature.FeatureType}s configured here.
     * @return an {@link ImsFeatureConfiguration} containing Features this ImsService supports,
     * defined in {@link ImsFeature.FeatureType}.
     * @hide
     */
    public @Nullable MMTelFeature onCreateEmergencyMMTelImsFeature(int slotId) {
        return null;
    public ImsFeatureConfiguration querySupportedImsFeatures() {
        // Return empty for base implementation
        return new ImsFeatureConfiguration();
    }

    /**
     * Updates the framework with a new {@link ImsFeatureConfiguration} containing the updated
     * features, defined in {@link ImsFeature.FeatureType} that this ImsService supports. This may
     * trigger the framework to add/remove new ImsFeatures, depending on the configuration.
     * @hide
     */
    public final void onUpdateSupportedImsFeatures(ImsFeatureConfiguration c)
            throws RemoteException {
        if (mListener == null) {
            throw new IllegalStateException("Framework is not ready");
        }
        mListener.onUpdateSupportedImsFeatures(c);
    }

    /**
     * The ImsService has been bound and is ready for ImsFeature creation based on the Features that
     * the ImsService has registered for with the framework, either in the manifest or via
     * The ImsService should use this signal instead of onCreate/onBind or similar to perform
     * feature initialization because the framework may bind to this service multiple times to
     * query the ImsService's {@link ImsFeatureConfiguration} via
     * {@link #querySupportedImsFeatures()}before creating features.
     * @hide
     */
    public void readyForFeatureCreation() {
    }

    /**
     * @return An implementation of MMTelFeature that will be used by the system for MMTel
     * functionality.
     * The framework has enabled IMS for the slot specified, the ImsService should register for IMS
     * and perform all appropriate initialization to bring up all ImsFeatures.
     * @hide
     */
    public @Nullable MMTelFeature onCreateMMTelImsFeature(int slotId) {
    public void enableIms(int slotId) {
    }

    /**
     * The framework has disabled IMS for the slot specified. The ImsService must deregister for IMS
     * and set capability status to false for all ImsFeatures.
     * @hide
     */
    public void disableIms(int slotId) {
    }

    /**
     * When called, the framework is requesting that a new MmTelFeature is created for the specified
     * slot.
     *
     * @param slotId The slot ID that the MMTel Feature is being created for.
     * @return The newly created MmTelFeature associated with the slot or null if the feature is not
     * supported.
     * @hide
     */
    public MmTelFeature createMmTelFeature(int slotId) {
        return null;
    }

    /**
     * @return An implementation of RcsFeature that will be used by the system for RCS.
     * When called, the framework is requesting that a new RcsFeature is created for the specified
     * slot
     *
     * @param slotId The slot ID that the RCS Feature is being created for.
     * @return The newly created RcsFeature associated with the slot or null if the feature is not
     * supported.
     * @hide
     */
    public @Nullable RcsFeature onCreateRcsFeature(int slotId) {
    public RcsFeature createRcsFeature(int slotId) {
        return null;
    }

    /**
     * @param slotId The slot that the IMS configuration is associated with.
     * @return ImsConfig implementation that is associated with the specified slot.
     * @hide
     */
    public ImsConfigImplBase getConfig(int slotId) {
        return new ImsConfigImplBase();
    }

    /**
     * @param slotId The slot that is associated with the IMS Registration.
     * @return the ImsRegistration implementation associated with the slot.
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package android.telephony.ims.internal.aidl;
package android.telephony.ims.aidl;

/**
 * See ImsFeature#CapabilityCallback for more information.
+2 −2
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@
 */


package android.telephony.ims.internal.aidl;
package android.telephony.ims.aidl;

import android.telephony.ims.internal.aidl.IImsConfigCallback;
import android.telephony.ims.aidl.IImsConfigCallback;

import com.android.ims.ImsConfigListener;

Loading