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

Commit daa3d5fc authored by Yongnam Cha's avatar Yongnam Cha Committed by Android (Google) Code Review
Browse files

Merge changes from topic "flagCBM" into main

* changes:
  Updating the APIs for the emergency callback mode
  Add feature flag for Emergency Callback Mode Notification
parents 1d442cb6 73ae62a6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -62,3 +62,11 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

# OWNER=yongnamcha TARGET=25Q2
flag {
    name: "emergency_callback_mode_notification"
    namespace: "telephony"
    description: "Used to notify the emergency callback mode for call/SMS to other applications."
    bug:"359064059"
}
+17 −3
Original line number Diff line number Diff line
@@ -303,14 +303,28 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    }

    @Override
    public void notifyCallbackModeStarted(Phone sender, @EmergencyCallbackModeType int type) {
        mTelephonyRegistryMgr.notifyCallBackModeStarted(sender.getPhoneId(),
                sender.getSubId(), type);
    public void notifyCallbackModeStarted(Phone sender, @EmergencyCallbackModeType int type,
            long durationMillis) {
        if (!mFeatureFlags.emergencyCallbackModeNotification()) return;

        mTelephonyRegistryMgr.notifyCallbackModeStarted(sender.getPhoneId(),
                sender.getSubId(), type, durationMillis);
    }

    @Override
    public void notifyCallbackModeRestarted(Phone sender, @EmergencyCallbackModeType int type,
            long durationMillis) {
        if (!mFeatureFlags.emergencyCallbackModeNotification()) return;

        mTelephonyRegistryMgr.notifyCallbackModeRestarted(sender.getPhoneId(),
                sender.getSubId(), type, durationMillis);
    }

    @Override
    public void notifyCallbackModeStopped(Phone sender, @EmergencyCallbackModeType int type,
            @EmergencyCallbackModeStopReason int reason) {
        if (!mFeatureFlags.emergencyCallbackModeNotification()) return;

        mTelephonyRegistryMgr.notifyCallbackModeStopped(sender.getPhoneId(),
                sender.getSubId(), type, reason);
    }
+28 −7
Original line number Diff line number Diff line
@@ -5295,22 +5295,43 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    }

    /**
     * Start callback mode
     * Start the emergency callback mode
     * @param type for callback mode entry.
     * @param durationMillis is the number of milliseconds remaining in the emergency callback
     *                        mode.
     */
    public void startCallbackMode(@TelephonyManager.EmergencyCallbackModeType int type) {
        Rlog.d(mLogTag, "startCallbackMode:type=" + type);
        mNotifier.notifyCallbackModeStarted(this, type);
    public void startEmergencyCallbackMode(@TelephonyManager.EmergencyCallbackModeType int type,
            long durationMillis) {
        if (!mFeatureFlags.emergencyCallbackModeNotification()) return;

        Rlog.d(mLogTag, "startEmergencyCallbackMode:type=" + type);
        mNotifier.notifyCallbackModeStarted(this, type, durationMillis);
    }

    /**
     * Restart the emergency callback mode
     * @param type for callback mode entry.
     * @param durationMillis is the number of milliseconds remaining in the emergency callback
     *                        mode.
     */
    public void restartEmergencyCallbackMode(@TelephonyManager.EmergencyCallbackModeType int type,
            long durationMillis) {
        if (!mFeatureFlags.emergencyCallbackModeNotification()) return;

        Rlog.d(mLogTag, "restartEmergencyCallbackMode:type=" + type);
        mNotifier.notifyCallbackModeRestarted(this, type, durationMillis);
    }

    /**
     * Stop callback mode
     * Stop the emergency callback mode
     * @param type for callback mode exit.
     * @param reason for stopping callback mode.
     */
    public void stopCallbackMode(@TelephonyManager.EmergencyCallbackModeType int type,
    public void stopEmergencyCallbackMode(@TelephonyManager.EmergencyCallbackModeType int type,
            @TelephonyManager.EmergencyCallbackModeStopReason int reason) {
        Rlog.d(mLogTag, "stopCallbackMode:type=" + type + ", reason=" + reason);
        if (!mFeatureFlags.emergencyCallbackModeNotification()) return;

        Rlog.d(mLogTag, "stopEmergencyCallbackMode:type=" + type + ", reason=" + reason);
        mNotifier.notifyCallbackModeStopped(this, type, reason);
    }

+6 −1
Original line number Diff line number Diff line
@@ -145,7 +145,12 @@ public interface PhoneNotifier {
            List<LinkCapacityEstimate> linkCapacityEstimateList);

    /** Notify callback mode started. */
    void notifyCallbackModeStarted(Phone sender, @EmergencyCallbackModeType int type);
    void notifyCallbackModeStarted(Phone sender, @EmergencyCallbackModeType int type,
            long durationMillis);

    /** Notify callback mode restarted. */
    void notifyCallbackModeRestarted(Phone sender, @EmergencyCallbackModeType int type,
            long durationMillis);

    /** Notify callback mode stopped. */
    void notifyCallbackModeStopped(Phone sender, @EmergencyCallbackModeType int type,
+45 −0
Original line number Diff line number Diff line
@@ -376,6 +376,51 @@ public class DefaultPhoneNotifierTest extends TelephonyTest {
                eq(subs));
    }

    @Test
    @SmallTest
    public void testNotifyCallbackModeStarted() {
        doReturn(true).when(mFeatureFlags).emergencyCallbackModeNotification();
        int phoneId = mPhone.getPhoneId();
        int subId = mPhone.getSubId();
        int type = 1;
        long durationMillis = 1000;

        mDefaultPhoneNotifierUT.notifyCallbackModeStarted(mPhone, type, durationMillis);

        verify(mTelephonyRegistryManager).notifyCallbackModeStarted(eq(phoneId), eq(subId),
                eq(type), eq(durationMillis));
    }

    @Test
    @SmallTest
    public void testNotifyCallbackModeRestarted() {
        doReturn(true).when(mFeatureFlags).emergencyCallbackModeNotification();
        int phoneId = mPhone.getPhoneId();
        int subId = mPhone.getSubId();
        int type = 1;
        long durationMillis = 1000;

        mDefaultPhoneNotifierUT.notifyCallbackModeRestarted(mPhone, type, durationMillis);

        verify(mTelephonyRegistryManager).notifyCallbackModeRestarted(eq(phoneId), eq(subId),
                eq(type), eq(durationMillis));
    }

    @Test
    @SmallTest
    public void testNotifyCallbackModeStopped() {
        doReturn(true).when(mFeatureFlags).emergencyCallbackModeNotification();
        int phoneId = mPhone.getPhoneId();
        int subId = mPhone.getSubId();
        int type = 1;
        int reason = 0;

        mDefaultPhoneNotifierUT.notifyCallbackModeStopped(mPhone, type, reason);

        verify(mTelephonyRegistryManager).notifyCallbackModeStopped(eq(phoneId), eq(subId),
                eq(type), eq(reason));
    }

    @Test
    @SmallTest
    public void testCarrierRoamingNtnModeChanged() {
Loading