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

Commit d83bf77b authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Batch Compatibility changes when sub boots and fix VT bug

1) The MmTelFeature#changeEnabledCapabilities supports batching
multiple capabilitiy requests in one command. Modify ImsManager
to batch these changes into one command and send it to the modem.

2) Remove VT capability enablement in the compat layer for older
devices that expect enabling VT+VoLTE = only enable VoLTE.

3) Correct old bug in ImsManager, where we were checking VoLTE
instead of VT enabled.

Test: atest FrameworksTelephonyTests and manual
Bug: 110130897
Change-Id: Ie98e557edf5c223bc104c72f9d870b99d8d6fa38
parent 757882f2
Loading
Loading
Loading
Loading
+71 −48
Original line number Original line Diff line number Diff line
@@ -1401,16 +1401,19 @@ public class ImsManager {
                // Note: currently the order of updates is set to produce different order of
                // Note: currently the order of updates is set to produce different order of
                // changeEnabledCapabilities() function calls from setAdvanced4GMode(). This is done
                // changeEnabledCapabilities() function calls from setAdvanced4GMode(). This is done
                // to differentiate this code path from vendor code perspective.
                // to differentiate this code path from vendor code perspective.
                boolean isImsUsed = updateVolteFeatureValue();
                CapabilityChangeRequest request = new CapabilityChangeRequest();
                isImsUsed |= updateWfcFeatureAndProvisionedValues();
                updateVolteFeatureValue(request);
                isImsUsed |= updateVideoCallFeatureValue();
                updateWfcFeatureAndProvisionedValues(request);
                isImsUsed |= updateRttConfigValue();
                updateVideoCallFeatureValue(request);

                boolean isImsNeededForRtt = updateRttConfigValue();
                // Supplementary services over UT do not require IMS registration. Do not alter IMS
                // Supplementary services over UT do not require IMS registration. Do not alter IMS
                // registration based on UT.
                // registration based on UT.
                updateUtFeatureValue();
                updateUtFeatureValue(request);


                if (isImsUsed || !isTurnOffImsAllowedByPlatform()) {
                // Send the batched request to the modem.
                changeMmTelCapability(request);

                if (isImsNeededForRtt || !isTurnOffImsAllowedByPlatform() || isImsNeeded(request)) {
                    // Turn on IMS if it is used.
                    // Turn on IMS if it is used.
                    // Also, if turning off is not allowed for current carrier,
                    // Also, if turning off is not allowed for current carrier,
                    // we need to turn IMS on because it might be turned off before
                    // we need to turn IMS on because it might be turned off before
@@ -1431,12 +1434,17 @@ public class ImsManager {
        }
        }
    }
    }


    private boolean isImsNeeded(CapabilityChangeRequest r) {
        // IMS is not needed for UT, so only enabled IMS if any other capability is enabled.
        return r.getCapabilitiesToEnable().stream()
                .anyMatch((c) ->
                        (c.getCapability() != MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_UT));
    }

    /**
    /**
     * Update VoLTE config
     * Update VoLTE config
     * @return whether feature is On
     * @throws ImsException
     */
     */
    private boolean updateVolteFeatureValue() throws ImsException {
    private void updateVolteFeatureValue(CapabilityChangeRequest request) {
        boolean available = isVolteEnabledByPlatform();
        boolean available = isVolteEnabledByPlatform();
        boolean enabled = isEnhanced4gLteModeSettingEnabledByUser();
        boolean enabled = isEnhanced4gLteModeSettingEnabledByUser();
        boolean isNonTty = isNonTtyOrTtyOnVolteEnabled();
        boolean isNonTty = isNonTtyOrTtyOnVolteEnabled();
@@ -1446,18 +1454,21 @@ public class ImsManager {
                + ", enabled = " + enabled
                + ", enabled = " + enabled
                + ", nonTTY = " + isNonTty);
                + ", nonTTY = " + isNonTty);


        changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
        if (isFeatureOn) {
                ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn);
            request.addCapabilitiesToEnableForTech(

                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
        return isFeatureOn;
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        } else {
            request.addCapabilitiesToDisableForTech(
                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        }
    }
    }


    /**
    /**
     * Update video call over LTE config
     * Update video call over LTE config
     * @return whether feature is On
     * @throws ImsException
     */
     */
    private boolean updateVideoCallFeatureValue() throws ImsException {
    private void updateVideoCallFeatureValue(CapabilityChangeRequest request) {
        boolean available = isVtEnabledByPlatform();
        boolean available = isVtEnabledByPlatform();
        boolean enabled = isVtEnabledByUser();
        boolean enabled = isVtEnabledByUser();
        boolean isNonTty = isNonTtyOrTtyOnVolteEnabled();
        boolean isNonTty = isNonTtyOrTtyOnVolteEnabled();
@@ -1473,18 +1484,21 @@ public class ImsManager {
                + ", nonTTY = " + isNonTty
                + ", nonTTY = " + isNonTty
                + ", data enabled = " + isDataEnabled);
                + ", data enabled = " + isDataEnabled);


        changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
        if (isFeatureOn) {
                ImsRegistrationImplBase.REGISTRATION_TECH_LTE, isFeatureOn);
            request.addCapabilitiesToEnableForTech(

                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
        return isFeatureOn;
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        } else {
            request.addCapabilitiesToDisableForTech(
                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        }
    }
    }


    /**
    /**
     * Update WFC config
     * Update WFC config
     * @return whether feature is On
     * @throws ImsException
     */
     */
    private boolean updateWfcFeatureAndProvisionedValues() throws ImsException {
    private void updateWfcFeatureAndProvisionedValues(CapabilityChangeRequest request) {
        TelephonyManager tm = new TelephonyManager(mContext, getSubId());
        TelephonyManager tm = new TelephonyManager(mContext, getSubId());
        boolean isNetworkRoaming = tm.isNetworkRoaming();
        boolean isNetworkRoaming = tm.isNetworkRoaming();
        boolean available = isWfcEnabledByPlatform();
        boolean available = isWfcEnabledByPlatform();
@@ -1498,8 +1512,15 @@ public class ImsManager {
                + ", mode = " + mode
                + ", mode = " + mode
                + ", roaming = " + roaming);
                + ", roaming = " + roaming);


        changeMmTelCapability(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
        if (isFeatureOn) {
                ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN, isFeatureOn);
            request.addCapabilitiesToEnableForTech(
                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
                    ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN);
        } else {
            request.addCapabilitiesToDisableForTech(
                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
                    ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN);
        }


        if (!isFeatureOn) {
        if (!isFeatureOn) {
            mode = ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED;
            mode = ImsMmTelManager.WIFI_MODE_CELLULAR_PREFERRED;
@@ -1507,12 +1528,10 @@ public class ImsManager {
        }
        }
        setWfcModeInternal(mode);
        setWfcModeInternal(mode);
        setWfcRoamingSettingInternal(roaming);
        setWfcRoamingSettingInternal(roaming);

        return isFeatureOn;
    }
    }




    private boolean updateUtFeatureValue() throws ImsException {
    private void updateUtFeatureValue(CapabilityChangeRequest request) {
        boolean isCarrierSupported = isSuppServicesOverUtEnabledByPlatform();
        boolean isCarrierSupported = isSuppServicesOverUtEnabledByPlatform();
        boolean requiresProvisioning = getBooleanCarrierConfig(
        boolean requiresProvisioning = getBooleanCarrierConfig(
                CarrierConfigManager.KEY_CARRIER_UT_PROVISIONING_REQUIRED_BOOL);
                CarrierConfigManager.KEY_CARRIER_UT_PROVISIONING_REQUIRED_BOOL);
@@ -1533,7 +1552,6 @@ public class ImsManager {
                Log.e(TAG, "updateUtFeatureValue: couldn't reach telephony! returning provisioned");
                Log.e(TAG, "updateUtFeatureValue: couldn't reach telephony! returning provisioned");
            }
            }
        }
        }
        CapabilityChangeRequest request = new CapabilityChangeRequest();
        boolean isFeatureOn = isCarrierSupported && isProvisioned;
        boolean isFeatureOn = isCarrierSupported && isProvisioned;


        log("updateUtFeatureValue: available = " + isCarrierSupported
        log("updateUtFeatureValue: available = " + isCarrierSupported
@@ -1549,13 +1567,6 @@ public class ImsManager {
                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_UT,
                    MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_UT,
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        }
        }
        try {
            mMmTelFeatureConnection.changeEnabledCapabilities(request, null);
        } catch (RemoteException e) {
            throw new ImsException("updateUtFeatureValue()", e,
                    ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
        }
        return isFeatureOn;
    }
    }


    /**
    /**
@@ -2076,7 +2087,6 @@ public class ImsManager {
            @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
            @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
            @ImsRegistrationImplBase.ImsRegistrationTech int radioTech,
            @ImsRegistrationImplBase.ImsRegistrationTech int radioTech,
            boolean isEnabled) throws ImsException {
            boolean isEnabled) throws ImsException {
        checkAndThrowExceptionIfServiceUnavailable();


        CapabilityChangeRequest request = new CapabilityChangeRequest();
        CapabilityChangeRequest request = new CapabilityChangeRequest();
        if (isEnabled) {
        if (isEnabled) {
@@ -2084,18 +2094,31 @@ public class ImsManager {
        } else {
        } else {
            request.addCapabilitiesToDisableForTech(capability, radioTech);
            request.addCapabilitiesToDisableForTech(capability, radioTech);
        }
        }
        try {
        changeMmTelCapability(request);
            mMmTelFeatureConnection.changeEnabledCapabilities(request, null);
            if (mImsConfigListener != null) {
                mImsConfigListener.onSetFeatureResponse(capability,
                        mMmTelFeatureConnection.getRegistrationTech(),
                        isEnabled ? ProvisioningManager.PROVISIONING_VALUE_ENABLED
                                : ProvisioningManager.PROVISIONING_VALUE_DISABLED, -1);
    }
    }

    public void changeMmTelCapability(CapabilityChangeRequest r) throws ImsException {
        checkAndThrowExceptionIfServiceUnavailable();
        try {
            Log.i(TAG, "changeMmTelCapability: changing capabilities for sub: " + getSubId()
            Log.i(TAG, "changeMmTelCapability: changing capabilities for sub: " + getSubId()
                    + ", request: " + request);
                    + ", request: " + r);
            mMmTelFeatureConnection.changeEnabledCapabilities(r, null);
            if (mImsConfigListener == null) {
                return;
            }
            for (CapabilityChangeRequest.CapabilityPair enabledCaps : r.getCapabilitiesToEnable()) {
                mImsConfigListener.onSetFeatureResponse(enabledCaps.getCapability(),
                        enabledCaps.getRadioTech(),
                        ProvisioningManager.PROVISIONING_VALUE_ENABLED, -1);
            }
            for (CapabilityChangeRequest.CapabilityPair disabledCaps :
                    r.getCapabilitiesToDisable()) {
                mImsConfigListener.onSetFeatureResponse(disabledCaps.getCapability(),
                        disabledCaps.getRadioTech(),
                        ProvisioningManager.PROVISIONING_VALUE_DISABLED, -1);
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw new ImsException("changeMmTelCapability()", e,
            throw new ImsException("changeMmTelCapability(CCR)", e,
                    ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
                    ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
        }
        }
    }
    }
@@ -2408,7 +2431,7 @@ public class ImsManager {
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
                    ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
        }
        }


        if (isVolteEnabledByPlatform()) {
        if (isVtEnabledByPlatform()) {
            boolean ignoreDataEnabledChanged = getBooleanCarrierConfig(
            boolean ignoreDataEnabledChanged = getBooleanCarrierConfig(
                    CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS);
                    CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS);
            boolean enableViLte = turnOn && isVtEnabledByUser() &&
            boolean enableViLte = turnOn && isVtEnabledByUser() &&