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

Commit 4f0731d5 authored by Hunsuk Choi's avatar Hunsuk Choi Committed by Android (Google) Code Review
Browse files

Merge "Add system apis to notify IMS registration state to modem"

parents 4dc478a9 0689a503
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -45443,6 +45443,7 @@ package android.telephony.ims.feature {
package android.telephony.ims.stub {
  public class ImsRegistrationImplBase {
    field public static final int REGISTRATION_TECH_3G = 4; // 0x4
    field public static final int REGISTRATION_TECH_CROSS_SIM = 2; // 0x2
    field public static final int REGISTRATION_TECH_IWLAN = 1; // 0x1
    field public static final int REGISTRATION_TECH_LTE = 0; // 0x0
+11 −0
Original line number Diff line number Diff line
@@ -15506,6 +15506,16 @@ package android.telephony.ims {
    method public void onPublishStateChange(int);
  }
  public interface RegistrationManager {
    field public static final int SUGGESTED_ACTION_NONE = 0; // 0x0
    field public static final int SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK = 1; // 0x1
    field public static final int SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT = 2; // 0x2
  }
  public static class RegistrationManager.RegistrationCallback {
    method public void onUnregistered(@NonNull android.telephony.ims.ImsReasonInfo, int);
  }
  public final class RtpHeaderExtension implements android.os.Parcelable {
    ctor public RtpHeaderExtension(@IntRange(from=1, to=14) int, @NonNull byte[]);
    method public int describeContents();
@@ -15902,6 +15912,7 @@ package android.telephony.ims.stub {
    ctor public ImsRegistrationImplBase();
    ctor public ImsRegistrationImplBase(@NonNull java.util.concurrent.Executor);
    method public final void onDeregistered(android.telephony.ims.ImsReasonInfo);
    method public final void onDeregistered(@Nullable android.telephony.ims.ImsReasonInfo, int);
    method public final void onRegistered(int);
    method public final void onRegistered(@NonNull android.telephony.ims.ImsRegistrationAttributes);
    method public final void onRegistering(int);
+53 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Binder;
@@ -75,6 +76,41 @@ public interface RegistrationManager {
     */
    int REGISTRATION_STATE_REGISTERED = 2;

    /** @hide */
    @IntDef(prefix = {"SUGGESTED_ACTION_"},
            value = {
            SUGGESTED_ACTION_NONE,
            SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK,
            SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SuggestedAction {}

    /**
     * Default value. No action is suggested when IMS registration fails.
     * @hide
     */
    @SystemApi
    public static final int SUGGESTED_ACTION_NONE = 0;

    /**
     * Indicates that the IMS registration is failed with fatal error such as 403 or 404
     * on all P-CSCF addresses. The radio shall block the current PLMN or disable
     * the RAT as per the carrier requirements.
     * @hide
     */
    @SystemApi
    public static final int SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK = 1;

    /**
     * Indicates that the IMS registration on current PLMN failed multiple times.
     * The radio shall block the current PLMN or disable the RAT during EPS or 5GS mobility
     * management timer value as per the carrier requirements.
     * @hide
     */
    @SystemApi
    public static final int SUGGESTED_ACTION_TRIGGER_PLMN_BLOCK_WITH_TIMEOUT = 2;

    /**@hide*/
    // Translate ImsRegistrationImplBase API to new AccessNetworkConstant because WLAN
    // and WWAN are more accurate constants.
@@ -167,12 +203,12 @@ public interface RegistrationManager {
            }

            @Override
            public void onDeregistered(ImsReasonInfo info) {
            public void onDeregistered(ImsReasonInfo info, @SuggestedAction int suggestedAction) {
                if (mLocalCallback == null) return;

                final long callingIdentity = Binder.clearCallingIdentity();
                try {
                    mExecutor.execute(() -> mLocalCallback.onUnregistered(info));
                    mExecutor.execute(() -> mLocalCallback.onUnregistered(info, suggestedAction));
                } finally {
                    restoreCallingIdentity(callingIdentity);
                }
@@ -257,6 +293,21 @@ public interface RegistrationManager {
        public void onUnregistered(@NonNull ImsReasonInfo info) {
        }

        /**
         * Notifies the framework when the IMS Provider is unregistered from the IMS network.
         *
         * @param info the {@link ImsReasonInfo} associated with why registration was disconnected.
         * @param suggestedAction the expected behavior of radio protocol stack.
         *
         * @hide
         */
        @SystemApi
        public void onUnregistered(@NonNull ImsReasonInfo info,
                @SuggestedAction int suggestedAction) {
            // Default impl to keep backwards compatibility with old implementations
            onUnregistered(info);
        }

        /**
         * A failure has occurred when trying to handover registration to another technology type.
         *
+2 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import android.telephony.ims.ImsRegistrationAttributes;
oneway interface IImsRegistrationCallback {
   void onRegistered(in ImsRegistrationAttributes attr);
   void onRegistering(in ImsRegistrationAttributes attr);
   void onDeregistered(in ImsReasonInfo info);
   void onDeregistered(in ImsReasonInfo info, int suggestedAction);
   void onTechnologyChangeFailed(int imsRadioTech, in ImsReasonInfo info);
   void onSubscriberAssociatedUriChanged(in Uri[] uris);
}
+44 −6
Original line number Diff line number Diff line
@@ -64,7 +64,8 @@ public class ImsRegistrationImplBase {
                    REGISTRATION_TECH_LTE,
                    REGISTRATION_TECH_IWLAN,
                    REGISTRATION_TECH_CROSS_SIM,
                    REGISTRATION_TECH_NR
                    REGISTRATION_TECH_NR,
                    REGISTRATION_TECH_3G
            })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ImsRegistrationTech {}
@@ -91,11 +92,16 @@ public class ImsRegistrationImplBase {
     */
    public static final int REGISTRATION_TECH_NR = 3;

    /**
     * This ImsService is registered to IMS via 3G.
     */
    public static final int REGISTRATION_TECH_3G = 4;

    /**
     * This is used to check the upper range of registration tech
     * @hide
     */
    public static final int REGISTRATION_TECH_MAX = REGISTRATION_TECH_NR + 1;
    public static final int REGISTRATION_TECH_MAX = REGISTRATION_TECH_3G + 1;

    // Registration states, used to notify new ImsRegistrationImplBase#Callbacks of the current
    // state.
@@ -301,6 +307,8 @@ public class ImsRegistrationImplBase {
    private int mRegistrationState = REGISTRATION_STATE_UNKNOWN;
    // Locked on mLock, create unspecified disconnect cause.
    private ImsReasonInfo mLastDisconnectCause = new ImsReasonInfo();
    // Locked on mLock
    private int mLastDisconnectSuggestedAction = RegistrationManager.SUGGESTED_ACTION_NONE;

    // We hold onto the uris each time they change so that we can send it to a callback when its
    // first added.
@@ -467,12 +475,37 @@ public class ImsRegistrationImplBase {
     */
    @SystemApi
    public final void onDeregistered(ImsReasonInfo info) {
        updateToDisconnectedState(info);
        // Default impl to keep backwards compatibility with old implementations
        onDeregistered(info, RegistrationManager.SUGGESTED_ACTION_NONE);
    }

    /**
     * Notify the framework that the device is disconnected from the IMS network.
     * <p>
     * Note: Prior to calling {@link #onDeregistered(ImsReasonInfo,int)}, you should ensure that any
     * changes to {@link android.telephony.ims.feature.ImsFeature} capability availability is sent
     * to the framework.  For example,
     * {@link android.telephony.ims.feature.MmTelFeature.MmTelCapabilities#CAPABILITY_TYPE_VIDEO}
     * and
     * {@link android.telephony.ims.feature.MmTelFeature.MmTelCapabilities#CAPABILITY_TYPE_VOICE}
     * may be set to unavailable to ensure the framework knows these services are no longer
     * available due to de-registration.  If you do not report capability changes impacted by
     * de-registration, the framework will not know which features are no longer available as a
     * result.
     *
     * @param info the {@link ImsReasonInfo} associated with why registration was disconnected.
     * @param suggestedAction the expected behavior of radio protocol stack.
     * @hide This API is not part of the Android public SDK API
     */
    @SystemApi
    public final void onDeregistered(@Nullable ImsReasonInfo info,
            @RegistrationManager.SuggestedAction int suggestedAction) {
        updateToDisconnectedState(info, suggestedAction);
        // ImsReasonInfo should never be null.
        final ImsReasonInfo reasonInfo = (info != null) ? info : new ImsReasonInfo();
        mCallbacks.broadcastAction((c) -> {
            try {
                c.onDeregistered(reasonInfo);
                c.onDeregistered(reasonInfo, suggestedAction);
            } catch (RemoteException e) {
                Log.w(LOG_TAG, e + "onDeregistered() - Skipping callback.");
            }
@@ -531,10 +564,12 @@ public class ImsRegistrationImplBase {
            mRegistrationAttributes = attributes;
            mRegistrationState = newState;
            mLastDisconnectCause = null;
            mLastDisconnectSuggestedAction = RegistrationManager.SUGGESTED_ACTION_NONE;
        }
    }

    private void updateToDisconnectedState(ImsReasonInfo info) {
    private void updateToDisconnectedState(ImsReasonInfo info,
            @RegistrationManager.SuggestedAction int suggestedAction) {
        synchronized (mLock) {
            //We don't want to send this info over if we are disconnected
            mUrisSet = false;
@@ -544,6 +579,7 @@ public class ImsRegistrationImplBase {
                    RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED);
            if (info != null) {
                mLastDisconnectCause = info;
                mLastDisconnectSuggestedAction = suggestedAction;
            } else {
                Log.w(LOG_TAG, "updateToDisconnectedState: no ImsReasonInfo provided.");
                mLastDisconnectCause = new ImsReasonInfo();
@@ -560,18 +596,20 @@ public class ImsRegistrationImplBase {
        int state;
        ImsRegistrationAttributes attributes;
        ImsReasonInfo disconnectInfo;
        int suggestedAction;
        boolean urisSet;
        Uri[] uris;
        synchronized (mLock) {
            state = mRegistrationState;
            attributes = mRegistrationAttributes;
            disconnectInfo = mLastDisconnectCause;
            suggestedAction = mLastDisconnectSuggestedAction;
            urisSet = mUrisSet;
            uris = mUris;
        }
        switch (state) {
            case RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED: {
                c.onDeregistered(disconnectInfo);
                c.onDeregistered(disconnectInfo, suggestedAction);
                break;
            }
            case RegistrationManager.REGISTRATION_STATE_REGISTERING: {