Bug 1264076 - Allow customized device string for user agent on Fennec; r=mcmanus a=lizzard
authorMichael Kaply <mozilla@kaply.com>
Wed, 13 Apr 2016 20:46:13 -0500
changeset 325854 6e15177d45741c5c4b00c343100d581a9014c723
parent 325853 51ec91ed78a5cd33e600b82512f5b8357d524254
child 325855 0c6e295e6f0a9aef71d04c8167166cdbf3975ca8
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, lizzard
bugs1264076
milestone47.0a2
Bug 1264076 - Allow customized device string for user agent on Fennec; r=mcmanus a=lizzard MozReview-Commit-ID: 4PNVWNSphEV
mobile/android/confvars.sh
netwerk/protocol/http/nsHttpHandler.cpp
--- a/mobile/android/confvars.sh
+++ b/mobile/android/confvars.sh
@@ -86,17 +86,17 @@ MOZ_ANDROID_SEARCH_ACTIVITY=1
 
 # Enable the Mozilla Location Service stumbler.
 MOZ_ANDROID_MLS_STUMBLER=1
 
 # Enable adding to the system downloads list.
 MOZ_ANDROID_DOWNLOADS_INTEGRATION=1
 
 # Build and package the install bouncer APK by default.
-MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER=1
+#MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER=1
 
 # Use the low-memory GC tuning.
 export JS_GC_SMALL_CHUNK_SIZE=1
 
 # Enable GCM registration on Nightly builds only.
 if test "$NIGHTLY_BUILD"; then
   MOZ_ANDROID_GCM=1
 fi
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -121,24 +121,34 @@ NewURI(const nsACString &aSpec,
 
     url.forget(aURI);
     return NS_OK;
 }
 
 #ifdef ANDROID
 static nsCString
 GetDeviceModelId() {
+    // Assumed to be running on the main thread
+    // We need the device property in either case
+    nsAutoCString deviceModelId;
     nsCOMPtr<nsIPropertyBag2> infoService = do_GetService("@mozilla.org/system-info;1");
     MOZ_ASSERT(infoService, "Could not find a system info service");
     nsAutoString androidDevice;
     nsresult rv = infoService->GetPropertyAsAString(NS_LITERAL_STRING("device"), androidDevice);
     if (NS_SUCCEEDED(rv)) {
-        return NS_LossyConvertUTF16toASCII(androidDevice);
+        deviceModelId = NS_LossyConvertUTF16toASCII(androidDevice);
     }
-    return EmptyCString();
+    nsAutoCString deviceString;
+    rv = Preferences::GetCString(UA_PREF("device_string"), &deviceString);
+    if (NS_SUCCEEDED(rv)) {
+        deviceString.Trim(" ", true, true);
+        deviceString.ReplaceSubstring(NS_LITERAL_CSTRING("%DEVICEID%"), deviceModelId);
+        return deviceString;
+    }
+    return deviceModelId;
 }
 #endif
 
 //-----------------------------------------------------------------------------
 // nsHttpHandler <public>
 //-----------------------------------------------------------------------------
 
 nsHttpHandler *gHttpHandler = nullptr;