Renaming CustomInputTestService to SampleCustomInputService
This is a reference implementation service to be used as a guideline for
OEMs, not a Car test suite.
Test script:
1. Start emulator (with Google Maps app installed)
2. Run `make SampleCustomInputService`
3. Run `adb install $OUT/target/product/emulator_car_x86/system/app/SampleCustomInputService/SampleCustomInputService.apk`
4. Run `adb shell am start-foreground-service com.android.car.custominput.sample/.SampleCustomInputService`
5. Run `adb shell cmd car_service inject-custom-input -d 0 f1` and expect Maps app to show up
Bug: 12219669
Test: manual testing (see script above)
Test: atest SampleCustomInputServiceTest
Test: atest CarServiceUnitTest
Change-Id: I0ce8b7932da08c683a20b4b0f4906cec9db3c4e0
diff --git a/tests/CustomInputTestService/AndroidManifest.xml b/tests/CustomInputTestService/AndroidManifest.xml
deleted file mode 100644
index 6aba2a7..0000000
--- a/tests/CustomInputTestService/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2020 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.car.custominput.test">
-
- <uses-permission android:name="android.permission.MONITOR_INPUT"/>
- <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
-
- <application>
- <service android:name=".CustomInputTestService"
- android:exported="true" android:enabled="true" >
- <intent-filter>
- <action android:name="com.android.car.custominput.action.START_SILENT"/>
- </intent-filter>
- </service>
- </application>
-</manifest>
-
diff --git a/tests/CustomInputTestService/readme.md b/tests/CustomInputTestService/readme.md
deleted file mode 100644
index 1b1d7a7..0000000
--- a/tests/CustomInputTestService/readme.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# Custom Input Event
-
-## Building
-```bash
-make CustomInputTestService -j64
-```
-
-### Installing
-```bash
-adb install $OUT/target/product/emulator_car_x86/system/app/CustomInputTestService/CustomInputTestService.apk
-```
-
-## Start CustomInputTestService
-```bash
-adb shell am start-foreground-service com.android.car.custominput.test/.CustomInputTestService
-```
-
-### Running tests
-
-Steps to run unit tests:
-
-1. Build and install CustomInputTestService.apk (see above sections).
-1. Then run:
-
-```bash
-atest CustomInputTestServiceTest
-```
-
-## Inject events (test scripts)
-
-These are the test scripts to demonstrate how CustomInputEvent can be used to implement OEM
-partners non-standard events. They all represent hypothetical features for the sake of documentation
- only.
-
-*Note*: Make sure CustomInputTestService is installed and started. Especially if you've just
- ran tests. Depending on the configuration you use, running CustomInputTestServiceTest may
- uninstall CustomInputTestService.
-
-### Inject Maps event from steering wheel control
-
-For this example, press home first, then inject the event to start Maps activity by running:
-
-```
-adb shell cmd car_service inject-custom-input -d 0 -customEvent f1
-```
-
-Parameters are:
-* `-d 0`: sets target display type to main display;
-* `-customEvent f1`: sets the OEM partner function to execute. In this implementation, `f1` argument
- represents the action used to launch Google maps app;
-
-*Note*: For this command to run, make sure Google Maps app is installed first.
diff --git a/tests/CustomInputTestService/Android.bp b/tests/SampleCustomInputService/Android.bp
similarity index 89%
rename from tests/CustomInputTestService/Android.bp
rename to tests/SampleCustomInputService/Android.bp
index 18c45db..355860e 100644
--- a/tests/CustomInputTestService/Android.bp
+++ b/tests/SampleCustomInputService/Android.bp
@@ -13,15 +13,15 @@
// limitations under the License.
filegroup {
- name: "CustomInputTestService-srcs",
+ name: "SampleCustomInputService-srcs",
srcs: [
"src/**/*.java",
],
}
android_app {
- name: "CustomInputTestService",
- srcs: [":CustomInputTestService-srcs"],
+ name: "SampleCustomInputService",
+ srcs: [":SampleCustomInputService-srcs"],
resource_dirs: ["res"],
// Because it uses a platform API (CarInputManager).
@@ -51,11 +51,11 @@
}
android_test {
- name: "CustomInputTestServiceTest",
+ name: "SampleCustomInputServiceTest",
srcs: [
"tests/src/**/*.java",
- ":CustomInputTestService-srcs",
+ ":SampleCustomInputService-srcs",
],
manifest: "tests/AndroidManifest.xml",
diff --git a/tests/SampleCustomInputService/AndroidManifest.xml b/tests/SampleCustomInputService/AndroidManifest.xml
new file mode 100644
index 0000000..964e477
--- /dev/null
+++ b/tests/SampleCustomInputService/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.car.custominput.sample">
+
+ <uses-permission android:name="android.permission.MONITOR_INPUT"/>
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
+
+ <application>
+ <service android:name=".SampleCustomInputService"
+ android:exported="true" android:enabled="true">
+ <intent-filter>
+ <action android:name="com.android.car.custominput.action.START_SILENT"/>
+ </intent-filter>
+ </service>
+ </application>
+</manifest>
+
diff --git a/tests/SampleCustomInputService/readme.md b/tests/SampleCustomInputService/readme.md
new file mode 100644
index 0000000..8789d6a
--- /dev/null
+++ b/tests/SampleCustomInputService/readme.md
@@ -0,0 +1,52 @@
+# Custom Input Event
+
+## Building
+```bash
+make SampleCustomInputService -j64
+```
+
+### Installing
+```bash
+adb install $OUT/target/product/emulator_car_x86/system/app/SampleCustomInputService/SampleCustomInputService.apk
+```
+
+## Start SampleCustomInputService
+```bash
+adb shell am start-foreground-service com.android.car.custominput.sample/.SampleCustomInputService
+```
+
+### Running tests
+
+Steps to run unit tests:
+
+1. Build and install SampleCustomInputService.apk (see above sections).
+1. Then run:
+
+```bash
+atest SampleCustomInputServiceTest
+```
+
+## Inject events (test scripts)
+
+These are the test scripts to demonstrate how CustomInputEvent can be used to implement OEM
+partners non-standard events. They all represent hypothetical features for the sake of documentation
+ only.
+
+*Note*: Make sure SampleCustomInputService is installed and started. Especially if you've just
+ ran tests. Depending on the configuration you use, running SampleCustomInputServiceTest may
+ uninstall SampleCustomInputService.
+
+### Inject Maps event from steering wheel control
+
+For this example, press home first, then inject the event to start Maps activity by running:
+
+```
+adb shell cmd car_service inject-custom-input -d 0 f1
+```
+
+Parameters are:
+* `-d 0`: sets target display type to main display;
+* `f1`: sets the OEM partner function `f1` to execute. In this implementation, `f1` argument
+ represents the action used to launch Google maps app;
+
+*Note*: For this command to run, ensure that Google Maps app is installed first.
diff --git a/tests/CustomInputTestService/res/drawable/custom_input_ref_service.png b/tests/SampleCustomInputService/res/drawable/custom_input_ref_service.png
similarity index 100%
rename from tests/CustomInputTestService/res/drawable/custom_input_ref_service.png
rename to tests/SampleCustomInputService/res/drawable/custom_input_ref_service.png
Binary files differ
diff --git a/tests/CustomInputTestService/res/values/strings.xml b/tests/SampleCustomInputService/res/values/strings.xml
similarity index 100%
rename from tests/CustomInputTestService/res/values/strings.xml
rename to tests/SampleCustomInputService/res/values/strings.xml
diff --git a/tests/CustomInputTestService/src/com/android/car/custominput/test/CustomInputEventListener.java b/tests/SampleCustomInputService/src/com/android/car/custominput/sample/CustomInputEventListener.java
similarity index 94%
rename from tests/CustomInputTestService/src/com/android/car/custominput/test/CustomInputEventListener.java
rename to tests/SampleCustomInputService/src/com/android/car/custominput/sample/CustomInputEventListener.java
index 805565a..1c37096 100644
--- a/tests/CustomInputTestService/src/com/android/car/custominput/test/CustomInputEventListener.java
+++ b/tests/SampleCustomInputService/src/com/android/car/custominput/sample/CustomInputEventListener.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.car.custominput.test;
+package com.android.car.custominput.sample;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -31,15 +31,14 @@
/**
* Handles incoming {@link CustomInputEvent}. In this implementation, incoming events are expected
- * to have the display id set, the event input type is represented by the value passed in
- * `-customEvent` flag (see {@link EventAction} for the available actions).
+ * to have the display id and the function set.
*/
final class CustomInputEventListener {
private static final String TAG = CustomInputEventListener.class.getSimpleName();
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- private final CustomInputTestService mService;
+ private final SampleCustomInputService mService;
private final Context mContext;
/** List of defined actions for this reference service implementation */
@@ -67,7 +66,7 @@
CustomInputEventListener(
@NonNull Context context,
- @NonNull CustomInputTestService service) {
+ @NonNull SampleCustomInputService service) {
mContext = context;
mService = service;
}
diff --git a/tests/CustomInputTestService/src/com/android/car/custominput/test/CustomInputTestService.java b/tests/SampleCustomInputService/src/com/android/car/custominput/sample/SampleCustomInputService.java
similarity index 90%
rename from tests/CustomInputTestService/src/com/android/car/custominput/test/CustomInputTestService.java
rename to tests/SampleCustomInputService/src/com/android/car/custominput/sample/SampleCustomInputService.java
index ea30930..ced6e63 100644
--- a/tests/CustomInputTestService/src/com/android/car/custominput/test/CustomInputTestService.java
+++ b/tests/SampleCustomInputService/src/com/android/car/custominput/sample/SampleCustomInputService.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.car.custominput.test;
+package com.android.car.custominput.sample;
import static android.car.input.CarInputManager.TargetDisplayType;
@@ -35,14 +35,13 @@
* This service is a reference implementation to be used as an example on how to define and handle
* HW_CUSTOM_INPUT events.
*/
-// TODO(b/12219669): Rename this to CustomInputSampleService
-public class CustomInputTestService extends Service implements
+public class SampleCustomInputService extends Service implements
CarInputManager.CarInputCaptureCallback {
- private static final String TAG = CustomInputTestService.class.getSimpleName();
+ private static final String TAG = SampleCustomInputService.class.getSimpleName();
private static final boolean DEBUG = false;
- private static final String CHANNEL_ID = CustomInputTestService.class.getSimpleName();
+ private static final String CHANNEL_ID = SampleCustomInputService.class.getSimpleName();
private static final int FOREGROUND_ID = 1;
private Car mCar;
@@ -64,7 +63,7 @@
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
Notification notification = new Notification.Builder(getApplicationContext(), CHANNEL_ID)
- .setContentTitle("CustomInputTestService")
+ .setContentTitle("SampleCustomInputService")
.setContentText("Processing...")
.setSmallIcon(R.drawable.custom_input_ref_service)
.build();
diff --git a/tests/CustomInputTestService/tests/AndroidManifest.xml b/tests/SampleCustomInputService/tests/AndroidManifest.xml
similarity index 86%
rename from tests/CustomInputTestService/tests/AndroidManifest.xml
rename to tests/SampleCustomInputService/tests/AndroidManifest.xml
index d32e506..b2c441a 100644
--- a/tests/CustomInputTestService/tests/AndroidManifest.xml
+++ b/tests/SampleCustomInputService/tests/AndroidManifest.xml
@@ -16,11 +16,11 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.car.custominput.test" >
+ package="com.android.car.custominput.sample">
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.car.custominput.test"
- android:label="Unit Tests for CustomInputTestService"/>
+ android:targetPackage="com.android.car.custominput.sample"
+ android:label="Unit Tests for SampleCustomInputService"/>
<application android:debuggable="true">
<uses-library android:name="android.test.runner"/>
diff --git a/tests/CustomInputTestService/tests/src/com/android/car/custominput/test/CustomInputEventListenerTest.java b/tests/SampleCustomInputService/tests/src/com/android/car/custominput/sample/CustomInputEventListenerTest.java
similarity index 97%
rename from tests/CustomInputTestService/tests/src/com/android/car/custominput/test/CustomInputEventListenerTest.java
rename to tests/SampleCustomInputService/tests/src/com/android/car/custominput/sample/CustomInputEventListenerTest.java
index b4e1e4f..b69e07a 100644
--- a/tests/CustomInputTestService/tests/src/com/android/car/custominput/test/CustomInputEventListenerTest.java
+++ b/tests/SampleCustomInputService/tests/src/com/android/car/custominput/sample/CustomInputEventListenerTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.car.custominput.test;
+package com.android.car.custominput.sample;
import static com.google.common.truth.Truth.assertThat;
@@ -46,7 +46,7 @@
private Context mContext;
@Mock
- private CustomInputTestService mService;
+ private SampleCustomInputService mService;
@Before
public void setUp() {