public abstract class SMSDispatcher extends Handler
Modifier and Type | Class and Description |
---|---|
protected class |
SMSDispatcher.DataSmsSender
Use the carrier messaging service to send a data SMS.
|
protected class |
SMSDispatcher.SmsSender
Use the carrier messaging service to send a data or text SMS.
|
protected class |
SMSDispatcher.SmsSenderCallback
Callback for TextSmsSender and DataSmsSender from the carrier messaging service.
|
static class |
SMSDispatcher.SmsTracker
Keeps track of an SMS that has been sent to the RIL, until it has
successfully been sent, or we're done trying.
|
protected class |
SMSDispatcher.TextSmsSender
Use the carrier messaging service to send a text SMS.
|
Handler.Callback
Modifier and Type | Field and Description |
---|---|
protected ArrayList<SMSDispatcher.SmsTracker> |
deliveryPendingList
Sent messages awaiting a delivery status report.
|
protected static int |
EVENT_HANDLE_STATUS_REPORT
Handle status report from
CdmaInboundSmsHandler . |
protected static int |
EVENT_ICC_CHANGED |
protected static int |
EVENT_IMS_STATE_CHANGED
IMS registration/SMS format changed
|
protected static int |
EVENT_IMS_STATE_DONE
Callback from RIL_REQUEST_IMS_REGISTRATION_STATE
|
protected static int |
EVENT_NEW_ICC_SMS |
protected static int |
EVENT_RADIO_ON
Radio is ON
|
protected static int |
EVENT_SEND_SMS_COMPLETE
SMS send complete.
|
protected CommandsInterface |
mCi |
protected Context |
mContext |
protected Phone |
mPhone |
protected ContentResolver |
mResolver |
protected boolean |
mSmsCapable |
protected boolean |
mSmsSendDisabled |
protected TelephonyManager |
mTelephonyManager |
Modifier | Constructor and Description |
---|---|
protected |
SMSDispatcher(Phone phone,
SmsUsageMonitor usageMonitor,
ImsSMSDispatcher imsSMSDispatcher)
Create a new SMS dispatcher.
|
Modifier and Type | Method and Description |
---|---|
protected abstract GsmAlphabet.TextEncodingDetails |
calculateLength(CharSequence messageBody,
boolean use7bitOnly)
Calculate the number of septets needed to encode the message.
|
void |
dispose()
Unregister for incoming SMS events.
|
protected String |
getCarrierAppPackageName() |
protected abstract String |
getFormat()
The format of the message PDU in the associated broadcast intent.
|
String |
getImsSmsFormat() |
protected abstract SMSDispatcher.SmsTracker |
getNewSubmitPduTracker(String destinationAddress,
String scAddress,
String message,
SmsHeader smsHeader,
int encoding,
PendingIntent sentIntent,
PendingIntent deliveryIntent,
boolean lastPart,
AtomicInteger unsentPartCount,
AtomicBoolean anyPartFailed,
Uri messageUri,
String fullMessageText)
Create a new SubmitPdu and return the SMS tracker.
|
protected static int |
getNextConcatenatedRef() |
protected static int |
getNotInServiceError(int ss) |
int |
getPremiumSmsPermission(String packageName)
Returns the premium SMS permission for the specified package.
|
protected SMSDispatcher.SmsTracker |
getSmsTracker(HashMap<String,Object> data,
PendingIntent sentIntent,
PendingIntent deliveryIntent,
String format,
AtomicInteger unsentPartCount,
AtomicBoolean anyPartFailed,
Uri messageUri,
SmsHeader smsHeader,
boolean isExpectMore,
String fullMessageText,
boolean isText,
boolean persistMessage) |
protected SMSDispatcher.SmsTracker |
getSmsTracker(HashMap<String,Object> data,
PendingIntent sentIntent,
PendingIntent deliveryIntent,
String format,
Uri messageUri,
boolean isExpectMore,
String fullMessageText,
boolean isText,
boolean persistMessage) |
protected HashMap<String,Object> |
getSmsTrackerMap(String destAddr,
String scAddr,
int destPort,
byte[] data,
SmsMessageBase.SubmitPduBase pdu) |
protected HashMap<String,Object> |
getSmsTrackerMap(String destAddr,
String scAddr,
String text,
SmsMessageBase.SubmitPduBase pdu) |
protected int |
getSubId() |
protected void |
handleConfirmShortCode(boolean isPremium,
SMSDispatcher.SmsTracker tracker)
Post an alert for user confirmation when sending to a potential short code.
|
void |
handleMessage(Message msg)
Handles events coming from the phone stack.
|
protected static void |
handleNotInService(int ss,
PendingIntent sentIntent)
Handles outbound message when the phone is not in service.
|
protected void |
handleReachSentLimit(SMSDispatcher.SmsTracker tracker)
Post an alert when SMS needs confirmation due to excessive usage.
|
protected void |
handleSendComplete(AsyncResult ar)
Called when SMS send completes.
|
protected void |
handleStatusReport(Object o)
Pass the Message object to subclass to handle.
|
protected abstract void |
injectSmsPdu(byte[] pdu,
String format,
PendingIntent receivedIntent)
Inject an SMS PDU into the android platform.
|
boolean |
isIms() |
protected abstract void |
sendData(String destAddr,
String scAddr,
int destPort,
byte[] data,
PendingIntent sentIntent,
PendingIntent deliveryIntent)
Send a data based SMS to a specific application port.
|
protected void |
sendMultipartText(String destAddr,
String scAddr,
ArrayList<String> parts,
ArrayList<PendingIntent> sentIntents,
ArrayList<PendingIntent> deliveryIntents,
Uri messageUri,
String callingPkg,
boolean persistMessage)
Send a multi-part text based SMS.
|
protected void |
sendRawPdu(SMSDispatcher.SmsTracker tracker)
Send an SMS
|
void |
sendRetrySms(SMSDispatcher.SmsTracker tracker)
Retry the message along to the radio.
|
protected abstract void |
sendSms(SMSDispatcher.SmsTracker tracker)
Send the message along to the radio.
|
protected abstract void |
sendSmsByPstn(SMSDispatcher.SmsTracker tracker)
Send the SMS via the PSTN network.
|
protected abstract void |
sendSubmitPdu(SMSDispatcher.SmsTracker tracker)
Send an SMS PDU.
|
protected abstract void |
sendText(String destAddr,
String scAddr,
String text,
PendingIntent sentIntent,
PendingIntent deliveryIntent,
Uri messageUri,
String callingPkg,
boolean persistMessage)
Send a text based SMS.
|
void |
setPremiumSmsPermission(String packageName,
int permission)
Sets the premium SMS permission for the specified package and save the value asynchronously
to persistent storage.
|
protected void |
updatePhoneObject(Phone phone) |
dispatchMessage, dump, getLooper, getMessageName, getTraceName, hasCallbacks, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, runWithScissors, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
protected static final int EVENT_SEND_SMS_COMPLETE
protected static final int EVENT_HANDLE_STATUS_REPORT
CdmaInboundSmsHandler
.protected static final int EVENT_RADIO_ON
protected static final int EVENT_IMS_STATE_CHANGED
protected static final int EVENT_IMS_STATE_DONE
protected static final int EVENT_NEW_ICC_SMS
protected static final int EVENT_ICC_CHANGED
protected Phone mPhone
protected final Context mContext
protected final ContentResolver mResolver
protected final CommandsInterface mCi
protected final TelephonyManager mTelephonyManager
protected boolean mSmsCapable
protected boolean mSmsSendDisabled
protected final ArrayList<SMSDispatcher.SmsTracker> deliveryPendingList
protected SMSDispatcher(Phone phone, SmsUsageMonitor usageMonitor, ImsSMSDispatcher imsSMSDispatcher)
phone
- the Phone to useusageMonitor
- the SmsUsageMonitor to useprotected static int getNextConcatenatedRef()
protected void updatePhoneObject(Phone phone)
public void dispose()
protected abstract String getFormat()
SmsMessage
which take an
extra format parameter. This is required in order to correctly decode the PDU on
devices which require support for both 3GPP and 3GPP2 formats at the same time,
such as CDMA/LTE devices and GSM/CDMA world phones.protected void handleStatusReport(Object o)
CdmaInboundSmsHandler
.o
- the SmsMessage containing the status reportpublic void handleMessage(Message msg)
handleMessage
in class Handler
msg
- the message to handleprotected abstract void sendSubmitPdu(SMSDispatcher.SmsTracker tracker)
sendRawPdu
.protected void handleSendComplete(AsyncResult ar)
ar
- AsyncResult passed into the message handler. ar.result should
an SmsResponse instance if send was successful. ar.userObj
should be an SmsTracker instance.protected static void handleNotInService(int ss, PendingIntent sentIntent)
ss
- Current service state. Valid values are:
OUT_OF_SERVICE
EMERGENCY_ONLY
POWER_OFFsentIntent
- the PendingIntent to send the error toprotected static int getNotInServiceError(int ss)
ss
- service stateprotected abstract void sendData(String destAddr, String scAddr, int destPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
destAddr
- the address to send the message toscAddr
- is the service center address or null to use
the current default SMSCdestPort
- the port to deliver the message todata
- the body of the message to sendsentIntent
- if not NULL this PendingIntent
is
broadcast when the message is successfully sent, or failed.
The result code will be Activity.RESULT_OK for success,
or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_NO_SERVICE
.
For RESULT_ERROR_GENERIC_FAILURE
the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.
The per-application based SMS control checks sentIntent. If sentIntent
is NULL the caller will be checked against all unknown applications,
which cause smaller number of SMS to be sent in checking period.
deliveryIntent
- if not NULL this PendingIntent
is
broadcast when the message is delivered to the recipient. The
raw pdu of the status report is in the extended data ("pdu").protected abstract void sendText(String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, Uri messageUri, String callingPkg, boolean persistMessage)
destAddr
- the address to send the message toscAddr
- is the service center address or null to use
the current default SMSCtext
- the body of the message to sendsentIntent
- if not NULL this PendingIntent
is
broadcast when the message is successfully sent, or failed.
The result code will be Activity.RESULT_OK for success,
or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_NO_SERVICE
.
For RESULT_ERROR_GENERIC_FAILURE
the sentIntent may include
the extra "errorCode" containing a radio technology specific value,
generally only useful for troubleshooting.
The per-application based SMS control checks sentIntent. If sentIntent
is NULL the caller will be checked against all unknown applications,
which cause smaller number of SMS to be sent in checking period.
deliveryIntent
- if not NULL this PendingIntent
is
broadcast when the message is delivered to the recipient. ThemessageUri
- optional URI of the message if it is already stored in the systemcallingPkg
- the calling package namepersistMessage
- whether to save the sent message into SMS DB for a
non-default SMS app.protected abstract void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent)
pdu
- is the byte array of pdu to be injected into android telephony layerformat
- is the format of SMS pdu (3gpp or 3gpp2)receivedIntent
- if not NULL this PendingIntent
is
broadcast when the message is successfully received by the
android telephony layer. This intent is broadcasted at
the same time an SMS received from radio is responded back.protected abstract GsmAlphabet.TextEncodingDetails calculateLength(CharSequence messageBody, boolean use7bitOnly)
messageBody
- the message to encodeuse7bitOnly
- ignore (but still count) illegal characters if trueprotected void sendMultipartText(String destAddr, String scAddr, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents, Uri messageUri, String callingPkg, boolean persistMessage)
destAddr
- the address to send the message toscAddr
- is the service center address or null to use
the current default SMSCparts
- an ArrayList
of strings that, in order,
comprise the original messagesentIntents
- if not null, an ArrayList
of
PendingIntent
s (one for each message part) that is
broadcast when the corresponding message part has been sent.
The result code will be Activity.RESULT_OK for success,
or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_NO_SERVICE
.
The per-application based SMS control checks sentIntent. If sentIntent
is NULL the caller will be checked against all unknown applications,
which cause smaller number of SMS to be sent in checking period.
deliveryIntents
- if not null, an ArrayList
of
PendingIntent
s (one for each message part) that is
broadcast when the corresponding message part has been delivered
to the recipient. The raw pdu of the status report is in themessageUri
- optional URI of the message if it is already stored in the systemcallingPkg
- the calling package namepersistMessage
- whether to save the sent message into SMS DB for a
non-default SMS app.protected abstract SMSDispatcher.SmsTracker getNewSubmitPduTracker(String destinationAddress, String scAddress, String message, SmsHeader smsHeader, int encoding, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean lastPart, AtomicInteger unsentPartCount, AtomicBoolean anyPartFailed, Uri messageUri, String fullMessageText)
protected void sendRawPdu(SMSDispatcher.SmsTracker tracker)
tracker
- will contain:
-smsc the SMSC to send the message through, or NULL for the
default SMSC
-pdu the raw PDU to send
-sentIntent if not NULL this Intent
is
broadcast when the message is successfully sent, or failed.
The result code will be Activity.RESULT_OK for success,
or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
RESULT_ERROR_NO_SERVICE
.
The per-application based SMS control checks sentIntent. If sentIntent
is NULL the caller will be checked against all unknown applications,
which cause smaller number of SMS to be sent in checking period.
-deliveryIntent if not NULL this Intent
is
broadcast when the message is delivered to the recipient. The
raw pdu of the status report is in the extended data ("pdu").
-param destAddr the destination phone number (for short code confirmation)
protected void handleReachSentLimit(SMSDispatcher.SmsTracker tracker)
tracker
- an SmsTracker for the current message.protected void handleConfirmShortCode(boolean isPremium, SMSDispatcher.SmsTracker tracker)
isPremium
- true if the destination is known to be a premium short codetracker
- the SmsTracker for the current message.public int getPremiumSmsPermission(String packageName)
SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER
will be returned.packageName
- the name of the package to query permissionSmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN
,
SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER
,
SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW
, or
SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW
public void setPremiumSmsPermission(String packageName, int permission)
packageName
- the name of the package to set permissionpermission
- one of SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER
,
SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW
, or
SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW
protected abstract void sendSms(SMSDispatcher.SmsTracker tracker)
tracker
- holds the SMS message to sendprotected abstract void sendSmsByPstn(SMSDispatcher.SmsTracker tracker)
tracker
- holds the Sms tracker ready to be sentpublic void sendRetrySms(SMSDispatcher.SmsTracker tracker)
tracker
- holds the SMS message to sendprotected SMSDispatcher.SmsTracker getSmsTracker(HashMap<String,Object> data, PendingIntent sentIntent, PendingIntent deliveryIntent, String format, AtomicInteger unsentPartCount, AtomicBoolean anyPartFailed, Uri messageUri, SmsHeader smsHeader, boolean isExpectMore, String fullMessageText, boolean isText, boolean persistMessage)
protected SMSDispatcher.SmsTracker getSmsTracker(HashMap<String,Object> data, PendingIntent sentIntent, PendingIntent deliveryIntent, String format, Uri messageUri, boolean isExpectMore, String fullMessageText, boolean isText, boolean persistMessage)
protected HashMap<String,Object> getSmsTrackerMap(String destAddr, String scAddr, String text, SmsMessageBase.SubmitPduBase pdu)
protected HashMap<String,Object> getSmsTrackerMap(String destAddr, String scAddr, int destPort, byte[] data, SmsMessageBase.SubmitPduBase pdu)
public boolean isIms()
public String getImsSmsFormat()
protected String getCarrierAppPackageName()
protected int getSubId()