[Android Apps and Games] kitecarl:
OSX / Shell specific instructions for Miui Toggle2G installation

Hi everyone, here at last are my notes and general instructions for getting Toggle 2G up and running successfully on MIUI. Note that if you follow my instructions, you do so at your own risk!!! I will provide any help/guidance/clarification if requested, but it's your phone not mine so don't blame me if things go wrong :rolleyes:

My suggestion here is to perform this on a CLEAN ROM INSTALL, in other words just after flashing your Miui distribution of choice. Personally I use the excellent SCI Miui for Desire HD by a user (you can find it on the DHD Android Development forum). I tend to flash every week since, well, I'm a flashaholic :) Part of the fun of having an Android phone!

Note these instructions were pretty much ripped off directly from TheMasterBaron's batch file included in the OP, just customized to work running manually from the terminal. Here we go:

1) Prerequisites on your Mac / Linux PC - install adb following Google's android documentation, and also make sure java is installed and working fine. Java should be in your system PATH so that you can invoke java.exe from any directory. I installed adb in the following directory:

/users/Carl/androidsdk/platform-tools

I have to simply "cd" to the above to run adb. Of course I could add this directory to my PATH if I felt like it.

Download the resignRom ZIP file linked in this thread's OP, and extract all files to the directory where you installed adb. Please make sure to extract all files here - otherwise the below steps will not work.

2) As stated above, I recommend doing this after a fresh Miui installation. If you're already on a Miui distribution and want to upgrade, use the excellent built in backup utility to back up personal settings, phone logs, sms, applications, etc etc. It couldn't be simpler, and built right into Miui - since I'm going to stay with Miui, my previously trusty backup utility, TitaniumBackup, goes unused now since I like the full integration of Miui backup. So, make sure you have the new Miui flashable ZIP file ready to go on your SD Card, since we'll be going on out to ClockworkMod from here..

3) Reboot into CWM. I would backup in CWM your current ROM - that way you can CWM restore if something goes wrong.

4) Now, get flashing! Wipe data/factory settings, wipe cache, advanced - > wipe dalvik cache, you know all the usual wipe stuff. I also downloading a FULL WIPE ZIP file for DHD that does an extra clean wipe of NAND and internal memory. Figured it doesn't hurt - and cleans up any relics of old ROMs.

5) After the new ROM is flashed, reboot your phone via CWM and importantly let the new ROM settle in with one successful boot. Once boot is complete, don't do anything (add accounts, etc) - just let it boot successfully, then reboot once again into Recovery to proceed...

6) Once back in CWM, connect your phone to your computer via the USB cable, and then go to Mounts and Storage, and choose mount /system.

7) On your computer, open up Terminal and then cd to your android home directory. We're ready to go...

8) From the terminal prompt, run the below.

mkdir SystemAppOld <enter>

mkdir SystemAppNew <enter>

mkdir SystemFrameworkOld <enter>

mkdir SystemFrameworkNew <enter>

adb pull /system/app SystemAppOld <enter>

adb pull /system/framework SystemFrameworkOld <enter>

This creates new temporary directories for where the original and modified .apk files will be stored, and then pulls the old .apks from your phone to your PC so that they can be re-certified.

9) Ok, ready to re-cert! Again, type the below.

cd SystemAppOld <enter>

for i in *.apk <enter>

do <enter>

java -jar ../SignApk.jar ../security/platform.x509.pem ../security/platform.pk8 $i ../SystemAppNew/$i <enter>

done <enter>

This will take a few minutes since there are quite a few .apk files in /system/app. Once complete you'll be back at a blinking prompt awaiting the next command.

cd ../SystemFrameworkOld <enter>

for i in *.apk <enter>

do <enter>

java -jar ../SignApk.jar ../security/platform.x509.pem ../security/platform.pk8 $i ../SystemFrameworkNew/$i <enter>

done <enter>

System Framework re-certing is much quicker (for me at least) since there was only one .apk file found in my distribution, framework-res.apk

10) If you're curious, you can cd to SystemFrameworkNew and SystemAppNew and you'll see that there are newly created (and re-certified) .apk files in those directories.

11) Now cd back again to the adb home directory. Time to push the new files back to your phone, and also push Toggle2G.apk to the phone, and then finally wiping Dalvik cache.

adb remount <enter>

adb push SystemAppNew /system/app <enter>

adb push SystemFrameworkNew /system/framework <enter>

adb push Toggle2G.apk /system/app <enter>

adb shell rm -rf /system/sd/dalvik-cache <enter>

12) All done with adb now. On your phone, in CWM, go to Mounts and storage and then choose Unmount /system. While still in CWM, go to Advanced, then Fix Permissions, and then finally go to Wipe data/factory reset. While I'm not 100% sure these two things are necessary, it doesn't hurt. Just listing what I had to do to have 100% success.

13) Unplug your phone from the USB cable, and then Reboot through CWM. After the ROM boots up you should now see Toggle2G installed and ready to use. Configure and customize the ROM as usual, such as restoring from Miui Backup, adding Google account login, etc.

Good luck! If this was helpful to you, please hit the Thanks button.