forked from honeynet/droidbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add timeout of monkeyrunner connection
- Loading branch information
1 parent
98a7b6b
commit e31147c
Showing
3 changed files
with
118 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This file contains the main class of droidbot | ||
# It can be used after AVD was started, app was installed, and adb had been set up properly | ||
# By configuring and creating a droidbot instance, | ||
# droidbot will start interacting with Android in AVD like a human | ||
|
||
__author__ = 'liyc' | ||
import logging | ||
from types import App, Device | ||
from app_env import AppEnvManager | ||
from app_event import AppEventManager | ||
from connection import TelnetException, ADBException, MonkeyRunnerException | ||
|
||
|
||
class DroidBot(object): | ||
""" | ||
The main class of droidbot | ||
A robot which interact with Android automatically | ||
""" | ||
|
||
def __init__(self, options): | ||
""" | ||
initiate droidbot with configurations | ||
:param options: the options which contain configurations of droidbot | ||
:return: | ||
""" | ||
self.logger = logging.getLogger('DroidBot') | ||
self.options = options | ||
|
||
def start(self): | ||
""" | ||
start interacting | ||
:return: | ||
""" | ||
try: | ||
device = Device(self.options.device_serial) | ||
app = App(self.options.package_name, self.options.app_path) | ||
except TelnetException as te: | ||
# allow telnet not connected | ||
self.logger.exception(te) | ||
|
||
env_manager = AppEnvManager(device, app, self.options.env_policy) | ||
event_manager = AppEventManager(device, app, self.options.event_policy, self.options.event_count) | ||
|
||
env_manager.deploy() | ||
event_manager.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters