1# Custom Input Event
2
3## Building
4```bash
5make SampleCustomInputService -j64
6```
7
8### Installing
9```bash
10adb install $OUT/target/product/emulator_car_x86/system/app/SampleCustomInputService/SampleCustomInputService.apk
11```
12
13## Start SampleCustomInputService
14```bash
15adb shell am start-foreground-service com.android.car.custominput.sample/.SampleCustomInputService
16```
17
18### Running tests
19
20Steps to run unit tests:
21
221. Build and install SampleCustomInputService.apk (see above sections).
231. Then run:
24
25```bash
26atest SampleCustomInputServiceTest
27```
28
29## Inject events (test scripts)
30
31These are the test scripts to demonstrate how CustomInputEvent can be used to implement OEM
32partners non-standard events. They all represent hypothetical features for the sake of documentation
33 only.
34
35*Note*: Make sure SampleCustomInputService is installed and started. Especially if you've just
36        ran tests. Depending on the configuration you use, running SampleCustomInputServiceTest may
37        uninstall SampleCustomInputService.
38
39### Inject Maps event from steering wheel control
40
41For this example, press home first, then inject the event to start Maps activity by running:
42
43```shell script
44adb shell cmd car_service inject-custom-input -d 0 f1
45```
46
47Parameters are:
48* `-d 0`: sets target display type to main display;
49* `f1`: sets the OEM partner function `f1` to execute. In this implementation, `f1` argument
50    represents the action used to launch Google maps app;
51
52*Note*: For this command to run, ensure that Google Maps app is installed first.
53
54### Inject events to accept or reject incoming calls
55
56In this example, CustomInputEvents are send to accept or reject incoming calls. First cell phone
57must be connected to Android via Bluetooth. Then, to accept incoming calls, run:
58
59```shell script
60adb shell cmd car_service inject-custom-input f2
61```
62
63Alternatively, to reject incoming calls, run:
64
65```shell script
66adb shell cmd car_service inject-custom-input f3
67```
68
69### Inject events to increase or decrease media volume
70
71To increase media volume, run:
72
73```shell script
74adb shell cmd car_service inject-custom-input f4
75```
76
77To decrease media volume, run:
78
79```shell script
80adb shell cmd car_service inject-custom-input f5
81```
82
83### Inject events to increase or decrease alarm volume
84
85To increase alarm volume, run:
86
87```shell script
88adb shell cmd car_service inject-custom-input f6
89```
90
91To decrease alarm volume, run:
92
93```shell script
94adb shell cmd car_service inject-custom-input f7
95```
96
97### Inject event to simulate pressing BACK HOME button
98
99To simulate pressing BACK HOME button, run:
100
101```shell script
102adb shell cmd car_service inject-custom-input f8
103```
104
105To notify driver UI to move navigation view, run:
106
107```shell script
108adb shell cmd car_service inject-custom-input 1011
109```
110