CMParts: Allow CompCache size to be set by user - via % of total RAM
Use % instead of a set size - per suggestion from Cyanogen
Fix to integer instead of decimal being passed around - props to Nameless
Handle older versions changing enabled CC to Default CC size (25%)
Enable PerformanceSettings dialog to view new CC setup
Final cleanup and fix default values / bash arithmetic
Change-Id: Ie7525cfa1f8829bb037961a66620ab8664f39cec
German translation - Matthias Büchner
French translation - Sébastien Vaucher
diff --git a/prebuilt/common/bin/compcache b/prebuilt/common/bin/compcache
index ffadb3e..6c9a4f0 100755
--- a/prebuilt/common/bin/compcache
+++ b/prebuilt/common/bin/compcache
@@ -12,7 +12,7 @@
start)
echo 3 > /proc/sys/vm/drop_caches
modprobe $MODULE
- rzscontrol $DEV --init
+ rzscontrol $DEV --disksize_kb=$2 --init
swapon $DEV
;;
@@ -24,7 +24,7 @@
rzscontrol $DEV --stats
;;
*)
- echo "Usage: $0 {start|stop|stats}"
+ echo "Usage: $0 {start <size>|stop|stats}"
exit 1
esac
diff --git a/prebuilt/common/bin/handle_compcache b/prebuilt/common/bin/handle_compcache
index f7a249b..44ab0b7 100755
--- a/prebuilt/common/bin/handle_compcache
+++ b/prebuilt/common/bin/handle_compcache
@@ -3,6 +3,13 @@
# Compcache handler
# Decides whether or not Compcache is enabled
#
+MEMTOTAL=$( awk '{ if ($1 eq "MemTotal:") print $2 ;exit }' </proc/meminfo )
+
+if [ `getprop persist.service.compcache` == 1 ];
+then
+ PROP=`getprop ro.compcache.default`
+ setprop persist.service.compcache $PROP
+fi
if [ -e /data/property/persist.service.compcache ];
then
@@ -12,9 +19,10 @@
setprop persist.service.compcache $PROP
fi
-if [ $PROP == 1 ]
+if [ $PROP != 0 ]
then
- `dirname $0`/compcache start
+ CCSIZE=$(($(($MEMTOTAL * $PROP)) / 100))
+ `dirname $0`/compcache start $CCSIZE
else
`dirname $0`/compcache stop
fi