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

Commit efed9824 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Expose SRVCC state changes as @SystemAPI

ImsService needs to be able to register for SRVCC state
changes.

Test: Telephony Unit tests
Bug: 117555643
Change-Id: I87631b51a19cdd46d6b4d15f3631345de03bb771
parent 3ef1990e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -5160,7 +5160,9 @@ package android.telephony {

  public class PhoneStateListener {
    method public void onRadioPowerStateChanged(int);
    method public void onSrvccStateChanged(int);
    field public static final int LISTEN_RADIO_POWER_STATE_CHANGED = 8388608; // 0x800000
    field public static final int LISTEN_SRVCC_STATE_CHANGED = 16384; // 0x4000
  }

  public class ServiceState implements android.os.Parcelable {
@@ -5389,6 +5391,11 @@ package android.telephony {
    field public static final int SIM_ACTIVATION_STATE_UNKNOWN = 0; // 0x0
    field public static final int SIM_STATE_LOADED = 10; // 0xa
    field public static final int SIM_STATE_PRESENT = 11; // 0xb
    field public static final int SRVCC_STATE_HANDOVER_CANCELED = 3; // 0x3
    field public static final int SRVCC_STATE_HANDOVER_COMPLETED = 1; // 0x1
    field public static final int SRVCC_STATE_HANDOVER_FAILED = 2; // 0x2
    field public static final int SRVCC_STATE_HANDOVER_NONE = -1; // 0xffffffff
    field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0
  }

  public final class UiccAccessRule implements android.os.Parcelable {
+39 −15
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.VoLteServiceState;
import android.util.LocalLog;
import android.util.StatsLog;

@@ -196,7 +195,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {

    private ArrayList<List<PhysicalChannelConfig>> mPhysicalChannelConfigs;

    private VoLteServiceState mVoLteServiceState = new VoLteServiceState();
    private int[] mSrvccState;

    private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;

@@ -230,8 +229,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {

    static final int ENFORCE_PHONE_STATE_PERMISSION_MASK =
                PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
                PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
                PhoneStateListener.LISTEN_VOLTE_STATE;
                PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR;

    static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
                PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
@@ -356,6 +354,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        mCallForwarding = new boolean[numPhones];
        mCellLocation = new Bundle[numPhones];
        mCellInfo = new ArrayList<List<CellInfo>>();
        mSrvccState = new int[numPhones];
        mPhysicalChannelConfigs = new ArrayList<List<PhysicalChannelConfig>>();
        for (int i = 0; i < numPhones; i++) {
            mCallState[i] =  TelephonyManager.CALL_STATE_IDLE;
@@ -371,6 +370,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            mCallForwarding[i] =  false;
            mCellLocation[i] = new Bundle();
            mCellInfo.add(i, null);
            mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE;
            mPhysicalChannelConfigs.add(i, new ArrayList<PhysicalChannelConfig>());
        }

@@ -772,6 +772,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                            remove(r.binder);
                        }
                    }
                    if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) {
                        try {
                            r.callback.onSrvccStateChanged(mSrvccState[phoneId]);
                        } catch (RemoteException ex) {
                            remove(r.binder);
                        }
                    }
                }
            }
        } else {
@@ -1522,22 +1529,33 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
    }

    public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
        if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) {
    @Override
    public void notifySrvccStateChanged(int subId, @TelephonyManager.SrvccState int state) {
        if (!checkNotifyPermission("notifySrvccStateChanged()")) {
            return;
        }
        if (VDBG) {
            log("notifySrvccStateChanged: subId=" + subId + " srvccState=" + state);
        }
        int phoneId = SubscriptionManager.getPhoneId(subId);
        synchronized (mRecords) {
            mVoLteServiceState = lteState;
            if (validatePhoneId(phoneId)) {
                mSrvccState[phoneId]  = state;
                for (Record r : mRecords) {
                if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_VOLTE_STATE)) {
                    if (r.matchPhoneStateListenerEvent(
                            PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) &&
                            idMatch(r.subId, subId, phoneId)) {
                        try {
                        r.callback.onVoLteServiceStateChanged(
                                new VoLteServiceState(mVoLteServiceState));
                            if (DBG_LOC) {
                                log("notifySrvccStateChanged: mSrvccState=" + state + " r=" + r);
                            }
                            r.callback.onSrvccStateChanged(state);
                        } catch (RemoteException ex) {
                            mRemoveList.add(r.binder);
                        }
                    }
                }
            }
            handleRemoveListLocked();
        }
    }
@@ -1680,7 +1698,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            pw.println("mRingingCallState=" + mRingingCallState);
            pw.println("mForegroundCallState=" + mForegroundCallState);
            pw.println("mBackgroundCallState=" + mBackgroundCallState);
            pw.println("mVoLteServiceState=" + mVoLteServiceState);
            pw.println("mSrvccState=" + mSrvccState);
            pw.println("mPhoneCapability=" + mPhoneCapability);
            pw.println("mPreferredDataSubId=" + mPreferredDataSubId);
            pw.println("mRadioPowerState=" + mRadioPowerState);
@@ -1931,6 +1949,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
        }

        if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) {
            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
        }


        return true;
    }

+16 −13
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package android.telephony;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.os.Bundle;
@@ -201,12 +203,13 @@ public class PhoneStateListener {
    public static final int LISTEN_DATA_CONNECTION_REAL_TIME_INFO           = 0x00002000;

    /**
     * Listen for changes to LTE network state
     *
     * @see #onLteNetworkStateChanged
     * Listen for changes to the SRVCC state of the active call.
     * @see #onServiceStateChanged(ServiceState)
     * @hide
     */
    public static final int LISTEN_VOLTE_STATE                              = 0x00004000;
    @SystemApi
    @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    public static final int LISTEN_SRVCC_STATE_CHANGED                     = 0x00004000;

    /**
     * Listen for OEM hook raw event
@@ -401,8 +404,8 @@ public class PhoneStateListener {
                        PhoneStateListener.this.onDataConnectionRealTimeInfoChanged(
                                (DataConnectionRealTimeInfo)msg.obj);
                        break;
                    case LISTEN_VOLTE_STATE:
                        PhoneStateListener.this.onVoLteServiceStateChanged((VoLteServiceState)msg.obj);
                    case LISTEN_SRVCC_STATE_CHANGED:
                        PhoneStateListener.this.onSrvccStateChanged((int) msg.obj);
                        break;
                    case LISTEN_VOICE_ACTIVATION_STATE:
                        PhoneStateListener.this.onVoiceActivationStateChanged((int)msg.obj);
@@ -605,13 +608,13 @@ public class PhoneStateListener {
    }

    /**
     * Callback invoked when the service state of LTE network
     * related to the VoLTE service has changed.
     * @param stateInfo is the current LTE network information
     * Callback invoked when there has been a change in the Single Radio Voice Call Continuity
     * (SRVCC) state for the currently active call.
     * @hide
     */
    @UnsupportedAppUsage
    public void onVoLteServiceStateChanged(VoLteServiceState stateInfo) {
    @SystemApi
    public void onSrvccStateChanged(@TelephonyManager.SrvccState int srvccState) {

    }

    /**
@@ -795,8 +798,8 @@ public class PhoneStateListener {
            send(LISTEN_DATA_CONNECTION_REAL_TIME_INFO, 0, 0, dcRtInfo);
        }

        public void onVoLteServiceStateChanged(VoLteServiceState lteState) {
            send(LISTEN_VOLTE_STATE, 0, 0, lteState);
        public void onSrvccStateChanged(int state) {
            send(LISTEN_SRVCC_STATE_CHANGED, 0, 0, state);
        }

        public void onVoiceActivationStateChanged(int activationState) {
+51 −0
Original line number Diff line number Diff line
@@ -177,6 +177,57 @@ public class TelephonyManager {
    /** @hide */
    static public final int KEY_TYPE_WLAN = 2;

    /**
     * No Single Radio Voice Call Continuity (SRVCC) handover is active.
     * See TS 23.216 for more information.
     * @hide
     */
    @SystemApi
    public static final int SRVCC_STATE_HANDOVER_NONE  = -1;

    /**
     * Single Radio Voice Call Continuity (SRVCC) handover has been started on the network.
     * See TS 23.216 for more information.
     * @hide
     */
    @SystemApi
    public static final int SRVCC_STATE_HANDOVER_STARTED  = 0;

    /**
     * Ongoing Single Radio Voice Call Continuity (SRVCC) handover has successfully completed.
     * See TS 23.216 for more information.
     * @hide
     */
    @SystemApi
    public static final int SRVCC_STATE_HANDOVER_COMPLETED = 1;

    /**
     * Ongoing Single Radio Voice Call Continuity (SRVCC) handover has failed.
     * See TS 23.216 for more information.
     * @hide
     */
    @SystemApi
    public static final int SRVCC_STATE_HANDOVER_FAILED   = 2;

    /**
     * Ongoing Single Radio Voice Call Continuity (SRVCC) handover has been canceled.
     * See TS 23.216 for more information.
     * @hide
     */
    @SystemApi
    public static final int SRVCC_STATE_HANDOVER_CANCELED  = 3;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"SRVCC_STATE_"},
            value = {
                    SRVCC_STATE_HANDOVER_NONE,
                    SRVCC_STATE_HANDOVER_STARTED,
                    SRVCC_STATE_HANDOVER_COMPLETED,
                    SRVCC_STATE_HANDOVER_FAILED,
                    SRVCC_STATE_HANDOVER_CANCELED})
    public @interface SrvccState {}

    private final Context mContext;
    private final int mSubId;
    @UnsupportedAppUsage
+3 −1
Original line number Diff line number Diff line
@@ -24,9 +24,11 @@ import android.telephony.Rlog;

/**
 * Contains LTE network state related information.
 *
 * @deprecated Only contains SRVCC state, which isn't specific to LTE handovers. For SRVCC
 * indications, use {@link PhoneStateListener#onSrvccStateChanged(int)}.
 * @hide
 */
@Deprecated
public final class VoLteServiceState implements Parcelable {

    private static final String LOG_TAG = "VoLteServiceState";
Loading