summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-09-22 22:04:05 -0400
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-09-22 22:04:05 -0400
commitc3c6621a2cf2f0d40d062dcad1c9f65485473841 (patch)
treeee9898bb772c74b567eb0003ea9b8949b277f821 /core
parentdf5862173c03f0d9595a2a5cb56c4af407d893dd (diff)
parentd0f80d445644bfc08b62339f01766b924e42dc4d (diff)
downloadframeworks_base-c3c6621a2cf2f0d40d062dcad1c9f65485473841.zip
frameworks_base-c3c6621a2cf2f0d40d062dcad1c9f65485473841.tar.gz
frameworks_base-c3c6621a2cf2f0d40d062dcad1c9f65485473841.tar.bz2
Merge change 25879 into eclair
* changes: Setting the default HTTP user agent at runtime init.
Diffstat (limited to 'core')
-rw-r--r--core/java/com/android/internal/os/RuntimeInit.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java
index 4e6f9ca..c782c8c 100644
--- a/core/java/com/android/internal/os/RuntimeInit.java
+++ b/core/java/com/android/internal/os/RuntimeInit.java
@@ -25,6 +25,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.os.Build;
import android.server.data.CrashData;
import android.util.Config;
import android.util.Log;
@@ -111,6 +112,12 @@ public class RuntimeInit {
new AndroidConfig();
/*
+ * Sets the default HTTP User-Agent used by HttpURLConnection.
+ */
+ String userAgent = getDefaultUserAgent();
+ System.setProperty("http.agent", userAgent);
+
+ /*
* If we're running in an emulator launched with "-trace", put the
* VM into emulator trace profiling mode so that the user can hit
* F9/F10 at any time to capture traces. This has performance
@@ -126,6 +133,36 @@ public class RuntimeInit {
}
/**
+ * Returns an HTTP user agent of the form
+ * "Dalvik/1.1.0 (Linux; U; Android Eclair Build/MASTER)".
+ */
+ private static String getDefaultUserAgent() {
+ StringBuilder result = new StringBuilder(64);
+ result.append("Dalvik/");
+ result.append(System.getProperty("java.vm.version")); // such as 1.1.0
+ result.append(" (Linux; U; Android ");
+
+ String version = Build.VERSION.RELEASE; // "1.0" or "3.4b5"
+ result.append(version.length() > 0 ? version : "1.0");
+
+ // add the model for the release build
+ if ("REL".equals(Build.VERSION.CODENAME)) {
+ String model = Build.MODEL;
+ if (model.length() > 0) {
+ result.append("; ");
+ result.append(model);
+ }
+ }
+ String id = Build.ID; // "MASTER" or "M4-rc20"
+ if (id.length() > 0) {
+ result.append(" Build/");
+ result.append(id);
+ }
+ result.append(")");
+ return result.toString();
+ }
+
+ /**
* Invokes a static "main(argv[]) method on class "className".
* Converts various failing exceptions into RuntimeExceptions, with
* the assumption that they will then cause the VM instance to exit.