honeynet / droidbot

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

Feature: Start application, if not running #4

Closed hannoL closed 9 years ago

hannoL commented 9 years ago

Error 6.1 - can't start activity

If the app is not started yet, droidbot can't start the application. It looks like droidbot try to open it with:

INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}

But nothing happen. I think it would be good to start the app automatically if not running. Or is that a Bug?

Can you reproduce this? Or did you need any further information?

Envirement:

hanno@dockerDroidBox:~/work/PycharmProjects/gsoc_droidbot$ python start.py -d emulator-5554 -a ~/mobileSamples/myApkTresor/0xA1EA512A.apk
Connecting to a device with serialno=emulator-5554 with a timeout of 60 secs...
Connected to device with serialno=emulator-5554
Actual device serialno=emulator-5554
INFO:TelnetConsole:telnet successfully initiated, the addr is (localhost:5554)
INFO:AppEnvManager:start deploying environment, policy is none
INFO:AppEnvManager:finish deploying environment, policy is none
INFO:AppEventManager:start sending events, policy is monkey
INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}
INFO:Device:sending event: {'intent': 'am broadcast -a android.intent.action.BATTERY_CHANGED', 'type': 'intent'}
INFO:Device:sending event: {'event_type': 'key', 'name': 'MENU'}
INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}
INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}
INFO:Device:sending event: {'intent': 'am broadcast -a android.intent.action.PICK_ACTIVITY', 'type': 'intent'}
INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}
INFO:Device:sending event: {'intent': 'am broadcast -a android.intent.action.BOOT_COMPLETED', 'type': 'intent'}
INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}
INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}
INFO:Device:sending event: {'intent': 'am broadcast -a android.intent.action.POWER_USAGE_SUMMARY', 'type': 'intent'}
INFO:Device:sending event: {'intent': u'am start com.ctf.hack_lu', 'type': 'intent'}
INFO:Device:sending event: {'intent': 'am broadcast -a android.intent.action.PACKAGE_ADDED', 'type': 'intent'}
^CTraceback (most recent call last):
  File "start.py", line 59, in <module>
    main()
  File "start.py", line 54, in main
    droidbot.start()
  File "/home/hanno/work/PycharmProjects/gsoc_droidbot/droidbot/droidbot.py", line 57, in start
    event_manager.start()
  File "/home/hanno/work/PycharmProjects/gsoc_droidbot/droidbot/app_event.py", line 596, in start
    self.event_factory.start(self)
  File "/home/hanno/work/PycharmProjects/gsoc_droidbot/droidbot/app_event.py", line 624, in start
    time.sleep(event_manager.duration)
KeyboardInterrupt
yuanchun-li commented 9 years ago

Usually, apps can be started by calling "am start ." However, some apps require calling "am start / " to start. Use the later version of command line should solve this issue. Does this work for you?

adepasquale commented 9 years ago

This alternative method to start the app is interesting, have you ever tried it? http://stackoverflow.com/questions/4567904/how-to-start-an-application-using-android-adb-tools/25398877#25398877

yuanchun-li commented 9 years ago

Cool, this method doesn't require main activity name. I tried it just now and it works.

hannoL commented 9 years ago

Now it works fine. I think you fix that in 866657a.