Skip to content

Instantly share code, notes, and snippets.

@cgudea
Last active December 19, 2015 00:08
Show Gist options
  • Save cgudea/5866173 to your computer and use it in GitHub Desktop.
Save cgudea/5866173 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# 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
# (at your option) 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/>.
# system var paths
stat_bar_exp_head_xml='SystemUI/res/layout/status_bar_expanded_header.xml'
int_xml='SystemUI/res/values/integers.xml'
dims_xml='SystemUI/res/values/dimens.xml'
style_xml='SystemUI/res/values/styles.xml'
colors_xml='SystemUI/res/values/colors.xml'
stat_bar_xml='SystemUI/res/layout/status_bar.xml'
# Check if arguments are correctly given
if [ -z "$1" ]; then
echo "\nUSAGE: $0 <ARG>"
echo "For 4 quicksetting tiles, type: \n$0 qs\n"
echo "For center clock mod, type: \n$0 clock"
exit 1
fi
adb_state=$(./adb get-state)
# Check if device is connected
if [ "$adb_state" = "unknown" ]; then
echo "Your android device isn't connected, dummy!"
exit 1
fi
# Retrieve files from phone
./adb pull /system/framework/framework-res.apk
./adb pull /system/app/SystemUI.apk
# Make backup of systemUI if it doesn't exist
sysUIbak='SystemUI.apk.bak'
if [ ! -f $sysUIbak ]; then
cp SystemUI.apk $sysUIbak
fi
# Loading Framework
./apktool if framework-res.apk
# Decompile SystemUI
./apktool d SystemUI.apk
# Copy modded files into SystemUI folder
if [ "$1" = "clock" ]; then
mod_dir='ccmod'
echo "\nPerforming center clock mod\n"
cp $mod_dir/status_bar_expanded_header.xml $stat_bar_exp_head_xml
cp $mod_dir/status_bar.xml $stat_bar_xml
elif [ "$1" = "qs" ]; then
mod_dir='qsmod'
echo "\nPerforming quick settings mod\n"
# Files for Quick Settings Tile
cp $mod_dir/status_bar_expanded_header.xml $stat_bar_exp_head_xml
cp $mod_dir/integers.xml $int_xml
cp $mod_dir/dimens.xml $dims_xml
cp $mod_dir/styles.xml $style_xml
else
echo "\n-------------"
echo "\nUSAGE: $0 <ARG>"
echo "For 4 quicksetting tiles, type: \n$0 qs\n"
echo "For center clock mod, type: \n$0 clock"
# Clean up files
echo "\ncleaning up files and exiting..."
rm -rf SystemUI framework
rm framework-res.apk SystemUI.apk 2> /dev/null
exit 1
fi
# Final Assembly
./apktool b SystemUI/ SystemUI.apk
# Copy meta-inf and AndMani to apk
file-roller -e sui --force $sysUIbak
file-roller sui/META-INF/ sui/AndroidManifest.xml -a SystemUI.apk
adb_state=$(./adb get-state)
counter=0
# Check if device is connected
while [ "$adb_state" != "device" ]
do
echo "unable to connect to android device. attemping to reconnect..."
counter=$((counter+1))
sleep 1
if [ "$counter" -eq 10 ]; then
exit 1
fi
adb_state=$(./adb get-state)
done
# Mount system as writable
echo "\nattempting to mount /system/app as writable..."
./adb root
./adb shell mount -o remount,rw /dev/block/stl9 /system
./adb shell chmod 777 /system/app
# Push files and reboot
echo "\npushing SystemUI.apk to /system/app/"
./adb push SystemUI.apk /system/app/SystemUI.apk
echo "\nrebooting phone"
./adb reboot
# Clean up files
echo "\ncleaning up files..."
rm -rf SystemUI framework sui
rm framework-res.apk SystemUI.apk 2> /dev/null
echo "\n-------------"
echo "If you want to reset back to your original SystemUI, run:"
echo "./restore_SystemUI\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment