Communication Controller server for Audio Test Harness

The proto file defines communication request and response for
Device-Host communication and CommunicationServiceImpl class is
responsible for executing the request sent from Device.
The workflow is:
1. Device send StreamAudioRequest.
2. Server receives the requests, executes the command and starts
streaming back the captured Audio data back to Device.
3. Device receives streamed data and parse its results.

Bug: 151768015
Test: Manual for now.
Change-Id: I810b52912b25cdafced4d5e378c0a0eec7bad4c0
diff --git a/libraries/audio-test-harness/Android.bp b/libraries/audio-test-harness/Android.bp
new file mode 100644
index 0000000..7437132
--- /dev/null
+++ b/libraries/audio-test-harness/Android.bp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+filegroup {
+    name: "CommunicationControllerProto",
+    srcs: [
+        "proto/communication_service.proto",
+    ],
+}
+
+genrule {
+    name: "CommunicationControllerStub",
+    tools: [
+        "aprotoc",
+        "protoc-gen-grpc-java-plugin",
+        "soong_zip",
+    ],
+    cmd: "mkdir -p $(genDir)/gen && " +
+        "$(location aprotoc) -Iplatform_testing/libraries -Iexternal/protobuf/src --plugin=protoc-gen-grpc-java=$(location protoc-gen-grpc-java-plugin) --grpc-java_out=$(genDir)/gen $(in) && " +
+        "$(location soong_zip) -o $(out) -C $(genDir)/gen -D $(genDir)/gen",
+    srcs: [
+        ":CommunicationControllerProto",
+    ],
+    out: [
+        "protos.srcjar",
+    ],
+}
+
+java_library_host {
+    name: "communication_controller_server",
+    srcs: [
+        "src/android/media/server/CommunicationServiceImpl.java",
+        ":CommunicationControllerStub",
+        ":CommunicationControllerProto",
+    ],
+    static_libs: [
+        "libprotobuf-java-full",
+        "grpc-java",
+        "guava",
+    ],
+    java_version: "1.8",
+    proto: {
+        type: "full",
+    },
+}
diff --git a/libraries/audio-test-harness/proto/communication_service.proto b/libraries/audio-test-harness/proto/communication_service.proto
new file mode 100644
index 0000000..d70ebb5
--- /dev/null
+++ b/libraries/audio-test-harness/proto/communication_service.proto
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+package media.audio.test.harness;
+
+option java_package = "com.android.media.audio.test.harness.proto";
+
+
+// The Device-Host communication service definition.
+service CommunicationService {
+  // Processes request sent from Device to start audio recording.
+  rpc CaptureAudioStream(StreamAudioRecordRequest) returns (stream AudioData) {}
+}
+
+// Request to start audio record on the Host and stream recorded result back to
+// Device.
+message StreamAudioRecordRequest{
+  // TODO: this needs to be implemented.
+}
+
+// AudioData that is recorded on the Host and to be streamed back to Device.
+message AudioData {
+  // TODO: this needs to be implemented.
+}
diff --git a/libraries/audio-test-harness/src/android/media/server/CommunicationServiceImpl.java b/libraries/audio-test-harness/src/android/media/server/CommunicationServiceImpl.java
new file mode 100644
index 0000000..0e552ed
--- /dev/null
+++ b/libraries/audio-test-harness/src/android/media/server/CommunicationServiceImpl.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/** CommunicationService is responsible for Device-Host request processing. */
+package com.android.media.audio.test.harness.server;
+
+import io.grpc.stub.StreamObserver;
+
+import com.android.media.audio.test.harness.proto.CommunicationServiceGrpc;
+import com.android.media.audio.test.harness.proto.CommunicationServiceOuterClass.StreamAudioRecordRequest;
+import com.android.media.audio.test.harness.proto.CommunicationServiceOuterClass.AudioData;
+
+/**
+ * CommunicationServiceImpl implements methods defined in communication_service.proto.
+ *
+ * <p>This class is responsible for processing request sent from Device, executes the corresponding
+ * commands on Host and sends back response if required.
+ */
+public class CommunicationServiceImpl
+        extends CommunicationServiceGrpc.CommunicationServiceImplBase {
+
+    @Override
+    public void captureAudioStream(
+            StreamAudioRecordRequest request, StreamObserver<AudioData> responseObserver) {}
+}