TransactionSettingspublic class TransactionSettings extends Object Container of transaction settings. Instances of this class are contained
within Transaction instances to allow overriding of the default APN
settings or of the MMS Client. |
Fields Summary |
---|
private static final String | TAG | private static final boolean | DEBUG | private static final boolean | LOCAL_LOGV | private String | mServiceCenter | private String | mProxyAddress | private int | mProxyPort | private static final String[] | APN_PROJECTION | private static final int | COLUMN_TYPE | private static final int | COLUMN_MMSC | private static final int | COLUMN_MMSPROXY | private static final int | COLUMN_MMSPORT |
Constructors Summary |
---|
public TransactionSettings(android.content.Context context, String apnName)Constructor that uses the default settings of the MMS Client.
String selection = (apnName != null)?
Telephony.Carriers.APN + "='"+apnName+"'": null;
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(),
Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"),
APN_PROJECTION, selection, null, null);
if (cursor == null) {
Log.e(TAG, "Apn is not found in Database!");
return;
}
boolean sawValidApn = false;
try {
while (cursor.moveToNext() && TextUtils.isEmpty(mServiceCenter)) {
// Read values from APN settings
if (isValidApnType(cursor.getString(COLUMN_TYPE), Phone.APN_TYPE_MMS)) {
sawValidApn = true;
mServiceCenter = cursor.getString(COLUMN_MMSC);
mProxyAddress = cursor.getString(COLUMN_MMSPROXY);
if (isProxySet()) {
String portString = cursor.getString(COLUMN_MMSPORT);
try {
mProxyPort = Integer.parseInt(portString);
} catch (NumberFormatException e) {
Log.e(TAG, "Bad port number format: " + portString, e);
}
}
}
}
} finally {
cursor.close();
}
if (sawValidApn && TextUtils.isEmpty(mServiceCenter)) {
Log.e(TAG, "Invalid APN setting: MMSC is empty");
}
| public TransactionSettings(String mmscUrl, String proxyAddr, int proxyPort)Constructor that overrides the default settings of the MMS Client.
mServiceCenter = mmscUrl;
mProxyAddress = proxyAddr;
mProxyPort = proxyPort;
|
Methods Summary |
---|
public java.lang.String | getMmscUrl()
return mServiceCenter;
| public java.lang.String | getProxyAddress()
return mProxyAddress;
| public int | getProxyPort()
return mProxyPort;
| public boolean | isProxySet()
return (mProxyAddress != null) && (mProxyAddress.trim().length() != 0);
| private static boolean | isValidApnType(java.lang.String types, java.lang.String requestType)
// If APN type is unspecified, assume APN_TYPE_ALL.
if (TextUtils.isEmpty(types)) {
return true;
}
for (String t : types.split(",")) {
if (t.equals(requestType) || t.equals(Phone.APN_TYPE_ALL)) {
return true;
}
}
return false;
|
|