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

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

am 24a4f20c: Merge change 5239 into donut

Merge commit '24a4f20c'

* commit '24a4f20c':
  Fix SMS Ack.
parents cf946df3 24a4f20c
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -1365,7 +1365,6 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        RILRequest rr
        RILRequest rr
                = RILRequest.obtain(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, result);
                = RILRequest.obtain(RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, result);


        rr.mp.writeInt(2);
        rr.mp.writeInt(success ? 0 : 1); //RIL_CDMA_SMS_ErrorClass
        rr.mp.writeInt(success ? 0 : 1); //RIL_CDMA_SMS_ErrorClass
        // cause code according to X.S004-550E
        // cause code according to X.S004-550E
        rr.mp.writeInt(cause);
        rr.mp.writeInt(cause);
+19 −8
Original line number Original line Diff line number Diff line
@@ -289,7 +289,13 @@ public abstract class SMSDispatcher extends Handler {
            sms = (SmsMessage) ar.result;
            sms = (SmsMessage) ar.result;
            try {
            try {
                if (mStorageAvailable) {
                if (mStorageAvailable) {
                    dispatchMessage(sms.mWrappedSmsMessage);
                    int result = dispatchMessage(sms.mWrappedSmsMessage);
                    if (result != Activity.RESULT_OK) {
                        // RESULT_OK means that message was broadcast for app(s) to handle.
                        // Any other result, we should ack here.
                        boolean handled = (result == Intents.RESULT_SMS_HANDLED);
                        acknowledgeLastIncomingSms(handled, result, null);
                    }
                } else {
                } else {
                    acknowledgeLastIncomingSms(false, Intents.RESULT_SMS_OUT_OF_MEMORY, null);
                    acknowledgeLastIncomingSms(false, Intents.RESULT_SMS_OUT_OF_MEMORY, null);
                }
                }
@@ -469,8 +475,11 @@ public abstract class SMSDispatcher extends Handler {
     * Dispatches an incoming SMS messages.
     * Dispatches an incoming SMS messages.
     *
     *
     * @param sms the incoming message from the phone
     * @param sms the incoming message from the phone
     * @return a result code from {@link Telephony.Sms.Intents}, or
     *         {@link Activity#RESULT_OK} if the message has been broadcast
     *         to applications
     */
     */
    protected abstract void dispatchMessage(SmsMessageBase sms);
    protected abstract int dispatchMessage(SmsMessageBase sms);




    /**
    /**
@@ -478,8 +487,11 @@ public abstract class SMSDispatcher extends Handler {
     * 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.
     * NOTE: concatRef (naturally) needs to be non-null, but portAddrs can be null.
     * @return a result code from {@link Telephony.Sms.Intents}, or
     *         {@link Activity#RESULT_OK} if the message has been broadcast
     *         to applications
     */
     */
    protected void processMessagePart(SmsMessageBase sms,
    protected int processMessagePart(SmsMessageBase sms,
            SmsHeader.ConcatRef concatRef, SmsHeader.PortAddrs portAddrs) {
            SmsHeader.ConcatRef concatRef, SmsHeader.PortAddrs portAddrs) {


        // Lookup all other related parts
        // Lookup all other related parts
@@ -506,8 +518,7 @@ public abstract class SMSDispatcher extends Handler {
                    values.put("destination_port", portAddrs.destPort);
                    values.put("destination_port", portAddrs.destPort);
                }
                }
                mResolver.insert(mRawUri, values);
                mResolver.insert(mRawUri, values);
                acknowledgeLastIncomingSms(true, Intents.RESULT_SMS_HANDLED, null);
                return Intents.RESULT_SMS_HANDLED;
                return;
            }
            }


            // All the parts are in place, deal with them
            // All the parts are in place, deal with them
@@ -529,8 +540,7 @@ public abstract class SMSDispatcher extends Handler {
        } catch (SQLException e) {
        } catch (SQLException e) {
            Log.e(TAG, "Can't access multipart SMS database", e);
            Log.e(TAG, "Can't access multipart SMS database", e);
            // TODO:  Would OUT_OF_MEMORY be more appropriate?
            // TODO:  Would OUT_OF_MEMORY be more appropriate?
            acknowledgeLastIncomingSms(false, Intents.RESULT_SMS_GENERIC_ERROR, null);
            return Intents.RESULT_SMS_GENERIC_ERROR;
            return;
        } finally {
        } finally {
            if (cursor != null) cursor.close();
            if (cursor != null) cursor.close();
        }
        }
@@ -555,7 +565,7 @@ public abstract class SMSDispatcher extends Handler {
                    output.write(data, 0, data.length);
                    output.write(data, 0, data.length);
                }
                }
                // Handle the PUSH
                // Handle the PUSH
                mWapPush.dispatchWapPdu(output.toByteArray());
                return mWapPush.dispatchWapPdu(output.toByteArray());
            } else {
            } else {
                // The messages were sent to a port, so concoct a URI for it
                // The messages were sent to a port, so concoct a URI for it
                dispatchPortAddressedPdus(pdus, portAddrs.destPort);
                dispatchPortAddressedPdus(pdus, portAddrs.destPort);
@@ -564,6 +574,7 @@ public abstract class SMSDispatcher extends Handler {
            // The messages were not sent to a port
            // The messages were not sent to a port
            dispatchPdus(pdus);
            dispatchPdus(pdus);
        }
        }
        return Activity.RESULT_OK;
    }
    }


    /**
    /**
+12 −6
Original line number Original line Diff line number Diff line
@@ -16,8 +16,10 @@


package com.android.internal.telephony;
package com.android.internal.telephony;


import android.app.Activity;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
import android.provider.Telephony.Sms.Intents;
import android.util.Config;
import android.util.Config;
import android.util.Log;
import android.util.Log;
@@ -51,8 +53,11 @@ public class WapPushOverSms {
     * wap-230-wsp-20010705-a section 8 for details on the WAP PDU format.
     * wap-230-wsp-20010705-a section 8 for details on the WAP PDU format.
     *
     *
     * @param pdu The WAP PDU, made up of one or more SMS PDUs
     * @param pdu The WAP PDU, made up of one or more SMS PDUs
     * @return a result code from {@link Telephony.Sms.Intents}, or
     *         {@link Activity#RESULT_OK} if the message has been broadcast
     *         to applications
     */
     */
    public void dispatchWapPdu(byte[] pdu) {
    public int dispatchWapPdu(byte[] pdu) {


        if (Config.LOGD) Log.d(LOG_TAG, "Rx: " + IccUtils.bytesToHexString(pdu));
        if (Config.LOGD) Log.d(LOG_TAG, "Rx: " + IccUtils.bytesToHexString(pdu));


@@ -64,7 +69,7 @@ public class WapPushOverSms {
        if ((pduType != WspTypeDecoder.PDU_TYPE_PUSH) &&
        if ((pduType != WspTypeDecoder.PDU_TYPE_PUSH) &&
                (pduType != WspTypeDecoder.PDU_TYPE_CONFIRMED_PUSH)) {
                (pduType != WspTypeDecoder.PDU_TYPE_CONFIRMED_PUSH)) {
            if (Config.LOGD) Log.w(LOG_TAG, "Received non-PUSH WAP PDU. Type = " + pduType);
            if (Config.LOGD) Log.w(LOG_TAG, "Received non-PUSH WAP PDU. Type = " + pduType);
            return;
            return Intents.RESULT_SMS_HANDLED;
        }
        }


        pduDecoder = new WspTypeDecoder(pdu);
        pduDecoder = new WspTypeDecoder(pdu);
@@ -77,7 +82,7 @@ public class WapPushOverSms {
         */
         */
        if (pduDecoder.decodeUintvarInteger(index) == false) {
        if (pduDecoder.decodeUintvarInteger(index) == false) {
            if (Config.LOGD) Log.w(LOG_TAG, "Received PDU. Header Length error.");
            if (Config.LOGD) Log.w(LOG_TAG, "Received PDU. Header Length error.");
            return;
            return Intents.RESULT_SMS_GENERIC_ERROR;
        }
        }
        headerLength = (int)pduDecoder.getValue32();
        headerLength = (int)pduDecoder.getValue32();
        index += pduDecoder.getDecodedDataLength();
        index += pduDecoder.getDecodedDataLength();
@@ -98,7 +103,7 @@ public class WapPushOverSms {
         */
         */
        if (pduDecoder.decodeContentType(index) == false) {
        if (pduDecoder.decodeContentType(index) == false) {
            if (Config.LOGD) Log.w(LOG_TAG, "Received PDU. Header Content-Type error.");
            if (Config.LOGD) Log.w(LOG_TAG, "Received PDU. Header Content-Type error.");
            return;
            return Intents.RESULT_SMS_GENERIC_ERROR;
        }
        }
        int binaryContentType;
        int binaryContentType;
        String mimeType = pduDecoder.getValueString();
        String mimeType = pduDecoder.getValueString();
@@ -128,7 +133,7 @@ public class WapPushOverSms {
                        Log.w(LOG_TAG,
                        Log.w(LOG_TAG,
                                "Received PDU. Unsupported Content-Type = " + binaryContentType);
                                "Received PDU. Unsupported Content-Type = " + binaryContentType);
                    }
                    }
                return;
                return Intents.RESULT_SMS_HANDLED;
            }
            }
        } else {
        } else {
            if (mimeType.equals(WspTypeDecoder.CONTENT_MIME_TYPE_B_DRM_RIGHTS_XML)) {
            if (mimeType.equals(WspTypeDecoder.CONTENT_MIME_TYPE_B_DRM_RIGHTS_XML)) {
@@ -145,7 +150,7 @@ public class WapPushOverSms {
                binaryContentType = WspTypeDecoder.CONTENT_TYPE_B_MMS;
                binaryContentType = WspTypeDecoder.CONTENT_TYPE_B_MMS;
            } else {
            } else {
                if (Config.LOGD) Log.w(LOG_TAG, "Received PDU. Unknown Content-Type = " + mimeType);
                if (Config.LOGD) Log.w(LOG_TAG, "Received PDU. Unknown Content-Type = " + mimeType);
                return;
                return Intents.RESULT_SMS_HANDLED;
            }
            }
        }
        }
        index += pduDecoder.getDecodedDataLength();
        index += pduDecoder.getDecodedDataLength();
@@ -167,6 +172,7 @@ public class WapPushOverSms {
        if (dispatchedByApplication == false) {
        if (dispatchedByApplication == false) {
            dispatchWapPdu_default(pdu, transactionId, pduType, mimeType, dataIndex);
            dispatchWapPdu_default(pdu, transactionId, pduType, mimeType, dataIndex);
        }
        }
        return Activity.RESULT_OK;
    }
    }


    private void dispatchWapPdu_default(
    private void dispatchWapPdu_default(
+25 −23
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.database.Cursor;
import android.database.SQLException;
import android.database.SQLException;
import android.os.AsyncResult;
import android.os.AsyncResult;
import android.os.Message;
import android.os.Message;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
import android.provider.Telephony.Sms.Intents;
import android.preference.PreferenceManager;
import android.preference.PreferenceManager;
import android.util.Config;
import android.util.Config;
@@ -66,17 +67,12 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
        Log.d(TAG, "handleStatusReport is a special GSM function, should never be called in CDMA!");
        Log.d(TAG, "handleStatusReport is a special GSM function, should never be called in CDMA!");
    }
    }


    /**
    /** {@inheritDoc} */
     * Dispatches an incoming SMS messages.
    protected int dispatchMessage(SmsMessageBase smsb) {
     *
     * @param smsb the incoming message from the phone
     */
    protected void dispatchMessage(SmsMessageBase smsb) {


        // If sms is null, means there was a parsing error.
        // If sms is null, means there was a parsing error.
        // TODO: Should NAK this.
        if (smsb == null) {
        if (smsb == null) {
            return;
            return Intents.RESULT_SMS_GENERIC_ERROR;
        }
        }


        // Decode BD stream and set sms variables.
        // Decode BD stream and set sms variables.
@@ -92,11 +88,13 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
            handled = true;
            handled = true;
        }
        }


        if (handled) return;
        if (handled) {
            return Intents.RESULT_SMS_HANDLED;
        }


        if (SmsEnvelope.TELESERVICE_WAP == teleService){
        if (SmsEnvelope.TELESERVICE_WAP == teleService){
            processCdmaWapPdu(sms.getUserData(), sms.messageRef, sms.getOriginatingAddress());
            return processCdmaWapPdu(sms.getUserData(), sms.messageRef,
            return;
                    sms.getOriginatingAddress());
        } else if (SmsEnvelope.TELESERVICE_VMN == teleService) {
        } else if (SmsEnvelope.TELESERVICE_VMN == teleService) {
            // handling Voicemail
            // handling Voicemail
            int voicemailCount = sms.getNumOfVoicemails();
            int voicemailCount = sms.getNumOfVoicemails();
@@ -108,7 +106,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
            editor.putInt(CDMAPhone.VM_COUNT_CDMA, voicemailCount);
            editor.putInt(CDMAPhone.VM_COUNT_CDMA, voicemailCount);
            editor.commit();
            editor.commit();
            ((CDMAPhone) mPhone).updateMessageWaitingIndicator(voicemailCount);
            ((CDMAPhone) mPhone).updateMessageWaitingIndicator(voicemailCount);
            return;
            return Intents.RESULT_SMS_HANDLED;
        }
        }


        /**
        /**
@@ -138,17 +136,19 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
            if (smsHeader != null && smsHeader.portAddrs != null) {
            if (smsHeader != null && smsHeader.portAddrs != null) {
                if (smsHeader.portAddrs.destPort == SmsHeader.PORT_WAP_PUSH) {
                if (smsHeader.portAddrs.destPort == SmsHeader.PORT_WAP_PUSH) {
                    // GSM-style WAP indication
                    // GSM-style WAP indication
                    mWapPush.dispatchWapPdu(sms.getUserData());
                    return mWapPush.dispatchWapPdu(sms.getUserData());
                }
                } else {
                    // The message was sent to a port, so concoct a URI for it.
                    // The message was sent to a port, so concoct a URI for it.
                    dispatchPortAddressedPdus(pdus, smsHeader.portAddrs.destPort);
                    dispatchPortAddressedPdus(pdus, smsHeader.portAddrs.destPort);
                }
            } else {
            } else {
                // Normal short and non-port-addressed message, dispatch it.
                // Normal short and non-port-addressed message, dispatch it.
                dispatchPdus(pdus);
                dispatchPdus(pdus);
            }
            }
            return Activity.RESULT_OK;
        } else {
        } else {
            // Process the message part.
            // Process the message part.
            processMessagePart(sms, smsHeader.concatRef, smsHeader.portAddrs);
            return processMessagePart(sms, smsHeader.concatRef, smsHeader.portAddrs);
        }
        }
    }
    }


@@ -158,8 +158,11 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
     * WDP segments are gathered until a datagram completes and gets dispatched.
     * WDP segments are gathered until a datagram completes and gets dispatched.
     *
     *
     * @param pdu The WAP-WDP PDU segment
     * @param pdu The WAP-WDP PDU segment
     * @return a result code from {@link Telephony.Sms.Intents}, or
     *         {@link Activity#RESULT_OK} if the message has been broadcast
     *         to applications
     */
     */
    protected void processCdmaWapPdu(byte[] pdu, int referenceNumber, String address) {
    protected int processCdmaWapPdu(byte[] pdu, int referenceNumber, String address) {
        int segment;
        int segment;
        int totalSegments;
        int totalSegments;
        int index = 0;
        int index = 0;
@@ -171,7 +174,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
        msgType = pdu[index++];
        msgType = pdu[index++];
        if (msgType != 0){
        if (msgType != 0){
            Log.w(TAG, "Received a WAP SMS which is not WDP. Discard.");
            Log.w(TAG, "Received a WAP SMS which is not WDP. Discard.");
            return;
            return Intents.RESULT_SMS_HANDLED;
        }
        }
        totalSegments = pdu[index++]; // >=1
        totalSegments = pdu[index++]; // >=1
        segment = pdu[index++]; // >=0
        segment = pdu[index++]; // >=0
@@ -210,7 +213,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {


                mResolver.insert(mRawUri, values);
                mResolver.insert(mRawUri, values);


                return;
                return Intents.RESULT_SMS_HANDLED;
            }
            }


            // All the parts are in place, deal with them
            // All the parts are in place, deal with them
@@ -230,7 +233,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
            mResolver.delete(mRawUri, where.toString(), whereArgs);
            mResolver.delete(mRawUri, where.toString(), whereArgs);
        } catch (SQLException e) {
        } catch (SQLException e) {
            Log.e(TAG, "Can't access multipart SMS database", e);
            Log.e(TAG, "Can't access multipart SMS database", e);
            return;  // TODO: NACK the message or something, don't just discard.
            return Intents.RESULT_SMS_GENERIC_ERROR;
        } finally {
        } finally {
            if (cursor != null) cursor.close();
            if (cursor != null) cursor.close();
        }
        }
@@ -250,15 +253,14 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
        switch (destinationPort) {
        switch (destinationPort) {
        case SmsHeader.PORT_WAP_PUSH:
        case SmsHeader.PORT_WAP_PUSH:
            // Handle the PUSH
            // Handle the PUSH
            mWapPush.dispatchWapPdu(datagram);
            return mWapPush.dispatchWapPdu(datagram);
            break;


        default:{
        default:{
            pdus = new byte[1][];
            pdus = new byte[1][];
            pdus[0] = datagram;
            pdus[0] = datagram;
            // The messages were sent to any other WAP port
            // The messages were sent to any other WAP port
            dispatchPortAddressedPdus(pdus, destinationPort);
            dispatchPortAddressedPdus(pdus, destinationPort);
            break;
            return Activity.RESULT_OK;
        }
        }
        }
        }
    }
    }
+13 −17
Original line number Original line Diff line number Diff line
@@ -78,24 +78,16 @@ final class GsmSMSDispatcher extends SMSDispatcher {
                }
                }
            }
            }
        }
        }

        acknowledgeLastIncomingSms(true, Intents.RESULT_SMS_HANDLED, null);
        if (mCm != null) {
            mCm.acknowledgeLastIncomingGsmSms(true, Intents.RESULT_SMS_HANDLED, null);
        }
    }
    }




    /**
    /** {@inheritDoc} */
     * Dispatches an incoming SMS messages.
    protected int dispatchMessage(SmsMessageBase smsb) {
     *
     * @param sms the incoming message from the phone
     */
    protected void dispatchMessage(SmsMessageBase smsb) {


        // If sms is null, means there was a parsing error.
        // If sms is null, means there was a parsing error.
        // TODO: Should NAK this.
        if (smsb == null) {
        if (smsb == null) {
            return;
            return Intents.RESULT_SMS_GENERIC_ERROR;
        }
        }
        SmsMessage sms = (SmsMessage) smsb;
        SmsMessage sms = (SmsMessage) smsb;
        boolean handled = false;
        boolean handled = false;
@@ -115,7 +107,9 @@ final class GsmSMSDispatcher extends SMSDispatcher {
            }
            }
        }
        }


        if (handled) return;
        if (handled) {
            return Intents.RESULT_SMS_HANDLED;
        }


        SmsHeader smsHeader = sms.getUserDataHeader();
        SmsHeader smsHeader = sms.getUserDataHeader();
         // See if message is partial or port addressed.
         // See if message is partial or port addressed.
@@ -126,17 +120,19 @@ final class GsmSMSDispatcher extends SMSDispatcher {


            if (smsHeader != null && smsHeader.portAddrs != null) {
            if (smsHeader != null && smsHeader.portAddrs != null) {
                if (smsHeader.portAddrs.destPort == SmsHeader.PORT_WAP_PUSH) {
                if (smsHeader.portAddrs.destPort == SmsHeader.PORT_WAP_PUSH) {
                    mWapPush.dispatchWapPdu(sms.getUserData());
                    return mWapPush.dispatchWapPdu(sms.getUserData());
                }
                } else {
                    // The message was sent to a port, so concoct a URI for it.
                    // The message was sent to a port, so concoct a URI for it.
                    dispatchPortAddressedPdus(pdus, smsHeader.portAddrs.destPort);
                    dispatchPortAddressedPdus(pdus, smsHeader.portAddrs.destPort);
                }
            } else {
            } else {
                // Normal short and non-port-addressed message, dispatch it.
                // Normal short and non-port-addressed message, dispatch it.
                dispatchPdus(pdus);
                dispatchPdus(pdus);
            }
            }
            return Activity.RESULT_OK;
        } else {
        } else {
            // Process the message part.
            // Process the message part.
            processMessagePart(sms, smsHeader.concatRef, smsHeader.portAddrs);
            return processMessagePart(sms, smsHeader.concatRef, smsHeader.portAddrs);
        }
        }
    }
    }