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

Commit d3a9df88 authored by Tim Lin's avatar Tim Lin
Browse files

Support IRadio 1.6 setRadioPower

Bug: 170938075
Test: make. calling API on Cuttlefish.
Change-Id: I536aa81b33c60dc5b20f4e2a526b6f2a637bb0b8
parent 59698b98
Loading
Loading
Loading
Loading
+56 −13
Original line number Diff line number Diff line
@@ -1602,7 +1602,16 @@ public class RIL extends BaseCommands implements CommandsInterface {
                        + " preferredForEmergencyCall="  + preferredForEmergencyCall);
            }

            if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
            if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_6)) {
                android.hardware.radio.V1_6.IRadio radioProxy16 =
                        (android.hardware.radio.V1_6.IRadio) radioProxy;
                try {
                    radioProxy16.setRadioPower_1_6(rr.mSerial, on, forEmergencyCall,
                            preferredForEmergencyCall);
                } catch (RemoteException | RuntimeException e) {
                    handleRadioProxyExceptionForRR(rr, "setRadioPower_1_6", e);
                }
            } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) {
                android.hardware.radio.V1_5.IRadio radioProxy15 =
                        (android.hardware.radio.V1_5.IRadio) radioProxy;
                try {
@@ -5501,10 +5510,24 @@ public class RIL extends BaseCommands implements CommandsInterface {
     */
    @VisibleForTesting
    public RILRequest processResponse(RadioResponseInfo responseInfo) {
        int serial = responseInfo.serial;
        int error = responseInfo.error;
        int type = responseInfo.type;
        return processResponseInternal(responseInfo.serial, responseInfo.error, responseInfo.type);
    }

    /**
     * This is a helper function for V1_6.RadioResponseInfo to be called when a RadioResponse
     * callback is called.
     * It takes care of acks, wakelocks, and finds and returns RILRequest corresponding to the
     * response if one is found.
     * @param responseInfo RadioResponseInfo received in response callback
     * @return RILRequest corresponding to the response
     */
    @VisibleForTesting
    public RILRequest processResponse_1_6(
                    android.hardware.radio.V1_6.RadioResponseInfo responseInfo) {
        return processResponseInternal(responseInfo.serial, responseInfo.error, responseInfo.type);
    }

    private RILRequest processResponseInternal(int serial, int error, int type) {
        RILRequest rr = null;

        if (type == RadioResponseType.SOLICITED_ACK) {
@@ -5608,7 +5631,28 @@ public class RIL extends BaseCommands implements CommandsInterface {
     */
    @VisibleForTesting
    public void processResponseDone(RILRequest rr, RadioResponseInfo responseInfo, Object ret) {
        if (responseInfo.error == 0) {
        processResponseDoneInternal(rr, responseInfo.error, responseInfo.type, ret);
    }

    /**
     * This is a helper function to be called at the end of the RadioResponse callbacks using for
     * V1_6.RadioResponseInfo.
     * It takes care of sending error response, logging, decrementing wakelock if needed, and
     * releases the request from memory pool.
     * @param rr RILRequest for which response callback was called
     * @param responseInfo RadioResponseInfo received in the callback
     * @param ret object to be returned to request sender
     */
    @VisibleForTesting
    public void processResponseDone_1_6(
                    RILRequest rr, android.hardware.radio.V1_6.RadioResponseInfo responseInfo,
                    Object ret) {
        processResponseDoneInternal(rr, responseInfo.error, responseInfo.type, ret);
    }

    private void processResponseDoneInternal(
            RILRequest rr, int rilError, int responseType, Object ret) {
        if (rilError == 0) {
            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "< " + requestToString(rr.mRequest)
                        + " " + retToString(rr.mRequest, ret));
@@ -5616,11 +5660,11 @@ public class RIL extends BaseCommands implements CommandsInterface {
        } else {
            if (RILJ_LOGD) {
                riljLog(rr.serialString() + "< " + requestToString(rr.mRequest)
                        + " error " + responseInfo.error);
                        + " error " + rilError);
            }
            rr.onError(responseInfo.error, ret);
            rr.onError(rilError, ret);
        }
        processResponseCleanUp(rr, responseInfo, ret);
        processResponseCleanUp(rr, rilError, responseType, ret);
    }

    /**
@@ -5638,14 +5682,13 @@ public class RIL extends BaseCommands implements CommandsInterface {
            riljLog(rr.serialString() + "< " + requestToString(rr.mRequest)
                    + " request not supported, falling back");
        }
        processResponseCleanUp(rr, responseInfo, ret);
        processResponseCleanUp(rr, responseInfo.error, responseInfo.type, ret);
    }

    private void processResponseCleanUp(RILRequest rr, RadioResponseInfo responseInfo, Object ret) {
    private void processResponseCleanUp(RILRequest rr, int rilError, int responseType, Object ret) {
        if (rr != null) {
            mMetrics.writeOnRilSolicitedResponse(mPhoneId, rr.mSerial, responseInfo.error,
                    rr.mRequest, ret);
            if (responseInfo.type == RadioResponseType.SOLICITED) {
            mMetrics.writeOnRilSolicitedResponse(mPhoneId, rr.mSerial, rilError, rr.mRequest, ret);
            if (responseType == RadioResponseType.SOLICITED) {
                decrementWakeLock(rr);
            }
            rr.release();
+19 −0
Original line number Diff line number Diff line
@@ -2067,6 +2067,18 @@ public class RadioResponse extends IRadioResponse.Stub {
        }
    }

    private void responseVoid_1_6(android.hardware.radio.V1_6.RadioResponseInfo responseInfo) {
        RILRequest rr = mRil.processResponse_1_6(responseInfo);

        if (rr != null) {
            Object ret = null;
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, ret);
            }
            mRil.processResponseDone_1_6(rr, responseInfo, ret);
        }
    }

    private void responseString(RadioResponseInfo responseInfo, String str) {
        RILRequest rr = mRil.processResponse(responseInfo);

@@ -2648,6 +2660,13 @@ public class RadioResponse extends IRadioResponse.Stub {
        responseVoid(info);
    }

    /**
     * @param info Response info struct containing response type, serial no. and error.
     */
    public void setRadioPowerResponse_1_6(android.hardware.radio.V1_6.RadioResponseInfo info) {
        responseVoid_1_6(info);
    }

    /**
     * @param info Response info struct containing response type, serial no. and error.
     */