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

Commit d8fe3ba2 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Client (framework) side HAL changes for RIL solicited responses.

Bug: 32020264
Merged-in: Ib72f2443fb0580092e0f8560a40d3fb9b182887e
Change-Id: Ib72f2443fb0580092e0f8560a40d3fb9b182887e
parent 8b9bce47
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ public class GsmCdmaPhone extends Phone {
    @Override
    protected void finalize() {
        if(DBG) logd("GsmCdmaPhone finalized");
        if (mWakeLock.isHeld()) {
        if (mWakeLock != null && mWakeLock.isHeld()) {
            Rlog.e(LOG_TAG, "UNEXPECTED; mWakeLock is held when finalizing.");
            mWakeLock.release();
        }
+201 −90
Original line number Diff line number Diff line
@@ -1384,14 +1384,20 @@ public final class RIL extends BaseCommands implements CommandsInterface {
    }

    @Override
    public void
    getSignalStrength (Message result) {
        RILRequest rr
                = RILRequest.obtain(RIL_REQUEST_SIGNAL_STRENGTH, result, mRILDefaultWorkSource);
    public void getSignalStrength(Message result) {
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_SIGNAL_STRENGTH, result,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

        send(rr);
            try {
                radioProxy.getSignalStrength(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "getSignalStrength", e);
            }
        }
    }

    @Override
@@ -1537,10 +1543,34 @@ public final class RIL extends BaseCommands implements CommandsInterface {
    }

    @Override
    public void
    setupDataCall(int radioTechnology, int profile, String apn,
    public void setupDataCall(int radioTechnology, int profile, String apn,
                              String user, String password, int authType, String protocol,
                              Message result) {
        /* todo: hidlize
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_SETUP_DATA_CALL, result,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> "
                        + requestToString(rr.mRequest) + " radioTechnology = " + radioTechnology
                        + " profile = " + profile + " apn = " + apn + " user = " + user
                        + " password = " + password + " authType = " + authType + " protocol = "
                        + protocol);
            }

            try {
                radioProxy.setupDataCall(rr.mSerial, radioTechnology + 2, profile,
                        convertNullToEmptyString(apn), convertNullToEmptyString(user),
                        convertNullToEmptyString(password), authType,
                        convertNullToEmptyString(protocol));
                mMetrics.writeRilSetupDataCall(mPhoneId, rr.mSerial,
                        radioTechnology, profile, apn, authType, protocol);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "setupDataCall", e);
            }
        } */
        RILRequest rr
                = RILRequest.obtain(RIL_REQUEST_SETUP_DATA_CALL, result, mRILDefaultWorkSource);

@@ -2147,12 +2177,19 @@ public final class RIL extends BaseCommands implements CommandsInterface {

    @Override
    public void getDataCallList(Message result) {
        RILRequest rr = RILRequest.obtain(RIL_REQUEST_DATA_CALL_LIST, result,
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_DATA_CALL_LIST, result,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

        send(rr);
            try {
                radioProxy.getDataCallList(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "getDataCallList", e);
            }
        }
    }

    @Override
@@ -3119,11 +3156,21 @@ public final class RIL extends BaseCommands implements CommandsInterface {
    @Override
    public void getCellInfoList(Message result, WorkSource workSource) {
        workSource = getDeafultWorkSourceIfInvalid(workSource);
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_GET_CELL_INFO_LIST, result,
                    workSource);

        RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_CELL_INFO_LIST, result, workSource);
        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
            }

        send(rr);
            try {
                radioProxy.getCellInfoList(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "getCellInfoList", e);
            }
        }
    }

    @Override
@@ -3518,12 +3565,20 @@ public final class RIL extends BaseCommands implements CommandsInterface {
    @Override
    public void
    getHardwareConfig (Message result) {
        RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_HARDWARE_CONFIG, result,
        IRadio radioProxy = getRadioProxy(result);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_GET_HARDWARE_CONFIG, result,
                    mRILDefaultWorkSource);

            // Do not log function args for privacy
            if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));

        send(rr);
            try {
                radioProxy.getHardwareConfig(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "getHardwareConfig", e);
            }
        }
    }

    @Override
@@ -3627,32 +3682,50 @@ public final class RIL extends BaseCommands implements CommandsInterface {

    @Override
    public void getRadioCapability(Message response) {
        RILRequest rr = RILRequest.obtain(
                RIL_REQUEST_GET_RADIO_CAPABILITY, response, mRILDefaultWorkSource);
        IRadio radioProxy = getRadioProxy(response);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_GET_RADIO_CAPABILITY, response,
                    mRILDefaultWorkSource);

        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
            }

        send(rr);
            try {
                radioProxy.getRadioCapability(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "getRadioCapability", e);
            }
        }
    }

    @Override
    public void setRadioCapability(RadioCapability rc, Message response) {
        RILRequest rr = RILRequest.obtain(
                RIL_REQUEST_SET_RADIO_CAPABILITY, response, mRILDefaultWorkSource);

        rr.mParcel.writeInt(rc.getVersion());
        rr.mParcel.writeInt(rc.getSession());
        rr.mParcel.writeInt(rc.getPhase());
        rr.mParcel.writeInt(rc.getRadioAccessFamily());
        rr.mParcel.writeString(rc.getLogicalModemUuid());
        rr.mParcel.writeInt(rc.getStatus());
        IRadio radioProxy = getRadioProxy(response);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_SET_RADIO_CAPABILITY, response,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
                    + " " + rc.toString());
                        + " RadioCapability = " + rc.toString());
            }

        send(rr);
            android.hardware.radio.V1_0.RadioCapability halRc =
                    new android.hardware.radio.V1_0.RadioCapability();

            halRc.session = rc.getSession();
            halRc.phase = rc.getPhase();
            halRc.raf = rc.getRadioAccessFamily();
            halRc.logicalModemUuid = convertNullToEmptyString(rc.getLogicalModemUuid());
            halRc.status = rc.getStatus();

            try {
                radioProxy.setRadioCapability(rr.mSerial, halRc);
            } catch (Exception e) {
                handleRadioProxyExceptionForRR(rr, "setRadioCapability", e);
            }
        }
    }

    @Override
@@ -3696,12 +3769,21 @@ public final class RIL extends BaseCommands implements CommandsInterface {

    @Override
    public void pullLceData(Message response) {
        RILRequest rr = RILRequest.obtain(RIL_REQUEST_PULL_LCEDATA, response,
        IRadio radioProxy = getRadioProxy(response);
        if (radioProxy != null) {
            RILRequest rr = obtainRequest(RIL_REQUEST_PULL_LCEDATA, response,
                    mRILDefaultWorkSource);

            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
            }
        send(rr);

            try {
                radioProxy.pullLceData(rr.mSerial);
            } catch (RemoteException | RuntimeException e) {
                handleRadioProxyExceptionForRR(rr, "pullLceData", e);
            }
        }
    }

    @Override
@@ -3973,7 +4055,24 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        int error = responseInfo.error;
        int type = responseInfo.type;

        RILRequest rr = findAndRemoveRequestFromList(serial);
        RILRequest rr = null;

        if (type == RadioResponseType.SOLICITED_ACK) {
            synchronized (mRequestList) {
                rr = mRequestList.get(serial);
            }
            if (rr == null) {
                Rlog.w(RILJ_LOG_TAG, "Unexpected solicited ack response! sn: " + serial);
            } else {
                decrementWakeLock(rr);
                if (RILJ_LOGD) {
                    riljLog(rr.serialString() + " Ack < " + requestToString(rr.mRequest));
                }
            }
            return rr;
        }

        rr = findAndRemoveRequestFromList(serial);
        if (rr == null) {
            Rlog.e(RIL.RILJ_LOG_TAG, "processResponse: Unexpected response! serial: " + serial
                    + " error: " + error);
@@ -4366,7 +4465,6 @@ public final class RIL extends BaseCommands implements CommandsInterface {
            }
        }


        Object ret = null;

        if (error == 0 || p.dataAvail() > 0) {
@@ -4377,25 +4475,15 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                    // will be using same code as unsolicited ril commands which will be done in
                    // separate CL. Other RIL commands below are deprecated and require framework
                    // code to be modified to remove them completely.
                    case RIL_REQUEST_SIGNAL_STRENGTH: ret =  responseSignalStrength(p); break;
                    case RIL_REQUEST_SETUP_DATA_CALL: ret =  responseSetupDataCall(p); break;
                    case RIL_REQUEST_GET_IMEI: ret =  responseString(p); break;
                    case RIL_REQUEST_GET_IMEISV: ret =  responseString(p); break;
                    case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret =  responseInts(p); break;
                    case RIL_REQUEST_DATA_CALL_LIST: ret =  responseDataCallList(p); break;
                    case RIL_REQUEST_RESET_RADIO: ret =  responseVoid(p); break;
                    case RIL_REQUEST_OEM_HOOK_RAW: ret =  responseRaw(p); break;
                    case RIL_REQUEST_STK_GET_PROFILE: ret =  responseString(p); break;
                    case RIL_REQUEST_STK_SET_PROFILE: ret =  responseVoid(p); break;
                    case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret =  responseVoid(p); break;
                    case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break;
                    case RIL_REQUEST_GET_CELL_INFO_LIST: ret = responseCellInfoList(p); break;
                    case RIL_REQUEST_SET_INITIAL_ATTACH_APN: ret = responseVoid(p); break;
                    case RIL_REQUEST_SET_DATA_PROFILE: ret = responseVoid(p); break;
                    case RIL_REQUEST_GET_HARDWARE_CONFIG: ret = responseHardwareConfig(p); break;
                    case RIL_REQUEST_GET_RADIO_CAPABILITY: ret =  responseRadioCapability(p); break;
                    case RIL_REQUEST_SET_RADIO_CAPABILITY: ret =  responseRadioCapability(p); break;
                    case RIL_REQUEST_PULL_LCEDATA: ret = responseLceData(p); break;
                    default:
                        throw new RuntimeException("Unrecognized solicited response: "
                                + rr.mRequest);
@@ -4474,7 +4562,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        return rr;
    }

    private RadioCapability makeStaticRadioCapability() {
    RadioCapability makeStaticRadioCapability() {
        // default to UNKNOWN so we fail fast.
        int raf = RadioAccessFamily.RAF_UNKNOWN;

@@ -5440,9 +5528,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        return ret;
    }

    static ArrayList<DataCallResponse> convertHalDcList(ArrayList<SetupDataCallResult> dcList) {
        ArrayList<DataCallResponse> dcResponseList = new ArrayList<>(dcList.size());
        for (SetupDataCallResult dc : dcList) {
    static DataCallResponse convertHalDc(SetupDataCallResult dc) {
        DataCallResponse dcResponse = new DataCallResponse();
        // todo: get rid of this version field?
        // todo: create a DataCallResponse constructor that takes in these fields to make sure
@@ -5476,6 +5562,13 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        }
        dcResponse.mtu = dc.mtu;

        return dcResponse;
    }

    static ArrayList<DataCallResponse> convertHalDcList(ArrayList<SetupDataCallResult> dcList) {
        ArrayList<DataCallResponse> dcResponseList = new ArrayList<>(dcList.size());
        for (SetupDataCallResult dc : dcList) {
            DataCallResponse dcResponse = convertHalDc(dc);
            dcResponseList.add(dcResponse);
        }
        return dcResponseList;
@@ -5556,7 +5649,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        return capacityResponse;
    }

    static ArrayList<CellInfo> responseCellInfoList(
    static ArrayList<CellInfo> convertHalCellInfoList(
            ArrayList<android.hardware.radio.V1_0.CellInfo> records) {
        ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size());

@@ -5637,4 +5730,22 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        return response;
    }

    static SignalStrength convertHalSignalStrength(
            android.hardware.radio.V1_0.SignalStrength signalStrength) {
        return new SignalStrength(signalStrength.gw.signalStrength,
                signalStrength.gw.bitErrorRate,
                signalStrength.cdma.dbm,
                signalStrength.cdma.ecio,
                signalStrength.evdo.dbm,
                signalStrength.evdo.ecio,
                signalStrength.evdo.signalNoiseRatio,
                signalStrength.lte.signalStrength,
                signalStrength.lte.rsrp,
                signalStrength.lte.rsrq,
                signalStrength.lte.rssnr,
                signalStrength.lte.cqi,
                signalStrength.tdScdma.rscp,
                false /* gsmFlag - don't care; will be changed by SST */);
    }

}
+2 −16
Original line number Diff line number Diff line
@@ -219,21 +219,7 @@ public class RadioIndication extends IRadioIndication.Stub {
                                      android.hardware.radio.V1_0.SignalStrength signalStrength) {
        mRil.processIndication(indicationType);

        SignalStrength ss = new SignalStrength(signalStrength.gw.signalStrength,
                signalStrength.gw.bitErrorRate,
                signalStrength.cdma.dbm,
                signalStrength.cdma.ecio,
                signalStrength.evdo.dbm,
                signalStrength.evdo.ecio,
                signalStrength.evdo.signalNoiseRatio,
                signalStrength.lte.signalStrength,
                signalStrength.lte.rsrp,
                signalStrength.lte.rsrq,
                signalStrength.lte.rssnr,
                signalStrength.lte.cqi,
                signalStrength.tdScdma.rscp,
                false /* gsmFlag - don't care; will be changed by SST */);

        SignalStrength ss = RIL.convertHalSignalStrength(signalStrength);
        // Note this is set to "verbose" because it happens frequently
        if (RIL.RILJ_LOGV) mRil.unsljLogvRet(RIL_UNSOL_SIGNAL_STRENGTH, ss);

@@ -649,7 +635,7 @@ public class RadioIndication extends IRadioIndication.Stub {
                             ArrayList<android.hardware.radio.V1_0.CellInfo> records) {
        mRil.processIndication(indicationType);

        ArrayList<CellInfo> response = RIL.responseCellInfoList(records);
        ArrayList<CellInfo> response = RIL.convertHalCellInfoList(records);

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_CELL_INFO_LIST, response);

+154 −9

File changed.

Preview size limit exceeded, changes collapsed.