[Android Software/Hacking General [Developers Only]] MotoCache1:
I've noticed since upgrading my Droid X to Gingerbread that many websites that were previously fooled by setting the User Agent (in Dolphin HD) to "desktop" are no longer fooled and can now detect that I'm on a mobile device. This can be quite irritating as the mobile version of many sites is horrible.

To see if this article pertains to you, if you're set for a desktop user agent string, go to http://www.bbc.co.uk and see if you get the mobile version of the page or the desktop version. If you get the mobile version despite your user agent setting, this hack may help you.

When this first happened to me I decided to find out how the sites were detecting the fact that I'm on a mobile device. Generally a website only knows what you tell it about yourself, and what you tell it about yourself is 100% in the HTTP headers your browser sends (or that get added by a proxy server if you use one). So the first logical place to look was to see what all headers the browser was sending. Note: for any who might object that it also knows things about you by your cookies, your cookies are actually sent as HTTP headers as well.

I have a CGI script on one of my web servers that I use to see what all headers my browser is passing. There are plenty such scripts/sites on the web -- here is a decent one (it's not mine) if you want to see what your browser sends. Examining the headers, one stuck out like a sore thumb:

HTTP_X_WAP_PROFILE='http://uaprof.vtext/com/mot/mb810/mb810.xml'

Geez, that's a pretty dead giveaway isn't it? I checked a phone running FroYo and it does not send that header, so that further confirms this is the header these sites use to detect me as a mobile (since they don't detect me as a mobile under FroYo and do under Gingerbread).

I then Googled HTTP_X_WAP_PROFILE and found numerous coding resources where they suggest looking to see if that header exists and/or is set to anything in order to detect mobile browsers. Bingo.

Great - so how to get rid of it? My first thought is that since the header is clearly identifying me as a Droid X (MB810), there has to be something in the phone that is providing the data. Since I observed that the header is present whether I access the net via WiFi or via 3G, that further confirmed that this is all happening in the phone and not being added by Verizon in transit.

The first sensible place to look was /system/build.prop. Turns out that the first sensible place to look was the right place to look as I found this line:

ro.mot.hw.uaprof='http://uaprof.vtext/com/mot/mb810/mb810.xml'

Well, that's about as perfect as you could ask for. Not knowing if the phone might be touchy about completely removing this setting, my first attempt was to change the line to read like this:

ro.mot.hw.uaprof=''

I found that you must reboot the phone for the setting to take effect (no real surprise there). Unfortunately, afterward, when I examined the headers being sent by the browser, they now contained this:

HTTP_X_WAP_PROFILE=''

With that setting, the various websites still detected me as a mobile browser (which you would expect). Next I tried changing the build.prop to this:

ro.mot.hw.uaprof=

* Note - there is nothing after the equal sign - not a space or anything, just a carrriage return.

This (pleasantly) resulted in the HTTP_X_WAP_PROFILE header being completely absent -- the ideal outcome. Happily, the various websites that were detecting me as a mobile no longer did. Success!

In the interest of being thorough, I tested just removing the ro.mot.hw.uaprof setting altogether (by commenting out the line). I figured that probably was not the best plan, but I wanted to see what would happen. When I did that, the following header was the result:

ro.mot.hw.uaprof='http://uaprof.motorola.com/phoneconfig/MotoMB200/profile/MotoMB200.rdf'

Interesting default value -- and of course I was again identifiable as a mobile device.

So, the fix for this is pretty simple. The exact property that needs to be modified in your build.prop would of course vary if you're not running a Motorola build, but I'd expect it to be readily identifiable. Of course you have to be rooted to do this, and of course you should make a backup copy of your build.prop before you modify it, and of course you should think about what your fallback recovery is going to be if you foul up your build.prop and end up in a boot loop or something. Can you boot into Recovery and then fix the file with ADB, etc. -- it all depends on how your phone is set up.

For those that like step-by-step, here's precisely what I did:

Open Root Explorer (or other "root aware" editor)

Navigate to /system

Mount system as R/W

Open build.prop in text editor

Find the ro.mot.hw.uaprof line

Put a # at the beginning of the existing line (to make it into a comment)

Insert a new line below the existing line that says "ro.mot.hw.uaprof=" (without the double quotes -- no characters after the equal sign)

Save and exit editor

Mount system as R/O

Reboot phone

By doing it this way I end up with a backup copy of the original string in case I want to easily put it back. Root explorer automatically saves the original build.prop as build.prop.bak, but if you're really cautious you might want to actually make a copy of the file to your SD card or something.

At this point, in Dolphin HD, with my user agent string set to Desktop, all of the web sites that had begun seeing me as a mobile device now serve the normal desktop page (as desired). If I want to see the mobile version (for some reason) I can just switch Dolphin HD back to Android mode (user agent string) and then I get the mobile version.

Hope this helps someone. Sorry it was so long -- almost everything I write up is.

P.S. If you do this successfully on a non-Motorola phone, post here and let others know.