: [Tutorial/Mod] Replace god modewithOwnership Mode" / Edit any APK's MikRuny 1.03


trkaaa
19-02-2012, 05:11 PM
Tutorial for replacing the name god mode with the actual function name Ownership mode or Get Ownership mode

And Editing APKs implemented on MikTweaks




Other Posts Links


[ guide ] Successful S-OFF using htc dev Unlock for GB or ICS after non proper Wrong S-ON with Security Warning ( the Only known working method ) link is here (http://forum.xda-developers.com/showthread.php?p=21922297#post21922297) ( Sensation )




Solve WiFi Errors , Radio Flashing Problem , Caused by htc Dev Unlock Method , link is here (http://forum.xda-developers.com/showthread.php?p=21924999#post21924999) ( Sensation )


Credit

, ,
, ( )


content


Tutorial for Editing APKs implemented on MikTweaks
Mod for Mikrunny World v1.0.3 Rom, see Ownership Mode a.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906722&stc=1&d=1329516104),Ownership Mode b.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906723&stc=1&d=1329516104)
This tutorial can be used with any custom Rom to Edit an APK ( Settings , tweaks , MikTweaks , RCMix Tweaks , etc ) in about 5 ~ 10 min in the first time , and no more 3~5 min afterwards



Mod


this Mod is for htc Incredible 2 ( VIVOW )
You can use the tutorial to Create your own Mod for htc Sensation or htc Incredible or any device with similar tweaks APK
This Mod is for Mikrunny World v1.0.3 ( maybe works with v1.0.2 ) Rom MikTweaks ( it functions normal as is , it only changed the displayed string name , Note that some functions need to download components in order to work )
This Mod for MikTweaks will restores the string god mode into its actual full development name Ownership mode or Get Ownership mode , which is more relevant development wise


Download Links


Mod Replacing name to Ownershiop Mode or Ownershiop Mode ( Flashable zip ) , For Manual replacement extract the files from within the Mod

https://rapidshare.com/files/2937232704/MikRunny_World_1.03_MikTweaks_Rename_to_ _Ownership.zip
http://www.mediafire.com/download.php?tqqbk38uzbwd0du





All photo attachments and permissions photos

https://rapidshare.com/files/636497641/All_attached_and_Permissions_Photos.zip
http://www.mediafire.com/download.php?8s8ansudq9owmtm
Or Download attached Zip







NB : Please feel free to PM me regarding any Questions and help in modifying similar APK for other Custom Roms or Rom Version for your own use



if you created your own similar Mod for a Different Custom Rom or Rom Version , PM me to add it in Post # 2




DISCLAIMER
I am not responsible if following this Method results in bricking your phone
Whatever you do is at your Own Risk






Tutorial

replacing the name god mode with the actual function name Ownership mode or Get Ownership mode
And Editing APKs implemented on MikTweaks


General


this Tutorial is split into two Parts ( Due to Post length limitation )
I tried to make this tutorial Noob Proof ( for those with little computer skills ) as much as possible , so it is a bit long
This tutorial is implemented on MikTweaks , and can be applied for any custom Rom you use that includes ( MikTweaks , RCMix Tweaks or any similar tweak ) to restore the name god mode into its actual full development name Ownership mode or Get Ownership mode , see Ownership Mode a.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906722&stc=1&d=1329515947) , Ownership Mode b.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906723&stc=1&d=1329515947)
This tutorial can also be used for editing the APK of your choice



Editing an APK means ( decompile decompress the apk , edit xml and smali files , recompile the apk ) , and then sign the APK or zip file .
Please note that editing an apk without decompiling it first , will cause FC ( force Close )



Required tools and Links ( All Free )


Press on any text displayed in orange color to open the associated link ( web page , or Download link ) , always download latest software versions from those websites
Notepad ++ { to view and edit xml files and smali } , links for Notepad ++ web Page (http://notepad-plus-plus.org/) and Notepad ++ installer v5.9.8 (http://download.tuxfamily.org/notepadplus/5.9.8/npp.5.9.8.Installer.exe) ( 5 MB )
apktool { to decompile Decompress and recompile recompress APK files } , apktool web page (http://code.google.com/p/android-apktool/) , Download links forWindows users ( 4 MB) :

Download apktool-* file (http://code.google.com/p/android-apktool/downloads/detail?name=apktool1.4.3.tar.bz2&can=2&q=)( for All operating systems )
and apktool-install-windows-* file (http://code.google.com/p/android-apktool/downloads/detail?name=apktool-install-windows-r04-brut1.tar.bz2&can=2&q=) ( Linux and mac users should choose appropriate file )
Unpack both zip files to the Same directory
Java Runtime Environment should be installed JRE (http://java.com/en/download/index.jsp) or manually choose JRE (http://java.com/en/download/manual.jsp) for any Operating systems or offline installation


Zipsigner 2 ( NOT Zipsigner ) { to sign APKs and Zip files } , Download Zipsigner 2 (https://market.android.com/details?id=kellinwood.zipsigner2)from Android market
Windows Grep ( Optional ) { to seach all files inside an entire directory for a word } , ( in options you can change the editor to be Notepad++ ) , DownloadWindows Grep (http://www.wingrep.com/download.htm)( less than one MB )



tips for using cmd window


you dont need to write full path for the folder , just drag the folder from within my computer or Desktop to the cmd window and the path will be written automatically
also for names just copy a name and right click the toolbar of cmd window then choose edit then Paste , see att 1 - cmd Copy&Paste - apktools folder.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906643&stc=1&d=1329512723)
You can use up and down arrows to toggle the previously used commands instead of writing them again
Press enter after typing any of the following commands



Steps


1. decompiling Decompress the APK


here you can find a more detailed information , Procedure , and solve errors (http://www.miui-au.com/add-ons/apktool/)
Open your Rom zip in a winrar window and drag the following files to your desktop ( or extract the zip file and find the files ) :

Framework-res.apk located in System \ framework
Tweaks ( or xxxtweaks according to how each rom name it ) located in System \ app
For certain APKs ( like settings apk ) you will need to extract also com.htc.resources.apk and/or SystemUI.apk ( But this is not needed for tweaks apk )
Extract both apktool-* file and apktool-install-windows-* to the same folder and rename it to apktools and put it in the root of Drive C: ( it includes 3 files aapt.exe , apktool.bat , apktool.jar
Copy both Framework-res.apk and Tweaks.apk ( i.e MikTweaks, RCMixTweaks , ???tweaks etc ) inside apktools folder , see att 1 - cmd Copy&Paste - apktools folder.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906643&stc=1&d=1329512723)


Go to windows start menu \ Accessories \ cmd , Right click it and choose run as administrator
In cmd window Navigate to apktools folder by typing the following : cd c:\apktools ( or type cd followed by a space then drag the folder apktools to cmd window ) , you should see this c:\apktools>
Now to decompile (for example tweaks.apk ) , see att 2 - cmd decompile & recompile.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906644&stc=1&d=1329512723) , type the following :

Type apktool if framework-res.apk
Type apktool d tweaks.apk ( dont forget to add .apk )
Use the exact same original APK name ( case sensitive upper or lower case ) , to avoid typing mistake use cmd copy and paste . Otherwise after editing and signing the apk and try to over-write the original apk , it will not replace the original apk and both APKs will be there
If you want to over-right the created folder , use apktool d -f tweaks.apk , or delete the created folder and use apktool d tweaks.apk to create it again
A new folder is created with the same name of the Tweak ( i.e tweaks , ???tweaks , etc ) inside c:\apktools , see att 1 - cmd Copy&Paste - apktools folder.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906643&stc=1&d=1329512723)
The apk is now decompiled
( this is not needed for tweaks apk ) , For certain APKs ( like settings apk ) that requires for example com.htc.resources.apk you will need to add it to apktools folder and execute apktool if com.htc.resources.apk





2. Edit xml and smali Files


Install Notepad++ and put a shortcut at the desktop
Four files to be modified :

open the 4 following files together with Notepad++ by dragging each file to Notepad++ shortcut at the desktop
system_prefs.xml , located in C:\apktools\MikTweaks\res\xml\
SystemActivity.smali , located in C:\apktools\MikTweaks\smali\com\themikmi k\tweaks\system
SystemActivity$15.smali , located in C:\apktools\MikTweaks\smali\com\themikmi k\tweaks\system
godmode.bin located in your Rom zip inside System \bin


Use any PC explorer and navigate into c:\apktools\tweaks then do a search for word including god . open the files found in the search ( just drag them into Notepad++ shortcut on the desktop)
In Notepad++ press Ctl +F to open search window , type god and press find all in all open Documents , the results will be shown at the bottom of the notepad++ window , Double click any line of them and it will move you to its xml file
Replace the string god with the string ownership or Get Ownership as follows :

Double click any line of them and it will move you to its xml file , only replace the highlighted strings
system_prefs.xml : for Android : title ( replace with ownership or Get Ownership ) , for Android : key (replace with ownership to read ownershipmod_command ) , see att 3 - system_prefs.xml.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906645&stc=1&d=1329512723)
SystemActivity.smali : replace with ownership to read ownershipmod_command , see att 4 - systemActivity.smali.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906646&stc=1&d=1329512723)
SystemActivity$15.smali : for line const-string v2 ( replace with ownership or Get Ownership ) , for line const-string v1 ( replace with ownership to read ownershipmod_command ) , see att 5a - systemActivity$15.smali.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906647&stc=1&d=1329512723) , att 5b - systemActivity$15.smali.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906648&stc=1&d=1329512723)
godmode.bin : inside the filereplace with ownershipmode , see att 6 - Ownership Mode.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906649&stc=1&d=1329512723)
godmode.bin : rename the file itself to ownershipmode.bin ( this file is edited and placed separately )


if needed for other APKs , you can use Windows Grep to seach all files inside an entire directory for a certain word ( in options you can change the editor to be Notepad++ )



3. Re-compiling compress the APK


Run cmd as administrator , in cmd window Navigate to apktools folder by typing the following : cd c:\apktools ( or type cd followed by a space then drag the folder apktools to cmd window ) , you should see this c:\apktools> , see att 2 - cmd decompile & recompile.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906644&stc=1&d=1329512723)
Type apktool b tweaks ( dont add .apk )
Use the exact same original APK name ( case sensitive upper or lower case ) , to avoid typing mistake use cmd copy and paste . Otherwise after editing and signing the apk and try to over-write the original apk , it will not replace the original apk and both APKs will be there
two new folder are created inside apktools \ tweaks folder :

A folder named Build , it includes the decompiled files with the saved changes
A folder named dist , it includes the new modified apk ( not signed yet )


If you want to over-right the created folder , use apktool b -f tweaks , or delete the two created folders and use apktool b tweaks to create them again



4. Signing the APK


Install Zipsigner 2 on your phone , note that the compiled APK is not signed yet
Create a folder on your sd card name it for example sign apk and zip , Copy the modified compiled APK to that folder
Start Zipsigner 2 and leave all settings as it is defaults , press choose in/out and navigate to the compiled APK for example tweaks and select it , then press sign the File , a massage will tell you that the file is signed ,
Go to folder sign apk and zip and you will find the signed apk named as ( tweaks-signed.apk ) , copy ( tweaks-signed.apk ) to other location and rename it to ( tweaks.apk ) exactly as the original compiled apk
The apk is now ready to replace the original one located in system \ app

zip )

the /system folder can be anything you need ( in our case MikTweaks.apk and ownershipmode.bin ) , to add different items for your update you should then if needed modify Updater Script accordingly ,
update-binary , updater-script are needed to let the zip file to be flashable zip ( update.zip ) , For backward compatibility reasons, it's still possible to also add an update-script file.
updater-script is where you put the required commands to be executed during flashing the zip

trkaaa
19-02-2012, 05:22 PM
Part 2 of the tutorial ( the tutorial is split into two Parts due to limitation of Post size )


السلام عليكم و رحمه الله و بركاته , ارجو من احد الاخوه الافاضل ان يقوم بترجمه هذا النص للعربيه لكي تعم الفائده , و جزاه الله خيرا



5.Apply the changes

Applying the changes can be done by either of the following two methods :


Create a MOD and Apply it from recovery
Manually by moving both the APK and bin file
Manually by moving both the APK and bin file inside the Custom Rom Zip before installing it

a) Using Manual Replacement


The modified apk is now compiled and signed and ready to replace the original one located in system \ app
Make sure that the modified APK has the exact same original APK name , Otherwise it will not replace the original apk and both APKs will be there
Set system to read\write using Root Explorer or the original tweak itself ( open tweak then go to system tab , and choose mount system reaed/ write )
Use Root Explorer or any similar apk to review permission and ownership values before over-writing the required APK or bin file

Over-write the Apk or file and correct permission and ownership values to the same values for the original APK or bin file MikTweaks Permissions.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=907481&stc=1&d=1329556070) , MikTweaks Owner.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=907482&stc=1&d=1329556070) ( values are different for other similar tweaks ).
For ownershipmode.bin file , navigate to system \ bin , review permission and ownership values before deleting godmode.bin, then delete godmode.bin and copy ownershipmod.bin inside system \ bin , and correct permission and ownership values to the same values for the original file Ownershipmode Permissions.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=907483&stc=1&d=1329556070) , Ownershipmode Owner.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=907484&stc=1&d=1329556070) ( values are different for other similar tweaks )

b) Using MOD Replacement


Put the flashable zip ( MOD ) in your SD Card , Reboot into recovery
Clear dalvik and Cache , use install zip from SD Card , navigate to the file and install it then reboot



6.signing Zip file ( create your own MOD )


For future versions of tweaks apk , your can edit the new APK and use the attached MOD, just over-write the existing files with yours , and flash it
the following , see att 7 - Update.zip Structure.jpg (http://forum.xda-developers.com/attachment.php?attachmentid=906650&stc=1&d=1329512723) , is the layout for the update.zip , In general you can create a folder with the same attached structure
Create a folder let us call it Work , Create two folders inside it (META-INF , system ) according to the above attached structure ,
Add both update-binary and updater-script inside folder META-INF \ com \ google\ Android ,
Add the files you want to update inside System folder ( use the same structure as in the original Rom),
highlight both of the two folders (META-INF , system ) then right click then choose send to then compressed folder ( Dont compress the Work folder itself ) , rename the created zip as you prefer
Place prepared zip file on your SD Card and use the same procedure mentioned in Step no 4 (Signing the APK ) and in Step no 5 B ( Using MOD Replacement )

General Notes

+- META-INF/
+- MANIFEST.MF
+- CERT.SF
+- CERT.RSA
...........................com/
.....................................goo gle/
........................................ .........android/
........................................ .......................update-script
........................................ .......................update-binary
........................................ .......................updater-script
+- system/
.................app/
.........................MikTweaks.apk
..................bin/
.........................ownershipmode.b in


Note that the structure of META-INF ( name is case sensitive , as in above att 7 ) is always the same ( MANIFEST.MF , CERT.SF , CERT.RSA are created during singing the flashable zip )
the /system folder can be anything you need ( in our case MikTweaks.apk and ownershipmode.bin ) , to add different items for your update you should then if needed modify Updater Script accordingly ,
update-binary , updater-script are needed to let the zip file to be flashable zip ( update.zip ) , For backward compatibility reasons, it's still possible to also add an update-script file.
updater-script is where you put the required commands to be executed during flashing the zip

7. Adding your own Similar Mod or APK here in Post # 2


you can Add your own Similar Mod of Modified APK here in Post # 2 ( For Different Custom Rom or Different Version of a Rom ) , Please PM me


Press the thanks Button for this Post

---------- Post added at 05:22 PM ---------- Previous post was at 05:16 PM ----------

Place you Own Similar Modfor different Custom Roms and Rom Versions here