1page.title=Desktop Head Unit
2page.tags="auto", "car", "testing","dhu"
3@jd:body
4
5
6<div id="qv-wrapper">
7<div id="qv">
8
9    <h2>In this document</h2>
10    <ol>
11      <li><a href="#launching-dhu">Launching the DHU</a></li>
12      <li><a href="#dhu-commands">Issuing DHU Commands</a></li>
13    </ol>
14
15  <h2>See also</h2>
16  <ol>
17    <li><a href="{@docRoot}training/auto/start/index.html#test-it-dhu">Run and Test Auto Apps</a></li>
18  </ol>
19
20</div>
21</div>
22
23
24<p>The Desktop Head Unit (DHU) enables your development machine to emulate an Android Auto
25head unit, so you can easily run and test Android Auto apps. The DHU runs on
26Windows, Mac, and Linux hosts and replaces previous Android Auto simulators,
27such as the Android Media Browser and Messaging
28simulators.</p>
29
30<p class="note"><strong>Note:</strong> For other information about testing Auto apps, see the
31training lesson
32<a href="{@docRoot}training/auto/start/index.html#test-it-dhu">Run and Test Auto Apps</a>.  </p>
33
34
35<h2 id="launching-dhu">Launching the DHU</h2>
36
37<p>
38  To launch the DHU, run the <code>desktop-head-unit.exe</code> (on Windows)
39  or <code>desktop-head-unit</code> (on Mac or Linux) command, as described in
40  <a href="{@docRoot}training/auto/start/index.html#connecting-dhu">Connecting
41  the DHU to your mobile device</a>.
42</p>
43
44<p>
45  By default, the DHU emulates the most common form of Android Auto-compatible
46  head unit, which uses a touch screen user interface. You can simulate user
47  touches by clicking the DHU with a mouse. To emulate head units which use
48  a rotary controller for input, you can use the <code>-i controller</code> flag,
49  as in this example:
50</p>
51
52<pre class="no-pretty-print">$ ./desktop-head-unit -i controller</pre>
53
54<p>
55  When the DHU is in rotary-controller mode you can simulate controller
56  operations by using keyboard shortcuts, as described in <a href=
57  "#cmd-bindings">DHU commands and key bindings</a>. If the DHU is in rotary
58  controller mode, it ignores mouse clicks; you must operate Android Auto with
59  the simulated rotary controller operations.
60</p>
61
62<h2 id="dhu-commands">Issuing DHU Commands</h2>
63
64<p>
65  DHU commands allow you to test your app with Android Auto features, such as
66  playing voice input or switching between night and day display mode. You can issue commands to
67  the DHU by running commands from the terminal window where you launched DHU.
68  You can also issue commands by selecting the DHU window and
69  using keyboard shortcuts. The DHU commands
70  and key bindings for all controls are listed in <a href="#cmd-bindings">DHU
71  commands and key bindings</a>.
72</p>
73
74
75<h3 id="day-night">Switching between day and night mode</h3>
76
77<p>
78  Android Auto supports different color schemes for day and night. You should test your app in both
79  day and night mode. You can switch between night and day mode in either of the
80  following ways:
81</p>
82
83<ul>
84  <li>Run the command <code>daynight</code> in the terminal where you launched the DHU.
85  </li>
86
87  <li>Select the DHU window and press the <strong>N</strong> key.
88  </li>
89</ul>
90
91<h3>Microphone testing</h3>
92
93<p>The DHU supports using a microphone for voice input. You can also instruct the DHU to treat
94a pre-recorded voice track as input, as if the DHU had heard the track through the microphone.</p>
95
96<p>To use a pre-recorded sound file as input, enter this command: </p>
97<pre class="no-pretty-print">
98$ mic play &lt;sound_file_path&gt;/&lt;sound_file&gt;.wav
99</pre>
100
101<p>For your convenience, we have provided the following sound files for common
102voice commands. These sound files are installed in the
103<code>&lt;sdk&gt;/extras/google/auto/voice/</code> directory.</p>
104
105<dl>
106  <dt>
107    <code>exitnav.wav</code>
108  </dt>
109
110  <dd>
111    "Exit navigation."
112  </dd>
113
114  <dt>
115    <code>navgoogle.wav</code>
116  </dt>
117
118  <dd>
119    "Navigate to 1600 Amphitheatre Parkway, Mountain View."
120  </dd>
121
122  <dt>
123    <code>navsoh.wav</code>
124  </dt>
125
126  <dd>
127    "Navigate to Sydney Opera House."
128  </dd>
129
130  <dt>
131    <code>nextturn.wav</code>
132  </dt>
133
134  <dd>
135    "When is my next turn?"
136  </dd>
137
138  <dt>
139    <code>showalternateroute.wav</code>
140  </dt>
141
142  <dd>
143    "Show alternate routes.""
144  </dd>
145
146  <dt>
147    <code>howlong.wav</code>
148  </dt>
149
150  <dd>
151    "How long until I get there?"
152  </dd>
153
154  <dt>
155    <code>navhome.wav</code>
156  </dt>
157
158  <dd>
159    "Navigate to home."
160  </dd>
161
162  <dt>
163    <code>navwork.wav</code>
164  </dt>
165
166  <dd>
167    "Navigate to work.""
168  </dd>
169
170  <dt>
171    <code>pause.wav</code>
172  </dt>
173
174  <dd>
175    "Pause music."
176  </dd>
177
178  <dt>
179    <code>showtraffic.wav</code>
180  </dt>
181
182  <dd>
183    "Show traffic."
184  </dd>
185</dl>
186<h3 id="cmd-bindings">DHU commands and key bindings</h3>
187
188<p>The DHU supports the following commands.</p>
189
190<p class="table-caption" id="table-commands"><strong>Table 1.</strong> Commands and key bindings</p>
191<table>
192<tr>
193  <th>Category</th>
194  <th>Command</th>
195  <th>Subcommand</th>
196  <th>Argument(s)</th>
197  <th>Keyboard Shortcut(s)</th>
198  <th>Description</th>
199</tr>
200
201<!--system-->
202
203<tr>
204<td rowspan="4">System</td>
205<td>help</td>
206<td></td>
207<td>[command]</td>
208<td></td>
209<td>Shows the full command set. Specifying a command name (for example, <code>help day</code>)
210  causes the system to show help for that command.</td>
211</tr>
212
213<tr>
214
215<td>quit</td>
216<td></td>
217<td></td>
218<td>Alt+q</td>
219<td>Quits the head unit.</td>
220</tr>
221
222<tr>
223
224<td>sleep</td>
225<td></td>
226<td>[seconds]</td>
227<td></td>
228<td>Sleeps for one second. Specifying an argument (for example, <code>sleep 30</code>) causes the
229system to sleep the specified number of seconds. This command
230is useful if you are writing scripts for the DHU. (You can run a script by using I/O redirection
231from the command line: <code>./desktop-head-unit &lt; script.txt</code> loads commands from the
232file <code>script.txt</code>.)</td>
233</tr>
234
235<tr>
236
237<td>screenshot</td>
238<td></td>
239<td>filename.png</td>
240<td></td>
241<td>Saves a screenshot to <code>filename.png</code>.</td>
242</tr>
243
244
245<!--microphone-->
246
247<tr>
248<td rowspan="3">Microphone</td>
249<td rowspan="3">mic</td>
250<td>begin</td>
251<td></td>
252<td>m </td>
253<td>Activates the microphone (equivalent to clicking the steering wheel's microphone button) and
254waits for input from the computer microphone.</td>
255</tr>
256
257<tr>
258
259
260<td>play</td>
261<td>filename.wav</td>
262<td></td>
263<td>Causes the DHU to treat <code>filename.wav</code> as voice input, as if it had heard that sound
264  through the microphone. You do not hear the sound file being played, but you do hear
265  the response from Android Auto.</td>
266</tr>
267
268<tr>
269
270
271<td>repeat</td>
272<td></td>
273<td></td>
274<td>Repeats the last <code>mic play</code> command, as if you had called <code>mic play</code>
275  again with the same sound file parameter.</td>
276</tr>
277
278<!--Input-->
279
280<tr>
281<td rowspan="7">Input</td>
282<td rowspan="6">dpad</td>
283<td>up <br> down <br> left <br> right</td>
284<td></td>
285<td>Arrow keys</td>
286<td>Simulates moving the rotary controller.</td>
287</tr>
288
289<tr>
290
291
292<td>soft left <br> soft right</td>
293<td></td>
294<td>Shift+Arrow keys</td>
295<td>Simulates pressing the side buttons available on some rotary controllers.</td>
296</tr>
297
298<tr>
299
300
301<td>click</td>
302<td></td>
303<td>Return</td>
304<td>Simulates pressing the rotary controller.</td>
305</tr>
306
307<tr>
308
309
310<td>back</td>
311<td></td>
312<td>Backspace</td>
313<td>Simulates pressing the <strong>back</strong> button available below some rotary
314  controllers.</td>
315</tr>
316
317<tr>
318
319
320<td>rotate left <br> rotate right</td>
321<td></td>
322<td>1 <br> 2</td>
323<td>Simulates rotating the rotary controller left (counter-clockwise) or right (clockwise).</td>
324</tr>
325
326<tr>
327
328
329<td>flick left <br> flick right</td>
330<td></td>
331<td>Shift+1 <br> Shift+2</td>
332<td>Simulates a fast spin of the rotary controller to the left (counter-clockwise) or right
333  (clockwise).</td>
334</tr>
335
336<tr>
337
338<td>tap</td>
339<td></td>
340<td>x y</td>
341<td></td>
342<td>Simulates a touch event at the specified coordinates. For example, <code>tap 50 100</code></td>
343</tr>
344
345
346<!--Day/Night-->
347
348<tr>
349<td rowspan="3">Day/Night</td>
350<td>day</td>
351<td></td>
352<td></td>
353<td>Shift+n</td>
354<td>Activates day mode (high brightness, full color).</td>
355</tr>
356
357<tr>
358
359<td>night</td>
360<td></td>
361<td> </td>
362<td>Ctrl+n </td>
363<td>Activates night mode (low brightness, high contrast).</td>
364</tr>
365
366<tr>
367
368<td>daynight</td>
369<td></td>
370<td></td>
371<td>n </td>
372<td>Toggles current day/night mode.</td>
373</tr>
374
375</table>
376
377
378
379
380<h2 id="auto-simulators">Media Browser and Messaging Simulators</h2>
381
382<p class="caution"><strong>Important:</strong> Use of the Android Media Browser and Messaging
383Simulators for testing Android Auto apps is deprecated. Instead, we recommend using the
384Desktop Head Unit, which enables your development machine to act as if it were an Android Auto head
385unit.</p>
386
387<p>To get the simulators, open the
388<a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a> and download
389them from <strong>Extras &gt; Android Auto API Simulators</strong>.</p>
390
391<p>Before you begin testing, compile your app in your development environment.
392Install your app and the Android simulator for the features you want to test
393(that is, audio or messaging) on a physical or virtual device running Android
3945.0 (API level 21) or higher. To check the version of Android on the device, go
395to <strong>Settings &gt; About phone</strong> (or <strong>About tablet</strong>)
396<strong>&gt; Android Version</strong>.</p>
397
398<h3 id="testing-audio-apps">Testing audio apps</h3>
399<p>To run and test audio apps:</p>
400
401<ol>
402<li>Install the Android Media Browser simulator
403({@code &lt;sdk&gt;/extras/google/simulators/media-browser-simulator.apk}) on
404the test device. You can do this using
405the <a href="{@docRoot}tools/help/adb.html#move">adb</a> command line tool.</li>
406<li>Enable <a href="{@docRoot}tools/device.html#developer-device-options">
407developer options</a> on the test device.</li>
408<li>Install your app on the test device.</li>
409<li>Launch the Android Media Browser simulator to see how your audio app
410appears in Auto. If your app does not appear, stop the simulator from
411<strong>Settings &gt; Apps</strong> and restart it.</li>
412</ol>
413
414
415<h3 id="testing-messaging-apps">Testing messaging apps</h3>
416<p>To run and test messaging apps:</p>
417
418<ol>
419<li>Install the Android Messaging simulator
420  ({@code &lt;sdk&gt;/extras/google/simulators/messaging-simulator.apk})
421on the test device. You can do this using the
422<a href="{@docRoot}tools/help/adb.html#move">adb</a> command line tool.</li>
423<li>Enable the simulator to read notifications posted on the system:
424<ol type="a">
425	<li>Enable <a href="{@docRoot}tools/device.html#developer-device-options">
426developer options</a> on the test device.</li>
427  <li>Click <strong>Settings &gt; Sounds &amp; Notifications &gt; Notification
428    Access</strong> and check the box labeled
429    <strong>Messaging Simulator</strong>.</li>
430</ol>
431<li>Install your app on the test device.</li>
432<li>Launch the Android Messaging Simulator to see how your messaging app appears
433in Auto. If your app does not appear, stop the simulator from
434<strong>Settings &gt; Apps</strong> and restart it.</li>
435</ol>
436
437
438
439
440