Saturday, July 18, 2015

Lollipop

Man, that was a doozy.

I've had my Nexus 10 for a while now. I still haven't named my Nexus 10 yet, though I am veering towards calling it Eirian III. Eirian II is still going strong, and I have a tendency to take her out for a spin every month or two -- there are just some things were the E-Ink screen works better than your typical LCD display. In fact, for heavy reading (think more than 100 pages in a day), it is more comfortable to read on an E-Ink screen than a non-E-Ink one.

A pity that the Kindle DX is basically extinct, and that Amazon isn't really going to resurrect the larger form factor, deferring instead towards a high resolution (200+ ppi) displays in a 6-inch form factor, a format that I feel is quite useless for A4/letter-sized PDFs.

Anyway, my Nexus 10 shipped with Android 4.2 ``Jelly Bean'', and at the time of purchase the CyanogenMod version wasn't ready for it. And so I had been running the stock Android image for as long as I can remember.

My biggest beef with the stock Android image is that there is just so little... control that is available, without rooting the device. I don't trust Big Corp to have my interests as a priority, and thus prefer that anything that I paid money for should have the option of allowing me full control over it -- I am willing to take on the responsibility of undoing any damage done by my own stupidity, as long as I had the power to enact all the control that I care to give. In particular, I am very annoyed at the advertising.

Advertising is the bane of all things relating to the web. On the one hand, it sounds like a fair trade to provide ``free'' content at the expense of a few advertisements, but on the other hand, advertisers tend to cross the gray area of what is acceptable by either being more intrusive, or even downright misleading. I blame this on a couple of factors, namely the laziness of web site owners in managing their own advertising, and the negative side of the ``network effect''.

Most advertisements on web sites do not come from the web site owners themselves, they are instead delivered from one of many ad-networks, farms of servers whose operators act as a type of aggregation point for anyone who wants to run an advertisement. This... market arises naturally due to the cumulative heft of such ad-networks in fulfilling the two requirements of a successful advertising platform -- largest reach for those who want to advertise and a single point of contact and out-sourced management for those who want to have advertising dollars to support their sites.

Initially, I was neutral with respect to advertising on the web. Then it started to get obnoxious. Bandwidth was wasted in running large payloads of advertisements instead of the content that one was looking for, then the increasingly shady practices of the ad-networks allowing malware and downright unethical methods of gaining those click-throughs proliferated. Basically, ad-networks have turned from a somewhat tolerable nuisance to an unwanted harassment.

On the desktop, it is easy to mitigate these. Web browsers have various plugins that aid in blocking access to these ad-networks, which have the dual benefit of making pages load faster and saving of precious bandwidth particularly on those with quotas on them (think mobile internet or dial-up).

But the phone, or technically, the smart phone -- it is hard to use such tools. For one, actual control is hard to get at for such locked down devices. Android may be open source, but once the environment is ``live'', it is hard to impossible to enact controls on the fly. For two, much of the ads are found within the applications themselves, and by decree there cannot exist tools that publicly block ad-networks system-wide. Couple that with the misleading display graphics of the ads in question, it is a no brainer that the phone environment is particularly susceptible to bad ad-networks, especially since their user interface is error prone to begin with -- it is easy to ``slip'' and click the wrong damn button.

So what has this got to do with the ability to root? The answer is this file: /system/etc/hosts. That's a file that the underlying DNS look up libraries respect to obtain the equivalent IP addresses for a given domain name provided. With the proper set up, it is possible to hijack the domain name of the ad-network and redirect it to nothing, thus stopping the access of the ad-network at the lowest level of the OSI layers. This means that we have a system-wide (though crude) way of eliminating those pesky ad-networks.

CyanogenMod provides such powers on the get-go, and that's the reason why my Galaxy Nexus phone runs that instead of stock. But the Nexus 10, well, as you can tell from the link, development for it is sort of... slow to non-existent. So, I just load in the latest and greatest factory images (Lollipop 5.1.1 at writing) instead and root that instead and use the new root powers to load up a custom hosts file that will prevent access to the ad-networks' machines.

There is, however, a catch.

Unlike CyanogenMod, the stock factory images are very stingy in setting up the system partition -- there is literally no space for the 500kiB needed to load the custom hosts file. The way in which I discovered how to workaround that is something that I probably won't write about here. The principle though, is rather simple -- make space by deleting files already in system.

And so now, my Nexus 10 is running Android 5.1.1, somewhat secured from the dastardly ad-networks, complete with the obligatory screenshot:

I don't think I have anything else to write about now. Till the next update, I suppose?

No comments: