Blissify
diff --git a/tools/slim_process_props.py b/tools/bliss_process_props.py
similarity index 97%
rename from tools/slim_process_props.py
rename to tools/bliss_process_props.py
index 373ba31..6a49380 100755
--- a/tools/slim_process_props.py
+++ b/tools/bliss_process_props.py
@@ -34,7 +34,7 @@
         new_lcd = lcd_changer.get(lcd, lcd)
     if new_lcd != '':
         prop.put('persist.sys.lcd_density', new_lcd)
-        prop.put('ro.slim.lcd_density', new_lcd)
+        prop.put('ro.bliss.lcd_density', new_lcd)
 
 
 def mangle_build_prop(prop):
diff --git a/tools/build.sh b/tools/build.sh
new file mode 100644
index 0000000..495018d
--- /dev/null
+++ b/tools/build.sh
@@ -0,0 +1,181 @@
+#!/bin/bash
+
+#    BlissPop  Compilation Script
+#
+#    Copyright (C) 2015 Team Bliss
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# No scrollback buffer
+echo -e '\0033\0143'
+
+
+
+# Get intial time of script startup
+res1=$(date +%s.%N)
+
+
+
+# Specify colors for shell
+red='tput setaf 1'              # red
+green='tput setaf 2'            # green
+yellow='tput setaf 3'           # yellow
+blue='tput setaf 4'             # blue
+violet='tput setaf 5'           # violet
+cyan='tput setaf 6'             # cyan
+white='tput setaf 7'            # white
+txtbld=$(tput bold)             # Bold
+bldred=${txtbld}$(tput setaf 1) # Bold red
+bldgrn=${txtbld}$(tput setaf 2) # Bold green
+bldblu=${txtbld}$(tput setaf 4) # Bold blue
+bldcya=${txtbld}$(tput setaf 6) # Bold cyan
+normal='tput sgr0'
+
+
+tput bold
+tput setaf 1
+clear
+echo -e ""
+echo -e "      ___           ___                   ___           ___              "
+echo -e "     /\  \         /\__\      ___        /\  \         /\  \             "
+echo -e "    /::\  \       /:/  /     /\  \      /::\  \       /::\  \            "
+echo -e "   /:/\:\  \     /:/  /      \:\  \    /:/\ \  \     /:/\ \  \           "
+echo -e "  /::\~\:\__\   /:/  /       /::\__\  _\:\~\ \  \   _\:\~\ \  \          "
+echo -e " /:/\:\ \:|__| /:/__/     __/:/\/__/ /\ \:\ \ \__\ /\ \:\ \ \__\         "
+echo -e " \:\~\:\/:/  / \:\  \    /\/:/  /    \:\ \:\ \/__/ \:\ \:\ \/__/         "
+echo -e "  \:\ \::/  /   \:\  \   \::/__/      \:\ \:\__\    \:\ \:\__\           " 
+echo -e "   \:\/:/  /     \:\  \   \:\__\       \:\/:/  /     \:\/:/  /           "  
+echo -e "    \::/__/       \:\__\   \/__/        \::/  /       \::/  /            "
+echo -e "     ~~            \/__/                 \/__/         \/__/             "
+echo -e ""
+echo -e ""
+echo -e ""
+echo -e ""
+echo -e ""
+
+sleep 3s
+
+
+# Confirm 'repo sync'
+echo -e "\n\n${bldgrn}  Do you want to repo sync before proceeding?\n"
+echo ""
+echo -e "${bldblu}  1. Yes"
+echo -e "${bldblu}  2. No"
+echo ""
+echo ""
+$normal
+read askreposync
+
+# Confirm 'make clean'
+echo -e "\n\n${bldgrn}  Do you want to make clean?\n"
+echo ""
+echo -e "${bldblu}  1. Yes"
+echo -e "${bldblu}  2. No"
+echo ""
+echo ""
+$normal
+read askClean
+
+echo ""
+echo ""
+if [ "$askreposync" == "1" ]
+then
+    echo -e "${bldred}  Will repo sync before starting the build... "
+else
+    echo -e "${bldred}  Will continue without repo syncing... "
+fi
+echo ""
+echo ""
+
+echo ""
+echo ""
+
+if [ "$askClean" == "1" ]
+then
+    echo -e "${bldred}  Compilation will continue after cleaning previous build files... "
+else
+    echo -e "${bldred}  ROM will be compiled without cleaning previous build files... "
+fi
+echo ""
+echo ""
+
+echo ""
+echo ""
+
+
+sleep 2s
+
+
+if [ "$askreposync" == "1" ]
+then
+	echo ""
+	echo ""
+	echo -e "${bldgrn}  syncing... "
+	echo ""
+	echo ""
+	$normal
+	repo sync -j250
+fi
+
+if [ "$askClean" == "1" ]
+then
+	echo ""
+	echo ""
+	echo -e "${bldgrn}  Cleaning before starting build... "
+	echo ""
+	echo ""
+	$normal
+	rm -rf out
+fi
+
+# Setup environment
+echo -e ""
+echo -e ""
+echo -e "${bldgrn}  Setting up build environment..."
+echo -e ""
+echo -e ""
+$normal
+. build/envsetup.sh
+
+
+# Lunch device
+echo -e ""
+echo -e ""
+echo -e "${bldcya}  Choose your device from the lunch menu..."
+echo -e ""
+echo -e ""
+$normal
+$green
+lunch
+
+# Start compilation
+echo -e ""
+echo -e ""
+echo -e "${bldcya}  Starting compilation BlissPop..."
+echo -e ""
+echo -e ""
+$normal
+mka bacon
+echo -e ""
+
+
+
+# Compilation complete
+tput bold
+tput setaf 1
+echo -e ""
+echo -e "The build process has finished"
+echo -e ""
+echo -e ""
diff --git a/tools/changelog b/tools/changelog
new file mode 100755
index 0000000..2ee6e3b
--- /dev/null
+++ b/tools/changelog
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Exports
+
+. $ANDROID_BUILD_TOP/vendor/bliss/tools/colors
+
+export Changelog=CHANGELOG-bliss.txt
+
+if [ -f $Changelog ];
+then
+	rm -f $Changelog
+fi
+
+touch $Changelog
+
+# Print something to build output
+echo ${bldppl}"Generating changelog..."${txtrst}
+
+for i in $(seq 5);
+do
+export After_Date=`date --date="$i days ago" +%m-%d-%Y`
+k=$(expr $i - 1)
+	export Until_Date=`date --date="$k days ago" +%m-%d-%Y`
+
+	# Line with after --- until was too long for a small ListView
+	echo '====================' >> $Changelog;
+	echo  "     "$Until_Date       >> $Changelog;
+	echo '===================='	>> $Changelog;
+	echo >> $Changelog;
+
+	# Cycle through every repo to find commits between 2 dates
+	repo forall -pc 'git log --oneline --after=$After_Date --until=$Until_Date' >> $Changelog
+	echo >> $Changelog;
+done
+
+sed -i 's/project/   */g' $Changelog
+
+cp $Changelog $OUT/system/etc/
+rm $Changelog
diff --git a/tools/colors b/tools/colors
new file mode 100755
index 0000000..b653210
--- /dev/null
+++ b/tools/colors
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+if [ ! "$BUILD_WITH_COLORS" = "0" ]; then
+    red=$(tput setaf 1)             #  red
+    grn=$(tput setaf 2)             #  green
+    ylw=$(tput setaf 3)             #  yellow
+    blu=$(tput setaf 4)             #  blue
+    ppl=$(tput setaf 5)             #  purple
+    cya=$(tput setaf 6)             #  cyan
+    txtbld=$(tput bold)             #  Bold
+    bldred=${txtbld}$(tput setaf 1) #  red
+    bldgrn=${txtbld}$(tput setaf 2) #  green
+    bldylw=${txtbld}$(tput setaf 3) #  yellow
+    bldblu=${txtbld}$(tput setaf 4) #  blue
+    bldppl=${txtbld}$(tput setaf 5) #  purple
+    bldcya=${txtbld}$(tput setaf 6) #  cyan
+    txtrst=$(tput sgr0)             #  Reset
+    rev=$(tput rev)                 #  Reverse color
+    pplrev=${rev}$(tput setaf 5)
+    cyarev=${rev}$(tput setaf 6)
+    ylwrev=${rev}$(tput setaf 3)
+    blurev=${rev}$(tput setaf 4)
+fi
diff --git a/tools/opticharger b/tools/opticharger
new file mode 100755
index 0000000..a869c6c
--- /dev/null
+++ b/tools/opticharger
@@ -0,0 +1,163 @@
+#!/bin/bash
+#
+# Super-mega LiquidSmooth opticharger of doom
+# Shrinks apks by running pngquant or pngcrush or optipng or pngout on png images
+#
+
+. $ANDROID_BUILD_TOP/vendor/bliss/tools/colors
+
+OUT_TARGET_HOST=$(uname -a | grep Darwin)
+if [ -z "$OUT_TARGET_HOST" ]
+then
+    OUT_TARGET_HOST=linux-x86
+else
+    OUT_TARGET_HOST=darwin-x86
+fi
+
+set -e
+QUIET=1
+BASE=`pwd`
+BRUTECRUSH="-brute"
+TMPDIR=/tmp/opticharge-$$
+
+if [ -z "$BRUTE_PNGCRUSH" ]
+then
+    BRUTECRUSH=""
+fi
+
+if [ "$APKCERTS" = "" ];
+then
+    if [ "$TARGET_BUILD_VARIANT" = "userdebug" ]; then
+       TARGET_BUILD_VARIANT="eng"
+    elif [ "$TARGET_BUILD_VARIANT" = "user" ]; then
+       TARGET_BUILD_VARIANT="eng"
+    fi
+
+    APKCERTS=$OUT/obj/PACKAGING/target_files_intermediates/$TARGET_PRODUCT-target_files-$TARGET_BUILD_VARIANT.$USER/META/apkcerts.txt
+    if [ ! -f "$APKCERTS" ];
+    then
+        echo -e ${red}"Set APKCERTS to the path to your apkcerts.txt file"${txtrst}
+        exit 1;
+    fi
+fi
+
+if [ ! -f "$APKCERTS" ];
+then
+    echo -e ${red}"Invalid path to apkcerts.txt, set APKCERTS to the correct path."${txtrst}
+fi
+
+if [ "$(which pngquant)" != "" ];
+then
+    optimize_png () {
+        pngquant --speed 1 --force --ext .png $1 1> /dev/null 2> /dev/null
+    }
+elif [ "$(which pngcrush)" != "" ];
+then
+    optimize_png () {
+        pngcrush -q ${BRUTECRUSH} $1 ${1}.out 1> /dev/null 2> /dev/null
+        mv ${1}.out ${1} 2> /dev/null
+    }
+elif [ "$(which optipng)" != "" ];
+then
+    optimize_png () {
+        optipng -o7 -quiet $1 1> /dev/null 2> /dev/null
+    }
+elif [ "$(which pngout-static)" != "" ];
+then
+    optimize_png () {
+        pngout-static $1
+    }
+elif [ "$(which pngout)" != "" ];
+then
+    optimize_png () {
+        pngout $1
+    }
+else
+    echo -e ${red}"Please install pngquant, pngcrush, optipng, or pngout"${txtrst}
+    exit 1;
+fi
+
+if [ "`which aapt`" = "" ];
+then
+    echo -e ${red}"Please ensure aapt is in your \$PATH"${txtrst}
+    exit 1;
+fi
+
+if [ "`which zipalign`" = "" ];
+then
+    echo -e ${red}"Please ensure zipalign is in your \$PATH"${txtrst}
+    exit 1;
+fi
+
+if [ -e "$1" ];
+then
+    NAME=`basename $1`;
+    echo -e ${bldgrn}"Optimizing:${txtrst} $NAME...";
+
+    if [ "$2" != "" ];
+    then
+        if [ "$DEFAULT_SYSTEM_DEV_CERTIFICATE" ]; then
+            CERT_PATH=`dirname $DEFAULT_SYSTEM_DEV_CERTIFICATE`
+        else
+            CERT_PATH=build/target/product/security
+        fi
+        CERT="$CERT_PATH"/$2.x509.pem
+        KEY="$CERT_PATH"/$2.pk8
+        if [ ! -f "$ANDROID_BUILD_TOP/$CERT" ];
+        then
+            echo -e ${red}"$CERT does not exist!"${txtrst};
+            exit 1;
+        fi
+    else
+        APKINFO=`grep "name=\"$NAME\"" $APKCERTS`;
+        [ $QUIET ] || echo -e "APKINFO: $APKINFO";
+        if [ "$APKINFO" = "" ];
+        then
+            echo -e ${red}"No apk info for $NAME"${txtrst};
+            exit 1;
+        fi
+        CERT=`echo -e $APKINFO | awk {'print $2'} | cut -f 2 -d "=" | tr -d "\""`;
+        KEY=`echo -e $APKINFO | awk {'print $3'} | cut -f 2 -d "=" | tr -d "\""`;
+        if [ "$CERT" = "" ];
+        then
+            echo -e ${red}"Unable to find certificate for $NAME"${txtrst}
+            exit 1;
+        fi
+        if [ "$CERT" = "PRESIGNED" ];
+        then
+            echo -e ${cya}"$NAME is presigned, skipping"${txtrst}
+            exit 1;
+        fi
+    fi
+
+    [ $QUIET ] || echo -e ${bldylw}"Certificate:${txtrst} $CERT";
+
+    [ -d $TMPDIR/$NAME ] && rm -rf $TMPDIR/$NAME
+    mkdir -p $TMPDIR/$NAME
+    trap "rm -rf $TMPDIR; exit" INT TERM EXIT
+    cd $TMPDIR/$NAME
+    unzip -q $BASE/$1
+    for x in `find . -name "*.png" | grep -v "\.9.png$" | tr "\n" " "`
+    do
+        [ $QUIET ] || echo -e ${bldgrn}"Crushing${txtrst} $x"
+        optimize_png $x
+    done
+    cp $BASE/$1 $BASE/$1.old
+
+    [ $QUIET ] || echo -e ${bldgrn}"Repacking apk.."${txtrst}
+    aapt p -0 .dat -0 .dict -0 .arsc -F $NAME .
+
+    [ $QUIET ] || echo -e ${bldgrn}"Resigning with cert:${txtrst} `echo -e $CERT`"
+
+    [ $QUIET ] || echo java -jar $ANDROID_HOST_OUT/framework/signapk.jar $ANDROID_BUILD_TOP/$CERT $ANDROID_BUILD_TOP/$KEY $NAME signed_$NAME
+    java -jar $ANDROID_HOST_OUT/framework/signapk.jar $ANDROID_BUILD_TOP/$CERT $ANDROID_BUILD_TOP/$KEY $NAME signed_$NAME
+    [ $QUIET ] || echo -e ${bldgrn}"Zipalign.."${txtrst}
+    zipalign -f 4 signed_$NAME $BASE/$1
+    if [ ! $QUIET ]; then
+        ls -l $BASE/$1.old
+        ls -l $BASE/$1
+    fi
+    rm $BASE/$1.old
+else
+    echo -e "Usage: $0 [apk file]"
+fi
diff --git a/tools/otaxml b/tools/otaxml
new file mode 100755
index 0000000..d0849fe
--- /dev/null
+++ b/tools/otaxml
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Exports
+
+. $ANDROID_BUILD_TOP/vendor/bliss/tools/colors
+
+export otaxml=ota${BLISS_OTA_XMLVER}.xml
+
+if [ -f $otaxml ];
+then
+  rm -f $otaxml
+fi
+
+cp vendor/bliss/ota.xml $otaxml
+
+touch $otaxml
+
+BLISS_OTA_MD5=$(cat "$OUT/$BLISS_OTA_VERNAME.zip.md5sum" | cut -d ' ' -f 1)
+BLISS_OTA_FILESIZE=$(ls -la "$OUT/$BLISS_OTA_VERNAME.zip" | cut -d ' ' -f 5)
+
+sed -i "s/BLISS_OTA_ROM/${BLISS_OTA_ROM}/g" $otaxml
+sed -i "s/BLISS_OTA_VERNAME/${BLISS_OTA_VERNAME}/g" $otaxml
+sed -i "s/BLISS_OTA_VERSION/${BLISS_OTA_VER}/g" $otaxml
+sed -i "s|BLISS_OTA_URL|${BLISS_OTA_URL}|g" $otaxml
+sed -i "s/BLISS_OTA_MD5/${BLISS_OTA_MD5}/g" $otaxml
+sed -i "s/BLISS_OTA_FILESIZE/${BLISS_OTA_FILESIZE}/g" $otaxml
+sed -i "s/BLISS_DEVELOPER/${BLISS_DEVELOPER}/g" $otaxml
+sed -i "s|BLISS_DONATE|${BLISS_DONATE}|g" $otaxml
+
+cp $otaxml $OUT/
+rm $otaxml
+
+echo ${bldppl}"ota.xml generated."${txtrst}
diff --git a/tools/squisher b/tools/squisher
new file mode 100755
index 0000000..20f5f9c
--- /dev/null
+++ b/tools/squisher
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# Squish a CM otapackage for distribution
+# cyanogen
+
+. $ANDROID_BUILD_TOP/vendor/bliss/tools/colors
+
+OUT_TARGET_HOST=`uname -s`
+if [ x"$OUT_TARGET_HOST" = x"Linux" ]
+then
+   OUT_TARGET_HOST=linux-x86
+   XARGS="xargs --max-args=1 --max-procs `grep 'processor' /proc/cpuinfo|wc -l`"
+elif [ x"$OUT_TARGET_HOST" = x"Darwin" ]
+then
+   OUT_TARGET_HOST=darwin-x86
+   XARGS="xargs -n 1 -P `sysctl hw.ncpu | awk '{print $2}'`"
+else
+   echo -e ${red}"ERROR: unknown/unsupported host OS!"${txtrst}
+   exit 1
+fi
+
+if [ -z "$OUT" -o ! -d "$OUT" ]; then
+	echo -e ${red}"ERROR: $0 only works with a full build environment. $OUT should exist."${txtrst}
+	exit 1
+fi
+
+OPTICHARGER=$ANDROID_BUILD_TOP/vendor/bliss/tools/opticharger
+QUIET=-q
+DELETE_BINS="applypatch applypatch_static check_prereq recovery updater"
+
+# Optimize PNG resources in APKs
+( cd $OUT/system; find framework/ app/ priv-app/ vendor/app/ -name \*.apk -print | $XARGS $OPTICHARGER; )
+
+exit 0