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

Commit 5d9b8866 authored by kaiyiz's avatar kaiyiz Committed by Steve Kondik
Browse files

Telephony: Add support for copy SMS to RUIM card

RIL received PDU data is wrong.

Rearrange the PDU data make it can be RIL parse correctly.

Change-Id: I8045484fabe46262835f2cdc241911cbb3cb57e8
CRs-Fixed: 543087
parent c8f2f83a
Loading
Loading
Loading
Loading
+93 −1
Original line number Diff line number Diff line
@@ -1483,7 +1483,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                response);

        rr.mParcel.writeInt(status);
        rr.mParcel.writeString(pdu);
        constructCdmaWriteSmsRilRequest(rr, IccUtils.hexStringToBytes(pdu));

        if (RILJ_LOGV) riljLog(rr.serialString() + "> "
                + requestToString(rr.mRequest)
@@ -1492,6 +1492,98 @@ public class RIL extends BaseCommands implements CommandsInterface {
        send(rr);
    }

    /**
     *  Restructures PDU data so that it is consistent with RIL
     *  data structure.
     *
     *  @param pdu The data to be written to the RUIM card.
     */
    private void constructCdmaWriteSmsRilRequest(RILRequest rr, byte[] pdu) {
        int address_nbr_of_digits;
        int subaddr_nbr_of_digits;
        int bearerDataLength;
        ByteArrayInputStream bais = new ByteArrayInputStream(pdu);
        DataInputStream dis = new DataInputStream(bais);

        try {
            int teleServiceId = 0;
            byte servicePresent = 0;
            int serviceCategory = 0;

            int address_digit_mode = 0;
            int address_nbr_mode = 0;
            int address_ton = 0;
            int address_nbr_plan = 0;

            int subaddressType = 0;
            byte subaddr_odd = 0;

            teleServiceId = dis.readInt();
            rr.mParcel.writeInt(teleServiceId);
            servicePresent = (byte) dis.readInt();
            rr.mParcel.writeByte(servicePresent);
            serviceCategory = dis.readInt();
            rr.mParcel.writeInt(serviceCategory);

            address_digit_mode = dis.readByte();
            rr.mParcel.writeInt(address_digit_mode);
            address_nbr_mode = dis.readByte();
            rr.mParcel.writeInt(address_nbr_mode);
            address_ton = dis.readByte();
            rr.mParcel.writeInt(address_ton);
            address_nbr_plan = dis.readByte();
            rr.mParcel.writeInt(address_nbr_plan);

            address_nbr_of_digits = dis.readByte();
            rr.mParcel.writeByte((byte) address_nbr_of_digits);
            for (int i = 0; i < address_nbr_of_digits; i++) {
                rr.mParcel.writeByte(dis.readByte()); // address_orig_bytes[i]
            }

            // int
            subaddressType = dis.readByte();
            rr.mParcel.writeInt(subaddressType); // subaddressType
            subaddr_odd = (byte) dis.readByte();
            rr.mParcel.writeByte(subaddr_odd); // subaddr_odd
            subaddr_nbr_of_digits = (byte) dis.readByte();
            rr.mParcel.writeByte((byte) subaddr_nbr_of_digits);
            for (int i = 0; i < subaddr_nbr_of_digits; i++) {
                rr.mParcel.writeByte(dis.readByte()); // subaddr_orig_bytes[i]
            }

            bearerDataLength = dis.readByte() & 0xff;
            rr.mParcel.writeInt(bearerDataLength);
            for (int i = 0; i < bearerDataLength; i++) {
                rr.mParcel.writeByte(dis.readByte()); // bearerData[i]
            }

            riljLog(" teleServiceId=" + teleServiceId + " servicePresent=" + servicePresent
                + " serviceCategory=" + serviceCategory
                + " address_digit_mode=" + address_digit_mode
                + " address_nbr_mode=" + address_nbr_mode + " address_ton=" + address_ton
                + " address_nbr_plan=" + address_nbr_plan
                + " address_nbr_of_digits=" + address_nbr_of_digits
                + " subaddressType=" + subaddressType + " subaddr_odd= " + subaddr_odd
                + " subaddr_nbr_of_digits=" + subaddr_nbr_of_digits
                + " bearerDataLength=" + bearerDataLength);
        } catch (IOException ex) {
            if (RILJ_LOGD) riljLog("sendSmsCdma: conversion from input stream to object failed: "
                    + ex);
        } finally {
            try {
                if (null != bais) {
                    bais.close();
                }

                if (null != dis) {
                    dis.close();
                }
            } catch (IOException e) {
                if (RILJ_LOGD) riljLog("sendSmsCdma: close input stream exception" + e);
            }
        }
    }

    /**
     *  Translates EF_SMS status bits to a status value compatible with
     *  SMS AT commands.  See TS 27.005 3.1.