[TUTORIAL] How to test if scripts (tweaks) actually work

Search This thread

iridaki

Retired Forum Moderator
Feb 21, 2007
4,532
5,190
37
Edinburgh, Scotland
Hello!

As some of you know, pvyParts and I have been working on a custom stock-based ROM, T.E.A.M., which was initially released as a themed ROM to offer transparency and replace the Theme Chooser that we haven't been able to port properly, giving endless options on custom backgrounds (since your wallpaper is the system background). ;)

As the ROM evolved and custom kernels became available, I wanted to tweak it using init.d scripts.
As all good developers here do, I searched the Android Software and Hacking General section,
browsed other devices' forums and came up with some tweaks that were really good -on paper.

To my disappointment, most of these did not work.
And I am not saying this because I didn't "feel" a difference
or because I could not spread my X10's smoothness on a cracker. :D

There is actually a way to test if a script runs with no errors, a.k.a actually works.

Without further adieu, here is how:

1. Place the script you want to test (let's say test.sh)
in /system and give it all permissions,
either with Root Explorer or via adb:

Code:
adb shell chmod 777 /system/test.sh
NOTE: Sometimes scripts don't have an extension (sh).
It's OK, you can still test it with this method.


2. Now install an app like Script Manager and run the script.
Or, do it via adb:

Code:
adb shell sh /system/test.sh
3. Now there are 3 things you might face:

- If you get an error in return, it means the script doesn't work,
so no point in placing it in init.d and running it at every boot, right?

- Some scripts include debug, so you may get a message saying Done, Success, or whatever, which means you are good to go.

- You might not get any output at all, but still that means the script ran fine.

For the latter two cases, you can safely run the script at boot by placing it in init.d folder.


The reason this thread is in development, is because I feel that since the X10 is getting old and many developers have left,
(but luckily new ones still appear, which is plainly AWESOME :)), quality of ROMs is very important.
We have fewer choices, so let's make them worthwhile! ;)
 
Last edited:

Arnold.Alexius

Senior Member
Aug 12, 2011
163
65
its good to see dev sharing their dev knowledge and skills. this will make more dev for x10. more dev, more improvement we can do on our phone. Thanks My Immortal / iridaki. you're awsome ;)
 

maddes1402

Senior Member
May 11, 2011
943
571
so if my rom has a init.d folder, does it means it supports or run script (on init.d folder) at boot? is there a way to check if my rom has init.d support??

Yes, support at boot.
To my less knowledge, just look if there is a init. d folder in system/etc/
When you make an own rom check if the kernel you wanna use,has init. d support.
Hope I didn't talk crap and this is right :D


Sent from my X10i using Tapatalk
 
  • Like
Reactions: draiyan

draiyan

Senior Member
Dec 5, 2011
429
44
Cebu City
Redmi Note 10 Pro
but im really confuse here, i found this script,
Code:
/etc/init.d/03sdcardspeedfix
at some line of this script, it reads;
READ_AHEAD_KB="2048"

i know some c++ programming, and from what i know the value 2048 is assigned to read_ahead_kb, so i assume its the same in android. BUT, after reboot, i jumped to
Code:
/sys/devices/virtual/bdi/179:0/read_ahead_kb
to found out that its still 128, then i started thinking that the script didnt run, but the dev says the rom is init.d supported.

is there a way to test if init.d is reallty working? like at terminal emulator?
 

kaosdroid

Senior Member
Feb 2, 2011
409
67
caen
sure man !

you have two way for run tweak

in install-recovery.sh

or ini.d folder

but for be sure

create a file in system/etc

name it "install-recovery.sh"

copy this in and give all permission.



#!/system/bin/sh

#Mount Points
busybox mount -o remount,rw,noatime,nodiratime / -t rootfs
busybox mount -o remount,rw,noatime,nodiratime /sys -t sysfs
busybox mount -o remount,rw,noatime,nodiratime /system
busybox mount -o remount,rw,noatime,nodiratime /data
busybox mount -o remount,rw,noatime,nodiratime /cache


#init.d support
busybox run-parts /system/etc/init.d

run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1







now put your tweak in ini.d folder and reboot


be carefull !
if you have zipalign tweak
this tweak kill all tweak at boot because it unmount partition
and make it r/o instead of r/w

well,
tweak cannot access system or data like VM or sdcard tweak like read-ahead kb 2048.


now go in data/local/tmp
and check the log
to see if all it ok


but if ini.d does not run,
you could
insert tweak in install-recovery.sh

like this



#!/system/bin/sh

#give system permissions
busybox mount -o remount,rw /system
chmod 777 /system

#init.d support
busybox run-parts /system/etc/init.d

run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1

#uncap fps
mount -t debugfs debugfs /sys/kernel/debug
echo '0' > /sys/kernel/debug/msm_fb/0/vsync_enable
#th config
echo '0' > /sys/kernel/debug/msm_fb/0/hw_vsync_mode
echo '0' > /sys/kernel/debug/msm_fb/0/sw_refreshing_enable
echo '2' > /sys/kernel/debug/msm_fb/0/ref_cnt
echo '8' > /sys/kernel/debug/msm_fb/0/backbuff
echo '6000' > /sys/kernel/debug/msm_fb/0/refx100
#echo '1' > /sys/power/wake_lock *dangerous
#echo '1' > /sys/kernel/debug/kgsl/cache_enable *dangerous
echo '8192' > /sys/block/mmcblk0/queue/read_ahead_kb
echo '128' > /sys/block/mmcblk0/queue/max_sectors_kb
echo '8192' > /sys/block/mmcblk1/queue/read_ahead_kb
echo '128' > /sys/block/mmcblk1/queue/max_sectors_kb
#rm -f -rf /data/idd
#rm -f -rf /data/semc-checkin
umount /sys/kernel/debug

echo 0 > /sys/kernel/logger/log_main/enable
echo 0 > /sys/kernel/logger/log_event/enable
echo 0 > /sys/kernel/logger/log_radio/enable

echo 1024 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo 1024 > /sys/devices/virtual/bdi/default/read_ahead_kb

echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 30 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/down_differential
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load

# Delay the Media Scanner to help boot times
pm disable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &
sleep 80 && pm enable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &

#I/O Scheduler Tweaks
mount -o remount,noatime / -t rootfs
mount -o remount,noatime /dev -t devpts
mount -o remount,noatime /proc -t proc
mount -o remount,noatime /sys -t sysfs
mount -o remount,noatime /mnt/asec -t tmpfs
mount -o remount,noatime /system -t yaffs2
mount -o remount,noatime /data -t yaffs2
mount -o remount,noatime /cache -t yaffs2
mount -o remount,noatime /mnt/sdcard -t vfat
mount -o remount,noatime /mnt/secure/asec -t vfat
mount -o remount,noatime /mnt/sdcard/.android_secure -t tmpfs

i=`ls -d /sys/block/mtdblock3/queue/scheduler`;
STL=`ls -d /sys/block/stl*`;
BML=`ls -d /sys/block/bml*`;
MMC=`ls -d /sys/block/mmc*`;
TFSR=`ls -d /sys/block/tfsr*`;
DM=`ls -d /sys/block/dm*`;
MTD=`ls -d /sys/block/mtd*`;
LOOP=`ls -d /sys/block/loop*`;
RAM=`ls -d /sys/block/ram*`;
SYSDEV=`mount | grep '/system' | cut -d '/' -f 4`;
IO_SCHEDULER=`echo "noop" > /sys/block/mtdblock3/queue/scheduler/queue/rotational`;

for i in `busybox ls -1 /sys/block/mtdblock*`; do
echo "deadline" > $i/queue/scheduler;
done;

for k in $(busybox mount | cut -d " " -f3)
do
sync;
busybox mount -o remount,noatime,nodiratime $k;
done;

echo "deadline" > /sys/block/mmcblk0/queue/scheduler
echo "deadline" > /sys/block/dm-0/queue/scheduler
echo "deadline" > /sys/block/dm-1/queue/scheduler

for i in $MMC $MTD $LOOP; do
echo 0 > $i/queue/rotational;
done;

for i in $MMC $MTD; do
echo "deadline" > $i/queue/scheduler;
done;

for i in $MMC; do
echo 4096 > $i/queue/read_ahead_kb;
echo 0 > $i/queue/rotational;
echo 1 > $i/queue/iosched/low_latency;
echo 16 > $i/queue/iosched/quantum;
echo 8192 > $i/queue/nr_requests;
echo 1000000000 > $i/queue/iosched/back_seek_max;

for i in $STL $BML $MMC;
do
echo $IO_SCHEDULER > $i/queue/scheduler;
case $IO_SCHEDULER in
"deadline")
echo 1 > $i/queue/iosched/fifo_batch;;
"cfq")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
"bfq")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
"noop")
echo 1 > $i/queue/iosched/back_seek_penalty;
echo 3 > $i/queue/iosched/slice_idle;;
esac;
done;

#Dalvik Cache
if [ ! -d /cache/dalvik-cache ]
then
busybox rm -rf /cache/dalvik-cache /data/dalvik-cache
mkdir /cache/dalvik-cache /data/dalvik-cache
fi

#Dalvik Cache
busybox chown 1000:1000 /cache/dalvik-cache
busybox chmod 0771 /cache/dalvik-cache

#bind mount dalvik-cache so we can still boot without the sdcard
busybox mount -o bind /cache/dalvik-cache /data/dalvik-cache
busybox chown 1000:1000 /data/dalvik-cache
busybox chmod 0771 /data/dalvik-cache

#Remove
busybox rm -rf /data/tombstones/*

#Zipalign
mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system
cd /system/app
for z in *.apk; do
zipalign -c 4 $z
if [ "$?" -ne "0" ]; then
echo zipalign $z !
zipalign -f 4 $z /tmp/$z
cp /tmp/$z $z
rm /tmp/$z
fi
done
mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system

mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data
cd /data/app
for z in *.apk; do
zipalign -c 4 $z
if [ "$?" -ne "0" ]; then
echo zipalign $z !
zipalign -f 4 $z /tmp/$z
cp /tmp/$z $z
rm /tmp/$z
fi
done
mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data

#Phone Lag Tweaks
MAX_PHONE() {
pidphone=`pidof com.android.phone`;
if [ $pidphone ]; then
echo -17 > /proc/$pidphone/oom_adj;
renice -20 $pidphone;
exit;
else
sleep 5;
MAX_PHONE;
fi;
}

(while [ 1 ]; do
sleep 10;
MAX_PHONE;
done &);

if [ $ENABLE_MAXPHONE -eq 1 ];
then
PROC_ADJUST "com.android.phone" "-20" &
fi;

for j in $DM $MTD $LOOP $RAM; do
echo 0 > $j/queue/rotational;
done;

strace -p $(pidof yourapp) # for all your running applications
ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time

#CPUTweak's Variables
last_source="unknown";
charging_source=$(cat /sys/class/power_supply/battery/charging_source);
capacity=$(cat /sys/class/power_supply/battery/capacity);

if [ $ENABLE_SWITCH -eq 1 ];
then
ALLFREQS=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`;
(while [ 1 ];
do
cat /sys/power/wait_for_fb_wake;
AWAKE_MODE;

cat /sys/power/wait_for_fb_sleep;
SLEEP_MODE;
done &)
fi;

BAT_SLEEP_GOV="powersave"
USB_SLEEP_GOV="powersave"
POW_SLEEP_GOV="powersave"

#CPUTweak's Functions
Battery() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $BAT_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 100 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $BAT_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3
}

USB() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $USB_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $USB_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
}

Power() {
(while [ 1 ]; do
if [ $AWAKE = "awake" ]; then
echo $POW_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
AWAKE=
fi;
if [ $SLEEPING = "sleeping" ]; then
echo $POW_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
SLEEPING=
fi;
done &)
}

#
# Loopy Smoothness Tweak for X10
#

for n in 1 2
do

USER_LAUNCHER="com.sonyericsson.home" # Change this to your launcher app

NUMBER_OF_CHECKS=35 # Total number of rechecks before ending 1st loop
SLEEP_TIME=3 # Number of seconds between rechecking processes
PROCESSES_TOTAL=4 # Must be edited to match the number of processes to be checked
DEBUG_ECHO=0 # Debug on/off

CHECK_COUNT=0 # Don't edit
P_CHECK=0 # Don't edit
CHECK_OK=0 # Unused

PROCESS_1=0; PROCESS_2=0; PROCESS_3=0; PROCESS_4=0; PROCESS_5=0; PROCESS_6=0;
PROCESS_7=0; PROCESS_8=0; PROCESS_9=0; PROCESS_10=0; PROCESS_11=0; PROCESS_12=0;
PROCESS_13=0; PROCESS_14=0; PROCESS_15=0; PROCESS_16=0; PROCESS_17=0; PROCESS_18=0;
PROCESS_19=0; PROCESS_20=0; PROCESS_21=0; PROCESS_22=0; PROCESS_23=0; PROCESS_24=0;

if [ $n -eq "1" ]; then
if [ $DEBUG_ECHO -eq "1" ]; then
echo ""
echo "LST Debug: $(date)"
echo "LST Debug: Initiate"
fi;

# Pause and then loop until kswapd0 is found, which should be instant anyway
sleep 1
SWAP_SLEEP_TIME=3; SWAP_NUMBER_OF_CHECKS=30; SWAP_CHECK_COUNT=0; SWAP_CHECK_COUNT_OK=0; while [ $SWAP_CHECK_COUNT -lt $SWAP_NUMBER_OF_CHECKS ]; do if [ `pidof kswapd0` ]; then renice 19 `pidof kswapd0`; SWAP_CHECK_COUNT=$SWAP_NUMBER_OF_CHECKS; SWAP_CHECK_COUNT_OK=1; else sleep $SWAP_SLEEP_TIME; fi; SWAP_CHECK_COUNT=`expr $SWAP_CHECK_COUNT + 1`; done; if [ $SWAP_CHECK_COUNT_OK -lt 1 ]; then echo "LST Debug: 'kswapd0' expired after `expr $SWAP_CHECK_COUNT \* $SWAP_SLEEP_TIME` seconds"; fi;

if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: $(date)";
echo "LST Debug: kswapd0 found";
fi;
fi;

# Check briefly one more time
if [ $n -eq "2" ]; then
if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: 2nd loop"
fi;
NUMBER_OF_CHECKS=6 # Editing not recommended
SLEEP_TIME=5 # Editing not recommended
fi;

while [ $CHECK_COUNT -lt $NUMBER_OF_CHECKS ];
do
# Resident system apps
if [ $PROCESS_1 -eq "0" ]; then PNAME="com.android.phone"; NICELEVEL=-20; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_1=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_2 -eq "0" ]; then PNAME="$USER_LAUNCHER"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_2=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_3 -eq "0" ]; then PNAME="com.sonyericsson.conversations"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_3=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
if [ $PROCESS_4 -eq "0" ]; then PNAME="com.sonyericsson.music"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_4=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;

# If all processes are done, loop can finish early
if [ $P_CHECK -ge $PROCESSES_TOTAL ]; then CHECK_COUNT=$NUMBER_OF_CHECKS; else sleep $SLEEP_TIME; fi;

CHECK_COUNT=`expr $CHECK_COUNT + 1`;
done

if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: $(date)"
if [ $PROCESS_1 -eq "0" ]; then echo "LST Debug: PROCESS_1 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_2 -eq "0" ]; then echo "LST Debug: PROCESS_2 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;

echo "LST Debug: Checking complete"
fi;

done

if [ $DEBUG_ECHO -eq "1" ]; then
echo "LST Debug: Done"
echo ""
fi;






this is an exemple!
but you could use it !
it improve speed of your phone hahaha !!!

bip
 
Last edited:

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
Another tip - add this command to the top of the script:

Code:
set -xv

This will give full command echoing when you run the script so you can see where the error is. The android shell doesn't report lines accurately, I think it's because it doesn't count comments as lines. It will also make easily visible syntax errors that dont error but cause a conditional to report incorrect, e.g. if you accidentally use == instead of = or forget double-quotes when comparing strings.
 
  • Like
Reactions: Arnold.Alexius

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    Hello!

    As some of you know, pvyParts and I have been working on a custom stock-based ROM, T.E.A.M., which was initially released as a themed ROM to offer transparency and replace the Theme Chooser that we haven't been able to port properly, giving endless options on custom backgrounds (since your wallpaper is the system background). ;)

    As the ROM evolved and custom kernels became available, I wanted to tweak it using init.d scripts.
    As all good developers here do, I searched the Android Software and Hacking General section,
    browsed other devices' forums and came up with some tweaks that were really good -on paper.

    To my disappointment, most of these did not work.
    And I am not saying this because I didn't "feel" a difference
    or because I could not spread my X10's smoothness on a cracker. :D

    There is actually a way to test if a script runs with no errors, a.k.a actually works.

    Without further adieu, here is how:

    1. Place the script you want to test (let's say test.sh)
    in /system and give it all permissions,
    either with Root Explorer or via adb:

    Code:
    adb shell chmod 777 /system/test.sh
    NOTE: Sometimes scripts don't have an extension (sh).
    It's OK, you can still test it with this method.


    2. Now install an app like Script Manager and run the script.
    Or, do it via adb:

    Code:
    adb shell sh /system/test.sh
    3. Now there are 3 things you might face:

    - If you get an error in return, it means the script doesn't work,
    so no point in placing it in init.d and running it at every boot, right?

    - Some scripts include debug, so you may get a message saying Done, Success, or whatever, which means you are good to go.

    - You might not get any output at all, but still that means the script ran fine.

    For the latter two cases, you can safely run the script at boot by placing it in init.d folder.


    The reason this thread is in development, is because I feel that since the X10 is getting old and many developers have left,
    (but luckily new ones still appear, which is plainly AWESOME :)), quality of ROMs is very important.
    We have fewer choices, so let's make them worthwhile! ;)
    3
    Doing it right now.

    BTW- I'm first! Again!

    Let us know how it went! ;)
    2
    its good to see dev sharing their dev knowledge and skills. this will make more dev for x10. more dev, more improvement we can do on our phone. Thanks My Immortal / iridaki. you're awsome ;)
    2
    sure man !

    you have two way for run tweak

    in install-recovery.sh

    or ini.d folder

    but for be sure

    create a file in system/etc

    name it "install-recovery.sh"

    copy this in and give all permission.



    #!/system/bin/sh

    #Mount Points
    busybox mount -o remount,rw,noatime,nodiratime / -t rootfs
    busybox mount -o remount,rw,noatime,nodiratime /sys -t sysfs
    busybox mount -o remount,rw,noatime,nodiratime /system
    busybox mount -o remount,rw,noatime,nodiratime /data
    busybox mount -o remount,rw,noatime,nodiratime /cache


    #init.d support
    busybox run-parts /system/etc/init.d

    run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1







    now put your tweak in ini.d folder and reboot


    be carefull !
    if you have zipalign tweak
    this tweak kill all tweak at boot because it unmount partition
    and make it r/o instead of r/w

    well,
    tweak cannot access system or data like VM or sdcard tweak like read-ahead kb 2048.


    now go in data/local/tmp
    and check the log
    to see if all it ok


    but if ini.d does not run,
    you could
    insert tweak in install-recovery.sh

    like this



    #!/system/bin/sh

    #give system permissions
    busybox mount -o remount,rw /system
    chmod 777 /system

    #init.d support
    busybox run-parts /system/etc/init.d

    run-parts /system/etc/init.d >> /data/local/tmp/runparts.log 2>&1

    #uncap fps
    mount -t debugfs debugfs /sys/kernel/debug
    echo '0' > /sys/kernel/debug/msm_fb/0/vsync_enable
    #th config
    echo '0' > /sys/kernel/debug/msm_fb/0/hw_vsync_mode
    echo '0' > /sys/kernel/debug/msm_fb/0/sw_refreshing_enable
    echo '2' > /sys/kernel/debug/msm_fb/0/ref_cnt
    echo '8' > /sys/kernel/debug/msm_fb/0/backbuff
    echo '6000' > /sys/kernel/debug/msm_fb/0/refx100
    #echo '1' > /sys/power/wake_lock *dangerous
    #echo '1' > /sys/kernel/debug/kgsl/cache_enable *dangerous
    echo '8192' > /sys/block/mmcblk0/queue/read_ahead_kb
    echo '128' > /sys/block/mmcblk0/queue/max_sectors_kb
    echo '8192' > /sys/block/mmcblk1/queue/read_ahead_kb
    echo '128' > /sys/block/mmcblk1/queue/max_sectors_kb
    #rm -f -rf /data/idd
    #rm -f -rf /data/semc-checkin
    umount /sys/kernel/debug

    echo 0 > /sys/kernel/logger/log_main/enable
    echo 0 > /sys/kernel/logger/log_event/enable
    echo 0 > /sys/kernel/logger/log_radio/enable

    echo 1024 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
    echo 1024 > /sys/devices/virtual/bdi/default/read_ahead_kb

    echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
    echo 30 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/down_differential
    echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
    echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
    echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load

    # Delay the Media Scanner to help boot times
    pm disable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &
    sleep 80 && pm enable com.android.providers.media/com.android.providers.media.MediaScannerReceiver &

    #I/O Scheduler Tweaks
    mount -o remount,noatime / -t rootfs
    mount -o remount,noatime /dev -t devpts
    mount -o remount,noatime /proc -t proc
    mount -o remount,noatime /sys -t sysfs
    mount -o remount,noatime /mnt/asec -t tmpfs
    mount -o remount,noatime /system -t yaffs2
    mount -o remount,noatime /data -t yaffs2
    mount -o remount,noatime /cache -t yaffs2
    mount -o remount,noatime /mnt/sdcard -t vfat
    mount -o remount,noatime /mnt/secure/asec -t vfat
    mount -o remount,noatime /mnt/sdcard/.android_secure -t tmpfs

    i=`ls -d /sys/block/mtdblock3/queue/scheduler`;
    STL=`ls -d /sys/block/stl*`;
    BML=`ls -d /sys/block/bml*`;
    MMC=`ls -d /sys/block/mmc*`;
    TFSR=`ls -d /sys/block/tfsr*`;
    DM=`ls -d /sys/block/dm*`;
    MTD=`ls -d /sys/block/mtd*`;
    LOOP=`ls -d /sys/block/loop*`;
    RAM=`ls -d /sys/block/ram*`;
    SYSDEV=`mount | grep '/system' | cut -d '/' -f 4`;
    IO_SCHEDULER=`echo "noop" > /sys/block/mtdblock3/queue/scheduler/queue/rotational`;

    for i in `busybox ls -1 /sys/block/mtdblock*`; do
    echo "deadline" > $i/queue/scheduler;
    done;

    for k in $(busybox mount | cut -d " " -f3)
    do
    sync;
    busybox mount -o remount,noatime,nodiratime $k;
    done;

    echo "deadline" > /sys/block/mmcblk0/queue/scheduler
    echo "deadline" > /sys/block/dm-0/queue/scheduler
    echo "deadline" > /sys/block/dm-1/queue/scheduler

    for i in $MMC $MTD $LOOP; do
    echo 0 > $i/queue/rotational;
    done;

    for i in $MMC $MTD; do
    echo "deadline" > $i/queue/scheduler;
    done;

    for i in $MMC; do
    echo 4096 > $i/queue/read_ahead_kb;
    echo 0 > $i/queue/rotational;
    echo 1 > $i/queue/iosched/low_latency;
    echo 16 > $i/queue/iosched/quantum;
    echo 8192 > $i/queue/nr_requests;
    echo 1000000000 > $i/queue/iosched/back_seek_max;

    for i in $STL $BML $MMC;
    do
    echo $IO_SCHEDULER > $i/queue/scheduler;
    case $IO_SCHEDULER in
    "deadline")
    echo 1 > $i/queue/iosched/fifo_batch;;
    "cfq")
    echo 1 > $i/queue/iosched/back_seek_penalty;
    echo 3 > $i/queue/iosched/slice_idle;;
    "bfq")
    echo 1 > $i/queue/iosched/back_seek_penalty;
    echo 3 > $i/queue/iosched/slice_idle;;
    "noop")
    echo 1 > $i/queue/iosched/back_seek_penalty;
    echo 3 > $i/queue/iosched/slice_idle;;
    esac;
    done;

    #Dalvik Cache
    if [ ! -d /cache/dalvik-cache ]
    then
    busybox rm -rf /cache/dalvik-cache /data/dalvik-cache
    mkdir /cache/dalvik-cache /data/dalvik-cache
    fi

    #Dalvik Cache
    busybox chown 1000:1000 /cache/dalvik-cache
    busybox chmod 0771 /cache/dalvik-cache

    #bind mount dalvik-cache so we can still boot without the sdcard
    busybox mount -o bind /cache/dalvik-cache /data/dalvik-cache
    busybox chown 1000:1000 /data/dalvik-cache
    busybox chmod 0771 /data/dalvik-cache

    #Remove
    busybox rm -rf /data/tombstones/*

    #Zipalign
    mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system
    cd /system/app
    for z in *.apk; do
    zipalign -c 4 $z
    if [ "$?" -ne "0" ]; then
    echo zipalign $z !
    zipalign -f 4 $z /tmp/$z
    cp /tmp/$z $z
    rm /tmp/$z
    fi
    done
    mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /system

    mount -o remount,rw -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data
    cd /data/app
    for z in *.apk; do
    zipalign -c 4 $z
    if [ "$?" -ne "0" ]; then
    echo zipalign $z !
    zipalign -f 4 $z /tmp/$z
    cp /tmp/$z $z
    rm /tmp/$z
    fi
    done
    mount -o remount,ro -t yaffs2 `grep /system /proc/mounts | cut -d' ' -f1` /data

    #Phone Lag Tweaks
    MAX_PHONE() {
    pidphone=`pidof com.android.phone`;
    if [ $pidphone ]; then
    echo -17 > /proc/$pidphone/oom_adj;
    renice -20 $pidphone;
    exit;
    else
    sleep 5;
    MAX_PHONE;
    fi;
    }

    (while [ 1 ]; do
    sleep 10;
    MAX_PHONE;
    done &);

    if [ $ENABLE_MAXPHONE -eq 1 ];
    then
    PROC_ADJUST "com.android.phone" "-20" &
    fi;

    for j in $DM $MTD $LOOP $RAM; do
    echo 0 > $j/queue/rotational;
    done;

    strace -p $(pidof yourapp) # for all your running applications
    ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time

    #CPUTweak's Variables
    last_source="unknown";
    charging_source=$(cat /sys/class/power_supply/battery/charging_source);
    capacity=$(cat /sys/class/power_supply/battery/capacity);

    if [ $ENABLE_SWITCH -eq 1 ];
    then
    ALLFREQS=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies`;
    (while [ 1 ];
    do
    cat /sys/power/wait_for_fb_wake;
    AWAKE_MODE;

    cat /sys/power/wait_for_fb_sleep;
    SLEEP_MODE;
    done &)
    fi;

    BAT_SLEEP_GOV="powersave"
    USB_SLEEP_GOV="powersave"
    POW_SLEEP_GOV="powersave"

    #CPUTweak's Functions
    Battery() {
    (while [ 1 ]; do
    if [ $AWAKE = "awake" ]; then
    echo $BAT_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
    echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
    echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
    echo 100 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
    AWAKE=
    fi;
    if [ $SLEEPING = "sleeping" ]; then
    echo $BAT_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
    echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
    echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
    echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
    echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
    SLEEPING=
    fi;
    done &)
    mount -o remount,ro -t yaffs2 /dev/block/mtdblock3
    }

    USB() {
    (while [ 1 ]; do
    if [ $AWAKE = "awake" ]; then
    echo $USB_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
    echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
    echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
    echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
    AWAKE=
    fi;
    if [ $SLEEPING = "sleeping" ]; then
    echo $USB_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
    echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
    echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
    echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
    echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
    SLEEPING=
    fi;
    done &)
    }

    Power() {
    (while [ 1 ]; do
    if [ $AWAKE = "awake" ]; then
    echo $POW_AWAKE_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
    echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
    echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
    echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
    AWAKE=
    fi;
    if [ $SLEEPING = "sleeping" ]; then
    echo $POW_SLEEP_GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
    echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
    echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/up_threshold
    echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/sampling_rate
    echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/powersave/powersave_bias
    SLEEPING=
    fi;
    done &)
    }

    #
    # Loopy Smoothness Tweak for X10
    #

    for n in 1 2
    do

    USER_LAUNCHER="com.sonyericsson.home" # Change this to your launcher app

    NUMBER_OF_CHECKS=35 # Total number of rechecks before ending 1st loop
    SLEEP_TIME=3 # Number of seconds between rechecking processes
    PROCESSES_TOTAL=4 # Must be edited to match the number of processes to be checked
    DEBUG_ECHO=0 # Debug on/off

    CHECK_COUNT=0 # Don't edit
    P_CHECK=0 # Don't edit
    CHECK_OK=0 # Unused

    PROCESS_1=0; PROCESS_2=0; PROCESS_3=0; PROCESS_4=0; PROCESS_5=0; PROCESS_6=0;
    PROCESS_7=0; PROCESS_8=0; PROCESS_9=0; PROCESS_10=0; PROCESS_11=0; PROCESS_12=0;
    PROCESS_13=0; PROCESS_14=0; PROCESS_15=0; PROCESS_16=0; PROCESS_17=0; PROCESS_18=0;
    PROCESS_19=0; PROCESS_20=0; PROCESS_21=0; PROCESS_22=0; PROCESS_23=0; PROCESS_24=0;

    if [ $n -eq "1" ]; then
    if [ $DEBUG_ECHO -eq "1" ]; then
    echo ""
    echo "LST Debug: $(date)"
    echo "LST Debug: Initiate"
    fi;

    # Pause and then loop until kswapd0 is found, which should be instant anyway
    sleep 1
    SWAP_SLEEP_TIME=3; SWAP_NUMBER_OF_CHECKS=30; SWAP_CHECK_COUNT=0; SWAP_CHECK_COUNT_OK=0; while [ $SWAP_CHECK_COUNT -lt $SWAP_NUMBER_OF_CHECKS ]; do if [ `pidof kswapd0` ]; then renice 19 `pidof kswapd0`; SWAP_CHECK_COUNT=$SWAP_NUMBER_OF_CHECKS; SWAP_CHECK_COUNT_OK=1; else sleep $SWAP_SLEEP_TIME; fi; SWAP_CHECK_COUNT=`expr $SWAP_CHECK_COUNT + 1`; done; if [ $SWAP_CHECK_COUNT_OK -lt 1 ]; then echo "LST Debug: 'kswapd0' expired after `expr $SWAP_CHECK_COUNT \* $SWAP_SLEEP_TIME` seconds"; fi;

    if [ $DEBUG_ECHO -eq "1" ]; then
    echo "LST Debug: $(date)";
    echo "LST Debug: kswapd0 found";
    fi;
    fi;

    # Check briefly one more time
    if [ $n -eq "2" ]; then
    if [ $DEBUG_ECHO -eq "1" ]; then
    echo "LST Debug: 2nd loop"
    fi;
    NUMBER_OF_CHECKS=6 # Editing not recommended
    SLEEP_TIME=5 # Editing not recommended
    fi;

    while [ $CHECK_COUNT -lt $NUMBER_OF_CHECKS ];
    do
    # Resident system apps
    if [ $PROCESS_1 -eq "0" ]; then PNAME="com.android.phone"; NICELEVEL=-20; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_1=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
    if [ $PROCESS_2 -eq "0" ]; then PNAME="$USER_LAUNCHER"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_2=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
    if [ $PROCESS_3 -eq "0" ]; then PNAME="com.sonyericsson.conversations"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_3=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;
    if [ $PROCESS_4 -eq "0" ]; then PNAME="com.sonyericsson.music"; NICELEVEL=-19; if [ `pidof $PNAME` ]; then renice $NICELEVEL `pidof $PNAME`; PROCESS_4=1; P_CHECK=`expr $P_CHECK + 1`; fi; fi;

    # If all processes are done, loop can finish early
    if [ $P_CHECK -ge $PROCESSES_TOTAL ]; then CHECK_COUNT=$NUMBER_OF_CHECKS; else sleep $SLEEP_TIME; fi;

    CHECK_COUNT=`expr $CHECK_COUNT + 1`;
    done

    if [ $DEBUG_ECHO -eq "1" ]; then
    echo "LST Debug: $(date)"
    if [ $PROCESS_1 -eq "0" ]; then echo "LST Debug: PROCESS_1 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
    if [ $PROCESS_2 -eq "0" ]; then echo "LST Debug: PROCESS_2 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
    if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;
    if [ $PROCESS_3 -eq "0" ]; then echo "LST Debug: PROCESS_3 expired after `expr $CHECK_COUNT \* $SLEEP_TIME` seconds"; fi;

    echo "LST Debug: Checking complete"
    fi;

    done

    if [ $DEBUG_ECHO -eq "1" ]; then
    echo "LST Debug: Done"
    echo ""
    fi;






    this is an exemple!
    but you could use it !
    it improve speed of your phone hahaha !!!

    bip
    1
    Doing it right now.

    BTW- I'm first! Again!