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

Commit 7640ee45 authored by Malcolm Chen's avatar Malcolm Chen
Browse files

Connect IRadioConfig 1.1 HAL interfaces with RadioConfig.java

IRadioConfig 1.1 getPhoneCapability and setPreferredDataModem
are defined. Here we hook the calls into RadioConfig.

Bug: 121354686
Test: sanity
Change-Id: I02472803eb0f0b07b884fe657a71296052ad25a2
parent 2f2d21c0
Loading
Loading
Loading
Loading
+48 −3
Original line number Diff line number Diff line
@@ -18,9 +18,11 @@ package com.android.internal.telephony;

import static com.android.internal.telephony.RILConstants.RADIO_NOT_AVAILABLE;
import static com.android.internal.telephony.RILConstants.REQUEST_NOT_SUPPORTED;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_PHONE_CAPABILITY;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SLOT_STATUS;
import static com.android.internal.telephony.RILConstants
        .RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING;
import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_PREFERRED_DATA_MODEM;

import android.content.Context;
import android.hardware.radio.V1_0.RadioResponseInfo;
@@ -268,8 +270,50 @@ public class RadioConfig extends Handler {
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
            }
            return;
        }

        RILRequest rr = obtainRequest(RIL_REQUEST_SET_PREFERRED_DATA_MODEM,
                result, mDefaultWorkSource);

        if (DBG) {
            logd(rr.serialString() + "> " + requestToString(rr.mRequest));
        }

        try {
            ((android.hardware.radio.config.V1_1.IRadioConfig) mRadioConfigProxy)
                    .setPreferredDataModem(rr.mSerial, (byte) modemId);
        } catch (RemoteException | RuntimeException e) {
            resetProxyAndRequestList("setPreferredDataModem", e);
        }
    }

    /**
     * Wrapper function for IRadioConfig.getPhoneCapability().
     */
    public void getPhoneCapability(Message result) {
        IRadioConfig radioConfigProxy = getRadioConfigProxy(result);
        if (radioConfigProxy == null || mRadioConfigVersion.less(RADIO_CONFIG_HAL_VERSION_1_1)) {
            if (result != null) {
                AsyncResult.forMessage(result, null,
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
            }
            return;
        }

        RILRequest rr = obtainRequest(RIL_REQUEST_GET_PHONE_CAPABILITY, result, mDefaultWorkSource);

        if (DBG) {
            logd(rr.serialString() + "> " + requestToString(rr.mRequest));
        }

        try {
            ((android.hardware.radio.config.V1_1.IRadioConfig) mRadioConfigProxy)
                    .getPhoneCapability(rr.mSerial);
        } catch (RemoteException | RuntimeException e) {
            resetProxyAndRequestList("getPhoneCapability", e);
        }
        // TODO: call radioConfigProxy.setPreferredDataModem when it's ready.
    }

    /**
@@ -279,8 +323,9 @@ public class RadioConfig extends Handler {
     * See PhoneSwitcher for more details.
     */
    public boolean isSetPreferredDataCommandSupported() {
        // TODO: call radioConfigProxy.isSetPreferredDataCommandSupported when it's ready.
        return false;
        IRadioConfig radioConfigProxy = getRadioConfigProxy(null);
        return radioConfigProxy != null && mRadioConfigVersion
                .greaterOrEqual(RADIO_CONFIG_HAL_VERSION_1_1);
    }

    /**
+56 −4
Original line number Diff line number Diff line
@@ -18,13 +18,15 @@ package com.android.internal.telephony;

import android.hardware.radio.V1_0.RadioError;
import android.hardware.radio.V1_0.RadioResponseInfo;
import android.hardware.radio.config.V1_1.PhoneCapability;
import android.hardware.radio.config.V1_2.IRadioConfigResponse;
import android.telephony.ModemInfo;
import android.telephony.PhoneCapability;
import android.telephony.Rlog;

import com.android.internal.telephony.uicc.IccSlotStatus;

import java.util.ArrayList;
import java.util.List;

/**
 * This class is the implementation of IRadioConfigResponse interface.
@@ -111,16 +113,66 @@ public class RadioConfigResponse extends IRadioConfigResponse.Stub {
        }
    }

    private PhoneCapability convertHalPhoneCapability(
            android.hardware.radio.config.V1_1.PhoneCapability phoneCapability) {
        // TODO b/121394331: clean up V1_1.PhoneCapability fields.
        int maxActiveVoiceCalls = 0;
        int maxActiveData = phoneCapability.maxActiveData;
        int max5G = 0;
        List<ModemInfo> logicalModemList = new ArrayList();

        for (android.hardware.radio.config.V1_1.ModemInfo
                modemInfo : phoneCapability.logicalModemList) {
            logicalModemList.add(new ModemInfo(modemInfo.modemId));
        }

        return new PhoneCapability(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList);
    }
    /**
     * Response function for IRadioConfig.getPhoneCapability().
     */
    public void getPhoneCapabilityResponse(RadioResponseInfo info,
            PhoneCapability phoneCapability) {
    public void getPhoneCapabilityResponse(RadioResponseInfo responseInfo,
            android.hardware.radio.config.V1_1.PhoneCapability phoneCapability) {
        RILRequest rr = mRadioConfig.processResponse(responseInfo);

        if (rr != null) {
            PhoneCapability ret = convertHalPhoneCapability(phoneCapability);
            if (responseInfo.error == RadioError.NONE) {
                // send response
                RadioResponse.sendMessageResponse(rr.mResult, ret);
                Rlog.d(TAG, rr.serialString() + "< "
                        + mRadioConfig.requestToString(rr.mRequest) + " " + ret.toString());
            } else {
                rr.onError(responseInfo.error, ret);
                Rlog.e(TAG, rr.serialString() + "< "
                        + mRadioConfig.requestToString(rr.mRequest) + " error "
                        + responseInfo.error);
            }
        } else {
            Rlog.e(TAG, "getPhoneCapabilityResponse: Error " + responseInfo.toString());
        }
    }

    /**
     * Response function for IRadioConfig.setPreferredDataModem().
     */
    public void setPreferredDataModemResponse(RadioResponseInfo info) {
    public void setPreferredDataModemResponse(RadioResponseInfo responseInfo) {
        RILRequest rr = mRadioConfig.processResponse(responseInfo);

        if (rr != null) {
            if (responseInfo.error == RadioError.NONE) {
                // send response
                RadioResponse.sendMessageResponse(rr.mResult, null);
                Rlog.d(TAG, rr.serialString() + "< "
                        + mRadioConfig.requestToString(rr.mRequest));
            } else {
                rr.onError(responseInfo.error, null);
                Rlog.e(TAG, rr.serialString() + "< "
                        + mRadioConfig.requestToString(rr.mRequest) + " error "
                        + responseInfo.error);
            }
        } else {
            Rlog.e(TAG, "setPreferredDataModemResponse: Error " + responseInfo.toString());
        }
    }
}