About Fps cap - Streak 5 General

Before you read this thread, please understand my poor english... T T;
Dell streak have fps cap. (45fps)
The cause is same with evo 4g.
Go to htc-linux.org and search FPS, you can find Novatek NT35582/FPS Hack page.
Vsync framerate formula is
(1,000,000,000 x (1 / (T2 x (Lines + VPA)))) / 60 = LCD Frequency (hz)
http://www.mediafire.com/?cap0otpr062wxlr <- Datasheet
In datasheet, (at 259 page)
VPA/Parameter - B100H
T2/Parameter - B101H, B102H
T3/Parameter - B103H ...
Line = 800, VPA = 6, T2 Register = 0x1BC = 444
Then, FPS is
(1,000,000,000 x (1 / (444 x (800 + 6)))) / 60 = 46.572627218Hz
It's same for streak's vsynced fps. right?
And when
echo 32 > /sys/kernel/debug/msm_fb/0/bpp
or echo 16 > /sys/kernel/debug/msm_fb/0/bpp
, FPS will be increased. (50fps -> 56fps)
So if you modify T2 Register, vsync framerate will be change.
ex) 1. 0x78(376) = 55fps, 2. 0x86(390) = 53fps, 3. 0x9D(413) = 50fps (attached screecshot)
Attachment is vsync modules and module source file.
vsync.ko <- for 2.6.35.7-perf
vsyncDSC7.ko <- for 2.6.35.14-DSC-Team-Phoenix+
vsyncDSC71.ko <- for 2.6.35.14-DSC-Team-Phoenix
init.streak.post_boot.sh and install-recovery.sh are for use vsync module because
insmod /system/lib/modules/vsync.ko
auo_lcd_on=`busybox grep -w auo_lcd_on /proc/kallsyms|busybox sed -e "s/\([0-9A-Fa-f]\{8\}\).*/\1/"`
mddi_auo_prim_lcd_init=`busybox grep -w mddi_auo_prim_lcd_init /proc/kallsyms|busybox sed -e "s/\([0-9A-Fa-f]\{8\}\).*/\1/"`
echo 0x$auo_lcd_on > /proc/t2_register/auo_lcd_on_addr
echo 0x$mddi_auo_prim_lcd_init > /proc/t2_register/mddi_auo_prim_lcd_init_addr
and
mount -t debugfs debugfs /sys/kernel/debug
echo 32 > /sys/kernel/debug/msm_fb/0/bpp
are necessary.
Module will modify just two codes in lcd source (mddi_auo.c)
static void mddi_auo_prim_lcd_init(void)
{
printk(KERN_ERR "mddi_auo_prim_lcd_init()+\n");
...
mddi_queue_register_write(0xC700, 0x8B, FALSE, 0);
mddi_queue_register_write(0xB102, 0xBC, FALSE, 0);
mddi_queue_register_write(0x1100, 0, FALSE, 0);
...
printk(KERN_ERR "mddi_auo_prim_lcd_init()-\n");
}
static int auo_lcd_on(struct platform_device *pdev)
{
struct msm_fb_data_type *mfd;
...
mddi_queue_register_write(0x4401, 0x0000, FALSE, 0);
mddi_queue_register_write(0xB102, 0xBC, FALSE, 0);
write_multi_mddi_reg(auo_lcd_bkl_init_array);
....
printk(KERN_ERR "auo_lcd_on()-\n");
return 0;
}
There are two examples for setting parameters.
(Tested by Korea forum. Special thanks to SCOTT!!!)
1. Framerate patch v1 (vsync on)
T2 register = 367 (0x16F)
echo 367 > /proc/t2_register/value
2. Framerate patch v2 (vsync off)
T2 register = 361 (0x169)
echo 361 > /proc/t2_register/hz
echo 0 > /sys/kernel/debug/msm_fb/0/hw_vsync_mode
echo 0 > /sys/kernel/debug/msm_fb/0/vsync_enable
v2 is more smooth then v1, but more consume battery.
CM7 and MIUI use v2.
I hope that this thread is helpful for you.
...not? T T;;

Can I flash this streakmod recovery? What benfit would I get?
Thanks for your hard work

mrkavanagh said:
Can I flash this streakmod recovery? What benfit would I get?
Thanks for your hard work
Click to expand...
Click to collapse
This is modifications for the kernel, most/all of the custom kernels already have the fps cap turned off.

Related

[Ruby] SMS Converter (from Pim Backup -> HTML)

I wanted to share a small script I wrote for those who know how to use it. It converts non-binary pim-backup message files to html files.
Usage: ruby <file> <message_file>
Code:
#-sms2html----------------------------------------------------------------#
# ChaosR (<[email protected]>) wrote this file. As long as #
# you do not touch this note and keep this note here you can do whatever #
# you want with this stuff. Also, the author(s) are not responsible for #
# whatever happens using this. #
#-------------------------------------------------------------------------#
require 'jcode' if RUBY_VERSION[0..2] == "1.8"
class SMSConverter
attr_accessor :messages, :raw, :by_folder, :by_name, :by_number
SPEC = [
:msg_id,
:sender_name,
:sender_address,
:sender_address_type,
:prefix,
:subject,
:body,
:body_type,
:folder,
:account,
:msg_class,
:content_length,
:msg_size,
:msg_flags,
:msg_status,
:modify_time,
:delivery_time,
:recipient_nbr,
:recipients,
:attachment_nbr,
:attachments
]
RECIP_SPEC = [
:id,
:name,
:phone,
:var1,
:var2,
:type
]
FOLDERS = {
"\\%MDF1" => "INBOX",
"\\%MDF2" => "OUTBOX",
"\\%MDF3" => "SENT",
"\\%MDF4" => "TRASH",
"\\%MDF5" => "DRAFTS"
}
def initialize(file)
f = File.open(file)
@raw = f.read
f.close
raw2array
clean_messages
sort_messages
end
def raw2array
messages = []
state = { :arg => 0, :escaped => false, :in_string => false }
sms = {}
@raw.each_char do |byte|
arg = SPEC[state[:arg]]
sms[arg] = "" unless sms[arg]
if byte == "\0" or byte == "\r"
next
elsif state[:escaped]
sms[arg] << byte
state[:escaped] = false
elsif state[:in_string]
if byte == "\""
state[:in_string] = false
elsif byte == "\\"
state[:escaped] = true
else
sms[arg] << byte
end
elsif byte == "\\"
state[:escaped] = true
elsif byte == "\""
state[:in_string] = true
elsif byte == ";"
state[:arg] += 1
elsif byte == "\n"
raise "Faulty conversion or corrupt file" if state[:escaped] or state[:in_string] or state[:arg] != 20
messages << sms
sms = {}
state[:arg] = 0
else
sms[arg] << byte
end
end
@messages = messages
end
def clean_messages
@messages.map! do |sms|
sms[:modify_time] = Time.local( *sms[:modify_time].split(",") )
unless sms[:delivery_time] == ""
sms[:delivery_time] = Time.local( *sms[:delivery_time].split(",") )
else
sms[:delivery_time] = sms[:modify_time]
end
sms[:recipient_nbr] = sms[:recipient_nbr].to_i
sms[:body_type] = sms[:body_type].to_i
sms[:msg_flags] = sms[:msg_flags].to_i
sms[:msg_status] = sms[:msg_status].to_i
sms[:attachment_nbr] = sms[:attachment_nbr].to_i
sms[:content_length] = sms[:content_length].to_i
sms[:msg_size] = sms[:msg_size].to_i
sms[:folder] = FOLDERS[sms[:folder]]
if sms[:recipient_nbr] > 0
recipients = {}
sms[:recipients].split(";").each_with_index { |var, index| recipients[RECIP_SPEC[index]] = var }
recipients[:id] = recipients[:id].to_i
recipients[:var1] = recipients[:var1].to_i
recipients[:var2] = recipients[:var2].to_i
sms[:recipients] = recipients
end
sms
end
end
def sort_messages
@messages = @messages.sort { |a, b| a[:delivery_time] <=> b[:delivery_time] }
@by_folder = {}
@messages.each do |sms|
@by_folder[sms[:folder]] = [] unless @by_folder[sms[:folder]]
@by_folder[sms[:folder]] << sms
end
@by_name = {}
@messages.each do |sms|
if sms[:recipient_nbr] > 0
if sms[:recipients][:name] != ""
name = sms[:recipients][:name]
else
name = sms[:recipients][:phone]
end
else
if sms[:sender_name] != ""
name = sms[:sender_name]
else
name = get_number_from_address(sms[:sender_address])
end
end
@by_name[name] = [] unless @by_name[name]
@by_name[name] << sms
end
@by_number = {}
@messages.each do |sms|
if sms[:recipient_nbr] > 0
name = sms[:recipients][:phone]
else
name = get_number_from_address(sms[:sender_address])
end
@by_number[name] = [] unless @by_number[name]
@by_number[name] << sms
end
end
def get_number_from_address(address)
if address =~ /^(\+?\d+)$/
return address
elsif address =~ /\<(\+?\d+)\>/
return $1
else
return false
end
end
end
if $0 == __FILE__
require 'fileutils'
dir = "./messages"
my_name = "yourname"
sms = SMSConverter.new(ARGV[0])
FileUtils.mkdir_p(dir)
sms.by_name.each { |name, messages|
filename = File.join(dir, "#{name}.html")
f = File.open(filename, "w")
f << "<html><body>"
messages.each { |sms|
sent = sms[:recipient_nbr] > 0
message = sms[:subject]
f << "<b>--- #{sent ? my_name : name} (#{sms[:delivery_time].strftime("%H:%M:%S, %a %d-%b-%Y")}) ---</b><br/>"
f << "<pre>#{message.strip}</pre><br/><br/>"
}
f << "</body></html>"
f.close
}
end
I'm a little new to this, but am really interested.
I installed Ruby and then created your ruby script. I then run from command prompt:
convertsms.rb pim.vol convertedsms.htm
but I get the following error. What have I done wrong?
C:\Users\mjt\Desktop>convertsms.rb pim.vol convertedsms.htm
C:/Users/mjt/Desktop/convertsms.rb:67:in `raw2array': undefined method `each_cha
r' for #<String:0x24ee9d4> (NoMethodError)
from C:/Users/mjt/Desktop/convertsms.rb:57:in `initialize'
from C:/Users/mjt/Desktop/convertsms.rb:199:in `new'
from C:/Users/mjt/Desktop/convertsms.rb:199
I'm just supposed to run it on a copy of my pim.vol correct?
Thanks!
You have to install pimbackup on your phone, make a non-binary backup. Download the backup to your computer, unzip it, and run this script on the msgs_<date>.csm file. This script will then create a folder called messages and store all the messages per user in it.
ChaosR said:
You have to install pimbackup on your phone, make a non-binary backup. Download the backup to your computer, unzip it, and run this script on the msgs_<date>.csm file. This script will then create a folder called messages and store all the messages per user in it.
Click to expand...
Click to collapse
Ok, I installed pim backup backed up the messages, copied the file to my computer, extracted the csm file and the following happened when I tried to run it.
C:\Users\mjt\Desktop>ruby convertsms.rb msgs.csm
convertsms.rb:67:in `raw2array': undefined method `each_char' for #<String:0x33e
94c> (NoMethodError)
from convertsms.rb:57:in `initialize'
from convertsms.rb:199:in `new'
from convertsms.rb:199
Thanks!
Heh, it seems on Windows you need to include jcode for each_char to work. Put the new code in. Cheers.
how to convert the binary backup to a non binary backup? other than restoring and backing up.
Relaying SMS
Would it be possible to relay the SMS to another phone when backing up, perhaps as a transfer operation, or by sending SMS via a webservice?

HD2 take only photo with 640x480 when using CameraCaptureDialog

Hi,
I have write an application for the HD2 to take a photo in my application.
But the photo has always a resolution of 640x480 even if I set
ccd.Resolution = new Size(2592, 1552);
My code:
Code:
public void OpenCamera(CameraCaptureMode mode)
{
DateTime timestamp = DateTime.Now;
CameraCaptureDialog ccd = new CameraCaptureDialog();
ccd.InitialDirectory = Config.GetString("UserImageFolder");
if (!System.IO.Directory.Exists(ccd.InitialDirectory))
System.IO.Directory.CreateDirectory(ccd.InitialDirectory);
ccd.Mode = mode;
ccd.StillQuality = CameraCaptureStillQuality.High;
ccd.Resolution = new Size(2592, 1552);
String basename = String.Format("{0:0000}-{1:00}-{2:00} {3:00}{4:00}{5:00} - ", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
if (Global.SelectedCache != null)
{
basename += Global.RemoveInvalidFatChars(StringUtils.Left(Global.SelectedCache.Name, 32).Trim());
ccd.Title = Global.SelectedCache.Name;
}
String extension = (mode == CameraCaptureMode.Still) ? ".jpg" : ".mp4";
int cnt = 0;
while (System.IO.File.Exists(Config.GetString("UserImageFolder") + "\\" + basename + ((cnt > 0) ? " - " + cnt.ToString() : "") + extension))
cnt++;
ccd.DefaultFileName = basename + ((cnt > 0) ? " - " + cnt.ToString() : "") + extension;
try
{
ccd.ShowDialog();
String name = (Global.SelectedCache != null) ? Global.SelectedCache.Name : "Image";
AnnotateMedia(name, ccd.DefaultFileName, Global.Locator.LastValidPosition, timestamp);
}
catch (Exception exc)
{
#if DEBUG
Global.AddLog("Main.OpenCamera: " + exc.ToString());
#endif
MessageBox.Show("An error occured! Seems as if your device had no camera!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
cameraImageButton.Enabled = false;
cameraVideoButton.Enabled = false;
}
ccd.Dispose();
}
Is anybody out here, who can tell me what I have to do, to change the resolution to the max. (2592x1552) of the HD2?
Thanks a lot and please sorry my bad english.
Andreas
I found the solution
CameraCaptureDialog accept only resolution that define in the registry.
So I modify
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Pictures\Camera\OEM\PictureResolution\1]
the keys
Height = 1944
Width = 2592
No I can take pictures with 2592x1552 with the code modify
Code:
ccd.Resolution = new Size(2592, 1552);

Universal Script for Android Phone

Create 00tweaks and put all the codes inside 00tweaks then put the file to system/etc/init.d
This universal script boost RAM performance.
This universal script mounts all partition as NOATIME
This universal script lessen lags on selected applications (MMS / Handcent / DialerOne)
This universal script enhances deadline scheduler
This universal script performs background process to check screen state
Click to expand...
Click to collapse
Code:
#!/system/bin/sh
#remounting the file systems with noatime and nodiratime flags to save battery and CPU cycles
for k in $(busybox mount | grep relatime | cut -d " " -f3)
do
sync
busybox mount -o remount,noatime,nodiratime $k
done
#if mounting is not successful then manual mounting will do the thing for you
mount -o remount,noatime,nodiratime auto /
mount -o remount,noatime,nodiratime auto /dev
mount -o remount,noatime,nodiratime auto /proc
mount -o remount,noatime,nodiratime auto /sys
mount -o remount,noatime,nodiratime auto /mnt/asec
mount -o remount,noatime,nodiratime auto /system
mount -o remount,noatime,nodiratime auto /data
mount -o remount,noatime,nodiratime auto /cache
mount -o remount,noatime,nodiratime auto /mnt/sdcard
mount -o remount,noatime,nodiratime auto /mnt/secure/asec
mount -o remount,noatime,nodiratime auto /mnt/sdcard/.android_secure
#flags every mounted partition as non rotational and increases it's cache size for more read speed
MTD=`ls -d /sys/block/mtd*`;
LOOP=`ls -d /sys/block/loop*`;
RAM=`ls -d /sys/block/ram*`;
MMC=`ls -d /sys/block/mmc*`;
for j in $MTD $LOOP $RAM
do
echo "0" > $j/queue/rotational;
echo "4096" > $j/queue/read_ahead_kb;
done
echo "4096" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
for a in $MTD $MMC
do
echo "512" > $a/queue/nr_requests;
done
#internet speed tweaks
echo 0 > /proc/sys/net/ipv4/tcp_timestamps;
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse;
echo 1 > /proc/sys/net/ipv4/tcp_sack;
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle;
echo 1 > /proc/sys/net/ipv4/tcp_window_scaling;
echo 5 > /proc/sys/net/ipv4/tcp_keepalive_probes;
echo 30 > /proc/sys/net/ipv4/tcp_keepalive_intvl;
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout;
echo 404480 > /proc/sys/net/core/wmem_max;
echo 404480 > /proc/sys/net/core/rmem_max;
echo 256960 > /proc/sys/net/core/rmem_default;
echo 256960 > /proc/sys/net/core/wmem_default;
echo 4096 16384 404480 > /proc/sys/net/ipv4/tcp_wmem;
echo 4096 87380 404480 > /proc/sys/net/ipv4/tcp_rmem;
#vm management tweaks
echo "0" > /proc/sys/vm/swappiness;
echo "95" > /proc/sys/vm/dirty_ratio;
echo "10" > /proc/sys/vm/vfs_cache_pressure;
echo "20480" > /proc/sys/vm/min_free_kbytes;
echo "1" > /proc/sys/vm/oom_kill_allocating_task;
echo "0" > /proc/sys/vm/laptop_mode;
echo "60000" > /proc/sys/vm/dirty_expire_centisecs;
echo "60" > /proc/sys/vm/dirty_background_ratio;
echo "6000" > /proc/sys/vm/dirty_writeback_centisecs;
echo "3" > /proc/sys/vm/drop_caches;
#kernel tweaks
echo "8" > /proc/sys/vm/page-cluster;
echo "64000" > /proc/sys/kernel/msgmni;
echo "64000" > /proc/sys/kernel/msgmax;
echo "10" > /proc/sys/fs/lease-break-time;
echo 500 512000 64 2048 > /proc/sys/kernel/sem;
# use deadline scheduler
echo deadline > /sys/class/block/mmcblk0/queue/scheduler;
echo deadline > /sys/class/block/stl14/queue/scheduler;
echo deadline > /sys/class/block/stl13/queue/scheduler;
echo deadline > /sys/class/block/stl12/queue/scheduler;
echo 8 > /sys/class/block/mmcblk0/queue/iosched/fifo_batch;
echo 8 > /sys/class/block/stl14/queue/iosched/fifo_batch;
echo 8 > /sys/class/block/stl13/queue/iosched/fifo_batch;
echo 8 > /sys/class/block/stl12/queue/iosched/fifo_batch;
echo 400 > /sys/class/block/mmcblk0/queue/iosched/read_expire;
echo 400 > /sys/class/block/stl14/queue/iosched/read_expire;
echo 400 > /sys/class/block/stl13/queue/iosched/read_expire;
echo 400 > /sys/class/block/stl12/queue/iosched/read_expire;
echo 4 > /sys/class/block/mmcblk0/queue/iosched/writes_starved;
echo 4 > /sys/class/block/stl14/queue/iosched/writes_starved;
echo 4 > /sys/class/block/stl13/queue/iosched/writes_starved;
echo 4 > /sys/class/block/stl12/queue/iosched/writes_starved;
#setprop
setprop wifi.supplicant_scan_interval 600;
setprop windowsmgr.max_events_per_sec 260;
setprop ro.lge.proximity.delay 25;
setprop mot.proximity.delay 75;
setprop net.tcp.buffersize.default 4096,87380,256960,4096,16384,256960;
setprop net.tcp.buffersize.wifi 4096,87380,256960,4096,16384,256960;
setprop net.tcp.buffersize.umts 4096,87380,256960,4096,16384,256960;
setprop ro.HOME_APP_ADJ 1;
setprop ro.mot.eri.losalert.delay 1000;
setprop video.accelerate.hw 1;
setprop ro.ril.disable.power.collapse 0;
setprop pm.sleep_mode 1;
setprop media.stagefright.enable-player true;
#lowmemory
FOREGROUND_APP_MEM="2560";
VISIBLE_APP_MEM="4096";
SECONDARY_SERVER_MEM="6144";
HIDDEN_APP_MEM="17408";
CONTENT_PROVIDER_MEM="19456";
EMPTY_APP_MEM="23552";
#governor scaling awake
GOVERNOR_SCALE="ondemand";
GOVERNOR_FREQENCY_MAX="800000";
GOVERNOR_FREQENCY_MIN="245760";
SAMPLING_RATE="50000";
FREQ_STEP="40";
UP_THRESHOLD="90";
DOWN_THRESHOLD="20";
#governor scaling sleep
SLEEP_SCALE="ondemand";
SLEEP_FREQENCY_MAX="480000";
SLEEP_FREQENCY_MIN="245760";
XSAMPLING_RATE="100000";
XFREQ_STEP="15";
XUP_THRESHOLD="90";
XDOWN_THRESHOLD="20";
#locking app
LOCK_APP_IN_MEMORY_ENABLED="0"
LOCK_APP_SU="1"
LOCK_APP_DIALER="0"
LOCK_APP_MMS="0"
LOCK_APP_HANDCENT="0"
# =========
# remove lag when answering phone calls
# =========
MAX_PHONE()
{
pidphone=`pidof com.android.phone`;
if [ $pidphone ];
then
/system/xbin/echo "-17" > /proc/$pidphone/oom_adj;
renice -20 $pidphone;
if [ $MAX_APP -eq "1" ];
then
exit;
else
MAX_APP_STARTER;
MAX_APP=1;
exit;
fi;
else
sleep 3;
MAX_PHONE;
fi;
}
# =========
# remove lag from su (root)
# =========
MAX_SU()
{
pidsu=`pidof com.noshufou.android.su`;
if [ $pidsu ];
then
/system/xbin/echo "-17" > /proc/$pidsu/oom_adj;
renice -20 $pidsu;
exit;
else
sleep 3;
MAX_SU;
fi;
}
# =========
# remove lag from Clock
# =========
MAX_DIALER()
{
piddialer=`pidof kz.mek.DialerOne`;
if [ $piddialer ];
then
/system/xbin/echo "-17" > /proc/$piddialer/oom_adj;
renice -10 $piddialer;
exit;
else
sleep 3;
MAX_DIALER;
fi;
}
# =========
# remove lag from MMS
# =========
MAX_MMS()
{
pidmms=`pidof com.android.mms`;
if [ $pidmms ];
then
/system/xbin/echo "-17" > /proc/$pidmms/oom_adj;
renice -10 $pidmms;
exit;
else
sleep 3;
MAX_MMS;
fi;
}
# =========
# remove lag from HANDCENT
# =========
MAX_HANDCENT()
{
pidhandcent=`pidof com.handcent.nextsms`;
if [ $pidhandcent ];
then
/system/xbin/echo "-17" > /proc/$pidhandcent/oom_adj;
renice -10 $pidhandcent;
exit;
else
sleep 3;
MAX_HANDCENT;
fi;
}
# =========
# Background process to optimize process
# =========
MAX_APP_STARTER()
{
if [ $LOCK_APP_IN_MEMORY_ENABLED -eq "1" ];
then
if [ $LOCK_APP_SU -eq "1" ];
then
(while [ 1 ];
do
sleep 5;
MAX_SU;
done &);
fi;
if [ $LOCK_APP_MMS -eq "1" ];
then
(while [ 1 ];
do
sleep 3;
MAX_MMS;
done &);
fi;
if [ $LOCK_APP_HANDCENT -eq "1" ];
then
(while [ 1 ];
do
sleep 3;
MAX_HANDCENT;
done &);
fi;
if [ $LOCK_APP_DIALER -eq "1" ];
then
(while [ 1 ];
do
sleep 3;
MAX_DIALER;
done &);
fi;
exit;
else
(while [ 1 ];
do
sleep 3;
MAX_APP_STARTER;
done &);
fi;
}
if [ $LOCK_APP_IN_MEMORY_ENABLED -eq "1" ];
then
(while [ 1 ];
do
sleep 3;
MAX_PHONE;
done &);
fi;
GOV_MODE()
{
echo "1" >/proc/sys/vm/overcommit_memory;
echo "4" > /proc/sys/vm/min_free_order_shift;
echo $FOREGROUND_APP_MEM,$VISIBLE_APP_MEM,$SECONDARY_SERVER_MEM,$HIDDEN_APP_MEM,$CONTENT_PROVIDER_MEM,$EMPTY_APP_MEM > /sys/module/lowmemorykiller/parameters/minfree;
echo $GOVERNOR_SCALE > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
echo $GOVERNOR_FREQENCY_MAX > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo $GOVERNOR_FREQENCY_MIN > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo $SAMPLING_RATE > /sys/devices/system/cpu/cpu0/cpufreq/$GOVERNOR_SCALE/sampling_rate;
echo $FREQ_STEP > /sys/devices/system/cpu/cpu0/cpufreq/$GOVERNOR_SCALE/freq_step;
echo $UP_THRESHOLD > /sys/devices/system/cpu/cpu0/cpufreq/$GOVERNOR_SCALE/up_threshold;
echo $DOWN_THRESHOLD > /sys/devices/system/cpu/cpu0/cpufreq/$GOVERNOR_SCALE/down_threshold;
}
SLEEP_MODE()
{
echo "1" >/proc/sys/vm/overcommit_memory;
echo "4" > /proc/sys/vm/min_free_order_shift;
echo $FOREGROUND_APP_MEM,$VISIBLE_APP_MEM,$SECONDARY_SERVER_MEM,$HIDDEN_APP_MEM,$CONTENT_PROVIDER_MEM,$EMPTY_APP_MEM > /sys/module/lowmemorykiller/parameters/minfree;
echo $SLEEP_SCALE > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
echo $SLEEP_FREQENCY_MAX > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo $SLEEP_FREQENCY_MIN > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo $XSAMPLING_RATE > /sys/devices/system/cpu/cpu0/cpufreq/$SLEEP_SCALE/sampling_rate;
echo $XFREQ_STEP > /sys/devices/system/cpu/cpu0/cpufreq/$SLEEP_SCALE/freq_step;
echo $XUP_THRESHOLD > /sys/devices/system/cpu/cpu0/cpufreq/$SLEEP_SCALE/up_threshold;
echo $XDOWN_THRESHOLD > /sys/devices/system/cpu/cpu0/cpufreq/$SLEEP_SCALE/down_threshold;
}
# =========
# Background process to check screen state
# =========
(while [ 1 ];
do
STATE=`cat /sys/power/wait_for_fb_wake`;
GOV_MODE;
sleep 3;
STATE=`cat /sys/power/wait_for_fb_sleep`;
SLEEP_MODE;
sleep 3;
done &);
Some brief explanation for the contents of the script
1. /proc/sys/vm/laptop_mode
How many seconds after a read should a writeout of changed files start (this is based on the assumption that a read will cause an otherwise spun down disk to spin up again).
2. /proc/sys/vm/dirty_writeba​ck_centisecs
How often the kernel should check if there is "dirty" (changed) data to write out to disk (in centiseconds).
3./proc/sys/vm/dirty_expir​e_centisecs
How old "dirty" data should be before the kernel considers it old enough to be written to disk. It is in general a good idea to set this to the same value as dirty_writeback_centisecs above.
4./proc/sys/vm/dirty_ratio​
The maximum amount of memory (in percent) to be used to store dirty data before the process that generates the data will be forced to write it out. Setting this to a high value should not be a problem as writeouts will also occur if the system is low on memory.
5./proc/sys/vm/dirty_backg​round_ratio
The lower amount of memory (in percent) where a writeout of dirty data to disk is allowed to stop. This should be quite a bit lower than the above dirty_ratio to allow the kernel to write out chunks of dirty data in one go.
I thought I should return the Tweak Manager's 00tweaks script back to initramfs
let me give it a try
what if i already have 00tweaks? should i had this script to the current file or substitute?
Hey, the values are similar to CF-Root Great then, gonna try it out
What should I do if I want to try your script, but I have already used CF-Root With Tweak Manager that also using another script in 00tweaks file
Wow I just ran this on GSB 3.8 workshed for the eris. And WOW the phone rings on 1 1/2 rings with a ringtone and the screen lights up. Very nice work. I hope you don't mind but i posted a link from the eris fourms to this file. I been looking for for so long on how to get rid of the rintone LAG and WOW i think you got it! Thank you
How to create the script?
Thnx
A lil question, this wont collide with the V6 Supercharger?
Hey guys,
can somebody please tell me how to make a script of this? I really want to know, but i'm new to this.
I can't find anything on the "search".
Cheers
QNBT said:
A lil question, this wont collide with the V6 Supercharger?
Click to expand...
Click to collapse
I think something does because I am getting complete homescreen redraws since I started using this a couple days ago. The phone seems to boot way faster and seems to run a little better but I think there is a conflict somewhere.
Sgace said:
Hey guys,
can somebody please tell me how to make a script of this? I really want to know, but i'm new to this.
I can't find anything on the "search".
Cheers
Click to expand...
Click to collapse
You don't have to make a script just copy it all to a text document on your desktop and after you save it delete the .txt at the end. Then put it on your SD card and use Root Explorer, or similar, to move it the proper location. I set the ownership and permissions the same as other files in the same location and rebooted. Just be sure to tap the "R/W" button at the top of the screen if you are using Root Explorer so you have read/write permission to work in the folder.
PieceKeepr said:
You don't have to make a script just copy it all to a text document on your desktop and after you save it delete the .txt at the end. Then put it on your SD card and use Root Explorer, or similar, to move it the proper location. I set the ownership and permissions the same as other files in the same location and rebooted. Just be sure to tap the "R/W" button at the top of the screen if you are using Root Explorer so you have read/write permission to work in the folder.
Click to expand...
Click to collapse
Hey,
thnx man. Found notepad++ and made a text file with that.
Tried the script for a couple of ours and for my personal feeling it made my phone slower at multiple points. Also Quadrant standard gave me a lower score (11-13) then when i'm using 00tweaks/v4 tt.
So this goes out the door.
Cheers
I hate bringing things back from the dead, so I apologize in advance.
If I want just the atime section of this script, do I just keep the first part? Where does it stop?
AUTO
what does the auto do in the mounting script?

[TWEAKS] Applying Phenomenal's internal voltages in Siyah Kernel!

Hi guys,
I had a little frustration, because two of the 4 things I told in that post don't save battery. And the reason is, to we undervolt a "driver" (cpu, gpu, etc) We need to change it specifically. But what we changed here was their regulators.
A regulator is a constraint. It doesn't change any voltage at all. When we change it he just allows the "driver" of that group changes it voltages between the min_volt / max_volt specified on regulator.
Example. I want to undervolt gpu to 750. But the gpu is "ruled" by a regulator. If I want to undervolt I must change gpu voltages and also change the min_volt of the regulator to 750. When I change it I tell that the gpu can be undervolted to 750, but I didn't undervolted in that moment. Got it?
So, the great internal voltages made in regulator of phenomenal are useless.
So the only thing that really do work in my post is the cpu asv voltages (the first two variables of the script).
So, that's all folks. We could try undervolting gpu less then 800 by changing it file + changing it's min_volt regulator with kmemhelper. In fact, I don't think this post is over. I'll try to find out which driver is been regulated by these regulators we are changing, then I'll add here, in the script.
==================
DO IT AT YOUR OWN RISKS
This is a advanced topic. Don't apply the things above if you don't understand it.
Hi people!
This thread is for all who wants who suffer from the "undervolting to save battery" disorder
In fact i would any undervolts that were possible to save battery. Today we can easily undervolt cpu and gpu, with apps. What is not so easy to undervolt is the internal voltages.
- "OMG! Internal Voltages?!?! You are going to crash your system!!!"
Calm, don't panic. Let's take a look in Phenomenal's Kernel. I think you agree with Phenomenal's good battery saving, at least reasonable. But what Phenomenal do? He is the SpeedMod Kernel compilated with cpu and gpu undervolting +internal undervoltings(in extreme variation)!
But i personally love the Siyah Kernel. 2 rom's, a lot of funcionalities, etc.
So i decided to apply the internal voltages of Phenomenal in Siyah Kernel!
Observation: This is not a guide that teaches undervolting values and approaches, that guide shows what to undervolt!
With the help of Phenomenals tutorial and droidphile's tutorial we can figure out how to do it.
The kmemhelper binnary can read and write variables at the kernel's memory address. In fact, he can get/set all variables that are in /proc/kallsysms.
Observaton: It may be possible to do it in other kernel's, but the variables must be in /proc/kallsyms and you MUST look in kernel's source code to be sure that the variable is really the one.
So, what we want to do is:
1 - Get the variables name that stores internal voltages
2 - See the values that they have
3 - Set the new values via init.d script.
What else you'll need:
1 - Script Manager
At this point a liitle observation:
From one version of Siyah to another, the values could be changed. It's kernel's owner call. With init.d we'll always overwrite his changes (if he does). But that's not a problem at all, since we want to undervolt and we can control how much we'll undervolt.
To get the variables names i first looked in Phenomenals tutorial. After that its necessary to look inside Siyah's source code to make sure that their names is the same.
Okay, so we got that the variables that contain the internal voltages are:
bus and cpu internal voltages:
exynos4_busfreq_table[] (-100000 in extreme)
exynos4_asv_volt[] (-50000 in extreme)
screen voltages:
ldo13_init_data (-300000 in extreme)
ldo18_init_data (-300000 in extreme)
memory voltages:
buck5_init_data (-100000 in extreme)
A really important thing: The stock internal voltages values are in Phenomenal's tutorial. So you undervolt that values, not the values that are in the kernel you want to undervolt! that's because the developer could already undervolted something. Pay atention!
I checked out what values Siyah Kernel had for that variables. I looked at the source code, but you can do this with kmemhelper also.
=======================================
#!/system/bin/sh
su
# /sbin is the location where my kmemhelper is. See where it is yours.
# could be in xbin also.
export PATH=$PATH:/sbin
FILE="/mnt/sdcard/variables.txt"
> $FILE
echo "Printing variables: " >> $FILE
echo "Bus voltages: ">> $FILE
kmemhelper -n exynos4_busfreq_table -t int -o 8 >> $FILE
kmemhelper -n exynos4_busfreq_table -t int -o 28 >> $FILE
kmemhelper -n exynos4_busfreq_table -t int -o 48 >> $FILE
echo "Cpu internal voltages: ">> $FILE
kmemhelper -n exynos4_asv_volt -t int >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 4 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 8 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 12 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 16 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 20 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 24 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 28 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 32 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 36 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 40 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 44 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 48 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 52 >> $FILE
kmemhelper -n exynos4_asv_volt -t int -o 56 >> $FILE
echo "Screen voltages: ">> $FILE
kmemhelper -n ldo13_init_data -t int -o 8 >> $FILE
kmemhelper -n ldo13_init_data -t int -o 12 >> $FILE
kmemhelper -n ldo18_init_data -t int -o 8 >> $FILE
kmemhelper -n ldo18_init_data -t int -o 12 >> $FILE
echo "Memory voltages: ">> $FILE
kmemhelper -n buck5_init_data -t int -o 8 >> $FILE
kmemhelper -n buck5_init_data -t int -o 12 >> $FILE
kmemhelper -n buck5_init_data -t int -o 56 >> $FILE
exit 0;
=====================================
Now that you got the actual values you can plan at how much you'll undervolt.
I didnt use the extreme values (not for now). Again, the undervolting values is at your own risk.
I suggest you to create a new script in init.d to apply these commands and backup init.d folder. If something went wrong you just remove init.d folder in recovery mode.
=====================================
#!/system/bin/sh
su
export PATH=$PATH:/sbin
#
# phenomenal kernel undervolting
#
# 1. bus frequencies: exynos4_busfreq_table
#static struct busfreq_table exynos4_busfreq_table[] = {
#{LV_0, 400000, 1100000, 0, 0},
#{LV_1, 267000, 1000000, 0, 0},
#{LV_2, 133000, 950000, 0, 0},
#{0, 0, 0, 0, 0},
#};
#
# -50 undervolting
kmemhelper -n exynos4_busfreq_table -t int -o 8 1050000
kmemhelper -n exynos4_busfreq_table -t int -o 28 950000
kmemhelper -n exynos4_busfreq_table -t int -o 48 900000
#define ASV_GROUP5
#static unsigned int exynos4_asv_volt[ASV_GROUP][LV_END] = {
#{1150000, 1050000, 1050000},
#{1125000, 1025000, 1025000},
#{1100000, 1000000, 1000000},
#{1075000, 975000, 975000},
#{1050000, 950000, 950000},
#};
#
# -50 undervolting
kmemhelper -n exynos4_asv_volt -t int 1100000
kmemhelper -n exynos4_asv_volt -t int -o 4 1000000
kmemhelper -n exynos4_asv_volt -t int -o 8 1000000
kmemhelper -n exynos4_asv_volt -t int -o 12 1075000
kmemhelper -n exynos4_asv_volt -t int -o 16 975000
kmemhelper -n exynos4_asv_volt -t int -o 20 975000
kmemhelper -n exynos4_asv_volt -t int -o 24 1050000
kmemhelper -n exynos4_asv_volt -t int -o 28 950000
kmemhelper -n exynos4_asv_volt -t int -o 32 950000
kmemhelper -n exynos4_asv_volt -t int -o 36 1025000
kmemhelper -n exynos4_asv_volt -t int -o 40 925000
kmemhelper -n exynos4_asv_volt -t int -o 44 925000
kmemhelper -n exynos4_asv_volt -t int -o 48 1000000
kmemhelper -n exynos4_asv_volt -t int -o 52 900000
kmemhelper -n exynos4_asv_volt -t int -o 56 900000
#
# 2. Screen undervolting
#
#REGULATOR_INIT(ldo13, "VCC_3.0V_LCD", 3000000, 3000000, 1,
#REGULATOR_CHANGE_STATUS, 1
#
#REGULATOR_INIT(ldo18, "TOUCH_LED_3.3V", 2500000, 3300000, 0,
#REGULATOR_CHANGE_STATUS | #REGULATOR_CHANGE_VOLTAGE, 1)
kmemhelper -n ldo13_init_data -t int -o 8 2700000
kmemhelper -n ldo13_init_data -t int -o 12 2700000
# Siyah undervolted: 2500000
# kmemhelper -n ldo18_init_data -t int -o 8 2700000
kmemhelper -n ldo18_init_data -t int -o 12 3000000
#
# 3. Memory undervolting
#
#static struct regulator_init_data buck5_init_data = {
#.constraints= {
#.name= "VMEM_1.2V",
#.min_uV= 1200000,
#.max_uV= 1200000,
#.apply_uV= 1,
#.always_on= 1,
#.state_mem= {
#.uV= 1200000,
#.mode= REGULATOR_MODE_NORMAL,
#.enabled = 1,
#},
#},
#};
# - 50 undervolt
# didnt undervolt for now.
#kmemhelper -n buck5_init_data -t int -o 8 1150000
#kmemhelper -n buck5_init_data -t int -o 12 1150000
#kmemhelper -n buck5_init_data -t int -o 56 1150000
=====================================
=====================================
So, i think this is it. I ask you to not get this guide as the untouchable truth. It could be a detail or another wrong. But be sure, i did what i tell u to do. At that moment, my cel seems just fine at it was, with internal undervolt!!!
I would be happy if you guys that already have something like this could share your informations also, and for the adventurers who want to apply this guide i'm able to help.
And please, show the improovements of your battery!!!!
[EDIT]: I attached both scripts and the "var" result file so you guys can directly download it. Remove the ".txt" extension.
Cheers.
If you like, pls hit the thank button
Couldn't understand all. Those are multiple init.d scripts? Where to insert the voltage value? What about this kmemhelper? I can't find it anywhere. If it's too low, what the side effects? Are this really safe?
marcellocord said:
Couldn't understand all. Those are multiple init.d scripts? Where to insert the voltage value? What about this kmemhelper? I can't find it anywhere. If it's too low, what the side effects? Are this really safe?
Click to expand...
Click to collapse
There is just one init.d scripts, the last one. The first one is a normal script that you can execute before and after to see the old and new undervolted values.
U can get more info about Kmemhelper in droidphile guide, the link is in the post!
Undervolts aren't safe by nature. Go slowly.
Sent from my GT-I9100 using Tapatalk
Excellent mate! It would be awesome if someone could interface kmemhelper stuff into an app.
Sent from my GT-I9100 using xda premium
OK so the output file shows data but which freq step do they correspond to they look out of order to me.
Edit: I made a Tasker slider control for mdnie colour control. Link in Siyah thread. I'm keen to make one for this too.
Sent from my GT-I9100 using xda premium
You init.d script as is froze on my phone but I upped some of the internals and it's running fine now!
Curious if upping internal voltages for the highest frequencies a bit might make ARM undervolting more stable. This certainly was the case for me with my sgs1
Sent from my GT-I9100 using xda premium
rlorange said:
OK so the output file shows data but which freq step do they correspond to they look out of order to me.
Edit: I made a Tasker slider control for mdnie colour control. Link in Siyah thread. I'm keen to make one for this too.
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
Strange. The output is in order with me. You can adapt it to print the frequence also so you can be sure of the values.
That would be great if you do something like a slider.
Sent from my GT-I9100 using Tapatalk
rlorange said:
You init.d script as is froze on my phone but I upped some of the internals and it's running fine now!
Curious if upping internal voltages for the highest frequencies a bit might make ARM undervolting more stable. This certainly was the case for me with my sgs1
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
Lol, i did more undervolt now. Sometimes my cel freezes and I have to reboot, I just undervolted -100 to memory. If continues to freezes ill up a little, for now I'll keep like that.
And also is a interesting idea to give them more power so you can undervolt more or the other side. But would it work?
Sent from my GT-I9100 using Tapatalk
Very cool info here thanks! So I'm guessing there's three internal voltages per CPU step for each bus freq?
Did you try my colour Tasker XMLs?
Import all and then shortcut the siyahCOLOUR task. Assuming you use the app
http://db.tt/MPqNPPr2
Started working on a internal voltages one
Sent from my GT-I9100 using xda premium
rlorange said:
Very cool info here thanks! So I'm guessing there's three internal voltages per CPU step for each bus freq?
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
Humm.... that I really don't know. Don't know how it works. I'm starting to study kernel's source code. I'll try to understand how this part works and I post the awnser here.
But first ill take a look in pegasusq algorithm to make sure that my settings are ok, or if I can improve something.
Sent from my GT-I9100 using Tapatalk
Great mate, very useful !
Will give a try ;-)
The must would be that gokhan put this in Extweaks ^^
Just one detail, error ?
For the screen undervolting, you undervolt for 30 ok ?
For lcd13 3000000-3000000 become 2700000-2700000, but for lcd18 2500000-3300000 become 2700000-3300000. Shouldn't be 2200000 ?
Thx
Sent from my GT-I9100 using xda premium
I believe it is the case. There are 5 groups of three internal voltages. Originally there were 5 five frequency steps and there are 3 bus frequencies so makes sense
Sent from my GT-I9100 using xda premium
Very interesting. What do you think saves most power? Screen undervolting?
Could someone please upload the scripts with Medium or Extreme settings for us lazy noobs?
Shinfei said:
Great mate, very useful !
Will give a try ;-)
The must would be that gokhan put this in Extweaks ^^
Just one detail, error ?
For the screen undervolting, you undervolt for 30 ok ?
For lcd13 3000000-3000000 become 2700000-2700000, but for lcd18 2500000-3300000 become 2700000-3300000. Shouldn't be 2200000 ?
Thx
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
No, not an error. That's the point we must be careful.
The stock l18 values are 3000000, 3300000.
Gokhan already undervolted first parameter to 2500000. So we don't need to undervolt that.
Just undervolted the second to 3000000.
Sent from my GT-I9100 using Tapatalk
apphoarder said:
Very interesting. What do you think saves most power? Screen undervolting?
Could someone please upload the scripts with Medium or Extreme settings for us lazy noobs?
Click to expand...
Click to collapse
I'm not sure. Certainly the most battery enemy is screen on. Just look how much volts we need to give it: 3.000.000 for ld13 and 3.300.000 for ld18. It's so much.
While to memory for example is 1.200.000.
Sent from my GT-I9100 using Tapatalk
Those second screen voltage values a are for the touch keys. These are already tunable by breathing parameters and extweaks. 2500000 is not visible. 3300000 max and 3000000 stock
Sent from my GT-I9100 using xda premium
robertobsc said:
No, not an error. That's the point we must be careful.
The stock l18 values are 3000000, 3300000.
Gokhan already undervolted first parameter to 2500000. So we don't need to undervolt that.
Just undervolted the second to 3000000.
Sent from my GT-I9100 using Tapatalk
Click to expand...
Click to collapse
Ok thx, misunderstood, think you've write the default values ;-)
Sent from my GT-I9100 using xda premium
Does these scripts work on other kernels that support init.d?
I'm using it on cf root and it seems the phone never becomes hot anymore since I use this.
Sent from my GT-I9100 using xda premium
hikarugo said:
Does these scripts work on other kernels that support init.d?
I'm using it on cf root and it seems the phone never becomes hot anymore since I use this.
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
With cf root?? really??
I don't think cf root supports init.d scripts, does it?
In anyway, to verify if the values were applied, exec the first script of the topic. It will create a file variables.txt in /mnt/sdcard with the values returned by kmemhelper.
If there's no values then its not possible to apply the values for that kernel.
If you like post the results so I can see.
Sent from my GT-I9100 using Tapatalk
robertobsc said:
With cf root?? really??
I don't think cf root supports init.d scripts, does it?
In anyway, to verify if the values were applied, exec the first script of the topic. It will create a file variables.txt in /mnt/sdcard with the values returned by kmemhelper.
If there's no values then its not possible to apply the values for that kernel.
If you like post the results so I can see.
Sent from my GT-I9100 using Tapatalk
Click to expand...
Click to collapse
The following is copied directly from cf root thread:
Custom boot / init scriptsCF-Root will execute the following scripts if present, in the order listed:- /system/etc/init.d/* (there can be many files here, no extensions! use #!)- /system/bin/customboot.sh (busybox sh)- /system/xbin/customboot.sh (busybox sh)- /data/local/customboot.sh (busybox sh)
Click to expand...
Click to collapse
However there is no variables.txt. Perhaps what I said earlier is just a placebo
Sent from my GT-I9100 using xda premium

[Q] app to calculate RAM,CPU usage and other stuffs

hey xda people...i am pretty new to android development.. (have started building some basic apps! )
i was planning to build an app that can:
1.calculate RAM usage by the system
2.CPU usage by the system.
3.number of ongoing processes in the system.
4.kill unused running background applications to free space.
can anyone please provide the java source code for the above?
thanks in advance
Wait a moment. I'll code your new app in a minute.
thanks m eagerly waiting ...
To get free RAM:
Code:
public Integer getFreeRAM() {
MemoryInfo mi = new MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
Integer mem = (int) (mi.availMem / 1048576L);
return mem;
}
To get total RAM you can parse
Code:
/proc/meminfo
To get CPU Load/Usage parse
Code:
/proc/stat
To get Running apps use something like:
Code:
ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<RunningTaskInfo> procInfos = actvityManager.getRunningTasks(1000);
or you could execute ps or top and parse output
Hope it helps
by a fellow developer: https://play.google.com/store/apps/...mNvbS5jZ29sbG5lci5zeXN0ZW1tb25pdG9yLmxpdGUiXQ..
Take a look at it should be helpful at what you want to achieve.
pedja1 said:
To get free RAM:
Code:
public Integer getFreeRAM() {
MemoryInfo mi = new MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
Integer mem = (int) (mi.availMem / 1048576L);
return mem;
}
To get total RAM you can parse
Code:
/proc/meminfo
To get CPU Load/Usage parse
Code:
/proc/stat
To get Running apps use something like:
Code:
ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<RunningTaskInfo> procInfos = actvityManager.getRunningTasks(1000);
or you could execute ps or top and parse output
Hope it helps
Click to expand...
Click to collapse
thanx for rplyin...
i have already built an app to calculate available ram
can u please elaborate a bit more about the parsing issue??
because i am unable to get what u are saying
Arnab B said:
thanx for rplyin...
i have already built an app to calculate available ram
can u please elaborate a bit more about the parsing issue??
because i am unable to get what u are saying
Click to expand...
Click to collapse
Files /proc/stat and meminfo contains information you need. You just have to read from those files. For ram its easy, first line from proc/meminfo is what you need.
For CPU load check here:
http://stackoverflow.com/questions/3118234/how-to-get-memory-usage-and-cpu-usage-in-android
Sent from my Evo 3D GSM using Tapatalk 2
to get values you need to let the app read the file and import the content in an array (if contains multiple values) or in a simple String.
Code:
File yourFile = new File("/complete/path/to/the/file");
FileInputStream fin = null;
try {
fin = new FileInputStream(yourfile);
byte fileContent[] = new byte[(int)yourfile.length()];
fin.read(fileContent);
String s = new String(fileContent);
}
catch (FileNotFoundException e) {
System.out.println("File not found" + e);
}
catch (IOException ioe) {
System.out.println("Exception while reading file " + ioe);
}
finally {
try {
if (fin != null) {
fin.close();
}
}
catch (IOException ioe) {
System.out.println("Error while closing stream: " + ioe);
}
}
String[] values = s.split("\\s+");
Note that if you need to retrieve a specific value, the first item in the array is called "0".
for example, if we read the file /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies , this is the content:
Code:
51000 102000 204000 340000 475000 640000 760000 860000 1000000 1100000 1200000 1300000 1400000 1500000
so:
"s" will be:
Code:
[B]s[/B] = 51000 102000 204000 340000 475000 640000 760000 860000 1000000 1100000 1200000 1300000 1400000 1500000
note that, s.split("\\s+");, will split the string where there are "spaces" (" ")
and "values" will be:
Code:
[B]values[/B] = {51000;102000;204000;340000;475000;640000;760000;860000;1000000;1100000;1200000;1300000;1400000;1500000}
so, if you need to call one item from the "values" array, you can simply do it by calling values[position] , where "position" it's an integer from 0 ( = 51000) to the max lenght of your array.
if you need to convert these numbers in Integers to make some math operations you can do this using:
Code:
int val = Integer.parseInt(values[position]);
simple

Categories

Resources