Merge "Coalesce OWNERS and add component"
diff --git a/audio/aidl/Android.bp b/audio/aidl/Android.bp
index 4871058..4e50b7a 100644
--- a/audio/aidl/Android.bp
+++ b/audio/aidl/Android.bp
@@ -148,11 +148,20 @@
name: "android.hardware.audio.effect",
vendor_available: true,
srcs: [
+ "android/hardware/audio/effect/Capability.aidl",
+ "android/hardware/audio/effect/CommandId.aidl",
"android/hardware/audio/effect/Descriptor.aidl",
+ "android/hardware/audio/effect/Equalizer.aidl",
+ "android/hardware/audio/effect/Flags.aidl",
"android/hardware/audio/effect/IEffect.aidl",
"android/hardware/audio/effect/IFactory.aidl",
+ "android/hardware/audio/effect/Parameter.aidl",
+ "android/hardware/audio/effect/Processing.aidl",
+ "android/hardware/audio/effect/State.aidl",
],
imports: [
+ "android.hardware.common-V2",
+ "android.hardware.common.fmq-V1",
"android.hardware.audio.common-V1",
"android.media.audio.common.types-V2",
],
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
new file mode 100644
index 0000000..11acf5e
--- /dev/null
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.audio.effect;
+@VintfStability
+union Capability {
+ android.hardware.audio.effect.Capability.VendorEffectCapability vendor;
+ android.hardware.audio.effect.Equalizer.Capability equalizer;
+ @VintfStability
+ parcelable VendorEffectCapability {
+ ParcelableHolder extension;
+ }
+}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/CommandId.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/CommandId.aidl
new file mode 100644
index 0000000..79299ee
--- /dev/null
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/CommandId.aidl
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.audio.effect;
+@Backing(type="int") @VintfStability
+enum CommandId {
+ START = 0,
+ STOP = 1,
+ RESET = 2,
+ VENDOR_COMMAND_0 = 256,
+ VENDOR_COMMAND_1 = 257,
+ VENDOR_COMMAND_2 = 258,
+ VENDOR_COMMAND_3 = 259,
+ VENDOR_COMMAND_4 = 260,
+ VENDOR_COMMAND_5 = 261,
+ VENDOR_COMMAND_6 = 262,
+ VENDOR_COMMAND_7 = 263,
+ VENDOR_COMMAND_8 = 264,
+ VENDOR_COMMAND_9 = 265,
+}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl
index 94cacd9..07b25f8 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl
@@ -35,6 +35,7 @@
@VintfStability
parcelable Descriptor {
android.hardware.audio.effect.Descriptor.Common common;
+ android.hardware.audio.effect.Capability capability;
const String EFFECT_TYPE_UUID_ENV_REVERB = "c2e5d5f0-94bd-4763-9cac-4e234d06839e";
const String EFFECT_TYPE_UUID_PRESET_REVERB = "47382d60-ddd8-11db-bf3a-0002a5d5c51b";
const String EFFECT_TYPE_UUID_EQUALIZER = "0bed4300-ddd6-11db-8f34-0002a5d5c51b";
@@ -52,6 +53,8 @@
parcelable Identity {
android.media.audio.common.AudioUuid type;
android.media.audio.common.AudioUuid uuid;
+ @nullable android.media.audio.common.AudioUuid proxy;
+ android.hardware.audio.effect.Flags flags;
}
@VintfStability
parcelable Common {
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
new file mode 100644
index 0000000..31732d3
--- /dev/null
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.audio.effect;
+@VintfStability
+union Equalizer {
+ android.hardware.audio.effect.Equalizer.VendorExtension vendor;
+ @VintfStability
+ parcelable Capability {
+ ParcelableHolder extension;
+ }
+ @VintfStability
+ parcelable VendorExtension {
+ ParcelableHolder extension;
+ }
+}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Flags.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Flags.aidl
new file mode 100644
index 0000000..af774e8
--- /dev/null
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Flags.aidl
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.audio.effect;
+@VintfStability
+parcelable Flags {
+}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IEffect.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IEffect.aidl
index 7f868ad..e5c96f5 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IEffect.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IEffect.aidl
@@ -34,7 +34,23 @@
package android.hardware.audio.effect;
@VintfStability
interface IEffect {
- void open();
+ android.hardware.audio.effect.IEffect.OpenEffectReturn open(in android.hardware.audio.effect.Parameter.Common common, in android.hardware.audio.effect.Parameter.Specific specific);
void close();
android.hardware.audio.effect.Descriptor getDescriptor();
+ void command(in android.hardware.audio.effect.CommandId commandId);
+ android.hardware.audio.effect.State getState();
+ void setParameter(in android.hardware.audio.effect.Parameter param);
+ android.hardware.audio.effect.Parameter getParameter(in android.hardware.audio.effect.Parameter.Id paramId);
+ @FixedSize @VintfStability
+ parcelable Status {
+ int status;
+ int fmqByteConsumed;
+ int fmqByteProduced;
+ }
+ @VintfStability
+ parcelable OpenEffectReturn {
+ android.hardware.common.fmq.MQDescriptor<android.hardware.audio.effect.IEffect.Status,android.hardware.common.fmq.SynchronizedReadWrite> statusMQ;
+ android.hardware.common.fmq.MQDescriptor<byte,android.hardware.common.fmq.SynchronizedReadWrite> inputDataMQ;
+ android.hardware.common.fmq.MQDescriptor<byte,android.hardware.common.fmq.SynchronizedReadWrite> outputDataMQ;
+ }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl
index db06475..a22c591 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl
@@ -35,6 +35,7 @@
@VintfStability
interface IFactory {
android.hardware.audio.effect.Descriptor.Identity[] queryEffects(in @nullable android.media.audio.common.AudioUuid type, in @nullable android.media.audio.common.AudioUuid implementation);
+ android.hardware.audio.effect.Processing[] queryProcessing(in @nullable android.hardware.audio.effect.Processing.Type type);
android.hardware.audio.effect.IEffect createEffect(in android.media.audio.common.AudioUuid implUuid);
void destroyEffect(in android.hardware.audio.effect.IEffect handle);
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
new file mode 100644
index 0000000..16bd3bb
--- /dev/null
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.audio.effect;
+@VintfStability
+union Parameter {
+ android.hardware.audio.effect.Parameter.Common common;
+ android.hardware.audio.effect.Parameter.VendorEffectParameter vendorEffect;
+ android.hardware.audio.effect.Parameter.Specific specific;
+ @VintfStability
+ union Id {
+ int commonTag;
+ int vendorTag;
+ android.hardware.audio.effect.Parameter.Specific.Tag specificTag;
+ }
+ @VintfStability
+ parcelable Common {
+ int session;
+ int ioHandle;
+ android.media.audio.common.AudioDeviceDescription device;
+ android.media.audio.common.AudioConfig input;
+ android.media.audio.common.AudioConfig output;
+ }
+ @VintfStability
+ parcelable VendorEffectParameter {
+ ParcelableHolder extension;
+ }
+ @VintfStability
+ union Specific {
+ android.hardware.audio.effect.Equalizer equalizer;
+ }
+}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Processing.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Processing.aidl
new file mode 100644
index 0000000..a779ae4
--- /dev/null
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Processing.aidl
@@ -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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.audio.effect;
+@VintfStability
+parcelable Processing {
+ android.hardware.audio.effect.Processing.Type type;
+ android.hardware.audio.effect.Descriptor.Identity[] ids;
+ @VintfStability
+ union Type {
+ android.media.audio.common.AudioStreamType streamType = android.media.audio.common.AudioStreamType.INVALID;
+ android.media.audio.common.AudioSource source;
+ }
+}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/State.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/State.aidl
new file mode 100644
index 0000000..3176b01
--- /dev/null
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/State.aidl
@@ -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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.audio.effect;
+@Backing(type="byte") @VintfStability
+enum State {
+ INIT = 0,
+ IDLE = 1,
+ PROCESSING = 2,
+}
diff --git a/audio/aidl/android/hardware/audio/effect/Capability.aidl b/audio/aidl/android/hardware/audio/effect/Capability.aidl
new file mode 100644
index 0000000..e792f86
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/Capability.aidl
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package android.hardware.audio.effect;
+
+import android.hardware.audio.effect.Equalizer;
+
+/**
+ * Effect capability definitions.
+ * This data structure is used as part of effect Descriptor to identify effect capabilities which
+ * not meant to change at runtime.
+ */
+@VintfStability
+union Capability {
+ /**
+ * Vendor defined effect capability.
+ * This extension can be used when vendor have a new effect implementated and need
+ * capability definition for this new type of effect.
+ * If vendor want to extend existing effect capabilities, it is recommended to expose though
+ * the ParcelableHolder in each effect capability definition. For example:
+ * Equalizer.Capability.extension.
+ */
+ @VintfStability
+ parcelable VendorEffectCapability {
+ ParcelableHolder extension;
+ }
+ VendorEffectCapability vendor;
+
+ /**
+ * Equalizer capability definition.
+ */
+ Equalizer.Capability equalizer;
+}
diff --git a/audio/aidl/android/hardware/audio/effect/CommandId.aidl b/audio/aidl/android/hardware/audio/effect/CommandId.aidl
new file mode 100644
index 0000000..208c163
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/CommandId.aidl
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package android.hardware.audio.effect;
+
+/**
+ * Defines all commands supported by the effect instance.
+ *
+ * There are three groups of commands:
+ * 1. Common part which MUST be supported by all effects.
+ * 2. Commands MUST be supported by a specific type of effect.
+ * 3. Extension commands for vendor.
+ */
+@VintfStability
+@Backing(type="int")
+enum CommandId {
+ /// MUST be supported by all effects
+ /**
+ * Start effect engine processing.
+ * An effect instance must start processing data and transfer to PROCESSING state if it is in
+ * IDLE state and have all necessary information. Otherwise it must:
+ * 1. Throw a EX_ILLEGAL_STATE exception if effect is not in IDLE state, or
+ * 2. Throw a EX_TRANSACTION_FAILED for all other errors.
+ *
+ * Depending on parameters set to the effect instance, effect may do process or reverse
+ * process after START command.
+ */
+ START = 0,
+ /**
+ * Stop effect engine processing with all resource kept.
+ * The currently processed audio data will be discarded if the effect engine is in PROCESSING
+ * state.
+ * Effect instance must do nothing and return ok when it receive STOP command in IDLE state.
+ */
+ STOP = 1,
+ /**
+ * Keep all parameter settings but reset the buffer content, stop engine processing, and transit
+ * instance state to IDLE if its in PROCESSING state.
+ * Effect instance must be able to handle RESET command at IDLE and PROCESSING states.
+ */
+ RESET = 2,
+
+ /// MUST be supported by a specific type of effect.
+ // Commands must supported by Equalizer.
+
+ /// Extension commands for vendor.
+ VENDOR_COMMAND_0 = 0x100,
+ VENDOR_COMMAND_1,
+ VENDOR_COMMAND_2,
+ VENDOR_COMMAND_3,
+ VENDOR_COMMAND_4,
+ VENDOR_COMMAND_5,
+ VENDOR_COMMAND_6,
+ VENDOR_COMMAND_7,
+ VENDOR_COMMAND_8,
+ VENDOR_COMMAND_9,
+}
diff --git a/audio/aidl/android/hardware/audio/effect/Descriptor.aidl b/audio/aidl/android/hardware/audio/effect/Descriptor.aidl
index 51b31c2..9c18f2e 100644
--- a/audio/aidl/android/hardware/audio/effect/Descriptor.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Descriptor.aidl
@@ -16,12 +16,20 @@
package android.hardware.audio.effect;
+import android.hardware.audio.effect.Capability;
+import android.hardware.audio.effect.Flags;
import android.media.audio.common.AudioUuid;
/**
- * Effect descriptor contains all information (capabilities, attributes, and ownership) for an
- * effect implemented in the Audio Effect HAL. Framework uses this information to decide when and
- * how to apply the effect.
+ * Descriptor contains all information (capabilities, attributes, etc) for an effect implementation.
+ * The client uses this information to decide when and how to apply an effect implementation.
+ *
+ * Each type of effect can have more than one implementation (differentiated by implementation
+ * UUID), the effect proxy act as a combination of two implementations (usually one software and
+ * one offload implementation), so effect processing can be seamlessly switched between
+ * implementations in same proxy depending on the configuration and/or use case. If the optional
+ * proxy UUID is specified in Descriptor.Identity, then client must consider the effect instance as
+ * part of the effect proxy.
*/
@VintfStability
parcelable Descriptor {
@@ -68,6 +76,15 @@
* UUID for this particular implementation.
*/
AudioUuid uuid;
+ /**
+ * Optional proxy UUID. This field must be set to the proxy effect type UUID if the effect
+ * implementation is part of a proxy effect.
+ */
+ @nullable AudioUuid proxy;
+ /**
+ * Capability flags defined for the effect implementation.
+ */
+ Flags flags;
}
// Common attributes of all effect implementation.
@@ -79,4 +96,9 @@
Identity id;
}
Common common;
+
+ /**
+ * Effect implementation capability.
+ */
+ Capability capability;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
new file mode 100644
index 0000000..309874d
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package android.hardware.audio.effect;
+
+import android.media.audio.common.AudioProfile;
+
+/**
+ * Equalizer specific definitions.
+ */
+@VintfStability
+union Equalizer {
+ /**
+ * Defines Equalizer implementation capabilities, it MUST be supported by all equalizer
+ * implementations.
+ *
+ * Equalizer.Capability definition is used by android.hardware.audio.effect.Capability.
+ */
+ @VintfStability
+ parcelable Capability {
+ /**
+ * Equalizer capability extension, vendor can use this extension in case existing capability
+ * definition not enough.
+ */
+ ParcelableHolder extension;
+ }
+
+ // Vendor Equalizer implementation definition for additional parameters.
+ @VintfStability
+ parcelable VendorExtension {
+ ParcelableHolder extension;
+ }
+ VendorExtension vendor;
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/audio/aidl/android/hardware/audio/effect/Flags.aidl
similarity index 60%
rename from audio/aidl/default/include/visualizer-impl/Visualizer.h
rename to audio/aidl/android/hardware/audio/effect/Flags.aidl
index 4b82dd0..8add975 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/audio/aidl/android/hardware/audio/effect/Flags.aidl
@@ -14,18 +14,13 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.audio.effect;
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+/**
+ * The common part of available capability/configuration for effects. For effect type specific
+ * capability, see @c android.hardware.audio.effect.Capability.
+ */
+@VintfStability
+parcelable Flags {
+ // TODO: add Effect engine defined capabilities/requirements flags.
+}
diff --git a/audio/aidl/android/hardware/audio/effect/IEffect.aidl b/audio/aidl/android/hardware/audio/effect/IEffect.aidl
index d7a9501..9ab8b02 100644
--- a/audio/aidl/android/hardware/audio/effect/IEffect.aidl
+++ b/audio/aidl/android/hardware/audio/effect/IEffect.aidl
@@ -16,24 +16,68 @@
package android.hardware.audio.effect;
+import android.hardware.audio.effect.CommandId;
import android.hardware.audio.effect.Descriptor;
+import android.hardware.audio.effect.Parameter;
+import android.hardware.audio.effect.State;
+import android.hardware.common.fmq.MQDescriptor;
+import android.hardware.common.fmq.SynchronizedReadWrite;
/**
* Effect interfaces definitions to configure and control the effect instance.
*/
@VintfStability
interface IEffect {
+ @VintfStability
+ @FixedSize
+ parcelable Status {
+ /**
+ * One of Binder STATUS_* statuses:
+ * - STATUS_OK: the command has completed successfully;
+ * - STATUS_BAD_VALUE: invalid value in the 'Command' structure;
+ * - STATUS_INVALID_OPERATION: the mix port is not connected
+ * to any producer or consumer, thus
+ * positions can not be reported;
+ * - STATUS_NOT_ENOUGH_DATA: a read or write error has
+ * occurred for the 'audio.fmq' queue;
+ *
+ */
+ int status;
+ /**
+ * The amount of bytes consumed by the effect instance.
+ */
+ int fmqByteConsumed;
+ /**
+ * The amount of bytes produced by the effect instance.
+ */
+ int fmqByteProduced;
+ }
+
+ // Return data structure of IEffect.open() interface.
+ @VintfStability
+ parcelable OpenEffectReturn {
+ // Message queue for effect processing status.
+ MQDescriptor<Status, SynchronizedReadWrite> statusMQ;
+ // Message queue for input data buffer.
+ MQDescriptor<byte, SynchronizedReadWrite> inputDataMQ;
+ // Message queue for output data buffer.
+ MQDescriptor<byte, SynchronizedReadWrite> outputDataMQ;
+ }
+
/**
- * Open an effect instance, effect should not start processing data before receive START
- * command. All necessary information should be allocated and instance should transfer to IDLE
- * state after open() call has been handled successfully.
- * After open, the effect instance should be able to handle all IEffect interface calls.
+ * Open an effect instance, effect must not start processing data before receive
+ * CommandId::START command. All necessary information should be allocated and instance must
+ * transfer to State::IDLE state after open() call has been handled successfully. After open,
+ * the effect instance must be able to handle all IEffect interface calls.
*
+ * @param common Parameters which MUST pass from client at open time.
+ *
+ * @throws EX_ILLEGAL_ARGUMENT if the effect instance receive unsupported command.
* @throws a EX_UNSUPPORTED_OPERATION if device capability/resource is not enough or system
* failure happens.
* @note Open an already-opened effect instance should do nothing and should not throw an error.
*/
- void open();
+ OpenEffectReturn open(in Parameter.Common common, in Parameter.Specific specific);
/**
* Called by the client to close the effect instance, processing thread should be destroyed and
@@ -45,7 +89,7 @@
*
* Effect instance close interface should always succeed unless:
* 1. The effect instance is not in a proper state to be closed, for example it's still in
- * processing state.
+ * State::PROCESSING state.
* 2. There is system/hardware related failure when close.
*
* @throws EX_ILLEGAL_STATE if the effect instance is not in a proper state to be closed.
@@ -62,4 +106,53 @@
* @return Descriptor The @c Descriptor of this effect instance.
*/
Descriptor getDescriptor();
+
+ /**
+ * Send a command (defined in enum CommandId) to the effect instance, instance state can be
+ * changed as result of command handling.
+ *
+ * Must be available for the effect instance after it has been open().
+ *
+ * @param commandId ID of the command send to the effect instance.
+ *
+ * @throws EX_ILLEGAL_STATE if the effect instance is not in a proper state to handle the
+ * command.
+ * @throws EX_ILLEGAL_ARGUMENT if the effect instance receive unsupported command.
+ */
+ void command(in CommandId commandId);
+
+ /**
+ * Get current state of the effect instance.
+ *
+ * Must be available for the effect instance at anytime and should always succeed.
+ *
+ * @return Current effect instance state.
+ */
+ State getState();
+
+ /**
+ * Set a parameter to the effect instance.
+ *
+ * Must be available for the effect instance after open().
+ *
+ * @param param Parameter data to set to the effect instance.
+ *
+ * @throws EX_ILLEGAL_ARGUMENT if the effect instance receive unsupported parameter.
+ */
+ void setParameter(in Parameter param);
+
+ /**
+ * Get a parameter from the effect instance with parameter ID.
+ *
+ * This interface must return the current parameter of the effect instance, if no parameter
+ * has been set by client yet, the default value must be returned.
+ *
+ * Must be available for the effect instance after open().
+ *
+ * @param paramId The tag enum of parameter to get.
+ * @return Parameter The parameter to get from the effect instance.
+ *
+ * @throws EX_ILLEGAL_ARGUMENT if the effect instance receive unsupported parameter tag.
+ */
+ Parameter getParameter(in Parameter.Id paramId);
}
diff --git a/audio/aidl/android/hardware/audio/effect/IFactory.aidl b/audio/aidl/android/hardware/audio/effect/IFactory.aidl
index 4873d3a..db26e61 100644
--- a/audio/aidl/android/hardware/audio/effect/IFactory.aidl
+++ b/audio/aidl/android/hardware/audio/effect/IFactory.aidl
@@ -18,6 +18,7 @@
import android.hardware.audio.effect.Descriptor;
import android.hardware.audio.effect.IEffect;
+import android.hardware.audio.effect.Processing;
import android.media.audio.common.AudioUuid;
/**
@@ -45,6 +46,16 @@
in @nullable AudioUuid type, in @nullable AudioUuid implementation);
/**
+ * Return a list of defined processings, with the optional filter by Processing type.
+ * An effect can exist more than once in the returned list, which means this effect must be used
+ * in more than one processing type.
+ *
+ * @param type Type of processing to query, can be AudioStreamType or AudioSource.
+ * @return list of processing defined with the optional filter by Processing.Type.
+ */
+ Processing[] queryProcessing(in @nullable Processing.Type type);
+
+ /**
* Called by the audio framework to create the effect (identified by the implementation UUID
* parameter).
*
diff --git a/audio/aidl/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
new file mode 100644
index 0000000..2951660
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package android.hardware.audio.effect;
+
+import android.hardware.audio.effect.Equalizer;
+import android.media.audio.common.AudioConfig;
+import android.media.audio.common.AudioDeviceDescription;
+/**
+ * Defines all parameters supported by the effect instance.
+ *
+ * There are three groups of parameters:
+ * 1. Common parameters are essential parameters, MUST pass to effects at open() interface.
+ * 2. Parameters defined for a specific effect type.
+ * 3. Extension parameters for vendor.
+ *
+ * For all supported parameter, implementation MUST support both set and get.
+ */
+@VintfStability
+union Parameter {
+ /**
+ * Client can pass in Parameter.Id with the corresponding tag value in IEffect.getParameter()
+ * call to get android.hardware.audio.effect.Parameter.
+ *
+ * As an example, if a client want to get audio.hardware.audio.effect.Specific.Equalizer, the
+ * value of Id should be audio.hardware.audio.effect.Parameter.Specific.equalizer.
+ */
+ @VintfStability
+ union Id {
+ // Common parameter tag.
+ int commonTag;
+ // Vendor defined parameter tag.
+ int vendorTag;
+ // Specific effect parameter tag.
+ Specific.Tag specificTag;
+ }
+
+ /**
+ * Common parameters MUST be supported by all effect implementations.
+ */
+ @VintfStability
+ parcelable Common {
+ // Type of Audio device.
+ int session;
+ // I/O Handle.
+ int ioHandle;
+ // Type of Audio device.
+ AudioDeviceDescription device;
+ // Input config.
+ AudioConfig input;
+ // Output config.
+ AudioConfig output;
+ }
+ Common common;
+
+ /**
+ * Parameters for vendor extension effect implementation usage.
+ */
+ @VintfStability
+ parcelable VendorEffectParameter {
+ ParcelableHolder extension;
+ }
+ VendorEffectParameter vendorEffect;
+
+ /**
+ * Parameters MUST be supported by a Specific type of effect.
+ */
+ @VintfStability
+ union Specific {
+ Equalizer equalizer;
+ // TODO: add other effect definitions here
+ }
+ Specific specific;
+}
diff --git a/audio/aidl/android/hardware/audio/effect/Processing.aidl b/audio/aidl/android/hardware/audio/effect/Processing.aidl
new file mode 100644
index 0000000..ef32e8c
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/Processing.aidl
@@ -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.
+ */
+
+package android.hardware.audio.effect;
+
+import android.hardware.audio.effect.Descriptor;
+import android.media.audio.common.AudioSource;
+import android.media.audio.common.AudioStreamType;
+import android.media.audio.common.AudioUuid;
+
+/**
+ * List of effects which must be used for certain pre-processing or post-processing.
+ */
+@VintfStability
+parcelable Processing {
+ @VintfStability
+ union Type {
+ AudioStreamType streamType = AudioStreamType.INVALID;
+ AudioSource source;
+ }
+
+ /**
+ * Specifies the type of processing by referring to the output stream type (AudioStreamType) or
+ * the input stream source (AudioSource).
+ */
+ Type type;
+ /**
+ * List of effect identities for this processing.
+ */
+ Descriptor.Identity[] ids;
+}
diff --git a/audio/aidl/android/hardware/audio/effect/State.aidl b/audio/aidl/android/hardware/audio/effect/State.aidl
new file mode 100644
index 0000000..85a4afc
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/State.aidl
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+package android.hardware.audio.effect;
+
+/**
+ * Possible states of an effect instance.
+ * A typical effect instance will be in INIT state when it is created with IFactory.createEffect()
+ * interface, transfer to IDLE after open(), and to PROCESSING after
+ * IEffect.command(Command.Id.START) command. When an effect instance receive STOP or RESET command,
+ * it should transfer to IDLE state after handle the command successfully. Effect instance should
+ * consume minimal resource and transfer to INIT state after it was close().
+ *
+ * Refer to State.gv for detailed state diagram.
+ */
+@VintfStability
+@Backing(type="byte")
+enum State {
+
+ /**
+ * An effect instance is in INIT state by default after it was created with
+ * IFactory.createEffect(). When an effect instance is in INIT state, it should have instance
+ * context initialized, and ready to handle IEffect.setParameter(), IEffect.open() as well as
+ * all getter interfaces.
+ *
+ * In INIT state, effect instance must:
+ * 1. Not handle any IEffect.command() and return EX_ILLEGAL_STATE with any Command.Id.
+ * 2. Be able to handle all parameter setting with IEffect.setParameter().
+ * 3. Be able to handle all getter interface calls like IEffect.getParameter() and
+ * IEffect.getState().
+ * 4. Be able to handle IEffect.open() successfully after configuration.
+ *
+ * Client is expected to do necessary configuration with IEffect.setParameter(), get all
+ * resource ready with IEffect.open(), and make sure effect instance transfer to IDLE state
+ * before sending commands with IEffect.command() interface. Effect instance must transfer
+ * from INIT to IDLE state after handle IEffect.open() call successfully.
+ */
+ INIT,
+ /**
+ * An effect instance transfer to IDLE state after it was open successfully with IEffect.open()
+ * in INIT state, or after it was stop/reset with Command.Id.STOP/RESET in PROCESSING state.
+ *
+ * In IDLE state, effect instance must:
+ * 1. Be able to start effect processing engine with IEffect.command(Command.Id.START) call.
+ * 2. Be able to handle all parameter setting with IEffect.setParameter().
+ * 3. Be able to handle all getter interface calls like IEffect.getParameter() and
+ * IEffect.getState().
+ *
+ * The following state transfer can happen in IDLE state:
+ * 1. Transfer to PROCESSING if instance receive an START command and start processing data
+ * successfully.
+ * 2. Transfer to INIT if instance receive a close() call.
+ */
+ IDLE,
+ /**
+ * An effect instance is in PROCESSING state after it receive an START command and start
+ * processing data successfully. Effect instance will transfer from PROCESSING to IDLE state if
+ * it receive an STOP or RESET command and handle the command successfully.
+ *
+ * When an instance is in PROCESSING state, client should try not to close() it directly,
+ * instead client should try to stop processing data first with STOP command before close(). In
+ * the case of a close() call received when instance in PROCESSING state, it should try to stop
+ * processing and transfer to IDLE first before close().
+ *
+ * In PROCESSING state, effect instance must:
+ * 1. Return EX_ILLEGAL_STATE if it's not able to handle any parameter settings at runtime.
+ * 2. Be able to handle STOP and RESET for IEffect.command() interface, and return
+ * EX_ILLEGAL_STATE for all other commands.
+ * 3. Must be able to handle all get* interface calls like IEffect.getParameter() and
+ * IEffect.getState().
+ */
+ PROCESSING,
+}
diff --git a/audio/aidl/android/hardware/audio/effect/state.gv b/audio/aidl/android/hardware/audio/effect/state.gv
new file mode 100644
index 0000000..e19e6c7
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/state.gv
@@ -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.
+ */
+
+// To render: "dot -Tpng state.gv -o state.png"
+digraph effect_state_machine {
+ node [shape=point style=filled fillcolor=black width=0.5] I;
+ node [shape=doublecircle] F;
+ node [shape=oval width=1];
+ node [fillcolor=lightgreen] INIT;
+ node [fillcolor=lightblue] IDLE;
+ node [fillcolor=lightyellow] PROCESSING;
+
+ I -> INIT [label="IFactory.createEffect" labelfontcolor="navy"];
+ INIT -> F [label="IFactory.destroyEffect"];
+ INIT -> IDLE [label="open()" labelfontcolor="lime"];
+ IDLE -> PROCESSING [label="command(START"];
+ PROCESSING -> IDLE [label="command(STOP)\ncommand(RESET)"];
+ IDLE -> INIT [label="close()"];
+
+ INIT -> INIT [label="getState\ngetDescriptor"];
+ IDLE -> IDLE [label="getXXX\nsetParameter\ncommand(RESET)"];
+ PROCESSING -> PROCESSING [label="getXXX\nsetParameter"];
+}
\ No newline at end of file
diff --git a/audio/aidl/default/Android.bp b/audio/aidl/default/Android.bp
index 53ed908..2baaad9 100644
--- a/audio/aidl/default/Android.bp
+++ b/audio/aidl/default/Android.bp
@@ -21,6 +21,9 @@
"android.hardware.common-V2-ndk",
"android.hardware.common.fmq-V1-ndk",
],
+ header_libs: [
+ "libaudioaidl_headers",
+ ],
}
cc_library_static {
@@ -81,18 +84,23 @@
cc_library_static {
name: "libaudioeffectserviceexampleimpl",
defaults: ["aidlaudioeffectservice_defaults"],
- export_include_dirs: [
- "include",
- "include/equalizer-impl/",
- ],
+ export_include_dirs: ["include"],
srcs: [
"EffectFactory.cpp",
],
+ header_libs: [
+ "libsystem_headers",
+ ],
visibility: [
":__subpackages__",
],
}
+filegroup {
+ name: "effectCommonFile",
+ srcs: ["EffectThread.cpp"],
+}
+
cc_binary {
name: "android.hardware.audio.effect.service-aidl.example",
relative_install_path: "hw",
@@ -104,3 +112,10 @@
],
srcs: ["EffectMain.cpp"],
}
+
+cc_library_headers {
+ name: "libaudioaidl_headers",
+ export_include_dirs: ["include"],
+ vendor: true,
+ host_supported: true,
+}
diff --git a/audio/aidl/default/EffectFactory.cpp b/audio/aidl/default/EffectFactory.cpp
index a9848fd..8e107a2 100644
--- a/audio/aidl/default/EffectFactory.cpp
+++ b/audio/aidl/default/EffectFactory.cpp
@@ -16,57 +16,167 @@
#define LOG_TAG "AHAL_EffectFactory"
#include <android-base/logging.h>
+#include <dlfcn.h>
+#include "effect-impl/EffectUUID.h"
#include "effectFactory-impl/EffectFactory.h"
-#include "equalizer-impl/Equalizer.h"
-#include "visualizer-impl/Visualizer.h"
using aidl::android::media::audio::common::AudioUuid;
namespace aidl::android::hardware::audio::effect {
Factory::Factory() {
- // TODO: implement this with xml parser on audio_effect.xml, and filter with optional
- // parameters.
+ std::function<void(void*)> dlClose = [](void* handle) -> void {
+ if (handle && dlclose(handle)) {
+ LOG(ERROR) << "dlclose failed " << dlerror();
+ }
+ };
+ // TODO: implement this with audio_effect.xml.
+ auto libHandle =
+ std::unique_ptr<void, decltype(dlClose)>{dlopen("libequalizer.so", RTLD_LAZY), dlClose};
+ if (!libHandle) {
+ LOG(ERROR) << __func__ << ": dlopen failed, err: " << dlerror();
+ return;
+ }
+
+ LOG(DEBUG) << __func__ << " dlopen uuid: " << EqualizerSwImplUUID.toString() << " handle "
+ << libHandle;
+ mEffectLibMap.insert({EqualizerSwImplUUID, std::make_pair(std::move(libHandle), nullptr)});
+
Descriptor::Identity id;
id.type = EqualizerTypeUUID;
id.uuid = EqualizerSwImplUUID;
mIdentityList.push_back(id);
}
-ndk::ScopedAStatus Factory::queryEffects(const std::optional<AudioUuid>& in_type,
- const std::optional<AudioUuid>& in_instance,
+Factory::~Factory() {
+ if (auto count = mEffectUuidMap.size()) {
+ LOG(ERROR) << __func__ << " remaining " << count
+ << " effect instances not destroyed indicating resource leak!";
+ for (const auto& it : mEffectUuidMap) {
+ if (auto spEffect = it.first.lock()) {
+ LOG(ERROR) << __func__ << " erase remaining instance UUID " << it.second.toString();
+ destroyEffectImpl(spEffect);
+ }
+ }
+ }
+}
+
+ndk::ScopedAStatus Factory::queryEffects(const std::optional<AudioUuid>& in_type_uuid,
+ const std::optional<AudioUuid>& in_impl_uuid,
std::vector<Descriptor::Identity>* _aidl_return) {
std::copy_if(mIdentityList.begin(), mIdentityList.end(), std::back_inserter(*_aidl_return),
[&](auto& desc) {
- return (!in_type.has_value() || in_type.value() == desc.type) &&
- (!in_instance.has_value() || in_instance.value() == desc.uuid);
+ return (!in_type_uuid.has_value() || in_type_uuid.value() == desc.type) &&
+ (!in_impl_uuid.has_value() || in_impl_uuid.value() == desc.uuid);
});
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus Factory::createEffect(
- const AudioUuid& in_impl_uuid,
- std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>* _aidl_return) {
+ndk::ScopedAStatus Factory::queryProcessing(const std::optional<Processing::Type>& in_type,
+ std::vector<Processing>* _aidl_return) {
+ // TODO: implement this with audio_effect.xml.
+ if (in_type.has_value()) {
+ // return all matching process filter
+ LOG(DEBUG) << __func__ << " process type: " << in_type.value().toString();
+ }
+ LOG(DEBUG) << __func__ << " return " << _aidl_return->size();
+ return ndk::ScopedAStatus::ok();
+}
+
+#define RETURN_IF_BINDER_EXCEPTION(functor) \
+ { \
+ binder_exception_t exception = functor; \
+ if (EX_NONE != exception) { \
+ LOG(ERROR) << #functor << ": failed with error " << exception; \
+ return ndk::ScopedAStatus::fromExceptionCode(exception); \
+ } \
+ }
+
+ndk::ScopedAStatus Factory::createEffect(const AudioUuid& in_impl_uuid,
+ std::shared_ptr<IEffect>* _aidl_return) {
LOG(DEBUG) << __func__ << ": UUID " << in_impl_uuid.toString();
if (in_impl_uuid == EqualizerSwImplUUID) {
- *_aidl_return = ndk::SharedRefBase::make<Equalizer>();
+ if (mEffectLibMap.count(in_impl_uuid)) {
+ auto& lib = mEffectLibMap[in_impl_uuid];
+ // didn't do dlsym yet
+ if (nullptr == lib.second) {
+ void* libHandle = lib.first.get();
+ struct effect_interface_s intf = {
+ .createEffectFunc = (EffectCreateFunctor)dlsym(libHandle, "createEffect"),
+ .destroyEffectFunc =
+ (EffectDestroyFunctor)dlsym(libHandle, "destroyEffect")};
+ auto dlInterface = std::make_unique<struct effect_interface_s>(intf);
+ if (!dlInterface->createEffectFunc || !dlInterface->destroyEffectFunc) {
+ LOG(ERROR) << __func__
+ << ": create or destroy symbol not exist in library: " << libHandle
+ << "!";
+ return ndk::ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
+ }
+ lib.second = std::move(dlInterface);
+ }
+
+ auto& libInterface = lib.second;
+ std::shared_ptr<IEffect> effectSp;
+ RETURN_IF_BINDER_EXCEPTION(libInterface->createEffectFunc(&effectSp));
+ if (!effectSp) {
+ LOG(ERROR) << __func__ << ": library created null instance without return error!";
+ return ndk::ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
+ }
+ *_aidl_return = effectSp;
+ mEffectUuidMap[std::weak_ptr<IEffect>(effectSp)] = in_impl_uuid;
+ LOG(DEBUG) << __func__ << ": instance " << effectSp.get() << " created successfully";
+ return ndk::ScopedAStatus::ok();
+ } else {
+ LOG(ERROR) << __func__ << ": library doesn't exist";
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
} else {
- LOG(ERROR) << __func__ << ": UUID "
- << " not supported";
+ LOG(ERROR) << __func__ << ": UUID not supported";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus Factory::destroyEffect(
- const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_handle) {
- if (in_handle) {
- // TODO: b/245393900 need check the instance state with IEffect.getState before destroy.
+ndk::ScopedAStatus Factory::destroyEffectImpl(const std::shared_ptr<IEffect>& in_handle) {
+ std::weak_ptr<IEffect> wpHandle(in_handle);
+ // find UUID with key (std::weak_ptr<IEffect>)
+ if (auto uuidIt = mEffectUuidMap.find(wpHandle); uuidIt != mEffectUuidMap.end()) {
+ auto& uuid = uuidIt->second;
+ // find implementation library with UUID
+ if (auto libIt = mEffectLibMap.find(uuid); libIt != mEffectLibMap.end()) {
+ if (libIt->second.second->destroyEffectFunc) {
+ RETURN_IF_BINDER_EXCEPTION(libIt->second.second->destroyEffectFunc(in_handle));
+ }
+ } else {
+ LOG(ERROR) << __func__ << ": UUID " << uuid.toString() << " does not exist in libMap!";
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ mEffectUuidMap.erase(uuidIt);
return ndk::ScopedAStatus::ok();
} else {
+ LOG(ERROR) << __func__ << ": instance " << in_handle << " does not exist!";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
}
+// go over the map and cleanup all expired weak_ptrs.
+void Factory::cleanupEffectMap() {
+ for (auto it = mEffectUuidMap.begin(); it != mEffectUuidMap.end();) {
+ if (nullptr == it->first.lock()) {
+ it = mEffectUuidMap.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
+ndk::ScopedAStatus Factory::destroyEffect(const std::shared_ptr<IEffect>& in_handle) {
+ LOG(DEBUG) << __func__ << ": instance " << in_handle.get();
+ ndk::ScopedAStatus status = destroyEffectImpl(in_handle);
+ // always do the cleanup
+ cleanupEffectMap();
+ return status;
+}
+
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/EffectThread.cpp b/audio/aidl/default/EffectThread.cpp
new file mode 100644
index 0000000..0ad9a14
--- /dev/null
+++ b/audio/aidl/default/EffectThread.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "AHAL_EffectThread"
+#include <android-base/logging.h>
+#include <pthread.h>
+#include <sys/resource.h>
+
+#include "effect-impl/EffectThread.h"
+
+namespace aidl::android::hardware::audio::effect {
+
+EffectThread::EffectThread() {
+ LOG(DEBUG) << __func__;
+}
+
+EffectThread::~EffectThread() {
+ destroy();
+ LOG(DEBUG) << __func__ << " done";
+};
+
+RetCode EffectThread::create(const std::string& name, const int priority) {
+ if (mThread.joinable()) {
+ LOG(WARNING) << __func__ << " thread already created, no-op";
+ return RetCode::SUCCESS;
+ }
+ mName = name;
+ mPriority = priority;
+ mThread = std::thread(&EffectThread::threadLoop, this);
+ LOG(DEBUG) << __func__ << " " << name << " priority " << mPriority << " done";
+ return RetCode::SUCCESS;
+}
+
+RetCode EffectThread::destroy() {
+ {
+ std::lock_guard lg(mMutex);
+ mStop = mExit = true;
+ }
+ mCv.notify_one();
+
+ if (mThread.joinable()) {
+ mThread.join();
+ }
+ LOG(DEBUG) << __func__ << " done";
+ return RetCode::SUCCESS;
+}
+
+RetCode EffectThread::start() {
+ if (!mThread.joinable()) {
+ LOG(ERROR) << __func__ << " thread already destroyed";
+ return RetCode::ERROR;
+ }
+
+ {
+ std::lock_guard lg(mMutex);
+ if (!mStop) {
+ LOG(WARNING) << __func__ << " already start";
+ return RetCode::SUCCESS;
+ }
+ mStop = false;
+ }
+
+ mCv.notify_one();
+ LOG(DEBUG) << __func__ << " done";
+ return RetCode::SUCCESS;
+}
+
+RetCode EffectThread::stop() {
+ if (!mThread.joinable()) {
+ LOG(ERROR) << __func__ << " thread already destroyed";
+ return RetCode::ERROR;
+ }
+
+ {
+ std::lock_guard lg(mMutex);
+ if (mStop) {
+ LOG(WARNING) << __func__ << " already stop";
+ return RetCode::SUCCESS;
+ }
+ mStop = true;
+ }
+ LOG(DEBUG) << __func__ << " done";
+ return RetCode::SUCCESS;
+}
+
+void EffectThread::threadLoop() {
+ pthread_setname_np(pthread_self(), mName.substr(0, MAX_TASK_COMM_LEN - 1).c_str());
+ setpriority(PRIO_PROCESS, 0, mPriority);
+ while (true) {
+ bool needExit = false;
+ {
+ std::unique_lock l(mMutex);
+ mCv.wait(l, [&]() REQUIRES(mMutex) {
+ needExit = mExit;
+ return mExit || !mStop;
+ });
+ }
+ if (needExit) {
+ LOG(WARNING) << __func__ << " EXIT!";
+ return;
+ }
+ // process without lock
+ process();
+ }
+}
+
+std::string toString(RetCode& code) {
+ switch (code) {
+ case RetCode::SUCCESS:
+ return "SUCCESS";
+ case RetCode::ERROR:
+ return "ERROR";
+ default:
+ return "EnumError";
+ }
+}
+
+} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/equalizer/Android.bp b/audio/aidl/default/equalizer/Android.bp
index b842149..2a2ddbc 100644
--- a/audio/aidl/default/equalizer/Android.bp
+++ b/audio/aidl/default/equalizer/Android.bp
@@ -27,17 +27,24 @@
name: "libequalizer",
vendor: true,
shared_libs: [
+ "libaudioaidlcommon",
"libbase",
- "libbinder_ndk",
- "libstagefright_foundation",
+ "android.hardware.common-V2-ndk",
],
defaults: [
+ "aidlaudioservice_defaults",
"latest_android_media_audio_common_types_ndk_shared",
"latest_android_hardware_audio_effect_ndk_shared",
],
- include_dirs: ["hardware/interfaces/audio/aidl/default/include/equalizer-impl"],
srcs: [
"Equalizer.cpp",
+ ":effectCommonFile",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-Wthread-safety",
],
visibility: [
"//hardware/interfaces/audio/aidl/default",
diff --git a/audio/aidl/default/equalizer/Equalizer.cpp b/audio/aidl/default/equalizer/Equalizer.cpp
index 8b157fa..2e4e538 100644
--- a/audio/aidl/default/equalizer/Equalizer.cpp
+++ b/audio/aidl/default/equalizer/Equalizer.cpp
@@ -14,27 +14,243 @@
* limitations under the License.
*/
-#define LOG_TAG "AHAL_Equalizer"
+#define LOG_TAG "AHAL_EqualizerSw"
+#include <Utils.h>
#include <android-base/logging.h>
+#include <unordered_set>
-#include "Equalizer.h"
+#include "effect-impl/EffectUUID.h"
+#include "equalizer-impl/EqualizerSw.h"
+
+using android::hardware::audio::common::getFrameSizeInBytes;
namespace aidl::android::hardware::audio::effect {
-ndk::ScopedAStatus Equalizer::open() {
+extern "C" binder_exception_t createEffect(std::shared_ptr<IEffect>* instanceSpp) {
+ if (instanceSpp) {
+ *instanceSpp = ndk::SharedRefBase::make<EqualizerSw>();
+ LOG(DEBUG) << __func__ << " instance " << instanceSpp->get() << " created";
+ return EX_NONE;
+ } else {
+ LOG(ERROR) << __func__ << " invalid input parameter!";
+ return EX_ILLEGAL_ARGUMENT;
+ }
+}
+
+extern "C" binder_exception_t destroyEffect(const std::shared_ptr<IEffect>& instanceSp) {
+ State state;
+ ndk::ScopedAStatus status = instanceSp->getState(&state);
+ if (!status.isOk() || State::INIT != state) {
+ LOG(ERROR) << __func__ << " instance " << instanceSp.get()
+ << " in state: " << toString(state) << ", status: " << status.getDescription();
+ return EX_ILLEGAL_STATE;
+ }
+ LOG(DEBUG) << __func__ << " instance " << instanceSp.get() << " destroyed";
+ return EX_NONE;
+}
+
+ndk::ScopedAStatus EqualizerSw::open(const Parameter::Common& common,
+ const Parameter::Specific& specific,
+ OpenEffectReturn* _aidl_return) {
+ LOG(DEBUG) << __func__;
+ if (mState != State::INIT) {
+ LOG(WARNING) << __func__ << " eq already open";
+ return ndk::ScopedAStatus::ok();
+ }
+
+ // Set essential parameters before create worker thread.
+ setCommonParameter(common);
+ setSpecificParameter(specific);
+
+ LOG(DEBUG) << " common: " << common.toString() << " specific " << specific.toString();
+
+ auto& input = common.input;
+ auto& output = common.output;
+ size_t inputFrameSize = getFrameSizeInBytes(input.base.format, input.base.channelMask);
+ size_t outputFrameSize = getFrameSizeInBytes(output.base.format, output.base.channelMask);
+ if (!createFmq(1, input.frameCount * inputFrameSize, output.frameCount * outputFrameSize,
+ _aidl_return)) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_UNSUPPORTED_OPERATION,
+ "FailedToCreateFmq");
+ }
+
+ // create the worker thread
+ if (RetCode::SUCCESS != mWorker->create(LOG_TAG)) {
+ LOG(ERROR) << __func__ << " created worker thread failed";
+ destroyFmq();
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_UNSUPPORTED_OPERATION,
+ "FailedToCreateFmq");
+ }
+
+ mState = State::IDLE;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EqualizerSw::close() {
+ if (mState == State::INIT) {
+ LOG(WARNING) << __func__ << " instance already closed";
+ return ndk::ScopedAStatus::ok();
+ } else if (mState == State::PROCESSING) {
+ LOG(ERROR) << __func__ << " instance still processing";
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_STATE,
+ "EqInstanceProcessing");
+ }
+
+ // stop the worker thread
+ mState = State::INIT;
+ mWorker->destroy();
+ destroyFmq();
LOG(DEBUG) << __func__;
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus Equalizer::close() {
- LOG(DEBUG) << __func__;
- return ndk::ScopedAStatus::ok();
-}
-
-ndk::ScopedAStatus Equalizer::getDescriptor(Descriptor* _aidl_return) {
- LOG(DEBUG) << __func__ << "descriptor " << mDesc.toString();
+ndk::ScopedAStatus EqualizerSw::getDescriptor(Descriptor* _aidl_return) {
+ LOG(DEBUG) << __func__ << mDesc.toString();
*_aidl_return = mDesc;
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus EqualizerSw::command(CommandId in_commandId) {
+ LOG(DEBUG) << __func__ << ": receive command:" << toString(in_commandId);
+ if (mState == State::INIT) {
+ LOG(ERROR) << __func__ << ": instance not open yet";
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_STATE,
+ "CommandStateError");
+ }
+ switch (in_commandId) {
+ case CommandId::START:
+ // start processing.
+ mState = State::PROCESSING;
+ mWorker->start();
+ LOG(DEBUG) << __func__ << " state: " << toString(mState);
+ return ndk::ScopedAStatus::ok();
+ case CommandId::STOP:
+ // stop processing.
+ mState = State::IDLE;
+ mWorker->stop();
+ LOG(DEBUG) << __func__ << " state: " << toString(mState);
+ return ndk::ScopedAStatus::ok();
+ case CommandId::RESET:
+ // TODO: reset buffer status.
+ mState = State::IDLE;
+ mWorker->stop();
+ LOG(DEBUG) << __func__ << " state: " << toString(mState);
+ return ndk::ScopedAStatus::ok();
+ default:
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "CommandIdNotSupported");
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EqualizerSw::setParameter(const Parameter& in_param) {
+ if (mState == State::INIT) {
+ LOG(ERROR) << __func__ << ": instance not open yet";
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_STATE, "StateError");
+ }
+ LOG(DEBUG) << __func__ << " with: " << in_param.toString();
+ auto tag = in_param.getTag();
+ switch (tag) {
+ case Parameter::common: {
+ return setCommonParameter(in_param.get<Parameter::common>());
+ }
+ case Parameter::specific: {
+ return setSpecificParameter(in_param.get<Parameter::specific>());
+ }
+ default:
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "ParameterNotSupported");
+ }
+}
+
+ndk::ScopedAStatus EqualizerSw::getParameter(const Parameter::Id& in_paramId,
+ Parameter* _aidl_return) {
+ LOG(DEBUG) << __func__ << in_paramId.toString();
+ auto tag = in_paramId.getTag();
+ switch (tag) {
+ case Parameter::Id::commonTag: {
+ _aidl_return->set<Parameter::common>(mCommonParam);
+ LOG(DEBUG) << __func__ << " get: " << _aidl_return->toString();
+ return ndk::ScopedAStatus::ok();
+ }
+ case Parameter::Id::specificTag: {
+ auto& id = in_paramId.get<Parameter::Id::specificTag>();
+ if (id != Parameter::Specific::equalizer) {
+ LOG(ERROR) << " unsupported parameter Id: " << in_paramId.toString();
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "Parameter::IdNotSupported");
+ }
+ Parameter::Specific specific;
+ specific.set<Parameter::Specific::equalizer>(mEqualizerParam);
+ _aidl_return->set<Parameter::specific>(specific);
+ LOG(DEBUG) << __func__ << _aidl_return->toString();
+ return ndk::ScopedAStatus::ok();
+ }
+ default:
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Parameter::IdNotSupported");
+ }
+}
+
+ndk::ScopedAStatus EqualizerSw::getState(State* _aidl_return) {
+ *_aidl_return = mState;
+ return ndk::ScopedAStatus::ok();
+}
+
+/// Private methods.
+bool EqualizerSw::createFmq(int statusDepth, int inBufferSize, int outBufferSize,
+ OpenEffectReturn* ret) {
+ mStatusMQ = std::make_unique<StatusMQ>(statusDepth, true /*configureEventFlagWord*/);
+ mInputMQ = std::make_unique<DataMQ>(inBufferSize);
+ mOutputMQ = std::make_unique<DataMQ>(outBufferSize);
+
+ if (!mStatusMQ->isValid() || !mInputMQ->isValid() || !mOutputMQ->isValid()) {
+ LOG(ERROR) << __func__ << " created invalid FMQ";
+ return false;
+ }
+ ret->statusMQ = mStatusMQ->dupeDesc();
+ ret->inputDataMQ = mInputMQ->dupeDesc();
+ ret->outputDataMQ = mOutputMQ->dupeDesc();
+ return true;
+}
+
+void EqualizerSw::destroyFmq() {
+ mStatusMQ.reset(nullptr);
+ mInputMQ.reset(nullptr);
+ mOutputMQ.reset(nullptr);
+}
+
+ndk::ScopedAStatus EqualizerSw::setCommonParameter(const Parameter::Common& common) {
+ mCommonParam = common;
+ LOG(DEBUG) << __func__ << " set: " << mCommonParam.toString();
+ return ndk::ScopedAStatus::ok();
+}
+
+// TODO: implementation need change to save all parameters.
+ndk::ScopedAStatus EqualizerSw::setSpecificParameter(const Parameter::Specific& specific) {
+ if (Parameter::Specific::equalizer != specific.getTag()) {
+ LOG(ERROR) << " unsupported effect: " << specific.toString();
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "EffectNotSupported");
+ }
+
+ mEqualizerParam = specific.get<Parameter::Specific::equalizer>();
+ LOG(DEBUG) << __func__ << mEqualizerParam.toString();
+ return ndk::ScopedAStatus::ok();
+}
+
+void EqualizerSw::cleanUp() {
+ if (State::PROCESSING == mState) {
+ command(CommandId::STOP);
+ }
+ if (State::INIT != mState) {
+ close();
+ }
+}
+
+// Processing method running in worker thread.
+void EqualizerSwWorker::process() {
+ // TODO: add EQ processing with FMQ, should wait until data available before data processing.
+}
+
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/include/effect-impl/EffectThread.h b/audio/aidl/default/include/effect-impl/EffectThread.h
new file mode 100644
index 0000000..e831cea
--- /dev/null
+++ b/audio/aidl/default/include/effect-impl/EffectThread.h
@@ -0,0 +1,59 @@
+/*
+ * 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 <atomic>
+#include <string>
+#include <thread>
+
+#include <android-base/thread_annotations.h>
+#include <system/thread_defs.h>
+
+namespace aidl::android::hardware::audio::effect {
+
+enum class RetCode { SUCCESS, ERROR };
+
+std::string toString(RetCode& code);
+
+class EffectThread {
+ public:
+ // default priority is same as HIDL: ANDROID_PRIORITY_URGENT_AUDIO
+ EffectThread();
+ virtual ~EffectThread();
+
+ // called by effect implementation.
+ RetCode create(const std::string& name, const int priority = ANDROID_PRIORITY_URGENT_AUDIO);
+ RetCode destroy();
+ RetCode start();
+ RetCode stop();
+
+ // Will call process() in a loop if the thread is running.
+ void threadLoop();
+
+ // User of EffectThread must implement the effect processing logic in this method.
+ virtual void process() = 0;
+ const int MAX_TASK_COMM_LEN = 15;
+
+ private:
+ std::mutex mMutex;
+ std::condition_variable mCv;
+ bool mExit GUARDED_BY(mMutex) = false;
+ bool mStop GUARDED_BY(mMutex) = true;
+ std::thread mThread;
+ int mPriority;
+ std::string mName;
+};
+} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/include/effect-impl/EffectUUID.h b/audio/aidl/default/include/effect-impl/EffectUUID.h
new file mode 100644
index 0000000..99f6c24
--- /dev/null
+++ b/audio/aidl/default/include/effect-impl/EffectUUID.h
@@ -0,0 +1,45 @@
+/*
+ * 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/media/audio/common/AudioUuid.h>
+
+namespace aidl::android::hardware::audio::effect {
+
+using ::aidl::android::media::audio::common::AudioUuid;
+
+// Equalizer type UUID.
+static const AudioUuid EqualizerTypeUUID = {static_cast<int32_t>(0x0bed4300),
+ 0xddd6,
+ 0x11db,
+ 0x8f34,
+ {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+
+// Equalizer implementation UUID.
+static const AudioUuid EqualizerSwImplUUID = {static_cast<int32_t>(0x0bed4300),
+ 0x847d,
+ 0x11df,
+ 0xbb17,
+ {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+
+// Visualizer type UUID.
+static const AudioUuid VisualizerTypeUUID = {static_cast<int32_t>(0x1d4033c0),
+ 0x8557,
+ 0x11df,
+ 0x9f2d,
+ {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+
+} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
index 8da5525..6195d8a 100644
--- a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
+++ b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
@@ -16,6 +16,8 @@
#pragma once
+#include <any>
+#include <map>
#include <optional>
#include <vector>
@@ -41,6 +43,16 @@
std::vector<Descriptor::Identity>* out_descriptor) override;
/**
+ * @brief Query list of defined processing, with the optional filter by AudioStreamType
+ *
+ * @param in_type Type of processing, could be AudioStreamType or AudioSource. Optional.
+ * @param _aidl_return List of processing filtered by in_type.
+ * @return ndk::ScopedAStatus
+ */
+ ndk::ScopedAStatus queryProcessing(const std::optional<Processing::Type>& in_type,
+ std::vector<Processing>* _aidl_return) override;
+
+ /**
* @brief Create an effect instance for a certain implementation (identified by UUID).
*
* @param in_impl_uuid Effect implementation UUID.
@@ -63,7 +75,26 @@
override;
private:
+ ~Factory();
// List of effect descriptors supported by the devices.
std::vector<Descriptor::Identity> mIdentityList;
+
+ typedef binder_exception_t (*EffectCreateFunctor)(std::shared_ptr<IEffect>*);
+ typedef binder_exception_t (*EffectDestroyFunctor)(const std::shared_ptr<IEffect>&);
+ struct effect_interface_s {
+ EffectCreateFunctor createEffectFunc;
+ EffectDestroyFunctor destroyEffectFunc;
+ };
+
+ std::map<aidl::android::media::audio::common::AudioUuid /* implementationUUID */,
+ std::pair<std::unique_ptr<void, std::function<void(void*)>> /* dlHandle */,
+ std::unique_ptr<struct effect_interface_s>>>
+ mEffectLibMap;
+ std::map<std::weak_ptr<IEffect>, aidl::android::media::audio::common::AudioUuid,
+ std::owner_less<>>
+ mEffectUuidMap;
+
+ ndk::ScopedAStatus destroyEffectImpl(const std::shared_ptr<IEffect>& in_handle);
+ void cleanupEffectMap();
};
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/include/equalizer-impl/Equalizer.h b/audio/aidl/default/include/equalizer-impl/Equalizer.h
deleted file mode 100644
index ea16cb9..0000000
--- a/audio/aidl/default/include/equalizer-impl/Equalizer.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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/audio/effect/BnEffect.h>
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Equalizer type UUID.
-static const ::aidl::android::media::audio::common::AudioUuid EqualizerTypeUUID = {
- static_cast<int32_t>(0x0bed4300),
- 0xddd6,
- 0x11db,
- 0x8f34,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-// Equalizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid EqualizerSwImplUUID = {
- static_cast<int32_t>(0x0bed4300),
- 0x847d,
- 0x11df,
- 0xbb17,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-class Equalizer : public BnEffect {
- public:
- Equalizer() = default;
- ndk::ScopedAStatus open() override;
- ndk::ScopedAStatus close() override;
- ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
-
- private:
- // Effect descriptor.
- Descriptor mDesc = {.common = {.id = {.type = EqualizerTypeUUID, .uuid = EqualizerSwImplUUID}}};
-};
-} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/include/equalizer-impl/EqualizerSw.h b/audio/aidl/default/include/equalizer-impl/EqualizerSw.h
new file mode 100644
index 0000000..58ad1de
--- /dev/null
+++ b/audio/aidl/default/include/equalizer-impl/EqualizerSw.h
@@ -0,0 +1,86 @@
+/*
+ * 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/audio/effect/BnEffect.h>
+#include <fmq/AidlMessageQueue.h>
+#include <cstdlib>
+#include <memory>
+
+#include "effect-impl/EffectThread.h"
+
+namespace aidl::android::hardware::audio::effect {
+
+class EqualizerSwWorker : public EffectThread {
+ // EqualizerSwWorker(const std::string name){EffectThread(name)};
+ void process() override;
+};
+
+class EqualizerSw : public BnEffect {
+ public:
+ EqualizerSw() {
+ // create the worker
+ mWorker = std::make_unique<EqualizerSwWorker>();
+ LOG(DEBUG) << __func__;
+ };
+ ~EqualizerSw() {
+ cleanUp();
+ LOG(DEBUG) << __func__;
+ };
+ ndk::ScopedAStatus open(const Parameter::Common& common, const Parameter::Specific& specific,
+ OpenEffectReturn* _aidl_return) override;
+ ndk::ScopedAStatus close() override;
+ ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
+
+ ndk::ScopedAStatus getState(State* _aidl_return) override;
+ ndk::ScopedAStatus command(CommandId in_commandId) override;
+ ndk::ScopedAStatus setParameter(const Parameter& in_param) override;
+ ndk::ScopedAStatus getParameter(const Parameter::Id& in_paramId,
+ Parameter* _aidl_return) override;
+
+ private:
+ // effect processing thread.
+ std::unique_ptr<EqualizerSwWorker> mWorker;
+ // Effect descriptor.
+ const Descriptor mDesc = {
+ .common = {.id = {.type = EqualizerTypeUUID, .uuid = EqualizerSwImplUUID}}};
+
+ // Parameters.
+ Parameter::Common mCommonParam;
+ Equalizer mEqualizerParam; // TODO: the equalizer parameter needs to update
+
+ // Instance state INIT by default.
+ State mState = State::INIT;
+
+ typedef ::android::AidlMessageQueue<
+ Status, ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>
+ StatusMQ;
+ typedef ::android::AidlMessageQueue<
+ int8_t, ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>
+ DataMQ;
+
+ std::unique_ptr<StatusMQ> mStatusMQ;
+ std::unique_ptr<DataMQ> mInputMQ;
+ std::unique_ptr<DataMQ> mOutputMQ;
+
+ ndk::ScopedAStatus setCommonParameter(const Parameter::Common& common_param);
+ ndk::ScopedAStatus setSpecificParameter(const Parameter::Specific& specific);
+ bool createFmq(int statusDepth, int inBufferSize, int outBufferSize, OpenEffectReturn* ret);
+ void destroyFmq();
+ void cleanUp();
+};
+} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/vts/Android.bp b/audio/aidl/vts/Android.bp
index 6ea7cef..63fc415 100644
--- a/audio/aidl/vts/Android.bp
+++ b/audio/aidl/vts/Android.bp
@@ -43,6 +43,36 @@
}
cc_test {
+ name: "VtsHalAudioEffectFactoryTargetTest",
+ defaults: [
+ "latest_android_media_audio_common_types_ndk_static",
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: [
+ "VtsHalAudioEffectFactoryTargetTest.cpp",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ ],
+ static_libs: [
+ "android.hardware.audio.effect-V1-ndk",
+ "android.hardware.common-V2-ndk",
+ "android.hardware.common.fmq-V1-ndk",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-Wthread-safety",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+}
+
+cc_test {
name: "VtsHalAudioEffectTargetTest",
defaults: [
"latest_android_media_audio_common_types_ndk_static",
@@ -57,6 +87,8 @@
],
static_libs: [
"android.hardware.audio.effect-V1-ndk",
+ "android.hardware.common-V2-ndk",
+ "android.hardware.common.fmq-V1-ndk",
],
cflags: [
"-Wall",
diff --git a/audio/aidl/vts/EffectFactoryHelper.h b/audio/aidl/vts/EffectFactoryHelper.h
new file mode 100644
index 0000000..cf94e58
--- /dev/null
+++ b/audio/aidl/vts/EffectFactoryHelper.h
@@ -0,0 +1,144 @@
+/*
+ * 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 <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include <android/binder_auto_utils.h>
+
+#include "TestUtils.h"
+
+using namespace android;
+
+using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::IEffect;
+using aidl::android::hardware::audio::effect::IFactory;
+using aidl::android::hardware::audio::effect::Parameter;
+using aidl::android::hardware::audio::effect::Processing;
+using aidl::android::media::audio::common::AudioUuid;
+
+class EffectFactoryHelper {
+ public:
+ explicit EffectFactoryHelper(const std::string& name) : mServiceName(name) {}
+
+ void ConnectToFactoryService() {
+ mEffectFactory = IFactory::fromBinder(binderUtil.connectToService(mServiceName));
+ ASSERT_NE(mEffectFactory, nullptr);
+ }
+
+ void RestartFactoryService() {
+ ASSERT_NE(mEffectFactory, nullptr);
+ mEffectFactory = IFactory::fromBinder(binderUtil.restartService());
+ ASSERT_NE(mEffectFactory, nullptr);
+ ClearEffectMap();
+ }
+
+ void QueryEffects(const std::optional<AudioUuid>& in_type,
+ const std::optional<AudioUuid>& in_instance,
+ std::vector<Descriptor::Identity>* _aidl_return) {
+ ASSERT_NE(mEffectFactory, nullptr);
+ EXPECT_IS_OK(mEffectFactory->queryEffects(in_type, in_instance, _aidl_return));
+ mIds = *_aidl_return;
+ }
+
+ void QueryProcessing(const std::optional<Processing::Type>& in_type,
+ std::vector<Processing>* _aidl_return) {
+ ASSERT_NE(mEffectFactory, nullptr);
+ EXPECT_IS_OK(mEffectFactory->queryProcessing(in_type, _aidl_return));
+ // only update the whole list if no filter applied
+ if (!in_type.has_value()) {
+ mProcesses = *_aidl_return;
+ }
+ }
+
+ void CreateEffects() {
+ ASSERT_NE(mEffectFactory, nullptr);
+ for (const auto& id : mIds) {
+ std::shared_ptr<IEffect> effect;
+ EXPECT_IS_OK(mEffectFactory->createEffect(id.uuid, &effect));
+ EXPECT_NE(effect, nullptr) << id.toString();
+ if (effect) {
+ mEffectIdMap[effect] = id;
+ }
+ }
+ }
+
+ void CreateEffectsAndExpect(
+ const std::vector<std::pair<Descriptor::Identity, binder_exception_t>>& uuid_status) {
+ ASSERT_NE(mEffectFactory, nullptr);
+ for (const auto& it : uuid_status) {
+ std::shared_ptr<IEffect> effect;
+ auto status = mEffectFactory->createEffect(it.first.uuid, &effect);
+ EXPECT_STATUS(it.second, status);
+ if (effect) {
+ mEffectIdMap[effect] = it.first;
+ }
+ }
+ }
+
+ void DestroyEffectAndExpect(std::shared_ptr<IEffect>& instance, binder_exception_t exception) {
+ ASSERT_NE(mEffectFactory, nullptr);
+ auto status = mEffectFactory->destroyEffect(instance);
+ EXPECT_STATUS(exception, status);
+ }
+
+ void QueryAndCreateAllEffects() {
+ ASSERT_NE(mEffectFactory, nullptr);
+ EXPECT_IS_OK(mEffectFactory->queryEffects(std::nullopt, std::nullopt, &mCompleteIds));
+ for (const auto& id : mCompleteIds) {
+ std::shared_ptr<IEffect> effect;
+ EXPECT_IS_OK(mEffectFactory->createEffect(id.uuid, &effect));
+ EXPECT_NE(effect, nullptr) << id.toString();
+ mEffectIdMap[effect] = id;
+ }
+ }
+
+ void DestroyEffects(const binder_exception_t expected = EX_NONE, const int remaining = 0) {
+ ASSERT_NE(mEffectFactory, nullptr);
+
+ for (auto it = mEffectIdMap.begin(); it != mEffectIdMap.end();) {
+ auto erased = it++;
+ auto status = mEffectFactory->destroyEffect(erased->first);
+ EXPECT_STATUS(expected, status);
+ if (status.isOk()) {
+ mEffectIdMap.erase(erased);
+ }
+ }
+ EXPECT_EQ((unsigned int)remaining, mEffectIdMap.size());
+ }
+
+ std::shared_ptr<IFactory> GetFactory() { return mEffectFactory; }
+ const std::vector<Descriptor::Identity>& GetEffectIds() { return mIds; }
+ const std::vector<Descriptor::Identity>& GetCompleteEffectIdList() { return mCompleteIds; }
+ const std::map<std::shared_ptr<IEffect>, Descriptor::Identity>& GetEffectMap() {
+ return mEffectIdMap;
+ }
+ void ClearEffectMap() { mEffectIdMap.clear(); }
+
+ private:
+ std::shared_ptr<IFactory> mEffectFactory;
+ std::string mServiceName;
+ AudioHalBinderServiceUtil binderUtil;
+ std::vector<Descriptor::Identity> mIds;
+ std::vector<Descriptor::Identity> mCompleteIds;
+ std::vector<Processing> mProcesses;
+
+ std::map<std::shared_ptr<IEffect>, Descriptor::Identity> mEffectIdMap;
+};
diff --git a/audio/aidl/vts/VtsHalAudioEffectFactoryTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectFactoryTargetTest.cpp
new file mode 100644
index 0000000..454ce29
--- /dev/null
+++ b/audio/aidl/vts/VtsHalAudioEffectFactoryTargetTest.cpp
@@ -0,0 +1,242 @@
+/*
+ * 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 <memory>
+#include <string>
+#include <vector>
+
+#define LOG_TAG "VtsHalAudioEffectFactory"
+
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <android/binder_interface_utils.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+#include <aidl/android/hardware/audio/effect/IFactory.h>
+
+#include "AudioHalBinderServiceUtil.h"
+#include "EffectFactoryHelper.h"
+#include "TestUtils.h"
+
+using namespace android;
+
+using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::IFactory;
+using aidl::android::hardware::audio::effect::Processing;
+using aidl::android::media::audio::common::AudioUuid;
+
+/// Effect factory testing.
+class EffectFactoryTest : public testing::TestWithParam<std::string> {
+ public:
+ void SetUp() override { ASSERT_NO_FATAL_FAILURE(mFactory.ConnectToFactoryService()); }
+
+ void TearDown() override { mFactory.DestroyEffects(); }
+
+ EffectFactoryHelper mFactory = EffectFactoryHelper(GetParam());
+
+ // TODO: these UUID can get from config file
+ // ec7178ec-e5e1-4432-a3f4-4657e6795210
+ const AudioUuid nullUuid = {static_cast<int32_t>(0xec7178ec),
+ 0xe5e1,
+ 0x4432,
+ 0xa3f4,
+ {0x46, 0x57, 0xe6, 0x79, 0x52, 0x10}};
+ const AudioUuid zeroUuid = {
+ static_cast<int32_t>(0x0), 0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
+ const Descriptor::Identity nullDesc = {.uuid = nullUuid};
+ const Descriptor::Identity zeroDesc = {.uuid = zeroUuid};
+};
+
+TEST_P(EffectFactoryTest, SetupAndTearDown) {
+ // Intentionally empty test body.
+}
+
+TEST_P(EffectFactoryTest, CanBeRestarted) {
+ ASSERT_NO_FATAL_FAILURE(mFactory.RestartFactoryService());
+}
+
+TEST_P(EffectFactoryTest, QueriedDescriptorList) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ EXPECT_NE(descriptors.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, DescriptorUUIDNotNull) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ // TODO: Factory eventually need to return the full list of MUST supported AOSP effects.
+ for (auto& desc : descriptors) {
+ EXPECT_NE(desc.type, zeroUuid);
+ EXPECT_NE(desc.uuid, zeroUuid);
+ }
+}
+
+TEST_P(EffectFactoryTest, QueriedDescriptorNotExistType) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(nullUuid, std::nullopt, &descriptors);
+ EXPECT_EQ(descriptors.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, QueriedDescriptorNotExistInstance) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, nullUuid, &descriptors);
+ EXPECT_EQ(descriptors.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, CreateAndDestroyOnce) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ auto numIds = mFactory.GetEffectIds().size();
+ EXPECT_NE(numIds, 0UL);
+
+ auto& effectMap = mFactory.GetEffectMap();
+ EXPECT_EQ(effectMap.size(), 0UL);
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ mFactory.DestroyEffects();
+ EXPECT_EQ(effectMap.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, CreateAndDestroyRepeat) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ auto numIds = mFactory.GetEffectIds().size();
+ EXPECT_NE(numIds, 0UL);
+
+ auto& effectMap = mFactory.GetEffectMap();
+ EXPECT_EQ(effectMap.size(), 0UL);
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ mFactory.DestroyEffects();
+ EXPECT_EQ(effectMap.size(), 0UL);
+
+ // Create and destroy again
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ mFactory.DestroyEffects();
+ EXPECT_EQ(effectMap.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, CreateMultipleInstanceOfSameEffect) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ auto numIds = mFactory.GetEffectIds().size();
+ EXPECT_NE(numIds, 0UL);
+
+ auto& effectMap = mFactory.GetEffectMap();
+ EXPECT_EQ(effectMap.size(), 0UL);
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ // Create effect instances of same implementation
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), 2 * numIds);
+
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), 3 * numIds);
+
+ mFactory.DestroyEffects();
+ EXPECT_EQ(effectMap.size(), 0UL);
+}
+
+// Expect EX_ILLEGAL_ARGUMENT when create with invalid UUID.
+TEST_P(EffectFactoryTest, CreateWithInvalidUuid) {
+ std::vector<std::pair<Descriptor::Identity, binder_status_t>> descriptors;
+ descriptors.push_back(std::make_pair(nullDesc, EX_ILLEGAL_ARGUMENT));
+ descriptors.push_back(std::make_pair(zeroDesc, EX_ILLEGAL_ARGUMENT));
+
+ auto& effectMap = mFactory.GetEffectMap();
+ mFactory.CreateEffectsAndExpect(descriptors);
+ EXPECT_EQ(effectMap.size(), 0UL);
+}
+
+// Expect EX_ILLEGAL_ARGUMENT when destroy null interface.
+TEST_P(EffectFactoryTest, DestroyWithInvalidInterface) {
+ std::shared_ptr<IEffect> spDummyEffect(nullptr);
+
+ mFactory.DestroyEffectAndExpect(spDummyEffect, EX_ILLEGAL_ARGUMENT);
+}
+
+TEST_P(EffectFactoryTest, CreateAndRemoveReference) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ auto numIds = mFactory.GetEffectIds().size();
+ EXPECT_NE(numIds, 0UL);
+
+ auto& effectMap = mFactory.GetEffectMap();
+ EXPECT_EQ(effectMap.size(), 0UL);
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ // remove all reference
+ mFactory.ClearEffectMap();
+ EXPECT_EQ(effectMap.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, CreateRemoveReferenceAndCreateDestroy) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ auto numIds = mFactory.GetEffectIds().size();
+ EXPECT_NE(numIds, 0UL);
+
+ auto& effectMap = mFactory.GetEffectMap();
+ EXPECT_EQ(effectMap.size(), 0UL);
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ // remove all reference
+ mFactory.ClearEffectMap();
+ EXPECT_EQ(effectMap.size(), 0UL);
+
+ // Create and destroy again
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ mFactory.DestroyEffects();
+ EXPECT_EQ(effectMap.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, CreateRestartAndCreateDestroy) {
+ std::vector<Descriptor::Identity> descriptors;
+ mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
+ auto numIds = mFactory.GetEffectIds().size();
+ auto& effectMap = mFactory.GetEffectMap();
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ ASSERT_NO_FATAL_FAILURE(mFactory.RestartFactoryService());
+
+ mFactory.CreateEffects();
+ EXPECT_EQ(effectMap.size(), numIds);
+ mFactory.DestroyEffects();
+ EXPECT_EQ(effectMap.size(), 0UL);
+}
+
+TEST_P(EffectFactoryTest, QueryProcess) {
+ std::vector<Processing> processing;
+ mFactory.QueryProcessing(std::nullopt, &processing);
+ // TODO: verify the number of process in example implementation after audio_effects.xml migrated
+}
+
+INSTANTIATE_TEST_SUITE_P(EffectFactoryTest, EffectFactoryTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(IFactory::descriptor)),
+ android::PrintInstanceNameToString);
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EffectFactoryTest);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+ return RUN_ALL_TESTS();
+}
\ No newline at end of file
diff --git a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
index 8b5eb13..23b20bd 100644
--- a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
@@ -30,205 +30,68 @@
#include <android/binder_manager.h>
#include <android/binder_process.h>
+#include <aidl/android/hardware/audio/effect/IEffect.h>
#include <aidl/android/hardware/audio/effect/IFactory.h>
+#include <aidl/android/media/audio/common/AudioChannelLayout.h>
+#include <aidl/android/media/audio/common/AudioDeviceType.h>
#include "AudioHalBinderServiceUtil.h"
+#include "EffectFactoryHelper.h"
#include "TestUtils.h"
using namespace android;
using ndk::ScopedAStatus;
+using aidl::android::hardware::audio::effect::CommandId;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
-using aidl::android::media::audio::common::AudioUuid;
+using aidl::android::hardware::audio::effect::Parameter;
+using aidl::android::hardware::audio::effect::State;
+using aidl::android::media::audio::common::AudioChannelLayout;
+using aidl::android::media::audio::common::AudioDeviceType;
-class EffectFactoryHelper {
- public:
- explicit EffectFactoryHelper(const std::string& name) : mServiceName(name) {}
-
- void ConnectToFactoryService() {
- mEffectFactory = IFactory::fromBinder(binderUtil.connectToService(mServiceName));
- ASSERT_NE(mEffectFactory, nullptr);
- }
-
- void RestartFactoryService() {
- ASSERT_NE(mEffectFactory, nullptr);
- mEffectFactory = IFactory::fromBinder(binderUtil.restartService());
- ASSERT_NE(mEffectFactory, nullptr);
- }
-
- void QueryAllEffects() {
- EXPECT_NE(mEffectFactory, nullptr);
- EXPECT_IS_OK(mEffectFactory->queryEffects(std::nullopt, std::nullopt, &mCompleteIds));
- }
-
- void QueryEffects(const std::optional<AudioUuid>& in_type,
- const std::optional<AudioUuid>& in_instance,
- std::vector<Descriptor::Identity>* _aidl_return) {
- EXPECT_NE(mEffectFactory, nullptr);
- EXPECT_IS_OK(mEffectFactory->queryEffects(in_type, in_instance, _aidl_return));
- mIds = *_aidl_return;
- }
-
- void CreateEffects() {
- EXPECT_NE(mEffectFactory, nullptr);
- for (const auto& id : mIds) {
- std::shared_ptr<IEffect> effect;
- EXPECT_IS_OK(mEffectFactory->createEffect(id.uuid, &effect));
- EXPECT_NE(effect, nullptr) << id.toString();
- mEffectIdMap[effect] = id;
- }
- }
-
- void DestroyEffects() {
- EXPECT_NE(mEffectFactory, nullptr);
- for (const auto& it : mEffectIdMap) {
- EXPECT_IS_OK(mEffectFactory->destroyEffect(it.first));
- }
- mEffectIdMap.clear();
- }
-
- std::shared_ptr<IFactory> GetFactory() { return mEffectFactory; }
- const std::vector<Descriptor::Identity>& GetEffectIds() { return mIds; }
- const std::vector<Descriptor::Identity>& GetCompleteEffectIdList() { return mCompleteIds; }
- const std::unordered_map<std::shared_ptr<IEffect>, Descriptor::Identity>& GetEffectMap() {
- return mEffectIdMap;
- }
-
- private:
- std::shared_ptr<IFactory> mEffectFactory;
- std::string mServiceName;
- AudioHalBinderServiceUtil binderUtil;
- std::vector<Descriptor::Identity> mIds;
- std::vector<Descriptor::Identity> mCompleteIds;
- std::unordered_map<std::shared_ptr<IEffect>, Descriptor::Identity> mEffectIdMap;
-};
-
-/// Effect factory testing.
-class EffectFactoryTest : public testing::TestWithParam<std::string> {
- public:
- void SetUp() override { ASSERT_NO_FATAL_FAILURE(mFactory.ConnectToFactoryService()); }
-
- void TearDown() override { mFactory.DestroyEffects(); }
-
- EffectFactoryHelper mFactory = EffectFactoryHelper(GetParam());
-
- // TODO: these UUID can get from config file
- // ec7178ec-e5e1-4432-a3f4-4657e6795210
- const AudioUuid nullUuid = {static_cast<int32_t>(0xec7178ec),
- 0xe5e1,
- 0x4432,
- 0xa3f4,
- {0x46, 0x57, 0xe6, 0x79, 0x52, 0x10}};
- const AudioUuid zeroUuid = {
- static_cast<int32_t>(0x0), 0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
-};
-
-TEST_P(EffectFactoryTest, SetupAndTearDown) {
- // Intentionally empty test body.
-}
-
-TEST_P(EffectFactoryTest, CanBeRestarted) {
- ASSERT_NO_FATAL_FAILURE(mFactory.RestartFactoryService());
-}
-
-TEST_P(EffectFactoryTest, QueriedDescriptorList) {
- std::vector<Descriptor::Identity> descriptors;
- mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
- EXPECT_NE(descriptors.size(), 0UL);
-}
-
-TEST_P(EffectFactoryTest, DescriptorUUIDNotNull) {
- std::vector<Descriptor::Identity> descriptors;
- mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
- // TODO: Factory eventually need to return the full list of MUST supported AOSP effects.
- for (auto& desc : descriptors) {
- EXPECT_NE(desc.type, zeroUuid);
- EXPECT_NE(desc.uuid, zeroUuid);
- }
-}
-
-TEST_P(EffectFactoryTest, QueriedDescriptorNotExistType) {
- std::vector<Descriptor::Identity> descriptors;
- mFactory.QueryEffects(nullUuid, std::nullopt, &descriptors);
- EXPECT_EQ(descriptors.size(), 0UL);
-}
-
-TEST_P(EffectFactoryTest, QueriedDescriptorNotExistInstance) {
- std::vector<Descriptor::Identity> descriptors;
- mFactory.QueryEffects(std::nullopt, nullUuid, &descriptors);
- EXPECT_EQ(descriptors.size(), 0UL);
-}
-
-TEST_P(EffectFactoryTest, CreateAndDestroyRepeat) {
- std::vector<Descriptor::Identity> descriptors;
- mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
- auto numIds = mFactory.GetEffectIds().size();
- EXPECT_NE(numIds, 0UL);
-
- EXPECT_EQ(mFactory.GetEffectMap().size(), 0UL);
- mFactory.CreateEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), numIds);
- mFactory.DestroyEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), 0UL);
-
- // Create and destroy again
- mFactory.CreateEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), numIds);
- mFactory.DestroyEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), 0UL);
-}
-
-TEST_P(EffectFactoryTest, CreateMultipleInstanceOfSameEffect) {
- std::vector<Descriptor::Identity> descriptors;
- mFactory.QueryEffects(std::nullopt, std::nullopt, &descriptors);
- auto numIds = mFactory.GetEffectIds().size();
- EXPECT_NE(numIds, 0UL);
-
- EXPECT_EQ(mFactory.GetEffectMap().size(), 0UL);
- mFactory.CreateEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), numIds);
- // Create effect instances of same implementation
- mFactory.CreateEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), 2 * numIds);
-
- mFactory.CreateEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), 3 * numIds);
-
- mFactory.DestroyEffects();
- EXPECT_EQ(mFactory.GetEffectMap().size(), 0UL);
-}
-
-INSTANTIATE_TEST_SUITE_P(EffectFactoryTest, EffectFactoryTest,
- testing::ValuesIn(android::getAidlHalInstanceNames(IFactory::descriptor)),
- android::PrintInstanceNameToString);
-GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EffectFactoryTest);
-
-/// Effect testing.
class AudioEffect : public testing::TestWithParam<std::string> {
public:
void SetUp() override {
- ASSERT_NO_FATAL_FAILURE(mFactory.ConnectToFactoryService());
- ASSERT_NO_FATAL_FAILURE(mFactory.CreateEffects());
+ ASSERT_NO_FATAL_FAILURE(mFactoryHelper.ConnectToFactoryService());
+ CreateEffects();
+ initParamCommon();
+ initParamSpecific();
}
void TearDown() override {
CloseEffects();
- ASSERT_NO_FATAL_FAILURE(mFactory.DestroyEffects());
+ DestroyEffects();
}
void OpenEffects() {
- auto open = [](const std::shared_ptr<IEffect>& effect) { EXPECT_IS_OK(effect->open()); };
+ auto open = [&](const std::shared_ptr<IEffect>& effect) {
+ IEffect::OpenEffectReturn ret;
+ EXPECT_IS_OK(effect->open(mCommon, mSpecific, &ret));
+ };
EXPECT_NO_FATAL_FAILURE(ForEachEffect(open));
}
- void CloseEffects() {
- auto close = [](const std::shared_ptr<IEffect>& effect) { EXPECT_IS_OK(effect->close()); };
+ void CloseEffects(const binder_status_t status = EX_NONE) {
+ auto close = [&](const std::shared_ptr<IEffect>& effect) {
+ EXPECT_STATUS(status, effect->close());
+ };
+
EXPECT_NO_FATAL_FAILURE(ForEachEffect(close));
}
+ void CreateEffects(const int n = 1) {
+ for (int i = 0; i < n; i++) {
+ ASSERT_NO_FATAL_FAILURE(mFactoryHelper.QueryAndCreateAllEffects());
+ }
+ }
+
+ void DestroyEffects(const binder_status_t status = EX_NONE, const int remaining = 0) {
+ ASSERT_NO_FATAL_FAILURE(mFactoryHelper.DestroyEffects(status, remaining));
+ }
+
void GetEffectDescriptors() {
auto get = [](const std::shared_ptr<IEffect>& effect) {
Descriptor desc;
@@ -237,16 +100,101 @@
EXPECT_NO_FATAL_FAILURE(ForEachEffect(get));
}
+ void CommandEffects(CommandId command) {
+ auto close = [&](const std::shared_ptr<IEffect>& effect) {
+ EXPECT_IS_OK(effect->command(command));
+ };
+ EXPECT_NO_FATAL_FAILURE(ForEachEffect(close));
+ }
+
+ void CommandEffectsExpectStatus(CommandId command, const binder_status_t status) {
+ auto func = [&](const std::shared_ptr<IEffect>& effect) {
+ EXPECT_STATUS(status, effect->command(command));
+ };
+ EXPECT_NO_FATAL_FAILURE(ForEachEffect(func));
+ }
+
+ void ExpectState(State expected) {
+ auto get = [&](const std::shared_ptr<IEffect>& effect) {
+ State state = State::INIT;
+ EXPECT_IS_OK(effect->getState(&state));
+ EXPECT_EQ(expected, state);
+ };
+ EXPECT_NO_FATAL_FAILURE(ForEachEffect(get));
+ }
+
+ void SetParameter() {
+ auto func = [&](const std::shared_ptr<IEffect>& effect) {
+ Parameter param;
+ param.set<Parameter::common>(mCommon);
+ EXPECT_IS_OK(effect->setParameter(param));
+ };
+ EXPECT_NO_FATAL_FAILURE(ForEachEffect(func));
+ }
+
+ void VerifyParameters() {
+ auto func = [&](const std::shared_ptr<IEffect>& effect) {
+ Parameter paramCommonGet = Parameter(), paramCommonExpect = Parameter();
+ Parameter::Id id;
+ id.set<Parameter::Id::commonTag>(0);
+ paramCommonExpect.set<Parameter::common>(mCommon);
+ EXPECT_IS_OK(effect->getParameter(id, ¶mCommonGet));
+ EXPECT_EQ(paramCommonExpect, paramCommonGet)
+ << paramCommonExpect.toString() << " vs " << paramCommonGet.toString();
+ };
+ EXPECT_NO_FATAL_FAILURE(ForEachEffect(func));
+ }
+
template <typename Functor>
void ForEachEffect(Functor functor) {
- auto effectMap = mFactory.GetEffectMap();
+ auto effectMap = mFactoryHelper.GetEffectMap();
for (const auto& it : effectMap) {
SCOPED_TRACE(it.second.toString());
functor(it.first);
}
}
- EffectFactoryHelper mFactory = EffectFactoryHelper(GetParam());
+ void initParamCommon(int session = -1, int ioHandle = -1,
+ AudioDeviceType deviceType = AudioDeviceType::NONE,
+ int iSampleRate = 48000, int oSampleRate = 48000, long iFrameCount = 0x100,
+ long oFrameCount = 0x100) {
+ mCommon.session = session;
+ mCommon.ioHandle = ioHandle;
+ mCommon.device.type = deviceType;
+ mCommon.input.base.sampleRate = iSampleRate;
+ mCommon.input.base.channelMask = mInputChannelLayout;
+ mCommon.input.frameCount = iFrameCount;
+ mCommon.output.base.sampleRate = oSampleRate;
+ mCommon.output.base.channelMask = mOutputChannelLayout;
+ mCommon.output.frameCount = oFrameCount;
+ }
+
+ void initParamSpecific(Parameter::Specific::Tag tag = Parameter::Specific::equalizer) {
+ switch (tag) {
+ case Parameter::Specific::equalizer:
+ mSpecific.set<Parameter::Specific::equalizer>();
+ break;
+ default:
+ return;
+ }
+ }
+
+ void setInputChannelLayout(AudioChannelLayout input) { mInputChannelLayout = input; }
+ void setOutputChannelLayout(AudioChannelLayout output) { mOutputChannelLayout = output; }
+
+ EffectFactoryHelper mFactoryHelper = EffectFactoryHelper(GetParam());
+
+ private:
+ AudioChannelLayout mInputChannelLayout =
+ AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
+ AudioChannelLayout::LAYOUT_STEREO);
+ AudioChannelLayout mOutputChannelLayout =
+ AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
+ AudioChannelLayout::LAYOUT_STEREO);
+
+ Parameter::Common mCommon;
+ Parameter::Specific mSpecific;
+ static IEffect::OpenEffectReturn mOpenReturn;
};
TEST_P(AudioEffect, OpenEffectTest) {
@@ -286,7 +234,7 @@
Descriptor desc;
std::vector<Descriptor::Identity> idList;
EXPECT_IS_OK(effect->getDescriptor(&desc));
- mFactory.QueryEffects(desc.common.id.type, desc.common.id.uuid, &idList);
+ mFactoryHelper.QueryEffects(desc.common.id.type, desc.common.id.uuid, &idList);
EXPECT_EQ(idList.size(), 1UL);
};
EXPECT_NO_FATAL_FAILURE(ForEachEffect(checker));
@@ -295,7 +243,7 @@
auto stringHash = [](const Descriptor::Identity& id) {
return std::hash<std::string>()(id.toString());
};
- auto vec = mFactory.GetCompleteEffectIdList();
+ auto vec = mFactoryHelper.GetCompleteEffectIdList();
std::unordered_set<Descriptor::Identity, decltype(stringHash)> idSet(0, stringHash);
for (auto it : vec) {
EXPECT_EQ(idSet.count(it), 0UL);
@@ -303,6 +251,212 @@
}
}
+/// State testing.
+// An effect instance is in INIT state by default after it was created.
+TEST_P(AudioEffect, InitStateAfterCreation) {
+ ExpectState(State::INIT);
+}
+
+// An effect instance transfer to INIT state after it was open successfully with IEffect.open().
+TEST_P(AudioEffect, IdleStateAfterOpen) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// An effect instance is in PROCESSING state after it receive an START command.
+TEST_P(AudioEffect, ProcessingStateAfterStart) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// An effect instance transfer to IDLE state after Command.Id.STOP in PROCESSING state.
+TEST_P(AudioEffect, IdleStateAfterStop) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// An effect instance transfer to IDLE state after Command.Id.RESET in PROCESSING state.
+TEST_P(AudioEffect, IdleStateAfterReset) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// An effect instance transfer to INIT if instance receive a close() call.
+TEST_P(AudioEffect, InitStateAfterClose) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+ ExpectState(State::INIT);
+}
+
+// An effect instance shouldn't accept any command before open.
+TEST_P(AudioEffect, NoCommandAcceptedBeforeOpen) {
+ ExpectState(State::INIT);
+ EXPECT_NO_FATAL_FAILURE(CommandEffectsExpectStatus(CommandId::START, EX_ILLEGAL_STATE));
+ EXPECT_NO_FATAL_FAILURE(CommandEffectsExpectStatus(CommandId::STOP, EX_ILLEGAL_STATE));
+ EXPECT_NO_FATAL_FAILURE(CommandEffectsExpectStatus(CommandId::RESET, EX_ILLEGAL_STATE));
+ ExpectState(State::INIT);
+}
+
+// No-op when receive STOP command in IDLE state.
+TEST_P(AudioEffect, StopCommandInIdleStateNoOp) {
+ ExpectState(State::INIT);
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// No-op when receive STOP command in IDLE state.
+TEST_P(AudioEffect, ResetCommandInIdleStateNoOp) {
+ ExpectState(State::INIT);
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// Repeat START and STOP command.
+TEST_P(AudioEffect, RepeatStartAndStop) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// Repeat START and RESET command.
+TEST_P(AudioEffect, RepeatStartAndReset) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// Repeat START and STOP command, try to close at PROCESSING state.
+TEST_P(AudioEffect, CloseProcessingStateEffects) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects(EX_ILLEGAL_STATE));
+ // cleanup
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+}
+
+// Expect EX_ILLEGAL_STATE if the effect instance is not in a proper state to be destroyed.
+TEST_P(AudioEffect, DestroyOpenEffects) {
+ // cleanup all effects.
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+ ASSERT_NO_FATAL_FAILURE(DestroyEffects());
+
+ // open effects, destroy without close, expect to get EX_ILLEGAL_STATE status.
+ EXPECT_NO_FATAL_FAILURE(CreateEffects());
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(DestroyEffects(EX_ILLEGAL_STATE, 1));
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+/// Parameter testing.
+// Verify parameters pass in open can be successfully get.
+TEST_P(AudioEffect, VerifyParametersAfterOpen) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// Verify parameters pass in set can be successfully get.
+TEST_P(AudioEffect, SetAndGetParameter) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
+ 44100 /* iSampleRate */, 44100 /* oSampleRate */);
+ EXPECT_NO_FATAL_FAILURE(SetParameter());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// Verify parameters pass in set can be successfully get.
+TEST_P(AudioEffect, SetAndGetParameterInProcessing) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
+ 44100 /* iSampleRate */, 44100 /* oSampleRate */);
+ EXPECT_NO_FATAL_FAILURE(SetParameter());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// Parameters kept after reset.
+TEST_P(AudioEffect, ResetAndVerifyParameter) {
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
+ 44100 /* iSampleRate */, 44100 /* oSampleRate */);
+ EXPECT_NO_FATAL_FAILURE(SetParameter());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
+// Multiple instances of same implementation running.
+TEST_P(AudioEffect, MultipleInstancesRunning) {
+ EXPECT_NO_FATAL_FAILURE(CreateEffects(3));
+ ExpectState(State::INIT);
+ EXPECT_NO_FATAL_FAILURE(OpenEffects());
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
+ ExpectState(State::PROCESSING);
+ initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
+ 44100 /* iSampleRate */, 44100 /* oSampleRate */);
+ EXPECT_NO_FATAL_FAILURE(SetParameter());
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
+ ExpectState(State::IDLE);
+ EXPECT_NO_FATAL_FAILURE(VerifyParameters());
+ EXPECT_NO_FATAL_FAILURE(CloseEffects());
+}
+
INSTANTIATE_TEST_SUITE_P(AudioEffectTest, AudioEffect,
testing::ValuesIn(android::getAidlHalInstanceNames(IFactory::descriptor)),
android::PrintInstanceNameToString);
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index ceb5dcf..3158624 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -432,18 +432,6 @@
<regex-instance>vendor[0-9]*_software</regex-instance>
</interface>
</hal>
- <hal format="hidl" optional="true">
- <name>android.hardware.media.omx</name>
- <version>1.0</version>
- <interface>
- <name>IOmx</name>
- <instance>default</instance>
- </interface>
- <interface>
- <name>IOmxStore</name>
- <instance>default</instance>
- </interface>
- </hal>
<hal format="aidl" optional="true">
<name>android.hardware.memtrack</name>
<version>1</version>
@@ -680,6 +668,20 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="aidl" optional="true">
+ <name>android.hardware.tv.cec</name>
+ <interface>
+ <name>IHdmiCec</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="aidl" optional="true">
+ <name>android.hardware.tv.hdmi</name>
+ <interface>
+ <name>IHdmi</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<hal format="hidl" optional="true">
<name>android.hardware.tv.input</name>
<version>1.0</version>
diff --git a/gatekeeper/1.0/vts/OWNERS b/gatekeeper/1.0/vts/OWNERS
index 738c710..ee2af97 100644
--- a/gatekeeper/1.0/vts/OWNERS
+++ b/gatekeeper/1.0/vts/OWNERS
@@ -1,3 +1,3 @@
-jdanis@google.com
+# Bug component: 1124862
swillden@google.com
guangzhu@google.com
diff --git a/gatekeeper/OWNERS b/gatekeeper/OWNERS
index d95b856..fddc2ff 100644
--- a/gatekeeper/OWNERS
+++ b/gatekeeper/OWNERS
@@ -1,2 +1,4 @@
+# Bug component: 1124862
swillden@google.com
guangzhu@google.com
+subrahmanyaman@google.com
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index 2cfa04a..b81dd8f 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -83,6 +83,14 @@
DurationWrapper(1000000000L, 4L),
};
+// DEVICEs launching with Android 11 MUST meet the requirements for the
+// target-level=5 compatibility_matrix file.
+const uint64_t kCompatibilityMatrix5ApiLevel = 30;
+
+// DEVICEs launching with Android 13 MUST meet the requirements for the
+// target-level=7 compatibility_matrix file.
+const uint64_t kCompatibilityMatrix7ApiLevel = 33;
+
inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) {
return status.getStatus() == STATUS_UNKNOWN_TRANSACTION ||
status.getExceptionCode() == EX_UNSUPPORTED_OPERATION;
@@ -94,9 +102,13 @@
AIBinder* binder = AServiceManager_waitForService(GetParam().c_str());
ASSERT_NE(binder, nullptr);
power = IPower::fromBinder(ndk::SpAIBinder(binder));
+
+ mApiLevel = GetUintProperty<uint64_t>("ro.vendor.api_level", 0);
+ ASSERT_NE(mApiLevel, 0);
}
std::shared_ptr<IPower> power;
+ uint64_t mApiLevel;
};
TEST_P(PowerAidl, setMode) {
@@ -152,11 +164,11 @@
TEST_P(PowerAidl, getHintSessionPreferredRate) {
int64_t rate = -1;
auto status = power->getHintSessionPreferredRate(&rate);
- if (!status.isOk()) {
+ if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
EXPECT_TRUE(isUnknownOrUnsupported(status));
- return;
+ GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
}
-
+ ASSERT_TRUE(status.isOk());
// At least 1ms rate limit from HAL
ASSERT_GE(rate, 1000000);
}
@@ -164,10 +176,11 @@
TEST_P(PowerAidl, createAndCloseHintSession) {
std::shared_ptr<IPowerHintSession> session;
auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
- if (!status.isOk()) {
+ if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
EXPECT_TRUE(isUnknownOrUnsupported(status));
- return;
+ GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
}
+ ASSERT_TRUE(status.isOk());
ASSERT_NE(nullptr, session);
ASSERT_TRUE(session->pause().isOk());
ASSERT_TRUE(session->resume().isOk());
@@ -175,12 +188,18 @@
ASSERT_TRUE(session->close().isOk());
session.reset();
}
+
TEST_P(PowerAidl, createHintSessionFailed) {
std::shared_ptr<IPowerHintSession> session;
auto status = power->createHintSession(getpid(), getuid(), kEmptyTids, 16666666L, &session);
+
+ // Regardless of whether V2 and beyond is supported, the status is always not STATUS_OK.
ASSERT_FALSE(status.isOk());
- if (isUnknownOrUnsupported(status)) {
- return;
+
+ // If device not launching with Android 13 and beyond, check whether it's supported,
+ // if not, skip the test.
+ if (mApiLevel < kCompatibilityMatrix7ApiLevel && isUnknownOrUnsupported(status)) {
+ GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
}
ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
}
@@ -188,10 +207,11 @@
TEST_P(PowerAidl, updateAndReportDurations) {
std::shared_ptr<IPowerHintSession> session;
auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session);
- if (!status.isOk()) {
+ if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) {
EXPECT_TRUE(isUnknownOrUnsupported(status));
- return;
+ GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond.";
}
+ ASSERT_TRUE(status.isOk());
ASSERT_NE(nullptr, session);
ASSERT_TRUE(session->updateTargetWorkDuration(16666667LL).isOk());
@@ -201,14 +221,13 @@
// FIXED_PERFORMANCE mode is required for all devices which ship on Android 11
// or later
TEST_P(PowerAidl, hasFixedPerformance) {
- auto apiLevel = GetUintProperty<uint64_t>("ro.vendor.api_level", 0);
- ASSERT_NE(apiLevel, 0);
-
- if (apiLevel >= 30) {
- bool supported;
- ASSERT_TRUE(power->isModeSupported(Mode::FIXED_PERFORMANCE, &supported).isOk());
- ASSERT_TRUE(supported);
+ if (mApiLevel < kCompatibilityMatrix5ApiLevel) {
+ GTEST_SKIP() << "FIXED_PERFORMANCE mode is only required for all devices launching Android "
+ "11 or later.";
}
+ bool supported;
+ ASSERT_TRUE(power->isModeSupported(Mode::FIXED_PERFORMANCE, &supported).isOk());
+ ASSERT_TRUE(supported);
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PowerAidl);
diff --git a/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp b/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
index e1f65fe..9b21e4e 100644
--- a/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
+++ b/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp
@@ -200,9 +200,7 @@
RpcHardwareInfo hwInfo;
ASSERT_TRUE(rpc->getHardwareInfo(&hwInfo).isOk());
- int32_t version;
- ASSERT_TRUE(rpc->getInterfaceVersion(&version).isOk());
- if (version >= VERSION_WITH_UNIQUE_ID_SUPPORT) {
+ if (hwInfo.versionNumber >= VERSION_WITH_UNIQUE_ID_SUPPORT) {
ASSERT_TRUE(hwInfo.uniqueId);
auto [_, wasInserted] = uniqueIds.insert(*hwInfo.uniqueId);
EXPECT_TRUE(wasInserted);
@@ -232,10 +230,7 @@
* Verify that the unique id is within the length limits as described in RpcHardwareInfo.aidl.
*/
TEST_P(GetHardwareInfoTests, uniqueId) {
- int32_t version;
- ASSERT_TRUE(provisionable_->getInterfaceVersion(&version).isOk());
-
- if (version < VERSION_WITH_UNIQUE_ID_SUPPORT) {
+ if (rpcHardwareInfo.versionNumber < VERSION_WITH_UNIQUE_ID_SUPPORT) {
return;
}
diff --git a/tv/cec/aidl/Android.bp b/tv/cec/aidl/Android.bp
new file mode 100644
index 0000000..0b0e7cf
--- /dev/null
+++ b/tv/cec/aidl/Android.bp
@@ -0,0 +1,29 @@
+// 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.
+
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+aidl_interface {
+ name: "android.hardware.tv.cec",
+ vendor_available: true,
+ srcs: ["android/hardware/tv/cec/*.aidl"],
+ stability: "vintf",
+ backend: {
+ java: {
+ sdk_version: "module_current",
+ },
+ },
+}
diff --git a/tv/cec/aidl/OWNERS b/tv/cec/aidl/OWNERS
new file mode 100644
index 0000000..d9c6783
--- /dev/null
+++ b/tv/cec/aidl/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 826094
+include platform/frameworks/base:/core/java/android/hardware/hdmi/OWNERS
\ No newline at end of file
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/AbortReason.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/AbortReason.aidl
new file mode 100644
index 0000000..7377d81
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/AbortReason.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@Backing(type="int") @VintfStability
+enum AbortReason {
+ UNRECOGNIZED_MODE = 0,
+ NOT_IN_CORRECT_MODE = 1,
+ CANNOT_PROVIDE_SOURCE = 2,
+ INVALID_OPERAND = 3,
+ REFUSED = 4,
+ UNABLE_TO_DETERMINE = 5,
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecDeviceType.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecDeviceType.aidl
new file mode 100644
index 0000000..4d991cd
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecDeviceType.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@Backing(type="byte") @VintfStability
+enum CecDeviceType {
+ INACTIVE = -1,
+ TV = 0,
+ RECORDER = 1,
+ TUNER = 3,
+ PLAYBACK = 4,
+ AUDIO_SYSTEM = 5,
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecLogicalAddress.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecLogicalAddress.aidl
new file mode 100644
index 0000000..a36935b
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecLogicalAddress.aidl
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@Backing(type="byte") @VintfStability
+enum CecLogicalAddress {
+ TV = 0,
+ RECORDER_1 = 1,
+ RECORDER_2 = 2,
+ TUNER_1 = 3,
+ PLAYBACK_1 = 4,
+ AUDIO_SYSTEM = 5,
+ TUNER_2 = 6,
+ TUNER_3 = 7,
+ PLAYBACK_2 = 8,
+ RECORDER_3 = 9,
+ TUNER_4 = 10,
+ PLAYBACK_3 = 11,
+ BACKUP_1 = 12,
+ BACKUP_2 = 13,
+ FREE_USE = 14,
+ BROADCAST = 15,
+ UNREGISTERED = 15,
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecMessage.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecMessage.aidl
new file mode 100644
index 0000000..5ce5ce8
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecMessage.aidl
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@VintfStability
+parcelable CecMessage {
+ android.hardware.tv.cec.CecLogicalAddress initiator;
+ android.hardware.tv.cec.CecLogicalAddress destination;
+ byte[] body;
+ const int MAX_MESSAGE_BODY_LENGTH = 15;
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecMessageType.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecMessageType.aidl
new file mode 100644
index 0000000..61ebb94
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/CecMessageType.aidl
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@Backing(type="int") @VintfStability
+enum CecMessageType {
+ FEATURE_ABORT = 0,
+ IMAGE_VIEW_ON = 4,
+ TUNER_STEP_INCREMENT = 5,
+ TUNER_STEP_DECREMENT = 6,
+ TUNER_DEVICE_STATUS = 7,
+ GIVE_TUNER_DEVICE_STATUS = 8,
+ RECORD_ON = 9,
+ RECORD_STATUS = 10,
+ RECORD_OFF = 11,
+ TEXT_VIEW_ON = 13,
+ RECORD_TV_SCREEN = 15,
+ GIVE_DECK_STATUS = 26,
+ DECK_STATUS = 27,
+ SET_MENU_LANGUAGE = 50,
+ CLEAR_ANALOG_TIMER = 51,
+ SET_ANALOG_TIMER = 52,
+ TIMER_STATUS = 53,
+ STANDBY = 54,
+ PLAY = 65,
+ DECK_CONTROL = 66,
+ TIMER_CLEARED_STATUS = 67,
+ USER_CONTROL_PRESSED = 68,
+ USER_CONTROL_RELEASED = 69,
+ GIVE_OSD_NAME = 70,
+ SET_OSD_NAME = 71,
+ SET_OSD_STRING = 100,
+ SET_TIMER_PROGRAM_TITLE = 103,
+ SYSTEM_AUDIO_MODE_REQUEST = 112,
+ GIVE_AUDIO_STATUS = 113,
+ SET_SYSTEM_AUDIO_MODE = 114,
+ REPORT_AUDIO_STATUS = 122,
+ GIVE_SYSTEM_AUDIO_MODE_STATUS = 125,
+ SYSTEM_AUDIO_MODE_STATUS = 126,
+ ROUTING_CHANGE = 128,
+ ROUTING_INFORMATION = 129,
+ ACTIVE_SOURCE = 130,
+ GIVE_PHYSICAL_ADDRESS = 131,
+ REPORT_PHYSICAL_ADDRESS = 132,
+ REQUEST_ACTIVE_SOURCE = 133,
+ SET_STREAM_PATH = 134,
+ DEVICE_VENDOR_ID = 135,
+ VENDOR_COMMAND = 137,
+ VENDOR_REMOTE_BUTTON_DOWN = 138,
+ VENDOR_REMOTE_BUTTON_UP = 139,
+ GIVE_DEVICE_VENDOR_ID = 140,
+ MENU_REQUEST = 141,
+ MENU_STATUS = 142,
+ GIVE_DEVICE_POWER_STATUS = 143,
+ REPORT_POWER_STATUS = 144,
+ GET_MENU_LANGUAGE = 145,
+ SELECT_ANALOG_SERVICE = 146,
+ SELECT_DIGITAL_SERVICE = 147,
+ SET_DIGITAL_TIMER = 151,
+ CLEAR_DIGITAL_TIMER = 153,
+ SET_AUDIO_RATE = 154,
+ INACTIVE_SOURCE = 157,
+ CEC_VERSION = 158,
+ GET_CEC_VERSION = 159,
+ VENDOR_COMMAND_WITH_ID = 160,
+ CLEAR_EXTERNAL_TIMER = 161,
+ SET_EXTERNAL_TIMER = 162,
+ REPORT_SHORT_AUDIO_DESCRIPTOR = 163,
+ REQUEST_SHORT_AUDIO_DESCRIPTOR = 164,
+ INITIATE_ARC = 192,
+ REPORT_ARC_INITIATED = 193,
+ REPORT_ARC_TERMINATED = 194,
+ REQUEST_ARC_INITIATION = 195,
+ REQUEST_ARC_TERMINATION = 196,
+ TERMINATE_ARC = 197,
+ ABORT = 255,
+ GIVE_FEATURES = 165,
+ REPORT_FEATURES = 166,
+ REQUEST_CURRENT_LATENCY = 167,
+ REPORT_CURRENT_LATENCY = 168,
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/IHdmiCec.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/IHdmiCec.aidl
new file mode 100644
index 0000000..cf8425e
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/IHdmiCec.aidl
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@VintfStability
+interface IHdmiCec {
+ android.hardware.tv.cec.Result addLogicalAddress(in android.hardware.tv.cec.CecLogicalAddress addr);
+ void clearLogicalAddress();
+ void enableAudioReturnChannel(in int portId, in boolean enable);
+ int getCecVersion();
+ int getPhysicalAddress();
+ int getVendorId();
+ android.hardware.tv.cec.SendMessageResult sendMessage(in android.hardware.tv.cec.CecMessage message);
+ void setCallback(in android.hardware.tv.cec.IHdmiCecCallback callback);
+ void setLanguage(in String language);
+ void enableWakeupByOtp(in boolean value);
+ void enableCec(in boolean value);
+ void enableSystemCecControl(in boolean value);
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/IHdmiCecCallback.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/IHdmiCecCallback.aidl
new file mode 100644
index 0000000..1918765
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/IHdmiCecCallback.aidl
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@VintfStability
+interface IHdmiCecCallback {
+ oneway void onCecMessage(in android.hardware.tv.cec.CecMessage message);
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/Result.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/Result.aidl
new file mode 100644
index 0000000..a5ba276
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/Result.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@Backing(type="byte") @VintfStability
+enum Result {
+ SUCCESS = 0,
+ FAILURE_UNKNOWN = 1,
+ FAILURE_INVALID_ARGS = 2,
+ FAILURE_INVALID_STATE = 3,
+ FAILURE_NOT_SUPPORTED = 4,
+ FAILURE_BUSY = 5,
+}
diff --git a/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/SendMessageResult.aidl b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/SendMessageResult.aidl
new file mode 100644
index 0000000..58206c8
--- /dev/null
+++ b/tv/cec/aidl/aidl_api/android.hardware.tv.cec/current/android/hardware/tv/cec/SendMessageResult.aidl
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.cec;
+@Backing(type="byte") @VintfStability
+enum SendMessageResult {
+ SUCCESS = 0,
+ NACK = 1,
+ BUSY = 2,
+ FAIL = 3,
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/tv/cec/aidl/android/hardware/tv/cec/AbortReason.aidl
similarity index 60%
copy from audio/aidl/default/include/visualizer-impl/Visualizer.h
copy to tv/cec/aidl/android/hardware/tv/cec/AbortReason.aidl
index 4b82dd0..3ae23ec 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/tv/cec/aidl/android/hardware/tv/cec/AbortReason.aidl
@@ -14,18 +14,18 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.tv.cec;
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+/**
+ * Operand description [Abort Reason]
+ */
+@VintfStability
+@Backing(type="int")
+enum AbortReason {
+ UNRECOGNIZED_MODE = 0,
+ NOT_IN_CORRECT_MODE = 1,
+ CANNOT_PROVIDE_SOURCE = 2,
+ INVALID_OPERAND = 3,
+ REFUSED = 4,
+ UNABLE_TO_DETERMINE = 5,
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/tv/cec/aidl/android/hardware/tv/cec/CecDeviceType.aidl
similarity index 60%
copy from audio/aidl/default/include/visualizer-impl/Visualizer.h
copy to tv/cec/aidl/android/hardware/tv/cec/CecDeviceType.aidl
index 4b82dd0..16dfbec 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/tv/cec/aidl/android/hardware/tv/cec/CecDeviceType.aidl
@@ -14,18 +14,15 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.tv.cec;
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+@VintfStability
+@Backing(type="byte")
+enum CecDeviceType {
+ INACTIVE = -1,
+ TV = 0,
+ RECORDER = 1,
+ TUNER = 3,
+ PLAYBACK = 4,
+ AUDIO_SYSTEM = 5,
+}
diff --git a/tv/cec/aidl/android/hardware/tv/cec/CecLogicalAddress.aidl b/tv/cec/aidl/android/hardware/tv/cec/CecLogicalAddress.aidl
new file mode 100644
index 0000000..fbf5328
--- /dev/null
+++ b/tv/cec/aidl/android/hardware/tv/cec/CecLogicalAddress.aidl
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package android.hardware.tv.cec;
+
+@VintfStability
+@Backing(type="byte")
+enum CecLogicalAddress {
+ TV = 0,
+ RECORDER_1 = 1,
+ RECORDER_2 = 2,
+ TUNER_1 = 3,
+ PLAYBACK_1 = 4,
+ AUDIO_SYSTEM = 5,
+ TUNER_2 = 6,
+ TUNER_3 = 7,
+ PLAYBACK_2 = 8,
+ RECORDER_3 = 9,
+ TUNER_4 = 10,
+ PLAYBACK_3 = 11,
+ BACKUP_1 = 12,
+ BACKUP_2 = 13,
+ FREE_USE = 14,
+ BROADCAST = 15,
+ UNREGISTERED = 15,
+}
diff --git a/tv/cec/aidl/android/hardware/tv/cec/CecMessage.aidl b/tv/cec/aidl/android/hardware/tv/cec/CecMessage.aidl
new file mode 100644
index 0000000..b126045
--- /dev/null
+++ b/tv/cec/aidl/android/hardware/tv/cec/CecMessage.aidl
@@ -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.
+ */
+
+package android.hardware.tv.cec;
+
+import android.hardware.tv.cec.CecLogicalAddress;
+
+@VintfStability
+parcelable CecMessage {
+ /**
+ * Maximum length of the message body
+ */
+ const int MAX_MESSAGE_BODY_LENGTH = 15;
+ /**
+ * logical address of the initiator
+ */
+ CecLogicalAddress initiator;
+ /**
+ * logical address of destination
+ */
+ CecLogicalAddress destination;
+ /**
+ * The maximum size of body is 15 (MAX_MESSAGE_BODY_LENGTH) as specified in
+ * the section 6 of the CEC Spec 1.4b. Overflowed data must be ignored.
+ */
+ byte[] body;
+}
diff --git a/tv/cec/aidl/android/hardware/tv/cec/CecMessageType.aidl b/tv/cec/aidl/android/hardware/tv/cec/CecMessageType.aidl
new file mode 100644
index 0000000..b544a91
--- /dev/null
+++ b/tv/cec/aidl/android/hardware/tv/cec/CecMessageType.aidl
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+package android.hardware.tv.cec;
+
+@VintfStability
+@Backing(type="int")
+enum CecMessageType {
+ FEATURE_ABORT = 0x00,
+ IMAGE_VIEW_ON = 0x04,
+ TUNER_STEP_INCREMENT = 0x05,
+ TUNER_STEP_DECREMENT = 0x06,
+ TUNER_DEVICE_STATUS = 0x07,
+ GIVE_TUNER_DEVICE_STATUS = 0x08,
+ RECORD_ON = 0x09,
+ RECORD_STATUS = 0x0A,
+ RECORD_OFF = 0x0B,
+ TEXT_VIEW_ON = 0x0D,
+ RECORD_TV_SCREEN = 0x0F,
+ GIVE_DECK_STATUS = 0x1A,
+ DECK_STATUS = 0x1B,
+ SET_MENU_LANGUAGE = 0x32,
+ CLEAR_ANALOG_TIMER = 0x33,
+ SET_ANALOG_TIMER = 0x34,
+ TIMER_STATUS = 0x35,
+ STANDBY = 0x36,
+ PLAY = 0x41,
+ DECK_CONTROL = 0x42,
+ TIMER_CLEARED_STATUS = 0x43,
+ USER_CONTROL_PRESSED = 0x44,
+ USER_CONTROL_RELEASED = 0x45,
+ GIVE_OSD_NAME = 0x46,
+ SET_OSD_NAME = 0x47,
+ SET_OSD_STRING = 0x64,
+ SET_TIMER_PROGRAM_TITLE = 0x67,
+ SYSTEM_AUDIO_MODE_REQUEST = 0x70,
+ GIVE_AUDIO_STATUS = 0x71,
+ SET_SYSTEM_AUDIO_MODE = 0x72,
+ REPORT_AUDIO_STATUS = 0x7A,
+ GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D,
+ SYSTEM_AUDIO_MODE_STATUS = 0x7E,
+ ROUTING_CHANGE = 0x80,
+ ROUTING_INFORMATION = 0x81,
+ ACTIVE_SOURCE = 0x82,
+ GIVE_PHYSICAL_ADDRESS = 0x83,
+ REPORT_PHYSICAL_ADDRESS = 0x84,
+ REQUEST_ACTIVE_SOURCE = 0x85,
+ SET_STREAM_PATH = 0x86,
+ DEVICE_VENDOR_ID = 0x87,
+ VENDOR_COMMAND = 0x89,
+ VENDOR_REMOTE_BUTTON_DOWN = 0x8A,
+ VENDOR_REMOTE_BUTTON_UP = 0x8B,
+ GIVE_DEVICE_VENDOR_ID = 0x8C,
+ MENU_REQUEST = 0x8D,
+ MENU_STATUS = 0x8E,
+ GIVE_DEVICE_POWER_STATUS = 0x8F,
+ REPORT_POWER_STATUS = 0x90,
+ GET_MENU_LANGUAGE = 0x91,
+ SELECT_ANALOG_SERVICE = 0x92,
+ SELECT_DIGITAL_SERVICE = 0x93,
+ SET_DIGITAL_TIMER = 0x97,
+ CLEAR_DIGITAL_TIMER = 0x99,
+ SET_AUDIO_RATE = 0x9A,
+ INACTIVE_SOURCE = 0x9D,
+ CEC_VERSION = 0x9E,
+ GET_CEC_VERSION = 0x9F,
+ VENDOR_COMMAND_WITH_ID = 0xA0,
+ CLEAR_EXTERNAL_TIMER = 0xA1,
+ SET_EXTERNAL_TIMER = 0xA2,
+ REPORT_SHORT_AUDIO_DESCRIPTOR = 0xA3,
+ REQUEST_SHORT_AUDIO_DESCRIPTOR = 0xA4,
+ INITIATE_ARC = 0xC0,
+ REPORT_ARC_INITIATED = 0xC1,
+ REPORT_ARC_TERMINATED = 0xC2,
+ REQUEST_ARC_INITIATION = 0xC3,
+ REQUEST_ARC_TERMINATION = 0xC4,
+ TERMINATE_ARC = 0xC5,
+ ABORT = 0xFF,
+ GIVE_FEATURES = 0xA5,
+ REPORT_FEATURES = 0xA6,
+ REQUEST_CURRENT_LATENCY = 0xA7,
+ REPORT_CURRENT_LATENCY = 0xA8,
+}
diff --git a/tv/cec/aidl/android/hardware/tv/cec/IHdmiCec.aidl b/tv/cec/aidl/android/hardware/tv/cec/IHdmiCec.aidl
new file mode 100644
index 0000000..dbf7139
--- /dev/null
+++ b/tv/cec/aidl/android/hardware/tv/cec/IHdmiCec.aidl
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+package android.hardware.tv.cec;
+
+import android.hardware.tv.cec.CecLogicalAddress;
+import android.hardware.tv.cec.CecMessage;
+import android.hardware.tv.cec.IHdmiCecCallback;
+import android.hardware.tv.cec.Result;
+import android.hardware.tv.cec.SendMessageResult;
+
+/**
+ * HDMI-CEC HAL interface definition.
+ */
+@VintfStability
+interface IHdmiCec {
+ /**
+ * Passes the logical address that must be used in this system.
+ *
+ * HAL must use it to configure the hardware so that the CEC commands
+ * addressed the given logical address can be filtered in. This method must
+ * be able to be called as many times as necessary in order to support
+ * multiple logical devices.
+ *
+ * @param addr Logical address that must be used in this system. It must be
+ * in the range of valid logical addresses for the call to succeed.
+ * @return Result status of the operation. SUCCESS if successful,
+ * FAILURE_INVALID_ARGS if the given logical address is invalid,
+ * FAILURE_BUSY if device or resource is busy
+ */
+ Result addLogicalAddress(in CecLogicalAddress addr);
+
+ /**
+ * Clears all the logical addresses.
+ *
+ * It is used when the system doesn't need to process CEC command any more,
+ * hence to tell HAL to stop receiving commands from the CEC bus, and change
+ * the state back to the beginning.
+ */
+ void clearLogicalAddress();
+
+ /**
+ * Configures ARC circuit in the hardware logic to start or stop the
+ * feature.
+ *
+ * @param portId Port id to be configured.
+ * @param enable Flag must be either true to start the feature or false to
+ * stop it.
+ */
+ void enableAudioReturnChannel(in int portId, in boolean enable);
+
+ /**
+ * Returns the CEC version supported by underlying hardware.
+ *
+ * @return the CEC version supported by underlying hardware.
+ */
+ int getCecVersion();
+
+ /**
+ * Gets the CEC physical address.
+ *
+ * The physical address depends on the topology of the network formed by
+ * connected HDMI devices. It is therefore likely to change if the cable is
+ * plugged off and on again. It is advised to call getPhysicalAddress to get
+ * the updated address when hot plug event takes place.
+ *
+ * @param out addr Physical address of this device.
+ */
+ int getPhysicalAddress();
+
+ /**
+ * Gets the identifier of the vendor.
+ *
+ * @return Identifier of the vendor that is the 24-bit unique
+ * company ID obtained from the IEEE Registration Authority
+ * Committee (RAC). The upper 8 bits must be 0.
+ */
+ int getVendorId();
+
+ /**
+ * Transmits HDMI-CEC message to other HDMI device.
+ *
+ * The method must be designed to return in a certain amount of time and not
+ * hanging forever which may happen if CEC signal line is pulled low for
+ * some reason.
+ *
+ * It must try retransmission at least once as specified in the section '7.1
+ * Frame Re-transmissions' of the CEC Spec 1.4b.
+ *
+ * @param message CEC message to be sent to other HDMI device.
+ * @return Result status of the operation. SUCCESS if successful,
+ * NACK if the sent message is not acknowledged,
+ * BUSY if the CEC bus is busy,
+ * FAIL if the message could not be sent.
+ */
+ SendMessageResult sendMessage(in CecMessage message);
+
+ /**
+ * Sets a callback that HDMI-CEC HAL must later use for incoming CEC
+ * messages.
+ *
+ * @param callback Callback object to pass hdmi events to the system. The
+ * previously registered callback must be replaced with this one.
+ * setCallback(null) should deregister the callback.
+ */
+ void setCallback(in IHdmiCecCallback callback);
+
+ /**
+ * Passes the updated language information of Android system. Contains
+ * three-letter code as defined in ISO/FDIS 639-2. Must be used for HAL to
+ * respond to <Get Menu Language> while in standby mode.
+ *
+ * @param language Three-letter code defined in ISO/FDIS 639-2. Must be
+ * lowercase letters. (e.g., eng for English)
+ */
+ void setLanguage(in String language);
+
+ /**
+ * Determines whether a TV panel device in standby mode should wake up when
+ * it receives an OTP (One Touch Play) from a source device.
+ *
+ * @param value If true, the TV device will wake up when OTP is received
+ * and if false, the TV device will not wake up for an OTP.
+ */
+ void enableWakeupByOtp(in boolean value);
+
+ /**
+ * Switch to enable or disable CEC on the device.
+ *
+ * @param value If true, the device will have all CEC functionalities
+ * and if false, the device will not perform any CEC functions.
+ */
+ void enableCec(in boolean value);
+
+ /**
+ * Determines which module processes CEC messages - the Android framework or
+ * the HAL.
+ *
+ * @param value If true, the Android framework will actively process CEC
+ * messages and if false, only the HAL will process the CEC messages.
+ */
+ void enableSystemCecControl(in boolean value);
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/tv/cec/aidl/android/hardware/tv/cec/IHdmiCecCallback.aidl
similarity index 60%
copy from audio/aidl/default/include/visualizer-impl/Visualizer.h
copy to tv/cec/aidl/android/hardware/tv/cec/IHdmiCecCallback.aidl
index 4b82dd0..4934a64 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/tv/cec/aidl/android/hardware/tv/cec/IHdmiCecCallback.aidl
@@ -14,18 +14,18 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.tv.cec;
-#include <cstdlib>
+import android.hardware.tv.cec.CecMessage;
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+/**
+ * Callbacks from the HAL implementation to notify the system of new events.
+ */
+@VintfStability
+oneway interface IHdmiCecCallback {
+ /**
+ * The callback function that must be called by HAL implementation to notify
+ * the system of new CEC message arrival.
+ */
+ void onCecMessage(in CecMessage message);
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/tv/cec/aidl/android/hardware/tv/cec/Result.aidl
similarity index 60%
copy from audio/aidl/default/include/visualizer-impl/Visualizer.h
copy to tv/cec/aidl/android/hardware/tv/cec/Result.aidl
index 4b82dd0..3184c46 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/tv/cec/aidl/android/hardware/tv/cec/Result.aidl
@@ -14,18 +14,15 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.tv.cec;
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+@VintfStability
+@Backing(type="byte")
+enum Result {
+ SUCCESS = 0,
+ FAILURE_UNKNOWN = 1,
+ FAILURE_INVALID_ARGS = 2,
+ FAILURE_INVALID_STATE = 3,
+ FAILURE_NOT_SUPPORTED = 4,
+ FAILURE_BUSY = 5,
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/tv/cec/aidl/android/hardware/tv/cec/SendMessageResult.aidl
similarity index 60%
copy from audio/aidl/default/include/visualizer-impl/Visualizer.h
copy to tv/cec/aidl/android/hardware/tv/cec/SendMessageResult.aidl
index 4b82dd0..8cb98bc 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/tv/cec/aidl/android/hardware/tv/cec/SendMessageResult.aidl
@@ -14,18 +14,16 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.tv.cec;
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+/**
+ * error code used for send_message.
+ */
+@VintfStability
+@Backing(type="byte")
+enum SendMessageResult {
+ SUCCESS = 0,
+ NACK = 1,
+ BUSY = 2,
+ FAIL = 3,
+}
diff --git a/tv/cec/aidl/default/Android.bp b/tv/cec/aidl/default/Android.bp
new file mode 100644
index 0000000..5479601
--- /dev/null
+++ b/tv/cec/aidl/default/Android.bp
@@ -0,0 +1,58 @@
+// 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.
+
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_binary {
+ name: "android.hardware.tv.cec-service",
+ vintf_fragments: ["android.hardware.tv.cec-service.xml"],
+ relative_install_path: "hw",
+ vendor: true,
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ ],
+ init_rc: ["android.hardware.tv.cec-service.rc"],
+ srcs: [
+ "serviceMock.cpp",
+ "HdmiCecMock.cpp",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ "liblog",
+ "libbase",
+ "libutils",
+ "libhardware",
+ "libhidlbase",
+ "android.hardware.tv.cec-V1-ndk",
+ ],
+}
+
+cc_fuzz {
+ name: "android.hardware.tv.cec-service_fuzzer",
+ defaults: ["service_fuzzer_defaults"],
+ static_libs: [
+ "android.hardware.tv.cec-V1-ndk",
+ "liblog",
+ ],
+ srcs: [
+ "fuzzer.cpp",
+ "HdmiCecMock.cpp",
+ ],
+ fuzz_config: {
+ componentid: 826094,
+ },
+}
diff --git a/tv/cec/aidl/default/HdmiCecMock.cpp b/tv/cec/aidl/default/HdmiCecMock.cpp
new file mode 100644
index 0000000..d8d655b
--- /dev/null
+++ b/tv/cec/aidl/default/HdmiCecMock.cpp
@@ -0,0 +1,266 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "android.hardware.tv.cec"
+#include <android-base/logging.h>
+#include <fcntl.h>
+#include <utils/Log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/hdmi_cec.h>
+#include "HdmiCecMock.h"
+
+using ndk::ScopedAStatus;
+
+namespace android {
+namespace hardware {
+namespace tv {
+namespace cec {
+namespace implementation {
+
+void HdmiCecMock::serviceDied(void* cookie) {
+ ALOGE("HdmiCecMock died");
+ auto hdmiCecMock = static_cast<HdmiCecMock*>(cookie);
+ hdmiCecMock->mCecThreadRun = false;
+}
+
+ScopedAStatus HdmiCecMock::addLogicalAddress(CecLogicalAddress addr, Result* _aidl_return) {
+ // Have a list to maintain logical addresses
+ mLogicalAddresses.push_back(addr);
+ *_aidl_return = Result::SUCCESS;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::clearLogicalAddress() {
+ // Remove logical address from the list
+ mLogicalAddresses = {};
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::enableAudioReturnChannel(int32_t portId __unused, bool enable __unused) {
+ // Maintain ARC status
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::getCecVersion(int32_t* _aidl_return) {
+ // Maintain a cec version and return it
+ *_aidl_return = mCecVersion;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::getPhysicalAddress(int32_t* _aidl_return) {
+ // Maintain a physical address and return it
+ // Default 0xFFFF, update on hotplug event
+ *_aidl_return = mPhysicalAddress;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::getVendorId(int32_t* _aidl_return) {
+ *_aidl_return = mCecVendorId;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::sendMessage(const CecMessage& message, SendMessageResult* _aidl_return) {
+ if (message.body.size() == 0) {
+ *_aidl_return = SendMessageResult::NACK;
+ } else {
+ sendMessageToFifo(message);
+ *_aidl_return = SendMessageResult::SUCCESS;
+ }
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::setCallback(const std::shared_ptr<IHdmiCecCallback>& callback) {
+ // If callback is null, mCallback is also set to null so we do not call the old callback.
+ mCallback = callback;
+
+ if (callback != nullptr) {
+ AIBinder_linkToDeath(this->asBinder().get(), mDeathRecipient.get(), 0 /* cookie */);
+
+ mInputFile = open(CEC_MSG_IN_FIFO, O_RDWR | O_CLOEXEC);
+ mOutputFile = open(CEC_MSG_OUT_FIFO, O_RDWR | O_CLOEXEC);
+ pthread_create(&mThreadId, NULL, __threadLoop, this);
+ pthread_setname_np(mThreadId, "hdmi_cec_loop");
+ }
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::setLanguage(const std::string& language) {
+ if (language.size() != 3) {
+ LOG(ERROR) << "Wrong language code: expected 3 letters, but it was " << language.size()
+ << ".";
+ return ScopedAStatus::ok();
+ }
+ // TODO Validate if language is a valid language code
+ const char* languageStr = language.c_str();
+ int convertedLanguage = ((languageStr[0] & 0xFF) << 16) | ((languageStr[1] & 0xFF) << 8) |
+ (languageStr[2] & 0xFF);
+ mOptionLanguage = convertedLanguage;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::enableWakeupByOtp(bool value) {
+ mOptionWakeUp = value;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::enableCec(bool value) {
+ mOptionEnableCec = value;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiCecMock::enableSystemCecControl(bool value) {
+ mOptionSystemCecControl = value;
+ return ScopedAStatus::ok();
+}
+
+void* HdmiCecMock::__threadLoop(void* user) {
+ HdmiCecMock* const self = static_cast<HdmiCecMock*>(user);
+ self->threadLoop();
+ return 0;
+}
+
+int HdmiCecMock::readMessageFromFifo(unsigned char* buf, int msgCount) {
+ if (msgCount <= 0 || !buf) {
+ return 0;
+ }
+
+ int ret = -1;
+ // Maybe blocked at driver
+ ret = read(mInputFile, buf, msgCount);
+ if (ret < 0) {
+ ALOGE("[halimp_aidl] read :%s failed, ret:%d\n", CEC_MSG_IN_FIFO, ret);
+ return -1;
+ }
+
+ return ret;
+}
+
+int HdmiCecMock::sendMessageToFifo(const CecMessage& message) {
+ unsigned char msgBuf[CEC_MESSAGE_BODY_MAX_LENGTH + 1] = {0};
+ int ret = -1;
+
+ msgBuf[0] = ((static_cast<uint8_t>(message.initiator) & 0xf) << 4) |
+ (static_cast<uint8_t>(message.destination) & 0xf);
+
+ size_t length = std::min(static_cast<size_t>(message.body.size()),
+ static_cast<size_t>(CEC_MESSAGE_BODY_MAX_LENGTH));
+ for (size_t i = 0; i < length; ++i) {
+ msgBuf[i + 1] = static_cast<unsigned char>(message.body[i]);
+ }
+
+ // Open the output pipe for writing outgoing cec message
+ mOutputFile = open(CEC_MSG_OUT_FIFO, O_WRONLY | O_CLOEXEC);
+ if (mOutputFile < 0) {
+ ALOGD("[halimp_aidl] file open failed for writing");
+ return -1;
+ }
+
+ // Write message into the output pipe
+ ret = write(mOutputFile, msgBuf, length + 1);
+ close(mOutputFile);
+ if (ret < 0) {
+ ALOGE("[halimp_aidl] write :%s failed, ret:%d\n", CEC_MSG_OUT_FIFO, ret);
+ return -1;
+ }
+ return ret;
+}
+
+void HdmiCecMock::printCecMsgBuf(const char* msg_buf, int len) {
+ int i, size = 0;
+ const int bufSize = CEC_MESSAGE_BODY_MAX_LENGTH * 3;
+ // Use 2 characters for each byte in the message plus 1 space
+ char buf[bufSize] = {0};
+
+ // Messages longer than max length will be truncated.
+ for (i = 0; i < len && size < bufSize; i++) {
+ size += sprintf(buf + size, " %02x", msg_buf[i]);
+ }
+ ALOGD("[halimp_aidl] %s, msg:%.*s", __FUNCTION__, size, buf);
+}
+
+void HdmiCecMock::handleCecMessage(unsigned char* msgBuf, int msgSize) {
+ CecMessage message;
+ size_t length = std::min(static_cast<size_t>(msgSize - 1),
+ static_cast<size_t>(CEC_MESSAGE_BODY_MAX_LENGTH));
+ message.body.resize(length);
+
+ for (size_t i = 0; i < length; ++i) {
+ message.body[i] = static_cast<uint8_t>(msgBuf[i + 1]);
+ ALOGD("[halimp_aidl] msg body %x", message.body[i]);
+ }
+
+ message.initiator = static_cast<CecLogicalAddress>((msgBuf[0] >> 4) & 0xf);
+ ALOGD("[halimp_aidl] msg init %hhd", message.initiator);
+ message.destination = static_cast<CecLogicalAddress>((msgBuf[0] >> 0) & 0xf);
+ ALOGD("[halimp_aidl] msg dest %hhd", message.destination);
+
+ if (mCallback != nullptr) {
+ mCallback->onCecMessage(message);
+ }
+}
+
+void HdmiCecMock::threadLoop() {
+ ALOGD("[halimp_aidl] threadLoop start.");
+ unsigned char msgBuf[CEC_MESSAGE_BODY_MAX_LENGTH];
+ int r = -1;
+
+ // Open the input pipe
+ while (mInputFile < 0) {
+ usleep(1000 * 1000);
+ mInputFile = open(CEC_MSG_IN_FIFO, O_RDONLY | O_CLOEXEC);
+ }
+ ALOGD("[halimp_aidl] file open ok, fd = %d.", mInputFile);
+
+ while (mCecThreadRun) {
+ if (!mOptionSystemCecControl) {
+ usleep(1000 * 1000);
+ continue;
+ }
+
+ memset(msgBuf, 0, sizeof(msgBuf));
+ // Try to get a message from dev.
+ // echo -n -e '\x04\x83' >> /dev/cec
+ r = readMessageFromFifo(msgBuf, CEC_MESSAGE_BODY_MAX_LENGTH);
+ if (r <= 1) {
+ // Ignore received ping messages
+ continue;
+ }
+
+ printCecMsgBuf((const char*)msgBuf, r);
+
+ if (((msgBuf[0] >> 4) & 0xf) == 0xf) {
+ // The message is a hotplug event, handled by HDMI HAL.
+ continue;
+ }
+
+ handleCecMessage(msgBuf, r);
+ }
+
+ ALOGD("[halimp_aidl] thread end.");
+}
+
+HdmiCecMock::HdmiCecMock() {
+ ALOGE("[halimp_aidl] Opening a virtual CEC HAL for testing and virtual machine.");
+ mCallback = nullptr;
+ mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied));
+}
+
+} // namespace implementation
+} // namespace cec
+} // namespace tv
+} // namespace hardware
+} // namespace android
diff --git a/tv/cec/aidl/default/HdmiCecMock.h b/tv/cec/aidl/default/HdmiCecMock.h
new file mode 100644
index 0000000..08f4d6f
--- /dev/null
+++ b/tv/cec/aidl/default/HdmiCecMock.h
@@ -0,0 +1,94 @@
+/*
+ * 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 <aidl/android/hardware/tv/cec/BnHdmiCec.h>
+#include <algorithm>
+#include <vector>
+
+using namespace std;
+
+namespace android {
+namespace hardware {
+namespace tv {
+namespace cec {
+namespace implementation {
+
+using ::aidl::android::hardware::tv::cec::BnHdmiCec;
+using ::aidl::android::hardware::tv::cec::CecLogicalAddress;
+using ::aidl::android::hardware::tv::cec::CecMessage;
+using ::aidl::android::hardware::tv::cec::IHdmiCec;
+using ::aidl::android::hardware::tv::cec::IHdmiCecCallback;
+using ::aidl::android::hardware::tv::cec::Result;
+using ::aidl::android::hardware::tv::cec::SendMessageResult;
+
+#define CEC_MSG_IN_FIFO "/dev/cec_aidl_in_pipe"
+#define CEC_MSG_OUT_FIFO "/dev/cec_aidl_out_pipe"
+
+struct HdmiCecMock : public BnHdmiCec {
+ HdmiCecMock();
+ ::ndk::ScopedAStatus addLogicalAddress(CecLogicalAddress addr, Result* _aidl_return) override;
+ ::ndk::ScopedAStatus clearLogicalAddress() override;
+ ::ndk::ScopedAStatus enableAudioReturnChannel(int32_t portId, bool enable) override;
+ ::ndk::ScopedAStatus getCecVersion(int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getPhysicalAddress(int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getVendorId(int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus sendMessage(const CecMessage& message,
+ SendMessageResult* _aidl_return) override;
+ ::ndk::ScopedAStatus setCallback(const std::shared_ptr<IHdmiCecCallback>& callback) override;
+ ::ndk::ScopedAStatus setLanguage(const std::string& language) override;
+ ::ndk::ScopedAStatus enableWakeupByOtp(bool value) override;
+ ::ndk::ScopedAStatus enableCec(bool value) override;
+ ::ndk::ScopedAStatus enableSystemCecControl(bool value) override;
+ void printCecMsgBuf(const char* msg_buf, int len);
+
+ private:
+ static void* __threadLoop(void* data);
+ void threadLoop();
+ int readMessageFromFifo(unsigned char* buf, int msgCount);
+ int sendMessageToFifo(const CecMessage& message);
+ void handleCecMessage(unsigned char* msgBuf, int length);
+
+ private:
+ static void serviceDied(void* cookie);
+ std::shared_ptr<IHdmiCecCallback> mCallback;
+
+ // Variables for the virtual cec hal impl
+ uint16_t mPhysicalAddress = 0xFFFF;
+ vector<CecLogicalAddress> mLogicalAddresses;
+ int32_t mCecVersion = 0x06;
+ uint32_t mCecVendorId = 0x01;
+
+ // CEC Option value
+ bool mOptionWakeUp = 0;
+ bool mOptionEnableCec = 0;
+ bool mOptionSystemCecControl = 0;
+ int mOptionLanguage;
+
+ // Testing variables
+ // Input file descriptor
+ int mInputFile;
+ // Output file descriptor
+ int mOutputFile;
+ bool mCecThreadRun = true;
+ pthread_t mThreadId = 0;
+
+ ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
+};
+} // namespace implementation
+} // namespace cec
+} // namespace tv
+} // namespace hardware
+} // namespace android
diff --git a/tv/cec/aidl/default/android.hardware.tv.cec-service.rc b/tv/cec/aidl/default/android.hardware.tv.cec-service.rc
new file mode 100644
index 0000000..c79520c
--- /dev/null
+++ b/tv/cec/aidl/default/android.hardware.tv.cec-service.rc
@@ -0,0 +1,5 @@
+service vendor.cec-default /vendor/bin/hw/android.hardware.tv.cec-service
+ interface aidl android.hardware.tv.cec.IHdmiCec/default
+ class hal
+ user system
+ group system
diff --git a/tv/cec/aidl/default/android.hardware.tv.cec-service.xml b/tv/cec/aidl/default/android.hardware.tv.cec-service.xml
new file mode 100644
index 0000000..e68450d
--- /dev/null
+++ b/tv/cec/aidl/default/android.hardware.tv.cec-service.xml
@@ -0,0 +1,10 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.tv.cec</name>
+ <version>1</version>
+ <interface>
+ <name>IHdmiCec</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/tv/cec/aidl/default/fuzzer.cpp b/tv/cec/aidl/default/fuzzer.cpp
new file mode 100644
index 0000000..9f6a9ac
--- /dev/null
+++ b/tv/cec/aidl/default/fuzzer.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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 <HdmiCecMock.h>
+#include <fuzzbinder/libbinder_ndk_driver.h>
+#include <fuzzer/FuzzedDataProvider.h>
+
+using android::fuzzService;
+using android::hardware::tv::cec::implementation::HdmiCecMock;
+using ndk::SharedRefBase;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ auto hdmiCecAidl = SharedRefBase::make<HdmiCecMock>();
+
+ fuzzService(hdmiCecAidl->asBinder().get(), FuzzedDataProvider(data, size));
+
+ return 0;
+}
diff --git a/tv/cec/aidl/default/serviceMock.cpp b/tv/cec/aidl/default/serviceMock.cpp
new file mode 100644
index 0000000..ab86c3f
--- /dev/null
+++ b/tv/cec/aidl/default/serviceMock.cpp
@@ -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.
+ */
+
+#define LOG_TAG "android.hardware.tv.cec-service-shim"
+
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <hidl/HidlTransportSupport.h>
+#include <utils/Log.h>
+#include "HdmiCecMock.h"
+
+using android::hardware::tv::cec::implementation::HdmiCecMock;
+
+int main() {
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+
+ std::shared_ptr<HdmiCecMock> hdmiCecAidl = ndk::SharedRefBase::make<HdmiCecMock>();
+ const std::string instance = std::string() + HdmiCecMock::descriptor + "/default";
+ binder_status_t status =
+ AServiceManager_addService(hdmiCecAidl->asBinder().get(), instance.c_str());
+ CHECK_EQ(status, STATUS_OK);
+
+ ABinderProcess_joinThreadPool();
+ return 0;
+}
diff --git a/tv/cec/aidl/vts/functional/Android.bp b/tv/cec/aidl/vts/functional/Android.bp
new file mode 100644
index 0000000..37fbaf0
--- /dev/null
+++ b/tv/cec/aidl/vts/functional/Android.bp
@@ -0,0 +1,38 @@
+// 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.
+
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_test {
+ name: "VtsHalTvCecAidlTargetTest",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: ["VtsHalTvCecAidlTargetTest.cpp"],
+ static_libs: [
+ "android.hardware.tv.cec-V1-ndk",
+ "android.hardware.tv.hdmi-V1-ndk",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+ disable_framework: true,
+}
diff --git a/tv/cec/aidl/vts/functional/VtsHalTvCecAidlTargetTest.cpp b/tv/cec/aidl/vts/functional/VtsHalTvCecAidlTargetTest.cpp
new file mode 100644
index 0000000..69c209f
--- /dev/null
+++ b/tv/cec/aidl/vts/functional/VtsHalTvCecAidlTargetTest.cpp
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "HdmiCec_hal_test"
+
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/tv/cec/BnHdmiCec.h>
+#include <aidl/android/hardware/tv/cec/BnHdmiCecCallback.h>
+#include <aidl/android/hardware/tv/cec/CecDeviceType.h>
+#include <aidl/android/hardware/tv/hdmi/BnHdmi.h>
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <gtest/gtest.h>
+#include <log/log.h>
+#include <sstream>
+#include <vector>
+
+using ::aidl::android::hardware::tv::cec::BnHdmiCecCallback;
+using ::aidl::android::hardware::tv::cec::CecDeviceType;
+using ::aidl::android::hardware::tv::cec::CecLogicalAddress;
+using ::aidl::android::hardware::tv::cec::CecMessage;
+using ::aidl::android::hardware::tv::cec::IHdmiCec;
+using ::aidl::android::hardware::tv::cec::IHdmiCecCallback;
+using ::aidl::android::hardware::tv::cec::Result;
+using ::aidl::android::hardware::tv::cec::SendMessageResult;
+using ::aidl::android::hardware::tv::hdmi::HdmiPortInfo;
+using ::ndk::SpAIBinder;
+
+#define CEC_VERSION 0x05
+#define INCORRECT_VENDOR_ID 0x00
+#define TV_PHYSICAL_ADDRESS 0x0000
+
+// The main test class for TV CEC HAL.
+class HdmiCecTest : public ::testing::TestWithParam<std::string> {
+ static void serviceDied(void* /* cookie */) { ALOGE("VtsHalTvCecAidlTargetTest died"); }
+
+ public:
+ void SetUp() override {
+ hdmiCec = IHdmiCec::fromBinder(
+ SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
+ ASSERT_NE(hdmiCec, nullptr);
+ ALOGI("%s: getService() for hdmiCec is %s", __func__,
+ hdmiCec->isRemote() ? "remote" : "local");
+
+ hdmiCecCallback = ::ndk::SharedRefBase::make<CecCallback>();
+ ASSERT_NE(hdmiCecCallback, nullptr);
+ hdmiCecDeathRecipient =
+ ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(&serviceDied));
+ ASSERT_EQ(AIBinder_linkToDeath(hdmiCec->asBinder().get(), hdmiCecDeathRecipient.get(), 0),
+ STATUS_OK);
+ }
+
+ std::vector<int> getDeviceTypes() {
+ std::vector<int> deviceTypes;
+ FILE* p = popen("getprop ro.hdmi.device_type", "re");
+ if (p) {
+ char* line = NULL;
+ size_t len = 0;
+ if (getline(&line, &len, p) > 0) {
+ std::istringstream stream(line);
+ std::string number{};
+ while (std::getline(stream, number, ',')) {
+ deviceTypes.push_back(stoi(number));
+ }
+ }
+ pclose(p);
+ }
+ return deviceTypes;
+ }
+
+ bool hasDeviceType(CecDeviceType type) {
+ std::vector<int> deviceTypes = getDeviceTypes();
+ return std::find(deviceTypes.begin(), deviceTypes.end(), (int)type) != deviceTypes.end();
+ }
+
+ class CecCallback : public BnHdmiCecCallback {
+ public:
+ ::ndk::ScopedAStatus onCecMessage(const CecMessage& message __unused) {
+ return ::ndk::ScopedAStatus::ok();
+ };
+ };
+
+ std::shared_ptr<IHdmiCec> hdmiCec;
+ std::shared_ptr<IHdmiCecCallback> hdmiCecCallback;
+ ::ndk::ScopedAIBinder_DeathRecipient hdmiCecDeathRecipient;
+};
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HdmiCecTest);
+INSTANTIATE_TEST_SUITE_P(PerInstance, HdmiCecTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(IHdmiCec::descriptor)),
+ android::PrintInstanceNameToString);
+
+TEST_P(HdmiCecTest, ClearAddLogicalAddress) {
+ Result addLaResult;
+ ASSERT_TRUE(hdmiCec->clearLogicalAddress().isOk());
+ ASSERT_TRUE(hdmiCec->addLogicalAddress(CecLogicalAddress::PLAYBACK_3, &addLaResult).isOk());
+ EXPECT_EQ(addLaResult, Result::SUCCESS);
+}
+
+TEST_P(HdmiCecTest, PhysicalAddress) {
+ int32_t addr;
+ ASSERT_TRUE(hdmiCec->getPhysicalAddress(&addr).isOk());
+ if (!hasDeviceType(CecDeviceType::TV)) {
+ EXPECT_NE(addr, TV_PHYSICAL_ADDRESS);
+ }
+}
+
+TEST_P(HdmiCecTest, SendMessage) {
+ CecMessage message;
+ message.initiator = CecLogicalAddress::PLAYBACK_1;
+ message.destination = CecLogicalAddress::BROADCAST;
+ message.body.resize(1);
+ message.body[0] = 131;
+ SendMessageResult result;
+ ASSERT_TRUE(hdmiCec->sendMessage(message, &result).isOk());
+ EXPECT_EQ(result, SendMessageResult::SUCCESS);
+}
+
+TEST_P(HdmiCecTest, CecVersion) {
+ int32_t version;
+ ASSERT_TRUE(hdmiCec->getCecVersion(&version).isOk());
+ EXPECT_GE(version, CEC_VERSION);
+}
+
+TEST_P(HdmiCecTest, SetCallback) {
+ ASSERT_TRUE(hdmiCec->setCallback(::ndk::SharedRefBase::make<CecCallback>()).isOk());
+}
+
+TEST_P(HdmiCecTest, VendorId) {
+ int32_t vendorId;
+ ASSERT_TRUE(hdmiCec->getVendorId(&vendorId).isOk());
+ EXPECT_NE(vendorId, INCORRECT_VENDOR_ID);
+}
+
+TEST_P(HdmiCecTest, EnableWakeupByOtp) {
+ ASSERT_TRUE(hdmiCec->enableWakeupByOtp(false).isOk());
+ // Restore option to its default value
+ ASSERT_TRUE(hdmiCec->enableWakeupByOtp(true).isOk());
+}
+
+TEST_P(HdmiCecTest, EnableCec) {
+ ASSERT_TRUE(hdmiCec->enableCec(false).isOk());
+ // Restore option to its default value
+ ASSERT_TRUE(hdmiCec->enableCec(true).isOk());
+}
+
+TEST_P(HdmiCecTest, EnableSystemCecControl) {
+ ASSERT_TRUE(hdmiCec->enableSystemCecControl(true).isOk());
+ // Restore option to its default value
+ ASSERT_TRUE(hdmiCec->enableSystemCecControl(false).isOk());
+}
+
+TEST_P(HdmiCecTest, SetLanguage) {
+ ASSERT_TRUE(hdmiCec->setLanguage("eng").isOk());
+}
diff --git a/tv/hdmi/aidl/Android.bp b/tv/hdmi/aidl/Android.bp
new file mode 100644
index 0000000..d8c6e5f
--- /dev/null
+++ b/tv/hdmi/aidl/Android.bp
@@ -0,0 +1,29 @@
+// 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.
+
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+aidl_interface {
+ name: "android.hardware.tv.hdmi",
+ vendor_available: true,
+ srcs: ["android/hardware/tv/hdmi/*.aidl"],
+ stability: "vintf",
+ backend: {
+ java: {
+ sdk_version: "module_current",
+ },
+ },
+}
diff --git a/tv/hdmi/aidl/OWNERS b/tv/hdmi/aidl/OWNERS
new file mode 100644
index 0000000..d9c6783
--- /dev/null
+++ b/tv/hdmi/aidl/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 826094
+include platform/frameworks/base:/core/java/android/hardware/hdmi/OWNERS
\ No newline at end of file
diff --git a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HdmiPortInfo.aidl b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HdmiPortInfo.aidl
new file mode 100644
index 0000000..a5e3a2a
--- /dev/null
+++ b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HdmiPortInfo.aidl
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.hdmi;
+@VintfStability
+parcelable HdmiPortInfo {
+ android.hardware.tv.hdmi.HdmiPortType type;
+ int portId;
+ boolean cecSupported;
+ boolean arcSupported;
+ int physicalAddress;
+}
diff --git a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HdmiPortType.aidl b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HdmiPortType.aidl
new file mode 100644
index 0000000..af5f0f7
--- /dev/null
+++ b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HdmiPortType.aidl
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.hdmi;
+@Backing(type="byte") @VintfStability
+enum HdmiPortType {
+ INPUT = 0,
+ OUTPUT = 1,
+}
diff --git a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmi.aidl b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmi.aidl
new file mode 100644
index 0000000..3fc7f41
--- /dev/null
+++ b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmi.aidl
@@ -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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.hdmi;
+@VintfStability
+interface IHdmi {
+ android.hardware.tv.hdmi.HdmiPortInfo[] getPortInfo();
+ boolean isConnected(in int portId);
+ void setCallback(in android.hardware.tv.hdmi.IHdmiCallback callback);
+}
diff --git a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmiCallback.aidl b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmiCallback.aidl
new file mode 100644
index 0000000..05fe623
--- /dev/null
+++ b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmiCallback.aidl
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// 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 <name>-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.hdmi;
+@VintfStability
+interface IHdmiCallback {
+ oneway void onHotplugEvent(in boolean connected, in int portId);
+}
diff --git a/tv/hdmi/aidl/android/hardware/tv/hdmi/HdmiPortInfo.aidl b/tv/hdmi/aidl/android/hardware/tv/hdmi/HdmiPortInfo.aidl
new file mode 100644
index 0000000..1d6f27d
--- /dev/null
+++ b/tv/hdmi/aidl/android/hardware/tv/hdmi/HdmiPortInfo.aidl
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package android.hardware.tv.hdmi;
+
+import android.hardware.tv.hdmi.HdmiPortType;
+
+/**
+ * HDMI port descriptor
+ */
+@VintfStability
+parcelable HdmiPortInfo {
+ HdmiPortType type;
+ int portId; // Should start from 1 which corresponds to HDMI "port 1".
+ boolean cecSupported;
+ boolean arcSupported;
+ // The physical address of the device connected to this port, valid range is 0x0000 to 0xFFFF
+ // (ref Sec 8.7.2 of HDMI 1.4b).
+ int physicalAddress;
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/tv/hdmi/aidl/android/hardware/tv/hdmi/HdmiPortType.aidl
similarity index 60%
copy from audio/aidl/default/include/visualizer-impl/Visualizer.h
copy to tv/hdmi/aidl/android/hardware/tv/hdmi/HdmiPortType.aidl
index 4b82dd0..59c0d42 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/tv/hdmi/aidl/android/hardware/tv/hdmi/HdmiPortType.aidl
@@ -14,18 +14,14 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.tv.hdmi;
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+/**
+ * HDMI port type.
+ */
+@VintfStability
+@Backing(type="byte")
+enum HdmiPortType {
+ INPUT = 0,
+ OUTPUT = 1,
+}
diff --git a/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmi.aidl b/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmi.aidl
new file mode 100644
index 0000000..5536846
--- /dev/null
+++ b/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmi.aidl
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+package android.hardware.tv.hdmi;
+
+import android.hardware.tv.hdmi.HdmiPortInfo;
+import android.hardware.tv.hdmi.IHdmiCallback;
+
+/**
+ * HDMI HAL interface definition.
+ */
+@VintfStability
+interface IHdmi {
+ /**
+ * Gets the hdmi port information of underlying hardware.
+ *
+ * @return The list of HDMI port information
+ */
+ HdmiPortInfo[] getPortInfo();
+
+ /**
+ * Gets the connection status of the specified port.
+ *
+ * @param portId Port id to be inspected for the connection status.
+ * @return True if a device is connected, otherwise false. The HAL
+ * must watch for +5V power signal to determine the status.
+ */
+ boolean isConnected(in int portId);
+
+ /**
+ * Sets a callback that HDMI HAL must later use for internal HDMI events
+ *
+ * @param callback Callback object to pass hdmi events to the system. The
+ * previously registered callback must be replaced with this one.
+ * setCallback(null) should deregister the callback.
+ */
+ void setCallback(in IHdmiCallback callback);
+}
diff --git a/audio/aidl/default/include/visualizer-impl/Visualizer.h b/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmiCallback.aidl
similarity index 60%
copy from audio/aidl/default/include/visualizer-impl/Visualizer.h
copy to tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmiCallback.aidl
index 4b82dd0..51275b0 100644
--- a/audio/aidl/default/include/visualizer-impl/Visualizer.h
+++ b/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmiCallback.aidl
@@ -14,18 +14,16 @@
* limitations under the License.
*/
-#pragma once
+package android.hardware.tv.hdmi;
-#include <cstdlib>
-
-namespace aidl::android::hardware::audio::effect {
-
-// Visualizer implementation UUID.
-static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
- static_cast<int32_t>(0x1d4033c0),
- 0x8557,
- 0x11df,
- 0x9f2d,
- {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-
-} // namespace aidl::android::hardware::audio::effect
\ No newline at end of file
+/**
+ * Callbacks from the HDMI HAL implementation to notify the system of new events.
+ */
+@VintfStability
+oneway interface IHdmiCallback {
+ /**
+ * The callback function that must be called by HAL implementation to notify
+ * the system of new hotplug event.
+ */
+ void onHotplugEvent(in boolean connected, in int portId);
+}
diff --git a/tv/hdmi/aidl/default/Android.bp b/tv/hdmi/aidl/default/Android.bp
new file mode 100644
index 0000000..3e466a0
--- /dev/null
+++ b/tv/hdmi/aidl/default/Android.bp
@@ -0,0 +1,58 @@
+// 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.
+
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_binary {
+ name: "android.hardware.tv.hdmi-service",
+ vintf_fragments: ["android.hardware.tv.hdmi-service.xml"],
+ relative_install_path: "hw",
+ vendor: true,
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ ],
+ init_rc: ["android.hardware.tv.hdmi-service.rc"],
+ srcs: [
+ "serviceMock.cpp",
+ "HdmiMock.cpp",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ "liblog",
+ "libbase",
+ "libutils",
+ "libhardware",
+ "libhidlbase",
+ "android.hardware.tv.hdmi-V1-ndk",
+ ],
+}
+
+cc_fuzz {
+ name: "android.hardware.tv.hdmi-service_fuzzer",
+ defaults: ["service_fuzzer_defaults"],
+ static_libs: [
+ "android.hardware.tv.hdmi-V1-ndk",
+ "liblog",
+ ],
+ srcs: [
+ "fuzzer.cpp",
+ "HdmiMock.cpp",
+ ],
+ fuzz_config: {
+ componentid: 826094,
+ },
+}
diff --git a/tv/hdmi/aidl/default/HdmiMock.cpp b/tv/hdmi/aidl/default/HdmiMock.cpp
new file mode 100644
index 0000000..0cf5118
--- /dev/null
+++ b/tv/hdmi/aidl/default/HdmiMock.cpp
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "android.hardware.tv.hdmi"
+#include <android-base/logging.h>
+#include <fcntl.h>
+#include <utils/Log.h>
+
+#include "HdmiMock.h"
+
+using ndk::ScopedAStatus;
+
+namespace android {
+namespace hardware {
+namespace tv {
+namespace hdmi {
+namespace implementation {
+
+void HdmiMock::serviceDied(void* cookie) {
+ ALOGE("HdmiMock died");
+ auto hdmi = static_cast<HdmiMock*>(cookie);
+ hdmi->mHdmiThreadRun = false;
+}
+
+ScopedAStatus HdmiMock::getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) {
+ *_aidl_return = mPortInfos;
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiMock::isConnected(int32_t portId, bool* _aidl_return) {
+ // Maintain port connection status and update on hotplug event
+ if (portId <= mTotalPorts && portId >= 1) {
+ *_aidl_return = mPortConnectionStatus[portId];
+ } else {
+ *_aidl_return = false;
+ }
+
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus HdmiMock::setCallback(const std::shared_ptr<IHdmiCallback>& callback) {
+ if (mCallback != nullptr) {
+ mCallback = nullptr;
+ }
+
+ if (callback != nullptr) {
+ mCallback = callback;
+ AIBinder_linkToDeath(this->asBinder().get(), mDeathRecipient.get(), 0 /* cookie */);
+
+ mInputFile = open(HDMI_MSG_IN_FIFO, O_RDWR | O_CLOEXEC);
+ pthread_create(&mThreadId, NULL, __threadLoop, this);
+ pthread_setname_np(mThreadId, "hdmi_loop");
+ }
+ return ScopedAStatus::ok();
+}
+
+void* HdmiMock::__threadLoop(void* user) {
+ HdmiMock* const self = static_cast<HdmiMock*>(user);
+ self->threadLoop();
+ return 0;
+}
+
+int HdmiMock::readMessageFromFifo(unsigned char* buf, int msgCount) {
+ if (msgCount <= 0 || !buf) {
+ return 0;
+ }
+
+ int ret = -1;
+ // Maybe blocked at driver
+ ret = read(mInputFile, buf, msgCount);
+ if (ret < 0) {
+ ALOGE("[halimp_aidl] read :%s failed, ret:%d\n", HDMI_MSG_IN_FIFO, ret);
+ return -1;
+ }
+
+ return ret;
+}
+
+void HdmiMock::printEventBuf(const char* msg_buf, int len) {
+ int i, size = 0;
+ const int bufSize = MESSAGE_BODY_MAX_LENGTH * 3;
+ // Use 2 characters for each byte in the message plus 1 space
+ char buf[bufSize] = {0};
+
+ // Messages longer than max length will be truncated.
+ for (i = 0; i < len && size < bufSize; i++) {
+ size += sprintf(buf + size, " %02x", msg_buf[i]);
+ }
+ ALOGD("[halimp_aidl] %s, msg:%.*s", __FUNCTION__, size, buf);
+}
+
+void HdmiMock::handleHotplugMessage(unsigned char* msgBuf) {
+ bool connected = ((msgBuf[3]) & 0xf) > 0;
+ int32_t portId = static_cast<uint32_t>(msgBuf[0] & 0xf);
+
+ if (portId > static_cast<int32_t>(mPortInfos.size())) {
+ ALOGD("[halimp_aidl] ignore hot plug message, id %x does not exist", portId);
+ return;
+ }
+
+ ALOGD("[halimp_aidl] hot plug port id %x, is connected %x", (msgBuf[0] & 0xf),
+ (msgBuf[3] & 0xf));
+ mPortConnectionStatus[portId] = connected;
+ if (mPortInfos[portId].type == HdmiPortType::OUTPUT) {
+ mPhysicalAddress = (connected ? 0xffff : ((msgBuf[1] << 8) | (msgBuf[2])));
+ mPortInfos[portId].physicalAddress = mPhysicalAddress;
+ ALOGD("[halimp_aidl] hot plug physical address %x", mPhysicalAddress);
+ }
+
+ if (mCallback != nullptr) {
+ mCallback->onHotplugEvent(connected, portId);
+ }
+}
+
+void HdmiMock::threadLoop() {
+ ALOGD("[halimp_aidl] threadLoop start.");
+ unsigned char msgBuf[MESSAGE_BODY_MAX_LENGTH];
+ int r = -1;
+
+ // Open the input pipe
+ while (mInputFile < 0) {
+ usleep(1000 * 1000);
+ mInputFile = open(HDMI_MSG_IN_FIFO, O_RDONLY | O_CLOEXEC);
+ }
+ ALOGD("[halimp_aidl] file open ok, fd = %d.", mInputFile);
+
+ while (mHdmiThreadRun) {
+ memset(msgBuf, 0, sizeof(msgBuf));
+ // Try to get a message from dev.
+ // echo -n -e '\x04\x83' >> /dev/cec
+ r = readMessageFromFifo(msgBuf, MESSAGE_BODY_MAX_LENGTH);
+ if (r <= 1) {
+ // Ignore received ping messages
+ continue;
+ }
+
+ printEventBuf((const char*)msgBuf, r);
+
+ if (((msgBuf[0] >> 4) & 0xf) == 0xf) {
+ handleHotplugMessage(msgBuf);
+ }
+ }
+
+ ALOGD("[halimp_aidl] thread end.");
+}
+
+HdmiMock::HdmiMock() {
+ ALOGE("[halimp_aidl] Opening a virtual HDMI HAL for testing and virtual machine.");
+ mCallback = nullptr;
+ mPortInfos.resize(mTotalPorts);
+ mPortConnectionStatus.resize(mTotalPorts);
+ mPortInfos[0] = {.type = HdmiPortType::OUTPUT,
+ .portId = static_cast<uint32_t>(1),
+ .cecSupported = true,
+ .arcSupported = false,
+ .physicalAddress = mPhysicalAddress};
+ mPortConnectionStatus[0] = false;
+ mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied));
+}
+
+} // namespace implementation
+} // namespace hdmi
+} // namespace tv
+} // namespace hardware
+} // namespace android
diff --git a/tv/hdmi/aidl/default/HdmiMock.h b/tv/hdmi/aidl/default/HdmiMock.h
new file mode 100644
index 0000000..05795dd
--- /dev/null
+++ b/tv/hdmi/aidl/default/HdmiMock.h
@@ -0,0 +1,77 @@
+/*
+ * 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 <aidl/android/hardware/tv/hdmi/BnHdmi.h>
+#include <algorithm>
+#include <vector>
+
+using namespace std;
+
+namespace android {
+namespace hardware {
+namespace tv {
+namespace hdmi {
+namespace implementation {
+
+using ::aidl::android::hardware::tv::hdmi::BnHdmi;
+using ::aidl::android::hardware::tv::hdmi::HdmiPortInfo;
+using ::aidl::android::hardware::tv::hdmi::HdmiPortType;
+using ::aidl::android::hardware::tv::hdmi::IHdmi;
+using ::aidl::android::hardware::tv::hdmi::IHdmiCallback;
+
+#define HDMI_MSG_IN_FIFO "/dev/hdmi_in_pipe"
+#define MESSAGE_BODY_MAX_LENGTH 4
+
+struct HdmiMock : public BnHdmi {
+ HdmiMock();
+
+ ::ndk::ScopedAStatus getPortInfo(std::vector<HdmiPortInfo>* _aidl_return) override;
+ ::ndk::ScopedAStatus isConnected(int32_t portId, bool* _aidl_return) override;
+ ::ndk::ScopedAStatus setCallback(const std::shared_ptr<IHdmiCallback>& callback) override;
+
+ void printEventBuf(const char* msg_buf, int len);
+
+ private:
+ static void* __threadLoop(void* data);
+ void threadLoop();
+ int readMessageFromFifo(unsigned char* buf, int msgCount);
+ void handleHotplugMessage(unsigned char* msgBuf);
+
+ private:
+ static void serviceDied(void* cookie);
+ std::shared_ptr<IHdmiCallback> mCallback;
+
+ // Variables for the virtual HDMI hal impl
+ std::vector<HdmiPortInfo> mPortInfos;
+ std::vector<bool> mPortConnectionStatus;
+
+ // Port configuration
+ uint16_t mPhysicalAddress = 0xFFFF;
+ int mTotalPorts = 1;
+
+ // Testing variables
+ // Input file descriptor
+ int mInputFile;
+ bool mHdmiThreadRun = true;
+ pthread_t mThreadId = 0;
+
+ ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
+};
+} // namespace implementation
+} // namespace hdmi
+} // Namespace tv
+} // namespace hardware
+} // namespace android
diff --git a/tv/hdmi/aidl/default/android.hardware.tv.hdmi-service.rc b/tv/hdmi/aidl/default/android.hardware.tv.hdmi-service.rc
new file mode 100644
index 0000000..c926221
--- /dev/null
+++ b/tv/hdmi/aidl/default/android.hardware.tv.hdmi-service.rc
@@ -0,0 +1,5 @@
+service vendor.hdmi-default /vendor/bin/hw/android.hardware.tv.hdmi-service
+ interface aidl android.hardware.tv.hdmi.IHdmi/default
+ class hal
+ user system
+ group system
diff --git a/tv/hdmi/aidl/default/android.hardware.tv.hdmi-service.xml b/tv/hdmi/aidl/default/android.hardware.tv.hdmi-service.xml
new file mode 100644
index 0000000..a03c199
--- /dev/null
+++ b/tv/hdmi/aidl/default/android.hardware.tv.hdmi-service.xml
@@ -0,0 +1,10 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.tv.hdmi</name>
+ <version>1</version>
+ <interface>
+ <name>IHdmi</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/tv/hdmi/aidl/default/fuzzer.cpp b/tv/hdmi/aidl/default/fuzzer.cpp
new file mode 100644
index 0000000..06a2bc0
--- /dev/null
+++ b/tv/hdmi/aidl/default/fuzzer.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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 <HdmiMock.h>
+#include <fuzzbinder/libbinder_ndk_driver.h>
+#include <fuzzer/FuzzedDataProvider.h>
+
+using android::fuzzService;
+using android::hardware::tv::hdmi::implementation::HdmiMock;
+using ndk::SharedRefBase;
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ auto hdmiAidl = SharedRefBase::make<HdmiMock>();
+
+ fuzzService(hdmiAidl->asBinder().get(), FuzzedDataProvider(data, size));
+
+ return 0;
+}
diff --git a/tv/hdmi/aidl/default/serviceMock.cpp b/tv/hdmi/aidl/default/serviceMock.cpp
new file mode 100644
index 0000000..1d8bf51
--- /dev/null
+++ b/tv/hdmi/aidl/default/serviceMock.cpp
@@ -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.
+ */
+
+#define LOG_TAG "android.hardware.tv.hdmi-service-shim"
+
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <hidl/HidlTransportSupport.h>
+#include <utils/Log.h>
+#include "HdmiMock.h"
+
+using android::hardware::tv::hdmi::implementation::HdmiMock;
+
+int main() {
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+
+ std::shared_ptr<HdmiMock> hdmiAidl = ndk::SharedRefBase::make<HdmiMock>();
+ const std::string instance = std::string() + HdmiMock::descriptor + "/default";
+ binder_status_t status =
+ AServiceManager_addService(hdmiAidl->asBinder().get(), instance.c_str());
+ CHECK_EQ(status, STATUS_OK);
+
+ ABinderProcess_joinThreadPool();
+ return 0;
+}
diff --git a/tv/hdmi/aidl/vts/functional/Android.bp b/tv/hdmi/aidl/vts/functional/Android.bp
new file mode 100644
index 0000000..f9af58d
--- /dev/null
+++ b/tv/hdmi/aidl/vts/functional/Android.bp
@@ -0,0 +1,37 @@
+// 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.
+
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_test {
+ name: "VtsHalTvHdmiAidlTargetTest",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: ["VtsHalTvHdmiAidlTargetTest.cpp"],
+ static_libs: [
+ "android.hardware.tv.hdmi-V1-ndk",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+ disable_framework: true,
+}
diff --git a/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp b/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp
new file mode 100644
index 0000000..78c2590
--- /dev/null
+++ b/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "Hdmi_hal_test"
+
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/tv/hdmi/BnHdmi.h>
+#include <aidl/android/hardware/tv/hdmi/BnHdmiCallback.h>
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <gtest/gtest.h>
+#include <log/log.h>
+#include <sstream>
+#include <vector>
+
+using ::aidl::android::hardware::tv::hdmi::BnHdmiCallback;
+using ::aidl::android::hardware::tv::hdmi::HdmiPortInfo;
+using ::aidl::android::hardware::tv::hdmi::HdmiPortType;
+using ::aidl::android::hardware::tv::hdmi::IHdmi;
+using ::aidl::android::hardware::tv::hdmi::IHdmiCallback;
+using ::ndk::SpAIBinder;
+
+#define INCORRECT_VENDOR_ID 0x00
+#define TV_PHYSICAL_ADDRESS 0x0000
+
+// The main test class for TV HDMI HAL.
+class HdmiTest : public ::testing::TestWithParam<std::string> {
+ static void serviceDied(void* /* cookie */) { ALOGE("VtsHalTvCecAidlTargetTest died"); }
+
+ public:
+ void SetUp() override {
+ hdmi = IHdmi::fromBinder(SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
+ ASSERT_NE(hdmi, nullptr);
+ ALOGI("%s: getService() for hdmi is %s", __func__, hdmi->isRemote() ? "remote" : "local");
+
+ hdmiCallback = ::ndk::SharedRefBase::make<HdmiCallback>();
+ ASSERT_NE(hdmiCallback, nullptr);
+ hdmiDeathRecipient =
+ ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(&serviceDied));
+ ASSERT_EQ(AIBinder_linkToDeath(hdmi->asBinder().get(), hdmiDeathRecipient.get(), 0),
+ STATUS_OK);
+ }
+
+ class HdmiCallback : public BnHdmiCallback {
+ public:
+ ::ndk::ScopedAStatus onHotplugEvent(bool connected __unused, int32_t portId __unused) {
+ return ::ndk::ScopedAStatus::ok();
+ };
+ };
+
+ std::shared_ptr<IHdmi> hdmi;
+ std::shared_ptr<IHdmiCallback> hdmiCallback;
+ ::ndk::ScopedAIBinder_DeathRecipient hdmiDeathRecipient;
+};
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HdmiTest);
+INSTANTIATE_TEST_SUITE_P(PerInstance, HdmiTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(IHdmi::descriptor)),
+ android::PrintInstanceNameToString);
+
+TEST_P(HdmiTest, SetCallback) {
+ ASSERT_TRUE(hdmi->setCallback(::ndk::SharedRefBase::make<HdmiCallback>()).isOk());
+}
+
+TEST_P(HdmiTest, GetPortInfo) {
+ std::vector<HdmiPortInfo> ports;
+ ASSERT_TRUE(hdmi->getPortInfo(&ports).isOk());
+
+ bool cecSupportedOnDevice = false;
+ for (size_t i = 0; i < ports.size(); ++i) {
+ EXPECT_TRUE((ports[i].type == HdmiPortType::OUTPUT) ||
+ (ports[i].type == HdmiPortType::INPUT));
+ if (ports[i].portId == 0) {
+ ALOGW("%s: Port id should start from 1", __func__);
+ }
+ cecSupportedOnDevice = cecSupportedOnDevice | ports[i].cecSupported;
+ }
+ EXPECT_NE(cecSupportedOnDevice, false) << "At least one port should support CEC";
+}
+
+TEST_P(HdmiTest, IsConnected) {
+ std::vector<HdmiPortInfo> ports;
+ ASSERT_TRUE(hdmi->getPortInfo(&ports).isOk());
+ for (size_t i = 0; i < ports.size(); ++i) {
+ bool connected;
+ ASSERT_TRUE(hdmi->isConnected(ports[i].portId, &connected).isOk());
+ }
+}
diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
index e6e61cf..02f8209 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
+++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
@@ -66,7 +66,7 @@
bool configureChipToSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
IfaceType type,
ChipModeId* configured_mode_id) {
- if (!configured_mode_id) {
+ if (!configured_mode_id || !wifi_chip.get()) {
return false;
}
const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes);
diff --git a/wifi/1.6/default/Android.bp b/wifi/1.6/default/Android.bp
index a132dee..0f98e71 100644
--- a/wifi/1.6/default/Android.bp
+++ b/wifi/1.6/default/Android.bp
@@ -226,3 +226,13 @@
"libwifi-system-iface",
],
}
+
+filegroup {
+ name: "default-android.hardware.wifi@1.0-service.rc",
+ srcs: ["android.hardware.wifi@1.0-service.rc"],
+}
+
+filegroup {
+ name: "default-android.hardware.wifi@1.0-service.xml",
+ srcs: ["android.hardware.wifi@1.0-service.xml"],
+}
diff --git a/wifi/apex/Android.bp b/wifi/apex/Android.bp
new file mode 100644
index 0000000..0afb96b
--- /dev/null
+++ b/wifi/apex/Android.bp
@@ -0,0 +1,55 @@
+package {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+apex_key {
+ name: "com.android.hardware.wifi.key",
+ public_key: "com.android.hardware.wifi.avbpubkey",
+ private_key: "com.android.hardware.wifi.pem",
+}
+
+android_app_certificate {
+ name: "com.android.hardware.wifi.certificate",
+ certificate: "com.android.hardware.wifi",
+}
+
+genrule {
+ name: "gen-android.hardware.wifi.rc",
+ srcs: [":default-android.hardware.wifi@1.0-service.rc"],
+ out: ["com.android.hardware.wifi-service.rc"],
+ cmd: "sed -e 's@/vendor/bin/@/apex/com.android.hardware.wifi/bin/@' $(in) > $(out)",
+}
+
+prebuilt_etc {
+ name: "com.android.hardware.wifi.rc",
+ src: ":gen-android.hardware.wifi.rc",
+ installable: false,
+}
+
+prebuilt_etc {
+ name: "com.android.hardware.wifi.xml",
+ src: ":default-android.hardware.wifi@1.0-service.xml",
+ installable: false,
+}
+
+apex {
+ name: "com.android.hardware.wifi",
+ manifest: "apex_manifest.json",
+ key: "com.android.hardware.wifi.key",
+ certificate: ":com.android.hardware.wifi.certificate",
+ file_contexts: "file_contexts",
+ vintf_fragments: [":com.android.hardware.wifi.xml"],
+ use_vndk_as_stable: true,
+ updatable: false,
+ soc_specific: true,
+ binaries: [
+ "android.hardware.wifi@1.0-service",
+ ],
+ prebuilts: [
+ "com.android.hardware.wifi.rc",
+ "com.android.hardware.wifi.xml",
+ ],
+ overrides: [
+ "android.hardware.wifi@1.0-service",
+ ],
+}
diff --git a/wifi/apex/apex_manifest.json b/wifi/apex/apex_manifest.json
new file mode 100644
index 0000000..cab0814
--- /dev/null
+++ b/wifi/apex/apex_manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "com.android.hardware.wifi",
+ "version": 1
+}
diff --git a/wifi/apex/com.android.hardware.wifi.avbpubkey b/wifi/apex/com.android.hardware.wifi.avbpubkey
new file mode 100644
index 0000000..63fba77
--- /dev/null
+++ b/wifi/apex/com.android.hardware.wifi.avbpubkey
Binary files differ
diff --git a/wifi/apex/com.android.hardware.wifi.pem b/wifi/apex/com.android.hardware.wifi.pem
new file mode 100644
index 0000000..9e589ac
--- /dev/null
+++ b/wifi/apex/com.android.hardware.wifi.pem
@@ -0,0 +1,52 @@
+-----BEGIN PRIVATE KEY-----
+MIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggkqAgEAAoICAQCtT/vNnVVg2QVD
+eMdG+YZ8qYz/fbAQF9hnH8dE5RWHXzoYItBG7DSOuVT4T6POBVmFaVKlWDd7tDyw
+nFO3MmE2/FzhVSiBPwhMITa7UIERr3od3rWJ5g6oaTCOu4wa98L466Jp60f2fYSZ
+M9lGiKaDpLDSpxTU9hexjp7C4PfinnkYnlHBnrFXTmiO6f8AvOEwFFx73/rUNoe7
+F3TkGvjZDqHvE+pjz/nilkhXYuOl3zgSaeznJ9+TO5C/Z+Xr+zRhaJGI4v5Dkgmc
+jNy74+0hjwobXO3iWE44InQMvMh8zDKBx9l1oSsFoG3waj9ayqSYD7M74RX3PkUL
+QrhgAHZWi5iEnpu50xBzAqZB1ZDVkdZiKiGzweJ8OqltnVpvzlnW3rA3y3HtFyLm
+73C4ll9MdLaw266vBxgZfFOcjpphbbh9J9uGjOCJY1AxUzsqKygFD2CyOdb1jab3
+AC6VvRa+bLtv8fd2etp3atXv+Y9ACUX6zNK6Oa8Zktoo2Z//OLtcrk7xhgKKDkUF
+OPQrIjW9x0fdClDioIS+y7EHNUrfyRL7XPtUqGCszgz5jK2SMVGMpFaEtfbyNP1H
+BTGXdzcDP0RZdOOKTdBFgoRW5+6TH5CU9Nl4uevpxzwsTkXg0a+W1BGP+s9J7ssH
+rNPmHz+pbKZPDs/nxlpsKq+N+K8cCwIDAQABAoICAAJL943Lgnikl53DyXxGzUH0
+q0Itg7pK3prLQIRItubS2727JGB0O+QST650u7p8tql+clJvn1ib1FwQzkk0uTYV
+1RNFYiKIV89Od1+3GubFmQwxSd2Yd2RC9JpHoP0wgFx1HvNhY1RAaJPxLHVzVSWU
+dqVsAmoqErlPJwp1GcPejsNFQdcbh8Uc7GTMdA0p86AD/Q/FMZlDWbwgfPOS6e5S
+c9HrxSTqeijHDhFeZZ7qnN8dmT6c+CkG1o26zkC41QJfdOJIA8+YbVkuQrSYuilC
+MIOZUSu5ONwklL4geFWzDQ5MPDUDXEMYU6ymc817tv+u4ZSvEG/02sxh53iaOPc6
+C6im4nm6ZlRP9HzIvLAiRSbvwEb9cnLKgYpioSGXehDYg3zMPURwoqIxw+7IlIUh
+s+rhmCJV62PK1Z0nmo7m7S8r+z6j4G7aztGcbvdecocOJYOQB1VB8Zh4bNEIWp0a
+GDteG6aWXOCHoYRWAOluppDWa7Z+EgesU3Oj9Prn/ekUzzXx3V30zSTZYxRnQCO0
+vZIZ6hrlsNJcNrDpxmiWBaEOd4k5QI39pu6fDHc+UEEJMN+7eVk8d9QVA/LhrCjc
+JH1EVjtWosMUeMaMTpcmHTQKnEvmT2LO2fxGlF4JvjzDdVMloJrIP2LSQjovo2PX
+x9UXVu8Dt3kQRefZ42XxAoIBAQDkBoSYVajaFlyv9lW8oPmrQyzp93ite+TKVR8z
+PmcFQukjp5Gm8PGlGtGoH8aeE9Ev+R86aNPFy4n4ZJ7fmZYH1hxZ6dSc/56k6lLn
+uVKvTudYqwcRgBKuSZ8IDPFz3sHd+MnOBonDIri28fcBTDNv4LJP/6cAUoIOCCPm
+lQtJBfMNMDOXG4jv1Rv/1P5opGFATerRCubOxmeaFhZIDEjvN5WvLK5jmL7I8lX3
+X+gPiMHFWBQFmVTOHeVYEORDO5xFCOvHqCVB78b2xe1NkkrQ0CexpdflJVLE9IWt
+wWH43nhjxaK+eiBPrj37BliJvNaYfuxqcAj3p8c5KweFEtP7AoIBAQDCkx72K/Ja
+rFrrI0Avfo+3n6yoTMtMkiVhMuIKKPBJ2o4Opc/uixk+uLH5UH0X5GZsE51FAhUD
+L3bWMxV+vzVefWS8Iryo94ucvnfqhsN3KZXHDGoAuYv72jND8qPLKksM0dceMBfl
+aoyXSPAe8zAZeEx4iR2axgtnA0EbiXIaNVE/LF+WYdM74jvk/QtRzJ8IAAkSc5Rr
+GiTHeeP3nRnkjWjkmwKXYSJHcrEl26c/2ckeZORtblqxR9wMU5OgvJvMSzmOIpVH
+Y5lylZUOTuJCkApHFNKdRsawsSNKsy4yfY1byN/WkODb7le6Crt1gcwldMxDZAo9
+iB25FHq4zksxAoIBAQC+SBYkDO9PtnN4PycCto5B9VeokmN42bdthKT5nSxY/qIQ
+p8fquIvdzEiCdKnIxh69WrVNh6aZGyWySz0suDyzo1+bRH6w2LrpQcUXK9YtBroV
+ivrmBqsQF82G6U4f9BZxhifZLimN1g6wU7Bcu9r8lFQYX+1bXn66+N4EkAGP2VAe
+hEe45Dhccsjfrzzx06J4B81YzjEXAgf4VFAZpW7DeO4G9VE9OXyTsW49dSHwvJ1+
+ceabWX2kVtxIpiflVvwru6sNvGoC4PV2fmptXhPitqE5JHzJ8mBkjOx0t7hq9jMe
+hxEsxDrsYynDrWL65cNqFBhzJbTF/ZNJSHgI+1I7AoIBAQC7m0shJOJ61vCbA9Qh
+dzBvZn/9jn3/CHMOMxeLoEl/jEGokevZHzlqJn9D2n2jCdBPqOHc5dMIzT0R7xNs
+sERvJQx58ixh5r0wlt3cva++N9R4pdmXdVApuAvyGgQgIllWtQVr0AdaZs/EFsmf
+re/Uvw9MsThgQVBBNPwT5wSjjIEYHlrUDuKzPMFvWyUM6/Tyq8YTimmykvSfeUF7
+QHj0y/w1X9ixyTBaH5X64L10bTLkIXe2o87CXH0pTXRsaS73XhjSmTnCKaCMwPmF
+YD383BFs1AD3MITnXQSgQ//pIvGnbBmXMv38UOU5NpvlAw+pleJVoCHXjmTKTZq+
+kfohAoIBAQCrEecN8XEPjGdtY71rDYEwHGM6G4czHX0PNhlMjQos3aBVZ/YvVxPG
+pkXbms3GRXv4W92u7b2MwEKBPxcBepEdDZN9wSpe63bDFE6gpkipDhgj97JlLEUd
+s7h6oOoazdxmsRZyFho99SRQWrvyOiiKdLJCRZiqjUB4roOQmy7f9VAz6+OxyGV9
+XZigwW6bfUzMCmhx5Ss6zW8wZI+gINQh+2sDmiBiMQv14Ya5zlNYN+4/257Sk/jS
+o3QUDJITbReq/DNZ6UUzQS+AZ7ztc81rk5kRg0I33FZarRJ7TLAz+XmZZFoIOORz
+etEvMk8bJ4u7X89NWW/i2J+kQiDQg819
+-----END PRIVATE KEY-----
diff --git a/wifi/apex/com.android.hardware.wifi.pk8 b/wifi/apex/com.android.hardware.wifi.pk8
new file mode 100644
index 0000000..f4481bf
--- /dev/null
+++ b/wifi/apex/com.android.hardware.wifi.pk8
Binary files differ
diff --git a/wifi/apex/com.android.hardware.wifi.x509.pem b/wifi/apex/com.android.hardware.wifi.x509.pem
new file mode 100644
index 0000000..c942e71
--- /dev/null
+++ b/wifi/apex/com.android.hardware.wifi.x509.pem
@@ -0,0 +1,36 @@
+-----BEGIN CERTIFICATE-----
+MIIGOzCCBCOgAwIBAgIUIEueuBFEoCFmLyEvXDsKVuZeH0EwDQYJKoZIhvcNAQEL
+BQAwgasxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQH
+DA1Nb3VudGFpbiBWaWV3MRAwDgYDVQQKDAdBbmRyb2lkMRAwDgYDVQQLDAdBbmRy
+b2lkMScwJQYDVQQDDB5jb20uYW5kcm9pZC5oYXJkd2FyZS53aWZpLmFwZXgxIjAg
+BgkqhkiG9w0BCQEWE2FuZHJvaWRAYW5kcm9pZC5jb20wIBcNMjIxMDA2MTY1MDQy
+WhgPNDc2MDA5MDExNjUwNDJaMIGrMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2Fs
+aWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4GA1UECgwHQW5kcm9p
+ZDEQMA4GA1UECwwHQW5kcm9pZDEnMCUGA1UEAwweY29tLmFuZHJvaWQuaGFyZHdh
+cmUud2lmaS5hcGV4MSIwIAYJKoZIhvcNAQkBFhNhbmRyb2lkQGFuZHJvaWQuY29t
+MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAo4N23iL0J42qG2lt4ysD
+t6XxAKdi4sTWB6ZjFWerBm11s3yLr1KBZV82z3j2o7+EOaWa/91Mgc+aoiGYUa1f
+IweugKTrnRmrzOvtq/Wp5PGqSxsmLPPvH3wyEB/CMgAn0pqDf0WyCWJ2kAlcCkmy
+qVNFupkGFyIE6gkoc+AmJGbSTquDlL07R/8XYDicqrcgeqy9ZaCJ5FLfmbnnRb2A
+vm4Un7e5dFz5+dPaOJXf4AOMUSPUd7fuBliGYFLzcZnYQbzMktXa4XnPuSlmerwy
+EwY767L2bjRjaSgPb0Js13gZ4S4ZHZe07AV7HPlt/EzbxV/jtMgHl4xn5p0WhVnK
+MPtLsO/e7FkDPAKpT02sgUK6pVKqgBGOWm27tmTB09lscMLQeVFqwpoFq2zMUrDn
+ipDFMWRBeLrEDKx41zF3gqdPmP+SMkQYJu4OATIXOndIeo7AN9iE+N6snHkckNyE
+saCwmnzyhVAbMn/epfIQZz3zcyljA9yfOpv5jctN4es+3i0htDnoNO9ij4M5fxuP
+jtNAP3EA61nKZ5+Js0/MMQKrfwCLogPl/4vCNuuGT2rhCkhq1CLYXmb9ghvVzcPe
+BOGXNDKdB+aUTxrQUOYlHf0cRDHdU6cchrz9+QhR7t9dlibtiyCZE34xgR3klmyz
+XJ3M1r/QRihjARH7exrrwiUCAwEAAaNTMFEwHQYDVR0OBBYEFGN9tMk+4SDk7twk
+MrLjM+nRxGDJMB8GA1UdIwQYMBaAFGN9tMk+4SDk7twkMrLjM+nRxGDJMA8GA1Ud
+EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggIBAHoTfVBRG0rVE7gkV526gwR5
+/3mXyYA57lKJhZ21fu2qfTE6WYj4DsOTZKrPIAUFv/SnzZ6Rvv7W81XV5M/1m+5R
+/1wYvWwm3FBOvvt4VDUiel0Zfc9+nwynjz1seYdXU8fNIOzBcr9hutkYdRZDkNpc
+Zcl4NG04TzyedkQ/0SyHnygmq4ZY9OUEvrNaWBFHzw2SQhYvHh8jUrqpPvoJz0Px
+avKI8bOgXTJRJ+Pk7hjXDFQY/fbE0RGivorPMLs+XHaEIb+YPyXsX4OZwowG5KL8
+txyvUsH+qZToytdPk4LCuwYBobBlr+AAg7pxOtbDW1ITDhQ9n05UFK2iUwsJecgg
+VDA0K3GuCjmGVmkw7SFRYfToCyGWah8sQCUMCCcsof7gS+dMxuWeee+sRxRJcJY+
+xR2uySe8g4ohwNjQ0zLQv7PZOKQh91yEWxRXmhPYVpiVAjpSD2zH7Vd6CJ9xji//
+5S1UrxWwQ5igvu8v5veqNAW7uXGXADnxL69HVGTLm0XDIUUOAUIG8waiVkYUo3UU
+AzAFbF7ewYMKdg7ylUYcTaMRIsKYW/3/1t3NJv2z99W4V/p8e1kRCeWMPB5C+/Lo
+b/hSWj1NF9AJ30ukBndMh6bRprq+G5NLV6OaoCLp606CMdXdT8uw9lYCt7DbQHG9
+Hw3iw61svpUwcaWfN1hI
+-----END CERTIFICATE-----
diff --git a/wifi/apex/file_contexts b/wifi/apex/file_contexts
new file mode 100644
index 0000000..812d51d
--- /dev/null
+++ b/wifi/apex/file_contexts
@@ -0,0 +1,3 @@
+(/.*)? u:object_r:vendor_file:s0
+/bin/hw/android\.hardware\.wifi@1.0-service u:object_r:hal_wifi_default_exec:s0
+