How to filter ads on your G1

duckredbeard

Senior Member
Aug 21, 2010
1,432
189
0
I believe I did a similar process...I am already rooted, of course. Using Root Explorer for file management.

1. Downloaded the hosts file from just a few posts back.
2. Extracted it to a known folder.
3. Renamed the existing hosts file "hostsx"
4. Copied the extracted hosts file to /data/data where I found the other one
5. Moved the "hostsx" file to a safe place.
6. Rebooted and launched adfree.

No improvement. If there is any critical detail from your process, let me know, and I will try it your way. I don't see much difference, but this isn't my forte.
 

JimmyLeeBillyBob

Senior Member
Apr 4, 2011
65
5
0
You shouldn't launch adfree because it will overwrite the hosts file you just added. Since you already know how to add the hosts file manually there's really no need for you to use adfree anymore. At least not since adfree added some weird authentication option and runs in the background and is all secretive about the most recent changelogs. Also the hosts file adfree uses doesn't really block a lot anymore since around June 15 or so.
 

duckredbeard

Senior Member
Aug 21, 2010
1,432
189
0
So that is it? Uninstall adfree and just go with the manual "hosts" file change and I'm good? Can anyone confirm this? Anyone see this work on an HTC Aria/Liberty/Gratia/Intruder?
 

hiddenhandgun

Member
Jun 10, 2010
38
7
0
I'm updating my hosts with Tasker, the Locale execute plugin, and cURL.
You can get cUrl for android at

http://code.google.com/p/android-nixutils/downloads/list

and copy it into /system/xbin

I made a simple script to download the hosts file, "update-hosts.sh"
and placed it into /sdcard/scripts

Code:
#!/system/xbin/bash
/system/xbin/curl -o /data/data/hosts http://winhelp2002.mvps.org/hosts.txt
For whatever reason issuing the curl command directly in the Locale execute plugin borks.

Create a new task in Tasker using the Locale execute plugin as such:

Code:
!/system/xbin/bash /sdcard/scripts/update-hosts.sh
The bang at the beginning of the line invokes root

Volia! Your hosts will update whenever you run the task.
 

JimmyLeeBillyBob

Senior Member
Apr 4, 2011
65
5
0
OK, I'm offically out of ideas. I tried all sorts of things now and nothing worked. I got the hosts file from a friend who uses adfree and has no ads anywhere. I put the hosts file in /data/data, fixed the owner and the permissions. Then I symlinked the file to /system/etc. That's how it was before and how it should be and how it should friggin work. But it doesn't. I know I'm repeating myself but this is just strange.

@hiddenhandgun: Thanks for the tip, this is a neat idea. Unfortunately a) I find Tasker way overpriced and b) blocking ads through the hosts file just doesn't seem to do it for me.

This crap is really bothering me. I'm thankful for any idea that you guys might have to fix this. Thanks in advance.
 

hiddenhandgun

Member
Jun 10, 2010
38
7
0
@JimmyLeeBillyBob Tasker has replaced about a dozen other apps for me, so I find it very reasonable, but I understand how not everyone finds it so. If you don't like tasker you could probably do the same thing with sl4a, but idk if root is available. I seem to recall that there is a free app which can use locale plugins, but damned if i can remember which it was. I may have been hallucinating.

In theory, as long as apps use the system resolver libs, the host.conf file should be referenced. Not that I have tried it, but you could make a "host.conf" in your /system/etc that looks like:

Code:
order hosts,bind
and ping a host that's included in the hosts file to see if it works. It should force name resolution to the hosts file first.
 

JimmyLeeBillyBob

Senior Member
Apr 4, 2011
65
5
0
Actually I've pinged known ad-hosts before and it was successfully resolved to the localhost address. However, ads are still displayed in apps. I tried your idea of creating a host.conf but it made no difference. Thanks again for the help but I'll just install a more recent nightly of CM7 and hope the problem is gone.
 

XlAfbk

Senior Member
Aug 11, 2010
1,454
421
113
here's what I use:
Code:
#!/system/xbin/bash
/system/xbin/curl -so /data/data/hoststmp http://hosts-file.net/ad_servers.asp
/system/xbin/curl -s http://winhelp2002.mvps.org/hosts.txt >> /data/data/hoststmp
echo "127.0.0.1 appadserver.com" >> /data/data/hoststmp
echo "127.0.0.1 caggsm-img.appads.com" >> /data/data/hoststmp
echo "127.0.0.1 rovio.appads.com" >> /data/data/hoststmp
echo "127.0.0.1 an.appads.com" >> /data/data/hoststmp
echo "127.0.0.1 rovio-news-app.angrybirdsgame.com" >> /data/data/hoststmp
echo "127.0.0.1 rovio-news-assets.angrybirdsgame.com" >> /data/data/hoststmp
cat /data/data/hoststmp | cut -d'#' -f 1 | awk NF | awk '{sub(/\r$/,"")};1' | sed 's/  \|\t/ /g' | sort | uniq -u > /data/data/hosts
rm /data/data/hoststmp
requires curl in /system/xbin (busybox wget doesn't resolve hostnames). Assumes you have linked /data/data/hosts to /system/etc/hosts.
Adding more sourced for hosts is as simple as copying the 3rd line and changing the URL.
That long line removes all comments, whitespace, duplicate entries and converts CRLF to LF.
 

bmdixon

Senior Member
Aug 2, 2010
139
50
0
here's what I use:
[snip]
requires curl in /system/xbin (busybox wget doesn't resolve hostnames). Assumes you have linked /data/data/hosts to /system/etc/hosts.
Adding more sourced for hosts is as simple as copying the 3rd line and changing the URL.
That long line removes all comments, whitespace, duplicate entries and converts CRLF to LF.
That's ace! :D Thanks.
How would i go about editing it to remove certain lines. eg. if i want any line that contains "gravatar.com" to be removed? Thanks in advance...
 

SubMatrix

Senior Member
Jun 24, 2010
164
13
0
here's what I use:
Code:
#!/system/xbin/bash
/system/xbin/curl -so /data/data/hoststmp http://hosts-file.net/ad_servers.asp
/system/xbin/curl -s http://winhelp2002.mvps.org/hosts.txt >> /data/data/hoststmp
echo "127.0.0.1 appadserver.com" >> /data/data/hoststmp
echo "127.0.0.1 caggsm-img.appads.com" >> /data/data/hoststmp
echo "127.0.0.1 rovio.appads.com" >> /data/data/hoststmp
echo "127.0.0.1 an.appads.com" >> /data/data/hoststmp
echo "127.0.0.1 rovio-news-app.angrybirdsgame.com" >> /data/data/hoststmp
echo "127.0.0.1 rovio-news-assets.angrybirdsgame.com" >> /data/data/hoststmp
cat /data/data/hoststmp | cut -d'#' -f 1 | awk NF | awk '{sub(/\r$/,"")};1' | sed 's/  \|\t/ /g' | sort | uniq -u > /data/data/hosts
rm /data/data/hoststmp
requires curl in /system/xbin (busybox wget doesn't resolve hostnames). Assumes you have linked /data/data/hosts to /system/etc/hosts.
Adding more sourced for hosts is as simple as copying the 3rd line and changing the URL.
That long line removes all comments, whitespace, duplicate entries and converts CRLF to LF.
XIA do you play angry birds? If so, can you confirm that this removes all ads from the game?

edit: nm i was being dumb, i see that the urls you are blocking are specifically rovio ones. i tried adding these urls to my hosts file and it didn't seem to work (just modifying my hosts file, not using curl stuff).

I have noticed that ads from admob just come up as blue ads now, no pictures, which is better....but its still an ad.
 
Last edited:

XlAfbk

Senior Member
Aug 11, 2010
1,454
421
113
I don't get any ads at all (just the pause screen ones) in AB. Check webcacheview to see where your ads were loaded from.
 

magillos

Member
Mar 4, 2011
41
4
0
Well, I can't see there anything that wouldn't be blocked in my hosts file. Hosts file seems to to be ignored. Playing angry birds with ads is awful.
 

SubMatrix

Senior Member
Jun 24, 2010
164
13
0
I have the same issue as magillos. I checked my webcacheview.db and I see entries from urls like this:

rovio-news-assets.angrybirdsgame.com
rovio-news-app.angrybirdsgame.com
mmv.admob.com

These are clearly in my hosts file:

127.0.0.1 mmv.admob.com
127.0.0.1 appadserver.com
127.0.0.1 caggsm-img.appads.com
127.0.0.1 rovio.appads.com
127.0.0.1 an.appads.com
127.0.0.1 rovio-news-app.angrybirdsgame.com
127.0.0.1 rovio-news-assets.angrybirdsgame.com

Let me outline my process just to make sure I'm not doing anything wrong. I modify the hosts file by adding lines such as above, and then copy it to /system/etc. I then try angry birds. Sometimes I reboot but it doesn't seem to make a difference.

Here are some images of the kinds of ads I see now:


 
Last edited:

XlAfbk

Senior Member
Aug 11, 2010
1,454
421
113
are you sure these ads aren't cached ones? just delete everything in /data/data/com.rovio.angrybirds but the 2 .lua files in files, similar for rio and seasons, also keep the "lib" folder there
 
  • Like
Reactions: filou75

SubMatrix

Senior Member
Jun 24, 2010
164
13
0
are you sure these ads aren't cached ones? just delete everything in /data/data/com.rovio.angrybirds but the 2 .lua files in files, similar for rio and seasons, also keep the "lib" folder there
I tried this and now I'm getting the full ads :(

It seems like my hosts file isn't really doing anything somehow...am I missing something? I checked the webviewcache.db after deleting all the /data/data stuff and the urls are all ones that are in my hosts file.