mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "EARC: Add eARC AIDL files" am: 7fb9baae1c am: 87243fbbd7 am: f3686eba77
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2308889 Change-Id: Ib4f858b958a6eecdb07bf9d0a7eb4bee4758f8c5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -655,6 +655,13 @@
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.tv.earc</name>
|
||||
<interface>
|
||||
<name>IEArc</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.tv.hdmi</name>
|
||||
<interface>
|
||||
|
||||
29
tv/earc/aidl/Android.bp
Normal file
29
tv/earc/aidl/Android.bp
Normal file
@@ -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.earc",
|
||||
vendor_available: true,
|
||||
srcs: ["android/hardware/tv/earc/*.aidl"],
|
||||
stability: "vintf",
|
||||
backend: {
|
||||
java: {
|
||||
sdk_version: "module_current",
|
||||
},
|
||||
},
|
||||
}
|
||||
2
tv/earc/aidl/OWNERS
Normal file
2
tv/earc/aidl/OWNERS
Normal file
@@ -0,0 +1,2 @@
|
||||
# Bug component: 826094
|
||||
include platform/frameworks/base:/core/java/android/hardware/hdmi/OWNERS
|
||||
@@ -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.earc;
|
||||
@VintfStability
|
||||
interface IEArc {
|
||||
void setEArcEnabled(in boolean enabled);
|
||||
boolean isEArcEnabled();
|
||||
void setCallback(in android.hardware.tv.earc.IEArcCallback callback);
|
||||
android.hardware.tv.earc.IEArcStatus getState(in int portId);
|
||||
byte[] getLastReportedAudioCapabilities(in int portId);
|
||||
}
|
||||
@@ -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.earc;
|
||||
@VintfStability
|
||||
interface IEArcCallback {
|
||||
oneway void onStateChange(in android.hardware.tv.earc.IEArcStatus status, in int portId);
|
||||
oneway void onCapabilitiesReported(in byte[] rawCapabilities, in int portId);
|
||||
}
|
||||
@@ -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.earc;
|
||||
@Backing(type="byte") @VintfStability
|
||||
enum IEArcStatus {
|
||||
STATUS_IDLE = 0,
|
||||
STATUS_EARC_PENDING = 1,
|
||||
STATUS_ARC_PENDING = 2,
|
||||
STATUS_EARC_CONNECTED = 3,
|
||||
}
|
||||
@@ -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.earc;
|
||||
@VintfStability
|
||||
enum Result {
|
||||
SUCCESS = 0,
|
||||
FAILURE_UNKNOWN = 1,
|
||||
FAILURE_INVALID_ARGS = 2,
|
||||
FAILURE_NOT_SUPPORTED = 4,
|
||||
}
|
||||
71
tv/earc/aidl/android/hardware/tv/earc/IEArc.aidl
Normal file
71
tv/earc/aidl/android/hardware/tv/earc/IEArc.aidl
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.earc;
|
||||
|
||||
import android.hardware.tv.earc.IEArcCallback;
|
||||
import android.hardware.tv.earc.IEArcStatus;
|
||||
|
||||
/**
|
||||
* eARC HAL interface definition
|
||||
*/
|
||||
@VintfStability
|
||||
interface IEArc {
|
||||
/**
|
||||
* Function to enable or disable eARC in the device's driver and HAL. If enabled, the driver and
|
||||
* HAL shall attempt to establish an eARC connection and inform the Android framework about
|
||||
* updates with IEArcCallback callbacks. If disabled, the driver and HAL shall not attempt to
|
||||
* establish an eARC connection and shall not send any IEArcCallback callbacks to the Android
|
||||
* framework.
|
||||
* The error status is set to
|
||||
* {@code SUCCESS} if the setting could be changed to the value passed.
|
||||
* {@code FAILURE_NOT_SUPPORTED} if the setting is not supported.
|
||||
* {@code FAILURE_INVALID_ARGS} if the setting value is invalid.
|
||||
* {@code FAILURE_UNKNOWN} if there was an unknown failure.
|
||||
*/
|
||||
void setEArcEnabled(in boolean enabled);
|
||||
|
||||
/**
|
||||
* Function to check if eARC is enabled in the device's driver and HAL.
|
||||
*/
|
||||
boolean isEArcEnabled();
|
||||
|
||||
/**
|
||||
* Function to set callback that the HAL will use to notify the system of connection state
|
||||
* changes and capabilities of connected devices.
|
||||
*
|
||||
* @param callback The callback object to pass the events to the system. A previously registered
|
||||
* callback should be replaced by this new object. If callback is {@code null} the
|
||||
* previously registered callback should be deregistered.
|
||||
*/
|
||||
void setCallback(in IEArcCallback callback);
|
||||
|
||||
/**
|
||||
* Getter for the current eARC state of a port.
|
||||
*
|
||||
* @param portId The port ID for which the state is to be reported.
|
||||
* @return The state of the port.
|
||||
*/
|
||||
IEArcStatus getState(in int portId);
|
||||
|
||||
/**
|
||||
* Getter for the most recent capabilities reported by the device connected to port.
|
||||
*
|
||||
* @param portId The port ID on which the device is connected.
|
||||
* @return The raw, unparsed audio capabilities
|
||||
*/
|
||||
byte[] getLastReportedAudioCapabilities(in int portId);
|
||||
}
|
||||
45
tv/earc/aidl/android/hardware/tv/earc/IEArcCallback.aidl
Normal file
45
tv/earc/aidl/android/hardware/tv/earc/IEArcCallback.aidl
Normal file
@@ -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.
|
||||
*/
|
||||
|
||||
package android.hardware.tv.earc;
|
||||
|
||||
import android.hardware.tv.earc.IEArcStatus;
|
||||
|
||||
/**
|
||||
* eARC HAL callback methods
|
||||
*/
|
||||
@VintfStability
|
||||
oneway interface IEArcCallback {
|
||||
/**
|
||||
* The callback function that must be called by the eARC driver and HAL implementation to notify
|
||||
* the Android framework of an eARC status change.
|
||||
* @param status The new status of the port
|
||||
* @param portId The port ID for which the state change is being reported
|
||||
*/
|
||||
void onStateChange(in IEArcStatus status, in int portId);
|
||||
|
||||
/**
|
||||
* The callback function that must be called by the eARC driver and HAL implementation to
|
||||
* notify the Android framework of the audio capabilities reported by the connected device. On
|
||||
* every state change to {@code STATUS_EARC_CONNECTED}, the driver shall read the capabilities
|
||||
* reported by the eARC RX. The onStateChange callback shall always be invoked first and the
|
||||
* onCapabilitiesReported callback shall be invoked second.
|
||||
* @param rawCapabilities The raw unparsed audio capabilities (Ref "Section 9.5.3.6 - eARC RX
|
||||
* Capabilities Data Structure" in HDMI 2.1 specification).
|
||||
* @param portId The port ID for which the audio capabilities are being reported
|
||||
*/
|
||||
void onCapabilitiesReported(in byte[] rawCapabilities, in int portId);
|
||||
}
|
||||
29
tv/earc/aidl/android/hardware/tv/earc/IEArcStatus.aidl
Normal file
29
tv/earc/aidl/android/hardware/tv/earc/IEArcStatus.aidl
Normal file
@@ -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 android.hardware.tv.earc;
|
||||
|
||||
/**
|
||||
* eARC HAL connection states
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="byte")
|
||||
enum IEArcStatus {
|
||||
STATUS_IDLE = 0,
|
||||
STATUS_EARC_PENDING = 1,
|
||||
STATUS_ARC_PENDING = 2,
|
||||
STATUS_EARC_CONNECTED = 3,
|
||||
}
|
||||
43
tv/earc/aidl/android/hardware/tv/earc/Result.aidl
Normal file
43
tv/earc/aidl/android/hardware/tv/earc/Result.aidl
Normal file
@@ -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.
|
||||
*/
|
||||
|
||||
package android.hardware.tv.earc;
|
||||
|
||||
/**
|
||||
* Result enum for return values. Used by the HDMI related AIDL.
|
||||
*/
|
||||
@VintfStability
|
||||
enum Result {
|
||||
/**
|
||||
* The eARC enabled setting was set successfully.
|
||||
*/
|
||||
SUCCESS = 0,
|
||||
|
||||
/**
|
||||
* The eARC enabled setting could not be set because of an unknown failure.
|
||||
*/
|
||||
FAILURE_UNKNOWN = 1,
|
||||
|
||||
/**
|
||||
* The eARC enabled setting could not be set because the arguments were invalid.
|
||||
*/
|
||||
FAILURE_INVALID_ARGS = 2,
|
||||
|
||||
/**
|
||||
* The eARC enabled setting could not be set because eARC feature is not supported.
|
||||
*/
|
||||
FAILURE_NOT_SUPPORTED = 4,
|
||||
}
|
||||
58
tv/earc/aidl/default/Android.bp
Normal file
58
tv/earc/aidl/default/Android.bp
Normal file
@@ -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.earc-service",
|
||||
vintf_fragments: ["android.hardware.tv.earc-service.xml"],
|
||||
relative_install_path: "hw",
|
||||
vendor: true,
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
],
|
||||
init_rc: ["android.hardware.tv.earc-service.rc"],
|
||||
srcs: [
|
||||
"serviceMock.cpp",
|
||||
"EArcMock.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbinder_ndk",
|
||||
"liblog",
|
||||
"libbase",
|
||||
"libutils",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"android.hardware.tv.earc-V1-ndk",
|
||||
],
|
||||
}
|
||||
|
||||
cc_fuzz {
|
||||
name: "android.hardware.tv.earc-service_fuzzer",
|
||||
defaults: ["service_fuzzer_defaults"],
|
||||
static_libs: [
|
||||
"android.hardware.tv.earc-V1-ndk",
|
||||
"liblog",
|
||||
],
|
||||
srcs: [
|
||||
"fuzzer.cpp",
|
||||
"EArcMock.cpp",
|
||||
],
|
||||
fuzz_config: {
|
||||
componentid: 826094,
|
||||
},
|
||||
}
|
||||
119
tv/earc/aidl/default/EArcMock.cpp
Normal file
119
tv/earc/aidl/default/EArcMock.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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.earc"
|
||||
#include <android-base/logging.h>
|
||||
#include <fcntl.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "EArcMock.h"
|
||||
|
||||
using ndk::ScopedAStatus;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace tv {
|
||||
namespace earc {
|
||||
namespace implementation {
|
||||
|
||||
void EArcMock::serviceDied(void* cookie) {
|
||||
ALOGE("EArcMock died");
|
||||
auto eArc = static_cast<EArcMock*>(cookie);
|
||||
eArc->mEArcEnabled = false;
|
||||
}
|
||||
|
||||
ScopedAStatus EArcMock::setEArcEnabled(bool in_enabled) {
|
||||
mEArcEnabled = in_enabled;
|
||||
if (mEArcEnabled != in_enabled) {
|
||||
return ScopedAStatus::fromServiceSpecificError(
|
||||
static_cast<int32_t>(Result::FAILURE_UNKNOWN));
|
||||
} else {
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
}
|
||||
|
||||
ScopedAStatus EArcMock::isEArcEnabled(bool* _aidl_return) {
|
||||
*_aidl_return = mEArcEnabled;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus EArcMock::getState(int32_t portId, IEArcStatus* _aidl_return) {
|
||||
// Maintain port connection status and update on hotplug event
|
||||
if (portId <= mTotalPorts && portId >= 1) {
|
||||
*_aidl_return = mPortStatus[portId];
|
||||
} else {
|
||||
return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus EArcMock::getLastReportedAudioCapabilities(int32_t portId,
|
||||
std::vector<uint8_t>* _aidl_return) {
|
||||
if (portId <= mTotalPorts && portId >= 1) {
|
||||
*_aidl_return = mCapabilities[portId];
|
||||
} else {
|
||||
return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus EArcMock::setCallback(const std::shared_ptr<IEArcCallback>& callback) {
|
||||
if (mCallback != nullptr) {
|
||||
mCallback = nullptr;
|
||||
}
|
||||
|
||||
if (callback != nullptr) {
|
||||
mCallback = callback;
|
||||
AIBinder_linkToDeath(this->asBinder().get(), mDeathRecipient.get(), 0 /* cookie */);
|
||||
}
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus EArcMock::reportCapabilities(const std::vector<uint8_t> capabilities,
|
||||
int32_t portId) {
|
||||
if (mCallback != nullptr) {
|
||||
mCallback->onCapabilitiesReported(capabilities, portId);
|
||||
return ScopedAStatus::ok();
|
||||
} else {
|
||||
return ScopedAStatus::fromExceptionCode(EX_NULL_POINTER);
|
||||
}
|
||||
}
|
||||
|
||||
ScopedAStatus EArcMock::changeState(const IEArcStatus status, int32_t portId) {
|
||||
if (mCallback != nullptr) {
|
||||
mCallback->onStateChange(status, portId);
|
||||
return ScopedAStatus::ok();
|
||||
} else {
|
||||
return ScopedAStatus::fromExceptionCode(EX_NULL_POINTER);
|
||||
}
|
||||
}
|
||||
|
||||
EArcMock::EArcMock() {
|
||||
ALOGE("[halimp_aidl] Opening a virtual eARC HAL for testing and virtual machine.");
|
||||
mCallback = nullptr;
|
||||
mCapabilities.resize(mTotalPorts);
|
||||
mPortStatus.resize(mTotalPorts);
|
||||
mPortStatus[0] = IEArcStatus::STATUS_IDLE;
|
||||
mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied));
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace earc
|
||||
} // namespace tv
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
74
tv/earc/aidl/default/EArcMock.h
Normal file
74
tv/earc/aidl/default/EArcMock.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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/earc/BnEArc.h>
|
||||
#include <aidl/android/hardware/tv/earc/Result.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace tv {
|
||||
namespace earc {
|
||||
namespace implementation {
|
||||
|
||||
using ::aidl::android::hardware::tv::earc::BnEArc;
|
||||
using ::aidl::android::hardware::tv::earc::IEArc;
|
||||
using ::aidl::android::hardware::tv::earc::IEArcCallback;
|
||||
using ::aidl::android::hardware::tv::earc::IEArcStatus;
|
||||
using ::aidl::android::hardware::tv::earc::Result;
|
||||
|
||||
struct EArcMock : public BnEArc {
|
||||
EArcMock();
|
||||
|
||||
::ndk::ScopedAStatus setEArcEnabled(bool in_enabled) override;
|
||||
::ndk::ScopedAStatus isEArcEnabled(bool* _aidl_return) override;
|
||||
::ndk::ScopedAStatus setCallback(const std::shared_ptr<IEArcCallback>& in_callback) override;
|
||||
::ndk::ScopedAStatus getState(int32_t in_portId, IEArcStatus* _aidl_return) override;
|
||||
::ndk::ScopedAStatus getLastReportedAudioCapabilities(
|
||||
int32_t in_portId, std::vector<uint8_t>* _aidl_return) override;
|
||||
::ndk::ScopedAStatus reportCapabilities(const std::vector<uint8_t> capabilities,
|
||||
int32_t portId);
|
||||
::ndk::ScopedAStatus changeState(const IEArcStatus status, int32_t portId);
|
||||
|
||||
private:
|
||||
static void* __threadLoop(void* data);
|
||||
void threadLoop();
|
||||
|
||||
private:
|
||||
static void serviceDied(void* cookie);
|
||||
std::shared_ptr<IEArcCallback> mCallback;
|
||||
|
||||
// Variables for the virtual EARC hal impl
|
||||
std::vector<std::vector<uint8_t>> mCapabilities;
|
||||
std::vector<IEArcStatus> mPortStatus;
|
||||
bool mEArcEnabled = true;
|
||||
|
||||
// Port configuration
|
||||
int mTotalPorts = 1;
|
||||
|
||||
// Testing variables
|
||||
pthread_t mThreadId = 0;
|
||||
|
||||
::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
|
||||
};
|
||||
} // namespace implementation
|
||||
} // namespace earc
|
||||
} // Namespace tv
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
5
tv/earc/aidl/default/android.hardware.tv.earc-service.rc
Normal file
5
tv/earc/aidl/default/android.hardware.tv.earc-service.rc
Normal file
@@ -0,0 +1,5 @@
|
||||
service vendor.earc-default /vendor/bin/hw/android.hardware.tv.earc-service
|
||||
interface aidl android.hardware.tv.earc.IEArc/default
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
10
tv/earc/aidl/default/android.hardware.tv.earc-service.xml
Normal file
10
tv/earc/aidl/default/android.hardware.tv.earc-service.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.tv.earc</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IEArc</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
30
tv/earc/aidl/default/fuzzer.cpp
Normal file
30
tv/earc/aidl/default/fuzzer.cpp
Normal file
@@ -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 <EArcMock.h>
|
||||
#include <fuzzbinder/libbinder_ndk_driver.h>
|
||||
#include <fuzzer/FuzzedDataProvider.h>
|
||||
|
||||
using android::fuzzService;
|
||||
using android::hardware::tv::earc::implementation::EArcMock;
|
||||
using ndk::SharedRefBase;
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
auto earcAidl = SharedRefBase::make<EArcMock>();
|
||||
|
||||
fuzzService(earcAidl->asBinder().get(), FuzzedDataProvider(data, size));
|
||||
|
||||
return 0;
|
||||
}
|
||||
40
tv/earc/aidl/default/serviceMock.cpp
Normal file
40
tv/earc/aidl/default/serviceMock.cpp
Normal file
@@ -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.earc-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 "EArcMock.h"
|
||||
|
||||
using android::hardware::tv::earc::implementation::EArcMock;
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(1);
|
||||
ABinderProcess_startThreadPool();
|
||||
|
||||
std::shared_ptr<EArcMock> earcAidl = ndk::SharedRefBase::make<EArcMock>();
|
||||
const std::string instance = std::string() + EArcMock::descriptor + "/default";
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(earcAidl->asBinder().get(), instance.c_str());
|
||||
CHECK_EQ(status, STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return 0;
|
||||
}
|
||||
37
tv/earc/aidl/vts/functional/Android.bp
Normal file
37
tv/earc/aidl/vts/functional/Android.bp
Normal file
@@ -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: "VtsHalTvEArcAidlTargetTest",
|
||||
defaults: [
|
||||
"VtsHalTargetTestDefaults",
|
||||
"use_libaidlvintf_gtest_helper_static",
|
||||
],
|
||||
srcs: ["VtsHalTvEArcAidlTargetTest.cpp"],
|
||||
static_libs: [
|
||||
"android.hardware.tv.earc-V1-ndk",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbinder_ndk",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
disable_framework: true,
|
||||
}
|
||||
100
tv/earc/aidl/vts/functional/VtsHalTvEArcAidlTargetTest.cpp
Normal file
100
tv/earc/aidl/vts/functional/VtsHalTvEArcAidlTargetTest.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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 "EArc_hal_test"
|
||||
|
||||
#include <aidl/Gtest.h>
|
||||
#include <aidl/Vintf.h>
|
||||
#include <aidl/android/hardware/tv/earc/BnEArcCallback.h>
|
||||
#include <aidl/android/hardware/tv/earc/IEArc.h>
|
||||
#include <aidl/android/hardware/tv/earc/IEArcStatus.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::earc::BnEArcCallback;
|
||||
using ::aidl::android::hardware::tv::earc::IEArc;
|
||||
using ::aidl::android::hardware::tv::earc::IEArcCallback;
|
||||
using ::aidl::android::hardware::tv::earc::IEArcStatus;
|
||||
using ::ndk::SpAIBinder;
|
||||
|
||||
// The main test class for TV EARC HAL.
|
||||
class EArcTest : public ::testing::TestWithParam<std::string> {
|
||||
static void serviceDied(void* /* cookie */) { ALOGE("VtsHalTvCecAidlTargetTest died"); }
|
||||
|
||||
public:
|
||||
void SetUp() override {
|
||||
eArc = IEArc::fromBinder(SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
|
||||
ASSERT_NE(eArc, nullptr);
|
||||
ALOGI("%s: getService() for eArc is %s", __func__, eArc->isRemote() ? "remote" : "local");
|
||||
|
||||
eArcCallback = ::ndk::SharedRefBase::make<EArcCallback>();
|
||||
ASSERT_NE(eArcCallback, nullptr);
|
||||
eArcDeathRecipient =
|
||||
ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(&serviceDied));
|
||||
ASSERT_EQ(AIBinder_linkToDeath(eArc->asBinder().get(), eArcDeathRecipient.get(), 0),
|
||||
STATUS_OK);
|
||||
}
|
||||
|
||||
class EArcCallback : public BnEArcCallback {
|
||||
public:
|
||||
::ndk::ScopedAStatus onStateChange(IEArcStatus connected __unused,
|
||||
int32_t portId __unused) {
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
};
|
||||
::ndk::ScopedAStatus onCapabilitiesReported(
|
||||
const std::vector<uint8_t>& capabilities __unused, int32_t portId __unused) {
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
};
|
||||
};
|
||||
|
||||
std::shared_ptr<IEArc> eArc;
|
||||
std::shared_ptr<IEArcCallback> eArcCallback;
|
||||
::ndk::ScopedAIBinder_DeathRecipient eArcDeathRecipient;
|
||||
};
|
||||
|
||||
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EArcTest);
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, EArcTest,
|
||||
testing::ValuesIn(android::getAidlHalInstanceNames(IEArc::descriptor)),
|
||||
android::PrintInstanceNameToString);
|
||||
|
||||
TEST_P(EArcTest, setGetEArcEnabled) {
|
||||
bool initial_state;
|
||||
bool changed_state;
|
||||
ASSERT_TRUE(eArc->isEArcEnabled(&initial_state).isOk());
|
||||
ASSERT_TRUE(eArc->setEArcEnabled(!initial_state).isOk());
|
||||
ASSERT_TRUE(eArc->isEArcEnabled(&changed_state).isOk());
|
||||
ASSERT_TRUE(initial_state != changed_state);
|
||||
ASSERT_TRUE(eArc->setEArcEnabled(initial_state).isOk());
|
||||
}
|
||||
|
||||
TEST_P(EArcTest, SetCallback) {
|
||||
ASSERT_TRUE(eArc->setCallback(eArcCallback).isOk());
|
||||
}
|
||||
|
||||
TEST_P(EArcTest, GetState) {
|
||||
IEArcStatus connectionStatus;
|
||||
ASSERT_TRUE(eArc->getState(1, &connectionStatus).isOk());
|
||||
}
|
||||
|
||||
TEST_P(EArcTest, GetLastReportedAudioCapabilities) {
|
||||
std::vector<uint8_t> capabilities;
|
||||
ASSERT_TRUE(eArc->getLastReportedAudioCapabilities(1, &capabilities).isOk());
|
||||
}
|
||||
Reference in New Issue
Block a user