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

Commit b91f7a2f authored by Hunsuk Choi's avatar Hunsuk Choi
Browse files

Interworking between CallWaitingController and SsDomainController

If vendor Ims service handles the terminal based call waiting service
by itself, we should forward the request to Ims service as legacy
implementation when Ut is available. And SS_ROUTING_OVER_UT is replaced
with getSsRoutingOverUt() to check isUtEnabled().

Bug: 202463005
Bug: 202463163
Test: atest
Change-Id: I2d49916da09c733f949807577ac1dc55947cc31d
(cherry picked from commit 344d04ba6b5f529aa2405557a41b2184a2932c45)
Merged-In: I2d49916da09c733f949807577ac1dc55947cc31d
parent de4910df
Loading
Loading
Loading
Loading
+41 −0
Original line number Original line Diff line number Diff line
@@ -2376,6 +2376,24 @@ public class GsmCdmaPhone extends Phone {
        return false;
        return false;
    }
    }


    /**
     * Checks the availability of Ut directly without SsDomainController.
     * This is only applicable for the case that the terminal-based call waiting service
     * is handled by the IMS service alone without interworking with CallWaitingController.
     */
    private boolean useCallWaitingOverUt(Message onComplete) {
        Phone imsPhone = mImsPhone;
        if (imsPhone == null) {
            logd("useCallWaitingOverUt: called for GsmCdma");
            return false;
        }

        boolean isUtEnabled = imsPhone.isUtEnabled();
        Rlog.d(LOG_TAG, "useCallWaitingOverUt isUtEnabled= " + isUtEnabled
                + " isCsRetry(onComplete))= " + isCsRetry(onComplete));
        return isUtEnabled && !isCsRetry(onComplete);
    }

    /**
    /**
     * Returns whether CSFB is supported for supplementary services.
     * Returns whether CSFB is supported for supplementary services.
     */
     */
@@ -2383,6 +2401,14 @@ public class GsmCdmaPhone extends Phone {
        return mSsDomainController.supportCsfb();
        return mSsDomainController.supportCsfb();
    }
    }


    /**
     * Returns whether the carrier supports the terminal-based call waiting service
     * and Ims service handles it by itself.
     */
    private boolean getOemHandlesTerminalBasedCallWaiting() {
        return mSsDomainController.getOemHandlesTerminalBasedCallWaiting();
    }

    /**
    /**
     * Sends response indicating no nework is available for supplementary services.
     * Sends response indicating no nework is available for supplementary services.
     */
     */
@@ -2742,6 +2768,13 @@ public class GsmCdmaPhone extends Phone {
                responseInvalidState(onComplete);
                responseInvalidState(onComplete);
                return;
                return;
            }
            }
        } else if (getOemHandlesTerminalBasedCallWaiting()) {
            // Ims service handles the terminal-based call waiting service by itself.
            // Use legacy implementation. Forward the request to Ims service if Ut is available.
            if (useCallWaitingOverUt(onComplete)) {
                imsPhone.getCallWaiting(onComplete);
                return;
            }
        }
        }


        if (isPhoneTypeGsm()) {
        if (isPhoneTypeGsm()) {
@@ -2800,6 +2833,13 @@ public class GsmCdmaPhone extends Phone {
                responseInvalidState(onComplete);
                responseInvalidState(onComplete);
                return;
                return;
            }
            }
        } else if (getOemHandlesTerminalBasedCallWaiting()) {
            // Ims service handles the terminal-based call waiting service by itself.
            // Use legacy implementation. Forward the request to Ims service if Ut is available.
            if (useCallWaitingOverUt(onComplete)) {
                imsPhone.setCallWaiting(enable, onComplete);
                return;
            }
        }
        }


        if (isPhoneTypeGsm()) {
        if (isPhoneTypeGsm()) {
@@ -2840,6 +2880,7 @@ public class GsmCdmaPhone extends Phone {
    @Override
    @Override
    public void setTerminalBasedCallWaitingSupported(boolean supported) {
    public void setTerminalBasedCallWaitingSupported(boolean supported) {
        mCallWaitingController.setTerminalBasedCallWaitingSupported(supported);
        mCallWaitingController.setTerminalBasedCallWaitingSupported(supported);
        mSsDomainController.setOemHandlesTerminalBasedCallWaiting(!supported);
    }
    }


    @Override
    @Override
+60 −9
Original line number Original line Diff line number Diff line
@@ -127,10 +127,6 @@ public class SsDomainController {
    public static final String SS_COLP = "COLP";
    public static final String SS_COLP = "COLP";
    public static final String SS_COLR = "COLR";
    public static final String SS_COLR = "COLR";


    // Common instance indicating that Ut is available.
    public static final SuppServiceRoutingInfo SS_ROUTING_OVER_UT =
            new SuppServiceRoutingInfo(true, true, true);

    // Barring list of incoming numbers
    // Barring list of incoming numbers
    public static final String CB_FACILITY_BIL = "BIL";
    public static final String CB_FACILITY_BIL = "BIL";
    // Barring of all anonymous incoming number
    // Barring of all anonymous incoming number
@@ -174,6 +170,9 @@ public class SsDomainController {
    private Set<Integer> mUtAvailableRats = new HashSet<>();
    private Set<Integer> mUtAvailableRats = new HashSet<>();
    private boolean mWiFiAvailable = false;
    private boolean mWiFiAvailable = false;
    private boolean mIsMonitoringConnectivity = false;
    private boolean mIsMonitoringConnectivity = false;
    /** true if Ims service handles the terminal-based call waiting service by itself. */
    private boolean mOemHandlesTerminalBasedCallWaiting = false;
    private boolean mSupportsTerminalBasedCallWaiting = false;


    public SsDomainController(GsmCdmaPhone phone) {
    public SsDomainController(GsmCdmaPhone phone) {
        mPhone = phone;
        mPhone = phone;
@@ -204,13 +203,16 @@ public class SsDomainController {
        int[] utRats = b.getIntArray(
        int[] utRats = b.getIntArray(
                CarrierConfigManager.ImsSs.KEY_XCAP_OVER_UT_SUPPORTED_RATS_INT_ARRAY);
                CarrierConfigManager.ImsSs.KEY_XCAP_OVER_UT_SUPPORTED_RATS_INT_ARRAY);


        int[] tbServices = b.getIntArray(
                CarrierConfigManager.ImsSs.KEY_UT_TERMINAL_BASED_SERVICES_INT_ARRAY);

        updateSsOverUtConfig(supportsUt, supportsCsfb, requiresImsRegistration,
        updateSsOverUtConfig(supportsUt, supportsCsfb, requiresImsRegistration,
                availableWhenPsDataOff, availableWhenRoaming, services, utRats);
                availableWhenPsDataOff, availableWhenRoaming, services, utRats, tbServices);
    }
    }


    private void updateSsOverUtConfig(boolean supportsUt, boolean supportsCsfb,
    private void updateSsOverUtConfig(boolean supportsUt, boolean supportsCsfb,
            boolean requiresImsRegistration, boolean availableWhenPsDataOff,
            boolean requiresImsRegistration, boolean availableWhenPsDataOff,
            boolean availableWhenRoaming, int[] services, int[] utRats) {
            boolean availableWhenRoaming, int[] services, int[] utRats, int[] tbServices) {


        mUtSupported = supportsUt;
        mUtSupported = supportsUt;
        mCsfbSupported = supportsCsfb;
        mCsfbSupported = supportsCsfb;
@@ -218,6 +220,18 @@ public class SsDomainController {
        mUtAvailableWhenPsDataOff = availableWhenPsDataOff;
        mUtAvailableWhenPsDataOff = availableWhenPsDataOff;
        mUtAvailableWhenRoaming = availableWhenRoaming;
        mUtAvailableWhenRoaming = availableWhenRoaming;


        mSupportsTerminalBasedCallWaiting = false;
        if (tbServices != null) {
            for (int tbService : tbServices) {
                if (tbService == SUPPLEMENTARY_SERVICE_CW) {
                    mSupportsTerminalBasedCallWaiting = true;
                    break;
                }
            }
        }
        Rlog.i(LOG_TAG, "updateSsOverUtConfig terminal-based cw "
                + mSupportsTerminalBasedCallWaiting);

        mCbOverUtSupported.clear();
        mCbOverUtSupported.clear();
        mCfOverUtSupported.clear();
        mCfOverUtSupported.clear();
        mSsOverUtSupported.clear();
        mSsOverUtSupported.clear();
@@ -521,9 +535,24 @@ public class SsDomainController {
     * Only for ImsPhoneMmiCode.
     * Only for ImsPhoneMmiCode.
     */
     */
    public SuppServiceRoutingInfo getSuppServiceRoutingInfoForSs(String service) {
    public SuppServiceRoutingInfo getSuppServiceRoutingInfoForSs(String service) {
        if (SS_CW.equals(service) && getOemHandlesTerminalBasedCallWaiting()) {
            // Ims service handles the terminal based call waiting service by itself.
            // Use legacy implementation. Forward the request to Ims service if Ut is available.
            Phone imsPhone = mPhone.getImsPhone();
            boolean isUtEnabled = (imsPhone != null) && imsPhone.isUtEnabled();
            return new SuppServiceRoutingInfo(true, isUtEnabled, true);
        }
        return new SuppServiceRoutingInfo(useSsOverUt(service), isUtEnabled(), supportCsfb());
        return new SuppServiceRoutingInfo(useSsOverUt(service), isUtEnabled(), supportCsfb());
    }
    }


    /**
     * Returns SuppServiceRoutingInfo instance for a service will be served by Ut interface.
     * Only for ImsPhoneMmiCode.
     */
    public SuppServiceRoutingInfo getSsRoutingOverUt() {
        return new SuppServiceRoutingInfo(true, isUtEnabled(), true);
    }

    /**
    /**
     * Set the carrier configuration for test.
     * Set the carrier configuration for test.
     * Test purpose only.
     * Test purpose only.
@@ -531,17 +560,37 @@ public class SsDomainController {
    @VisibleForTesting
    @VisibleForTesting
    public void updateCarrierConfigForTest(boolean supportsUt, boolean supportsCsfb,
    public void updateCarrierConfigForTest(boolean supportsUt, boolean supportsCsfb,
            boolean requiresImsRegistration, boolean availableWhenPsDataOff,
            boolean requiresImsRegistration, boolean availableWhenPsDataOff,
            boolean availableWhenRoaming, int[] services, int[] utRats) {
            boolean availableWhenRoaming, int[] services, int[] utRats, int[] tbServices) {
        Rlog.i(LOG_TAG, "updateCarrierConfigForTest supportsUt=" + supportsUt
        Rlog.i(LOG_TAG, "updateCarrierConfigForTest supportsUt=" + supportsUt
                +  ", csfb=" + supportsCsfb
                +  ", csfb=" + supportsCsfb
                + ", reg=" + requiresImsRegistration
                + ", reg=" + requiresImsRegistration
                + ", whenPsDataOff=" + availableWhenPsDataOff
                + ", whenPsDataOff=" + availableWhenPsDataOff
                + ", whenRoaming=" + availableWhenRoaming
                + ", whenRoaming=" + availableWhenRoaming
                + ", services=" + Arrays.toString(services)
                + ", services=" + Arrays.toString(services)
                + ", rats=" + Arrays.toString(utRats));
                + ", rats=" + Arrays.toString(utRats)
                + ", tbServices=" + Arrays.toString(tbServices));


        updateSsOverUtConfig(supportsUt, supportsCsfb, requiresImsRegistration,
        updateSsOverUtConfig(supportsUt, supportsCsfb, requiresImsRegistration,
                availableWhenPsDataOff, availableWhenRoaming, services, utRats);
                availableWhenPsDataOff, availableWhenRoaming, services, utRats, tbServices);
    }

    /**
     * @param state true if Ims service handles the terminal-based call waiting service by itself.
     *              Otherwise, false.
     */
    public void setOemHandlesTerminalBasedCallWaiting(boolean state) {
        Rlog.i(LOG_TAG, "setOemHandlesTerminalBasedCallWaiting " + state);
        mOemHandlesTerminalBasedCallWaiting = state;
    }

    /**
     * Returns whether the carrier supports the terminal-based call waiting service
     * and Ims service handles it by itself.
     */
    public boolean getOemHandlesTerminalBasedCallWaiting() {
        Rlog.i(LOG_TAG, "getOemHandlesTerminalBasedCallWaiting "
                + mSupportsTerminalBasedCallWaiting + ", " + mOemHandlesTerminalBasedCallWaiting);
        return mSupportsTerminalBasedCallWaiting && mOemHandlesTerminalBasedCallWaiting;
    }
    }


    /**
    /**
@@ -561,6 +610,8 @@ public class SsDomainController {
        pw.println(" mUtAvailableWhenRoaming=" + mUtAvailableWhenRoaming);
        pw.println(" mUtAvailableWhenRoaming=" + mUtAvailableWhenRoaming);
        pw.println(" mUtAvailableRats=" + mUtAvailableRats);
        pw.println(" mUtAvailableRats=" + mUtAvailableRats);
        pw.println(" mWiFiAvailable=" + mWiFiAvailable);
        pw.println(" mWiFiAvailable=" + mWiFiAvailable);
        pw.println(" mOemHandlesTerminalBasedCallWaiting=" + mOemHandlesTerminalBasedCallWaiting);
        pw.println(" mSupportsTerminalBasedCallWaiting=" + mSupportsTerminalBasedCallWaiting);
        pw.decreaseIndent();
        pw.decreaseIndent();
    }
    }
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -542,7 +542,7 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
                return controller.getSuppServiceRoutingInfoForCb(scToBarringFacility(sc));
                return controller.getSuppServiceRoutingInfoForCb(scToBarringFacility(sc));
            } else if (sc != null && sc.equals(SC_CFUT)) {
            } else if (sc != null && sc.equals(SC_CFUT)) {
                // for backward compatibility, not specified by CarrierConfig
                // for backward compatibility, not specified by CarrierConfig
                return SsDomainController.SS_ROUTING_OVER_UT;
                return controller.getSsRoutingOverUt();
            } else if (sc != null && sc.equals(SC_CLIP)) {
            } else if (sc != null && sc.equals(SC_CLIP)) {
                return controller.getSuppServiceRoutingInfoForSs(SS_CLIP);
                return controller.getSuppServiceRoutingInfoForSs(SS_CLIP);
            } else if (sc != null && sc.equals(SC_CLIR)) {
            } else if (sc != null && sc.equals(SC_CLIR)) {
@@ -553,7 +553,7 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
                return controller.getSuppServiceRoutingInfoForSs(SS_COLR);
                return controller.getSuppServiceRoutingInfoForSs(SS_COLR);
            } else if (sc != null && sc.equals(SC_CNAP)) {
            } else if (sc != null && sc.equals(SC_CNAP)) {
                // for backward compatibility, not specified by CarrierConfig
                // for backward compatibility, not specified by CarrierConfig
                return SsDomainController.SS_ROUTING_OVER_UT;
                return controller.getSsRoutingOverUt();
            } else if (sc != null && sc.equals(SC_BS_MT)) {
            } else if (sc != null && sc.equals(SC_BS_MT)) {
                return controller.getSuppServiceRoutingInfoForCb(
                return controller.getSuppServiceRoutingInfoForCb(
                        SsDomainController.CB_FACILITY_BIL);
                        SsDomainController.CB_FACILITY_BIL);
@@ -562,12 +562,12 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
                        SsDomainController.CB_FACILITY_ACR);
                        SsDomainController.CB_FACILITY_ACR);
            } else if (sc != null && sc.equals(SC_PWD)) {
            } else if (sc != null && sc.equals(SC_PWD)) {
                // for backward compatibility, not specified by CarrierConfig
                // for backward compatibility, not specified by CarrierConfig
                return SsDomainController.SS_ROUTING_OVER_UT;
                return controller.getSsRoutingOverUt();
            } else if (sc != null && sc.equals(SC_WAIT)) {
            } else if (sc != null && sc.equals(SC_WAIT)) {
                return controller.getSuppServiceRoutingInfoForSs(SS_CW);
                return controller.getSuppServiceRoutingInfoForSs(SS_CW);
            } else if (isPinPukCommand(sc)) {
            } else if (isPinPukCommand(sc)) {
                // for backward compatibility, not specified by CarrierConfig
                // for backward compatibility, not specified by CarrierConfig
                return SsDomainController.SS_ROUTING_OVER_UT;
                return controller.getSsRoutingOverUt();
            }
            }
        }
        }
        return null;
        return null;
+28 −0
Original line number Original line Diff line number Diff line
@@ -2178,4 +2178,32 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        mPhoneUT.setCallWaiting(false, CommandsInterface.SERVICE_CLASS_VOICE, null);
        mPhoneUT.setCallWaiting(false, CommandsInterface.SERVICE_CLASS_VOICE, null);
        verify(mImsPhone, times(1)).setCallWaiting(eq(false), any());
        verify(mImsPhone, times(1)).setCallWaiting(eq(false), any());
    }
    }

    @Test
    @SmallTest
    public void testOemHandlesTerminalBasedCallWaiting() throws Exception {
        doReturn(true).when(mImsPhone).isUtEnabled();
        replaceInstance(Phone.class, "mImsPhone", mPhoneUT, mImsPhone);

        // Ut is disabled in config
        doReturn(false).when(mSsDomainController).useSsOverUt(anyString());
        doReturn(false).when(mSsDomainController).getOemHandlesTerminalBasedCallWaiting();

        replaceInstance(GsmCdmaPhone.class, "mSsDomainController", mPhoneUT, mSsDomainController);

        mPhoneUT.getCallWaiting(null);
        verify(mImsPhone, times(0)).getCallWaiting(any());

        mPhoneUT.setCallWaiting(false, CommandsInterface.SERVICE_CLASS_VOICE, null);
        verify(mImsPhone, times(0)).setCallWaiting(eq(false), any());

        // OEM handles the terminal-based call waiting service by itself.
        doReturn(true).when(mSsDomainController).getOemHandlesTerminalBasedCallWaiting();

        mPhoneUT.getCallWaiting(null);
        verify(mImsPhone, times(1)).getCallWaiting(any());

        mPhoneUT.setCallWaiting(false, CommandsInterface.SERVICE_CLASS_VOICE, null);
        verify(mImsPhone, times(1)).setCallWaiting(eq(false), any());
    }
}
}
+25 −2
Original line number Original line Diff line number Diff line
@@ -430,6 +430,29 @@ public class SsDomainControllerTest extends TelephonyTest {
        assertFalse(mSdc.isUtEnabled());
        assertFalse(mSdc.isUtEnabled());
    }
    }


    @Test
    @SmallTest
    public void testOemHandlesTerminalBasedCallWaiting() {
        setUtEnabled();

        // Enable terminal-based call waiting
        mSdc.updateCarrierConfigForTest(true, true, false, true, true,
                new int[] {}, UT_OVER_ALL, new int[] { SUPPLEMENTARY_SERVICE_CW });
        String sc = mServices.get(SS_CW);

        mSdc.setOemHandlesTerminalBasedCallWaiting(false);
        SsDomainController.SuppServiceRoutingInfo ssCode =
                ImsPhoneMmiCode.getSuppServiceRoutingInfo("*#" + sc + "#", mSdc);
        assertNotNull(ssCode);
        assertFalse(ssCode.useSsOverUt());

        mSdc.setOemHandlesTerminalBasedCallWaiting(true);
        ssCode = ImsPhoneMmiCode.getSuppServiceRoutingInfo("*#" + sc + "#", mSdc);

        assertNotNull(ssCode);
        assertTrue(ssCode.useSsOverUt());
    }

    private void setUtEnabled() {
    private void setUtEnabled() {
        doReturn(0).when(mImsPhone).getSubId();
        doReturn(0).when(mImsPhone).getSubId();
        mSdc.updateWifiForUt(false);
        mSdc.updateWifiForUt(false);
@@ -466,10 +489,10 @@ public class SsDomainControllerTest extends TelephonyTest {
    private void updateCarrierConfig(boolean supportsCsfb, boolean requiresImsRegistration,
    private void updateCarrierConfig(boolean supportsCsfb, boolean requiresImsRegistration,
            boolean availableWhenPsDataOff, boolean availableWhenRoaming, int[] utRats) {
            boolean availableWhenPsDataOff, boolean availableWhenRoaming, int[] utRats) {
        mSdc.updateCarrierConfigForTest(true, supportsCsfb, requiresImsRegistration,
        mSdc.updateCarrierConfigForTest(true, supportsCsfb, requiresImsRegistration,
                availableWhenPsDataOff, availableWhenRoaming, null, utRats);
                availableWhenPsDataOff, availableWhenRoaming, null, utRats, null);
    }
    }


    private void updateCarrierConfig(int[] services) {
    private void updateCarrierConfig(int[] services) {
        mSdc.updateCarrierConfigForTest(true, true, false, true, true, services, UT_OVER_ALL);
        mSdc.updateCarrierConfigForTest(true, true, false, true, true, services, UT_OVER_ALL, null);
    }
    }
}
}