[DEV][MIUI] New Automatic Hardware LED Fix - XPERIA X10 Android Development

Hello all,
I wrote this init.d script to be included in the next version of Team M&M's MIUI ROM. Here I am releasing it to the masses for inclusion in your ROM.
Automatically detects/changes light values to switch out framework-res.safe and framework-res.hwled - the script is pretty self explanatory. Enjoy
License...? Whatever you want, GPLv2 I guess. Just don't steal it and claim it as your own, credit would be nice.
Behold:
Code:
# ------------------------------------------------
# Team M&M's MIUI script by CosmicDan
# ------------------------------------------------
# Auto HW_LED fix
# You can change these variables to your liking, but don't blame us for explosions if you get it wrong ;)
# Pretty sure these do nothing anyway since the X10 ambient light sensor is not read by the OS (the LCD
# hardware controls it 100% on it's own AFAIK) but MiUI needs these values otherwise it won't boot.
#
# Second release - also disables "Automatic Brightness" (manual only). You can disable this toggle via XML
# now if you wish ;)
#
my_light_sensor_levels="200,400,1000,3000"
my_light_sensor_lcd_values="35,55,70,70,250"
my_light_sensor_button_values="255,255,0,0,0"
#
# ------------------------------------------------
# ------------------------------------------------
# ------------------------------------------------
# DON'T TOUCH ANYTHING BELOW HERE!
# ------------------------------------------------
# Verbose shell output for debugging purposes
# set -xv
# ------------------------------------------------
# Helper functions
# ------------------------------------------------
dodatabase()
{
if [ "$1" = "1" ];
then
if [ "$2" = "check" ];
then
dosql read "light_screen_dim";
fi
if [ "$2" = "set" ];
then
dosql write 88 "light_screen_dim" "20";
[ "$?" -eq "0" ] && light_screen_dim=20;
fi
fi
if [ "$1" = "2" ];
then
if [ "$2" = "check" ];
then
dosql read light_sensor_custom;
fi
if [ "$2" = "set" ];
then
dosql write 82 light_sensor_custom "1";
[ "$?" -eq "0" ] && light_sensor_custom=1;
fi
fi
if [ "$1" = "3" ];
then
[ "$2" = "check" ] && dosql read light_sensor_levels;
[ "$2" = "set" ] && dosql write 89 light_sensor_levels "$my_light_sensor_levels";
fi
if [ "$1" = "4" ];
then
[ "$2" = "check" ] && dosql read light_sensor_lcd_values;
[ "$2" = "set" ] && dosql write 90 light_sensor_lcd_values "$my_light_sensor_lcd_values";
fi
if [ "$1" = "5" ];
then
[ "$2" = "check" ] && dosql read light_sensor_button_values;
[ "$2" = "set" ] && dosql write 91 light_sensor_button_values "$my_light_sensor_button_values";
fi
if [ "$1" = "6" ];
then
[ "$2" = "check" ] && dosql read light_sensor_keyboard_values;
[ "$2" = "set" ] && dosql write 92 light_sensor_keyboard_values "0,0,0,0,0";
fi
if [ "$1" = "7" ];
then
[ "$2" = "check" ] && dosql read screen_brightness_mode;
[ "$2" = "set" ] && dosql write 25 screen_brightness_mode "0";
fi
}
dosql()
{
if [ "$1" = "read" ];
then
eval "$2"=`sqlite3 -nullvalue 'nullvalue' -column $SETTINGSDB 'SELECT value FROM system WHERE name='\"$2\"';'`;
elif [ "$1" = "write" ];
then
sqlite3 -nullvalue 'nullvalue' -column $SETTINGSDB 'INSERT OR REPLACE INTO system VALUES ('\"$2\"','\"$3\"','\"$4\"');';
echo "[M&M] Changed settings - \"$3\" (at _id $2) to $4";
fi
}
# ------------------------------------------------
# ------------------------------------------------
# ------------------------------------------------
echo "[M&M] Running M&M TEAM Custom Boot Parameters...";
SETTINGSDB=/data/data/com.android.providers.settings/databases/settings.db
if [ -e $SETTINGSDB ];
then
echo "[M&M] Verifying locked settings...";
dodatabase 1 check
if [ ! "$light_screen_dim" = "20" ];
then
dodatabase 1 set
else
echo "[M&M] light_screen_dim already 20, unchanged";
fi
dodatabase 2 check
if [ ! "$light_sensor_custom" = "1" ];
then
dodatabase 2 set
else
echo "[M&M] light_sensor_custom already enabled, unchanged";
fi
# Verify additional settings relating to Display
dodatabase 3 check
if [ ! "$my_light_sensor_levels" = "$light_sensor_levels" ];
then
dodatabase 3 set
else
echo "[M&M] light_sensor_levels already set, unchanged";
fi
dodatabase 4 check
if [ ! "$my_light_sensor_lcd_values" = "$light_sensor_lcd_values" ];
then
dodatabase 4 set
else
echo "[M&M] light_sensor_lcd_values already set, unchanged";
fi
dodatabase 5 check
if [ ! "$light_sensor_button_values" = "255,255,0,0,0" ];
then
dodatabase 5 set
else
echo "[M&M] light_sensor_button_values already set, unchanged";
fi
dodatabase 6 check
if [ ! "$light_sensor_keyboard_values" = "0,0,0,0,0" ];
then
dodatabase 6 set
else
echo "[M&M] light_sensor_keyboard_values already set, unchanged";
fi
dodatabase 7 check
if [ ! "$screen_brightness_mode" = "0" ];
then
dodatabase 7 set
else
echo "[M&M] screen_brightness_mode already manual, unchanged";
fi
else
echo "[M&M] Settings Provider database not found! Factory defaults assumed.";
fi
if [ "$light_screen_dim" -eq "20" ] && [ "$light_sensor_custom" -eq "1" ]; then hw_led=1; fi
if [ "$hw_led" -eq "1" ];
then
if [ -e /system/framework/framework-res.hwled ];
then
echo "[M&M] HW_LED fix is allowed but not enabled yet. Now enabling and clearing dalvik-cache...";
mount -o rw,remount -t yaffs2 /dev/block/mtdblock2 /system;
mv /system/framework/framework-res.apk /system/framework/framework-res.safe;
mv /system/framework/framework-res.hwled /system/framework/framework-res.apk;
mount -o ro,remount -t yaffs2 /dev/block/mtdblock2 /system;
sqlite3 -column $SETTINGSDB 'DROP INDEX systemIndex1;'
sqlite3 -column $SETTINGSDB 'CREATE INDEX systemIndex1 ON system (name);'
rm -r -f /data/dalvik-cache/*
fi
else
if [ -e /system/framework/framework-res.safe ];
then
echo "[M&M] HW_LED fix is NOT allowed yet but still enabled."
echo "[M&M] ...Assumed factory reset performed (or database permissions/integrity error)"
echo "[M&M] ...Now reverting to safe framework and clearing dalvik-cache to prevent bootloop...";
mount -o rw,remount -t yaffs2 /dev/block/mtdblock2 /system;
mv /system/framework/framework-res.apk /system/framework/framework-res.hwled;
mv /system/framework/framework-res.safe /system/framework/framework-res.apk;
mount -o ro,remount -t yaffs2 /dev/block/mtdblock2 /system;
if [ -e $SETTINGSDB ]; then
sqlite3 -column $SETTINGSDB 'DROP INDEX systemIndex1;'
sqlite3 -column $SETTINGSDB 'CREATE INDEX systemIndex1 ON system (name);'
fi
rm -r -f /data/dalvik-cache/*
fi
fi
SETTINGSDB=
light_screen_dim=
light_sensor_custom=
light_sensor_levels=
light_sensor_lcd_values=
light_sensor_button_values=
light_sensor_keyboard_values=
screen_brightness_mode=
my_light_sensor_levels=
my_light_sensor_lcd_values=
hw_led=
echo "[M&M] Custom boot processing complete."
exit 0
Obviously, you have the stock (safe) framework as "framework-res.apk" and then place your HW-LED modified one as framework-res.hwled
The basic summary is that it checks what the values are for display, adjusts them if needed, then enables the hwled fixed version of APK and backing up the old one. In the event of a Factory Reset (i.e. database for Settings Provider not found) it will swap the safe one back in. The user just has to reboot again to get the HW-LED one back, since the settings database has been recreated.

So this means we can finally use the automatic brightness function?

Hzu said:
So this means we can finally use the automatic brightness function?
Click to expand...
Click to collapse
Umm...... no. This is just a script for MIUI cookers and kangers to show that they don't need to make or provide manual enable/disable HWLED FIX ZIP's if they don't want them. This has nothing to do with auto brightness.
The auto-brightness thing in the X10 doesn't work because it's part of the hardware and not software-controlled like other Android phones made after. Maybe FXP developers will get it one day with a new driver but yeah, this is completely unrelated and only applies to address a known MiUI porting issue to X10 with an automatic workaround.

Ah, you mean THAT HW LED. Sorry, got a little bit confused. Shouldn't have read this while in the car.

Haha... yes, well... this is for the MiUI ROM's only. Just an automatic way instead of that whole "Change Dim to 20, reboot, flash ZIP, don't change from 20 again" nonsense. The auto-brightness for X10 I don't think will ever work, I am 90% sure that the ambient light sensor is directly tied to hardware LCD. I'm not just saying this because I'm an X10 fan but I think auto-brightness is pretty crap on most phones I've used anyway (Galaxy S II and HTC Wildfire S)....
....regardless, this fix will be included in Team M&M's MiUI v7 due for release soon. The ROM also completely disables the automatic brightness settings via Settings.apk XML editing, because they are useless.
Also, script in OP updated I'm sure at least one MiUI Dev for X10 will find this useful, if they want to compete with Team M&M that is

Yes, the auto brightness won't work due to lack of hardware Support. And I've tried the auto brightness setting on my friend's phone (I forgot the model) and its actually... very annoying to me.

Related

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

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.
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!
Doing it right now.
BTW- I'm first! Again!
Prodigy said:
Doing it right now.
BTW- I'm first! Again!
Click to expand...
Click to collapse
Let us know how it went!
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
Thank
cause script stress me well
Now i can see if work or not
X10-tripmiui,iris,00
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??
draiyan said:
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??
Click to expand...
Click to collapse
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
Sent from my X10i using Tapatalk
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"
Click to expand...
Click to collapse
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?
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
i tried install-recovery but i got no file at local/temp??? there should be a log file in it rigth?
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.

[Q] Repurpose Eris?

I have two of these devices sitting around and I was wondering how people were repurposing them. I just picked up a Raspberry Pi with the intention of setting up a home automation system. Isn't the Eris also an ARMv6 processor? Could they be used as smart WiIP video security cameras? Is there a Linux distro somewhere? Anyone have any experience?
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
roirraW "edor" ehT said:
Greetings! There's a thread here you might be interested in. http://forum.xda-developers.com/showthread.php?t=823564&highlight=linux
Click to expand...
Click to collapse
http://www.4shared.com/zip/uiPl7NhN/ubuntu.html Link to Ubuntu.img
to mount you can use this:
linuxboot.sh
#option if you wish to load a different file than the rc_enter just replace the rc_enter.sh with the script file you want to run
# i.e init.sh below this script I will post the initl.ls if you wan to replace the rc_enter.sh
Code:
#!/system/bin/sh
(
# If $BINDS does not exist, then done of the others are set iether.
if [ -z "$BINDS" ]; then
export DIST="debian squeeze"
export FILESYSTEM=/sdcard/ubuntu.img
export MOUNTPOINT=/sdcard/linux
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
export USER=root
export LOGNAME=root
export UID=0
export SHELL=bash
export FS=ext3
export busybox="/data/data/com.galoula.LinuxInstall/bin/busybox"
export BINDS="1"
unset TMPDIR
fi
createLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/proc")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
fi
else
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If the loop device is already mounted, we do nothing.
echo "W: $DIST is already mounted. Entering chroot..."
else
echo "I: Mounting device for $DIST..."
if $busybox [ ! -d $MOUNTPOINT ]; then
# Create the mount point if it does not already exist
$busybox mkdir -p $MOUNTPOINT 2> /dev/null
if $busybox [ ! -d $MOUNTPOINT ]; then
echo "F: It was not possible to create the missing mount location ($MOUNTPOINT)"
return 0
fi
fi
if $busybox [ -f "$FILESYSTEM" ]
then
# Android places loop devices in /dev/block/ instead of root /dev/
# If there are none in /dev/ we create links between /dev/loopX and /dev/block/loopX so that losetup will work as it should.
if $busybox [ ! -e /dev/block/loop0 ]; then
i=0
while [ $i -le 8 ]
do
$busybox mknod /dev/block/loop$i b 7 $i
let i=1+$i
done
fi
# Locate the current loop device file
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# If the filesystem file is already attached to an loop device, we get the path to the device file.
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
# If the filesystem file is not yet attached, we attach it.
loblk=$($busybox losetup -f)
$busybox losetup $loblk $FILESYSTEM 2> /dev/null
# Make sure that the device was successfully attached to a loop device file
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "F: It was not possible to attach the device to a loop device file"
return 0
fi
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Mount the filesystem
$busybox mount -t $FS $loblk $MOUNTPOINT 2> /dev/null
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# Bind some Android dirs to the linux filesystem
if $busybox [ $BINDS -eq 1 ]
then
# Create mtab
echo > "${MOUNTPOINT}/etc/mtab"
$busybox cat /proc/mounts > "${MOUNTPOINT}/etc/mtab"
# for i in `$busybox cat /proc/mounts | $busybox cut -d " " -f 2`
for i in $( $busybox cat /proc/mounts | $busybox awk '{print $2}' )
do
# /sdcard/Mon mount/Linux
$busybox mkdir -p "${MOUNTPOINT}/$i" 2> /dev/null
$busybox mount -o bind "${i}" "${MOUNTPOINT}/${i}" 2> /dev/null
#echo "${i}" >> "${MOUNTPOINT}/etc/mtab"
done
fi
#for i in $BINDS
#do
# # Bind the dirs if they are not already binded
# if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
# # Create any missing dirs in the mountpoint
# if $busybox [ ! -d $MOUNTPOINT/$i ]; then
# $busybox mkdir -p $MOUNTPOINT/$i
# fi
# $busybox mount -o bind $i $MOUNTPOINT$i
# fi
#done
else
echo "F: It was not possible to mount $DIST at the specified location ($MOUNTPOINT)"
return 0
fi
fi
fi
# FIX the "stdin: is not a tty" error in direct hadware case.
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox mount -t devpts devpts $MOUNTPOINT/dev/pts
fi
# For the network.
#sysctl -w net.ipv4.ip_forward=1
echo 1 > /proc/sys/net/ipv4/ip_forward
# Cleanup tmp folder.
$busybox rm -rf $MOUNTPOINT/tmp/*
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_mount.sh ]; then
# Execute the mount init file, if it exists
echo "I: Executing /etc/init.android/rc_mount.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_mount.sh
fi
echo "I: Entering chroot..."
return 1
}
removeLinuxBoot() {
if $busybox [ -d "$FILESYSTEM" ]
then
echo "I: Directory chroot !"
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts 2> /dev/null
fi
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
else
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
# If linux is not mounted, then do nothing.
echo "W: $DIST is already unmounted"
else
echo "I: Unmounting $DIST..."
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_unmount.sh ]; then
echo "I: Executing /etc/init.android/rc_unmount.sh"
# Execute the unmount init script, if it exist.
$busybox chroot $MOUNTPOINT /etc/init.android/rc_unmount.sh
fi
sync
# Make sure that we have an loop device file to use
if $busybox [ -f "$FILESYSTEM" ]
then
if $busybox [ ! -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
# Get the loop device file
loblk=$($busybox losetup | $busybox grep "$FILESYSTEM" | $busybox cut -d ":" -f 1)
else
echo "E: Could not locate the loop device file. $DIST was not unmounted successfully"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
loblk=$FILESYSTEM
fi
# Unmount pts
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/dev/pts ")" ]; then
$busybox umount $MOUNTPOINT/dev/pts
fi
for i in `$busybox cat /proc/mounts | $busybox tac | $busybox grep -v "$MOUNTPOINT " | $busybox grep "$MOUNTPOINT" | $busybox cut -d " " -f 2`;do umount $i 2> /dev/null;done
for i in $BINDS
do
# Unmount all binding dirs
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT/$i ")" ]; then
$busybox umount $MOUNTPOINT/$i
fi
done
sync && sleep 1
# Unmount the device
$busybox umount $MOUNTPOINT 2> /dev/null && sleep 1
# If the device could not be unmounted
if $busybox [ ! -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "E: $DIST could not be unmounted. Trying to kill attached processes..."
# Try to kill all processes holding the device
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill $i 2> /dev/null; echo; done
fuser -k -9 $MOUNTPOINT
for i in `$busybox grep "$MOUNTPOINT" /proc/*/maps 2> /dev/null | $busybox cut -d":" -f 1 | $busybox sort | $busybox uniq | $busybox cut -d "/" -f 3`; do kill -9 $i 2> /dev/null; echo; done
# Use umount with the -l option to take care of the rest
$busybox umount -l $MOUNTPOINT 2> /dev/null && sleep 1
fi
# Make sure the device has been successfully unmounted
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
if $busybox [ -f "$FILESYSTEM" ]
then
# Try to detach the device from the loop device file
$busybox losetup -d $loblk 2> /dev/null
# Make sure that the device was successfully detached
if $busybox [ -z "$($busybox losetup | $busybox grep "$FILESYSTEM")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
if $busybox [ -b "$FILESYSTEM" ]
then
if $busybox [ -z "$($busybox mount | $busybox grep "$MOUNTPOINT ")" ]; then
echo "I: $DIST has been successfully unmounted"
else
echo "E: $DIST has been unmounted, but could not detach the loop device"
fi
fi
else
echo "E: $DIST could not be unmounted successfully"
fi
fi
fi
}
if $busybox [ "$1" = "unmount" ]; then
removeLinuxBoot
else
createLinuxBoot
if $busybox [ $? -eq 1 ]; then
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_enter.sh ]; then
echo "I: Executing /etc/init.android/rc_enter.sh"
$busybox chroot $MOUNTPOINT /etc/init.android/rc_enter.sh
else
echo "I: To run command when enterring Linux create executable file at /etc/init.android/rc_enter.sh"
fi
$busybox chroot $MOUNTPOINT /bin/bash -i
if $busybox [ -f $MOUNTPOINT/etc/init.android/rc_leave.sh ]; then
echo "I: Executing /etc/init.android/rc_leave.sh ..."
$busybox chroot $MOUNTPOINT /etc/init.android/rc_leave.sh
else
echo "I: To run command when leaving Linux create executable file at /etc/init.android/rc_leave.sh"
fi
echo "Q: Do you want to unmount the $DIST environment, or leave it as is ? Y will kill all process as required; any other key will leave services running."
read REPLY
if $busybox [ "y$REPLY" = "yy" ] || $busybox [ "y$REPLY" = "yY" ]; then
removeLinuxBoot
fi
fi
fi
)
or you can mount it with this linuxboot.sh:
Code:
# Check Permissions
if [ $(whoami) != root ]; then
echo "This script must be run as root."
exit
fi
# Script Variables
NAME=ubuntu
PATH=$(dirname $0)
# Enviroment Variables
export BIN=/system/bin
export HOME=/root
export MOUNT=/data/local/mnt/$NAME
export PATH=$BIN:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export TERM=linux
export USER=root
# Change Directory
cd $PATH
# Create Mount Point
mkdir -p $MOUNT
# Remount System Read/Write
mount -o remount,rw /system
# Check Loop Block Device
if [ ! -b /dev/block/loop_$NAME ]; then
# Create Loop Block Device
mknod /dev/block/loop_$NAME b 7 255
fi
# Setup Loop Block Device
losetup /dev/block/loop_$NAME $NAME.img
# Mount Loop Block Device To Mount Point
mount -t ext3 /dev/block/loop_$NAME $MOUNT
# Add Mount Points
mount -o bind /dev $MOUNT/dev
mount -o bind /dev/pts $MOUNT/dev/pts
mount -o bind /dev/shm $MOUNT/dev/shm
mount -o bind /sdcard $MOUNT/media
mount -t proc none $MOUNT/proc
mount -t sysfs none $MOUNT/sys
# Set Options
echo "127.0.0.1 localhost" > $MOUNT/etc/hosts
echo "nameserver 8.8.4.4" > $MOUNT/etc/resolv.conf
echo "nameserver 8.8.8.8" >> $MOUNT/etc/resolv.conf
rm -rf $MOUNT/lost+found
sysctl -w net.ipv4.ip_forward=1 > /dev/null
sysctl -w net.ipv6.conf.all.forwarding=1 > /dev/null
# Enter Linux
chroot $MOUNT /bin/bash -c "source /etc/profile; bash"
# Remove Mount Points
umount $MOUNT/sys
umount $MOUNT/proc
umount $MOUNT/media
umount $MOUNT/dev/shm
umount $MOUNT/dev/pts
umount $MOUNT/dev
# Clean Up
umount $MOUNT
losetup -d /dev/block/loop_$NAME
rm /dev/block/loop_$NAME
rmdir $MOUNT
this is not the init.sh.
the init.sh is iniside the ubuntu.img so to boot using the init.sh you can edit the rc_enter.sh to start init.sh like so:
./init.sh
you can also start a service like so:
service hostname start

[MOD][SCRIPT] Button Backlight Script

Hi,
I made a little script, to run with Script Manager or in init.d.
Code:
#!/system/bin/sh
#Script written by jader13254
dev=/sys/devices/i2c-0/0-0040/leds
logFile=/data/backlight.log
log2=data/backlight2.log
if [ -f $logFile ]; then
rm $logFile
fi
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Script launched" >> $logFile
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Applying new values" >> $logFile
echo 1 > $dev/button-backlight/max_current
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Applied new values" >> $logFile
if [ -f $log2 ]; then
sh /system/etc/hw_config.sh
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Log2 exists! Means values were applied to hw_config.sh" >> $logFile
realvalue=`cat /sys/devices/i2c-0/0-0040/leds/button-backlight/max_current`
if [ "$realvalue" ] && [ "$realvalue" = "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): All done & Sucess!" >> $logFile
exit 0; fi;
if [ "$realvalue" ] && [ "$realvalue" != "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Error occured" >> $logFile
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Trying to fix Error" >> $logFile
echo "\n" >> /system/etc/hw_config.sh
echo "echo 1 > /sys/devices/i2c-0/0-0040/leds/button-backlight/max_current" >> /system/etc/hw_config.sh
sh /system/etc/hw_config.sh
if [ "$realvalue" ] && [ "$realvalue" = "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Values were just removed! All fine & Done." >> $logFile
exit 0; fi;
if [ "$realvalue" ] && [ "$realvalue" != "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Can't fix! Aborting" >> $logFile
exit 0; fi; fi; fi;
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Applying to hw_config.sh since it hasn't been done before" >> $logFile
echo "\n" >> /system/etc/hw_config.sh
echo "echo 1 > /sys/devices/i2c-0/0-0040/leds/button-backlight/max_current" >> /system/etc/hw_config.sh
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Applied to hw_config.sh" >> $logFile
echo " $( date +"%m-%d-%Y %H:%M:%S" ): hw_config patched" >> $log2
sh /system/etc/hw_config.sh
if [ "$realvalue" ] && [ "$realvalue" = "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): All done & Sucess!" >> $logFile
exit 0; fi;
if [ "$realvalue" ] && [ "$realvalue" != "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Error occured" >> $logFile
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Trying to fix Error" >> $logFile
echo "\n" >> /system/etc/hw_config.sh
echo "echo 1 > /sys/devices/i2c-0/0-0040/leds/button-backlight/max_current" >> /system/etc/hw_config.sh
sh /system/etc/hw_config.sh
if [ "$realvalue" ] && [ "$realvalue" = "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Values just weren't applied correctly! All fine & Done." >> $logFile
exit 0; fi;
if [ "$realvalue" ] && [ "$realvalue" != "1" ]; then
echo " $( date +"%m-%d-%Y %H:%M:%S" ): Can't fix! Aborting" >> $logFile
exit 0; fi; fi;
Make a new file in /system/etc/init.d, name it "03bl" and paste in the code. OR DOWNLOAD HERE and put to /system/etc/init.d.
Now reboot & see if Button Backlights are turned off. If not, download smanager and run the script on boot as root :victory:
what does this? it disables button backlight automagically, edites hw_config.sh to apply on boot again, after you runned once you can delete it
cheers,
jader
Download: http://d-h.st/6Md
jader13254 said:
reserved for silly jader in case he forgot something
Click to expand...
Click to collapse
To be honest i find it easier to do by hand
For this u gotta make file then rename it and then reboot
By hand jst change a few numbers (thnx to ur guide i learned hw to, thnx )
Sent from my LT18i
Sahaab said:
To be honest i find it easier to do by hand
For this u gotta make file then rename it and then reboot
By hand jst change a few numbers (thnx to ur guide i learned hw to, thnx )
Sent from my LT18i
Click to expand...
Click to collapse
haha lol yes maybe
i made this mainly for my ROM by your request
jader13254 said:
haha lol yes maybe
i made this mainly for my ROM by your request
Click to expand...
Click to collapse
Oh
I wntd 1 like CM that moved Dalvik Cache to the Cache partition
But i dnt thnk its gud for ur rom as sumbody told me that in lupus kernel , cache partition is only 8 mb
By the way, i made the script and its working really gd
Sent from my LT18i
Updated Script, now works 100% fine, EVEN after changing hw_config etc
jader13254 said:
Updated Script, now works 100% fine, EVEN after changing hw_config etc
Click to expand...
Click to collapse
Hi
From my use, i don't manage to disable the button backlight even with your script or with another from this forum.
The only way was to add the both, your's init.d script, then my hw_config.sh modded.
Look at :
Code:
# Audio jack configuration
dev=/sys/devices/platform/simple_remote.0
echo 0,201,1600 > $dev/accessory_min_vals # default = 0,200,1600
echo 200,1599 > $dev/accessory_max_vals # default = 200,1600
echo 0,100,280,500,700 > $dev/button_min_vals # default = 0,100,300,600,700
echo 99,199,399,699,5000 > $dev/button_max_vals # default = 99,199,399,699,5000
echo 512 > $dev/btn_trig_period_freq # Button Period Freq(Hz) default = 512
echo 16 > $dev/btn_trig_period_time # Button Period Time(cycle) default = 16
echo 512 > $dev/btn_trig_hyst_freq # Button Hysteresis Freq(Hz) default = 512
echo 16 > $dev/btn_trig_hyst_time # Button Hysteresis Time(Cycle) default = 16
echo 500 > $dev/btn_trig_level # default = 500
# Proximity sensor configuration
dev=/sys/bus/i2c/devices/0-0054/
hwid=`cat /sys/class/hwid/hwid`
case $hwid in
0x0a)
val_cycle=2
val_nburst=7
val_freq=3
val_threshold=15
val_filter=0
;;
*)
val_cycle=2
val_nburst=8
val_freq=2
val_threshold=15
val_filter=0
;;
esac
nv_param_loader 60240 prox_cal
val_calibrated=$?
case $val_calibrated in
1)
nv_param_loader 60240 threshold
val_threshold=$?
nv_param_loader 60240 rfilter
val_filter=$?
;;
esac
echo $val_cycle > $dev/cycle # Duration Cycle. Valid range is 0 - 3.
echo $val_nburst > $dev/nburst # Number of pulses in burst. Valid range is 0 - 15.
echo $val_freq > $dev/freq # Burst frequency. Valid range is 0 - 3.
echo $val_threshold > $dev/threshold # sensor threshold. Valid range is 0 - 15 (0.12V - 0.87V)
echo $val_filter > $dev/filter # RFilter. Valid range is 0 - 3.
# LMU AS3676 Configuration
dev=/sys/devices/i2c-0/0-0040/leds
echo 1 > $dev/button-backlight/max_current
# LMU AS3676 Configuration before chargemon
dev=/sys/devices/i2c-0/0-0040/leds
echo 0 > $dev/lcd-backlight/als/enable #Sensor on/off. 1 = on, reg 90h
echo 20000 > $dev/lcd-backlight/max_current
echo 10000 > $dev/red/max_current
echo 10000 > $dev/green/max_current
echo 10000 > $dev/blue/max_current
# TI BQ275xx firmware loader
bq275xx_fwloader
So finally i got this work and my battery life seems better :victory:
@jader13254
I have tested your (updated) script now on 4 roms, all stock-based, and I love it, kudos to you!
P.S.: Haters gonna hate, or in this case, RATE 1 star for your work
Master of Bisaster said:
@jader13254
I have tested your (updated) script now on 4 roms, all stock-based, and I love it, kudos to you!
P.S.: Haters gonna hate, or in this case, RATE 1 star for your work
Click to expand...
Click to collapse
Yeah, or they just have no idea what this does.
I also think @Pandemic is rating all my threads 1 star.
jader13254 said:
Yeah, or they just have no idea what this does.
I also think @Pandemic is rating all my threads 1 star.
Click to expand...
Click to collapse
No man that is not true @jader13254
Please dont act as a kid man, dont blaim me please !!
:::[ Pandemic ..:: JB MoonBreakers® 4 Ever !!:..
Sent From The Moon With My Xperia P !
Pandemic said:
No man that is not true @jader13254
Please dont act as a kid man, dont blaim me please !!
:::[ Pandemic ..:: JB MoonBreakers® 4 Ever !!:..
Sent From The Moon With My Xperia P !
Click to expand...
Click to collapse
AHAHAHAHAHAH @Pandemic
I lolled so hard
Sent from my C6903 using XDA Free mobile app
jader13254 said:
AHAHAHAHAHAH @Pandemic
I lolled so hard
Sent from my C6903 using XDA Free mobile app
Click to expand...
Click to collapse
Lol bro @jader13254
look how old this message is
29th July 2013, 10:49 AM
then you lolled very LATE and i laugh out loud now ^^
i am using your xperia ultimate hd rom but i want to disable the backlight button. in xperia ray and your download link is not working unable to download the script and there is no folder of buttonlight in leds folder .
please help
unable to download the script
please tell me how to disable button light on xperia ray?

[Q] How to reenable an App symlinked to SD "not installed" after reboot

Hi all,
I have a ZP980 rooted running android 4.2.1 that has 1.5GB for app storage and another partition of 26GB in the internal memory mounted as /sdcard used for data.
I wanted to use the big partition to store apps too and since none of the app I tried worked to move some apps to the fake SD I tried to do a script on my own.
PROBLEM:
The script works good but the problem is that if I reboot the phone all files and symlinks are still there but the app is "not installed" so I can't lunch it, I think android makes a scan on boot and maybe /sdcard is not available at that time.
TEMPORARY SOLUTION:
The only way to make it work again is to move the apk back to /data/app and reboot, or remove the symlink and use:
# pm install -r PACKAGE
WHAT I TRIED:
#pm enable PACKAGE
but it looks like it's not disabled that way
WHAT I'D LIKE TO HAVE:
I'd like to find a way to reenable the PACKAGE without having to reinstall it, any clue where android memorize that the app is "installed" or a command to do only that tiny bit and not the whole install process?
SCRIPT (for who interested)
Code:
#!/system/bin/sh
sdcard="/storage/sdcard0/Apps"
internal="/data"
data="/data/data"
package="$2"
usage()
{
echo "Usage: $0 [OPTION] [PACKAGE]"
echo
echo "This script copy app and dalvik cache from internal memory to sd and back creating a symlink."
echo
echo "OPTIONS:"
echo " -a Move app and dalvik cache to sd"
echo " -b Move app and dalvik cache back to internal memory"
echo " -r Restore apps after reboot"
echo
echo "PACKAGE"
echo " without .apk"
echo " ES. to move candycrush to sd:"
echo " mv2sd -a com.king.candycrushsaga"
}
function setperm
{
local file=$1
case $type in
"app")
group="system"
;;
"dalvik-cache")
local group=$(ls -ld $data/$package | awk '{print $4}')
;;
esac
chown system:$group $file
chmod 644 $file
}
function mvfile
{
local fileFrom=$1
local fileTo=$2
if [ "$back" -eq 1 ]; then
rm -f $fileTo
local destination="data"
else
local destination="sd"
fi
cp -a $fileFrom $fileTo
if [ $? -ne 0 ]; then
exit $?
else
echo "$package $type moved to $destination"
rm -f $fileFrom
if [ $back -eq 0 ]; then
ln -s $fileTo $fileFrom
else
setperm $fileTo
fi
fi
}
function mvfiles
{
type=$1
case $type in
"app")
local uri="$type/$filename"
;;
"dalvik-cache")
local uri="$type/[email protected]@[email protected]"
;;
esac
intFile="$internal/$uri"
sdFile="$sdcard/$uri"
if [ "$back" -eq 0 ] && [ -f "$intFile" ]; then
mvfile $intFile $sdFile
elif [ "$back" -eq 1 ] && [ -L "$intFile" ] && [ -f "$sdFile" ]; then
mvfile $sdFile $intFile
else
echo "$type file or symlink not found"
fi
}
#initialize
back=2
restore=0
while getopts "abrh" option
do
case $option in
a)
back=0;
;;
b)
back=1;
;;
r)
restore=1;
;;
h)
usage
exit
;;
esac
done
if [ "$back" -eq "2" ] && [ "$restore" -eq "0" ]; then
usage
exit 1
fi
#restore
if [ "$restore" -eq "1" ]; then
for file in $sdcard/app/*.apk
do
filename=$(basename "$file")
intFile="$internal/app/$filename"
sdFile="$sdcard/app/$filename"
intDalvik="$internal/dalvik-cache/[email protected]@[email protected]"
sdDalvik="$sdcard/dalvik-cache/[email protected]@[email protected]"
package="${filename%-*}"
if [ -L "$intFile" ] && [ -f "$sdFile" ] && [ -L "$intDalvik" ] && [ -f "$sdDalvik" ]; then
rm -f $intFile
rm -f $intDalvik
rm -f $sdDalvik
pm install -r $sdFile
rm -f $sdFile
mv2sd -a $package
fi
done
else
file=$(ls $internal/app/$package-*)
filename=$(basename "$file")
#move app
mvfiles "app"
mvfiles "dalvik-cache"
fi
shift $(($OPTIND -1))
I found something, thanks to this nice article:
http://www.kpbird.com/2012/10/in-depth-android-package-manager-and.html
So I tried to reboot and I see that in /data/system/packages.xml all apps I symlinked have flags="0"
Before:
<package name="com.king.candycrushsaga" codePath="/data/app/com.king.candycrushsaga-1.apk" nativeLibraryPath="/data/app-lib/com.king.candycrushsaga-1" flags="572996" ft="1435aa87ca0" it="140f50e81fe" ut="14303810da6" version="102212" userId="10084">
Click to expand...
Click to collapse
After:
<package name="com.king.candycrushsaga" codePath="/data/app/com.king.candycrushsaga-1.apk" nativeLibraryPath="/data/app-lib/com.king.candycrushsaga-1" flags="0" ft="1435aa87ca0" it="140f50e81fe" ut="14303810da6" version="102212" userId="10084">
Click to expand...
Click to collapse
Changing that value on runtime doesn't work.
I'm still looking how to change it maybe PackageManagerService.grantPermissionsLP()
https://android.googlesource.com/pl.../android/server/pm/PackageManagerService.java
At the end I solved the problem.
I'm not sure why but if an app is symlinked to anything on sdcard is disabled at start, but if it's symlinked on another folder on /data or /system it keeps working after reboot.
So first I tried to symlink /data/sdcard => /sdcard but it's not working because it can still see the final destination is the sdcard, so I mounted the sdcard on /data/sdcard and symlink /data/app/some.app-1.apk => /data/sdcard/app/some.app-1.apk and it's working
sdcard need to be mounted on start inside an init.d script so it's available when the scan happens.
Moving forward I decided to create an ext2 filesystem in a file, keep it in my sdcard partition and mount it on /data/sdcard.
This way, with a modified and improved version of my script I can move apks, libs, dalvik-cache and all the data folder for each app I want keeping the right file permissions

A script to get a random file

Dear developers,
I have an issue in my script switching from Android 9 to 10 (devices from a Umidigi s3 Pro to a Umidigi F2)
I have installed Bosybox App on the first and Busybox Magisk module on the latter
Now the script does not work because the command
list=(`busybox find "$dirs" -type f -name *.$ext`)
returns an empty array
This is the complete script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <[email protected]> v1.4 01.01.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
# here we have the ISSUE
list=(`busybox find "$dirs" -type f -name *.$ext`)
# count number of files
num=${#list[@]}
# initialize random generator
RANDOM=$$
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[ran]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext$delim2
Can you please help me why this happens, and how to fix it?
Thank you very much for your attention!
Uranya said:
[...]
Click to expand...
Click to collapse
Having done some tests I have found this:
opening a root privileged terminal and executing
---
echo `find /storage/7BC3-1805/Music/MP3/Abba -type f -name *.mp3`
---
it returns two strings containing the names of files inside that folder, but putting it in my script continues to return an empty array, so the issue is not in the access to the folder, but in the syntax, I guess
try putting that *.$ext into quotes...
Dear friends, CXZa, after a couple of hours debugging the script, finally, I have found the mistake!
The line to be used is:
list=( `find "$dirs" -type f -name "*.$ext"` )
it is a very subtle difference: the space after and before the parenthesis!
(even the word busybox is useless)
Oddly in the Busybox app (I have had on my S3 Pro) the spaces are not mandatory, whilst in the Busybox Magisk module those spaces ARE mandatory!
I'm using that script for almost 8 years to have an every day different music for my wake up.
I'm using Tasker to call it just before my alarm get off, so the same file contains every day, a different song.
I have done a change also in the array index that did not began by 0...
So, here it is the right script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <@uranya7x> v1.5 26.03.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
list=( `find "$dirs" -type f -name "*.$ext"` )
# count number of files
num=${#list[@]}
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[$ran-1]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext
I hope it will be useful to someone else that loves to be waked up by music...
Peace everywhere!

Categories

Resources