diff --git a/docs/html/_redirects.yaml b/docs/html/_redirects.yaml index 0e5417f2036b4..3647453a81b0e 100644 --- a/docs/html/_redirects.yaml +++ b/docs/html/_redirects.yaml @@ -947,6 +947,8 @@ redirects: to: /studio/command-line/bmgr.html - from: /tools/help/draw9patch.html to: /studio/write/draw9patch.html +- from: /tools/help/desktop-head-unit.html + to: /training/auto/testing/index.html - from: /tools/help/emulator.html to: /studio/run/emulator-commandline.html - from: /tools/help/etc1tool.html diff --git a/docs/html/training/_book.yaml b/docs/html/training/_book.yaml index 8f8fab20ad12e..47c690406d7e9 100644 --- a/docs/html/training/_book.yaml +++ b/docs/html/training/_book.yaml @@ -748,6 +748,11 @@ toc: path_attributes: - name: description value: How to extend text messaging apps to work with Auto devices. + - title: Testing for Auto + path: /training/auto/testing/index.html + path_attributes: + - name: description + value: How to use DHU to test Auto apps. - title: Building Apps for Work path: /training/enterprise/index.html diff --git a/docs/html/training/auto/start/index.jd b/docs/html/training/auto/start/index.jd index 0206a24a9b8f5..202e2c05d86a5 100644 --- a/docs/html/training/auto/start/index.jd +++ b/docs/html/training/auto/start/index.jd @@ -16,7 +16,6 @@ page.image=auto/images/assets/icons/auto_app_in_simulator.png
  1. Set Up an Auto Project
  2. Build Auto Apps
  3. -
  4. Run and Test Auto Apps

You should also read

@@ -152,136 +151,4 @@ more information, see -

Run and Test Auto Apps

- -

- As you develop, you can run and test your app on your development machine - using the Desktop Head Unit (DHU). The DHU replaces the existing - simulators and enables your development machine to simulate a vehicle - dashboard system running Android Auto. -

- -

Installing the DHU

- -
    -
  1. Enable developer mode on your mobile device, as described in - Enabling On-device - Developer Options.
  2. -
  3. Compile your app in your development environment and install your app on - a physical mobile device running Android 5.0 (API level 21) or higher. To check the - version of Android on a Nexus device, go to - Settings > About phone (or About tablet) > - Android version.
  4. - -
  5. Install the - Android Auto app on the mobile device.
  6. -
  7. Open the SDK Manager and - download the DHU package Android Auto Desktop Head Unit emulator from the - SDK Tools tab. The DHU installs in the <sdk>/extras/google/auto/ - directory.
  8. -
  9. If you are running the DHU on Linux, you must also install - the portaudio, libpng, sdl2, and sdl2_ttf libraries. - The procedure to do this varies depending on your Linux distribution. For example, on - Debian-derived Linux distributions, you can install the libraries with this command: - -
    -$ sudo apt-get install libsdl2-2.0-0 libsdl2-ttf-2.0-0 libportaudio2 libpng12-0
    -
    - -
  10. -
- -
-
- -

- Figure 1. Context menu with developer options. -

-
- -
- -

- Figure 2. Notification that the head unit server is running. -

-
-
- - -

Connecting the DHU to your mobile device

- -

Run the DHU by connecting your mobile device to a development machine and setting up a connection to - the head unit server over Android Debug Bridge - (ADB). Follow these steps to set up tunneling and start the DHU:

- -
    -
  1. On the mobile device, enable Android Auto developer mode by starting the Android Auto - companion app, and then tapping the Android Auto toolbar title 10 times. - This step is only required the first time you run the companion app. -
  2. -
  3. If the server is not already running, select Start head unit server - from the Android Auto menu. -

    On the device, a foreground service appears in the notification area.

    -
  4. - -
  5. In the Android Auto app, make sure the Only connect to known cars option - is disabled.
  6. - -
  7. Connect the mobile device to the development machine via USB.
  8. - -
  9. Make sure the mobile device has its screen unlocked, otherwise it cannot launch the DHU.
  10. - -
  11. On the development machine, run the following {@code adb} command to - forward socket connections from the - development machine's port 5277 to the same port number on the Android device. - This configuration allows the DHU to connect to the head unit server running on your phone over - a TCP socket. -
    $ adb forward tcp:5277 tcp:5277
    -
  12. - -
  13. Start the DHU by running the command desktop-head-unit.exe (on Windows) - or ./desktop-head-unit (on Mac or Linux) from the - <sdk>/extras/google/auto/ directory. - -
    $ cd <sdk>/extras/google/auto
    -$ ./desktop-head-unit
    - -

    - By default, the head unit server connects over port 5277. To override the host or port - (for example, to forward over SSH), use the - desktop-head-unit --adb <[localhost:]port> flag, as in - the following example: -

    - -
    $ ./desktop-head-unit --adb 5999
    - -
  14. -
- -
- - -

- Figure 4. DHU launches on the development machine. -

-
- - -

- Figure 3. Android Auto launches on the mobile device. -

- -

- After you set up and start the DHU, you can run DHU commands from the command line to run and - test your app from the terminal. You can also run these commands by using keyboard shortcuts. For - more information about DHU configuration and commands, see Desktop Head Unit. -

- diff --git a/docs/html/training/auto/testing/index.jd b/docs/html/training/auto/testing/index.jd new file mode 100644 index 0000000000000..c93012fab3518 --- /dev/null +++ b/docs/html/training/auto/testing/index.jd @@ -0,0 +1,560 @@ +page.title= Testing Apps for Auto +page.tags="auto", "car", "automotive" +page.article=true + +@jd:body + +
+
+

Dependencies and Prerequisites

+ +

In this document

+
    +
  1. Installing the DHU
  2. +
  3. Running the DHU
  4. +
  5. Issuing DHU Commands
  6. +
+
+
+ + +

+ Testing your Auto app ensures that users do not encounter unexpected results or + have a poor experience when interacting with your apps. Android now provides + Desktop Head Unit (DHU), a testing tool for Auto apps that lets you test + pre-released versions of your Android Auto apps without having to work from + your car.

+ +

The Desktop Head Unit (DHU) enables your development machine to emulate an +Android Auto head unit, so you can easily run and test Android Auto apps. +The DHU runs on Windows, Mac, and Linux hosts and replaces previous Android Auto + simulators, such as the Android Media Browser and Messaging simulators.

+ + +

Note: It's important that you test your auto + app for the criteria listed on + Auto app quality page prior to submitting to Google Play for review. +

+

+ This lesson teaches you how to install and run the DHU on your development + machine for testing your apps. Once you’ve + installed the DHU, you can test your Android Auto apps by connecting your phone + and workstation via USB. + +

Installing the DHU

+

Follow these steps to install the DHU on your development machine:

+
  • Enable developer mode on your mobile device, as described in + Enabling On-device + Developer Options.
  • +
  • Compile your app in your development environment and install your app on + a physical mobile device running Android 5.0 (API level 21) or higher. To check the + version of Android on a Nexus device, go to + Settings > About phone (or About tablet) > + Android version.
  • + +
  • Install the + Android Auto app on the mobile device.
  • +
  • Open the SDK Manager and + download the DHU package Android Auto Desktop Head Unit emulator from the + SDK Tools tab. The DHU installs in the <sdk>/extras/google/auto/ + directory.
  • +
  • If you are running the DHU on Linux, you must also install + the portaudio, libpng, sdl2, and sdl2_ttf libraries. + The procedure to do this varies depending on your Linux distribution. For example, on + Debian-derived Linux distributions, you can install the libraries with this command: + +
    +$ sudo apt-get install libsdl2-2.0-0 libsdl2-ttf-2.0-0 libportaudio2 libpng12-0
    +
    + +
  • + + +
    +
    + +

    + Figure 1. Context menu with developer options. +

    +
    + +
    + +

    + Figure 2. Notification that the head unit server is running. +

    +
    +
    + + +

    Running the DHU

    + +

    Run the DHU by connecting your mobile device to a development machine and +setting up a connection to the head unit server over Android Debug Bridge + (ADB). Follow these steps to set up tunneling and start the DHU:

    + +
      +
    1. On the mobile device, enable Android Auto developer mode by starting the Android Auto + companion app, and then tapping the Android Auto toolbar title 10 times. + This step is only required the first time you run the companion app. +
    2. +
    3. If the server is not already running, select Start head unit server + from the Android Auto menu. +

      On the device, a foreground service appears in the notification area.

      +
    4. + +
    5. In the Android Auto app, make sure the Only connect to known cars option + is disabled.
    6. + +
    7. Connect the mobile device to the development machine via USB.
    8. + +
    9. Make sure the mobile device has its screen unlocked, otherwise it cannot launch the DHU.
    10. + +
    11. On the development machine, run the following {@code adb} command to + forward socket connections from the + development machine's port 5277 to the same port number on the Android device. + This configuration allows the DHU to connect to the head unit server running on your phone over + a TCP socket. +
      $ adb forward tcp:5277 tcp:5277
      +
    12. + +
    13. Start the DHU by running the command desktop-head-unit.exe (on Windows) + or ./desktop-head-unit (on Mac or Linux) from the + <sdk>/extras/google/auto/ directory. + +
      $ cd <sdk>/extras/google/auto
      +$ ./desktop-head-unit
      + +

      + By default, the head unit server connects over port 5277. To override the host or port + (for example, to forward over SSH), use the + desktop-head-unit --adb <[localhost:]port> flag, as in + the following example: +

      + +
      $ ./desktop-head-unit --adb 5999
      +

      + By default, the DHU emulates the most common form of Android Auto-compatible + head unit, which uses a touch screen user interface. You can simulate user + touches by clicking the DHU with a mouse. To emulate head units which use + a rotary controller for input, you can use the -i controller flag, + as in this example: +

      +
      $ ./desktop-head-unit -i controller
      +

      + When the DHU is in rotary-controller mode you can simulate controller + operations by using keyboard shortcuts, as described in DHU commands and key bindings. If the DHU is in rotary + controller mode, it ignores mouse clicks; you must operate Android Auto with + the simulated rotary controller operations. +

      +
    14. +
    + + + + +
    + + +

    + Figure 4. DHU launches on the development machine. +

    +
    + + +

    + Figure 3. Android Auto launches on the mobile device. +

    + +

    + After you set up and start the DHU, you can run DHU commands from the command + line to run and test your app from the terminal. You can also run these commands + by using keyboard shortcuts. +

    + +

    Issuing DHU Commands

    + +

    + DHU commands allow you to test your app with Android Auto features, such as + playing voice input or switching between night and day display mode. You can issue commands to + the DHU by running commands from the terminal window where you launched DHU. + You can also issue commands by selecting the DHU window and + using keyboard shortcuts. The DHU commands + and key bindings for all controls are listed in DHU + commands and key bindings. +

    + + +

    Switching between day and night mode

    + +

    + Android Auto supports different color schemes for day and night. You should test your app in both + day and night mode. You can switch between night and day mode in either of the + following ways: +

    + + + +

    Microphone testing

    + +

    The DHU supports using a microphone for voice input. You can also instruct the DHU to treat +a pre-recorded voice track as input, as if the DHU had heard the track through the microphone.

    + +

    To use a pre-recorded sound file as input, enter this command:

    +
    +$ mic play <sound_file_path>/<sound_file>.wav
    +
    + +

    For your convenience, we have provided the following sound files for common +voice commands. These sound files are installed in the +<sdk>/extras/google/auto/voice/ directory.

    + +
    +
    + exitnav.wav +
    + +
    + "Exit navigation." +
    + +
    + navgoogle.wav +
    + +
    + "Navigate to 1600 Amphitheatre Parkway, Mountain View." +
    + +
    + navsoh.wav +
    + +
    + "Navigate to Sydney Opera House." +
    + +
    + nextturn.wav +
    + +
    + "When is my next turn?" +
    + +
    + showalternateroute.wav +
    + +
    + "Show alternate routes."" +
    + +
    + howlong.wav +
    + +
    + "How long until I get there?" +
    + +
    + navhome.wav +
    + +
    + "Navigate to home." +
    + +
    + navwork.wav +
    + +
    + "Navigate to work."" +
    + +
    + pause.wav +
    + +
    + "Pause music." +
    + +
    + showtraffic.wav +
    + +
    + "Show traffic." +
    +
    +

    DHU commands and key bindings

    + +

    The DHU supports the following commands.

    + +

    Table 1. Commands and key bindings

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CategoryCommandSubcommandArgument(s)Keyboard Shortcut(s)Description
    Systemhelp[command]Shows the full command set. Specifying a command name (for example, help day) + causes the system to show help for that command.
    quitAlt+qQuits the head unit.
    sleep[seconds]Sleeps for one second. Specifying an argument (for example, sleep 30) causes the +system to sleep the specified number of seconds. This command +is useful if you are writing scripts for the DHU. (You can run a script by using I/O redirection +from the command line: ./desktop-head-unit < script.txt loads commands from the +file script.txt.)
    screenshotfilename.pngSaves a screenshot to filename.png.
    Microphonemicbeginm Activates the microphone (equivalent to clicking the steering wheel's microphone button) and +waits for input from the computer microphone.
    playfilename.wavCauses the DHU to treat filename.wav as voice input, as if it had heard that sound + through the microphone. You do not hear the sound file being played, but you do hear + the response from Android Auto.
    repeatRepeats the last mic play command, as if you had called mic play + again with the same sound file parameter.
    Inputdpadup
    down
    left
    right
    Arrow keysSimulates moving the rotary controller.
    soft left
    soft right
    Shift+Arrow keysSimulates pressing the side buttons available on some rotary controllers.
    clickReturnSimulates pressing the rotary controller.
    backBackspaceSimulates pressing the back button available below some rotary + controllers.
    rotate left
    rotate right
    1
    2
    Simulates rotating the rotary controller left (counter-clockwise) or right (clockwise).
    flick left
    flick right
    Shift+1
    Shift+2
    Simulates a fast spin of the rotary controller to the left (counter-clockwise) or right + (clockwise).
    tapx ySimulates a touch event at the specified coordinates. For example, tap 50 100
    Day/NightdayShift+nActivates day mode (high brightness, full color).
    night Ctrl+n Activates night mode (low brightness, high contrast).
    daynightn Toggles current day/night mode.
    + + + + +

    Media Browser and Messaging Simulators

    + +

    Important: Use of the Android Media Browser and Messaging +Simulators for testing Android Auto apps is deprecated. Instead, we recommend using the +Desktop Head Unit, which enables your development machine to act as if it were an Android Auto head +unit.

    + +

    To get the simulators, open the +SDK Manager and download +them from Extras > Android Auto API Simulators.

    + +

    Before you begin testing, compile your app in your development environment. +Install your app and the Android simulator for the features you want to test +(that is, audio or messaging) on a physical or virtual device running Android +5.0 (API level 21) or higher. To check the version of Android on the device, go +to Settings > About phone (or About tablet) +> Android Version.

    + +

    Testing audio apps

    +

    To run and test audio apps:

    + +
      +
    1. Install the Android Media Browser simulator +({@code <sdk>/extras/google/simulators/media-browser-simulator.apk}) on +the test device. You can do this using +the adb command line tool.
    2. +
    3. Enable +developer options on the test device.
    4. +
    5. Install your app on the test device.
    6. +
    7. Launch the Android Media Browser simulator to see how your audio app +appears in Auto. If your app does not appear, stop the simulator from +Settings > Apps and restart it.
    8. +
    + + +

    Testing messaging apps

    +

    To run and test messaging apps:

    + +
      +
    1. Install the Android Messaging simulator + ({@code <sdk>/extras/google/simulators/messaging-simulator.apk}) +on the test device. You can do this using the +adb command line tool.
    2. +
    3. Enable the simulator to read notifications posted on the system: +
        +
      1. Enable +developer options on the test device.
      2. +
      3. Click Settings > Sounds & Notifications > Notification + Access and check the box labeled + Messaging Simulator.
      4. +
      +
    4. Install your app on the test device.
    5. +
    6. Launch the Android Messaging Simulator to see how your messaging app appears +in Auto. If your app does not appear, stop the simulator from +Settings > Apps and restart it.
    7. +
    + + diff --git a/docs/html/training/training_toc.cs b/docs/html/training/training_toc.cs index 756125405a033..2c0fb4ee8cf12 100644 --- a/docs/html/training/training_toc.cs +++ b/docs/html/training/training_toc.cs @@ -1178,6 +1178,11 @@ description="How to extend text messaging apps to work with Auto devices."> Messaging for Auto +
  • + + Testing Auto Apps +