From 9c750fe77fc8ea3d556cd71abf459f21839e4d56 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Thu, 1 Mar 2018 13:05:59 -0800 Subject: [PATCH] Support Dynamic ImsService Querying 1) Provide a "default" impl for MmTelFeature instead of returning null. 2) Introduce a FeatureSlotPair, which maps a SIM slot ID to a ImsFeature. This allows the ImsService to provide which features it supports for multi-SIM phones. 3) Pipe through ImsResolver state to help prevent IMS operation when the ImsResolver is in the process of figuring out feature capabilities. Test: Telephony ImsService test app, telephony unit tests Bug: 72642524 Merged-In: I4d7e9ba630739ade83e3242488f330ea6e73bbd7 Change-Id: Idb95f7651af200026d62e8b29eaed30bc0ebc9d3 --- api/system-current.txt | 11 +- .../java/android/telephony/TelephonyManager.java | 17 +++ .../telephony/ims/feature/MmTelFeature.java | 6 +- .../ims/stub/ImsFeatureConfiguration.java | 116 +++++++++++++++------ .../com/android/internal/telephony/ITelephony.aidl | 6 ++ 5 files changed, 117 insertions(+), 39 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 43425cb2da83..d543629ad2d9 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6127,19 +6127,24 @@ package android.telephony.ims.stub { } public final class ImsFeatureConfiguration implements android.os.Parcelable { - ctor public ImsFeatureConfiguration(); method public int describeContents(); - method public int[] getServiceFeatures(); + method public java.util.Set getServiceFeatures(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } public static class ImsFeatureConfiguration.Builder { ctor public ImsFeatureConfiguration.Builder(); - method public android.telephony.ims.stub.ImsFeatureConfiguration.Builder addFeature(int); + method public android.telephony.ims.stub.ImsFeatureConfiguration.Builder addFeature(int, int); method public android.telephony.ims.stub.ImsFeatureConfiguration build(); } + public static final class ImsFeatureConfiguration.FeatureSlotPair { + ctor public ImsFeatureConfiguration.FeatureSlotPair(int, int); + field public final int featureType; + field public final int slotId; + } + public class ImsMultiEndpointImplBase { ctor public ImsMultiEndpointImplBase(); method public final void onImsExternalCallStateUpdate(java.util.List); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 530eda1674f7..5f7fd2db25b4 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -5292,6 +5292,23 @@ public class TelephonyManager { } /** + * @return true if the IMS resolver is busy resolving a binding and should not be considered + * available, false if the IMS resolver is idle. + * @hide + */ + public boolean isResolvingImsBinding() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isResolvingImsBinding(); + } + } catch (RemoteException e) { + Rlog.e(TAG, "isResolvingImsBinding, RemoteException: " + e.getMessage()); + } + return false; + } + + /** * Set IMS registration state * * @param Registration state diff --git a/telephony/java/android/telephony/ims/feature/MmTelFeature.java b/telephony/java/android/telephony/ims/feature/MmTelFeature.java index 2fffd36a1a4f..c073d1ab03d6 100644 --- a/telephony/java/android/telephony/ims/feature/MmTelFeature.java +++ b/telephony/java/android/telephony/ims/feature/MmTelFeature.java @@ -575,7 +575,7 @@ public class MmTelFeature extends ImsFeature { */ public ImsUtImplBase getUt() { // Base Implementation - Should be overridden - return null; + return new ImsUtImplBase(); } /** @@ -584,7 +584,7 @@ public class MmTelFeature extends ImsFeature { */ public ImsEcbmImplBase getEcbm() { // Base Implementation - Should be overridden - return null; + return new ImsEcbmImplBase(); } /** @@ -593,7 +593,7 @@ public class MmTelFeature extends ImsFeature { */ public ImsMultiEndpointImplBase getMultiEndpoint() { // Base Implementation - Should be overridden - return null; + return new ImsMultiEndpointImplBase(); } /** diff --git a/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java b/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java index 98b67c3d3727..2f52c0ac2d99 100644 --- a/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java +++ b/telephony/java/android/telephony/ims/stub/ImsFeatureConfiguration.java @@ -21,6 +21,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.ims.feature.ImsFeature; import android.util.ArraySet; +import android.util.Pair; import java.util.Set; @@ -34,14 +35,57 @@ import java.util.Set; */ @SystemApi public final class ImsFeatureConfiguration implements Parcelable { + + public static final class FeatureSlotPair { + /** + * SIM slot that this feature is associated with. + */ + public final int slotId; + /** + * The feature that this slotId supports. Supported values are + * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and + * {@link ImsFeature#FEATURE_RCS}. + */ + public final @ImsFeature.FeatureType int featureType; + + /** + * A mapping from slotId to IMS Feature type. + * @param slotId the SIM slot ID associated with this feature. + * @param featureType The feature that this slotId supports. Supported values are + * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and + * {@link ImsFeature#FEATURE_RCS}. + */ + public FeatureSlotPair(int slotId, @ImsFeature.FeatureType int featureType) { + this.slotId = slotId; + this.featureType = featureType; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + FeatureSlotPair that = (FeatureSlotPair) o; + + if (slotId != that.slotId) return false; + return featureType == that.featureType; + } + + @Override + public int hashCode() { + int result = slotId; + result = 31 * result + featureType; + return result; + } + } + /** * Features that this ImsService supports. */ - private final Set mFeatures; + private final Set mFeatures; /** - * Builder for {@link ImsFeatureConfiguration} that makes adding supported {@link ImsFeature}s - * easier. + * Builder for {@link ImsFeatureConfiguration}. */ public static class Builder { ImsFeatureConfiguration mConfig; @@ -50,12 +94,15 @@ public final class ImsFeatureConfiguration implements Parcelable { } /** - * @param feature A feature defined in {@link ImsFeature.FeatureType} that this service - * supports. + * Adds an IMS feature associated with a SIM slot ID. + * @param slotId The slot ID associated with the IMS feature. + * @param featureType The feature that the slot ID supports. Supported values are + * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and + * {@link ImsFeature#FEATURE_RCS}. * @return a {@link Builder} to continue constructing the ImsFeatureConfiguration. */ - public Builder addFeature(@ImsFeature.FeatureType int feature) { - mConfig.addFeature(feature); + public Builder addFeature(int slotId, @ImsFeature.FeatureType int featureType) { + mConfig.addFeature(slotId, featureType); return this; } @@ -66,8 +113,7 @@ public final class ImsFeatureConfiguration implements Parcelable { /** * Creates with all registration features empty. - * - * Consider using the provided {@link Builder} to create this configuration instead. + * @hide */ public ImsFeatureConfiguration() { mFeatures = new ArraySet<>(); @@ -76,45 +122,41 @@ public final class ImsFeatureConfiguration implements Parcelable { /** * Configuration of the ImsService, which describes which features the ImsService supports * (for registration). - * @param features an array of feature integers defined in {@link ImsFeature} that describe - * which features this ImsService supports. Supported values are - * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and - * {@link ImsFeature#FEATURE_RCS}. + * @param features a set of {@link FeatureSlotPair}s that describe which features this + * ImsService supports. * @hide */ - public ImsFeatureConfiguration(int[] features) { + public ImsFeatureConfiguration(Set features) { mFeatures = new ArraySet<>(); if (features != null) { - for (int i : features) { - mFeatures.add(i); - } + mFeatures.addAll(features); } } /** - * @return an int[] containing the features that this ImsService supports. Supported values are - * {@link ImsFeature#FEATURE_EMERGENCY_MMTEL}, {@link ImsFeature#FEATURE_MMTEL}, and - * {@link ImsFeature#FEATURE_RCS}. + * @return a set of supported slot ID to feature type pairs contained within a + * {@link FeatureSlotPair}. */ - public int[] getServiceFeatures() { - return mFeatures.stream().mapToInt(i->i).toArray(); + public Set getServiceFeatures() { + return new ArraySet<>(mFeatures); } - void addFeature(int feature) { - mFeatures.add(feature); + /** + * @hide + */ + void addFeature(int slotId, int feature) { + mFeatures.add(new FeatureSlotPair(slotId, feature)); } /** @hide */ protected ImsFeatureConfiguration(Parcel in) { - int[] features = in.createIntArray(); - if (features != null) { - mFeatures = new ArraySet<>(features.length); - for(Integer i : features) { - mFeatures.add(i); - } - } else { - mFeatures = new ArraySet<>(); + int featurePairLength = in.readInt(); + // length + mFeatures = new ArraySet<>(featurePairLength); + for (int i = 0; i < featurePairLength; i++) { + // pair of reads for each entry (slotId->featureType) + mFeatures.add(new FeatureSlotPair(in.readInt(), in.readInt())); } } @@ -138,7 +180,15 @@ public final class ImsFeatureConfiguration implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeIntArray(mFeatures.stream().mapToInt(i->i).toArray()); + FeatureSlotPair[] featureSlotPairs = new FeatureSlotPair[mFeatures.size()]; + mFeatures.toArray(featureSlotPairs); + // length of list + dest.writeInt(featureSlotPairs.length); + // then pairs of integers for each entry (slotId->featureType). + for (FeatureSlotPair featureSlotPair : featureSlotPairs) { + dest.writeInt(featureSlotPair.slotId); + dest.writeInt(featureSlotPair.featureType); + } } /** diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 4002d3c94db7..afbb94776641 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -829,6 +829,12 @@ interface ITelephony { boolean isEmergencyMmTelAvailable(int slotId); /** + * @return true if the IMS resolver is busy resolving a binding and should not be considered + * available, false if the IMS resolver is idle. + */ + boolean isResolvingImsBinding(); + + /** * Set the network selection mode to automatic. * * @param subId the id of the subscription to update. -- 2.11.0