diff options
Diffstat (limited to 'chimpchat/src/com/android/chimpchat/ChimpChat.java')
-rw-r--r-- | chimpchat/src/com/android/chimpchat/ChimpChat.java | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/chimpchat/src/com/android/chimpchat/ChimpChat.java b/chimpchat/src/com/android/chimpchat/ChimpChat.java index 71684c9..1927535 100644 --- a/chimpchat/src/com/android/chimpchat/ChimpChat.java +++ b/chimpchat/src/com/android/chimpchat/ChimpChat.java @@ -17,12 +17,44 @@ package com.android.chimpchat; +import com.android.chimpchat.adb.AdbBackend; +import com.android.chimpchat.core.IChimpBackend; + import java.util.Map; +/** + * ChimpChat is a host-side library that provides an API for communication with + * an instance of Monkey on a device. This class provides an entry point to + * setting up communication with a device. Currently it only supports communciation + * over ADB, however. + */ public class ChimpChat { - private final Map<String, String> options; + private final IChimpBackend mBackend; + + private ChimpChat(IChimpBackend backend) { + this.mBackend = backend; + } + + /** + * Generates a new instance of ChimpChat based on the options passed. + * @param options a map of settings for the new ChimpChat instance + * @return a new instance of ChimpChat or null if there was an issue setting up the backend + */ + public static ChimpChat getInstance(Map<String, String> options) { + IChimpBackend backend = ChimpChat.createBackendByName(options.get("backend")); + if (backend == null) { + return null; + } + ChimpChat chimpchat = new ChimpChat(backend); + return chimpchat; + } + - public ChimpChat(Map<String, String> options) { - this.options = options; + public static IChimpBackend createBackendByName(String backendName) { + if ("adb".equals(backendName)) { + return new AdbBackend(); + } else { + return null; + } } } |