FileDocCategorySizeDatePackage
TransactionSettings.javaAPI DocAndroid 1.5 API5104Wed May 06 22:42:46 BST 2009com.android.mms.transaction

TransactionSettings

public 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.

param
context The context 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.

param
mmscUrl The MMSC URL
param
proxyAddr The proxy address
param
proxyPort The port used by the proxy address immediately start a SendTransaction upon completion of a NotificationTransaction, false otherwise.

        mServiceCenter = mmscUrl;
        mProxyAddress = proxyAddr;
        mProxyPort = proxyPort;
    
Methods Summary
public java.lang.StringgetMmscUrl()

        return mServiceCenter;
    
public java.lang.StringgetProxyAddress()

        return mProxyAddress;
    
public intgetProxyPort()

        return mProxyPort;
    
public booleanisProxySet()

        return (mProxyAddress != null) && (mProxyAddress.trim().length() != 0);
    
private static booleanisValidApnType(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;