5,600,335 Members 34,989 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE][VRTheme-MOD][How-To] Make your TW VR-Theme flash on 4.4 and 4.3 from one zip

Tip us?
 
Droidmissionary
Old
(Last edited by Droidmissionary; 18th February 2014 at 01:50 AM.)
#1  
Droidmissionary's Avatar
Senior Member - OP
Thanks Meter 320
Posts: 660
Join Date: Apr 2012
Location: Tulsa, Ok
Default [GUIDE][VRTheme-MOD][How-To] Make your TW VR-Theme flash on 4.4 and 4.3 from one zip

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 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.

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

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

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(" ");
    ),
    (
        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");
		package_extract_dir("system4.3", "/system");
		run_program("/sbin/busybox", "umount", "/system"); 
		run_program("/sbin/busybox", "umount", "/data"); 
		run_program("/sbin/busybox", "umount", "/dalvik"); 
		run_program("/sbin/busybox", "umount", "/sdcard"); 
    )
);

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");
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

Click image for larger version

Name:	VRTheme.jpg
Views:	68
Size:	125.0 KB
ID:	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

Code:
#!/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/vrtheme4.3/apply/system/app
cd /sdcard/vrtheme4.3/system/app/
for f in $(ls)
do
  echo "Processing $f"
  cp /system/app/$f /sdcard/vrtheme4.3/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/vrtheme4.3/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/vrtheme4.3/apply/system/framework
cd /sdcard/vrtheme4.3/system/framework
for f in $(ls)
do
  echo "Processing $f"
  cp /system/framework/$f /sdcard/vrtheme4.3/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/vrtheme4.3/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/vrtheme4.3/apply/data/app
cd /sdcard/vrtheme4.3/data/app/
for f in $(ls)
do
  echo "Processing $f"
  cp /data/app/$f /sdcard/vrtheme4.3/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/vrtheme4.3/apply/system/app/
for f in $(ls)
do
  echo "Working on $f"
  cd /sdcard/vrtheme4.3/system/app/$f/
  /sdcard/vrtheme4.3/zip -r /sdcard/vrtheme4.3/apply/system/app/$f *
done
echo "Patched system files"

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

done
echo "Patched data files"
fi

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

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

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

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

# time to now move each new app back to its original location
cd /sdcard/vrtheme4.3/apply/system/app/aligned/
cp * /system/app/
chmod 644 /system/app/*
if [ "$dataapps" -eq "1" ]; then
cd /sdcard/vrtheme4.3/apply/data/app/aligned/
cp * /data/app/
chmod 644 /data/app/*
fi
if [ "$framework" -eq "1" ]; then
cd /sdcard/vrtheme4.3/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 @RockRatt
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
The Following User Says Thank You to Droidmissionary For This Useful Post: [ Click to Expand ]
 
Droidmissionary
Old
(Last edited by Droidmissionary; 21st February 2014 at 04:09 PM.)
#2  
Droidmissionary's Avatar
Senior Member - OP
Thanks Meter 320
Posts: 660
Join Date: Apr 2012
Location: Tulsa, Ok
If anyone has ideas for other scripts, let me know and I'll work with you to make it happen
The Following User Says Thank You to Droidmissionary For This Useful Post: [ Click to Expand ]
 
RockRatt
Old
#3  
RockRatt's Avatar
Recognized Contributor
Thanks Meter 3386
Posts: 3,750
Join Date: Aug 2010
Great job and Thanks for working this out for me so I didn't have to post two different zips for each theme. I just posted up the full 4.2/4.3--4.4.2 vr theme for a test on my thread. Hopefully I will get a few testers. Again Great job and Thank you

Sent From My Spiderman,Ironman,Red,Dark Blue,Green, GreyedOut BadAss Themed I337
The Following 2 Users Say Thank You to RockRatt For This Useful Post: [ Click to Expand ]
 
Droidmissionary
Old
#4  
Droidmissionary's Avatar
Senior Member - OP
Thanks Meter 320
Posts: 660
Join Date: Apr 2012
Location: Tulsa, Ok
Quote:
Originally Posted by RockRatt View Post
Great job and Thanks for working this out for me so I didn't have to post two different zips for each theme. I just posted up the full 4.2/4.3--4.4.2 vr theme for a test on my thread. Hopefully I will get a few testers. Again Great job and Thank you

Sent From My Spiderman,Ironman,Red,Dark Blue,Green, GreyedOut BadAss Themed I337
No problem buddy! I'll head over and grab a zip and test it out for ya, Thanks again for everything.
The Following User Says Thank You to Droidmissionary For This Useful Post: [ Click to Expand ]
Tags
4.4 / 4.3, theme, touchwiz, vrtheme
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes