Transactionpublic abstract class Transaction extends Observable Transaction is an abstract class for notification transaction, send transaction
and other transactions described in MMS spec.
It provides the interfaces of them and some common methods for them. |
Fields Summary |
---|
private final int | mServiceId | protected android.content.Context | mContext | protected String | mId | protected TransactionState | mTransactionState | protected TransactionSettings | mTransactionSettings | public static final int | NOTIFICATION_TRANSACTIONIdentifies push requests. | public static final int | RETRIEVE_TRANSACTIONIdentifies deferred retrieve requests. | public static final int | SEND_TRANSACTIONIdentifies send multimedia message requests. | public static final int | READREC_TRANSACTIONIdentifies send read report requests. |
Constructors Summary |
---|
public Transaction(android.content.Context context, int serviceId, TransactionSettings settings)
mContext = context;
mTransactionState = new TransactionState();
mServiceId = serviceId;
mTransactionSettings = settings;
|
Methods Summary |
---|
private void | ensureRouteToHost(java.lang.String url, TransactionSettings settings)Make sure that a network route exists to allow us to reach the host in the
supplied URL, and to the MMS proxy host as well, if a proxy is used.
ConnectivityManager connMgr =
(ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
int inetAddr;
if (settings.isProxySet()) {
String proxyAddr = settings.getProxyAddress();
inetAddr = NetworkUtils.lookupHost(proxyAddr);
if (inetAddr == -1) {
throw new IOException("Cannot establish route for " + url + ": Unknown host");
} else {
if (!connMgr.requestRouteToHost(ConnectivityManager.TYPE_MOBILE, inetAddr)) {
throw new IOException("Cannot establish route to proxy " + inetAddr);
}
}
} else {
Uri uri = Uri.parse(url);
inetAddr = NetworkUtils.lookupHost(uri.getHost());
if (inetAddr == -1) {
throw new IOException("Cannot establish route for " + url + ": Unknown host");
} else {
if (!connMgr.requestRouteToHost(ConnectivityManager.TYPE_MOBILE, inetAddr)) {
throw new IOException("Cannot establish route to " + inetAddr + " for " + url);
}
}
}
| public TransactionSettings | getConnectionSettings()
return mTransactionSettings;
| protected byte[] | getPdu(java.lang.String url)A common method to retrieve a PDU from MMSC.
ensureRouteToHost(url, mTransactionSettings);
return HttpUtils.httpConnection(
mContext, SendingProgressTokenManager.NO_TOKEN,
url, null, HttpUtils.HTTP_GET_METHOD,
mTransactionSettings.isProxySet(),
mTransactionSettings.getProxyAddress(),
mTransactionSettings.getProxyPort());
| public int | getServiceId()Get the service-id of this transaction which was assigned by the framework.
return mServiceId;
| public TransactionState | getState()Returns the transaction state of this transaction.
return mTransactionState;
| public abstract int | getType()Get the type of the transaction.
| public boolean | isEquivalent(com.android.mms.transaction.Transaction transaction)Used to determine whether a transaction is equivalent to this instance.
return getClass().equals(transaction.getClass())
&& mId.equals(transaction.mId);
| public abstract void | process()An instance of Transaction encapsulates the actions required
during a MMS Client transaction.
| protected byte[] | sendPdu(byte[] pdu)A common method to send a PDU to MMSC.
String mmscUrl = mTransactionSettings.getMmscUrl();
ensureRouteToHost(mmscUrl, mTransactionSettings);
return HttpUtils.httpConnection(
mContext, SendingProgressTokenManager.NO_TOKEN,
mmscUrl,
pdu, HttpUtils.HTTP_POST_METHOD,
mTransactionSettings.isProxySet(),
mTransactionSettings.getProxyAddress(),
mTransactionSettings.getProxyPort());
| protected byte[] | sendPdu(long token, byte[] pdu)A common method to send a PDU to MMSC.
String mmscUrl = mTransactionSettings.getMmscUrl();
ensureRouteToHost(mmscUrl, mTransactionSettings);
return HttpUtils.httpConnection(
mContext, token,
mmscUrl,
pdu, HttpUtils.HTTP_POST_METHOD,
mTransactionSettings.isProxySet(),
mTransactionSettings.getProxyAddress(),
mTransactionSettings.getProxyPort());
| public void | setConnectionSettings(TransactionSettings settings)
mTransactionSettings = settings;
| public java.lang.String | toString()
return getClass().getName() + ": serviceId=" + mServiceId;
|
|