FORUMS

Sunday Debate: How Can We Get a No-Compromise Phone?

Join us in a fun Sunday Debate on Compromises. Come with your opinions and … more

PSA: You Can Optimize Your Note 4’s Recents Menu & RAM

The Note 4 never had the fastest Recents Menu, and despite its 3GB of RAM, … more

XDA Picks: Best Apps of the Week (July 25 – Aug 1)

Apps are at the front and center of any smartphone experience, and with over a … more

Voices Of XDA: Orbiting The Earth With Android

Editor’s note: This week’s feature has been written by forum … more

[PATCH/TESTING]: Avoiding mobile browser detection (EC05-ish)

153 posts
Thanks Meter: 318
 
By Fnorder, Senior Member on 1st October 2011, 06:56 PM
Post Reply Subscribe to Thread Email Thread
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:
Code:
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:
Code:
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
Attached Files
File Type: zip uaprof-patches.zip - [Click for QR Code] (1.4 KB, 37 views)
Last edited by Fnorder; 1st October 2011 at 06:58 PM.
The Following 5 Users Say Thank You to Fnorder For This Useful Post: [ View ]
 
 
1st October 2011, 07:03 PM |#2  
OP Senior Member
Flag Lake Vostok
Thanks Meter: 318
 
More
One final note; gawker websites are -horribly- coded and try to pre-cache all sorts of junk. They actually -need- the mobile site, and will run like molassis unless you block
the following:
||dyn-cache.io9.com^
||dyn-cache.lifehacker.com^
||dyn-cache.gizmodo.com^
http://hyperion.gawker.com^
http://fastcache.gawkerassets.com/as.../*/*/*/xsmall_
http://fastcache.gawkerassets.com/as...s/*/*/*/micro_
1st October 2011, 07:15 PM |#3  
Xhyperion's Avatar
Senior Member
Flag Miami
Thanks Meter: 55
 
Donate to Me
More
You did all this just for the hate of gawker? I understand but daaaammmn

Sent from my SPH-D700 using xda premium
1st October 2011, 10:22 PM |#4  
OP Senior Member
Flag Lake Vostok
Thanks Meter: 318
 
More
Actually it was one too many wordpress.com blogs that did it. Their idea of 'mobile-friendly' is rather minimalist.
3rd October 2011, 02:02 PM |#5  
nerdtaco's Avatar
Senior Member
Flag Lexington Park
Thanks Meter: 27
 
More
Porn sites do the same ****

Sent from my SPH-D700 using xda premium
The Following User Says Thank You to nerdtaco For This Useful Post: [ View ]
3rd October 2011, 03:22 PM |#6  
Senior Member
Thanks Meter: 1,253
 
More
Quote:
Originally Posted by nerdtaco

Porn sites do the same ****

Sent from my SPH-D700 using xda premium

And there isn't a smali patch to get yourself a girlfriend, that still needs to be done the old fashioned way

Wait... I'm not saying knock her out and drag her home by the hair... Much easier, I would imagine, but a little TOO old fashioned...

Sent from my SPH-D700 using XDA App
The Following 2 Users Say Thank You to styles420 For This Useful Post: [ View ]
3rd October 2011, 04:47 PM |#7  
Senior Member
Thanks Meter: 11
 
More
Quote:
Originally Posted by nerdtaco

Porn sites do the same ****

Sent from my SPH-D700 using xda premium

lol

10chars
6th October 2011, 04:32 PM |#8  
Ceelos09's Avatar
Senior Member
Thanks Meter: 291
 
More
Any way these patches could be put together into a CWM flashable zip?

Sent from my SPH-D700 using xda premium
6th October 2011, 06:03 PM |#9  
Senior Member
O 'Fallon, MO
Thanks Meter: 406
 
More
Quote:
Originally Posted by Ceelos09

Any way these patches could be put together into a CWM flashable zip?

Sent from my SPH-D700 using xda premium

Nope. Well, possibly. But it'd kinda be like a theme. Build-specific.

sent from my miui-ified epic
7th October 2011, 09:47 AM |#10  
lafronz's Avatar
Senior Member
Flag Fort Gordon
Thanks Meter: 13
 
Donate to Me
More
Or you can just use skyfire...

Sent from my SPH-D700 using Tapatalk
8th October 2011, 05:07 AM |#11  
Senior Member
Thanks Meter: 136
 
More
Quote:
Originally Posted by lafronz

Or you can just use skyfire...

Sent from my SPH-D700 using Tapatalk

Opera Mobile also has an option to set it as a desktop agent.

Read More
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes