[Epic 4G Android Development] Fnorder:
ONLY TESTED WITH EC05's library! (SRF 1.1)

DON'T BLAME ME IF YOU TRY THIS IN SOMETHING ELSE AND IT EATS YOUR PHONE AND/OR VILLAGE

This adds AdBlockPlus-(mostly)-compatible filtering to WebKit on Samsung's EC05. Why do this, when there's an app to auto-update /etc/hosts with a blocklist? Because /etc/hosts will only block full hostnames. This can block specific urls, with pattern matching, useful for filtering specific content from an entire domain:

http://*.wikia.com/*/oasis*_js
http://ads.*.com/tracking/*$script
||entiredomain.com/*.jpg
http://lolblog.hosts-own-banners.com/img/*

And it has a whitelist:

@@http://lolblog.hosts-own-banners.com/img/article*.png

This will affect all browsers and apps that use WebKit, and should remove some in-app ads as well.

Best of all, this only involves flashing a shared library; No hair-pulling due to signing issues. The included adblock.txt also fixes wikia sites, which crash froyo browsers in desktop mode.

How to install

* put webcore-ec05-orig.zip on your sdcard, so you can restore stock if needbe.

* put webcore-ec05-ab1.zip on sdcard and flash in CWM

* put the example adblock.txt in /data/adblock.txt. chmod 0644 /data/adblock.txt.

* ignore ab-vs-ec05.diff unless you want to roll your own

* Optionally, get http://easylist-downloads.adblockplus.org/easylist_noelemhide.txt and remove instances of bad syntax (see below)

Release 3: huge efficiency boost

added: log third party items (blocked or allowed): touch /data/.ab-logthirdparty

added: log all items (blocked or allowed): touch /data/.ab-logallow (which in testing made me discover...)

fixed: no longer runs shouldBlock() 3 times for every image/item/etc (not my bug! :P)

fixed: re-added missing external/webcore/WebKit/... portion to patch

Release 2:

added: $third-party support that actually checks for third party domain. More compatible with adblockplus subscription lists.

added: Blocklist will be reloaded if /data/adblock.txt changes. No need to restart browser. turn off with "touch /data/.ab-noautoreload"

added: Logs blocked items. turn off with "touch /data/.ab-nologging"

fixed: domain.com^

fixed: blank lines in adblock.txt no longer block everything.

I've been using a list based off of easyprivacy with 3k blocks for awhile and am also attaching this. If you use facebook or twitter you may want to add $third-party to the end of those entires.

Caveats

* Did I mention this has only been tested on EC05?

* The filter parser still needs work, don't expect full compatibility with Firefox adblock rules. Broken stuff includes:

|full.subdomain.com/*: use |http://full.subdomain.com/*
||http://entiredomain.com: use ||entiredomain.com
anything-that-has/options/that/are/not$match-case,third-party,image,stylesheet,script,subdocument

Original code by: http://vogue-android.blogspot.com/2009/01/adblock-for-webkitandroid.html

Gingerbread port: http://jahrome.free.fr/index.php/block-ads-android-adblock-browser-webkit?lang=en

EC05 backport changes:

* moved blocklist to /data/adblock.txt

* Improved AdBlockPlus filterlist compatibility: ||domainmatch, everypath^, workaround$third-party.

Q: I want to try this on an EH06, EG22, EF02/EF10, EE03, EC05, EB13, DK28 etc based ROM but don't want to kill my village! How do I know if it'll work?

A: md5sum /system/lib/libwebcore.so, if you see 54a7e97d99383c7f8e743154ad5e6dc1 it'll definitely work.

If you don't, it -might- work, but check for missing symbols:

unzip -p /sdcard/webcore-ec05-ab1.zip > /sdcard/new.so
strings /system/lib/libwebcore.so /sdcard/new.so |grep ............|egrep -v "[\'\+\\*:\!\(\)=/ ]" |sort -n|uniq -c|egrep -v ' [0-9]?[24680] '

You should see nothing, or crap strings like '3i#`4afh:F0F_'.

If you see anything that looks like a symbol: '_ZN7SkPaint11setXfermodeEP10SkXfermode', '__aeabi_ldivmod', 'nativeSetError', etc, it will probably need to be ported.

Q: I want to make this suck less, how do I shot build?

A:

* get: froyo source: curl https://android.git.kernel.org/repo > repo ; chmod a+x repo ; ./repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo ; ./repo sync

* get: SPH-D700_Froyo_EC05.tar.gz from https://opensource.samsung.com/ (search for 'ec05')

* copy over opensrc/dalvik and opensrc/external/webkit from SPH_D700_Froyo_Platform.tar

* run: patch -l -p0 < /path/to/ab-vs-ec05.diff

* edit: build/core/combo/TARGET_linux-arm.mk to have TARGET_ARCH_VARIANT := armv7-a

* edit: build/core/combo/arch/arm/armv7-a.mk, changing -mfpu=vfpv3-d16 to -mfpu=vfpv3

* . build/envsetup

* run: lunch

* select: generic

* run: make

* check out/target/product/generic/system/lib/libwebcore.so before flashing (see above)