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

Commit b7322dae authored by Brad Ebinger's avatar Brad Ebinger Committed by Android (Google) Code Review
Browse files

Merge "Add the ability to send the feature tags associated with IMS registration" into sc-dev

parents 56033d22 571acd85
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -42938,6 +42938,16 @@ package android.telephony.ims {
    field public static final int EXTRA_CODE_CALL_RETRY_SILENT_REDIAL = 2; // 0x2
  }
  public final class ImsRegistrationAttributes implements android.os.Parcelable {
    method public int describeContents();
    method public int getAttributeFlags();
    method @NonNull public java.util.Set<java.lang.String> getFeatureTags();
    method public int getTransportType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field public static final int ATTR_EPDG_OVER_CELL_INTERNET = 1; // 0x1
    field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ims.ImsRegistrationAttributes> CREATOR;
  }
  public class RcsUceAdapter {
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean isUceSettingEnabled() throws android.telephony.ims.ImsException;
  }
@@ -42947,7 +42957,6 @@ package android.telephony.ims {
    method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void getRegistrationTransportType(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
    method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void registerImsRegistrationCallback(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.ims.RegistrationManager.RegistrationCallback) throws android.telephony.ims.ImsException;
    method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void unregisterImsRegistrationCallback(@NonNull android.telephony.ims.RegistrationManager.RegistrationCallback);
    field public static final int ATTR_EPDG_OVER_CELL_INTERNET = 1; // 0x1
    field public static final int REGISTRATION_STATE_NOT_REGISTERED = 0; // 0x0
    field public static final int REGISTRATION_STATE_REGISTERED = 2; // 0x2
    field public static final int REGISTRATION_STATE_REGISTERING = 1; // 0x1
@@ -42956,9 +42965,9 @@ package android.telephony.ims {
  public static class RegistrationManager.RegistrationCallback {
    ctor public RegistrationManager.RegistrationCallback();
    method @Deprecated public void onRegistered(int);
    method public void onRegistered(int, int);
    method public void onRegistered(@NonNull android.telephony.ims.ImsRegistrationAttributes);
    method @Deprecated public void onRegistering(int);
    method public void onRegistering(int, int);
    method public void onRegistering(@NonNull android.telephony.ims.ImsRegistrationAttributes);
    method public void onTechnologyChangeFailed(int, @NonNull android.telephony.ims.ImsReasonInfo);
    method public void onUnregistered(@NonNull android.telephony.ims.ImsReasonInfo);
  }
+12 −0
Original line number Diff line number Diff line
@@ -12978,6 +12978,16 @@ package android.telephony.ims {
    field public static final String EXTRA_MSG_SERVICE_NOT_AUTHORIZED = "Forbidden. Not Authorized for Service";
  }
  public final class ImsRegistrationAttributes implements android.os.Parcelable {
    method public int getRegistrationTechnology();
  }
  public static final class ImsRegistrationAttributes.Builder {
    ctor public ImsRegistrationAttributes.Builder(int);
    method @NonNull public android.telephony.ims.ImsRegistrationAttributes build();
    method @NonNull public android.telephony.ims.ImsRegistrationAttributes.Builder setFeatureTags(@NonNull java.util.Set<java.lang.String>);
  }
  public class ImsService extends android.app.Service {
    ctor public ImsService();
    method public android.telephony.ims.feature.MmTelFeature createMmTelFeature(int);
@@ -13761,7 +13771,9 @@ package android.telephony.ims.stub {
    ctor public ImsRegistrationImplBase();
    method public final void onDeregistered(android.telephony.ims.ImsReasonInfo);
    method public final void onRegistered(int);
    method public final void onRegistered(@NonNull android.telephony.ims.ImsRegistrationAttributes);
    method public final void onRegistering(int);
    method public final void onRegistering(@NonNull android.telephony.ims.ImsRegistrationAttributes);
    method public final void onSubscriberAssociatedUriChanged(android.net.Uri[]);
    method public final void onTechnologyChangeFailed(int, android.telephony.ims.ImsReasonInfo);
    method public void triggerFullNetworkRegistration(@IntRange(from=100, to=699) int, @Nullable String);
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims;

parcelable ImsRegistrationAttributes;
+252 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.AccessNetworkConstants;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.ArraySet;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;

/**
 * Contains the attributes associated with the current IMS registration.
 */
public final class ImsRegistrationAttributes implements Parcelable {

    /**
     * Attribute to specify if an EPDG tunnel is setup over the cellular internet APN.
     * <p>
     * If IMS is registered through an EPDG tunnel is setup over the cellular internet APN then this
     * bit will be set. If IMS is registered through the IMS APN, then this bit will not be set.
     *
     */
    public static final int ATTR_EPDG_OVER_CELL_INTERNET = 1 << 0;

    /** @hide */
    // Defines the underlying radio technology type that we have registered for IMS over.
    @IntDef(prefix = "ATTR_",
            value = {
                    ATTR_EPDG_OVER_CELL_INTERNET,
            },
            flag = true)
    @Retention(RetentionPolicy.SOURCE)
    public @interface ImsAttributeFlag {}

    /**
     * Builder for creating {@link ImsRegistrationAttributes} instances.
     * @hide
     */
    @SystemApi
    public static final class Builder {
        private final int mRegistrationTech;
        private Set<String> mFeatureTags = Collections.emptySet();

        /**
         * Build a new instance of {@link ImsRegistrationAttributes}.
         *
         * @param registrationTech The Radio Access Technology that IMS is registered on.
         */
        public Builder(@ImsRegistrationImplBase.ImsRegistrationTech int registrationTech) {
            mRegistrationTech = registrationTech;
        }

        /**
         * Optional IMS feature tags included in this IMS registration.
         * @param tags A set of Strings containing the MMTEL and RCS feature tags associated with
         *         the IMS registration. This information is used for services such as the UCE
         *         service to ascertain the complete IMS registration state to ensure the SIP
         *         PUBLISH is accurate. The format of the set of feature tags must be one feature
         *         tag key and value per entry. Each feature tag will contain the feature tag name
         *         and string value (if applicable), even if they have the same feature tag name.
         *         For example,
         *         {@code +g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.msg,
         *         urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.session", +g.gsma.callcomposer} must
         *         be split into three feature tag entries:
         *         {@code {+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.msg",
         *         +g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.session",
         *         +g.gsma.callcomposer}}.
         */
        public @NonNull Builder setFeatureTags(@NonNull Set<String> tags) {
            if (tags == null) {
                throw new IllegalArgumentException("feature tag set must not be null");
            }
            mFeatureTags = new ArraySet<>(tags);
            return this;
        }

        /**
         * @return A new instance created from this builder.
         */
        public @NonNull ImsRegistrationAttributes build() {
            return new ImsRegistrationAttributes(mRegistrationTech,
                    RegistrationManager.getAccessType(mRegistrationTech),
                    getAttributeFlags(mRegistrationTech),
                    mFeatureTags);
        }

        /**
         * @return attribute flags from the registration technology.
         */
        private static int getAttributeFlags(int imsRadioTech) {
            int attributes = 0;
            if (imsRadioTech == ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM) {
                attributes |= ATTR_EPDG_OVER_CELL_INTERNET;
            }
            return attributes;
        }
    }

    private final int mRegistrationTech;
    private final int mTransportType;
    private final int mImsAttributeFlags;
    private final ArrayList<String> mFeatureTags;

    /**
     * Create a new {@link ImsRegistrationAttributes} instance.
     *
     * @param registrationTech The technology that IMS has been registered on.
     * @param transportType The transport type that IMS has been registered on.
     * @param imsAttributeFlags The attributes associated with the IMS registration.
     * @param featureTags The feature tags included in the IMS registration.
     * @see Builder
     * @hide
     */
    public ImsRegistrationAttributes(
            @ImsRegistrationImplBase.ImsRegistrationTech int registrationTech,
            @AccessNetworkConstants.TransportType int transportType,
            @ImsAttributeFlag int imsAttributeFlags,
            @Nullable Set<String> featureTags) {
        mRegistrationTech = registrationTech;
        mTransportType = transportType;
        mImsAttributeFlags = imsAttributeFlags;
        mFeatureTags = new ArrayList<>(featureTags);
    }

    /**@hide*/
    public ImsRegistrationAttributes(Parcel source) {
        mRegistrationTech = source.readInt();
        mTransportType = source.readInt();
        mImsAttributeFlags = source.readInt();
        mFeatureTags = new ArrayList<>();
        source.readList(mFeatureTags, null /*classloader*/);
    }

    /**
     * @return The Radio Access Technology that the IMS registration has been registered over.
     * @hide
     */
    @SystemApi
    public @ImsRegistrationImplBase.ImsRegistrationTech int getRegistrationTechnology() {
        return mRegistrationTech;
    }

    /**
     * @return The access network transport type that IMS has been registered over.
     */
    public @AccessNetworkConstants.TransportType int  getTransportType() {
        return mTransportType;
    }

    /**
     * @return A bit-mask containing attributes associated with the IMS registration.
     */
    public @ImsAttributeFlag int getAttributeFlags() {
        return mImsAttributeFlags;
    }

    /**
     * Gets the Set of feature tags associated with the current IMS registration, if the IMS
     * service supports supplying this information.
     * <p>
     * The format of the set of feature tags will be one feature tag key and value per entry and
     * will potentially contain MMTEL and RCS feature tags, depending the configuration of the IMS
     * service associated with the registration indications. Each feature tag will contain the
     * feature tag name and string value (if applicable), even if they have the same feature tag
     * name. For example, {@code +g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.msg,
     * urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.session", +g.gsma.callcomposer} will be split
     * into three feature tag  entries:
     * {@code {+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.msg",
     * +g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.session",
     * +g.gsma.callcomposer}}.
     * @return The Set of feature tags associated with the current IMS registration.
     */
    public @NonNull Set<String> getFeatureTags() {
        if (mFeatureTags == null) {
            return Collections.emptySet();
        }
        return new ArraySet<>(mFeatureTags);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mRegistrationTech);
        dest.writeInt(mTransportType);
        dest.writeInt(mImsAttributeFlags);
        dest.writeList(mFeatureTags);
    }

    public static final @NonNull Creator<ImsRegistrationAttributes> CREATOR =
            new Creator<ImsRegistrationAttributes>() {
                @Override
                public ImsRegistrationAttributes createFromParcel(Parcel source) {
                    return new ImsRegistrationAttributes(source);
                }

                @Override
                public ImsRegistrationAttributes[] newArray(int size) {
                    return new ImsRegistrationAttributes[size];
                }
            };

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ImsRegistrationAttributes that = (ImsRegistrationAttributes) o;
        return mRegistrationTech == that.mRegistrationTech
                && mTransportType == that.mTransportType
                && mImsAttributeFlags == that.mImsAttributeFlags
                && Objects.equals(mFeatureTags, that.mFeatureTags);
    }

    @Override
    public int hashCode() {
        return Objects.hash(mRegistrationTech, mTransportType, mImsAttributeFlags, mFeatureTags);
    }

    @Override
    public String toString() {
        return "ImsRegistrationAttributes { transportType= " + mTransportType + ", attributeFlags="
                + mImsAttributeFlags + ", featureTags=[" + mFeatureTags + "]}";
    }
}
+31 −92
Original line number Diff line number Diff line
@@ -72,30 +72,6 @@ public interface RegistrationManager {
     */
    int REGISTRATION_STATE_REGISTERED = 2;

    /**
     * @hide
     */
    // Defines the underlying radio technology type that we have registered for IMS over.
    @IntDef(prefix = "ATTR_",
            value = {
                    ATTR_EPDG_OVER_CELL_INTERNET,
            },
            flag = true)
    @Retention(RetentionPolicy.SOURCE)
    public @interface ImsAttributes {}

    /**
     * Attribute to specify if EPDG tunnel is setup over cellular internet.
     * if EPDG tunnel is setup over cellular internet then this bit will be set else the same will
     * not be set.
     */
    int ATTR_EPDG_OVER_CELL_INTERNET = 0x00000001;

    //******************************************************************************************
    // Next attribute value: 0x00000002
    //******************************************************************************************


    /**@hide*/
    // Translate ImsRegistrationImplBase API to new AccessNetworkConstant because WLAN
    // and WWAN are more accurate constants.
@@ -103,7 +79,8 @@ public interface RegistrationManager {
            new HashMap<Integer, Integer>() {{
                // Map NONE to -1 to make sure that we handle the REGISTRATION_TECH_NONE
                // case, since it is defined.
                put(ImsRegistrationImplBase.REGISTRATION_TECH_NONE, -1);
                put(ImsRegistrationImplBase.REGISTRATION_TECH_NONE,
                        AccessNetworkConstants.TRANSPORT_TYPE_INVALID);
                put(ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
                        AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                put(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN,
@@ -131,6 +108,20 @@ public interface RegistrationManager {
        }
    }

    /**
     * @param regtech The registration technology.
     * @return The Access Network type from registration technology.
     * @hide
     */
    static int getAccessType(int regtech) {
        if (!RegistrationManager.IMS_REG_TO_ACCESS_TYPE_MAP.containsKey(regtech)) {
            Log.w("RegistrationManager", "getAccessType - invalid regType returned: "
                    + regtech);
            return AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
        }
        return RegistrationManager.IMS_REG_TO_ACCESS_TYPE_MAP.get(regtech);
    }

    /**
     * Callback class for receiving IMS network Registration callback events.
     * @see #registerImsRegistrationCallback(Executor, RegistrationCallback)
@@ -149,45 +140,24 @@ public interface RegistrationManager {
            }

            @Override
            public void onRegistered(int imsRadioTech) {
            public void onRegistered(ImsRegistrationAttributes attr) {
                if (mLocalCallback == null) return;

                final long callingIdentity = Binder.clearCallingIdentity();
                try {
                    mExecutor.execute(() -> {
                        mLocalCallback.onRegistered(getAccessType(imsRadioTech));
                    });
                    int attributes = 0;
                    if (imsRadioTech == ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM) {
                        attributes = changeBitmask(attributes, ATTR_EPDG_OVER_CELL_INTERNET,
                                true);
                    }
                    final int finalattributes = attributes;
                    mExecutor.execute(() ->
                            mLocalCallback.onRegistered(getAccessType(imsRadioTech),
                                    finalattributes));
                    mExecutor.execute(() -> mLocalCallback.onRegistered(attr));
                } finally {
                    restoreCallingIdentity(callingIdentity);
                }
            }

            @Override
            public void onRegistering(int imsRadioTech) {
            public void onRegistering(ImsRegistrationAttributes attr) {
                if (mLocalCallback == null) return;

                final long callingIdentity = Binder.clearCallingIdentity();
                try {
                    mExecutor.execute(() ->
                            mLocalCallback.onRegistering(getAccessType(imsRadioTech)));
                    int attributes = 0;
                    if (imsRadioTech == ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM) {
                        attributes = changeBitmask(attributes, ATTR_EPDG_OVER_CELL_INTERNET,
                                true);
                    }
                    final int finalattributes = attributes;
                    mExecutor.execute(() ->
                            mLocalCallback.onRegistering(getAccessType(imsRadioTech),
                                    finalattributes));
                    mExecutor.execute(() -> mLocalCallback.onRegistering(attr));
                } finally {
                    restoreCallingIdentity(callingIdentity);
                }
@@ -232,31 +202,6 @@ public interface RegistrationManager {
            private void setExecutor(Executor executor) {
                mExecutor = executor;
            }

            private static int getAccessType(int regType) {
                if (!RegistrationManager.IMS_REG_TO_ACCESS_TYPE_MAP.containsKey(regType)) {
                    Log.w("RegistrationManager", "RegistrationBinder - invalid regType returned: "
                            + regType);
                    return -1;
                }
                return RegistrationManager.IMS_REG_TO_ACCESS_TYPE_MAP.get(regType);
            }

            /**
             * Changes a attribute bit-mask to add or remove an attribute.
             *
             * @param bitmask The bit-mask.
             * @param bitfield The bit-field to change.
             * @param enabled Whether the bit-field should be set or removed.
             * @return The bit-mask with the bit-field changed.
             */
            private int changeBitmask(int bitmask, int bitfield, boolean enabled) {
                if (enabled) {
                    return bitmask | bitfield;
                } else {
                    return bitmask & ~bitfield;
                }
            }
        }

        private final RegistrationBinder mBinder = new RegistrationBinder(this);
@@ -265,7 +210,7 @@ public interface RegistrationManager {
         * Notifies the framework when the IMS Provider is registered to the IMS network.
         *
         * @param imsTransportType the radio access technology.
         * @deprecated Use {@link #onRegistered(int, int)} instead.
         * @deprecated Use {@link #onRegistered(ImsRegistrationAttributes)} instead.
         */
        @Deprecated
        public void onRegistered(@AccessNetworkConstants.TransportType int imsTransportType) {
@@ -273,25 +218,20 @@ public interface RegistrationManager {

        /**
         * Notifies the framework when the IMS Provider is registered to the IMS network
         * with corresponding attributes
         *
         * @param imsTransportType the radio access technology.
         * @param registrationAttributes IMS registration attributes as a bitmap of attributes.
         * Possible attributes are following
         * <ul>
         *     <li>{@link #ATTR_EPDG_OVER_CELL_INTERNET}</li>
         * </ul>
         * with corresponding attributes.
         *
         * @param attributes The attributes associated with this IMS registration.
         */
        public void onRegistered(@AccessNetworkConstants.TransportType int imsTransportType,
                @ImsAttributes int registrationAttributes) {
        public void onRegistered(@NonNull ImsRegistrationAttributes attributes) {
            // Default impl to keep backwards compatibility with old implementations
            onRegistered(attributes.getTransportType());
        }

        /**
         * Notifies the framework when the IMS Provider is trying to register the IMS network.
         *
         * @param imsTransportType the radio access technology.
         * @deprecated Use {@link #onRegistering(int, int)} instead.
         * @deprecated Use {@link #onRegistering(ImsRegistrationAttributes)} instead.
         */
        public void onRegistering(@AccessNetworkConstants.TransportType int imsTransportType) {
        }
@@ -299,12 +239,11 @@ public interface RegistrationManager {
        /**
         * Notifies the framework when the IMS Provider is trying to register the IMS network.
         *
         * @param imsTransportType the radio access technology.
         * @param registrationAttributes IMS registration attributes as a bitmap of attributes.
         * Possible attributes are following
         * @param attributes The attributes associated with this IMS registration.
         */
        public void onRegistering(@AccessNetworkConstants.TransportType int imsTransportType,
                @ImsAttributes int registrationAttributes) {
        public void onRegistering(@NonNull ImsRegistrationAttributes attributes) {
            // Default impl to keep backwards compatibility with old implementations
            onRegistering(attributes.getTransportType());
        }

        /**
Loading