FileDocCategorySizeDatePackage
GsmInboundSmsHandler.javaAPI DocAndroid 5.1 API7965Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.gsm

GsmInboundSmsHandler

public class GsmInboundSmsHandler extends com.android.internal.telephony.InboundSmsHandler
This class broadcasts incoming SMS messages to interested apps after storing them in the SmsProvider "raw" table and ACKing them to the SMSC. After each message has been

Fields Summary
private final UsimDataDownloadHandler
mDataDownloadHandler
Handler for SMS-PP data download messages to UICC.
Constructors Summary
private GsmInboundSmsHandler(android.content.Context context, com.android.internal.telephony.SmsStorageMonitor storageMonitor, com.android.internal.telephony.PhoneBase phone)
Create a new GSM inbound SMS handler.

        super("GsmInboundSmsHandler", context, storageMonitor, phone,
                GsmCellBroadcastHandler.makeGsmCellBroadcastHandler(context, phone));
        phone.mCi.setOnNewGsmSms(getHandler(), EVENT_NEW_SMS, null);
        mDataDownloadHandler = new UsimDataDownloadHandler(phone.mCi);
    
Methods Summary
protected voidacknowledgeLastIncomingSms(boolean success, int result, android.os.Message response)
Send an acknowledge message.

param
success indicates that last message was successfully received.
param
result result code indicating any error
param
response callback message sent when operation completes.

        mPhone.mCi.acknowledgeLastIncomingGsmSms(success, resultToCause(result), response);
    
protected intdispatchMessageRadioSpecific(com.android.internal.telephony.SmsMessageBase smsb)
Handle type zero, SMS-PP data download, and 3GPP/CPHS MWI type SMS. Normal SMS messages are handled by {@link #dispatchNormalMessage} in parent class.

param
smsb the SmsMessageBase object from the RIL
return
a result code from {@link android.provider.Telephony.Sms.Intents}, or {@link Activity#RESULT_OK} for delayed acknowledgment to SMSC

        SmsMessage sms = (SmsMessage) smsb;

        if (sms.isTypeZero()) {
            // As per 3GPP TS 23.040 9.2.3.9, Type Zero messages should not be
            // Displayed/Stored/Notified. They should only be acknowledged.
            log("Received short message type 0, Don't display or store it. Send Ack");
            return Intents.RESULT_SMS_HANDLED;
        }

        // Send SMS-PP data download messages to UICC. See 3GPP TS 31.111 section 7.1.1.
        if (sms.isUsimDataDownload()) {
            UsimServiceTable ust = mPhone.getUsimServiceTable();
            return mDataDownloadHandler.handleUsimDataDownload(ust, sms);
        }

        boolean handled = false;
        if (sms.isMWISetMessage()) {
            updateMessageWaitingIndicator(sms.getNumOfVoicemails());
            handled = sms.isMwiDontStore();
            if (DBG) log("Received voice mail indicator set SMS shouldStore=" + !handled);
        } else if (sms.isMWIClearMessage()) {
            updateMessageWaitingIndicator(0);
            handled = sms.isMwiDontStore();
            if (DBG) log("Received voice mail indicator clear SMS shouldStore=" + !handled);
        }
        if (handled) {
            return Intents.RESULT_SMS_HANDLED;
        }

        if (!mStorageMonitor.isStorageAvailable() &&
                sms.getMessageClass() != SmsConstants.MessageClass.CLASS_0) {
            // It's a storable message and there's no storage available.  Bail.
            // (See TS 23.038 for a description of class 0 messages.)
            return Intents.RESULT_SMS_OUT_OF_MEMORY;
        }

        return dispatchNormalMessage(smsb);
    
protected booleanis3gpp2()
Return true if this handler is for 3GPP2 messages; false for 3GPP format.

return
false (3GPP)

        return false;
    
public static com.android.internal.telephony.gsm.GsmInboundSmsHandlermakeInboundSmsHandler(android.content.Context context, com.android.internal.telephony.SmsStorageMonitor storageMonitor, com.android.internal.telephony.PhoneBase phone)
Wait for state machine to enter startup state. We can't send any messages until then.

        GsmInboundSmsHandler handler = new GsmInboundSmsHandler(context, storageMonitor, phone);
        handler.start();
        return handler;
    
protected voidonQuitting()
Unregister for GSM SMS.

        mPhone.mCi.unSetOnNewGsmSms(getHandler());
        mCellBroadcastHandler.dispose();

        if (DBG) log("unregistered for 3GPP SMS");
        super.onQuitting();     // release wakelock
    
protected voidonUpdatePhoneObject(com.android.internal.telephony.PhoneBase phone)
Called when the phone changes the default method updates mPhone mStorageMonitor and mCellBroadcastHandler.updatePhoneObject. Override if different or other behavior is desired.

param
phone

        super.onUpdatePhoneObject(phone);
        log("onUpdatePhoneObject: dispose of old CellBroadcastHandler and make a new one");
        mCellBroadcastHandler.dispose();
        mCellBroadcastHandler = GsmCellBroadcastHandler
                .makeGsmCellBroadcastHandler(mContext, phone);
    
private static intresultToCause(int rc)
Convert Android result code to 3GPP SMS failure cause.

param
rc the Android SMS intent result value
return
0 for success, or a 3GPP SMS failure cause value

        switch (rc) {
            case Activity.RESULT_OK:
            case Intents.RESULT_SMS_HANDLED:
                // Cause code is ignored on success.
                return 0;
            case Intents.RESULT_SMS_OUT_OF_MEMORY:
                return CommandsInterface.GSM_SMS_FAIL_CAUSE_MEMORY_CAPACITY_EXCEEDED;
            case Intents.RESULT_SMS_GENERIC_ERROR:
            default:
                return CommandsInterface.GSM_SMS_FAIL_CAUSE_UNSPECIFIED_ERROR;
        }
    
voidupdateMessageWaitingIndicator(int voicemailCount)

        // range check
        if (voicemailCount < 0) {
            voicemailCount = -1;
        } else if (voicemailCount > 0xff) {
            // TS 23.040 9.2.3.24.2
            // "The value 255 shall be taken to mean 255 or greater"
            voicemailCount = 0xff;
        }
        // update voice mail count in GsmPhone
        mPhone.setVoiceMessageCount(voicemailCount);
        // store voice mail count in SIM & shared preferences
        IccRecords records = UiccController.getInstance().getIccRecords(
                mPhone.getPhoneId(), UiccController.APP_FAM_3GPP);
        if (records != null) {
            log("updateMessageWaitingIndicator: updating SIM Records");
            records.setVoiceMessageWaiting(1, voicemailCount);
        } else {
            log("updateMessageWaitingIndicator: SIM Records not found");
        }
        storeVoiceMailCount();