Backup+ Lets You Backup Your App Data on Android Lollipop

Even though Android 5.0 Lollipop hasn’t yet seen its official release, quite … more

TechTalk Compiles All the Android News You Need in One App

If you’re as obsessed with mobile devices as the vast majority of our forum … more

Android App Review: Google Inbox to Improve Your Life – XDA TV

Recently, Google+ exploded with the announcement of Google Inbox, as … more

Damp the LG G3 Thermal Throttling

As our mobile devices grow thinner and more powerfulwith each passing generation, it’s inevitable … more
Post Reply

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

OP Fnorder

1st October 2011, 06:56 PM   |  #1  
OP Senior Member
Flag Lake Vostok
Thanks Meter: 318
 
153 posts
Join Date:Joined: Nov 2008
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, 31 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
 
153 posts
Join Date:Joined: Nov 2008
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
 
952 posts
Join Date:Joined: Oct 2010
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
 
153 posts
Join Date:Joined: Nov 2008
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
 
219 posts
Join Date:Joined: Sep 2008
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
 
2,177 posts
Join Date:Joined: Nov 2010
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
 
128 posts
Join Date:Joined: Aug 2010
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: 284
 
1,005 posts
Join Date:Joined: Apr 2011
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
 
1,485 posts
Join Date:Joined: Jun 2011
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
 
131 posts
Join Date:Joined: Sep 2010
Donate to Me
More
Or you can just use skyfire...

Sent from my SPH-D700 using Tapatalk

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

Advanced Search
Display Modes


Top Threads in Epic 4G Android Development by ThreadRank