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

Commit 7e286ec2 authored by donaldahn's avatar donaldahn
Browse files

[Telephony] support TTY Call on VoWifi

Bug: b/202966224
Test: TMUS-TTY Call on wifi with O6(oriole) device in Kansas
Test: Volte/WFC dial and disconnect basic test
Test: ATest ImsManagerTest testTtyStats
Change-Id: If165cd18d9ed9ae75f7c8a3732948cc9f3df45fd
parent 37f7d396
Loading
Loading
Loading
Loading
+36 −6
Original line number Diff line number Diff line
@@ -698,6 +698,28 @@ public class ImsManager implements FeatureUpdates {
        return getBooleanCarrierConfig(CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL);
    }

    /**
     * @return true if we are either not on TTY or TTY over VoWiFi is enabled. If we
     * are on TTY and TTY over VoWiFi is not allowed, this method will return false.
     */
    public boolean isNonTtyOrTtyOnVoWifiEnabled() {

        if (isTtyOnVoWifiCapable()) {
            return true;
        }

        TelecomManager tm = mContext.getSystemService(TelecomManager.class);
        if (tm == null) {
            logw("isNonTtyOrTtyOnVoWifiEnabled: telecom not available");
            return true;
        }
        return tm.getCurrentTtyMode() == TelecomManager.TTY_MODE_OFF;
    }

    public boolean isTtyOnVoWifiCapable() {
        return getBooleanCarrierConfig(CarrierConfigManager.KEY_CARRIER_VOWIFI_TTY_SUPPORTED_BOOL);
    }

    /**
     * Returns a platform configuration for VoLTE which may override the user setting.
     * @deprecated Does not support MSIM devices. Please use
@@ -1149,8 +1171,9 @@ public class ImsManager implements FeatureUpdates {

        try {
            if (enabled) {
                boolean isNonTtyWifi = isNonTtyOrTtyOnVoWifiEnabled();
                CapabilityChangeRequest request = new CapabilityChangeRequest();
                updateVoiceWifiFeatureAndProvisionedValues(request);
                updateVoiceWifiFeatureAndProvisionedValues(request, isNonTtyWifi);
                changeMmTelCapability(request);
                // Ensure IMS is on if this setting is updated.
                turnOnIms();
@@ -1693,8 +1716,9 @@ public class ImsManager implements FeatureUpdates {
        logi("reevaluateCapabilities");
        CapabilityChangeRequest request = new CapabilityChangeRequest();
        boolean isNonTty = isNonTtyOrTtyOnVolteEnabled();
        boolean isNonTtyWifi = isNonTtyOrTtyOnVoWifiEnabled();
        updateVoiceCellFeatureValue(request, isNonTty);
        updateVoiceWifiFeatureAndProvisionedValues(request);
        updateVoiceWifiFeatureAndProvisionedValues(request, isNonTtyWifi);
        updateCrossSimFeatureAndProvisionedValues(request);
        updateVideoCallFeatureValue(request, isNonTty);
        updateCallComposerFeatureValue(request);
@@ -1832,7 +1856,8 @@ public class ImsManager implements FeatureUpdates {
    /**
     * Update WFC config
     */
    private void updateVoiceWifiFeatureAndProvisionedValues(CapabilityChangeRequest request) {
    private void updateVoiceWifiFeatureAndProvisionedValues(CapabilityChangeRequest request,
     boolean isNonTty) {
        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
        boolean isNetworkRoaming =  false;
        if (tm == null) {
@@ -1855,9 +1880,10 @@ public class ImsManager implements FeatureUpdates {
                + ", mode = " + mode
                + ", provisioned = " + isProvisioned
                + ", roaming = " + roaming
                + ", isFeatureOn = " + isFeatureOn);
                + ", isFeatureOn = " + isFeatureOn
                + ", isNonTtyWifi = " + isNonTty);

        if (isFeatureOn) {
        if (isFeatureOn && isNonTty) {
            request.addCapabilitiesToEnableForTech(
                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
                    ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN);
@@ -2642,10 +2668,14 @@ public class ImsManager implements FeatureUpdates {
    public void setTtyMode(int ttyMode) throws ImsException {
        boolean isNonTtyOrTtyOnVolteEnabled = isTtyOnVoLteCapable() ||
                (ttyMode == TelecomManager.TTY_MODE_OFF);
        logi("setTtyMode: isNonTtyOrTtyOnVolteEnabled=" + isNonTtyOrTtyOnVolteEnabled);

        boolean isNonTtyOrTtyOnWifiEnabled = isTtyOnVoWifiCapable() ||
                (ttyMode == TelecomManager.TTY_MODE_OFF);

        CapabilityChangeRequest request = new CapabilityChangeRequest();
        updateVoiceCellFeatureValue(request, isNonTtyOrTtyOnVolteEnabled);
        updateVideoCallFeatureValue(request, isNonTtyOrTtyOnVolteEnabled);
        updateVoiceWifiFeatureAndProvisionedValues(request, isNonTtyOrTtyOnWifiEnabled);
        // update MMTEL caps for the new configuration.
        changeMmTelCapability(request);
        if (isImsNeeded(request)) {
+33 −0
Original line number Diff line number Diff line
@@ -235,6 +235,39 @@ public class ImsManagerTest extends ImsTestBase {
        args.recycle();
    }

    @SmallTest
    @Test
    public void testTtyStats() {
        setWfcEnabledByUser(true);
        SomeArgs args = SomeArgs.obtain();
        ImsManager.setImsStatsCallback(mPhoneId, new ImsManager.ImsStatsCallback() {
            @Override
            public void onEnabledMmTelCapabilitiesChanged(int capability, int regTech,
                    boolean isEnabled) {
                            if ((capability == MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE)
                            && (regTech == ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN)) {
                                    args.arg1 = isEnabled;
                            }
            }
        });
        //TTY over VoWIFI is not allowed
        mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_VOWIFI_TTY_SUPPORTED_BOOL, false);
        ImsManager imsManager = getImsManagerAndInitProvisionedValues();
        // Assert that the IMS stats callback is called properly when a tty setup changes.
        try {
                imsManager.setTtyMode(1);
        } catch (ImsException e) {}
        assertEquals(args.arg1, false);

        //TTY over VoWIFI is allowed
        mBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_VOWIFI_TTY_SUPPORTED_BOOL, true);
        try {
                imsManager.setTtyMode(1);
        } catch (ImsException e) {}
        assertEquals(args.arg1, true);
        args.recycle();
}

    @Test @SmallTest
    public void testSetValues() {
        setWfcEnabledByUser(true);