[Epic 4G Android Development] Fnorder:
Some of you may have noticed that, despite changing the User-Agent in the browser, you are still sent to a mobile website anyway. Gawker media (io9, lifehacker, gizmodo, etc) is especially obnoxious as there is no way to disable this, and the redirect fires when you hit the back button, keeping you trapped. Blogs hosted on wordpress.com have an option to view the full site, but you must select this for each blog.

These sites detect the UAProf (X-Wap-Profile) header, which android's web framework tacks onto every request. On the Epic - unlike other phones - there is no way to disable this using hiddenmenu; X-Wap-Profile: http://device.sprintpcs.com/Samsung/SPH-D700/EC05.rdf is hardcoded.

To further complicate matters, Google checkin, MMS, and Sprint Market purchasing all use webkit, and break if this header is suppressed.

Below are two smali patches that suppress the header in different ways. Only one is meant to be applied.

#1 is strict, and suppresses UAProf unless the User-Agent contains 'Android' or 'GoogleLog'. I have -not- tested this against the stock MMS client, but it works perfectly with AOSP provided you select the Android User-Agent.

#2 only suppresses UAProf if the User-Agent string contains 'Windows', which means it won't work for browsers that try to masquerade as a linux or mac browser in desktop mode.

I've tested patch#1 on SRF 1.1, with Dolphin Browser 4.x and AOSP MMS.

To apply:

$ adb pull /system/framework.jar .

$ apktool d framework.jar

$ unzip -p /somewhere/uaprof-patches.zip uaprof-1.diff.txt | patch -l -p0

-OR-

$ unzip -p /somewhere/uaprof-patches.zip uaprof-2.diff.txt | patch -l -p0

$ apktool b framework.jar.out

$ zip -ju framework.jar build/apk/classes.dex

I've thrown framework.jar directly back into /system/framework and rebooted without issue, but to play it safe you may wish to create an update.zip and backup before flashing in CWM.

Patch1:

diff -ur orig-framework.jar.out/smali/android/webkit/FrameLoader.smali framework.jar.out/smali/android/webkit/FrameLoader.smali
--- orig-framework.jar.out/smali/android/webkit/FrameLoader.smali 2011-10-01 15:09:02.000000000 +0000
+++ framework.jar.out/smali/android/webkit/FrameLoader.smali 2011-10-01 17:21:36.000000000 +0000
@@ -744,7 +744,7 @@
.end method

.method private populateStaticHeaders()V
- .locals 8
+ .locals 10

.prologue
const-string v6, "Accept"
@@ -824,6 +824,16 @@

move-result-object v6

+# UAProfMod
+ const-string v8, "Android"
+ invoke-virtual {v6, v8}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
+ move-result v8
+ const-string v9, "GoogleLog"
+ invoke-virtual {v6, v9}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
+ move-result v9
+
+# /UAProfMod
+
invoke-interface {v4, v5, v6}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

.line 369
@@ -851,6 +861,12 @@
.local v2, ver:Ljava/lang/String;
iget-object v4, p0, Landroid/webkit/FrameLoader;->mHeaders:Ljava/util/Map;

+# UAProfMod
+ if-nez v9, :cond_4
+ if-eqz v8, :cond_3
+ :cond_4
+# /UaProfMod
+
const-string v5, "X-Wap-Profile"

new-instance v6, Ljava/lang/StringBuilder;
@@ -879,6 +895,10 @@

invoke-interface {v4, v5, v6}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

+# UAProfMod
+ :cond_3
+# /UAProfMod
+
.line 375
return-void
.end method

Patch2:

diff -ur orig-framework.jar.out/smali/android/webkit/FrameLoader.smali framework.jar.out/smali/android/webkit/FrameLoader.smali
--- orig-framework.jar.out/smali/android/webkit/FrameLoader.smali 2011-10-01 15:09:02.000000000 +0000
+++ framework.jar.out/smali/android/webkit/FrameLoader.smali 2011-10-01 17:19:06.000000000 +0000
@@ -744,7 +744,7 @@
.end method

.method private populateStaticHeaders()V
- .locals 8
+ .locals 9

.prologue
const-string v6, "Accept"
@@ -824,6 +824,12 @@

move-result-object v6

+# UAProfMod
+ const-string v8, "Windows"
+ invoke-virtual {v6, v8}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
+ move-result v8
+# /UAProfMod
+
invoke-interface {v4, v5, v6}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

.line 369
@@ -851,6 +857,10 @@
.local v2, ver:Ljava/lang/String;
iget-object v4, p0, Landroid/webkit/FrameLoader;->mHeaders:Ljava/util/Map;

+# UAProfMod
+ if-nez v8, :cond_3
+# /UaProfMod
+
const-string v5, "X-Wap-Profile"

new-instance v6, Ljava/lang/StringBuilder;
@@ -879,6 +889,10 @@

invoke-interface {v4, v5, v6}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

+# UAProfMod
+ :cond_3
+# /UAProfMod
+
.line 375
return-void
.end method