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

Commit 7ead8b90 authored by Hunsuk Choi's avatar Hunsuk Choi Committed by Cherrypicker Worker
Browse files

Update CallWaitingController, SYNC_IMS_ONLY

Implement the configuration CALL_WAITING_SYNC_IMS_ONLY
Do not synchronize the service state between CS newtwork and IMS service.
If IMS service is registered, the change of user setting shall be handled
at the device without any communication with the network. Otherwise, the device
tries to communicate with the CS network to handle user's request.

Bug: 202463005
Test: atest

Change-Id: Ic8f5433e403ff3cc45e02d29d0aaeda24a1ba348
(cherry picked from commit 6acb43cdd8e993b6f977febacbdccc037737d1ac)
Merged-In: Ic8f5433e403ff3cc45e02d29d0aaeda24a1ba348
parent ff0ee996
Loading
Loading
Loading
Loading
+33 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.telephony;

import static android.telephony.CarrierConfigManager.ImsSs.CALL_WAITING_SYNC_FIRST_CHANGE;
import static android.telephony.CarrierConfigManager.ImsSs.CALL_WAITING_SYNC_FIRST_POWER_UP;
import static android.telephony.CarrierConfigManager.ImsSs.CALL_WAITING_SYNC_IMS_ONLY;
import static android.telephony.CarrierConfigManager.ImsSs.CALL_WAITING_SYNC_NONE;
import static android.telephony.CarrierConfigManager.ImsSs.CALL_WAITING_SYNC_USER_CHANGE;
import static android.telephony.CarrierConfigManager.ImsSs.KEY_TERMINAL_BASED_CALL_WAITING_DEFAULT_ENABLED_BOOL;
@@ -167,9 +168,14 @@ public class CallWaitingController extends Handler {
     * {@link #TERMINAL_BASED_NOT_SUPPORTED},
     * {@link #TERMINAL_BASED_NOT_ACTIVATED}, and
     * {@link #TERMINAL_BASED_ACTIVATED}.
     *
     * @param forCsOnly indicates the caller expects the result for CS calls only
     */
    @VisibleForTesting
    public synchronized int getTerminalBasedCallWaitingState() {
    public synchronized int getTerminalBasedCallWaitingState(boolean forCsOnly) {
        if (forCsOnly && (!mImsRegistered) && mSyncPreference == CALL_WAITING_SYNC_IMS_ONLY) {
            return TERMINAL_BASED_NOT_SUPPORTED;
        }
        if (!mValidSubscription) return TERMINAL_BASED_NOT_SUPPORTED;
        return mCallWaitingState;
    }
@@ -200,10 +206,12 @@ public class CallWaitingController extends Handler {

        if (mSyncPreference == CALL_WAITING_SYNC_NONE
                || mSyncPreference == CALL_WAITING_SYNC_FIRST_CHANGE
                || mSyncPreference == CALL_WAITING_SYNC_FIRST_POWER_UP) {
                || mSyncPreference == CALL_WAITING_SYNC_FIRST_POWER_UP
                || isSyncImsOnly()) {
            sendGetCallWaitingResponse(onComplete);
            return true;
        } else if (mSyncPreference == CALL_WAITING_SYNC_USER_CHANGE) {
        } else if (mSyncPreference == CALL_WAITING_SYNC_USER_CHANGE
                || mSyncPreference == CALL_WAITING_SYNC_IMS_ONLY) {
            Cw cw = new Cw(false, isImsRegistered(), onComplete);
            Message resp = obtainMessage(EVENT_GET_CALL_WAITING_DONE, 0, 0, cw);
            mPhone.mCi.queryCallWaiting(SERVICE_CLASS_NONE, resp);
@@ -246,13 +254,15 @@ public class CallWaitingController extends Handler {

        if (mSyncPreference == CALL_WAITING_SYNC_NONE
                || mSyncPreference == CALL_WAITING_SYNC_FIRST_CHANGE
                || mSyncPreference == CALL_WAITING_SYNC_FIRST_POWER_UP) {
                || mSyncPreference == CALL_WAITING_SYNC_FIRST_POWER_UP
                || isSyncImsOnly()) {
            updateState(
                    enable ? TERMINAL_BASED_ACTIVATED : TERMINAL_BASED_NOT_ACTIVATED);

            sendToTarget(onComplete, null, null);
            return true;
        } else if (mSyncPreference == CALL_WAITING_SYNC_USER_CHANGE) {
        } else if (mSyncPreference == CALL_WAITING_SYNC_USER_CHANGE
                || mSyncPreference == CALL_WAITING_SYNC_IMS_ONLY) {
            Cw cw = new Cw(enable, isImsRegistered(), onComplete);
            Message resp = obtainMessage(EVENT_SET_CALL_WAITING_DONE, 0, 0, cw);
            mPhone.mCi.setCallWaiting(enable, serviceClass, resp);
@@ -302,6 +312,13 @@ public class CallWaitingController extends Handler {

        if (DBG) Rlog.d(LOG_TAG, "onSetCallWaitingDone");
        Cw cw = (Cw) ar.userObj;

        if (mSyncPreference == CALL_WAITING_SYNC_IMS_ONLY) {
            // do not synchronize service state between CS and IMS
            sendToTarget(cw.mOnComplete, ar.result, ar.exception);
            return;
        }

        if (ar.exception == null) {
            if (mSyncPreference == CALL_WAITING_SYNC_FIRST_CHANGE) {
                // SYNC_FIRST_CHANGE implies cw.mEnable is true.
@@ -358,6 +375,13 @@ public class CallWaitingController extends Handler {

        if (DBG) Rlog.d(LOG_TAG, "onGetCallWaitingDone");
        Cw cw = (Cw) ar.userObj;

        if (mSyncPreference == CALL_WAITING_SYNC_IMS_ONLY) {
            // do not synchronize service state between CS and IMS
            sendToTarget(cw.mOnComplete, ar.result, ar.exception);
            return;
        }

        if (ar.exception == null) {
            int[] resp = (int[]) ar.result;
            //resp[0]: 1 if enabled, 0 otherwise
@@ -637,6 +661,10 @@ public class CallWaitingController extends Handler {
        sendEmptyMessage(EVENT_REGISTERED_TO_NETWORK);
    }

    private boolean isSyncImsOnly() {
        return (mSyncPreference == CALL_WAITING_SYNC_IMS_ONLY && mImsRegistered);
    }

    /**
     * Dump this instance into a readable format for dumpsys usage.
     */
+1 −1
Original line number Diff line number Diff line
@@ -1921,7 +1921,7 @@ public class GsmCdmaCallTracker extends CallTracker {
        GsmCdmaConnection newRinging = mConnections[index];
        if (newRinging == null) return false;

        if ((mPhone.getTerminalBasedCallWaitingState()
        if ((mPhone.getTerminalBasedCallWaitingState(true)
                        == CallWaitingController.TERMINAL_BASED_NOT_ACTIVATED)
                && (newRinging.getState() == Call.State.WAITING)) {
            Rlog.d(LOG_TAG, "hangupWaitingCallSilently");
+2 −2
Original line number Diff line number Diff line
@@ -2826,8 +2826,8 @@ public class GsmCdmaPhone extends Phone {
    }

    @Override
    public int getTerminalBasedCallWaitingState() {
        return mCallWaitingController.getTerminalBasedCallWaitingState();
    public int getTerminalBasedCallWaitingState(boolean forCsOnly) {
        return mCallWaitingController.getTerminalBasedCallWaitingState(forCsOnly);
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -4986,8 +4986,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    /**
     * Returns the user's last setting for terminal-based call waiting
     * @param forCsOnly indicates the caller expects the result for CS calls only
     */
    public int getTerminalBasedCallWaitingState() {
    public int getTerminalBasedCallWaitingState(boolean forCsOnly) {
        return CallWaitingController.TERMINAL_BASED_NOT_SUPPORTED;
    }

+2 −2
Original line number Diff line number Diff line
@@ -1186,7 +1186,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
                if (isActivate() || isDeactivate()) {
                    if (serviceClass == SERVICE_CLASS_NONE
                            || (serviceClass & SERVICE_CLASS_VOICE) == SERVICE_CLASS_VOICE) {
                        if (mPhone.getTerminalBasedCallWaitingState()
                        if (mPhone.getTerminalBasedCallWaitingState(true)
                                != CallWaitingController.TERMINAL_BASED_NOT_SUPPORTED) {
                            mPhone.setCallWaiting(isActivate(), serviceClass,
                                    obtainMessage(EVENT_SET_COMPLETE, this));
@@ -1196,7 +1196,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {
                    mPhone.mCi.setCallWaiting(isActivate(), serviceClass,
                            obtainMessage(EVENT_SET_COMPLETE, this));
                } else if (isInterrogate()) {
                    if (mPhone.getTerminalBasedCallWaitingState()
                    if (mPhone.getTerminalBasedCallWaitingState(true)
                            != CallWaitingController.TERMINAL_BASED_NOT_SUPPORTED) {
                        mPhone.getCallWaiting(obtainMessage(EVENT_QUERY_COMPLETE, this));
                    } else {
Loading