MmsConfig.java revision 2f3a42025f51d410162b9b4b3583528077117374
172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project/*
2bd09a4b8c2d1f922f1459c4d7b61e7e87ed4ddf3The Android Open Source Project * Copyright (C) 2009 The Android Open Source Project
372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *
472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * you may not use this file except in compliance with the License.
672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * You may obtain a copy of the License at
772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *
872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project *
1072735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software
1172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
1272735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1372735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * See the License for the specific language governing permissions and
1472735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project * limitations under the License.
1572735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project */
1672735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
1772735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectpackage com.android.mms;
1872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project
1986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport java.io.IOException;
2086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
2186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport org.xmlpull.v1.XmlPullParser;
2286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport org.xmlpull.v1.XmlPullParserException;
2386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
2486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport android.content.Context;
2586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport android.content.res.XmlResourceParser;
2686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport android.util.Config;
2786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport android.util.Log;
2886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
2986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylorimport com.android.internal.util.XmlUtils;
3086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
3172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Projectpublic class MmsConfig {
3286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static final String TAG = "MmsConfig";
3386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static final boolean DEBUG = false;
3486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV;
353b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang
363b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang    private static final String DEFAULT_HTTP_KEY_X_WAP_PROFILE = "x-wap-profile";
373b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang    private static final String DEFAULT_USER_AGENT = "Android-Mms/0.1";
383b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang
3972735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project    /**
40bd09a4b8c2d1f922f1459c4d7b61e7e87ed4ddf3The Android Open Source Project     * Whether to hide MMS functionality from the user (i.e. SMS only).
4172735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project     */
42604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom    private static boolean mTransIdEnabled = false;
4386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static int mMmsEnabled = -1;        // an int so we can tell whether it's been inited
4486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static int mMaxMessageSize = 0;
4589e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    private static String mUserAgent = null;
4689e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    private static String mUaProfTagName = null;
4786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static String mUaProfUrl = null;
4889e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    private static String mHttpParams = null;
4989e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    private static String mHttpParamsLine1Key = null;
50cea16acf02be8943133bc5048b1d64286bfef1d8Satish Roddom    private static String mEmailGateway = null;
5186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static int mMaxImageHeight = 0;
5286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static int mMaxImageWidth = 0;
5353a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    private static int mRecipientLimit = Integer.MAX_VALUE;     // default value
5453a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    private static int mDefaultSMSMessagesPerThread = 200;      // default value
5553a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    private static int mDefaultMMSMessagesPerThread = 20;       // default value
562f3a42025f51d410162b9b4b3583528077117374Tom Taylor    private static int mMinMessageCountPerThread = 2;           // default value
5753a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    private static int mMaxMessageCountPerThread = 5000;        // default value
58ce781a2d55d43ac6b6b6af9a399f6f9ca2145526Tom Taylor    private static int mSmsToMmsTextThreshold = 4;              // default value
59293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang    private static int mHttpSocketTimeout = 60*1000;            // default to 1 min
60e6367524d22c6bfedfb81c7e068e475b0f807053Tom Taylor    private static int mMinimumSlideElementDuration = 7;        // default to 7 sec
61161c9154aa7aafa397332caee40b2776db988bf7Christian Gustafsson    private static boolean mNotifyWapMMSC = false;
6207fd438290f18696092b00813ff1c57ac16fa81cTom Taylor
6386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    public static void init(Context context) {
6486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        if (LOCAL_LOGV) {
6586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            Log.v(TAG, "MmsConfig.init()");
6686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
6786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
6886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        loadMmsSettings(context);
6986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    }
7007fd438290f18696092b00813ff1c57ac16fa81cTom Taylor
7186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    public static boolean getMmsEnabled() {
7286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        return mMmsEnabled == 1 ? true : false;
7386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    }
7407fd438290f18696092b00813ff1c57ac16fa81cTom Taylor
7586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    public static int getMaxMessageSize() {
7686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        return mMaxMessageSize;
7786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    }
7807fd438290f18696092b00813ff1c57ac16fa81cTom Taylor
79604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom    /**
80604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom     * This function returns the value of "enabledTransID" present in mms_config file.
81604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom     * In case of single segment wap push message, this "enabledTransID" indicates whether
82604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom     * TransactionID should be appended to URI or not.
83604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom     */
84604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom    public static boolean getTransIdEnabled() {
85604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom        return mTransIdEnabled;
86604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom    }
87604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom
8889e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    public static String getUserAgent() {
8989e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson        return mUserAgent;
9089e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    }
9189e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson
9289e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    public static String getUaProfTagName() {
9389e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson        return mUaProfTagName;
9489e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    }
9589e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson
9686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    public static String getUaProfUrl() {
9786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        return mUaProfUrl;
9886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    }
9986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
10089e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    public static String getHttpParams() {
10189e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson        return mHttpParams;
10289e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    }
10389e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson
10489e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    public static String getHttpParamsLine1Key() {
10589e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson        return mHttpParamsLine1Key;
10689e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson    }
10789e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson
108cea16acf02be8943133bc5048b1d64286bfef1d8Satish Roddom    public static String getEmailGateway() {
109cea16acf02be8943133bc5048b1d64286bfef1d8Satish Roddom        return mEmailGateway;
110cea16acf02be8943133bc5048b1d64286bfef1d8Satish Roddom    }
111cea16acf02be8943133bc5048b1d64286bfef1d8Satish Roddom
11286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    public static int getMaxImageHeight() {
11386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        return mMaxImageHeight;
11486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    }
11507fd438290f18696092b00813ff1c57ac16fa81cTom Taylor
11686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    public static int getMaxImageWidth() {
11786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        return mMaxImageWidth;
11886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    }
11986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
12007fd438290f18696092b00813ff1c57ac16fa81cTom Taylor    public static int getRecipientLimit() {
12107fd438290f18696092b00813ff1c57ac16fa81cTom Taylor        return mRecipientLimit;
12207fd438290f18696092b00813ff1c57ac16fa81cTom Taylor    }
12307fd438290f18696092b00813ff1c57ac16fa81cTom Taylor
12453a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    public static int getDefaultSMSMessagesPerThread() {
12553a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor        return mDefaultSMSMessagesPerThread;
12653a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    }
12753a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor
12853a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    public static int getDefaultMMSMessagesPerThread() {
12953a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor        return mDefaultMMSMessagesPerThread;
13053a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    }
13153a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor
13253a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    public static int getMinMessageCountPerThread() {
13353a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor        return mMinMessageCountPerThread;
13453a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    }
13553a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor
13653a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    public static int getMaxMessageCountPerThread() {
13753a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor        return mMaxMessageCountPerThread;
13853a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor    }
13953a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor
140ce781a2d55d43ac6b6b6af9a399f6f9ca2145526Tom Taylor    public static int getSmsToMmsTextThreshold() {
141ce781a2d55d43ac6b6b6af9a399f6f9ca2145526Tom Taylor        return mSmsToMmsTextThreshold;
142ce781a2d55d43ac6b6b6af9a399f6f9ca2145526Tom Taylor    }
143ce781a2d55d43ac6b6b6af9a399f6f9ca2145526Tom Taylor
144293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang    public static int getHttpSocketTimeout() {
145293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang        return mHttpSocketTimeout;
146293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang    }
147293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang
148e6367524d22c6bfedfb81c7e068e475b0f807053Tom Taylor    public static int getMinimumSlideElementDuration() {
149e6367524d22c6bfedfb81c7e068e475b0f807053Tom Taylor        return mMinimumSlideElementDuration;
150e6367524d22c6bfedfb81c7e068e475b0f807053Tom Taylor    }
151e6367524d22c6bfedfb81c7e068e475b0f807053Tom Taylor
152161c9154aa7aafa397332caee40b2776db988bf7Christian Gustafsson    public static boolean getNotifyWapMMSC() {
153161c9154aa7aafa397332caee40b2776db988bf7Christian Gustafsson        return mNotifyWapMMSC;
154161c9154aa7aafa397332caee40b2776db988bf7Christian Gustafsson    }
155161c9154aa7aafa397332caee40b2776db988bf7Christian Gustafsson
15686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    private static void loadMmsSettings(Context context) {
15786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        XmlResourceParser parser = context.getResources()
15886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                .getXml(R.xml.mms_config);
15986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
16086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        try {
16186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            XmlUtils.beginDocument(parser, "mms_config");
16207fd438290f18696092b00813ff1c57ac16fa81cTom Taylor
16386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            while (true) {
16486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                XmlUtils.nextElement(parser);
16586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                String tag = parser.getName();
16686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                if (tag == null) {
16786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                    break;
16886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                }
16986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                String name = parser.getAttributeName(0);
17086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                String value = parser.getAttributeValue(0);
17186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                String text = null;
17286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                if (parser.next() == XmlPullParser.TEXT) {
17386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                    text = parser.getText();
17486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                }
17586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
17607fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                if (DEBUG) {
17707fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                    Log.v(TAG, "tag: " + tag + " value: " + value);
17807fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                }
17986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                if ("name".equalsIgnoreCase(name)) {
18086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                    if ("bool".equals(tag)) {
18186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        // bool config tags go here
18286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        if ("enabledMMS".equalsIgnoreCase(value)) {
18386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                            mMmsEnabled = "true".equalsIgnoreCase(text) ? 1 : 0;
184604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom                        } else if ("enabledTransID".equalsIgnoreCase(value)) {
185604b2555f16c8f90dd083b326590ab4bd8526244Satish Roddom                            mTransIdEnabled = "true".equalsIgnoreCase(text);
186161c9154aa7aafa397332caee40b2776db988bf7Christian Gustafsson                        } else if ("enabledNotifyWapMMSC".equalsIgnoreCase(value)) {
187161c9154aa7aafa397332caee40b2776db988bf7Christian Gustafsson                            mNotifyWapMMSC = "true".equalsIgnoreCase(text);
18886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        }
18986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                    } else if ("int".equals(tag)) {
19086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        // int config tags go here
19186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        if ("maxMessageSize".equalsIgnoreCase(value)) {
19286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                            mMaxMessageSize = Integer.parseInt(text);
19386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        } else if ("maxImageHeight".equalsIgnoreCase(value)) {
19486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                            mMaxImageHeight = Integer.parseInt(text);
19586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        } else if ("maxImageWidth".equalsIgnoreCase(value)) {
19686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                            mMaxImageWidth = Integer.parseInt(text);
19753a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                        } else if ("defaultSMSMessagesPerThread".equalsIgnoreCase(value)) {
19853a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                            mDefaultSMSMessagesPerThread = Integer.parseInt(text);
19953a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                        } else if ("defaultMMSMessagesPerThread".equalsIgnoreCase(value)) {
20053a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                            mDefaultMMSMessagesPerThread = Integer.parseInt(text);
20153a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                        } else if ("minMessageCountPerThread".equalsIgnoreCase(value)) {
20253a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                            mMinMessageCountPerThread = Integer.parseInt(text);
20353a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                        } else if ("maxMessageCountPerThread".equalsIgnoreCase(value)) {
20453a1dc1c4fed88c20a3ce4c2d37c909dc1e469e2Tom Taylor                            mMaxMessageCountPerThread = Integer.parseInt(text);
205ce781a2d55d43ac6b6b6af9a399f6f9ca2145526Tom Taylor                        } else if ("smsToMmsTextThreshold".equalsIgnoreCase(value)) {
206ce781a2d55d43ac6b6b6af9a399f6f9ca2145526Tom Taylor                            mSmsToMmsTextThreshold = Integer.parseInt(text);
20707fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                        } else if ("recipientLimit".equalsIgnoreCase(value)) {
20807fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                            mRecipientLimit = Integer.parseInt(text);
20907fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                            if (mRecipientLimit < 0) {
21007fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                                mRecipientLimit = Integer.MAX_VALUE;
21107fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                            }
212293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang                        } else if ("httpSocketTimeout".equalsIgnoreCase(value)) {
213293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang                            mHttpSocketTimeout = Integer.parseInt(text);
214e6367524d22c6bfedfb81c7e068e475b0f807053Tom Taylor                        } else if ("minimumSlideElementDuration".equalsIgnoreCase(value)) {
215e6367524d22c6bfedfb81c7e068e475b0f807053Tom Taylor                            mMinimumSlideElementDuration = Integer.parseInt(text);
21686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        }
21786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                    } else if ("string".equals(tag)) {
21886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        // string config tags go here
21989e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                        if ("userAgent".equalsIgnoreCase(value)) {
22089e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                            mUserAgent = text;
22189e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                        } else if ("uaProfTagName".equalsIgnoreCase(value)) {
22289e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                            mUaProfTagName = text;
22389e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                        } else if ("uaProfUrl".equalsIgnoreCase(value)) {
22486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                            mUaProfUrl = text;
22589e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                        } else if ("httpParams".equalsIgnoreCase(value)) {
22689e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                            mHttpParams = text;
22789e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                        } else if ("httpParamsLine1Key".equalsIgnoreCase(value)) {
22889e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson                            mHttpParamsLine1Key = text;
229cea16acf02be8943133bc5048b1d64286bfef1d8Satish Roddom                        } else if ("emailGatewayNumber".equalsIgnoreCase(value)) {
230cea16acf02be8943133bc5048b1d64286bfef1d8Satish Roddom                            mEmailGateway = text;
23186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        }
23286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                    }
23386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                }
23486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            }
23586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        } catch (XmlPullParserException e) {
236293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang            Log.e(TAG, "loadMmsSettings caught ", e);
23786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        } catch (NumberFormatException e) {
238293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang            Log.e(TAG, "loadMmsSettings caught ", e);
23986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        } catch (IOException e) {
240293000e15498b71a4986d7247e60fe8bdaa05a4bWei Huang            Log.e(TAG, "loadMmsSettings caught ", e);
24186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        } finally {
24286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            parser.close();
24386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
2443b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang
24586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        String errorStr = null;
2463b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang
24786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        if (mMmsEnabled == -1) {
24886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            errorStr = "enableMMS";
24986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
25086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        if (mMaxMessageSize == 0) {
25186a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            errorStr = "maxMessageSize";
25286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
25386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        if (mMaxImageHeight == 0) {
25486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            errorStr = "maxImageHeight";
25586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
25686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        if (mMaxImageWidth == 0) {
25786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            errorStr = "maxImageWidth";
25886a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
259437cfcb32630fb28ca6aa8f90b673d8068627bd1Tom Taylor        if (getMmsEnabled() && mUaProfUrl == null) {
2603b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang            errorStr = "uaProfUrl";
26189e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson        }
26289e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson        if (mUaProfTagName == null) {
2633b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang            mUaProfTagName = DEFAULT_HTTP_KEY_X_WAP_PROFILE;
26489e7af1acc0b62f2822ace8df6d56f4c6d37a40fChristian Gustafsson        }
2653b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang        if (mUserAgent == null) {
2663b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang            mUserAgent = DEFAULT_USER_AGENT;
26786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
2683b3d9ba082ee58fe2d408890ec3cbeee846e57ffWei Huang
26986a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        if (errorStr != null) {
27086a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            String err =
27107fd438290f18696092b00813ff1c57ac16fa81cTom Taylor                String.format("MmsConfig.loadMmsSettings mms_config.xml missing %s setting",
27286a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor                        errorStr);
27386a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            Log.e(TAG, err);
27486a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor            throw new ContentRestrictionException(err);
27586a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor        }
27686a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor    }
27786a1cf79bf92dbb2b9d09431379bff6de83c2581Tom Taylor
27872735c62aba8fd2a9420a0f9f83d22543e3c164fThe Android Open Source Project}
279