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

Commit 51373fdb authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Gerrit Code Review
Browse files

Merge "Connect IRadioConfig 1.1 HAL interfaces with RadioConfig.java"

parents 55cd6e08 0d98b08d
Loading
Loading
Loading
Loading
+48 −3
Original line number Original line 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.RADIO_NOT_AVAILABLE;
import static com.android.internal.telephony.RILConstants.REQUEST_NOT_SUPPORTED;
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_GET_SLOT_STATUS;
import static com.android.internal.telephony.RILConstants
import static com.android.internal.telephony.RILConstants
        .RIL_REQUEST_SET_LOGICAL_TO_PHYSICAL_SLOT_MAPPING;
        .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.content.Context;
import android.hardware.radio.V1_0.RadioResponseInfo;
import android.hardware.radio.V1_0.RadioResponseInfo;
@@ -298,8 +300,50 @@ public class RadioConfig extends Handler {
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                        CommandException.fromRilErrno(REQUEST_NOT_SUPPORTED));
                result.sendToTarget();
                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.
    }
    }


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


    /**
    /**
+56 −4
Original line number Original line 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.RadioError;
import android.hardware.radio.V1_0.RadioResponseInfo;
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.hardware.radio.config.V1_2.IRadioConfigResponse;
import android.telephony.ModemInfo;
import android.telephony.PhoneCapability;
import android.telephony.Rlog;
import android.telephony.Rlog;


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


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


/**
/**
 * This class is the implementation of IRadioConfigResponse interface.
 * This class is the implementation of IRadioConfigResponse interface.
@@ -111,17 +113,67 @@ 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().
     * Response function for IRadioConfig.getPhoneCapability().
     */
     */
    public void getPhoneCapabilityResponse(RadioResponseInfo info,
    public void getPhoneCapabilityResponse(RadioResponseInfo responseInfo,
            PhoneCapability phoneCapability) {
            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().
     * 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());
        }
    }
    }


    /**
    /**