skylot / jadx

Dex to Java decompiler
Apache License 2.0
42.02k stars 4.9k forks source link

[feature] Find usage for external functions #1115

Open AndnixSH opened 3 years ago

AndnixSH commented 3 years ago

Currently, you can't find usage of any functions of PackageInfo, like getPackageManager()

image

But on Android Studio, you can.

Is it possible to implement that on Jadx so I can see if there is more functions that uses PackageInfo?

jpstotz commented 3 years ago

At the moment Jadx only tracks classes that are present in the APK itself. AndroidStudio in difference has access to the Android SDK and the Android.jar that contains the classes of the Android API for the selected API level.

The only way for Jadx to be able to track class to non-existing classes would be to generate "phantom classes" for classes and methods that are used/called but do not exist in the APK. Such classes would be invisible regarding the class tree, could not be opened via Ctrl+click on the class name but could be used for finding references.

@skylot Do you think a "PhantomClass" JNode would be feasible?

skylot commented 3 years ago

@jpstotz I don't think we need to generate any "phantom classes" we just need to attach code annotations for method reference (MethodInfo in jadx code) and next collect usage for them. It fits quite good in current codebase, I just wonder how much memory it will cost. Also, we can add a similar feature for classes and fields references.

AndnixSH commented 3 years ago

Oh, thanks guys for info. I figured you can search, but this still would be neat