Argus-SAF icon indicating copy to clipboard operation
Argus-SAF copied to clipboard

Question: Is there a way to retrieve corresponding widget for callback methods?

Open sangamk opened this issue 6 years ago • 9 comments

For the callbacks apk.model.getCallbackMethodsis there a way to find the layout widget that calls that method? If there is one ofcourse.

public void click(View view){
}
<button android:onClick="click"/>

or for:

findById(id).setOnClickListener

sangamk avatar Jun 18 '18 12:06 sangamk

Yes, the click method should be collected as callback method for getCallbackMethods.

fgwei avatar Jun 19 '18 03:06 fgwei

Yes but can I also find out which widget is linked to that method? So I want to find this -> <button android:onClick="click"/>

sangamk avatar Jun 19 '18 10:06 sangamk

I see. You cannot currently do that. But you can achieve that by modifying this file: https://github.com/arguslab/Argus-SAF/blob/68f87fd596a06f5a6b2f6a4303bbc709005df3cd/org.argus.amandroid/src/main/scala/org/argus/amandroid/core/parser/LayoutFileParser.scala

fgwei avatar Jun 20 '18 03:06 fgwei

For this ->

public void click(View view){
}
<button android:onClick="click"/>

I got it working.

However I can't find out how to find the buttonview (button2) for these kinds of methods ->

        Button b = findViewById(R.id.button2);
        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), ThirdActvity.class));
            }
        })

How would I go about doing this? Is there a way to see what view is passed on to the onClick method?

sangamk avatar Jun 20 '18 15:06 sangamk

Anyone?

sangamk avatar Jun 22 '18 21:06 sangamk

This onClick method will be automatically collected as a callback method for this component. To find the view binding you need to do a point-to analysis to figure out when setOnClickListener get called which button object it is called upon and what is the OnClickListener is been registered.

fgwei avatar Jun 22 '18 22:06 fgwei

Thx I will give it a try: To clarify I am only interested in the type of the widget that calls the method not its name. So android.widget.Button or android.widget.TextView

sangamk avatar Jun 22 '18 22:06 sangamk

You may use something like ExplicitValueFinder

fgwei avatar Jun 22 '18 22:06 fgwei

So I got it working for most of the callbackmethods. However, I am missing some information. Specifically for menu items and support views. Is there a reason that Menus and support views are not part of the layoutcontrol or is it a missing feature?

sangamk avatar Jun 28 '18 09:06 sangamk