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/CHANGELOG.mkdn b/CHANGELOG.mkdn
index 15d9bc1..808a1bb 100644
--- a/CHANGELOG.mkdn
+++ b/CHANGELOG.mkdn
@@ -62,6 +62,7 @@
 * N1/Bravo/Supersonic: FM Radio support - MIUI - http://miui.com (graphics from Fitsnugly and HaXzAmaTiC)
 * N1/DS/Hero - Slightly better Gallery3D orientation fix - Jonas Larsson
 * N1/DS - Kernel 2.6.35 based on Pershoot's repository
+* DS: CompCache sizes can be adjusted through CMParts - Wes Garner
 * Supersonic - Kernel 2.6.34 courtesy of Toast and Madcoder
 * Bravo: Kernel 2.6.35
 * Espresso: Improve backlights - Wes Garner
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
diff --git a/products/cyanogen_dream_sapphire.mk b/products/cyanogen_dream_sapphire.mk
index 018b386..48f7b69 100644
--- a/products/cyanogen_dream_sapphire.mk
+++ b/products/cyanogen_dream_sapphire.mk
@@ -33,7 +33,7 @@
 
 # Enable Compcache by default on D/S
 PRODUCT_PROPERTY_OVERRIDES += \
-    ro.compcache.default=1
+    ro.compcache.default=25
 
 #
 # Set ro.modversion