Console

public class Console
extends Thread

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


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 INVOC_PATTERN

String LIST_COMMANDS_PATTERN

String LIST_PATTERN

String REMOVE_PATTERN

String RUN_PATTERN

String SET_PATTERN

String VERSION_PATTERN

Fields

protected static final String LINE_SEPARATOR

protected ConsoleReader mConsoleReader

protected IKeyStoreFactory mKeyStoreFactory

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 printLine(String output, PrintStream pw)

Print the line to a Printwriter

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.

Constants

DEBUG_PATTERN

String DEBUG_PATTERN

Constant Value: "debug"

DUMP_PATTERN

String DUMP_PATTERN

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

EXIT_PATTERN

String EXIT_PATTERN

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

HELP_PATTERN

String HELP_PATTERN

Constant Value: "\?|h|help"

INVOC_PATTERN

String INVOC_PATTERN

Constant Value: "i(?:nvocation)?"

LIST_COMMANDS_PATTERN

String LIST_COMMANDS_PATTERN

Constant Value: "c(?:ommands)?"

LIST_PATTERN

String LIST_PATTERN

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

REMOVE_PATTERN

String REMOVE_PATTERN

Constant Value: "remove"

RUN_PATTERN

String RUN_PATTERN

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

SET_PATTERN

String SET_PATTERN

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

VERSION_PATTERN

String VERSION_PATTERN

Constant Value: "version"

Fields

LINE_SEPARATOR

String LINE_SEPARATOR

mConsoleReader

ConsoleReader mConsoleReader

mKeyStoreFactory

IKeyStoreFactory mKeyStoreFactory

mScheduler

ICommandScheduler mScheduler

Protected constructors

Console

Console ()

Public methods

main

void main (String[] mainArgs)

Parameters
mainArgs String

Throws
InterruptedException
ConfigurationException

run

void run ()

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

setArgs

void setArgs (List<String> mainArgs)

Sets the console starting arguments.

Parameters
mainArgs List: the arguments

startConsole

void startConsole (Console console, 
                String[] args)

Starts the given Tradefed console with given args

Parameters
console Console: the Console to start

args String: the command line arguments

Throws
InterruptedException
ConfigurationException

Protected methods

getConsolePrompt

String getConsolePrompt ()

Returns
String the text String to display for the console prompt

getGenericHelpString

String getGenericHelpString (List<String> genericHelp)

Return the generic help string to display

Parameters
genericHelp List: a list of String representing the generic help to be aggregated.

Returns
String

getReader

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.

Returns
ConsoleReader

printLine

void printLine (String output)

Display a line of text on console

printLine

void printLine (String output, 
                PrintStream pw)

Print the line to a Printwriter

Parameters
pw PrintStream

setCustomCommands

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 RegexTrie: The RegexTrie to add the commands to

genericHelp List: A List of lines to print when the user runs the "help" command with no arguments.

commandHelp Map: 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.