public class

Console

extends Thread
java.lang.Object
   ↳ java.lang.Thread
     ↳ com.android.tradefed.command.Console

Class Overview

Main TradeFederation console providing user with the interface to interact

Currently supports operations such as

  • add a command to test
  • list devices and their state
  • list invocations in progress
  • list commands in queue
  • dump invocation log to file/stdout
  • shutdown

Summary

Nested Classes
class Console.ArgRunnable<T> A Runnable with a run method that can take an argument  
class Console.CaptureList A convenience type for List<List<String>>  
Constants
String DEBUG_PATTERN
String DUMP_PATTERN
String EXIT_PATTERN
String HELP_PATTERN
String LIST_PATTERN
String REMOVE_PATTERN
String RUN_PATTERN
String SET_PATTERN
String VERSION_PATTERN
[Expand]
Inherited Constants
From class java.lang.Thread
Fields
protected static final String LINE_SEPARATOR
protected ConsoleReader mConsoleReader
protected ICommandScheduler mScheduler
Protected Constructors
Console()
Public Methods
static void main(String[] mainArgs)
void run()
The main method to launch the console.
void setArgs(List<String> mainArgs)
Sets the console starting arguments.
static void startConsole(Console console, String[] args)
Starts the given tradefed console with given args
Protected Methods
String getConsolePrompt()
String getGenericHelpString(List<String> genericHelp)
Return the generic help string to display
static ConsoleReader getReader()
Return a new ConsoleReader, or null if an IOException occurs.
void printLine(String output)
Display a line of text on console
void setCustomCommands(RegexTrie<Runnable> trie, List<String> genericHelp, Map<String, String> commandHelp)
A customization point that subclasses can use to alter which commands are available in the console.
[Expand]
Inherited Methods
From class java.lang.Thread
From class java.lang.Object
From interface java.lang.Runnable

Constants

protected static final String DEBUG_PATTERN

Constant Value: "debug"

protected static final String DUMP_PATTERN

Constant Value: "d(?:ump)?"

protected static final String EXIT_PATTERN

Constant Value: "(?:q|exit)"

protected static final String HELP_PATTERN

Constant Value: "\?|h|help"

protected static final String LIST_PATTERN

Constant Value: "l(?:ist)?"

protected static final String REMOVE_PATTERN

Constant Value: "remove"

protected static final String RUN_PATTERN

Constant Value: "r(?:un)?"

protected static final String SET_PATTERN

Constant Value: "s(?:et)?"

protected static final String VERSION_PATTERN

Constant Value: "version"

Fields

protected static final String LINE_SEPARATOR

protected ConsoleReader mConsoleReader

protected ICommandScheduler mScheduler

Protected Constructors

protected Console ()

Public Methods

public static void main (String[] mainArgs)

Throws
InterruptedException
ConfigurationException

public void run ()

The main method to launch the console. Will keep running until shutdown command is issued.

public void setArgs (List<String> mainArgs)

Sets the console starting arguments.

Parameters
mainArgs the arguments

public static void startConsole (Console console, String[] args)

Starts the given tradefed console with given args

Parameters
console the Console to start
args the command line arguments
Throws
InterruptedException
ConfigurationException

Protected Methods

protected String getConsolePrompt ()

Returns
  • the text String to display for the console prompt

protected String getGenericHelpString (List<String> genericHelp)

Return the generic help string to display

protected static ConsoleReader getReader ()

Return a new ConsoleReader, or null if an IOException occurs. Note that this function must be static so that we can run it before the superclass constructor.

protected void printLine (String output)

Display a line of text on console

protected void setCustomCommands (RegexTrie<Runnable> trie, List<String> genericHelp, Map<String, String> commandHelp)

A customization point that subclasses can use to alter which commands are available in the console.

Implementations should modify the genericHelp and commandHelp variables to document what functionality they may have added, modified, or removed.

Parameters
trie The RegexTrie to add the commands to
genericHelp A Console.CaptureList of lines to print when the user runs the "help" command with no arguments.
commandHelp A Map containing documentation for any new commands that may have been added. The key is a regular expression to use as a key for RegexTrie. The value should be a String containing the help text to print for that command.