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

Commit f68498ea authored by Android (Google) Code Review's avatar Android (Google) Code Review Committed by The Android Open Source Project
Browse files

am 5bc21aa0: Merge change 1127 into donut

Merge commit '5bc21aa0'

* commit '5bc21aa0':
  SmsHeader rewrite, in preparation for migration to public API.
parents 1312d370 5bc21aa0
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.os.Parcel;


import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.EncodeException;
import com.android.internal.telephony.EncodeException;
import com.android.internal.telephony.SmsHeader;
import com.android.internal.telephony.SmsMessageBase;
import com.android.internal.telephony.SmsMessageBase;
import com.android.internal.telephony.SmsMessageBase.SubmitPduBase;
import com.android.internal.telephony.SmsMessageBase.SubmitPduBase;


@@ -307,7 +308,8 @@ public class SmsMessage {


        if (PHONE_TYPE_CDMA == activePhone) {
        if (PHONE_TYPE_CDMA == activePhone) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested, header);
                    destinationAddress, message, statusReportRequested,
                    SmsHeader.fromByteArray(header));
        } else {
        } else {
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested, header);
                    destinationAddress, message, statusReportRequested, header);
@@ -331,7 +333,7 @@ public class SmsMessage {


        if (PHONE_TYPE_CDMA == activePhone) {
        if (PHONE_TYPE_CDMA == activePhone) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested);
                    destinationAddress, message, statusReportRequested, null);
        } else {
        } else {
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested);
                    destinationAddress, message, statusReportRequested);
+4 −3
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.telephony.TelephonyManager;


import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.GsmAlphabet;
import com.android.internal.telephony.EncodeException;
import com.android.internal.telephony.EncodeException;
import com.android.internal.telephony.SmsHeader;
import com.android.internal.telephony.SmsMessageBase;
import com.android.internal.telephony.SmsMessageBase;
import com.android.internal.telephony.SmsMessageBase.SubmitPduBase;
import com.android.internal.telephony.SmsMessageBase.SubmitPduBase;


@@ -369,7 +370,8 @@ public class SmsMessage {


        if (PHONE_TYPE_CDMA == activePhone) {
        if (PHONE_TYPE_CDMA == activePhone) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested, header);
                    destinationAddress, message, statusReportRequested,
                    SmsHeader.fromByteArray(header));
        } else {
        } else {
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested, header);
                    destinationAddress, message, statusReportRequested, header);
@@ -395,7 +397,7 @@ public class SmsMessage {


        if (PHONE_TYPE_CDMA == activePhone) {
        if (PHONE_TYPE_CDMA == activePhone) {
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested);
                    destinationAddress, message, statusReportRequested, null);
        } else {
        } else {
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
            spb = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(scAddress,
                    destinationAddress, message, statusReportRequested);
                    destinationAddress, message, statusReportRequested);
@@ -744,4 +746,3 @@ public class SmsMessage {
        }
        }
    }
    }
}
}
+3 −2
Original line number Original line Diff line number Diff line
@@ -182,7 +182,7 @@ public class GsmAlphabet {
            return stringToGsm7BitPacked(data);
            return stringToGsm7BitPacked(data);
        }
        }


        int headerBits = header.length * 8;
        int headerBits = (header.length + 1) * 8;
        int headerSeptets = headerBits / 7;
        int headerSeptets = headerBits / 7;
        headerSeptets += (headerBits % 7) > 0 ? 1 : 0;
        headerSeptets += (headerBits % 7) > 0 ? 1 : 0;


@@ -194,7 +194,8 @@ public class GsmAlphabet {
                (headerSeptets*7), true);
                (headerSeptets*7), true);


        // Paste in the header
        // Paste in the header
        System.arraycopy(header, 0, ret, 1, header.length);
        ret[1] = (byte)header.length;
        System.arraycopy(header, 0, ret, 2, header.length);
        return ret;
        return ret;
    }
    }


+44 −34
Original line number Original line Diff line number Diff line
@@ -122,7 +122,7 @@ public abstract class SMSDispatcher extends Handler {
     * CONCATENATED_16_BIT_REFERENCE message set.  Should be
     * CONCATENATED_16_BIT_REFERENCE message set.  Should be
     * incremented for each set of concatenated messages.
     * incremented for each set of concatenated messages.
     */
     */
    protected static int sConcatenatedRef;
    private static int sConcatenatedRef;


    private SmsCounter mCounter;
    private SmsCounter mCounter;


@@ -132,6 +132,11 @@ public abstract class SMSDispatcher extends Handler {
    private static SmsMessageBase mSmsMessageBase;
    private static SmsMessageBase mSmsMessageBase;
    private SmsMessageBase.SubmitPduBase mSubmitPduBase;
    private SmsMessageBase.SubmitPduBase mSubmitPduBase;


    protected static int getNextConcatenatedRef() {
        sConcatenatedRef += 1;
        return sConcatenatedRef;
    }

    /**
    /**
     *  Implement the per-application based SMS control, which only allows
     *  Implement the per-application based SMS control, which only allows
     *  a limit on the number of SMS/MMS messages an app can send in checking
     *  a limit on the number of SMS/MMS messages an app can send in checking
@@ -419,12 +424,15 @@ public abstract class SMSDispatcher extends Handler {
    /**
    /**
     * If this is the last part send the parts out to the application, otherwise
     * If this is the last part send the parts out to the application, otherwise
     * the part is stored for later processing.
     * the part is stored for later processing.
     *
     * NOTE: concatRef (naturally) needs to be non-null, but portAddrs can be null.
     */
     */
    protected void processMessagePart(SmsMessageBase sms, int referenceNumber,
    protected void processMessagePart(SmsMessageBase sms,
            int sequence, int count, int destinationPort) {
            SmsHeader.ConcatRef concatRef, SmsHeader.PortAddrs portAddrs) {

        // Lookup all other related parts
        // Lookup all other related parts
        StringBuilder where = new StringBuilder("reference_number =");
        StringBuilder where = new StringBuilder("reference_number =");
        where.append(referenceNumber);
        where.append(concatRef.refNumber);
        where.append(" AND address = ?");
        where.append(" AND address = ?");
        String[] whereArgs = new String[] {sms.getOriginatingAddress()};
        String[] whereArgs = new String[] {sms.getOriginatingAddress()};


@@ -433,20 +441,19 @@ public abstract class SMSDispatcher extends Handler {
        try {
        try {
            cursor = mResolver.query(mRawUri, RAW_PROJECTION, where.toString(), whereArgs, null);
            cursor = mResolver.query(mRawUri, RAW_PROJECTION, where.toString(), whereArgs, null);
            int cursorCount = cursor.getCount();
            int cursorCount = cursor.getCount();
            if (cursorCount != count - 1) {
            if (cursorCount != concatRef.msgCount - 1) {
                // We don't have all the parts yet, store this one away
                // We don't have all the parts yet, store this one away
                ContentValues values = new ContentValues();
                ContentValues values = new ContentValues();
                values.put("date", new Long(sms.getTimestampMillis()));
                values.put("date", new Long(sms.getTimestampMillis()));
                values.put("pdu", HexDump.toHexString(sms.getPdu()));
                values.put("pdu", HexDump.toHexString(sms.getPdu()));
                values.put("address", sms.getOriginatingAddress());
                values.put("address", sms.getOriginatingAddress());
                values.put("reference_number", referenceNumber);
                values.put("reference_number", concatRef.refNumber);
                values.put("count", count);
                values.put("count", concatRef.msgCount);
                values.put("sequence", sequence);
                values.put("sequence", concatRef.seqNumber);
                if (destinationPort != -1) {
                if (portAddrs != null) {
                    values.put("destination_port", destinationPort);
                    values.put("destination_port", portAddrs.destPort);
                }
                }
                mResolver.insert(mRawUri, values);
                mResolver.insert(mRawUri, values);

                return;
                return;
            }
            }


@@ -454,7 +461,7 @@ public abstract class SMSDispatcher extends Handler {
            int pduColumn = cursor.getColumnIndex("pdu");
            int pduColumn = cursor.getColumnIndex("pdu");
            int sequenceColumn = cursor.getColumnIndex("sequence");
            int sequenceColumn = cursor.getColumnIndex("sequence");


            pdus = new byte[count][];
            pdus = new byte[concatRef.msgCount][];
            for (int i = 0; i < cursorCount; i++) {
            for (int i = 0; i < cursorCount; i++) {
                cursor.moveToNext();
                cursor.moveToNext();
                int cursorSequence = (int)cursor.getLong(sequenceColumn);
                int cursorSequence = (int)cursor.getLong(sequenceColumn);
@@ -462,7 +469,7 @@ public abstract class SMSDispatcher extends Handler {
                        cursor.getString(pduColumn));
                        cursor.getString(pduColumn));
            }
            }
            // This one isn't in the DB, so add it
            // This one isn't in the DB, so add it
            pdus[sequence - 1] = sms.getPdu();
            pdus[concatRef.seqNumber - 1] = sms.getPdu();


            // Remove the parts from the database
            // Remove the parts from the database
            mResolver.delete(mRawUri, where.toString(), whereArgs);
            mResolver.delete(mRawUri, where.toString(), whereArgs);
@@ -473,31 +480,34 @@ public abstract class SMSDispatcher extends Handler {
            if (cursor != null) cursor.close();
            if (cursor != null) cursor.close();
        }
        }


        /**
         * TODO(cleanup): The following code has duplicated logic with
         * the radio-specific dispatchMessage code, which is fragile,
         * in addition to being redundant.  Instead, if this method
         * maybe returned the reassembled message (or just contents),
         * the following code (which is not really related to
         * reconstruction) could be better consolidated.
         */

        // Dispatch the PDUs to applications
        // Dispatch the PDUs to applications
        switch (destinationPort) {
        if (portAddrs != null) {
        case SmsHeader.PORT_WAP_PUSH: {
            if (portAddrs.destPort == SmsHeader.PORT_WAP_PUSH) {
                // Build up the data stream
                // Build up the data stream
                ByteArrayOutputStream output = new ByteArrayOutputStream();
                ByteArrayOutputStream output = new ByteArrayOutputStream();
            for (int i = 0; i < count; i++) {
                for (int i = 0; i < concatRef.msgCount; i++) {
                    SmsMessage msg = SmsMessage.createFromPdu(pdus[i]);
                    SmsMessage msg = SmsMessage.createFromPdu(pdus[i]);
                    byte[] data = msg.getUserData();
                    byte[] data = msg.getUserData();
                    output.write(data, 0, data.length);
                    output.write(data, 0, data.length);
                }
                }

                // Handle the PUSH
                // Handle the PUSH
                mWapPush.dispatchWapPdu(output.toByteArray());
                mWapPush.dispatchWapPdu(output.toByteArray());
            break;
            } else {
                // The messages were sent to a port, so concoct a URI for it
                dispatchPortAddressedPdus(pdus, portAddrs.destPort);
            }
            }

        } else {
        case -1:
            // The messages were not sent to a port
            // The messages were not sent to a port
            dispatchPdus(pdus);
            dispatchPdus(pdus);
            break;

        default:
            // The messages were sent to a port, so concoct a URI for it
            dispatchPortAddressedPdus(pdus, destinationPort);
            break;
        }
        }
    }
    }


+194 −188

File changed.

Preview size limit exceeded, changes collapsed.

Loading