public abstract class InboundSmsHandler extends StateMachine
The state machine starts in IdleState
state. When the SMSDispatcher
receives a
new SMS from the radio, it calls dispatchNormalMessage(com.android.internal.telephony.SmsMessageBase)
,
which sends a message to the state machine, causing the wakelock to be acquired in
StateMachine.haltedProcessMessage(android.os.Message)
, which transitions to DeliveringState
state, where the message
is saved to the raw table, then acknowledged via the SMSDispatcher
which called us.
After saving the SMS, if the message is complete (either single-part or the final segment
of a multi-part SMS), we broadcast the completed PDUs as an ordered broadcast, then transition to
WaitingState
state to wait for the broadcast to complete. When the local
BroadcastReceiver
is called with the result, it sends EVENT_BROADCAST_COMPLETE
to the state machine, causing us to either broadcast the next pending message (if one has
arrived while waiting for the broadcast to complete), or to transition back to the halted state
after all messages are processed. Then the wakelock is released and we wait for the next SMS.
StateMachine.LogRec
Modifier and Type | Field and Description |
---|---|
static int |
ADDRESS_COLUMN |
static int |
COUNT_COLUMN |
static int |
DATE_COLUMN |
protected static boolean |
DBG |
static int |
DESTINATION_PORT_COLUMN |
static int |
EVENT_BROADCAST_SMS
Message type containing a
InboundSmsTracker ready to broadcast to listeners. |
static int |
EVENT_INJECT_SMS
New SMS received as an AsyncResult.
|
static int |
EVENT_NEW_SMS
New SMS received as an AsyncResult.
|
static int |
EVENT_START_ACCEPTING_SMS
Sent by
SmsBroadcastUndelivered after cleaning the raw table. |
static int |
ID_COLUMN |
protected CellBroadcastHandler |
mCellBroadcastHandler |
protected Context |
mContext |
static int |
MESSAGE_BODY_COLUMN |
protected Phone |
mPhone |
protected SmsStorageMonitor |
mStorageMonitor
Helper class to check whether storage is available for incoming messages.
|
static int |
PDU_COLUMN |
static int |
REFERENCE_NUMBER_COLUMN |
static String |
SELECT_BY_ID |
static String |
SELECT_BY_REFERENCE |
static int |
SEQUENCE_COLUMN |
protected static Uri |
sRawUri
URI for raw table of SMS provider.
|
protected static Uri |
sRawUriPermanentDelete |
HANDLED, NOT_HANDLED
Modifier | Constructor and Description |
---|---|
protected |
InboundSmsHandler(String name,
Context context,
SmsStorageMonitor storageMonitor,
Phone phone,
CellBroadcastHandler cellBroadcastHandler)
Create a new SMS broadcast helper.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
acknowledgeLastIncomingSms(boolean success,
int result,
Message response)
Send an acknowledge message to the SMSC.
|
protected int |
addTrackerToRawTableAndSendMessage(InboundSmsTracker tracker,
boolean deDup)
Helper to add the tracker to the raw table and then send a message to broadcast it, if
successful.
|
void |
dispatchIntent(Intent intent,
String permission,
int appOp,
Bundle opts,
BroadcastReceiver resultReceiver,
UserHandle user)
Dispatch the intent with the specified permission, appOp, and result receiver, using
this state machine's handler thread to run the result receiver.
|
protected abstract int |
dispatchMessageRadioSpecific(SmsMessageBase smsb)
Process voicemail notification, SMS-PP data download, CDMA CMAS, CDMA WAP push, and other
3GPP/3GPP2-specific messages.
|
protected int |
dispatchNormalMessage(SmsMessageBase sms)
Dispatch a normal incoming SMS.
|
void |
dispose()
Tell the state machine to quit after processing all messages.
|
Phone |
getPhone() |
PowerManager.WakeLock |
getWakeLock() |
int |
getWakeLockTimeout() |
protected abstract boolean |
is3gpp2()
Return true if this handler is for 3GPP2 messages; false for 3GPP format.
|
protected void |
log(String s)
Log with debug level.
|
protected void |
loge(String s)
Log with error level.
|
protected void |
loge(String s,
Throwable e)
Log with error level.
|
protected void |
onQuitting()
Dispose of the WAP push object and release the wakelock.
|
protected void |
onUpdatePhoneObject(Phone phone)
Called when the phone changes the default method updates mPhone
mStorageMonitor and mCellBroadcastHandler.updatePhoneObject.
|
void |
updatePhoneObject(Phone phone)
Update the phone object when it changes.
|
addLogRec, addState, addState, copyLogRecs, deferMessage, dump, getCurrentMessage, getCurrentState, getHandler, getLogRec, getLogRecCount, getLogRecSize, getLogRecString, getName, getWhatToString, haltedProcessMessage, hasDeferredMessages, hasMessages, isDbg, isQuit, logAndAddLogRec, logd, logi, logv, logw, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, onHalting, onPostHandleMessage, onPreHandleMessage, quit, quitNow, recordLogRec, removeDeferredMessages, removeMessages, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtFrontOfQueue, sendMessageAtFrontOfQueue, sendMessageAtFrontOfQueue, sendMessageAtFrontOfQueue, sendMessageAtFrontOfQueue, sendMessageDelayed, sendMessageDelayed, sendMessageDelayed, sendMessageDelayed, sendMessageDelayed, sendMessageDelayed, setDbg, setInitialState, setLogOnlyTransitions, setLogRecSize, start, toString, transitionTo, transitionToHaltingState, unhandledMessage
protected static final boolean DBG
public static final int PDU_COLUMN
public static final int SEQUENCE_COLUMN
public static final int DESTINATION_PORT_COLUMN
public static final int DATE_COLUMN
public static final int REFERENCE_NUMBER_COLUMN
public static final int COUNT_COLUMN
public static final int ADDRESS_COLUMN
public static final int ID_COLUMN
public static final int MESSAGE_BODY_COLUMN
public static final String SELECT_BY_ID
public static final String SELECT_BY_REFERENCE
public static final int EVENT_NEW_SMS
public static final int EVENT_BROADCAST_SMS
InboundSmsTracker
ready to broadcast to listeners.public static final int EVENT_START_ACCEPTING_SMS
SmsBroadcastUndelivered
after cleaning the raw table.public static final int EVENT_INJECT_SMS
protected static final Uri sRawUri
protected static final Uri sRawUriPermanentDelete
protected final Context mContext
protected SmsStorageMonitor mStorageMonitor
protected Phone mPhone
protected CellBroadcastHandler mCellBroadcastHandler
protected InboundSmsHandler(String name, Context context, SmsStorageMonitor storageMonitor, Phone phone, CellBroadcastHandler cellBroadcastHandler)
name
- the class name for loggingcontext
- the context of the phone appstorageMonitor
- the SmsStorageMonitor to check for storage availabilitypublic void dispose()
public void updatePhoneObject(Phone phone)
protected void onQuitting()
onQuitting
in class StateMachine
public Phone getPhone()
protected abstract int dispatchMessageRadioSpecific(SmsMessageBase smsb)
dispatchNormalMessage(com.android.internal.telephony.SmsMessageBase)
from this class.smsb
- the SmsMessageBase object from the RILTelephony.Sms.Intents
,
or Activity.RESULT_OK
for delayed acknowledgment to SMSCprotected abstract void acknowledgeLastIncomingSms(boolean success, int result, Message response)
success
- indicates that last message was successfully received.result
- result code indicating any errorresponse
- callback message sent when operation completes.protected void onUpdatePhoneObject(Phone phone)
phone
- protected abstract boolean is3gpp2()
protected int dispatchNormalMessage(SmsMessageBase sms)
dispatchMessageRadioSpecific(com.android.internal.telephony.SmsMessageBase)
if no format-specific handling was required. Saves the PDU to the SMS provider raw table,
creates an InboundSmsTracker
, then sends it to the state machine as an
EVENT_BROADCAST_SMS
. Returns Telephony.Sms.Intents.RESULT_SMS_HANDLED
or an error value.sms
- the message to dispatchTelephony.Sms.Intents.RESULT_SMS_HANDLED
if the message was accepted, or an error statusprotected int addTrackerToRawTableAndSendMessage(InboundSmsTracker tracker, boolean deDup)
tracker
- the tracker to save to the raw table and then deliverTelephony.Sms.Intents.RESULT_SMS_HANDLED
or Telephony.Sms.Intents.RESULT_SMS_GENERIC_ERROR
or Telephony.Sms.Intents.RESULT_SMS_DUPLICATED
public void dispatchIntent(Intent intent, String permission, int appOp, Bundle opts, BroadcastReceiver resultReceiver, UserHandle user)
intent
- the intent to broadcastpermission
- receivers are required to have this permissionappOp
- app op that is being performed when dispatching to a receiveruser
- user to deliver the intent toprotected void log(String s)
log
in class StateMachine
s
- the string to logprotected void loge(String s)
loge
in class StateMachine
s
- the string to logprotected void loge(String s, Throwable e)
loge
in class StateMachine
s
- the string to loge
- is a Throwable which logs additional information.public PowerManager.WakeLock getWakeLock()
public int getWakeLockTimeout()