Merge "Browser: add to customize and show useragent"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9b29fd2..13f13b3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -54,6 +54,9 @@
                    android:hardwareAccelerated="true"
                    android:taskAffinity="android.task.browser" >
 
+        <uses-library android:name="com.qrd.useragent"
+                      android:required="false" />
+
         <provider android:name=".provider.BrowserProvider2"
                   android:authorities="com.android.browser;browser"
                   android:multiprocess="false"
diff --git a/res/menu/browser.xml b/res/menu/browser.xml
index 9be1208..9578026 100644
--- a/res/menu/browser.xml
+++ b/res/menu/browser.xml
@@ -104,6 +104,9 @@
         <item
             android:id="@+id/exit_menu_id"
             android:title="@string/exit" />
+        <item
+            android:id="@+id/about_menu_id"
+            android:title="@string/about" />
         <!-- followings are debug only -->
         <item
             android:id="@+id/dump_nav_menu_id"
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
old mode 100755
new mode 100644
index bd751cc..afe3b9f
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -407,4 +407,7 @@
 
     <!-- Add for Carrier Feature.Content description for exit menu item -->
     <string name="exit">退出</string>
+
+    <!-- Add for Carrier Feature.Content description for about menu item -->
+    <string name="about">关于</string>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
old mode 100755
new mode 100644
index 14e3ca5..e03b576
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1022,4 +1022,6 @@
     <!-- Add for Carrier Feature.Content description for exit menu item -->
     <string name="exit">Exit</string>
 
+    <!-- Add for Carrier Feature.Content description for about menu item -->
+    <string name="about">About</string>
 </resources>
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 74eede7..c548322 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -17,6 +17,7 @@
 package com.android.browser;
 
 import android.app.Activity;
+import android.app.AlertDialog;
 import android.app.KeyguardManager;
 import android.content.Context;
 import android.content.Intent;
@@ -34,6 +35,8 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.Window;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
 import android.webkit.JavascriptInterface;
 
 import com.android.browser.UI.ComboViews;
@@ -239,6 +242,22 @@
                     }
                 }, 300);
             }
+            if (item.getItemId() == R.id.about_menu_id) {
+                final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+                builder.setTitle(R.string.about);
+                builder.setCancelable(true);
+                String ua = "";
+                final WebView current = getController().getCurrentWebView();
+                if (current != null) {
+                    final WebSettings s = current.getSettings();
+                    if (s != null) {
+                        ua = s.getUserAgentString();
+                    }
+                }
+                builder.setMessage("Agent:" + ua);
+                builder.setPositiveButton(android.R.string.ok, null);
+                builder.create().show();
+            }
             return super.onOptionsItemSelected(item);
         }
         return true;
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index c390ab6..9e0971d 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -33,6 +33,7 @@
 import android.provider.Settings;
 import android.util.DisplayMetrics;
 import android.util.Log;
+import android.util.Log;
 import android.webkit.CookieManager;
 import android.webkit.GeolocationPermissions;
 import android.webkit.WebIconDatabase;
@@ -53,7 +54,9 @@
 import com.android.browser.search.SearchEngines;
 
 import java.io.InputStream;
+import java.lang.Class;
 import java.lang.ref.WeakReference;
+import java.lang.reflect.Method;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Locale;
@@ -94,6 +97,8 @@
             HONEYCOMB_USERAGENT,
     };
 
+    private static final String TAG = "BrowserSettings";
+
     // The minimum min font size
     // Aka, the lower bounds for the min font size range
     // which is 1:5..24
@@ -342,7 +347,18 @@
         settings.setSaveFormData(saveFormdata());
         settings.setUseWideViewPort(isWideViewport());
 
-        String ua = mCustomUserAgents.get(settings);
+        // add for carrier useragent feature
+        String ua = null;
+        try {
+            Class c = Class.forName("com.qrd.useragent.UserAgentHandler");
+            Object cObj = c.newInstance();
+            Method m = c.getDeclaredMethod("getUAString", Context.class);
+            ua = (String)m.invoke(cObj, mContext);
+        } catch (Exception e) {
+            Log.e(TAG, "plug in Load failed, err " + e);
+            ua = mCustomUserAgents.get(settings);
+        }
+
         if (ua != null) {
             settings.setUserAgentString(ua);
         } else {