Transport Emulator console commands

Stay organized with collections Save and categorize content based on your preferences.

Each running virtual device provides a console that lets you lot query and command the emulated device surroundings. For case, yous can utilise the console to manage port redirection, network characteristics, and telephony events while your app is running on the emulator.

The following commands crave that you already have an emulator running. For more data virtually running an emulator, see Run Apps on the Android Emulator and Start the Emulator from the Command Line.

Start and stop a console session

To admission the panel and enter commands, from a terminal window, utilise telnet to connect to the panel port and provide your authentication token. Each fourth dimension the panel displays OK, it'due south set to accept commands. It doesn't accept a typical prompt.

To connect to the console of a running virtual device:

  1. Open a terminal window and enter the post-obit command:
  2. telnet localhost                      console-port                    

    The emulator window title lists the console port number. For example, the window title for an emulator using console port 5554 could be Nexus_5X_API_23:5554. Likewise, the adb devices control prints a list of running virtual devices and their console port numbers. For more information, run into Querying for Emulator/Device Instances.

    Note: The emulator listens for connections on ports 5554 to 5585 and accepts connections from localhost only.

  3. Later the console displays OK, enter the auth auth_token control.
  4. Before you tin enter panel commands, the emulator console requires authentication. auth_token must match the contents of the .emulator_console_auth_token file in your home directory.

    If that file doesn't be, the telnet localhost console-port command creates the file, which contains a randomly generated authentication token. To disable authentication, delete the token from the .emulator_console_auth_token file or create an empty file if it doesn't exist.

  5. Later you're connected to the console, enter console commands.
  6. Enter assist, help command , or assistance-verbose to see a list of console commands and acquire about specific commands.

  7. To leave the panel session, enter quit or leave.

Here'south an instance session:

$                    telnet localhost 5554                    Trying ::ane... telnet: connect to accost ::1: Connection refused Trying 127.0.0.1... Continued to localhost. Escape character is '^]'. Android Panel: Authentication required Android Panel: blazon 'auth <auth_token>' to authenticate Android Console: you can find your <auth_token> in '/Users/me/.emulator_console_auth_token' OK                    auth 123456789ABCdefZ                    Android Console: type 'help' for a list of commands OK                    help-verbose                    Android panel command aid:     help|h|?         print a listing of commands     assist-verbose     print a list of commands with descriptions     ping             check if the emulator is live     automation       manage emulator automation     issue            simulate hardware events     geo              Geo-location commands     gsm              GSM related commands     cdma             CDMA related commands     crash            crash the emulator instance     crash-on-exit    simulate crash on exit for the emulator case     kill             kill the emulator example     restart          restart the emulator instance     network          manage network settings     power            power related commands     quit|go out        quit control session     redir            manage port redirections     sms              SMS related commands     avd              control virtual device execution     qemu             QEMU-specific commands     sensor           manage emulator sensors     physics          manage physical model     finger           manage emulator finger impress     debug            control the emulator debug output tags     rotate           rotate the screen clockwise by 90 degrees     screenrecord     Records the emulator'due south display     fold             fold the device     unfold           unfold the device     multidisplay     configure the multi-display  try 'assistance <control>' for command-specific aid OK                    get out                    Connexion airtight by foreign host.                  

Emulator command reference

The following tabular array describes the emulator panel commands with their parameters and values.

Table one. Emulator console commands

General Commands Description
avd {stop|start|status|proper noun} Query, control, and manage the virtual device, as follows:
  • cease: End the execution of the device.
  • start: Start the execution of the device.
  • status: Query the virtual device condition, which can exist running or stopped.
  • name: Query the virtual device name.
avd snapshot {list|salvage name|load proper noun|delete name} Save and restore the device land in snapshots, as follows:
  • listing: List all saved snapshots.
  • save proper noun : Salvage the snapshot equally name.
  • load name : Load the named snapshot.
  • delete name : Delete the named snapshot.

The post-obit instance saves a snapshot with the name firstactivitysnapshot.

avd snapshot save firstactivitysnapshot
fold Fold the device to display its smaller screen configuration (if the device is foldable and currently unfolded).
unfold Unfold the device to display its larger screen configuration (if the device is foldable and currently folded).
kill Stop the virtual device.
ping Cheque whether the virtual device is running.
rotate Rotate the AVD counterclockwise in 45 caste increments.
Crash the emulator Clarification
crash Crash the emulator during app execution.
crash-on-exit Crash the emulator when the app exits.
Debug tags Description
debug tags ...

Enable or disable debug messages from specific parts of the emulator. The tags parameter must be a value from the list of debug tags that appears when you lot execute emulator -aid-debug-tags. For more than information about the -help-debug-tags option, see Commonly used emulator options.

The post-obit example enables the radio tag:

debug radio
Port redirection Clarification
redir listing Listing the current port redirection.
redir add protocol:host-port:guest-port Add a new port redirection, every bit follows:
  • protocol : Must be either tcp or udp.
  • host-port : The port number to open on the host.
  • guest-port : The port number to route information to on the emulator.
redir del protocol:host-port Delete a port redirection.
  • protocol : Must exist either tcp or udp.
  • host-port : The port number to open on the host.
Geographic location Description
Set the geographic location reported to the apps running within an emulator by sending a GPS fix to the emulator.

You tin result the geo control as soon every bit a virtual device is running. The emulator sets the location yous enter by creating a mock location provider. This provider responds to location listeners set by apps, and likewise supplies the location to the LocationManager. Any app can query the location director to obtain the current GPS fix for the emulated device by calling LocationManager.getLastKnownLocation("gps")

geo fix longitude latitude [distance] [satellites] [velocity] Transport a unproblematic GPS fix to the emulator. Specify longitude and latitude in decimal degrees. Use a number from 1 to 12 to specify the number of satellites to use to determine the position, and specify distance in meters and velocity in knots.
geo nmea judgement Send an NMEA 0183 judgement to the emulated device, as if it were sent from an emulated GPS modem. Kickoff sentence with '$GP'. Only '$GPGGA' and '$GPRCM' sentences are currently supported. The following instance is a GPGGA (Global Positioning Organization Fix Data) sentence that gets the time, position, and fix data for a GPS receiver:
geo nmea $GPGGA ,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,twenty,x.x,x.x,M,x.x,K,x.x,xxxx
Fake hardware events Description
event types List all fake event types. For events that have codes, the number of codes is listed in parens on the correct.
                            event types                            event <type> can be an integer or one of the following aliases:     EV_SYN     EV_KEY    (405 lawmaking aliases)     EV_REL    (ii code aliases)     EV_ABS    (27 code aliases)     EV_MSC     EV_SW     (4 code aliases)     EV_LED     EV_SND     EV_REP     EV_FF     EV_PWR     EV_FF_STATUS     EV_MAX OK                          
issue ship types [types ...] Send one or more than fake event types.
event codes blazon List the event codes for the specified fake event blazon.
event transport type[:code]:[value] [...] Send one or more than simulated events with optional codes and code values.

To notice exactly which consequence to send, you tin use the adb command, while manually pressing the buttons on the emulator.

These are the events generated when y'all press the power button:

                            adb shell getevent -lt                            /dev/input/event12: EV_KEY       KEY_POWER            Downward /dev/input/event12: EV_SYN       SYN_REPORT           00000000 /dev/input/event12: EV_KEY       KEY_POWER            UP /dev/input/event12: EV_SYN       SYN_REPORT           00000000                          
In this item case, we only needed to ship the ii EV_KEY events, keydown, and a keyup event to simulate a long printing of the power button:
                            event transport EV_KEY:KEY_POWER:0                            OK                            event ship EV_KEY:KEY_POWER:1                            OK                          
event text bulletin Send a string of characters that simulate keypresses. The message must be a UTF-viii cord. Unicode posts are reverse-mapped co-ordinate to the current device keyboard, and unsupported characters are discarded silently.
Control the power state reported by the emulator to apps Description
power display Brandish battery and charger state.
power ac {on|off} Set AC charging state to on or off.
power status {unknown|charging|discharging|non-charging|full} Change battery status as specified.
power present {true|false} Fix battery presence country.
power health {unknown|good|overheat|dead|overvoltage|failure} Set battery health state.
power capacity percent Set remaining battery capacity land equally a per centum from 0 to 100.
Network connection status Clarification
network condition Check the network status and current delay and speed characteristics.
network delay latency Alter the emulated network latency.

The emulator lets you simulate various network latency levels, and then that you can test your app in an surround more typical of the actual weather condition in which it will run. Y'all can prepare a latency level or range at emulator startup, or you lot tin can utilize the console to change the latency while the app is running in the emulator.

To set latency at emulator startup, employ the -netdelay emulator option with a supported latency value, as listed in the Network latency format list below. Here are some examples:

emulator -netdelay gprs emulator -netdelay 40,100

To make changes to network delay while the emulator is running, connect to the panel and utilise the netdelay command with a supported latency value from the Network latency format list below.

network filibuster gprs network filibuster 40 100

Network latency format:

The format of network latency is one of the following (numbers are milliseconds):

  • gprs: GPRS, which uses a latency range of 150 minimum and 550 maximum.
  • edge: EDGE/EGPRS, which uses a latency range of 80 minimum and 400 maximum.
  • umts: UMTS/3G, which uses a latency range of 35 minimum and 200 maximum.
  • none: No latency.
  • num : Emulate the specified latency in milliseconds.
  • min:max : Emulate the specified latency range.
network speed speed The emulator lets yous simulate various network transfer rates.

Yous can set up a transfer charge per unit or range at emulator startup, or you tin can use the console to change the charge per unit, while the app is running in the emulator.

To set the network speed at emulator startup, apply the -netspeed emulator pick with a supported speed value, as listed in the network speed format list below. Here are some examples:

emulator -netspeed gsm @Pixel_API_26 emulator -netspeed 14.4,80 @Pixel_API_26                          

To make changes to network speed while the emulator is running, connect to the console and utilize the network speed command with a supported speed value from the Network speed format listing beneath.

network speed 14.4 80

Network speed format:

The format of network speed is i of the post-obit (numbers are kilobits/sec):

  • gsm: GSM/CSD, which uses a speed of 14.iv upwards and fourteen.iv down.
  • hscsd: HSCSD, which uses a speed of fourteen.iv up and 43.2 downwards.
  • gprs: GPRS, which uses a speed of twoscore.0 up and fourscore.0 down.
  • edge: Edge/EGPRS, which uses a speed of 118.4 up and 236.8 downwardly.
  • umts: UMTS/3G, which uses a speed of 128.0 up and 1920 downward.
  • hsdpa: HSDPA, which uses a speed of 348.0 up and 14400.0 downwards.
  • lte: LTE, which uses a speed of 58,000 up and 173,000 down.
  • evdo: EVDO, which uses a speed of 75,000 up and 280,000 downwardly.
  • total: Unlimited speed, but depends on the connection speed of your estimator.
  • num : Ready an exact rate in kilobits/sec used for both upload and download.
  • up:down : Ready verbal rates in kilobits/sec for upload and download separately.
network capture {showtime|end} file Ship packets to a file. The following list describes the parameters and parameter values:
  • offset file : Start sending packets to the specified file.
  • terminate file : Stop sending packets to the specified file.
Telephony emulation Description
The Android emulator includes its own GSM and CDMA emulated modems that let you simulate telephony functions in the emulator. For example, with GSM y'all can simulate inbound phone calls and found and cease data connections. With CDMA you provide a subscription source and the preferred roaming listing. The Android system handles imitation calls exactly as it would actual calls. The emulator does not support telephone call audio.
gsm {phone call|accept|abolish|decorated} phonenumber The gsm parameters are the post-obit:
  • call: Simulate an entering telephone phone call from phonenumber .
  • accept: Accept an entering telephone call from phonenumber and modify the call state to active. You can change a telephone call state to active merely when its current state is waiting or held.
  • cancel: End an entering or outbound phone call to or from phonenumber .
  • busy: Close an outbound call to phonenumber and alter the call country to busy. Y'all can change a telephone call state to busy only when its electric current country is waiting.
gsm {data|vocalisation} state The information country command changes the state of the GPRS data connection, and the information voice state changes the state of the GPRS vocalization connection, every bit follows:
  • unregistered: No network available.
  • dwelling: On local network, non-roaming.
  • roaming: On roaming network.
  • searching: Searching networks.
  • denied: Emergency calls only.
  • off: Same every bit unregistered.
  • on: Aforementioned equally dwelling.
gsm concord Modify the land of a call to hold. Yous can alter a telephone call state to hold only when its current land is agile or waiting.
gsm list List all inbound and outbound calls and their states.
gsm status Report the current GSM voice/data land. Values are those described for the vocalism and data commands.
gsm signal {rssi|ber} Modify the reported bespeak strength (rssi) and bit fault charge per unit (ber) on the next 15 seconds of update. The following list describes the parameters and their values:
  • rssi range is 0 through 31 and 99 for unknown.
  • ber range is 0 through seven and 99 for unknown.
gsm signal-profile num Set the signal strength profile. Enter a number from 0 through 4.
cdma ssource source source : Set the current CDMA subscription source where source is a network-based allowlist that contains the CDMA carrier's subscribers and their values, every bit follows:
  • nv: Read subscription from non-volatile RAM.
  • ruim: Read subscription from Removable User Identity Module (RUIM).
cdma prl_version version Dump the current preferred roaming listing (PRL) version. The version number is for the PRL database that contains information used during the organisation selection and acquisition process.
Manage Sensors on the emulator Description
These commands relate to which sensors are available in the AVD. Besides using the sensor command, you lot can run across and adjust the settings in the emulator in the Virtual sensors screen in the Accelerometer and Additional sensors tabs. For more information, see Working with the extended controls, settings, and help.
sensor status List all sensors and their status. The following is case output for the sensor status control:
sensor get sensor-name Get the settings for sensor-name . The following example gets the value for the acceleration sensor:
sensor get acceleration acceleration = ii.23517e-07:9.77631:0.812348                          

The acceleration values separated past colons(:) refer to the x, y, and z coordinates for the virtual sensors described in Working with the extended controls, settings, and assist.

sensor ready sensor-proper noun value-x:value-y:value-z Fix the values for sensor-name . The following example sets the dispatch sensor to the post-obit x, y, and z values separated by colons. For more than information, see Working with the extended controls, settings, and help.
sensor set acceleration 2.23517e-07:9.77631:0.812348
SMS emulation Description
sms transport sender-phone-number textmessage Generate an emulated incoming SMS. The following listing describes the parameter and their values:
  • sender-phone-number : Contains an arbitrary numeric string.
  • textmessage : The sms bulletin.

The following instance sends the message "hello there" to the 4085555555 phone number.

sms transport 4085555555 hullo there

The console forwards the SMS bulletin to the Android framework, which passes it to an app on the emulator that handles SMS, such every bit the Messages app. If you lot pass 10 numbers, the app formats it as a phone number. Longer or shorter numeric strings display the fashion you sent them.

Fingerprint simulation Description
finger impact fingerprint-id Simulate a finger touching the sensor.
finger remove Simulate finger removal.

For instructions about how to use these commands, see Fingerprint simulation and validation.

Fingerprint simulation and validation

Figure one. Fingerprint authentication screen.

Use the finger command to simulate and validate fingerprint hallmark for your app. You demand SDK Tools 24.iii or higher, and Android 6.0 (API level 23) or higher.

To simulate and validate fingerprint hallmark, follow these steps:

  1. If you don't still accept a fingerprint ID, enroll a new fingerprint in the emulator by selecting Settings > Security > Fingerprint and following the enrollment instructions.
  2. Ready upwards your app to accept fingerprint hallmark. Afterward you perform this setup, your device displays the fingerprint hallmark screen.
  3. While your app displays the fingerprint authentication screen, become to the console and enter the finger touch command and the fingerprint ID you created. This simulates a finger touch.
  4. Then, enter the finger remove control to simulate finger removal.

    Your app should answer as if a user touched and so removed their finger from the fingerprint sensor.