SwiFTP - fix for freezing downloads - Galaxy S III General

I was using SwiFTP to upload files, but it seemed to freeze when downloading ...
The reason is that the /system/bin/ls command on S3 returns output which is different from previous Android versions ...
The solution is to replace /system/bin/ls (which points to toolbox) to point to busybox.
Code:
cd /system/bin
mv ls ls.orig
ln -s /system/xbin/busybox ls
Make sure you have busybox installed in /system/xbin and that your /system partition is mounted read/write.
If you don't know what this is doing, please don't attempt to do it

Related

Adfree does not updating [Updated 2/17/11]

So I am running Adfree and everytime I update it and restart the phone and launch an app, in this case XDA, I still have adds, any ideas. Thanks.
Sent from my GT-P1000 using XDA App
EDIT: ok so i found this on another thread and it states do use the following:
adb shell
su
remount rw /system
cd /system/etc
cp hosts /data/data/
rm hosts
ln -s /data/data/hosts .
remount ro /system
since i am not familiar with adb i tried running via terminal emulator and i get the following error:
remount: not found
any suggestions?
EDIT [2/17/11] thanks to shmigao for the answer, it seems that apparently the command remount is not available in this ROM (MoDaCo Custom ROM)

sl4a shell script help

Hi all,
I'm trying to run a shell script in sl4a but I'm running into problems. Here's what I want to do: change ADW configuration files in one click (since the app doesn't yet do it natively). There are two files that need to be changed for this to happen:
Code:
/data/data/org.adwfreak.launcher/databases/launcher.db
/data/data/org.adwfreak.launcher/shared_prefs/adw_ex_preferences.xml
I'm trying to delete those files and copy in new files from a stored location on the SD card but I can't get the sl4a script to run the following rm commands:
Code:
rm -rR /data/data/org.adwfreak.launcher/databases/launcher.db
rm -rR /data/data/org.adwfreak.launcher/shared_prefs/adw_ex_preferences.xml
I use
Code:
su -c
before the rm commands to run them as root, but the error then is that the /data partition is not mounted (which I find strange since it should be rw anyway...). I've tried using
Code:
mount -o remount,rw /dev/block/userdata /data
and it looks like it runs but then it doesn't work and I can't rm the files anyway.
Am I running into a limitation of sl4a or shell scripts in sl4a? I can rm the files from the terminal, so I'm not sure what the issue is. I'm very new to this (obviously) so any tips would be helpful. Thanks!
Here is my full script currently:
Code:
#!
kill android.process.acore
kill org.adwfreak.launcher
busybox rm -R /data/data/org.adwfreak.launcher/databases/*
busybox rm -R /data/data/org.adwfreak.launcher/files/*
busybox rm -R /data/data/org.adwfreak.launcher/shared_prefs/*
cp /sdcard/adw_ex_launcher.db /sdcard/ADW/Honeycomb/adw_ex_launcher.db
cp /sdcard/adw_ex_settings.xml /sdcard/ADW/Honeycomb/adw_ex_settings.xml
cp /sdcard/ADW/Portrait/adw_ex_launcher.db /sdcard/adw_ex_launcher.db
cp /sdcard/ADW/Portrait/adw_ex_launcher.db /data/data/org.adwfreak.launcher/databases/launcher.db
chmod 664 /data/data/org.adwfreak.launcher/databases/launcher.db
cp /sdcard/ADW/Portrait/adw_ex_settings.xml /sdcard/adw_ex_settings.xml
cp /sdcard/ADW/Portrait/adw_ex_settings.xml /data/data/org.adwfreak.launcher/shared_prefs/adw_ex_preferences.xml
chmod 664 /data/data/org.adwfreak.launcher/shared_prefs/adw_ex_preferences.xml
exit
When I test the rm commands in the sl4a shell, they don't remove the files even when the /data partition is mounted. I've tried all that I know. Help please!
Sent from my DROIDX
I don't know what you are trying in your second post, but from your first post I would say:
Code:
su
busybox rm -r /data/data/org.adwfreak.launcher/databases/*
busybox rm -r /data/data/org.adwfreak.launcher/files/*
busybox rm -r /data/data/org.adwfreak.launcher/shared_prefs/*
cp /sdcard/adw/prefs.xml /data/data/org.adwfreak.launcher/shared_prefs/
..
kill org.adwfreak.launcher
If you do "chmod 664" on the files, you also have to do "chown & chgrp" or the launcher won't be able to write into the settings xml's/db's.
And /data ist mounted rw, everything else would be senseless.
Thanks for the response.
I'm trying to change ADW configuration with one click. I'm going to use Tasker to create a widget that, when clicked, runs a script. That script will:
1. delete the current ADW configuration files (launcher.db and adw_ex_preferences.xml)
2. copy the target configuration files to the proper places (and set permissions, owner, group)
3. restart ADW so that the configuration is loaded
OR
3. open the ADW settings page so that I can click "restore desktop" and "restore preferences" and have the configuration loaded in an almost-one-click solution.
The script in the 2nd post is my best effort at that. I have tried the busybox part of the script, but I don't believe it makes a difference. I will try again, though, and report back.
As far as chown and chgrp goes, I'll add in what I think that should be and post that back later, too.
Fr4gg0r said:
I don't know what you are trying in your second post, but from your first post I would say:
Code:
su
busybox rm -r /data/data/org.adwfreak.launcher/databases/*
busybox rm -r /data/data/org.adwfreak.launcher/files/*
busybox rm -r /data/data/org.adwfreak.launcher/shared_prefs/*
cp /sdcard/adw/prefs.xml /data/data/org.adwfreak.launcher/shared_prefs/
..
kill org.adwfreak.launcher
If you do "chmod 664" on the files, you also have to do "chown & chgrp" or the launcher won't be able to write into the settings xml's/db's.
And /data ist mounted rw, everything else would be senseless.
Click to expand...
Click to collapse
Progress update: Success! More or less.
I realized I wouldn't need to remove the files since the ones I was copying in would just overwrite them anyway, so that cleared up that issue.
I did add chown and chgrp (a piece of information I'm sure I'll find useful in the future) so I'm sure that helped. Making sure to get the group and owner right PER YOUR OWN SETUP was key. When I changed ROMs I had to redo it... so check properties with Root Explorer or whatever.
I revised my script a little to add the background wall paper, too.
The true key, however, was using Lua in SL4A and using the 'sush' script in this post here:
http://code.google.com/p/android-scripting/issues/detail?id=184 (comment #9). That allowed me to run my script in the 'sush' format and do what I wanted.
I also had to add a line to kill the launcher process (android.process.acore) so it would restart itself.
I now have a one-click solution to changing between two ADW desktop configurations/settings!
I've attached my script if anyone would like it. Just get SL4A, the Lua interpreter, and put the pieces together! (Use a custom shortcut on the desktop and not a widget and the desktop setup will be preserved; widgets aren't supported in any method...)

Replacing Toolbox with Busybox

Hi,
I've just replaced the stock toolbox with busybox provided by netarchy kernel package. Maybe there is a better way to do this, but I'm just playing with my new phone
Anyway, this is what I did:
Info
nexus model: I9023
rom: stock 2.3.4 with root permission
kernel: 2.6.35.13-netarchy-nexus-1.3.7-bfs-2.3.4
busybox version: 1.16.0 (included in netarchy kernel package)
Entering adb shell
Code:
adb shell
Inside adb shell:
Replacing toolbox with busybox
Code:
mount -o rw,remount /dev/block/mmcblk0p1 /system
busybox mv /system/bin/toolbox /system/bin/toolbox.bak
busybox ln -s /system/xbin/busybox /system/bin/toolbox
mount -o ro,remount /dev/block/mmcblk0p1 /system
Add a new command
After remounting rw /system
Code:
ln -s /system/xbin/busybox /system/xbin/COMMAND
For example:
Code:
mount -o rw,remount /dev/block/mmcblk0p1 /system
ln -s /system/xbin/busybox /system/xbin/chroot
mount -o ro,remount /dev/block/mmcblk0p1 /system
If you know a better way, tell me! Anyway I hope this could be useful
Download "busybox" by Stericson
Install busybox thru that app
Uninstall "busybox" by Stericson (busybox will stay intact)
snandlal said:
Download "busybox" by Stericson
Install busybox thru that app
Uninstall "busybox" by Stericson (busybox will stay intact)
Click to expand...
Click to collapse
Or just download BusyBox from Titanium Backup.
Code:
# busybox --install /system/xbin
should do the trick -- be warned, you'll get *a whole lot* of symlinks to busybox
snandlal said:
Download "busybox" by Stericson
Install busybox thru that app
Uninstall "busybox" by Stericson (busybox will stay intact)
Click to expand...
Click to collapse
Great, thanks. I've installed that busybox and it works great!
suksit said:
Code:
# busybox --install /system/xbin
should do the trick -- be warned, you'll get *a whole lot* of symlinks to busybox
Click to expand...
Click to collapse
Yes, I installed busybox in /system/xbin and it created a lot of symlinks, but it's ok because in this dir there is almost nothing.
Anyway, thanks for the tip
???
Weird! After running shell script, I can no longer stay connected on wireless for more than a couple of minutes. I think something was replaced and it shouldn't be replaced!
Any hint?
In most Android systems, the c binary stalk is installed in /system/bin and is handled by TOOLBOX.
If we install BUSYBOX with any of the apps mentioned above, it will most likely be installed in /system/xbin
So at the end we'll end up with 2 utilities handling some binaries that are clones as it show in both /system/bin and /system/xbin
and because the PATH includes both locations then wouldn't that create some complications and possible hanging/crashing of the android system ???

[HOWTO] Add init.d to stock ROM + a few other goodies

I have been resisting the urge to flash a custom ROM for a bit, but I really miss having init.d support. So I read a few threads for other phones and rolled my own.
Warnings
I borrowed bits and pieces from various places. If you don't know what init.d is, you probably don't want to do this. If you aren't willing to take responsibility for bricking your tablet, don't do this. Seriously, the risk of bricking is very low, but if you aren't comfortable booting into an adb shell from recovery, maybe this is not for you. Strongly suggest a nandroid backup before you get started so if you totally bork things you can just hit rewind.
Note: The latest CWM may prompt you on a reboot that the ROM may overwrite the bootloader and offer to fix it for you. Don't do that. The init.d hack takes over the bootloader install script, but does not change your bootloader! If you accidentally do let it fix things for you, just rebuild the install-bootloader.sh file. The other steps should be fine.
Prerequisites
First, you need root, busybox, and some sort of terminal (either adb, or some terminal you like using on the tablet).
I have found that I like Busybox Installer (from the market; https://play.google.com/store/apps/details?id=com.jrummy.busybox.installer) but for some reason it doesn't create new symlinks unless you click advanced install.
Let's get to it!
In the shell (don't type # or anything after #):
Code:
su # get root
mount -o remount,rw /system # get access to /system (4.04 seems to mount ro as is usual; seems like the original mounted rw)
which run-parts # if you don't see /system/xbin/run-parts you need to install/reinstall busybox; if it is somewhere else, note it
mkdir /system/etc/init.d
Create a file called sysinit -- we are going to put it in /system/bin. You can edit it in place with vi, mount your tablet and edit it on your computer, or create it on the computer and push it via adb. Whatever.
Here's the file (you do need the # and the things after it in the file!):
Code:
#!/system/bin/sh
export PATH=/sbin:/system/sbin:/system/bin:/system/xbin
/system/bin/logwrapper /system/xbin/run-parts /system/etc/init.d
Note that if your run-parts is not in /system/xbin (from the which command) then fix the above to reflect your reality.
In the shell, make it executable
Code:
chmod 755 /system/bin/sysinit
Now go in the init.d directory and create some things you want to run at start up. For example:
Code:
cd /system/etc/init.d
echo '#!/system/bin/sh' >99test # note: you do need the first # in this line but not the 2nd!
echo 'date >>/data/tmp/init.d-log.txt' >>99test
chmod 755 99test
Here's a more practical one (yes, you need the # signs). Name it something like 10diskperf -- don't forget to chmod it.
Code:
#!/system/bin/sh
# Set disk read aheads to 1024
chmod 777 /sys/block/mmcblk0/queue/read_ahead_kb
echo "1024" > /sys/block/mmcblk0/queue/read_ahead_kb
chmod 777 /sys/block/mmcblk1/queue/read_ahead_kb
echo "1024" > /sys/block/mmcblk1/queue/read_ahead_kb
chmod 777 /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo "1024" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
Or here is one to tweak some TCP parameters (25sysctl):
Code:
#!/system/bin/sh
sysctl -w net.core.rmem_max=524288
sysctl -w net.core.wmem_max=524288
sysctl -w net.ipv4.tcp_rmem=6144 87380 524288
sysctl -w net.ipv4.tcp_wmem=6144 87380 524288
Whatever files you put in, you need to remember to make them executable (chmod 755).
Finally, you need to kick it all off at start up. The hack for that is we are going to create /system/etc/install-recovery.sh which apparently runs on each boot.
Code:
cd /system/etc
echo '#!/system/bin/sh' >install-recovery.sh
echo '/system/bin/sysinit' >>install-recovery.sh
chmod 755 install-recovery.sh
Tips and troubleshooting
If you are too lazy to cut and paste I have the files here (View attachment init.d-support.zip) that you can just move to the right places and change permission. If you are really lazy there is lightly tested install script below.
I like to try running the whole thing before a reboot to see if I get any errors:
Code:
/system/etc/install-recovery.sh
I'd suggest putting the 99test file in first. Verify that you get the expected file in /data/tmp and then reboot and check again. Then you can remove 99test.
Same goes for adding new scripts. Try running them from the shell to see if they throw errors before you reboot!
If you have trouble, see if this looks right:
Code:
ls -ld /system/etc/install-recovery.sh /system/bin/sysinit /system/etc/init.d /system/xbin/run-parts
-rwxr-xr-x root root 39 2012-07-14 10:00 install-recovery.sh
-rwxr-xr-x root root 140 2012-07-14 10:01 sysinit
drwxrwxrwx root root 2012-07-14 10:10 init.d
lrwxrwxrwx root root 2012-07-14 09:55 run-parts -> /system/xbin/busybox
For the brave
The install-init.d zip file (View attachment install-init.d.zip) contains a lightly tested script that SHOULD do the install steps for you.
Send the file to your android to someplace that can execute code (e.g., /system/xbin; I had to use adb to put it on the sdcard and then move it to /systemxbin in the shell since I don't have the adb root kernel installed).
Code:
cd /system/xbin # or wherever you have it
chmod 755 install-init.d
./install-init.d
It performs rude checks to see if init.d exists, and tries to handle moving or missing busybox. It only installs 99test as a script.
Let me know if this works or doesn't work for you.
For the extra brave: There is no reason this should only work on the Samsung. This ought to work on pretty much most stock ROMs as long as they execute install-recovery.sh on start up.
Scripts
What do you put in your init.d? If you post anything cool I'll put it up here in the op.
One that gave me some real gains in I/O performance required a new version of the tune2fs executable. By default, it is part of busybox but the busybox one only has a few simple options. I've included a stand alone version and the script 10disktune here View attachment disktune.zip. Unpack the zip and put the 10disktune in /system/etc/init.d (don't forget to chmod) and put tune2fs in /system/bin (chmod that too). Note that busybox has one in /system/xbin but the script specifically calls out the one in /system/bin.
Here's one that will zipalign your apks on each boot
Code:
#!/system/bin/sh
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk
ZCHECK=$?
if [ $ZCHECK -eq 1 ]; then
zipalign -f 4 $apk /cache/$(basename $apk)
if [ -e /cache/$(basename $apk) ]; then
cp -p -f /cache/$(basename $apk) $apk
rm /cache/$(basename $apk)
fi;
fi;
done;
Fin
Corrections welcome. I considered using exec or . to load some of this into one shell but given that it runs once at startup, I figured it is fine as is.
All files for reference
View attachment init.d-support.zip
View attachment install-init.d.zip
View attachment disktune.zip
Great guide, gonna try it tonight.
Sent from a GNote, hell yeah!
SirRhor said:
Great guide, gonna try it tonight.
Sent from a GNote, hell yeah!
Click to expand...
Click to collapse
I'm curious how it went. If you ran into any issues, let me know so I can update the op. Thanks!
Hmm did anyone get this to work?
wd5gnr said:
Hmm did anyone get this to work?
Click to expand...
Click to collapse
I did it on my Galaxy Nexus.
It works great, I had a bit of problem with the sysinit file, but when I downloaded your zip file and used your sysinit, it worked, so it must be a problem from my side
Thanks for this, I can finally use "Odex Me"
aavan said:
I did it on my Galaxy Nexus.
It works great, I had a bit of problem with the sysinit file, but when I downloaded your zip file and used your sysinit, it worked, so it must be a problem from my side
Thanks for this, I can finally use "Odex Me"
Click to expand...
Click to collapse
Great, just wanted to be sure I hadn't made any typos/errors in the guide.
A lot of init.d files collected here: http://forum.xda-developers.com/showthread.php?t=1227269
Also build.prop things, etc.
Thanks, I use your guide and worksperfect for my RK3066 devices. Very simple to understand all steps and what we are doing to our system, perfect for me. Thanks again dude
Melch1zedeK said:
Thanks, I use your guide and worksperfect for my RK3066 devices. Very simple to understand all steps and what we are doing to our system, perfect for me. Thanks again dude
Click to expand...
Click to collapse
Glad to help!
What is thhe utility of this?
moliverac8 said:
What is thhe utility of this?
Click to expand...
Click to collapse
Init.d is how Linux and many Android (which is kind of Linux, after all) systems manage executing commands on boot up.
The /etc/init.d files run in numerical order as root and you can do things like change system settings, manipulate the file system, etc.
See the init.d section linked below for some ideas.
http://forum.xda-developers.com/showthread.php?t=1227269
Question? what is the difference in this method and running a script?
wd5gnr said:
Init.d is how Linux and many Android (which is kind of Linux, after all) systems manage executing commands on boot up.
The /etc/init.d files run in numerical order as root and you can do things like change system settings, manipulate the file system, etc.
See the init.d section linked below for some ideas.
http://forum.xda-developers.com/showthread.php?t=1227269
Click to expand...
Click to collapse
I use the "swap memory script" and was wondering if it would also work this way with the init.d If so would there be any benefit this way over the current way of running it one way or the other? One drawback I see running the script as is is that I have to wait once the system has fully booted until the script has run and I see the Smanager screen to let me know that my memory has been remounted.
Thanks for the info and the learning process.
Here is the script and the link.
http://forum.xda-developers.com/showthread.php?t=1961097
Code:
sleep 5
mount -o remount,rw /
mount -t vfat -o umask=0000 /dev/block/vold/179:25 /mnt/sdcard
sleep 5
mount -o bind /data/media /mnt/extSdCard
As long as the device is ready to mount at boot time and doesn't get remounted, ought to work. Backup and try it
External memory wasn't ready
wd5gnr said:
As long as the device is ready to mount at boot time and doesn't get remounted, ought to work. Backup and try it
Click to expand...
Click to collapse
Thanks for the guide, but I think that the external memory was not ready to be mounted at that time. it didn't see the card till after boot. It was worth a shot, Reverted back to the script in /data and all worked again,
Note: I didn't find /system/xbin/run-parts however, I did find /system/bin/run-parts and changed the path to reflect that, I don't think this was an issue but I'm not 100% sure.

wrongly mounted s4 i9506 = now bricked?

I just rooted my SG S4 Android 5.0.1 with auto-root. Everything worked fine (root complete and SU installed) till I think I gave a bad mount command in the root directory on the phone in terminal (i guess here it went wrong, not sure. Or perhaps during installation of bash or nano) when I was installing bash and nano. Since it rebooted, I **lost the wifi and cannot adb shell into my phone** anymore from mac.
Afterwards, I managed to flash clockwork mod recovery v6.0.4.6. and was able to mount /system, which enabled the ./adb shell again. However i can now only pwd and cd, everything else gets this error: /sbin/sh: ls: Permission denied
I think my phone is still recoverable, however I don't know what to do and don't want to risk making things worse. Which andoird wizard can help me please?
**Below here were my bash nano install commands:**
./adb shell
su
mount -o remount,rw /system
cp -r /storage/extSdCard/bashnano/terminfo /system/etc
cp /storage/extSdCard/bashnano/profile /etc
cp /storage/extSdCard/bashnano/bash /data
cp /storage/extSdCard/bashnano/nano /data
chmod 755 /data/bash
chmod 755 /data/nano
cd /system/bin/
mv sh sh.old
ln -s /data/bash sh
ln -s /data/bash bash
ln -s /data/nano nano
export TERMINFO=/etc/terminfo
export TERM=linux
mount -o remount,ro /system
**P.S. So I also performed a regular mount in root, which i think is what made things bad, but not totally sure!**
ansjovis86 said:
I just rooted my SG S4 Android 5.0.1 with auto-root. Everything worked fine (root complete and SU installed) till I think I gave a bad mount command in the root directory on the phone in terminal (i guess here it went wrong, not sure. Or perhaps during installation of bash or nano) when I was installing bash and nano. Since it rebooted, I **lost the wifi and cannot adb shell into my phone** anymore from mac.
Afterwards, I managed to flash clockwork mod recovery v6.0.4.6. and was able to mount /system, which enabled the ./adb shell again. However i can now only pwd and cd, everything else gets this error: /sbin/sh: ls: Permission denied
I think my phone is still recoverable, however I don't know what to do and don't want to risk making things worse. Which andoird wizard can help me please?
**Below here were my bash nano install commands:**
./adb shell
su
mount -o remount,rw /system
cp -r /storage/extSdCard/bashnano/terminfo /system/etc
cp /storage/extSdCard/bashnano/profile /etc
cp /storage/extSdCard/bashnano/bash /data
cp /storage/extSdCard/bashnano/nano /data
chmod 755 /data/bash
chmod 755 /data/nano
cd /system/bin/
mv sh sh.old
ln -s /data/bash sh
ln -s /data/bash bash
ln -s /data/nano nano
export TERMINFO=/etc/terminfo
export TERM=linux
mount -o remount,ro /system
**P.S. So I also performed a regular mount in root, which i think is what made things bad, but not totally sure!**
Click to expand...
Click to collapse
If you can get into download mode ,flash stock rom from Sammobile

Categories

Resources