Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different generated code for console and gui version #430

Closed
bagipro opened this issue Jan 15, 2019 · 2 comments
Closed

Different generated code for console and gui version #430

bagipro opened this issue Jan 15, 2019 · 2 comments

Comments

@bagipro
Copy link
Collaborator

bagipro commented Jan 15, 2019

Hi, I run jadx with the following arguments

jadx.bat --no-replace-consts --show-bad-code --threads-count 4 --deobf --deobf-min 2 --no-imports --output-dir WISH com.contextlogic.wish_2018-12-19.apk

and get method in com.contextlogic.wish.activity.BaseFragment

    public A getBaseActivity() {
        return (com.contextlogic.wish.activity.BaseActivity) getLifecycleActivity(); // this method is never declared and doesn't exist
    }

but gui version with generates correct code

    public A getBaseActivity() {
        return (BaseActivity) getActivity();
    }

APK: https://drive.google.com/file/d/1Eit8ZcYI9OTboOnDCA3cil_6E6gkqxN-/view?usp=sharing

@bagipro
Copy link
Collaborator Author

bagipro commented Jan 15, 2019

And one more thing in the same class

    public void withActivity(com.contextlogic.wish.activity.BaseFragment.ActivityTask<A> activityTask) {
        com.contextlogic.wish.activity.BaseActivity baseActivity = getBaseActivity(); // returns A
        if (baseActivity != null) {
            activityTask.performTask(baseActivity);
        }
    }

shouldn't baseActivity object has A type, but not com.contextlogic.wish.activity.BaseActivity? Because if you grep where that method is called, you will see e.g

    class C42772 implements com.contextlogic.wish.activity.BaseFragment.ActivityTask<com.contextlogic.wish.activity.webview.WebViewActivity> {

        public void performTask(com.contextlogic.wish.activity.webview.WebViewActivity webViewActivity) {
            //...
        }
    }

so the parameter type is not BaseActivity

@skylot
Copy link
Owner

skylot commented Jan 16, 2019

I made a fix. The root of the problem is #336. There I made a rename of method wrapped by the synthetic method to restore its original name in some cases. In this app such renaming was done in method com.google.android.gms.common.api.internal.zzcc.getLifecycleActivity():

.method public final synthetic getLifecycleActivity()Landroid/app/Activity;
    .locals 1
    invoke-virtual {p0}, Lcom/google/android/gms/common/api/internal/zzcc;->getActivity()Landroid/support/v4/app/FragmentActivity;
    move-result-object v0
    return-object v0
.end method

and zzcc.getActivity() method resolved to android.support.v4.app.Fragment.getActivity() and this method was renamed to getLifecycleActivity.
CLI and GUI difference occur because of different class processing order, i.e if zzcc class not processed then method is not renamed. Order will be same if in GUI you run decompilation without clicking any classes.
In the fix I allow rename only for methods from the same class, I think it is the correct solution. Also, this will be not dependent on class processing order, so there are will be no difference between CLI and GUI.

About different type: you are right there must be A type and it must be fixed, but it is not very critical because any A type will extends a BaseActivity class as declared here:

public abstract class BaseFragment<A extends com.contextlogic.wish.activity.BaseActivity> extends android.support.v4.app.Fragment {

so WebViewActivity also extends BaseActivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants