Public ID Converter
What is it?
If you've ever messed with smali files you have probably come across a line like this:
Code:
const v0, 0x7f040001
This tool will easily replace all public.xml references in a smali file with the public.xml you're porting to.
How to use it:
(As of now, this tool will not add anything to the public.xml)
- The decompiled apk must have all of the neccessary resource files added to the public.xml.
You can do this by adding the resources(drawables, strings, ids, etc.) and then compiling the apk. Then decompile the new apk and copy the public.xml. - Open this app and select the files (can be opened for GUI or run from command line)
- Convert the smali file
- The new modified file will be at the same location of the original smali file with the same name but with "-MODIFIED" appended to it
- If it was unable to find the reference in either public.xml it will add the word MISSING so you can easily search the smali file after.
Example:
Everything going smoothly:
Smali:
Code:
const v0, 0x7f040001
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
Source public.xml:
Code:
<public type="xml" name="pref_lockscreen" id="0x7f040001" />
Port public.xml:
Code:
<public type="xml" name="pref_lockscreen" id="0x7f041234" />
New modified smali:
Code:
const v0, 0x7f041234 # type="xml" name="pref_lockscreen"
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
Everything going poorly:
Smali:
Code:
const v0, 0x7f040001
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
const v0, 0x7f040002
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
const v0, 0x7f040003
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
Source public.xml:
Does not contain 0x7f040003
Code:
<public type="xml" name="pref_display" id="0x7f040001" />
<public type="xml" name="pref_lockscreen" id="0x7f040002" />
<public type="xml" name="pref_navigation_bar" id="0x7f040004" />
Port public.xml:
Does not contain type="xml" name="pref_lockscreen"
Code:
<public type="xml" name="pref_display" id="0x7f041234" />
<public type="xml" name="pref_navigation_bar" id="0x7f041235" />
New modified smali:
Code:
const v0, 0x7f041234 # type="xml" name="pref_display"
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
const v0, 0x7f040002 # MISSING: type="xml" name="pref_lockscreen"
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
const v0, 0x7f040003 # MISSING: Not found in source public.xml
invoke-virtual {p0, v0}, Lcom/example/SettingsActivity;->addPreferencesFromResource(I)V
Notes:
- It is recommended that you convert the source smali file before trying to port any code to your apk. This will avoid issues of searching the source public.xml for an already correct id and replacing it with an incorrect one.
- I've added the ability for this to be run with a GUI or from the command line. The command line arguments are as follows:
Code:
usage: public_id_convert f[ind] [options] <source public.xml> <source smali> public_id_convert c[onvert] [options] <source public.xml> <source smali> <port public.xml> -f Search for framework IDs
Download:
https://github.com/loserskater/PublicIDConverter/releases
Source:
https://github.com/loserskater/PublicIDConverter
XDA:DevDB Information
Public ID Converter, Tool/Utility for all devices (see above for details)
Contributors
loserskater
Source Code: https://github.com/loserskater/PublicIDConverter
Version Information
Status: Testing
Created 2015-03-25
Last Updated 2015-03-25