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

Commit 2883d9c0 authored by yongnamcha's avatar yongnamcha
Browse files

Updating the APIs for the Callback Mode

This commit updates the APIs for the Callback Mode.
This includes System API updates.

Bug: 260533540
Bug: 359064059
Test: atest CtsTelephonyTestCases:TelephonyCallbackTest,
      atest CtsTelephonyTestCases:TelephonyRegistryManagerTest
Test: atest TelephonyRegistryTest, atest DefaultPhoneNotifierTest
Test: Manual call tests related to emergency and non-emergency calls.
Flag: com.android.internal.telephony.flags.emergency_callback_mode_notification

Change-Id: I2db870b796b5bef9e9ac7d232ee4b960ed27731e
parent 4cc911dd
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -15320,6 +15320,7 @@ package android.telephony {
    field public static final int EVENT_DATA_CONNECTION_STATE_CHANGED = 7; // 0x7
    field @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public static final int EVENT_DATA_ENABLED_CHANGED = 34; // 0x22
    field public static final int EVENT_DISPLAY_INFO_CHANGED = 21; // 0x15
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final int EVENT_EMERGENCY_CALLBACK_MODE_CHANGED = 40; // 0x28
    field @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public static final int EVENT_EMERGENCY_NUMBER_LIST_CHANGED = 25; // 0x19
    field @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public static final int EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED = 28; // 0x1c
    field @RequiresPermission(android.Manifest.permission.READ_CALL_LOG) public static final int EVENT_LEGACY_CALL_STATE_CHANGED = 36; // 0x24
@@ -15357,6 +15358,12 @@ package android.telephony {
    method @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public void onDataEnabledChanged(boolean, int);
  }
  @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static interface TelephonyCallback.EmergencyCallbackModeListener {
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onCallbackModeRestarted(int, @NonNull java.time.Duration, int);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onCallbackModeStarted(int, @NonNull java.time.Duration, int);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onCallbackModeStopped(int, int, int);
  }
  public static interface TelephonyCallback.LinkCapacityEstimateChangedListener {
    method @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public void onLinkCapacityEstimateChanged(@NonNull java.util.List<android.telephony.LinkCapacityEstimate>);
  }
@@ -15618,6 +15625,8 @@ package android.telephony {
    field public static final int CELL_BROADCAST_RESULT_SUCCESS = 0; // 0x0
    field public static final int CELL_BROADCAST_RESULT_UNKNOWN = -1; // 0xffffffff
    field public static final int CELL_BROADCAST_RESULT_UNSUPPORTED = 1; // 0x1
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int EMERGENCY_CALLBACK_MODE_CALL = 1; // 0x1
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int EMERGENCY_CALLBACK_MODE_SMS = 2; // 0x2
    field public static final int ENABLE_NR_DUAL_CONNECTIVITY_INVALID_STATE = 4; // 0x4
    field public static final int ENABLE_NR_DUAL_CONNECTIVITY_NOT_SUPPORTED = 1; // 0x1
    field public static final int ENABLE_NR_DUAL_CONNECTIVITY_RADIO_ERROR = 3; // 0x3
@@ -15675,6 +15684,13 @@ package android.telephony {
    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
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_EMERGENCY_SMS_SENT = 4; // 0x4
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_NORMAL_SMS_SENT = 2; // 0x2
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_OUTGOING_EMERGENCY_CALL_INITIATED = 3; // 0x3
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_OUTGOING_NORMAL_CALL_INITIATED = 1; // 0x1
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_TIMER_EXPIRED = 5; // 0x5
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_UNKNOWN = 0; // 0x0
    field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_USER_ACTION = 6; // 0x6
    field public static final int THERMAL_MITIGATION_RESULT_INVALID_STATE = 3; // 0x3
    field public static final int THERMAL_MITIGATION_RESULT_MODEM_ERROR = 1; // 0x1
    field public static final int THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE = 2; // 0x2
+12 −4
Original line number Diff line number Diff line
@@ -1671,14 +1671,22 @@ public class PhoneStateListener {
        }

        /** @hide */
        public final void onCallBackModeStarted(
                @TelephonyManager.EmergencyCallbackModeType int type) {
        public final void onCallbackModeStarted(
                @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis,
                int subId) {
            // not support. Can't override. Use TelephonyCallback.
        }

        /** @hide */
        public final void onCallBackModeStopped(@EmergencyCallbackModeType int type,
                @EmergencyCallbackModeStopReason int reason) {
        public final void onCallbackModeRestarted(
                @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis,
                int subId) {
            // not support. Can't override. Use TelephonyCallback.
        }

        /** @hide */
        public final void onCallbackModeStopped(@EmergencyCallbackModeType int type,
                @EmergencyCallbackModeStopReason int reason, int subId) {
            // not support. Can't override. Use TelephonyCallback.
        }

+81 −23
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import dalvik.system.VMRuntime;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -619,16 +620,20 @@ public class TelephonyCallback {


    /**
     * Event for changes to the Emergency callback mode
     * Event for changes to the emergency callback mode
     *
     * <p>Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE}
     *
     * @see EmergencyCallbackModeListener#onCallbackModeStarted(int)
     * @see EmergencyCallbackModeListener#onCallbackModeStopped(int, int)
     * @see EmergencyCallbackModeListener#onCallbackModeStarted(int, Duration, int)
     * @see EmergencyCallbackModeListener#onCallbackModeRestarted(int, Duration, int)
     * @see EmergencyCallbackModeListener#onCallbackModeStopped(int, int, int)
     *
     * @hide
     */

    @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
    @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    @SystemApi
    public static final int EVENT_EMERGENCY_CALLBACK_MODE_CHANGED = 40;

    /**
@@ -1671,39 +1676,64 @@ public class TelephonyCallback {
    }

    /**
     * Interface for emergency callback mode listener.
     * Interface for the emergency callback mode listener.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
    @SystemApi
    public interface EmergencyCallbackModeListener {
        /**
         * Indicates that Callback Mode has been started.
         * Indicates that emergency callback mode has been started.
         * <p>
         * This method will be called when an emergency sms/emergency call is sent
         * and the callback mode is supported by the carrier.
         * If an emergency SMS is transmitted during callback mode for SMS, this API will be called
         * once again with TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS.
         * This method will be called when an emergency SMS or emergency call is ended and
         * the emergency callback mode is supported by the carrier.
         * If the emergency callback mode was started for an emergency call and an emergency SMS is
         * transmitted during callback mode for SMS then this API will be called once again with
         * TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS.
         *
         * @param type for callback mode entry
         * @param type for the emergency callback mode entry
         *             See {@link TelephonyManager.EmergencyCallbackModeType}.
         * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_CALL
         * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS
         *
         * @param timerDuration is the time remaining in the emergency callback mode.
         * @param subId The subscription ID used to start the emergency callback mode.
         */
        @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        void onCallBackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type);
        void onCallbackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type,
                @NonNull Duration timerDuration, int subId);

        /**
         * Indicates that Callback Mode has been stopped.
         * Indicates that emergency callback mode has been re-started.
         * <p>
         * This method will be called when the callback mode timer expires or when
         * a normal call/SMS is sent
         * This method will be called when an emergency SMS or emergency call is ended
         * in the emergency callback mode.
         * This is used to restart the emergency callback mode when it is already in progress.
         *
         * @param type for callback mode entry
         * @param type for the emergency callback mode entry
         *             See {@link TelephonyManager.EmergencyCallbackModeType}.
         * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_CALL
         * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS
         *
         * @param reason for changing callback mode
         * @param timerDuration is the time remaining in the emergency callback mode.
         * @param subId The subscription ID used to restart the emergency callback mode.
         */
        @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        void onCallbackModeRestarted(@TelephonyManager.EmergencyCallbackModeType int type,
                @NonNull Duration timerDuration, int subId);

        /**
         * Indicates that emergency callback mode has been stopped.
         * <p>
         * This method will be called when the emergency callback mode timer expires or when
         * a normal call/SMS is sent
         *
         * @param type for the emergency callback mode entry
         * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_CALL
         * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS
         *
         * @param reason for changing emergency callback mode
         * @see TelephonyManager#STOP_REASON_UNKNOWN
         * @see TelephonyManager#STOP_REASON_OUTGOING_NORMAL_CALL_INITIATED
         * @see TelephonyManager#STOP_REASON_NORMAL_SMS_SENT
@@ -1711,10 +1741,12 @@ public class TelephonyCallback {
         * @see TelephonyManager#STOP_REASON_EMERGENCY_SMS_SENT
         * @see TelephonyManager#STOP_REASON_TIMER_EXPIRED
         * @see TelephonyManager#STOP_REASON_USER_ACTION
         *
         * @param subId is the current subscription used the emergency callback mode.
         */
        @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        void onCallBackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
                @TelephonyManager.EmergencyCallbackModeStopReason int reason);
        void onCallbackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
                @TelephonyManager.EmergencyCallbackModeStopReason int reason, int subId);
    }

    /**
@@ -2132,18 +2164,43 @@ public class TelephonyCallback {
                            mediaQualityStatus)));
        }

        public void onCallBackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type) {
        @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        public void onCallbackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type,
                long durationMillis, int subId) {
            if (!Flags.emergencyCallbackModeNotification()) return;

            EmergencyCallbackModeListener listener =
                    (EmergencyCallbackModeListener) mTelephonyCallbackWeakRef.get();
            Log.d(LOG_TAG, "onCallBackModeStarted:type=" + type + ", listener=" + listener);
            if (listener == null) return;

            final Duration timerDuration = Duration.ofMillis(durationMillis);
            Binder.withCleanCallingIdentity(
                    () -> mExecutor.execute(() -> listener.onCallBackModeStarted(type)));
                    () -> mExecutor.execute(() -> listener.onCallbackModeStarted(type,
                            timerDuration, subId)));
        }

        public void onCallBackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
                @TelephonyManager.EmergencyCallbackModeStopReason int reason) {
        @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        public void onCallbackModeRestarted(@TelephonyManager.EmergencyCallbackModeType int type,
                long durationMillis, int subId) {
            if (!Flags.emergencyCallbackModeNotification()) return;

            EmergencyCallbackModeListener listener =
                    (EmergencyCallbackModeListener) mTelephonyCallbackWeakRef.get();
            Log.d(LOG_TAG, "onCallbackModeRestarted:type=" + type + ", listener=" + listener);
            if (listener == null) return;

            final Duration timerDuration = Duration.ofMillis(durationMillis);
            Binder.withCleanCallingIdentity(
                    () -> mExecutor.execute(() -> listener.onCallbackModeRestarted(type,
                            timerDuration, subId)));
        }

        @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        public void onCallbackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
                @TelephonyManager.EmergencyCallbackModeStopReason int reason, int subId) {
            if (!Flags.emergencyCallbackModeNotification()) return;

            EmergencyCallbackModeListener listener =
                    (EmergencyCallbackModeListener) mTelephonyCallbackWeakRef.get();
            Log.d(LOG_TAG, "onCallBackModeStopped:type=" + type
@@ -2151,7 +2208,8 @@ public class TelephonyCallback {
            if (listener == null) return;

            Binder.withCleanCallingIdentity(
                    () -> mExecutor.execute(() -> listener.onCallBackModeStopped(type, reason)));
                    () -> mExecutor.execute(() -> listener.onCallbackModeStopped(type, reason,
                            subId)));
        }

        public void onCarrierRoamingNtnModeChanged(boolean active) {
+27 −5
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ public class TelephonyRegistryManager {
                ICarrierConfigChangeListener>
            mCarrierConfigChangeListenerMap = new ConcurrentHashMap<>();


    /** @hide **/
    public TelephonyRegistryManager(@NonNull Context context) {
        mContext = context;
@@ -1721,13 +1720,36 @@ public class TelephonyRegistryManager {
     * @param subId Sender subscription ID.
     * @param type for callback mode entry.
     *             See {@link TelephonyManager.EmergencyCallbackModeType}.
     * @param durationMillis is the number of milliseconds remaining in the emergency callback
     *                        mode.
     * @hide
     */
    public void notifyCallbackModeStarted(int phoneId, int subId,
            @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis) {
        try {
            Log.d(TAG, "notifyCallbackModeStarted:type=" + type);
            sRegistry.notifyCallbackModeStarted(phoneId, subId, type, durationMillis);
        } catch (RemoteException ex) {
            // system process is dead
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Notify Callback Mode has been restarted.
     * @param phoneId Sender phone ID.
     * @param subId Sender subscription ID.
     * @param type for callback mode entry.
     *             See {@link TelephonyManager.EmergencyCallbackModeType}.
     * @param durationMillis is the number of milliseconds remaining in the emergency callback
     *                        mode.
     * @hide
     */
    public void notifyCallBackModeStarted(int phoneId, int subId,
            @TelephonyManager.EmergencyCallbackModeType int type) {
    public void notifyCallbackModeRestarted(int phoneId, int subId,
            @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis) {
        try {
            Log.d(TAG, "notifyCallBackModeStarted:type=" + type);
            sRegistry.notifyCallbackModeStarted(phoneId, subId, type);
            Log.d(TAG, "notifyCallbackModeRestarted:type=" + type);
            sRegistry.notifyCallbackModeRestarted(phoneId, subId, type, durationMillis);
        } catch (RemoteException ex) {
            // system process is dead
            throw ex.rethrowFromSystemServer();
+3 −2
Original line number Diff line number Diff line
@@ -78,8 +78,9 @@ oneway interface IPhoneStateListener {
    void onAllowedNetworkTypesChanged(in int reason, in long allowedNetworkType);
    void onLinkCapacityEstimateChanged(in List<LinkCapacityEstimate> linkCapacityEstimateList);
    void onMediaQualityStatusChanged(in MediaQualityStatus mediaQualityStatus);
    void onCallBackModeStarted(int type);
    void onCallBackModeStopped(int type, int reason);
    void onCallbackModeStarted(int type, long durationMillis, int subId);
    void onCallbackModeRestarted(int type, long durationMillis, int subId);
    void onCallbackModeStopped(int type, int reason, int subId);
    void onSimultaneousCallingStateChanged(in int[] subIds);
    void onCarrierRoamingNtnModeChanged(in boolean active);
    void onCarrierRoamingNtnEligibleStateChanged(in boolean eligible);
Loading