[SCRIPT] Adblock Script and Updater - Thunderbolt Android Development

I put together a small shell script to make it easy for anyone rooted to block ads and check to see if they have the latest version I keep of adhosts. If after checking you do not have the latest, it will download it for you automatically.
What does this script do (in a nutshell):
1) Checks to see if you have the latest version of ad hosts for adblocking from me
2) If you do not have the latest, it will download it for you
3) If you have the latest, it just exits out, no changes
4) Installs the script to your /system/xbin directory so the next time you just have to type:
Code:
su
blockads
and it will run the script for you
How to run this?
Get this if you are using an AOSP ROM:
1) Download it from http://dl.dropbox.com/u/24904191/blockads
Try this if you are using a SENSE ROM (thanks chrootz for the fixes):
1) http://dl.dropbox.com/u/24904191/sense/blockads
*** If you have troubles getting the script to work, try updating your system to the latest version of busybox (stick it in /system/xbin and overwrite the current version of busybox, then change the permissions to 755 and owner and group to root) ***
2) Move it to /data/local/tmp (if you dont have it, create it) from a file explorer with root permissions (must set the system in r/w mode) or from the terminal shell
3) make sure the script has the right permissions by typing:
Code:
su
chmod 755 /data/local/tmp/blockads
in the terminal shell (in the emulator or whatever you use to get to it)
4) run the script by typing
Code:
/data/local/tmp/blockads
5) let it do its thing
After its done you can run it again anytime from the terminal by typing
Code:
su
blockads
as already mentioned.
I'm working on making it a GUI app next (with more features), but this should tie anyone who wants it over until then
Anyone who finds any adservers and wants me to add them to the list, feel free to list them here and I will add them.
Latest updates:
2011-12-01: Updated to block carrieriq

Tried this out and got this:
sh-3.2# su
sh-3.2# /data/local/tmp/blockads
Fetching host file via hostname
wget: bad address 'dl.dropbox.com'
update could not be completed, sorry
sh-3.2#

newter55 said:
Tried this out and got this:
sh-3.2# su
sh-3.2# /data/local/tmp/blockads
Fetching host file via hostname
wget: bad address 'dl.dropbox.com'
update could not be completed, sorry
sh-3.2#
Click to expand...
Click to collapse
I forgot some ROMs and such have a busybox version that doesn't work right with hostnames in wget. I'll see if I can work around that and update the script
EDIT: updated to work around by using the IP for those that their busybox wget does not work correctly with hostnames. Only issue with that is the IP may change.

Ok. I am stuck. I actually don't have a hosts file under "etc", only a hosts.bak. With root explorer mounted as r/w I am still not able to rename the "host.bak" file to "hosts" - error message "read-only file/directory". I created a blank "hosts" text file, put in on the sdcard and with terminal emulator still can't cp to "etc" because of "read-only directory" error message. Any other suggestions?

GermanGuy said:
Ok. I am stuck. I actually don't have a hosts file under "etc", only a hosts.bak. With root explorer mounted as r/w I am still not able to rename the "host.bak" file to "hosts" - error message "read-only file/directory". I created a blank "hosts" text file, put in on the sdcard and with terminal emulator still can't cp to "etc" because of "read-only directory" error message. Any other suggestions?
Click to expand...
Click to collapse
Top right corner of Root Explorer .... Mount RW.
Sent from my A05PTH3ORY using XDA App

Does this do anything differently then AdFree, from the market?

yareally said:
I forgot some ROMs and such have a busybox version that doesn't work right with hostnames in wget. I'll see if I can work around that and update the script
EDIT: updated to work around by using the IP for those that their busybox wget does not work correctly with hostnames. Only issue with that is the IP may change.
Click to expand...
Click to collapse
Updated blockads script to test this am and:
sh-3.2$ export PATH=/data/local/bin:$PATH
sh-3.2$ su
sh-3.2# blockads
Fetching host file via hostname
wget: bad address 'dl.dropbox.com'
The busybox version of wget on your system does not work correctly with
hostnames. Trying workaround with latest known IP to the hostname...
Connecting to 184.73.229.87 (184.73.229.87:80)
hosts 100% |***********| 641k 00:00:00 ETA
backing up old host file and updating
failed on 'hosts' - Cross-device link
md5sum: can't open '/system/etc/hosts': No such file or directory
/system/xbin/blockads: line 38: [: 8172d35d1b72871f7e1ef4e709920f0e: unary operator expected
Unable to chmod /system/etc/hosts: No such file or directory
Unable to chmod /system/etc/hosts: No such file or directory
remounting filesystem in r/o mode...
Cleaning up files...
rm failed for -f, No such file or directory
update complete!
sh-3.2#
The end result is the existing hosts file being renamed hosts.bak and obviously no new hosts filebeing being created.
EDIT.... The above is testing on my inspire running busybox 1.19. Tried using the script on my sensation running bb 1.18.4 and it works fine.
Edit edit... Installed bb 1.18.4 on inspire and result is the same as posted above.

DroidTh3ory said:
Top right corner of Root Explorer .... Mount RW.
Sent from my A05PTH3ORY using XDA App
Click to expand...
Click to collapse
That's what I did, but it does not work - still does not let me modify read-only files.

After reading over the code and seeing the comments, I can only guess you had the modified version of wget on your device during testing, which does support host names. Before I continue, I am not trying to rain on your parade, but... By downloading the file, checking the md5, comparing it to the existing file, replacing if needed, and then cleaning up... you went about 5 steps beyond what just doing an "if server file is newer" check would do by including a custom wget. Even though you have to put in the code to install and verify the wget, the trade is that you no longer have to download the file every time, check it every time, and worry about making sure the md5 matches.
If you decide you want to switch over to that method, you can check out the option already included in http://forum.xda-developers.com/showthread.php?t=1092128 by downloading the live install version to view the actual script. Just a recommendation to optimize the process. Nice work, though, you definitely found a way to get the job done.
As for the difference between this and Adfree. There is no real difference. Adfree checks the server, does a callback, and prompts the user with updates. Adfree just requires an entire shell to turn it into an app, but will automatically run on boot.

twistedumbrella said:
As for the difference between this and Adfree. There is no real difference. Adfree checks the server, does a callback, and prompts the user with updates. Adfree just requires an entire shell to turn it into an app, but will automatically run on boot.
Click to expand...
Click to collapse
So, for those of you not comfortable running ADB, or Terminal Emulator, just install AdFree, and let it do everything for you.

spotmark said:
So, for those of you not comfortable running ADB, or Terminal Emulator, just install AdFree, and let it do everything for you.
Click to expand...
Click to collapse
Well, you also have the option of most included ROM toolkits, ScriptFusion, and a lot of preinstalled adblock scripts, but the big difference is the hosts file itself. Sounds like this one is custom, whereas mine takes bamf and adfree and merges them. This one may end up blocking more ads, but the only way to know would be to sit down and compare them all.
Sent from my ADR6400L using Tapatalk

twistedumbrella said:
Well, you also have the option of most included ROM toolkits, ScriptFusion, and a lot of preinstalled adblock scripts, but the big difference is the hosts file itself. Sounds like this one is custom, whereas mine takes bamf and adfree and merges them. This one may end up blocking more ads, but the only way to know would be to sit down and compare them all.
Sent from my ADR6400L using Tapatalk
Click to expand...
Click to collapse
Ah, I see.

Thank you for your comments everyone . I'll refine the script a bit more and also deal with a permanent workaround for not having a wget that checks hostsnames by testing with a ping and getting the IP first, using that and then doing wget. This started as a way for me to deal with having to move my ad host file each time I update it on my phone to just giving it out to everyone.
The only other difference than what was mentioned between my script and adfree as far as I know is I include a wider range of adhosts according to those that have used both. I have never used adfree, but people that have said I blocked more ads than they do and I also use an invalid IP address to block (0.0.0.0) instead of the loopback address (127.0.0.1) so it kills them a bit faster.
If anyone is still having problems that weren't resolved with it from above, let me know as well. I tested it against busybox 1.16.2 on my own phone, but it seems no 2 busybox version are alike
I havent tried this, but this one does include busybox 1.19 for those that don't want to manually install it. https://market.android.com/details?id=com.jrummy.busybox.installer&feature=related_apps

yareally said:
Thank you for your comments everyone . I'll refine the script a bit more and also deal with a permanent workaround for not having a wget that checks hostsnames by testing with a ping and getting the IP first, using that and then doing wget. This started as a way for me to deal with having to move my ad host file each time I update it on my phone to just giving it out to everyone.
The only other difference than what was mentioned between my script and adfree as far as I know is I include a wider range of adhosts according to those that have used both. I have never used adfree, but people that have said I blocked more ads than they do and I also use an invalid IP address to block (0.0.0.0) instead of the loopback address (127.0.0.1) so it kills them a bit faster.
If anyone is still having problems that weren't resolved with it from above, let me know as well. I tested it against busybox 1.16.2 on my own phone, but it seems no 2 busybox version are alike
I havent tried this, but this one does include busybox 1.19 for those that don't want to manually install it. https://market.android.com/details?id=com.jrummy.busybox.installer&feature=related_apps
Click to expand...
Click to collapse
Hit me up if I can be any help. It's good to have a better list available. Adfree has never been very thorough.
Sent from my ADR6400L using Tapatalk

+1 I exam yareally's hosts, This is much faster killing them and I glad you finally developing the script update for the hosts. I am going test your script update on 2 of the roms A05PTH3ORY and Gengeritis 3D VII. Thanks - Keep it up
yareally said:
The only other difference than what was mentioned between my script and adfree as far as I know is I include a wider range of adhosts according to those that have used both. I have never used adfree, but people that have said I blocked more ads than they do and I also use an invalid IP address to block (0.0.0.0) instead of the loopback address (127.0.0.1) so it kills them a bit faster.
Click to expand...
Click to collapse

Added about 10-15 more hosts today.

Thanks for the script. I'm going to give it a shot in a little bit. AdFree hasn't worked right in months. I've been using Absolute System to block ads, but I think I'll give this a try. Thanks again.

I'm about 50% done working on a basic gui app to do what the script does + some other features, just to give an update. GUI app will be free to any xda members of course
Things I am putting into it:
Choice between no blocking, partial blocking (basically in browser only stuff in case you want to show developers some love by not blocking their application ads), and full blocking.
Updating like the script does with just a touch of a button.
Optional ability to download a host block list for your desktop pc.
*features that may come later*
-ability to send me hosts from the app to add to the block list
-ability to add your own hosts on the fly to the list (either for personal routing or for adblocking, since adblocking is only the secondary use of the hosts file). Unfortunately, you will have to figure out the hosts yourself, since there's no easy way to tell really automatically.
Any other suggestions are welcomed

yareally said:
I'm about 50% done working on a basic gui app to do what the script does + some other features, just to give an update. GUI app will be free to any xda members of course
Things I am putting into it:
Choice between no blocking, partial blocking (basically in browser only stuff in case you want to show developers some love by not blocking their application ads), and full blocking.
Updating like the script does with just a touch of a button.
Optional ability to download a host block list for your desktop pc.
*features that may come later*
-ability to send me hosts from the app to add to the block list
-ability to add your own hosts on the fly to the list (either for personal routing or for adblocking, since adblocking is only the secondary use of the hosts file). Unfortunately, you will have to figure out the hosts yourself, since there's no easy way to tell really automatically.
Any other suggestions are welcomed
Click to expand...
Click to collapse
Sounds like AdFree but much better and will work better as well. Can't wait!!

Just tried this today on gingeritis 3d beta8 and it doesnt seem to work as i get the same error someone else posted a few posts back. Something about no such file or directory system/etc/hosts. I reverted adfree and uninstalled it and renamed the hosts file to hosts from hosts.bak but when I Su adblock it gets renamed to hosts.bak and terminal shows that same error

Related

VoiceDialer on stock ADP1

So I wanted VoiceDialer on my stock ADP1. I grabbed VoiceDialer.apk from JFv1.31_ADP1.zip and installed it using adb (sdcard mounted on computer, so it wasn't mounted on the phone). It runs, and I was quite satisfied with its recognition abilities, but when it comes to clicking "OK" to dial, it always crashes with a "force close" dialogue. Holding the "send" button does bring up the VoiceDialer program. My guess is I'm missing some sort of configuration somewhere. Does anyone know?
Make sure you grabbed the VoiceDialer.odex too, if there is one.
Koush said:
Make sure you grabbed the VoiceDialer.odex too, if there is one.
Click to expand...
Click to collapse
I didn't find any odex files (unless they would be in recovery.img, which I haven't yet learned how to open). These files are not created automatically?
Unzip a RC30 update.zip and look in \system\app\
On ADP1, the dex is created at runtime by the dalvikvm from the classes file inside the zip. On RC30, the dex files for the builtin apps are created ahead of time and stored alongside the apk. This prevents the system from using up \data partition space with dex files (As the ADP1 build does).
jashsu said:
Unzip a RC30 update.zip and look in \system\app\
On ADP1, the dex is created at runtime by the dalvikvm from the classes file inside the zip. On RC30, the dex files for the builtin apps are created ahead of time and stored alongside the apk. This prevents the system from using up \data partition space with dex files (As the ADP1 build does).
Click to expand...
Click to collapse
I was able to find a copy of VoiceDialer.odex as per your description, but if I understand you correctly, that will not solve my problem.
If the dev phone uses dex files instead, and these are created at runtime, then I would expect to find a dex file for VoiceDialer if everything is working properly. Indeed, the file "[email protected]@[email protected]" exists.
Any other hints as to why the application might crash after clicking "OK" to dial a number?
Yeah just grab the VoiceDialer.apk from JF's modified ADP1 build. It contains the classes.dex file required to run on ADP1 build.
jashsu said:
Yeah just grab the VoiceDialer.apk from JF's modified ADP1 build. It contains the classes.dex file required to run on ADP1 build.
Click to expand...
Click to collapse
That's what I did initially. That part all seems to work.
Doh, went around in a circle ;-) I thought we were talking about the RC30 version.
Yeah you'll have to ask JF about this since I think he compiled VoiceDialer from source for his ADP mod build. There is no odex file to look for.
jashsu said:
Yeah you'll have to ask JF about this since I think he compiled VoiceDialer from source for his ADP mod build.
Click to expand...
Click to collapse
Yeah, I'm sure JF could see the problem real quick. I'm real timid about bothering people, though - I was hoping he might swing by this thread by chance. What's considered appropriate on this forum: PM? E-mail? IM? Visitor Message?
IMSargon said:
Yeah, I'm sure JF could see the problem real quick. I'm real timid about bothering people, though - I was hoping he might swing by this thread by chance. What's considered appropriate on this forum: PM? E-mail? IM? Visitor Message?
Click to expand...
Click to collapse
Your best bet is IRC. A lot of us hang out in #android on Freenode.
IMSargon said:
So I wanted VoiceDialer on my stock ADP1. I grabbed VoiceDialer.apk from JFv1.31_ADP1.zip and installed it using adb (sdcard mounted on computer, so it wasn't mounted on the phone). It runs, and I was quite satisfied with its recognition abilities, but when it comes to clicking "OK" to dial, it always crashes with a "force close" dialogue. Holding the "send" button does bring up the VoiceDialer program. My guess is I'm missing some sort of configuration somewhere. Does anyone know?
Click to expand...
Click to collapse
Your best bet is to remount /system and push the .apk directly into /system/app. I haven't tried installing it with adb install, so I'm not sure if that's what is causing your problems or what.
JesusFreke said:
Your best bet is to remount /system and push the .apk directly into /system/app. I haven't tried installing it with adb install, so I'm not sure if that's what is causing your problems or what.
Click to expand...
Click to collapse
Yeah, I had the same problem (I've installed voice dialer using adb install)
Uninstalled in application manager, rebooted, remounted, pushed voicedialer.apk to /systemp/app, rebooted again, and it worked )
JesusFreke said:
Your best bet is to remount /system and push the .apk directly into /system/app. I haven't tried installing it with adb install, so I'm not sure if that's what is causing your problems or what.
Click to expand...
Click to collapse
It worked! Great! Thanks a ton!
------------------------------
Steps taken:
1. copy VoiceDialer.apk to phone
# adb push VoiceDialer.apk /sdcard/VoiceDialer.apk
763 KB/s (51125 bytes in 0.065s)
#
2. enter shell on phone, and gain root
# adb shell
$ su
#
3. mount the system partition as rewritable
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
#
4. copy VoiceDialer.apk to the proper system directory
# cat /sdcard/VoiceDialer.apk > /system/app/VoiceDialer.apk
#
5. make permissions match the other files
# chmod 644 /system/app/VoiceDialer.apk
#
6. reboot the phone
# reboot
------------------------------
For extra credit, does anyone understand why this happens? What does it tell us about how apps work and install?
adb pushing the apk directly bypasses the PackageManager. By using adb install, the package manager will run (as if the package was installed from the Market or Browser). There are various reasons the PackageManager might reject a package, including inability to run dexopt, incompatibility with existing data registered to an older version of an app, etc. A list of errors that would block an apk installation is here. Look at the constants starting with INSTALL_FAILED and INSTALL_PARSE_FAILED.
jashsu said:
adb pushing the apk directly bypasses the PackageManager. By using adb install, the package manager will run (as if the package was installed from the Market or Browser). There are various reasons the PackageManager might reject a package, including inability to run dexopt, incompatibility with existing data registered to an older version of an app, etc. A list of errors that would block an apk installation is here. Look at the constants starting with INSTALL_FAILED and INSTALL_PARSE_FAILED.
Click to expand...
Click to collapse
Interesting, but in this case the application did not fail to install. The installation went normally, and the application functioned normally up to the point where it attempted to interface with another application/subsystem (whatever dials the phone).
IMSargon said:
Interesting, but in this case the application did not fail to install. The installation went normally, and the application functioned normally up to the point where it attempted to interface with another application/subsystem (whatever dials the phone).
Click to expand...
Click to collapse
When you install it with adb install, it gets installed as a normal (non-system) application. This can be verified by checking /data/system/packages.xml:
Code:
<package name="com.android.voicedialer" codePath="/data/app/VoiceDialer.apk" [B]system="false"[/B] ts="1232083952000" userId="10029">
<sigs count="1">
<cert index="0" />
</sigs>
</package>
One of the permissions it requires is "android.permission.CALL_PRIVILEGED". Based on the info in frameworks/base/core/res/AndroidManifest.xml (in the git source):
Code:
<permission android:name="android.permission.CALL_PRIVILEGED"
android:label="@string/permlab_callPrivileged"
android:description="@string/permdesc_callPrivileged"
[B]android:protectionLevel="signatureOrSystem"[/B] />
You can see the protectionLevel is "signatureOrSystem", meaning that the application has to be a system application in order to use that permission. Since the voice dialer was not installed as a system application, it can't be assigned that permission.
To confirm this, I tried installing the voice dialer with adb install, and then took a look at the logcat output, which contains the following line:
Code:
01-15 23:32:32.903: WARN/PackageManager(56): Not granting permission android.permission.CALL_PRIVILEGED to package com.android.voicedialer (protectionLevel=3 flags=0x44)
However, when you copy the apk to /system/app, it gets installed as a system application, which can be verified again by looking at /data/system/packages.xml:
Code:
<package name="com.android.voicedialer" codePath="/system/app/VoiceDialer.apk" [B]system="true"[/B] ts="1232084484000" userId="10035">
<sigs count="1">
<cert index="0" />
</sigs>
</package>
So it is able to use the "android.permission.CALL_PRIVILEGED" permission. After coping the apk to /system/app, I checked the logcat output and there was no mention of not being able to grant the android.permission.CALL_PRIVILEGED permission, as expected.
Interestingly enough, copying the file to /system/app doesn't bypass the package manager. The package manager is watching both /data/app and /system/app for new files, and it automatically installs anything you copy into either location. It also does an uninstall when you delete an apk from either location.
JesusFreke said:
Interestingly enough, copying the file to /system/app doesn't bypass the package manager. The package manager is watching both /data/app and /system/app for new files, and it automatically installs anything you copy into either location. It also does an uninstalls when you delete an apk from either location.
Click to expand...
Click to collapse
I didn't know that. In that context it does make sense why it would disallow call permission if put into /data/app
Offtopic, but are you planning on creating a modified version of the newly released ADP1 "1.1" build?
Thanks, JF, your explanation makes the problem quite clear!

Post-Root Setup Instructions?

I know many of us are new to the whole rooting thing. I'm coming from the Windows Mobile world of custom ROMs, kitchens, etc., but I do have some linux experience. However, I can't for the life of me figure out how to do a lot of what comes "standard" in MoDaCo's ROM. Obviously it would be easier to simply install Paul's ROM and be done with it, but I'd really like to learn how to do it on my own too.
So, that being said, maybe we can pull together some tutorials, guides, and/or links to existing guides which explain how to go about setting up our Rooted phones manually. Here are some of the built-in mods the MoDaCo ROM comes with which would be nice to be able to do manually or on a one-off basis:
Included in MoDaCo 1.1 'core':
Rooted with 'adb remount' permission and superuser APK
A2SD included (fully automatic thanks cyanogen!) create a EXT2 partition as your second partition to use. dalvik-cache remains on device.
Added Jbed Java
Added Dropbear SSH running by default, check 'About' screen for password (port 2222). You can now remove this by running /system/bin/removedropbear.sh
Added Notes app from Dragon
Added Spare Parts (run it and switch the 2 animation types to 'fast' for an even better experience!)
Added android-wifi-tether 1.60 pre3 (props to the developer, this is a great app!)
Added WiFi Status indicator, with kind permission of Andrew Schwimmer
Added busybox 1.15.2 tweaked such that 'get information' in Swapper now works as desired
Added nano 2.09 text editor for use in shell mode
Added parted and sqlite tools
Added terminfo and settings to boot.img to allow nano etc. use
Added files required for Debian linux including loxley's updated bootdeb script
Moved Quickoffice to data partition to allow easy uninstall
Moved Google Maps and Google Voice Search to data partition to allow easy update
Silenced boot sound (it's still there and can be reactivated with a file edit)
Click to expand...
Click to collapse
*********
*********
!Working!
Wireless Tethering:
http://android-wifi-tether.googlecode.com/
Go to the "Downloads" tab and download version 1.61-pre
!Not Working!
Superuser Whitelist App
I found two threads here that describe how to install Superuser.apk.
http://forum.xda-developers.com/showthread.php?t=582140
http://forum.xda-developers.com/showpost.php?p=4897587&postcount=5
Using the first one, I was able to get the files onto the phone and I used the chmod commands found in the second file in the hopes this would work; however, whenever I try to use it, nothing happens. The ES File Explorer, in particular, used to work with MoDaCo. When I'd try to browse as root, Superuser would pop-up and ask if I wanted to grant the app permissions. Now it just hangs there (black screen) and ES File Explorer says I don't have root access. Other Root apps work fine though, it's just they don't seem to be dependant on Superuser Whitelist.
'adb remount' permission
This requires that the default.prop file be edited from ro.secure=1 to ro.secure=0. Unfortunately, I can't seem to get this file to stick. If I use the mv command using adb shell, I get some kind of permissions error. If I use the cp command when booting into the recovery menu and using adb shell, the file reverts to the original on boot. Or maybe it's simply not being overwritten, but not throwing any errors either
I think I may have found a thread that will help with the default.prop changes. Looks like this has to be done in the recovery.img which apparently overwrites any modifications in the root of the device on each reboot. I'll post an update if/when I figure it out.
HOWTO: Unpack, Edit, and Repack Boot Images
http://forum.xda-developers.com/showthread.php?t=443994
The adb remount permission issue is driving me crazy. Please keep us updated if you figure out a way of resetting that without installing a new ROM.
I ended up modifying one of the MoDaCo update scripts to set up ADB Remount, Superuser.apk, and Busybox. It's been working fine for me, but be sure to do a backup before you apply the update. Check it out here:
http://forum.xda-developers.com/showthread.php?t=593952

Easy Ad-Blocking

First a special thanks to kushdeck for the updated signed hosts
I know many people want to support the devs, if you do then don't apply this little trick.
Many ads are ill placed on videos or other free apps, by following the instructions below, it will eliminate those annoying ads.
Tested on android 2.2 (Phone must be rooted!!!!)
1. Download signed-hosts file below.
2. Place file on root of SD card
3. Reboot into recovery
4. select option to install zip from sdcard
5. Select choose zip from sdcard
6. Find and highlight Signed-hosts.zip
7. install and reboot.
8. Once phone has rebooted go to your favorite app that has ads and enjoy.
Even easier: Download AdFree from the Market.
Just removed ad-free and installed this host file.
EDIT: Seems to be working fine. Good post, thanks.
Will that block ads for the internet to or just apps
internet and apps
Is Ad-free supposed to block app ads as well or is it just less efficient in doing so?
I've noticed Ad-free does fine blocking internet ads, but it's not as great for app adds.
Basically, is this a better alternative to using Ad-free?
I never liked Ad blocking from Apps.
Will this work on 2.1? Has anyone tested it on 2.1?
Android 17 said:
Is Ad-free supposed to block app ads as well or is it just less efficient in doing so?
I've noticed Ad-free does fine blocking internet ads, but it's not as great for app adds.
Basically, is this a better alternative to using Ad-free?
Click to expand...
Click to collapse
AdFree does the exact same thing. It downloads a host file and replaces your current one.
MSmith1 said:
Will this work on 2.1? Has anyone tested it on 2.1?
Click to expand...
Click to collapse
It should, but so does AdFree.
Does ad-free not work on froyo or is it just not available in the ap store for it?
Sent from my PC36100 using XDA App
SharkUW said:
Does ad-free not work on froyo or is it just not available in the ap store for it?
Sent from my PC36100 using XDA App
Click to expand...
Click to collapse
Not only is it in the Market, but it works flawlessly. Search for "AdFree Android."
Neat trick! Before the days of firefox and adblock (plus) for firefox, we used to do the same thing in windows!
Is there a more recent hosts file available than 7/31/2010?
gpz1100 said:
Neat trick! Before the days of firefox and adblock (plus) for firefox, we used to do the same thing in windows!
Is there a more recent hosts file available than 7/31/2010?
Click to expand...
Click to collapse
This is why you should just use Ad Free, lol. It will constantly keep the hosts file up to date. THIS fix is simply a one time manual way to do it, and of course is not self updating lol.
Agreed, but as part of the learning process, I try to do simple things like this manually.
From several threads on here, I compiled enough information to generate a simple dos batch file which makes use of adb. Should be run from a command prompt containing the adb executable.
It's operation is very simple, permit writing to the /system, renames existing hosts to hosts.bak, downloads new one, then change /system permissions to read only.
I called the file hosts.bat
Code:
@echo off
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
adb shell mv /system/etc/hosts /system/etc/hosts.bak
adb shell wget http://209.68.48.119/winhelp2002/hosts.txt -O /system/etc/hosts
adb shell mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system
Edit: the ip address above is just the resolved numeric equivalent of http://www.mvps.org/
Adfree is great but I have had problems with adfree and 4g. When I have adfree enabled and I try to browse webpages on a 4g connection, most pages won't load properly it will just hand there for a long time and then load the page.... when I disable adfree web browsing on 4g is fine....
DarkManX4lf , I thought adfree was just a front end for something similar to my post above (#14)?
I realize it's a bit more complicated with update checking, but is it doing anything more than that?
Reference post #14 above.
I believe on the evo's with the 3.7 software, the file system should be
/dev/block/mtdblock4, not /dev/block/mtdblock3 .
However, even with this change, something isn't right after changing the hosts file. I get identical results replacing the file in recovery mode vs fully booted.
Epst, debug no longer works (##data#, or ##debug# from the phone screen). It shows loading, but never comes up.
I don't think see how copying the file over can break something. I suspect something else needs to be done to the file system to prevent these functions from breaking. They work properly with adfree, so it must be doing more than the above lines do.
Thoughts?
DarkManX4lf said:
Adfree is great but I have had problems with adfree and 4g. When I have adfree enabled and I try to browse webpages on a 4g connection, most pages won't load properly it will just hand there for a long time and then load the page.... when I disable adfree web browsing on 4g is fine....
Click to expand...
Click to collapse
Same situation here.
Can you provide some specific sites you're having issues with?
I tried 4g here with adfree and didn't run into issues with any of the sites I tried, including several banking ssl sites.
Me too i have issues with adblocking and this mod when i use 4G. Pages do not load fully or correctly. Literally any site.
evo 3.70
running fresh 3.5.0.1

Debian working niceley on Desire.

Debian for Desire.
If you are able to try this on another android device, please do as I will be very interested in the results.
Download
http://www.multiupload.com/79TSI1AAF9
You will need.
-Root access.
-Busybox (included in most custom roms)
-1.4gig free on SDCARD
-VNC Client (ie. AndroidVNC)
-Terminal Emulator (ie. ConnectBot)
-7zip
Instructions
-Extract the file deSIREbian.7z on your PC using 7zip.
-Copy the contents (debian.img and deboot) to root directory of SDCARD.
-On your phone in terminal emulator type
su
sh /sdcard/deboot
Click to expand...
Click to collapse
You should get a blank screen showing "localhost:/#" after a couple of seconds.
-On your phone in your VNC client log in using these details
Password - password
Port - 5901
Click to expand...
Click to collapse
Nickname and Address are not needed, call it what you want though.
Changing the colour to 24bit and enabling local mouse pointer and full screen bit map are not neccesary but reccomended.
-Thats it.
Notes.
-You can log in via ssh, (gives a much better terminal, ie works properly with aptitude). Use [email protected] and password "toor"
-The version of Debian is Armel Lenny, installed using debootstrap.
-It is just the base package with LXDE on top, you only get a desktop, a file browser, an internet browser, and a pic viewer.
-If you want more packages there's tonnes of room on the image. eg apt-get install openoffice.org or apt-get install abiword or apt-get install any flipping thing u want
-You can access the SDCARD from Debian at "root/sdcard" (read-write)
-You can access Debian filesystem from Android (When Debian is running) at "sdcard/debian" (read only)
-debian.img is mounted at "sdcard/debian" using "dev/block/loop5"
-So far the only rom i have come accross that this dont work with is one of the cyanogen nightlies from last week. apart from that, working on opendesire, cyanogen, defrost, leedroid, official 2.2 with busybox...
Issues.
Debian cannot be shut down. You need to reboot the phone to do this. (You can kill the VNC server with "vncserver -kill :1" there is an icon on the festoons to do this.)
Update log.
deSIREbain.
-First release.
deSIREbain2
Fixed
-Loading a second terminal no longer breaks vnc.
-You no longer need to create the folder debian on sdcard.
Added
-ssh server (login with root and toor)
Removed.
-The image has been downsized from 2 gig to 1.4
Hey,
thank you for your work, i will test it so far and will tell you the results
got this error:
Code:
# su
su
# sh /sdcard/deboot
sh /sdcard/deboot
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
mount: mounting /sdcard on /sdcard/debian/root/sdcard failed: No such file or di
rectory
net.ipv4.ip_forward = 1
chroot: can't change root directory to /sdcard/debian: No such file or directory
#
If you have the same problems try out
su
mkdir /sdcard/debian
losetup /dev/block/loop3 /sdcard/debian.img
mount -t ext2 /dev/block/loop3 /sdcard/debian
ls /sdcard/debian
thx to mercianary for help
greetings
I found this guide quite helpful at getting a bootstrapped Debian setup running.
http://www.saurik.com/id/10
I didn't need to insert the ext2 module as it's already loaded for me, I guess G1s didn't have that convenience back then.
blackstoneuser5 said:
I found this guide quite helpful at getting a bootstrapped Debian setup running.
www . saurik.com/id/10
I didn't need to insert the ext2 module as it's already loaded for me, I guess G1s didn't have that convenience back then.
Click to expand...
Click to collapse
I used parts of this for reference too. Its a great guide, explains things really well.
i've just updated this. link is in the first post.
Fixed
-Loading a second terminal no longer breaks vnc.
-You no longer need to create the folder debian on sdcard.
Added
-ssh server (login with root and toor)
Removed.
-The image has been downsized from 2 gig to 1.4
debian for desire--help please
hi
I spent much time for searching debian or ubuntu for desire, but nothin worked
know i found this and i have download everything and start to install over the terminal
but the " sh /sdcard/deboot" is not workin to
there's only this answer:
# su
su
# sh /sdcard/deboot
sh /sdcard/deboot
[: not found
losetup: not found
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
busybox: not found
sysctl: not found
chroot: not found
may somebody help me?
i really want to have it on the desire
thanks
It looks like you had not installed busybox
Which ROM do you use ?
oh i'm sorry
i'm a newbie and don't really know what a rom is
but i had problems with busybox and there was a somebody who said i can get the app titanium and let it install the busybox
could you please show me a tut how to install busybox
maybe a german tut
thanks
Getting error at: sh /sdcard/deboot
line 5: syntax error near unexpected token `else'
Rosi1337 said:
Getting error at: sh /sdcard/deboot
line 5: syntax error near unexpected token `else'
Click to expand...
Click to collapse
dont know why that happened.. works on mine. syntax looks ok to me.
try with this one (attatched), it's the same but without the bit that's not working for you.
what rom are you using, i shall try to replicate the error so I can try to fix properly.
thepuechen said:
could you please show me a tut how to install busybox
maybe a german tut
thanks
Click to expand...
Click to collapse
There should be a guide on installing busybox somewhere if you want to search for it, i know i remember seeing one a while ago.
Too be honest, your better off just flashing a rom that includes busybox, it would be MUCH easier.
have a look here and see what takes your fancy, I would recomend defrost, because it is stable and easy to overclock.
Thanks mercianary,
It works fine!,
I use customised DeFroST_0.9b_uvonly with USB-host patch.
By the way I would like to add more options to kernel line.
Where can I find like a menu.lst file ? or How to add it to kernel line.
There is no /dev/graphics/* in running Debian console.
I would like to use FrameBuffer on running Debian.
thanks,
Android VNC won't connect Trying to get a handshake, but then says that VNC connection failed
please paste at that time log
jacobtc said:
Android VNC won't connect Trying to get a handshake, but then says that VNC connection failed
Click to expand...
Click to collapse
Please paste at that time log.
Maybe vnc server does not running.
tknv said:
Thanks mercianary,
It works fine!,
I use customised DeFroST_0.9b_uvonly with USB-host patch.
By the way I would like to add more options to kernel line.
Where can I find like a menu.lst file ? or How to add it to kernel line.
There is no /dev/graphics/* in running Debian console.
I would like to use FrameBuffer on running Debian.
thanks,
Click to expand...
Click to collapse
You should understand that this is not a really booted native linux. Instead you are working in a chroot environment. So there is no kernel running that can get parameters. Only the the stock kernel of your DeFroST. Also there is no FrameBuffer as the graphic hardware ist not accessible. Instead this approach uses a vnc-server to which you can connect via a local viewer.
The advantage of this approach is clear:
- run almost any linux package available in the debian repository
- use your phone as before with the nice android
The disadvantage:
- no graphic output, so no 3D-games (which are rare under linux on the arm platform ;-)
- you can crash your android by eating up to much ram (not such a problem - it restarts on its own and if not you just have to reboot)
Thread is dead?
It seems this thread is dead. The problems many users seem to have come from a dirty setup. The image is broken in many terms:
- wrong file permissions on important binaries, like su
- wrong file permissions on many device files under /dev, so the ttys are only accessible by root
- wrong permissions on other places so there are always errors when installing additonal software (e.g. with the man pages)
- wrong setup that uses the root user for the desktop - instead an unprivileged user should be used
- missing packages for timezones and locales so the time is only right, if you are in a UTC region and console programs having trouble displaying anything else then plain english
I can not recommend using this setup image. It is better to use one of the instructions available online to get a clean setup.
Su doesn't work because your allready root.
Getting anything but root to work would be a real pain.
As you said its a chroot environment, its never going to be perfect.
The image was made using debootstrap just like all the other 'clean' ones.
Yep, it is broken as hell, but it works for what most people would need it for...make,gcc,python,a proper web browser,torrents, and some emergency word processing on the train to work.
The problem most people have is not being able to mount the image, this is due to fro-yo a2sd taking up all the loop devices.
Just thought I'd add my 2 cents.
I tried this on a MIUI rom and the scripy didnt do anything - ie i ran it using:
"# sh /sdcard/deboot"
.....and all it said was:
"#"
I entered all the lines in the shell script but the last one said it failed to launch VLC and no commands registered property (not even ls)
So i tried it on Defrost 5.1, and the script still didn't work.
But when i entered everything manually, it did work. Not too sure about the green theme though.
But thanks alot! Saves me spending a few hours trying to coax a working debootstrap out of my computer.
Thanks!
Josh.
mercianary said:
Su doesn't work because your allready root.
Click to expand...
Click to collapse
Nope. Actually su works only for root. It's missing the setuid root flag like all other binaries that should have it set.
mercianary said:
Getting anything but root to work would be a real pain.
Click to expand...
Click to collapse
Nope. I am always working as a normal, unprivileged user in my chroot. You just have to be in the proper groups. No need to work as root. Android works also with an unprivileged user.
mercianary said:
As you said its a chroot environment, its never going to be perfect.
The image was made using debootstrap just like all the other 'clean' ones.
Yep, it is broken as hell, but it works for what most people would need it for...make,gcc,python,a proper web browser,torrents, and some emergency word processing on the train to work.
Click to expand...
Click to collapse
This is what I do not understand. There is no need that it is broken, as mine works without any errors. So I think something went wrong in creating yours. For sure a chroot is no running OS but you can server almost any service with it and run anything you want (if your ram does not get exhausted ;-).
mercianary said:
The problem most people have is not being able to mount the image, this is due to fro-yo a2sd taking up all the loop devices.
Click to expand...
Click to collapse
Yes. Everyone with a good rom should have a2sd+ (aka the old a2sd) which saves more space than the froyo one and leaves your loop devices for you.
jo

How to block ads without root

Since this is a vanilla android phone, the only real modification I wanted was to change the hosts file to block ads. Turns out you can do that without rooting your phone, but you DO need an unlocked bootloader.
After you're unlocked, you'll need the TWRP recovery image:
http://forum.xda-developers.com/nex...recovery-twrp-2-8-7-0-touch-recovery-t3230471
and the flashable hosts file:
http://forum.xda-developers.com/showthread.php?t=1916098
Reboot into the factory bootloader, then into TWRP:
Code:
fastboot boot twrp-2.8.7.0-bullhead.img
Start ADB Sideload in TWRP and push the flashable hosts file:
Code:
adb sideload MoaAB_ADBlocking_12October2015_R4.zip
Reboot, DON'T install superuser when prompted, and you're done! You'll still have the factory recovery, but you will get the device is corrupt message since this changes the system.
There may be an easier way to do this, but just wanted to put it out there if there's anyone else looking to do the same thing.
I seem to lose adb access when I am in TWRP, do I type "adb sideload MoaAB_ADBlocking_12October2015_R4.zip" in the command prompt on my computer or is there a way to type this within TWRP?
The command prompt. I've had driver issues with adb in recovery on some computers, check in device manager and see if it shows up. You may have to update the driver (right click on the phone in device manager) and manually select adb. Not at my computer, so I can't give specific steps, sorry.
Sent from my Nexus 5X using Tapatalk
Yup you were right, driver issues, fixing right now, thanks!
If you use the Amazon app, it will be broken with MoaAB, unless it was fixed.
Seems to work fine, so they must have updated the list.
Sent from my Nexus 5X using Tapatalk
thanks for posting this , will try it soon!
Can I load this if I am on unlocked bl, unencrypted, and rooted?
Yup, then you can just flash it in TWRP. Or use an app like AdAway.
Sent from my Nexus 5X using Tapatalk
Can anyone tell me if flashing this host file will prevent future OTA's from installing successfully?
If so, would saving the original host file as a backup and pushing that back via ADB allow the OTAs?
Thanks!
I can't tell you for sure, but it's certainly a possibility. Having a backup is always a good idea, but there is a flashable stock hosts file in the same thread as the ad blocking file.
Personally, I'll probably just flash the factory system.img when it's time for an update.
Sent from my Nexus 5X using Tapatalk
Rbrowser is a good alternative, if you'd prefer to keep everything stock for updates. Does an excellent job at blocking ads, and very Chrome like.
As an avid flasher and owner of all the Nexus this is the first time I'm trying to go non-root and I was able to find any alternative for ad blocking. I'd recommend you install AdGuard, it blocks websites and apps but it redirects the traffic through its vpn server so Google battery stats will determine it's eating all the juice. This however is simply not true, after extensive use I can still do 3-4hrs SOT, so give it a shot if you want ad blocking non-root.
Since AdAway always did a great job for me, I made a script that grabs all the same sources and builds a single hosts file to push to the phone. You'll need Linux or another UNIX to run it though.
http://www.jimsrandomcrap.com/2015/12/12/ad-blocking-without-root-on-the-nexus-5x/
wow you are the best
beavis9k said:
Since AdAway always did a great job for me, I made a script that grabs all the same sources and builds a single hosts file to push to the phone. You'll need Linux or another UNIX to run it though.
Click to expand...
Click to collapse
:good:
No problem; I'm glad other people find it useful. Maybe I should make a post for it in the development section.
@beavis9k: I followed your tutorial and I was able to push the hosts file to my phone but ads still do not get blocked.
Should there be some kind of a response after applying the "adb shell chmod 644 /system/etc/hosts" command?
If I open the hosts file the only entry is "127.0.0.1 localhost::1 localhost". I guess that isn't correct and the script is not able to grab the sources when I run it.
UPDATE: Solved it. There was a problem with cygwin running the script.
Norlam said:
@beavis9k: I followed your tutorial and I was able to push the hosts file to my phone but ads still do not get blocked.
Should there be some kind of a response after applying the "adb shell chmod 644 /system/etc/hosts" command?
If I open the hosts file the only entry is "127.0.0.1 localhost::1 localhost". I guess that isn't correct and the script is not able to grab the sources when I run it.
UPDATE: Solved it. There was a problem with cygwin running the script.
Click to expand...
Click to collapse
Ahhh... thanks for letting me know. I never did try it under cygwin. I figured it would just work. If the generated hosts file only has localhost in it, I would guess that wget isn't installed with cygwin.
Yeah that was the problem. I forgot the check the "wget" package during the installation of cygwin
After installing the package the hosts file was working as it should :good:

Categories

Resources