[TOOL] Public ID Converter

Search This thread

loserskater

Inactive Recognized Developer
Jun 6, 2008
2,160
4,433
Palmdale, CA
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
When you come across this you know that you have to search the public.xml of the apk you're porting from and the public.xml of the apk you're porting to in order to find the correct reference. This can get overwhelming when you have multiple references.
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)
  1. 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.
  2. Open this app and select the files (can be opened for GUI or run from command line)
  3. Convert the smali file
  4. 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
  5. 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

daZgOYQ.png


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
 

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    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
    When you come across this you know that you have to search the public.xml of the apk you're porting from and the public.xml of the apk you're porting to in order to find the correct reference. This can get overwhelming when you have multiple references.
    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)
    1. 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.
    2. Open this app and select the files (can be opened for GUI or run from command line)
    3. Convert the smali file
    4. 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
    5. 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

    daZgOYQ.png


    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
    4
    Update to 0.2
    Use regex when searching smali.
    Remove custom search and add option for framework.
    2
    Winnerskater! nice job man. looks awessssssoooooommeeee!
    2
    awesome tool sir :good: :D

    thankyou for share, gonna try soon :D

    Have you used it yet? Any feedback?
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone