Changes to conform to new overlay format

- Added new overlay resources and checks for new resource values
- Removed all references to carrier specific lookups and
converted them to overlay implementations instead.
- Removed old resources from assets directory

Change-Id: I5143b499ffb6f1e08d1f9c846eec94300de87561
diff --git a/src/com/android/browser/AddBookmarkFolder.java b/src/com/android/browser/AddBookmarkFolder.java
index 4a9c13c..c6dc653 100644
--- a/src/com/android/browser/AddBookmarkFolder.java
+++ b/src/com/android/browser/AddBookmarkFolder.java
@@ -605,7 +605,6 @@
         mFakeTitle.setText(this.getString(R.string.new_folder));
 
         mTitle = (EditText) findViewById(R.id.title);
-        // add for cmcc test about waring limit of edit text
         BrowserUtils.maxLengthFilter(AddBookmarkFolder.this, mTitle, BrowserUtils.FILENAME_MAX_LENGTH);
 
         mTitle.setText(title);
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 0e4fba6..0281167 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -21,15 +21,14 @@
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.content.res.AssetManager;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.os.Build;
 import android.preference.PreferenceManager;
 import android.provider.Browser;
 import android.provider.Settings;
+import android.text.TextUtils;
 import android.util.DisplayMetrics;
-import android.util.Log;
 import android.webkit.WebIconDatabase;
 import android.webkit.WebStorage;
 import android.webkit.WebViewDatabase;
@@ -41,7 +40,6 @@
 import com.android.browser.search.SearchEngine;
 import com.android.browser.search.SearchEngines;
 
-import java.io.InputStream;
 import java.lang.ref.WeakReference;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -135,9 +133,6 @@
 
     private static String sFactoryResetUrl;
 
-    // add for carrier feature
-    private static Context sResPackageCtx;
-
     public static void initialize(final Context context) {
         sInstance = new BrowserSettings(context);
     }
@@ -152,15 +147,6 @@
         mAutofillHandler = new AutofillHandler(mContext);
         mManagedSettings = new LinkedList<WeakReference<WebSettings>>();
         mCustomUserAgents = new WeakHashMap<WebSettings, String>();
-
-        // add for carrier feature
-        try {
-            sResPackageCtx = context.createPackageContext(
-                "com.android.browser.res",
-                Context.CONTEXT_IGNORE_SECURITY);
-        } catch (Exception e) {
-            Log.e("Res_Update", "Create Res Apk Failed");
-        }
         BackgroundHandler.execute(mSetup);
     }
 
@@ -245,64 +231,12 @@
             }
 
             // add for carrier homepage feature
-            String browserRes = mContext.getResources().getString(R.string.config_carrier_resource);
-            if ("cu".equals(browserRes) || "cmcc".equals(browserRes)) {
-                int resID = sResPackageCtx.getResources().getIdentifier(
-                        "homepage_base", "string", "com.android.browser.res");
-                sFactoryResetUrl = sResPackageCtx.getResources().getString(resID);
-            } else if ("ct".equals(browserRes)) {
-                int resID = sResPackageCtx.getResources().getIdentifier(
-                        "homepage_base", "string", "com.android.browser.res");
-                sFactoryResetUrl = sResPackageCtx.getResources().getString(resID);
-
-                int pathID = sResPackageCtx.getResources().getIdentifier(
-                        "homepage_path", "string", "com.android.browser.res");
-                String path = sResPackageCtx.getResources().getString(pathID);
-                Locale locale = Locale.getDefault();
-                path = path.replace("%y", locale.getLanguage().toLowerCase());
-                path = path.replace("%z", '_'+locale.getCountry().toLowerCase());
-                boolean useCountry = true;
-                boolean useLanguage = true;
-                InputStream is = null;
-                AssetManager am = mContext.getAssets();
-                try {
-                    is = am.open(path);
-                } catch (Exception ignored) {
-                    useCountry = false;
-                    path = sResPackageCtx.getResources().getString(pathID);
-                    path = path.replace("%y", locale.getLanguage().toLowerCase());
-                    path = path.replace("%z", "");
-                    try {
-                        is = am.open(path);
-                    } catch (Exception ignoredlanguage) {
-                        useLanguage = false;
-                    }
-                } finally {
-                    if (is != null) {
-                        try {
-                            is.close();
-                        } catch (Exception ignored) {}
-                    }
-                }
-
-                if (!useCountry && !useLanguage) {
-                    sFactoryResetUrl = sFactoryResetUrl.replace("%y%z", "en");
-                } else {
-                    sFactoryResetUrl = sFactoryResetUrl.replace("%y",
-                            locale.getLanguage().toLowerCase());
-                    sFactoryResetUrl = sFactoryResetUrl.replace("%z", useCountry ?
-                            '_' + locale.getCountry().toLowerCase() : "");
-                }
-            } else {
-                sFactoryResetUrl = mContext.getResources().getString(R.string.homepage_base);
-            }
+            sFactoryResetUrl = mContext.getResources().getString(R.string.homepage_base);
 
             if (!mPrefs.contains(PREF_DEFAULT_TEXT_ENCODING)) {
-                if (!"default".equals(browserRes)) {
-                    mPrefs.edit().putString(PREF_DEFAULT_TEXT_ENCODING,
-                            "UTF-8").apply();
-                }
+                mPrefs.edit().putString(PREF_DEFAULT_TEXT_ENCODING, "UTF-8").apply();
             }
+
             if (sFactoryResetUrl.indexOf("{CID}") != -1) {
                 sFactoryResetUrl = sFactoryResetUrl.replace("{CID}",
                     BrowserProvider.getClientId(mContext.getContentResolver()));
@@ -347,23 +281,7 @@
         settings.setSavePassword(rememberPasswords());
         settings.setSaveFormData(saveFormdata());
         settings.setUseWideViewPort(isWideViewport());
-
-        // add for carrier useragent feature
-        String ua = null;
-        Object objUserAgentHandler = ReflectHelper.newObject(
-                "com.qrd.useragent.UserAgentHandler", null, null);
-        Object[] params = {mContext};
-        Class[] type = new Class[] {Context.class};
-        ua = (String) ReflectHelper.invokeMethod(objUserAgentHandler,"getUAString",
-                                type, params);
-        if (ua == null)
-            ua = mCustomUserAgents.get(settings);
-
-        if (ua != null){
-            settings.setUserAgentString(ua);
-        } else {
-            settings.setUserAgentString(USER_AGENTS[getUserAgent()]);
-        }
+        setUserAgent(settings);
 
         WebSettings settingsClassic = (WebSettings) settings;
         settingsClassic.setHardwareAccelSkiaEnabled(isSkiaHardwareAccelerated());
@@ -388,6 +306,35 @@
         settingsClassic.setLinkPrefetchEnabled(mLinkPrefetchAllowed);
     }
 
+    private void setUserAgent(WebSettings settings){
+        String ua = mContext.getResources().getString(R.string.def_useragent);
+
+        if (!TextUtils.isEmpty(ua))
+            ua = constructUserAgent(ua);
+
+        if (TextUtils.isEmpty(ua))
+            ua = mCustomUserAgents.get(settings);
+
+        if (!TextUtils.isEmpty(ua)){
+            settings.setUserAgentString(ua);
+        } else {
+            settings.setUserAgentString(USER_AGENTS[getUserAgent()]);
+        }
+    }
+
+    private String constructUserAgent(String userAgent) {
+        try {
+            userAgent = userAgent.replaceAll("<%build_model>", Build.MODEL);
+            userAgent = userAgent.replaceAll("<%build_version>", Build.VERSION.RELEASE);
+            userAgent = userAgent.replaceAll("<%build_id>", Build.ID);
+            userAgent = userAgent.replaceAll("<%language>", Locale.getDefault().getLanguage());
+            userAgent = userAgent.replaceAll("<%country>", Locale.getDefault().getCountry());
+            return userAgent;
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+
     /**
      * Syncs all the settings that have no UI
      * These cannot change, so we only need to set them once per WebSettings
@@ -687,7 +634,7 @@
         WebSettings settings = view.getSettings();
         if (mCustomUserAgents.get(settings) != null) {
             mCustomUserAgents.remove(settings);
-            settings.setUserAgentString(USER_AGENTS[getUserAgent()]);
+            setUserAgent(settings);
         } else {
             mCustomUserAgents.put(settings, DESKTOP_USERAGENT);
             settings.setUserAgentString(DESKTOP_USERAGENT);
diff --git a/src/com/android/browser/BrowserWebViewFactory.java b/src/com/android/browser/BrowserWebViewFactory.java
index caa0cf8..9f5e503 100644
--- a/src/com/android/browser/BrowserWebViewFactory.java
+++ b/src/com/android/browser/BrowserWebViewFactory.java
@@ -64,15 +64,6 @@
                 || pm.hasSystemFeature(PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT);
         w.getSettings().setDisplayZoomControls(!supportsMultiTouch);
 
-        // add for carrier homepage feature
-        String browserRes = mContext.getResources().getString(R.string.config_carrier_resource);
-        if ("ct".equals(browserRes)) {
-            w.getSettings().setJavaScriptEnabled(true);
-            if (mContext instanceof BrowserActivity) {
-                w.addJavascriptInterface(mContext, "default_homepage");
-            }
-        }
-
         // Add this WebView to the settings observer list and update the
         // settings
         final BrowserSettings s = BrowserSettings.getInstance();
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 406c73c..012191e 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -23,12 +23,10 @@
 import android.app.DownloadManager;
 import android.app.ProgressDialog;
 import android.content.Context;
-import android.content.res.Resources;
 import android.content.ClipboardManager;
 import android.content.ContentResolver;
 import android.content.ContentUris;
 import android.content.ContentValues;
-import android.content.Context;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnCancelListener;
 import android.content.Intent;
@@ -129,15 +127,8 @@
         "android.speech.extras.SEND_APPLICATION_ID_EXTRA";
     private static final String INCOGNITO_URI = "browser:incognito";
 
-    private static final String OFFLINE_PAGE =
-        "content://com.android.browser.mynavigation/websites";
-
-    private static final String ACTION_WIFI_SELECTION_DATA_CONNECTION =
-             "android.net.wifi.cmcc.WIFI_SELECTION_DATA_CONNECTION";
     // Remind switch to data connection if wifi is unavailable
     private static final int NETWORK_SWITCH_TYPE_OK = 1;
-    private static final String WIFI_BROWSER_INTERACTION_REMIND_TYPE =
-             "wifi_browser_interaction_remind";
 
     public final static String EXTRA_SHARE_SCREENSHOT = "share_screenshot";
     public final static String EXTRA_SHARE_FAVICON = "share_favicon";
@@ -204,6 +195,8 @@
     private boolean mShouldShowErrorConsole;
     private boolean mNetworkShouldNotify = true;
 
+    private boolean mJsInterfaceEnabled = false;
+
     private SystemAllowGeolocationOrigins mSystemAllowGeolocationOrigins;
 
     // FIXME, temp address onPrepareMenu performance problem.
@@ -341,11 +334,10 @@
                 }
                 Tab t = null;
                 if (urlData.isEmpty()) {
-                    Resources res = mActivity.getResources();
-                    String browserRes = res.getString(R.string.config_carrier_resource);
-                    if (browserRes.equals(
-                            "cmcc")) {
-                        t = openTab(OFFLINE_PAGE, false, true, true);
+                    String landingPage = mActivity.getResources().getString(
+                                                   R.string.def_landing_page);
+                    if (!landingPage.isEmpty()) {
+                        t = openTab(landingPage, false, true, true);
                     } else {
                         t = openTabToHomePage();
                     }
@@ -875,27 +867,48 @@
     }
 
     private void handleNetworkNotify(WebView view) {
+        final String reminderType = getContext().getResources().getString(
+                R.string.def_wifi_browser_interaction_remind_type);
+        final String selectionConnnection = getContext().getResources().getString(
+                R.string.def_action_wifi_selection_data_connections);
+
+        if (reminderType.isEmpty() || selectionConnnection.isEmpty())
+            return;
+
         ConnectivityManager conMgr = (ConnectivityManager) this.getContext().getSystemService(
             Context.CONNECTIVITY_SERVICE);
         NetworkInfo networkInfo = conMgr.getActiveNetworkInfo();
         if (networkInfo == null
             || (networkInfo != null && (networkInfo.getType() !=
                 ConnectivityManager.TYPE_WIFI))) {
-            int isReminder = Settings.System.getInt(
-                mActivity.getContentResolver(),
-                WIFI_BROWSER_INTERACTION_REMIND_TYPE,
-                NETWORK_SWITCH_TYPE_OK);
-
-        if (isReminder == NETWORK_SWITCH_TYPE_OK) {
-            mNetworkShouldNotify = false;
-                Intent intent = new Intent(
-                    ACTION_WIFI_SELECTION_DATA_CONNECTION);
+            int isReminder = Settings.System.getInt(mActivity.getContentResolver(),
+                                                    reminderType, NETWORK_SWITCH_TYPE_OK);
+            if (isReminder == NETWORK_SWITCH_TYPE_OK) {
+                mNetworkShouldNotify = false;
+                Intent intent = new Intent(selectionConnnection);
                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 this.getContext().startActivity(intent);
             } else {
-                if (!mNetworkHandler.isNetworkUp()) {
+                if (!mNetworkHandler.isNetworkUp())
                     view.setNetworkAvailable(false);
-                }
+            }
+        }
+    }
+
+    /***
+     * Add/remove a Javascript interface for a local default homepage only
+     */
+    private void handleJsInterface(WebView webview){
+        if (webview.getUrl() != null &&
+            webview.getUrl().equals(mActivity.getResources().getString(R.string.homepage_base)) &&
+            webview.getUrl().startsWith("file:///")) {
+                mJsInterfaceEnabled = true;
+                webview.getSettings().setJavaScriptEnabled(true);
+                webview.addJavascriptInterface(mActivity, "default_homepage");
+        } else {
+            if (mJsInterfaceEnabled) {
+                webview.removeJavascriptInterface("default_homepage");
+                mJsInterfaceEnabled = false;
             }
         }
     }
@@ -909,15 +922,15 @@
         // to save a screenshot then we will now take the new page and save
         // an incorrect screenshot. Therefore, remove any pending thumbnail
         // messages from the queue.
-        mHandler.removeMessages(Controller.UPDATE_BOOKMARK_THUMBNAIL,
-                tab);
+        mHandler.removeMessages(Controller.UPDATE_BOOKMARK_THUMBNAIL, tab);
 
         // reset sync timer to avoid sync starts during loading a page
         CookieSyncManager.getInstance().resetSync();
         WifiManager wifiMgr = (WifiManager) this.getContext()
             .getSystemService(Context.WIFI_SERVICE);
-        String browserRes = mActivity.getResources().getString(R.string.config_carrier_resource);
-        if ("cmcc".equals(browserRes) && mNetworkShouldNotify && wifiMgr.isWifiEnabled()) {
+        boolean networkNotifier =
+            mActivity.getApplicationContext().getResources().getBoolean(R.bool.network_notifier);
+        if (networkNotifier && mNetworkShouldNotify && wifiMgr.isWifiEnabled()) {
             handleNetworkNotify(view);
         } else {
             if (!mNetworkHandler.isNetworkUp()) {
@@ -968,6 +981,7 @@
         int newProgress = tab.getLoadProgress();
 
         if (newProgress == 100) {
+            handleJsInterface(tab.getWebView());
             CookieSyncManager.getInstance().sync();
             // onProgressChanged() may continue to be called after the main
             // frame has finished loading, as any remaining sub frames continue
@@ -1096,8 +1110,12 @@
 
     @Override
     public void doUpdateVisitedHistory(Tab tab, boolean isReload) {
-        // Don't save anything in private browsing mode
-        if (tab.isPrivateBrowsingEnabled()) return;
+        boolean disableHistoryWrites =
+                mActivity.getResources().getBoolean(R.bool.def_disable_history);
+
+        // Don't save anything in private browsing mode or when explicitly set
+        // not to write history via an overlay
+        if (tab.isPrivateBrowsingEnabled() || disableHistoryWrites) return;
         String url = tab.getOriginalUrl();
 
         if (TextUtils.isEmpty(url)
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index f4d63d9..da3f3da 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -37,7 +37,6 @@
 
 import com.android.browser.R;
 import com.android.browser.UrlInputView.UrlInputListener;
-import com.android.browser.reflect.ReflectHelper;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
@@ -171,9 +170,7 @@
         stopEditingUrl();
         if (UrlInputView.TYPED.equals(source)) {
             String url = null;
-            String browserRes =
-                getContext().getResources().getString(R.string.config_carrier_resource);
-            boolean wap2estore = "ct".equals(browserRes);
+            boolean wap2estore = getContext().getResources().getBoolean(R.bool.wap2estore);
             if ((wap2estore && isEstoreTypeUrl(text)) || isRtspTypeUrl(text)
                 || isMakeCallTypeUrl(text)) {
                 url = text;
diff --git a/src/com/android/browser/NavigationBarPhone.java b/src/com/android/browser/NavigationBarPhone.java
index 50ddea2..a5257d1 100644
--- a/src/com/android/browser/NavigationBarPhone.java
+++ b/src/com/android/browser/NavigationBarPhone.java
@@ -132,15 +132,7 @@
             if (title == null) {
                 mUrlInput.setText(R.string.new_tab);
             } else {
-                Tab tab = mUiController.getTabControl().getCurrentTab();
-                if (tab != null && tab.getUrl() != null &&
-                        tab.getUrl().startsWith("http://218.206.177.209:8080/waptest/browser15")) {
-                    //for cmcc test case, display website title for specified cmcc website,
-                    //not url address.
-                    mUrlInput.setText(tab.getTitle(), false);
-                } else {
-                    mUrlInput.setText(UrlUtils.stripUrl(title), false);
-                }
+                mUrlInput.setText(UrlUtils.stripUrl(title), false);
             }
             mUrlInput.setSelection(0);
         }
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index e0c3286..a9da8cf 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -410,22 +410,6 @@
                     // sNextId to be set correctly.
                     continue;
                 }
-
-                // add for carrier homepage feature
-                // If the webview restore successfully, add javascript interface again.
-                WebView view = t.getWebView();
-                if (view != null) {
-                    String browserRes = mController.getActivity().getApplicationContext()
-                            .getResources().getString(R.string.config_carrier_resource);
-                    if ("ct".equals(browserRes)) {
-                        view.getSettings().setJavaScriptEnabled(true);
-                        if (mController.getActivity() instanceof BrowserActivity) {
-                            view.addJavascriptInterface(mController.getActivity(),
-                                    "default_homepage");
-                        }
-                    }
-                }
-
                 tabMap.put(id, t);
                 // Me must set the current tab before restoring the state
                 // so that all the client classes are set.
diff --git a/src/com/android/browser/UploadHandler.java b/src/com/android/browser/UploadHandler.java
index 51ca7f9..e3eda33 100644
--- a/src/com/android/browser/UploadHandler.java
+++ b/src/com/android/browser/UploadHandler.java
@@ -119,10 +119,10 @@
         }
 
         // Add for carrier feature - prevent uploading DRM type files.
-        String browserRes = mController.getActivity().getResources().
-                getString(R.string.config_carrier_resource);
+        boolean drmUploadEnabled = mController.getContext().getResources().getBoolean(
+                                       R.bool.drm_uploads);
         boolean isDRMFileType = false;
-        if ("ct".equals(browserRes) && filePath != null
+        if (drmUploadEnabled && filePath != null
                 && (filePath.endsWith(".fl") || filePath.endsWith(".dm")
                 || filePath.endsWith(".dcf") || filePath.endsWith(".dr")
                 || filePath.endsWith(".dd"))) {
diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java
index 914edae..a3936b4 100755
--- a/src/com/android/browser/UrlHandler.java
+++ b/src/com/android/browser/UrlHandler.java
@@ -28,9 +28,7 @@
 import android.widget.Toast;
 
 import com.android.browser.R;
-import com.android.browser.reflect.ReflectHelper;
 
-import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -110,8 +108,8 @@
         }
 
         // add for carrier feature - wap2estore
-        String browserRes = mActivity.getResources().getString(R.string.config_carrier_resource);
-        boolean wap2estore = "ct".equals(browserRes);
+        boolean wap2estore =
+                mActivity.getApplicationContext().getResources().getBoolean(R.bool.wap2estore);
         if (wap2estore && isEstoreTypeUrl(url) && handleEstoreTypeUrl(url)) {
             return true;
         }
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 8b968a9..05508ad 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -656,25 +656,16 @@
             values.put(Bookmarks.DIRTY, true);
             db.insertOrThrow(TABLE_BOOKMARKS, null, values);
 
-            // add for carrier bookmark feature
-            String browserRes = getContext().getResources().getString(
-                    R.string.config_carrier_resource);
-
-            //don't add default bookmarks for cmcc
-            if (!"cmcc".equals(browserRes)) {
-                addDefaultBookmarks(db, FIXED_ID_ROOT);
-            }
-            if ("ct".equals(browserRes) || "cmcc".equals(browserRes)) {
-                addDefaultCarrierBookmarks(db, FIXED_ID_ROOT);
-            }
+            //add the default bookmarks
+            addDefaultBookmarks(db, FIXED_ID_ROOT);
         }
 
         private void addDefaultBookmarks(SQLiteDatabase db, long parentId) {
             Resources res = getContext().getResources();
-            final CharSequence[] bookmarks = res.getTextArray(
-                    R.array.bookmarks);
+            final CharSequence[] bookmarks = res.getTextArray(R.array.bookmarks);
             int size = bookmarks.length;
-            TypedArray preloads = res.obtainTypedArray(R.array.bookmark_preloads);
+            String[] preloads = res.getStringArray(R.array.bookmark_preloads);
+
             try {
                 String parent = Long.toString(parentId);
                 String now = Long.toString(System.currentTimeMillis());
@@ -697,17 +688,25 @@
                             now +
                             ");");
 
-                    int faviconId = preloads.getResourceId(i, 0);
-                    int thumbId = preloads.getResourceId(i + 1, 0);
+                    String faviconFileName = preloads[i];
+                    String thumbFileName = preloads[i+1];
+
+                    int favIconId = res.getIdentifier(faviconFileName, "raw",
+                                                      getContext().getPackageName());
+                    int thumbId = res.getIdentifier(thumbFileName, "raw",
+                                                    getContext().getPackageName());
+
                     byte[] thumb = null, favicon = null;
+
                     try {
                         thumb = readRaw(res, thumbId);
                     } catch (IOException e) {
                     }
                     try {
-                        favicon = readRaw(res, faviconId);
+                        favicon = readRaw(res, favIconId);
                     } catch (IOException e) {
                     }
+
                     if (thumb != null || favicon != null) {
                         ContentValues imageValues = new ContentValues();
                         imageValues.put(Images.URL, bookmarkDestination.toString());
@@ -721,95 +720,6 @@
                     }
                 }
             } catch (ArrayIndexOutOfBoundsException e) {
-            } finally {
-                preloads.recycle();
-            }
-        }
-
-        // add for carrier bookmark feature
-        private void addDefaultCarrierBookmarks(SQLiteDatabase db, long parentId) {
-            Context mResPackageCtx = null;
-            try {
-                mResPackageCtx = getContext().createPackageContext(
-                    "com.android.browser.res",
-                    Context.CONTEXT_IGNORE_SECURITY);
-            } catch (Exception e) {
-                Log.e(TAG, "Create Res Apk Failed");
-            }
-            if (mResPackageCtx == null)
-                return;
-
-            CharSequence[] bookmarks = null;
-            TypedArray preloads = null;
-            Resources res = mResPackageCtx.getResources();
-            int resBookmarksID = res.getIdentifier("bookmarks",
-                                                   "array",
-                                                   "com.android.browser.res");
-            int resPreloadsID = res.getIdentifier("bookmark_preloads", "array",
-                    "com.android.browser.res");
-            if (resBookmarksID != 0 && resPreloadsID != 0) {
-                bookmarks = res.getTextArray(resBookmarksID);
-                preloads = res.obtainTypedArray(resPreloadsID);
-            } else {
-                return;
-            }
-
-            // The Default Carrier bookmarks size
-            int size = bookmarks.length;
-
-            // googleSize the Default Google bookmarks size.
-            // The Default Carrier Bookmarks original position need move to googleSize index.
-            final CharSequence[] googleBookmarks = getContext().getResources().getTextArray(
-                    R.array.bookmarks);
-            int googleSize = googleBookmarks.length;
-            try {
-                String parent = Long.toString(parentId);
-                String now = Long.toString(System.currentTimeMillis());
-                for (int i = 0; i < size; i = i + 2) {
-                    CharSequence bookmarkDestination = replaceSystemPropertyInString(getContext(),
-                            bookmarks[i + 1]);
-                    db.execSQL("INSERT INTO bookmarks (" +
-                            Bookmarks.TITLE + ", " +
-                            Bookmarks.URL + ", " +
-                            Bookmarks.IS_FOLDER + "," +
-                            Bookmarks.PARENT + "," +
-                            Bookmarks.POSITION + "," +
-                            Bookmarks.DATE_CREATED +
-                        ") VALUES (" +
-                            "'" + bookmarks[i] + "', " +
-                            "'" + bookmarkDestination + "', " +
-                            "0," +
-                            parent + "," +
-                            Integer.toString(googleSize + i) + "," +
-                            now +
-                            ");");
-
-                    int faviconId = preloads.getResourceId(i, 0);
-                    int thumbId = preloads.getResourceId(i + 1, 0);
-                    byte[] thumb = null, favicon = null;
-                    try {
-                        thumb = readRaw(res, thumbId);
-                    } catch (IOException e) {
-                    }
-                    try {
-                        favicon = readRaw(res, faviconId);
-                    } catch (IOException e) {
-                    }
-                    if (thumb != null || favicon != null) {
-                        ContentValues imageValues = new ContentValues();
-                        imageValues.put(Images.URL, bookmarkDestination.toString());
-                        if (favicon != null) {
-                            imageValues.put(Images.FAVICON, favicon);
-                        }
-                        if (thumb != null) {
-                            imageValues.put(Images.THUMBNAIL, thumb);
-                        }
-                        db.insert(TABLE_IMAGES, Images.FAVICON, imageValues);
-                    }
-                }
-            } catch (ArrayIndexOutOfBoundsException e) {
-            } finally {
-                preloads.recycle();
             }
         }
 
diff --git a/src/com/android/browser/search/SearchEngines.java b/src/com/android/browser/search/SearchEngines.java
index 91bddc8..64497c3 100644
--- a/src/com/android/browser/search/SearchEngines.java
+++ b/src/com/android/browser/search/SearchEngines.java
@@ -35,19 +35,11 @@
 
     public static List<SearchEngineInfo> getSearchEngineInfos(Context context) {
         ArrayList<SearchEngineInfo> searchEngineInfos = new ArrayList<SearchEngineInfo>();
-        Resources res = context.getResources();
-        String[] searchEngines = res.getStringArray(R.array.search_engines);
-        // add for carrier feature - preset search engine
-        String browserRes = res.getString(R.string.config_carrier_resource);
+        String[] searchEngines = context.getResources().getStringArray(R.array.search_engines);
         for (int i = 0; i < searchEngines.length; i++) {
             String name = searchEngines[i];
-            if ("cmcc".equals(browserRes)) {
-                SearchEngineInfo info = new SearchEngineInfo(context, name);
-                searchEngineInfos.add(info);
-            } else if (!name.startsWith("cmcc")) {
-                SearchEngineInfo info = new SearchEngineInfo(context, name);
-                searchEngineInfos.add(info);
-            }
+            SearchEngineInfo info = new SearchEngineInfo(context, name);
+            searchEngineInfos.add(info);
         }
         return searchEngineInfos;
     }