diff --git a/tv/input/OWNERS b/tv/input/OWNERS index a02291a3c2..ae65f674b0 100644 --- a/tv/input/OWNERS +++ b/tv/input/OWNERS @@ -1,3 +1,4 @@ +# Bug component: 105688 hgchen@google.com shubang@google.com quxiangfang@google.com diff --git a/tv/input/aidl/Android.bp b/tv/input/aidl/Android.bp index 1987174990..2591151fe8 100644 --- a/tv/input/aidl/Android.bp +++ b/tv/input/aidl/Android.bp @@ -14,6 +14,7 @@ aidl_interface { imports: [ "android.hardware.common-V2", "android.media.audio.common.types-V1", + "android.hardware.common.fmq-V1", ], stability: "vintf", backend: { diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl index f8d5e058d4..84fe2fb7d7 100644 --- a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl +++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl @@ -38,6 +38,8 @@ interface ITvInput { android.hardware.tv.input.TvStreamConfig[] getStreamConfigurations(in int deviceId); android.hardware.common.NativeHandle openStream(in int deviceId, in int streamId); void setCallback(in android.hardware.tv.input.ITvInputCallback callback); + void setTvMessageEnabled(int deviceId, int streamId, in android.hardware.tv.input.TvMessageEventType type, boolean enabled); + void getTvMessageQueueDesc(out android.hardware.common.fmq.MQDescriptor queue, int deviceId, int streamId); const int STATUS_UNKNOWN = 1; const int STATUS_NO_RESOURCE = 2; const int STATUS_INVALID_ARGUMENTS = 3; diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl index 7f2aff6d78..974701341c 100644 --- a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl +++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl @@ -35,4 +35,5 @@ package android.hardware.tv.input; @VintfStability interface ITvInputCallback { void notify(in android.hardware.tv.input.TvInputEvent event); + void notifyTvMessageEvent(in android.hardware.tv.input.TvMessageEvent event); } diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessage.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessage.aidl new file mode 100644 index 0000000000..637b01cc6f --- /dev/null +++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessage.aidl @@ -0,0 +1,40 @@ +/* + * Copyright 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.tv.input; +@VintfStability +parcelable TvMessage { + String subType; + long groupId; + int dataLengthBytes; +} diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEvent.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEvent.aidl new file mode 100644 index 0000000000..94fe665d1d --- /dev/null +++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEvent.aidl @@ -0,0 +1,40 @@ +/* + * Copyright 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.tv.input; +@VintfStability +parcelable TvMessageEvent { + android.hardware.tv.input.TvMessageEventType type; + int streamId; + android.hardware.tv.input.TvMessage[] messages; +} diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEventType.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEventType.aidl new file mode 100644 index 0000000000..a033903814 --- /dev/null +++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEventType.aidl @@ -0,0 +1,40 @@ +/* + * Copyright 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.tv.input; +@Backing(type="int") @VintfStability +enum TvMessageEventType { + WATERMARK = 1, + CLOSED_CAPTION = 2, + OTHER = 3, +} diff --git a/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl b/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl index 31d6586135..cbaf0663b6 100644 --- a/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl +++ b/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl @@ -17,7 +17,10 @@ package android.hardware.tv.input; import android.hardware.common.NativeHandle; +import android.hardware.common.fmq.MQDescriptor; +import android.hardware.common.fmq.SynchronizedReadWrite; import android.hardware.tv.input.ITvInputCallback; +import android.hardware.tv.input.TvMessageEventType; import android.hardware.tv.input.TvStreamConfig; @VintfStability @@ -73,4 +76,32 @@ interface ITvInput { * @throws ServiceSpecificException with values from the ITvInput::STATUS_* constants */ void setCallback(in ITvInputCallback callback); + + /** + * Enables or disables TV message detection for the specified stream on the device. + * + * @param deviceId The ID of the device that contains the stream to set the flag for. + * @param streamId The ID of the stream to set the flag for. + * @param type The type of {@link android.hardware.tv.input.TvMessageEventType}. + * @param enabled {@code true} if you want to enable TV message detection + * {@code false} otherwise. + */ + void setTvMessageEnabled( + int deviceId, int streamId, in TvMessageEventType type, boolean enabled); + + /** + * Gets the TV message queue for the specified stream on the device. + * + * The FMQ is used to relay events that are parsed from the specified stream to the + * app or service responsible for processing the message. The HAL implementation + * is expected to parse these messages and add them to the queue as new events are + * detected from the stream based on whether or not they are enabled by + * {@link #setTvMessageEnabled(int, int, TvMessageEventType, boolean)}. + * + * @param deviceId The ID of the device that contains the stream to get the queue for. + * @param streamId THe ID of the stream to get the queue for. + * @return The descriptor of the TV message queue. + */ + void getTvMessageQueueDesc( + out MQDescriptor queue, int deviceId, int streamId); } diff --git a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl index fc7492d7b4..5d4731737b 100644 --- a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl +++ b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl @@ -17,6 +17,7 @@ package android.hardware.tv.input; import android.hardware.tv.input.TvInputEvent; +import android.hardware.tv.input.TvMessageEvent; @VintfStability interface ITvInputCallback { @@ -27,4 +28,11 @@ interface ITvInputCallback { * @param event Event passed to the client. */ void notify(in TvInputEvent event); + /** + * Notifies the client that an TV message event has occurred. For possible event types, + * check TvMessageEventType. + * + * @param event Event passed to the client. + */ + void notifyTvMessageEvent(in TvMessageEvent event); } diff --git a/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl b/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl new file mode 100644 index 0000000000..6df1f9a25b --- /dev/null +++ b/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl @@ -0,0 +1,35 @@ +/* + * Copyright 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. + */ + +package android.hardware.tv.input; + +@VintfStability +parcelable TvMessage { + /** + * Extended data type, like “ATSC A/336 Watermark”, “ATSC_CC”, etc. This is opaque + * to the framework. + */ + String subType; + /** + * This group id is used to optionally identify messages that belong together, such as + * headers and bodies of the same event. For messages that do not have a group, this value + * should be -1. + * + * As -1 is a reserved value, -1 should not be used as a valid groupId. + */ + long groupId; + int dataLengthBytes; +} diff --git a/tv/input/aidl/android/hardware/tv/input/TvMessageEvent.aidl b/tv/input/aidl/android/hardware/tv/input/TvMessageEvent.aidl new file mode 100644 index 0000000000..74a078a45e --- /dev/null +++ b/tv/input/aidl/android/hardware/tv/input/TvMessageEvent.aidl @@ -0,0 +1,28 @@ +/* + * Copyright 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. + */ + +package android.hardware.tv.input; + +import android.hardware.tv.input.TvMessage; +import android.hardware.tv.input.TvMessageEventType; + +@VintfStability +parcelable TvMessageEvent { + TvMessageEventType type; + + int streamId; + TvMessage[] messages; +} diff --git a/tv/input/aidl/android/hardware/tv/input/TvMessageEventType.aidl b/tv/input/aidl/android/hardware/tv/input/TvMessageEventType.aidl new file mode 100644 index 0000000000..5a5f472a77 --- /dev/null +++ b/tv/input/aidl/android/hardware/tv/input/TvMessageEventType.aidl @@ -0,0 +1,25 @@ +/* + * Copyright 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. + */ + +package android.hardware.tv.input; + +@VintfStability +@Backing(type="int") +enum TvMessageEventType { + WATERMARK = 1, + CLOSED_CAPTION = 2, + OTHER = 3, +} diff --git a/tv/input/aidl/default/Android.bp b/tv/input/aidl/default/Android.bp index 66148c8aaa..05af6a94fb 100644 --- a/tv/input/aidl/default/Android.bp +++ b/tv/input/aidl/default/Android.bp @@ -13,6 +13,10 @@ cc_binary { init_rc: ["input-default.rc"], vintf_fragments: ["input-default.xml"], vendor: true, + cflags: [ + "-Werror", + "-Wno-unused-parameter", + ], srcs: [ "TvInput.cpp", "service.cpp", @@ -23,9 +27,11 @@ cc_binary { shared_libs: [ "libbase", "liblog", + "libfmq", "libutils", "libcutils", "libbinder_ndk", "android.hardware.tv.input-V1-ndk", + "android.hardware.common.fmq-V1-ndk", ], } diff --git a/tv/input/aidl/default/TvInput.cpp b/tv/input/aidl/default/TvInput.cpp index ed12cbc92d..47f8be5e39 100644 --- a/tv/input/aidl/default/TvInput.cpp +++ b/tv/input/aidl/default/TvInput.cpp @@ -65,6 +65,21 @@ void TvInput::init() { return ::ndk::ScopedAStatus::ok(); } +::ndk::ScopedAStatus TvInput::setTvMessageEnabled(int32_t deviceId, int32_t streamId, + TvMessageEventType in_type, bool enabled) { + ALOGV("%s", __FUNCTION__); + // TODO: Implement this + return ::ndk::ScopedAStatus::ok(); +} + +::ndk::ScopedAStatus TvInput::getTvMessageQueueDesc( + MQDescriptor* out_queue, int32_t in_deviceId, + int32_t in_streamId) { + ALOGV("%s", __FUNCTION__); + // TODO: Implement this + return ::ndk::ScopedAStatus::ok(); +} + ::ndk::ScopedAStatus TvInput::getStreamConfigurations(int32_t in_deviceId, vector* _aidl_return) { ALOGV("%s", __FUNCTION__); diff --git a/tv/input/aidl/default/TvInput.h b/tv/input/aidl/default/TvInput.h index a72bca3806..9cb7ae6fe2 100644 --- a/tv/input/aidl/default/TvInput.h +++ b/tv/input/aidl/default/TvInput.h @@ -19,6 +19,8 @@ #include #include +#include +#include #include #include "TvInputDeviceInfoWrapper.h" #include "TvStreamConfigWrapper.h" @@ -26,6 +28,9 @@ using namespace android; using namespace std; using ::aidl::android::hardware::common::NativeHandle; +using ::aidl::android::hardware::common::fmq::MQDescriptor; +using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite; +using ::android::AidlMessageQueue; namespace aidl { namespace android { @@ -38,6 +43,11 @@ class TvInput : public BnTvInput { TvInput(); ::ndk::ScopedAStatus setCallback(const shared_ptr& in_callback) override; + ::ndk::ScopedAStatus setTvMessageEnabled(int32_t deviceId, int32_t streamId, + TvMessageEventType in_type, bool enabled) override; + ::ndk::ScopedAStatus getTvMessageQueueDesc( + MQDescriptor* out_queue, int32_t in_deviceId, + int32_t in_streamId) override; ::ndk::ScopedAStatus getStreamConfigurations(int32_t in_deviceId, vector* _aidl_return) override; ::ndk::ScopedAStatus openStream(int32_t in_deviceId, int32_t in_streamId, diff --git a/tv/input/aidl/vts/functional/Android.bp b/tv/input/aidl/vts/functional/Android.bp index 9829b6d679..22487eafb1 100644 --- a/tv/input/aidl/vts/functional/Android.bp +++ b/tv/input/aidl/vts/functional/Android.bp @@ -9,10 +9,16 @@ package { cc_test { name: "VtsHalTvInputTargetTest", - defaults: ["VtsHalTargetTestDefaults","use_libaidlvintf_gtest_helper_static",], + defaults: [ + "VtsHalTargetTestDefaults", + "use_libaidlvintf_gtest_helper_static", + ], + cflags: [ + "-Werror", + "-Wno-unused-parameter", + ], srcs: ["VtsHalTvInputTargetTest.cpp"], static_libs: [ - "android.hardware.tv.input-V1-ndk", "android.media.audio.common.types-V1-ndk", "android.hardware.common-V2-ndk", "libaidlcommonsupport", @@ -24,6 +30,9 @@ cc_test { shared_libs: [ "libbinder_ndk", "libvndksupport", + "libfmq", + "android.hardware.common.fmq-V1-ndk", + "android.hardware.tv.input-V1-ndk", ], require_root: true, } diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp index ec83e29bfd..9c2606984b 100644 --- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp +++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp @@ -43,6 +43,11 @@ TvInputAidlTest::TvInputCallback::TvInputCallback(shared_ptr pa return ::ndk::ScopedAStatus::ok(); } +::ndk::ScopedAStatus TvInputAidlTest::TvInputCallback::notifyTvMessageEvent( + const TvMessageEvent& in_event) { + return ::ndk::ScopedAStatus::ok(); +} + void TvInputAidlTest::SetUp() { if (AServiceManager_isDeclared(GetParam().c_str())) { ::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str())); diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h index c76e5686fc..693d49dd40 100644 --- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h +++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h @@ -25,15 +25,19 @@ #include #include #include +#include +#include #include +#include #include #include using namespace aidl::android::hardware::tv::input; using namespace std; - using ::aidl::android::hardware::common::NativeHandle; +using ::aidl::android::hardware::common::fmq::MQDescriptor; +using ::android::AidlMessageQueue; #define WAIT_FOR_EVENT_TIMEOUT 5 #define DEFAULT_ID INT32_MIN @@ -46,6 +50,7 @@ class TvInputAidlTest : public testing::TestWithParam { public: TvInputCallback(shared_ptr parent); ::ndk::ScopedAStatus notify(const TvInputEvent& in_event) override; + ::ndk::ScopedAStatus notifyTvMessageEvent(const TvMessageEvent& in_event) override; private: shared_ptr parent_;