Related
Ok, I didn't like to open a new thread about OBEX and android, but, as I explain in this post http://forum.xda-developers.com/showpost.php?p=3932525&postcount=57 , I got OBEX working in my G1, and now I'm thinking about integrating a clean and elegant OBEX support into our ROMS.
Yes, there is already an application in the market for receiving and sending files via OBEX, but I simply don't like to pay for a feature that should be supported by default in every mobile phone.
I was wondering how would be the first approach for integrating the obexserver by default, and it would be really easy executing at boot time something like:
Code:
sdptool add --channel=4 OPUSH
test -d /sdcard/bluetooth_received || mkdir /sdcard/bluetooth_received
cd /sdcard/bluetooth_received && ( while true; do obexserver; done ) &
The only problem, is that disabling bluetooth and enabling it again, it loses the OPUSH service added by sdptool.
So, I'm now trying to find a way to tell the bluetooth daemons that they should add the OPUSH service when they are enabled, and here is where I need your help. Anybody knows how can this be done?
Also, another way would be simply executing a GScript when the OPUSH service is needed.
What do you think?
Thanks!
EDIT: Here is a simple script that enables the OBEX profile and receives 1 file. It is necessary to re-execute it to receive more files.
obex_get.sh:
Code:
#!/system/bin/sh
obex_status=`sdptool browse local 2>&1| egrep "^Service Name: OBEX Object Push|^Failed to connect"`
case "$obex_status" in
Failed*)
# bt disabled
echo "Please, enable bluetooth first!"
exit
;;
"")
# bt enabled, but no OPUSH profile
sdptool add --channel=4 OPUSH
;;
*)
# bt enabled, opush enabled
;;
esac
test -d /sdcard/bluetooth_downloads || mkdir /sdcard/bluetooth_downloads
cd /sdcard/bluetooth_downloads && obexserver
EDIT: Daemonized version of the script. It can be run as service at boot time, and every 3 seconds it will check if the opush profile has been lost.
Code:
#!/system/bin/sh
# create the download directory if it doesn't exist
test -d /sdcard/bluetooth_downloads || mkdir /sdcard/bluetooth_downloads
while sleep 3; do
# get bluetooth status
hcid_status_now="`getprop init.svc.hcid`"
# do nothing if bluetooth is stopped
test "$hcid_status_now" == "stopped" && continue
# if bluetooth is enabled, get opush profile status
obex_status=`sdptool browse local 2>&1| egrep "^Service Name: OBEX Object Push|^Failed to connect"`
case "$obex_status" in
"")
# bt enabled, but no OPUSH profile
sdptool add --channel=4 OPUSH; echo
;;
Failed*)
# bt disabled
#echo "Please, enable bluetooth first!"; echo
continue
;;
*)
# bt enabled, opush enabled
;;
esac
# if obexserver isn't already running, execute it.
pidof obexserver >/dev/null || ( cd /sdcard/bluetooth_downloads && obexserver ) &
done
EDIT: Ok, a definitely better version of the daemon:
Code:
#!/system/bin/sh
# create the download directory if it doesn't exist
test -d /sdcard/bluetooth_downloads || mkdir /sdcard/bluetooth_downloads
# in case /sdcard/bluetooth_downloads already exists, and is not a directory. Exit
test -d /sdcard/bluetooth_downloads || exit
# execute the obexserver loop (for it to be multifile)
( cd /sdcard/bluetooth_downloads && while true; do obexserver; done ) &
# execute the sdptool add OPUSH loop
while sleep 3; do
# get bluetooth status
hcid_status_now="`getprop init.svc.hcid`"
# do nothing if bluetooth is stopped
test "$hcid_status_now" == "stopped" && continue
# if bluetooth is enabled and no obex profile exists, add it
sdptool browse local 2>&1| egrep "^Service Name: OBEX Object Push" >/dev/null || sdptool add --channel=4 OPUSH
done
Still don't like to query the "sdptool browse local" every 3 seconds
Bugs and corrections are welcome.
juanmasg said:
Ok, I didn't like to open a new thread about OBEX and android, but, as I explain in this post http://forum.xda-developers.com/showpost.php?p=3932525&postcount=57 , I got OBEX working in my G1, and now I'm thinking about integrating a clean and elegant OBEX support into our ROMS.
Yes, there is already an application in the market for receiving and sending files via OBEX, but I simply don't like to pay for a feature that should be supported by default in every mobile phone.
I was wondering how would be the first approach for integrating the obexserver by default, and it would be really easy executing at boot time something like:
Code:
sdptool add --channel=4 OPUSH
test -d /sdcard/bluetooth_received || mkdir /sdcard/bluetooth_received
cd /sdcard/bluetooth_received && ( while true; do obexserver; done ) &
The only problem, is that disabling bluetooth and enabling it again, it loses the OPUSH service added by sdptool.
So, I'm now trying to find a way to say the bluetooth daemons that they should add the OPUSH service when they are enabled, and here is where I need your help. Anybody knows how can this be done?
Also, another way would be simply executing a GScript when the OPUSH service is needed.
What do you think?
Thanks!
Click to expand...
Click to collapse
I am not really sure how the bluetooth stack works, but does the OPUSH profile has its own process or it there someway to detect its presence?
If so we could easily implement some detecting mechanism in the loop body.
Another possibility is to check the error returned by obexserver if it implements any.
im gonna check out the source tree for you, cause i was just looking last night. i will post again as a read into the source a lot more
billc.cn said:
I am not really sure how the bluetooth stack works, but does the OPUSH profile has its own process or it there someway to detect its presence?
If so we could easily implement some detecting mechanism in the loop body.
Another possibility is to check the error returned by obexserver if it implements any.
Click to expand...
Click to collapse
The obex profile does not have it's own process, sdptool simply enables it in one of the bluez daemons (don't know which of them)
The "problem" here is that obexserver does not get any error when I disable bluetooth, it simply continues waiting for a connection. I'll try to look at the openobex API to see if we can get the bluetooth status or force some error. Sorry, my knowledgement about the bluetooth protocol is quite limited.
The curious thing about this, is that if I execute obexserver, disable bt, re-enable bt, and add the opush profile, without restarting the obexserver it still works.
juanmasg said:
The obex profile does not have it's own process, sdptool simply enables it in one of the bluez daemons (don't know which of them)
The "problem" here is that obexserver does not get any error when I disable bluetooth, it simply continues waiting for a connection. I'll try to look at the openobex API to see if we can get the bluetooth status or force some error. Sorry, my knowledgement about the bluetooth protocol is quite limited.
The curious thing about this, is that if I execute obexserver, disable bt, re-enable bt, and add the opush profile, without restarting the obexserver it still works.
Click to expand...
Click to collapse
so maybe this is running on a seperate process? no its entirely own, but maybe a child process? seems kinda weird to me... and its gonna be a while before i can start checking this out along with you, i need to re-download the android repo >.<
As long as you have that script that has to be run every time you want 1 file, would it be possible to do that every, say, 3 seconds in a loop? Maybe even have an obex app where you can press a button to have the script start running the loop and press again to kill the process. I'm thinking something similar to the wifi tether for root users in terms of interface.
EDIT: so something similar to this in terms of scriptage(can't remember the exact syntax for loops)
Code:
while 1
do
#!/system/bin/sh
obex_status=`sdptool browse local 2>&1| egrep "^Service Name: OBEX Object Push|^Failed to connect"`
case "$obex_status" in
Failed*)
# bt disabled
echo "Please, enable bluetooth first!"
exit
;;
"")
# bt enabled, but no OPUSH profile
sdptool add --channel=4 OPUSH
;;
*)
# bt enabled, opush enabled
;;
esac
test -d /sdcard/bluetooth_downloads || mkdir /sdcard/bluetooth_downloads
cd /sdcard/bluetooth_downloads && obexserver
sleep 3;
done;
corp769 said:
so maybe this is running on a seperate process? no its entirely own, but maybe a child process? seems kinda weird to me...
Click to expand...
Click to collapse
I think that we shouldn't monitor the obex profile status, but spawn the profile activation when bluetooth gets active. This will be more efficient.
We can monitor the bluetooth status with "getprop init.svc.hcid". This could be used in the script loop, but it would save a lot of work if we simply could (de)activate it when the bluetooth gets enabled or disabled.
I'm looking at /etc/bluez in the G1 and in my linux desktop to see if some file could do the magic.
i need to re-download the android repo
Click to expand...
Click to collapse
be patient my friend
Can't you just do this from init with the other daemons?
service hfag /system/bin/sdptool add --channel=10 HFAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service hsag /system/bin/sdptool add --channel=11 HSAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
...etc
haha, i have no patience man, i'm in the military, and patience is not a virtue to me, i just want to get sh*t done
as far as what you are talking about, i understand what you mean. i'm also looking at the obex source in my linux distro (fedora 10) and kinda pondering if we could write a completely new routine (as a script for now of course) that would only be called when we need it, as in running it at boot and run in the background constantly. that hopefully wouldn't run up the processor tho...
and by the way, i would really like to help in everyway because i always wanted bluetooth file transfer on my G1
cyanogen said:
Can't you just do this from init with the other daemons?
service hfag /system/bin/sdptool add --channel=10 HFAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service hsag /system/bin/sdptool add --channel=11 HSAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
...etc
Click to expand...
Click to collapse
Already tried that, but didn't work . Those "services" seem to be requested by the a2dp daemon when it starts, and the a2dp daemon starts and stops when bluetooth is enabled or disabled, so we still would need to get our daemon spawned with all the bluetooth stuff.
Thanks anyways.
BluetoothDeviceService.java does the work, would be trivial to patch this in..
Code:
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_REGISTER_SDP_RECORDS:
//TODO: Don't assume HSP/HFP is running, don't use sdptool,
if (isEnabled()) {
SystemService.start("hsag");
SystemService.start("hfag");
}
break;
case MESSAGE_FINISH_DISABLE:
finishDisable(msg.arg1 != 0);
break;
}
}
};
cyanogen said:
BluetoothDeviceService.java does the work, would be trivial to patch this in..
Code:
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_REGISTER_SDP_RECORDS:
//TODO: Don't assume HSP/HFP is running, don't use sdptool,
if (isEnabled()) {
SystemService.start("hsag");
SystemService.start("hfag");
}
break;
case MESSAGE_FINISH_DISABLE:
finishDisable(msg.arg1 != 0);
break;
}
}
};
Click to expand...
Click to collapse
Thanks cyanogen, that is what I was looking for.
I wanted to avoid to recompile the android core server, but It seems that we'll have to :-/.
cyanogen said:
BluetoothDeviceService.java does the work, would be trivial to patch this in..
Code:
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_REGISTER_SDP_RECORDS:
//TODO: Don't assume HSP/HFP is running, don't use sdptool,
if (isEnabled()) {
SystemService.start("hsag");
SystemService.start("hfag");
}
break;
case MESSAGE_FINISH_DISABLE:
finishDisable(msg.arg1 != 0);
break;
}
}
};
Click to expand...
Click to collapse
Exactly. Let's add the opush service here...
I'd love to patch it into my next ROM release
I added to the first post a modified version of the script that can be run as a "daemon".
Anyway, the way to implement this seems to be patching BluetoothDeviceService.java.
cyanogen said:
I'd love to patch it into my next ROM release
Click to expand...
Click to collapse
Can't wait for it
As for sending files, I was thinking about creating a mime handler that could be used with, p.e Filer (http://android.hlidskialf.com/software/filer) so that it could be able to send files via OBEX also.
Any idea?
cyanogen said:
BluetoothDeviceService.java does the work, would be trivial to patch this in..
Code:
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_REGISTER_SDP_RECORDS:
//TODO: Don't assume HSP/HFP is running, don't use sdptool,
if (isEnabled()) {
SystemService.start("hsag");
SystemService.start("hfag");
}
break;
case MESSAGE_FINISH_DISABLE:
finishDisable(msg.arg1 != 0);
break;
}
}
};
Click to expand...
Click to collapse
The more I think about it, the more I feel, that it should be done in ObexServer initialisation (ObexServer.java) ... which should be started from BluetoothDeviceService
here is my question... ok, we have the obex server for receiving files. now as far as sending files, how will that be set up? like will it be a seperate script to run the program, or will it be combined with the obex server?
an idea or two... juan, you mentioned about setting up a mime handler to send files. what it be possible to set up the handler for both receiving and sending files? it could most definitely be accomplished by creating a whole separate APK, and have that register the handles for the system, running as a service in the background. also we could use that for a graphical interface in the long run after we get the basics down pat, and have a file browser for sending files. i know this is jumping the gun, but it is all my ideas i have going on. on that note though, i think it would be the best way, unless you have a better idea
EDIT: now that i think of it, the APK would be best off other wise so we wouldnt have to have everyone who wants file transfer to reflash their whole phone just for a partially modified kernel
corp769 said:
EDIT: now that i think of it, the APK would be best off other wise so we wouldnt have to have everyone who wants file transfer to reflash their whole phone just for a partially modified kernel
Click to expand...
Click to collapse
I'd rather make part of the framework ready to be accepted by the AOSP than some kind of hack running only on rooted devices. Which brings another question: I was just starting to port the obexserver, when I realized that the OpenOBEX library is licensed under LGPL ... can we use it?
Hello Everyone,
First, I did search. That is how I figured out how to disable compcache and enable the swap. It's working great, however since I am no longer using compcache, I would like to make available the RAM that it is using. Here are my free commands:
BEFORE:
# free
free
total used free shared buffers
Mem: 97928 96356 1572 0 8164
Swap: 24476 15516 8960
Total: 122404 111872 10532
AFTER:
# free
free
total used free shared buffers
Mem: 97928 96416 1512 0 300
Swap: 31768 3092 28676
Total: 129696 99508 30188
Notice that the Physical Memory is still the same number, despite compcache being disabled (well, atleast swapoff'd) Here is my userinit and you can see that it's just enabling the swap.
#!/system/bin/sh
##adb push userinit.sh /system/sd/
uname_r=`uname -r`
moddir=`find /system/modules -type d -name $uname_r`
#insmod=/system/bin/insmod
#$insmod $moddir/compcache/xvmalloc.ko;
#$insmod $moddir/compcache/ramzswap.ko disksize_kb=32768;
#$insmod $moddir/compcache/ramzswap.ko backing_swap=/dev/block/mmcblk0p3;
#mknod /dev/ramzswap0 b 253 0;
echo 20 > /proc/sys/vm/swappiness;
# Experimental settings
#echo 1 > /proc/sys/vm/page-cluster; # default: 3 Changes Page clustering from 8 to 2.
#echo 5 > /proc/sys/vm/laptop_mode; # default: 0 Helps keep SSD from getting worn.
#echo 5000 > /proc/sys/vm/dirty_expire_centisecs; # default: 3000
#echo 800 > /proc/sys/vm/dirty_writeback_centisecs; # default: 500
#echo 10 > /proc/sys/vm/dirty_background_ratio; # default: 5
#echo 16 > /proc/sys/vm/dirty_ratio; # default: 10
#
#swapon /dev/ramzswap0;
swapon /dev/block/mmcblk0p3;
#Over Clock CPU when in use, puts at lower freq when idol. # if you don't want it.
#echo 128000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
#echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
QUESTION: Is there any way to re-allocate the compcache section of my physical RAM to be used again? There is that 24476b that I cannot use, as I'm using a swap.
Thanks for your time.
andjohn said:
Hello Everyone,
First, I did search. That is how I figured out how to disable compcache and enable the swap. It's working great, however since I am no longer using compcache, I would like to make available the RAM that it is using. Here are my free commands:
BEFORE:
# free
free
total used free shared buffers
Mem: 97928 96356 1572 0 8164
Swap: 24476 15516 8960
Total: 122404 111872 10532
AFTER:
# free
free
total used free shared buffers
Mem: 97928 96416 1512 0 300
Swap: 31768 3092 28676
Total: 129696 99508 30188
Notice that the Physical Memory is still the same number, despite compcache being disabled (well, atleast swapoff'd) Here is my userinit and you can see that it's just enabling the swap.
#!/system/bin/sh
##adb push userinit.sh /system/sd/
uname_r=`uname -r`
moddir=`find /system/modules -type d -name $uname_r`
#insmod=/system/bin/insmod
#$insmod $moddir/compcache/xvmalloc.ko;
#$insmod $moddir/compcache/ramzswap.ko disksize_kb=32768;
#$insmod $moddir/compcache/ramzswap.ko backing_swap=/dev/block/mmcblk0p3;
#mknod /dev/ramzswap0 b 253 0;
echo 20 > /proc/sys/vm/swappiness;
# Experimental settings
#echo 1 > /proc/sys/vm/page-cluster; # default: 3 Changes Page clustering from 8 to 2.
#echo 5 > /proc/sys/vm/laptop_mode; # default: 0 Helps keep SSD from getting worn.
#echo 5000 > /proc/sys/vm/dirty_expire_centisecs; # default: 3000
#echo 800 > /proc/sys/vm/dirty_writeback_centisecs; # default: 500
#echo 10 > /proc/sys/vm/dirty_background_ratio; # default: 5
#echo 16 > /proc/sys/vm/dirty_ratio; # default: 10
#
#swapon /dev/ramzswap0;
swapon /dev/block/mmcblk0p3;
#Over Clock CPU when in use, puts at lower freq when idol. # if you don't want it.
#echo 128000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
#echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
QUESTION: Is there any way to re-allocate the compcache section of my physical RAM to be used again? There is that 24476b that I cannot use, as I'm using a swap.
Thanks for your time.
Click to expand...
Click to collapse
hahaha, compcache doesn't take up your physical RAM.
ccyrowski said:
hahaha, compcache doesn't take up your physical RAM.
Click to expand...
Click to collapse
Ok, so where is it taking from? I understood that compcache is a Compression Swap that runs in RAM. Is that incorrect?
This does not belong in this area plz post questions like this in the Q&A area.
Prod1702 said:
This does not belong in this area plz post questions like this in the Q&A area.
Click to expand...
Click to collapse
Sorry, Mods please close. Reposting in QA
I modified the original rookeemod-oxygen script, so that you can supply limits in array form, eg:
LIMITS=( [10]=384000 [30]=691200 [50]=806400 [75]=998400)
It is attached to this post
First time i used bash, so if it isnt correct, please correct me.
I tested it and it works
Credits go to original creators, see copyright notice.
Code:
#!/system/bin/sh
#
# screenstate_scaling - switch CPU frequency governor on screen state change
# originally by [email protected] (FloHimself)
# mod teppic74 / xda - 12/10/2010
# Changelog:
# * Test for battery charging/full - if so, use alternative settings.
# * Allow for alternative frequencies when battery is below 30, 20 and 10%
# Modified by twicejr / xda - 15/01/2011 - made alternative frequencies work with an array, for more dynamic configurability.
# Modifications Copyright 2010
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
# ( note: options for freqs: 245000 384000 422400 460800 499200 537600 576000 614400 652800 691200 729600 768000 806400 844800 883200 921600 960000 998400 1036800 1075200 1113600 )
AWAKE_GOVERNOR="interactive"
AWAKE_GOVERNOR_FREQENCY_MAX="1113600"
AWAKE_GOVERNOR_FREQENCY_MIN="245000"
AWAKE_SAMPLING_RATE="40000"
AWAKE_CHARGING_GOVERNOR="interactive"
AWAKE_GOVERNOR_CHARGING_MAX="1113600"
AWAKE_GOVERNOR_CHARGING_MIN="499200"
SLEEP_GOVERNOR="interactive"
# irrelevant max for powersave
SLEEP_GOVERNOR_FREQENCY_MAX="245000"
SLEEP_GOVERNOR_FREQENCY_MIN="245000"
#LIMITS=( [10]=384000 [20]=460800 [30]=614400 [40]=729600 [50]=768000 [60]=806400 [70]=883200 [80]=998400 )
LIMITS=( [10]=384000 [30]=691200 [50]=806400 [75]=998400 )
SETCPU="com.mhuang.overclocking"
(while [ 1 ]
do
LIMIT_REACHED="0"
AWAKE=`cat /sys/power/wait_for_fb_wake`
BSTAT=`cat /sys/class/power_supply/battery/status`
if [ "$BSTAT" = "Charging" ] || [ "$BSTAT" = "Full" ] && [ ! "`pidof $SETCPU`" ]; then
echo $AWAKE_GOVERNOR_CHARGING_MIN > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $AWAKE_GOVERNOR_CHARGING_MAX > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo $AWAKE_CHARGING_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
log -p i -t screenstate_scaling "*** awake ***: $BSTAT - switching CPU frequency governor to -> $AWAKE_CHARGING_GOVERNOR"
elif [ $AWAKE = "awake" ] && [ ! "`pidof $SETCPU`" ]; then
echo $AWAKE_GOVERNOR_FREQENCY_MIN > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $AWAKE_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
BATT=`cat /sys/class/power_supply/battery/capacity`
for PERCENTAGE in ${!LIMITS[@]} ;
do
if [ $BATT -lt $PERCENTAGE ]; then
echo ${LIMITS[$PERCENTAGE]} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
LIMIT_REACHED="1"
break
fi
done
if [ $LIMIT_REACHED = "0"]
echo $AWAKE_GOVERNOR_FREQENCY_MAX > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
fi
if [ $AWAKE_GOVERNOR = "ondemand" ]; then
echo $AWAKE_SAMPLING_RATE > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
fi
log -p i -t screenstate_scaling "*** awake ***: switching CPU frequency governor to -> $AWAKE_GOVERNOR"
AWAKE=
fi
SLEEPING=`cat /sys/power/wait_for_fb_sleep`
if [ $SLEEPING = "sleeping" ] && [ ! "`pidof $SETCPU`" ]; then
echo $SLEEP_GOVERNOR_FREQENCY_MIN > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $SLEEP_GOVERNOR_FREQENCY_MAX > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo $SLEEP_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
log -p i -t screenstate_scaling "*** sleeping ***: switching CPU frequency governor to -> $SLEEP_GOVERNOR"
SLEEPING=
fi
done &)
i dont want to sound silly, but isnt it "easier" to simply use SetCPU?
waebi said:
i dont want to sound silly, but isnt it "easier" to simply use SetCPU?
Click to expand...
Click to collapse
Yes it is, but i think that in oxygen clean rom is more important
I find it better than having yet another app boot up at start.
Wont the handset be sluggish to wake from 245MHZ and powersave governor?!
Jagdish84 said:
Wont the handset be sluggish to wake from 245MHZ and powersave governor?!
Click to expand...
Click to collapse
I dunno, I set it to interactive: SLEEP_GOVERNOR="interactive"
.
I just think that interactive in combination with scaling down is just as "power-saving" as ondemand in the end, and it feels faster
twicejr said:
I dunno, I set it to interactive: SLEEP_GOVERNOR="interactive"
.
I just think that interactive in combination with scaling down is just as "power-saving" as ondemand in the end, and it feels faster
Click to expand...
Click to collapse
I agree, i got mixed up didnt notice you were using interactive
i would give it a shot but i aint using oxygen rom and ssts aint lying in init.d...
nice script nontheless
Yes, rom cooking with any kitchen is easy enough for anyone to start with but I think it's better to have a clear tutorial for the newbie like me. As I've tried searching for sometimes, I came up with this post. It may not be a perfect guide but at least, it's better than start from nothing.
This guide is made in Thailand, that's why I add the Thai keyboard.
Sorry, if I made any mistakes, and please tell me to fix.
Thanks: pj from droidsans, eRobot from pdamobiz (these two guys are Thai dev who help me so much)
For dsixda, your kitchen is amazing, love it so much.
For what?
GoLauncherEX -> default(ADWLauncher)
There are many reasons why I would say GoLauncherEX is better than ADWLauncher; having task manager and uninstaller within itself prevent us from wating any more space on the applications. GoLauncherEX also provide a lot of FREE widgets, while some other launchers may ask you yo pay extra, and the best characteristic of all is "this-thing-flows-fluently" you may not believe how small of RAM it is consuming.
MIUI music player -> default(Music)
MIUI (Me-U-I) is one of the most popular chinese ROM as you can see from Andriod phone recently, what imprest me the most in MIUI is the music player, it allows you to shuffle the music my just shaking a phone (as you have seen in many apple products) and provide playlist function which I found very convienient.
Gallery2D -> default(Gallery3D)
To be honest with you, the Gallery3D is not going to be use in this article. Due to the beautiful effects from this program (which has not done any good but being beautiful) which consume a lot of resources and took you for-ever to load the pictures, this issue brings me down to Gallery2D, with the same abilities except for the affected effects.
DroidSansThaiKeyboard -> default
Another sweetener in the recipe from Thai Andriod developer. Custom rom usually does not provide Thai keyboard indeed, and since I am cooking my own rom right now, I decided to drop it in!
CPU 19,710 smartassV2 -> default(264, 518)
Kernel that I use is called "flykernel-13" many versions has been released and this guy has never disappoint me. We are going to overclock at the speed of 19-710 MHz., I use smartassV2 as a CPU governor. The reason why I choose smartassV2 instead of ondemand is because; smartassV2 is not running at the maximum speed or minimum speed all the time, it has the ideal frequencies that store two CPU value, it is set for 518 and 352 for scree on and off sequentially.
Minimum free memory optimization
Theoritically, Andriod is going to clear and retrieve the memory automatically, but this operation is too slow sometime. What we can do is, change the minimum and maximim limits of the CPU before Andriod will recall to use ram. Unfortunately, HTC hero has such a tiny memory capacity comparing to recent Andriod phones, therefore, the background application should be terminate inorder to save memory for the currently using application.
Let’s get is started, shall we?
Prepare ingredients
Base rom: Mine is Elelinux-7.1.0-RC1-Hero-v3.5-Light
Android SDK: Just in case we have to use the ADB
dsixda Android kitchen:
Other packages such as .apk application and kernel (in case you want to change it))
Set up the kitchen
First of all, you can download dsixda kitchen from here:
http://forum.xda-developers.com/showthread.php?t=633246v
Although the owner of dsixda has stopped developing this guy a while ago, dsixda is still very popular among the developers. So far I haven’t seen any kitchen work as easy as this one.
Steps of installation here, works well on windows, linux and mac:
http://forum.xda-developers.com/showpost.php?p=5626300&postcount=3
Find your base rom
Before cooking, we need to prepare the ingredients, and the most important thing in this process is base rom. I suggest that you should find some base rom to work with, but if not, this kitchen is able to work with official rom and nandriod backup. The instruction of importing rom into the kitchen should be at the bottom of the forum. (http://forum.xda-developers.com/showpost.php?p=5626300&postcount=3)
Extract the base rom
After you have import the base rom into the kitchen, unzip the file and follow these steps:
open the terminal, go to directory of kitchen image we have created previously by using command:
cd /Volumes/kitchen
then type:
./menu
to activate the kitchen, the sceen will be as shown below.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
insert 1 and press Enter, kitchen will ask about setuo WORKING folder, follow the provided instructions and default. At the end, we are going to have a folder named WORKING_*****_***** which contain our rom inside, every configurations will be done in here.
Add more applications
We have two choices for adding applications in rom; one is to add it before the installation (which means it will become part of the system application, note that you won’t be able to uninstall the application unless you use titanium backup to take out the root access and uninstall from that), second is to install it as a user application (which is able to uninstall later on).
System applications
In WORKING_xxx, go to folder system > app you will see many .apk files, these are base applications in your phone; Settings.apk, Calendar.apk, etc.
Erase .apk files that you don’t want it to be in rom (caution: you many erase some important base applpications, so pick out the one you really know, and leave out all the rest.)
Copy .apk from other sources in here, if I was going to add GoLauncherEX, I’m going to browse for WORKING_xxx > system > app and erase a file name Launcher2.apk (this is the default launcher that comes with my base rom) then insert GoLaunherEX.apk into this folder (haven’t got the GoLauncherEX file? Google it!)
User applications
Open kitchen at the main menu.
type 0 to get to the Advanced options
type 13 to Enable /data/app
Follow the instructions of System applications except for the path, change it to:
WORKING_xxx > data > app
Minfree memory scripting
There are many applications in Andriod market that is able to work with this part, but since we are going to build your own rom, it make more sense to manage it before we flash the rom, it may be complicate, but I guarantee this is worth to do.
Kitchen has a function to do this for us, but it’s kind of mess up for me, somehow after you restart the phone, every setup is running back to default, so I decided to write them a script to make it actually work even after we restart the machine.
We are going to add the script in the system/etc/init.d/02memcputweak, if you couldn’t find a file name 02memcputeak, then create one of your own.
We are going to use the script from Juwe11 from XDA to be a default of minfree memory (http://forum.xda-developers.com/showthread.php?t=1111145) according to the link, you will see a script like this:
Code:
#!/system/bin/sh
# Copyright© 2011 Juwe11
# 13.8.2011 Updated VM values - Thanks to [Kalis] for help
# 18.8.2011 Added oom_adj values
# 19.9.2011 Updated VM and LMK values
if [ -e /sys/module/lowmemorykiller/parameters/adj ]; then
echo "0,1,2,4,6,15" > /sys/module/lowmemorykiller/parameters/adj
fi
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "2560,4096,5632,10240,11776,14848" > /sys/module/lowmemorykiller/parameters/minfree
fi
if [ -e /proc/sys/vm/swappiness ]; then
echo "20" > /proc/sys/vm/swappiness
fi
if [ -e /proc/sys/vm/vfs_cache_pressure ]; then
echo "70" > /proc/sys/vm/vfs_cache_pressure
fi
if [ -e /proc/sys/vm/dirty_expire_centisecs ]; then
echo "3000" > /proc/sys/vm/dirty_expire_centisecs
fi
if [ -e /proc/sys/vm/dirty_writeback_centisecs ]; then
echo "500" > /proc/sys/vm/dirty_writeback_centisecs
fi
if [ -e /proc/sys/vm/dirty_ratio ]; then
echo "15" > /proc/sys/vm/dirty_ratio
fi
if [ -e /proc/sys/vm/dirty_background_ratio ]; then
echo "3" > /proc/sys/vm/dirty_background_ratio
fi
Let’s take a look at this part.
Code:
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "2560,4096,5632,10240,11776,14848" > /sys/module/lowmemorykiller/parameters/minfree
fi
There are 6 sets of number, each one response to different part of work, which are
position 1 : 2560 -> foreground app ; applications that is now currently using.
position 2 : 4096 -> visible app ; applications that is not currently using, but haven’t finish the execution
position 3 : 5632 -> Secondary server ; service of the Operation Systems that applications needed to use.
position 4 : 10240 -> hidden app ; service that applications may needed to use, but not right now
position 5 : 11776 -> content provider ; connections between applications and the content
position 6 : 14848 -> empty app ; applications that are purposely left out in ram, in case you are going to use it again.
*FYI: number you above are the amount of page, if you want it in MB, multiply by 4 and divvided by 1024 (or X*4/1024) i.e. foreground app is 2560; 2560*4/1024 = 10 MB means that, if the free ram in total is less than 10MB, the foreground application will be terminated.
Next problem is, how are we going to manage
Code:
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "1536,4096,4096,25000,25000,25000" > /sys/module/lowmemorykiller/parameters/minfree
fi
position 1 : 1536 -> foreground app ; applications which are being used right now, pour out some more ram please.
position 2 : 4096 -> visible app ; applications that haven’t stop working, so leave them alone.
position 3 : 4096 -> Secondary server ; service that still in use and should not be terminate. ชุดที่ 4 : 25000 -> hidden app ; service that applications may or may not use, we are not going to keep this one for too long.
position 5 : 25000 -> content provider ; we haven’t use much content from other applications.
position 6 : 25000 -> empty app ; applications that may be left out, just in case we are going to use it, which we occasionally do.
OC memory scripting
We are still going to mess with file 02memcputweak. After we have prepared the memory part, we are further going to manipulate the speed and the governor of CPU. The scripts within this part are easy scripts that will go to configuration file of the kernel during the OS boosting.
Code:
#!/system/bin/sh
#
echo 19200 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 710400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo smartassV2 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chmod 0755 /system/etc/init.d/*
Set the value of 19200 in /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq to be a minimum frequency, as well as the value of 710400 in /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq to be the maximum frequency.
After we adjust the speed of CPU, we are going to adjust the govenor as well. For the best performance, I pick smartassV2 and put it in:
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Then set the permission of files in init.d by using a command:
chmod 0755 /system/etc/init.d/*
Now we are eventually done with 02memcputweak.
Code:
#!/system/bin/sh
#
# Copyright© 2011 Juwe11
# 13.8.2011 Updated VM values - Thanks to [Kalis] for help
# 18.8.2011 Added oom_adj values
# 19.9.2011 Updated VM and LMK values
if [ -e /sys/module/lowmemorykiller/parameters/adj ]; then
echo "0,1,2,4,6,15" > /sys/module/lowmemorykiller/parameters/adj
fi
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "1536,4096,4096,25000,25000,25000" > /sys/module/lowmemorykiller/parameters/minfree
fi
if [ -e /proc/sys/vm/swappiness ]; then
echo "20" > /proc/sys/vm/swappiness
fi
if [ -e /proc/sys/vm/vfs_cache_pressure ]; then
echo "70" > /proc/sys/vm/vfs_cache_pressure
fi
if [ -e /proc/sys/vm/dirty_expire_centisecs ]; then
echo "3000" > /proc/sys/vm/dirty_expire_centisecs
fi
if [ -e /proc/sys/vm/dirty_writeback_centisecs ]; then
echo "500" > /proc/sys/vm/dirty_writeback_centisecs
fi
if [ -e /proc/sys/vm/dirty_ratio ]; then
echo "15" > /proc/sys/vm/dirty_ratio
fi
if [ -e /proc/sys/vm/dirty_background_ratio ]; then
echo "3" > /proc/sys/vm/dirty_background_ratio
fi
echo 19200 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 710400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo smartassV2 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chmod 0755 /system/etc/init.d/*
Last steps, to make our script works in boot stage of Andriod, we have to insert
service script /system/etc/init.d/02memcputweak
oneshot
into file init.rc, which is located in WORKING_xxx > system > etc, the file will look similar to the text below::
Code:
# CyanogenMod Extras
# Compcache - handle at boot
service compcache /system/bin/handle_compcache
user root
group root
oneshot
service script /system/etc/init.d/02memcputweak
oneshot
Build rom from working directory
Back in the kitchen again, we are now going to pack rom back to .zip file so we could further test it.
In main menu of kitchen, there are options what to do with rom, type 99 to build the rom
After you have chosen a build option, change yourself to be an Interactive Mode (better for the new cooker).
Continue pressing Enter, throughout the process zipalign for optimize to reduce ram usage, and writting updater-script into rom (this part is the one who work with recovery and tell what to do in flashing.)
After every process is finished, we will get our rom in the folder OUTPUT_ZIP.
The next thing you have to do is flash and test the rom, enjoy.
can i use it to built a rom for lg p690
This is killer man. You're no noob.
Sent from my SGH-I727R using Tapatalk 2
sample rom
Can u give me the sample of rom?bcoz i dont want to use other base rom to cook
Hello,
New here at XDA, I've done a lot of reading here and found the site extremely useful in the past, so I thought I'd join up. Thanks for all the help you have provided!
Anyway, I am wondering if anybody knows of an Android equivalent to 'cpulimit' for Linux.
I am looking for a way to limit maximum CPU usage for a single process.
Thank you.
Bryan
Well, I have come to the conclusion there is no CPU limiter for Android, unless cpulimit could be compiled for it, which I have not tried.
However, this solution seems to work. If anybody is interested, I figured I'd update my thread.
Use the renice cmd.
Negative number raises scheduling priority, positive lowers it. From -20 to 20, 0 being the base priority.
I found that a value of even 5 limits the CPU usage of a process greatly when another processes is demanding a lot of CPU ad the same time, the one with base priority will receive much more attention.
Using Opera Mini as example:
# ps | grep opera
ps | grep opera
app_94 30814 93 114260 16956 ffffffff afd0c53c S com.opera.mini.android
Found PID of 30814
# ps -p 30814
ps -p 30814
USER PID PPID VSIZE RSS PRIO NICE RTPRI SCHED WCHAN PC NAME
app_94 30814 93 114260 16956 20 0 0 0 ffffffff afd0c53c S com.opera.mini.android
Now we see NICE value is 0 - base
# renice -1 30814
renice -1 30814
renice process to -1, increase priority slightly
# ps -p 30814
ps -p 30814
USER PID PPID VSIZE RSS PRIO NICE RTPRI SCHED WCHAN PC
NAME
app_94 30814 93 114260 16956 19 -1 0 0 ffffffff afd0c53c S com.opera.mini.android
This shows new NICE value worked, and is now -1.
It can also change priority for processes started by a particular user or group.
There is kind of an extra step in there.
ps -p | grep opera
Could use this to see pid and nice value all at once.
Sent from my Samsung