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

Commit 57dabba1 authored by Daniel Bright's avatar Daniel Bright Committed by Gerrit Code Review
Browse files

Merge "Add Handover Failure Mode to Radio Hal"

parents e597bb85 b911fc4c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ java_library {
        "android.hardware.radio-V1.3-java",
        "android.hardware.radio-V1.4-java",
        "android.hardware.radio-V1.5-java",
        "android.hardware.radio-V1.6-java",
        "voip-common",
        "ims-common",
        "unsupportedappusage",
+73 −3
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager.PrefNetworkMode;
import android.telephony.data.ApnSetting;
import android.telephony.data.DataCallResponse;
import android.telephony.data.DataCallResponse.HandoverFailureMode;
import android.telephony.data.DataProfile;
import android.telephony.data.DataService;
import android.telephony.emergency.EmergencyNumber;
@@ -191,6 +192,9 @@ public class RIL extends BaseCommands implements CommandsInterface {
    /** @hide */
    public static final HalVersion RADIO_HAL_VERSION_1_5 = new HalVersion(1, 5);

    /** @hide */
    public static final HalVersion RADIO_HAL_VERSION_1_6 = new HalVersion(1, 6);

    // IRadio version
    private HalVersion mRadioVersion = RADIO_HAL_VERSION_UNKNOWN;

@@ -487,12 +491,21 @@ public class RIL extends BaseCommands implements CommandsInterface {
                riljLoge("getRadioProxy: mRadioProxy for " + HIDL_SERVICE_NAME[mPhoneId]
                        + " is disabled");
            } else {
                try {
                    mRadioProxy = android.hardware.radio.V1_6.IRadio.getService(
                            HIDL_SERVICE_NAME[mPhoneId], true);
                    mRadioVersion = RADIO_HAL_VERSION_1_6;
                } catch (NoSuchElementException e) {
                }

                if (mRadioProxy == null) {
                    try {
                        mRadioProxy = android.hardware.radio.V1_5.IRadio.getService(
                                HIDL_SERVICE_NAME[mPhoneId], true);
                        mRadioVersion = RADIO_HAL_VERSION_1_5;
                    } catch (NoSuchElementException e) {
                    }
                }

                if (mRadioProxy == null) {
                    try {
@@ -1844,7 +1857,40 @@ public class RIL extends BaseCommands implements CommandsInterface {
            }

            try {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
                if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_6)) {
                    // IRadio V1.6
                    android.hardware.radio.V1_6.IRadio radioProxy16 =
                            (android.hardware.radio.V1_6.IRadio) radioProxy;

                    // Convert to HAL data profile
                    android.hardware.radio.V1_5.DataProfileInfo dpi =
                            convertToHalDataProfile15(dataProfile);

                    ArrayList<android.hardware.radio.V1_5.LinkAddress> addresses15 =
                            new ArrayList<>();
                    if (linkProperties != null) {
                        for (LinkAddress la : linkProperties.getAllLinkAddresses()) {
                            android.hardware.radio.V1_5.LinkAddress linkAddress =
                                    new android.hardware.radio.V1_5.LinkAddress();
                            linkAddress.address = la.getAddress().getHostAddress();
                            linkAddress.properties = la.getFlags();
                            linkAddress.deprecationTime = la.getDeprecationTime();
                            linkAddress.expirationTime = la.getExpirationTime();
                            addresses15.add(linkAddress);
                        }
                    }

                    if (RILJ_LOGD) {
                        riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
                                + ",accessNetworkType="
                                + AccessNetworkType.toString(accessNetworkType) + ",isRoaming="
                                + isRoaming + ",allowRoaming=" + allowRoaming + "," + dataProfile
                                + ",addresses=" + addresses15 + ",dnses=" + dnses);
                    }

                    radioProxy16.setupDataCall_1_6(rr.mSerial, accessNetworkType, dpi, allowRoaming,
                            reason, addresses15, dnses);
                } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
                    // IRadio V1.5
                    android.hardware.radio.V1_5.IRadio radioProxy15 =
                            (android.hardware.radio.V1_5.IRadio) radioProxy;
@@ -6788,6 +6834,9 @@ public class RIL extends BaseCommands implements CommandsInterface {
        String[] gateways = null;
        String[] pcscfs = null;

        @HandoverFailureMode
        int handoverFailureMode = DataCallResponse.HANDOVER_FAILURE_MODE_LEGACY;

        List<LinkAddress> laList = new ArrayList<>();

        if (dcResult instanceof android.hardware.radio.V1_0.SetupDataCallResult) {
@@ -6855,6 +6904,26 @@ public class RIL extends BaseCommands implements CommandsInterface {
            mtu = Math.max(result.mtuV4, result.mtuV6);
            mtuV4 = result.mtuV4;
            mtuV6 = result.mtuV6;
        } else if (dcResult instanceof android.hardware.radio.V1_6.SetupDataCallResult) {
            final android.hardware.radio.V1_6.SetupDataCallResult result =
                    (android.hardware.radio.V1_6.SetupDataCallResult) dcResult;
            cause = result.base.cause;
            suggestedRetryTime = result.base.suggestedRetryTime;
            cid = result.base.cid;
            active = result.base.active;
            protocolType = result.base.type;
            ifname = result.base.ifname;
            laList = result.base.addresses.stream().map(la -> createLinkAddressFromString(
                    la.address, la.properties, la.deprecationTime, la.expirationTime))
                    .collect(Collectors.toList());

            dnses = result.base.dnses.stream().toArray(String[]::new);
            gateways = result.base.gateways.stream().toArray(String[]::new);
            pcscfs = result.base.pcscf.stream().toArray(String[]::new);
            mtu = Math.max(result.base.mtuV4, result.base.mtuV6);
            mtuV4 = result.base.mtuV4;
            mtuV6 = result.base.mtuV6;
            handoverFailureMode = result.handoverFailureMode;
        } else {
            Rlog.e(RILJ_LOG_TAG, "Unsupported SetupDataCallResult " + dcResult);
            return null;
@@ -6919,6 +6988,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                .setMtu(mtu)
                .setMtuV4(mtuV4)
                .setMtuV6(mtuV6)
                .setHandoverFailureMode(handoverFailureMode)
                .build();
    }

+1 −3
Original line number Diff line number Diff line
@@ -2126,9 +2126,7 @@ public class DataConnection extends StateMachine {
                            // failure cause and determine if we need to retry this APN later
                            // or not.
                            mInactiveState.setEnterNotificationParams(cp, result.mFailCause,
                                    // TODO: The actual failure mode should come from the underlying
                                    //  data service
                                    DataCallResponse.HANDOVER_FAILURE_MODE_LEGACY);
                                    dataCallResponse.getHandoverFailureMode());
                            transitionTo(mInactiveState);
                            break;
                        case ERROR_STALE:
+19 −5
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import static android.telephony.TelephonyManager.NETWORK_TYPE_NR;
import static android.telephony.data.ApnSetting.PROTOCOL_IPV4V6;
import static android.telephony.data.ApnSetting.TYPE_DEFAULT;
import static android.telephony.data.ApnSetting.TYPE_IA;
import static android.telephony.data.DataCallResponse.HANDOVER_FAILURE_MODE_DO_FALLBACK;
import static android.telephony.data.DataCallResponse.HANDOVER_FAILURE_MODE_LEGACY;

import static com.android.internal.telephony.RILConstants.DATA_PROFILE_DEFAULT;
import static com.android.internal.telephony.RILConstants.DATA_PROFILE_INVALID;
@@ -2462,13 +2464,25 @@ public class DcTracker extends Handler {
        b.putInt(DATA_COMPLETE_MSG_EXTRA_REQUEST_TYPE, requestType);
        b.putInt(DATA_COMPLETE_MSG_EXTRA_TRANSPORT_TYPE, transport);
        b.putBoolean(DATA_COMPLETE_MSG_EXTRA_HANDOVER_FAILURE_FALLBACK,
                (handoverFailureMode == DataCallResponse.HANDOVER_FAILURE_MODE_DO_FALLBACK
                        || (handoverFailureMode
                        == DataCallResponse.HANDOVER_FAILURE_MODE_LEGACY
                        && cause == DataFailCause.HANDOFF_PREFERENCE_CHANGED)));
                shouldFallbackOnFailedHandover(handoverFailureMode, requestType, cause));
        message.sendToTarget();
    }

    private boolean shouldFallbackOnFailedHandover(@HandoverFailureMode int handoverFailureMode,
                               @RequestNetworkType int requestType,
                               @DataFailureCause int cause) {
        if (requestType != REQUEST_TYPE_HANDOVER) {
            //The fallback is only relevant if the request is a handover
            return false;
        } else if (handoverFailureMode == HANDOVER_FAILURE_MODE_DO_FALLBACK) {
            return true;
        } else if (handoverFailureMode == HANDOVER_FAILURE_MODE_LEGACY) {
            return cause == DataFailCause.HANDOFF_PREFERENCE_CHANGED;
        } else {
            return false;
        }
    }

    public void enableApn(@ApnType int apnType, @RequestNetworkType int requestType,
            Message onCompleteMsg) {
        sendMessage(obtainMessage(DctConstants.EVENT_ENABLE_APN, apnType, requestType,