Merge "Convert from HIDL mapper to libui GraphicBufferMapper" into main
diff --git a/audio/aidl/default/EffectThread.cpp b/audio/aidl/default/EffectThread.cpp
index cd2ba53..47ba9f4 100644
--- a/audio/aidl/default/EffectThread.cpp
+++ b/audio/aidl/default/EffectThread.cpp
@@ -48,6 +48,8 @@
mPriority = priority;
{
std::lock_guard lg(mThreadMutex);
+ mStop = true;
+ mExit = false;
mThreadContext = std::move(context);
auto statusMQ = mThreadContext->getStatusFmq();
EventFlag* efGroup = nullptr;
diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp
index 3117134..819b3c5 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -1277,6 +1277,12 @@
mmapSources.insert(port.id);
}
}
+ if (mmapSources.empty() && mmapSinks.empty()) {
+ AudioMMapPolicyInfo never;
+ never.mmapPolicy = AudioMMapPolicy::NEVER;
+ _aidl_return->push_back(never);
+ return ndk::ScopedAStatus::ok();
+ }
for (const auto& route : getConfig().routes) {
if (mmapSinks.count(route.sinkPortId) != 0) {
// The sink is a mix port, add the sources if they are device ports.
diff --git a/audio/aidl/default/alsa/ModuleAlsa.cpp b/audio/aidl/default/alsa/ModuleAlsa.cpp
index 8e75d56..8512631 100644
--- a/audio/aidl/default/alsa/ModuleAlsa.cpp
+++ b/audio/aidl/default/alsa/ModuleAlsa.cpp
@@ -39,13 +39,14 @@
if (!deviceProfile.has_value()) {
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
- auto profile = alsa::readAlsaDeviceInfo(*deviceProfile);
- if (!profile.has_value()) {
+ auto proxy = alsa::readAlsaDeviceInfo(*deviceProfile);
+ if (proxy.get() == nullptr) {
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
- std::vector<AudioChannelLayout> channels = alsa::getChannelMasksFromProfile(&profile.value());
- std::vector<int> sampleRates = alsa::getSampleRatesFromProfile(&profile.value());
+ alsa_device_profile* profile = proxy.getProfile();
+ std::vector<AudioChannelLayout> channels = alsa::getChannelMasksFromProfile(profile);
+ std::vector<int> sampleRates = alsa::getSampleRatesFromProfile(profile);
for (size_t i = 0; i < std::min(MAX_PROFILE_FORMATS, AUDIO_PORT_MAX_AUDIO_PROFILES) &&
profile->formats[i] != PCM_FORMAT_INVALID;
diff --git a/audio/aidl/default/alsa/StreamAlsa.cpp b/audio/aidl/default/alsa/StreamAlsa.cpp
index 0605d6f..403b94b 100644
--- a/audio/aidl/default/alsa/StreamAlsa.cpp
+++ b/audio/aidl/default/alsa/StreamAlsa.cpp
@@ -83,7 +83,7 @@
proxy = alsa::openProxyForAttachedDevice(
device, const_cast<struct pcm_config*>(&mConfig.value()), mBufferSizeFrames);
}
- if (!proxy) {
+ if (proxy.get() == nullptr) {
return ::android::NO_INIT;
}
alsaDeviceProxies.push_back(std::move(proxy));
diff --git a/audio/aidl/default/alsa/Utils.cpp b/audio/aidl/default/alsa/Utils.cpp
index 9dcd024..c08836c 100644
--- a/audio/aidl/default/alsa/Utils.cpp
+++ b/audio/aidl/default/alsa/Utils.cpp
@@ -37,6 +37,23 @@
namespace aidl::android::hardware::audio::core::alsa {
+DeviceProxy::DeviceProxy() : mProfile(nullptr), mProxy(nullptr, alsaProxyDeleter) {}
+
+DeviceProxy::DeviceProxy(const DeviceProfile& deviceProfile)
+ : mProfile(new alsa_device_profile), mProxy(new alsa_device_proxy, alsaProxyDeleter) {
+ profile_init(mProfile.get(), deviceProfile.direction);
+ mProfile->card = deviceProfile.card;
+ mProfile->device = deviceProfile.device;
+ memset(mProxy.get(), 0, sizeof(alsa_device_proxy));
+}
+
+void DeviceProxy::alsaProxyDeleter(alsa_device_proxy* proxy) {
+ if (proxy != nullptr) {
+ proxy_close(proxy);
+ delete proxy;
+ }
+}
+
namespace {
using AudioChannelCountToMaskMap = std::map<unsigned int, AudioChannelLayout>;
@@ -261,39 +278,24 @@
return sampleRates;
}
-DeviceProxy makeDeviceProxy() {
- DeviceProxy proxy(new alsa_device_proxy, [](alsa_device_proxy* proxy) {
- if (proxy != nullptr) {
- proxy_close(proxy);
- delete proxy;
- }
- });
- memset(proxy.get(), 0, sizeof(alsa_device_proxy));
- return proxy;
-}
-
DeviceProxy openProxyForAttachedDevice(const DeviceProfile& deviceProfile,
struct pcm_config* pcmConfig, size_t bufferFrameCount) {
if (deviceProfile.isExternal) {
LOG(FATAL) << __func__ << ": called for an external device, address=" << deviceProfile;
}
- alsa_device_profile profile;
- profile_init(&profile, deviceProfile.direction);
- profile.card = deviceProfile.card;
- profile.device = deviceProfile.device;
- if (!profile_fill_builtin_device_info(&profile, pcmConfig, bufferFrameCount)) {
+ DeviceProxy proxy(deviceProfile);
+ if (!profile_fill_builtin_device_info(proxy.getProfile(), pcmConfig, bufferFrameCount)) {
LOG(FATAL) << __func__ << ": failed to init for built-in device, address=" << deviceProfile;
}
- auto proxy = makeDeviceProxy();
- if (int err = proxy_prepare_from_default_config(proxy.get(), &profile); err != 0) {
+ if (int err = proxy_prepare_from_default_config(proxy.get(), proxy.getProfile()); err != 0) {
LOG(FATAL) << __func__ << ": fail to prepare for device address=" << deviceProfile
<< " error=" << err;
- return nullptr;
+ return DeviceProxy();
}
if (int err = proxy_open(proxy.get()); err != 0) {
LOG(ERROR) << __func__ << ": failed to open device, address=" << deviceProfile
<< " error=" << err;
- return nullptr;
+ return DeviceProxy();
}
return proxy;
}
@@ -303,42 +305,36 @@
if (!deviceProfile.isExternal) {
LOG(FATAL) << __func__ << ": called for an attached device, address=" << deviceProfile;
}
- auto profile = readAlsaDeviceInfo(deviceProfile);
- if (!profile.has_value()) {
- LOG(ERROR) << __func__ << ": unable to read device info, device address=" << deviceProfile;
- return nullptr;
+ auto proxy = readAlsaDeviceInfo(deviceProfile);
+ if (proxy.get() == nullptr) {
+ return proxy;
}
- auto proxy = makeDeviceProxy();
- if (int err = proxy_prepare(proxy.get(), &profile.value(), pcmConfig, requireExactMatch);
+ if (int err = proxy_prepare(proxy.get(), proxy.getProfile(), pcmConfig, requireExactMatch);
err != 0) {
LOG(ERROR) << __func__ << ": fail to prepare for device address=" << deviceProfile
<< " error=" << err;
- return nullptr;
+ return DeviceProxy();
}
if (int err = proxy_open(proxy.get()); err != 0) {
LOG(ERROR) << __func__ << ": failed to open device, address=" << deviceProfile
<< " error=" << err;
- return nullptr;
+ return DeviceProxy();
}
return proxy;
}
-std::optional<alsa_device_profile> readAlsaDeviceInfo(const DeviceProfile& deviceProfile) {
- alsa_device_profile profile;
- profile_init(&profile, deviceProfile.direction);
- profile.card = deviceProfile.card;
- profile.device = deviceProfile.device;
- if (!profile_read_device_info(&profile)) {
- LOG(ERROR) << __func__ << ": failed to read device info, card=" << profile.card
- << ", device=" << profile.device;
- return std::nullopt;
+DeviceProxy readAlsaDeviceInfo(const DeviceProfile& deviceProfile) {
+ DeviceProxy proxy(deviceProfile);
+ if (!profile_read_device_info(proxy.getProfile())) {
+ LOG(ERROR) << __func__ << ": unable to read device info, device address=" << deviceProfile;
+ return DeviceProxy();
}
- return profile;
+ return proxy;
}
void resetTransferredFrames(DeviceProxy& proxy, uint64_t frames) {
- if (proxy != nullptr) {
- proxy->transferred = frames;
+ if (proxy.get() != nullptr) {
+ proxy.get()->transferred = frames;
}
}
diff --git a/audio/aidl/default/alsa/Utils.h b/audio/aidl/default/alsa/Utils.h
index 37414b3..980f685 100644
--- a/audio/aidl/default/alsa/Utils.h
+++ b/audio/aidl/default/alsa/Utils.h
@@ -43,8 +43,21 @@
bool isExternal;
};
std::ostream& operator<<(std::ostream& os, const DeviceProfile& device);
-using DeviceProxyDeleter = std::function<void(alsa_device_proxy*)>;
-using DeviceProxy = std::unique_ptr<alsa_device_proxy, DeviceProxyDeleter>;
+
+class DeviceProxy {
+ public:
+ DeviceProxy(); // Constructs a "null" proxy.
+ explicit DeviceProxy(const DeviceProfile& deviceProfile);
+ alsa_device_profile* getProfile() { return mProfile.get(); }
+ alsa_device_proxy* get() { return mProxy.get(); }
+
+ private:
+ static void alsaProxyDeleter(alsa_device_proxy* proxy);
+ using AlsaProxy = std::unique_ptr<alsa_device_proxy, decltype(alsaProxyDeleter)*>;
+
+ std::unique_ptr<alsa_device_profile> mProfile;
+ AlsaProxy mProxy;
+};
::aidl::android::media::audio::common::AudioChannelLayout getChannelLayoutMaskFromChannelCount(
unsigned int channelCount, int isInput);
@@ -60,12 +73,11 @@
const ::aidl::android::media::audio::common::AudioPort& audioPort);
std::optional<struct pcm_config> getPcmConfig(const StreamContext& context, bool isInput);
std::vector<int> getSampleRatesFromProfile(const alsa_device_profile* profile);
-DeviceProxy makeDeviceProxy();
DeviceProxy openProxyForAttachedDevice(const DeviceProfile& deviceProfile,
struct pcm_config* pcmConfig, size_t bufferFrameCount);
DeviceProxy openProxyForExternalDevice(const DeviceProfile& deviceProfile,
struct pcm_config* pcmConfig, bool requireExactMatch);
-std::optional<alsa_device_profile> readAlsaDeviceInfo(const DeviceProfile& deviceProfile);
+DeviceProxy readAlsaDeviceInfo(const DeviceProfile& deviceProfile);
void resetTransferredFrames(DeviceProxy& proxy, uint64_t frames);
::aidl::android::media::audio::common::AudioFormatDescription
diff --git a/audio/aidl/vts/TestUtils.h b/audio/aidl/vts/TestUtils.h
index 10c2fc6..b559669 100644
--- a/audio/aidl/vts/TestUtils.h
+++ b/audio/aidl/vts/TestUtils.h
@@ -78,9 +78,9 @@
EXPECT_PRED_FORMAT2(::android::hardware::audio::common::testing::detail::assertResult, \
expected, ret)
-#define SKIP_TEST_IF_DATA_UNSUPPORTED(flags) \
- ({ \
- if ((flags).hwAcceleratorMode == Flags::HardwareAccelerator::TUNNEL || (flags).bypass) { \
- GTEST_SKIP() << "Skip data path for offload"; \
- } \
+#define SKIP_TEST_IF_DATA_UNSUPPORTED(flags) \
+ ({ \
+ if ((flags).hwAcceleratorMode == Flags::HardwareAccelerator::TUNNEL || (flags).bypass) { \
+ GTEST_SKIP() << "Skip data path for offload"; \
+ } \
})
\ No newline at end of file
diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
index ccf7cfc..a4670db 100644
--- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
@@ -87,6 +87,7 @@
using aidl::android::media::audio::common::AudioFormatType;
using aidl::android::media::audio::common::AudioIoFlags;
using aidl::android::media::audio::common::AudioLatencyMode;
+using aidl::android::media::audio::common::AudioMMapPolicy;
using aidl::android::media::audio::common::AudioMMapPolicyInfo;
using aidl::android::media::audio::common::AudioMMapPolicyType;
using aidl::android::media::audio::common::AudioMode;
@@ -2133,7 +2134,13 @@
std::vector<AudioMMapPolicyInfo> policyInfos;
EXPECT_IS_OK(module->getMmapPolicyInfos(mmapPolicyType, &policyInfos))
<< toString(mmapPolicyType);
- EXPECT_EQ(isMmapSupported, !policyInfos.empty());
+ const bool isMMapSupportedByPolicyInfos =
+ std::find_if(policyInfos.begin(), policyInfos.end(), [](const auto& info) {
+ return info.mmapPolicy == AudioMMapPolicy::AUTO ||
+ info.mmapPolicy == AudioMMapPolicy::ALWAYS;
+ }) != policyInfos.end();
+ EXPECT_EQ(isMmapSupported, isMMapSupportedByPolicyInfos)
+ << ::android::internal::ToString(policyInfos);
}
}
@@ -4172,58 +4179,32 @@
class WithRemoteSubmix {
public:
WithRemoteSubmix() = default;
- WithRemoteSubmix(AudioDeviceAddress address) : mAddress(address) {}
+ explicit WithRemoteSubmix(AudioDeviceAddress address) : mAddress(address) {}
WithRemoteSubmix(const WithRemoteSubmix&) = delete;
WithRemoteSubmix& operator=(const WithRemoteSubmix&) = delete;
- std::optional<AudioPort> getAudioPort() {
+ static std::optional<AudioPort> getRemoteSubmixAudioPort(
+ ModuleConfig* moduleConfig,
+ const std::optional<AudioDeviceAddress>& address = std::nullopt) {
AudioDeviceType deviceType = IOTraits<Stream>::is_input ? AudioDeviceType::IN_SUBMIX
: AudioDeviceType::OUT_SUBMIX;
- auto ports = mModuleConfig->getAudioPortsForDeviceTypes(
+ auto ports = moduleConfig->getAudioPortsForDeviceTypes(
std::vector<AudioDeviceType>{deviceType},
AudioDeviceDescription::CONNECTION_VIRTUAL);
- if (!ports.empty()) return ports.front();
- return {};
- }
- /* Connect remote submix external device */
- void SetUpPortConnection() {
- auto port = getAudioPort();
- ASSERT_TRUE(port.has_value()) << "Device AudioPort for remote submix not found";
- if (mAddress.has_value()) {
- port.value().ext.template get<AudioPortExt::Tag::device>().device.address =
- mAddress.value();
+ if (ports.empty()) return {};
+ AudioPort port = ports.front();
+ if (address) {
+ port.ext.template get<AudioPortExt::Tag::device>().device.address = address.value();
} else {
- port = GenerateUniqueDeviceAddress(port.value());
+ port = GenerateUniqueDeviceAddress(port);
}
- mConnectedPort = std::make_unique<WithDevicePortConnectedState>(port.value());
- ASSERT_NO_FATAL_FAILURE(mConnectedPort->SetUp(mModule, mModuleConfig));
+ return port;
}
- AudioDeviceAddress getAudioDeviceAddress() {
- if (!mAddress.has_value()) {
- mAddress = mConnectedPort->get()
- .ext.template get<AudioPortExt::Tag::device>()
- .device.address;
- }
- return mAddress.value();
- }
- /* Get mix port config for stream and setup patch for it. */
- void SetupPatch() {
- const auto portConfig =
- mModuleConfig->getSingleConfigForMixPort(IOTraits<Stream>::is_input);
- if (!portConfig.has_value()) {
- LOG(DEBUG) << __func__ << ": portConfig not found";
- mSkipTest = true;
- return;
- }
- auto devicePortConfig = mModuleConfig->getSingleConfigForDevicePort(mConnectedPort->get());
- mPatch = std::make_unique<WithAudioPatch>(IOTraits<Stream>::is_input, portConfig.value(),
- devicePortConfig);
- ASSERT_NO_FATAL_FAILURE(mPatch->SetUp(mModule));
- }
- void SetUp(IModule* module, ModuleConfig* moduleConfig) {
+ std::optional<AudioDeviceAddress> getAudioDeviceAddress() const { return mAddress; }
+ void SetUp(IModule* module, ModuleConfig* moduleConfig, const AudioPort& connectedPort) {
mModule = module;
mModuleConfig = moduleConfig;
- ASSERT_NO_FATAL_FAILURE(SetUpPortConnection());
- ASSERT_NO_FATAL_FAILURE(SetupPatch());
+
+ ASSERT_NO_FATAL_FAILURE(SetupPatch(connectedPort));
if (!mSkipTest) {
// open stream
mStream = std::make_unique<WithStream<Stream>>(
@@ -4231,6 +4212,11 @@
ASSERT_NO_FATAL_FAILURE(
mStream->SetUp(mModule, AudioCoreModuleBase::kDefaultBufferSizeFrames));
}
+ mAddress = connectedPort.ext.template get<AudioPortExt::Tag::device>().device.address;
+ }
+ void SetUp(IModule* module, ModuleConfig* moduleConfig) {
+ ASSERT_NO_FATAL_FAILURE(SetUpPortConnection(module, moduleConfig));
+ SetUp(module, moduleConfig, mConnectedPort->get());
}
void sendBurstCommands() {
const StreamContext* context = mStream->getContext();
@@ -4248,9 +4234,31 @@
}
EXPECT_FALSE(driver.hasRetrogradeObservablePosition());
}
- bool skipTest() { return mSkipTest; }
+ bool skipTest() const { return mSkipTest; }
private:
+ /* Connect remote submix external device */
+ void SetUpPortConnection(IModule* module, ModuleConfig* moduleConfig) {
+ auto port = getRemoteSubmixAudioPort(moduleConfig, mAddress);
+ ASSERT_TRUE(port.has_value()) << "Device AudioPort for remote submix not found";
+ mConnectedPort = std::make_unique<WithDevicePortConnectedState>(port.value());
+ ASSERT_NO_FATAL_FAILURE(mConnectedPort->SetUp(module, moduleConfig));
+ }
+ /* Get mix port config for stream and setup patch for it. */
+ void SetupPatch(const AudioPort& connectedPort) {
+ const auto portConfig =
+ mModuleConfig->getSingleConfigForMixPort(IOTraits<Stream>::is_input);
+ if (!portConfig.has_value()) {
+ LOG(DEBUG) << __func__ << ": portConfig not found";
+ mSkipTest = true;
+ return;
+ }
+ auto devicePortConfig = mModuleConfig->getSingleConfigForDevicePort(connectedPort);
+ mPatch = std::make_unique<WithAudioPatch>(IOTraits<Stream>::is_input, portConfig.value(),
+ devicePortConfig);
+ ASSERT_NO_FATAL_FAILURE(mPatch->SetUp(mModule));
+ }
+
bool mSkipTest = false;
IModule* mModule = nullptr;
ModuleConfig* mModuleConfig = nullptr;
@@ -4288,9 +4296,11 @@
if (streamOut.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
}
+ auto address = streamOut.getAudioDeviceAddress();
+ ASSERT_TRUE(address.has_value());
// open input stream
- WithRemoteSubmix<IStreamIn> streamIn(streamOut.getAudioDeviceAddress());
+ WithRemoteSubmix<IStreamIn> streamIn(address.value());
ASSERT_NO_FATAL_FAILURE(streamIn.SetUp(module.get(), moduleConfig.get()));
if (streamIn.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
@@ -4307,9 +4317,11 @@
if (streamOut.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
}
+ auto address = streamOut.getAudioDeviceAddress();
+ ASSERT_TRUE(address.has_value());
// open input stream
- WithRemoteSubmix<IStreamIn> streamIn(streamOut.getAudioDeviceAddress());
+ WithRemoteSubmix<IStreamIn> streamIn(address.value());
ASSERT_NO_FATAL_FAILURE(streamIn.SetUp(module.get(), moduleConfig.get()));
if (streamIn.skipTest()) {
GTEST_SKIP() << "No mix port for attached devices";
@@ -4321,6 +4333,43 @@
ASSERT_NO_FATAL_FAILURE(streamIn.sendBurstCommands());
}
+TEST_P(AudioModuleRemoteSubmix, OpenInputMultipleTimes) {
+ // open output stream
+ WithRemoteSubmix<IStreamOut> streamOut;
+ ASSERT_NO_FATAL_FAILURE(streamOut.SetUp(module.get(), moduleConfig.get()));
+ if (streamOut.skipTest()) {
+ GTEST_SKIP() << "No mix port for attached devices";
+ }
+ auto address = streamOut.getAudioDeviceAddress();
+ ASSERT_TRUE(address.has_value());
+
+ // connect remote submix input device port
+ auto port = WithRemoteSubmix<IStreamIn>::getRemoteSubmixAudioPort(moduleConfig.get(),
+ address.value());
+ ASSERT_TRUE(port.has_value()) << "Device AudioPort for remote submix not found";
+ WithDevicePortConnectedState connectedInputPort(port.value());
+ ASSERT_NO_FATAL_FAILURE(connectedInputPort.SetUp(module.get(), moduleConfig.get()));
+
+ // open input streams
+ const int streamInCount = 3;
+ std::vector<std::unique_ptr<WithRemoteSubmix<IStreamIn>>> streamIns(streamInCount);
+ for (int i = 0; i < streamInCount; i++) {
+ streamIns[i] = std::make_unique<WithRemoteSubmix<IStreamIn>>();
+ ASSERT_NO_FATAL_FAILURE(
+ streamIns[i]->SetUp(module.get(), moduleConfig.get(), connectedInputPort.get()));
+ if (streamIns[i]->skipTest()) {
+ GTEST_SKIP() << "No mix port for attached devices";
+ }
+ }
+ // write something to output stream
+ ASSERT_NO_FATAL_FAILURE(streamOut.sendBurstCommands());
+
+ // read from input streams
+ for (int i = 0; i < streamInCount; i++) {
+ ASSERT_NO_FATAL_FAILURE(streamIns[i]->sendBurstCommands());
+ }
+}
+
INSTANTIATE_TEST_SUITE_P(AudioModuleRemoteSubmixTest, AudioModuleRemoteSubmix,
::testing::ValuesIn(getRemoteSubmixModuleInstance()));
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioModuleRemoteSubmix);
diff --git a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
index 3011a5e..1876756 100644
--- a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
@@ -42,11 +42,11 @@
using aidl::android::hardware::audio::effect::CommandId;
using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::Flags;
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::State;
-using aidl::android::hardware::audio::effect::Flags;
using aidl::android::media::audio::common::AudioDeviceDescription;
using aidl::android::media::audio::common::AudioDeviceType;
using aidl::android::media::audio::common::AudioMode;
@@ -87,11 +87,11 @@
};
class AudioEffectDataPathTest : public AudioEffectTest {
- public:
- void SetUp() override {
- AudioEffectTest::SetUp();
- SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
- }
+ public:
+ void SetUp() override {
+ AudioEffectTest::SetUp();
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
+ }
};
TEST_P(AudioEffectTest, SetupAndTearDown) {
@@ -504,6 +504,11 @@
// Set and get AudioDeviceDescription in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterDeviceDescription) {
+ if (!mDescriptor.common.flags.deviceIndication) {
+ GTEST_SKIP() << "Skipping test as effect does not support deviceIndication"
+ << mDescriptor.common.flags.toString();
+ }
+
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
@@ -527,6 +532,11 @@
// Set and get AudioMode in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterAudioMode) {
+ if (!mDescriptor.common.flags.audioModeIndication) {
+ GTEST_SKIP() << "Skipping test as effect does not support audioModeIndication"
+ << mDescriptor.common.flags.toString();
+ }
+
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
@@ -547,6 +557,11 @@
// Set and get AudioSource in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterAudioSource) {
+ if (!mDescriptor.common.flags.audioSourceIndication) {
+ GTEST_SKIP() << "Skipping test as effect does not support audioSourceIndication"
+ << mDescriptor.common.flags.toString();
+ }
+
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
@@ -567,6 +582,11 @@
// Set and get VolumeStereo in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterVolume) {
+ if (mDescriptor.common.flags.volume == Flags::Volume::NONE) {
+ GTEST_SKIP() << "Skipping test as effect does not support volume"
+ << mDescriptor.common.flags.toString();
+ }
+
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
diff --git a/automotive/can/1.0/default/libc++fs/include/automotive/filesystem b/automotive/can/1.0/default/libc++fs/include/automotive/filesystem
index 660ad09..bd3dda5 100644
--- a/automotive/can/1.0/default/libc++fs/include/automotive/filesystem
+++ b/automotive/can/1.0/default/libc++fs/include/automotive/filesystem
@@ -9,6 +9,18 @@
//===----------------------------------------------------------------------===//
#ifndef _LIBAUTO_FILESYSTEM
#define _LIBAUTO_FILESYSTEM
+
+// TODO(152067309): Remove this once the libc++ upgrade is complete.
+#include <__config>
+#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION > 8000
+
+#include <filesystem>
+namespace android::hardware::automotive {
+namespace filesystem = std::filesystem;
+}
+
+#else
+
/*
filesystem synopsis
@@ -2696,4 +2708,6 @@
_LIBCPP_POP_MACROS
+#endif // defined(_LIBCPP_VERSION) && _LIBCPP_VERSION > 8000
+
#endif // _LIBAUTO_FILESYSTEM
diff --git a/automotive/can/1.0/default/libc++fs/src/filesystem/directory_iterator.cpp b/automotive/can/1.0/default/libc++fs/src/filesystem/directory_iterator.cpp
index 37c863b..0dbf492 100644
--- a/automotive/can/1.0/default/libc++fs/src/filesystem/directory_iterator.cpp
+++ b/automotive/can/1.0/default/libc++fs/src/filesystem/directory_iterator.cpp
@@ -6,9 +6,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
+// TODO(152067309): Remove this once the libc++ upgrade is complete.
+#include <__config>
+#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 8000
+
/* clang-format off */
#include "automotive/filesystem"
#include <__config>
+
#if defined(_LIBCPP_WIN32API)
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
@@ -395,3 +401,5 @@
} // namespace android::hardware::automotive::filesystem
/* clang-format on */
+
+#endif // defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 8000
diff --git a/automotive/can/1.0/default/libc++fs/src/filesystem/operations.cpp b/automotive/can/1.0/default/libc++fs/src/filesystem/operations.cpp
index 404c0bd..6a76bdc 100644
--- a/automotive/can/1.0/default/libc++fs/src/filesystem/operations.cpp
+++ b/automotive/can/1.0/default/libc++fs/src/filesystem/operations.cpp
@@ -6,6 +6,11 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+
+// TODO(152067309): Remove this once the libc++ upgrade is complete.
+#include <__config>
+#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 8000
+
/* clang-format off */
#include "automotive/filesystem"
#include <array>
@@ -1771,3 +1776,5 @@
#endif
} // namespace android::hardware::automotive::filesystem
/* clang-format on */
+
+#endif // defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 8000
diff --git a/automotive/evs/aidl/impl/default/Android.bp b/automotive/evs/aidl/impl/default/Android.bp
index 79ee956..6b638a3 100644
--- a/automotive/evs/aidl/impl/default/Android.bp
+++ b/automotive/evs/aidl/impl/default/Android.bp
@@ -21,45 +21,41 @@
default_applicable_licenses: ["hardware_interfaces_license"],
}
-cc_binary {
- name: "android.hardware.automotive.evs-aidl-default-service",
+cc_defaults {
+ name: "android.hardware.automotive.evs-aidl-default-service-default",
defaults: ["EvsHalDefaults"],
- vintf_fragments: ["manifest_evs-default-service.xml"],
- init_rc: ["evs-default-service.rc"],
- vendor: true,
- relative_install_path: "hw",
- cflags: [
- "-DGL_GLEXT_PROTOTYPES",
- "-DEGL_EGLEXT_PROTOTYPES",
- "-Wall",
- "-Wextra",
- "-Werror",
- "-Wthread-safety",
- ],
- srcs: [
- ":libgui_frame_event_aidl",
- "src/*.cpp",
- ],
shared_libs: [
"android.hardware.graphics.bufferqueue@1.0",
"android.hardware.graphics.bufferqueue@2.0",
"android.hidl.token@1.0-utils",
"libEGL",
"libGLESv2",
- "libbase",
"libbinder_ndk",
"libbufferqueueconverter",
"libcamera_metadata",
"libhardware_legacy",
"libhidlbase",
- "liblog",
"libnativewindow",
"libtinyxml2",
"libui",
- "libutils",
"libyuv",
],
- static_libs: [
+}
+
+cc_library {
+ name: "android.hardware.automotive.evs-aidl-default-service-lib",
+ defaults: ["android.hardware.automotive.evs-aidl-default-service-default"],
+ vendor: true,
+ cflags: [
+ "-DGL_GLEXT_PROTOTYPES",
+ "-DEGL_EGLEXT_PROTOTYPES",
+ ],
+ srcs: [
+ ":libgui_frame_event_aidl",
+ "src/*.cpp",
+ ],
+ exclude_srcs: ["src/service.cpp"],
+ whole_static_libs: [
"android.frameworks.automotive.display-V2-ndk",
"android.hardware.automotive.evs-V2-ndk",
"android.hardware.common-V2-ndk",
@@ -71,6 +67,25 @@
],
local_include_dirs: ["include"],
include_dirs: ["frameworks/native/include/"],
+ export_include_dirs: ["include"],
+}
+
+cc_binary {
+ name: "android.hardware.automotive.evs-aidl-default-service",
+ defaults: ["android.hardware.automotive.evs-aidl-default-service-default"],
+ vintf_fragments: ["manifest_evs-default-service.xml"],
+ init_rc: ["evs-default-service.rc"],
+ vendor: true,
+ relative_install_path: "hw",
+ cflags: [
+ "-DGL_GLEXT_PROTOTYPES",
+ "-DEGL_EGLEXT_PROTOTYPES",
+ ],
+ srcs: ["src/service.cpp"],
+ static_libs: [
+ "android.hardware.automotive.evs-aidl-default-service-lib",
+ ],
+ include_dirs: ["frameworks/native/include/"],
required: ["evs_mock_hal_configuration.xml"],
}
@@ -80,3 +95,31 @@
src: "resources/evs_mock_configuration.xml",
sub_dir: "automotive/evs",
}
+
+cc_test {
+ name: "android.hardware.automotive.evs-aidl-default-service_cam_buffer_test",
+ defaults: ["android.hardware.automotive.evs-aidl-default-service-default"],
+ vendor: true,
+ srcs: ["tests/EvsCameraBufferTest.cpp"],
+ static_libs: [
+ "android.hardware.automotive.evs-aidl-default-service-lib",
+ "libgmock",
+ ],
+ test_suites: [
+ "general-tests",
+ ],
+}
+
+cc_test {
+ name: "android.hardware.automotive.evs-aidl-default-service_cam_state_test",
+ defaults: ["android.hardware.automotive.evs-aidl-default-service-default"],
+ vendor: true,
+ srcs: ["tests/EvsCameraStateTest.cpp"],
+ static_libs: [
+ "android.hardware.automotive.evs-aidl-default-service-lib",
+ "libgmock",
+ ],
+ test_suites: [
+ "general-tests",
+ ],
+}
diff --git a/automotive/evs/aidl/impl/default/include/EvsAllCameras.h b/automotive/evs/aidl/impl/default/include/EvsAllCameras.h
new file mode 100644
index 0000000..a76501d
--- /dev/null
+++ b/automotive/evs/aidl/impl/default/include/EvsAllCameras.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2023 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 "EvsMockCamera.h"
+#include "EvsVideoEmulatedCamera.h"
diff --git a/automotive/evs/aidl/impl/default/include/EvsCamera.h b/automotive/evs/aidl/impl/default/include/EvsCamera.h
new file mode 100644
index 0000000..539d5f6
--- /dev/null
+++ b/automotive/evs/aidl/impl/default/include/EvsCamera.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2023 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 "EvsCameraBase.h"
+
+#include <aidl/android/hardware/automotive/evs/IEvsCameraStream.h>
+#include <cutils/native_handle.h>
+
+#include <cstddef>
+#include <mutex>
+#include <utility>
+#include <vector>
+
+namespace aidl::android::hardware::automotive::evs::implementation {
+
+class EvsCamera : public EvsCameraBase {
+ private:
+ using Base = EvsCameraBase;
+ using Self = EvsCamera;
+
+ public:
+ using Base::Base;
+
+ ~EvsCamera() override;
+
+ // Methods from ::android::hardware::automotive::evs::IEvsCamera follow.
+ ndk::ScopedAStatus doneWithFrame(const std::vector<evs::BufferDesc>& buffers) override;
+
+ ndk::ScopedAStatus importExternalBuffers(const std::vector<evs::BufferDesc>& buffers,
+ int32_t* _aidl_return) override;
+
+ ndk::ScopedAStatus setMaxFramesInFlight(int32_t bufferCount) override;
+
+ ndk::ScopedAStatus startVideoStream(
+ const std::shared_ptr<evs::IEvsCameraStream>& receiver) override;
+
+ ndk::ScopedAStatus stopVideoStream() override;
+
+ ndk::ScopedAStatus pauseVideoStream() override;
+
+ ndk::ScopedAStatus resumeVideoStream() override;
+
+ protected:
+ virtual ::android::status_t allocateOneFrame(buffer_handle_t* handle) = 0;
+
+ virtual void freeOneFrame(const buffer_handle_t handle);
+
+ virtual bool preVideoStreamStart_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck);
+
+ virtual bool startVideoStreamImpl_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) = 0;
+
+ virtual bool postVideoStreamStart_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck);
+
+ virtual bool preVideoStreamStop_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck);
+
+ virtual bool stopVideoStreamImpl_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) = 0;
+
+ virtual bool postVideoStreamStop_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck);
+
+ void shutdown() override;
+
+ void closeAllBuffers_unsafe();
+
+ // Returns (ID, handle) if succeeds. (kInvalidBufferID, nullptr) otherwise.
+ [[nodiscard]] std::pair<std::size_t, buffer_handle_t> useBuffer_unsafe();
+
+ void returnBuffer_unsafe(const std::size_t id);
+
+ bool increaseAvailableFrames_unsafe(const buffer_handle_t handle);
+
+ bool decreaseAvailableFrames_unsafe();
+
+ bool setAvailableFrames_unsafe(const std::size_t bufferCount);
+
+ void swapBufferFrames_unsafe(const std::size_t pos1, const std::size_t pos2);
+
+ struct BufferRecord {
+ BufferRecord() = default;
+ BufferRecord(const BufferRecord&) = default;
+ BufferRecord(BufferRecord&&) = default;
+ BufferRecord& operator=(const BufferRecord&) = default;
+ BufferRecord& operator=(BufferRecord&&) = default;
+ ~BufferRecord() = default;
+
+ explicit BufferRecord(buffer_handle_t h) : handle(h) {}
+
+ buffer_handle_t handle{nullptr};
+ bool inUse{false};
+ };
+
+ enum class StreamState {
+ STOPPED = 0,
+ RUNNING = 1,
+ STOPPING = 2,
+ DEAD = 3,
+ };
+
+ StreamState mStreamState{StreamState::STOPPED};
+
+ std::mutex mMutex;
+
+ // Graphics buffers to transfer images, always in the order of:
+ // In use buffers ... available buffers ... unavailable (unallocated) buffers.
+ std::vector<BufferRecord> mBuffers;
+
+ // Double-mapping between buffer position and ID.
+ std::vector<std::size_t> mBufferPosToId;
+ std::vector<std::size_t> mBufferIdToPos;
+
+ std::size_t mAvailableFrames{0};
+ std::size_t mFramesInUse{0};
+
+ // We use all 1's as a reserved invalid buffer ID.
+ static constexpr std::size_t kInvalidBufferID = ~static_cast<std::size_t>(0);
+
+ public:
+ static bool IsBufferIDValid(const std::size_t bufferId) { return ~bufferId; }
+};
+
+} // namespace aidl::android::hardware::automotive::evs::implementation
diff --git a/automotive/evs/aidl/impl/default/include/EvsMockCamera.h b/automotive/evs/aidl/impl/default/include/EvsMockCamera.h
index c7b9e0f..cd68532 100644
--- a/automotive/evs/aidl/impl/default/include/EvsMockCamera.h
+++ b/automotive/evs/aidl/impl/default/include/EvsMockCamera.h
@@ -17,29 +17,36 @@
#pragma once
#include "ConfigManager.h"
-#include "EvsCameraBase.h"
+#include "EvsCamera.h"
-#include <aidl/android/hardware/automotive/evs/BufferDesc.h>
#include <aidl/android/hardware/automotive/evs/CameraDesc.h>
#include <aidl/android/hardware/automotive/evs/CameraParam.h>
-#include <aidl/android/hardware/automotive/evs/EvsResult.h>
#include <aidl/android/hardware/automotive/evs/IEvsCameraStream.h>
#include <aidl/android/hardware/automotive/evs/IEvsDisplay.h>
#include <aidl/android/hardware/automotive/evs/ParameterRange.h>
#include <aidl/android/hardware/automotive/evs/Stream.h>
-// #include <android-base/result.h>
#include <android/hardware_buffer.h>
#include <ui/GraphicBuffer.h>
-#include <functional>
+#include <cstdint>
+#include <memory>
#include <thread>
+#include <unordered_map>
+#include <vector>
namespace aidl::android::hardware::automotive::evs::implementation {
-class EvsMockCamera : public EvsCameraBase {
+class EvsMockCamera : public EvsCamera {
+ private:
+ using Base = EvsCamera;
+
public:
+ EvsMockCamera(Sigil sigil, const char* deviceName,
+ std::unique_ptr<ConfigManager::CameraInfo>& camInfo);
+ EvsMockCamera(const EvsMockCamera&) = delete;
+ EvsMockCamera& operator=(const EvsMockCamera&) = delete;
+
// Methods from ::android::hardware::automotive::evs::IEvsCamera follow.
- ndk::ScopedAStatus doneWithFrame(const std::vector<evs::BufferDesc>& buffers) override;
ndk::ScopedAStatus forcePrimaryClient(
const std::shared_ptr<evs::IEvsDisplay>& display) override;
ndk::ScopedAStatus getCameraInfo(evs::CameraDesc* _aidl_return) override;
@@ -51,49 +58,37 @@
ndk::ScopedAStatus getParameterList(std::vector<evs::CameraParam>* _aidl_return) override;
ndk::ScopedAStatus getPhysicalCameraInfo(const std::string& deviceId,
evs::CameraDesc* _aidl_return) override;
- ndk::ScopedAStatus importExternalBuffers(const std::vector<evs::BufferDesc>& buffers,
- int32_t* _aidl_return) override;
- ndk::ScopedAStatus pauseVideoStream() override;
- ndk::ScopedAStatus resumeVideoStream() override;
ndk::ScopedAStatus setExtendedInfo(int32_t opaqueIdentifier,
const std::vector<uint8_t>& opaqueValue) override;
ndk::ScopedAStatus setIntParameter(evs::CameraParam id, int32_t value,
std::vector<int32_t>* effectiveValue) override;
ndk::ScopedAStatus setPrimaryClient() override;
- ndk::ScopedAStatus setMaxFramesInFlight(int32_t bufferCount) override;
- ndk::ScopedAStatus startVideoStream(
- const std::shared_ptr<evs::IEvsCameraStream>& receiver) override;
- ndk::ScopedAStatus stopVideoStream() override;
ndk::ScopedAStatus unsetPrimaryClient() override;
+ const evs::CameraDesc& getDesc() { return mDescription; }
+
static std::shared_ptr<EvsMockCamera> Create(const char* deviceName);
static std::shared_ptr<EvsMockCamera> Create(
const char* deviceName, std::unique_ptr<ConfigManager::CameraInfo>& camInfo,
const evs::Stream* streamCfg = nullptr);
- EvsMockCamera(const EvsMockCamera&) = delete;
- EvsMockCamera& operator=(const EvsMockCamera&) = delete;
-
- virtual ~EvsMockCamera() override;
-
- // Methods from EvsCameraBase follow.
- void shutdown() override;
-
- const evs::CameraDesc& getDesc() { return mDescription; }
-
- // Constructors
- EvsMockCamera(Sigil sigil, const char* deviceName,
- std::unique_ptr<ConfigManager::CameraInfo>& camInfo);
private:
- // These three functions are expected to be called while mAccessLock is held
- bool setAvailableFrames_Locked(unsigned bufferCount);
- unsigned increaseAvailableFrames_Locked(unsigned numToAdd);
- unsigned decreaseAvailableFrames_Locked(unsigned numToRemove);
-
void generateFrames();
void fillMockFrame(buffer_handle_t handle, const AHardwareBuffer_Desc* pDesc);
- void returnBufferLocked(const uint32_t bufferId);
- ndk::ScopedAStatus stopVideoStream_impl();
+
+ ::android::status_t allocateOneFrame(buffer_handle_t* handle) override;
+
+ bool startVideoStreamImpl_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override;
+
+ bool stopVideoStreamImpl_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override;
+
+ bool postVideoStreamStop_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override;
+
+ void initializeParameters();
CameraDesc mDescription = {}; // The properties of this camera
@@ -114,28 +109,6 @@
// Bytes per line in the buffers
uint32_t mStride = 0;
- struct BufferRecord {
- buffer_handle_t handle;
- bool inUse;
-
- explicit BufferRecord(buffer_handle_t h) : handle(h), inUse(false){};
- };
-
- std::vector<BufferRecord> mBuffers; // Graphics buffers to transfer images
- unsigned mFramesAllowed; // How many buffers are we currently using
- unsigned mFramesInUse; // How many buffers are currently outstanding
-
- enum StreamStateValues {
- STOPPED,
- RUNNING,
- STOPPING,
- DEAD,
- };
- StreamStateValues mStreamState;
-
- // Synchronization necessary to deconflict mCaptureThread from the main service thread
- std::mutex mAccessLock;
-
// Static camera module information
std::unique_ptr<ConfigManager::CameraInfo>& mCameraInfo;
@@ -155,7 +128,6 @@
int32_t value;
};
std::unordered_map<CameraParam, std::shared_ptr<CameraParameterDesc>> mParams;
- void initializeParameters();
};
} // namespace aidl::android::hardware::automotive::evs::implementation
diff --git a/automotive/evs/aidl/impl/default/include/EvsVideoEmulatedCamera.h b/automotive/evs/aidl/impl/default/include/EvsVideoEmulatedCamera.h
new file mode 100644
index 0000000..356a42a
--- /dev/null
+++ b/automotive/evs/aidl/impl/default/include/EvsVideoEmulatedCamera.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2023 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 "ConfigManager.h"
+#include "EvsCamera.h"
+
+#include <aidl/android/hardware/automotive/evs/BufferDesc.h>
+#include <aidl/android/hardware/automotive/evs/CameraDesc.h>
+#include <aidl/android/hardware/automotive/evs/CameraParam.h>
+#include <aidl/android/hardware/automotive/evs/IEvsCameraStream.h>
+#include <aidl/android/hardware/automotive/evs/IEvsDisplay.h>
+#include <aidl/android/hardware/automotive/evs/ParameterRange.h>
+#include <aidl/android/hardware/automotive/evs/Stream.h>
+
+#include <cstdint>
+#include <memory>
+#include <unordered_map>
+#include <vector>
+
+namespace aidl::android::hardware::automotive::evs::implementation {
+
+class EvsVideoEmulatedCamera : public EvsCamera {
+ public:
+ EvsVideoEmulatedCamera(Sigil sigil, const char* deviceName,
+ std::unique_ptr<ConfigManager::CameraInfo>& camInfo);
+
+ ~EvsVideoEmulatedCamera() override;
+
+ // Methods from ::android::hardware::automotive::evs::IEvsCamera follow.
+ ndk::ScopedAStatus forcePrimaryClient(
+ const std::shared_ptr<evs::IEvsDisplay>& display) override;
+ ndk::ScopedAStatus getCameraInfo(evs::CameraDesc* _aidl_return) override;
+ ndk::ScopedAStatus getExtendedInfo(int32_t opaqueIdentifier,
+ std::vector<uint8_t>* value) override;
+ ndk::ScopedAStatus getIntParameter(evs::CameraParam id, std::vector<int32_t>* value) override;
+ ndk::ScopedAStatus getIntParameterRange(evs::CameraParam id,
+ evs::ParameterRange* _aidl_return) override;
+ ndk::ScopedAStatus getParameterList(std::vector<evs::CameraParam>* _aidl_return) override;
+ ndk::ScopedAStatus getPhysicalCameraInfo(const std::string& deviceId,
+ evs::CameraDesc* _aidl_return) override;
+ ndk::ScopedAStatus setExtendedInfo(int32_t opaqueIdentifier,
+ const std::vector<uint8_t>& opaqueValue) override;
+ ndk::ScopedAStatus setIntParameter(evs::CameraParam id, int32_t value,
+ std::vector<int32_t>* effectiveValue) override;
+ ndk::ScopedAStatus setPrimaryClient() override;
+ ndk::ScopedAStatus unsetPrimaryClient() override;
+
+ const evs::CameraDesc& getDesc() { return mDescription; }
+
+ static std::shared_ptr<EvsVideoEmulatedCamera> Create(const char* deviceName);
+ static std::shared_ptr<EvsVideoEmulatedCamera> Create(
+ const char* deviceName, std::unique_ptr<ConfigManager::CameraInfo>& camInfo,
+ const evs::Stream* streamCfg = nullptr);
+
+ private:
+ // For the camera parameters.
+ struct CameraParameterDesc {
+ CameraParameterDesc(int min = 0, int max = 0, int step = 0, int value = 0) {
+ this->range.min = min;
+ this->range.max = max;
+ this->range.step = step;
+ this->value = value;
+ }
+
+ ParameterRange range;
+ int32_t value;
+ };
+
+ void initializeParameters();
+
+ ::android::status_t allocateOneFrame(buffer_handle_t* handle) override;
+
+ bool startVideoStreamImpl_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override;
+
+ bool stopVideoStreamImpl_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override;
+
+ // The properties of this camera.
+ CameraDesc mDescription = {};
+
+ // Camera parameters.
+ std::unordered_map<CameraParam, std::shared_ptr<CameraParameterDesc>> mParams;
+
+ // Static camera module information
+ std::unique_ptr<ConfigManager::CameraInfo>& mCameraInfo;
+
+ // For the extended info
+ std::unordered_map<uint32_t, std::vector<uint8_t>> mExtInfo;
+};
+
+} // namespace aidl::android::hardware::automotive::evs::implementation
diff --git a/automotive/evs/aidl/impl/default/src/EvsCamera.cpp b/automotive/evs/aidl/impl/default/src/EvsCamera.cpp
new file mode 100644
index 0000000..bc3bfdd
--- /dev/null
+++ b/automotive/evs/aidl/impl/default/src/EvsCamera.cpp
@@ -0,0 +1,378 @@
+/*
+ * Copyright (C) 2023 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 "EvsCamera.h"
+
+#include <aidl/android/hardware/automotive/evs/EvsResult.h>
+#include <aidlcommonsupport/NativeHandle.h>
+#include <android-base/logging.h>
+#include <android/hardware_buffer.h>
+#include <ui/GraphicBufferAllocator.h>
+#include <ui/GraphicBufferMapper.h>
+
+#include <cstddef>
+#include <mutex>
+
+namespace aidl::android::hardware::automotive::evs::implementation {
+
+// Arbitrary limit on number of graphics buffers allowed to be allocated
+// Safeguards against unreasonable resource consumption and provides a testable limit
+constexpr std::size_t kMaxBuffersInFlight = 100;
+
+// Minimum number of buffers to run a video stream
+constexpr int kMinimumBuffersInFlight = 1;
+
+EvsCamera::~EvsCamera() {
+ shutdown();
+}
+
+ndk::ScopedAStatus EvsCamera::doneWithFrame(const std::vector<evs::BufferDesc>& buffers) {
+ std::lock_guard lck(mMutex);
+ for (const auto& desc : buffers) {
+ returnBuffer_unsafe(desc.bufferId);
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsCamera::importExternalBuffers(const std::vector<evs::BufferDesc>& buffers,
+ int32_t* _aidl_return) {
+ if (buffers.empty()) {
+ LOG(DEBUG) << __func__
+ << ": Ignoring a request to import external buffers with an empty list.";
+ return ndk::ScopedAStatus::ok();
+ }
+ static auto& mapper = ::android::GraphicBufferMapper::get();
+ std::lock_guard lck(mMutex);
+ std::size_t numBuffersToAdd = std::min(buffers.size(), kMaxBuffersInFlight - mAvailableFrames);
+ if (numBuffersToAdd == 0) {
+ LOG(WARNING) << __func__ << ": The number of buffers has hit the upper limit ("
+ << kMaxBuffersInFlight << "). Stop importing.";
+ return ndk::ScopedAStatus::ok();
+ } else if (numBuffersToAdd < buffers.size()) {
+ LOG(WARNING) << "Exceeds the limit on the number of buffers. Only " << numBuffersToAdd
+ << " buffers will be imported. " << buffers.size() << " are asked.";
+ }
+ const size_t before = mAvailableFrames;
+ for (std::size_t idx = 0; idx < numBuffersToAdd; ++idx) {
+ auto& buffer = buffers[idx];
+ const AHardwareBuffer_Desc* pDesc =
+ reinterpret_cast<const AHardwareBuffer_Desc*>(&buffer.buffer.description);
+
+ buffer_handle_t handleToImport = ::android::dupFromAidl(buffer.buffer.handle);
+ buffer_handle_t handleToStore = nullptr;
+ if (handleToImport == nullptr) {
+ LOG(WARNING) << "Failed to duplicate a memory handle. Ignoring a buffer "
+ << buffer.bufferId;
+ continue;
+ }
+
+ ::android::status_t result =
+ mapper.importBuffer(handleToImport, pDesc->width, pDesc->height, pDesc->layers,
+ pDesc->format, pDesc->usage, pDesc->stride, &handleToStore);
+ if (result != ::android::NO_ERROR || handleToStore == nullptr ||
+ !increaseAvailableFrames_unsafe(handleToStore)) {
+ LOG(WARNING) << "Failed to import a buffer " << buffer.bufferId;
+ }
+ }
+ *_aidl_return = mAvailableFrames - before;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsCamera::setMaxFramesInFlight(int32_t bufferCount) {
+ std::lock_guard lock(mMutex);
+ if (bufferCount < 1) {
+ LOG(ERROR) << "Ignoring setMaxFramesInFlight with less than one buffer requested.";
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::INVALID_ARG));
+ }
+ if (!setAvailableFrames_unsafe(bufferCount)) {
+ LOG(ERROR) << "Failed to adjust the maximum number of frames in flight.";
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::BUFFER_NOT_AVAILABLE));
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
+void EvsCamera::freeOneFrame(const buffer_handle_t handle) {
+ static auto& alloc = ::android::GraphicBufferAllocator::get();
+ alloc.free(handle);
+}
+
+bool EvsCamera::preVideoStreamStart_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& /* lck */) {
+ if (!receiver) {
+ LOG(ERROR) << __func__ << ": Null receiver.";
+ status = ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::INVALID_ARG));
+ return false;
+ }
+
+ // If we've been displaced by another owner of the camera, then we can't do anything else
+ if (mStreamState == StreamState::DEAD) {
+ LOG(ERROR) << __func__ << ": Ignoring when camera has been lost.";
+ status = ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::OWNERSHIP_LOST));
+ return false;
+ }
+
+ if (mStreamState != StreamState::STOPPED) {
+ LOG(ERROR) << __func__ << ": Ignoring when a stream is already running.";
+ status = ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::STREAM_ALREADY_RUNNING));
+ return false;
+ }
+
+ // If the client never indicated otherwise, configure ourselves for a single streaming buffer
+ if (mAvailableFrames < kMinimumBuffersInFlight &&
+ !setAvailableFrames_unsafe(kMinimumBuffersInFlight)) {
+ LOG(ERROR) << __func__ << "Failed to because we could not get a graphics buffer.";
+ status = ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::BUFFER_NOT_AVAILABLE));
+ return false;
+ }
+ mStreamState = StreamState::RUNNING;
+ return true;
+}
+
+bool EvsCamera::postVideoStreamStart_locked(
+ const std::shared_ptr<evs::IEvsCameraStream>& /* receiver */,
+ ndk::ScopedAStatus& /* status */, std::unique_lock<std::mutex>& /* lck */) {
+ return true;
+}
+
+bool EvsCamera::preVideoStreamStop_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& /* lck */) {
+ if (mStreamState != StreamState::RUNNING) {
+ // Terminate the stop process because a stream is not running.
+ status = ndk::ScopedAStatus::ok();
+ return false;
+ }
+ mStreamState = StreamState::STOPPING;
+ return true;
+}
+
+bool EvsCamera::postVideoStreamStop_locked(ndk::ScopedAStatus& /* status */,
+ std::unique_lock<std::mutex>& /* lck */) {
+ mStreamState = StreamState::STOPPED;
+ return true;
+}
+
+ndk::ScopedAStatus EvsCamera::startVideoStream(
+ const std::shared_ptr<evs::IEvsCameraStream>& receiver) {
+ bool needShutdown = false;
+ auto status = ndk::ScopedAStatus::ok();
+ {
+ std::unique_lock lck(mMutex);
+ if (!preVideoStreamStart_locked(receiver, status, lck)) {
+ return status;
+ }
+
+ if ((!startVideoStreamImpl_locked(receiver, status, lck) ||
+ !postVideoStreamStart_locked(receiver, status, lck)) &&
+ !status.isOk()) {
+ needShutdown = true;
+ }
+ }
+ if (needShutdown) {
+ shutdown();
+ }
+ return status;
+}
+
+ndk::ScopedAStatus EvsCamera::stopVideoStream() {
+ bool needShutdown = false;
+ auto status = ndk::ScopedAStatus::ok();
+ {
+ std::unique_lock lck(mMutex);
+ if ((!preVideoStreamStop_locked(status, lck) || !stopVideoStreamImpl_locked(status, lck) ||
+ !postVideoStreamStop_locked(status, lck)) &&
+ !status.isOk()) {
+ needShutdown = true;
+ }
+ }
+ if (needShutdown) {
+ shutdown();
+ }
+ return status;
+}
+
+ndk::ScopedAStatus EvsCamera::pauseVideoStream() {
+ return ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::NOT_SUPPORTED));
+}
+
+ndk::ScopedAStatus EvsCamera::resumeVideoStream() {
+ return ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::NOT_SUPPORTED));
+}
+
+bool EvsCamera::setAvailableFrames_unsafe(const std::size_t bufferCount) {
+ if (bufferCount < 1) {
+ LOG(ERROR) << "Ignoring request to set buffer count to zero.";
+ return false;
+ }
+ if (bufferCount > kMaxBuffersInFlight) {
+ LOG(ERROR) << "Rejecting buffer request in excess of internal limit";
+ return false;
+ }
+
+ if (bufferCount > mAvailableFrames) {
+ bool success = true;
+ const std::size_t numBufferBeforeAlloc = mAvailableFrames;
+ for (int numBufferToAllocate = bufferCount - mAvailableFrames;
+ success && numBufferToAllocate > 0; --numBufferToAllocate) {
+ buffer_handle_t handle = nullptr;
+ const auto result = allocateOneFrame(&handle);
+ if (result != ::android::NO_ERROR || !handle) {
+ LOG(ERROR) << __func__ << ": Failed to allocate a graphics buffer. Error " << result
+ << ", handle: " << handle;
+ success = false;
+ break;
+ }
+ success &= increaseAvailableFrames_unsafe(handle);
+ }
+ if (!success) {
+ // Rollback when failure.
+ for (int numBufferToRelease = mAvailableFrames - numBufferBeforeAlloc;
+ numBufferToRelease > 0; --numBufferToRelease) {
+ decreaseAvailableFrames_unsafe();
+ }
+ return false;
+ }
+ } else {
+ for (int numBufferToRelease = mAvailableFrames - std::max(bufferCount, mFramesInUse);
+ numBufferToRelease > 0; --numBufferToRelease) {
+ decreaseAvailableFrames_unsafe();
+ }
+ if (mAvailableFrames > bufferCount) {
+ // This shouldn't happen with a properly behaving client because the client
+ // should only make this call after returning sufficient outstanding buffers
+ // to allow a clean resize.
+ LOG(ERROR) << "Buffer queue shrink failed, asked: " << bufferCount
+ << ", actual: " << mAvailableFrames
+ << " -- too many buffers currently in use?";
+ }
+ }
+ return true;
+}
+
+void EvsCamera::shutdown() {
+ stopVideoStream();
+ std::lock_guard lck(mMutex);
+ closeAllBuffers_unsafe();
+ mStreamState = StreamState::DEAD;
+}
+
+void EvsCamera::closeAllBuffers_unsafe() {
+ if (mFramesInUse > 0) {
+ LOG(WARNING) << __func__ << ": Closing while " << mFramesInUse
+ << " frame(s) are still in use.";
+ }
+ for (auto& buffer : mBuffers) {
+ freeOneFrame(buffer.handle);
+ buffer.handle = nullptr;
+ }
+ mBuffers.clear();
+ mBufferPosToId.clear();
+ mBufferIdToPos.clear();
+}
+
+std::pair<std::size_t, buffer_handle_t> EvsCamera::useBuffer_unsafe() {
+ if (mFramesInUse >= mAvailableFrames) {
+ DCHECK_EQ(mFramesInUse, mAvailableFrames);
+ return {kInvalidBufferID, nullptr};
+ }
+ const std::size_t pos = mFramesInUse++;
+ auto& buffer = mBuffers[pos];
+ DCHECK(!buffer.inUse);
+ DCHECK(buffer.handle);
+ buffer.inUse = true;
+ return {mBufferPosToId[pos], buffer.handle};
+}
+
+void EvsCamera::returnBuffer_unsafe(const std::size_t id) {
+ if (id >= mBuffers.size()) {
+ LOG(ERROR) << __func__ << ": ID out-of-bound. id: " << id
+ << " max: " << mBuffers.size() - 1;
+ return;
+ }
+ const std::size_t pos = mBufferIdToPos[id];
+
+ if (!mBuffers[pos].inUse) {
+ LOG(ERROR) << __func__ << ": Ignoring returning frame " << id << " which is already free.";
+ return;
+ }
+ DCHECK_LT(pos, mFramesInUse);
+ const std::size_t last_in_use_pos = --mFramesInUse;
+ swapBufferFrames_unsafe(pos, last_in_use_pos);
+ mBuffers[last_in_use_pos].inUse = false;
+}
+
+bool EvsCamera::increaseAvailableFrames_unsafe(const buffer_handle_t handle) {
+ if (mAvailableFrames >= kMaxBuffersInFlight) {
+ LOG(WARNING) << __func__ << ": The number of buffers has hit the upper limit ("
+ << kMaxBuffersInFlight << "). Stop increasing.";
+ return false;
+ }
+ const std::size_t pos = mAvailableFrames++;
+ if (mAvailableFrames > mBuffers.size()) {
+ const std::size_t oldBufferSize = mBuffers.size();
+ mBuffers.resize(mAvailableFrames);
+ mBufferPosToId.resize(mAvailableFrames);
+ mBufferIdToPos.resize(mAvailableFrames);
+ // Build position/ID mapping.
+ for (std::size_t idx = oldBufferSize; idx < mBuffers.size(); ++idx) {
+ mBufferPosToId[idx] = idx;
+ mBufferIdToPos[idx] = idx;
+ }
+ }
+ auto& buffer = mBuffers[pos];
+ DCHECK(!buffer.inUse);
+ DCHECK(!buffer.handle);
+ buffer.handle = handle;
+ return true;
+}
+
+bool EvsCamera::decreaseAvailableFrames_unsafe() {
+ if (mFramesInUse >= mAvailableFrames) {
+ DCHECK_EQ(mFramesInUse, mAvailableFrames);
+ return false;
+ }
+ const std::size_t pos = --mAvailableFrames;
+ auto& buffer = mBuffers[pos];
+ DCHECK(!buffer.inUse);
+ DCHECK(buffer.handle);
+ freeOneFrame(buffer.handle);
+ buffer.handle = nullptr;
+ return true;
+}
+
+void EvsCamera::swapBufferFrames_unsafe(const std::size_t pos1, const std::size_t pos2) {
+ if (pos1 == pos2) {
+ return;
+ }
+ if (pos1 >= mBuffers.size() || pos2 >= mBuffers.size()) {
+ LOG(ERROR) << __func__ << ": Index out-of-bound. pos1: " << pos1 << ", pos2: " << pos2
+ << ", buffer size: " << mBuffers.size();
+ return;
+ }
+ const std::size_t id1 = mBufferPosToId[pos1];
+ const std::size_t id2 = mBufferPosToId[pos2];
+ std::swap(mBufferPosToId[pos1], mBufferPosToId[pos2]);
+ std::swap(mBufferIdToPos[id1], mBufferIdToPos[id2]);
+ std::swap(mBuffers[pos1], mBuffers[pos2]);
+}
+
+} // namespace aidl::android::hardware::automotive::evs::implementation
diff --git a/automotive/evs/aidl/impl/default/src/EvsEnumerator.cpp b/automotive/evs/aidl/impl/default/src/EvsEnumerator.cpp
index ec4b18f..80e72a7 100644
--- a/automotive/evs/aidl/impl/default/src/EvsEnumerator.cpp
+++ b/automotive/evs/aidl/impl/default/src/EvsEnumerator.cpp
@@ -17,9 +17,9 @@
#include "EvsEnumerator.h"
#include "ConfigManager.h"
+#include "EvsAllCameras.h"
#include "EvsCameraBase.h"
#include "EvsGlDisplay.h"
-#include "EvsMockCamera.h"
#include <aidl/android/hardware/automotive/evs/EvsResult.h>
#include <aidl/android/hardware/graphics/common/BufferUsage.h>
@@ -264,6 +264,10 @@
pActiveCamera = EvsMockCamera::Create(id.data(), cameraInfo, &cfg);
break;
+ case DeviceType::VIDEO:
+ pActiveCamera = EvsVideoEmulatedCamera::Create(id.data(), cameraInfo, &cfg);
+ break;
+
default:
LOG(ERROR) << __func__ << ": camera device type "
<< static_cast<std::int32_t>(cameraInfo->deviceType)
diff --git a/automotive/evs/aidl/impl/default/src/EvsMockCamera.cpp b/automotive/evs/aidl/impl/default/src/EvsMockCamera.cpp
index 797b221..ef43925 100644
--- a/automotive/evs/aidl/impl/default/src/EvsMockCamera.cpp
+++ b/automotive/evs/aidl/impl/default/src/EvsMockCamera.cpp
@@ -15,28 +15,25 @@
*/
#include "EvsMockCamera.h"
-#include "ConfigManager.h"
-#include "EvsEnumerator.h"
+
+#include <aidl/android/hardware/automotive/evs/EvsResult.h>
#include <aidlcommonsupport/NativeHandle.h>
+#include <android-base/logging.h>
#include <ui/GraphicBufferAllocator.h>
#include <ui/GraphicBufferMapper.h>
#include <utils/SystemClock.h>
+#include <cstddef>
+#include <cstdint>
#include <memory>
+#include <tuple>
namespace {
using ::aidl::android::hardware::graphics::common::BufferUsage;
using ::ndk::ScopedAStatus;
-// Arbitrary limit on number of graphics buffers allowed to be allocated
-// Safeguards against unreasonable resource consumption and provides a testable limit
-constexpr unsigned kMaxBuffersInFlight = 100;
-
-// Minimum number of buffers to run a video stream
-constexpr int kMinimumBuffersInFlight = 1;
-
// Colors for the colorbar test pattern in ABGR format
constexpr uint32_t kColors[] = {
0xFFFFFFFF, // white
@@ -56,7 +53,7 @@
EvsMockCamera::EvsMockCamera([[maybe_unused]] Sigil sigil, const char* id,
std::unique_ptr<ConfigManager::CameraInfo>& camInfo)
- : mFramesAllowed(0), mFramesInUse(0), mStreamState(STOPPED), mCameraInfo(camInfo) {
+ : mCameraInfo(camInfo) {
LOG(DEBUG) << __FUNCTION__;
/* set a camera id */
@@ -73,11 +70,6 @@
initializeParameters();
}
-EvsMockCamera::~EvsMockCamera() {
- LOG(DEBUG) << __FUNCTION__;
- shutdown();
-}
-
void EvsMockCamera::initializeParameters() {
mParams.emplace(
CameraParam::BRIGHTNESS,
@@ -90,35 +82,6 @@
new CameraParameterDesc(/* min= */ 0, /* max= */ 255, /* step= */ 1, /* value= */ 255));
}
-// This gets called if another caller "steals" ownership of the camera
-void EvsMockCamera::shutdown() {
- LOG(DEBUG) << __FUNCTION__;
-
- // Make sure our output stream is cleaned up
- // (It really should be already)
- stopVideoStream_impl();
-
- // Claim the lock while we work on internal state
- std::lock_guard lock(mAccessLock);
-
- // Drop all the graphics buffers we've been using
- if (mBuffers.size() > 0) {
- ::android::GraphicBufferAllocator& alloc(::android::GraphicBufferAllocator::get());
- for (auto&& rec : mBuffers) {
- if (rec.inUse) {
- LOG(WARNING) << "WARNING: releasing a buffer remotely owned.";
- }
- alloc.free(rec.handle);
- rec.handle = nullptr;
- }
- mBuffers.clear();
- }
-
- // Put this object into an unrecoverable error state since somebody else
- // is going to own the underlying camera now
- mStreamState = DEAD;
-}
-
// Methods from ::aidl::android::hardware::automotive::evs::IEvsCamera follow.
ScopedAStatus EvsMockCamera::getCameraInfo(CameraDesc* _aidl_return) {
LOG(DEBUG) << __FUNCTION__;
@@ -128,115 +91,6 @@
return ScopedAStatus::ok();
}
-ScopedAStatus EvsMockCamera::setMaxFramesInFlight(int32_t bufferCount) {
- LOG(DEBUG) << __FUNCTION__ << ", bufferCount = " << bufferCount;
- ;
-
- std::lock_guard lock(mAccessLock);
-
- // If we've been displaced by another owner of the camera, then we can't do anything else
- if (mStreamState == DEAD) {
- LOG(ERROR) << "Ignoring setMaxFramesInFlight call when camera has been lost.";
- return ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::OWNERSHIP_LOST));
- }
-
- // We cannot function without at least one video buffer to send data
- if (bufferCount < 1) {
- LOG(ERROR) << "Ignoring setMaxFramesInFlight with less than one buffer requested.";
- return ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::INVALID_ARG));
- }
-
- // Update our internal state
- if (!setAvailableFrames_Locked(bufferCount)) {
- LOG(ERROR) << "Failed to adjust the maximum number of frames in flight.";
- return ScopedAStatus::fromServiceSpecificError(
- static_cast<int>(EvsResult::BUFFER_NOT_AVAILABLE));
- }
-
- return ScopedAStatus::ok();
-}
-
-ScopedAStatus EvsMockCamera::startVideoStream(const std::shared_ptr<IEvsCameraStream>& cb) {
- LOG(DEBUG) << __FUNCTION__;
-
- if (!cb) {
- LOG(ERROR) << "A given stream callback is invalid.";
- return ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::INVALID_ARG));
- }
-
- std::lock_guard lock(mAccessLock);
-
- // If we've been displaced by another owner of the camera, then we can't do anything else
- if (mStreamState == DEAD) {
- LOG(ERROR) << "Ignoring startVideoStream call when camera has been lost.";
- return ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::OWNERSHIP_LOST));
- }
-
- if (mStreamState != STOPPED) {
- LOG(ERROR) << "Ignoring startVideoStream call when a stream is already running.";
- return ScopedAStatus::fromServiceSpecificError(
- static_cast<int>(EvsResult::STREAM_ALREADY_RUNNING));
- }
-
- // If the client never indicated otherwise, configure ourselves for a single streaming buffer
- if (mFramesAllowed < kMinimumBuffersInFlight &&
- !setAvailableFrames_Locked(kMinimumBuffersInFlight)) {
- LOG(ERROR) << "Failed to start stream because we couldn't get a graphics buffer";
- return ScopedAStatus::fromServiceSpecificError(
- static_cast<int>(EvsResult::BUFFER_NOT_AVAILABLE));
- }
-
- // Record the user's callback for use when we have a frame ready
- mStream = cb;
-
- // Start the frame generation thread
- mStreamState = RUNNING;
- mCaptureThread = std::thread([this]() { generateFrames(); });
-
- return ScopedAStatus::ok();
-}
-
-ScopedAStatus EvsMockCamera::doneWithFrame(const std::vector<BufferDesc>& list) {
- std::lock_guard lock(mAccessLock);
- for (const auto& desc : list) {
- returnBufferLocked(desc.bufferId);
- }
-
- return ScopedAStatus::ok();
-}
-
-ScopedAStatus EvsMockCamera::stopVideoStream() {
- LOG(DEBUG) << __FUNCTION__;
- return stopVideoStream_impl();
-}
-
-ScopedAStatus EvsMockCamera::stopVideoStream_impl() {
- std::unique_lock lock(mAccessLock);
-
- if (mStreamState != RUNNING) {
- // Safely return here because a stream is not running.
- return ScopedAStatus::ok();
- }
-
- // Tell the GenerateFrames loop we want it to stop
- mStreamState = STOPPING;
-
- // Block outside the mutex until the "stop" flag has been acknowledged
- // We won't send any more frames, but the client might still get some already in flight
- LOG(DEBUG) << "Waiting for stream thread to end...";
- lock.unlock();
- if (mCaptureThread.joinable()) {
- mCaptureThread.join();
- }
- lock.lock();
-
- mStreamState = STOPPED;
- mStream = nullptr;
- LOG(DEBUG) << "Stream marked STOPPED.";
-
- return ScopedAStatus::ok();
-}
-
ScopedAStatus EvsMockCamera::getExtendedInfo(int32_t opaqueIdentifier,
std::vector<uint8_t>* opaqueValue) {
const auto it = mExtInfo.find(opaqueIdentifier);
@@ -264,14 +118,6 @@
return ScopedAStatus::ok();
}
-ScopedAStatus EvsMockCamera::pauseVideoStream() {
- return ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::NOT_SUPPORTED));
-}
-
-ScopedAStatus EvsMockCamera::resumeVideoStream() {
- return ScopedAStatus::fromServiceSpecificError(static_cast<int>(EvsResult::NOT_SUPPORTED));
-}
-
ScopedAStatus EvsMockCamera::setPrimaryClient() {
/* Because EVS HW module reference implementation expects a single client at
* a time, this returns a success code always.
@@ -346,232 +192,27 @@
return ScopedAStatus::ok();
}
-ScopedAStatus EvsMockCamera::importExternalBuffers(const std::vector<BufferDesc>& buffers,
- int32_t* _aidl_return) {
- size_t numBuffersToAdd = buffers.size();
- if (numBuffersToAdd < 1) {
- LOG(DEBUG) << "Ignoring a request to import external buffers with an empty list.";
- return ScopedAStatus::ok();
- }
-
- std::lock_guard lock(mAccessLock);
- if (numBuffersToAdd > (kMaxBuffersInFlight - mFramesAllowed)) {
- numBuffersToAdd -= (kMaxBuffersInFlight - mFramesAllowed);
- LOG(WARNING) << "Exceed the limit on the number of buffers. " << numBuffersToAdd
- << " buffers will be imported only.";
- }
-
- ::android::GraphicBufferMapper& mapper = ::android::GraphicBufferMapper::get();
- const size_t before = mFramesAllowed;
- for (size_t i = 0; i < numBuffersToAdd; ++i) {
- auto& b = buffers[i];
- const AHardwareBuffer_Desc* pDesc =
- reinterpret_cast<const AHardwareBuffer_Desc*>(&b.buffer.description);
-
- buffer_handle_t handleToImport = ::android::dupFromAidl(b.buffer.handle);
- buffer_handle_t handleToStore = nullptr;
- if (handleToImport == nullptr) {
- LOG(WARNING) << "Failed to duplicate a memory handle. Ignoring a buffer " << b.bufferId;
- continue;
- }
-
- ::android::status_t result =
- mapper.importBuffer(handleToImport, pDesc->width, pDesc->height, pDesc->layers,
- pDesc->format, pDesc->usage, pDesc->stride, &handleToStore);
- if (result != ::android::NO_ERROR || handleToStore == nullptr) {
- LOG(WARNING) << "Failed to import a buffer " << b.bufferId;
- continue;
- }
-
- bool stored = false;
- for (auto&& rec : mBuffers) {
- if (rec.handle != nullptr) {
- continue;
- }
-
- // Use this existing entry.
- rec.handle = handleToStore;
- rec.inUse = false;
- stored = true;
- break;
- }
-
- if (!stored) {
- // Add a BufferRecord wrapping this handle to our set of available buffers.
- mBuffers.push_back(BufferRecord(handleToStore));
- }
- ++mFramesAllowed;
- }
-
- *_aidl_return = mFramesAllowed - before;
- return ScopedAStatus::ok();
-}
-
-bool EvsMockCamera::setAvailableFrames_Locked(unsigned bufferCount) {
- if (bufferCount < 1) {
- LOG(ERROR) << "Ignoring request to set buffer count to zero";
- return false;
- }
- if (bufferCount > kMaxBuffersInFlight) {
- LOG(ERROR) << "Rejecting buffer request in excess of internal limit";
- return false;
- }
-
- // Is an increase required?
- if (mFramesAllowed < bufferCount) {
- // An increase is required
- auto needed = bufferCount - mFramesAllowed;
- LOG(INFO) << "Allocating " << needed << " buffers for camera frames";
-
- auto added = increaseAvailableFrames_Locked(needed);
- if (added != needed) {
- // If we didn't add all the frames we needed, then roll back to the previous state
- LOG(ERROR) << "Rolling back to previous frame queue size";
- decreaseAvailableFrames_Locked(added);
- return false;
- }
- } else if (mFramesAllowed > bufferCount) {
- // A decrease is required
- auto framesToRelease = mFramesAllowed - bufferCount;
- LOG(INFO) << "Returning " << framesToRelease << " camera frame buffers";
-
- auto released = decreaseAvailableFrames_Locked(framesToRelease);
- if (released != framesToRelease) {
- // This shouldn't happen with a properly behaving client because the client
- // should only make this call after returning sufficient outstanding buffers
- // to allow a clean resize.
- LOG(ERROR) << "Buffer queue shrink failed -- too many buffers currently in use?";
- }
- }
-
- return true;
-}
-
-unsigned EvsMockCamera::increaseAvailableFrames_Locked(unsigned numToAdd) {
- // Acquire the graphics buffer allocator
- ::android::GraphicBufferAllocator& alloc(::android::GraphicBufferAllocator::get());
-
- unsigned added = 0;
- while (added < numToAdd) {
- unsigned pixelsPerLine = 0;
- buffer_handle_t memHandle = nullptr;
- auto result = alloc.allocate(mWidth, mHeight, mFormat, 1, mUsage, &memHandle,
- &pixelsPerLine, 0, "EvsMockCamera");
- if (result != ::android::NO_ERROR) {
- LOG(ERROR) << "Error " << result << " allocating " << mWidth << " x " << mHeight
- << " graphics buffer";
- break;
- }
- if (memHandle == nullptr) {
- LOG(ERROR) << "We didn't get a buffer handle back from the allocator";
- break;
- }
- if (mStride > 0) {
- if (mStride != pixelsPerLine) {
- LOG(ERROR) << "We did not expect to get buffers with different strides!";
- }
- } else {
- // Gralloc defines stride in terms of pixels per line
- mStride = pixelsPerLine;
- }
-
- // Find a place to store the new buffer
- auto stored = false;
- for (auto&& rec : mBuffers) {
- if (rec.handle == nullptr) {
- // Use this existing entry
- rec.handle = memHandle;
- rec.inUse = false;
- stored = true;
- break;
- }
- }
- if (!stored) {
- // Add a BufferRecord wrapping this handle to our set of available buffers
- mBuffers.push_back(BufferRecord(memHandle));
- }
-
- ++mFramesAllowed;
- ++added;
- }
-
- return added;
-}
-
-unsigned EvsMockCamera::decreaseAvailableFrames_Locked(unsigned numToRemove) {
- // Acquire the graphics buffer allocator
- ::android::GraphicBufferAllocator& alloc(::android::GraphicBufferAllocator::get());
-
- unsigned removed = 0;
- for (auto&& rec : mBuffers) {
- // Is this record not in use, but holding a buffer that we can free?
- if ((rec.inUse == false) && (rec.handle != nullptr)) {
- // Release buffer and update the record so we can recognize it as "empty"
- alloc.free(rec.handle);
- rec.handle = nullptr;
-
- --mFramesAllowed;
- ++removed;
-
- if (removed == numToRemove) {
- break;
- }
- }
- }
-
- return removed;
-}
-
// This is the asynchronous frame generation thread that runs in parallel with the
// main serving thread. There is one for each active camera instance.
void EvsMockCamera::generateFrames() {
LOG(DEBUG) << "Frame generation loop started.";
- unsigned idx = 0;
while (true) {
- bool timeForFrame = false;
const nsecs_t startTime = systemTime(SYSTEM_TIME_MONOTONIC);
-
- // Lock scope for updating shared state
+ std::size_t bufferId = kInvalidBufferID;
+ buffer_handle_t bufferHandle = nullptr;
{
- std::lock_guard lock(mAccessLock);
-
- if (mStreamState != RUNNING) {
- // Break out of our main thread loop
+ std::lock_guard lock(mMutex);
+ if (mStreamState != StreamState::RUNNING) {
break;
}
-
- // Are we allowed to issue another buffer?
- if (mFramesInUse >= mFramesAllowed) {
- // Can't do anything right now -- skip this frame
- LOG(WARNING) << "Skipped a frame because too many are in flight.";
- } else {
- // Identify an available buffer to fill
- for (idx = 0; idx < mBuffers.size(); idx++) {
- if (!mBuffers[idx].inUse) {
- if (mBuffers[idx].handle != nullptr) {
- // Found an available record, so stop looking
- break;
- }
- }
- }
- if (idx >= mBuffers.size()) {
- // This shouldn't happen since we already checked mFramesInUse vs mFramesAllowed
- ALOGE("Failed to find an available buffer slot\n");
- } else {
- // We're going to make the frame busy
- mBuffers[idx].inUse = true;
- mFramesInUse++;
- timeForFrame = true;
- }
- }
+ std::tie(bufferId, bufferHandle) = useBuffer_unsafe();
}
- if (timeForFrame) {
+ if (bufferHandle != nullptr) {
using AidlPixelFormat = ::aidl::android::hardware::graphics::common::PixelFormat;
// Assemble the buffer description we'll transmit below
- buffer_handle_t memHandle = mBuffers[idx].handle;
BufferDesc newBuffer = {
.buffer =
{
@@ -584,39 +225,31 @@
.usage = static_cast<BufferUsage>(mUsage),
.stride = static_cast<int32_t>(mStride),
},
- .handle = ::android::dupToAidl(memHandle),
+ .handle = ::android::dupToAidl(bufferHandle),
},
- .bufferId = static_cast<int32_t>(idx),
+ .bufferId = static_cast<int32_t>(bufferId),
.deviceId = mDescription.id,
.timestamp = static_cast<int64_t>(::android::elapsedRealtimeNano() *
1e+3), // timestamps is in microseconds
};
// Write test data into the image buffer
- fillMockFrame(memHandle, reinterpret_cast<const AHardwareBuffer_Desc*>(
- &newBuffer.buffer.description));
+ fillMockFrame(bufferHandle, reinterpret_cast<const AHardwareBuffer_Desc*>(
+ &newBuffer.buffer.description));
+
+ std::vector<BufferDesc> frames;
+ frames.push_back(std::move(newBuffer));
// Issue the (asynchronous) callback to the client -- can't be holding the lock
- auto flag = false;
- if (mStream) {
- std::vector<BufferDesc> frames;
- frames.push_back(std::move(newBuffer));
- flag = mStream->deliverFrame(frames).isOk();
- }
-
- if (flag) {
- LOG(DEBUG) << "Delivered " << memHandle << ", id = " << mBuffers[idx].handle;
+ if (mStream && mStream->deliverFrame(frames).isOk()) {
+ LOG(DEBUG) << "Delivered " << bufferHandle << ", id = " << bufferId;
} else {
// This can happen if the client dies and is likely unrecoverable.
// To avoid consuming resources generating failing calls, we stop sending
// frames. Note, however, that the stream remains in the "STREAMING" state
// until cleaned up on the main thread.
LOG(ERROR) << "Frame delivery call failed in the transport layer.";
-
- // Since we didn't actually deliver it, mark the frame as available
- std::lock_guard<std::mutex> lock(mAccessLock);
- mBuffers[idx].inUse = false;
- mFramesInUse--;
+ doneWithFrame(frames);
}
}
@@ -671,34 +304,45 @@
mapper.unlock(handle);
}
-void EvsMockCamera::returnBufferLocked(const uint32_t bufferId) {
- if (bufferId >= mBuffers.size()) {
- ALOGE("ignoring doneWithFrame called with invalid bufferId %d (max is %zu)", bufferId,
- mBuffers.size() - 1);
- return;
+::android::status_t EvsMockCamera::allocateOneFrame(buffer_handle_t* handle) {
+ static auto& alloc = ::android::GraphicBufferAllocator::get();
+ unsigned pixelsPerLine = 0;
+ const auto result = alloc.allocate(mWidth, mHeight, mFormat, 1, mUsage, handle, &pixelsPerLine,
+ 0, "EvsMockCamera");
+ if (mStride < mWidth) {
+ // Gralloc defines stride in terms of pixels per line
+ mStride = pixelsPerLine;
+ } else if (mStride != pixelsPerLine) {
+ LOG(ERROR) << "We did not expect to get buffers with different strides!";
}
+ return result;
+}
- if (!mBuffers[bufferId].inUse) {
- ALOGE("ignoring doneWithFrame called on frame %d which is already free", bufferId);
- return;
+bool EvsMockCamera::startVideoStreamImpl_locked(
+ const std::shared_ptr<evs::IEvsCameraStream>& receiver, ndk::ScopedAStatus& /* status */,
+ std::unique_lock<std::mutex>& /* lck */) {
+ mStream = receiver;
+ mCaptureThread = std::thread([this]() { generateFrames(); });
+ return true;
+}
+
+bool EvsMockCamera::stopVideoStreamImpl_locked(ndk::ScopedAStatus& /* status */,
+ std::unique_lock<std::mutex>& lck) {
+ lck.unlock();
+ if (mCaptureThread.joinable()) {
+ mCaptureThread.join();
}
+ lck.lock();
+ return true;
+}
- // Mark the frame as available
- mBuffers[bufferId].inUse = false;
- mFramesInUse--;
-
- // If this frame's index is high in the array, try to move it down
- // to improve locality after mFramesAllowed has been reduced.
- if (bufferId >= mFramesAllowed) {
- // Find an empty slot lower in the array (which should always exist in this case)
- for (auto&& rec : mBuffers) {
- if (rec.handle == nullptr) {
- rec.handle = mBuffers[bufferId].handle;
- mBuffers[bufferId].handle = nullptr;
- break;
- }
- }
+bool EvsMockCamera::postVideoStreamStop_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) {
+ if (!Base::postVideoStreamStop_locked(status, lck)) {
+ return false;
}
+ mStream = nullptr;
+ return true;
}
std::shared_ptr<EvsMockCamera> EvsMockCamera::Create(const char* deviceName) {
diff --git a/automotive/evs/aidl/impl/default/src/EvsVideoEmulatedCamera.cpp b/automotive/evs/aidl/impl/default/src/EvsVideoEmulatedCamera.cpp
new file mode 100644
index 0000000..f198a64
--- /dev/null
+++ b/automotive/evs/aidl/impl/default/src/EvsVideoEmulatedCamera.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2023 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 "EvsVideoEmulatedCamera.h"
+
+#include <aidl/android/hardware/automotive/evs/EvsResult.h>
+
+#include <android-base/logging.h>
+
+#include <cstddef>
+#include <cstdint>
+
+namespace aidl::android::hardware::automotive::evs::implementation {
+
+EvsVideoEmulatedCamera::EvsVideoEmulatedCamera(Sigil, const char* deviceName,
+ std::unique_ptr<ConfigManager::CameraInfo>& camInfo)
+ : mCameraInfo(camInfo) {
+ mDescription.id = deviceName;
+
+ /* set camera metadata */
+ if (camInfo) {
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(camInfo->characteristics);
+ const size_t len = get_camera_metadata_size(camInfo->characteristics);
+ mDescription.metadata.insert(mDescription.metadata.end(), ptr, ptr + len);
+ }
+
+ initializeParameters();
+}
+
+void EvsVideoEmulatedCamera::initializeParameters() {
+ mParams.emplace(
+ CameraParam::BRIGHTNESS,
+ new CameraParameterDesc(/* min= */ 0, /* max= */ 255, /* step= */ 1, /* value= */ 255));
+ mParams.emplace(
+ CameraParam::CONTRAST,
+ new CameraParameterDesc(/* min= */ 0, /* max= */ 255, /* step= */ 1, /* value= */ 255));
+ mParams.emplace(
+ CameraParam::SHARPNESS,
+ new CameraParameterDesc(/* min= */ 0, /* max= */ 255, /* step= */ 1, /* value= */ 255));
+}
+
+::android::status_t EvsVideoEmulatedCamera::allocateOneFrame(buffer_handle_t* /* handle */) {
+ LOG(FATAL) << __func__ << ": Not implemented yet.";
+ return ::android::UNKNOWN_ERROR;
+}
+
+bool EvsVideoEmulatedCamera::startVideoStreamImpl_locked(
+ const std::shared_ptr<evs::IEvsCameraStream>& /* receiver */,
+ ndk::ScopedAStatus& /* status */, std::unique_lock<std::mutex>& /* lck */) {
+ LOG(FATAL) << __func__ << ": Not implemented yet.";
+ return false;
+}
+
+bool EvsVideoEmulatedCamera::stopVideoStreamImpl_locked(ndk::ScopedAStatus& /* status */,
+ std::unique_lock<std::mutex>& /* lck */) {
+ LOG(FATAL) << __func__ << ": Not implemented yet.";
+ return false;
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::forcePrimaryClient(
+ const std::shared_ptr<evs::IEvsDisplay>& /* display */) {
+ /* Because EVS HW module reference implementation expects a single client at
+ * a time, this returns a success code always.
+ */
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::getCameraInfo(evs::CameraDesc* _aidl_return) {
+ *_aidl_return = mDescription;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::getExtendedInfo(int32_t opaqueIdentifier,
+ std::vector<uint8_t>* value) {
+ const auto it = mExtInfo.find(opaqueIdentifier);
+ if (it == mExtInfo.end()) {
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::INVALID_ARG));
+ } else {
+ *value = mExtInfo[opaqueIdentifier];
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::getIntParameter(evs::CameraParam id,
+ std::vector<int32_t>* value) {
+ const auto it = mParams.find(id);
+ if (it == mParams.end()) {
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::NOT_SUPPORTED));
+ }
+ value->push_back(it->second->value);
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::getIntParameterRange(evs::CameraParam id,
+ evs::ParameterRange* _aidl_return) {
+ const auto it = mParams.find(id);
+ if (it == mParams.end()) {
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::NOT_SUPPORTED));
+ }
+ _aidl_return->min = it->second->range.min;
+ _aidl_return->max = it->second->range.max;
+ _aidl_return->step = it->second->range.step;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::getParameterList(
+ std::vector<evs::CameraParam>* _aidl_return) {
+ if (mCameraInfo) {
+ _aidl_return->resize(mCameraInfo->controls.size());
+ std::size_t idx = 0;
+ for (const auto& [name, range] : mCameraInfo->controls) {
+ (*_aidl_return)[idx++] = name;
+ }
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::getPhysicalCameraInfo(const std::string& /* deviceId */,
+ evs::CameraDesc* _aidl_return) {
+ return getCameraInfo(_aidl_return);
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::setExtendedInfo(
+ int32_t opaqueIdentifier, const std::vector<uint8_t>& opaqueValue) {
+ mExtInfo.insert_or_assign(opaqueIdentifier, opaqueValue);
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::setIntParameter(evs::CameraParam id, int32_t value,
+ std::vector<int32_t>* effectiveValue) {
+ const auto it = mParams.find(id);
+ if (it == mParams.end()) {
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::NOT_SUPPORTED));
+ }
+ // Rounding down to the closest value.
+ int32_t candidate = value / it->second->range.step * it->second->range.step;
+ if (candidate < it->second->range.min || candidate > it->second->range.max) {
+ return ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int>(EvsResult::INVALID_ARG));
+ }
+ it->second->value = candidate;
+ effectiveValue->push_back(candidate);
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::setPrimaryClient() {
+ /* Because EVS HW module reference implementation expects a single client at
+ * a time, this returns a success code always.
+ */
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus EvsVideoEmulatedCamera::unsetPrimaryClient() {
+ /* Because EVS HW module reference implementation expects a single client at
+ * a time, there is no chance that this is called by the secondary client and
+ * therefore returns a success code always.
+ */
+ return ndk::ScopedAStatus::ok();
+}
+
+std::shared_ptr<EvsVideoEmulatedCamera> EvsVideoEmulatedCamera::Create(const char* deviceName) {
+ std::unique_ptr<ConfigManager::CameraInfo> nullCamInfo = nullptr;
+ return Create(deviceName, nullCamInfo);
+}
+
+std::shared_ptr<EvsVideoEmulatedCamera> EvsVideoEmulatedCamera::Create(
+ const char* deviceName, std::unique_ptr<ConfigManager::CameraInfo>& camInfo,
+ const evs::Stream* /* streamCfg */) {
+ std::shared_ptr<EvsVideoEmulatedCamera> c =
+ ndk::SharedRefBase::make<EvsVideoEmulatedCamera>(Sigil{}, deviceName, camInfo);
+ if (!c) {
+ LOG(ERROR) << "Failed to instantiate EvsVideoEmulatedCamera.";
+ return nullptr;
+ }
+ c->mDescription.vendorFlags = 0xFFFFFFFF; // Arbitrary test value
+ return c;
+}
+
+EvsVideoEmulatedCamera::~EvsVideoEmulatedCamera() {}
+
+} // namespace aidl::android::hardware::automotive::evs::implementation
diff --git a/automotive/evs/aidl/impl/default/tests/EvsCameraBufferTest.cpp b/automotive/evs/aidl/impl/default/tests/EvsCameraBufferTest.cpp
new file mode 100644
index 0000000..8b4676e
--- /dev/null
+++ b/automotive/evs/aidl/impl/default/tests/EvsCameraBufferTest.cpp
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2023 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 "EvsCamera.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <cstdint>
+#include <unordered_set>
+#include <vector>
+
+namespace aidl::android::hardware::automotive::evs::implementation {
+
+class EvsCameraForTest : public EvsCamera {
+ public:
+ using EvsCamera::increaseAvailableFrames_unsafe;
+ using EvsCamera::returnBuffer_unsafe;
+ using EvsCamera::useBuffer_unsafe;
+
+ ~EvsCameraForTest() override { shutdown(); }
+
+ ::android::status_t allocateOneFrame(buffer_handle_t* handle) override {
+ static std::intptr_t handle_cnt = 0;
+ *handle = reinterpret_cast<buffer_handle_t>(++handle_cnt);
+ return ::android::OK;
+ }
+
+ void freeOneFrame(const buffer_handle_t /* handle */) override {
+ // Nothing to free because the handles are fake.
+ }
+
+ void checkBufferOrder() {
+ for (std::size_t idx = 0; idx < mBuffers.size(); ++idx) {
+ const auto& buffer = mBuffers[idx];
+ EXPECT_EQ(idx < mFramesInUse, buffer.inUse);
+ EXPECT_EQ(idx < mAvailableFrames, buffer.handle != nullptr);
+ EXPECT_LE(mFramesInUse, mAvailableFrames);
+ }
+ }
+
+ MOCK_METHOD(::ndk::ScopedAStatus, forcePrimaryClient,
+ (const std::shared_ptr<::aidl::android::hardware::automotive::evs::IEvsDisplay>&
+ in_display),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getCameraInfo,
+ (::aidl::android::hardware::automotive::evs::CameraDesc * _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getExtendedInfo,
+ (int32_t in_opaqueIdentifier, std::vector<uint8_t>* _aidl_return), (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getIntParameter,
+ (::aidl::android::hardware::automotive::evs::CameraParam in_id,
+ std::vector<int32_t>* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getIntParameterRange,
+ (::aidl::android::hardware::automotive::evs::CameraParam in_id,
+ ::aidl::android::hardware::automotive::evs::ParameterRange* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getParameterList,
+ (std::vector<::aidl::android::hardware::automotive::evs::CameraParam> *
+ _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getPhysicalCameraInfo,
+ (const std::string& in_deviceId,
+ ::aidl::android::hardware::automotive::evs::CameraDesc* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, setExtendedInfo,
+ (int32_t in_opaqueIdentifier, const std::vector<uint8_t>& in_opaqueValue),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, setIntParameter,
+ (::aidl::android::hardware::automotive::evs::CameraParam in_id, int32_t in_value,
+ std::vector<int32_t>* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, setPrimaryClient, (), (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, unsetPrimaryClient, (), (override));
+ MOCK_METHOD(bool, startVideoStreamImpl_locked,
+ (const std::shared_ptr<evs::IEvsCameraStream>& receiver, ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck),
+ (override));
+ MOCK_METHOD(bool, stopVideoStreamImpl_locked,
+ (ndk::ScopedAStatus & status, std::unique_lock<std::mutex>& lck), (override));
+};
+
+TEST(EvsCameraBufferTest, ChangeBufferPoolSize) {
+ auto evsCam = ndk::SharedRefBase::make<EvsCameraForTest>();
+ EXPECT_TRUE(evsCam->setMaxFramesInFlight(100).isOk());
+ evsCam->checkBufferOrder();
+ EXPECT_TRUE(evsCam->setMaxFramesInFlight(50).isOk());
+ evsCam->checkBufferOrder();
+
+ // 2 buffers in use.
+ const auto [id1, handle1] = evsCam->useBuffer_unsafe();
+ const auto [id2, handle2] = evsCam->useBuffer_unsafe();
+ std::ignore = evsCam->useBuffer_unsafe();
+
+ // It allows you to set the buffer pool size to 1, but it will keep the space for the in use
+ // buffers.
+ EXPECT_TRUE(evsCam->setMaxFramesInFlight(1).isOk());
+ evsCam->checkBufferOrder();
+
+ evsCam->returnBuffer_unsafe(id1);
+ evsCam->checkBufferOrder();
+ evsCam->returnBuffer_unsafe(id2);
+ evsCam->checkBufferOrder();
+}
+
+TEST(EvsCameraBufferTest, UseAndReturn) {
+ constexpr std::size_t kNumOfHandles = 20;
+ auto evsCam = ndk::SharedRefBase::make<EvsCameraForTest>();
+
+ // Our "fake handles" of this test case is 1 to kNumOfHandles.
+ for (std::size_t i = 1; i <= kNumOfHandles; ++i) {
+ evsCam->increaseAvailableFrames_unsafe(reinterpret_cast<buffer_handle_t>(i));
+ }
+ evsCam->checkBufferOrder();
+
+ {
+ std::vector<std::pair<std::size_t, std::intptr_t>> inUseIDHandlePairs;
+ std::unordered_set<std::size_t> inUseIDs;
+ std::unordered_set<std::intptr_t> inUseHandles;
+ for (std::size_t i = 0; i < kNumOfHandles; ++i) {
+ const auto [id, handle] = evsCam->useBuffer_unsafe();
+ const std::size_t handleInt = reinterpret_cast<std::size_t>(handle);
+ EXPECT_TRUE(EvsCamera::IsBufferIDValid(id));
+ EXPECT_NE(handle, nullptr);
+ EXPECT_LT(id, kNumOfHandles);
+
+ // handleInt must be between [1, kNumOfHandles] as we "allocated" above.
+ EXPECT_LT(0u, handleInt);
+ EXPECT_LE(handleInt, kNumOfHandles);
+
+ inUseIDHandlePairs.push_back({id, handleInt});
+ EXPECT_TRUE(inUseIDs.insert(id).second);
+ EXPECT_TRUE(inUseHandles.insert(handleInt).second);
+ evsCam->checkBufferOrder();
+ }
+ // Return buffers in the order of acquiring.
+ for (const auto [id, handleInt] : inUseIDHandlePairs) {
+ evsCam->returnBuffer_unsafe(id);
+ evsCam->checkBufferOrder();
+ }
+ }
+
+ {
+ std::vector<std::pair<std::size_t, std::intptr_t>> inUseIDHandlePairs;
+ std::unordered_set<std::size_t> inUseIDs;
+ std::unordered_set<std::intptr_t> inUseHandles;
+ for (std::size_t i = 0; i < kNumOfHandles; ++i) {
+ const auto [id, handle] = evsCam->useBuffer_unsafe();
+ const std::size_t handleInt = reinterpret_cast<std::size_t>(handle);
+ EXPECT_TRUE(EvsCamera::IsBufferIDValid(id));
+ EXPECT_NE(handle, nullptr);
+ EXPECT_LT(id, kNumOfHandles);
+
+ // handleInt must be between [1, kNumOfHandles] as we "allocated" above.
+ EXPECT_LT(0u, handleInt);
+ EXPECT_LE(handleInt, kNumOfHandles);
+
+ inUseIDHandlePairs.push_back({id, handleInt});
+ EXPECT_TRUE(inUseIDs.insert(id).second);
+ EXPECT_TRUE(inUseHandles.insert(handleInt).second);
+ evsCam->checkBufferOrder();
+ }
+ // Return buffers in the reverse order of acquiring.
+ std::reverse(inUseIDHandlePairs.begin(), inUseIDHandlePairs.end());
+ for (const auto [id, handleInt] : inUseIDHandlePairs) {
+ evsCam->returnBuffer_unsafe(id);
+ evsCam->checkBufferOrder();
+ }
+ }
+
+ {
+ // Making sure the handles are still in [1, kNumOfHandles] and IDs are still [0,
+ // kNumOfHandles). The mapping may be different, though.
+ std::vector<std::pair<std::size_t, std::intptr_t>> inUseIDHandlePairs;
+ std::unordered_set<std::size_t> inUseIDs;
+ std::unordered_set<std::intptr_t> inUseHandles;
+ for (std::size_t i = 0; i < kNumOfHandles; ++i) {
+ const auto [id, handle] = evsCam->useBuffer_unsafe();
+ const std::size_t handleInt = reinterpret_cast<std::size_t>(handle);
+ EXPECT_TRUE(EvsCamera::IsBufferIDValid(id));
+ EXPECT_NE(handle, nullptr);
+ EXPECT_LT(id, kNumOfHandles);
+
+ // handleInt must be between [1, kNumOfHandles] as we "allocated" above.
+ EXPECT_LT(0u, handleInt);
+ EXPECT_LE(handleInt, kNumOfHandles);
+
+ inUseIDHandlePairs.push_back({id, handleInt});
+ EXPECT_TRUE(inUseIDs.insert(id).second);
+ EXPECT_TRUE(inUseHandles.insert(handleInt).second);
+ evsCam->checkBufferOrder();
+ }
+ }
+}
+
+} // namespace aidl::android::hardware::automotive::evs::implementation
diff --git a/automotive/evs/aidl/impl/default/tests/EvsCameraStateTest.cpp b/automotive/evs/aidl/impl/default/tests/EvsCameraStateTest.cpp
new file mode 100644
index 0000000..1925c79
--- /dev/null
+++ b/automotive/evs/aidl/impl/default/tests/EvsCameraStateTest.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2023 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 "EvsCamera.h"
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <cstdint>
+#include <unordered_set>
+#include <vector>
+
+namespace aidl::android::hardware::automotive::evs::implementation {
+
+class EvsCameraForTest : public EvsCamera {
+ private:
+ using Base = EvsCamera;
+
+ public:
+ using EvsCamera::mStreamState;
+ using EvsCamera::shutdown;
+ using EvsCamera::StreamState;
+
+ ~EvsCameraForTest() override { shutdown(); }
+
+ ::android::status_t allocateOneFrame(buffer_handle_t* handle) override {
+ static std::intptr_t handle_cnt = 0;
+ *handle = reinterpret_cast<buffer_handle_t>(++handle_cnt);
+ return ::android::OK;
+ }
+
+ void freeOneFrame(const buffer_handle_t /* handle */) override {
+ // Nothing to free because the handles are fake.
+ }
+
+ bool preVideoStreamStart_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override {
+ mPreStartCalled = true;
+ EXPECT_EQ(mStreamState, StreamState::STOPPED);
+ EXPECT_FALSE(mStreamStarted);
+ EXPECT_FALSE(mStreamStopped);
+ return Base::preVideoStreamStart_locked(receiver, status, lck);
+ }
+
+ bool startVideoStreamImpl_locked(const std::shared_ptr<evs::IEvsCameraStream>& /* receiver */,
+ ndk::ScopedAStatus& /* status */,
+ std::unique_lock<std::mutex>& /* lck */) override {
+ EXPECT_EQ(mStreamState, StreamState::RUNNING);
+ EXPECT_FALSE(mStreamStarted);
+ EXPECT_FALSE(mStreamStopped);
+ mStreamStarted = true;
+ return true;
+ }
+
+ bool postVideoStreamStart_locked(const std::shared_ptr<evs::IEvsCameraStream>& receiver,
+ ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override {
+ mPostStartCalled = true;
+ EXPECT_EQ(mStreamState, StreamState::RUNNING);
+ EXPECT_TRUE(mStreamStarted);
+ EXPECT_FALSE(mStreamStopped);
+ return Base::postVideoStreamStart_locked(receiver, status, lck);
+ }
+
+ bool preVideoStreamStop_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override {
+ // Skip the check if stop was called before.
+ if (!mPreStopCalled) {
+ mPreStopCalled = true;
+ EXPECT_EQ(mStreamState, StreamState::RUNNING);
+ EXPECT_TRUE(mStreamStarted);
+ EXPECT_FALSE(mStreamStopped);
+ }
+ return Base::preVideoStreamStop_locked(status, lck);
+ }
+
+ bool stopVideoStreamImpl_locked(ndk::ScopedAStatus& /* status */,
+ std::unique_lock<std::mutex>& /* lck */) override {
+ EXPECT_EQ(mStreamState, StreamState::STOPPING);
+ EXPECT_TRUE(mStreamStarted);
+ EXPECT_FALSE(mStreamStopped);
+ mStreamStopped = true;
+ return true;
+ }
+
+ bool postVideoStreamStop_locked(ndk::ScopedAStatus& status,
+ std::unique_lock<std::mutex>& lck) override {
+ mPostStopCalled = true;
+ const auto ret = Base::postVideoStreamStop_locked(status, lck);
+ EXPECT_EQ(mStreamState, StreamState::STOPPED);
+ EXPECT_TRUE(mStreamStarted);
+ EXPECT_TRUE(mStreamStopped);
+ return ret;
+ }
+
+ MOCK_METHOD(::ndk::ScopedAStatus, forcePrimaryClient,
+ (const std::shared_ptr<::aidl::android::hardware::automotive::evs::IEvsDisplay>&
+ in_display),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getCameraInfo,
+ (::aidl::android::hardware::automotive::evs::CameraDesc * _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getExtendedInfo,
+ (int32_t in_opaqueIdentifier, std::vector<uint8_t>* _aidl_return), (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getIntParameter,
+ (::aidl::android::hardware::automotive::evs::CameraParam in_id,
+ std::vector<int32_t>* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getIntParameterRange,
+ (::aidl::android::hardware::automotive::evs::CameraParam in_id,
+ ::aidl::android::hardware::automotive::evs::ParameterRange* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getParameterList,
+ (std::vector<::aidl::android::hardware::automotive::evs::CameraParam> *
+ _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getPhysicalCameraInfo,
+ (const std::string& in_deviceId,
+ ::aidl::android::hardware::automotive::evs::CameraDesc* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, setExtendedInfo,
+ (int32_t in_opaqueIdentifier, const std::vector<uint8_t>& in_opaqueValue),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, setIntParameter,
+ (::aidl::android::hardware::automotive::evs::CameraParam in_id, int32_t in_value,
+ std::vector<int32_t>* _aidl_return),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, setPrimaryClient, (), (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, unsetPrimaryClient, (), (override));
+
+ bool mStreamStarted = false;
+ bool mStreamStopped = false;
+ bool mPreStartCalled = false;
+ bool mPostStartCalled = false;
+ bool mPreStopCalled = false;
+ bool mPostStopCalled = false;
+};
+
+class MockEvsCameraStream : public evs::IEvsCameraStream {
+ MOCK_METHOD(::ndk::SpAIBinder, asBinder, (), (override));
+ MOCK_METHOD(bool, isRemote, (), (override));
+ MOCK_METHOD(
+ ::ndk::ScopedAStatus, deliverFrame,
+ (const std::vector<::aidl::android::hardware::automotive::evs::BufferDesc>& in_buffer),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, notify,
+ (const ::aidl::android::hardware::automotive::evs::EvsEventDesc& in_event),
+ (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getInterfaceVersion, (int32_t * _aidl_return), (override));
+ MOCK_METHOD(::ndk::ScopedAStatus, getInterfaceHash, (std::string * _aidl_return), (override));
+};
+
+using StreamState = EvsCameraForTest::StreamState;
+
+TEST(EvsCameraStateTest, StateChangeHooks) {
+ auto evsCam = ndk::SharedRefBase::make<EvsCameraForTest>();
+ auto mockStream = ndk::SharedRefBase::make<MockEvsCameraStream>();
+ EXPECT_FALSE(evsCam->mPreStartCalled);
+ EXPECT_FALSE(evsCam->mPostStartCalled);
+ EXPECT_FALSE(evsCam->mPreStopCalled);
+ EXPECT_FALSE(evsCam->mPostStopCalled);
+ EXPECT_FALSE(evsCam->mStreamStarted);
+ EXPECT_FALSE(evsCam->mStreamStopped);
+ EXPECT_EQ(evsCam->mStreamState, StreamState::STOPPED);
+ evsCam->startVideoStream(mockStream);
+
+ EXPECT_TRUE(evsCam->mPreStartCalled);
+ EXPECT_TRUE(evsCam->mPostStartCalled);
+ EXPECT_FALSE(evsCam->mPreStopCalled);
+ EXPECT_FALSE(evsCam->mPostStopCalled);
+ EXPECT_TRUE(evsCam->mStreamStarted);
+ EXPECT_FALSE(evsCam->mStreamStopped);
+ EXPECT_EQ(evsCam->mStreamState, StreamState::RUNNING);
+ evsCam->stopVideoStream();
+
+ EXPECT_TRUE(evsCam->mPreStartCalled);
+ EXPECT_TRUE(evsCam->mPostStartCalled);
+ EXPECT_TRUE(evsCam->mPreStopCalled);
+ EXPECT_TRUE(evsCam->mPostStopCalled);
+ EXPECT_TRUE(evsCam->mStreamStarted);
+ EXPECT_TRUE(evsCam->mStreamStopped);
+ EXPECT_EQ(evsCam->mStreamState, StreamState::STOPPED);
+
+ evsCam->shutdown();
+ EXPECT_EQ(evsCam->mStreamState, StreamState::DEAD);
+}
+
+} // namespace aidl::android::hardware::automotive::evs::implementation
diff --git a/automotive/remoteaccess/Android.bp b/automotive/remoteaccess/Android.bp
index 7cd6f60..e1e9041 100644
--- a/automotive/remoteaccess/Android.bp
+++ b/automotive/remoteaccess/Android.bp
@@ -42,6 +42,5 @@
imports: [],
},
],
- frozen: true,
-
+ frozen: false,
}
diff --git a/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl b/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl
index b0935c2..ccfa22d 100644
--- a/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl
+++ b/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl
@@ -40,4 +40,10 @@
void setRemoteTaskCallback(android.hardware.automotive.remoteaccess.IRemoteTaskCallback callback);
void clearRemoteTaskCallback();
void notifyApStateChange(in android.hardware.automotive.remoteaccess.ApState state);
+ boolean isTaskScheduleSupported();
+ void scheduleTask(in android.hardware.automotive.remoteaccess.ScheduleInfo scheduleInfo);
+ void unscheduleTask(String clientId, String scheduleId);
+ void unscheduleAllTasks(String clientId);
+ boolean isTaskScheduled(String clientId, String scheduleId);
+ List<android.hardware.automotive.remoteaccess.ScheduleInfo> getAllScheduledTasks(String clientId);
}
diff --git a/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/ScheduleInfo.aidl b/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/ScheduleInfo.aidl
new file mode 100644
index 0000000..a929e10
--- /dev/null
+++ b/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/ScheduleInfo.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2023 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.automotive.remoteaccess;
+@JavaDerive(equals=true, toString=true) @VintfStability
+parcelable ScheduleInfo {
+ String clientId;
+ String scheduleId;
+ byte[] taskData;
+ int count;
+ long startTimeInEpochSeconds;
+ long periodicInSeconds;
+}
diff --git a/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl b/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl
index 0f4125f..4912651 100644
--- a/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl
+++ b/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl
@@ -18,6 +18,7 @@
import android.hardware.automotive.remoteaccess.ApState;
import android.hardware.automotive.remoteaccess.IRemoteTaskCallback;
+import android.hardware.automotive.remoteaccess.ScheduleInfo;
/**
* Interface representing a remote wakeup client.
@@ -96,4 +97,69 @@
* <p>If {@code isWakeupRequired} is false, it must not try to wake up AP.
*/
void notifyApStateChange(in ApState state);
+
+ /**
+ * Returns whether task scheduling is supported.
+ *
+ * <p>If this returns {@code true}, user may use {@link scheduleTask} to schedule a task to be
+ * executed at a later time. If the device is off when the task is scheduled to be executed,
+ * the device will be woken up to execute the task.
+ *
+ * @return {@code true} if serverless remote task scheduling is supported.
+ */
+ boolean isTaskScheduleSupported();
+
+ /**
+ * Schedules a task to be executed later even when the vehicle is off.
+ *
+ * <p>If {@link isTaskScheduleSupported} returns {@code false}. This is no-op.
+ *
+ * <p>This sends a scheduled task message to a device external to Android so that the device
+ * can wake up Android and deliver the task through {@link IRemoteTaskCallback}.
+ *
+ * <p>Note that the scheduled task execution is on a best-effort basis. Multiple situations
+ * might cause the task not to execute successfully:
+ *
+ * <ul>
+ * <li>The vehicle is low on battery and the other device decides not to wake up Android.
+ * <li>User turns off vehicle while the task is executing.
+ * <li>The task logic itself fails.
+ *
+ * <p>Must return {@code EX_ILLEGAL_ARGUMENT} if a pending schedule with the same
+ * {@code scheduleId} for this client exists.
+ */
+ void scheduleTask(in ScheduleInfo scheduleInfo);
+
+ /**
+ * Unschedules a scheduled task.
+ *
+ * <p>If {@link isTaskScheduleSupported} returns {@code false}. This is no-op.
+ *
+ * <p>Does nothing if a pending schedule with {@code clientId} and {@code scheduleId} does not
+ * exist.
+ */
+ void unscheduleTask(String clientId, String scheduleId);
+
+ /**
+ * Unschedules all scheduled tasks for the client.
+ *
+ * <p>If {@link isTaskScheduleSupported} returns {@code false}. This is no-op.
+ */
+ void unscheduleAllTasks(String clientId);
+
+ /**
+ * Returns whether the specified task is scheduled.
+ *
+ * <p>If {@link isTaskScheduleSupported} returns {@code false}, This must return {@code false}.
+ */
+ boolean isTaskScheduled(String clientId, String scheduleId);
+
+ /**
+ * Gets all pending scheduled tasks for the client.
+ *
+ * <p>If {@link isTaskScheduleSupported} returns {@code false}. This must return empty array.
+ *
+ * <p>The finished scheduled tasks will not be included.
+ */
+ List<ScheduleInfo> getAllScheduledTasks(String clientId);
}
diff --git a/automotive/remoteaccess/android/hardware/automotive/remoteaccess/ScheduleInfo.aidl b/automotive/remoteaccess/android/hardware/automotive/remoteaccess/ScheduleInfo.aidl
new file mode 100644
index 0000000..cf1437b
--- /dev/null
+++ b/automotive/remoteaccess/android/hardware/automotive/remoteaccess/ScheduleInfo.aidl
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2023 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.automotive.remoteaccess;
+
+@VintfStability
+@JavaDerive(equals=true, toString=true)
+parcelable ScheduleInfo {
+ /**
+ * The ID used to identify the client this schedule is for. This must be one of the
+ * preconfigured remote access serverless client ID defined in car service resource
+ * {@code R.xml.remote_access_serverless_client_map}.
+ */
+ String clientId;
+ /**
+ * A unique scheduling ID (among the same client). Adding a new schedule info with a duplicate
+ * scheduleId will return {@code EX_ILLEGAL_ARGUMENT}.
+ */
+ String scheduleId;
+ /**
+ * The opaque task data that will be sent back to the remote task client app when the task is
+ * executed. It is not interpreted/parsed by the Android system.
+ */
+ byte[] taskData;
+ /**
+ * How many times this task will be executed. 0 means infinite.
+ *
+ * <p>This must be >= 0.
+ */
+ int count;
+ /**
+ * The start time in epoch seconds.
+ *
+ * <p>The external device issuing remote task must have a clock synced with the
+ * {@code System.currentTimeMillis()} used in Android system.
+ *
+ * <p>Optionally, the VHAL property {@code EPOCH_TIME} can be used to sync the time.
+ *
+ * <p>This must be >= 0.
+ */
+ long startTimeInEpochSeconds;
+ /**
+ * The interval (in seconds) between scheduled task execution.
+ *
+ * <p>This must be >=0. This is not useful when {@code count} is 1. If this is 0,
+ * The tasks will be delivered multiple times with no interval in between.
+ */
+ long periodicInSeconds;
+}
diff --git a/automotive/remoteaccess/hal/default/Android.bp b/automotive/remoteaccess/hal/default/Android.bp
index 48a7309..70dba30 100644
--- a/automotive/remoteaccess/hal/default/Android.bp
+++ b/automotive/remoteaccess/hal/default/Android.bp
@@ -47,9 +47,20 @@
],
}
+// TODO(b/295393732): remove this once we finish the migration from V1 to V2.
cc_binary {
name: "android.hardware.automotive.remoteaccess@V1-default-service",
defaults: ["remote-access-hal-defaults"],
+ vintf_fragments: ["remoteaccess-default-service-v1.xml"],
+ init_rc: ["remoteaccess-default-service-v1.rc"],
+ cflags: [
+ "-DGRPC_SERVICE_ADDRESS=\"10.0.2.2:50051\"",
+ ],
+}
+
+cc_binary {
+ name: "android.hardware.automotive.remoteaccess@V2-default-service",
+ defaults: ["remote-access-hal-defaults"],
vintf_fragments: ["remoteaccess-default-service.xml"],
init_rc: ["remoteaccess-default-service.rc"],
cflags: [
@@ -57,9 +68,21 @@
],
}
+// TODO(b/295393732): remove this once we finish the migration from V1 to V2.
cc_binary {
name: "android.hardware.automotive.remoteaccess@V1-tcu-test-service",
defaults: ["remote-access-hal-defaults"],
+ vintf_fragments: ["remoteaccess-default-service-v1.xml"],
+ init_rc: ["remoteaccess-tcu-test-service-v1.rc"],
+ cflags: [
+ "-DGRPC_SERVICE_ADDRESS=\"10.10.10.1:50051\"",
+ "-DGRPC_SERVICE_IFNAME=\"eth1\"",
+ ],
+}
+
+cc_binary {
+ name: "android.hardware.automotive.remoteaccess@V2-tcu-test-service",
+ defaults: ["remote-access-hal-defaults"],
vintf_fragments: ["remoteaccess-default-service.xml"],
init_rc: ["remoteaccess-tcu-test-service.rc"],
cflags: [
@@ -77,7 +100,7 @@
"src/RemoteAccessService.cpp",
],
whole_static_libs: [
- "android.hardware.automotive.remoteaccess-V1-ndk",
+ "android.hardware.automotive.remoteaccess-V2-ndk",
"wakeup_client_protos",
"libvhalclient",
],
@@ -99,7 +122,7 @@
}
cc_fuzz {
- name: "android.hardware.automotive.remoteaccess@V1-default-service.aidl_fuzzer",
+ name: "android.hardware.automotive.remoteaccess@V2-default-service.aidl_fuzzer",
srcs: ["fuzzer/fuzzer.cpp"],
whole_static_libs: [
"RemoteAccessService",
diff --git a/automotive/remoteaccess/hal/default/include/RemoteAccessService.h b/automotive/remoteaccess/hal/default/include/RemoteAccessService.h
index b18986a..1fc4037 100644
--- a/automotive/remoteaccess/hal/default/include/RemoteAccessService.h
+++ b/automotive/remoteaccess/hal/default/include/RemoteAccessService.h
@@ -21,6 +21,7 @@
#include <aidl/android/hardware/automotive/remoteaccess/BnRemoteAccess.h>
#include <aidl/android/hardware/automotive/remoteaccess/BnRemoteTaskCallback.h>
#include <aidl/android/hardware/automotive/remoteaccess/IRemoteTaskCallback.h>
+#include <aidl/android/hardware/automotive/remoteaccess/ScheduleInfo.h>
#include <android-base/thread_annotations.h>
#include <android/binder_auto_utils.h>
#include <utils/SystemClock.h>
@@ -78,6 +79,25 @@
ndk::ScopedAStatus notifyApStateChange(
const aidl::android::hardware::automotive::remoteaccess::ApState& newState) override;
+ ndk::ScopedAStatus isTaskScheduleSupported(bool* out) override;
+
+ ndk::ScopedAStatus scheduleTask(
+ const aidl::android::hardware::automotive::remoteaccess::ScheduleInfo& scheduleInfo)
+ override;
+
+ ndk::ScopedAStatus unscheduleTask(const std::string& clientId,
+ const std::string& scheduleId) override;
+
+ ndk::ScopedAStatus unscheduleAllTasks(const std::string& clientId) override;
+
+ ndk::ScopedAStatus isTaskScheduled(const std::string& clientId, const std::string& scheduleId,
+ bool* out) override;
+
+ ndk::ScopedAStatus getAllScheduledTasks(
+ const std::string& clientId,
+ std::vector<aidl::android::hardware::automotive::remoteaccess::ScheduleInfo>* out)
+ override;
+
binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
private:
diff --git a/automotive/remoteaccess/hal/default/remoteaccess-default-service-v1.rc b/automotive/remoteaccess/hal/default/remoteaccess-default-service-v1.rc
new file mode 100644
index 0000000..b7a9cdc
--- /dev/null
+++ b/automotive/remoteaccess/hal/default/remoteaccess-default-service-v1.rc
@@ -0,0 +1,4 @@
+service vendor.remoteaccess-default /vendor/bin/hw/android.hardware.automotive.remoteaccess@V1-default-service
+ class hal
+ user vehicle_network
+ group system inet
diff --git a/automotive/remoteaccess/hal/default/remoteaccess-default-service-v1.xml b/automotive/remoteaccess/hal/default/remoteaccess-default-service-v1.xml
new file mode 100644
index 0000000..d050a1b
--- /dev/null
+++ b/automotive/remoteaccess/hal/default/remoteaccess-default-service-v1.xml
@@ -0,0 +1,7 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.automotive.remoteaccess</name>
+ <version>1</version>
+ <fqname>IRemoteAccess/default</fqname>
+ </hal>
+</manifest>
diff --git a/automotive/remoteaccess/hal/default/remoteaccess-default-service.rc b/automotive/remoteaccess/hal/default/remoteaccess-default-service.rc
index b7a9cdc..c9b282c 100644
--- a/automotive/remoteaccess/hal/default/remoteaccess-default-service.rc
+++ b/automotive/remoteaccess/hal/default/remoteaccess-default-service.rc
@@ -1,4 +1,4 @@
-service vendor.remoteaccess-default /vendor/bin/hw/android.hardware.automotive.remoteaccess@V1-default-service
+service vendor.remoteaccess-default /vendor/bin/hw/android.hardware.automotive.remoteaccess@V2-default-service
class hal
user vehicle_network
group system inet
diff --git a/automotive/remoteaccess/hal/default/remoteaccess-default-service.xml b/automotive/remoteaccess/hal/default/remoteaccess-default-service.xml
index d050a1b..44ac309 100644
--- a/automotive/remoteaccess/hal/default/remoteaccess-default-service.xml
+++ b/automotive/remoteaccess/hal/default/remoteaccess-default-service.xml
@@ -1,7 +1,7 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.automotive.remoteaccess</name>
- <version>1</version>
+ <version>2</version>
<fqname>IRemoteAccess/default</fqname>
</hal>
</manifest>
diff --git a/automotive/remoteaccess/hal/default/remoteaccess-tcu-test-service-v1.rc b/automotive/remoteaccess/hal/default/remoteaccess-tcu-test-service-v1.rc
new file mode 100644
index 0000000..59315eb
--- /dev/null
+++ b/automotive/remoteaccess/hal/default/remoteaccess-tcu-test-service-v1.rc
@@ -0,0 +1,5 @@
+service vendor.remoteaccess-default /vendor/bin/hw/android.hardware.automotive.remoteaccess@V1-tcu-test-service
+ class hal
+ user vehicle_network
+ group system inet
+ capabilities NET_RAW
diff --git a/automotive/remoteaccess/hal/default/remoteaccess-tcu-test-service.rc b/automotive/remoteaccess/hal/default/remoteaccess-tcu-test-service.rc
index 59315eb..19faaf4 100644
--- a/automotive/remoteaccess/hal/default/remoteaccess-tcu-test-service.rc
+++ b/automotive/remoteaccess/hal/default/remoteaccess-tcu-test-service.rc
@@ -1,4 +1,4 @@
-service vendor.remoteaccess-default /vendor/bin/hw/android.hardware.automotive.remoteaccess@V1-tcu-test-service
+service vendor.remoteaccess-default /vendor/bin/hw/android.hardware.automotive.remoteaccess@V2-tcu-test-service
class hal
user vehicle_network
group system inet
diff --git a/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp b/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp
index 5081ac0..7721bf4 100644
--- a/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp
+++ b/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp
@@ -39,6 +39,7 @@
using ::aidl::android::hardware::automotive::remoteaccess::ApState;
using ::aidl::android::hardware::automotive::remoteaccess::IRemoteTaskCallback;
+using ::aidl::android::hardware::automotive::remoteaccess::ScheduleInfo;
using ::aidl::android::hardware::automotive::vehicle::VehicleProperty;
using ::android::base::Error;
using ::android::base::ParseInt;
@@ -313,6 +314,41 @@
return ScopedAStatus::ok();
}
+ScopedAStatus RemoteAccessService::isTaskScheduleSupported([[maybe_unused]] bool* out) {
+ // TODO(b/297271235): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus RemoteAccessService::scheduleTask([[maybe_unused]] const ScheduleInfo& scheduleInfo) {
+ // TODO(b/297271235): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus RemoteAccessService::unscheduleTask([[maybe_unused]] const std::string& clientId,
+ [[maybe_unused]] const std::string& scheduleId) {
+ // TODO(b/297271235): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus RemoteAccessService::unscheduleAllTasks(
+ [[maybe_unused]] const std::string& clientId) {
+ // TODO(b/297271235): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus RemoteAccessService::isTaskScheduled([[maybe_unused]] const std::string& clientId,
+ [[maybe_unused]] const std::string& scheduleId,
+ [[maybe_unused]] bool* out) {
+ // TODO(b/297271235): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus RemoteAccessService::getAllScheduledTasks(const std::string& clientId,
+ std::vector<ScheduleInfo>* out) {
+ // TODO(b/297271235): implement this.
+ return ScopedAStatus::ok();
+}
+
bool RemoteAccessService::checkDumpPermission() {
uid_t uid = AIBinder_getCallingUid();
return uid == AID_ROOT || uid == AID_SHELL || uid == AID_SYSTEM;
diff --git a/automotive/remoteaccess/test_grpc_server/README.md b/automotive/remoteaccess/test_grpc_server/README.md
index af3d54a..d2b6bbe 100644
--- a/automotive/remoteaccess/test_grpc_server/README.md
+++ b/automotive/remoteaccess/test_grpc_server/README.md
@@ -141,7 +141,7 @@
* The android lunch target: sdk_car_x86_64-userdebug and
cf_x86_64_auto-userdebug already contains the default remote access HAL. For
other lunch target, you can add the default remote access HAL by adding
- 'android.hardware.automotive.remoteaccess@V1-default-service' to
+ 'android.hardware.automotive.remoteaccess@V2-default-service' to
'PRODUCT_PACKAGES' variable in mk file, see `device/generic/car/common/car.mk`
as example.
diff --git a/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp b/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp
index 98834f5..4c4cc70 100644
--- a/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp
+++ b/automotive/sv/1.0/default/tests/fuzzer/AutomotiveSvV1_0Fuzzer.cpp
@@ -41,35 +41,32 @@
void SurroundViewFuzzer::invoke2dSessionAPI() {
sp<ISurroundView2dSession> surroundView2dSession;
+ sp<SurroundViewStream> handler;
+ mSurroundViewService->start2dSession(
+ [&surroundView2dSession](const sp<ISurroundView2dSession>& session, SvResult result) {
+ if (result == SvResult::OK) {
+ surroundView2dSession = session;
+ }
+ });
+
+ if (surroundView2dSession && !mIs2dStreamStarted) {
+ handler = sp<SurroundViewStream>::make(surroundView2dSession);
+ if (surroundView2dSession->startStream(handler) == SvResult::OK) {
+ mIs2dStreamStarted = true;
+ }
+ }
while (mFuzzedDataProvider.remaining_bytes() > 0) {
auto surroundView2dFunc = mFuzzedDataProvider.PickValueInArray<
const std::function<void()>>({
[&]() {
- mSurroundViewService->start2dSession(
- [&surroundView2dSession](const sp<ISurroundView2dSession>& session,
- SvResult result) {
- if (result == SvResult::OK) {
- surroundView2dSession = session;
- }
- });
- },
- [&]() {
- if (surroundView2dSession) {
- sp<SurroundViewStream> handler =
- sp<SurroundViewStream>::make(surroundView2dSession);
- surroundView2dSession->startStream(handler);
- mIs2dStreamStarted = true;
- }
- },
- [&]() {
if (surroundView2dSession) {
surroundView2dSession->get2dMappingInfo(
[]([[maybe_unused]] Sv2dMappingInfo info) {});
}
},
[&]() {
- if (surroundView2dSession) {
+ if (surroundView2dSession && mIs2dStreamStarted) {
Sv2dConfig config;
config.width = mFuzzedDataProvider.ConsumeIntegralInRange<uint32_t>(
kMinConfigDimension, kMaxConfigDimension);
@@ -149,8 +146,11 @@
}
},
[&]() {
- mSurroundViewService->stop2dSession(
+ SvResult result = mSurroundViewService->stop2dSession(
mFuzzedDataProvider.ConsumeBool() ? surroundView2dSession : nullptr);
+ if (result == SvResult::OK) {
+ mIs2dStreamStarted = false;
+ }
},
});
surroundView2dFunc();
@@ -159,31 +159,40 @@
if (surroundView2dSession && mIs2dStreamStarted) {
surroundView2dSession->stopStream();
}
+
+ if (surroundView2dSession) {
+ mSurroundViewService->stop2dSession(surroundView2dSession);
+ }
}
void SurroundViewFuzzer::invoke3dSessionAPI() {
sp<ISurroundView3dSession> surroundView3dSession;
+ sp<SurroundViewStream> handler;
+ mSurroundViewService->start3dSession(
+ [&surroundView3dSession](const sp<ISurroundView3dSession>& session, SvResult result) {
+ if (result == SvResult::OK) {
+ surroundView3dSession = session;
+ }
+ });
+
+ const size_t numViews = mFuzzedDataProvider.ConsumeIntegralInRange<size_t>(1, kMaxViews);
+ std::vector<View3d> views(numViews);
+ for (size_t i = 0; i < numViews; ++i) {
+ views[i].viewId = mFuzzedDataProvider.ConsumeIntegral<uint32_t>();
+ }
+ surroundView3dSession->setViews(views);
+
+ if (surroundView3dSession) {
+ handler = sp<SurroundViewStream>::make(surroundView3dSession);
+
+ if (surroundView3dSession->startStream(handler) == SvResult::OK) {
+ mIs3dStreamStarted = true;
+ }
+ }
while (mFuzzedDataProvider.remaining_bytes() > 0) {
auto surroundView3dFunc = mFuzzedDataProvider.PickValueInArray<
const std::function<void()>>({
[&]() {
- mSurroundViewService->start3dSession(
- [&surroundView3dSession](const sp<ISurroundView3dSession>& session,
- SvResult result) {
- if (result == SvResult::OK) {
- surroundView3dSession = session;
- }
- });
- },
- [&]() {
- if (surroundView3dSession) {
- sp<SurroundViewStream> handler =
- sp<SurroundViewStream>::make(surroundView3dSession);
- surroundView3dSession->startStream(handler);
- mIs3dStreamStarted = true;
- }
- },
- [&]() {
if (surroundView3dSession) {
const size_t numViews =
mFuzzedDataProvider.ConsumeIntegralInRange<size_t>(1, kMaxViews);
@@ -195,7 +204,7 @@
}
},
[&]() {
- if (surroundView3dSession) {
+ if (surroundView3dSession && mIs3dStreamStarted) {
Sv3dConfig config;
config.width = mFuzzedDataProvider.ConsumeIntegralInRange<uint32_t>(
kMinConfigDimension, kMaxConfigDimension);
@@ -306,8 +315,11 @@
}
},
[&]() {
- mSurroundViewService->stop3dSession(
+ SvResult result = mSurroundViewService->stop3dSession(
mFuzzedDataProvider.ConsumeBool() ? surroundView3dSession : nullptr);
+ if (result == SvResult::OK) {
+ mIs3dStreamStarted = false;
+ }
},
});
surroundView3dFunc();
@@ -315,6 +327,10 @@
if (surroundView3dSession && mIs3dStreamStarted) {
surroundView3dSession->stopStream();
}
+
+ if (surroundView3dSession) {
+ mSurroundViewService->stop3dSession(surroundView3dSession);
+ }
}
void SurroundViewFuzzer::process() {
diff --git a/automotive/vehicle/2.0/default/tests/fuzzer/VehicleManager_fuzzer.cpp b/automotive/vehicle/2.0/default/tests/fuzzer/VehicleManager_fuzzer.cpp
index 796c08f..8a085e5 100644
--- a/automotive/vehicle/2.0/default/tests/fuzzer/VehicleManager_fuzzer.cpp
+++ b/automotive/vehicle/2.0/default/tests/fuzzer/VehicleManager_fuzzer.cpp
@@ -161,10 +161,13 @@
hidl_string debugOption = mFuzzedDataProvider->PickValueInArray(
{"--help", "--list", "--get", "--set", "", "invalid"});
hidl_handle fd = {};
- fd.setTo(native_handle_create(/*numFds=*/1, /*numInts=*/0), /*shouldOwn=*/true);
+
+ native_handle_t* rawHandle = native_handle_create(/*numFds=*/1, /*numInts=*/0);
+ fd.setTo(native_handle_clone(rawHandle), /*shouldOwn=*/true);
mManager->debug(fd, {});
mManager->debug(fd, {debugOption});
+ native_handle_delete(rawHandle);
}
void VehicleHalManagerFuzzer::invokePropConfigs() {
diff --git a/automotive/vehicle/OWNERS b/automotive/vehicle/OWNERS
index 429ec39..d6969e5 100644
--- a/automotive/vehicle/OWNERS
+++ b/automotive/vehicle/OWNERS
@@ -1,3 +1,2 @@
ericjeong@google.com
-keunyoung@google.com
shanyu@google.com
diff --git a/automotive/vehicle/aidl/impl/README.md b/automotive/vehicle/aidl/impl/README.md
index 121ffd1..2cd3a3e 100644
--- a/automotive/vehicle/aidl/impl/README.md
+++ b/automotive/vehicle/aidl/impl/README.md
@@ -46,7 +46,7 @@
use this library, along with their own implementation for `IVehicleHardware`
interface.
-Also defines a binary `android.hardware.automotive.vehicle@V1-default-service`
+Also defines a binary `android.hardware.automotive.vehicle@V3-default-service`
which is the reference VHAL implementation. It implements `IVehicle.aidl`
interface. It uses `DefaultVehicleHal`, along with `FakeVehicleHardware`
(in fake_impl). It simulates the vehicle bus interaction by using an
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
index f130fa4..e8da43a 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
@@ -99,12 +99,17 @@
const std::shared_ptr<VehiclePropValuePool> mValuePool;
const std::shared_ptr<VehiclePropertyStore> mServerSidePropStore;
+ const std::string mDefaultConfigDir;
+ const std::string mOverrideConfigDir;
+
ValueResultType getValue(
const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value) const;
VhalResult<void> setValue(
const aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);
+ bool UseOverrideConfigDir();
+
private:
// Expose private methods to unit test.
friend class FakeVehicleHardwareTestHelper;
@@ -156,8 +161,6 @@
aidl::android::hardware::automotive::vehicle::SetValueRequest>
mPendingSetValueRequests;
- const std::string mDefaultConfigDir;
- const std::string mOverrideConfigDir;
const bool mForceOverride;
bool mAddExtraTestVendorConfigs;
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
index 73defe2..13c48c6 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
@@ -241,6 +241,8 @@
std::string overrideConfigDir, bool forceOverride)
: mValuePool(std::make_unique<VehiclePropValuePool>()),
mServerSidePropStore(new VehiclePropertyStore(mValuePool)),
+ mDefaultConfigDir(defaultConfigDir),
+ mOverrideConfigDir(overrideConfigDir),
mFakeObd2Frame(new obd2frame::FakeObd2Frame(mServerSidePropStore)),
mFakeUserHal(new FakeUserHal(mValuePool)),
mRecurrentTimer(new RecurrentTimer()),
@@ -248,8 +250,6 @@
[this](const VehiclePropValue& value) { eventFromVehicleBus(value); })),
mPendingGetValueRequests(this),
mPendingSetValueRequests(this),
- mDefaultConfigDir(defaultConfigDir),
- mOverrideConfigDir(overrideConfigDir),
mForceOverride(forceOverride) {
init();
}
@@ -260,11 +260,15 @@
mGeneratorHub.reset();
}
+bool FakeVehicleHardware::UseOverrideConfigDir() {
+ return mForceOverride ||
+ android::base::GetBoolProperty(OVERRIDE_PROPERTY, /*default_value=*/false);
+}
+
std::unordered_map<int32_t, ConfigDeclaration> FakeVehicleHardware::loadConfigDeclarations() {
std::unordered_map<int32_t, ConfigDeclaration> configsByPropId;
loadPropConfigsFromDir(mDefaultConfigDir, &configsByPropId);
- if (mForceOverride ||
- android::base::GetBoolProperty(OVERRIDE_PROPERTY, /*default_value=*/false)) {
+ if (UseOverrideConfigDir()) {
loadPropConfigsFromDir(mOverrideConfigDir, &configsByPropId);
}
return configsByPropId;
diff --git a/automotive/vehicle/aidl/impl/grpc/GRPCVehicleHardware.h b/automotive/vehicle/aidl/impl/grpc/GRPCVehicleHardware.h
index e740da7..ddd620e 100644
--- a/automotive/vehicle/aidl/impl/grpc/GRPCVehicleHardware.h
+++ b/automotive/vehicle/aidl/impl/grpc/GRPCVehicleHardware.h
@@ -82,6 +82,10 @@
bool waitForConnected(std::chrono::milliseconds waitTime);
+ protected:
+ std::shared_mutex mCallbackMutex;
+ std::unique_ptr<const PropertyChangeCallback> mOnPropChange;
+
private:
void ValuePollingLoop();
@@ -90,8 +94,6 @@
std::unique_ptr<proto::VehicleServer::Stub> mGrpcStub;
std::thread mValuePollingThread;
- std::shared_mutex mCallbackMutex;
- std::unique_ptr<const PropertyChangeCallback> mOnPropChange;
std::unique_ptr<const PropertySetErrorCallback> mOnSetErr;
std::mutex mShutdownMutex;
diff --git a/automotive/vehicle/aidl/impl/vhal/Android.bp b/automotive/vehicle/aidl/impl/vhal/Android.bp
index 4feea79..c29345f 100644
--- a/automotive/vehicle/aidl/impl/vhal/Android.bp
+++ b/automotive/vehicle/aidl/impl/vhal/Android.bp
@@ -19,7 +19,7 @@
}
cc_binary {
- name: "android.hardware.automotive.vehicle@V1-default-service",
+ name: "android.hardware.automotive.vehicle@V3-default-service",
vendor: true,
defaults: [
"FakeVehicleHardwareDefaults",
@@ -68,7 +68,7 @@
}
cc_fuzz {
- name: "android.hardware.automotive.vehicle@V1-default-service_fuzzer",
+ name: "android.hardware.automotive.vehicle-default-service_fuzzer",
vendor: true,
defaults: [
"FakeVehicleHardwareDefaults",
diff --git a/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
index 19267cd..9fa7b98 100644
--- a/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
+++ b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
@@ -1,4 +1,4 @@
-service vendor.vehicle-hal-default /vendor/bin/hw/android.hardware.automotive.vehicle@V1-default-service
+service vendor.vehicle-hal-default /vendor/bin/hw/android.hardware.automotive.vehicle@V3-default-service
class early_hal
user vehicle_network
group system inet
diff --git a/automotive/vehicle/proto/Android.bp b/automotive/vehicle/proto/Android.bp
index 683f128..7b98540 100644
--- a/automotive/vehicle/proto/Android.bp
+++ b/automotive/vehicle/proto/Android.bp
@@ -27,6 +27,7 @@
visibility: [
"//hardware/interfaces/automotive/vehicle:__subpackages__",
"//device/generic/car/emulator:__subpackages__",
+ "//device/google/sdv/sdv_ivi_cf:__subpackages__",
],
vendor: true,
host_supported: true,
diff --git a/biometrics/common/util/include/util/Util.h b/biometrics/common/util/include/util/Util.h
index da19dc6..efd66bc 100644
--- a/biometrics/common/util/include/util/Util.h
+++ b/biometrics/common/util/include/util/Util.h
@@ -23,6 +23,9 @@
#include <thread>
#include <vector>
+#include <android-base/parseint.h>
+using ::android::base::ParseInt;
+
namespace aidl::android::hardware::biometrics {
#define SLEEP_MS(x) \
@@ -64,6 +67,87 @@
std::sregex_token_iterator());
return parts;
}
+
+ // Returns a vector of integers for the string separated by comma,
+ // Empty vector is returned if there is any parsing error
+ static std::vector<int32_t> parseIntSequence(const std::string& str,
+ const std::string& sep = ",") {
+ std::vector<std::string> seqs = Util::split(str, sep);
+ std::vector<int32_t> res;
+
+ for (const auto& seq : seqs) {
+ int32_t val;
+ if (ParseInt(seq, &val)) {
+ res.push_back(val);
+ } else {
+ LOG(WARNING) << "Invalid int sequence:" + str + " seq:" + seq;
+ res.clear();
+ break;
+ }
+ }
+
+ return res;
+ }
+
+ // Parses a single enrollment stage string in the format of
+ // enroll_stage_spec: <duration>[-acquiredInfos]
+ // duration: integerInMs
+ // acquiredInfos: [info1,info2,...]
+ //
+ // Returns false if there is parsing error
+ //
+ static bool parseEnrollmentCaptureSingle(const std::string& str,
+ std::vector<std::vector<int32_t>>& res) {
+ std::vector<int32_t> defaultAcquiredInfo = {1};
+ bool aborted = true;
+
+ do {
+ std::smatch sms;
+ // Parses strings like "1000-[5,1]" or "500"
+ std::regex ex("((\\d+)(-\\[([\\d|,]+)\\])?)");
+ if (!regex_match(str.cbegin(), str.cend(), sms, ex)) break;
+ int32_t duration;
+ if (!ParseInt(sms.str(2), &duration)) break;
+ res.push_back({duration});
+ if (!sms.str(4).empty()) {
+ auto acqv = parseIntSequence(sms.str(4));
+ if (acqv.empty()) break;
+ res.push_back(acqv);
+ } else
+ res.push_back(defaultAcquiredInfo);
+ aborted = false;
+ } while (0);
+
+ return !aborted;
+ }
+
+ // Parses enrollment string consisting of one or more stages in the formst of
+ // <enroll_stage_spec>[,enroll_stage_spec,...]
+ // Empty vector is returned in case of parsing error
+ static std::vector<std::vector<int32_t>> parseEnrollmentCapture(const std::string& str) {
+ std::vector<std::vector<int32_t>> res;
+
+ std::string s(str);
+ s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end());
+ bool aborted = false;
+ std::smatch sms;
+ // Parses strings like "1000-[5,1],500,800-[6,5,1]"
+ // -------------- ----- ---------------
+ // into parts: A B C
+ while (regex_search(s, sms, std::regex("^(,)?(\\d+(-\\[[\\d|,]+\\])?)"))) {
+ if (!parseEnrollmentCaptureSingle(sms.str(2), res)) {
+ aborted = true;
+ break;
+ }
+ s = sms.suffix();
+ }
+ if (aborted || s.length() != 0) {
+ res.clear();
+ LOG(ERROR) << "Failed to parse enrollment captures:" + str;
+ }
+
+ return res;
+ }
};
} // namespace aidl::android::hardware::biometrics
diff --git a/biometrics/face/aidl/default/FakeFaceEngine.cpp b/biometrics/face/aidl/default/FakeFaceEngine.cpp
index 0f088f4..578231d 100644
--- a/biometrics/face/aidl/default/FakeFaceEngine.cpp
+++ b/biometrics/face/aidl/default/FakeFaceEngine.cpp
@@ -136,56 +136,127 @@
const std::future<void>& cancel) {
BEGIN_OP(FaceHalProperties::operation_authenticate_latency().value_or(0));
- // Signal to the framework that we have begun authenticating.
- AuthenticationFrame frame;
- frame.data.acquiredInfo = AcquiredInfo::START;
- frame.data.vendorCode = 0;
- cb->onAuthenticationFrame(frame);
-
- // Also signal that we have opened the camera.
- frame = {};
- frame.data.acquiredInfo = AcquiredInfo::FIRST_FRAME_RECEIVED;
- frame.data.vendorCode = 0;
- cb->onAuthenticationFrame(frame);
-
- auto now = Util::getSystemNanoTime();
- int64_t duration = FaceHalProperties::operation_authenticate_duration().value_or(0);
- if (duration > 0) {
- do {
- SLEEP_MS(5);
- } while (!Util::hasElapsed(now, duration));
- }
-
- if (FaceHalProperties::operation_authenticate_fails().value_or(false)) {
- LOG(ERROR) << "Fail: operation_authenticate_fails";
- cb->onError(Error::VENDOR, 0 /* vendorError */);
- return;
- }
-
- if (FaceHalProperties::lockout().value_or(false)) {
- LOG(ERROR) << "Fail: lockout";
- cb->onLockoutPermanent();
- cb->onError(Error::HW_UNAVAILABLE, 0 /* vendorError */);
- return;
- }
-
- if (shouldCancel(cancel)) {
- LOG(ERROR) << "Fail: cancel";
- cb->onError(Error::CANCELED, 0 /* vendorCode */);
- return;
- }
-
auto id = FaceHalProperties::enrollment_hit().value_or(0);
auto enrolls = FaceHalProperties::enrollments();
auto isEnrolled = std::find(enrolls.begin(), enrolls.end(), id) != enrolls.end();
- if (id < 0 || !isEnrolled) {
- LOG(ERROR) << (isEnrolled ? "invalid enrollment hit" : "Fail: not enrolled");
- cb->onAuthenticationFailed();
+
+ auto vec2str = [](std::vector<AcquiredInfo> va) {
+ std::stringstream ss;
+ bool isFirst = true;
+ for (auto ac : va) {
+ if (!isFirst) ss << ",";
+ ss << std::to_string((int8_t)ac);
+ isFirst = false;
+ }
+ return ss.str();
+ };
+
+ // default behavior mimic face sensor in U
+ int64_t defaultAuthDuration = 500;
+ std::string defaultAcquiredInfo =
+ vec2str({AcquiredInfo::START, AcquiredInfo::FIRST_FRAME_RECEIVED});
+ if (!isEnrolled) {
+ std::vector<AcquiredInfo> v;
+ for (int i = 0; i < 56; i++) v.push_back(AcquiredInfo::NOT_DETECTED);
+ defaultAcquiredInfo += "," + vec2str(v);
+ defaultAuthDuration = 2100;
+ } else {
+ defaultAcquiredInfo += "," + vec2str({AcquiredInfo::TOO_BRIGHT, AcquiredInfo::TOO_BRIGHT,
+ AcquiredInfo::TOO_BRIGHT, AcquiredInfo::TOO_BRIGHT,
+ AcquiredInfo::GOOD, AcquiredInfo::GOOD});
+ }
+
+ int64_t now = Util::getSystemNanoTime();
+ int64_t duration =
+ FaceHalProperties::operation_authenticate_duration().value_or(defaultAuthDuration);
+ auto acquired =
+ FaceHalProperties::operation_authenticate_acquired().value_or(defaultAcquiredInfo);
+ auto acquiredInfos = Util::parseIntSequence(acquired);
+ int N = acquiredInfos.size();
+
+ if (N == 0) {
+ LOG(ERROR) << "Fail to parse authentiate acquired info: " + acquired;
cb->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorError */);
return;
}
- cb->onAuthenticationSucceeded(id, {} /* hat */);
+ int i = 0;
+ do {
+ if (FaceHalProperties::lockout().value_or(false)) {
+ LOG(ERROR) << "Fail: lockout";
+ cb->onLockoutPermanent();
+ cb->onError(Error::HW_UNAVAILABLE, 0 /* vendorError */);
+ return;
+ }
+
+ if (FaceHalProperties::operation_authenticate_fails().value_or(false)) {
+ LOG(ERROR) << "Fail: operation_authenticate_fails";
+ cb->onAuthenticationFailed();
+ return;
+ }
+
+ auto err = FaceHalProperties::operation_authenticate_error().value_or(0);
+ if (err != 0) {
+ LOG(ERROR) << "Fail: operation_authenticate_error";
+ auto ec = convertError(err);
+ cb->onError(ec.first, ec.second);
+ return; /* simply terminating current operation for any user inserted error,
+ revisit if tests need*/
+ }
+
+ if (shouldCancel(cancel)) {
+ LOG(ERROR) << "Fail: cancel";
+ cb->onError(Error::CANCELED, 0 /* vendorCode */);
+ return;
+ }
+
+ if (i < N) {
+ auto ac = convertAcquiredInfo(acquiredInfos[i]);
+ AuthenticationFrame frame;
+ frame.data.acquiredInfo = ac.first;
+ frame.data.vendorCode = ac.second;
+ cb->onAuthenticationFrame(frame);
+ LOG(INFO) << "AcquiredInfo:" << i << ": (" << (int)ac.first << "," << (int)ac.second
+ << ")";
+ i++;
+ }
+
+ SLEEP_MS(duration / N);
+ } while (!Util::hasElapsed(now, duration));
+
+ if (id > 0 && isEnrolled) {
+ cb->onAuthenticationSucceeded(id, {} /* hat */);
+ return;
+ } else {
+ LOG(ERROR) << "Fail: face not enrolled";
+ cb->onAuthenticationFailed();
+ cb->onError(Error::TIMEOUT, 0 /* vendorError*/);
+ return;
+ }
+}
+
+std::pair<AcquiredInfo, int32_t> FakeFaceEngine::convertAcquiredInfo(int32_t code) {
+ std::pair<AcquiredInfo, int32_t> res;
+ if (code > FACE_ACQUIRED_VENDOR_BASE) {
+ res.first = AcquiredInfo::VENDOR;
+ res.second = code - FACE_ACQUIRED_VENDOR_BASE;
+ } else {
+ res.first = (AcquiredInfo)code;
+ res.second = 0;
+ }
+ return res;
+}
+
+std::pair<Error, int32_t> FakeFaceEngine::convertError(int32_t code) {
+ std::pair<Error, int32_t> res;
+ if (code > FACE_ERROR_VENDOR_BASE) {
+ res.first = Error::VENDOR;
+ res.second = code - FACE_ERROR_VENDOR_BASE;
+ } else {
+ res.first = (Error)code;
+ res.second = 0;
+ }
+ return res;
}
void FakeFaceEngine::detectInteractionImpl(ISessionCallback* cb, const std::future<void>& cancel) {
@@ -315,4 +386,4 @@
cb->onLockoutCleared();
}
-} // namespace aidl::android::hardware::biometrics::face
\ No newline at end of file
+} // namespace aidl::android::hardware::biometrics::face
diff --git a/biometrics/face/aidl/default/FakeFaceEngine.h b/biometrics/face/aidl/default/FakeFaceEngine.h
index eb99441..06dd396 100644
--- a/biometrics/face/aidl/default/FakeFaceEngine.h
+++ b/biometrics/face/aidl/default/FakeFaceEngine.h
@@ -62,6 +62,12 @@
void resetLockoutImpl(ISessionCallback* cb, const keymaster::HardwareAuthToken& /*hat*/);
std::mt19937 mRandom;
+
+ private:
+ static constexpr int32_t FACE_ACQUIRED_VENDOR_BASE = 1000;
+ static constexpr int32_t FACE_ERROR_VENDOR_BASE = 1000;
+ std::pair<AcquiredInfo, int32_t> convertAcquiredInfo(int32_t code);
+ std::pair<Error, int32_t> convertError(int32_t code);
};
} // namespace aidl::android::hardware::biometrics::face
diff --git a/biometrics/face/aidl/default/README.md b/biometrics/face/aidl/default/README.md
index 77bfe57..516a7aa 100644
--- a/biometrics/face/aidl/default/README.md
+++ b/biometrics/face/aidl/default/README.md
@@ -18,6 +18,7 @@
Face VHAL enabling is gated by the following two AND conditions:
1. The Face VHAL feature flag (as part of Trunk-development strategy) must be tured until the flags life-cycle ends.
2. The Face VHAL must be enabled via sysprop
+See adb commands below
##Getting Stared
@@ -47,8 +48,7 @@
$ adb shell setprop vendor.face.virtual.operation_authenticate_duration 800
$ adb shell setprop vendor.face.virtual.enrollment_hit 1
```
-Note: At the initial phase of the Face VHAL development, Face-on-camera simulation is not supported, hence
-the authentication immediately occurrs as soon as the authentication request arriving at VHAL.
+Refer to face.sysprop for full supported features of authentication, such as error and acquiredInfo insertion
## Enrollment via Setup
diff --git a/biometrics/face/aidl/default/face.sysprop b/biometrics/face/aidl/default/face.sysprop
index 6b0f37f..be32015 100644
--- a/biometrics/face/aidl/default/face.sysprop
+++ b/biometrics/face/aidl/default/face.sysprop
@@ -157,3 +157,22 @@
access: ReadWrite
api_name: "operation_authenticate_duration"
}
+
+# insert error for authenticate operations
+prop {
+ prop_name: "vendor.face.virtual.operation_authenticate_error"
+ type: Integer
+ scope: Internal
+ access: ReadWrite
+ api_name: "operation_authenticate_error"
+}
+
+# acquired info during authentication in format of sequence
+prop {
+ prop_name: "vendor.face.virtual.operation_authenticate_acquired"
+ type: String
+ scope: Internal
+ access: ReadWrite
+ api_name: "operation_authenticate_acquired"
+}
+
diff --git a/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp b/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp
index c8ad6b7..6897dc4 100644
--- a/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp
+++ b/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp
@@ -245,7 +245,7 @@
FaceHalProperties::enrollments({3});
FaceHalProperties::enrollment_hit(100);
mEngine.authenticateImpl(mCallback.get(), 0 /* operationId*/, mCancel.get_future());
- ASSERT_EQ(Error::UNABLE_TO_PROCESS, mCallback->mError);
+ ASSERT_EQ(Error::TIMEOUT, mCallback->mError);
ASSERT_TRUE(mCallback->mAuthenticateFailed);
}
@@ -380,4 +380,4 @@
ASSERT_FALSE(mCallback->mAuthenticateFailed);
}
-} // namespace aidl::android::hardware::biometrics::face
\ No newline at end of file
+} // namespace aidl::android::hardware::biometrics::face
diff --git a/biometrics/fingerprint/aidl/default/FakeFingerprintEngine.cpp b/biometrics/fingerprint/aidl/default/FakeFingerprintEngine.cpp
index 54076c8..574570e 100644
--- a/biometrics/fingerprint/aidl/default/FakeFingerprintEngine.cpp
+++ b/biometrics/fingerprint/aidl/default/FakeFingerprintEngine.cpp
@@ -142,7 +142,7 @@
return true;
}
auto enrollmentId = std::stoi(parts[0]);
- auto progress = parseEnrollmentCapture(parts[1]);
+ auto progress = Util::parseEnrollmentCapture(parts[1]);
for (size_t i = 0; i < progress.size(); i += 2) {
auto left = (progress.size() - i) / 2 - 1;
auto duration = progress[i][0];
@@ -193,7 +193,7 @@
int64_t now = Util::getSystemNanoTime();
int64_t duration = FingerprintHalProperties::operation_authenticate_duration().value_or(10);
auto acquired = FingerprintHalProperties::operation_authenticate_acquired().value_or("1");
- auto acquiredInfos = parseIntSequence(acquired);
+ auto acquiredInfos = Util::parseIntSequence(acquired);
int N = acquiredInfos.size();
if (N == 0) {
@@ -271,7 +271,7 @@
FingerprintHalProperties::operation_detect_interaction_duration().value_or(10);
auto acquired = FingerprintHalProperties::operation_detect_interaction_acquired().value_or("1");
- auto acquiredInfos = parseIntSequence(acquired);
+ auto acquiredInfos = Util::parseIntSequence(acquired);
int N = acquiredInfos.size();
int64_t now = Util::getSystemNanoTime();
@@ -450,76 +450,6 @@
return SensorLocation();
}
-std::vector<int32_t> FakeFingerprintEngine::parseIntSequence(const std::string& str,
- const std::string& sep) {
- std::vector<std::string> seqs = Util::split(str, sep);
- std::vector<int32_t> res;
-
- for (const auto& seq : seqs) {
- int32_t val;
- if (ParseInt(seq, &val)) {
- res.push_back(val);
- } else {
- LOG(WARNING) << "Invalid int sequence:" + str;
- res.clear();
- break;
- }
- }
-
- return res;
-}
-
-bool FakeFingerprintEngine::parseEnrollmentCaptureSingle(const std::string& str,
- std::vector<std::vector<int32_t>>& res) {
- std::vector<int32_t> defaultAcquiredInfo = {(int32_t)AcquiredInfo::GOOD};
- bool aborted = true;
-
- do {
- std::smatch sms;
- // Parses strings like "1000-[5,1]" or "500"
- std::regex ex("((\\d+)(-\\[([\\d|,]+)\\])?)");
- if (!regex_match(str.cbegin(), str.cend(), sms, ex)) break;
- int32_t duration;
- if (!ParseInt(sms.str(2), &duration)) break;
- res.push_back({duration});
- if (!sms.str(4).empty()) {
- auto acqv = parseIntSequence(sms.str(4));
- if (acqv.empty()) break;
- res.push_back(acqv);
- } else
- res.push_back(defaultAcquiredInfo);
- aborted = false;
- } while (0);
-
- return !aborted;
-}
-
-std::vector<std::vector<int32_t>> FakeFingerprintEngine::parseEnrollmentCapture(
- const std::string& str) {
- std::vector<std::vector<int32_t>> res;
-
- std::string s(str);
- s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end());
- bool aborted = false;
- std::smatch sms;
- // Parses strings like "1000-[5,1],500,800-[6,5,1]"
- // ---------- --- -----------
- // into parts: A B C
- while (regex_search(s, sms, std::regex("^(,)?(\\d+(-\\[[\\d|,]+\\])?)"))) {
- if (!parseEnrollmentCaptureSingle(sms.str(2), res)) {
- aborted = true;
- break;
- }
- s = sms.suffix();
- }
- if (aborted || s.length() != 0) {
- res.clear();
- LOG(ERROR) << "Failed to parse enrollment captures:" + str;
- }
-
- return res;
-}
-
std::pair<AcquiredInfo, int32_t> FakeFingerprintEngine::convertAcquiredInfo(int32_t code) {
std::pair<AcquiredInfo, int32_t> res;
if (code > FINGERPRINT_ACQUIRED_VENDOR_BASE) {
diff --git a/biometrics/fingerprint/aidl/default/include/FakeFingerprintEngine.h b/biometrics/fingerprint/aidl/default/include/FakeFingerprintEngine.h
index 2450115..15d8360 100644
--- a/biometrics/fingerprint/aidl/default/include/FakeFingerprintEngine.h
+++ b/biometrics/fingerprint/aidl/default/include/FakeFingerprintEngine.h
@@ -68,10 +68,6 @@
virtual void fingerDownAction();
- std::vector<int32_t> parseIntSequence(const std::string& str, const std::string& sep = ",");
-
- std::vector<std::vector<int32_t>> parseEnrollmentCapture(const std::string& str);
-
int32_t getLatency(const std::vector<std::optional<std::int32_t>>& latencyVec);
std::mt19937 mRandom;
@@ -110,8 +106,6 @@
static constexpr int32_t FINGERPRINT_ERROR_VENDOR_BASE = 1000;
std::pair<AcquiredInfo, int32_t> convertAcquiredInfo(int32_t code);
std::pair<Error, int32_t> convertError(int32_t code);
- bool parseEnrollmentCaptureSingle(const std::string& str,
- std::vector<std::vector<int32_t>>& res);
int32_t getRandomInRange(int32_t bound1, int32_t bound2);
bool checkSensorLockout(ISessionCallback*);
void clearLockout(ISessionCallback* cb);
diff --git a/biometrics/fingerprint/aidl/default/tests/FakeFingerprintEngineTest.cpp b/biometrics/fingerprint/aidl/default/tests/FakeFingerprintEngineTest.cpp
index fe405f4..45b5be8 100644
--- a/biometrics/fingerprint/aidl/default/tests/FakeFingerprintEngineTest.cpp
+++ b/biometrics/fingerprint/aidl/default/tests/FakeFingerprintEngineTest.cpp
@@ -421,29 +421,29 @@
TEST_F(FakeFingerprintEngineTest, parseIntSequence) {
std::vector<int32_t> seqV;
- seqV = mEngine.parseIntSequence("");
+ seqV = Util::parseIntSequence("");
ASSERT_EQ(0, seqV.size());
- seqV = mEngine.parseIntSequence("2");
+ seqV = Util::parseIntSequence("2");
ASSERT_EQ(1, seqV.size());
ASSERT_EQ(2, seqV[0]);
- seqV = mEngine.parseIntSequence("2,3,4");
+ seqV = Util::parseIntSequence("2,3,4");
std::vector<int32_t> expV{2, 3, 4};
ASSERT_EQ(expV, seqV);
- seqV = mEngine.parseIntSequence("2,3,a");
+ seqV = Util::parseIntSequence("2,3,a");
ASSERT_EQ(0, seqV.size());
- seqV = mEngine.parseIntSequence("2, 3, 4");
+ seqV = Util::parseIntSequence("2, 3, 4");
ASSERT_EQ(expV, seqV);
- seqV = mEngine.parseIntSequence("123,456");
+ seqV = Util::parseIntSequence("123,456");
ASSERT_EQ(2, seqV.size());
std::vector<int32_t> expV1{123, 456};
ASSERT_EQ(expV1, seqV);
- seqV = mEngine.parseIntSequence("12f3,456");
+ seqV = Util::parseIntSequence("12f3,456");
ASSERT_EQ(0, seqV.size());
}
TEST_F(FakeFingerprintEngineTest, parseEnrollmentCaptureOk) {
std::vector<std::vector<int32_t>> ecV;
- ecV = mEngine.parseEnrollmentCapture("100,200,300");
+ ecV = Util::parseEnrollmentCapture("100,200,300");
ASSERT_EQ(6, ecV.size());
std::vector<std::vector<int32_t>> expE{{100}, {200}, {300}};
std::vector<int32_t> defC{1};
@@ -451,26 +451,26 @@
ASSERT_EQ(expE[i / 2], ecV[i]);
ASSERT_EQ(defC, ecV[i + 1]);
}
- ecV = mEngine.parseEnrollmentCapture("100");
+ ecV = Util::parseEnrollmentCapture("100");
ASSERT_EQ(2, ecV.size());
ASSERT_EQ(expE[0], ecV[0]);
ASSERT_EQ(defC, ecV[1]);
- ecV = mEngine.parseEnrollmentCapture("100-[5,6,7]");
+ ecV = Util::parseEnrollmentCapture("100-[5,6,7]");
std::vector<int32_t> expC{5, 6, 7};
ASSERT_EQ(2, ecV.size());
for (int i = 0; i < ecV.size(); i += 2) {
ASSERT_EQ(expE[i / 2], ecV[i]);
ASSERT_EQ(expC, ecV[i + 1]);
}
- ecV = mEngine.parseEnrollmentCapture("100-[5,6,7], 200, 300-[9,10]");
+ ecV = Util::parseEnrollmentCapture("100-[5,6,7], 200, 300-[9,10]");
std::vector<std::vector<int32_t>> expC1{{5, 6, 7}, {1}, {9, 10}};
ASSERT_EQ(6, ecV.size());
for (int i = 0; i < ecV.size(); i += 2) {
ASSERT_EQ(expE[i / 2], ecV[i]);
ASSERT_EQ(expC1[i / 2], ecV[i + 1]);
}
- ecV = mEngine.parseEnrollmentCapture("100-[5,6,7], 200-[2,1], 300-[9]");
+ ecV = Util::parseEnrollmentCapture("100-[5,6,7], 200-[2,1], 300-[9]");
std::vector<std::vector<int32_t>> expC2{{5, 6, 7}, {2, 1}, {9}};
ASSERT_EQ(ecV.size(), 6);
for (int i = 0; i < ecV.size(); i += 2) {
@@ -484,7 +484,7 @@
"100,2x0,300", "200-[f]", "a,b"};
std::vector<std::vector<int32_t>> ecV;
for (const auto& s : badStr) {
- ecV = mEngine.parseEnrollmentCapture(s);
+ ecV = Util::parseEnrollmentCapture(s);
ASSERT_EQ(ecV.size(), 0);
}
}
@@ -508,7 +508,7 @@
TEST_F(FakeFingerprintEngineTest, lockoutTimer) {
mEngine.startLockoutTimer(200, mCallback.get());
ASSERT_TRUE(mEngine.getLockoutTimerStarted());
- std::this_thread::sleep_for(std::chrono::milliseconds(210));
+ std::this_thread::sleep_for(std::chrono::milliseconds(230));
ASSERT_FALSE(mEngine.getLockoutTimerStarted());
ASSERT_TRUE(mCallback->mLockoutCleared);
}
diff --git a/boot/1.1/default/Android.bp b/boot/1.1/default/Android.bp
index 0b0a5b7..e7a8d6e 100644
--- a/boot/1.1/default/Android.bp
+++ b/boot/1.1/default/Android.bp
@@ -20,6 +20,7 @@
srcs: ["BootControl.cpp"],
shared_libs: [
+ "libbase",
"liblog",
"libhidlbase",
"libhardware",
diff --git a/boot/1.1/default/boot_control/Android.bp b/boot/1.1/default/boot_control/Android.bp
index 6aa30c2..d0dcb59 100644
--- a/boot/1.1/default/boot_control/Android.bp
+++ b/boot/1.1/default/boot_control/Android.bp
@@ -35,14 +35,13 @@
],
shared_libs: [
- "android.hardware.boot@1.1",
- "libbase",
"liblog",
],
static_libs: [
"libbootloader_message",
"libfstab",
],
+
}
cc_library_static {
@@ -52,7 +51,13 @@
recovery_available: true,
vendor_available: true,
- srcs: ["libboot_control.cpp"],
+ srcs: [
+ "libboot_control.cpp",
+ ],
+ static_libs: [
+ "android.hardware.boot@1.1",
+ "libbase",
+ ],
}
cc_library_shared {
@@ -67,6 +72,8 @@
"libboot_control",
],
shared_libs: [
+ "android.hardware.boot@1.1",
+ "libbase",
"libhardware",
],
}
diff --git a/boot/1.2/default/Android.bp b/boot/1.2/default/Android.bp
index 4e1c35e..f1e9c34 100644
--- a/boot/1.2/default/Android.bp
+++ b/boot/1.2/default/Android.bp
@@ -20,6 +20,7 @@
srcs: ["BootControl.cpp"],
shared_libs: [
+ "libbase",
"liblog",
"libhidlbase",
"libhardware",
diff --git a/boot/aidl/default/Android.bp b/boot/aidl/default/Android.bp
index dcb40db..c1d3c57 100644
--- a/boot/aidl/default/Android.bp
+++ b/boot/aidl/default/Android.bp
@@ -27,7 +27,39 @@
name: "android.hardware.boot-service_common",
relative_install_path: "hw",
defaults: ["libboot_control_defaults"],
+ srcs: [
+ "main.cpp",
+ "BootControl.cpp",
+ ],
+}
+
+cc_binary {
+ name: "android.hardware.boot-service.default",
+ defaults: ["android.hardware.boot-service_common"],
+ vendor: true,
+
+ stl: "c++_static",
+ shared_libs: [
+ "libbinder_ndk",
+ "liblog",
+ ],
+ static_libs: [
+ "android.hardware.boot@1.1",
+ "android.hardware.boot-V1-ndk",
+ "libbase",
+ "libboot_control",
+ ],
+
+ installable: false, // installed in APEX
+}
+
+cc_binary {
+ name: "android.hardware.boot-service.default_recovery",
+ defaults: ["android.hardware.boot-service_common"],
+ init_rc: ["android.hardware.boot-service.default_recovery.rc"],
vintf_fragments: ["android.hardware.boot-service.default.xml"],
+ recovery: true,
+
shared_libs: [
"libbase",
"libbinder_ndk",
@@ -37,19 +69,35 @@
static_libs: [
"libboot_control",
],
- srcs: ["main.cpp", "BootControl.cpp"],
}
-cc_binary {
- name: "android.hardware.boot-service.default",
- defaults: ["android.hardware.boot-service_common"],
- init_rc: ["android.hardware.boot-service.default.rc"],
+prebuilt_etc {
+ name: "android.hardware.boot-service.default.rc",
+ src: "android.hardware.boot-service.default.rc",
+ installable: false,
+}
+
+prebuilt_etc {
+ name: "android.hardware.boot-service.default.xml",
+ src: "android.hardware.boot-service.default.xml",
+ sub_dir: "vintf",
+ installable: false,
+}
+
+apex {
+ name: "com.android.hardware.boot",
vendor: true,
-}
+ manifest: "apex_manifest.json",
+ file_contexts: "apex_file_contexts",
+ key: "com.android.hardware.key",
+ certificate: ":com.android.hardware.certificate",
+ updatable: false,
-cc_binary {
- name: "android.hardware.boot-service.default_recovery",
- defaults: ["android.hardware.boot-service_common"],
- init_rc: ["android.hardware.boot-service.default_recovery.rc"],
- recovery: true,
+ binaries: [
+ "android.hardware.boot-service.default",
+ ],
+ prebuilts: [
+ "android.hardware.boot-service.default.rc",
+ "android.hardware.boot-service.default.xml",
+ ],
}
diff --git a/boot/aidl/default/android.hardware.boot-service.default.rc b/boot/aidl/default/android.hardware.boot-service.default.rc
index 589f803..5090e2c 100644
--- a/boot/aidl/default/android.hardware.boot-service.default.rc
+++ b/boot/aidl/default/android.hardware.boot-service.default.rc
@@ -1,4 +1,4 @@
-service vendor.boot-default /vendor/bin/hw/android.hardware.boot-service.default
+service vendor.boot-default /apex/com.android.hardware.boot/bin/hw/android.hardware.boot-service.default
class early_hal
user root
group root
diff --git a/boot/aidl/default/apex_file_contexts b/boot/aidl/default/apex_file_contexts
new file mode 100644
index 0000000..bf03585
--- /dev/null
+++ b/boot/aidl/default/apex_file_contexts
@@ -0,0 +1,3 @@
+(/.*)? u:object_r:vendor_file:s0
+/etc(/.*)? u:object_r:vendor_configs_file:s0
+/bin/hw/android\.hardware\.boot-service\.default u:object_r:hal_bootctl_default_exec:s0
diff --git a/boot/aidl/default/apex_manifest.json b/boot/aidl/default/apex_manifest.json
new file mode 100644
index 0000000..92661c9
--- /dev/null
+++ b/boot/aidl/default/apex_manifest.json
@@ -0,0 +1,5 @@
+{
+ "name": "com.android.hardware.boot",
+ "version": 1,
+ "vendorBootstrap": true
+}
\ No newline at end of file
diff --git a/camera/metadata/aidl/Android.bp b/camera/metadata/aidl/Android.bp
index 5872a86..2b2be55 100644
--- a/camera/metadata/aidl/Android.bp
+++ b/camera/metadata/aidl/Android.bp
@@ -11,7 +11,7 @@
name: "android.hardware.camera.metadata",
vendor_available: true,
srcs: ["android/hardware/camera/metadata/*.aidl"],
- frozen: true,
+ frozen: false,
stability: "vintf",
backend: {
cpp: {
diff --git a/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl b/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl
index 71d4e41..0290aef 100644
--- a/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl
+++ b/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl
@@ -108,6 +108,11 @@
ANDROID_FLASH_COLOR_TEMPERATURE,
ANDROID_FLASH_MAX_ENERGY,
ANDROID_FLASH_STATE,
+ ANDROID_FLASH_STRENGTH_LEVEL,
+ ANDROID_FLASH_SINGLE_STRENGTH_MAX_LEVEL,
+ ANDROID_FLASH_SINGLE_STRENGTH_DEFAULT_LEVEL,
+ ANDROID_FLASH_TORCH_STRENGTH_MAX_LEVEL,
+ ANDROID_FLASH_TORCH_STRENGTH_DEFAULT_LEVEL,
ANDROID_FLASH_INFO_AVAILABLE = android.hardware.camera.metadata.CameraMetadataSectionStart.ANDROID_FLASH_INFO_START /* 327680 */,
ANDROID_FLASH_INFO_CHARGE_DURATION,
ANDROID_FLASH_INFO_STRENGTH_MAXIMUM_LEVEL,
diff --git a/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl b/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl
index 56aa690..dd679f3 100644
--- a/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl
+++ b/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl
@@ -560,6 +560,36 @@
*/
ANDROID_FLASH_STATE,
/**
+ * android.flash.strengthLevel [dynamic, int32, public]
+ *
+ * <p>Flash strength level to be used when manual flash control is active.</p>
+ */
+ ANDROID_FLASH_STRENGTH_LEVEL,
+ /**
+ * android.flash.singleStrengthMaxLevel [static, int32, public]
+ *
+ * <p>Maximum flash brightness level for manual flash control in SINGLE mode.</p>
+ */
+ ANDROID_FLASH_SINGLE_STRENGTH_MAX_LEVEL,
+ /**
+ * android.flash.singleStrengthDefaultLevel [static, int32, public]
+ *
+ * <p>Default flash brightness level for manual flash control in SINGLE mode.</p>
+ */
+ ANDROID_FLASH_SINGLE_STRENGTH_DEFAULT_LEVEL,
+ /**
+ * android.flash.torchStrengthMaxLevel [static, int32, public]
+ *
+ * <p>Maximum flash brightness level for manual flash control in TORCH mode</p>
+ */
+ ANDROID_FLASH_TORCH_STRENGTH_MAX_LEVEL,
+ /**
+ * android.flash.torchStrengthDefaultLevel [static, int32, public]
+ *
+ * <p>Default flash brightness level for manual flash control in TORCH mode</p>
+ */
+ ANDROID_FLASH_TORCH_STRENGTH_DEFAULT_LEVEL,
+ /**
* android.flash.info.available [static, enum, public]
*
* <p>Whether this camera device has a
diff --git a/common/fmq/aidl/Android.bp b/common/fmq/aidl/Android.bp
index 3b022fc..6c37213 100644
--- a/common/fmq/aidl/Android.bp
+++ b/common/fmq/aidl/Android.bp
@@ -43,8 +43,9 @@
min_sdk_version: "29",
},
rust: {
- // FMQ is not supported in the rust backend
- enabled: false,
+ // FMQ is not supported in the rust backend, but we need this AIDL interface for
+ // HardwareBuffer.
+ enabled: true,
},
},
frozen: true,
diff --git a/compatibility_matrices/compatibility_matrix.9.xml b/compatibility_matrices/compatibility_matrix.9.xml
index 57fa2bf..0013923 100644
--- a/compatibility_matrices/compatibility_matrix.9.xml
+++ b/compatibility_matrices/compatibility_matrix.9.xml
@@ -102,6 +102,7 @@
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.automotive.remoteaccess</name>
+ <version>1-2</version>
<interface>
<name>IRemoteAccess</name>
<instance>default</instance>
diff --git a/contexthub/aidl/default/Android.bp b/contexthub/aidl/default/Android.bp
index 74bac69..03213bc 100644
--- a/contexthub/aidl/default/Android.bp
+++ b/contexthub/aidl/default/Android.bp
@@ -57,3 +57,34 @@
],
srcs: ["main.cpp"],
}
+
+prebuilt_etc {
+ name: "android.hardware.contexthub-service.example.rc",
+ src: "android.hardware.contexthub-service.example.rc",
+ installable: false,
+}
+
+prebuilt_etc {
+ name: "contexthub-default.xml",
+ src: "contexthub-default.xml",
+ sub_dir: "vintf",
+ installable: false,
+}
+
+apex {
+ name: "com.android.hardware.contexthub",
+ vendor: true,
+ manifest: "apex_manifest.json",
+ file_contexts: "apex_file_contexts",
+ key: "com.android.hardware.key",
+ certificate: ":com.android.hardware.certificate",
+ updatable: false,
+
+ binaries: [
+ "android.hardware.contexthub-service.example",
+ ],
+ prebuilts: [
+ "android.hardware.contexthub-service.example.rc",
+ "contexthub-default.xml",
+ ],
+}
diff --git a/contexthub/aidl/default/android.hardware.contexthub-service.example.rc b/contexthub/aidl/default/android.hardware.contexthub-service.example.rc
new file mode 100644
index 0000000..7d5d2aa
--- /dev/null
+++ b/contexthub/aidl/default/android.hardware.contexthub-service.example.rc
@@ -0,0 +1,4 @@
+service vendor.contexthub-default /apex/com.android.hardware.contexthub/bin/hw/android.hardware.contexthub-service.example
+ class hal
+ user context_hub
+ group context_hub
diff --git a/contexthub/aidl/default/apex_file_contexts b/contexthub/aidl/default/apex_file_contexts
new file mode 100644
index 0000000..c3c67df
--- /dev/null
+++ b/contexthub/aidl/default/apex_file_contexts
@@ -0,0 +1,3 @@
+(/.*)? u:object_r:vendor_file:s0
+/etc(/.*)? u:object_r:vendor_configs_file:s0
+/bin/hw/android\.hardware\.contexthub-service\.example u:object_r:hal_contexthub_default_exec:s0
diff --git a/contexthub/aidl/default/apex_manifest.json b/contexthub/aidl/default/apex_manifest.json
new file mode 100644
index 0000000..aed7081
--- /dev/null
+++ b/contexthub/aidl/default/apex_manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "com.android.hardware.contexthub",
+ "version": 1
+}
\ No newline at end of file
diff --git a/drm/aidl/vts/Android.bp b/drm/aidl/vts/Android.bp
index 190f60d..5139036 100644
--- a/drm/aidl/vts/Android.bp
+++ b/drm/aidl/vts/Android.bp
@@ -59,13 +59,13 @@
data: [":libvtswidevine-arm-prebuilts"],
},
arm64: {
- data: [":libvtswidevine-arm64-prebuilts"],
+ data: [":libvtswidevine-arm64-prebuilts", ":libvtswidevine-arm-prebuilts"],
},
x86: {
data: [":libvtswidevine-x86-prebuilts"],
},
x86_64: {
- data: [":libvtswidevine-x86_64-prebuilts"],
+ data: [":libvtswidevine-x86_64-prebuilts", ":libvtswidevine-x86-prebuilts"],
},
},
test_suites: [
diff --git a/dumpstate/aidl/default/Android.bp b/dumpstate/aidl/default/Android.bp
index 45fdc17..a9da69c 100644
--- a/dumpstate/aidl/default/Android.bp
+++ b/dumpstate/aidl/default/Android.bp
@@ -44,3 +44,41 @@
"-DLOG_TAG=\"android.hardware.dumpstate-service.example\"",
],
}
+
+prebuilt_etc {
+ name: "dumpstate-default.xml",
+ src: "dumpstate-default.xml",
+ sub_dir: "vintf",
+ installable: false,
+}
+
+prebuilt_etc {
+ name: "dumpstate-default.rc",
+ src: ":gen-dumpstate-default.rc-for-apex",
+ installable: false,
+}
+
+genrule {
+ name: "gen-dumpstate-default.rc-for-apex",
+ srcs: ["dumpstate-default.rc"],
+ out: ["dumpstate-default-apex.rc"],
+ cmd: "sed -E 's/\\/vendor\\/bin\\/hw/\\/apex\\/com.android.hardware.dumpstate\\/bin\\/hw/' $(in) > $(out)",
+}
+
+apex {
+ name: "com.android.hardware.dumpstate",
+ vendor: true,
+ manifest: "apex_manifest.json",
+ file_contexts: "apex_file_contexts",
+ key: "com.android.hardware.key",
+ certificate: ":com.android.hardware.certificate",
+ updatable: false,
+
+ binaries: [
+ "android.hardware.dumpstate-service.example",
+ ],
+ prebuilts: [
+ "dumpstate-default.rc",
+ "dumpstate-default.xml",
+ ],
+}
diff --git a/dumpstate/aidl/default/apex_file_contexts b/dumpstate/aidl/default/apex_file_contexts
new file mode 100644
index 0000000..91153a9
--- /dev/null
+++ b/dumpstate/aidl/default/apex_file_contexts
@@ -0,0 +1,3 @@
+(/.*)? u:object_r:vendor_file:s0
+/etc(/.*)? u:object_r:vendor_configs_file:s0
+/bin/hw/android\.hardware\.dumpstate-service\.example u:object_r:hal_dumpstate_default_exec:s0
\ No newline at end of file
diff --git a/dumpstate/aidl/default/apex_manifest.json b/dumpstate/aidl/default/apex_manifest.json
new file mode 100644
index 0000000..32beea4
--- /dev/null
+++ b/dumpstate/aidl/default/apex_manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "com.android.hardware.dumpstate",
+ "version": 1
+}
\ No newline at end of file
diff --git a/health/1.0/default/convert.cpp b/health/1.0/default/convert.cpp
index 31b4679..e12e197 100644
--- a/health/1.0/default/convert.cpp
+++ b/health/1.0/default/convert.cpp
@@ -117,7 +117,7 @@
info.batteryCycleCount = p->batteryCycleCount;
info.batteryFullCharge = p->batteryFullCharge;
info.batteryChargeCounter = p->batteryChargeCounter;
- info.batteryTechnology = p->batteryTechnology;
+ info.batteryTechnology = p->batteryTechnology.c_str();
}
void convertFromHealthInfo(const HealthInfo& info,
diff --git a/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp b/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp
index f57a668..1bff076 100644
--- a/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp
+++ b/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp
@@ -137,7 +137,7 @@
auto nonces = copyNonces(params);
EXPECT_EQ(allKeymasters().size(), nonces.size());
std::sort(nonces.begin(), nonces.end());
- std::unique(nonces.begin(), nonces.end());
+ nonces.erase(std::unique(nonces.begin(), nonces.end()), nonces.end());
EXPECT_EQ(allKeymasters().size(), nonces.size());
auto responses = computeSharedHmac(allKeymasters(), params);
diff --git a/media/bufferpool/aidl/Android.bp b/media/bufferpool/aidl/Android.bp
index 8caf525..8e013e0 100644
--- a/media/bufferpool/aidl/Android.bp
+++ b/media/bufferpool/aidl/Android.bp
@@ -46,6 +46,9 @@
],
min_sdk_version: "29",
},
+ rust: {
+ enabled: true,
+ },
},
versions_with_info: [
{
diff --git a/media/c2/aidl/Android.bp b/media/c2/aidl/Android.bp
index 75d74ac..3f2cadb 100644
--- a/media/c2/aidl/Android.bp
+++ b/media/c2/aidl/Android.bp
@@ -11,11 +11,12 @@
aidl_interface {
name: "android.hardware.media.c2",
+ min_sdk_version: "31",
vendor_available: true,
double_loadable: true,
srcs: ["android/hardware/media/c2/*.aidl"],
- include_dirs: [
- "frameworks/base/core/java",
+ headers: [
+ "HardwareBuffer_aidl",
],
imports: [
"android.hardware.common-V2",
@@ -31,6 +32,11 @@
},
ndk: {
enabled: true,
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.media.swcodec",
+ "test_com.android.media.swcodec",
+ ],
additional_shared_libraries: [
"libnativewindow",
],
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
index da3d5ff..3e460dd 100644
--- a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
@@ -36,7 +36,7 @@
interface IGraphicBufferAllocator {
android.hardware.media.c2.IGraphicBufferAllocator.Allocation allocate(in android.hardware.media.c2.IGraphicBufferAllocator.Description desc);
boolean deallocate(in long id);
- android.hardware.media.c2.IGraphicBufferAllocator.WaitableFds getWaitableFds();
+ ParcelFileDescriptor getWaitableFd();
parcelable Allocation {
android.hardware.HardwareBuffer buffer;
ParcelFileDescriptor fence;
@@ -47,8 +47,4 @@
int format;
long usage;
}
- parcelable WaitableFds {
- ParcelFileDescriptor allocEvent;
- ParcelFileDescriptor statusEvent;
- }
}
diff --git a/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl b/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
index 1c97214..49c4ea4 100644
--- a/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
+++ b/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
@@ -75,31 +75,22 @@
boolean deallocate(in long id);
/**
- * Fds for waitable object events.
- *
- * Fds are created by eventfd() with semaphore mode.
- * For allocEvent, An integer counter regarding dequeuable buffer count is maintained
- * by client using read()/write() to the fd. The fd can be checked whether it is
- * readable via poll(). When in readable status, the specified counter is positive
- * so allocate/dequeue can happen.
- *
- * For statusEvent, the client can notify further allocation is not feasible.
- * e.g.) life-cycle of the underlying allocator is ended.
- *
- * C2Fence object should be implemented based on this Fds. Thus, C2Fence can return
- * either by allocation being ready or allocation being infeasible by the client status
- * change.
- */
- parcelable WaitableFds {
- ParcelFileDescriptor allocEvent;
- ParcelFileDescriptor statusEvent;
- }
-
- /**
- * Gets waiable file descriptors.
+ * Gets a waitable file descriptor.
*
* Use this method once and cache it in order not to create unnecessary duplicated fds.
- * The returned array will have two fds.
+ *
+ * Two file descriptors are created by pipe2(), and the reading end will be returned
+ * and shared by this method. Whenever a dequeuable buffer is ready a byte will be
+ * written to the writing end. Whenever a buffer is allocated(or dequeued) a byte will
+ * be read from the reading end.
+ *
+ * The returned file descriptor(the reading end) can be polled whether the read is ready
+ * via ::poll(). If no more allocate() can be fulfilled(by status change or etc.), the
+ * writing end will be closed. In the case, POLLHUP event can be retrieved via ::poll().
+ *
+ * C2Fence object should be implemented based on this Fd. Thus, C2Fence can return
+ * either by allocation being ready or allocation being infeasible by the client status
+ * change.
*
* If many waitable objects based on the same fd are competing, all watiable objects will be
* notified. After being notified, they should invoke allocate(). At least one of them can
@@ -110,5 +101,5 @@
* @return an fd array which will be wrapped to C2Fence and will be waited for
* until allocating is unblocked.
*/
- WaitableFds getWaitableFds();
+ ParcelFileDescriptor getWaitableFd();
}
diff --git a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
index 97b4e27..9678da4 100644
--- a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
+++ b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
@@ -293,11 +293,13 @@
std::vector<uint8_t> response;
LogicalChannelResponse logical_channel_response;
+ /* Temporaly disable this check to clarify Basic Channel behavior (b/300502872)
// Note: no channel is opened for this test
// transmit() will return an empty response with the error
// code CHANNEL_NOT_AVAILABLE when the SE cannot be
// communicated with.
EXPECT_ERR(secure_element_->transmit(kDataApdu, &response));
+ */
EXPECT_OK(secure_element_->openLogicalChannel(kSelectableAid, 0x00, &logical_channel_response));
EXPECT_GE(logical_channel_response.selectResponse.size(), 2u);
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 5f8ec0e..3a8a1e8 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -841,7 +841,7 @@
int vendor_api_level = property_get_int32("ro.vendor.api_level", 0);
if (SecLevel() == SecurityLevel::STRONGBOX) {
// This is known to be broken on older vendor implementations.
- if (vendor_api_level < __ANDROID_API_T__) {
+ if (vendor_api_level <= __ANDROID_API_U__) {
compare_output = false;
} else {
additional_information = " (b/194134359) ";
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index ebc039a..de563c4 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -4797,7 +4797,7 @@
EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
string result;
- EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result));
+ EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result));
EXPECT_EQ(0U, result.size());
}
}
@@ -5305,7 +5305,7 @@
EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
string result;
- EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result));
+ EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result));
EXPECT_EQ(0U, result.size());
}
}
@@ -5372,7 +5372,7 @@
.Digest(Digest::SHA_2_256)
.Padding(PaddingMode::RSA_OAEP)));
string result;
- EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext, &result));
+ EXPECT_NE(ErrorCode::OK, Finish(ciphertext, &result));
EXPECT_EQ(0U, result.size());
}
@@ -5442,7 +5442,7 @@
EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
string result;
- EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result));
+ EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result));
EXPECT_EQ(0U, result.size());
}
}
@@ -5486,7 +5486,7 @@
EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
string result;
- EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext, &result));
+ EXPECT_NE(ErrorCode::OK, Finish(ciphertext, &result));
EXPECT_EQ(0U, result.size());
}
@@ -5618,7 +5618,7 @@
EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
string result;
- EXPECT_EQ(ErrorCode::UNKNOWN_ERROR, Finish(ciphertext1, &result));
+ EXPECT_NE(ErrorCode::OK, Finish(ciphertext1, &result));
EXPECT_EQ(0U, result.size());
}
diff --git a/security/keymint/support/remote_prov_utils.cpp b/security/keymint/support/remote_prov_utils.cpp
index 780c3d2..34f7ce4 100644
--- a/security/keymint/support/remote_prov_utils.cpp
+++ b/security/keymint/support/remote_prov_utils.cpp
@@ -962,6 +962,20 @@
return signedRequest->value();
}
+ErrMsgOr<hwtrust::DiceChain::Kind> getDiceChainKind() {
+ int vendor_api_level = ::android::base::GetIntProperty("ro.vendor.api_level", -1);
+ switch (vendor_api_level) {
+ case __ANDROID_API_T__:
+ return hwtrust::DiceChain::Kind::kVsr13;
+ case __ANDROID_API_U__:
+ return hwtrust::DiceChain::Kind::kVsr14;
+ case __ANDROID_API_V__:
+ return hwtrust::DiceChain::Kind::kVsr15;
+ default:
+ return "Unsupported vendor API level: " + std::to_string(vendor_api_level);
+ }
+}
+
ErrMsgOr<bytevec> parseAndValidateAuthenticatedRequest(const std::vector<uint8_t>& request,
const std::vector<uint8_t>& challenge) {
auto [parsedRequest, _, csrErrMsg] = cppbor::parse(request);
@@ -996,7 +1010,12 @@
}
// DICE chain is [ pubkey, + DiceChainEntry ].
- auto diceContents = validateBcc(diceCertChain, hwtrust::DiceChain::Kind::kVsr14);
+ auto diceChainKind = getDiceChainKind();
+ if (!diceChainKind) {
+ return diceChainKind.message();
+ }
+
+ auto diceContents = validateBcc(diceCertChain, *diceChainKind);
if (!diceContents) {
return diceContents.message() + "\n" + prettyPrint(diceCertChain);
}
diff --git a/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl b/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl
index 80f7cbd..15b0442 100644
--- a/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl
+++ b/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl
@@ -90,9 +90,10 @@
DiceChainEntryPayload = { ; CWT [RFC8392]
1 : tstr, ; Issuer
2 : tstr, ; Subject
+ -4670554 : "android.15", ; Profile Name
-4670552 : bstr .cbor PubKeyEd25519 /
bstr .cbor PubKeyECDSA256 /
- bstr .cbor PubKeyECDSA384, ; Subject Public Key
+ bstr .cbor PubKeyECDSA384, ; Subject Public Key
-4670553 : bstr ; Key Usage
; NOTE: All of the following fields may be omitted for a "Degenerate DICE Chain", as
diff --git a/security/sharedsecret/aidl/vts/functional/SharedSecretAidlTest.cpp b/security/sharedsecret/aidl/vts/functional/SharedSecretAidlTest.cpp
index 51938ba..7599bce 100644
--- a/security/sharedsecret/aidl/vts/functional/SharedSecretAidlTest.cpp
+++ b/security/sharedsecret/aidl/vts/functional/SharedSecretAidlTest.cpp
@@ -164,7 +164,7 @@
auto nonces = copyNonces(params);
EXPECT_EQ(sharedSecrets.size(), nonces.size());
std::sort(nonces.begin(), nonces.end());
- std::unique(nonces.begin(), nonces.end());
+ nonces.erase(std::unique(nonces.begin(), nonces.end()), nonces.end());
EXPECT_EQ(sharedSecrets.size(), nonces.size());
auto responses = computeAllSharedSecrets(params);
diff --git a/soundtrigger/aidl/cli/java/android/hardware/soundtrigger3/cli/SthalCli.java b/soundtrigger/aidl/cli/java/android/hardware/soundtrigger3/cli/SthalCli.java
index 127f062..41e2533 100644
--- a/soundtrigger/aidl/cli/java/android/hardware/soundtrigger3/cli/SthalCli.java
+++ b/soundtrigger/aidl/cli/java/android/hardware/soundtrigger3/cli/SthalCli.java
@@ -289,6 +289,8 @@
Properties properties = new Properties();
properties.implementor = "Android";
properties.description = "Mock STHAL";
+ properties.uuid = "a5af2d2a-4cc4-4b69-a22f-c9d5b6d492c3";
+ properties.supportedModelArch = "Mock arch";
properties.maxSoundModels = 2;
properties.maxKeyPhrases = 1;
properties.recognitionModes =
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
index bb99ae4..46cba93 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
@@ -48,6 +48,13 @@
virtual void SetUp() override {
wifi_instance_name_ = std::get<0>(GetParam());
hostapd_instance_name_ = std::get<1>(GetParam());
+
+ // Disable Wi-Fi framework to avoid interference
+ isWifiEnabled_ = isWifiFrameworkEnabled();
+ isScanAlwaysEnabled_ = isWifiScanAlwaysAvailable();
+ toggleWifiFramework(false);
+ toggleWifiScanAlwaysAvailable(false);
+
stopSupplicantIfNeeded(wifi_instance_name_);
startHostapdAndWaitForHidlService(wifi_instance_name_,
hostapd_instance_name_);
@@ -58,14 +65,21 @@
virtual void TearDown() override {
HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate);
stopHostapd(wifi_instance_name_);
+
+ // Restore Wi-Fi framework state
+ toggleWifiFramework(isWifiEnabled_);
+ toggleWifiScanAlwaysAvailable(isScanAlwaysEnabled_);
}
protected:
- std::string getPrimaryWlanIfaceName() {
+ bool isWifiEnabled_ = false;
+ bool isScanAlwaysEnabled_ = false;
+
+ std::string getPrimaryWlanIfaceName() {
std::array<char, PROPERTY_VALUE_MAX> buffer;
property_get("wifi.interface", buffer.data(), "wlan0");
return buffer.data();
- }
+ }
IHostapd::IfaceParams getIfaceParamsWithAcs() {
IHostapd::IfaceParams iface_params;
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
index 56f285d..4c452fb 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
@@ -98,3 +98,24 @@
::android::hardware::wifi::hostapd::V1_1::IHostapd::castFrom(hostapd);
return hostapd_1_1.get() != nullptr;
}
+
+void toggleWifiFramework(bool enable) {
+ std::string cmd = "/system/bin/cmd wifi set-wifi-enabled ";
+ cmd += enable ? "enabled" : "disabled";
+ testing::checkSubstringInCommandOutput(cmd.c_str(), "X");
+}
+
+void toggleWifiScanAlwaysAvailable(bool enable) {
+ std::string cmd = "/system/bin/cmd wifi set-scan-always-available ";
+ cmd += enable ? "enabled" : "disabled";
+ testing::checkSubstringInCommandOutput(cmd.c_str(), "X");
+}
+
+bool isWifiFrameworkEnabled() {
+ return testing::checkSubstringInCommandOutput("/system/bin/cmd wifi status", "Wifi is enabled");
+}
+
+bool isWifiScanAlwaysAvailable() {
+ return testing::checkSubstringInCommandOutput("/system/bin/cmd wifi status",
+ "Wifi scanning is always available");
+}
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
index 893de1e..aa34c9a 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
@@ -17,14 +17,17 @@
#ifndef HOSTAPD_HIDL_TEST_UTILS_H
#define HOSTAPD_HIDL_TEST_UTILS_H
+#include <VtsCoreUtil.h>
#include <android/hardware/wifi/hostapd/1.0/IHostapd.h>
#include <android/hardware/wifi/hostapd/1.1/IHostapd.h>
// Used to stop the android wifi framework before every test.
-void stopWifiFramework(const std::string& instance_name);
-void startWifiFramework(const std::string& instance_name);
void stopSupplicantIfNeeded(const std::string& instance_name);
void stopHostapd(const std::string& instance_name);
+void toggleWifiFramework(bool enable);
+void toggleWifiScanAlwaysAvailable(bool enable);
+bool isWifiFrameworkEnabled();
+bool isWifiScanAlwaysAvailable();
// Used to configure the chip, driver and start wpa_hostapd before every
// test.
void startHostapdAndWaitForHidlService(