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

Commit bc0e2a59 authored by Sarah Chin's avatar Sarah Chin
Browse files

Implement IRadio modules

Test: atest FrameworksTelephonyTests
Bug: 198331673
Change-Id: Ie4df4638f94193ca839c7256ada95224532d46ed
Merged-In: Ie4df4638f94193ca839c7256ada95224532d46ed
parent ec7d6a54
Loading
Loading
Loading
Loading
+15 −19
Original line number Diff line number Diff line
@@ -221,16 +221,12 @@ public class CellularNetworkService extends NetworkService {
            final int domain = NetworkRegistrationInfo.DOMAIN_CS;

            if (result instanceof android.hardware.radio.V1_6.RegStateResult) {
                return getNetworkRegistrationInfo1_6(
                        domain,
                        transportType,
                return getNetworkRegistrationInfo1_6(domain, transportType,
                        (android.hardware.radio.V1_6.RegStateResult) result);
            }
            // 1.5 at the top so that we can do an "early exit" from the method
            else if (result instanceof android.hardware.radio.V1_5.RegStateResult) {
                return getNetworkRegistrationInfo(
                        domain,
                        transportType,
                return getNetworkRegistrationInfo(domain, transportType,
                        (android.hardware.radio.V1_5.RegStateResult) result);
            } else if (result instanceof android.hardware.radio.V1_0.VoiceRegStateResult) {
                android.hardware.radio.V1_0.VoiceRegStateResult voiceRegState =
@@ -245,7 +241,8 @@ public class CellularNetworkService extends NetworkService {
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity = CellIdentity.create(voiceRegState.cellIdentity);
                CellIdentity cellIdentity =
                        RILUtils.convertHalCellIdentity(voiceRegState.cellIdentity);
                final String rplmn = getPlmnFromCellIdentity(cellIdentity);

                return new NetworkRegistrationInfo(domain, transportType, regState,
@@ -265,7 +262,8 @@ public class CellularNetworkService extends NetworkService {
                int defaultRoamingIndicator = voiceRegState.defaultRoamingIndicator;
                List<Integer> availableServices = getAvailableServices(
                        regState, domain, emergencyOnly);
                CellIdentity cellIdentity = CellIdentity.create(voiceRegState.cellIdentity);
                CellIdentity cellIdentity =
                        RILUtils.convertHalCellIdentity(voiceRegState.cellIdentity);
                final String rplmn = getPlmnFromCellIdentity(cellIdentity);

                return new NetworkRegistrationInfo(domain, transportType, regState,
@@ -296,16 +294,12 @@ public class CellularNetworkService extends NetworkService {
                            LteVopsSupportInfo.LTE_STATUS_NOT_AVAILABLE);

            if (result instanceof android.hardware.radio.V1_6.RegStateResult) {
                return getNetworkRegistrationInfo1_6(
                        domain,
                        transportType,
                return getNetworkRegistrationInfo1_6(domain, transportType,
                        (android.hardware.radio.V1_6.RegStateResult) result);
            }
            // 1.5 at the top so that we can do an "early exit" from the method
            else if (result instanceof android.hardware.radio.V1_5.RegStateResult) {
                return getNetworkRegistrationInfo(
                        domain,
                        transportType,
                return getNetworkRegistrationInfo(domain, transportType,
                        (android.hardware.radio.V1_5.RegStateResult) result);
            } else if (result instanceof android.hardware.radio.V1_0.DataRegStateResult) {
                android.hardware.radio.V1_0.DataRegStateResult dataRegState =
@@ -315,7 +309,7 @@ public class CellularNetworkService extends NetworkService {
                reasonForDenial = dataRegState.reasonDataDenied;
                emergencyOnly = isEmergencyOnly(dataRegState.regState);
                maxDataCalls = dataRegState.maxDataCalls;
                cellIdentity = CellIdentity.create(dataRegState.cellIdentity);
                cellIdentity = RILUtils.convertHalCellIdentity(dataRegState.cellIdentity);
            } else if (result instanceof android.hardware.radio.V1_2.DataRegStateResult) {
                android.hardware.radio.V1_2.DataRegStateResult dataRegState =
                        (android.hardware.radio.V1_2.DataRegStateResult) result;
@@ -324,7 +318,7 @@ public class CellularNetworkService extends NetworkService {
                reasonForDenial = dataRegState.reasonDataDenied;
                emergencyOnly = isEmergencyOnly(dataRegState.regState);
                maxDataCalls = dataRegState.maxDataCalls;
                cellIdentity = CellIdentity.create(dataRegState.cellIdentity);
                cellIdentity = RILUtils.convertHalCellIdentity(dataRegState.cellIdentity);
            } else if (result instanceof android.hardware.radio.V1_4.DataRegStateResult) {
                android.hardware.radio.V1_4.DataRegStateResult dataRegState =
                        (android.hardware.radio.V1_4.DataRegStateResult) result;
@@ -334,7 +328,7 @@ public class CellularNetworkService extends NetworkService {
                reasonForDenial = dataRegState.base.reasonDataDenied;
                emergencyOnly = isEmergencyOnly(dataRegState.base.regState);
                maxDataCalls = dataRegState.base.maxDataCalls;
                cellIdentity = CellIdentity.create(dataRegState.base.cellIdentity);
                cellIdentity = RILUtils.convertHalCellIdentity(dataRegState.base.cellIdentity);
                android.hardware.radio.V1_4.NrIndicators nrIndicators = dataRegState.nrIndicators;

                // Check for lteVopsInfo only if its initialized and RAT is EUTRAN
@@ -379,7 +373,8 @@ public class CellularNetworkService extends NetworkService {
            final List<Integer> availableServices = getAvailableServices(
                    regState, domain, isEmergencyOnly);
            final int rejectCause = regResult.reasonForDenial;
            final CellIdentity cellIdentity = CellIdentity.create(regResult.cellIdentity);
            final CellIdentity cellIdentity =
                    RILUtils.convertHalCellIdentity(regResult.cellIdentity);
            final String rplmn = regResult.registeredPlmn;
            final int reasonForDenial = regResult.reasonForDenial;

@@ -459,7 +454,8 @@ public class CellularNetworkService extends NetworkService {
            final List<Integer> availableServices = getAvailableServices(
                    regState, domain, isEmergencyOnly);
            final int rejectCause = regResult.reasonForDenial;
            final CellIdentity cellIdentity = CellIdentity.create(regResult.cellIdentity);
            final CellIdentity cellIdentity =
                    RILUtils.convertHalCellIdentity(regResult.cellIdentity);
            final String rplmn = regResult.registeredPlmn;
            final int reasonForDenial = regResult.reasonForDenial;

+11 −12
Original line number Diff line number Diff line
@@ -35,18 +35,18 @@ import java.util.ArrayList;
 * Interface declaring unsolicited radio indications for data APIs.
 */
public class DataIndication extends IRadioDataIndication.Stub {
    RIL mRil;
    private final RIL mRil;

    DataIndication(RIL ril) {
    public DataIndication(RIL ril) {
        mRil = ril;
    }

    /**
     * Indicates data call contexts have changed.
     * @param indicationType RadioIndicationType
     * @param indicationType Type of radio indication
     * @param dcList List of SetupDataCallResult identical to that returned by getDataCallList.
     *               It is the complete list of current data contexts including new contexts that
     *               have been activated.
     *        It is the complete list of current data contexts including new contexts that have
     *        been activated.
     */
    public void dataCallListChanged(int indicationType,
            android.hardware.radio.data.SetupDataCallResult[] dcList) {
@@ -60,7 +60,7 @@ public class DataIndication extends IRadioDataIndication.Stub {

    /**
     * Indicates a status update for an ongoing Keepalive session.
     * @param indicationType RadioIndicationType
     * @param indicationType Type of radio indication
     * @param halStatus Status of the ongoing Keepalive session
     */
    public void keepaliveStatus(int indicationType,
@@ -68,8 +68,8 @@ public class DataIndication extends IRadioDataIndication.Stub {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) {
            mRil.unsljLogRet(RIL_UNSOL_KEEPALIVE_STATUS,
                    "handle=" + halStatus.sessionHandle + " code=" +  halStatus.code);
            mRil.unsljLogRet(RIL_UNSOL_KEEPALIVE_STATUS, "handle=" + halStatus.sessionHandle
                    + " code=" +  halStatus.code);
        }

        KeepaliveStatus ks = new KeepaliveStatus(halStatus.sessionHandle, halStatus.code);
@@ -78,7 +78,7 @@ public class DataIndication extends IRadioDataIndication.Stub {

    /**
     * Indicates when there is new Carrier PCO data received for a data call.
     * @param indicationType RadioIndicationType
     * @param indicationType Type of radio indication
     * @param pco New PcoData
     */
    public void pcoData(int indicationType, android.hardware.radio.data.PcoDataInfo pco) {
@@ -93,7 +93,7 @@ public class DataIndication extends IRadioDataIndication.Stub {

    /**
     * Stop throttling calls to setupDataCall for the given APN.
     * @param indicationType RadioIndicationType
     * @param indicationType Type of radio indication
     * @param apn APN to unthrottle
     * @throws RemoteException
     */
@@ -102,7 +102,6 @@ public class DataIndication extends IRadioDataIndication.Stub {

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_UNTHROTTLE_APN, apn);

        mRil.mApnUnthrottledRegistrants.notifyRegistrants(
                new AsyncResult(null, apn, null));
        mRil.mApnUnthrottledRegistrants.notifyRegistrants(new AsyncResult(null, apn, null));
    }
}
+15 −42
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.internal.telephony;
import android.hardware.radio.RadioError;
import android.hardware.radio.RadioResponseInfo;
import android.hardware.radio.data.IRadioDataResponse;
import android.os.AsyncResult;
import android.os.Message;
import android.telephony.data.DataCallResponse;
import android.telephony.data.NetworkSlicingConfig;

@@ -38,30 +36,6 @@ public class DataResponse extends IRadioDataResponse.Stub {
        mRil = ril;
    }

    /**
     * Helper function to send response msg
     * @param msg Response message to be sent
     * @param ret Return object to be included in the response message
     */
    private static void sendMessageResponse(Message msg, Object ret) {
        if (msg != null) {
            AsyncResult.forMessage(msg, ret, null);
            msg.sendToTarget();
        }
    }

    private void responseVoid(RadioResponseInfo responseInfo) {
        RILRequest rr = mRil.processResponse(responseInfo);

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

    /**
     * Acknowledge the receipt of radio request sent to the vendor. This must be sent only for
     * radio request which take long time to respond.
@@ -80,7 +54,7 @@ public class DataResponse extends IRadioDataResponse.Stub {
        RILRequest rr = mRil.processResponse(responseInfo);
        if (rr != null) {
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, id);
                RadioResponse.sendMessageResponse(rr.mResult, id);
            }
            mRil.processResponseDone(rr, responseInfo, id);
        }
@@ -90,20 +64,19 @@ public class DataResponse extends IRadioDataResponse.Stub {
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void cancelHandoverResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void deactivateDataCallResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     * @param dataCallResultList Response to get data call list as defined by setupDataCallResult in
     *                           types.hal
     * @param dataCallResultList Response to get data call list as defined by SetupDataCallResult
     */
    public void getDataCallListResponse(RadioResponseInfo responseInfo,
            android.hardware.radio.data.SetupDataCallResult[] dataCallResultList) {
@@ -113,7 +86,7 @@ public class DataResponse extends IRadioDataResponse.Stub {
            ArrayList<DataCallResponse> response =
                    RILUtils.convertHalDataCallResultList(dataCallResultList);
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, response);
                RadioResponse.sendMessageResponse(rr.mResult, response);
            }
            mRil.processResponseDone(rr, responseInfo, response);
        }
@@ -130,7 +103,7 @@ public class DataResponse extends IRadioDataResponse.Stub {
        if (rr != null) {
            NetworkSlicingConfig ret = RILUtils.convertHalSlicingConfig(slicingConfig);
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, ret);
                RadioResponse.sendMessageResponse(rr.mResult, ret);
            }
            mRil.processResponseDone(rr, responseInfo, ret);
        }
@@ -140,35 +113,35 @@ public class DataResponse extends IRadioDataResponse.Stub {
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void releasePduSessionIdResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void setDataAllowedResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void setDataProfileResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void setDataThrottlingResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void setInitialAttachApnResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
@@ -182,7 +155,7 @@ public class DataResponse extends IRadioDataResponse.Stub {
        if (rr != null) {
            DataCallResponse response = RILUtils.convertHalDataCallResult(setupDataCallResult);
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, response);
                RadioResponse.sendMessageResponse(rr.mResult, response);
            }
            mRil.processResponseDone(rr, responseInfo, response);
        }
@@ -192,7 +165,7 @@ public class DataResponse extends IRadioDataResponse.Stub {
     * @param responseInfo Response info struct containing response type, serial no. and error
     */
    public void startHandoverResponse(RadioResponseInfo responseInfo) {
        responseVoid(responseInfo);
        RadioResponse.responseVoid(mRil, responseInfo);
    }

    /**
@@ -218,7 +191,7 @@ public class DataResponse extends IRadioDataResponse.Stub {
                    }
                    // If responseInfo.error is NONE, response function sends the response message
                    // even if result is actually an error.
                    sendMessageResponse(rr.mResult, ret);
                    RadioResponse.sendMessageResponse(rr.mResult, ret);
                    break;
                case RadioError.REQUEST_NOT_SUPPORTED:
                    ret = new KeepaliveStatus(KeepaliveStatus.ERROR_UNSUPPORTED);
@@ -245,7 +218,7 @@ public class DataResponse extends IRadioDataResponse.Stub {

        try {
            if (responseInfo.error == RadioError.NONE) {
                sendMessageResponse(rr.mResult, null);
                RadioResponse.sendMessageResponse(rr.mResult, null);
            } else {
                //TODO: Error code translation
            }
+180 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import static com.android.internal.telephony.RILConstants.RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ON_USSD;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_CDMA_NEW_SMS;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_SMS;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SIM_SMS_STORAGE_FULL;

import android.hardware.radio.messaging.IRadioMessagingIndication;
import android.os.AsyncResult;
import android.telephony.SmsMessage;

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

/**
 * Interface declaring unsolicited radio indications for messaging APIs.
 */
public class MessagingIndication extends IRadioMessagingIndication.Stub {
    private final RIL mRil;

    public MessagingIndication(RIL ril) {
        mRil = ril;
    }

    /**
     * Indicates when new CDMA SMS is received.
     * @param indicationType Type of radio indication
     * @param msg CdmaSmsMessage
     */
    public void cdmaNewSms(int indicationType,
            android.hardware.radio.messaging.CdmaSmsMessage msg) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_CDMA_NEW_SMS);

        SmsMessage sms = new SmsMessage(RILUtils.convertHalCdmaSmsMessage(msg));
        if (mRil.mCdmaSmsRegistrant != null) {
            mRil.mCdmaSmsRegistrant.notifyRegistrant(new AsyncResult(null, sms, null));
        }
    }

    /**
     * Indicates that SMS storage on the RUIM is full. Messages cannot be saved on the RUIM until
     * space is freed.
     * @param indicationType Type of radio indication
     */
    public void cdmaRuimSmsStorageFull(int indicationType) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL);

        if (mRil.mIccSmsFullRegistrant != null) {
            mRil.mIccSmsFullRegistrant.notifyRegistrant();
        }
    }

    /**
     * Indicates when new Broadcast SMS is received
     * @param indicationType Type of radio indication
     * @param data If received from GSM network, "data" is byte array of 88 bytes which indicates
     *        each page of a CBS Message sent to the MS by the BTS as coded in 3GPP 23.041 Section
     *        9.4.1.2. If received from UMTS network, "data" is byte array of 90 up to 1252 bytes
     *        which contain between 1 and 15 CBS Message pages sent as one packet to the MS by the
     *        BTS as coded in 3GPP 23.041 Section 9.4.2.2
     */
    public void newBroadcastSms(int indicationType, byte[] data) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) {
            mRil.unsljLogvRet(RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS,
                    IccUtils.bytesToHexString(data));
        }

        if (mRil.mGsmBroadcastSmsRegistrant != null) {
            mRil.mGsmBroadcastSmsRegistrant.notifyRegistrant(new AsyncResult(null, data, null));
        }
    }

    /**
     * Indicates when new SMS is received.
     * @param indicationType Type of radio indication
     * @param pdu PDU of SMS-DELIVER represented as byte array.
     *        The PDU starts with the SMSC address per TS 27.005 (+CMT:)
     */
    public void newSms(int indicationType, byte[] pdu) {
        mRil.processIndication(indicationType);
        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_NEW_SMS);

        SmsMessageBase smsb = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
        if (mRil.mGsmSmsRegistrant != null) {
            mRil.mGsmSmsRegistrant.notifyRegistrant(
                    new AsyncResult(null, smsb == null ? null : new SmsMessage(smsb), null));
        }
    }

    /**
     * Indicates when new SMS has been stored on SIM card.
     * @param indicationType Type of radio indication
     * @param recordNumber Record number on the SIM
     */
    public void newSmsOnSim(int indicationType, int recordNumber) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM);

        if (mRil.mSmsOnSimRegistrant != null) {
            mRil.mSmsOnSimRegistrant.notifyRegistrant(new AsyncResult(null, recordNumber, null));
        }
    }

    /**
     * Indicates when new SMS Status Report is received.
     * @param indicationType Type of radio indication
     * @param pdu PDU of SMS-STATUS-REPORT represented as byte array.
     *        The PDU starts with the SMSC address per TS 27.005 (+CMT:)
     */
    public void newSmsStatusReport(int indicationType, byte[] pdu) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT);

        if (mRil.mSmsStatusRegistrant != null) {
            mRil.mSmsStatusRegistrant.notifyRegistrant(new AsyncResult(null, pdu, null));
        }
    }

    /**
     * Indicates when a new USSD message is received. The USSD session is assumed to persist if the
     * type code is REQUEST, otherwise the current session (if any) is assumed to have terminated.
     * @param indicationType Type of radio indication
     * @param ussdModeType USSD type code
     * @param msg Message string in UTF-8, if applicable
     */
    public void onUssd(int indicationType, int ussdModeType, String msg) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLogMore(RIL_UNSOL_ON_USSD, "" + ussdModeType);

        // TODO: Clean this up with a parcelable class for better self-documentation
        String[] resp = new String[]{"" + ussdModeType, msg};
        if (mRil.mUSSDRegistrant != null) {
            mRil.mUSSDRegistrant.notifyRegistrant(new AsyncResult(null, resp, null));
        }
    }

    /**
     * Indicates that SMS storage on the SIM is full. Sent when the network attempts to deliver a
     * new SMS message. Messages cannot be saved on the SIM until space is freed. In particular,
     * incoming Class 2 messages must not be stored.
     * @param indicationType Type of radio indication
     */
    public void simSmsStorageFull(int indicationType) {
        mRil.processIndication(indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLog(RIL_UNSOL_SIM_SMS_STORAGE_FULL);

        if (mRil.mIccSmsFullRegistrant != null) {
            mRil.mIccSmsFullRegistrant.notifyRegistrant();
        }
    }
}
+290 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading