Convert InputClassifier HAL to AIDL
No changes to the HAL are made in this change, we are only updating the
interface to use AIDL.
At the same time, the HAL is getting renamed to 'InputProcessor', which
will mean that it's more general-purpose than just classification. We
will be adding more stuff to this HAL in the future.
Bug: 167946763
Bug: 205761620
Test: integration tested with other framework changes on top
Change-Id: I8046cd5c74e1b69f85f21b28d5c4c3b88a61bb33
diff --git a/input/processor/aidl/default/Android.bp b/input/processor/aidl/default/Android.bp
new file mode 100644
index 0000000..f485597
--- /dev/null
+++ b/input/processor/aidl/default/Android.bp
@@ -0,0 +1,54 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_library_static {
+ name: "libinputprocessorexampleimpl",
+ vendor: true,
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "liblog",
+ "libutils",
+ "android.hardware.input.common-V1-ndk",
+ "android.hardware.input.processor-V1-ndk",
+ ],
+ export_include_dirs: ["include"],
+ srcs: [
+ "InputProcessor.cpp",
+ ],
+ visibility: [
+ ":__subpackages__",
+ "//hardware/interfaces/tests/extension/input/processor:__subpackages__",
+ ],
+}
+
+filegroup {
+ name: "android.hardware.input.processor.xml",
+ srcs: ["android.hardware.input.processor.xml"],
+}
+
+cc_binary {
+ name: "android.hardware.input.processor-service.example",
+ relative_install_path: "hw",
+ init_rc: ["inputprocessor-default.rc"],
+ vintf_fragments: [":android.hardware.input.processor.xml"],
+ vendor: true,
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "liblog",
+ "libutils",
+ "android.hardware.input.common-V1-ndk",
+ "android.hardware.input.processor-V1-ndk",
+ ],
+ static_libs: [
+ "libinputprocessorexampleimpl",
+ ],
+ srcs: ["main.cpp"],
+}
diff --git a/input/processor/aidl/default/InputProcessor.cpp b/input/processor/aidl/default/InputProcessor.cpp
new file mode 100644
index 0000000..fb6bbd5
--- /dev/null
+++ b/input/processor/aidl/default/InputProcessor.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include "inputprocessor-impl/InputProcessor.h"
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace input {
+namespace processor {
+
+using ::aidl::android::hardware::input::common::Classification;
+using aidl::android::hardware::input::common::MotionEvent;
+
+::ndk::ScopedAStatus InputProcessor::classify(const MotionEvent& /*in_event*/,
+ Classification* _aidl_return) {
+ *_aidl_return = Classification::NONE;
+ return ndk::ScopedAStatus::ok();
+}
+::ndk::ScopedAStatus InputProcessor::reset() {
+ return ndk::ScopedAStatus::ok();
+}
+::ndk::ScopedAStatus InputProcessor::resetDevice(int32_t /*in_deviceId*/) {
+ return ndk::ScopedAStatus::ok();
+}
+
+} // namespace processor
+} // namespace input
+} // namespace hardware
+} // namespace android
+} // namespace aidl
\ No newline at end of file
diff --git a/input/processor/aidl/default/android.hardware.input.processor.xml b/input/processor/aidl/default/android.hardware.input.processor.xml
new file mode 100644
index 0000000..5ecbd2a
--- /dev/null
+++ b/input/processor/aidl/default/android.hardware.input.processor.xml
@@ -0,0 +1,7 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.input.processor</name>
+ <version>1</version>
+ <fqname>IInputProcessor/default</fqname>
+ </hal>
+</manifest>
\ No newline at end of file
diff --git a/input/processor/aidl/default/include/inputprocessor-impl/InputProcessor.h b/input/processor/aidl/default/include/inputprocessor-impl/InputProcessor.h
new file mode 100644
index 0000000..0d6bc58
--- /dev/null
+++ b/input/processor/aidl/default/include/inputprocessor-impl/InputProcessor.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/input/processor/BnInputProcessor.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace input {
+namespace processor {
+
+class InputProcessor : public ::aidl::android::hardware::input::processor::BnInputProcessor {
+ public:
+ ::ndk::ScopedAStatus classify(
+ const ::aidl::android::hardware::input::common::MotionEvent& in_event,
+ ::aidl::android::hardware::input::common::Classification* _aidl_return) override;
+ ::ndk::ScopedAStatus reset() override;
+ ::ndk::ScopedAStatus resetDevice(int32_t in_deviceId) override;
+};
+
+} // namespace processor
+} // namespace input
+} // namespace hardware
+} // namespace android
+} // namespace aidl
\ No newline at end of file
diff --git a/input/processor/aidl/default/inputprocessor-default.rc b/input/processor/aidl/default/inputprocessor-default.rc
new file mode 100644
index 0000000..bcc6c02
--- /dev/null
+++ b/input/processor/aidl/default/inputprocessor-default.rc
@@ -0,0 +1,4 @@
+service vendor.inputprocessor-default /vendor/bin/hw/android.hardware.input.processor-service.example
+ class hal
+ user nobody
+ group nobody
\ No newline at end of file
diff --git a/input/processor/aidl/default/main.cpp b/input/processor/aidl/default/main.cpp
new file mode 100644
index 0000000..7b519dd
--- /dev/null
+++ b/input/processor/aidl/default/main.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include "inputprocessor-impl/InputProcessor.h"
+
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+using ::aidl::android::hardware::input::processor::IInputProcessor;
+using ::aidl::android::hardware::input::processor::InputProcessor;
+
+int main() {
+ ABinderProcess_setThreadPoolMaxThreadCount(0);
+
+ auto processor = ndk::SharedRefBase::make<InputProcessor>();
+ const std::string name = std::string() + InputProcessor::descriptor + "/default";
+ binder_status_t status = AServiceManager_addService(processor->asBinder().get(), name.c_str());
+ CHECK_EQ(status, STATUS_OK);
+
+ ABinderProcess_joinThreadPool();
+ return EXIT_FAILURE; // should not reach
+}
\ No newline at end of file