[AT&T Samsung Galaxy S 4 Themes and Apps] Droidmissionary:
Android Version Check for Touch Wiz VR-Theme Install on 4.4 & 4.3 Based Roms

As you may know, since Android has updated to 4.4 KK, some files have been moved to new folders and file names have been changed making it a pain to install your old TW 4.3 VR-Theme on a 4.4 Rom. The main change I've seen is the addition of System/Priv-App. I'm going to show you how to make a script to put into your updater-script to check which version of Android the user is running, and how to modify the files so that it will install either, the files for a 4.4 based rom theme, or a 4.3 and earlier based rom theme all from the same zip. This essentially requires a 4.4 theme and your original 4.3 theme but will auto detect which one needs flashed. It will not convert your 4.3 to a 4.4 theme.

The files we will need to alter are:

Updater-script

VRtheme Folder itself (will be duplicated and one renamed)

Installtheme.sh (located inside VRTheme folder will also be renamed and modified in the duplicated folder)

System and Data apps (If your using them, will need to be duplicated and renamed)

Let's get started!

You can do these in any order but I'll go through it the way it all played out in my brain!

First, In the 4.4 VRtheme zip, I modified the updater script-located in META-INF/com/google/android/updater-script

by adding a Rom detection code just after the "mount" process, see RED text

If the user is running a 4.4 Rom the code will skip down to the bottom and install the theme files for 4.4, See the bottom Red text

None of these files need to be changed as long as you set up the original VRtheme folders to install the 4.4 theme. Just add your themed files into the folders as normal and it will flash

*IF* the code detects user is not running 4.4 (setup to work with anything other than 4.4 at this time so it will flash to 4.3,4.2 etc.)

It will complete the ifelse statement with what you instruct it to do. Which, in this case, we tell it to extract and install vrtheme4.3 and the installtheme4.3.sh which are the duplicated and renamed VRtheme folder and installtheme.sh file. See Blue Text

run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
run_program("/sbin/busybox", "mount", "/dalvik");

[COLOR="Red"]ui_print(" Version Check For Theme Install");
ui_print(" By DroidMissionary");
ui_print("");
ui_print(" Checking Android Version");
# Check build version so we know which theme package to install 4.4 or earlier
ifelse(
is_substring("4.4", file_getprop("/system/build.prop","ro.build.version.release")),
(
ui_print(" Android 4.4 ROM detected");
ui_print(" Applying 4.4 Theme");
ui_print(" ");
),[/COLOR]
[COLOR="Blue"] (
ui_print(" *** Pre 4.4 Rom Detected ***");
ui_print(" ");
ui_print(" Applying 4.3 and Earlier Theme");
ui_print(" ");
ui_print(" Theming In Process");
ui_print(" ");
package_extract_dir("vrtheme4.3", "/sdcard/vrtheme4.3");
set_perm(0, 0, 0755, "/sdcard/vrtheme4.3/installtheme4.3.sh");
set_perm(0, 0, 0755, "/sdcard/vrtheme4.3/zip");
set_perm(0, 0, 0755, "/sdcard/vrtheme4.3/cleanup.sh");
set_perm(0, 0, 0755, "/sdcard/vrtheme4.3/zipalign");
run_program("/sdcard/vrtheme4.3/installtheme4.3.sh");
run_program("/sdcard/vrtheme4.3/cleanup.sh");
[COLOR="DarkOrange"]package_extract_dir("system4.3", "/system");[/COLOR]
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/busybox", "umount", "/dalvik");
run_program("/sbin/busybox", "umount", "/sdcard");
)
);
[/COLOR]
[COLOR="Red"]package_extract_dir("vrtheme", "/sdcard/vrtheme");
set_perm(0, 0, 0755, "/sdcard/vrtheme/installtheme.sh");
set_perm(0, 0, 0755, "/sdcard/vrtheme/zip");
set_perm(0, 0, 0755, "/sdcard/vrtheme/cleanup.sh");
set_perm(0, 0, 0755, "/sdcard/vrtheme/zipalign");
run_program("/sdcard/vrtheme/installtheme.sh");
run_program("/sdcard/vrtheme/cleanup.sh");
package_extract_dir("system", "/system");
package_extract_dir("data", "/data");
ui_print("Additional files copied");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");
run_program("/sbin/busybox", "umount", "/dalvik");
run_program("/sbin/busybox", "umount", "/sdcard");
ui_print("Thanks for using VillainTheme Flasher");[/COLOR]

Second, I opened the 4.3/4.2 Theme and renamed the VRTheme folder to VRtheme4.3.

Do this also for the system and data folders if you are using them, in this case only system was used so I renamed it to system4.3

The modified system folder is called out in the Blue section above. See orange text ABOVE for the 4.3 system folder call out.

After you have them renamed, add them into you main zip file with the original VTtheme folders that contain the 4.4 theme.

This will keep them separated and allow you to call them out individually in the install-script and installtheme.sh

View attachment 2585670

From here, I opened VrTheme4.3 folder and renamed installtheme.sh to installtheme4.3.sh. This way I would know which one it's for

Now that it is renamed, we need to go in and modify sections of the installtheme.sh that call out for the VRTheme folder. Since this is for the 4.3 theme, we will locate these call outs and simply add 4.3 to the end of VRTheme through-out the file. See Green Text for modified names

#!/sbin/sh
# Copyright VillainROM 2011. All Rights Reserved
# cleanup from last time
[ -d /sdcard/vrtheme-backup ] && rm -r /sdcard/vrtheme-backup

# we need to first go through each file in the "app" folder, and for each one present, apply the modified theme to the APK
# let us copy each original APK here first.
echo "Processing /system/app/"
busybox mkdir -p /sdcard/vrtheme-backup/system/app
busybox mkdir -p /sdcard/[COLOR="Green"]vrtheme4.3[/COLOR]/apply/system/app
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/system/app/
for f in $(ls)
do
echo "Processing $f"
cp /system/app/$f /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/app/
cp /system/app/$f /sdcard/vrtheme-backup/system/app/
done
echo "Backups done for system apps"

# repeat for /system/framework now

[ -d /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/system/framework ] && framework=1 || framework=0

if [ "$framework" -eq "1" ]; then
echo "Processing /system/framework"
busybox mkdir -p /sdcard/vrtheme-backup/system/framework
busybox mkdir -p /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/framework
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/system/framework
for f in $(ls)
do
echo "Processing $f"
cp /system/framework/$f /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/framework/
cp /system/framework/$f /sdcard/vrtheme-backup/system/framework/
done
echo "Backups done for frameworks"
fi

# repeat for /data/app now

[ -d /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/data ] && dataapps=1 || dataapps=0

if [ "$dataapps" -eq "1" ]; then
echo "Processing /data/app/"
busybox mkdir -p /sdcard/vrtheme-backup/data/app
busybox mkdir -p /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/data/app
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/data/app/
for f in $(ls)
do
echo "Processing $f"
cp /data/app/$f /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/data/app/
cp /data/app/$f /sdcard/vrtheme-backup/data/app/
done
echo "Backups done for data apps"
fi

# for each of the system apps needing processed
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/app/
for f in $(ls)
do
echo "Working on $f"
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/system/app/$f/
/sdcard/[COLOR="Green"]vrtheme4.3[/COLOR]/zip -r /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/app/$f *
done
echo "Patched system files"

if [ "$dataapps" -eq "1" ]; then
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/data/app/
for f in $(ls)
do
echo "Working on $f"
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/data/app/$f/
/sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/zip -r /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/data/app/$f *

done
echo "Patched data files"
fi

if [ "$framework" -eq "1" ]; then
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/framework
for f in $(ls)
do
echo "Working on $f"
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/system/framework/$f/
/sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/zip -r /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/framework/$f *
done
echo "Patched framework files"
fi

# and now time to zipalign
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/app/
busybox mkdir aligned
for f in $(ls)
do
echo "Zipaligning $f"
/sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/zipalign -f 4 $f ./aligned/$f
done

if [ "$dataapps" -eq "1" ]; then
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/data/app/
busybox mkdir aligned
for f in $(ls)
do
echo "Zipaligning $f"
/sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/zipalign -f 4 $f ./aligned/$f
done
fi

if [ "$framework" -eq "1" ]; then
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/framework/
busybox mkdir aligned
for f in $(ls)
do
echo "Zipaligning $f"
/sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/zipalign -f 4 $f ./aligned/$f
done
fi

# time to now move each new app back to its original location
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/app/aligned/
cp * /system/app/
chmod 644 /system/app/*
if [ "$dataapps" -eq "1" ]; then
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/data/app/aligned/
cp * /data/app/
chmod 644 /data/app/*
fi
if [ "$framework" -eq "1" ]; then
cd /sdcard/[COLOR="green"]vrtheme4.3[/COLOR]/apply/system/framework/aligned/
cp * /system/framework/
chmod 644 /system/framework/*
fi

# Do not remove the credits from this, it's called being a douche
echo "VillainTheme is done"
# we are all done now

That is it! After you have the 4.3 folders in place, renamed, and the install script/installtheme.sh calling out the correct folders, you are ready to flash!

Feel free to use any of my script in your theme zips, please just give credit and leave thanks​

Problems I ran into myself

The theme failed to install immediately upon starting to flash: My file was breaking when I unzipped the original, modified the files, and then re-zipped for some reason, to correct it, I modified the files then opened the original zip with 7zip file manager without un-zipping it, and pushed my files into the original zip overwriting the original. This allowed the original to flash with my modified files. It was acting like an improper signature on a decompiled/compiled apk.

Theme claimed it had installed but went quickly through the process and nothing installed:I need to modify the installtheme.sh to call out the proper 4.3 folders

I'd Like to give thanks to firstly, the most important factor [MENTION=2799235]RockRatt[/MENTION]

He allowed me to use his 4.4 theme template to build this Mod and is currently Helping me get my start in theming

All the Rom Devs

VRtheme system for the theme system of course

and

The XDA-Community

**Notes**

I am new to programming/ theming, really everything besides reading and replying to posts.

If you see an error or have a way to clean up or make things better please let me know, I'm always looking to improve​

Generic theme zip containing the Updater-script and Installtheme.sh - This theme zip is not however fully setup for installing on multiple platforms so just pull the two files and build your theme as shown in this post.

https://www.dropbox.com/s/ico5e9ouh15cu0d/MissionaryThemeScripts.zip