honeynet / droidbot

A lightweight test input generator for Android. Similar to Monkey, but with more intelligence and cool features!
MIT License
791 stars 230 forks source link

How do I know what exactly Droidbot did to the phone at any given time? #140

Open HongheZ opened 2 years ago

HongheZ commented 2 years ago

Hello, may I ask after running Droidbot, how do I know what Droidbot is doing to my phone at any given time? For example, if Droidbot cliacks a button, I want to know the button name and the date and time of this operation. I read user_input.txt, it seems only record the click operation happend, but does not record other details, such as the name of the button being clicked. Is there any other way I can get this information?

ThePearhead commented 2 years ago

Hi, take a look at the index.html in your browser. There you see the UTG, where one node represents a screen/activity and the edges represent the action, which was performed between the activities. When you click on the edge, you should see which button was clicked. I hope this helps!

Edit: unfortunately, date and time aren't recorded in the UTG

HongheZ commented 2 years ago

Hello, thank you so much for your reply! After I read the UTG, I have another question. In the command, I set the DroidBot to create 100 count event. However, in the UTG, I only see 38 edges(actions). What is the reason for this?

ThePearhead commented 2 years ago

Hi, I'm not completely sure about this, but I think that's the case when the same action which led to a specific activity is performed more than once. In this case, the edge is labeled with more than one number: e.g. "21, 73" on the edge means that event no. 21 and 73 performed the same action between the same activities. The counter in the UTG isn't increased, when the edge for this action is already present.

HongheZ commented 2 years ago

Thanks! And for UTG, is there a way to merge nodes with the same activity name into one and remove the extra edge? Which file I need to edit?

ThePearhead commented 2 years ago

The file for the UTG should be utg.js, which is also in your output directory. I'm not sure if this will work - I tried it and simply deleted some nodes in utg.js and the UTG shown in my browser via index.html looked weird after that (all edges were gone). I think that was because the changes I made caused some inconsistency in the UTG. But with more exact changes, it could work!

HongheZ commented 2 years ago

Got it. Thank you so much!

HongheZ commented 2 years ago

Hello! May I ask another question? The number on the edge of the UTG is the serial number of the event that the model created, is it right? But why are some of the numbers on the edges the same? For example, in one UTG I generated, there were two edges with serial number 17. But they represent two different events, one is clicking the button to jump to another interface, and the other is clicking the back button to jump back.

ThePearhead commented 2 years ago

Hi! I'm no developer of droidbot (i just used it pretty much in the last weeks), so I'm not sure if I can help you with this question. But when I look at my utgs I see the same behaviour - I never noticed that. But it's only when Droidbot leaves the app; one node is the homescreen. Perhaps because droidbot leaves the app, it doesn't count as an event? Just a guessing. Would be interesting in what cases you have those double-numbered edges - is it also only when Droidbot leaves your tested app?

HongheZ commented 2 years ago

Eh, no. Sometimes when it click button to jump one activity to another activity within the one app, it still has double-numbered edges.

HongheZ commented 2 years ago

Thank you so much all the same. I will have more try to figure it out.

ThePearhead commented 2 years ago

Eh, no. Sometimes when it click button to jump one activity to another activity within the one app, it still has double-numbered edges.

Hmmm, okay, that was the only idea i had for this. I'll look at my future utgs closer, perhaps I'll find another reason for this behaviour (or it's just a bug).

Thank you so much all the same. I will have more try to figure it out.

You're welcome! :)

ThePearhead commented 2 years ago

I took a closer look at my utgs and noticed some things (note: i always used 100 events, with different policies):

utg.js is the file for the UTG you see in index.html. at the end of this file, there is an interesting information, which isn't shown in index.html: num_effective_events Mostly I have something betwenn 70-80 effective events. An "ineffective" event could be Droidbot clicking on a component (e.g. a TextView), which doesn't affect the UI. This explains also, why we never have 100 edges or nodes. It seems clear now, but I didn't think of this at first. It would be great if this information would be shown in index.html.

Also, sometimes edges seem to be missed: e.g. edge no. 8 goes to a node, and the next edge to another node is labeled with 12 - 9, 10 and 11 are missing! This could also be caused by "ineffective" events.

I also noticed a bug in the cluster structure and cluster activity (which is also shown in index.html): in some utgs the nodes have the wrong screenshots linked, from another activity.

But: I still have no new idea for the problem with the same label...

HongheZ commented 2 years ago

These infromation is useful, thank you so much!