Merge "Add a field for auto cable plugin detection in TV Input HAL"
diff --git a/Android.bp b/Android.bp
index 7aef46b..79e8609 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,3 +1,11 @@
subdirs = [
"*"
]
+
+cc_defaults {
+ name: "hidl_defaults",
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp
index c16a956..29946fe 100644
--- a/audio/2.0/default/Stream.cpp
+++ b/audio/2.0/default/Stream.cpp
@@ -189,7 +189,9 @@
}
Return<AudioDevice> Stream::getDevice() {
- return AudioDevice(mStream->get_device(mStream));
+ int device;
+ Result retval = getParam(AudioParameter::keyRouting, &device);
+ return retval == Result::OK ? static_cast<AudioDevice>(device) : AudioDevice::NONE;
}
Return<Result> Stream::setDevice(const DeviceAddress& address) {
diff --git a/audio/2.0/default/Stream.h b/audio/2.0/default/Stream.h
index 63ea1bb..b49e658 100644
--- a/audio/2.0/default/Stream.h
+++ b/audio/2.0/default/Stream.h
@@ -146,7 +146,6 @@
}
_hidl_cb(retval, info);
if (hidlHandle != nullptr) {
- native_handle_close(hidlHandle);
native_handle_delete(hidlHandle);
}
return Void();
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index cdc8ded..6ccdbcd 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -79,10 +79,6 @@
ssize_t writeResult = mStream->write(mStream, &mBuffer[0], availToRead);
if (writeResult >= 0) {
mStatus.reply.written = writeResult;
- // Diagnostics of the cause of b/35813113.
- ALOGE_IF(writeResult > availToRead,
- "legacy hal reports more bytes written than asked for: %lld > %lld",
- (long long)writeResult, (long long)availToRead);
} else {
mStatus.retval = Stream::analyzeStatus("write", writeResult);
}
diff --git a/audio/2.0/vts/functional/Android.bp b/audio/2.0/vts/functional/Android.bp
new file mode 100644
index 0000000..02f9330
--- /dev/null
+++ b/audio/2.0/vts/functional/Android.bp
@@ -0,0 +1,38 @@
+//
+// Copyright (C) 2017 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.
+//
+
+cc_test {
+ name: "VtsHalAudioV2_0TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["AudioPrimaryHidlHalTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libhidlbase",
+ "libutils",
+ "libcutils",
+ "android.hardware.audio@2.0",
+ "android.hardware.audio.common@2.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+}
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
new file mode 100644
index 0000000..e50b912
--- /dev/null
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -0,0 +1,986 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "VtsHalAudioV2_0TargetTest"
+
+#include <algorithm>
+#include <cmath>
+#include <cstddef>
+#include <cstdio>
+#include <limits>
+#include <list>
+#include <string>
+#include <type_traits>
+#include <vector>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+#include <android-base/logging.h>
+
+#include <android/hardware/audio/2.0/IDevice.h>
+#include <android/hardware/audio/2.0/IDevicesFactory.h>
+#include <android/hardware/audio/2.0/IPrimaryDevice.h>
+#include <android/hardware/audio/2.0/types.h>
+#include <android/hardware/audio/common/2.0/types.h>
+
+#include "utility/ReturnIn.h"
+#include "utility/AssertOk.h"
+#include "utility/PrettyPrintAudioTypes.h"
+
+using std::string;
+using std::to_string;
+using std::vector;
+
+using ::android::sp;
+using ::android::hardware::Return;
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::MQDescriptorSync;
+using ::android::hardware::audio::V2_0::DeviceAddress;
+using ::android::hardware::audio::V2_0::IDevice;
+using ::android::hardware::audio::V2_0::IPrimaryDevice;
+using TtyMode = ::android::hardware::audio::V2_0::IPrimaryDevice::TtyMode;
+using ::android::hardware::audio::V2_0::IDevicesFactory;
+using ::android::hardware::audio::V2_0::IStream;
+using ::android::hardware::audio::V2_0::IStreamIn;
+using ReadParameters = ::android::hardware::audio::V2_0::IStreamIn::ReadParameters;
+using ReadStatus = ::android::hardware::audio::V2_0::IStreamIn::ReadStatus;
+using ::android::hardware::audio::V2_0::IStreamOut;
+using ::android::hardware::audio::V2_0::MmapBufferInfo;
+using ::android::hardware::audio::V2_0::MmapPosition;
+using ::android::hardware::audio::V2_0::ParameterValue;
+using ::android::hardware::audio::V2_0::Result;
+using ::android::hardware::audio::common::V2_0::AudioChannelMask;
+using ::android::hardware::audio::common::V2_0::AudioConfig;
+using ::android::hardware::audio::common::V2_0::AudioDevice;
+using ::android::hardware::audio::common::V2_0::AudioFormat;
+using ::android::hardware::audio::common::V2_0::AudioHandleConsts;
+using ::android::hardware::audio::common::V2_0::AudioInputFlag;
+using ::android::hardware::audio::common::V2_0::AudioIoHandle;
+using ::android::hardware::audio::common::V2_0::AudioMode;
+using ::android::hardware::audio::common::V2_0::AudioOffloadInfo;
+using ::android::hardware::audio::common::V2_0::AudioOutputFlag;
+using ::android::hardware::audio::common::V2_0::AudioSource;
+using ::android::hardware::audio::common::V2_0::ThreadInfo;
+
+using utility::returnIn;
+
+namespace doc {
+/** Document the current test case.
+ * Eg: calling `doc::test("Dump the state of the hal")` in the "debugDump" test will output:
+ * <testcase name="debugDump" status="run" time="6" classname="AudioPrimaryHidlTest"
+ description="Dump the state of the hal." />
+ * see https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#logging-additional-information
+ */
+void test(const std::string& testCaseDocumentation) {
+ ::testing::Test::RecordProperty("description", testCaseDocumentation);
+}
+
+/** Document why a test was not fully run. Usually due to an optional feature not implemented. */
+void partialTest(const std::string& reason) {
+ ::testing::Test::RecordProperty("partialyRunTest", reason);
+}
+}
+
+// Register callback for static object destruction
+// Avoid destroying static objects after main return.
+// Post main return destruction leads to incorrect gtest timing measurements as well as harder
+// debuging if anything goes wrong during destruction.
+class Environment : public ::testing::Environment {
+public:
+ using TearDownFunc = std::function<void ()>;
+ void registerTearDown(TearDownFunc&& tearDown) {
+ tearDowns.push_back(std::move(tearDown));
+ }
+
+private:
+ void TearDown() override {
+ // Call the tear downs in reverse order of insertion
+ for (auto& tearDown : tearDowns) {
+ tearDown();
+ }
+ }
+ std::list<TearDownFunc> tearDowns;
+};
+// Instance to register global tearDown
+static Environment* environment;
+
+class HidlTest : public ::testing::VtsHalHidlTargetTestBase {
+protected:
+ // Convenient member to store results
+ Result res;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+////////////////////// getService audio_devices_factory //////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+// Test all audio devices
+class AudioHidlTest : public HidlTest {
+public:
+ void SetUp() override {
+ ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp()); // setup base
+
+ if (devicesFactory == nullptr) {
+ environment->registerTearDown([]{ devicesFactory.clear(); });
+ devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>();
+ }
+ ASSERT_TRUE(devicesFactory != nullptr);
+ }
+
+protected:
+ // Cache the devicesFactory retrieval to speed up each test by ~0.5s
+ static sp<IDevicesFactory> devicesFactory;
+};
+sp<IDevicesFactory> AudioHidlTest::devicesFactory;
+
+TEST_F(AudioHidlTest, GetAudioDevicesFactoryService) {
+ doc::test("test the getService (called in SetUp)");
+}
+
+//////////////////////////////////////////////////////////////////////////////
+/////////////////////////////// openDevice primary ///////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+// Test the primary device
+class AudioPrimaryHidlTest : public AudioHidlTest {
+public:
+ /** Primary HAL test are NOT thread safe. */
+ void SetUp() override {
+ ASSERT_NO_FATAL_FAILURE(AudioHidlTest::SetUp()); // setup base
+
+ if (device == nullptr) {
+ IDevicesFactory::Result result;
+ sp<IDevice> baseDevice;
+ ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY,
+ returnIn(result, baseDevice)));
+ ASSERT_TRUE(baseDevice != nullptr);
+
+ environment->registerTearDown([]{ device.clear(); });
+ device = IPrimaryDevice::castFrom(baseDevice);
+ ASSERT_TRUE(device != nullptr);
+ }
+ }
+
+protected:
+ // Cache the device opening to speed up each test by ~0.5s
+ static sp<IPrimaryDevice> device;
+};
+sp<IPrimaryDevice> AudioPrimaryHidlTest::device;
+
+TEST_F(AudioPrimaryHidlTest, OpenPrimaryDevice) {
+ doc::test("Test the openDevice (called in SetUp)");
+}
+
+TEST_F(AudioPrimaryHidlTest, Init) {
+ doc::test("Test that the audio primary hal initialized correctly");
+ ASSERT_OK(device->initCheck());
+}
+
+//////////////////////////////////////////////////////////////////////////////
+///////////////////// {set,get}{Master,Mic}{Mute,Volume} /////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+template <class Property>
+class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
+protected:
+
+ /** Test a property getter and setter. */
+ template <class Getter, class Setter>
+ void testAccessors(const string& propertyName, const vector<Property>& valuesToTest,
+ Setter setter, Getter getter,
+ const vector<Property>& invalidValues = {}) {
+
+ Property initialValue; // Save initial value to restore it at the end of the test
+ ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue)));
+ ASSERT_OK(res);
+
+ for (Property setValue : valuesToTest) {
+ SCOPED_TRACE("Test " + propertyName + " getter and setter for " +
+ testing::PrintToString(setValue));
+ ASSERT_OK((device.get()->*setter)(setValue));
+ Property getValue;
+ // Make sure the getter returns the same value just set
+ ASSERT_OK((device.get()->*getter)(returnIn(res, getValue)));
+ ASSERT_OK(res);
+ EXPECT_EQ(setValue, getValue);
+ }
+
+ for (Property invalidValue : invalidValues) {
+ SCOPED_TRACE("Try to set " + propertyName + " with the invalid value " +
+ testing::PrintToString(invalidValue));
+ EXPECT_RESULT(Result::INVALID_ARGUMENTS, (device.get()->*setter)(invalidValue));
+ }
+
+ ASSERT_OK((device.get()->*setter)(initialValue)); // restore initial value
+ }
+
+ /** Test the getter and setter of an optional feature. */
+ template <class Getter, class Setter>
+ void testOptionalAccessors(const string& propertyName, const vector<Property>& valuesToTest,
+ Setter setter, Getter getter,
+ const vector<Property>& invalidValues = {}) {
+ doc::test("Test the optional " + propertyName + " getters and setter");
+ {
+ SCOPED_TRACE("Test feature support by calling the getter");
+ Property initialValue;
+ ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue)));
+ if (res == Result::NOT_SUPPORTED) {
+ doc::partialTest(propertyName + " getter is not supported");
+ return;
+ }
+ ASSERT_OK(res); // If it is supported it must succeed
+ }
+ // The feature is supported, test it
+ testAccessors(propertyName, valuesToTest, setter, getter, invalidValues);
+ }
+};
+
+using BoolAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<bool>;
+
+TEST_F(BoolAccessorPrimaryHidlTest, MicMuteTest) {
+ doc::test("Check that the mic can be muted and unmuted");
+ testAccessors("mic mute", {true, false, true}, &IDevice::setMicMute, &IDevice::getMicMute);
+ // TODO: check that the mic is really muted (all sample are 0)
+}
+
+TEST_F(BoolAccessorPrimaryHidlTest, MasterMuteTest) {
+ doc::test("If master mute is supported, try to mute and unmute the master output");
+ testOptionalAccessors("master mute", {true, false, true},
+ &IDevice::setMasterMute, &IDevice::getMasterMute);
+ // TODO: check that the master volume is really muted
+}
+
+using FloatAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<float>;
+TEST_F(FloatAccessorPrimaryHidlTest, MasterVolumeTest) {
+ doc::test("Test the master volume if supported");
+ testOptionalAccessors("master volume", {0, 0.5, 1},
+ &IDevice::setMasterVolume, &IDevice::getMasterVolume,
+ {-0.1, 1.1, NAN, INFINITY, -INFINITY,
+ 1 + std::numeric_limits<float>::epsilon()});
+ // TODO: check that the master volume is really changed
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////// AudioPatches ////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+class AudioPatchPrimaryHidlTest : public AudioPrimaryHidlTest {
+protected:
+ bool areAudioPatchesSupported() {
+ auto result = device->supportsAudioPatches();
+ EXPECT_TRUE(result.isOk());
+ return result;
+ }
+};
+
+TEST_F(AudioPatchPrimaryHidlTest, AudioPatches) {
+ doc::test("Test if audio patches are supported");
+ if (!areAudioPatchesSupported()) {
+ doc::partialTest("Audio patches are not supported");
+ return;
+ }
+ // TODO: test audio patches
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////// Required and recommended audio format support ///////////////
+// From: https://source.android.com/compatibility/android-cdd.html#5_4_audio_recording
+// From: https://source.android.com/compatibility/android-cdd.html#5_5_audio_playback
+/////////// TODO: move to the beginning of the file for easier update ////////
+//////////////////////////////////////////////////////////////////////////////
+
+class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
+public:
+ // Cache result ?
+ static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() {
+ return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
+ {8000, 11025, 16000, 22050, 32000, 44100},
+ {AudioFormat::PCM_16_BIT});
+ }
+
+ static const vector<AudioConfig> getRecommendedSupportPlaybackAudioConfig() {
+ return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
+ {24000, 48000},
+ {AudioFormat::PCM_16_BIT});
+ }
+
+ static const vector<AudioConfig> getSupportedPlaybackAudioConfig() {
+ // TODO: retrieve audio config supported by the platform
+ // as declared in the policy configuration
+ return {};
+ }
+
+ static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() {
+ return combineAudioConfig({AudioChannelMask::IN_MONO},
+ {8000, 11025, 16000, 44100},
+ {AudioFormat::PCM_16_BIT});
+ }
+ static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() {
+ return combineAudioConfig({AudioChannelMask::IN_STEREO},
+ {22050, 48000},
+ {AudioFormat::PCM_16_BIT});
+ }
+ static const vector<AudioConfig> getSupportedCaptureAudioConfig() {
+ // TODO: retrieve audio config supported by the platform
+ // as declared in the policy configuration
+ return {};
+ }
+private:
+ static const vector<AudioConfig> combineAudioConfig(
+ vector<AudioChannelMask> channelMasks,
+ vector<uint32_t> sampleRates,
+ vector<AudioFormat> formats) {
+ vector<AudioConfig> configs;
+ for (auto channelMask: channelMasks) {
+ for (auto sampleRate : sampleRates) {
+ for (auto format : formats) {
+ AudioConfig config{};
+ // leave offloadInfo to 0
+ config.channelMask = channelMask;
+ config.sampleRateHz = sampleRate;
+ config.format = format;
+ // FIXME: leave frameCount to 0 ?
+ configs.push_back(config);
+ }
+ }
+ }
+ return configs;
+ }
+};
+
+/** Generate a test name based on an audio config.
+ *
+ * As the only parameter changing are channel mask and sample rate,
+ * only print those ones in the test name.
+ */
+static string generateTestName(const testing::TestParamInfo<AudioConfig>& info) {
+ const AudioConfig& config = info.param;
+ return to_string(info.index) + "__" + to_string(config.sampleRateHz)+ "_" +
+ // "MONO" is more clear than "FRONT_LEFT"
+ ((config.channelMask == AudioChannelMask::OUT_MONO ||
+ config.channelMask == AudioChannelMask::IN_MONO) ?
+ "MONO" : toString(config.channelMask));
+}
+
+//////////////////////////////////////////////////////////////////////////////
+///////////////////////////// getInputBufferSize /////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+// FIXME: execute input test only if platform declares android.hardware.microphone
+// how to get this value ? is it a property ???
+
+class AudioCaptureConfigPrimaryTest : public AudioConfigPrimaryTest,
+ public ::testing::WithParamInterface<AudioConfig> {
+protected:
+ void inputBufferSizeTest(const AudioConfig& audioConfig, bool supportRequired) {
+ uint64_t bufferSize;
+ ASSERT_OK(device->getInputBufferSize(audioConfig, returnIn(res, bufferSize)));
+
+ switch (res) {
+ case Result::INVALID_ARGUMENTS:
+ EXPECT_FALSE(supportRequired);
+ break;
+ case Result::OK:
+ // Check that the buffer is of a sane size
+ // For now only that it is > 0
+ EXPECT_GT(bufferSize, uint64_t(0));
+ break;
+ default:
+ FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
+ }
+ }
+};
+
+// Test that the required capture config and those declared in the policy are indeed supported
+class RequiredInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {};
+TEST_P(RequiredInputBufferSizeTest, RequiredInputBufferSizeTest) {
+ doc::test("Input buffer size must be retrievable for a format with required support.");
+ inputBufferSizeTest(GetParam(), true);
+}
+INSTANTIATE_TEST_CASE_P(
+ RequiredInputBufferSize, RequiredInputBufferSizeTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
+ &generateTestName);
+INSTANTIATE_TEST_CASE_P(
+ SupportedInputBufferSize, RequiredInputBufferSizeTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
+ &generateTestName);
+
+// Test that the recommended capture config are supported or lead to a INVALID_ARGUMENTS return
+class OptionalInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {};
+TEST_P(OptionalInputBufferSizeTest, OptionalInputBufferSizeTest) {
+ doc::test("Input buffer size should be retrievable for a format with recommended support.");
+ inputBufferSizeTest(GetParam(), false);
+}
+INSTANTIATE_TEST_CASE_P(
+ RecommendedCaptureAudioConfigSupport, OptionalInputBufferSizeTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
+ &generateTestName);
+
+//////////////////////////////////////////////////////////////////////////////
+/////////////////////////////// setScreenState ///////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+TEST_F(AudioPrimaryHidlTest, setScreenState) {
+ doc::test("Check that the hal can receive the screen state");
+ for (bool turnedOn : {false, true, true, false, false}) {
+ auto ret = device->setScreenState(turnedOn);
+ ASSERT_TRUE(ret.isOk());
+ Result result = ret;
+ ASSERT_TRUE(result == Result::OK || result == Result::NOT_SUPPORTED) << toString(result);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////// {get,set}Parameters /////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+TEST_F(AudioPrimaryHidlTest, getParameters) {
+ doc::test("Check that the hal can set and get parameters");
+ hidl_vec<hidl_string> keys;
+ hidl_vec<ParameterValue> values;
+ ASSERT_OK(device->getParameters(keys, returnIn(res, values)));
+ ASSERT_OK(device->setParameters(values));
+ values.resize(0);
+ ASSERT_OK(device->setParameters(values));
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////// debugDebug //////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+template <class DebugDump>
+static void testDebugDump(DebugDump debugDump) {
+ FILE* file = tmpfile();
+ ASSERT_NE(nullptr, file) << errno;
+
+ auto* nativeHandle = native_handle_create(1, 0);
+ ASSERT_NE(nullptr, nativeHandle);
+ nativeHandle->data[0] = fileno(file);
+
+ hidl_handle handle;
+ handle.setTo(nativeHandle, true /*take ownership*/);
+
+ // TODO: debugDump does not return a Result.
+ // This mean that the hal can not report that it not implementing the function.
+ ASSERT_OK(debugDump(handle));
+
+ rewind(file); // can not fail
+
+ // Check that at least one bit was written by the hal
+ char buff;
+ ASSERT_EQ(size_t{1}, fread(&buff, sizeof(buff), 1, file));
+ EXPECT_EQ(0, fclose(file)) << errno;
+}
+
+TEST_F(AudioPrimaryHidlTest, debugDump) {
+ doc::test("Check that the hal can dump its state without error");
+ testDebugDump([this](const auto& handle){ return device->debugDump(handle); });
+}
+
+//////////////////////////////////////////////////////////////////////////////
+////////////////////////// open{Output,Input}Stream //////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+template <class Stream>
+class OpenStreamTest : public AudioConfigPrimaryTest,
+ public ::testing::WithParamInterface<AudioConfig> {
+protected:
+ template <class Open>
+ void testOpen(Open openStream, const AudioConfig& config) {
+ // FIXME: Open a stream without an IOHandle
+ // This is not required to be accepted by hal implementations
+ AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE;
+ AudioConfig suggestedConfig{};
+ ASSERT_OK(openStream(ioHandle, config, returnIn(res, stream, suggestedConfig)));
+
+ // TODO: only allow failure for RecommendedPlaybackAudioConfig
+ switch (res) {
+ case Result::OK:
+ ASSERT_TRUE(stream != nullptr);
+ audioConfig = config;
+ break;
+ case Result::INVALID_ARGUMENTS:
+ ASSERT_TRUE(stream == nullptr);
+ AudioConfig suggestedConfigRetry;
+ // Could not open stream with config, try again with the suggested one
+ ASSERT_OK(openStream(ioHandle, suggestedConfig,
+ returnIn(res, stream, suggestedConfigRetry)));
+ // This time it must succeed
+ ASSERT_OK(res);
+ ASSERT_TRUE(stream == nullptr);
+ audioConfig = suggestedConfig;
+ break;
+ default:
+ FAIL() << "Invalid return status: " << ::testing::PrintToString(res);
+ }
+ open = true;
+ }
+
+ Return<Result> closeStream() {
+ open = false;
+ return stream->close();
+ }
+private:
+ void TearDown() override {
+ if (open) {
+ ASSERT_OK(stream->close());
+ }
+ }
+
+protected:
+
+ AudioConfig audioConfig;
+ DeviceAddress address = {};
+ sp<Stream> stream;
+ bool open = false;
+};
+
+////////////////////////////// openOutputStream //////////////////////////////
+
+class OutputStreamTest : public OpenStreamTest<IStreamOut> {
+ virtual void SetUp() override {
+ ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base
+ address.device = AudioDevice::OUT_DEFAULT;
+ const AudioConfig& config = GetParam();
+ AudioOutputFlag flags = AudioOutputFlag::NONE; // TODO: test all flag combination
+ testOpen([&](AudioIoHandle handle, AudioConfig config, auto cb)
+ { return device->openOutputStream(handle, address, config, flags, cb); },
+ config);
+ }
+};
+TEST_P(OutputStreamTest, OpenOutputStreamTest) {
+ doc::test("Check that output streams can be open with the required and recommended config");
+ // Open done in SetUp
+}
+INSTANTIATE_TEST_CASE_P(
+ RequiredOutputStreamConfigSupport, OutputStreamTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()),
+ &generateTestName);
+INSTANTIATE_TEST_CASE_P(
+ SupportedOutputStreamConfig, OutputStreamTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()),
+ &generateTestName);
+
+INSTANTIATE_TEST_CASE_P(
+ RecommendedOutputStreamConfigSupport, OutputStreamTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()),
+ &generateTestName);
+
+////////////////////////////// openInputStream //////////////////////////////
+
+class InputStreamTest : public OpenStreamTest<IStreamIn> {
+
+ virtual void SetUp() override {
+ ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base
+ address.device = AudioDevice::IN_DEFAULT;
+ const AudioConfig& config = GetParam();
+ AudioInputFlag flags = AudioInputFlag::NONE; // TODO: test all flag combination
+ AudioSource source = AudioSource::DEFAULT; // TODO: test all flag combination
+ testOpen([&](AudioIoHandle handle, AudioConfig config, auto cb)
+ { return device->openInputStream(handle, address, config, flags, source, cb); },
+ config);
+ }
+};
+
+TEST_P(InputStreamTest, OpenInputStreamTest) {
+ doc::test("Check that input streams can be open with the required and recommended config");
+ // Open done in setup
+}
+INSTANTIATE_TEST_CASE_P(
+ RequiredInputStreamConfigSupport, InputStreamTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
+ &generateTestName);
+INSTANTIATE_TEST_CASE_P(
+ SupportedInputStreamConfig, InputStreamTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
+ &generateTestName);
+
+INSTANTIATE_TEST_CASE_P(
+ RecommendedInputStreamConfigSupport, InputStreamTest,
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
+ &generateTestName);
+
+//////////////////////////////////////////////////////////////////////////////
+////////////////////////////// IStream getters ///////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+/** Unpack the provided result.
+ * If the result is not OK, register a failure and return an undefined value. */
+template <class R>
+static R extract(Return<R> ret) {
+ if (!ret.isOk()) {
+ ADD_FAILURE();
+ return R{};
+ }
+ return ret;
+}
+
+/* Could not find a way to write a test for two parametrized class fixure
+ * thus use this macro do duplicate tests for Input and Output stream */
+#define TEST_IO_STREAM(test_name, documentation, code) \
+ TEST_P(InputStreamTest, test_name) { \
+ doc::test(documentation); \
+ code; \
+ } \
+ TEST_P(OutputStreamTest, test_name) { \
+ doc::test(documentation); \
+ code; \
+ }
+
+TEST_IO_STREAM(GetFrameCount, "Check that the stream frame count == the one it was opened with",
+ ASSERT_EQ(audioConfig.frameCount, extract(stream->getFrameCount())))
+
+TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with",
+ ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate())))
+
+TEST_IO_STREAM(GetChannelMask, "Check that the stream channel mask == the one it was opened with",
+ ASSERT_EQ(audioConfig.channelMask, extract(stream->getChannelMask())))
+
+TEST_IO_STREAM(GetFormat, "Check that the stream format == the one it was opened with",
+ ASSERT_EQ(audioConfig.format, extract(stream->getFormat())))
+
+// TODO: for now only check that the framesize is not incoherent
+TEST_IO_STREAM(GetFrameSize, "Check that the stream frame size == the one it was opened with",
+ ASSERT_GT(extract(stream->getFrameSize()), 0U))
+
+TEST_IO_STREAM(GetBufferSize, "Check that the stream buffer size== the one it was opened with",
+ ASSERT_GE(extract(stream->getBufferSize()), \
+ extract(stream->getFrameSize())));
+
+template <class Property, class CapabilityGetter, class Getter, class Setter>
+static void testCapabilityGetter(const string& name, IStream* stream, Property currentValue,
+ CapabilityGetter capablityGetter, Getter getter, Setter setter) {
+ hidl_vec<Property> capabilities;
+ ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
+ if (capabilities.size() == 0) {
+ // The default hal should probably return a NOT_SUPPORTED if the hal does not expose
+ // capability retrieval. For now it returns an empty list if not implemented
+ doc::partialTest(name + " is not supported");
+ return;
+ };
+ // TODO: This code has never been tested on a hal that supports getSupportedSampleRates
+ EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
+ capabilities.end())
+ << "current " << name << " is not in the list of the supported ones "
+ << toString(capabilities);
+
+ // Check that all declared supported values are indeed supported
+ for (auto capability : capabilities) {
+ ASSERT_OK((stream->*setter)(capability));
+ ASSERT_EQ(capability, extract((stream->*getter)()));
+ }
+}
+
+TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declared as supported",
+ testCapabilityGetter("getSupportedSampleRate", stream.get(), \
+ extract(stream->getSampleRate()), \
+ &IStream::getSupportedSampleRates, \
+ &IStream::getSampleRate, &IStream::setSampleRate))
+
+TEST_IO_STREAM(SupportedChannelMask, "Check that the stream channel mask is declared as supported",
+ testCapabilityGetter("getSupportedChannelMask", stream.get(), \
+ extract(stream->getChannelMask()), \
+ &IStream::getSupportedChannelMasks, \
+ &IStream::getChannelMask, &IStream::setChannelMask))
+
+TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as supported",
+ testCapabilityGetter("getSupportedFormat", stream.get(), \
+ extract(stream->getFormat()), \
+ &IStream::getSupportedFormats, \
+ &IStream::getFormat, &IStream::setFormat))
+
+static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
+ auto ret = stream->getDevice();
+ ASSERT_TRUE(ret.isOk());
+ AudioDevice device = ret;
+ ASSERT_EQ(expectedDevice, device);
+}
+
+TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with",
+ areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") : \
+ testGetDevice(stream.get(), address.device))
+
+static void testSetDevice(IStream* stream, const DeviceAddress& address) {
+ DeviceAddress otherAddress = address;
+ otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ?
+ AudioDevice::OUT_SPEAKER : AudioDevice::IN_BUILTIN_MIC;
+ EXPECT_OK(stream->setDevice(otherAddress));
+
+ ASSERT_OK(stream->setDevice(address)); // Go back to the original value
+}
+
+TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
+ areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") : \
+ testSetDevice(stream.get(), address))
+
+static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) {
+ uint32_t sampleRateHz;
+ AudioChannelMask mask;
+ AudioFormat format;
+
+ stream->getAudioProperties(returnIn(sampleRateHz, mask, format));
+
+ // FIXME: the qcom hal it does not currently negotiate the sampleRate & channel mask
+ EXPECT_EQ(expectedConfig.sampleRateHz, sampleRateHz);
+ EXPECT_EQ(expectedConfig.channelMask, mask);
+ EXPECT_EQ(expectedConfig.format, format);
+}
+
+TEST_IO_STREAM(GetAudioProperties,
+ "Check that the stream audio properties == the ones it was opened with",
+ testGetAudioProperties(stream.get(), audioConfig))
+
+static void testConnectedState(IStream* stream) {
+ DeviceAddress address = {};
+ using AD = AudioDevice;
+ for (auto device : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
+ address.device = device;
+
+ ASSERT_OK(stream->setConnectedState(address, true));
+ ASSERT_OK(stream->setConnectedState(address, false));
+ }
+}
+TEST_IO_STREAM(SetConnectedState,
+ "Check that the stream can be notified of device connection and deconnection",
+ testConnectedState(stream.get()))
+
+
+static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED};
+TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value",
+ ASSERT_RESULT(invalidArgsOrNotSupported, stream->setHwAvSync(666)))
+
+static void checkGetParameter(IStream* stream, hidl_vec<hidl_string> keys,
+ vector<Result> expectedResults) {
+ hidl_vec<ParameterValue> parameters;
+ Result res;
+ ASSERT_OK(stream->getParameters(keys, returnIn(res, parameters)));
+ ASSERT_RESULT(expectedResults, res);
+ if (res == Result::OK) {
+ ASSERT_EQ(0U, parameters.size());
+ }
+}
+
+/* Get/Set parameter is intended to be an opaque channel between vendors app and their HALs.
+ * Thus can not be meaningfully tested.
+ * TODO: Doc missing. Should asking for an empty set of params raise an error ?
+ */
+TEST_IO_STREAM(getEmptySetParameter, "Retrieve the values of an empty set",
+ checkGetParameter(stream.get(), {} /* keys */,
+ {Result::OK, Result::INVALID_ARGUMENTS}))
+
+
+TEST_IO_STREAM(getNonExistingParameter, "Retrieve the values of an non existing parameter",
+ checkGetParameter(stream.get(), {"Non existing key"} /* keys */,
+ {Result::INVALID_ARGUMENTS}))
+
+static vector<Result> okOrNotSupported = {Result::OK, Result::INVALID_ARGUMENTS};
+TEST_IO_STREAM(setEmptySetParameter, "Set the values of an empty set of parameters",
+ ASSERT_RESULT(okOrNotSupported, stream->setParameters({})))
+
+TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing parameter",
+ ASSERT_RESULT(Result::INVALID_ARGUMENTS,
+ stream->setParameters({{"non existing key", "0"}})))
+
+TEST_IO_STREAM(DebugDump,
+ "Check that a stream can dump its state without error",
+ testDebugDump([this](const auto& handle){ return stream->debugDump(handle); }))
+
+//////////////////////////////////////////////////////////////////////////////
+////////////////////////////// addRemoveEffect ///////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+TEST_IO_STREAM(AddNonExistingEffect, "Adding a non existing effect should fail",
+ ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->addEffect(666)))
+TEST_IO_STREAM(RemoveNonExistingEffect, "Removing a non existing effect should fail",
+ ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->removeEffect(666)))
+
+//TODO: positive tests
+
+//////////////////////////////////////////////////////////////////////////////
+/////////////////////////////// Control ////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+TEST_IO_STREAM(standby, "Make sure the stream can be put in stanby",
+ ASSERT_OK(stream->standby())) // can not fail
+
+static vector<Result> invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED};
+
+TEST_IO_STREAM(startNoMmap, "Starting a mmaped stream before mapping it should fail",
+ ASSERT_RESULT(invalidStateOrNotSupported, stream->start()))
+
+TEST_IO_STREAM(stopNoMmap, "Stopping a mmaped stream before mapping it should fail",
+ ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
+
+TEST_IO_STREAM(getMmapPositionNoMmap, "Get a stream Mmap position before mapping it should fail",
+ ASSERT_RESULT(invalidStateOrNotSupported, stream->stop()))
+
+TEST_IO_STREAM(close, "Make sure a stream can be closed", ASSERT_OK(closeStream()))
+TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice",
+ ASSERT_OK(closeStream()); \
+ ASSERT_RESULT(Result::INVALID_STATE, closeStream()))
+
+static void testCreateTooBigMmapBuffer(IStream* stream) {
+ MmapBufferInfo info;
+ Result res;
+ // Assume that int max is a value too big to be allocated
+ // This is true currently with a 32bit media server, but might not when it will run in 64 bit
+ auto minSizeFrames = std::numeric_limits<int32_t>::max();
+ ASSERT_OK(stream->createMmapBuffer(minSizeFrames, returnIn(res, info)));
+ ASSERT_RESULT(invalidArgsOrNotSupported, res);
+}
+
+TEST_IO_STREAM(CreateTooBigMmapBuffer, "Create mmap buffer too big should fail",
+ testCreateTooBigMmapBuffer(stream.get()))
+
+
+static void testGetMmapPositionOfNonMmapedStream(IStream* stream) {
+ Result res;
+ MmapPosition position;
+ ASSERT_OK(stream->getMmapPosition(returnIn(res, position)));
+ ASSERT_RESULT(invalidArgsOrNotSupported, res);
+}
+
+TEST_IO_STREAM(GetMmapPositionOfNonMmapedStream,
+ "Retrieving the mmap position of a non mmaped stream should fail",
+ testGetMmapPositionOfNonMmapedStream(stream.get()))
+
+//////////////////////////////////////////////////////////////////////////////
+///////////////////////////////// StreamIn ///////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+TEST_P(InputStreamTest, GetAudioSource) {
+ doc::test("Retrieving the audio source of an input stream should always succeed");
+ AudioSource source;
+ ASSERT_OK(stream->getAudioSource(returnIn(res, source)));
+ ASSERT_OK(res);
+ ASSERT_EQ(AudioSource::DEFAULT, source);
+}
+
+static void testUnitaryGain(std::function<Return<Result> (float)> setGain) {
+ for (float value : {0.0, 0.01, 0.5, 0.09, 1.0}) {
+ SCOPED_TRACE("value=" + to_string(value));
+ ASSERT_OK(setGain(value));
+ }
+ for (float value : (float[]){-INFINITY,-1.0, -0.0,
+ 1.0 + std::numeric_limits<float>::epsilon(), 2.0, INFINITY,
+ NAN}) {
+ SCOPED_TRACE("value=" + to_string(value));
+ // FIXME: NAN should never be accepted
+ // FIXME: Missing api doc. What should the impl do if the volume is outside [0,1] ?
+ ASSERT_RESULT(Result::INVALID_ARGUMENTS, setGain(value));
+ }
+}
+
+TEST_P(InputStreamTest, SetGain) {
+ doc::test("The gain of an input stream should only be set between [0,1]");
+ testUnitaryGain([this](float volume) { return stream->setGain(volume); });
+}
+
+static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount) {
+ Result res;
+ // Ignore output parameters as the call should fail
+ ASSERT_OK(stream->prepareForReading(frameSize, framesCount,
+ [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
+ EXPECT_RESULT(invalidArgsOrNotSupported, res);
+}
+
+TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) {
+ doc::test("Preparing a stream for reading with a 2^32 sized buffer should fail");
+ testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max());
+}
+
+TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
+ doc::test("Preparing a stream for reading with a overflowing sized buffer should fail");
+ auto uintMax = std::numeric_limits<uint32_t>::max();
+ testPrepareForReading(stream.get(), uintMax, uintMax);
+}
+
+TEST_P(InputStreamTest, getCapturePosition) {
+ doc::test("The capture position of a non prepared stream should not be retrievable");
+ uint64_t frames;
+ uint64_t time;
+ ASSERT_OK(stream->getCapturePosition(returnIn(res, frames, time)));
+ ASSERT_RESULT(invalidStateOrNotSupported, res);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+/////////////////////////////// PrimaryDevice ////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+
+TEST_F(AudioPrimaryHidlTest, setVoiceVolume) {
+ doc::test("Make sure setVoiceVolume only succeed if volume is in [0,1]");
+ testUnitaryGain([this](float volume) { return device->setVoiceVolume(volume); });
+}
+
+TEST_F(AudioPrimaryHidlTest, setMode) {
+ doc::test("Make sure setMode always succeeds if mode is valid");
+ for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION,
+ AudioMode::RINGTONE, AudioMode::CURRENT,
+ AudioMode::NORMAL /* Make sure to leave the test in normal mode */ }) {
+ SCOPED_TRACE("mode=" + toString(mode));
+ ASSERT_OK(device->setMode(mode));
+ }
+
+ // FIXME: Missing api doc. What should the impl do if the mode is invalid ?
+ ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode::INVALID));
+}
+
+
+TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) {
+ doc::test("Query and set the BT SCO NR&EC state");
+ testOptionalAccessors("BtScoNrecEnabled", {true, false, true},
+ &IPrimaryDevice::setBtScoNrecEnabled,
+ &IPrimaryDevice::getBtScoNrecEnabled);
+}
+
+TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) {
+ doc::test("Query and set the SCO whideband state");
+ testOptionalAccessors("BtScoWideband", {true, false, true},
+ &IPrimaryDevice::setBtScoWidebandEnabled,
+ &IPrimaryDevice::getBtScoWidebandEnabled);
+}
+
+using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
+TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
+ doc::test("Query and set the TTY mode state");
+ testOptionalAccessors("TTY mode", {TtyMode::OFF, TtyMode::HCO, TtyMode::VCO, TtyMode::FULL},
+ &IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode);
+}
+
+TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {
+ doc::test("Query and set the HAC state");
+ testAccessors("HAC", {true, false, true},
+ &IPrimaryDevice::setHacEnabled,
+ &IPrimaryDevice::getHacEnabled);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////// Clean caches on global tear down ////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+int main(int argc, char** argv) {
+ environment = new Environment;
+ ::testing::AddGlobalTestEnvironment(environment);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/audio/2.0/vts/functional/utility/AssertOk.h b/audio/2.0/vts/functional/utility/AssertOk.h
new file mode 100644
index 0000000..39c9a1d
--- /dev/null
+++ b/audio/2.0/vts/functional/utility/AssertOk.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2017 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 <vector>
+#include <algorithm>
+
+#include <hidl/Status.h>
+
+namespace detail {
+
+// This is a detail namespace, thus it is OK to import a class as nobody else is allowed to use it
+using ::android::hardware::Return;
+using ::android::hardware::audio::V2_0::Result;
+
+inline void assertResult(Result expected, Result result) {
+ ASSERT_EQ(expected, result);
+}
+
+inline void assertResult(Result expected, Return<Result> ret) {
+ ASSERT_TRUE(ret.isOk());
+ Result result = ret;
+ assertResult(expected, result);
+}
+
+inline void assertResult(std::vector<Result> expected, Result result) {
+ if (std::find(expected.begin(), expected.end(), result) != expected.end()) {
+ return; // result is in expected
+ }
+ FAIL() << "Expected result " << ::testing::PrintToString(result)
+ << " to be one of " << ::testing::PrintToString(expected);
+}
+
+inline void assertResult(std::vector<Result> expected, Return<Result> ret) {
+ ASSERT_TRUE(ret.isOk());
+ Result result = ret;
+ assertResult(expected, result);
+}
+
+inline void assertOk(Return<void> ret) {
+ ASSERT_TRUE(ret.isOk());
+}
+
+inline void assertOk(Result result) {
+ assertResult(Result::OK, result);
+}
+
+inline void assertOk(Return<Result> ret) {
+ assertResult(Result::OK, std::move(ret));
+}
+
+}
+
+// Test anything provided is and contains only OK
+#define ASSERT_OK(ret) ASSERT_NO_FATAL_FAILURE(detail::assertOk(ret))
+#define EXPECT_OK(ret) EXPECT_NO_FATAL_FAILURE(detail::assertOk(ret))
+
+#define ASSERT_RESULT(expected, ret) ASSERT_NO_FATAL_FAILURE(detail::assertResult(expected, ret))
+#define EXPECT_RESULT(expected, ret) ASSERT_NO_FATAL_FAILURE(detail::assertResult(expected, ret))
diff --git a/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h b/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h
new file mode 100644
index 0000000..025cd1c
--- /dev/null
+++ b/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 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 <type_traits>
+
+/** @file Use HIDL generated toString methods to pretty print gtest errors */
+
+namespace detail {
+
+// Print the value of an enum as hex
+template <class Enum>
+inline void printUnderlyingValue(Enum value, ::std::ostream* os) {
+ *os << std::hex << " (0x" << static_cast<std::underlying_type_t<Enum>>(value) << ")";
+}
+
+} // namespace detail
+
+namespace android {
+namespace hardware {
+namespace audio {
+namespace V2_0 {
+
+inline void PrintTo(const Result& result, ::std::ostream* os) {
+ *os << toString(result);
+ detail::printUnderlyingValue(result, os);
+}
+
+} // namespace V2_0
+namespace common {
+namespace V2_0 {
+
+inline void PrintTo(const AudioConfig& config, ::std::ostream* os) {
+ *os << toString(config);
+}
+
+inline void PrintTo(const AudioDevice& device, ::std::ostream* os) {
+ *os << toString(device);
+ detail::printUnderlyingValue(device, os);
+}
+
+inline void PrintTo(const AudioChannelMask& channelMask, ::std::ostream* os) {
+ *os << toString(channelMask);
+ detail::printUnderlyingValue(channelMask, os);
+}
+
+} // namespace V2_0
+} // namespace common
+} // namespace audio
+} // namespace hardware
+} // namespace android
diff --git a/audio/2.0/vts/functional/utility/ReturnIn.h b/audio/2.0/vts/functional/utility/ReturnIn.h
new file mode 100644
index 0000000..bb2389a
--- /dev/null
+++ b/audio/2.0/vts/functional/utility/ReturnIn.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 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 <tuple>
+
+namespace utility {
+
+namespace detail {
+// Helper class to generate the HIDL synchronous callback
+template <class... ResultStore>
+class ReturnIn {
+ public:
+ // Provide to the constructor the variables where the output parameters must be copied
+ // TODO: take pointers to match google output parameter style ?
+ ReturnIn(ResultStore&... ts) : results(ts...) {}
+ // Synchronous callback
+ template <class... Results>
+ void operator() (Results&&...results) {
+ set(std::forward<Results>(results)...);
+ }
+ private:
+ // Recursively set all output parameters
+ template <class Head, class... Tail>
+ void set(Head&& head, Tail&&... tail) {
+ std::get<sizeof...(ResultStore) - sizeof...(Tail) - 1>(results)
+ = std::forward<Head>(head);
+ set(tail...);
+ }
+ // Trivial case
+ void set() {}
+
+ // All variables to set are stored here
+ std::tuple<ResultStore&...> results;
+};
+} // namespace detail
+
+// Generate the HIDL synchronous callback with a copy policy
+// Input: the variables (lvalue reference) where to save the return values
+// Output: the callback to provide to a HIDL call with a synchronous callback
+// The output parameters *will be copied* do not use this function if you have
+// a zero copy policy
+template <class... ResultStore>
+detail::ReturnIn<ResultStore...> returnIn(ResultStore&... ts) { return {ts...};}
+
+}
diff --git a/audio/Android.bp b/audio/Android.bp
index 3121a36..8a1e892 100644
--- a/audio/Android.bp
+++ b/audio/Android.bp
@@ -1,6 +1,7 @@
// This is an autogenerated file, do not edit.
subdirs = [
"2.0",
+ "2.0/vts/functional",
"common/2.0",
"effect/2.0",
"effect/2.0/vts/functional",
diff --git a/audio/common/2.0/types.hal b/audio/common/2.0/types.hal
index ae7f545..93b898b 100644
--- a/audio/common/2.0/types.hal
+++ b/audio/common/2.0/types.hal
@@ -537,6 +537,7 @@
/* audio bus implemented by the audio system (e.g an MOST stereo channel) */
OUT_BUS = 0x1000000,
OUT_PROXY = 0x2000000,
+ OUT_USB_HEADSET = 0x4000000,
OUT_DEFAULT = BIT_DEFAULT,
OUT_ALL = (OUT_EARPIECE |
OUT_SPEAKER |
@@ -603,6 +604,7 @@
/* audio bus implemented by the audio system (e.g an MOST stereo channel) */
IN_BUS = BIT_IN | 0x100000,
IN_PROXY = BIT_IN | 0x1000000,
+ IN_USB_HEADSET = BIT_IN | 0x2000000,
IN_DEFAULT = BIT_IN | BIT_DEFAULT,
IN_ALL = (IN_COMMUNICATION |
@@ -670,6 +672,7 @@
DIRECT_PCM = 0x2000, // Audio stream containing PCM data that needs
// to pass through compress path for DSP post proc.
MMAP_NOIRQ = 0x4000, // output operates in MMAP no IRQ mode.
+ VOIP_CALL_RX = 0x8000, // preferred output for VoIP calls.
};
/*
@@ -680,12 +683,13 @@
*/
@export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_")
enum AudioInputFlag : int32_t {
- NONE = 0x0, // no attributes
- FAST = 0x1, // prefer an input that supports "fast tracks"
- HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source
- RAW = 0x4, // minimize signal processing
- SYNC = 0x8, // synchronize I/O streams
- MMAP_NOIRQ = 0x10, // input operates in MMAP no IRQ mode.
+ NONE = 0x0, // no attributes
+ FAST = 0x1, // prefer an input that supports "fast tracks"
+ HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source
+ RAW = 0x4, // minimize signal processing
+ SYNC = 0x8, // synchronize I/O streams
+ MMAP_NOIRQ = 0x10, // input operates in MMAP no IRQ mode.
+ VOIP_CALL_TX = 0x20, // preferred input for VoIP calls.
};
@export(name="audio_usage_t", value_prefix="AUDIO_USAGE_")
diff --git a/audio/effect/2.0/IEffect.hal b/audio/effect/2.0/IEffect.hal
index 9e10117..d254e8c 100644
--- a/audio/effect/2.0/IEffect.hal
+++ b/audio/effect/2.0/IEffect.hal
@@ -59,7 +59,7 @@
*
* @return retval operation completion status.
*/
- @callflow(next={"process"})
+ @callflow(next={"prepareForProcessing"})
enable() generates (Result retval);
/*
@@ -67,7 +67,7 @@
*
* @return retval operation completion status.
*/
- @exit
+ @callflow(next={"close"})
disable() generates (Result retval);
/*
@@ -75,6 +75,9 @@
* effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its
* descriptor to receive this command when the device changes.
*
+ * Note: this method is only supported for effects inserted into
+ * the output chain.
+ *
* @param device output device specification.
* @return retval operation completion status.
*/
@@ -145,6 +148,9 @@
* implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to
* receive this command when the device changes.
*
+ * Note: this method is only supported for effects inserted into
+ * the input chain.
+ *
* @param device input device specification.
* @return retval operation completion status.
*/
@@ -209,6 +215,9 @@
* Set the audio source the capture path is configured for (Camcorder, voice
* recognition...).
*
+ * Note: this method is only supported for effects inserted into
+ * the input chain.
+ *
* @param source source descriptor.
* @return retval operation completion status.
*/
@@ -258,6 +267,7 @@
* the queue.
* @return statusMQ a message queue used for passing status from the effect.
*/
+ @callflow(next={"setProcessBuffers"})
prepareForProcessing() generates (Result retval, fmq_sync<Result> statusMQ);
/*
@@ -275,6 +285,7 @@
* INVALID_ARGUMENTS if there was a problem with mapping
* any of the buffers.
*/
+ @callflow(next={"*"})
setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer) generates (
Result retval);
@@ -423,5 +434,6 @@
* @return retval OK in case the success.
* INVALID_STATE if the effect was already closed.
*/
+ @exit
close() generates (Result retval);
};
diff --git a/audio/effect/2.0/IEqualizerEffect.hal b/audio/effect/2.0/IEqualizerEffect.hal
index afcc4b6..b8fa177 100644
--- a/audio/effect/2.0/IEqualizerEffect.hal
+++ b/audio/effect/2.0/IEqualizerEffect.hal
@@ -29,34 +29,36 @@
* Returns the minimum and maximum band levels supported.
*/
getLevelRange()
- generates (Result retval, uint16_t minLevel, uint16_t maxLevel);
+ generates (Result retval, int16_t minLevel, int16_t maxLevel);
/*
* Sets the gain for the given equalizer band.
*/
- setBandLevel(uint16_t band, uint16_t level) generates (Result retval);
+ setBandLevel(uint16_t band, int16_t level) generates (Result retval);
/*
* Gets the gain for the given equalizer band.
*/
- getBandLevel(uint16_t band) generates (Result retval, uint16_t level);
+ getBandLevel(uint16_t band) generates (Result retval, int16_t level);
/*
- * Gets the center frequency of the given band.
+ * Gets the center frequency of the given band, in milliHertz.
*/
getBandCenterFrequency(uint16_t band)
- generates (Result retval, uint32_t centerFreq);
+ generates (Result retval, uint32_t centerFreqmHz);
/*
- * Gets the frequency range of the given frequency band.
+ * Gets the frequency range of the given frequency band, in milliHertz.
*/
getBandFrequencyRange(uint16_t band)
- generates (Result retval, uint32_t minFreqHz, uint32_t maxFreqHz);
+ generates (Result retval, uint32_t minFreqmHz, uint32_t maxFreqmHz);
/*
- * Gets the band that has the most effect on the given frequency.
+ * Gets the band that has the most effect on the given frequency
+ * in milliHertz.
*/
- getBandForFrequency(uint32_t freq) generates (Result retval, uint16_t band);
+ getBandForFrequency(uint32_t freqmHz)
+ generates (Result retval, uint16_t band);
/*
* Gets the names of all presets the equalizer supports.
@@ -76,7 +78,7 @@
struct AllProperties {
uint16_t curPreset;
- vec<uint16_t> bandLevels;
+ vec<int16_t> bandLevels;
};
/*
diff --git a/audio/effect/2.0/default/Effect.cpp b/audio/effect/2.0/default/Effect.cpp
index 83c8e09..6704239 100644
--- a/audio/effect/2.0/default/Effect.cpp
+++ b/audio/effect/2.0/default/Effect.cpp
@@ -188,6 +188,8 @@
// static
void Effect::effectBufferConfigFromHal(
const buffer_config_t& halConfig, EffectBufferConfig* config) {
+ config->buffer.id = 0;
+ config->buffer.frameCount = 0;
config->samplingRateHz = halConfig.samplingRate;
config->channels = AudioChannelMask(halConfig.channels);
config->format = AudioFormat(halConfig.format);
@@ -282,7 +284,7 @@
void Effect::getConfigImpl(int commandCode, const char* commandName, GetConfigCallback cb) {
uint32_t halResultSize = sizeof(effect_config_t);
- effect_config_t halConfig;
+ effect_config_t halConfig{};
status_t status = (*mHandle)->command(
mHandle, commandCode, 0, NULL, &halResultSize, &halConfig);
EffectConfig config;
@@ -309,15 +311,16 @@
Result Effect::getParameterImpl(
uint32_t paramSize,
const void* paramData,
- uint32_t valueSize,
+ uint32_t requestValueSize,
+ uint32_t replyValueSize,
GetParameterSuccessCallback onSuccess) {
// As it is unknown what method HAL uses for copying the provided parameter data,
// it is safer to make sure that input and output buffers do not overlap.
std::vector<uint8_t> halCmdBuffer =
- parameterToHal(paramSize, paramData, valueSize, nullptr);
+ parameterToHal(paramSize, paramData, requestValueSize, nullptr);
const void *valueData = nullptr;
std::vector<uint8_t> halParamBuffer =
- parameterToHal(paramSize, paramData, valueSize, &valueData);
+ parameterToHal(paramSize, paramData, replyValueSize, &valueData);
uint32_t halParamBufferSize = halParamBuffer.size();
return sendCommandReturningStatusAndData(
diff --git a/audio/effect/2.0/default/Effect.h b/audio/effect/2.0/default/Effect.h
index 13faec4..0918cd8 100644
--- a/audio/effect/2.0/default/Effect.h
+++ b/audio/effect/2.0/default/Effect.h
@@ -60,6 +60,8 @@
struct Effect : public IEffect {
typedef MessageQueue<Result, kSynchronizedReadWrite> StatusMQ;
+ using GetParameterSuccessCallback =
+ std::function<void(uint32_t valueSize, const void* valueData)>;
explicit Effect(effect_handle_t handle);
@@ -163,6 +165,22 @@
return setParameterImpl(sizeof(params), params, sizeof(T), ¶mValue);
}
+ Result getParameterImpl(
+ uint32_t paramSize,
+ const void* paramData,
+ uint32_t valueSize,
+ GetParameterSuccessCallback onSuccess) {
+ return getParameterImpl(paramSize, paramData, valueSize, valueSize, onSuccess);
+ }
+ Result getParameterImpl(
+ uint32_t paramSize,
+ const void* paramData,
+ uint32_t requestValueSize,
+ uint32_t replyValueSize,
+ GetParameterSuccessCallback onSuccess);
+ Result setParameterImpl(
+ uint32_t paramSize, const void* paramData, uint32_t valueSize, const void* valueData);
+
private:
friend struct VirtualizerEffect; // for getParameterImpl
friend struct VisualizerEffect; // to allow executing commands
@@ -170,8 +188,6 @@
using CommandSuccessCallback = std::function<void()>;
using GetConfigCallback = std::function<void(Result retval, const EffectConfig& config)>;
using GetCurrentConfigSuccessCallback = std::function<void(void* configData)>;
- using GetParameterSuccessCallback =
- std::function<void(uint32_t valueSize, const void* valueData)>;
using GetSupportedConfigsSuccessCallback =
std::function<void(uint32_t supportedConfigs, void* configsData)>;
@@ -220,11 +236,6 @@
void getConfigImpl(int commandCode, const char* commandName, GetConfigCallback cb);
Result getCurrentConfigImpl(
uint32_t featureId, uint32_t configSize, GetCurrentConfigSuccessCallback onSuccess);
- Result getParameterImpl(
- uint32_t paramSize,
- const void* paramData,
- uint32_t valueSize,
- GetParameterSuccessCallback onSuccess);
Result getSupportedConfigsImpl(
uint32_t featureId,
uint32_t maxConfigs,
@@ -252,8 +263,6 @@
const EffectConfig& config,
const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider);
- Result setParameterImpl(
- uint32_t paramSize, const void* paramData, uint32_t valueSize, const void* valueData);
};
} // namespace implementation
diff --git a/audio/effect/2.0/default/EffectsFactory.cpp b/audio/effect/2.0/default/EffectsFactory.cpp
index 572a428..08d92bd 100644
--- a/audio/effect/2.0/default/EffectsFactory.cpp
+++ b/audio/effect/2.0/default/EffectsFactory.cpp
@@ -95,7 +95,7 @@
status = EffectQueryNumberEffects(&numEffects);
if (status != OK) {
retval = Result::NOT_INITIALIZED;
- ALOGW("Error querying number of effects: %s", strerror(-status));
+ ALOGE("Error querying number of effects: %s", strerror(-status));
goto exit;
}
result.resize(numEffects);
@@ -105,7 +105,7 @@
if (status == OK) {
effectDescriptorFromHal(halDescriptor, &result[i]);
} else {
- ALOGW("Error querying effect at position %d / %d: %s",
+ ALOGE("Error querying effect at position %d / %d: %s",
i, numEffects, strerror(-status));
switch (status) {
case -ENOSYS: {
@@ -139,7 +139,7 @@
effectDescriptorFromHal(halDescriptor, &descriptor);
Result retval(Result::OK);
if (status != OK) {
- ALOGW("Error querying effect descriptor for %s: %s",
+ ALOGE("Error querying effect descriptor for %s: %s",
uuidToString(halUuid).c_str(), strerror(-status));
if (status == -ENOENT) {
retval = Result::INVALID_ARGUMENTS;
@@ -168,11 +168,13 @@
effect = dispatchEffectInstanceCreation(halDescriptor, handle);
effectId = EffectMap::getInstance().add(handle);
} else {
+ ALOGE("Error querying effect descriptor for %s: %s",
+ uuidToString(halUuid).c_str(), strerror(-status));
EffectRelease(handle);
}
}
if (status != OK) {
- ALOGW("Error creating effect %s: %s", uuidToString(halUuid).c_str(), strerror(-status));
+ ALOGE("Error creating effect %s: %s", uuidToString(halUuid).c_str(), strerror(-status));
if (status == -ENOENT) {
retval = Result::INVALID_ARGUMENTS;
} else {
diff --git a/audio/effect/2.0/default/EqualizerEffect.cpp b/audio/effect/2.0/default/EqualizerEffect.cpp
index 223716c..808d8eb 100644
--- a/audio/effect/2.0/default/EqualizerEffect.cpp
+++ b/audio/effect/2.0/default/EqualizerEffect.cpp
@@ -35,10 +35,15 @@
EqualizerEffect::~EqualizerEffect() {}
void EqualizerEffect::propertiesFromHal(
- t_equalizer_settings& halProperties,
+ const t_equalizer_settings& halProperties,
IEqualizerEffect::AllProperties* properties) {
properties->curPreset = halProperties.curPreset;
- properties->bandLevels.setToExternal(&halProperties.bandLevels[0], halProperties.numBands);
+ // t_equalizer_settings incorrectly defines bandLevels as uint16_t,
+ // whereas the actual type of values used by effects is int16_t.
+ const int16_t* signedBandLevels =
+ reinterpret_cast<const int16_t*>(&halProperties.bandLevels[0]);
+ properties->bandLevels.setToExternal(
+ const_cast<int16_t*>(signedBandLevels), halProperties.numBands);
}
std::vector<uint8_t> EqualizerEffect::propertiesToHal(
@@ -200,18 +205,18 @@
}
Return<void> EqualizerEffect::getLevelRange(getLevelRange_cb _hidl_cb) {
- uint16_t halLevels[2] = { 0, 0 };
+ int16_t halLevels[2] = { 0, 0 };
Result retval = mEffect->getParam(EQ_PARAM_LEVEL_RANGE, halLevels);
_hidl_cb(retval, halLevels[0], halLevels[1]);
return Void();
}
-Return<Result> EqualizerEffect::setBandLevel(uint16_t band, uint16_t level) {
+Return<Result> EqualizerEffect::setBandLevel(uint16_t band, int16_t level) {
return mEffect->setParam(EQ_PARAM_BAND_LEVEL, band, level);
}
Return<void> EqualizerEffect::getBandLevel(uint16_t band, getBandLevel_cb _hidl_cb) {
- uint16_t halLevel = 0;
+ int16_t halLevel = 0;
Result retval = mEffect->getParam(EQ_PARAM_BAND_LEVEL, band, halLevel);
_hidl_cb(retval, halLevel);
return Void();
@@ -272,14 +277,28 @@
const IEqualizerEffect::AllProperties& properties) {
t_equalizer_settings *halPropertiesPtr = nullptr;
std::vector<uint8_t> halBuffer = propertiesToHal(properties, &halPropertiesPtr);
- return mEffect->setParam(EQ_PARAM_PROPERTIES, *halPropertiesPtr);
+ uint32_t paramId = EQ_PARAM_PROPERTIES;
+ return mEffect->setParameterImpl(
+ sizeof(paramId), ¶mId, halBuffer.size(), halPropertiesPtr);
}
Return<void> EqualizerEffect::getAllProperties(getAllProperties_cb _hidl_cb) {
- t_equalizer_settings halProperties;
- Result retval = mEffect->getParam(EQ_PARAM_PROPERTIES, halProperties);
+ uint16_t numBands = 0;
+ Result retval = mEffect->getParam(EQ_PARAM_NUM_BANDS, numBands);
AllProperties properties;
- propertiesFromHal(halProperties, &properties);
+ if (retval != Result::OK) {
+ _hidl_cb(retval, properties);
+ return Void();
+ }
+ size_t valueSize = sizeof(t_equalizer_settings) + sizeof(int16_t) * numBands;
+ uint32_t paramId = EQ_PARAM_PROPERTIES;
+ retval = mEffect->getParameterImpl(
+ sizeof(paramId), ¶mId, valueSize,
+ [&] (uint32_t, const void* valueData) {
+ const t_equalizer_settings* halProperties =
+ reinterpret_cast<const t_equalizer_settings*>(valueData);
+ propertiesFromHal(*halProperties, &properties);
+ });
_hidl_cb(retval, properties);
return Void();
}
diff --git a/audio/effect/2.0/default/EqualizerEffect.h b/audio/effect/2.0/default/EqualizerEffect.h
index c9bed4f..9e8d75b 100644
--- a/audio/effect/2.0/default/EqualizerEffect.h
+++ b/audio/effect/2.0/default/EqualizerEffect.h
@@ -114,7 +114,7 @@
// Methods from ::android::hardware::audio::effect::V2_0::IEqualizerEffect follow.
Return<void> getNumBands(getNumBands_cb _hidl_cb) override;
Return<void> getLevelRange(getLevelRange_cb _hidl_cb) override;
- Return<Result> setBandLevel(uint16_t band, uint16_t level) override;
+ Return<Result> setBandLevel(uint16_t band, int16_t level) override;
Return<void> getBandLevel(uint16_t band, getBandLevel_cb _hidl_cb) override;
Return<void> getBandCenterFrequency(
uint16_t band, getBandCenterFrequency_cb _hidl_cb) override;
@@ -132,7 +132,7 @@
virtual ~EqualizerEffect();
void propertiesFromHal(
- t_equalizer_settings& halProperties,
+ const t_equalizer_settings& halProperties,
IEqualizerEffect::AllProperties* properties);
std::vector<uint8_t> propertiesToHal(
const IEqualizerEffect::AllProperties& properties,
diff --git a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp b/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
index e58b42c..fda5eb0 100644
--- a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
+++ b/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
@@ -182,7 +182,18 @@
}
Return<void> LoudnessEnhancerEffect::getTargetGain(getTargetGain_cb _hidl_cb) {
- return mEffect->getIntegerParam(LOUDNESS_ENHANCER_DEFAULT_TARGET_GAIN_MB, _hidl_cb);
+ // AOSP Loudness Enhancer expects the size of the request to not include the
+ // size of the parameter.
+ uint32_t paramId = LOUDNESS_ENHANCER_DEFAULT_TARGET_GAIN_MB;
+ uint32_t targetGainMb = 0;
+ Result retval = mEffect->getParameterImpl(
+ sizeof(paramId), ¶mId,
+ 0, sizeof(targetGainMb),
+ [&] (uint32_t, const void* valueData) {
+ memcpy(&targetGainMb, valueData, sizeof(targetGainMb));
+ });
+ _hidl_cb(retval, targetGainMb);
+ return Void();
}
} // namespace implementation
diff --git a/audio/effect/2.0/vts/functional/Android.bp b/audio/effect/2.0/vts/functional/Android.bp
index a162534..8a370cd 100644
--- a/audio/effect/2.0/vts/functional/Android.bp
+++ b/audio/effect/2.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalAudioEffectV2_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalAudioEffectV2_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -25,9 +26,12 @@
"libhidltransport",
"libnativehelper",
"libutils",
+ "android.hardware.audio.common@2.0",
"android.hardware.audio.effect@2.0",
+ "android.hidl.allocator@1.0",
+ "android.hidl.memory@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp b/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp
index 6c5b980..f6da213 100644
--- a/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp
+++ b/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2017 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.
@@ -16,47 +16,67 @@
#define LOG_TAG "AudioEffectHidlHalTest"
#include <android-base/logging.h>
-#include <cutils/native_handle.h>
+#include <system/audio.h>
+#include <android/hardware/audio/effect/2.0/IEffect.h>
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
+#include <android/hardware/audio/effect/2.0/IEqualizerEffect.h>
+#include <android/hardware/audio/effect/2.0/ILoudnessEnhancerEffect.h>
#include <android/hardware/audio/effect/2.0/types.h>
+#include <android/hidl/allocator/1.0/IAllocator.h>
+#include <android/hidl/memory/1.0/IMemory.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
-using ::android::hardware::audio::common::V2_0::Uuid;
-using ::android::hardware::audio::effect::V2_0::EffectDescriptor;
-using ::android::hardware::audio::effect::V2_0::IEffect;
-using ::android::hardware::audio::effect::V2_0::IEffectsFactory;
-using ::android::hardware::audio::effect::V2_0::Result;
-using ::android::hardware::Return;
-using ::android::hardware::Status;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::sp;
+using android::hardware::audio::common::V2_0::AudioDevice;
+using android::hardware::audio::common::V2_0::AudioHandleConsts;
+using android::hardware::audio::common::V2_0::AudioMode;
+using android::hardware::audio::common::V2_0::Uuid;
+using android::hardware::audio::effect::V2_0::AudioBuffer;
+using android::hardware::audio::effect::V2_0::EffectBufferConfig;
+using android::hardware::audio::effect::V2_0::EffectConfig;
+using android::hardware::audio::effect::V2_0::EffectDescriptor;
+using android::hardware::audio::effect::V2_0::EffectOffloadParameter;
+using android::hardware::audio::effect::V2_0::IEffect;
+using android::hardware::audio::effect::V2_0::IEffectsFactory;
+using android::hardware::audio::effect::V2_0::IEqualizerEffect;
+using android::hardware::audio::effect::V2_0::ILoudnessEnhancerEffect;
+using android::hardware::audio::effect::V2_0::Result;
+using android::hardware::MQDescriptorSync;
+using android::hardware::Return;
+using android::hardware::Void;
+using android::hardware::hidl_memory;
+using android::hardware::hidl_string;
+using android::hardware::hidl_vec;
+using android::hidl::allocator::V1_0::IAllocator;
+using android::hidl::memory::V1_0::IMemory;
+using android::sp;
-// The main test class for Audio Effect HIDL HAL.
-class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+#endif
+
+// The main test class for Audio Effects Factory HIDL HAL.
+class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
- virtual void SetUp() override {
- effectsFactory = ::testing::VtsHalHidlTargetBaseTest::getService<IEffectsFactory>();
+ void SetUp() override {
+ effectsFactory =
+ ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
ASSERT_NE(effectsFactory, nullptr);
}
- virtual void TearDown() override {}
+ void TearDown() override { effectsFactory.clear(); }
+
+ protected:
+ static void description(const std::string& description) {
+ RecordProperty("description", description);
+ }
sp<IEffectsFactory> effectsFactory;
};
-// A class for test environment setup (kept since this file is a template).
-class AudioEffectHidlEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- private:
-};
-
-TEST_F(AudioEffectHidlTest, EnumerateEffects) {
+TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) {
+ description("Verify that EnumerateEffects returns at least one effect");
Result retval = Result::NOT_INITIALIZED;
size_t effectCount = 0;
Return<void> ret = effectsFactory->getAllDescriptors(
@@ -65,11 +85,12 @@
effectCount = result.size();
});
EXPECT_TRUE(ret.isOk());
- EXPECT_EQ(retval, Result::OK);
+ EXPECT_EQ(Result::OK, retval);
EXPECT_GT(effectCount, 0u);
}
-TEST_F(AudioEffectHidlTest, CreateEffect) {
+TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) {
+ description("Verify that an effect can be created via CreateEffect");
bool gotEffect = false;
Uuid effectUuid;
Return<void> ret = effectsFactory->getAllDescriptors(
@@ -84,7 +105,7 @@
Result retval = Result::NOT_INITIALIZED;
sp<IEffect> effect;
ret = effectsFactory->createEffect(
- effectUuid, 1 /* session */, 1 /* ioHandle */,
+ effectUuid, 1 /*session*/, 1 /*ioHandle*/,
[&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
retval = r;
if (r == Result::OK) {
@@ -92,11 +113,14 @@
}
});
EXPECT_TRUE(ret.isOk());
- EXPECT_EQ(retval, Result::OK);
- EXPECT_NE(effect, nullptr);
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_NE(nullptr, effect.get());
}
-TEST_F(AudioEffectHidlTest, GetDescriptor) {
+TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) {
+ description(
+ "Verify that effects factory can provide an effect descriptor via "
+ "GetDescriptor");
hidl_vec<EffectDescriptor> allDescriptors;
Return<void> ret = effectsFactory->getAllDescriptors(
[&](Result r, const hidl_vec<EffectDescriptor>& result) {
@@ -116,10 +140,602 @@
EXPECT_TRUE(ret.isOk());
}
-int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new AudioEffectHidlEnvironment);
- ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- LOG(INFO) << "Test result = " << status;
- return status;
+// Equalizer effect is required by CDD, but only the type is fixed.
+// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java.
+static const Uuid EQUALIZER_EFFECT_TYPE = {
+ 0x0bed4300, 0xddd6, 0x11db, 0x8f34,
+ std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}};
+// Loudness Enhancer effect is required by CDD, but only the type is fixed.
+// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java.
+static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = {
+ 0xfe3199be, 0xaed0, 0x413f, 0x87bb,
+ std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}};
+
+// The main test class for Audio Effect HIDL HAL.
+class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ void SetUp() override {
+ effectsFactory =
+ ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
+ ASSERT_NE(nullptr, effectsFactory.get());
+
+ findAndCreateEffect(getEffectType());
+ ASSERT_NE(nullptr, effect.get());
+
+ Return<Result> ret = effect->init();
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, ret);
+ }
+
+ void TearDown() override {
+ effect.clear();
+ effectsFactory.clear();
+ }
+
+ protected:
+ static void description(const std::string& description) {
+ RecordProperty("description", description);
+ }
+
+ virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; }
+
+ void findAndCreateEffect(const Uuid& type);
+ void findEffectInstance(const Uuid& type, Uuid* uuid);
+ void getChannelCount(uint32_t* channelCount);
+
+ sp<IEffectsFactory> effectsFactory;
+ sp<IEffect> effect;
+};
+
+void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
+ Uuid effectUuid;
+ findEffectInstance(type, &effectUuid);
+ Return<void> ret = effectsFactory->createEffect(
+ effectUuid, 1 /*session*/, 1 /*ioHandle*/,
+ [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
+ if (r == Result::OK) {
+ effect = result;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+}
+
+void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) {
+ bool effectFound = false;
+ Return<void> ret = effectsFactory->getAllDescriptors(
+ [&](Result r, const hidl_vec<EffectDescriptor>& result) {
+ if (r == Result::OK) {
+ for (const auto& desc : result) {
+ if (desc.type == type) {
+ effectFound = true;
+ *uuid = desc.uuid;
+ break;
+ }
+ }
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_TRUE(effectFound);
+}
+
+void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
+ Result retval;
+ EffectConfig currentConfig;
+ Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+ retval = r;
+ if (r == Result::OK) {
+ currentConfig = conf;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, retval);
+ ASSERT_TRUE(audio_channel_mask_is_valid(
+ static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)));
+ *channelCount = audio_channel_count_from_out_mask(
+ static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
+}
+
+TEST_F(AudioEffectHidlTest, Close) {
+ description("Verify that an effect can be closed");
+ Return<Result> ret = effect->close();
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, GetDescriptor) {
+ description(
+ "Verify that an effect can return its own descriptor via GetDescriptor");
+ Result retval = Result::NOT_INITIALIZED;
+ Uuid actualType;
+ Return<void> ret =
+ effect->getDescriptor([&](Result r, const EffectDescriptor& desc) {
+ retval = r;
+ if (r == Result::OK) {
+ actualType = desc.type;
+ }
+ });
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_EQ(getEffectType(), actualType);
+}
+
+TEST_F(AudioEffectHidlTest, GetSetConfig) {
+ description(
+ "Verify that it is possible to manipulate effect config via Get / "
+ "SetConfig");
+ Result retval = Result::NOT_INITIALIZED;
+ EffectConfig currentConfig;
+ Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+ retval = r;
+ if (r == Result::OK) {
+ currentConfig = conf;
+ }
+ });
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr);
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, ret2);
+}
+
+// Not generated automatically because AudioBuffer contains
+// instances of hidl_memory which can't be compared properly
+// in general case due to presence of handles.
+//
+// However, in this particular case, handles must not present
+// thus comparison is possible.
+//
+// operator== must be defined in the same namespace as the structures.
+namespace android {
+namespace hardware {
+namespace audio {
+namespace effect {
+namespace V2_0 {
+inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
+ return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount &&
+ lhs.data.handle() == nullptr && rhs.data.handle() == nullptr;
+}
+
+inline bool operator==(const EffectBufferConfig& lhs,
+ const EffectBufferConfig& rhs) {
+ return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
+ lhs.channels == rhs.channels && lhs.format == rhs.format &&
+ lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
+}
+
+inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) {
+ return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg;
+}
+} // namespace V2_0
+} // namespace effect
+} // namespace audio
+} // namespace hardware
+} // namespace android
+
+TEST_F(AudioEffectHidlTest, Reset) {
+ description("Verify that Reset preserves effect configuration");
+ Result retval = Result::NOT_INITIALIZED;
+ EffectConfig originalConfig;
+ Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+ retval = r;
+ if (r == Result::OK) {
+ originalConfig = conf;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, retval);
+ Return<Result> ret2 = effect->reset();
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, ret2);
+ EffectConfig configAfterReset;
+ ret = effect->getConfig([&](Result r, const EffectConfig& conf) {
+ retval = r;
+ if (r == Result::OK) {
+ configAfterReset = conf;
+ }
+ });
+ EXPECT_EQ(originalConfig, configAfterReset);
+}
+
+TEST_F(AudioEffectHidlTest, DisableEnableDisable) {
+ description("Verify Disable -> Enable -> Disable sequence for an effect");
+ Return<Result> ret = effect->disable();
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::INVALID_ARGUMENTS, ret);
+ ret = effect->enable();
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+ ret = effect->disable();
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, SetDevice) {
+ description("Verify that SetDevice works for an output chain effect");
+ Return<Result> ret = effect->setDevice(AudioDevice::OUT_SPEAKER);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, SetAndGetVolume) {
+ description("Verify that SetAndGetVolume method works for an effect");
+ uint32_t channelCount;
+ getChannelCount(&channelCount);
+ hidl_vec<uint32_t> volumes;
+ volumes.resize(channelCount);
+ for (uint32_t i = 0; i < channelCount; ++i) {
+ volumes[i] = 0;
+ }
+ Result retval = Result::NOT_INITIALIZED;
+ Return<void> ret = effect->setAndGetVolume(
+ volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; });
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, retval);
+}
+
+TEST_F(AudioEffectHidlTest, VolumeChangeNotification) {
+ description("Verify that effect accepts VolumeChangeNotification");
+ uint32_t channelCount;
+ getChannelCount(&channelCount);
+ hidl_vec<uint32_t> volumes;
+ volumes.resize(channelCount);
+ for (uint32_t i = 0; i < channelCount; ++i) {
+ volumes[i] = 0;
+ }
+ Return<Result> ret = effect->volumeChangeNotification(volumes);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, SetAudioMode) {
+ description("Verify that SetAudioMode works for an effect");
+ Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, Offload) {
+ description("Verify that calling Offload methods works for an effect");
+ EffectOffloadParameter offloadParam;
+ offloadParam.isOffload = false;
+ offloadParam.ioHandle =
+ static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE);
+ Return<Result> ret = effect->offload(offloadParam);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+}
+
+TEST_F(AudioEffectHidlTest, PrepareForProcessing) {
+ description("Verify that PrepareForProcessing method works for an effect");
+ Result retval = Result::NOT_INITIALIZED;
+ Return<void> ret = effect->prepareForProcessing(
+ [&](Result r, const MQDescriptorSync<Result>&) { retval = r; });
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, retval);
+}
+
+TEST_F(AudioEffectHidlTest, SetProcessBuffers) {
+ description("Verify that SetProcessBuffers works for an effect");
+ sp<IAllocator> ashmem = IAllocator::getService("ashmem");
+ ASSERT_NE(nullptr, ashmem.get());
+ bool success = false;
+ AudioBuffer buffer;
+ Return<void> ret =
+ ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) {
+ success = s;
+ if (s) {
+ buffer.data = memory;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_TRUE(success);
+ Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer);
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, ret2);
+}
+
+// Testing getConfigReverse, getAuxChannelsConfig,
+// getSupportedAuxChannelsConfigs, setAudioSource, setConfigReverse,
+// setInputDevice doesn't make sense, because normally they are not supported by
+// the Equalizer, but it wouldn't be a problem if some vendor implementation
+// supports them, thus we can't test these methods neither for success, nor for
+// failure.
+
+// command, getParameter, getSupportedConfigsForFeature,
+// getCurrentConfigForFeature, setCurrentConfigForFeature, setParameter are
+// opaque channels between vendor apps and HALs, and can't be meaningfully
+// tested with effects that don't support them.
+
+// The main test class for Equalizer Audio Effect HIDL HAL.
+class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest {
+ public:
+ void SetUp() override {
+ AudioEffectHidlTest::SetUp();
+ equalizer = IEqualizerEffect::castFrom(effect);
+ ASSERT_NE(nullptr, equalizer.get());
+ }
+
+ protected:
+ Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; }
+ void getNumBands(uint16_t* numBands);
+ void getLevelRange(int16_t* minLevel, int16_t* maxLevel);
+ void getBandFrequencyRange(uint16_t band, uint32_t* minFreq,
+ uint32_t* centerFreq, uint32_t* maxFreq);
+ void getPresetCount(size_t* count);
+
+ sp<IEqualizerEffect> equalizer;
+};
+
+void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) {
+ Result retval = Result::NOT_INITIALIZED;
+ Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) {
+ retval = r;
+ if (retval == Result::OK) {
+ *numBands = b;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, retval);
+}
+
+void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel,
+ int16_t* maxLevel) {
+ Result retval = Result::NOT_INITIALIZED;
+ Return<void> ret =
+ equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) {
+ retval = r;
+ if (retval == Result::OK) {
+ *minLevel = min;
+ *maxLevel = max;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, retval);
+}
+
+void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band,
+ uint32_t* minFreq,
+ uint32_t* centerFreq,
+ uint32_t* maxFreq) {
+ Result retval = Result::NOT_INITIALIZED;
+ Return<void> ret = equalizer->getBandFrequencyRange(
+ band, [&](Result r, uint32_t min, uint32_t max) {
+ retval = r;
+ if (retval == Result::OK) {
+ *minFreq = min;
+ *maxFreq = max;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, retval);
+ ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) {
+ retval = r;
+ if (retval == Result::OK) {
+ *centerFreq = center;
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, retval);
+}
+
+void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) {
+ Result retval = Result::NOT_INITIALIZED;
+ Return<void> ret = equalizer->getPresetNames(
+ [&](Result r, const hidl_vec<hidl_string>& names) {
+ retval = r;
+ if (retval == Result::OK) {
+ *count = names.size();
+ }
+ });
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(Result::OK, retval);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) {
+ description("Verify that Equalizer effect reports at least one band");
+ uint16_t numBands = 0;
+ getNumBands(&numBands);
+ EXPECT_GT(numBands, 0);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) {
+ description("Verify that Equalizer effect reports adequate band level range");
+ int16_t minLevel = 0x7fff, maxLevel = 0;
+ getLevelRange(&minLevel, &maxLevel);
+ EXPECT_GT(maxLevel, minLevel);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
+ description(
+ "Verify that manipulating band levels works for Equalizer effect");
+ uint16_t numBands = 0;
+ getNumBands(&numBands);
+ ASSERT_GT(numBands, 0);
+ int16_t levels[3]{0x7fff, 0, 0};
+ getLevelRange(&levels[0], &levels[2]);
+ ASSERT_GT(levels[2], levels[0]);
+ levels[1] = (levels[2] + levels[0]) / 2;
+ for (uint16_t i = 0; i < numBands; ++i) {
+ for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) {
+ Return<Result> ret = equalizer->setBandLevel(i, levels[j]);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+ Result retval = Result::NOT_INITIALIZED;
+ int16_t actualLevel;
+ Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) {
+ retval = r;
+ if (retval == Result::OK) {
+ actualLevel = l;
+ }
+ });
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_EQ(levels[j], actualLevel);
+ }
+ }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
+ description(
+ "Verify that Equalizer effect reports adequate band frequency range");
+ uint16_t numBands = 0;
+ getNumBands(&numBands);
+ ASSERT_GT(numBands, 0);
+ for (uint16_t i = 0; i < numBands; ++i) {
+ uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff,
+ maxFreq = 0xffffffff;
+ getBandFrequencyRange(i, &minFreq, ¢erFreq, &maxFreq);
+ // Note: NXP legacy implementation reports "1" as upper bound for last band,
+ // so this check fails.
+ EXPECT_GE(maxFreq, centerFreq);
+ EXPECT_GE(centerFreq, minFreq);
+ }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
+ description(
+ "Verify that Equalizer effect supports GetBandForFrequency correctly");
+ uint16_t numBands = 0;
+ getNumBands(&numBands);
+ ASSERT_GT(numBands, 0);
+ for (uint16_t i = 0; i < numBands; ++i) {
+ uint32_t freqs[3]{0, 0, 0};
+ getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]);
+ // NXP legacy implementation reports "1" as upper bound for last band, some
+ // of the checks fail.
+ for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) {
+ if (j == 0) {
+ freqs[j]++;
+ } // Min frequency is an open interval.
+ Result retval = Result::NOT_INITIALIZED;
+ uint16_t actualBand = numBands + 1;
+ Return<void> ret =
+ equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) {
+ retval = r;
+ if (retval == Result::OK) {
+ actualBand = b;
+ }
+ });
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j];
+ }
+ }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) {
+ description("Verify that Equalizer effect reports at least one preset");
+ size_t presetCount;
+ getPresetCount(&presetCount);
+ EXPECT_GT(presetCount, 0u);
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
+ description(
+ "Verify that manipulating the current preset for Equalizer effect");
+ size_t presetCount;
+ getPresetCount(&presetCount);
+ ASSERT_GT(presetCount, 0u);
+ for (uint16_t i = 0; i < presetCount; ++i) {
+ Return<Result> ret = equalizer->setCurrentPreset(i);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+ Result retval = Result::NOT_INITIALIZED;
+ uint16_t actualPreset = 0xffff;
+ Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) {
+ retval = r;
+ if (retval == Result::OK) {
+ actualPreset = p;
+ }
+ });
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_EQ(i, actualPreset);
+ }
+}
+
+TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
+ description(
+ "Verify that setting band levels and presets works via Get / "
+ "SetAllProperties for Equalizer effect");
+ using AllProperties =
+ android::hardware::audio::effect::V2_0::IEqualizerEffect::AllProperties;
+ uint16_t numBands = 0;
+ getNumBands(&numBands);
+ ASSERT_GT(numBands, 0);
+ AllProperties props;
+ props.bandLevels.resize(numBands);
+ for (size_t i = 0; i < numBands; ++i) {
+ props.bandLevels[i] = 0;
+ }
+
+ AllProperties actualProps;
+ Result retval = Result::NOT_INITIALIZED;
+
+ // Verify setting of the band levels via properties.
+ props.curPreset = -1;
+ Return<Result> ret = equalizer->setAllProperties(props);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+ Return<void> ret2 =
+ equalizer->getAllProperties([&](Result r, AllProperties p) {
+ retval = r;
+ if (retval == Result::OK) {
+ actualProps = p;
+ }
+ });
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_EQ(props.bandLevels, actualProps.bandLevels);
+
+ // Verify setting of the current preset via properties.
+ props.curPreset = 0; // Assuming there is at least one preset.
+ ret = equalizer->setAllProperties(props);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+ ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) {
+ retval = r;
+ if (retval == Result::OK) {
+ actualProps = p;
+ }
+ });
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_EQ(props.curPreset, actualProps.curPreset);
+}
+
+// The main test class for Equalizer Audio Effect HIDL HAL.
+class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest {
+ public:
+ void SetUp() override {
+ AudioEffectHidlTest::SetUp();
+ enhancer = ILoudnessEnhancerEffect::castFrom(effect);
+ ASSERT_NE(nullptr, enhancer.get());
+ }
+
+ protected:
+ Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; }
+
+ sp<ILoudnessEnhancerEffect> enhancer;
+};
+
+TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
+ description(
+ "Verify that manipulating the target gain works for Loudness Enhancer "
+ "effect");
+ const int32_t gain = 100;
+ Return<Result> ret = enhancer->setTargetGain(gain);
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::OK, ret);
+ int32_t actualGain = 0;
+ Result retval;
+ Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) {
+ retval = r;
+ if (retval == Result::OK) {
+ actualGain = g;
+ }
+ });
+ EXPECT_TRUE(ret2.isOk());
+ EXPECT_EQ(Result::OK, retval);
+ EXPECT_EQ(gain, actualGain);
}
diff --git a/automotive/Android.bp b/automotive/Android.bp
index 1f39e88..9b24ded 100644
--- a/automotive/Android.bp
+++ b/automotive/Android.bp
@@ -1,5 +1,7 @@
// This is an autogenerated file, do not edit.
subdirs = [
+ "evs/1.0",
+ "evs/1.0/default",
"vehicle/2.0",
"vehicle/2.1",
]
diff --git a/automotive/evs/1.0/Android.bp b/automotive/evs/1.0/Android.bp
new file mode 100644
index 0000000..042becd
--- /dev/null
+++ b/automotive/evs/1.0/Android.bp
@@ -0,0 +1,83 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.automotive.evs@1.0_hal",
+ srcs: [
+ "types.hal",
+ "IEvsCamera.hal",
+ "IEvsCameraStream.hal",
+ "IEvsDisplay.hal",
+ "IEvsEnumerator.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.automotive.evs@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.automotive.evs@1.0",
+ srcs: [
+ ":android.hardware.automotive.evs@1.0_hal",
+ ],
+ out: [
+ "android/hardware/automotive/evs/1.0/types.cpp",
+ "android/hardware/automotive/evs/1.0/EvsCameraAll.cpp",
+ "android/hardware/automotive/evs/1.0/EvsCameraStreamAll.cpp",
+ "android/hardware/automotive/evs/1.0/EvsDisplayAll.cpp",
+ "android/hardware/automotive/evs/1.0/EvsEnumeratorAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.automotive.evs@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.automotive.evs@1.0",
+ srcs: [
+ ":android.hardware.automotive.evs@1.0_hal",
+ ],
+ out: [
+ "android/hardware/automotive/evs/1.0/types.h",
+ "android/hardware/automotive/evs/1.0/IEvsCamera.h",
+ "android/hardware/automotive/evs/1.0/IHwEvsCamera.h",
+ "android/hardware/automotive/evs/1.0/BnHwEvsCamera.h",
+ "android/hardware/automotive/evs/1.0/BpHwEvsCamera.h",
+ "android/hardware/automotive/evs/1.0/BsEvsCamera.h",
+ "android/hardware/automotive/evs/1.0/IEvsCameraStream.h",
+ "android/hardware/automotive/evs/1.0/IHwEvsCameraStream.h",
+ "android/hardware/automotive/evs/1.0/BnHwEvsCameraStream.h",
+ "android/hardware/automotive/evs/1.0/BpHwEvsCameraStream.h",
+ "android/hardware/automotive/evs/1.0/BsEvsCameraStream.h",
+ "android/hardware/automotive/evs/1.0/IEvsDisplay.h",
+ "android/hardware/automotive/evs/1.0/IHwEvsDisplay.h",
+ "android/hardware/automotive/evs/1.0/BnHwEvsDisplay.h",
+ "android/hardware/automotive/evs/1.0/BpHwEvsDisplay.h",
+ "android/hardware/automotive/evs/1.0/BsEvsDisplay.h",
+ "android/hardware/automotive/evs/1.0/IEvsEnumerator.h",
+ "android/hardware/automotive/evs/1.0/IHwEvsEnumerator.h",
+ "android/hardware/automotive/evs/1.0/BnHwEvsEnumerator.h",
+ "android/hardware/automotive/evs/1.0/BpHwEvsEnumerator.h",
+ "android/hardware/automotive/evs/1.0/BsEvsEnumerator.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.automotive.evs@1.0",
+ generated_sources: ["android.hardware.automotive.evs@1.0_genc++"],
+ generated_headers: ["android.hardware.automotive.evs@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.automotive.evs@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hidl.base@1.0",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hidl.base@1.0",
+ ],
+}
diff --git a/evs/1.0/IEvsCamera.hal b/automotive/evs/1.0/IEvsCamera.hal
similarity index 98%
rename from evs/1.0/IEvsCamera.hal
rename to automotive/evs/1.0/IEvsCamera.hal
index d0559d7..1b55d1f 100644
--- a/evs/1.0/IEvsCamera.hal
+++ b/automotive/evs/1.0/IEvsCamera.hal
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.hardware.evs@1.0;
+package android.hardware.automotive.evs@1.0;
import types;
import IEvsCameraStream;
diff --git a/evs/1.0/IEvsCameraStream.hal b/automotive/evs/1.0/IEvsCameraStream.hal
similarity index 96%
rename from evs/1.0/IEvsCameraStream.hal
rename to automotive/evs/1.0/IEvsCameraStream.hal
index fcd5717..4e743b2 100644
--- a/evs/1.0/IEvsCameraStream.hal
+++ b/automotive/evs/1.0/IEvsCameraStream.hal
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.hardware.evs@1.0;
+package android.hardware.automotive.evs@1.0;
/**
diff --git a/evs/1.0/IEvsDisplay.hal b/automotive/evs/1.0/IEvsDisplay.hal
similarity index 98%
rename from evs/1.0/IEvsDisplay.hal
rename to automotive/evs/1.0/IEvsDisplay.hal
index 8352221..bbad428 100644
--- a/evs/1.0/IEvsDisplay.hal
+++ b/automotive/evs/1.0/IEvsDisplay.hal
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.hardware.evs@1.0;
+package android.hardware.automotive.evs@1.0;
import types;
diff --git a/evs/1.0/IEvsEnumerator.hal b/automotive/evs/1.0/IEvsEnumerator.hal
similarity index 97%
rename from evs/1.0/IEvsEnumerator.hal
rename to automotive/evs/1.0/IEvsEnumerator.hal
index 3779866..334430b 100644
--- a/evs/1.0/IEvsEnumerator.hal
+++ b/automotive/evs/1.0/IEvsEnumerator.hal
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.hardware.evs@1.0;
+package android.hardware.automotive.evs@1.0;
import types;
import IEvsCamera;
diff --git a/evs/1.0/default/Android.bp b/automotive/evs/1.0/default/Android.bp
similarity index 66%
rename from evs/1.0/default/Android.bp
rename to automotive/evs/1.0/default/Android.bp
index c47f035..8b214e3 100644
--- a/evs/1.0/default/Android.bp
+++ b/automotive/evs/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_binary {
- name: "android.hardware.evs@1.0-service",
+ name: "android.hardware.automotive.evs@1.0-service",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: [
@@ -8,10 +9,10 @@
"EvsEnumerator.cpp",
"EvsDisplay.cpp"
],
- init_rc: ["android.hardware.evs@1.0-service.rc"],
+ init_rc: ["android.hardware.automotive.evs@1.0-service.rc"],
shared_libs: [
- "android.hardware.evs@1.0",
+ "android.hardware.automotive.evs@1.0",
"libui",
"libbase",
"libbinder",
diff --git a/evs/1.0/default/EvsCamera.cpp b/automotive/evs/1.0/default/EvsCamera.cpp
similarity index 97%
rename from evs/1.0/default/EvsCamera.cpp
rename to automotive/evs/1.0/default/EvsCamera.cpp
index df7e844..c4436ee 100644
--- a/evs/1.0/default/EvsCamera.cpp
+++ b/automotive/evs/1.0/default/EvsCamera.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.evs@1.0-service"
+#define LOG_TAG "android.hardware.automotive.evs@1.0-service"
#include "EvsCamera.h"
@@ -24,6 +24,7 @@
namespace android {
namespace hardware {
+namespace automotive {
namespace evs {
namespace V1_0 {
namespace implementation {
@@ -42,9 +43,9 @@
// As it stands, if the client dies suddenly, the buffer may be stranded.
EvsCamera::EvsCamera(const char *id) :
- mFramesAllowed(0),
- mFramesInUse(0),
- mStreamState(STOPPED) {
+ mFramesAllowed(0),
+ mFramesInUse(0),
+ mStreamState(STOPPED) {
ALOGD("EvsCamera instantiated");
@@ -96,7 +97,7 @@
}
-// Methods from ::android::hardware::evs::V1_0::IEvsCamera follow.
+// Methods from ::android::hardware::automotive::evs::V1_0::IEvsCamera follow.
Return<void> EvsCamera::getId(getId_cb id_cb) {
ALOGD("getId");
@@ -161,7 +162,7 @@
if (buffer.memHandle == nullptr) {
ALOGE("ignoring doneWithFrame called with null handle");
} else if (buffer.bufferId >= mBuffers.size()) {
- ALOGE("ignoring doneWithFrame called with invalid bufferId %d (max is %lu)",
+ ALOGE("ignoring doneWithFrame called with invalid bufferId %d (max is %zu)",
buffer.bufferId, mBuffers.size()-1);
} else if (!mBuffers[buffer.bufferId].inUse) {
ALOGE("ignoring doneWithFrame called on frame %d which is already free",
@@ -487,5 +488,6 @@
} // namespace implementation
} // namespace V1_0
} // namespace evs
+} // namespace automotive
} // namespace hardware
} // namespace android
diff --git a/automotive/evs/1.0/default/EvsCamera.h b/automotive/evs/1.0/default/EvsCamera.h
new file mode 100644
index 0000000..ee91ca4
--- /dev/null
+++ b/automotive/evs/1.0/default/EvsCamera.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERA_H
+#define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERA_H
+
+#include <android/hardware/automotive/evs/1.0/types.h>
+#include <android/hardware/automotive/evs/1.0/IEvsCamera.h>
+#include <ui/GraphicBuffer.h>
+
+#include <thread>
+
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace evs {
+namespace V1_0 {
+namespace implementation {
+
+
+class EvsCamera : public IEvsCamera {
+public:
+ // Methods from ::android::hardware::automotive::evs::V1_0::IEvsCamera follow.
+ Return<void> getId(getId_cb id_cb) override;
+
+ Return <EvsResult> setMaxFramesInFlight(uint32_t bufferCount) override;
+
+ Return <EvsResult> startVideoStream(const ::android::sp<IEvsCameraStream>& stream) override;
+
+ Return<void> doneWithFrame(const BufferDesc& buffer) override;
+
+ Return<void> stopVideoStream() override;
+
+ Return <int32_t> getExtendedInfo(uint32_t opaqueIdentifier) override;
+
+ Return <EvsResult> setExtendedInfo(uint32_t opaqueIdentifier, int32_t opaqueValue) override;
+
+ // Implementation details
+ EvsCamera(const char* id);
+
+ virtual ~EvsCamera() override;
+
+ const CameraDesc& getDesc() { return mDescription; };
+
+ static const char kCameraName_Backup[];
+ static const char kCameraName_RightTurn[];
+
+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 fillTestFrame(const BufferDesc& buff);
+
+ CameraDesc mDescription = {}; // The properties of this camera
+
+ std::thread mCaptureThread; // The thread we'll use to synthesize frames
+
+ uint32_t mWidth = 0; // Horizontal pixel count in the buffers
+ uint32_t mHeight = 0; // Vertical pixel count in the buffers
+ uint32_t mFormat = 0; // Values from android_pixel_format_t [TODO: YUV? Leave opaque?]
+ uint32_t mUsage = 0; // Values from from Gralloc.h
+ uint32_t mStride = 0; // Bytes per line in the buffers
+
+ sp <IEvsCameraStream> mStream = nullptr; // The callback used to deliver each frame
+
+ 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,
+ };
+ StreamStateValues mStreamState;
+
+ // Syncrhonization necessary to deconflict mCaptureThread from the main service thread
+ std::mutex mAccessLock;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace evs
+} // namespace automotive
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERA_H
diff --git a/evs/1.0/default/EvsDisplay.cpp b/automotive/evs/1.0/default/EvsDisplay.cpp
similarity index 98%
rename from evs/1.0/default/EvsDisplay.cpp
rename to automotive/evs/1.0/default/EvsDisplay.cpp
index bbfff35..a1a76d0 100644
--- a/evs/1.0/default/EvsDisplay.cpp
+++ b/automotive/evs/1.0/default/EvsDisplay.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.evs@1.0-service"
+#define LOG_TAG "android.hardware.automotive.evs@1.0-service"
#include "EvsDisplay.h"
@@ -24,6 +24,7 @@
namespace android {
namespace hardware {
+namespace automotive {
namespace evs {
namespace V1_0 {
namespace implementation {
@@ -242,7 +243,7 @@
// If we failed to lock the pixel buffer, we're about to crash, but log it first
if (!pixels) {
- ALOGE("Camera failed to gain access to image buffer for reading");
+ ALOGE("Display failed to gain access to image buffer for reading");
}
// Check the test pixels
@@ -302,5 +303,6 @@
} // namespace implementation
} // namespace V1_0
} // namespace evs
+} // namespace automotive
} // namespace hardware
} // namespace android
diff --git a/evs/1.0/default/EvsDisplay.h b/automotive/evs/1.0/default/EvsDisplay.h
similarity index 81%
rename from evs/1.0/default/EvsDisplay.h
rename to automotive/evs/1.0/default/EvsDisplay.h
index f4d7ee9..fcf4a06 100644
--- a/evs/1.0/default/EvsDisplay.h
+++ b/automotive/evs/1.0/default/EvsDisplay.h
@@ -14,21 +14,22 @@
* limitations under the License.
*/
-#ifndef ANDROID_HARDWARE_EVS_V1_0_EVSDISPLAY_H
-#define ANDROID_HARDWARE_EVS_V1_0_EVSDISPLAY_H
+#ifndef ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSDISPLAY_H
+#define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSDISPLAY_H
-#include <android/hardware/evs/1.0/IEvsDisplay.h>
+#include <android/hardware/automotive/evs/1.0/IEvsDisplay.h>
#include <ui/GraphicBuffer.h>
namespace android {
namespace hardware {
+namespace automotive {
namespace evs {
namespace V1_0 {
namespace implementation {
class EvsDisplay : public IEvsDisplay {
public:
- // Methods from ::android::hardware::evs::V1_0::IEvsDisplay follow.
+ // Methods from ::android::hardware::automotive::evs::V1_0::IEvsDisplay follow.
Return<void> getDisplayInfo(getDisplayInfo_cb _hidl_cb) override;
Return<EvsResult> setDisplayState(DisplayState state) override;
Return<DisplayState> getDisplayState() override;
@@ -52,7 +53,8 @@
} // namespace implementation
} // namespace V1_0
} // namespace evs
+} // namespace automotive
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_EVS_V1_0_EVSDISPLAY_H
+#endif // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSDISPLAY_H
diff --git a/evs/1.0/default/EvsEnumerator.cpp b/automotive/evs/1.0/default/EvsEnumerator.cpp
similarity index 96%
rename from evs/1.0/default/EvsEnumerator.cpp
rename to automotive/evs/1.0/default/EvsEnumerator.cpp
index 4bf77f3..e54f699 100644
--- a/evs/1.0/default/EvsEnumerator.cpp
+++ b/automotive/evs/1.0/default/EvsEnumerator.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.evs@1.0-service"
+#define LOG_TAG "android.hardware.automotive.evs@1.0-service"
#include "EvsEnumerator.h"
#include "EvsCamera.h"
@@ -22,6 +22,7 @@
namespace android {
namespace hardware {
+namespace automotive {
namespace evs {
namespace V1_0 {
namespace implementation {
@@ -42,7 +43,7 @@
mCameraList.emplace_back( new EvsCamera(EvsCamera::kCameraName_RightTurn), false );
}
-// Methods from ::android::hardware::evs::V1_0::IEvsEnumerator follow.
+// Methods from ::android::hardware::automotive::evs::V1_0::IEvsEnumerator follow.
Return<void> EvsEnumerator::getCameraList(getCameraList_cb _hidl_cb) {
ALOGD("getCameraList");
@@ -168,5 +169,6 @@
} // namespace implementation
} // namespace V1_0
} // namespace evs
+} // namespace automotive
} // namespace hardware
} // namespace android
diff --git a/evs/1.0/default/EvsEnumerator.h b/automotive/evs/1.0/default/EvsEnumerator.h
similarity index 78%
rename from evs/1.0/default/EvsEnumerator.h
rename to automotive/evs/1.0/default/EvsEnumerator.h
index 0e719bd..3d6e264 100644
--- a/evs/1.0/default/EvsEnumerator.h
+++ b/automotive/evs/1.0/default/EvsEnumerator.h
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-#ifndef ANDROID_HARDWARE_EVS_V1_0_EVSCAMERAENUMERATOR_H
-#define ANDROID_HARDWARE_EVS_V1_0_EVSCAMERAENUMERATOR_H
+#ifndef ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERAENUMERATOR_H
+#define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERAENUMERATOR_H
-#include <android/hardware/evs/1.0/IEvsEnumerator.h>
-#include <android/hardware/evs/1.0/IEvsCamera.h>
+#include <android/hardware/automotive/evs/1.0/IEvsEnumerator.h>
+#include <android/hardware/automotive/evs/1.0/IEvsCamera.h>
#include <list>
@@ -26,13 +26,14 @@
namespace android {
namespace hardware {
+namespace automotive {
namespace evs {
namespace V1_0 {
namespace implementation {
class EvsEnumerator : public IEvsEnumerator {
public:
- // Methods from ::android::hardware::evs::V1_0::IEvsEnumerator follow.
+ // Methods from ::android::hardware::automotive::evs::V1_0::IEvsEnumerator follow.
Return<void> getCameraList(getCameraList_cb _hidl_cb) override;
Return<sp<IEvsCamera>> openCamera(const hidl_string& cameraId) override;
Return<void> closeCamera(const ::android::sp<IEvsCamera>& carCamera) override;
@@ -57,7 +58,8 @@
} // namespace implementation
} // namespace V1_0
} // namespace evs
+} // namespace automotive
} // namespace hardware
} // namespace android
-#endif // ANDROID_HARDWARE_EVS_V1_0_EVSCAMERAENUMERATOR_H
+#endif // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSCAMERAENUMERATOR_H
diff --git a/evs/1.0/default/ServiceNames.h b/automotive/evs/1.0/default/ServiceNames.h
similarity index 100%
rename from evs/1.0/default/ServiceNames.h
rename to automotive/evs/1.0/default/ServiceNames.h
diff --git a/automotive/evs/1.0/default/android.hardware.automotive.evs@1.0-service.rc b/automotive/evs/1.0/default/android.hardware.automotive.evs@1.0-service.rc
new file mode 100644
index 0000000..8957ecf
--- /dev/null
+++ b/automotive/evs/1.0/default/android.hardware.automotive.evs@1.0-service.rc
@@ -0,0 +1,4 @@
+service evs-hal-1-0 /vendor/bin/hw/android.hardware.automotive.evs@1.0-service
+ class hal
+ user cameraserver
+ group camera
diff --git a/evs/1.0/default/service.cpp b/automotive/evs/1.0/default/service.cpp
similarity index 87%
rename from evs/1.0/default/service.cpp
rename to automotive/evs/1.0/default/service.cpp
index 112c879..1b64e44 100644
--- a/evs/1.0/default/service.cpp
+++ b/automotive/evs/1.0/default/service.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.evs@1.0-service"
+#define LOG_TAG "android.hardware.automotive.evs@1.0-service"
#include <unistd.h>
@@ -33,11 +33,11 @@
using android::hardware::joinRpcThreadpool;
// Generated HIDL files
-using android::hardware::evs::V1_0::IEvsEnumerator;
-using android::hardware::evs::V1_0::IEvsDisplay;
+using android::hardware::automotive::evs::V1_0::IEvsEnumerator;
+using android::hardware::automotive::evs::V1_0::IEvsDisplay;
// The namespace in which all our implementation code lives
-using namespace android::hardware::evs::V1_0::implementation;
+using namespace android::hardware::automotive::evs::V1_0::implementation;
using namespace android;
diff --git a/evs/1.0/types.hal b/automotive/evs/1.0/types.hal
similarity index 98%
rename from evs/1.0/types.hal
rename to automotive/evs/1.0/types.hal
index 6b580cf..661c2a9 100644
--- a/evs/1.0/types.hal
+++ b/automotive/evs/1.0/types.hal
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.hardware.evs@1.0;
+package android.hardware.automotive.evs@1.0;
/*
diff --git a/automotive/vehicle/2.0/default/Android.mk b/automotive/vehicle/2.0/default/Android.mk
index ba4a6cd..4a010e9 100644
--- a/automotive/vehicle/2.0/default/Android.mk
+++ b/automotive/vehicle/2.0/default/Android.mk
@@ -118,6 +118,7 @@
LOCAL_SRC_FILES:= \
tests/AccessControlConfigParser_test.cpp \
+ tests/RecurrentTimer_test.cpp \
tests/SubscriptionManager_test.cpp \
tests/VehicleHalManager_test.cpp \
tests/VehicleObjectPool_test.cpp \
@@ -132,7 +133,7 @@
libutils \
$(vhal_v2_0) \
-LOCAL_CFLAGS += -Wall -Wextra
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_MODULE_TAGS := tests
include $(BUILD_NATIVE_TEST)
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/RecurrentTimer.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/RecurrentTimer.h
new file mode 100644
index 0000000..be25adc
--- /dev/null
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/RecurrentTimer.h
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef android_hardware_automotive_vehicle_V2_0_RecurrentTimer_H_
+#define android_hardware_automotive_vehicle_V2_0_RecurrentTimer_H_
+
+#include <atomic>
+#include <chrono>
+#include <condition_variable>
+#include <functional>
+#include <list>
+#include <mutex>
+#include <set>
+#include <thread>
+#include <unordered_map>
+
+/**
+ * This class allows to specify multiple time intervals to receive
+ * notifications. A single thread is used internally.
+ */
+class RecurrentTimer {
+private:
+ using Nanos = std::chrono::nanoseconds;
+ using Clock = std::chrono::steady_clock;
+ using TimePoint = std::chrono::time_point<Clock, Nanos>;
+public:
+ using Action = std::function<void(const std::vector<int32_t>& cookies)>;
+
+ RecurrentTimer(const Action& action) : mAction(action) {
+ mTimerThread = std::thread(&RecurrentTimer::loop, this, action);
+ }
+
+ virtual ~RecurrentTimer() {
+ stop();
+ }
+
+ /**
+ * Registers recurrent event for a given interval. Registred events are distinguished by
+ * cookies thus calling this method multiple times with the same cookie will override the
+ * interval provided before.
+ */
+ void registerRecurrentEvent(std::chrono::nanoseconds interval, int32_t cookie) {
+ TimePoint now = Clock::now();
+ // Align event time point among all intervals. Thus if we have two intervals 1ms and 2ms,
+ // during every second wake-up both intervals will be triggered.
+ TimePoint absoluteTime = now - Nanos(now.time_since_epoch().count() % interval.count());
+
+ {
+ std::lock_guard<std::mutex> g(mLock);
+ mCookieToEventsMap[cookie] = { interval, cookie, absoluteTime };
+ }
+ mCond.notify_one();
+ }
+
+ void unregisterRecurrentEvent(int32_t cookie) {
+ {
+ std::lock_guard<std::mutex> g(mLock);
+ mCookieToEventsMap.erase(cookie);
+ }
+ mCond.notify_one();
+ }
+
+
+private:
+
+ struct RecurrentEvent {
+ Nanos interval;
+ int32_t cookie;
+ TimePoint absoluteTime; // Absolute time of the next event.
+
+ void updateNextEventTime(TimePoint now) {
+ // We want to move time to next event by adding some number of intervals (usually 1)
+ // to previous absoluteTime.
+ int intervalMultiplier = (now - absoluteTime) / interval;
+ if (intervalMultiplier <= 0) intervalMultiplier = 1;
+ absoluteTime += intervalMultiplier * interval;
+ }
+ };
+
+ void loop(const Action& action) {
+ static constexpr auto kInvalidTime = TimePoint(Nanos::max());
+
+ std::vector<int32_t> cookies;
+
+ while (!mStopRequested) {
+ auto now = Clock::now();
+ auto nextEventTime = kInvalidTime;
+ cookies.clear();
+
+ {
+ std::unique_lock<std::mutex> g(mLock);
+
+ for (auto&& it : mCookieToEventsMap) {
+ RecurrentEvent& event = it.second;
+ if (event.absoluteTime <= now) {
+ event.updateNextEventTime(now);
+ cookies.push_back(event.cookie);
+ }
+
+ if (nextEventTime > event.absoluteTime) {
+ nextEventTime = event.absoluteTime;
+ }
+ }
+ }
+
+ if (cookies.size() != 0) {
+ action(cookies);
+ }
+
+ std::unique_lock<std::mutex> g(mLock);
+ mCond.wait_until(g, nextEventTime); // nextEventTime can be nanoseconds::max()
+ }
+ }
+
+ void stop() {
+ mStopRequested = true;
+ {
+ std::lock_guard<std::mutex> g(mLock);
+ mCookieToEventsMap.clear();
+ }
+ mCond.notify_one();
+ if (mTimerThread.joinable()) {
+ mTimerThread.join();
+ }
+ }
+private:
+ mutable std::mutex mLock;
+ std::thread mTimerThread;
+ std::condition_variable mCond;
+ std::atomic_bool mStopRequested { false };
+ Action mAction;
+ std::unordered_map<int32_t, RecurrentEvent> mCookieToEventsMap;
+};
+
+
+#endif // android_hardware_automotive_vehicle_V2_0_RecurrentTimer_H
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h
index 6a12b77..a808c66 100644
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h
@@ -23,6 +23,7 @@
#include <list>
#include <android/log.h>
+#include <hidl/HidlSupport.h>
#include <hwbinder/IPCThreadState.h>
#include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
@@ -50,10 +51,8 @@
}
void addOrUpdateSubscription(const SubscribeOptions &opts);
-
- bool isSubscribed(int32_t propId,
- int32_t areaId,
- SubscribeFlags flags);
+ bool isSubscribed(int32_t propId, int32_t areaId, SubscribeFlags flags);
+ std::vector<int32_t> getSubscribedProperties() const;
private:
const sp<IVehicleCallback> mCallback;
@@ -85,15 +84,29 @@
class SubscriptionManager {
public:
- virtual ~SubscriptionManager() {}
+ using OnPropertyUnsubscribed = std::function<void(int32_t)>;
+
+ /**
+ * Constructs SubscriptionManager
+ *
+ * @param onPropertyUnsubscribed - this callback function will be called when there are no
+ * more client subscribed to particular property.
+ */
+ SubscriptionManager(const OnPropertyUnsubscribed& onPropertyUnsubscribed)
+ : mOnPropertyUnsubscribed(onPropertyUnsubscribed),
+ mCallbackDeathRecipient(new DeathRecipient(
+ std::bind(&SubscriptionManager::onCallbackDead, this, std::placeholders::_1)))
+ {}
+
+ ~SubscriptionManager() = default;
/**
* Updates subscription. Returns the vector of properties subscription that
* needs to be updated in VehicleHAL.
*/
- std::list<SubscribeOptions> addOrUpdateSubscription(
- const sp<IVehicleCallback>& callback,
- const hidl_vec<SubscribeOptions>& optionList);
+ StatusCode addOrUpdateSubscription(const sp<IVehicleCallback>& callback,
+ const hidl_vec<SubscribeOptions>& optionList,
+ std::list<SubscribeOptions>* outUpdatedOptions);
/**
* Returns a list of IVehicleCallback -> list of VehiclePropValue ready for
@@ -103,30 +116,48 @@
const std::vector<recyclable_ptr<VehiclePropValue>>& propValues,
SubscribeFlags flags) const;
- std::list<sp<HalClient>> getSubscribedClients(
- int32_t propId, int32_t area, SubscribeFlags flags) const;
-
+ std::list<sp<HalClient>> getSubscribedClients(int32_t propId,
+ int32_t area,
+ SubscribeFlags flags) const;
/**
- * Returns true the client was unsubscribed successfully and there are
- * no more clients subscribed to given propId.
+ * If there are no clients subscribed to given properties than callback function provided
+ * in the constructor will be called.
*/
- bool unsubscribe(const sp<IVehicleCallback>& callback,
- int32_t propId);
+ void unsubscribe(const sp<IVehicleCallback>& callback, int32_t propId);
private:
- std::list<sp< HalClient>> getSubscribedClientsLocked(
- int32_t propId, int32_t area, SubscribeFlags flags) const;
+ std::list<sp<HalClient>> getSubscribedClientsLocked(int32_t propId,
+ int32_t area,
+ SubscribeFlags flags) const;
- bool updateHalEventSubscriptionLocked(const SubscribeOptions &opts,
- SubscribeOptions *out);
+ bool updateHalEventSubscriptionLocked(const SubscribeOptions &opts, SubscribeOptions* out);
- void addClientToPropMapLocked(int32_t propId,
- const sp<HalClient> &client);
+ void addClientToPropMapLocked(int32_t propId, const sp<HalClient>& client);
- sp<HalClientVector> getClientsForPropertyLocked(
- int32_t propId) const;
+ sp<HalClientVector> getClientsForPropertyLocked(int32_t propId) const;
- sp<HalClient> getOrCreateHalClientLocked(
- const sp<IVehicleCallback> &callback);
+ sp<HalClient> getOrCreateHalClientLocked(const sp<IVehicleCallback> &callback);
+
+ void onCallbackDead(uint64_t cookie);
+
+private:
+ using OnClientDead = std::function<void(uint64_t)>;
+
+ class DeathRecipient : public hidl_death_recipient {
+ public:
+ DeathRecipient(const OnClientDead& onClientDead)
+ : mOnClientDead(onClientDead) {}
+ ~DeathRecipient() = default;
+
+ DeathRecipient(const DeathRecipient& ) = delete;
+ DeathRecipient& operator=(const DeathRecipient&) = delete;
+
+ void serviceDied(uint64_t cookie,
+ const wp<::android::hidl::base::V1_0::IBase>& /* who */) override {
+ mOnClientDead(cookie);
+ }
+ private:
+ OnClientDead mOnClientDead;
+ };
private:
using MuxGuard = std::lock_guard<std::mutex>;
@@ -136,6 +167,9 @@
std::map<sp<IVehicleCallback>, sp<HalClient>> mClients;
std::map<int32_t, sp<HalClientVector>> mPropToClients;
std::map<int32_t, SubscribeOptions> mHalEventSubscribeOptions;
+
+ OnPropertyUnsubscribed mOnPropertyUnsubscribed;
+ sp<DeathRecipient> mCallbackDeathRecipient;
};
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h
index 4bff4d1..b8ab309 100644
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHalManager.h
@@ -56,7 +56,9 @@
class VehicleHalManager : public IVehicle {
public:
VehicleHalManager(VehicleHal* vehicleHal)
- : mHal(vehicleHal) {
+ : mHal(vehicleHal),
+ mSubscriptionManager(std::bind(&VehicleHalManager::onAllClientsUnsubscribed,
+ this, std::placeholders::_1)) {
init();
}
@@ -105,6 +107,8 @@
int32_t propertyId,
VehiclePropertyAccess requiredAccess) const;
+ void onAllClientsUnsubscribed(int32_t propertyId);
+
static bool isSubscribable(const VehiclePropConfig& config,
SubscribeFlags flags);
static bool isSampleRateFixed(VehiclePropertyChangeMode mode);
diff --git a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
index f6f2758..4493a41 100644
--- a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
+++ b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp
@@ -19,6 +19,7 @@
#include "SubscriptionManager.h"
#include <cmath>
+#include <inttypes.h>
#include <android/log.h>
@@ -58,6 +59,8 @@
}
void HalClient::addOrUpdateSubscription(const SubscribeOptions &opts) {
+ ALOGI("%s opts.propId: 0x%x", __func__, opts.propId);
+
auto it = mSubscriptions.find(opts.propId);
if (it == mSubscriptions.end()) {
mSubscriptions.emplace(opts.propId, opts);
@@ -84,17 +87,33 @@
return res;
}
-std::list<SubscribeOptions> SubscriptionManager::addOrUpdateSubscription(
+std::vector<int32_t> HalClient::getSubscribedProperties() const {
+ std::vector<int32_t> props;
+ for (const auto& subscription : mSubscriptions) {
+ ALOGI("%s propId: 0x%x, propId: 0x%x", __func__, subscription.first, subscription.second.propId);
+ props.push_back(subscription.first);
+ }
+ return props;
+}
+
+StatusCode SubscriptionManager::addOrUpdateSubscription(
const sp<IVehicleCallback> &callback,
- const hidl_vec<SubscribeOptions> &optionList) {
- std::list<SubscribeOptions> updatedSubscriptions;
+ const hidl_vec<SubscribeOptions> &optionList,
+ std::list<SubscribeOptions>* outUpdatedSubscriptions) {
+ outUpdatedSubscriptions->clear();
MuxGuard g(mLock);
+ ALOGI("SubscriptionManager::addOrUpdateSubscription, callback: %p", callback.get());
+
const sp<HalClient>& client = getOrCreateHalClientLocked(callback);
+ if (client.get() == nullptr) {
+ return StatusCode::INTERNAL_ERROR;
+ }
for (size_t i = 0; i < optionList.size(); i++) {
const SubscribeOptions& opts = optionList[i];
+ ALOGI("SubscriptionManager::addOrUpdateSubscription, prop: 0x%x", opts.propId);
client->addOrUpdateSubscription(opts);
addClientToPropMapLocked(opts.propId, client);
@@ -102,12 +121,12 @@
if (SubscribeFlags::HAL_EVENT & opts.flags) {
SubscribeOptions updated;
if (updateHalEventSubscriptionLocked(opts, &updated)) {
- updatedSubscriptions.push_back(updated);
+ outUpdatedSubscriptions->push_back(updated);
}
}
}
- return updatedSubscriptions;
+ return StatusCode::OK;
}
std::list<HalClientValues> SubscriptionManager::distributeValuesToClients(
@@ -205,6 +224,14 @@
const sp<IVehicleCallback>& callback) {
auto it = mClients.find(callback);
if (it == mClients.end()) {
+ uint64_t cookie = reinterpret_cast<uint64_t>(callback.get());
+ ALOGI("Creating new client and linking to death recipient, cookie: 0x%" PRIx64, cookie);
+ auto res = callback->linkToDeath(mCallbackDeathRecipient, cookie);
+ if (!res.isOk()) { // Client is already dead?
+ ALOGW("%s failed to link to death, client %p, err: %s",
+ __func__, callback.get(), res.description().c_str());
+ return nullptr;
+ }
IPCThreadState* self = IPCThreadState::self();
pid_t pid = self->getCallingPid();
uid_t uid = self->getCallingUid();
@@ -216,7 +243,7 @@
}
}
-bool SubscriptionManager::unsubscribe(const sp<IVehicleCallback>& callback,
+void SubscriptionManager::unsubscribe(const sp<IVehicleCallback>& callback,
int32_t propId) {
MuxGuard g(mLock);
auto propertyClients = getClientsForPropertyLocked(propId);
@@ -243,13 +270,39 @@
}
if (!isClientSubscribedToOtherProps) {
+ auto res = client->getCallback()->unlinkToDeath(mCallbackDeathRecipient);
+ if (!res.isOk()) {
+ ALOGW("%s failed to unlink to death, client: %p, err: %s",
+ __func__, client->getCallback().get(), res.description().c_str());
+ }
mClients.erase(clientIter);
}
}
- return (propertyClients == nullptr || propertyClients->isEmpty())
- ? mHalEventSubscribeOptions.erase(propId) == 1
- : false;
+ if (propertyClients == nullptr || propertyClients->isEmpty()) {
+ mHalEventSubscribeOptions.erase(propId);
+ mOnPropertyUnsubscribed(propId);
+ }
+}
+
+void SubscriptionManager::onCallbackDead(uint64_t cookie) {
+ ALOGI("%s, cookie: 0x%" PRIx64, __func__, cookie);
+ IVehicleCallback* callback = reinterpret_cast<IVehicleCallback*>(cookie);
+
+ std::vector<int32_t> props;
+ {
+ MuxGuard g(mLock);
+ const auto& it = mClients.find(callback);
+ if (it == mClients.end()) {
+ return; // Nothing to do here, client wasn't subscribed to any properties.
+ }
+ const auto& halClient = it->second;
+ props = halClient->getSubscribedProperties();
+ }
+
+ for (int32_t propId : props) {
+ unsubscribe(callback, propId);
+ }
}
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
index 3a5e504..8906f6e 100644
--- a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp
@@ -43,8 +43,7 @@
*/
constexpr auto kMaxHidlVecOfVehiclPropValuePoolSize = 20;
-Return<void> VehicleHalManager::getAllPropConfigs(
- getAllPropConfigs_cb _hidl_cb) {
+Return<void> VehicleHalManager::getAllPropConfigs(getAllPropConfigs_cb _hidl_cb) {
ALOGI("getAllPropConfigs called");
hidl_vec<VehiclePropConfig> hidlConfigs;
auto& halConfig = mConfigIndex->getAllConfigs();
@@ -58,9 +57,8 @@
return Void();
}
-Return<void> VehicleHalManager::getPropConfigs(
- const hidl_vec<int32_t> &properties,
- getPropConfigs_cb _hidl_cb) {
+Return<void> VehicleHalManager::getPropConfigs(const hidl_vec<int32_t> &properties,
+ getPropConfigs_cb _hidl_cb) {
std::vector<VehiclePropConfig> configs;
for (size_t i = 0; i < properties.size(); i++) {
auto prop = properties[i];
@@ -77,8 +75,7 @@
return Void();
}
-Return<void> VehicleHalManager::get(
- const VehiclePropValue& requestedPropValue, get_cb _hidl_cb) {
+Return<void> VehicleHalManager::get(const VehiclePropValue& requestedPropValue, get_cb _hidl_cb) {
const auto* config = getPropConfigOrNull(requestedPropValue.prop);
if (config == nullptr) {
ALOGE("Failed to get value: config not found, property: 0x%x",
@@ -119,9 +116,8 @@
return Return<StatusCode>(status);
}
-Return<StatusCode> VehicleHalManager::subscribe(
- const sp<IVehicleCallback> &callback,
- const hidl_vec<SubscribeOptions> &options) {
+Return<StatusCode> VehicleHalManager::subscribe(const sp<IVehicleCallback> &callback,
+ const hidl_vec<SubscribeOptions> &options) {
hidl_vec<SubscribeOptions> verifiedOptions(options);
auto caller = getCaller();
for (size_t i = 0; i < verifiedOptions.size(); i++) {
@@ -135,6 +131,11 @@
return StatusCode::INVALID_ARG;
}
+ if (ops.flags == SubscribeFlags::UNDEFINED) {
+ ALOGE("Failed to subscribe: undefined flag in options provided");
+ return StatusCode::INVALID_ARG;
+ }
+
if (!checkAcl(caller.uid, config->prop, VehiclePropertyAccess::READ)) {
return StatusCode::ACCESS_DENIED;
}
@@ -157,22 +158,24 @@
ops.sampleRate = checkSampleRate(*config, ops.sampleRate);
}
- std::list<SubscribeOptions> updatedOptions =
- mSubscriptionManager.addOrUpdateSubscription(callback, verifiedOptions);
+ std::list<SubscribeOptions> updatedOptions;
+ auto res = mSubscriptionManager.addOrUpdateSubscription(callback, verifiedOptions,
+ &updatedOptions);
+ if (StatusCode::OK != res) {
+ ALOGW("%s failed to subscribe, error code: %d", __func__, res);
+ return res;
+ }
for (auto opt : updatedOptions) {
mHal->subscribe(opt.propId, opt.vehicleAreas, opt.sampleRate);
}
- // TODO(pavelm): link to death callback (not implemented yet in HIDL)
return StatusCode::OK;
}
-Return<StatusCode> VehicleHalManager::unsubscribe(
- const sp<IVehicleCallback>& callback, int32_t propId) {
- if (mSubscriptionManager.unsubscribe(callback, propId)) {
- mHal->unsubscribe(propId);
- }
+Return<StatusCode> VehicleHalManager::unsubscribe(const sp<IVehicleCallback>& callback,
+ int32_t propId) {
+ mSubscriptionManager.unsubscribe(callback, propId);
return StatusCode::OK;
}
@@ -239,8 +242,7 @@
}
}
-void VehicleHalManager::onBatchHalEvent(
- const std::vector<VehiclePropValuePtr>& values) {
+void VehicleHalManager::onBatchHalEvent(const std::vector<VehiclePropValuePtr>& values) {
const auto& clientValues = mSubscriptionManager.distributeValuesToClients(
values, SubscribeFlags::HAL_EVENT);
@@ -257,7 +259,12 @@
for (VehiclePropValue* pValue : cv.values) {
shallowCopy(&(vec)[i++], *pValue);
}
- cv.client->getCallback()->onPropertyEvent(vec);
+ auto status = cv.client->getCallback()->onPropertyEvent(vec);
+ if (!status.isOk()) {
+ ALOGE("Failed to notify client %s, err: %s",
+ toString(cv.client->getCallback()).c_str(),
+ status.description().c_str());
+ }
}
}
@@ -379,6 +386,10 @@
}
}
+void VehicleHalManager::onAllClientsUnsubscribed(int32_t propertyId) {
+ mHal->unsubscribe(propertyId);
+}
+
} // namespace V2_0
} // namespace vehicle
} // namespace automotive
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
index f1a1ff4..95ca37b 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
@@ -176,13 +176,7 @@
{
.prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY),
.access = VehiclePropertyAccess::READ,
- .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
- .areaConfigs = {
- VehicleAreaConfig {
- .minFloatValue = 0,
- .maxFloatValue = 1.0
- }
- }
+ .changeMode = VehiclePropertyChangeMode::STATIC,
},
{
@@ -201,6 +195,14 @@
.prop = toInt(VehicleProperty::IGNITION_STATE),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
+ },
+
+ {
+ .prop = toInt(VehicleProperty::ENGINE_OIL_TEMP),
+ .access = VehiclePropertyAccess::READ,
+ .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
+ .minSampleRate = 0.1, // 0.1 Hz, every 10 seconds
+ .maxSampleRate = 10, // 10 Hz, every 100 ms
}
};
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
index e3c83d7..808aafb 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
@@ -118,6 +118,7 @@
val.prop = protoVal.prop();
val.areaId = protoVal.area_id();
+ val.timestamp = elapsedRealtimeNano();
// Copy value data if it is set. This automatically handles complex data types if needed.
if (protoVal.has_string_value()) {
@@ -176,7 +177,7 @@
if (prop != mProps.end()) {
return prop->second.get();
}
- ALOGW("%s: Property not found: propId = 0x%x, areaId = 0x%x", __FUNCTION__, propId, areaId);
+ ALOGW("%s: Property not found: propId = 0x%x, areaId = 0x%x", __func__, propId, areaId);
return nullptr;
}
@@ -202,7 +203,7 @@
doSetProperty(rxMsg, respMsg);
break;
default:
- ALOGW("%s: Unknown message received, type = %d", __FUNCTION__, rxMsg.msg_type());
+ ALOGW("%s: Unknown message received, type = %d", __func__, rxMsg.msg_type());
respMsg.set_status(emulator::ERROR_UNIMPLEMENTED_CMD);
break;
}
@@ -210,7 +211,7 @@
// Send the reply
txMsg(respMsg);
} else {
- ALOGE("%s: ParseFromString() failed. msgSize=%d", __FUNCTION__, static_cast<int>(msg.size()));
+ ALOGE("%s: ParseFromString() failed. msgSize=%d", __func__, static_cast<int>(msg.size()));
}
}
@@ -266,7 +267,7 @@
}
break;
default:
- ALOGW("%s: Unknown property type: 0x%x", __FUNCTION__, toInt(getPropType(cfg.prop)));
+ ALOGW("%s: Unknown property type: 0x%x", __func__, toInt(getPropType(cfg.prop)));
break;
}
@@ -317,7 +318,7 @@
parseRxProtoBuf(msg);
} else {
// This happens when connection is closed
- ALOGD("%s: numBytes=%d, msgSize=%d", __FUNCTION__, numBytes,
+ ALOGD("%s: numBytes=%d, msgSize=%d", __func__, numBytes,
static_cast<int32_t>(msg.size()));
break;
}
@@ -409,7 +410,10 @@
prop->value.int32Values[0] = toInt(VehicleGear::GEAR_PARK);
break;
case toInt(VehicleProperty::INFO_FUEL_CAPACITY):
- prop->value.floatValues[0] = 0.75f;
+ prop->value.floatValues[0] = 123000.0f; // In milliliters
+ break;
+ case toInt(VehicleProperty::ENGINE_OIL_TEMP):
+ prop->value.floatValues[0] = 101;
break;
case toInt(VehicleProperty::DISPLAY_BRIGHTNESS):
prop->value.int32Values[0] = 7;
@@ -418,7 +422,7 @@
prop->value.int32Values[0] = toInt(VehicleIgnitionState::ON);
break;
default:
- ALOGW("%s: propId=0x%x not found", __FUNCTION__, prop->prop);
+ ALOGW("%s: propId=0x%x not found", __func__, prop->prop);
break;
}
}
@@ -437,10 +441,10 @@
}
if (retVal < 0) {
- ALOGE("%s: Failed to tx message: retval=%d, errno=%d", __FUNCTION__, retVal, errno);
+ ALOGE("%s: Failed to tx message: retval=%d, errno=%d", __func__, retVal, errno);
}
} else {
- ALOGE("%s: SerializeToString failed!", __FUNCTION__);
+ ALOGE("%s: SerializeToString failed!", __func__);
}
}
@@ -456,7 +460,7 @@
VehiclePropValue* internalPropValue = getVehiclePropValueLocked(propId, areaId);
if (internalPropValue != nullptr) {
internalPropValue->value = propValue.value;
- internalPropValue->timestamp = elapsedRealtimeNano();
+ internalPropValue->timestamp = propValue.timestamp;
status = StatusCode::OK;
}
}
@@ -569,10 +573,8 @@
break;
}
continue;
- break;
- case VehiclePropertyType::MASK:
default:
- ALOGW("%s: propType=0x%x not found", __FUNCTION__, propType);
+ ALOGE("%s: propType=0x%x not found", __func__, propType);
vecSize = 0;
break;
}
@@ -605,6 +607,69 @@
mThread = std::thread(&DefaultVehicleHal::rxThread, this);
}
+void DefaultVehicleHal::onContinuousPropertyTimer(const std::vector<int32_t>& properties) {
+ VehiclePropValuePtr v;
+
+ auto& pool = *getValuePool();
+
+ for (int32_t property : properties) {
+ if (isContinuousProperty(property)) {
+ // In real implementation this value should be read from sensor, random
+ // value used for testing purpose only.
+ std::lock_guard<std::mutex> lock(mPropsMutex);
+
+ VehiclePropValue *internalPropValue = getVehiclePropValueLocked(property);
+ if (internalPropValue != nullptr) {
+ v = pool.obtain(*internalPropValue);
+ }
+ if (VehiclePropertyType::FLOAT == getPropType(property)) {
+ // Just get some randomness to continuous properties to see slightly differnt values
+ // on the other end.
+ v->value.floatValues[0] = v->value.floatValues[0] + std::rand() % 5;
+ }
+ } else {
+ ALOGE("Unexpected onContinuousPropertyTimer for property: 0x%x", property);
+ }
+
+ if (v.get()) {
+ v->timestamp = elapsedRealtimeNano();
+ doHalEvent(std::move(v));
+ }
+ }
+}
+
+StatusCode DefaultVehicleHal::subscribe(int32_t property, int32_t,
+ float sampleRate) {
+ ALOGI("subscribe called for property: 0x%x, sampleRate: %f", property, sampleRate);
+
+ if (isContinuousProperty(property)) {
+ mRecurrentTimer.registerRecurrentEvent(hertzToNanoseconds(sampleRate), property);
+ }
+ return StatusCode::OK;
+}
+
+StatusCode DefaultVehicleHal::unsubscribe(int32_t property) {
+ ALOGI("%s propId: 0x%x", __func__, property);
+ if (isContinuousProperty(property)) {
+ mRecurrentTimer.unregisterRecurrentEvent(property);
+ }
+ return StatusCode::OK;
+}
+
+const VehiclePropConfig* DefaultVehicleHal::getPropConfig(int32_t propId) const {
+ auto it = mPropConfigMap.find(propId);
+ return it == mPropConfigMap.end() ? nullptr : it->second;
+}
+
+bool DefaultVehicleHal::isContinuousProperty(int32_t propId) const {
+ const VehiclePropConfig* config = getPropConfig(propId);
+ if (config == nullptr) {
+ ALOGW("Config not found for property: 0x%x", propId);
+ return false;
+ }
+ return config->changeMode == VehiclePropertyChangeMode::CONTINUOUS;
+}
+
} // impl
} // namespace V2_0
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
index 1ad8702..98eef27 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.h
@@ -28,6 +28,7 @@
#include "CommBase.h"
#include "VehicleHalProto.pb.h"
+#include <vhal_v2_0/RecurrentTimer.h>
#include <vhal_v2_0/VehicleHal.h>
#include "DefaultConfig.h"
@@ -43,7 +44,13 @@
class DefaultVehicleHal : public VehicleHal {
public:
- DefaultVehicleHal() : mThread() {}
+ DefaultVehicleHal() : mRecurrentTimer(
+ std::bind(&DefaultVehicleHal::onContinuousPropertyTimer, this, std::placeholders::_1)) {
+ for (size_t i = 0; i < arraysize(kVehicleProperties); i++) {
+ mPropConfigMap[kVehicleProperties->prop] = &kVehicleProperties[i];
+ }
+ }
+
~DefaultVehicleHal() override {
// Notify thread to finish and wait for it to terminate
mExit = 1;
@@ -66,16 +73,9 @@
StatusCode set(const VehiclePropValue& propValue) override;
- StatusCode subscribe(int32_t property, int32_t areas, float sampleRate) {
- ALOGD("%s: not implemented: prop=0x%x, areas=0x%x, rate=%f", __FUNCTION__, property,
- areas, sampleRate);
- return StatusCode::OK;
- }
+ StatusCode subscribe(int32_t property, int32_t areas, float sampleRate) override;
- StatusCode unsubscribe(int32_t property) {
- ALOGD("%s: not implemented: prop=0x%x", __FUNCTION__, property);
- return StatusCode::OK;
- }
+ StatusCode unsubscribe(int32_t property) override;
private:
void doGetConfig(emulator::EmulatorMessage& rxMsg, emulator::EmulatorMessage& respMsg);
@@ -83,7 +83,9 @@
void doGetProperty(emulator::EmulatorMessage& rxMsg, emulator::EmulatorMessage& respMsg);
void doGetPropertyAll(emulator::EmulatorMessage& rxMsg, emulator::EmulatorMessage& respMsg);
void doSetProperty(emulator::EmulatorMessage& rxMsg, emulator::EmulatorMessage& respMsg);
- VehiclePropValue* getVehiclePropValueLocked(int32_t propId, int32_t areaId);
+ VehiclePropValue* getVehiclePropValueLocked(int32_t propId, int32_t areaId = 0);
+ const VehiclePropConfig* getPropConfig(int32_t propId) const;
+ bool isContinuousProperty(int32_t propId) const;
void parseRxProtoBuf(std::vector<uint8_t>& msg);
void populateProtoVehicleConfig(emulator::VehiclePropConfig* protoCfg,
const VehiclePropConfig& cfg);
@@ -94,6 +96,13 @@
void rxThread();
void txMsg(emulator::EmulatorMessage& txMsg);
StatusCode updateProperty(const VehiclePropValue& propValue);
+
+ constexpr std::chrono::nanoseconds hertzToNanoseconds(float hz) const {
+ return std::chrono::nanoseconds(static_cast<int64_t>(1000000000L / hz));
+ }
+
+ void onContinuousPropertyTimer(const std::vector<int32_t>& properties);
+
private:
std::map<
std::pair<int32_t /*VehicleProperty*/, int32_t /*areaId*/>,
@@ -103,6 +112,8 @@
std::mutex mPropsMutex;
std::thread mThread;
std::unique_ptr<CommBase> mComm{nullptr};
+ RecurrentTimer mRecurrentTimer;
+ std::unordered_map<int32_t, const VehiclePropConfig*> mPropConfigMap;
};
} // impl
diff --git a/automotive/vehicle/2.0/default/tests/RecurrentTimer_test.cpp b/automotive/vehicle/2.0/default/tests/RecurrentTimer_test.cpp
new file mode 100644
index 0000000..9fc17c6
--- /dev/null
+++ b/automotive/vehicle/2.0/default/tests/RecurrentTimer_test.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2017 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 <thread>
+
+#include <gtest/gtest.h>
+
+#include "vhal_v2_0/RecurrentTimer.h"
+
+namespace {
+
+using std::chrono::nanoseconds;
+using std::chrono::milliseconds;
+
+#define ASSERT_EQ_WITH_TOLERANCE(val1, val2, tolerance) \
+ASSERT_LE(val1 - tolerance, val2); \
+ASSERT_GE(val1 + tolerance, val2); \
+
+
+TEST(RecurrentTimerTest, oneInterval) {
+ std::atomic<int64_t> counter { 0L };
+ auto counterRef = std::ref(counter);
+ RecurrentTimer timer([&counterRef](const std::vector<int32_t>& cookies) {
+ ASSERT_EQ(1u, cookies.size());
+ ASSERT_EQ(0xdead, cookies.front());
+ counterRef.get()++;
+ });
+
+ timer.registerRecurrentEvent(milliseconds(1), 0xdead);
+ std::this_thread::sleep_for(milliseconds(100));
+ ASSERT_EQ_WITH_TOLERANCE(100, counter.load(), 20);
+}
+
+TEST(RecurrentTimerTest, multipleIntervals) {
+ std::atomic<int64_t> counter1ms { 0L };
+ std::atomic<int64_t> counter5ms { 0L };
+ auto counter1msRef = std::ref(counter1ms);
+ auto counter5msRef = std::ref(counter5ms);
+ RecurrentTimer timer(
+ [&counter1msRef, &counter5msRef](const std::vector<int32_t>& cookies) {
+ for (int32_t cookie : cookies) {
+ if (cookie == 0xdead) {
+ counter1msRef.get()++;
+ } else if (cookie == 0xbeef) {
+ counter5msRef.get()++;
+ } else {
+ FAIL();
+ }
+ }
+ });
+
+ timer.registerRecurrentEvent(milliseconds(1), 0xdead);
+ timer.registerRecurrentEvent(milliseconds(5), 0xbeef);
+
+ std::this_thread::sleep_for(milliseconds(100));
+ ASSERT_EQ_WITH_TOLERANCE(100, counter1ms.load(), 20);
+ ASSERT_EQ_WITH_TOLERANCE(20, counter5ms.load(), 5);
+}
+
+} // anonymous namespace
diff --git a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
index e13d003..7ec9b79 100644
--- a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
+++ b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
@@ -14,8 +14,9 @@
* limitations under the License.
*/
-#include <unordered_map>
+#include <functional>
#include <iostream>
+#include <unordered_map>
#include <gtest/gtest.h>
@@ -35,8 +36,9 @@
class SubscriptionManagerTest : public ::testing::Test {
public:
- SubscriptionManager manager;
+ SubscriptionManagerTest() : manager(([this](int x) { onPropertyUnsubscribed(x); })) {}
+ SubscriptionManager manager;
static constexpr int32_t PROP1 = toInt(VehicleProperty::HVAC_FAN_SPEED);
static constexpr int32_t PROP2 = toInt(VehicleProperty::DISPLAY_BRIGHTNESS);
@@ -44,6 +46,10 @@
sp<IVehicleCallback> cb2 = new MockedVehicleCallback();
sp<IVehicleCallback> cb3 = new MockedVehicleCallback();
+ void SetUp() override {
+ lastUnsubscribedProperty = -1;
+ }
+
hidl_vec<SubscribeOptions> subscrToProp1 = {
SubscribeOptions {
.propId = PROP1,
@@ -90,12 +96,31 @@
return manager.getSubscribedClients(PROP2, 0,
SubscribeFlags::DEFAULT);
}
+
+ void onPropertyUnsubscribed(int propertyId) {
+ // Called when there are no clients who subscribed to particular property. This can happen
+ // because of explict unsubscribe call or when client (IVehicleCallback) was disconnected.
+ lastUnsubscribedProperty = propertyId;
+ }
+
+ void assertOnPropertyUnsubscribedNotCalled() {
+ ASSERT_EQ(-1, lastUnsubscribedProperty);
+ }
+
+ void assertLastUnsubscribedProperty(int expectedPropertyId) {
+ ASSERT_EQ(expectedPropertyId, lastUnsubscribedProperty);
+ lastUnsubscribedProperty = -1;
+ }
+
+private:
+ int lastUnsubscribedProperty;
};
TEST_F(SubscriptionManagerTest, multipleClients) {
- manager.addOrUpdateSubscription(cb1, subscrToProp1);
- manager.addOrUpdateSubscription(cb2, subscrToProp1);
+ std::list<SubscribeOptions> updatedOptions;
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb2, subscrToProp1, &updatedOptions));
auto clients = manager.getSubscribedClients(
PROP1,
@@ -106,7 +131,8 @@
}
TEST_F(SubscriptionManagerTest, negativeCases) {
- manager.addOrUpdateSubscription(cb1, subscrToProp1);
+ std::list<SubscribeOptions> updatedOptions;
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
// Wrong zone
auto clients = manager.getSubscribedClients(
@@ -131,7 +157,8 @@
}
TEST_F(SubscriptionManagerTest, mulipleSubscriptions) {
- manager.addOrUpdateSubscription(cb1, subscrToProp1);
+ std::list<SubscribeOptions> updatedOptions;
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
auto clients = manager.getSubscribedClients(
PROP1,
@@ -142,13 +169,13 @@
// Same property, but different zone, to make sure we didn't unsubscribe
// from previous zone.
- manager.addOrUpdateSubscription(cb1, {
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, {
SubscribeOptions {
.propId = PROP1,
.vehicleAreas = toInt(VehicleAreaZone::ROW_2),
.flags = SubscribeFlags::DEFAULT
}
- });
+ }, &updatedOptions));
clients = manager.getSubscribedClients(PROP1,
toInt(VehicleAreaZone::ROW_1_LEFT),
@@ -162,31 +189,38 @@
}
TEST_F(SubscriptionManagerTest, unsubscribe) {
- manager.addOrUpdateSubscription(cb1, subscrToProp1);
- manager.addOrUpdateSubscription(cb2, subscrToProp2);
- manager.addOrUpdateSubscription(cb3, subscrToProp1and2);
+ std::list<SubscribeOptions> updatedOptions;
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb1, subscrToProp1, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb2, subscrToProp2, &updatedOptions));
+ ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(cb3, subscrToProp1and2,
+ &updatedOptions));
ASSERT_ALL_EXISTS({cb1, cb3}, extractCallbacks(clientsToProp1()));
ASSERT_ALL_EXISTS({cb2, cb3}, extractCallbacks(clientsToProp2()));
- ASSERT_FALSE(manager.unsubscribe(cb1, PROP1));
+ manager.unsubscribe(cb1, PROP1);
+ assertOnPropertyUnsubscribedNotCalled();
ASSERT_ALL_EXISTS({cb3}, extractCallbacks(clientsToProp1()));
// Make sure nothing changed in PROP2 so far.
ASSERT_ALL_EXISTS({cb2, cb3}, extractCallbacks(clientsToProp2()));
// No one subscribed to PROP1, subscription for PROP2 is not affected.
- ASSERT_TRUE(manager.unsubscribe(cb3, PROP1));
+ manager.unsubscribe(cb3, PROP1);
+ assertLastUnsubscribedProperty(PROP1);
ASSERT_ALL_EXISTS({cb2, cb3}, extractCallbacks(clientsToProp2()));
- ASSERT_FALSE(manager.unsubscribe(cb3, PROP2));
+ manager.unsubscribe(cb3, PROP2);
+ assertOnPropertyUnsubscribedNotCalled();
ASSERT_ALL_EXISTS({cb2}, extractCallbacks(clientsToProp2()));
// The last client unsubscribed from this property.
- ASSERT_TRUE(manager.unsubscribe(cb2, PROP2));
+ manager.unsubscribe(cb2, PROP2);
+ assertLastUnsubscribedProperty(PROP2);
- // No one was subscribed, return false.
- ASSERT_FALSE(manager.unsubscribe(cb1, PROP1));
+ // No one subscribed anymore
+ manager.unsubscribe(cb1, PROP1);
+ assertLastUnsubscribedProperty(PROP1);
}
} // namespace anonymous
diff --git a/automotive/vehicle/2.1/default/impl/vhal_v2_1/DefaultVehicleHal.cpp b/automotive/vehicle/2.1/default/impl/vhal_v2_1/DefaultVehicleHal.cpp
index dc96bf9..d4eae7f 100644
--- a/automotive/vehicle/2.1/default/impl/vhal_v2_1/DefaultVehicleHal.cpp
+++ b/automotive/vehicle/2.1/default/impl/vhal_v2_1/DefaultVehicleHal.cpp
@@ -270,6 +270,11 @@
case V2_0::toInt(V2_1::VehicleProperty::OBD2_FREEZE_FRAME_CLEAR):
return clearObd2FreezeFrames(propValue);
break;
+ case V2_0::toInt(V2_1::VehicleProperty::VEHICLE_MAP_SERVICE):
+ // Placeholder for future implementation of VMS property in the default hal. For now, just
+ // returns OK; otherwise, hal clients crash with property not supported.
+ return V2_0::StatusCode::OK;
+ break;
default:
return mVehicleHal20->set(propValue);
}
diff --git a/benchmarks/Android.bp b/benchmarks/Android.bp
deleted file mode 100644
index ab0f308..0000000
--- a/benchmarks/Android.bp
+++ /dev/null
@@ -1,4 +0,0 @@
-// This is an autogenerated file, do not edit.
-subdirs = [
- "msgq/1.0",
-]
diff --git a/benchmarks/msgq/1.0/Android.bp b/benchmarks/msgq/1.0/Android.bp
deleted file mode 100644
index 7f8ea99..0000000
--- a/benchmarks/msgq/1.0/Android.bp
+++ /dev/null
@@ -1,59 +0,0 @@
-// This file is autogenerated by hidl-gen. Do not edit manually.
-
-filegroup {
- name: "android.hardware.benchmarks.msgq@1.0_hal",
- srcs: [
- "IBenchmarkMsgQ.hal",
- ],
-}
-
-genrule {
- name: "android.hardware.benchmarks.msgq@1.0_genc++",
- tools: ["hidl-gen"],
- cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.benchmarks.msgq@1.0",
- srcs: [
- ":android.hardware.benchmarks.msgq@1.0_hal",
- ],
- out: [
- "android/hardware/benchmarks/msgq/1.0/BenchmarkMsgQAll.cpp",
- ],
-}
-
-genrule {
- name: "android.hardware.benchmarks.msgq@1.0_genc++_headers",
- tools: ["hidl-gen"],
- cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.benchmarks.msgq@1.0",
- srcs: [
- ":android.hardware.benchmarks.msgq@1.0_hal",
- ],
- out: [
- "android/hardware/benchmarks/msgq/1.0/IBenchmarkMsgQ.h",
- "android/hardware/benchmarks/msgq/1.0/IHwBenchmarkMsgQ.h",
- "android/hardware/benchmarks/msgq/1.0/BnHwBenchmarkMsgQ.h",
- "android/hardware/benchmarks/msgq/1.0/BpHwBenchmarkMsgQ.h",
- "android/hardware/benchmarks/msgq/1.0/BsBenchmarkMsgQ.h",
- ],
-}
-
-cc_library_shared {
- name: "android.hardware.benchmarks.msgq@1.0",
- generated_sources: ["android.hardware.benchmarks.msgq@1.0_genc++"],
- generated_headers: ["android.hardware.benchmarks.msgq@1.0_genc++_headers"],
- export_generated_headers: ["android.hardware.benchmarks.msgq@1.0_genc++_headers"],
- shared_libs: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "liblog",
- "libutils",
- "libcutils",
- "android.hidl.base@1.0",
- ],
- export_shared_lib_headers: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "libutils",
- "android.hidl.base@1.0",
- ],
-}
diff --git a/biometrics/fingerprint/2.1/vts/functional/Android.bp b/biometrics/fingerprint/2.1/vts/functional/Android.bp
index 63115c1..27b7157 100644
--- a/biometrics/fingerprint/2.1/vts/functional/Android.bp
+++ b/biometrics/fingerprint/2.1/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalBiometricsFingerprintV2_1TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalBiometricsFingerprintV2_1TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -26,7 +27,7 @@
"libutils",
"android.hardware.biometrics.fingerprint@2.1",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp b/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
index 87d70bb..c07c3e3 100644
--- a/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
+++ b/biometrics/fingerprint/2.1/vts/functional/VtsHalBiometricsFingerprintV2_1TargetTest.cpp
@@ -15,15 +15,16 @@
*/
#define LOG_TAG "fingerprint_hidl_hal_test"
+#define SERVICE_NAME "fingerprint_hal"
#include <android-base/logging.h>
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprintClientCallback.h>
-#include <chrono>
-#include <VtsHalHidlTargetBaseTest.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
+#include <VtsHalHidlTargetTestBase.h>
+using android::Condition;
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
using android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo;
@@ -31,68 +32,107 @@
using android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
using android::hardware::hidl_vec;
using android::hardware::Return;
+using android::Mutex;
+using android::sp;
-#define SERVICE_NAME "fingerprint_hal"
-
-class FingerprintHidlTest : public ::testing::VtsHalHidlTargetBaseTest,
- public IBiometricsFingerprintClientCallback {
+class FingerprintHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
- android::sp<IBiometricsFingerprint> service;
- FingerprintError err;
- // State changes should occur within this threshold, otherwise the
- // framework' will assume things have broken.
- std::chrono::seconds threshold;
+ class MyCallback : public IBiometricsFingerprintClientCallback {
+ // implement methods of IBiometricsFingerprintClientCallback
+ virtual Return<void> onEnrollResult(uint64_t, uint32_t, uint32_t,
+ uint32_t) override {
+ callBackCalled();
+ return Return<void>();
+ }
+
+ virtual Return<void> onAcquired(uint64_t, FingerprintAcquiredInfo,
+ int32_t) override {
+ callBackCalled();
+ return Return<void>();
+ }
+
+ virtual Return<void> onAuthenticated(uint64_t, uint32_t, uint32_t,
+ const hidl_vec<uint8_t>&) override {
+ callBackCalled();
+ return Return<void>();
+ }
+
+ virtual Return<void> onError(uint64_t, FingerprintError error, int32_t)
+ override {
+ mTestCase->mErr = error;
+ callBackCalled();
+ return Return<void>();
+ }
+
+ virtual Return<void> onRemoved(uint64_t, uint32_t, uint32_t, uint32_t)
+ override {
+ callBackCalled();
+ return Return<void>();
+ }
+
+ virtual Return<void> onEnumerate(uint64_t, uint32_t, uint32_t,
+ uint32_t) override {
+ callBackCalled();
+ return Return<void>();
+ }
+
+ void callBackCalled () {
+ mTestCase->mCallbackCalled = true;
+ mTestCase->mCallbackCond.broadcast();
+ }
+
+ FingerprintHidlTest* mTestCase;
+ public:
+ MyCallback(FingerprintHidlTest* aTest) : mTestCase(aTest) {}
+ };
+
+ sp<MyCallback> mCallback;
+ bool mCallbackCalled;
+ Condition mCallbackCond;
+ FingerprintError mErr;
+ Mutex mLock;
+ sp<IBiometricsFingerprint> mService;
+ static const unsigned int kThresholdInSeconds = 3;
+
+ void clearErr () {
+ mErr = FingerprintError::ERROR_NO_ERROR;
+ }
+
+ // Timed callback mechanism. Will block up to kThresholdInSeconds,
+ // returning true if callback was invoked in that time frame.
+ bool waitForCallback(const unsigned int seconds = kThresholdInSeconds) {
+ nsecs_t reltime = seconds_to_nanoseconds(seconds);
+ Mutex::Autolock _l(mLock);
+ nsecs_t endTime = systemTime() + reltime;
+ while (!mCallbackCalled) {
+ if (reltime == 0) {
+ mCallbackCond.wait(mLock);
+ } else {
+ nsecs_t now = systemTime();
+ if (now > endTime) {
+ return false;
+ }
+ mCallbackCond.waitRelative(mLock, endTime - now);
+ }
+ }
+ return true;
+ }
public:
- FingerprintHidlTest ():
- err(FingerprintError::ERROR_NO_ERROR), threshold(1) {}
+ FingerprintHidlTest (): mCallbackCalled(false) {}
virtual void SetUp() override {
- service = ::testing::VtsHalHidlTargetBaseTest::getService<IBiometricsFingerprint>(SERVICE_NAME);
+ mService = ::testing::VtsHalHidlTargetTestBase::getService<IBiometricsFingerprint>(SERVICE_NAME);
- ASSERT_NE(service, nullptr);
+ ASSERT_NE(mService, nullptr);
clearErr();
+ mCallback = new MyCallback(this);
// TODO: instantly fail any test that receives a death notification
}
virtual void TearDown() override {}
-
- // implement methods of IBiometricsFingerprintClientCallback
- virtual Return<void> onEnrollResult(uint64_t, uint32_t, uint32_t, uint32_t)
- override {
- return Return<void>();
- }
- virtual Return<void> onAcquired(uint64_t, FingerprintAcquiredInfo, int32_t)
- override {
- return Return<void>();
- }
-
- virtual Return<void> onAuthenticated(uint64_t, uint32_t, uint32_t, const
- hidl_vec<uint8_t>&) override {
- return Return<void>();
- }
-
- virtual Return<void> onError(uint64_t, FingerprintError error, int32_t)
- override {
- err = error;
- return Return<void>();
- }
-
- virtual Return<void> onRemoved(uint64_t, uint32_t, uint32_t, uint32_t)
- override {
- return Return<void>();
- }
-
- virtual Return<void> onEnumerate(uint64_t, uint32_t, uint32_t, uint32_t)
- override {
- return Return<void>();
- }
-
- void clearErr () {
- err = FingerprintError::ERROR_NO_ERROR;
- }
};
class FingerprintHidlEnvironment : public ::testing::Environment {
@@ -103,50 +143,42 @@
// The service should be reachable.
TEST_F(FingerprintHidlTest, ConnectTest) {
- Return<uint64_t> rc = service->setNotify(this);
+ Return<uint64_t> rc = mService->setNotify(mCallback);
EXPECT_NE(rc, 0UL);
}
// Cancel should always return ERROR_CANCELED from any starting state including
// the IDLE state.
TEST_F(FingerprintHidlTest, CancelTest) {
- Return<uint64_t> rc = service->setNotify(this);
+ Return<uint64_t> rc = mService->setNotify(mCallback);
EXPECT_NE(rc, 0UL);
- auto start = std::chrono::system_clock::now();
- Return<RequestStatus> res = service->cancel();
- auto end = std::chrono::system_clock::now();
- auto diff = end - start;
-
+ Return<RequestStatus> res = mService->cancel();
+ // make sure callback was invoked within kThresholdInSeconds
+ EXPECT_EQ(true, waitForCallback());
// check that we were able to make an IPC request successfully
EXPECT_EQ(RequestStatus::SYS_OK, res);
// check error should be ERROR_CANCELED
- EXPECT_EQ(FingerprintError::ERROR_CANCELED, err);
- // check that this did not take longer than a threshold
- EXPECT_TRUE(diff <= threshold);
+ EXPECT_EQ(FingerprintError::ERROR_CANCELED, mErr);
}
// A call to cancel should after any other method call should set the error
// state to canceled.
TEST_F(FingerprintHidlTest, AuthTest) {
- Return<uint64_t> rc = service->setNotify(this);
+ Return<uint64_t> rc = mService->setNotify(mCallback);
EXPECT_NE(rc, 0UL);
- Return<RequestStatus> res = service->authenticate(0, 0);
+ Return<RequestStatus> res = mService->authenticate(0, 0);
// check that we were able to make an IPC request successfully
EXPECT_EQ(RequestStatus::SYS_OK, res);
- auto start = std::chrono::system_clock::now();
- res = service->cancel();
- auto end = std::chrono::system_clock::now();
- auto diff = end - start;
-
+ res = mService->cancel();
+ // make sure callback was invoked within kThresholdInSeconds
+ EXPECT_EQ(true, waitForCallback());
// check that we were able to make an IPC request successfully
EXPECT_EQ(RequestStatus::SYS_OK, res);
// check error should be ERROR_CANCELED
- EXPECT_EQ(FingerprintError::ERROR_CANCELED, err);
- // check that this did not take longer than a threshold
- EXPECT_TRUE(diff <= threshold);
+ EXPECT_EQ(FingerprintError::ERROR_CANCELED, mErr);
}
int main(int argc, char **argv) {
diff --git a/bluetooth/1.0/default/Android.bp b/bluetooth/1.0/default/Android.bp
index fb20195..292f97c 100644
--- a/bluetooth/1.0/default/Android.bp
+++ b/bluetooth/1.0/default/Android.bp
@@ -15,6 +15,7 @@
cc_library_shared {
name: "android.hardware.bluetooth@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: [
@@ -40,6 +41,7 @@
cc_library_static {
name: "android.hardware.bluetooth-async",
+ defaults: ["hidl_defaults"],
srcs: [
"async_fd_watcher.cc",
],
@@ -54,8 +56,12 @@
cc_library_static {
name: "android.hardware.bluetooth-hci",
+ defaults: ["hidl_defaults"],
srcs: [
"hci_packetizer.cc",
+ "hci_protocol.cc",
+ "h4_protocol.cc",
+ "mct_protocol.cc",
],
export_include_dirs: ["."],
shared_libs: [
@@ -69,23 +75,30 @@
cc_test {
name: "bluetooth-vendor-interface-unit-tests",
+ defaults: ["hidl_defaults"],
srcs: [
"test/async_fd_watcher_unittest.cc",
+ "test/h4_protocol_unittest.cc",
+ "test/mct_protocol_unittest.cc",
],
local_include_dirs: [
"test",
],
shared_libs: [
"libbase",
+ "libhidlbase",
"liblog",
],
static_libs: [
"android.hardware.bluetooth-async",
+ "android.hardware.bluetooth-hci",
+ "libgmock",
],
}
cc_test_host {
name: "bluetooth-address-unit-tests",
+ defaults: ["hidl_defaults"],
srcs: [
"bluetooth_address.cc",
"test/bluetooth_address_test.cc",
diff --git a/bluetooth/1.0/default/async_fd_watcher.cc b/bluetooth/1.0/default/async_fd_watcher.cc
index 287d007..05ac537 100644
--- a/bluetooth/1.0/default/async_fd_watcher.cc
+++ b/bluetooth/1.0/default/async_fd_watcher.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <atomic>
#include <condition_variable>
+#include <map>
#include <mutex>
#include <thread>
#include <vector>
@@ -26,6 +27,8 @@
#include "sys/select.h"
#include "unistd.h"
+static const int INVALID_FD = -1;
+
namespace android {
namespace hardware {
namespace bluetooth {
@@ -36,8 +39,7 @@
// Add file descriptor and callback
{
std::unique_lock<std::mutex> guard(internal_mutex_);
- read_fd_ = file_descriptor;
- cb_ = on_read_fd_ready_callback;
+ watched_fds_[file_descriptor] = on_read_fd_ready_callback;
}
// Start the thread if not started yet
@@ -58,7 +60,7 @@
return 0;
}
-void AsyncFdWatcher::StopWatchingFileDescriptor() { stopThread(); }
+void AsyncFdWatcher::StopWatchingFileDescriptors() { stopThread(); }
AsyncFdWatcher::~AsyncFdWatcher() {}
@@ -90,8 +92,7 @@
{
std::unique_lock<std::mutex> guard(internal_mutex_);
- cb_ = nullptr;
- read_fd_ = -1;
+ watched_fds_.clear();
}
{
@@ -115,7 +116,11 @@
fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(notification_listen_fd_, &read_fds);
- FD_SET(read_fd_, &read_fds);
+ int max_read_fd = INVALID_FD;
+ for (auto& it : watched_fds_) {
+ FD_SET(it.first, &read_fds);
+ max_read_fd = std::max(max_read_fd, it.first);
+ }
struct timeval timeout;
struct timeval* timeout_ptr = NULL;
@@ -126,7 +131,7 @@
}
// Wait until there is data available to read on some FD.
- int nfds = std::max(notification_listen_fd_, read_fd_);
+ int nfds = std::max(notification_listen_fd_, max_read_fd);
int retval = select(nfds + 1, &read_fds, NULL, NULL, timeout_ptr);
// There was some error.
@@ -153,10 +158,15 @@
continue;
}
- // Invoke the data ready callback if appropriate.
- if (FD_ISSET(read_fd_, &read_fds)) {
+ // Invoke the data ready callbacks if appropriate.
+ {
+ // Hold the mutex to make sure that the callbacks are still valid.
std::unique_lock<std::mutex> guard(internal_mutex_);
- if (cb_) cb_(read_fd_);
+ for (auto& it : watched_fds_) {
+ if (FD_ISSET(it.first, &read_fds)) {
+ it.second(it.first);
+ }
+ }
}
}
}
diff --git a/bluetooth/1.0/default/async_fd_watcher.h b/bluetooth/1.0/default/async_fd_watcher.h
index 3f7ff54..358cbc3 100644
--- a/bluetooth/1.0/default/async_fd_watcher.h
+++ b/bluetooth/1.0/default/async_fd_watcher.h
@@ -16,6 +16,7 @@
#pragma once
+#include <map>
#include <mutex>
#include <thread>
@@ -36,7 +37,7 @@
const ReadCallback& on_read_fd_ready_callback);
int ConfigureTimeout(const std::chrono::milliseconds timeout,
const TimeoutCallback& on_timeout_callback);
- void StopWatchingFileDescriptor();
+ void StopWatchingFileDescriptors();
private:
AsyncFdWatcher(const AsyncFdWatcher&) = delete;
@@ -52,10 +53,9 @@
std::mutex internal_mutex_;
std::mutex timeout_mutex_;
- int read_fd_;
+ std::map<int, ReadCallback> watched_fds_;
int notification_listen_fd_;
int notification_write_fd_;
- ReadCallback cb_;
TimeoutCallback timeout_cb_;
std::chrono::milliseconds timeout_ms_;
};
diff --git a/bluetooth/1.0/default/bluetooth_hci.cc b/bluetooth/1.0/default/bluetooth_hci.cc
index 1d6e600..5a282bf 100644
--- a/bluetooth/1.0/default/bluetooth_hci.cc
+++ b/bluetooth/1.0/default/bluetooth_hci.cc
@@ -44,21 +44,14 @@
event_cb_->initializationComplete(
status ? Status::SUCCESS : Status::INITIALIZATION_ERROR);
},
- [this](HciPacketType type, const hidl_vec<uint8_t>& packet) {
- switch (type) {
- case HCI_PACKET_TYPE_EVENT:
- event_cb_->hciEventReceived(packet);
- break;
- case HCI_PACKET_TYPE_ACL_DATA:
- event_cb_->aclDataReceived(packet);
- break;
- case HCI_PACKET_TYPE_SCO_DATA:
- event_cb_->scoDataReceived(packet);
- break;
- default:
- ALOGE("%s Unexpected event type %d", __func__, type);
- break;
- }
+ [this](const hidl_vec<uint8_t>& packet) {
+ event_cb_->hciEventReceived(packet);
+ },
+ [this](const hidl_vec<uint8_t>& packet) {
+ event_cb_->aclDataReceived(packet);
+ },
+ [this](const hidl_vec<uint8_t>& packet) {
+ event_cb_->scoDataReceived(packet);
});
if (!rc) event_cb_->initializationComplete(Status::INITIALIZATION_ERROR);
return Void();
diff --git a/bluetooth/1.0/default/h4_protocol.cc b/bluetooth/1.0/default/h4_protocol.cc
new file mode 100644
index 0000000..8f24b5e
--- /dev/null
+++ b/bluetooth/1.0/default/h4_protocol.cc
@@ -0,0 +1,71 @@
+//
+// Copyright 2017 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 "h4_protocol.h"
+
+#define LOG_TAG "android.hardware.bluetooth-hci-h4"
+#include <android-base/logging.h>
+#include <assert.h>
+#include <fcntl.h>
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+size_t H4Protocol::Send(uint8_t type, const uint8_t* data, size_t length) {
+ int rv = WriteSafely(uart_fd_, &type, sizeof(type));
+ if (rv == sizeof(type)) {
+ rv = WriteSafely(uart_fd_, data, length);
+ }
+ return rv;
+}
+
+void H4Protocol::OnPacketReady() {
+ switch (hci_packet_type_) {
+ case HCI_PACKET_TYPE_EVENT:
+ event_cb_(hci_packetizer_.GetPacket());
+ break;
+ case HCI_PACKET_TYPE_ACL_DATA:
+ acl_cb_(hci_packetizer_.GetPacket());
+ break;
+ case HCI_PACKET_TYPE_SCO_DATA:
+ sco_cb_(hci_packetizer_.GetPacket());
+ break;
+ default: {
+ bool bad_packet_type = true;
+ CHECK(!bad_packet_type);
+ }
+ }
+ // Get ready for the next type byte.
+ hci_packet_type_ = HCI_PACKET_TYPE_UNKNOWN;
+}
+
+void H4Protocol::OnDataReady(int fd) {
+ if (hci_packet_type_ == HCI_PACKET_TYPE_UNKNOWN) {
+ uint8_t buffer[1] = {0};
+ size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
+ CHECK(bytes_read == 1);
+ hci_packet_type_ = static_cast<HciPacketType>(buffer[0]);
+ } else {
+ hci_packetizer_.OnDataReady(fd, hci_packet_type_);
+ }
+}
+
+} // namespace hci
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/h4_protocol.h b/bluetooth/1.0/default/h4_protocol.h
new file mode 100644
index 0000000..0d0a1ca
--- /dev/null
+++ b/bluetooth/1.0/default/h4_protocol.h
@@ -0,0 +1,61 @@
+//
+// Copyright 2017 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 <hidl/HidlSupport.h>
+
+#include "async_fd_watcher.h"
+#include "bt_vendor_lib.h"
+#include "hci_internals.h"
+#include "hci_protocol.h"
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+class H4Protocol : public HciProtocol {
+ public:
+ H4Protocol(int fd, PacketReadCallback event_cb, PacketReadCallback acl_cb,
+ PacketReadCallback sco_cb)
+ : uart_fd_(fd),
+ event_cb_(event_cb),
+ acl_cb_(acl_cb),
+ sco_cb_(sco_cb),
+ hci_packetizer_([this]() { OnPacketReady(); }) {}
+
+ size_t Send(uint8_t type, const uint8_t* data, size_t length);
+
+ void OnPacketReady();
+
+ void OnDataReady(int fd);
+
+ private:
+ int uart_fd_;
+
+ PacketReadCallback event_cb_;
+ PacketReadCallback acl_cb_;
+ PacketReadCallback sco_cb_;
+
+ HciPacketType hci_packet_type_{HCI_PACKET_TYPE_UNKNOWN};
+ hci::HciPacketizer hci_packetizer_;
+};
+
+} // namespace hci
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/hci_packetizer.cc b/bluetooth/1.0/default/hci_packetizer.cc
index 1a50196..9549858 100644
--- a/bluetooth/1.0/default/hci_packetizer.cc
+++ b/bluetooth/1.0/default/hci_packetizer.cc
@@ -18,7 +18,6 @@
#define LOG_TAG "android.hardware.bluetooth.hci_packetizer"
#include <android-base/logging.h>
-#include <cutils/properties.h>
#include <utils/Log.h>
#include <dlfcn.h>
@@ -46,63 +45,40 @@
namespace bluetooth {
namespace hci {
-HciPacketType HciPacketizer::GetPacketType() const {
- return hci_packet_type_;
-}
+const hidl_vec<uint8_t>& HciPacketizer::GetPacket() const { return packet_; }
-const hidl_vec<uint8_t>& HciPacketizer::GetPacket() const {
- return hci_packet_;
-}
-
-void HciPacketizer::OnDataReady(int fd) {
- switch (hci_parser_state_) {
- case HCI_IDLE: {
- uint8_t buffer[1] = {0};
- size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer, 1));
- CHECK(bytes_read == 1);
- hci_packet_type_ = static_cast<HciPacketType>(buffer[0]);
- CHECK(hci_packet_type_ >= HCI_PACKET_TYPE_ACL_DATA &&
- hci_packet_type_ <= HCI_PACKET_TYPE_EVENT)
- << "buffer[0] = " << static_cast<unsigned int>(buffer[0]);
- hci_parser_state_ = HCI_TYPE_READY;
- hci_packet_bytes_remaining_ = preamble_size_for_type[hci_packet_type_];
- hci_packet_bytes_read_ = 0;
- break;
- }
-
- case HCI_TYPE_READY: {
+void HciPacketizer::OnDataReady(int fd, HciPacketType packet_type) {
+ switch (state_) {
+ case HCI_PREAMBLE: {
size_t bytes_read = TEMP_FAILURE_RETRY(
- read(fd, hci_packet_preamble_ + hci_packet_bytes_read_,
- hci_packet_bytes_remaining_));
+ read(fd, preamble_ + bytes_read_,
+ preamble_size_for_type[packet_type] - bytes_read_));
CHECK(bytes_read > 0);
- hci_packet_bytes_remaining_ -= bytes_read;
- hci_packet_bytes_read_ += bytes_read;
- if (hci_packet_bytes_remaining_ == 0) {
+ bytes_read_ += bytes_read;
+ if (bytes_read_ == preamble_size_for_type[packet_type]) {
size_t packet_length =
- HciGetPacketLengthForType(hci_packet_type_, hci_packet_preamble_);
- hci_packet_.resize(preamble_size_for_type[hci_packet_type_] +
- packet_length);
- memcpy(hci_packet_.data(), hci_packet_preamble_,
- preamble_size_for_type[hci_packet_type_]);
- hci_packet_bytes_remaining_ = packet_length;
- hci_parser_state_ = HCI_PAYLOAD;
- hci_packet_bytes_read_ = 0;
+ HciGetPacketLengthForType(packet_type, preamble_);
+ packet_.resize(preamble_size_for_type[packet_type] + packet_length);
+ memcpy(packet_.data(), preamble_, preamble_size_for_type[packet_type]);
+ bytes_remaining_ = packet_length;
+ state_ = HCI_PAYLOAD;
+ bytes_read_ = 0;
}
break;
}
case HCI_PAYLOAD: {
- size_t bytes_read = TEMP_FAILURE_RETRY(
- read(fd,
- hci_packet_.data() + preamble_size_for_type[hci_packet_type_] +
- hci_packet_bytes_read_,
- hci_packet_bytes_remaining_));
+ size_t bytes_read = TEMP_FAILURE_RETRY(read(
+ fd,
+ packet_.data() + preamble_size_for_type[packet_type] + bytes_read_,
+ bytes_remaining_));
CHECK(bytes_read > 0);
- hci_packet_bytes_remaining_ -= bytes_read;
- hci_packet_bytes_read_ += bytes_read;
- if (hci_packet_bytes_remaining_ == 0) {
- hci_packet_ready_cb_();
- hci_parser_state_ = HCI_IDLE;
+ bytes_remaining_ -= bytes_read;
+ bytes_read_ += bytes_read;
+ if (bytes_remaining_ == 0) {
+ packet_ready_cb_();
+ state_ = HCI_PREAMBLE;
+ bytes_read_ = 0;
}
break;
}
diff --git a/bluetooth/1.0/default/hci_packetizer.h b/bluetooth/1.0/default/hci_packetizer.h
index e9c01dc..90579bd 100644
--- a/bluetooth/1.0/default/hci_packetizer.h
+++ b/bluetooth/1.0/default/hci_packetizer.h
@@ -32,20 +32,19 @@
class HciPacketizer {
public:
- HciPacketizer(HciPacketReadyCallback packet_cb) : hci_packet_ready_cb_(packet_cb) {};
- void OnDataReady(int fd);
+ HciPacketizer(HciPacketReadyCallback packet_cb)
+ : packet_ready_cb_(packet_cb){};
+ void OnDataReady(int fd, HciPacketType packet_type);
const hidl_vec<uint8_t>& GetPacket() const;
- HciPacketType GetPacketType() const;
protected:
- enum HciParserState { HCI_IDLE, HCI_TYPE_READY, HCI_PAYLOAD };
- HciParserState hci_parser_state_{HCI_IDLE};
- HciPacketType hci_packet_type_{HCI_PACKET_TYPE_UNKNOWN};
- uint8_t hci_packet_preamble_[HCI_PREAMBLE_SIZE_MAX];
- hidl_vec<uint8_t> hci_packet_;
- size_t hci_packet_bytes_remaining_;
- size_t hci_packet_bytes_read_;
- HciPacketReadyCallback hci_packet_ready_cb_;
+ enum State { HCI_PREAMBLE, HCI_PAYLOAD };
+ State state_{HCI_PREAMBLE};
+ uint8_t preamble_[HCI_PREAMBLE_SIZE_MAX];
+ hidl_vec<uint8_t> packet_;
+ size_t bytes_remaining_{0};
+ size_t bytes_read_{0};
+ HciPacketReadyCallback packet_ready_cb_;
};
} // namespace hci
diff --git a/bluetooth/1.0/default/hci_protocol.cc b/bluetooth/1.0/default/hci_protocol.cc
new file mode 100644
index 0000000..bb1e36b
--- /dev/null
+++ b/bluetooth/1.0/default/hci_protocol.cc
@@ -0,0 +1,57 @@
+//
+// Copyright 2017 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 "hci_protocol.h"
+
+#define LOG_TAG "android.hardware.bluetooth-hci-hci_protocol"
+#include <android-base/logging.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <utils/Log.h>
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+size_t HciProtocol::WriteSafely(int fd, const uint8_t* data, size_t length) {
+ size_t transmitted_length = 0;
+ while (length > 0) {
+ ssize_t ret =
+ TEMP_FAILURE_RETRY(write(fd, data + transmitted_length, length));
+
+ if (ret == -1) {
+ if (errno == EAGAIN) continue;
+ ALOGE("%s error writing to UART (%s)", __func__, strerror(errno));
+ break;
+
+ } else if (ret == 0) {
+ // Nothing written :(
+ ALOGE("%s zero bytes written - something went wrong...", __func__);
+ break;
+ }
+
+ transmitted_length += ret;
+ length -= ret;
+ }
+
+ return transmitted_length;
+}
+
+} // namespace hci
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/hci_protocol.h b/bluetooth/1.0/default/hci_protocol.h
new file mode 100644
index 0000000..6821107
--- /dev/null
+++ b/bluetooth/1.0/default/hci_protocol.h
@@ -0,0 +1,49 @@
+//
+// Copyright 2017 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 <hidl/HidlSupport.h>
+
+#include "bt_vendor_lib.h"
+#include "hci_internals.h"
+#include "hci_packetizer.h"
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+using ::android::hardware::hidl_vec;
+using PacketReadCallback = std::function<void(const hidl_vec<uint8_t>&)>;
+
+// Implementation of HCI protocol bits common to different transports
+class HciProtocol {
+ public:
+ HciProtocol() = default;
+ virtual ~HciProtocol(){};
+
+ // Protocol-specific implementation of sending packets.
+ virtual size_t Send(uint8_t type, const uint8_t* data, size_t length) = 0;
+
+ protected:
+ static size_t WriteSafely(int fd, const uint8_t* data, size_t length);
+};
+
+} // namespace hci
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/mct_protocol.cc b/bluetooth/1.0/default/mct_protocol.cc
new file mode 100644
index 0000000..813cebd
--- /dev/null
+++ b/bluetooth/1.0/default/mct_protocol.cc
@@ -0,0 +1,71 @@
+//
+// Copyright 2017 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 "mct_protocol.h"
+
+#include <assert.h>
+
+#define LOG_TAG "android.hardware.bluetooth-hci-mct"
+#include <android-base/logging.h>
+#include <utils/Log.h>
+
+#include <fcntl.h>
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+MctProtocol::MctProtocol(int* fds, PacketReadCallback event_cb,
+ PacketReadCallback acl_cb)
+ : event_cb_(event_cb),
+ acl_cb_(acl_cb),
+ event_packetizer_([this]() { OnEventPacketReady(); }),
+ acl_packetizer_([this]() { OnAclDataPacketReady(); }) {
+ for (int i = 0; i < CH_MAX; i++) {
+ uart_fds_[i] = fds[i];
+ }
+}
+
+size_t MctProtocol::Send(uint8_t type, const uint8_t* data, size_t length) {
+ if (type == HCI_PACKET_TYPE_COMMAND)
+ return WriteSafely(uart_fds_[CH_CMD], data, length);
+ if (type == HCI_PACKET_TYPE_ACL_DATA)
+ return WriteSafely(uart_fds_[CH_ACL_OUT], data, length);
+ CHECK(type == HCI_PACKET_TYPE_COMMAND || type == HCI_PACKET_TYPE_ACL_DATA);
+ return 0;
+}
+
+void MctProtocol::OnEventPacketReady() {
+ event_cb_(event_packetizer_.GetPacket());
+}
+
+void MctProtocol::OnAclDataPacketReady() {
+ acl_cb_(acl_packetizer_.GetPacket());
+}
+
+void MctProtocol::OnEventDataReady(int fd) {
+ event_packetizer_.OnDataReady(fd, HCI_PACKET_TYPE_EVENT);
+}
+
+void MctProtocol::OnAclDataReady(int fd) {
+ acl_packetizer_.OnDataReady(fd, HCI_PACKET_TYPE_ACL_DATA);
+}
+
+} // namespace hci
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/mct_protocol.h b/bluetooth/1.0/default/mct_protocol.h
new file mode 100644
index 0000000..6991746
--- /dev/null
+++ b/bluetooth/1.0/default/mct_protocol.h
@@ -0,0 +1,56 @@
+//
+// Copyright 2017 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 <hidl/HidlSupport.h>
+
+#include "async_fd_watcher.h"
+#include "bt_vendor_lib.h"
+#include "hci_internals.h"
+#include "hci_protocol.h"
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace hci {
+
+class MctProtocol : public HciProtocol {
+ public:
+ MctProtocol(int* fds, PacketReadCallback event_cb, PacketReadCallback acl_cb);
+
+ size_t Send(uint8_t type, const uint8_t* data, size_t length);
+
+ void OnEventPacketReady();
+ void OnAclDataPacketReady();
+
+ void OnEventDataReady(int fd);
+ void OnAclDataReady(int fd);
+
+ private:
+ int uart_fds_[CH_MAX];
+
+ PacketReadCallback event_cb_;
+ PacketReadCallback acl_cb_;
+
+ hci::HciPacketizer event_packetizer_;
+ hci::HciPacketizer acl_packetizer_;
+};
+
+} // namespace hci
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
index a7f5bda..b0c533c 100644
--- a/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
+++ b/bluetooth/1.0/default/test/async_fd_watcher_unittest.cc
@@ -14,6 +14,8 @@
// limitations under the License.
//
+#define LOG_TAG "async_fd_watcher_unittest"
+
#include "async_fd_watcher.h"
#include <gtest/gtest.h>
#include <cstdint>
@@ -122,8 +124,8 @@
}
void CleanUpServer() {
- async_fd_watcher_.StopWatchingFileDescriptor();
- conn_watcher_.StopWatchingFileDescriptor();
+ async_fd_watcher_.StopWatchingFileDescriptors();
+ conn_watcher_.StopWatchingFileDescriptors();
close(socket_fd_);
}
@@ -211,7 +213,7 @@
});
ConnectClient();
- conn_watcher.StopWatchingFileDescriptor();
+ conn_watcher.StopWatchingFileDescriptors();
close(socket_fd);
}
@@ -233,7 +235,7 @@
EXPECT_FALSE(timed_out);
sleep(1);
EXPECT_TRUE(timed_out);
- conn_watcher.StopWatchingFileDescriptor();
+ conn_watcher.StopWatchingFileDescriptors();
close(socket_fd);
}
@@ -265,10 +267,64 @@
sleep(1);
EXPECT_TRUE(timed_out);
EXPECT_TRUE(timed_out2);
- conn_watcher.StopWatchingFileDescriptor();
+ conn_watcher.StopWatchingFileDescriptors();
close(socket_fd);
}
+// Use a single AsyncFdWatcher to watch two file descriptors.
+TEST_F(AsyncFdWatcherSocketTest, WatchTwoFileDescriptors) {
+ int sockfd[2];
+ socketpair(AF_LOCAL, SOCK_STREAM, 0, sockfd);
+ bool cb1_called = false;
+ bool* cb1_called_ptr = &cb1_called;
+ bool cb2_called = false;
+ bool* cb2_called_ptr = &cb2_called;
+
+ AsyncFdWatcher watcher;
+ watcher.WatchFdForNonBlockingReads(sockfd[0], [cb1_called_ptr](int fd) {
+ char read_buf[1] = {0};
+ int n = TEMP_FAILURE_RETRY(read(fd, read_buf, sizeof(read_buf)));
+ ASSERT_TRUE(n == sizeof(read_buf));
+ ASSERT_TRUE(read_buf[0] == '1');
+ *cb1_called_ptr = true;
+ });
+
+ watcher.WatchFdForNonBlockingReads(sockfd[1], [cb2_called_ptr](int fd) {
+ char read_buf[1] = {0};
+ int n = TEMP_FAILURE_RETRY(read(fd, read_buf, sizeof(read_buf)));
+ ASSERT_TRUE(n == sizeof(read_buf));
+ ASSERT_TRUE(read_buf[0] == '2');
+ *cb2_called_ptr = true;
+ });
+
+ // Fail if the test doesn't pass within 3 seconds
+ watcher.ConfigureTimeout(std::chrono::seconds(3), [this]() {
+ bool connection_timeout = true;
+ ASSERT_FALSE(connection_timeout);
+ });
+
+ EXPECT_FALSE(cb1_called);
+ EXPECT_FALSE(cb2_called);
+
+ char one_buf[1] = {'1'};
+ TEMP_FAILURE_RETRY(write(sockfd[1], one_buf, sizeof(one_buf)));
+
+ sleep(1);
+
+ EXPECT_TRUE(cb1_called);
+ EXPECT_FALSE(cb2_called);
+
+ char two_buf[1] = {'2'};
+ TEMP_FAILURE_RETRY(write(sockfd[0], two_buf, sizeof(two_buf)));
+
+ sleep(1);
+
+ EXPECT_TRUE(cb1_called);
+ EXPECT_TRUE(cb2_called);
+
+ watcher.StopWatchingFileDescriptors();
+}
+
// Use two AsyncFdWatchers to set up a server socket.
TEST_F(AsyncFdWatcherSocketTest, ClientServer) {
ConfigureServer();
diff --git a/bluetooth/1.0/default/test/h4_protocol_unittest.cc b/bluetooth/1.0/default/test/h4_protocol_unittest.cc
new file mode 100644
index 0000000..d53aaa9
--- /dev/null
+++ b/bluetooth/1.0/default/test/h4_protocol_unittest.cc
@@ -0,0 +1,213 @@
+//
+// Copyright 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#define LOG_TAG "bt_h4_unittest"
+
+#include "h4_protocol.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <condition_variable>
+#include <cstdint>
+#include <cstring>
+#include <mutex>
+#include <vector>
+
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <utils/Log.h>
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace V1_0 {
+namespace implementation {
+
+using ::testing::Eq;
+using hci::H4Protocol;
+
+static char sample_data1[100] = "A point is that which has no part.";
+static char sample_data2[100] = "A line is breadthless length.";
+static char sample_data3[100] = "The ends of a line are points.";
+static char acl_data[100] =
+ "A straight line is a line which lies evenly with the points on itself.";
+static char sco_data[100] =
+ "A surface is that which has length and breadth only.";
+static char event_data[100] = "The edges of a surface are lines.";
+
+MATCHER_P3(HidlVecMatches, preamble, preamble_length, payload, "") {
+ size_t length = strlen(payload) + preamble_length;
+ if (length != arg.size()) {
+ return false;
+ }
+
+ if (memcmp(preamble, arg.data(), preamble_length) != 0) {
+ return false;
+ }
+
+ return memcmp(payload, arg.data() + preamble_length,
+ length - preamble_length) == 0;
+};
+
+ACTION_P2(Notify, mutex, condition) {
+ ALOGD("%s", __func__);
+ std::unique_lock<std::mutex> lock(*mutex);
+ condition->notify_one();
+}
+
+class H4ProtocolTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ ALOGD("%s", __func__);
+
+ int sockfd[2];
+ socketpair(AF_LOCAL, SOCK_STREAM, 0, sockfd);
+ H4Protocol* h4_hci =
+ new H4Protocol(sockfd[0], event_cb_.AsStdFunction(),
+ acl_cb_.AsStdFunction(), sco_cb_.AsStdFunction());
+ fd_watcher_.WatchFdForNonBlockingReads(
+ sockfd[0], [h4_hci](int fd) { h4_hci->OnDataReady(fd); });
+ protocol_ = h4_hci;
+
+ fake_uart_ = sockfd[1];
+ }
+
+ void TearDown() override { fd_watcher_.StopWatchingFileDescriptors(); }
+
+ void SendAndReadUartOutbound(uint8_t type, char* data) {
+ ALOGD("%s sending", __func__);
+ int data_length = strlen(data);
+ protocol_->Send(type, (uint8_t*)data, data_length);
+
+ int uart_length = data_length + 1; // + 1 for data type code
+ int i;
+
+ ALOGD("%s reading", __func__);
+ for (i = 0; i < uart_length; i++) {
+ fd_set read_fds;
+ FD_ZERO(&read_fds);
+ FD_SET(fake_uart_, &read_fds);
+ TEMP_FAILURE_RETRY(select(fake_uart_ + 1, &read_fds, NULL, NULL, NULL));
+
+ char byte;
+ TEMP_FAILURE_RETRY(read(fake_uart_, &byte, 1));
+
+ EXPECT_EQ(i == 0 ? type : data[i - 1], byte);
+ }
+
+ EXPECT_EQ(i, uart_length);
+ }
+
+ void WriteAndExpectInboundAclData(char* payload) {
+ // h4 type[1] + handle[2] + size[2]
+ char preamble[5] = {HCI_PACKET_TYPE_ACL_DATA, 19, 92, 0, 0};
+ int length = strlen(payload);
+ preamble[3] = length & 0xFF;
+ preamble[4] = (length >> 8) & 0xFF;
+
+ ALOGD("%s writing", __func__);
+ TEMP_FAILURE_RETRY(write(fake_uart_, preamble, sizeof(preamble)));
+ TEMP_FAILURE_RETRY(write(fake_uart_, payload, strlen(payload)));
+
+ ALOGD("%s waiting", __func__);
+ std::mutex mutex;
+ std::condition_variable done;
+ EXPECT_CALL(acl_cb_, Call(HidlVecMatches(preamble + 1, sizeof(preamble) - 1,
+ payload)))
+ .WillOnce(Notify(&mutex, &done));
+
+ // Fail if it takes longer than 100 ms.
+ auto timeout_time =
+ std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
+ {
+ std::unique_lock<std::mutex> lock(mutex);
+ done.wait_until(lock, timeout_time);
+ }
+ }
+
+ void WriteAndExpectInboundScoData(char* payload) {
+ // h4 type[1] + handle[2] + size[1]
+ char preamble[4] = {HCI_PACKET_TYPE_SCO_DATA, 20, 17, 0};
+ preamble[3] = strlen(payload) & 0xFF;
+
+ ALOGD("%s writing", __func__);
+ TEMP_FAILURE_RETRY(write(fake_uart_, preamble, sizeof(preamble)));
+ TEMP_FAILURE_RETRY(write(fake_uart_, payload, strlen(payload)));
+
+ ALOGD("%s waiting", __func__);
+ std::mutex mutex;
+ std::condition_variable done;
+ EXPECT_CALL(sco_cb_, Call(HidlVecMatches(preamble + 1, sizeof(preamble) - 1,
+ payload)))
+ .WillOnce(Notify(&mutex, &done));
+
+ // Fail if it takes longer than 100 ms.
+ auto timeout_time =
+ std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
+ {
+ std::unique_lock<std::mutex> lock(mutex);
+ done.wait_until(lock, timeout_time);
+ }
+ }
+
+ void WriteAndExpectInboundEvent(char* payload) {
+ // h4 type[1] + event_code[1] + size[1]
+ char preamble[3] = {HCI_PACKET_TYPE_EVENT, 9, 0};
+ preamble[2] = strlen(payload) & 0xFF;
+ ALOGD("%s writing", __func__);
+ TEMP_FAILURE_RETRY(write(fake_uart_, preamble, sizeof(preamble)));
+ TEMP_FAILURE_RETRY(write(fake_uart_, payload, strlen(payload)));
+
+ ALOGD("%s waiting", __func__);
+ std::mutex mutex;
+ std::condition_variable done;
+ EXPECT_CALL(event_cb_, Call(HidlVecMatches(preamble + 1,
+ sizeof(preamble) - 1, payload)))
+ .WillOnce(Notify(&mutex, &done));
+
+ {
+ std::unique_lock<std::mutex> lock(mutex);
+ done.wait(lock);
+ }
+ }
+
+ testing::MockFunction<void(const hidl_vec<uint8_t>&)> event_cb_;
+ testing::MockFunction<void(const hidl_vec<uint8_t>&)> acl_cb_;
+ testing::MockFunction<void(const hidl_vec<uint8_t>&)> sco_cb_;
+ async::AsyncFdWatcher fd_watcher_;
+ H4Protocol* protocol_;
+ int fake_uart_;
+};
+
+// Test sending data sends correct data onto the UART
+TEST_F(H4ProtocolTest, TestSends) {
+ SendAndReadUartOutbound(HCI_PACKET_TYPE_COMMAND, sample_data1);
+ SendAndReadUartOutbound(HCI_PACKET_TYPE_ACL_DATA, sample_data2);
+ SendAndReadUartOutbound(HCI_PACKET_TYPE_SCO_DATA, sample_data3);
+}
+
+// Ensure we properly parse data coming from the UART
+TEST_F(H4ProtocolTest, TestReads) {
+ WriteAndExpectInboundAclData(acl_data);
+ WriteAndExpectInboundScoData(sco_data);
+ WriteAndExpectInboundEvent(event_data);
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/test/mct_protocol_unittest.cc b/bluetooth/1.0/default/test/mct_protocol_unittest.cc
new file mode 100644
index 0000000..0a6e9eb
--- /dev/null
+++ b/bluetooth/1.0/default/test/mct_protocol_unittest.cc
@@ -0,0 +1,197 @@
+//
+// Copyright 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#define LOG_TAG "bt_h4_unittest"
+
+#include "mct_protocol.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <condition_variable>
+#include <cstdint>
+#include <cstring>
+#include <mutex>
+#include <vector>
+
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <utils/Log.h>
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace V1_0 {
+namespace implementation {
+
+using ::testing::Eq;
+using hci::MctProtocol;
+
+static char sample_data1[100] = "A point is that which has no part.";
+static char sample_data2[100] = "A line is breadthless length.";
+static char acl_data[100] =
+ "A straight line is a line which lies evenly with the points on itself.";
+static char event_data[100] = "The edges of a surface are lines.";
+
+MATCHER_P3(HidlVecMatches, preamble, preamble_length, payload, "") {
+ size_t length = strlen(payload) + preamble_length;
+ if (length != arg.size()) {
+ return false;
+ }
+
+ if (memcmp(preamble, arg.data(), preamble_length) != 0) {
+ return false;
+ }
+
+ return memcmp(payload, arg.data() + preamble_length,
+ length - preamble_length) == 0;
+};
+
+ACTION_P2(Notify, mutex, condition) {
+ ALOGD("%s", __func__);
+ std::unique_lock<std::mutex> lock(*mutex);
+ condition->notify_one();
+}
+
+class MctProtocolTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ ALOGD("%s", __func__);
+
+ int mct_fds[CH_MAX];
+ MakeFakeUartFd(CH_CMD, mct_fds, fake_uart_);
+ MakeFakeUartFd(CH_EVT, mct_fds, fake_uart_);
+ MakeFakeUartFd(CH_ACL_IN, mct_fds, fake_uart_);
+ MakeFakeUartFd(CH_ACL_OUT, mct_fds, fake_uart_);
+
+ MctProtocol* mct_hci = new MctProtocol(mct_fds, event_cb_.AsStdFunction(),
+ acl_cb_.AsStdFunction());
+ fd_watcher_.WatchFdForNonBlockingReads(
+ mct_fds[CH_EVT], [mct_hci](int fd) { mct_hci->OnEventDataReady(fd); });
+ fd_watcher_.WatchFdForNonBlockingReads(
+ mct_fds[CH_ACL_IN], [mct_hci](int fd) { mct_hci->OnAclDataReady(fd); });
+ protocol_ = mct_hci;
+ }
+
+ void MakeFakeUartFd(int index, int* host_side, int* controller_side) {
+ int sockfd[2];
+ socketpair(AF_LOCAL, SOCK_STREAM, 0, sockfd);
+ host_side[index] = sockfd[0];
+ controller_side[index] = sockfd[1];
+ }
+
+ void TearDown() override { fd_watcher_.StopWatchingFileDescriptors(); }
+
+ void SendAndReadUartOutbound(uint8_t type, char* data, int outbound_fd) {
+ ALOGD("%s sending", __func__);
+ int data_length = strlen(data);
+ protocol_->Send(type, (uint8_t*)data, data_length);
+
+ ALOGD("%s reading", __func__);
+ int i;
+ for (i = 0; i < data_length; i++) {
+ fd_set read_fds;
+ FD_ZERO(&read_fds);
+ FD_SET(outbound_fd, &read_fds);
+ TEMP_FAILURE_RETRY(select(outbound_fd + 1, &read_fds, NULL, NULL, NULL));
+
+ char byte;
+ TEMP_FAILURE_RETRY(read(outbound_fd, &byte, 1));
+
+ EXPECT_EQ(data[i], byte);
+ }
+
+ EXPECT_EQ(i, data_length);
+ }
+
+ void WriteAndExpectInboundAclData(char* payload) {
+ // handle[2] + size[2]
+ char preamble[4] = {19, 92, 0, 0};
+ int length = strlen(payload);
+ preamble[2] = length & 0xFF;
+ preamble[3] = (length >> 8) & 0xFF;
+
+ ALOGD("%s writing", __func__);
+ TEMP_FAILURE_RETRY(
+ write(fake_uart_[CH_ACL_IN], preamble, sizeof(preamble)));
+ TEMP_FAILURE_RETRY(write(fake_uart_[CH_ACL_IN], payload, strlen(payload)));
+
+ ALOGD("%s waiting", __func__);
+ std::mutex mutex;
+ std::condition_variable done;
+ EXPECT_CALL(acl_cb_,
+ Call(HidlVecMatches(preamble, sizeof(preamble), payload)))
+ .WillOnce(Notify(&mutex, &done));
+
+ // Fail if it takes longer than 100 ms.
+ auto timeout_time =
+ std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
+ {
+ std::unique_lock<std::mutex> lock(mutex);
+ done.wait_until(lock, timeout_time);
+ }
+ }
+
+ void WriteAndExpectInboundEvent(char* payload) {
+ // event_code[1] + size[1]
+ char preamble[2] = {9, 0};
+ preamble[1] = strlen(payload) & 0xFF;
+
+ ALOGD("%s writing", __func__);
+ TEMP_FAILURE_RETRY(write(fake_uart_[CH_EVT], preamble, sizeof(preamble)));
+ TEMP_FAILURE_RETRY(write(fake_uart_[CH_EVT], payload, strlen(payload)));
+
+ ALOGD("%s waiting", __func__);
+ std::mutex mutex;
+ std::condition_variable done;
+ EXPECT_CALL(event_cb_,
+ Call(HidlVecMatches(preamble, sizeof(preamble), payload)))
+ .WillOnce(Notify(&mutex, &done));
+
+ // Fail if it takes longer than 100 ms.
+ auto timeout_time =
+ std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
+ {
+ std::unique_lock<std::mutex> lock(mutex);
+ done.wait_until(lock, timeout_time);
+ }
+ }
+
+ testing::MockFunction<void(const hidl_vec<uint8_t>&)> event_cb_;
+ testing::MockFunction<void(const hidl_vec<uint8_t>&)> acl_cb_;
+ async::AsyncFdWatcher fd_watcher_;
+ MctProtocol* protocol_;
+ int fake_uart_[CH_MAX];
+};
+
+// Test sending data sends correct data onto the UART
+TEST_F(MctProtocolTest, TestSends) {
+ SendAndReadUartOutbound(HCI_PACKET_TYPE_COMMAND, sample_data1,
+ fake_uart_[CH_CMD]);
+ SendAndReadUartOutbound(HCI_PACKET_TYPE_ACL_DATA, sample_data2,
+ fake_uart_[CH_ACL_OUT]);
+}
+
+// Ensure we properly parse data coming from the UART
+TEST_F(MctProtocolTest, TestReads) {
+ WriteAndExpectInboundAclData(acl_data);
+ WriteAndExpectInboundEvent(event_data);
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index 3878129..57ea1a3 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -27,6 +27,8 @@
#include <fcntl.h>
#include "bluetooth_address.h"
+#include "h4_protocol.h"
+#include "mct_protocol.h"
static const char* VENDOR_LIBRARY_NAME = "libbt-vendor.so";
static const char* VENDOR_LIBRARY_SYMBOL_NAME =
@@ -64,30 +66,6 @@
return packet;
}
-size_t write_safely(int fd, const uint8_t* data, size_t length) {
- size_t transmitted_length = 0;
- while (length > 0) {
- ssize_t ret =
- TEMP_FAILURE_RETRY(write(fd, data + transmitted_length, length));
-
- if (ret == -1) {
- if (errno == EAGAIN) continue;
- ALOGE("%s error writing to UART (%s)", __func__, strerror(errno));
- break;
-
- } else if (ret == 0) {
- // Nothing written :(
- ALOGE("%s zero bytes written - something went wrong...", __func__);
- break;
- }
-
- transmitted_length += ret;
- length -= ret;
- }
-
- return transmitted_length;
-}
-
bool internal_command_event_match(const hidl_vec<uint8_t>& packet) {
uint8_t event_code = packet[0];
if (event_code != HCI_COMMAND_COMPLETE_EVENT) {
@@ -185,10 +163,12 @@
bool VendorInterface::Initialize(
InitializeCompleteCallback initialize_complete_cb,
- PacketReadCallback packet_read_cb) {
+ PacketReadCallback event_cb, PacketReadCallback acl_cb,
+ PacketReadCallback sco_cb) {
assert(!g_vendor_interface);
g_vendor_interface = new VendorInterface();
- return g_vendor_interface->Open(initialize_complete_cb, packet_read_cb);
+ return g_vendor_interface->Open(initialize_complete_cb, event_cb, acl_cb,
+ sco_cb);
}
void VendorInterface::Shutdown() {
@@ -201,9 +181,10 @@
VendorInterface* VendorInterface::get() { return g_vendor_interface; }
bool VendorInterface::Open(InitializeCompleteCallback initialize_complete_cb,
- PacketReadCallback packet_read_cb) {
+ PacketReadCallback event_cb,
+ PacketReadCallback acl_cb,
+ PacketReadCallback sco_cb) {
initialize_complete_cb_ = initialize_complete_cb;
- packet_read_cb_ = packet_read_cb;
// Initialize vendor interface
@@ -234,35 +215,46 @@
ALOGD("%s vendor library loaded", __func__);
- // Power cycle chip
+ // Power on the controller
- int power_state = BT_VND_PWR_OFF;
- lib_interface_->op(BT_VND_OP_POWER_CTRL, &power_state);
- power_state = BT_VND_PWR_ON;
+ int power_state = BT_VND_PWR_ON;
lib_interface_->op(BT_VND_OP_POWER_CTRL, &power_state);
- // Get the UART socket
+ // Get the UART socket(s)
int fd_list[CH_MAX] = {0};
int fd_count = lib_interface_->op(BT_VND_OP_USERIAL_OPEN, &fd_list);
- if (fd_count != 1) {
- ALOGE("%s fd count %d != 1; we can't handle this currently...", __func__,
- fd_count);
- return false;
+ for (int i = 0; i < fd_count; i++) {
+ if (fd_list[i] == INVALID_FD) {
+ ALOGE("%s: fd %d is invalid!", __func__, fd_list[i]);
+ return false;
+ }
}
- uart_fd_ = fd_list[0];
- if (uart_fd_ == INVALID_FD) {
- ALOGE("%s unable to determine UART fd", __func__);
- return false;
+ event_cb_ = event_cb;
+ PacketReadCallback intercept_events = [this](const hidl_vec<uint8_t>& event) {
+ HandleIncomingEvent(event);
+ };
+
+ if (fd_count == 1) {
+ hci::H4Protocol* h4_hci =
+ new hci::H4Protocol(fd_list[0], intercept_events, acl_cb, sco_cb);
+ fd_watcher_.WatchFdForNonBlockingReads(
+ fd_list[0], [h4_hci](int fd) { h4_hci->OnDataReady(fd); });
+ hci_ = h4_hci;
+ } else {
+ hci::MctProtocol* mct_hci =
+ new hci::MctProtocol(fd_list, intercept_events, acl_cb);
+ fd_watcher_.WatchFdForNonBlockingReads(
+ fd_list[CH_EVT], [mct_hci](int fd) { mct_hci->OnEventDataReady(fd); });
+ if (fd_count >= CH_ACL_IN)
+ fd_watcher_.WatchFdForNonBlockingReads(
+ fd_list[CH_ACL_IN],
+ [mct_hci](int fd) { mct_hci->OnAclDataReady(fd); });
+ hci_ = mct_hci;
}
- ALOGI("%s UART fd: %d", __func__, uart_fd_);
-
- fd_watcher_.WatchFdForNonBlockingReads(uart_fd_,
- [this](int fd) { hci_packetizer_.OnDataReady(fd); });
-
// Initially, the power management is off.
lpm_wake_deasserted = true;
@@ -274,14 +266,23 @@
}
void VendorInterface::Close() {
- fd_watcher_.StopWatchingFileDescriptor();
-
+ // These callbacks may send HCI events (vendor-dependent), so make sure to
+ // StopWatching the file descriptor after this.
if (lib_interface_ != nullptr) {
bt_vendor_lpm_mode_t mode = BT_VND_LPM_DISABLE;
lib_interface_->op(BT_VND_OP_LPM_SET_MODE, &mode);
+ }
+ fd_watcher_.StopWatchingFileDescriptors();
+
+ if (hci_ != nullptr) {
+ delete hci_;
+ hci_ = nullptr;
+ }
+
+ if (lib_interface_ != nullptr) {
lib_interface_->op(BT_VND_OP_USERIAL_CLOSE, nullptr);
- uart_fd_ = INVALID_FD;
+
int power_state = BT_VND_PWR_OFF;
lib_interface_->op(BT_VND_OP_POWER_CTRL, &power_state);
}
@@ -298,8 +299,6 @@
}
size_t VendorInterface::Send(uint8_t type, const uint8_t* data, size_t length) {
- if (uart_fd_ == INVALID_FD) return 0;
-
recent_activity_flag = true;
if (lpm_wake_deasserted == true) {
@@ -313,11 +312,7 @@
ALOGV("%s: Sent wake before (%02x)", __func__, data[0] | (data[1] << 8));
}
- int rv = write_safely(uart_fd_, &type, sizeof(type));
- if (rv == sizeof(type))
- rv = write_safely(uart_fd_, data, length);
-
- return rv;
+ return hci_->Send(type, data, length);
}
void VendorInterface::OnFirmwareConfigured(uint8_t result) {
@@ -357,26 +352,18 @@
recent_activity_flag = false;
}
-void VendorInterface::OnPacketReady() {
- VendorInterface::get()->HandleIncomingPacket();
-}
+void VendorInterface::HandleIncomingEvent(const hidl_vec<uint8_t>& hci_packet) {
+ if (internal_command.cb != nullptr &&
+ internal_command_event_match(hci_packet)) {
+ HC_BT_HDR* bt_hdr = WrapPacketAndCopy(HCI_PACKET_TYPE_EVENT, hci_packet);
-void VendorInterface::HandleIncomingPacket() {
- HciPacketType hci_packet_type = hci_packetizer_.GetPacketType();
- hidl_vec<uint8_t> hci_packet = hci_packetizer_.GetPacket();
- if (internal_command.cb != nullptr &&
- hci_packet_type == HCI_PACKET_TYPE_EVENT &&
- internal_command_event_match(hci_packet)) {
- HC_BT_HDR* bt_hdr =
- WrapPacketAndCopy(HCI_PACKET_TYPE_EVENT, hci_packet);
-
- // The callbacks can send new commands, so don't zero after calling.
- tINT_CMD_CBACK saved_cb = internal_command.cb;
- internal_command.cb = nullptr;
- saved_cb(bt_hdr);
- } else {
- packet_read_cb_(hci_packet_type, hci_packet);
- }
+ // The callbacks can send new commands, so don't zero after calling.
+ tINT_CMD_CBACK saved_cb = internal_command.cb;
+ internal_command.cb = nullptr;
+ saved_cb(bt_hdr);
+ } else {
+ event_cb_(hci_packet);
+ }
}
} // namespace implementation
diff --git a/bluetooth/1.0/default/vendor_interface.h b/bluetooth/1.0/default/vendor_interface.h
index 8115640..a401ee6 100644
--- a/bluetooth/1.0/default/vendor_interface.h
+++ b/bluetooth/1.0/default/vendor_interface.h
@@ -20,7 +20,7 @@
#include "async_fd_watcher.h"
#include "bt_vendor_lib.h"
-#include "hci_packetizer.h"
+#include "hci_protocol.h"
namespace android {
namespace hardware {
@@ -30,15 +30,15 @@
using ::android::hardware::hidl_vec;
using InitializeCompleteCallback = std::function<void(bool success)>;
-using PacketReadCallback =
- std::function<void(HciPacketType, const hidl_vec<uint8_t> &)>;
+using PacketReadCallback = std::function<void(const hidl_vec<uint8_t>&)>;
class FirmwareStartupTimer;
class VendorInterface {
public:
static bool Initialize(InitializeCompleteCallback initialize_complete_cb,
- PacketReadCallback packet_read_cb);
+ PacketReadCallback event_cb, PacketReadCallback acl_cb,
+ PacketReadCallback sco_cb);
static void Shutdown();
static VendorInterface *get();
@@ -46,27 +46,25 @@
void OnFirmwareConfigured(uint8_t result);
- static void OnPacketReady();
-
private:
virtual ~VendorInterface() = default;
bool Open(InitializeCompleteCallback initialize_complete_cb,
- PacketReadCallback packet_read_cb);
+ PacketReadCallback event_cb, PacketReadCallback acl_cb,
+ PacketReadCallback sco_cb);
void Close();
void OnTimeout();
- void HandleIncomingPacket();
+ void HandleIncomingEvent(const hidl_vec<uint8_t>& hci_packet);
void *lib_handle_;
bt_vendor_interface_t *lib_interface_;
async::AsyncFdWatcher fd_watcher_;
- int uart_fd_;
- PacketReadCallback packet_read_cb_;
InitializeCompleteCallback initialize_complete_cb_;
+ hci::HciProtocol* hci_;
- hci::HciPacketizer hci_packetizer_ {VendorInterface::OnPacketReady};
+ PacketReadCallback event_cb_;
FirmwareStartupTimer *firmware_startup_timer_;
};
diff --git a/bluetooth/1.0/vts/functional/Android.bp b/bluetooth/1.0/vts/functional/Android.bp
index a57a55a..d2e6553 100644
--- a/bluetooth/1.0/vts/functional/Android.bp
+++ b/bluetooth/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalBluetoothV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalBluetoothV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.bluetooth@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index c8c7cb5..9a4efae 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -23,7 +23,7 @@
#include <hardware/bluetooth.h>
#include <utils/Log.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <condition_variable>
#include <mutex>
#include <queue>
@@ -117,11 +117,11 @@
};
// The main test class for Bluetooth HIDL HAL.
-class BluetoothHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class BluetoothHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
// currently test passthrough mode only
- bluetooth = ::testing::VtsHalHidlTargetBaseTest::getService<IBluetoothHci>();
+ bluetooth = ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothHci>();
ASSERT_NE(bluetooth, nullptr);
ALOGI("%s: getService() for bluetooth is %s", __func__,
bluetooth->isRemote() ? "remote" : "local");
diff --git a/boot/1.0/vts/functional/Android.bp b/boot/1.0/vts/functional/Android.bp
index 7643e1d..5b14f54 100644
--- a/boot/1.0/vts/functional/Android.bp
+++ b/boot/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalBootV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalBootV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -26,7 +27,7 @@
"libutils",
"android.hardware.boot@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
index 49eefb1..9789ee6 100644
--- a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
+++ b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
@@ -21,7 +21,7 @@
#include <android/hardware/boot/1.0/IBootControl.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
using ::android::hardware::boot::V1_0::IBootControl;
using ::android::hardware::boot::V1_0::CommandResult;
@@ -32,10 +32,10 @@
using ::android::sp;
// The main test class for the Boot HIDL HAL.
-class BootHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class BootHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- boot = ::testing::VtsHalHidlTargetBaseTest::getService<IBootControl>();
+ boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>();
ASSERT_NE(boot, nullptr);
}
diff --git a/broadcastradio/1.0/vts/functional/Android.bp b/broadcastradio/1.0/vts/functional/Android.bp
index 25a6e22..cf52f49 100644
--- a/broadcastradio/1.0/vts/functional/Android.bp
+++ b/broadcastradio/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalBroadcastradioV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalBroadcastradioV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.broadcastradio@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
index 0e5f1fb..74911f0 100644
--- a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
+++ b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "BroadcastRadioHidlHalTest"
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <cutils/native_handle.h>
#include <cutils/properties.h>
@@ -42,6 +42,7 @@
using ::android::hardware::broadcastradio::V1_0::Result;
using ::android::hardware::broadcastradio::V1_0::Class;
using ::android::hardware::broadcastradio::V1_0::Properties;
+using ::android::hardware::broadcastradio::V1_0::Band;
using ::android::hardware::broadcastradio::V1_0::BandConfig;
using ::android::hardware::broadcastradio::V1_0::Direction;
using ::android::hardware::broadcastradio::V1_0::ProgramInfo;
@@ -50,11 +51,11 @@
// The main test class for Broadcast Radio HIDL HAL.
-class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
virtual void SetUp() override {
sp<IBroadcastRadioFactory> factory =
- ::testing::VtsHalHidlTargetBaseTest::getService<IBroadcastRadioFactory>();
+ ::testing::VtsHalHidlTargetTestBase::getService<IBroadcastRadioFactory>();
if (factory != 0) {
factory->connectModule(Class::AM_FM,
[&](Result retval, const ::android::sp<IBroadcastRadio>& result) {
@@ -83,15 +84,15 @@
return Void();
}
- virtual Return<void> configChange(Result result, const BandConfig& config __unused) {
+ virtual Return<void> configChange(Result result, const BandConfig& config) {
ALOGI("%s result %d", __FUNCTION__, result);
- mParentTest->onResultCallback(result);
+ mParentTest->onConfigChangeCallback(result, config);
return Void();
}
- virtual Return<void> tuneComplete(Result result, const ProgramInfo& info __unused) {
+ virtual Return<void> tuneComplete(Result result, const ProgramInfo& info) {
ALOGI("%s result %d", __FUNCTION__, result);
- mParentTest->onResultCallback(result);
+ mParentTest->onTuneCompleteCallback(result, info);
return Void();
}
@@ -146,11 +147,22 @@
}
/**
- * Method called by MyCallback when a callback with status is received
+ * Method called by MyCallback when configChange() callback is received.
*/
- void onResultCallback(Result result) {
+ void onConfigChangeCallback(Result result, const BandConfig& config) {
Mutex::Autolock _l(mLock);
mResultCallbackData = result;
+ mBandConfigCallbackData = config;
+ onCallback_l();
+ }
+
+ /**
+ * Method called by MyCallback when tuneComplete() callback is received.
+ */
+ void onTuneCompleteCallback(Result result, const ProgramInfo& info) {
+ Mutex::Autolock _l(mLock);
+ mResultCallbackData = result;
+ mProgramInfoCallbackData = info;
onCallback_l();
}
@@ -209,6 +221,8 @@
bool mCallbackCalled;
bool mBoolCallbackData;
Result mResultCallbackData;
+ ProgramInfo mProgramInfoCallbackData;
+ BandConfig mBandConfigCallbackData;
bool mHwFailure;
};
@@ -219,6 +233,35 @@
virtual void TearDown() {}
};
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace V1_0 {
+
+/**
+ * Compares two BandConfig objects for testing purposes.
+ */
+static bool operator==(const BandConfig& l, const BandConfig& r) {
+ if (l.type != r.type) return false;
+ if (l.antennaConnected != r.antennaConnected) return false;
+ if (l.lowerLimit != r.lowerLimit) return false;
+ if (l.upperLimit != r.upperLimit) return false;
+ if (l.spacings != r.spacings) return false;
+ if (l.type == Band::AM || l.type == Band::AM_HD) {
+ return l.ext.am == r.ext.am;
+ } else if (l.type == Band::FM || l.type == Band::FM_HD) {
+ return l.ext.fm == r.ext.fm;
+ } else {
+ // unsupported type
+ return false;
+ }
+}
+
+} // V1_0
+} // broadcastradio
+} // hardware
+} // android
+
bool BroadcastRadioHidlTest::getProperties()
{
if (mHalProperties.bands.size() == 0) {
@@ -351,11 +394,12 @@
ASSERT_EQ(true, openTuner());
// test setConfiguration
mCallbackCalled = false;
- Return<Result> hidlResult = mTuner->setConfiguration(mHalProperties.bands[0]);
+ Return<Result> hidlResult = mTuner->setConfiguration(mHalProperties.bands[1]);
EXPECT_TRUE(hidlResult.isOk());
EXPECT_EQ(Result::OK, hidlResult);
EXPECT_EQ(true, waitForCallback(kConfigCallbacktimeoutNs));
EXPECT_EQ(Result::OK, mResultCallbackData);
+ EXPECT_EQ(mHalProperties.bands[1], mBandConfigCallbackData);
// test getConfiguration
BandConfig halConfig;
@@ -369,7 +413,39 @@
});
EXPECT_TRUE(hidlReturn.isOk());
EXPECT_EQ(Result::OK, halResult);
- EXPECT_EQ(mHalProperties.bands[0].type, halConfig.type);
+ EXPECT_EQ(mHalProperties.bands[1], halConfig);
+}
+
+/**
+ * Test ITuner::setConfiguration() with invalid arguments.
+ *
+ * Verifies that:
+ * - the methods returns INVALID_ARGUMENTS on invalid arguments
+ * - the method recovers and succeeds after passing correct arguments
+ */
+TEST_F(BroadcastRadioHidlTest, SetConfigurationFails) {
+ ASSERT_EQ(true, openTuner());
+
+ // Let's define a config that's bad for sure.
+ BandConfig badConfig = {};
+ badConfig.type = Band::FM;
+ badConfig.lowerLimit = 0xFFFFFFFF;
+ badConfig.upperLimit = 0;
+ badConfig.spacings = (std::vector<uint32_t>){ 0 };
+
+ // Test setConfiguration failing on bad data.
+ mCallbackCalled = false;
+ auto setResult = mTuner->setConfiguration(badConfig);
+ EXPECT_TRUE(setResult.isOk());
+ EXPECT_EQ(Result::INVALID_ARGUMENTS, setResult);
+
+ // Test setConfiguration recovering after passing good data.
+ mCallbackCalled = false;
+ setResult = mTuner->setConfiguration(mHalProperties.bands[0]);
+ EXPECT_TRUE(setResult.isOk());
+ EXPECT_EQ(Result::OK, setResult);
+ EXPECT_EQ(true, waitForCallback(kConfigCallbacktimeoutNs));
+ EXPECT_EQ(Result::OK, mResultCallbackData);
}
/**
@@ -453,6 +529,7 @@
EXPECT_TRUE(hidlResult.isOk());
EXPECT_EQ(Result::OK, hidlResult);
EXPECT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs));
+ EXPECT_EQ(channel, mProgramInfoCallbackData.channel);
// test getProgramInformation
ProgramInfo halInfo;
@@ -481,6 +558,42 @@
EXPECT_EQ(Result::OK, hidlResult);
}
+/**
+ * Test ITuner::tune failing when channel out of the range is provided.
+ *
+ * Verifies that:
+ * - the method returns INVALID_ARGUMENTS when applicable
+ * - the method recovers and succeeds after passing correct arguments
+ */
+TEST_F(BroadcastRadioHidlTest, TuneFailsOutOfBounds) {
+ ASSERT_TRUE(openTuner());
+ ASSERT_TRUE(checkAntenna());
+
+ // get current channel bounds
+ BandConfig halConfig;
+ Result halResult;
+ auto configResult = mTuner->getConfiguration([&](Result result, const BandConfig& config) {
+ halResult = result;
+ halConfig = config;
+ });
+ ASSERT_TRUE(configResult.isOk());
+ ASSERT_EQ(Result::OK, halResult);
+
+ // try to tune slightly above the limit and expect to fail
+ auto badChannel = halConfig.upperLimit + halConfig.spacings[0];
+ auto tuneResult = mTuner->tune(badChannel, 0);
+ EXPECT_TRUE(tuneResult.isOk());
+ EXPECT_EQ(Result::INVALID_ARGUMENTS, tuneResult);
+ EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs));
+
+ // tuning exactly at the limit should succeed
+ auto goodChannel = halConfig.upperLimit;
+ tuneResult = mTuner->tune(goodChannel, 0);
+ EXPECT_TRUE(tuneResult.isOk());
+ EXPECT_EQ(Result::OK, tuneResult);
+ EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs));
+}
+
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(new BroadcastRadioHidlEnvironment);
diff --git a/broadcastradio/1.1/ITuner.hal b/broadcastradio/1.1/ITuner.hal
index 72b2847..4f34019 100644
--- a/broadcastradio/1.1/ITuner.hal
+++ b/broadcastradio/1.1/ITuner.hal
@@ -19,11 +19,32 @@
import @1.0::ITuner;
interface ITuner extends @1.0::ITuner {
- /*
+
+ /**
* Retrieve current station information.
* @return result OK if scan successfully started
* NOT_INITIALIZED if another error occurs
* @return info Current program information.
*/
getProgramInformation_1_1() generates(Result result, ProgramInfo info);
+
+ /**
+ * Retrieve station list.
+ *
+ * This call does not trigger actual scan, but operates on the list cached
+ * internally at the driver level.
+ *
+ * @param filter vendor-specific filter for the stations to be retrieved.
+ * An empty string MUST result in full list.
+ * Client application MUST verify vendor/product name
+ * before setting this parameter to anything else.
+ * @return result OK if the list was successfully retrieved.
+ * NOT_READY if the scan is in progress.
+ * NOT_STARTED if the scan has not been started.
+ * NOT_INITIALIZED if any other error occurs.
+ * @return programList List of stations available for user.
+ */
+ getProgramList(string filter)
+ generates(ProgramListResult result, vec<ProgramInfo> programList);
+
};
diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.1/default/Tuner.cpp
index 6258569..b4eb184 100644
--- a/broadcastradio/1.1/default/Tuner.cpp
+++ b/broadcastradio/1.1/default/Tuner.cpp
@@ -200,6 +200,13 @@
return Void();
}
+Return<void> Tuner::getProgramList(const hidl_string& filter __unused, getProgramList_cb _hidl_cb) {
+ hidl_vec<ProgramInfo> pList;
+ // TODO(b/34054813): do the actual implementation.
+ _hidl_cb(ProgramListResult::NOT_INITIALIZED, pList);
+ return Void();
+}
+
} // namespace implementation
} // namespace V1_1
} // namespace broadcastradio
diff --git a/broadcastradio/1.1/default/Tuner.h b/broadcastradio/1.1/default/Tuner.h
index 1f3dc7f..fcf053a 100644
--- a/broadcastradio/1.1/default/Tuner.h
+++ b/broadcastradio/1.1/default/Tuner.h
@@ -42,6 +42,7 @@
Return<Result> cancel() override;
Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
+ Return<void> getProgramList(const hidl_string& filter, getProgramList_cb _hidl_cb) override;
static void callback(radio_hal_event_t *halEvent, void *cookie);
void onCallback(radio_hal_event_t *halEvent);
diff --git a/broadcastradio/1.1/default/Utils.cpp b/broadcastradio/1.1/default/Utils.cpp
index 6d4777d..e21344e 100644
--- a/broadcastradio/1.1/default/Utils.cpp
+++ b/broadcastradio/1.1/default/Utils.cpp
@@ -236,7 +236,7 @@
info_1_0.signalStrength = halInfo->signal_strength;
convertMetaDataFromHal(info_1_0.metadata, halInfo->metadata);
// TODO(b/34348946): add support for HAL 1.1 fields
- info_1_1.digitalStatus = DigitalStatus::INVALID;
+ info_1_1.flags = 0;
}
//static
diff --git a/broadcastradio/1.1/types.hal b/broadcastradio/1.1/types.hal
index 38f4b39..b6f72d2 100644
--- a/broadcastradio/1.1/types.hal
+++ b/broadcastradio/1.1/types.hal
@@ -1,4 +1,4 @@
-/*
+/**
* Copyright 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,18 +20,44 @@
typedef @1.0::Result Result;
-enum DigitalStatus : int32_t {
- INVALID = -1,
- UNAVAILABLE = 1, // current program is analog-only
- AVAILABLE = 2, // digital mode is available, but disabled
- BUFFERING = 3, // digital mode is available and buffering has started
- ACTIVE = 4, // digital mode is currently playing
+enum ProgramListResult : Result {
+ NOT_READY,
+ NOT_STARTED,
+ TEMPORARILY_UNAVAILABLE,
};
-/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
+/**
+ * Extra flags for program information.
+ */
+enum ProgramInfoFlags : uint32_t {
+ /**
+ * Set when the program is currently playing live stream.
+ * This may result in a slightly altered reception parameters,
+ * usually targetted at reduced latency.
+ */
+ LIVE = 1 << 0,
+
+ /**
+ * Radio stream is not playing, ie. due to bad reception conditions or
+ * buffering. In this state volume knob MAY be disabled to prevent user
+ * increasing volume too much.
+ */
+ MUTED = 1 << 1,
+};
+
+/**
+ * Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
* Contains information on currently tuned channel.
*/
struct ProgramInfo {
@1.0::ProgramInfo base;
- DigitalStatus digitalStatus;
+ bitfield<ProgramInfoFlags> flags;
+
+ /**
+ * Vendors are allowed to define their own set of flags and store it in this
+ * field. They MUST verify vendor/product name from Properties struct
+ * (IBroadcastRadio::getProperties) before doing any interpretation
+ * of such values.
+ */
+ uint32_t vendorFlags;
};
diff --git a/broadcastradio/1.1/vts/functional/Android.bp b/broadcastradio/1.1/vts/functional/Android.bp
index 6d66f14..a4c0849 100644
--- a/broadcastradio/1.1/vts/functional/Android.bp
+++ b/broadcastradio/1.1/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalBroadcastradioV1_1TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalBroadcastradioV1_1TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -28,7 +29,7 @@
"android.hardware.broadcastradio@1.0",
"android.hardware.broadcastradio@1.1",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
index b980d31..aad01f6 100644
--- a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
+++ b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "BroadcastRadioHidlHalTest"
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <cutils/native_handle.h>
#include <cutils/properties.h>
@@ -52,10 +52,10 @@
// The main test class for Broadcast Radio HIDL HAL.
-class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
virtual void SetUp() override {
- auto factory = ::testing::VtsHalHidlTargetBaseTest::getService<IBroadcastRadioFactory>();
+ auto factory = ::testing::VtsHalHidlTargetTestBase::getService<IBroadcastRadioFactory>();
if (factory != 0) {
factory->connectModule(Class::AM_FM,
[&](Result retval, const ::android::sp<IBroadcastRadio>& result) {
diff --git a/camera/common/1.0/default/Android.bp b/camera/common/1.0/default/Android.bp
index 9ec266c..6437480 100644
--- a/camera/common/1.0/default/Android.bp
+++ b/camera/common/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_static {
name: "android.hardware.camera.common@1.0-helper",
+ defaults: ["hidl_defaults"],
srcs: [
"CameraModule.cpp",
"CameraMetadata.cpp",
diff --git a/camera/device/1.0/ICameraDevice.hal b/camera/device/1.0/ICameraDevice.hal
index 4a3a406..52d6cf0 100644
--- a/camera/device/1.0/ICameraDevice.hal
+++ b/camera/device/1.0/ICameraDevice.hal
@@ -125,8 +125,7 @@
* the torch on through the device interface.
* OPERATION_NOT_SUPPORTED:
* This camera device does not have a flash unit. This must
- * be returned if and only if android.flash.info.available is
- * false.
+ * be returned if and only if parameter key flash-mode-values is not present.
* CAMERA_DISCONNECTED:
* An external camera device has been disconnected, and is no longer
* available. This camera device interface is now stale, and a new
diff --git a/camera/device/1.0/default/Android.bp b/camera/device/1.0/default/Android.bp
index 1663787..5688fc1 100644
--- a/camera/device/1.0/default/Android.bp
+++ b/camera/device/1.0/default/Android.bp
@@ -1,5 +1,7 @@
cc_library_shared {
name: "camera.device@1.0-impl",
+ defaults: ["hidl_defaults"],
+ proprietary: true,
srcs: [
"CameraDevice.cpp",
],
diff --git a/camera/device/3.2/default/Android.bp b/camera/device/3.2/default/Android.bp
index f638f6f..e0dc5ff 100644
--- a/camera/device/3.2/default/Android.bp
+++ b/camera/device/3.2/default/Android.bp
@@ -1,5 +1,7 @@
cc_library_shared {
name: "camera.device@3.2-impl",
+ defaults: ["hidl_defaults"],
+ proprietary: true,
srcs: ["CameraDevice.cpp",
"CameraDeviceSession.cpp",
"convert.cpp"],
diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp
index 3c3c078..ae5d576 100644
--- a/camera/device/3.2/default/CameraDeviceSession.cpp
+++ b/camera/device/3.2/default/CameraDeviceSession.cpp
@@ -437,7 +437,6 @@
bool hasInputBuf = (hal_result->input_buffer != nullptr);
size_t numOutputBufs = hal_result->num_output_buffers;
size_t numBufs = numOutputBufs + (hasInputBuf ? 1 : 0);
- Status status = Status::OK;
{
Mutex::Autolock _l(d->mInflightLock);
if (hasInputBuf) {
diff --git a/camera/device/3.2/types.hal b/camera/device/3.2/types.hal
index c07a670..fe1edbf 100644
--- a/camera/device/3.2/types.hal
+++ b/camera/device/3.2/types.hal
@@ -161,8 +161,21 @@
* CONSTRAINED_HIGH_SPEED_VIDEO in the android.request.availableCapabilities
* static metadata.
*/
- CONSTRAINED_HIGH_SPEED_MODE = 1
+ CONSTRAINED_HIGH_SPEED_MODE = 1,
+ /**
+ * A set of vendor-defined operating modes, for custom default camera
+ * application features that can't be implemented in the fully flexible fashion
+ * required for NORMAL_MODE.
+ */
+ VENDOR_MODE_0 = 0x8000,
+ VENDOR_MODE_1,
+ VENDOR_MODE_2,
+ VENDOR_MODE_3,
+ VENDOR_MODE_4,
+ VENDOR_MODE_5,
+ VENDOR_MODE_6,
+ VENDOR_MODE_7
};
/**
diff --git a/camera/provider/2.4/default/Android.bp b/camera/provider/2.4/default/Android.bp
index a6febec..42dec4d 100644
--- a/camera/provider/2.4/default/Android.bp
+++ b/camera/provider/2.4/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.camera.provider@2.4-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["CameraProvider.cpp"],
@@ -25,6 +26,7 @@
cc_binary {
name: "android.hardware.camera.provider@2.4-service",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["service.cpp"],
diff --git a/camera/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp
index f478152..f1215b8 100644
--- a/camera/provider/2.4/vts/functional/Android.bp
+++ b/camera/provider/2.4/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalCameraProviderV2_4TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalCameraProviderV2_4TargetTest.cpp"],
shared_libs: [
"liblog",
@@ -28,7 +29,7 @@
"libcamera_metadata",
"libui"
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 19bc899..ce195f8 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -19,7 +19,7 @@
#include <android/hardware/camera/device/3.2/ICameraDevice.h>
#include <android/log.h>
#include <ui/GraphicBuffer.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <regex>
#include "system/camera_metadata.h"
#include <hardware/gralloc.h>
@@ -131,7 +131,7 @@
void CameraHidlEnvironment::SetUp() {
// TODO: test the binderized mode
- mProvider = ::testing::VtsHalHidlTargetBaseTest::getService<ICameraProvider>(CAMERA_PASSTHROUGH_SERVICE_NAME);
+ mProvider = ::testing::VtsHalHidlTargetTestBase::getService<ICameraProvider>(CAMERA_PASSTHROUGH_SERVICE_NAME);
// TODO: handle the device doesn't have any camera case
ALOGI_IF(mProvider, "provider is not nullptr, %p", mProvider.get());
ASSERT_NE(mProvider, nullptr);
@@ -142,7 +142,7 @@
}
// The main test class for camera HIDL HAL.
-class CameraHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class CameraHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {}
virtual void TearDown() override {}
@@ -810,7 +810,7 @@
int32_t streamId = 0;
for (auto &inputIter : inputOutputMap) {
- AvailableStream input, output;
+ AvailableStream input;
ASSERT_EQ(Status::OK,
findLargestSize(inputStreams, inputIter.inputFormat, input));
ASSERT_NE(0u, inputStreams.size());
diff --git a/configstore/1.0/ISurfaceFlingerConfigs.hal b/configstore/1.0/ISurfaceFlingerConfigs.hal
index 4403a90..f9a49ce 100644
--- a/configstore/1.0/ISurfaceFlingerConfigs.hal
+++ b/configstore/1.0/ISurfaceFlingerConfigs.hal
@@ -16,6 +16,58 @@
package android.hardware.configstore@1.0;
interface ISurfaceFlingerConfigs {
+ /*
+ * The following two methods define (respectively):
+ *
+ * - The phase offset between hardware vsync and when apps are woken up by the
+ * Choreographer callback
+ * - The phase offset between hardware vsync and when SurfaceFlinger wakes up
+ * to consume input
+ *
+ * Their values may be tuned to trade off between display pipeline latency (both
+ * overall latency and the lengths of the app --> SF and SF --> display phases)
+ * and frame delivery jitter (which typically manifests as "jank" or "jerkiness"
+ * while interacting with the device). The default values must produce a
+ * relatively low amount of jitter at the expense of roughly two frames of
+ * app --> display latency, and unless significant testing is performed to avoid
+ * increased display jitter (both manual investigation using systrace [1] and
+ * automated testing using dumpsys gfxinfo [2] are recommended), they should not
+ * be modified.
+ *
+ * [1] https://developer.android.com/studio/profile/systrace.html
+ * [2] https://developer.android.com/training/testing/performance.html
+ */
vsyncEventPhaseOffsetNs() generates (OptionalInt64 value);
+ vsyncSfEventPhaseOffsetNs() generates (OptionalInt64 value);
+
useTripleFramebuffer() generates (OptionalBool value);
+
+ /*
+ * Instruct the Render Engine to use EGL_IMG_context_priority hint if
+ * availabe.
+ */
+ useContextPriority() generates(OptionalBool value);
+
+ /*
+ * hasWideColorDisplay indicates that the device has
+ * or can support a wide-color display, e.g. color space
+ * greater than sRGB. Typical display may have same
+ * color primaries as DCI-P3.
+ * Indicate support for this feature by setting
+ * TARGET_HAS_WIDE_COLOR_DISPLAY to true in BoardConfig.mk
+ * This also means that the device is color managed.
+ * A color managed device will use the appropriate
+ * display mode depending on the content on the screen.
+ * Default is sRGB.
+ */
+ hasWideColorDisplay() generates (OptionalBool value);
+
+ /*
+ * hwHdrDisplay indicates that the device has
+ * or can support an HDR (High Dynamic Range) display.
+ * Typically an HDR display is also wide-color.
+ * Indicate support for this feature by setting
+ * TARGET_HAS_HDR_DISPLAY to true in BoardConfig.mk
+ */
+ hasHDRDisplay() generates (OptionalBool value);
};
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.cpp b/configstore/1.0/default/SurfaceFlingerConfigs.cpp
index 5d62b15..035479c 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.cpp
+++ b/configstore/1.0/default/SurfaceFlingerConfigs.cpp
@@ -19,6 +19,16 @@
return Void();
}
+Return<void> SurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) {
+#ifdef SF_VSYNC_EVENT_PHASE_OFFSET_NS
+ _hidl_cb({true, SF_VSYNC_EVENT_PHASE_OFFSET_NS});
+ LOG(INFO) << "sfvsync event phase offset ns = " << SF_VSYNC_EVENT_PHASE_OFFSET_NS;
+#else
+ _hidl_cb({false, 0});
+#endif
+ return Void();
+}
+
Return<void> SurfaceFlingerConfigs::useTripleFramebuffer(useTripleFramebuffer_cb _hidl_cb) {
bool value = false;
#ifdef USE_TRIPLE_FRAMEBUFFER
@@ -29,6 +39,36 @@
return Void();
}
+Return<void> SurfaceFlingerConfigs::useContextPriority(useContextPriority_cb _hidl_cb) {
+#ifdef USE_CONTEXT_PRIORITY
+ _hidl_cb({true, USE_CONTEXT_PRIORITY});
+ LOG(INFO) << "SurfaceFlinger useContextPriority=" << USE_CONTEXT_PRIORITY;
+#else
+ _hidl_cb({false, false});
+#endif
+ return Void();
+}
+
+Return<void> SurfaceFlingerConfigs::hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) {
+ bool value = false;
+#ifdef HAS_WIDE_COLOR_DISPLAY
+ value = true;
+#endif
+ _hidl_cb({true, value});
+ LOG(INFO) << "SurfaceFlinger Display: " << (value ? "Wide Color" : "Standard Color");
+ return Void();
+}
+
+Return<void> SurfaceFlingerConfigs::hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) {
+ bool value = false;
+#ifdef HAS_HDR_DISPLAY
+ value = true;
+#endif
+ _hidl_cb({true, value});
+ LOG(INFO) << "SurfaceFlinger Display: " << (value ? "HDR" : "SDR");
+ return Void();
+}
+
// Methods from ::android::hidl::base::V1_0::IBase follow.
ISurfaceFlingerConfigs* HIDL_FETCH_ISurfaceFlingerConfigs(const char* /* name */) {
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.h b/configstore/1.0/default/SurfaceFlingerConfigs.h
index c9652fc..aa7fb8b 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.h
+++ b/configstore/1.0/default/SurfaceFlingerConfigs.h
@@ -25,7 +25,11 @@
struct SurfaceFlingerConfigs : public ISurfaceFlingerConfigs {
// Methods from ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs follow.
Return<void> vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) override;
+ Return<void> vsyncSfEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) override;
Return<void> useTripleFramebuffer(useTripleFramebuffer_cb _hidl_cb) override;
+ Return<void> useContextPriority(useContextPriority_cb _hidl_cb) override;
+ Return<void> hasWideColorDisplay(hasWideColorDisplay_cb _hidl_cb) override;
+ Return<void> hasHDRDisplay(hasHDRDisplay_cb _hidl_cb) override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
diff --git a/configstore/1.0/default/surfaceflinger.mk b/configstore/1.0/default/surfaceflinger.mk
index 5a946f4..8ee3686 100644
--- a/configstore/1.0/default/surfaceflinger.mk
+++ b/configstore/1.0/default/surfaceflinger.mk
@@ -5,6 +5,27 @@
LOCAL_CFLAGS += -DVSYNC_EVENT_PHASE_OFFSET_NS=$(VSYNC_EVENT_PHASE_OFFSET_NS)
endif
+ifneq ($(SF_VSYNC_EVENT_PHASE_OFFSET_NS),)
+ LOCAL_CFLAGS += -DSF_VSYNC_EVENT_PHASE_OFFSET_NS=$(SF_VSYNC_EVENT_PHASE_OFFSET_NS)
+endif
+
ifeq ($(NUM_FRAMEBUFFER_SURFACE_BUFFERS),3)
LOCAL_CFLAGS += -DUSE_TRIPLE_FRAMEBUFFER
endif
+
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+ LOCAL_CFLAGS += -DUSE_CONTEXT_PRIORITY=1
+endif
+
+ifeq ($(TARGET_BOARD_PLATFORM),s5pc110)
+ LOCAL_CFLAGS += -DUSE_CONTEXT_PRIORITY=1
+endif
+
+ifeq ($(TARGET_HAS_WIDE_COLOR_DISPLAY),true)
+ LOCAL_CFLAGS += -DHAS_WIDE_COLOR_DISPLAY
+endif
+
+ifeq ($(TARGET_HAS_HDR_DISPLAY),true)
+ LOCAL_CFLAGS += -DHAS_HDR_DISPLAY
+endif
+
diff --git a/configstore/utils/Android.bp b/configstore/utils/Android.bp
index 09ab5b2..aa420d1 100644
--- a/configstore/utils/Android.bp
+++ b/configstore/utils/Android.bp
@@ -16,6 +16,7 @@
cc_library_headers {
name: "android.hardware.configstore-utils",
+ defaults: ["hidl_defaults"],
export_include_dirs: ["include"],
shared_libs: [
"libhidlbase"
diff --git a/contexthub/1.0/default/Android.bp b/contexthub/1.0/default/Android.bp
index 32ab0e0..78d27cc 100644
--- a/contexthub/1.0/default/Android.bp
+++ b/contexthub/1.0/default/Android.bp
@@ -16,6 +16,7 @@
cc_library_shared {
name: "android.hardware.contexthub@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Contexthub.cpp"],
diff --git a/contexthub/1.0/vts/functional/Android.bp b/contexthub/1.0/vts/functional/Android.bp
index 8ef5f62..c35386d 100644
--- a/contexthub/1.0/vts/functional/Android.bp
+++ b/contexthub/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalContexthubV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalContexthubV1_0TargetTest.cpp"],
shared_libs: [
"liblog",
@@ -24,7 +25,7 @@
"libutils",
"android.hardware.contexthub@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp
index c5eea89..765857f 100644
--- a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp
+++ b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp
@@ -21,7 +21,7 @@
#include <android/hardware/contexthub/1.0/IContexthubCallback.h>
#include <android/hardware/contexthub/1.0/types.h>
#include <android/log.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <cinttypes>
#include <future>
@@ -42,8 +42,6 @@
using ::android::hardware::contexthub::V1_0::TransactionResult;
using ::android::sp;
-#define CONTEXTHUB_SERVICE_NAME "contexthub"
-
#define ASSERT_OK(result) ASSERT_EQ(result, Result::OK)
#define EXPECT_OK(result) EXPECT_EQ(result, Result::OK)
@@ -80,7 +78,7 @@
static std::vector<uint32_t> hubIds;
if (hubIds.size() == 0) {
- sp<IContexthub> hubApi = ::testing::VtsHalHidlTargetBaseTest::getService<IContexthub>(CONTEXTHUB_SERVICE_NAME);
+ sp<IContexthub> hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>();
if (hubApi != nullptr) {
for (ContextHub hub : getHubsSync(hubApi)) {
@@ -95,10 +93,10 @@
// Base test fixture that initializes the HAL and makes the context hub API
// handle available
-class ContexthubHidlTestBase : public ::testing::VtsHalHidlTargetBaseTest {
+class ContexthubHidlTestBase : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- hubApi = ::testing::VtsHalHidlTargetBaseTest::getService<IContexthub>(CONTEXTHUB_SERVICE_NAME);
+ hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>();
ASSERT_NE(hubApi, nullptr);
// getHubs() must be called at least once for proper initialization of the
diff --git a/drm/1.0/IDrmPlugin.hal b/drm/1.0/IDrmPlugin.hal
index 5bae22d..083b311 100644
--- a/drm/1.0/IDrmPlugin.hal
+++ b/drm/1.0/IDrmPlugin.hal
@@ -179,8 +179,9 @@
* certificate authority (CA) is an entity which issues digital certificates
* for use by other parties. It is an example of a trusted third party.
* @return status the status of the call. The status must be OK or one of
- * the following errors: BAD_VALUE if the sessionId is invalid or
- * ERROR_DRM_INVALID_STATE if the HAL is in a state where the provision
+ * the following errors: BAD_VALUE if the sessionId is invalid,
+ * ERROR_DRM_CANNOT_HANDLE if the drm scheme does not require provisioning
+ * or ERROR_DRM_INVALID_STATE if the HAL is in a state where the provision
* request cannot be generated.
* @return request if successful the opaque certificate request blob
* is returned
diff --git a/drm/1.0/default/DrmFactory.cpp b/drm/1.0/default/DrmFactory.cpp
index 92f54f1..9ec0ab7 100644
--- a/drm/1.0/default/DrmFactory.cpp
+++ b/drm/1.0/default/DrmFactory.cpp
@@ -52,7 +52,7 @@
}
Return<void> DrmFactory::createPlugin(const hidl_array<uint8_t, 16>& uuid,
- const hidl_string& appPackageName, createPlugin_cb _hidl_cb) {
+ const hidl_string& /* appPackageName */, createPlugin_cb _hidl_cb) {
for (size_t i = 0; i < loader.factoryCount(); i++) {
if (loader.getFactory(i)->isCryptoSchemeSupported(uuid.data())) {
diff --git a/evs/1.0/Android.bp b/evs/1.0/Android.bp
deleted file mode 100644
index 89bac10..0000000
--- a/evs/1.0/Android.bp
+++ /dev/null
@@ -1,83 +0,0 @@
-// This file is autogenerated by hidl-gen. Do not edit manually.
-
-filegroup {
- name: "android.hardware.evs@1.0_hal",
- srcs: [
- "types.hal",
- "IEvsCamera.hal",
- "IEvsCameraStream.hal",
- "IEvsDisplay.hal",
- "IEvsEnumerator.hal",
- ],
-}
-
-genrule {
- name: "android.hardware.evs@1.0_genc++",
- tools: ["hidl-gen"],
- cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.evs@1.0",
- srcs: [
- ":android.hardware.evs@1.0_hal",
- ],
- out: [
- "android/hardware/evs/1.0/types.cpp",
- "android/hardware/evs/1.0/EvsCameraAll.cpp",
- "android/hardware/evs/1.0/EvsCameraStreamAll.cpp",
- "android/hardware/evs/1.0/EvsDisplayAll.cpp",
- "android/hardware/evs/1.0/EvsEnumeratorAll.cpp",
- ],
-}
-
-genrule {
- name: "android.hardware.evs@1.0_genc++_headers",
- tools: ["hidl-gen"],
- cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.evs@1.0",
- srcs: [
- ":android.hardware.evs@1.0_hal",
- ],
- out: [
- "android/hardware/evs/1.0/types.h",
- "android/hardware/evs/1.0/IEvsCamera.h",
- "android/hardware/evs/1.0/IHwEvsCamera.h",
- "android/hardware/evs/1.0/BnHwEvsCamera.h",
- "android/hardware/evs/1.0/BpHwEvsCamera.h",
- "android/hardware/evs/1.0/BsEvsCamera.h",
- "android/hardware/evs/1.0/IEvsCameraStream.h",
- "android/hardware/evs/1.0/IHwEvsCameraStream.h",
- "android/hardware/evs/1.0/BnHwEvsCameraStream.h",
- "android/hardware/evs/1.0/BpHwEvsCameraStream.h",
- "android/hardware/evs/1.0/BsEvsCameraStream.h",
- "android/hardware/evs/1.0/IEvsDisplay.h",
- "android/hardware/evs/1.0/IHwEvsDisplay.h",
- "android/hardware/evs/1.0/BnHwEvsDisplay.h",
- "android/hardware/evs/1.0/BpHwEvsDisplay.h",
- "android/hardware/evs/1.0/BsEvsDisplay.h",
- "android/hardware/evs/1.0/IEvsEnumerator.h",
- "android/hardware/evs/1.0/IHwEvsEnumerator.h",
- "android/hardware/evs/1.0/BnHwEvsEnumerator.h",
- "android/hardware/evs/1.0/BpHwEvsEnumerator.h",
- "android/hardware/evs/1.0/BsEvsEnumerator.h",
- ],
-}
-
-cc_library_shared {
- name: "android.hardware.evs@1.0",
- generated_sources: ["android.hardware.evs@1.0_genc++"],
- generated_headers: ["android.hardware.evs@1.0_genc++_headers"],
- export_generated_headers: ["android.hardware.evs@1.0_genc++_headers"],
- shared_libs: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "liblog",
- "libutils",
- "libcutils",
- "android.hidl.base@1.0",
- ],
- export_shared_lib_headers: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "libutils",
- "android.hidl.base@1.0",
- ],
-}
diff --git a/evs/1.0/default/EvsCamera.h b/evs/1.0/default/EvsCamera.h
deleted file mode 100644
index 02a677c..0000000
--- a/evs/1.0/default/EvsCamera.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-#ifndef ANDROID_HARDWARE_EVS_V1_0_EVSCAMERA_H
-#define ANDROID_HARDWARE_EVS_V1_0_EVSCAMERA_H
-
-#include <android/hardware/evs/1.0/types.h>
-#include <android/hardware/evs/1.0/IEvsCamera.h>
-#include <ui/GraphicBuffer.h>
-
-#include <thread>
-
-
-namespace android {
-namespace hardware {
-namespace evs {
-namespace V1_0 {
-namespace implementation {
-
-
-class EvsCamera : public IEvsCamera {
-public:
- // Methods from ::android::hardware::evs::V1_0::IEvsCamera follow.
- Return<void> getId(getId_cb id_cb) override;
- Return<EvsResult> setMaxFramesInFlight(uint32_t bufferCount) override;
- Return<EvsResult> startVideoStream(const ::android::sp<IEvsCameraStream>& stream) override;
- Return<void> doneWithFrame(const BufferDesc& buffer) override;
- Return<void> stopVideoStream() override;
- Return<int32_t> getExtendedInfo(uint32_t opaqueIdentifier) override;
- Return<EvsResult> setExtendedInfo(uint32_t opaqueIdentifier, int32_t opaqueValue) override;
-
- // Implementation details
- EvsCamera(const char* id);
- virtual ~EvsCamera() override;
-
- const CameraDesc& getDesc() { return mDescription; };
-
- static const char kCameraName_Backup[];
- static const char kCameraName_RightTurn[];
-
-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 fillTestFrame(const BufferDesc& buff);
-
- CameraDesc mDescription = {}; // The properties of this camera
-
- std::thread mCaptureThread; // The thread we'll use to synthesize frames
-
- uint32_t mWidth = 0; // Horizontal pixel count in the buffers
- uint32_t mHeight = 0; // Vertical pixel count in the buffers
- uint32_t mFormat = 0; // Values from android_pixel_format_t [TODO: YUV? Leave opaque?]
- uint32_t mUsage = 0; // Values from from Gralloc.h
- uint32_t mStride = 0; // Bytes per line in the buffers
-
- sp<IEvsCameraStream> mStream = nullptr; // The callback used to deliver each frame
-
- 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,
- };
- StreamStateValues mStreamState;
-
- // Syncrhonization necessary to deconflict mCaptureThread from the main service thread
- std::mutex mAccessLock;
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace evs
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_EVS_V1_0_EVSCAMERA_H
diff --git a/evs/1.0/default/android.hardware.evs@1.0-service.rc b/evs/1.0/default/android.hardware.evs@1.0-service.rc
deleted file mode 100644
index bb38668..0000000
--- a/evs/1.0/default/android.hardware.evs@1.0-service.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service evs-hal-1-0 /vendor/bin/hw/android.hardware.evs@1.0-service
- class hal
- user cameraserver
- group camera
diff --git a/evs/Android.bp b/evs/Android.bp
deleted file mode 100644
index ba90f2c..0000000
--- a/evs/Android.bp
+++ /dev/null
@@ -1,5 +0,0 @@
-// This is an autogenerated file, do not edit.
-subdirs = [
- "1.0",
- "1.0/default",
-]
diff --git a/gatekeeper/1.0/vts/functional/Android.bp b/gatekeeper/1.0/vts/functional/Android.bp
index c2c32a6..70cb615 100644
--- a/gatekeeper/1.0/vts/functional/Android.bp
+++ b/gatekeeper/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalGatekeeperV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalGatekeeperV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.gatekeeper@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp b/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
index 8d6f726..391dea0 100644
--- a/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
+++ b/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
@@ -30,7 +30,7 @@
#include <android/hardware/gatekeeper/1.0/IGatekeeper.h>
#include <android/hardware/gatekeeper/1.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
@@ -76,7 +76,7 @@
}
// The main test class for Gatekeeper HIDL HAL.
-class GatekeeperHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GatekeeperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void setUid(uint32_t uid) { uid_ = uid; }
@@ -187,7 +187,7 @@
GatekeeperHidlTest() : uid_(0) {}
virtual void SetUp() override {
GatekeeperResponse rsp;
- gatekeeper_ = ::testing::VtsHalHidlTargetBaseTest::getService<IGatekeeper>();
+ gatekeeper_ = ::testing::VtsHalHidlTargetTestBase::getService<IGatekeeper>();
ASSERT_NE(nullptr, gatekeeper_.get());
doDeleteAllUsers(rsp);
}
diff --git a/gnss/1.0/default/android.hardware.gnss@1.0-service.rc b/gnss/1.0/default/android.hardware.gnss@1.0-service.rc
index cf44944..f1116f4 100644
--- a/gnss/1.0/default/android.hardware.gnss@1.0-service.rc
+++ b/gnss/1.0/default/android.hardware.gnss@1.0-service.rc
@@ -1,4 +1,7 @@
service gnss_service /vendor/bin/hw/android.hardware.gnss@1.0-service
class main
user system
- group system
+#
+# TODO:(b/35757613) - STOPSHIP - HAL cannot have direct inet access
+#
+ group system inet
diff --git a/gnss/1.0/vts/functional/Android.bp b/gnss/1.0/vts/functional/Android.bp
index 2c8a6aa..6d96059 100644
--- a/gnss/1.0/vts/functional/Android.bp
+++ b/gnss/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalGnssV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalGnssV1_0TargetTest.cpp"],
shared_libs: [
"android.hardware.gnss@1.0",
@@ -27,7 +28,7 @@
"libnativehelper",
"libutils",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
index 38c2715..8f131cf 100644
--- a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
+++ b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
@@ -18,7 +18,7 @@
#include <android/hardware/gnss/1.0/IGnss.h>
#include <android/log.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <chrono>
#include <condition_variable>
@@ -36,7 +36,7 @@
#define TIMEOUT_SECONDS 5 // for basic commands/responses
// The main test class for GNSS HAL.
-class GnssHalTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
/* TODO(b/35678469): Setup the init.rc for VTS such that there's a
@@ -45,7 +45,7 @@
* callbacks trigger.
*/
- gnss_hal_ = ::testing::VtsHalHidlTargetBaseTest::getService<IGnss>();
+ gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>();
ASSERT_NE(gnss_hal_, nullptr);
gnss_cb_ = new GnssCallback(*this);
@@ -102,16 +102,16 @@
// Dummy callback handlers
Return<void> gnssStatusCb(
- const IGnssCallback::GnssStatusValue status) override {
+ const IGnssCallback::GnssStatusValue /* status */) override {
return Void();
}
Return<void> gnssSvStatusCb(
- const IGnssCallback::GnssSvStatus& svStatus) override {
+ const IGnssCallback::GnssSvStatus& /* svStatus */) override {
return Void();
}
Return<void> gnssNmeaCb(
- int64_t timestamp,
- const android::hardware::hidl_string& nmea) override {
+ int64_t /* timestamp */,
+ const android::hardware::hidl_string& /* nmea */) override {
return Void();
}
Return<void> gnssAcquireWakelockCb() override { return Void(); }
diff --git a/graphics/allocator/2.0/default/Android.bp b/graphics/allocator/2.0/default/Android.bp
index 67409d7..b8d4fde 100644
--- a/graphics/allocator/2.0/default/Android.bp
+++ b/graphics/allocator/2.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.graphics.allocator@2.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Gralloc.cpp"],
@@ -18,6 +19,7 @@
cc_binary {
name: "android.hardware.graphics.allocator@2.0-service",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["service.cpp"],
@@ -34,6 +36,7 @@
cc_library_static {
name: "libgralloc1-adapter",
+ defaults: ["hidl_defaults"],
srcs: ["gralloc1-adapter.cpp", "Gralloc1On0Adapter.cpp"],
include_dirs: ["system/core/libsync/include"],
cflags: ["-Wall", "-Wextra", "-Wno-unused-parameter"],
diff --git a/graphics/allocator/2.0/default/Gralloc.cpp b/graphics/allocator/2.0/default/Gralloc.cpp
index 3a102d1..0b9e863 100644
--- a/graphics/allocator/2.0/default/Gralloc.cpp
+++ b/graphics/allocator/2.0/default/Gralloc.cpp
@@ -131,7 +131,7 @@
void GrallocHal::initCapabilities()
{
- uint32_t count;
+ uint32_t count = 0;
mDevice->getCapabilities(mDevice, &count, nullptr);
std::vector<Capability> caps(count);
diff --git a/graphics/allocator/2.0/vts/functional/Android.bp b/graphics/allocator/2.0/vts/functional/Android.bp
index fdc91ae..fb77ab3 100644
--- a/graphics/allocator/2.0/vts/functional/Android.bp
+++ b/graphics/allocator/2.0/vts/functional/Android.bp
@@ -14,8 +14,29 @@
// limitations under the License.
//
+cc_library_static {
+ name: "libVtsHalGraphicsAllocatorTestUtils",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalGraphicsAllocatorTestUtils.cpp"],
+ shared_libs: [
+ "android.hardware.graphics.allocator@2.0",
+ ],
+ static_libs: [
+ "VtsHalHidlTargetTestBase",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-O0",
+ "-g",
+ ],
+ export_include_dirs: ["."],
+}
+
cc_test {
name: "VtsHalGraphicsAllocatorV2_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalGraphicsAllocatorV2_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,8 +48,14 @@
"libutils",
"android.hardware.graphics.allocator@2.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: [
+ "libVtsHalGraphicsAllocatorTestUtils",
+ "VtsHalHidlTargetTestBase",
+ ],
cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
"-O0",
"-g",
]
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
new file mode 100644
index 0000000..0dc43be
--- /dev/null
+++ b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2017 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 <VtsHalHidlTargetTestBase.h>
+
+#include "VtsHalGraphicsAllocatorTestUtils.h"
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace tests {
+
+Allocator::Allocator() { init(); }
+
+void Allocator::init() {
+ mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>();
+ ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service";
+
+ std::vector<IAllocator::Capability> capabilities = getCapabilities();
+ mCapabilities.insert(capabilities.begin(), capabilities.end());
+}
+
+sp<IAllocator> Allocator::getRaw() const { return mAllocator; }
+
+bool Allocator::hasCapability(IAllocator::Capability capability) const {
+ return mCapabilities.count(capability) > 0;
+}
+
+std::vector<IAllocator::Capability> Allocator::getCapabilities() {
+ std::vector<IAllocator::Capability> capabilities;
+ mAllocator->getCapabilities(
+ [&](const auto& tmpCapabilities) { capabilities = tmpCapabilities; });
+
+ return capabilities;
+}
+
+std::string Allocator::dumpDebugInfo() {
+ std::string debugInfo;
+ mAllocator->dumpDebugInfo(
+ [&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
+
+ return debugInfo;
+}
+
+std::unique_ptr<AllocatorClient> Allocator::createClient() {
+ std::unique_ptr<AllocatorClient> client;
+ mAllocator->createClient([&](const auto& tmpError, const auto& tmpClient) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
+ client = std::make_unique<AllocatorClient>(tmpClient);
+ });
+
+ return client;
+}
+
+AllocatorClient::AllocatorClient(const sp<IAllocatorClient>& client)
+ : mClient(client) {}
+
+AllocatorClient::~AllocatorClient() {
+ for (auto buffer : mBuffers) {
+ EXPECT_EQ(Error::NONE, mClient->free(buffer))
+ << "failed to free buffer " << buffer;
+ }
+ mBuffers.clear();
+
+ for (auto descriptor : mDescriptors) {
+ EXPECT_EQ(Error::NONE, mClient->destroyDescriptor(descriptor))
+ << "failed to destroy descriptor " << descriptor;
+ }
+ mDescriptors.clear();
+}
+
+sp<IAllocatorClient> AllocatorClient::getRaw() const { return mClient; }
+
+BufferDescriptor AllocatorClient::createDescriptor(
+ const IAllocatorClient::BufferDescriptorInfo& info) {
+ BufferDescriptor descriptor = 0;
+ mClient->createDescriptor(
+ info, [&](const auto& tmpError, const auto& tmpDescriptor) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to create descriptor";
+ descriptor = tmpDescriptor;
+
+ EXPECT_TRUE(mDescriptors.insert(descriptor).second)
+ << "duplicated descriptor id " << descriptor;
+ });
+
+ return descriptor;
+}
+
+void AllocatorClient::destroyDescriptor(BufferDescriptor descriptor) {
+ ASSERT_EQ(Error::NONE, mClient->destroyDescriptor(descriptor))
+ << "failed to destroy descriptor " << descriptor;
+
+ mDescriptors.erase(descriptor);
+}
+
+Error AllocatorClient::testAllocate(
+ const std::vector<BufferDescriptor>& descriptors) {
+ return mClient->testAllocate(descriptors);
+}
+
+bool AllocatorClient::testAllocate(BufferDescriptor descriptor) {
+ std::vector<BufferDescriptor> descriptors(1, descriptor);
+ Error error = testAllocate(descriptors);
+ return (error == Error::NONE || error == Error::NOT_SHARED);
+}
+
+Error AllocatorClient::allocate(
+ const std::vector<BufferDescriptor>& descriptors,
+ std::vector<Buffer>& buffers) {
+ Error error = Error::NO_RESOURCES;
+ mClient->allocate(descriptors, [&](const auto& tmpError,
+ const auto& tmpBuffers) {
+ ASSERT_TRUE(tmpError == Error::NONE || tmpError == Error::NOT_SHARED)
+ << "failed to allocate buffer";
+ ASSERT_EQ(descriptors.size(), tmpBuffers.size()) << "invalid buffer count";
+
+ error = tmpError;
+ buffers = tmpBuffers;
+
+ for (auto buffer : buffers) {
+ EXPECT_TRUE(mBuffers.insert(buffer).second)
+ << "duplicated buffer id " << buffer;
+ }
+ });
+
+ return error;
+}
+
+Buffer AllocatorClient::allocate(BufferDescriptor descriptor) {
+ std::vector<BufferDescriptor> descriptors(1, descriptor);
+ std::vector<Buffer> buffers;
+ allocate(descriptors, buffers);
+ if (::testing::Test::HasFatalFailure()) {
+ return 0;
+ }
+
+ return buffers[0];
+}
+
+void AllocatorClient::free(Buffer buffer) {
+ ASSERT_EQ(Error::NONE, mClient->free(buffer))
+ << "failed to free buffer " << buffer;
+
+ mBuffers.erase(buffer);
+}
+
+native_handle_t* AllocatorClient::exportHandle(BufferDescriptor descriptor,
+ Buffer buffer) {
+ native_handle_t* handle;
+ mClient->exportHandle(
+ descriptor, buffer, [&](const auto& tmpError, const auto& tmpHandle) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to export buffer handle";
+ ASSERT_NE(nullptr, tmpHandle.getNativeHandle())
+ << "invalid buffer handle";
+
+ handle = native_handle_clone(tmpHandle.getNativeHandle());
+ ASSERT_NE(nullptr, handle) << "failed to clone handle";
+ });
+
+ return handle;
+}
+
+} // namespace tests
+} // namespace V2_0
+} // namespace allocator
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h
new file mode 100644
index 0000000..c9bfe8f
--- /dev/null
+++ b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
+#define VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
+
+#include <memory>
+#include <string>
+#include <unordered_set>
+#include <vector>
+
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace tests {
+
+class AllocatorClient;
+
+// A wrapper to IAllocator.
+class Allocator {
+ public:
+ Allocator();
+
+ sp<IAllocator> getRaw() const;
+
+ // Returns true when the allocator supports the specified capability.
+ bool hasCapability(IAllocator::Capability capability) const;
+
+ std::vector<IAllocator::Capability> getCapabilities();
+ std::string dumpDebugInfo();
+ std::unique_ptr<AllocatorClient> createClient();
+
+ private:
+ void init();
+
+ sp<IAllocator> mAllocator;
+ std::unordered_set<IAllocator::Capability> mCapabilities;
+};
+
+// A wrapper to IAllocatorClient.
+class AllocatorClient {
+ public:
+ AllocatorClient(const sp<IAllocatorClient>& client);
+ ~AllocatorClient();
+
+ sp<IAllocatorClient> getRaw() const;
+
+ BufferDescriptor createDescriptor(
+ const IAllocatorClient::BufferDescriptorInfo& info);
+ void destroyDescriptor(BufferDescriptor descriptor);
+
+ Error testAllocate(const std::vector<BufferDescriptor>& descriptors);
+ bool testAllocate(BufferDescriptor descriptor);
+
+ Error allocate(const std::vector<BufferDescriptor>& descriptors,
+ std::vector<Buffer>& buffers);
+ Buffer allocate(BufferDescriptor descriptor);
+ void free(Buffer buffer);
+
+ // Returns a handle to the buffer. The ownership of the handle is
+ // transferred to the caller.
+ native_handle_t* exportHandle(BufferDescriptor descriptor, Buffer buffer);
+
+ private:
+ sp<IAllocatorClient> mClient;
+
+ // Keep track of all descriptors and buffers. When a test fails with
+ // ASSERT_*, the destructor will clean up the resources for the test.
+ std::unordered_set<BufferDescriptor> mDescriptors;
+ std::unordered_set<Buffer> mBuffers;
+};
+
+} // namespace tests
+} // namespace V2_0
+} // namespace allocator
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
index a8ced8c..b1c764f 100644
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
+++ b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
@@ -16,11 +16,10 @@
#define LOG_TAG "graphics_allocator_hidl_hal_test"
-#include <unordered_set>
-
#include <android-base/logging.h>
-#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
+
+#include "VtsHalGraphicsAllocatorTestUtils.h"
namespace android {
namespace hardware {
@@ -34,55 +33,18 @@
#define CHECK_FEATURE_OR_SKIP(FEATURE_NAME) \
do { \
- if (!hasCapability(FEATURE_NAME)) { \
+ if (!mAllocator->hasCapability(FEATURE_NAME)) { \
std::cout << "[ SKIPPED ] Feature " << #FEATURE_NAME \
<< " not supported" << std::endl; \
return; \
} \
} while (0)
-class TempDescriptor {
- public:
- TempDescriptor(const sp<IAllocatorClient>& client,
- const IAllocatorClient::BufferDescriptorInfo& info)
- : mClient(client), mError(Error::NO_RESOURCES) {
- mClient->createDescriptor(
- info, [&](const auto& tmpError, const auto& tmpDescriptor) {
- mError = tmpError;
- mDescriptor = tmpDescriptor;
- });
- }
-
- ~TempDescriptor() {
- if (mError == Error::NONE) {
- mClient->destroyDescriptor(mDescriptor);
- }
- }
-
- bool isValid() const { return (mError == Error::NONE); }
-
- operator BufferDescriptor() const { return mDescriptor; }
-
- private:
- sp<IAllocatorClient> mClient;
- Error mError;
- BufferDescriptor mDescriptor;
-};
-
-class GraphicsAllocatorHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GraphicsAllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
- mAllocator = ::testing::VtsHalHidlTargetBaseTest::getService<IAllocator>();
- ASSERT_NE(mAllocator, nullptr);
-
- mAllocator->createClient([this](const auto& error, const auto& client) {
- if (error == Error::NONE) {
- mClient = client;
- }
- });
- ASSERT_NE(mClient, nullptr);
-
- initCapabilities();
+ ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
+ ASSERT_NO_FATAL_FAILURE(mClient = mAllocator->createClient());
mDummyDescriptorInfo.width = 64;
mDummyDescriptorInfo.height = 64;
@@ -96,66 +58,27 @@
void TearDown() override {}
- /**
- * Initialize the set of supported capabilities.
- */
- void initCapabilities() {
- mAllocator->getCapabilities([this](const auto& capabilities) {
- std::vector<IAllocator::Capability> caps = capabilities;
- mCapabilities.insert(caps.cbegin(), caps.cend());
- });
- }
-
- /**
- * Test whether a capability is supported.
- */
- bool hasCapability(IAllocator::Capability capability) const {
- return (mCapabilities.count(capability) > 0);
- }
-
- sp<IAllocator> mAllocator;
- sp<IAllocatorClient> mClient;
+ std::unique_ptr<Allocator> mAllocator;
+ std::unique_ptr<AllocatorClient> mClient;
IAllocatorClient::BufferDescriptorInfo mDummyDescriptorInfo{};
-
- private:
- std::unordered_set<IAllocator::Capability> mCapabilities;
};
TEST_F(GraphicsAllocatorHidlTest, GetCapabilities) {
- auto ret = mAllocator->getCapabilities([](const auto& capabilities) {
- std::vector<IAllocator::Capability> caps = capabilities;
- for (auto cap : caps) {
- EXPECT_NE(IAllocator::Capability::INVALID, cap);
- }
- });
-
- ASSERT_TRUE(ret.isOk());
+ auto capabilities = mAllocator->getCapabilities();
+ for (auto cap : capabilities) {
+ EXPECT_NE(IAllocator::Capability::INVALID, cap);
+ }
}
TEST_F(GraphicsAllocatorHidlTest, DumpDebugInfo) {
- auto ret = mAllocator->dumpDebugInfo([](const auto&) {
- // nothing to do
- });
-
- ASSERT_TRUE(ret.isOk());
+ mAllocator->dumpDebugInfo();
}
TEST_F(GraphicsAllocatorHidlTest, CreateDestroyDescriptor) {
- Error error;
BufferDescriptor descriptor;
- auto ret = mClient->createDescriptor(
- mDummyDescriptorInfo,
- [&](const auto& tmpError, const auto& tmpDescriptor) {
- error = tmpError;
- descriptor = tmpDescriptor;
- });
-
- ASSERT_TRUE(ret.isOk());
- ASSERT_EQ(Error::NONE, error);
-
- auto err_ret = mClient->destroyDescriptor(descriptor);
- ASSERT_TRUE(err_ret.isOk());
- ASSERT_EQ(Error::NONE, static_cast<Error>(err_ret));
+ ASSERT_NO_FATAL_FAILURE(descriptor =
+ mClient->createDescriptor(mDummyDescriptorInfo));
+ mClient->destroyDescriptor(descriptor);
}
/**
@@ -164,18 +87,11 @@
TEST_F(GraphicsAllocatorHidlTest, TestAllocateBasic) {
CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
- TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
- ASSERT_TRUE(descriptor.isValid());
+ BufferDescriptor descriptor;
+ ASSERT_NO_FATAL_FAILURE(descriptor =
+ mClient->createDescriptor(mDummyDescriptorInfo));
- hidl_vec<BufferDescriptor> descriptors;
- descriptors.resize(1);
- descriptors[0] = descriptor;
-
- auto ret = mClient->testAllocate(descriptors);
- ASSERT_TRUE(ret.isOk());
-
- auto error = static_cast<Error>(ret);
- ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
+ ASSERT_TRUE(mClient->testAllocate(descriptor));
}
/**
@@ -184,18 +100,16 @@
TEST_F(GraphicsAllocatorHidlTest, TestAllocateArray) {
CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
- TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
- ASSERT_TRUE(descriptor.isValid());
+ BufferDescriptor descriptor;
+ ASSERT_NO_FATAL_FAILURE(descriptor =
+ mClient->createDescriptor(mDummyDescriptorInfo));
hidl_vec<BufferDescriptor> descriptors;
descriptors.resize(2);
descriptors[0] = descriptor;
descriptors[1] = descriptor;
- auto ret = mClient->testAllocate(descriptors);
- ASSERT_TRUE(ret.isOk());
-
- auto error = static_cast<Error>(ret);
+ auto error = mClient->testAllocate(descriptors);
ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
}
@@ -203,41 +117,27 @@
* Test allocate/free with a single buffer descriptor.
*/
TEST_F(GraphicsAllocatorHidlTest, AllocateFreeBasic) {
- TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
- ASSERT_TRUE(descriptor.isValid());
+ BufferDescriptor descriptor;
+ ASSERT_NO_FATAL_FAILURE(descriptor =
+ mClient->createDescriptor(mDummyDescriptorInfo));
- hidl_vec<BufferDescriptor> descriptors;
- descriptors.resize(1);
- descriptors[0] = descriptor;
+ Buffer buffer;
+ ASSERT_NO_FATAL_FAILURE(buffer = mClient->allocate(descriptor));
- Error error;
- std::vector<Buffer> buffers;
- auto ret = mClient->allocate(
- descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
- error = tmpError;
- buffers = tmpBuffers;
- });
-
- ASSERT_TRUE(ret.isOk());
- ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
- EXPECT_EQ(1u, buffers.size());
-
- if (!buffers.empty()) {
- auto err_ret = mClient->free(buffers[0]);
- EXPECT_TRUE(err_ret.isOk());
- EXPECT_EQ(Error::NONE, static_cast<Error>(err_ret));
- }
+ mClient->free(buffer);
}
/**
* Test allocate/free with an array of buffer descriptors.
*/
TEST_F(GraphicsAllocatorHidlTest, AllocateFreeArray) {
- TempDescriptor descriptor1(mClient, mDummyDescriptorInfo);
- ASSERT_TRUE(descriptor1.isValid());
+ BufferDescriptor descriptor1;
+ ASSERT_NO_FATAL_FAILURE(descriptor1 =
+ mClient->createDescriptor(mDummyDescriptorInfo));
- TempDescriptor descriptor2(mClient, mDummyDescriptorInfo);
- ASSERT_TRUE(descriptor2.isValid());
+ BufferDescriptor descriptor2;
+ ASSERT_NO_FATAL_FAILURE(descriptor2 =
+ mClient->createDescriptor(mDummyDescriptorInfo));
hidl_vec<BufferDescriptor> descriptors;
descriptors.resize(3);
@@ -245,54 +145,27 @@
descriptors[1] = descriptor1;
descriptors[2] = descriptor2;
- Error error;
std::vector<Buffer> buffers;
- auto ret = mClient->allocate(
- descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
- error = tmpError;
- buffers = tmpBuffers;
- });
-
- ASSERT_TRUE(ret.isOk());
- ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
- EXPECT_EQ(descriptors.size(), buffers.size());
+ ASSERT_NO_FATAL_FAILURE(mClient->allocate(descriptors, buffers));
for (auto buf : buffers) {
- auto err_ret = mClient->free(buf);
- EXPECT_TRUE(err_ret.isOk());
- EXPECT_EQ(Error::NONE, static_cast<Error>(err_ret));
+ mClient->free(buf);
}
}
TEST_F(GraphicsAllocatorHidlTest, ExportHandle) {
- TempDescriptor descriptor(mClient, mDummyDescriptorInfo);
- ASSERT_TRUE(descriptor.isValid());
+ BufferDescriptor descriptor;
+ ASSERT_NO_FATAL_FAILURE(descriptor =
+ mClient->createDescriptor(mDummyDescriptorInfo));
- hidl_vec<BufferDescriptor> descriptors;
- descriptors.resize(1);
- descriptors[0] = descriptor;
+ Buffer buffer;
+ ASSERT_NO_FATAL_FAILURE(buffer = mClient->allocate(descriptor));
- Error error;
- std::vector<Buffer> buffers;
- auto ret = mClient->allocate(
- descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
- error = tmpError;
- buffers = tmpBuffers;
- });
+ native_handle_t* handle;
+ ASSERT_NO_FATAL_FAILURE(handle = mClient->exportHandle(descriptor, buffer));
- ASSERT_TRUE(ret.isOk());
- ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
- ASSERT_EQ(1u, buffers.size());
-
- ret = mClient->exportHandle(
- descriptors[0], buffers[0],
- [&](const auto& tmpError, const auto&) { error = tmpError; });
- EXPECT_TRUE(ret.isOk());
- EXPECT_EQ(Error::NONE, error);
-
- auto err_ret = mClient->free(buffers[0]);
- EXPECT_TRUE(err_ret.isOk());
- EXPECT_EQ(Error::NONE, static_cast<Error>(err_ret));
+ native_handle_close(handle);
+ native_handle_delete(handle);
}
} // namespace anonymous
diff --git a/graphics/common/1.0/types.hal b/graphics/common/1.0/types.hal
index 1ddd892..dfecec1 100644
--- a/graphics/common/1.0/types.hal
+++ b/graphics/common/1.0/types.hal
@@ -1354,10 +1354,12 @@
*
* PC/Internet (sRGB) Gamma Correction (GC):
*
- * if Vlinear ≤ 0.0031308
+ * if Vlinear ≤ 0.0030186
* Vnonlinear = 12.92 * Vlinear
* else
* Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055
+ *
+ * Note: In most cases sRGB transfer function will be fine.
*/
DISPLAY_P3 = 9
};
diff --git a/graphics/composer/2.1/default/Android.bp b/graphics/composer/2.1/default/Android.bp
index d1173eb..d5da943 100644
--- a/graphics/composer/2.1/default/Android.bp
+++ b/graphics/composer/2.1/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_static {
name: "libhwcomposer-client",
+ defaults: ["hidl_defaults"],
export_include_dirs: ["."],
srcs: ["ComposerClient.cpp"],
shared_libs: [
@@ -19,6 +20,7 @@
cc_library_shared {
name: "android.hardware.graphics.composer@2.1-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Hwc.cpp"],
@@ -40,6 +42,7 @@
cc_binary {
name: "android.hardware.graphics.composer@2.1-service",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["service.cpp"],
@@ -63,6 +66,7 @@
cc_library_static {
name: "libhwcomposer-command-buffer",
+ defaults: ["hidl_defaults"],
shared_libs: ["android.hardware.graphics.composer@2.1"],
export_include_dirs: ["."],
}
diff --git a/graphics/composer/2.1/default/ComposerClient.cpp b/graphics/composer/2.1/default/ComposerClient.cpp
index 72ba8f8..a2d5d4b 100644
--- a/graphics/composer/2.1/default/ComposerClient.cpp
+++ b/graphics/composer/2.1/default/ComposerClient.cpp
@@ -193,30 +193,30 @@
} // anonymous namespace
-BufferClone::BufferClone()
+BufferCacheEntry::BufferCacheEntry()
: mHandle(nullptr)
{
}
-BufferClone::BufferClone(BufferClone&& other)
+BufferCacheEntry::BufferCacheEntry(BufferCacheEntry&& other)
{
mHandle = other.mHandle;
other.mHandle = nullptr;
}
-BufferClone& BufferClone::operator=(buffer_handle_t handle)
+BufferCacheEntry& BufferCacheEntry::operator=(buffer_handle_t handle)
{
clear();
mHandle = handle;
return *this;
}
-BufferClone::~BufferClone()
+BufferCacheEntry::~BufferCacheEntry()
{
clear();
}
-void BufferClone::clear()
+void BufferCacheEntry::clear()
{
if (mHandle) {
sHandleImporter.freeBuffer(mHandle);
@@ -230,30 +230,69 @@
ComposerClient::~ComposerClient()
{
- ALOGD("client destroyed");
+ // We want to call hwc2_close here (and move hwc2_open to the
+ // constructor), with the assumption that hwc2_close would
+ //
+ // - clean up all resources owned by the client
+ // - make sure all displays are blank (since there is no layer)
+ //
+ // But since SF used to crash at this point, different hwcomposer2
+ // implementations behave differently on hwc2_close. Our only portable
+ // choice really is to abort(). But that is not an option anymore
+ // because we might also have VTS or VR as clients that can come and go.
+ //
+ // Below we manually clean all resources (layers and virtual
+ // displays), and perform a presentDisplay afterwards.
+ ALOGW("destroying composer client");
mHal.enableCallback(false);
- mHal.removeClient();
- // no need to grab the mutex as any in-flight hwbinder call should keep
- // the client alive
+ // no need to grab the mutex as any in-flight hwbinder call would have
+ // kept the client alive
for (const auto& dpy : mDisplayData) {
- if (!dpy.second.Layers.empty()) {
- ALOGW("client destroyed with valid layers");
- }
+ ALOGW("destroying client resources for display %" PRIu64, dpy.first);
+
for (const auto& ly : dpy.second.Layers) {
mHal.destroyLayer(dpy.first, ly.first);
}
if (dpy.second.IsVirtual) {
- ALOGW("client destroyed with valid virtual display");
mHal.destroyVirtualDisplay(dpy.first);
+ } else {
+ ALOGW("performing a final presentDisplay");
+
+ std::vector<Layer> changedLayers;
+ std::vector<IComposerClient::Composition> compositionTypes;
+ uint32_t displayRequestMask = 0;
+ std::vector<Layer> requestedLayers;
+ std::vector<uint32_t> requestMasks;
+ mHal.validateDisplay(dpy.first, &changedLayers, &compositionTypes,
+ &displayRequestMask, &requestedLayers, &requestMasks);
+
+ mHal.acceptDisplayChanges(dpy.first);
+
+ int32_t presentFence = -1;
+ std::vector<Layer> releasedLayers;
+ std::vector<int32_t> releaseFences;
+ mHal.presentDisplay(dpy.first, &presentFence, &releasedLayers, &releaseFences);
+ if (presentFence >= 0) {
+ close(presentFence);
+ }
+ for (auto fence : releaseFences) {
+ if (fence >= 0) {
+ close(fence);
+ }
+ }
}
}
mDisplayData.clear();
sHandleImporter.cleanup();
+
+ mHal.removeClient();
+
+ ALOGW("removed composer client");
}
void ComposerClient::initialize()
@@ -706,10 +745,13 @@
auto damage = readRegion((length - 4) / 4);
auto err = lookupBuffer(BufferCache::CLIENT_TARGETS,
- slot, useCache, clientTarget);
+ slot, useCache, clientTarget, &clientTarget);
if (err == Error::NONE) {
err = mHal.setClientTarget(mDisplay, clientTarget, fence,
dataspace, damage);
+
+ updateBuffer(BufferCache::CLIENT_TARGETS, slot, useCache,
+ clientTarget);
}
if (err != Error::NONE) {
close(fence);
@@ -731,9 +773,12 @@
auto fence = readFence();
auto err = lookupBuffer(BufferCache::OUTPUT_BUFFERS,
- slot, useCache, outputBuffer);
+ slot, useCache, outputBuffer, &outputBuffer);
if (err == Error::NONE) {
err = mHal.setOutputBuffer(mDisplay, outputBuffer, fence);
+
+ updateBuffer(BufferCache::OUTPUT_BUFFERS,
+ slot, useCache, outputBuffer);
}
if (err != Error::NONE) {
close(fence);
@@ -831,9 +876,12 @@
auto fence = readFence();
auto err = lookupBuffer(BufferCache::LAYER_BUFFERS,
- slot, useCache, buffer);
+ slot, useCache, buffer, &buffer);
if (err == Error::NONE) {
err = mHal.setLayerBuffer(mDisplay, mLayer, buffer, fence);
+
+ updateBuffer(BufferCache::LAYER_BUFFERS,
+ slot, useCache, buffer);
}
if (err != Error::NONE) {
close(fence);
@@ -952,9 +1000,11 @@
auto stream = readHandle();
- auto err = lookupLayerSidebandStream(stream);
+ auto err = lookupLayerSidebandStream(stream, &stream);
if (err == Error::NONE) {
err = mHal.setLayerSidebandStream(mDisplay, mLayer, stream);
+
+ updateLayerSidebandStream(stream);
}
if (err != Error::NONE) {
mWriter.setError(getCommandLoc(), err);
@@ -1053,26 +1103,24 @@
};
}
-Error ComposerClient::CommandReader::lookupBuffer(BufferCache cache,
- uint32_t slot, bool useCache, buffer_handle_t& handle)
+Error ComposerClient::CommandReader::lookupBufferCacheEntryLocked(
+ BufferCache cache, uint32_t slot, BufferCacheEntry** outEntry)
{
- std::lock_guard<std::mutex> lock(mClient.mDisplayDataMutex);
-
auto dpy = mClient.mDisplayData.find(mDisplay);
if (dpy == mClient.mDisplayData.end()) {
return Error::BAD_DISPLAY;
}
- BufferClone* clone = nullptr;
+ BufferCacheEntry* entry = nullptr;
switch (cache) {
case BufferCache::CLIENT_TARGETS:
if (slot < dpy->second.ClientTargets.size()) {
- clone = &dpy->second.ClientTargets[slot];
+ entry = &dpy->second.ClientTargets[slot];
}
break;
case BufferCache::OUTPUT_BUFFERS:
if (slot < dpy->second.OutputBuffers.size()) {
- clone = &dpy->second.OutputBuffers[slot];
+ entry = &dpy->second.OutputBuffers[slot];
}
break;
case BufferCache::LAYER_BUFFERS:
@@ -1082,7 +1130,7 @@
return Error::BAD_LAYER;
}
if (slot < ly->second.Buffers.size()) {
- clone = &ly->second.Buffers[slot];
+ entry = &ly->second.Buffers[slot];
}
}
break;
@@ -1093,7 +1141,7 @@
return Error::BAD_LAYER;
}
if (slot == 0) {
- clone = &ly->second.SidebandStream;
+ entry = &ly->second.SidebandStream;
}
}
break;
@@ -1101,25 +1149,59 @@
break;
}
- if (!clone) {
- ALOGW("invalid buffer slot");
+ if (!entry) {
+ ALOGW("invalid buffer slot %" PRIu32, slot);
return Error::BAD_PARAMETER;
}
- // use or update cache
+ *outEntry = entry;
+
+ return Error::NONE;
+}
+
+Error ComposerClient::CommandReader::lookupBuffer(BufferCache cache,
+ uint32_t slot, bool useCache, buffer_handle_t handle,
+ buffer_handle_t* outHandle)
+{
if (useCache) {
- handle = *clone;
+ std::lock_guard<std::mutex> lock(mClient.mDisplayDataMutex);
+
+ BufferCacheEntry* entry;
+ Error error = lookupBufferCacheEntryLocked(cache, slot, &entry);
+ if (error != Error::NONE) {
+ return error;
+ }
+
+ // input handle is ignored
+ *outHandle = entry->getHandle();
} else {
if (!sHandleImporter.importBuffer(handle)) {
return Error::NO_RESOURCES;
}
- *clone = handle;
+ *outHandle = handle;
}
return Error::NONE;
}
+void ComposerClient::CommandReader::updateBuffer(BufferCache cache,
+ uint32_t slot, bool useCache, buffer_handle_t handle)
+{
+ // handle was looked up from cache
+ if (useCache) {
+ return;
+ }
+
+ std::lock_guard<std::mutex> lock(mClient.mDisplayDataMutex);
+
+ BufferCacheEntry* entry = nullptr;
+ lookupBufferCacheEntryLocked(cache, slot, &entry);
+ LOG_FATAL_IF(!entry, "failed to find the cache entry to update");
+
+ *entry = handle;
+}
+
} // namespace implementation
} // namespace V2_1
} // namespace composer
diff --git a/graphics/composer/2.1/default/ComposerClient.h b/graphics/composer/2.1/default/ComposerClient.h
index d351cfb..14da1f8 100644
--- a/graphics/composer/2.1/default/ComposerClient.h
+++ b/graphics/composer/2.1/default/ComposerClient.h
@@ -31,18 +31,18 @@
namespace V2_1 {
namespace implementation {
-class BufferClone {
+class BufferCacheEntry {
public:
- BufferClone();
- BufferClone(BufferClone&& other);
+ BufferCacheEntry();
+ BufferCacheEntry(BufferCacheEntry&& other);
- BufferClone(const BufferClone& other) = delete;
- BufferClone& operator=(const BufferClone& other) = delete;
+ BufferCacheEntry(const BufferCacheEntry& other) = delete;
+ BufferCacheEntry& operator=(const BufferCacheEntry& other) = delete;
- BufferClone& operator=(buffer_handle_t handle);
- ~BufferClone();
+ BufferCacheEntry& operator=(buffer_handle_t handle);
+ ~BufferCacheEntry();
- operator buffer_handle_t() const { return mHandle; }
+ buffer_handle_t getHandle() const { return mHandle; }
private:
void clear();
@@ -108,15 +108,15 @@
protected:
struct LayerBuffers {
- std::vector<BufferClone> Buffers;
- BufferClone SidebandStream;
+ std::vector<BufferCacheEntry> Buffers;
+ BufferCacheEntry SidebandStream;
};
struct DisplayData {
bool IsVirtual;
- std::vector<BufferClone> ClientTargets;
- std::vector<BufferClone> OutputBuffers;
+ std::vector<BufferCacheEntry> ClientTargets;
+ std::vector<BufferCacheEntry> OutputBuffers;
std::unordered_map<Layer, LayerBuffers> Layers;
@@ -167,12 +167,23 @@
LAYER_BUFFERS,
LAYER_SIDEBAND_STREAMS,
};
+ Error lookupBufferCacheEntryLocked(BufferCache cache, uint32_t slot,
+ BufferCacheEntry** outEntry);
Error lookupBuffer(BufferCache cache, uint32_t slot,
- bool useCache, buffer_handle_t& handle);
+ bool useCache, buffer_handle_t handle,
+ buffer_handle_t* outHandle);
+ void updateBuffer(BufferCache cache, uint32_t slot,
+ bool useCache, buffer_handle_t handle);
- Error lookupLayerSidebandStream(buffer_handle_t& handle)
+ Error lookupLayerSidebandStream(buffer_handle_t handle,
+ buffer_handle_t* outHandle)
{
return lookupBuffer(BufferCache::LAYER_SIDEBAND_STREAMS,
+ 0, false, handle, outHandle);
+ }
+ void updateLayerSidebandStream(buffer_handle_t handle)
+ {
+ updateBuffer(BufferCache::LAYER_SIDEBAND_STREAMS,
0, false, handle);
}
diff --git a/graphics/composer/2.1/vts/functional/Android.bp b/graphics/composer/2.1/vts/functional/Android.bp
index 9be04d1..8e1f925 100644
--- a/graphics/composer/2.1/vts/functional/Android.bp
+++ b/graphics/composer/2.1/vts/functional/Android.bp
@@ -14,8 +14,27 @@
// limitations under the License.
//
+cc_library_static {
+ name: "libVtsHalGraphicsComposerTestUtils",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalGraphicsComposerTestUtils.cpp"],
+ shared_libs: ["android.hardware.graphics.composer@2.1"],
+ static_libs: [
+ "VtsHalHidlTargetTestBase",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-O0",
+ "-g",
+ ],
+ export_include_dirs: ["."],
+}
+
cc_test {
name: "VtsHalGraphicsComposerV2_1TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalGraphicsComposerV2_1TargetTest.cpp"],
shared_libs: [
"android.hardware.graphics.allocator@2.0",
@@ -31,8 +50,17 @@
"libsync",
"libutils",
],
- static_libs: ["VtsHalHidlTargetBaseTest", "libhwcomposer-command-buffer"],
+ static_libs: [
+ "libhwcomposer-command-buffer",
+ "libVtsHalGraphicsAllocatorTestUtils",
+ "libVtsHalGraphicsComposerTestUtils",
+ "libVtsHalGraphicsMapperTestUtils",
+ "VtsHalHidlTargetTestBase",
+ ],
cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
"-O0",
"-g",
]
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
new file mode 100644
index 0000000..33cf84c
--- /dev/null
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
@@ -0,0 +1,300 @@
+/*
+ * Copyright (C) 2017 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 <VtsHalHidlTargetTestBase.h>
+
+#include "VtsHalGraphicsComposerTestUtils.h"
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace composer {
+namespace V2_1 {
+namespace tests {
+
+Composer::Composer() { init(); }
+
+void Composer::init() {
+ mComposer = ::testing::VtsHalHidlTargetTestBase::getService<IComposer>();
+ ASSERT_NE(nullptr, mComposer.get()) << "failed to get composer service";
+
+ std::vector<IComposer::Capability> capabilities = getCapabilities();
+ mCapabilities.insert(capabilities.begin(), capabilities.end());
+}
+
+sp<IComposer> Composer::getRaw() const { return mComposer; }
+
+bool Composer::hasCapability(IComposer::Capability capability) const {
+ return mCapabilities.count(capability) > 0;
+}
+
+std::vector<IComposer::Capability> Composer::getCapabilities() {
+ std::vector<IComposer::Capability> capabilities;
+ mComposer->getCapabilities(
+ [&](const auto& tmpCapabilities) { capabilities = tmpCapabilities; });
+
+ return capabilities;
+}
+
+std::string Composer::dumpDebugInfo() {
+ std::string debugInfo;
+ mComposer->dumpDebugInfo(
+ [&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
+
+ return debugInfo;
+}
+
+std::unique_ptr<ComposerClient> Composer::createClient() {
+ std::unique_ptr<ComposerClient> client;
+ mComposer->createClient([&](const auto& tmpError, const auto& tmpClient) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
+ client = std::make_unique<ComposerClient>(tmpClient);
+ });
+
+ return client;
+}
+
+ComposerClient::ComposerClient(const sp<IComposerClient>& client)
+ : mClient(client) {}
+
+ComposerClient::~ComposerClient() {
+ for (auto it : mDisplayResources) {
+ Display display = it.first;
+ DisplayResource& resource = it.second;
+
+ for (auto layer : resource.layers) {
+ EXPECT_EQ(Error::NONE, mClient->destroyLayer(display, layer))
+ << "failed to destroy layer " << layer;
+ }
+
+ if (resource.isVirtual) {
+ EXPECT_EQ(Error::NONE, mClient->destroyVirtualDisplay(display))
+ << "failed to destroy virtual display " << display;
+ }
+ }
+ mDisplayResources.clear();
+}
+
+sp<IComposerClient> ComposerClient::getRaw() const { return mClient; }
+
+void ComposerClient::registerCallback(const sp<IComposerCallback>& callback) {
+ mClient->registerCallback(callback);
+}
+
+uint32_t ComposerClient::getMaxVirtualDisplayCount() {
+ return mClient->getMaxVirtualDisplayCount();
+}
+
+Display ComposerClient::createVirtualDisplay(uint32_t width, uint32_t height,
+ PixelFormat formatHint,
+ uint32_t outputBufferSlotCount,
+ PixelFormat* outFormat) {
+ Display display = 0;
+ mClient->createVirtualDisplay(
+ width, height, formatHint, outputBufferSlotCount,
+ [&](const auto& tmpError, const auto& tmpDisplay, const auto& tmpFormat) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to create virtual display";
+ display = tmpDisplay;
+ *outFormat = tmpFormat;
+
+ ASSERT_TRUE(
+ mDisplayResources.insert({display, DisplayResource(true)}).second)
+ << "duplicated virtual display id " << display;
+ });
+
+ return display;
+}
+
+void ComposerClient::destroyVirtualDisplay(Display display) {
+ Error error = mClient->destroyVirtualDisplay(display);
+ ASSERT_EQ(Error::NONE, error)
+ << "failed to destroy virtual display " << display;
+
+ mDisplayResources.erase(display);
+}
+
+Layer ComposerClient::createLayer(Display display, uint32_t bufferSlotCount) {
+ Layer layer = 0;
+ mClient->createLayer(
+ display, bufferSlotCount,
+ [&](const auto& tmpError, const auto& tmpLayer) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to create layer";
+ layer = tmpLayer;
+
+ auto resourceIt = mDisplayResources.find(display);
+ if (resourceIt == mDisplayResources.end()) {
+ resourceIt =
+ mDisplayResources.insert({display, DisplayResource(false)}).first;
+ }
+
+ ASSERT_TRUE(resourceIt->second.layers.insert(layer).second)
+ << "duplicated layer id " << layer;
+ });
+
+ return layer;
+}
+
+void ComposerClient::destroyLayer(Display display, Layer layer) {
+ Error error = mClient->destroyLayer(display, layer);
+ ASSERT_EQ(Error::NONE, error) << "failed to destroy layer " << layer;
+
+ auto resourceIt = mDisplayResources.find(display);
+ ASSERT_NE(mDisplayResources.end(), resourceIt);
+ resourceIt->second.layers.erase(layer);
+}
+
+Config ComposerClient::getActiveConfig(Display display) {
+ Config config = 0;
+ mClient->getActiveConfig(
+ display, [&](const auto& tmpError, const auto& tmpConfig) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to get active config";
+ config = tmpConfig;
+ });
+
+ return config;
+}
+
+bool ComposerClient::getClientTargetSupport(Display display, uint32_t width,
+ uint32_t height, PixelFormat format,
+ Dataspace dataspace) {
+ Error error = mClient->getClientTargetSupport(display, width, height, format,
+ dataspace);
+ return error == Error::NONE;
+}
+
+std::vector<ColorMode> ComposerClient::getColorModes(Display display) {
+ std::vector<ColorMode> modes;
+ mClient->getColorModes(
+ display, [&](const auto& tmpError, const auto& tmpMode) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to get color mode";
+ modes = tmpMode;
+ });
+
+ return modes;
+}
+
+int32_t ComposerClient::getDisplayAttribute(
+ Display display, Config config, IComposerClient::Attribute attribute) {
+ int32_t value = 0;
+ mClient->getDisplayAttribute(display, config, attribute,
+ [&](const auto& tmpError, const auto& tmpValue) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get display attribute";
+ value = tmpValue;
+ });
+
+ return value;
+}
+
+std::vector<Config> ComposerClient::getDisplayConfigs(Display display) {
+ std::vector<Config> configs;
+ mClient->getDisplayConfigs(
+ display, [&](const auto& tmpError, const auto& tmpConfigs) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to get display configs";
+ configs = tmpConfigs;
+ });
+
+ return configs;
+}
+
+std::string ComposerClient::getDisplayName(Display display) {
+ std::string name;
+ mClient->getDisplayName(
+ display, [&](const auto& tmpError, const auto& tmpName) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to get display name";
+ name = tmpName.c_str();
+ });
+
+ return name;
+}
+
+IComposerClient::DisplayType ComposerClient::getDisplayType(Display display) {
+ IComposerClient::DisplayType type = IComposerClient::DisplayType::INVALID;
+ mClient->getDisplayType(
+ display, [&](const auto& tmpError, const auto& tmpType) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to get display type";
+ type = tmpType;
+ });
+
+ return type;
+}
+
+bool ComposerClient::getDozeSupport(Display display) {
+ bool support = false;
+ mClient->getDozeSupport(
+ display, [&](const auto& tmpError, const auto& tmpSupport) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to get doze support";
+ support = tmpSupport;
+ });
+
+ return support;
+}
+
+std::vector<Hdr> ComposerClient::getHdrCapabilities(
+ Display display, float* outMaxLuminance, float* outMaxAverageLuminance,
+ float* outMinLuminance) {
+ std::vector<Hdr> types;
+ mClient->getHdrCapabilities(
+ display,
+ [&](const auto& tmpError, const auto& tmpTypes,
+ const auto& tmpMaxLuminance, const auto& tmpMaxAverageLuminance,
+ const auto& tmpMinLuminance) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to get HDR capabilities";
+ types = tmpTypes;
+ *outMaxLuminance = tmpMaxLuminance;
+ *outMaxAverageLuminance = tmpMaxAverageLuminance;
+ *outMinLuminance = tmpMinLuminance;
+ });
+
+ return types;
+}
+
+void ComposerClient::setClientTargetSlotCount(Display display,
+ uint32_t clientTargetSlotCount) {
+ Error error =
+ mClient->setClientTargetSlotCount(display, clientTargetSlotCount);
+ ASSERT_EQ(Error::NONE, error) << "failed to set client target slot count";
+}
+
+void ComposerClient::setActiveConfig(Display display, Config config) {
+ Error error = mClient->setActiveConfig(display, config);
+ ASSERT_EQ(Error::NONE, error) << "failed to set active config";
+}
+
+void ComposerClient::setColorMode(Display display, ColorMode mode) {
+ Error error = mClient->setColorMode(display, mode);
+ ASSERT_EQ(Error::NONE, error) << "failed to set color mode";
+}
+
+void ComposerClient::setPowerMode(Display display,
+ IComposerClient::PowerMode mode) {
+ Error error = mClient->setPowerMode(display, mode);
+ ASSERT_EQ(Error::NONE, error) << "failed to set power mode";
+}
+
+void ComposerClient::setVsyncEnabled(Display display, bool enabled) {
+ IComposerClient::Vsync vsync = (enabled) ? IComposerClient::Vsync::ENABLE
+ : IComposerClient::Vsync::DISABLE;
+ Error error = mClient->setVsyncEnabled(display, vsync);
+ ASSERT_EQ(Error::NONE, error) << "failed to set vsync mode";
+}
+
+} // namespace tests
+} // namespace V2_1
+} // namespace composer
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h
new file mode 100644
index 0000000..4b57264
--- /dev/null
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef VTS_HAL_GRAPHICS_COMPOSER_UTILS
+#define VTS_HAL_GRAPHICS_COMPOSER_UTILS
+
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+#include <vector>
+
+#include <android/hardware/graphics/composer/2.1/IComposer.h>
+#include <utils/StrongPointer.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace composer {
+namespace V2_1 {
+namespace tests {
+
+using android::hardware::graphics::common::V1_0::ColorMode;
+using android::hardware::graphics::common::V1_0::Dataspace;
+using android::hardware::graphics::common::V1_0::Hdr;
+using android::hardware::graphics::common::V1_0::PixelFormat;
+
+class ComposerClient;
+
+// A wrapper to IComposer.
+class Composer {
+ public:
+ Composer();
+
+ sp<IComposer> getRaw() const;
+
+ // Returns true when the composer supports the specified capability.
+ bool hasCapability(IComposer::Capability capability) const;
+
+ std::vector<IComposer::Capability> getCapabilities();
+ std::string dumpDebugInfo();
+ std::unique_ptr<ComposerClient> createClient();
+
+ private:
+ void init();
+
+ sp<IComposer> mComposer;
+ std::unordered_set<IComposer::Capability> mCapabilities;
+};
+
+// A wrapper to IComposerClient.
+class ComposerClient {
+ public:
+ ComposerClient(const sp<IComposerClient>& client);
+ ~ComposerClient();
+
+ sp<IComposerClient> getRaw() const;
+
+ void registerCallback(const sp<IComposerCallback>& callback);
+ uint32_t getMaxVirtualDisplayCount();
+
+ Display createVirtualDisplay(uint32_t width, uint32_t height,
+ PixelFormat formatHint,
+ uint32_t outputBufferSlotCount,
+ PixelFormat* outFormat);
+ void destroyVirtualDisplay(Display display);
+
+ Layer createLayer(Display display, uint32_t bufferSlotCount);
+ void destroyLayer(Display display, Layer layer);
+
+ Config getActiveConfig(Display display);
+ bool getClientTargetSupport(Display display, uint32_t width, uint32_t height,
+ PixelFormat format, Dataspace dataspace);
+ std::vector<ColorMode> getColorModes(Display display);
+ int32_t getDisplayAttribute(Display display, Config config,
+ IComposerClient::Attribute attribute);
+ std::vector<Config> getDisplayConfigs(Display display);
+ std::string getDisplayName(Display display);
+ IComposerClient::DisplayType getDisplayType(Display display);
+ bool getDozeSupport(Display display);
+ std::vector<Hdr> getHdrCapabilities(Display display, float* outMaxLuminance,
+ float* outMaxAverageLuminance,
+ float* outMinLuminance);
+
+ void setClientTargetSlotCount(Display display,
+ uint32_t clientTargetSlotCount);
+ void setActiveConfig(Display display, Config config);
+ void setColorMode(Display display, ColorMode mode);
+ void setPowerMode(Display display, IComposerClient::PowerMode mode);
+ void setVsyncEnabled(Display display, bool enabled);
+
+ private:
+ sp<IComposerClient> mClient;
+
+ // Keep track of all virtual displays and layers. When a test fails with
+ // ASSERT_*, the destructor will clean up the resources for the test.
+ struct DisplayResource {
+ DisplayResource(bool isVirtual_) : isVirtual(isVirtual_) {}
+
+ bool isVirtual;
+ std::unordered_set<Layer> layers;
+ };
+ std::unordered_map<Display, DisplayResource> mDisplayResources;
+};
+
+} // namespace tests
+} // namespace V2_1
+} // namespace composer
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // VTS_HAL_GRAPHICS_COMPOSER_UTILS
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
index a565845..0da3a33 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
@@ -18,11 +18,11 @@
#include <IComposerCommandBuffer.h>
#include <android-base/logging.h>
-#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
-#include <android/hardware/graphics/composer/2.1/IComposer.h>
-#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include "VtsHalGraphicsAllocatorTestUtils.h"
+#include "VtsHalGraphicsComposerTestUtils.h"
+#include "VtsHalGraphicsMapperTestUtils.h"
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <unistd.h>
#include <algorithm>
@@ -46,12 +46,15 @@
using android::hardware::graphics::allocator::V2_0::IAllocator;
using android::hardware::graphics::allocator::V2_0::IAllocatorClient;
using android::hardware::graphics::allocator::V2_0::ProducerUsage;
+using android::hardware::graphics::allocator::V2_0::tests::Allocator;
+using android::hardware::graphics::allocator::V2_0::tests::AllocatorClient;
using android::hardware::graphics::common::V1_0::ColorMode;
using android::hardware::graphics::common::V1_0::ColorTransform;
using android::hardware::graphics::common::V1_0::Dataspace;
using android::hardware::graphics::common::V1_0::PixelFormat;
using android::hardware::graphics::common::V1_0::Transform;
using android::hardware::graphics::mapper::V2_0::IMapper;
+using android::hardware::graphics::mapper::V2_0::tests::Mapper;
using GrallocError = android::hardware::graphics::allocator::V2_0::Error;
// IComposerCallback to be installed with IComposerClient::registerCallback.
@@ -131,16 +134,11 @@
int mInvalidVsyncCount = 0;
};
-class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
- mComposer = ::testing::VtsHalHidlTargetBaseTest::getService<IComposer>();
- ASSERT_NE(nullptr, mComposer.get());
-
- mComposerClient = createClient();
- ASSERT_NE(nullptr, mComposerClient.get());
-
- initCapabilities();
+ ASSERT_NO_FATAL_FAILURE(mComposer = std::make_unique<Composer>());
+ ASSERT_NO_FATAL_FAILURE(mComposerClient = mComposer->createClient());
mComposerCallback = new GraphicsComposerCallback;
mComposerClient->registerCallback(mComposerCallback);
@@ -157,177 +155,16 @@
}
}
- /**
- * Initialize the set of supported capabilities.
- */
- void initCapabilities() {
- mComposer->getCapabilities([this](const auto& capabilities) {
- std::vector<IComposer::Capability> caps = capabilities;
- mCapabilities.insert(caps.cbegin(), caps.cend());
- });
- }
-
- /**
- * Test whether a capability is supported.
- */
- bool hasCapability(IComposer::Capability capability) const {
- return (mCapabilities.count(capability) > 0);
- }
-
- IComposerClient::DisplayType getDisplayType(Display display) {
- IComposerClient::DisplayType type = IComposerClient::DisplayType::INVALID;
- mComposerClient->getDisplayType(
- display, [&](const auto& tmpError, const auto& tmpType) {
- ASSERT_EQ(Error::NONE, tmpError);
- type = tmpType;
- });
- return type;
- }
-
- Error createVirtualDisplay(Display* outDisplay) {
- auto ret_count = mComposerClient->getMaxVirtualDisplayCount();
- if (ret_count == 0) {
- return Error::UNSUPPORTED;
- }
-
- Error err = Error::NO_RESOURCES;
- Display display;
- mComposerClient->createVirtualDisplay(
- 64, 64, PixelFormat::IMPLEMENTATION_DEFINED, kBufferSlotCount,
- [&](const auto& tmpError, const auto& tmpDisplay, const auto&) {
- err = tmpError;
- display = tmpDisplay;
- });
-
- *outDisplay = display;
- return err;
- }
-
- void destroyVirtualDisplay(Display display) {
- auto ret = mComposerClient->destroyVirtualDisplay(display);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
- }
-
- Error createLayer(Layer* outLayer) {
- Error err = Error::NO_RESOURCES;
- Layer layer;
- mComposerClient->createLayer(
- mPrimaryDisplay, kBufferSlotCount,
- [&](const auto& tmpError, const auto& tmpLayer) {
- err = tmpError;
- layer = tmpLayer;
- });
-
- *outLayer = layer;
- return err;
- }
-
- void destroyLayer(Layer layer) {
- auto ret = mComposerClient->destroyLayer(mPrimaryDisplay, layer);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
- }
-
- int32_t getDisplayAttribute(Config config,
- IComposerClient::Attribute attribute) {
- int32_t value = -1;
- mComposerClient->getDisplayAttribute(
- mPrimaryDisplay, config, attribute,
- [&](const auto& tmpError, const auto& tmpValue) {
- ASSERT_EQ(Error::NONE, tmpError);
- value = tmpValue;
- });
- return value;
- }
-
- std::vector<Config> getDisplayConfigs() {
- std::vector<Config> configs;
- mComposerClient->getDisplayConfigs(
- mPrimaryDisplay, [&](const auto& tmpError, const auto& tmpConfigs) {
- ASSERT_EQ(Error::NONE, tmpError);
-
- configs = tmpConfigs;
- ASSERT_FALSE(configs.empty());
- });
-
- return configs;
- }
-
- std::vector<ColorMode> getColorModes() {
- std::vector<ColorMode> modes;
- mComposerClient->getColorModes(
- mPrimaryDisplay, [&](const auto& tmpError, const auto& tmpModes) {
- ASSERT_EQ(Error::NONE, tmpError);
-
- modes = tmpModes;
- ASSERT_NE(modes.end(),
- std::find(modes.begin(), modes.end(), ColorMode::NATIVE));
- });
-
- return modes;
- }
-
- std::vector<IComposerClient::PowerMode> getPowerModes() {
- std::vector<IComposerClient::PowerMode> modes;
- modes.push_back(IComposerClient::PowerMode::OFF);
-
- mComposerClient->getDozeSupport(
- mPrimaryDisplay, [&](const auto& tmpError, const auto& tmpSupport) {
- ASSERT_EQ(Error::NONE, tmpError);
- if (tmpSupport) {
- modes.push_back(IComposerClient::PowerMode::DOZE);
- modes.push_back(IComposerClient::PowerMode::DOZE_SUSPEND);
- }
- });
-
- // push ON last
- modes.push_back(IComposerClient::PowerMode::ON);
-
- return modes;
- }
-
- void setActiveConfig(Config config) {
- auto ret = mComposerClient->setActiveConfig(mPrimaryDisplay, config);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
- }
-
- void setColorMode(ColorMode mode) {
- auto ret = mComposerClient->setColorMode(mPrimaryDisplay, mode);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
- }
-
- void setPowerMode(IComposerClient::PowerMode mode) {
- auto ret = mComposerClient->setPowerMode(mPrimaryDisplay, mode);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
- }
-
- void setVsyncEnabled(bool enable) {
- auto ret = mComposerClient->setVsyncEnabled(
- mPrimaryDisplay,
- enable ? IComposerClient::Vsync::ENABLE
- : IComposerClient::Vsync::DISABLE);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
- }
// use the slot count usually set by SF
static constexpr uint32_t kBufferSlotCount = 64;
- sp<IComposer> mComposer;
- sp<IComposerClient> mComposerClient;
+ std::unique_ptr<Composer> mComposer;
+ std::unique_ptr<ComposerClient> mComposerClient;
sp<GraphicsComposerCallback> mComposerCallback;
// the first display and is assumed never to be removed
Display mPrimaryDisplay;
private:
- sp<IComposerClient> createClient() {
- sp<IComposerClient> client;
- mComposer->createClient([&](const auto& tmpError, const auto& tmpClient) {
- if (tmpError == Error::NONE) {
- client = tmpClient;
- }
- });
-
- return client;
- }
-
Display waitForFirstDisplay() {
while (true) {
std::vector<Display> displays = mComposerCallback->getDisplays();
@@ -339,9 +176,6 @@
return displays[0];
}
}
-
- // the set of all supported capabilities
- std::unordered_set<IComposer::Capability> mCapabilities;
};
/**
@@ -350,22 +184,16 @@
* Test that IComposer::getCapabilities returns no invalid capabilities.
*/
TEST_F(GraphicsComposerHidlTest, GetCapabilities) {
- mComposer->getCapabilities([](const auto& tmpCapabilities) {
- std::vector<IComposer::Capability> capabilities = tmpCapabilities;
- ASSERT_EQ(capabilities.end(),
- std::find(capabilities.begin(), capabilities.end(),
- IComposer::Capability::INVALID));
- });
+ auto capabilities = mComposer->getCapabilities();
+ ASSERT_EQ(capabilities.end(),
+ std::find(capabilities.begin(), capabilities.end(),
+ IComposer::Capability::INVALID));
}
/**
* Test IComposer::dumpDebugInfo.
*/
-TEST_F(GraphicsComposerHidlTest, DumpDebugInfo) {
- mComposer->dumpDebugInfo([](const auto&) {
- // nothing to do
- });
-}
+TEST_F(GraphicsComposerHidlTest, DumpDebugInfo) { mComposer->dumpDebugInfo(); }
/**
* Test IComposer::createClient.
@@ -373,7 +201,7 @@
* Test that IComposerClient is a singleton.
*/
TEST_F(GraphicsComposerHidlTest, CreateClientSingleton) {
- mComposer->createClient([&](const auto& tmpError, const auto&) {
+ mComposer->getRaw()->createClient([&](const auto& tmpError, const auto&) {
EXPECT_EQ(Error::NO_RESOURCES, tmpError);
});
}
@@ -385,19 +213,22 @@
* Test that virtual displays can be created and has the correct display type.
*/
TEST_F(GraphicsComposerHidlTest, CreateVirtualDisplay) {
- Display display;
- Error err = createVirtualDisplay(&display);
- if (err == Error::UNSUPPORTED) {
+ if (mComposerClient->getMaxVirtualDisplayCount() == 0) {
GTEST_SUCCEED() << "no virtual display support";
return;
}
- ASSERT_EQ(Error::NONE, err);
+
+ Display display;
+ PixelFormat format;
+ ASSERT_NO_FATAL_FAILURE(display = mComposerClient->createVirtualDisplay(
+ 64, 64, PixelFormat::IMPLEMENTATION_DEFINED,
+ kBufferSlotCount, &format));
// test display type
- IComposerClient::DisplayType type = getDisplayType(display);
+ IComposerClient::DisplayType type = mComposerClient->getDisplayType(display);
EXPECT_EQ(IComposerClient::DisplayType::VIRTUAL, type);
- destroyVirtualDisplay(display);
+ mComposerClient->destroyVirtualDisplay(display);
}
/**
@@ -407,20 +238,17 @@
*/
TEST_F(GraphicsComposerHidlTest, CreateLayer) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
- destroyLayer(layer);
+ mComposerClient->destroyLayer(mPrimaryDisplay, layer);
}
/**
* Test IComposerClient::getDisplayName.
*/
TEST_F(GraphicsComposerHidlTest, GetDisplayName) {
- mComposerClient->getDisplayName(mPrimaryDisplay,
- [&](const auto& tmpError, const auto&) {
- ASSERT_EQ(Error::NONE, tmpError);
- });
+ mComposerClient->getDisplayName(mPrimaryDisplay);
}
/**
@@ -430,8 +258,8 @@
* for the primary display.
*/
TEST_F(GraphicsComposerHidlTest, GetDisplayType) {
- IComposerClient::DisplayType type = getDisplayType(mPrimaryDisplay);
- EXPECT_EQ(IComposerClient::DisplayType::PHYSICAL, type);
+ ASSERT_EQ(IComposerClient::DisplayType::PHYSICAL,
+ mComposerClient->getDisplayType(mPrimaryDisplay));
}
/**
@@ -441,21 +269,21 @@
* required client targets.
*/
TEST_F(GraphicsComposerHidlTest, GetClientTargetSupport) {
- std::vector<Config> configs = getDisplayConfigs();
+ std::vector<Config> configs =
+ mComposerClient->getDisplayConfigs(mPrimaryDisplay);
for (auto config : configs) {
- int32_t width =
- getDisplayAttribute(config, IComposerClient::Attribute::WIDTH);
- int32_t height =
- getDisplayAttribute(config, IComposerClient::Attribute::HEIGHT);
+ int32_t width = mComposerClient->getDisplayAttribute(
+ mPrimaryDisplay, config, IComposerClient::Attribute::WIDTH);
+ int32_t height = mComposerClient->getDisplayAttribute(
+ mPrimaryDisplay, config, IComposerClient::Attribute::HEIGHT);
ASSERT_LT(0, width);
ASSERT_LT(0, height);
- setActiveConfig(config);
+ mComposerClient->setActiveConfig(mPrimaryDisplay, config);
- auto ret = mComposerClient->getClientTargetSupport(
+ ASSERT_TRUE(mComposerClient->getClientTargetSupport(
mPrimaryDisplay, width, height, PixelFormat::RGBA_8888,
- Dataspace::UNKNOWN);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
+ Dataspace::UNKNOWN));
}
}
@@ -466,21 +294,22 @@
* formats, and succeeds or fails correctly for optional attributes.
*/
TEST_F(GraphicsComposerHidlTest, GetDisplayAttribute) {
- std::vector<Config> configs = getDisplayConfigs();
+ std::vector<Config> configs =
+ mComposerClient->getDisplayConfigs(mPrimaryDisplay);
for (auto config : configs) {
const std::array<IComposerClient::Attribute, 3> requiredAttributes = {{
IComposerClient::Attribute::WIDTH, IComposerClient::Attribute::HEIGHT,
IComposerClient::Attribute::VSYNC_PERIOD,
}};
for (auto attribute : requiredAttributes) {
- getDisplayAttribute(config, attribute);
+ mComposerClient->getDisplayAttribute(mPrimaryDisplay, config, attribute);
}
const std::array<IComposerClient::Attribute, 2> optionalAttributes = {{
IComposerClient::Attribute::DPI_X, IComposerClient::Attribute::DPI_Y,
}};
for (auto attribute : optionalAttributes) {
- mComposerClient->getDisplayAttribute(
+ mComposerClient->getRaw()->getDisplayAttribute(
mPrimaryDisplay, config, attribute,
[&](const auto& tmpError, const auto&) {
EXPECT_TRUE(tmpError == Error::NONE ||
@@ -494,19 +323,18 @@
* Test IComposerClient::getHdrCapabilities.
*/
TEST_F(GraphicsComposerHidlTest, GetHdrCapabilities) {
- mComposerClient->getHdrCapabilities(
- mPrimaryDisplay,
- [&](const auto& tmpError, const auto&, const auto&, const auto&,
- const auto&) { ASSERT_EQ(Error::NONE, tmpError); });
+ float maxLuminance;
+ float maxAverageLuminance;
+ float minLuminance;
+ mComposerClient->getHdrCapabilities(mPrimaryDisplay, &maxLuminance,
+ &maxAverageLuminance, &minLuminance);
}
/**
* Test IComposerClient::setClientTargetSlotCount.
*/
TEST_F(GraphicsComposerHidlTest, SetClientTargetSlotCount) {
- auto ret = mComposerClient->setClientTargetSlotCount(mPrimaryDisplay,
- kBufferSlotCount);
- ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
+ mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kBufferSlotCount);
}
/**
@@ -516,15 +344,11 @@
* configs.
*/
TEST_F(GraphicsComposerHidlTest, SetActiveConfig) {
- std::vector<Config> configs = getDisplayConfigs();
+ std::vector<Config> configs =
+ mComposerClient->getDisplayConfigs(mPrimaryDisplay);
for (auto config : configs) {
- setActiveConfig(config);
-
- mComposerClient->getActiveConfig(
- mPrimaryDisplay, [&](const auto& tmpError, const auto& tmpConfig) {
- EXPECT_EQ(Error::NONE, tmpError);
- EXPECT_EQ(config, tmpConfig);
- });
+ mComposerClient->setActiveConfig(mPrimaryDisplay, config);
+ ASSERT_EQ(config, mComposerClient->getActiveConfig(mPrimaryDisplay));
}
}
@@ -534,9 +358,10 @@
* Test that IComposerClient::setColorMode succeeds for all color modes.
*/
TEST_F(GraphicsComposerHidlTest, SetColorMode) {
- std::vector<ColorMode> modes = getColorModes();
+ std::vector<ColorMode> modes =
+ mComposerClient->getColorModes(mPrimaryDisplay);
for (auto mode : modes) {
- setColorMode(mode);
+ mComposerClient->setColorMode(mPrimaryDisplay, mode);
}
}
@@ -546,9 +371,19 @@
* Test that IComposerClient::setPowerMode succeeds for all power modes.
*/
TEST_F(GraphicsComposerHidlTest, SetPowerMode) {
- std::vector<IComposerClient::PowerMode> modes = getPowerModes();
+ std::vector<IComposerClient::PowerMode> modes;
+ modes.push_back(IComposerClient::PowerMode::OFF);
+
+ if (mComposerClient->getDozeSupport(mPrimaryDisplay)) {
+ modes.push_back(IComposerClient::PowerMode::DOZE);
+ modes.push_back(IComposerClient::PowerMode::DOZE_SUSPEND);
+ }
+
+ // push ON last
+ modes.push_back(IComposerClient::PowerMode::ON);
+
for (auto mode : modes) {
- setPowerMode(mode);
+ mComposerClient->setPowerMode(mPrimaryDisplay, mode);
}
}
@@ -561,9 +396,9 @@
TEST_F(GraphicsComposerHidlTest, SetVsyncEnabled) {
mComposerCallback->setVsyncAllowed(true);
- setVsyncEnabled(true);
+ mComposerClient->setVsyncEnabled(mPrimaryDisplay, true);
usleep(60 * 1000);
- setVsyncEnabled(false);
+ mComposerClient->setVsyncEnabled(mPrimaryDisplay, false);
mComposerCallback->setVsyncAllowed(false);
}
@@ -573,7 +408,10 @@
protected:
void SetUp() override {
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::SetUp());
- ASSERT_NO_FATAL_FAILURE(SetUpGralloc());
+
+ ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
+ ASSERT_NO_FATAL_FAILURE(mAllocatorClient = mAllocator->createClient());
+ ASSERT_NO_FATAL_FAILURE(mMapper = std::make_unique<Mapper>());
mWriter = std::make_unique<CommandWriterBase>(1024);
mReader = std::make_unique<CommandReader>();
@@ -583,80 +421,6 @@
ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::TearDown());
}
- const native_handle_t* cloneBuffer(const native_handle_t* handle) {
- auto clone = native_handle_clone(handle);
- if (!clone) {
- return nullptr;
- }
-
- GrallocError err = mMapper->retain(clone);
- if (err != GrallocError::NONE) {
- native_handle_close(clone);
- native_handle_delete(const_cast<native_handle_t*>(clone));
- return nullptr;
- }
-
- return clone;
- }
-
- const native_handle_t* allocate(
- const IAllocatorClient::BufferDescriptorInfo& info) {
- // create descriptor
- GrallocError err = GrallocError::NO_RESOURCES;
- BufferDescriptor descriptor;
- mAllocatorClient->createDescriptor(
- info, [&](const auto& tmpError, const auto& tmpDescriptor) {
- err = tmpError;
- descriptor = tmpDescriptor;
- });
- if (err != GrallocError::NONE) {
- return nullptr;
- }
-
- // allocate buffer
- hidl_vec<BufferDescriptor> descriptors;
- hidl_vec<Buffer> buffers;
- descriptors.setToExternal(&descriptor, 1);
- err = GrallocError::NO_RESOURCES;
- mAllocatorClient->allocate(
- descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
- err = tmpError;
- buffers = tmpBuffers;
- });
- if ((err != GrallocError::NONE && err != GrallocError::NOT_SHARED) ||
- buffers.size() != 1) {
- mAllocatorClient->destroyDescriptor(descriptors[0]);
- return nullptr;
- }
-
- // export handle
- err = GrallocError::NO_RESOURCES;
- const native_handle_t* handle = nullptr;
- mAllocatorClient->exportHandle(
- descriptors[0], buffers[0],
- [&](const auto& tmpError, const auto& tmpHandle) {
- err = tmpError;
- if (err != GrallocError::NONE) {
- return;
- }
-
- handle = cloneBuffer(tmpHandle.getNativeHandle());
- if (!handle) {
- err = GrallocError::NO_RESOURCES;
- return;
- }
- });
-
- mAllocatorClient->destroyDescriptor(descriptors[0]);
- mAllocatorClient->free(buffers[0]);
-
- if (err != GrallocError::NONE) {
- return nullptr;
- }
-
- return handle;
- }
-
const native_handle_t* allocate() {
IAllocatorClient::BufferDescriptorInfo info{};
info.width = 64;
@@ -666,12 +430,7 @@
info.producerUsageMask = static_cast<uint64_t>(ProducerUsage::CPU_WRITE);
info.consumerUsageMask = static_cast<uint64_t>(ConsumerUsage::CPU_READ);
- return allocate(info);
- }
-
- void free(const native_handle_t* handle) {
- auto ret = mMapper->release(handle);
- ASSERT_EQ(GrallocError::NONE, static_cast<GrallocError>(ret));
+ return mMapper->allocate(mAllocatorClient, info);
}
void execute() {
@@ -682,20 +441,20 @@
mWriter->writeQueue(&queueChanged, &commandLength, &commandHandles));
if (queueChanged) {
- auto ret =
- mComposerClient->setInputCommandQueue(*mWriter->getMQDescriptor());
+ auto ret = mComposerClient->getRaw()->setInputCommandQueue(
+ *mWriter->getMQDescriptor());
ASSERT_EQ(Error::NONE, static_cast<Error>(ret));
return;
}
- mComposerClient->executeCommands(
+ mComposerClient->getRaw()->executeCommands(
commandLength, commandHandles,
[&](const auto& tmpError, const auto& tmpOutQueueChanged,
const auto& tmpOutLength, const auto& tmpOutHandles) {
ASSERT_EQ(Error::NONE, tmpError);
if (tmpOutQueueChanged) {
- mComposerClient->getOutputCommandQueue(
+ mComposerClient->getRaw()->getOutputCommandQueue(
[&](const auto& tmpError, const auto& tmpDescriptor) {
ASSERT_EQ(Error::NONE, tmpError);
mReader->setMQDescriptor(tmpDescriptor);
@@ -748,25 +507,9 @@
std::unique_ptr<CommandReader> mReader;
private:
- void SetUpGralloc() {
- mAllocator = ::testing::VtsHalHidlTargetBaseTest::getService<IAllocator>();
- ASSERT_NE(nullptr, mAllocator.get());
-
- mAllocator->createClient([this](const auto& error, const auto& client) {
- if (error == GrallocError::NONE) {
- mAllocatorClient = client;
- }
- });
- ASSERT_NE(nullptr, mAllocatorClient.get());
-
- mMapper = ::testing::VtsHalHidlTargetBaseTest::getService<IMapper>();
- ASSERT_NE(nullptr, mMapper.get());
- ASSERT_FALSE(mMapper->isRemote());
- }
-
- sp<IAllocator> mAllocator;
- sp<IAllocatorClient> mAllocatorClient;
- sp<IMapper> mMapper;
+ std::unique_ptr<Allocator> mAllocator;
+ std::unique_ptr<AllocatorClient> mAllocatorClient;
+ std::unique_ptr<Mapper> mMapper;
};
/**
@@ -801,22 +544,23 @@
* Test IComposerClient::Command::SET_OUTPUT_BUFFER.
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_OUTPUT_BUFFER) {
- auto handle = allocate();
- ASSERT_NE(nullptr, handle);
-
- Display display;
- Error err = createVirtualDisplay(&display);
- if (err == Error::UNSUPPORTED) {
+ if (mComposerClient->getMaxVirtualDisplayCount() == 0) {
GTEST_SUCCEED() << "no virtual display support";
return;
}
- ASSERT_EQ(Error::NONE, err);
+
+ Display display;
+ PixelFormat format;
+ ASSERT_NO_FATAL_FAILURE(display = mComposerClient->createVirtualDisplay(
+ 64, 64, PixelFormat::IMPLEMENTATION_DEFINED,
+ kBufferSlotCount, &format));
+
+ const native_handle_t* handle;
+ ASSERT_NO_FATAL_FAILURE(handle = allocate());
mWriter->selectDisplay(display);
mWriter->setOutputBuffer(0, handle, -1);
-
- destroyVirtualDisplay(display);
- free(handle);
+ execute();
}
/**
@@ -853,16 +597,14 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_CURSOR_POSITION) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerCursorPosition(1, 1);
mWriter->setLayerCursorPosition(0, 0);
execute();
-
- destroyLayer(layer);
}
/**
@@ -873,16 +615,13 @@
ASSERT_NE(nullptr, handle);
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerBuffer(0, handle, -1);
execute();
-
- destroyLayer(layer);
- free(handle);
}
/**
@@ -890,8 +629,8 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_SURFACE_DAMAGE) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
IComposerClient::Rect empty{0, 0, 0, 0};
IComposerClient::Rect unit{0, 0, 1, 1};
@@ -902,8 +641,6 @@
mWriter->setLayerSurfaceDamage(std::vector<IComposerClient::Rect>(1, unit));
mWriter->setLayerSurfaceDamage(std::vector<IComposerClient::Rect>());
execute();
-
- destroyLayer(layer);
}
/**
@@ -911,8 +648,8 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_BLEND_MODE) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
@@ -920,8 +657,6 @@
mWriter->setLayerBlendMode(IComposerClient::BlendMode::PREMULTIPLIED);
mWriter->setLayerBlendMode(IComposerClient::BlendMode::COVERAGE);
execute();
-
- destroyLayer(layer);
}
/**
@@ -929,16 +664,14 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_COLOR) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerColor(IComposerClient::Color{0xff, 0xff, 0xff, 0xff});
mWriter->setLayerColor(IComposerClient::Color{0, 0, 0, 0});
execute();
-
- destroyLayer(layer);
}
/**
@@ -946,8 +679,8 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_COMPOSITION_TYPE) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
@@ -956,8 +689,6 @@
mWriter->setLayerCompositionType(IComposerClient::Composition::SOLID_COLOR);
mWriter->setLayerCompositionType(IComposerClient::Composition::CURSOR);
execute();
-
- destroyLayer(layer);
}
/**
@@ -965,15 +696,13 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_DATASPACE) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerDataspace(Dataspace::UNKNOWN);
execute();
-
- destroyLayer(layer);
}
/**
@@ -981,15 +710,13 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_DISPLAY_FRAME) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerDisplayFrame(IComposerClient::Rect{0, 0, 1, 1});
execute();
-
- destroyLayer(layer);
}
/**
@@ -997,23 +724,21 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_PLANE_ALPHA) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerPlaneAlpha(0.0f);
mWriter->setLayerPlaneAlpha(1.0f);
execute();
-
- destroyLayer(layer);
}
/**
* Test IComposerClient::Command::SET_LAYER_SIDEBAND_STREAM.
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_SIDEBAND_STREAM) {
- if (!hasCapability(IComposer::Capability::SIDEBAND_STREAM)) {
+ if (!mComposer->hasCapability(IComposer::Capability::SIDEBAND_STREAM)) {
GTEST_SUCCEED() << "no sideband stream support";
return;
}
@@ -1022,16 +747,13 @@
ASSERT_NE(nullptr, handle);
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerSidebandStream(handle);
execute();
-
- destroyLayer(layer);
- free(handle);
}
/**
@@ -1039,15 +761,13 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_SOURCE_CROP) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerSourceCrop(IComposerClient::FRect{0.0f, 0.0f, 1.0f, 1.0f});
execute();
-
- destroyLayer(layer);
}
/**
@@ -1055,8 +775,8 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_TRANSFORM) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
@@ -1071,8 +791,6 @@
mWriter->setLayerTransform(
static_cast<Transform>(Transform::FLIP_V | Transform::ROT_90));
execute();
-
- destroyLayer(layer);
}
/**
@@ -1080,8 +798,8 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_VISIBLE_REGION) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
IComposerClient::Rect empty{0, 0, 0, 0};
IComposerClient::Rect unit{0, 0, 1, 1};
@@ -1092,8 +810,6 @@
mWriter->setLayerVisibleRegion(std::vector<IComposerClient::Rect>(1, unit));
mWriter->setLayerVisibleRegion(std::vector<IComposerClient::Rect>());
execute();
-
- destroyLayer(layer);
}
/**
@@ -1101,16 +817,14 @@
*/
TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_Z_ORDER) {
Layer layer;
- Error err = createLayer(&layer);
- ASSERT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(
+ layer = mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
mWriter->selectDisplay(mPrimaryDisplay);
mWriter->selectLayer(layer);
mWriter->setLayerZOrder(10);
mWriter->setLayerZOrder(0);
execute();
-
- destroyLayer(layer);
}
} // namespace anonymous
diff --git a/graphics/mapper/2.0/default/Android.bp b/graphics/mapper/2.0/default/Android.bp
index 7e98faa..1dc5aea 100644
--- a/graphics/mapper/2.0/default/Android.bp
+++ b/graphics/mapper/2.0/default/Android.bp
@@ -15,6 +15,7 @@
cc_library_shared {
name: "android.hardware.graphics.mapper@2.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["GrallocMapper.cpp"],
diff --git a/graphics/mapper/2.0/default/GrallocMapper.cpp b/graphics/mapper/2.0/default/GrallocMapper.cpp
index 3b6460a..526aca2 100644
--- a/graphics/mapper/2.0/default/GrallocMapper.cpp
+++ b/graphics/mapper/2.0/default/GrallocMapper.cpp
@@ -127,7 +127,7 @@
void GrallocMapperHal::initCapabilities()
{
- uint32_t count;
+ uint32_t count = 0;
mDevice->getCapabilities(mDevice, &count, nullptr);
std::vector<int32_t> caps(count);
diff --git a/graphics/mapper/2.0/vts/functional/Android.bp b/graphics/mapper/2.0/vts/functional/Android.bp
index 24cd1be..e26f087 100644
--- a/graphics/mapper/2.0/vts/functional/Android.bp
+++ b/graphics/mapper/2.0/vts/functional/Android.bp
@@ -14,8 +14,31 @@
// limitations under the License.
//
+cc_library_static {
+ name: "libVtsHalGraphicsMapperTestUtils",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalGraphicsMapperTestUtils.cpp"],
+ shared_libs: [
+ "android.hardware.graphics.allocator@2.0",
+ "android.hardware.graphics.mapper@2.0",
+ ],
+ static_libs: [
+ "VtsHalHidlTargetTestBase",
+ "libVtsHalGraphicsAllocatorTestUtils",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-O0",
+ "-g",
+ ],
+ export_include_dirs: ["."],
+}
+
cc_test {
name: "VtsHalGraphicsMapperV2_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalGraphicsMapperV2_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -30,8 +53,15 @@
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.common@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: [
+ "libVtsHalGraphicsAllocatorTestUtils",
+ "libVtsHalGraphicsMapperTestUtils",
+ "VtsHalHidlTargetTestBase",
+ ],
cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
"-O0",
"-g",
]
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
new file mode 100644
index 0000000..f6a26ac
--- /dev/null
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2017 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 <VtsHalHidlTargetTestBase.h>
+
+#include "VtsHalGraphicsMapperTestUtils.h"
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace mapper {
+namespace V2_0 {
+namespace tests {
+
+using android::hardware::graphics::allocator::V2_0::Buffer;
+using android::hardware::graphics::allocator::V2_0::BufferDescriptor;
+using android::hardware::graphics::allocator::V2_0::Error;
+
+Mapper::Mapper() { init(); }
+
+void Mapper::init() {
+ mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>();
+ ASSERT_NE(nullptr, mMapper.get()) << "failed to get mapper service";
+ ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
+}
+
+Mapper::~Mapper() {
+ for (auto it : mHandles) {
+ while (it.second) {
+ EXPECT_EQ(Error::NONE, mMapper->release(it.first))
+ << "failed to release handle " << it.first;
+ it.second--;
+ }
+ }
+ mHandles.clear();
+}
+
+sp<IMapper> Mapper::getRaw() const { return mMapper; }
+
+void Mapper::retain(const native_handle_t* handle) {
+ Error error = mMapper->retain(handle);
+ ASSERT_EQ(Error::NONE, error) << "failed to retain handle " << handle;
+
+ mHandles[handle]++;
+}
+
+void Mapper::release(const native_handle_t* handle) {
+ Error error = mMapper->release(handle);
+ ASSERT_EQ(Error::NONE, error) << "failed to release handle " << handle;
+
+ if (--mHandles[handle] == 0) {
+ mHandles.erase(handle);
+ }
+}
+
+Mapper::Dimensions Mapper::getDimensions(const native_handle_t* handle) {
+ Dimensions dimensions = {};
+ mMapper->getDimensions(handle, [&](const auto& tmpError, const auto& tmpWidth,
+ const auto& tmpHeight) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get dimensions for handle " << handle;
+ dimensions.width = tmpWidth;
+ dimensions.height = tmpHeight;
+ });
+
+ return dimensions;
+}
+
+PixelFormat Mapper::getFormat(const native_handle_t* handle) {
+ PixelFormat format = static_cast<PixelFormat>(0);
+ mMapper->getFormat(handle, [&](const auto& tmpError, const auto& tmpFormat) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get format for handle " << handle;
+ format = tmpFormat;
+ });
+
+ return format;
+}
+
+uint32_t Mapper::getLayerCount(const native_handle_t* handle) {
+ uint32_t count = 0;
+ mMapper->getLayerCount(
+ handle, [&](const auto& tmpError, const auto& tmpCount) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get layer count for handle " << handle;
+ count = tmpCount;
+ });
+
+ return count;
+}
+
+uint64_t Mapper::getProducerUsageMask(const native_handle_t* handle) {
+ uint64_t usageMask = 0;
+ mMapper->getProducerUsageMask(
+ handle, [&](const auto& tmpError, const auto& tmpUsageMask) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get producer usage mask for handle " << handle;
+ usageMask = tmpUsageMask;
+ });
+
+ return usageMask;
+}
+
+uint64_t Mapper::getConsumerUsageMask(const native_handle_t* handle) {
+ uint64_t usageMask = 0;
+ mMapper->getConsumerUsageMask(
+ handle, [&](const auto& tmpError, const auto& tmpUsageMask) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get consumer usage mask for handle " << handle;
+ usageMask = tmpUsageMask;
+ });
+
+ return usageMask;
+}
+
+BackingStore Mapper::getBackingStore(const native_handle_t* handle) {
+ BackingStore backingStore = 0;
+ mMapper->getBackingStore(
+ handle, [&](const auto& tmpError, const auto& tmpBackingStore) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get backing store for handle " << handle;
+ backingStore = tmpBackingStore;
+ });
+
+ return backingStore;
+}
+
+uint32_t Mapper::getStride(const native_handle_t* handle) {
+ uint32_t stride = 0;
+ mMapper->getStride(handle, [&](const auto& tmpError, const auto& tmpStride) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to get stride for handle " << handle;
+ stride = tmpStride;
+ });
+
+ return stride;
+}
+
+void* Mapper::lock(const native_handle_t* handle, uint64_t producerUsageMask,
+ uint64_t consumerUsageMask,
+ const IMapper::Rect& accessRegion, int acquireFence) {
+ NATIVE_HANDLE_DECLARE_STORAGE(acquireFenceStorage, 0, 1);
+ native_handle_t* acquireFenceHandle = nullptr;
+ if (acquireFence >= 0) {
+ acquireFenceHandle = native_handle_init(acquireFenceStorage, 0, 1);
+ acquireFenceHandle->data[0] = acquireFence;
+ }
+
+ void* data = nullptr;
+ mMapper->lock(
+ handle, producerUsageMask, consumerUsageMask, accessRegion,
+ acquireFenceHandle, [&](const auto& tmpError, const auto& tmpData) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to lock handle " << handle;
+ data = tmpData;
+ });
+
+ if (acquireFence >= 0) {
+ close(acquireFence);
+ }
+
+ return data;
+}
+
+FlexLayout Mapper::lockFlex(const native_handle_t* handle,
+ uint64_t producerUsageMask,
+ uint64_t consumerUsageMask,
+ const IMapper::Rect& accessRegion,
+ int acquireFence) {
+ NATIVE_HANDLE_DECLARE_STORAGE(acquireFenceStorage, 0, 1);
+ native_handle_t* acquireFenceHandle = nullptr;
+ if (acquireFence >= 0) {
+ acquireFenceHandle = native_handle_init(acquireFenceStorage, 0, 1);
+ acquireFenceHandle->data[0] = acquireFence;
+ }
+
+ FlexLayout layout = {};
+ mMapper->lockFlex(handle, producerUsageMask, consumerUsageMask, accessRegion,
+ acquireFenceHandle,
+ [&](const auto& tmpError, const auto& tmpLayout) {
+ ASSERT_EQ(Error::NONE, tmpError)
+ << "failed to lockFlex handle " << handle;
+ layout = tmpLayout;
+ });
+
+ if (acquireFence >= 0) {
+ close(acquireFence);
+ }
+
+ return layout;
+}
+
+int Mapper::unlock(const native_handle_t* handle) {
+ int releaseFence = -1;
+ mMapper->unlock(handle, [&](const auto& tmpError,
+ const auto& tmpReleaseFence) {
+ ASSERT_EQ(Error::NONE, tmpError) << "failed to unlock handle " << handle;
+
+ auto handle = tmpReleaseFence.getNativeHandle();
+ if (handle) {
+ ASSERT_EQ(0, handle->numInts) << "invalid fence handle " << handle;
+ if (handle->numFds == 1) {
+ releaseFence = dup(handle->data[0]);
+ ASSERT_LT(0, releaseFence) << "failed to dup fence fd";
+ } else {
+ ASSERT_EQ(0, handle->numFds) << " invalid fence handle " << handle;
+ }
+ }
+ });
+
+ return releaseFence;
+}
+
+const native_handle_t* Mapper::allocate(
+ std::unique_ptr<AllocatorClient>& allocatorClient,
+ const IAllocatorClient::BufferDescriptorInfo& info) {
+ BufferDescriptor descriptor = allocatorClient->createDescriptor(info);
+ if (::testing::Test::HasFatalFailure()) {
+ return nullptr;
+ }
+
+ Buffer buffer = allocatorClient->allocate(descriptor);
+ if (::testing::Test::HasFatalFailure()) {
+ allocatorClient->destroyDescriptor(descriptor);
+ return nullptr;
+ }
+
+ const native_handle_t* handle =
+ allocatorClient->exportHandle(descriptor, buffer);
+ if (handle) {
+ retain(handle);
+ }
+
+ allocatorClient->free(buffer);
+ allocatorClient->destroyDescriptor(descriptor);
+
+ return handle;
+}
+
+} // namespace tests
+} // namespace V2_0
+} // namespace mapper
+} // namespace graphics
+} // namespace hardware
+} // namespace android
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h
new file mode 100644
index 0000000..c186b00
--- /dev/null
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef VTS_HAL_GRAPHICS_MAPPER_UTILS
+#define VTS_HAL_GRAPHICS_MAPPER_UTILS
+
+#include <memory>
+#include <unordered_map>
+
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <utils/StrongPointer.h>
+
+#include "VtsHalGraphicsAllocatorTestUtils.h"
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace mapper {
+namespace V2_0 {
+namespace tests {
+
+using android::hardware::graphics::common::V1_0::PixelFormat;
+using android::hardware::graphics::allocator::V2_0::IAllocatorClient;
+using android::hardware::graphics::allocator::V2_0::tests::AllocatorClient;
+
+// A wrapper to IMapper.
+class Mapper {
+ public:
+ Mapper();
+ ~Mapper();
+
+ sp<IMapper> getRaw() const;
+
+ void retain(const native_handle_t* handle);
+ void release(const native_handle_t* handle);
+
+ struct Dimensions {
+ uint32_t width;
+ uint32_t height;
+ };
+ Dimensions getDimensions(const native_handle_t* handle);
+
+ PixelFormat getFormat(const native_handle_t* handle);
+ uint32_t getLayerCount(const native_handle_t* handle);
+ uint64_t getProducerUsageMask(const native_handle_t* handle);
+ uint64_t getConsumerUsageMask(const native_handle_t* handle);
+ BackingStore getBackingStore(const native_handle_t* handle);
+ uint32_t getStride(const native_handle_t* handle);
+
+ // We use fd instead of hidl_handle in these functions to pass fences
+ // in and out of the mapper. The ownership of the fd is always transferred
+ // with each of these functions.
+ void* lock(const native_handle_t* handle, uint64_t producerUsageMask,
+ uint64_t consumerUsageMask, const IMapper::Rect& accessRegion,
+ int acquireFence);
+ FlexLayout lockFlex(const native_handle_t* handle, uint64_t producerUsageMask,
+ uint64_t consumerUsageMask,
+ const IMapper::Rect& accessRegion, int acquireFence);
+ int unlock(const native_handle_t* handle);
+
+ // Requests AllocatorClient to allocate a buffer, export the handle, and
+ // register the handle with mapper.
+ const native_handle_t* allocate(
+ std::unique_ptr<AllocatorClient>& allocatorClient,
+ const IAllocatorClient::BufferDescriptorInfo& info);
+
+ private:
+ void init();
+
+ sp<IMapper> mMapper;
+
+ // Keep track of all registered (retained) handles. When a test fails with
+ // ASSERT_*, the destructor will release the handles for the test.
+ std::unordered_map<const native_handle_t*, uint64_t> mHandles;
+};
+
+} // namespace tests
+} // namespace V2_0
+} // namespace mapper
+} // namespace graphics
+} // namespace hardware
+} // namespace android
+
+#endif // VTS_HAL_GRAPHICS_MAPPER_UTILS
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
index b2a37dd..92d74d5 100644
--- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
@@ -17,10 +17,9 @@
#define LOG_TAG "graphics_mapper_hidl_hal_test"
#include <android-base/logging.h>
-#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
-#include <android/hardware/graphics/mapper/2.0/IMapper.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <sync/sync.h>
+#include "VtsHalGraphicsMapperTestUtils.h"
namespace android {
namespace hardware {
@@ -31,24 +30,14 @@
namespace {
using namespace android::hardware::graphics::allocator::V2_0;
-using namespace android::hardware::graphics::common::V1_0;
+using namespace android::hardware::graphics::allocator::V2_0::tests;
-class GraphicsMapperHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GraphicsMapperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
- mAllocator = ::testing::VtsHalHidlTargetBaseTest::getService<IAllocator>();
- ASSERT_NE(mAllocator, nullptr);
-
- mAllocator->createClient([this](const auto& error, const auto& client) {
- if (error == Error::NONE) {
- mAllocatorClient = client;
- }
- });
- ASSERT_NE(mAllocatorClient, nullptr);
-
- mMapper = ::testing::VtsHalHidlTargetBaseTest::getService<IMapper>();
- ASSERT_NE(nullptr, mMapper.get());
- ASSERT_FALSE(mMapper->isRemote());
+ ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
+ ASSERT_NO_FATAL_FAILURE(mAllocatorClient = mAllocator->createClient());
+ ASSERT_NO_FATAL_FAILURE(mMapper = std::make_unique<Mapper>());
mDummyDescriptorInfo.width = 64;
mDummyDescriptorInfo.height = 64;
@@ -62,134 +51,51 @@
void TearDown() override {}
- const native_handle_t* allocate(
- const IAllocatorClient::BufferDescriptorInfo& info) {
- // create descriptor
- Error err = Error::NO_RESOURCES;
- BufferDescriptor descriptor;
- mAllocatorClient->createDescriptor(
- info, [&](const auto& tmpError, const auto& tmpDescriptor) {
- err = tmpError;
- descriptor = tmpDescriptor;
- });
- if (err != Error::NONE) {
- return nullptr;
- }
-
- // allocate buffer
- hidl_vec<BufferDescriptor> descriptors;
- hidl_vec<Buffer> buffers;
- descriptors.setToExternal(&descriptor, 1);
- err = Error::NO_RESOURCES;
- mAllocatorClient->allocate(
- descriptors, [&](const auto& tmpError, const auto& tmpBuffers) {
- err = tmpError;
- buffers = tmpBuffers;
- });
- if ((err != Error::NONE && err != Error::NOT_SHARED) ||
- buffers.size() != 1) {
- mAllocatorClient->destroyDescriptor(descriptors[0]);
- return nullptr;
- }
-
- // export handle
- err = Error::NO_RESOURCES;
- const native_handle_t* handle = nullptr;
- mAllocatorClient->exportHandle(
- descriptors[0], buffers[0],
- [&](const auto& tmpError, const auto& tmpHandle) {
- err = tmpError;
- if (err != Error::NONE) {
- return;
- }
-
- handle = native_handle_clone(tmpHandle);
- if (!handle) {
- err = Error::NO_RESOURCES;
- return;
- }
-
- err = mMapper->retain(handle);
- if (err != Error::NONE) {
- native_handle_close(handle);
- native_handle_delete(const_cast<native_handle_t*>(handle));
- handle = nullptr;
- }
- });
-
- mAllocatorClient->destroyDescriptor(descriptors[0]);
- mAllocatorClient->free(buffers[0]);
-
- if (err != Error::NONE) {
- return nullptr;
- }
-
- return handle;
- }
-
- sp<IMapper> mMapper;
-
+ std::unique_ptr<Allocator> mAllocator;
+ std::unique_ptr<AllocatorClient> mAllocatorClient;
+ std::unique_ptr<Mapper> mMapper;
IAllocatorClient::BufferDescriptorInfo mDummyDescriptorInfo{};
-
- private:
- sp<IAllocator> mAllocator;
- sp<IAllocatorClient> mAllocatorClient;
};
/**
* Test IMapper::retain and IMapper::release.
*/
TEST_F(GraphicsMapperHidlTest, RetainRelease) {
- const native_handle_t* buffer = allocate(mDummyDescriptorInfo);
- ASSERT_NE(buffer, nullptr);
+ const native_handle_t* buffer;
+ ASSERT_NO_FATAL_FAILURE(
+ buffer = mMapper->allocate(mAllocatorClient, mDummyDescriptorInfo));
const int maxRefs = 10;
for (int i = 0; i < maxRefs; i++) {
- auto err = mMapper->retain(buffer);
- EXPECT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(mMapper->retain(buffer));
}
for (int i = 0; i < maxRefs; i++) {
- auto err = mMapper->release(buffer);
- EXPECT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(mMapper->release(buffer));
}
- auto err = mMapper->release(buffer);
- EXPECT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(mMapper->release(buffer));
}
/**
* Test IMapper::get* getters.
*/
TEST_F(GraphicsMapperHidlTest, Getters) {
- const native_handle_t* buffer = allocate(mDummyDescriptorInfo);
- ASSERT_NE(buffer, nullptr);
+ const native_handle_t* buffer;
+ ASSERT_NO_FATAL_FAILURE(
+ buffer = mMapper->allocate(mAllocatorClient, mDummyDescriptorInfo));
- Error err = Error::NO_RESOURCES;
- IAllocatorClient::BufferDescriptorInfo info{};
- mMapper->getDimensions(buffer, [&](const auto& tmpError, const auto& tmpWidth,
- const auto& tmpHeight) {
- err = tmpError;
- info.width = tmpWidth;
- info.height = tmpHeight;
- });
- EXPECT_EQ(Error::NONE, err);
- mMapper->getFormat(buffer, [&](const auto& tmpError, const auto& tmpFormat) {
- err = tmpError;
- info.format = tmpFormat;
- });
- EXPECT_EQ(Error::NONE, err);
- mMapper->getProducerUsageMask(
- buffer, [&](const auto& tmpError, const auto& tmpUsage) {
- err = tmpError;
- info.producerUsageMask = tmpUsage;
- });
- EXPECT_EQ(Error::NONE, err);
- mMapper->getConsumerUsageMask(
- buffer, [&](const auto& tmpError, const auto& tmpUsage) {
- err = tmpError;
- info.consumerUsageMask = tmpUsage;
- });
- EXPECT_EQ(Error::NONE, err);
+ IAllocatorClient::BufferDescriptorInfo info = {};
+
+ Mapper::Dimensions dimensions;
+ ASSERT_NO_FATAL_FAILURE(dimensions = mMapper->getDimensions(buffer));
+ info.width = dimensions.width;
+ info.height = dimensions.height;
+
+ ASSERT_NO_FATAL_FAILURE(info.format = mMapper->getFormat(buffer));
+ ASSERT_NO_FATAL_FAILURE(info.producerUsageMask =
+ mMapper->getProducerUsageMask(buffer));
+ ASSERT_NO_FATAL_FAILURE(info.consumerUsageMask =
+ mMapper->getConsumerUsageMask(buffer));
EXPECT_EQ(mDummyDescriptorInfo.width, info.width);
EXPECT_EQ(mDummyDescriptorInfo.height, info.height);
@@ -197,24 +103,11 @@
EXPECT_EQ(mDummyDescriptorInfo.producerUsageMask, info.producerUsageMask);
EXPECT_EQ(mDummyDescriptorInfo.consumerUsageMask, info.consumerUsageMask);
- BackingStore store = 0;
- mMapper->getBackingStore(buffer,
- [&](const auto& tmpError, const auto& tmpStore) {
- err = tmpError;
- store = tmpStore;
- });
- EXPECT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(mMapper->getBackingStore(buffer));
- uint32_t stride = 0;
- mMapper->getStride(buffer, [&](const auto& tmpError, const auto& tmpStride) {
- err = tmpError;
- stride = tmpStride;
- });
- EXPECT_EQ(Error::NONE, err);
+ uint32_t stride;
+ ASSERT_NO_FATAL_FAILURE(stride = mMapper->getStride(buffer));
EXPECT_LE(info.width, stride);
-
- err = mMapper->release(buffer);
- EXPECT_EQ(Error::NONE, err);
}
/**
@@ -222,79 +115,113 @@
*/
TEST_F(GraphicsMapperHidlTest, LockBasic) {
const auto& info = mDummyDescriptorInfo;
- const native_handle_t* buffer = allocate(info);
- ASSERT_NE(buffer, nullptr);
- Error err = Error::NO_RESOURCES;
- uint32_t stride = 0;
- mMapper->getStride(buffer, [&](const auto& tmpError, const auto& tmpStride) {
- err = tmpError;
- stride = tmpStride;
- });
- EXPECT_EQ(Error::NONE, err);
+ const native_handle_t* buffer;
+ ASSERT_NO_FATAL_FAILURE(
+ buffer = mMapper->allocate(mAllocatorClient, mDummyDescriptorInfo));
+
+ uint32_t stride;
+ ASSERT_NO_FATAL_FAILURE(stride = mMapper->getStride(buffer));
// lock buffer for writing
const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
static_cast<int32_t>(info.height)};
- hidl_handle acquireFence(nullptr);
+ int fence = -1;
uint32_t* data;
- err = Error::NO_RESOURCES;
- mMapper->lock(buffer, info.producerUsageMask, 0, region, acquireFence,
- [&](const auto& tmpError, const auto& tmpData) {
- err = tmpError;
- data = static_cast<uint32_t*>(tmpData);
- });
+ ASSERT_NO_FATAL_FAILURE(
+ data = static_cast<uint32_t*>(
+ mMapper->lock(buffer, info.producerUsageMask, 0, region, fence)));
- if (err == Error::NONE) {
- for (uint32_t y = 0; y < info.height; y++) {
- for (uint32_t x = 0; x < info.width; x++) {
- data[stride * y + x] = info.height * y + x;
- }
+ for (uint32_t y = 0; y < info.height; y++) {
+ for (uint32_t x = 0; x < info.width; x++) {
+ data[stride * y + x] = info.height * y + x;
}
- } else {
- EXPECT_EQ(Error::NONE, err);
}
- err = Error::NO_RESOURCES;
- mMapper->unlock(buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
- err = tmpError;
- auto handle = tmpReleaseFence.getNativeHandle();
- if (handle && handle->numFds == 1) {
- sync_wait(handle->data[0], -1);
- close(handle->data[0]);
- }
- });
- EXPECT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
// lock buffer for reading
- mMapper->lock(buffer, 0, info.consumerUsageMask, region, acquireFence,
- [&](const auto& tmpError, const auto& tmpData) {
- err = tmpError;
- data = static_cast<uint32_t*>(tmpData);
- });
- if (err == Error::NONE) {
- for (uint32_t y = 0; y < info.height; y++) {
- for (uint32_t x = 0; x < info.width; x++) {
- EXPECT_EQ(info.height * y + x, data[stride * y + x]);
- }
+ ASSERT_NO_FATAL_FAILURE(
+ data = static_cast<uint32_t*>(
+ mMapper->lock(buffer, 0, info.consumerUsageMask, region, fence)));
+ for (uint32_t y = 0; y < info.height; y++) {
+ for (uint32_t x = 0; x < info.width; x++) {
+ EXPECT_EQ(info.height * y + x, data[stride * y + x]);
}
- } else {
- EXPECT_EQ(Error::NONE, err);
}
- err = Error::NO_RESOURCES;
- mMapper->unlock(buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
- err = tmpError;
- auto handle = tmpReleaseFence.getNativeHandle();
- if (handle && handle->numFds == 1) {
- sync_wait(handle->data[0], -1);
- close(handle->data[0]);
- }
- });
- EXPECT_EQ(Error::NONE, err);
+ ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
+ if (fence >= 0) {
+ close(fence);
+ }
+}
- err = mMapper->release(buffer);
- EXPECT_EQ(Error::NONE, err);
+/**
+ * Test IMapper::lockFlex. This locks a YV12 buffer, and makes sure we can
+ * write to and read from it.
+ */
+TEST_F(GraphicsMapperHidlTest, LockFlexBasic) {
+ auto info = mDummyDescriptorInfo;
+ info.format = PixelFormat::YV12;
+
+ const native_handle_t* buffer;
+ ASSERT_NO_FATAL_FAILURE(buffer = mMapper->allocate(mAllocatorClient, info));
+
+ // lock buffer for writing
+ const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
+ static_cast<int32_t>(info.height)};
+ int fence = -1;
+ FlexLayout layout;
+ ASSERT_NO_FATAL_FAILURE(
+ layout =
+ mMapper->lockFlex(buffer, info.producerUsageMask, 0, region, fence));
+ ASSERT_EQ(FlexFormat::YCBCR, layout.format);
+ ASSERT_EQ(3u, layout.planes.size());
+
+ const auto y_stride = layout.planes[0].vIncrement;
+ const auto c_stride = layout.planes[1].vIncrement;
+ auto y_data = static_cast<uint8_t*>(layout.planes[0].topLeft);
+ auto cb_data = static_cast<uint8_t*>(layout.planes[1].topLeft);
+ auto cr_data = static_cast<uint8_t*>(layout.planes[2].topLeft);
+
+ for (uint32_t y = 0; y < info.height; y++) {
+ for (uint32_t x = 0; x < info.width; x++) {
+ auto val = static_cast<uint8_t>(info.height * y + x);
+
+ y_data[y_stride * y + x] = val;
+ if (y % 2 == 0 && x % 2 == 0) {
+ cb_data[c_stride * y / 2 + x / 2] = val;
+ cr_data[c_stride * y / 2 + x / 2] = val;
+ }
+ }
+ }
+
+ ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
+
+ // lock buffer for reading
+ ASSERT_NO_FATAL_FAILURE(
+ layout =
+ mMapper->lockFlex(buffer, 0, info.consumerUsageMask, region, fence));
+
+ y_data = static_cast<uint8_t*>(layout.planes[0].topLeft);
+ cb_data = static_cast<uint8_t*>(layout.planes[1].topLeft);
+ cr_data = static_cast<uint8_t*>(layout.planes[2].topLeft);
+ for (uint32_t y = 0; y < info.height; y++) {
+ for (uint32_t x = 0; x < info.width; x++) {
+ auto val = static_cast<uint8_t>(info.height * y + x);
+
+ EXPECT_EQ(val, y_data[y_stride * y + x]);
+ if (y % 2 == 0 && x % 2 == 0) {
+ EXPECT_EQ(val, cb_data[c_stride * y / 2 + x / 2]);
+ EXPECT_EQ(val, cr_data[c_stride * y / 2 + x / 2]);
+ }
+ }
+ }
+
+ ASSERT_NO_FATAL_FAILURE(fence = mMapper->unlock(buffer));
+ if (fence >= 0) {
+ close(fence);
+ }
}
} // namespace anonymous
diff --git a/ir/1.0/default/Android.bp b/ir/1.0/default/Android.bp
index 151a9af..2b15387 100644
--- a/ir/1.0/default/Android.bp
+++ b/ir/1.0/default/Android.bp
@@ -14,6 +14,7 @@
// limitations under the License.
cc_library_shared {
name: "android.hardware.ir@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: ["ConsumerIr.cpp"],
@@ -29,6 +30,7 @@
cc_binary {
relative_install_path: "hw",
+ defaults: ["hidl_defaults"],
name: "android.hardware.ir@1.0-service",
proprietary: true,
init_rc: ["android.hardware.ir@1.0-service.rc"],
diff --git a/ir/1.0/vts/functional/Android.bp b/ir/1.0/vts/functional/Android.bp
index fe0a595..4aac297 100644
--- a/ir/1.0/vts/functional/Android.bp
+++ b/ir/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalIrV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalIrV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -26,7 +27,7 @@
"libutils",
"android.hardware.ir@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
index 605eabb..3dad3c1 100644
--- a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
+++ b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
@@ -21,7 +21,7 @@
#include <android/hardware/ir/1.0/IConsumerIr.h>
#include <android/hardware/ir/1.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <algorithm>
using ::android::hardware::ir::V1_0::IConsumerIr;
@@ -31,10 +31,10 @@
using ::android::sp;
// The main test class for IR HIDL HAL.
-class ConsumerIrHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class ConsumerIrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- ir = ::testing::VtsHalHidlTargetBaseTest::getService<IConsumerIr>();
+ ir = ::testing::VtsHalHidlTargetTestBase::getService<IConsumerIr>();
ASSERT_NE(ir, nullptr);
}
@@ -45,7 +45,6 @@
// Test transmit() for the min and max frequency of every available range
TEST_F(ConsumerIrHidlTest, TransmitTest) {
- int32_t freqs;
bool success;
hidl_vec<ConsumerIrFreqRange> ranges;
auto cb = [&](bool s, hidl_vec<ConsumerIrFreqRange> v) {
diff --git a/light/2.0/vts/functional/Android.bp b/light/2.0/vts/functional/Android.bp
index c21aa6b..0558ff2 100644
--- a/light/2.0/vts/functional/Android.bp
+++ b/light/2.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalLightV2_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalLightV2_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -24,7 +25,7 @@
"libutils",
"android.hardware.light@2.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
index 50b6d5f..3405422 100644
--- a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
+++ b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
@@ -19,7 +19,7 @@
#include <android-base/logging.h>
#include <android/hardware/light/2.0/ILight.h>
#include <android/hardware/light/2.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <set>
#include <unistd.h>
@@ -72,10 +72,10 @@
Type::WIFI
};
-class LightHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class LightHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- light = ::testing::VtsHalHidlTargetBaseTest::getService<ILight>();
+ light = ::testing::VtsHalHidlTargetTestBase::getService<ILight>();
ASSERT_NE(light, nullptr);
LOG(INFO) << "Test is remote " << light->isRemote();
diff --git a/media/omx/1.0/IGraphicBufferSource.hal b/media/omx/1.0/IGraphicBufferSource.hal
index 4dbfd32..62073ad 100644
--- a/media/omx/1.0/IGraphicBufferSource.hal
+++ b/media/omx/1.0/IGraphicBufferSource.hal
@@ -29,25 +29,25 @@
*/
interface IGraphicBufferSource {
- configure(IOmxNode omxNode, Dataspace dataspace);
+ configure(IOmxNode omxNode, Dataspace dataspace) generates (Status status);
- setSuspend(bool suspend, int64_t timeUs);
+ setSuspend(bool suspend, int64_t timeUs) generates (Status status);
- setRepeatPreviousFrameDelayUs(int64_t repeatAfterUs);
+ setRepeatPreviousFrameDelayUs(int64_t repeatAfterUs) generates (Status status);
- setMaxFps(float maxFps);
+ setMaxFps(float maxFps) generates (Status status);
- setTimeLapseConfig(int64_t timePerFrameUs, int64_t timePerCaptureUs);
+ setTimeLapseConfig(int64_t timePerFrameUs, int64_t timePerCaptureUs) generates (Status status);
- setStartTimeUs(int64_t startTimeUs);
+ setStartTimeUs(int64_t startTimeUs) generates (Status status);
- setStopTimeUs(int64_t stopTimeUs);
+ setStopTimeUs(int64_t stopTimeUs) generates (Status status);
- setColorAspects(ColorAspects aspects);
+ setColorAspects(ColorAspects aspects) generates (Status status);
- setTimeOffsetUs(int64_t timeOffsetUs);
+ setTimeOffsetUs(int64_t timeOffsetUs) generates (Status status);
- signalEndOfInputStream();
+ signalEndOfInputStream() generates (Status status);
};
diff --git a/memtrack/1.0/default/Android.bp b/memtrack/1.0/default/Android.bp
index dcb5025..76d7fc8 100644
--- a/memtrack/1.0/default/Android.bp
+++ b/memtrack/1.0/default/Android.bp
@@ -14,6 +14,7 @@
cc_library_shared {
name: "android.hardware.memtrack@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Memtrack.cpp"],
@@ -32,6 +33,7 @@
cc_binary {
relative_install_path: "hw",
+ defaults: ["hidl_defaults"],
proprietary: true,
name: "android.hardware.memtrack@1.0-service",
init_rc: ["android.hardware.memtrack@1.0-service.rc"],
diff --git a/memtrack/1.0/vts/functional/Android.bp b/memtrack/1.0/vts/functional/Android.bp
index 27781af..71e6111 100644
--- a/memtrack/1.0/vts/functional/Android.bp
+++ b/memtrack/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalMemtrackV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalMemtrackV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -26,7 +27,7 @@
"libutils",
"android.hardware.memtrack@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp
index 1113f42..a8d8aea 100644
--- a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp
+++ b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp
@@ -16,9 +16,11 @@
#define LOG_TAG "memtrack_hidl_hal_test"
#include <android-base/logging.h>
+#include <android-base/unique_fd.h>
+
#include <android/hardware/memtrack/1.0/IMemtrack.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <algorithm>
#include <vector>
@@ -31,13 +33,14 @@
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::sp;
+using ::android::base::unique_fd;
using std::vector;
using std::count_if;
-class MemtrackHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class MemtrackHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- memtrack = ::testing::VtsHalHidlTargetBaseTest::getService<IMemtrack>();
+ memtrack = ::testing::VtsHalHidlTargetTestBase::getService<IMemtrack>();
ASSERT_NE(memtrack, nullptr);
}
@@ -66,42 +69,6 @@
return std::find(statusVec.begin(), statusVec.end(), s) != statusVec.end();
}
-/* Returns a pid found in /proc for which the string read from
- * /proc/[pid]/cmdline matches cmd, or -1 if no such pid exists.
- */
-pid_t getPidFromCmd(const char cmd[], uint32_t len) {
- const char procs[] = "/proc/";
- DIR *dir = opendir(procs);
- if (!dir) {
- return -1;
- }
-
- struct dirent *proc;
- while ((proc = readdir(dir)) != NULL) {
- if (!isdigit(proc->d_name[0])) {
- continue;
- }
- char line[len];
- char fname[PATH_MAX];
- snprintf(fname, PATH_MAX, "/proc/%s/cmdline", proc->d_name);
-
- FILE *file = fopen(fname, "r");
- if (!file) {
- continue;
- }
- char *str = fgets(line, len, file);
- fclose(file);
- if (!str || strcmp(str, cmd)) {
- continue;
- } else {
- closedir(dir);
- return atoi(proc->d_name);
- }
- }
- closedir(dir);
- return -1;
-}
-
auto generate_cb(MemtrackStatus *s, hidl_vec<MemtrackRecord> *v) {
return [=](MemtrackStatus status, hidl_vec<MemtrackRecord> vec) {
*s = status;
@@ -135,15 +102,15 @@
ASSERT_TRUE(validStatus(s));
}
-/* Call memtrack on the surfaceflinger process and check that the results are
- * reasonable for all memory types, including valid flag combinations for
- * every MemtrackRecord returned.
+/* Call memtrack on this process and check that the results are reasonable
+ * for all memory types, including valid flag combinations for every
+ * MemtrackRecord returned.
*/
-TEST_F(MemtrackHidlTest, SurfaceflingerTest) {
- const char cmd[] = "/system/bin/surfaceflinger";
- const uint32_t len = sizeof(cmd);
- pid_t pid = getPidFromCmd(cmd, len);
- ASSERT_LE(0, pid) << "Surfaceflinger process not found";
+TEST_F(MemtrackHidlTest, GetMemoryTest) {
+ /* Opening this device causes the kernel to provide memtrack with memory
+ * info for this process.
+ */
+ unique_fd fd(open("/dev/kgsl-3d0", O_RDWR));
MemtrackStatus s;
hidl_vec<MemtrackRecord> v;
@@ -152,7 +119,7 @@
for (uint32_t i = 0; i < static_cast<uint32_t>(MemtrackType::NUM_TYPES);
i++) {
Return<void> ret =
- memtrack->getMemory(pid, static_cast<MemtrackType>(i), cb);
+ memtrack->getMemory(getpid(), static_cast<MemtrackType>(i), cb);
ASSERT_TRUE(ret.isOk());
switch (s) {
diff --git a/nfc/1.0/default/Android.bp b/nfc/1.0/default/Android.bp
index 051ca54..a157f86 100644
--- a/nfc/1.0/default/Android.bp
+++ b/nfc/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.nfc@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: ["Nfc.cpp"],
diff --git a/nfc/1.0/vts/functional/Android.bp b/nfc/1.0/vts/functional/Android.bp
index 0ab8dc5..d9ba702 100644
--- a/nfc/1.0/vts/functional/Android.bp
+++ b/nfc/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalNfcV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalNfcV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.nfc@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
index 5b6089d..aa3bc9c 100644
--- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
+++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
@@ -22,7 +22,7 @@
#include <android/hardware/nfc/1.0/types.h>
#include <hardware/nfc.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -56,10 +56,10 @@
#define TIMEOUT_PERIOD 5
// The main test class for NFC HIDL HAL.
-class NfcHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- nfc_ = ::testing::VtsHalHidlTargetBaseTest::getService<INfc>();
+ nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>();
ASSERT_NE(nfc_, nullptr);
nfc_cb_ = new NfcClientCallback(*this);
@@ -325,18 +325,42 @@
}
/*
+ * PowerCycleAfterClose:
+ * Calls powerCycle() after close()
+ * Checks status
+ */
+TEST_F(NfcHidlTest, PowerCycleAfterClose) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->close());
+ // Wait for CLOSE_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+
+ EXPECT_EQ(NfcStatus::FAILED, nfc_->powerCycle());
+
+ EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+ // Wait for OPEN_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+}
+
+/*
* CoreInitialized:
- * Calls coreInitialized()
+ * Calls coreInitialized() with different data
* Waits for NfcEvent.POST_INIT_CPLT
*/
TEST_F(NfcHidlTest, CoreInitialized) {
NfcData data;
data.resize(1);
- data[0] = 0;
- EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
- // Wait for NfcEvent.POST_INIT_CPLT
- EXPECT_EQ(std::cv_status::no_timeout, wait());
- EXPECT_EQ(NfcEvent::POST_INIT_CPLT, last_event_);
+ for (int i = 0; i <= 6; i++)
+ {
+ data[0] = i;
+ EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
+ // Wait for NfcEvent.POST_INIT_CPLT
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::POST_INIT_CPLT, last_event_);
+ }
}
/*
@@ -348,6 +372,27 @@
EXPECT_EQ(NfcStatus::OK, nfc_->controlGranted());
}
+/*
+ * ControlGrantedAfterClose:
+ * Call controlGranted() after close
+ * Checks the return value
+ */
+TEST_F(NfcHidlTest, ControlGrantedAfterClose) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->close());
+ // Wait for CLOSE_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+
+ EXPECT_EQ(NfcStatus::OK, nfc_->controlGranted());
+
+ EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+ // Wait for OPEN_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+}
+
/* PreDiscover:
* Calls prediscover()
* Checks the return value
@@ -356,6 +401,59 @@
EXPECT_EQ(NfcStatus::OK, nfc_->prediscover());
}
+/*
+ * PreDiscoverAfterClose:
+ * Call prediscover() after close
+ * Checks the return value
+ */
+TEST_F(NfcHidlTest, PreDiscoverAfterClose) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->close());
+ // Wait for CLOSE_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+
+ EXPECT_EQ(NfcStatus::OK, nfc_->prediscover());
+
+ EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+ // Wait for OPEN_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+}
+
+/*
+ * CloseAfterClose:
+ * Calls close() multiple times
+ * Checks status
+ */
+TEST_F(NfcHidlTest, CloseAfterClose) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->close());
+ // Wait for CLOSE_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::CLOSE_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+
+ EXPECT_EQ(NfcStatus::FAILED, nfc_->close());
+
+ EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+ // Wait for OPEN_CPLT event
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(NfcEvent::OPEN_CPLT, last_event_);
+ EXPECT_EQ(NfcStatus::OK, last_status_);
+}
+
+
+/*
+ * OpenAfterOpen:
+ * Calls open() multiple times
+ * Checks status
+ */
+TEST_F(NfcHidlTest, OpenAfterOpen) {
+ EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+ EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+}
+
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
::testing::InitGoogleTest(&argc, argv);
diff --git a/power/1.0/default/Android.bp b/power/1.0/default/Android.bp
index b3876df..4f43b95 100644
--- a/power/1.0/default/Android.bp
+++ b/power/1.0/default/Android.bp
@@ -14,6 +14,7 @@
cc_library_shared {
name: "android.hardware.power@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Power.cpp"],
@@ -36,6 +37,7 @@
cc_binary {
proprietary: true,
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
name: "android.hardware.power@1.0-service",
init_rc: ["android.hardware.power@1.0-service.rc"],
diff --git a/power/1.0/vts/functional/Android.bp b/power/1.0/vts/functional/Android.bp
index 984f9e3..5ab1eb4 100644
--- a/power/1.0/vts/functional/Android.bp
+++ b/power/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalPowerV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalPowerV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.power@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
index 757367b..cd1a261 100644
--- a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
+++ b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
@@ -22,7 +22,7 @@
#include <android-base/unique_fd.h>
#include <android/hardware/power/1.0/IPower.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <algorithm>
@@ -43,10 +43,10 @@
#define AVAILABLE_GOVERNORS_PATH \
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
-class PowerHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- power = ::testing::VtsHalHidlTargetBaseTest::getService<IPower>();
+ power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
ASSERT_NE(power, nullptr);
}
@@ -83,7 +83,7 @@
char governors[1024];
unsigned len = read(fd2, governors, 1024);
- ASSERT_LE(0, len);
+ ASSERT_LE(0u, len);
governors[len] = '\0';
char *saveptr;
diff --git a/radio/1.0/IRadio.hal b/radio/1.0/IRadio.hal
index a8c9d93..b3e3e98 100644
--- a/radio/1.0/IRadio.hal
+++ b/radio/1.0/IRadio.hal
@@ -731,20 +731,6 @@
oneway getDataCallList(int32_t serial);
/*
- * Indicates the current state of the screen. When the screen is off, the
- * Radio must notify the baseband to suppress certain notifications (eg,
- * signal strength and changes in LAC/CID or BID/SID/NID/latitude/longitude)
- * in an effort to conserve power. These notifications must resume when the
- * screen is on.
- *
- * @param serial Serial number of request.
- * @param enable true = screen on, false = screen off.
- *
- * Response function is IRadioResponse.sendScreenStateResponse()
- */
- oneway sendScreenState(int32_t serial, bool enable);
-
- /*
* Enables/disables supplementary service related notifications from the network.
* Notifications are reported via unsolSuppSvcNotification().
*
diff --git a/radio/1.0/IRadioResponse.hal b/radio/1.0/IRadioResponse.hal
index 11a1d03..cd0899a 100644
--- a/radio/1.0/IRadioResponse.hal
+++ b/radio/1.0/IRadioResponse.hal
@@ -928,17 +928,6 @@
* RadioError:NONE
* RadioError:RADIO_NOT_AVAILABLE
* RadioError:INVALID_ARGUMENTS
- * RadioError:GENERIC_FAILURE
- */
- oneway sendScreenStateResponse(RadioResponseInfo info);
-
- /*
- * @param info Response info struct containing response type, serial no. and error
- *
- * Valid errors returned:
- * RadioError:NONE
- * RadioError:RADIO_NOT_AVAILABLE
- * RadioError:INVALID_ARGUMENTS
* RadioError:SIM_BUSY
* RadioError:NO_MEMORY
* RadioError:SYSTEM_ERR
diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp
index 10bd725..7f16163 100644
--- a/radio/1.0/vts/functional/Android.bp
+++ b/radio/1.0/vts/functional/Android.bp
@@ -16,9 +16,12 @@
cc_test {
name: "VtsHalRadioV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["radio_hidl_hal_test.cpp",
"radio_response.cpp",
+ "radio_hidl_hal_voice.cpp",
"radio_hidl_hal_icc.cpp",
+ "radio_hidl_hal_sms.cpp",
"VtsHalRadioV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -30,9 +33,9 @@
"libutils",
"android.hardware.radio@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
],
-}
\ No newline at end of file
+}
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp b/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp
new file mode 100644
index 0000000..5bf7ae2
--- /dev/null
+++ b/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp
@@ -0,0 +1,431 @@
+/*
+ * Copyright (C) 2017 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<radio_hidl_hal_utils.h>
+
+using namespace ::android::hardware::radio::V1_0;
+
+/*
+ * Test IRadio.sendSms() for the response returned.
+ */
+TEST_F(RadioHidlTest, sendSms) {
+ int serial = 0;
+ GsmSmsMessage msg;
+ msg.smscPdu = "";
+ msg.pdu = "01000b916105770203f3000006d4f29c3e9b01";
+
+ radio->sendSms(++serial, msg);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ EXPECT_EQ(RadioError::INVALID_STATE, radioRsp->rspInfo.error);
+ EXPECT_EQ(0, radioRsp->sendSmsResult.errorCode);
+ } else {
+ EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
+ EXPECT_EQ("", radioRsp->sendSmsResult.ackPDU);
+ EXPECT_EQ(-1, radioRsp->sendSmsResult.errorCode);
+ }
+}
+
+/*
+ * Test IRadio.sendSMSExpectMore() for the response returned.
+ */
+TEST_F(RadioHidlTest, sendSMSExpectMore) {
+ int serial = 0;
+ GsmSmsMessage msg;
+ msg.smscPdu = "";
+ msg.pdu = "01000b916105770203f3000006d4f29c3e9b01";
+
+ radio->sendSMSExpectMore(++serial, msg);
+
+ // TODO(shuoq): add more test for this API when inserted sim card is considered
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ EXPECT_EQ(RadioError::INVALID_STATE, radioRsp->rspInfo.error);
+ } else {
+ EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
+ EXPECT_EQ("", radioRsp->sendSmsResult.ackPDU);
+ EXPECT_EQ(-1, radioRsp->sendSmsResult.errorCode);
+ }
+}
+
+/*
+ * Test IRadio.acknowledgeLastIncomingGsmSms() for the response returned.
+ */
+TEST_F(RadioHidlTest, acknowledgeLastIncomingGsmSms) {
+ int serial = 0;
+ bool success = true;
+
+ radio->acknowledgeLastIncomingGsmSms(++serial, success,
+ SmsAcknowledgeFailCause::MEMORY_CAPACITY_EXCEEDED);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ EXPECT_EQ(RadioError::INVALID_STATE, radioRsp->rspInfo.error);
+ } else {
+ // TODO(shuoq): Will test right behavior when inserted sim card is considered
+ }
+}
+
+/*
+ * Test IRadio.acknowledgeIncomingGsmSmsWithPdu() for the response returned.
+ */
+TEST_F(RadioHidlTest, acknowledgeIncomingGsmSmsWithPdu) {
+ int serial = 0;
+ bool success = true;
+ std::string ackPdu = "";
+
+ radio->acknowledgeIncomingGsmSmsWithPdu(++serial, success, ackPdu);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ // TODO(shuoq): Will test right behavior when inserted sim card is considered
+ }
+}
+
+/*
+ * Test IRadio.sendCdmaSms() for the response returned.
+ */
+TEST_F(RadioHidlTest, sendCdmaSms) {
+ int serial = 0;
+
+ // Create a CdmaSmsAddress
+ CdmaSmsAddress cdmaSmsAddress;
+ cdmaSmsAddress.digitMode = CdmaSmsDigitMode::FOUR_BIT;
+ cdmaSmsAddress.numberMode = CdmaSmsNumberMode::NOT_DATA_NETWORK;
+ cdmaSmsAddress.numberType = CdmaSmsNumberType::UNKNOWN;
+ cdmaSmsAddress.numberPlan = CdmaSmsNumberPlan::UNKNOWN;
+ cdmaSmsAddress.digits = (std::vector<uint8_t>) {11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3};
+
+ // Create a CdmaSmsSubAddress
+ CdmaSmsSubaddress cdmaSmsSubaddress;
+ cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddressType::NSAP;
+ cdmaSmsSubaddress.odd = false;
+ cdmaSmsSubaddress.digits = (std::vector<uint8_t>) {};
+
+ // Create a CdmaSmsMessage
+ android::hardware::radio::V1_0::CdmaSmsMessage cdmaSmsMessage;
+ cdmaSmsMessage.teleserviceId = 4098;
+ cdmaSmsMessage.isServicePresent = false;
+ cdmaSmsMessage.serviceCategory = 0;
+ cdmaSmsMessage.address = cdmaSmsAddress;
+ cdmaSmsMessage.subAddress = cdmaSmsSubaddress;
+ cdmaSmsMessage.bearerData = (std::vector<uint8_t>)
+ {15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0};
+
+ radio->sendCdmaSms(++serial, cdmaSmsMessage);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ // TODO(shuoq): radioRsp->sendSmsResult needs to be investigated when Sim card is in
+ }
+}
+
+/*
+ * Test IRadio.acknowledgeLastIncomingCdmaSms() for the response returned.
+ */
+TEST_F(RadioHidlTest, acknowledgeLastIncomingCdmaSms) {
+ int serial = 0;
+
+ // Create a CdmaSmsAck
+ CdmaSmsAck cdmaSmsAck;
+ cdmaSmsAck.errorClass = CdmaSmsErrorClass::NO_ERROR;
+ cdmaSmsAck.smsCauseCode = 1;
+
+ radio->acknowledgeLastIncomingCdmaSms(++serial, cdmaSmsAck);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ EXPECT_EQ(RadioError::NO_SMS_TO_ACK, radioRsp->rspInfo.error);
+ } else {
+ EXPECT_EQ(RadioError::NO_SMS_TO_ACK, radioRsp->rspInfo.error);
+ }
+}
+
+/*
+ * Test IRadio.sendImsSms() for the response returned.
+ */
+TEST_F(RadioHidlTest, sendImsSms) {
+ int serial = 1;
+
+ // Create a CdmaSmsAddress
+ CdmaSmsAddress cdmaSmsAddress;
+ cdmaSmsAddress.digitMode = CdmaSmsDigitMode::FOUR_BIT;
+ cdmaSmsAddress.numberMode = CdmaSmsNumberMode::NOT_DATA_NETWORK;
+ cdmaSmsAddress.numberType = CdmaSmsNumberType::UNKNOWN;
+ cdmaSmsAddress.numberPlan = CdmaSmsNumberPlan::UNKNOWN;
+ cdmaSmsAddress.digits = (std::vector<uint8_t>) {11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3};
+
+ // Create a CdmaSmsSubAddress
+ CdmaSmsSubaddress cdmaSmsSubaddress;
+ cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddressType::NSAP;
+ cdmaSmsSubaddress.odd = false;
+ cdmaSmsSubaddress.digits = (std::vector<uint8_t>) {};
+
+ // Create a CdmaSmsMessage
+ CdmaSmsMessage cdmaSmsMessage;
+ cdmaSmsMessage.teleserviceId = 4098;
+ cdmaSmsMessage.isServicePresent = false;
+ cdmaSmsMessage.serviceCategory = 0;
+ cdmaSmsMessage.address = cdmaSmsAddress;
+ cdmaSmsMessage.subAddress = cdmaSmsSubaddress;
+ cdmaSmsMessage.bearerData = (std::vector<uint8_t>)
+ {15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0};
+
+ // Creata an ImsSmsMessage
+ ImsSmsMessage msg;
+ msg.tech = RadioTechnologyFamily::THREE_GPP2;
+ msg.retry = false;
+ msg.messageRef = 0;
+ msg.cdmaMessage = (std::vector<CdmaSmsMessage>) {cdmaSmsMessage};
+ msg.gsmMessage = (std::vector<GsmSmsMessage>) {};
+
+ radio->sendImsSms(serial, msg);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp->rspInfo.error);
+ } else {
+ EXPECT_EQ(RadioError::INVALID_ARGUMENTS, radioRsp->rspInfo.error);
+ // TODO(shuoq): radioRsp->sendSmsResult needs to be investigated when sim card is in
+ }
+}
+
+/*
+ * Test IRadio.getSmscAddress() for the response returned.
+ */
+TEST_F(RadioHidlTest, getSmscAddress) {
+ int serial = 0;
+
+ radio->getSmscAddress(++serial);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
+ // TODO(shuoq): radioRsp->smscAddress needs to be investigated when Sim card is in
+ }
+}
+
+/*
+ * Test IRadio.setSmscAddress() for the response returned.
+ */
+TEST_F(RadioHidlTest, setSmscAddress) {
+ int serial = 0;
+ hidl_string address = hidl_string("smscAddress");
+
+ radio->setSmscAddress(++serial, address);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ EXPECT_EQ(RadioError::INVALID_SMS_FORMAT, radioRsp->rspInfo.error);
+ } else {
+ EXPECT_EQ(RadioError::INVALID_SMS_FORMAT, radioRsp->rspInfo.error);
+ }
+}
+
+/*
+ * Test IRadio.writeSmsToSim() for the response returned.
+ */
+TEST_F(RadioHidlTest, writeSmsToSim) {
+ int serial = 0;
+ SmsWriteArgs smsWriteArgs;
+ smsWriteArgs.status = SmsWriteArgsStatus::REC_UNREAD;
+ smsWriteArgs.smsc = "";
+ smsWriteArgs.pdu = "01000b916105770203f3000006d4f29c3e9b01";
+
+ radio->writeSmsToSim(++serial, smsWriteArgs);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ // TODO(shuoq): radioRsp->writeSmsToSimIndex needs to be investigated when Sim card is in
+ }
+}
+
+/*
+ * Test IRadio.deleteSmsOnSim() for the response returned.
+ */
+TEST_F(RadioHidlTest, deleteSmsOnSim) {
+ int serial = 0;
+ int index = 1;
+
+ radio->deleteSmsOnSim(++serial, index);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ EXPECT_EQ(RadioError::NO_SUCH_ENTRY, radioRsp->rspInfo.error);
+ }
+}
+
+/*
+ * Test IRadio.writeSmsToRuim() for the response returned.
+ */
+TEST_F(RadioHidlTest, writeSmsToRuim) {
+ int serial = 0;
+
+ // Create a CdmaSmsAddress
+ CdmaSmsAddress cdmaSmsAddress;
+ cdmaSmsAddress.digitMode = CdmaSmsDigitMode::FOUR_BIT;
+ cdmaSmsAddress.numberMode = CdmaSmsNumberMode::NOT_DATA_NETWORK;
+ cdmaSmsAddress.numberType = CdmaSmsNumberType::UNKNOWN;
+ cdmaSmsAddress.numberPlan = CdmaSmsNumberPlan::UNKNOWN;
+ cdmaSmsAddress.digits = (std::vector<uint8_t>) {11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3};
+
+ // Create a CdmaSmsSubAddress
+ CdmaSmsSubaddress cdmaSmsSubaddress;
+ cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddressType::NSAP;
+ cdmaSmsSubaddress.odd = false;
+ cdmaSmsSubaddress.digits = (std::vector<uint8_t>) {};
+
+ // Create a CdmaSmsMessage
+ CdmaSmsMessage cdmaSmsMessage;
+ cdmaSmsMessage.teleserviceId = 4098;
+ cdmaSmsMessage.isServicePresent = false;
+ cdmaSmsMessage.serviceCategory = 0;
+ cdmaSmsMessage.address = cdmaSmsAddress;
+ cdmaSmsMessage.subAddress = cdmaSmsSubaddress;
+ cdmaSmsMessage.bearerData = (std::vector<uint8_t>)
+ {15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0};
+
+ // Create a CdmaSmsWriteArgs
+ CdmaSmsWriteArgs cdmaSmsWriteArgs;
+ cdmaSmsWriteArgs.status = CdmaSmsWriteArgsStatus::REC_UNREAD;
+ cdmaSmsWriteArgs.message = cdmaSmsMessage;
+
+ radio->writeSmsToRuim(++serial, cdmaSmsWriteArgs);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ // TODO(shuoq): radioRsp->writeSmsToRuimIndex needs to be investigated when sim card is in
+ }
+}
+
+/*
+ * Test IRadio.deleteSmsOnRuim() for the response returned.
+ */
+TEST_F(RadioHidlTest, deleteSmsOnRuim) {
+ int serial = 0;
+ int index = 1;
+
+ // Create a CdmaSmsAddress
+ CdmaSmsAddress cdmaSmsAddress;
+ cdmaSmsAddress.digitMode = CdmaSmsDigitMode::FOUR_BIT;
+ cdmaSmsAddress.numberMode = CdmaSmsNumberMode::NOT_DATA_NETWORK;
+ cdmaSmsAddress.numberType = CdmaSmsNumberType::UNKNOWN;
+ cdmaSmsAddress.numberPlan = CdmaSmsNumberPlan::UNKNOWN;
+ cdmaSmsAddress.digits = (std::vector<uint8_t>) {11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3};
+
+ // Create a CdmaSmsSubAddress
+ CdmaSmsSubaddress cdmaSmsSubaddress;
+ cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddressType::NSAP;
+ cdmaSmsSubaddress.odd = false;
+ cdmaSmsSubaddress.digits = (std::vector<uint8_t>) {};
+
+ // Create a CdmaSmsMessage
+ CdmaSmsMessage cdmaSmsMessage;
+ cdmaSmsMessage.teleserviceId = 4098;
+ cdmaSmsMessage.isServicePresent = false;
+ cdmaSmsMessage.serviceCategory = 0;
+ cdmaSmsMessage.address = cdmaSmsAddress;
+ cdmaSmsMessage.subAddress = cdmaSmsSubaddress;
+ cdmaSmsMessage.bearerData = (std::vector<uint8_t>)
+ {15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0};
+
+ // Create a CdmaSmsWriteArgs
+ CdmaSmsWriteArgs cdmaSmsWriteArgs;
+ cdmaSmsWriteArgs.status = CdmaSmsWriteArgsStatus::REC_UNREAD;
+ cdmaSmsWriteArgs.message = cdmaSmsMessage;
+
+ radio->deleteSmsOnRuim(++serial, index);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ // TODO(shuoq): Will test right behavior when inserted sim card is considered
+ }
+}
+
+/*
+ * Test IRadio.reportSmsMemoryStatus() for the response returned.
+ */
+TEST_F(RadioHidlTest, reportSmsMemoryStatus) {
+ int serial = 0;
+ bool available = true;
+
+ radio->reportSmsMemoryStatus(++serial, available);
+
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ // TODO(shuoq): Will add error check when we know the expected error from QC
+ } else {
+ EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
+ }
+}
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
index 50b27e9..db7356f 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
@@ -17,7 +17,7 @@
#include<radio_hidl_hal_utils.h>
void RadioHidlTest::SetUp() {
- radio = ::testing::VtsHalHidlTargetBaseTest::getService<IRadio>(hidl_string("rild"));
+ radio = ::testing::VtsHalHidlTargetTestBase::getService<IRadio>(hidl_string("rild"));
ASSERT_NE(radio, nullptr);
radioRsp = new RadioResponse(*this);
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils.h b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
index 0429226..bb693ac 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
@@ -16,7 +16,7 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -29,6 +29,7 @@
using ::android::hardware::radio::V1_0::ActivityStatsInfo;
using ::android::hardware::radio::V1_0::AppType;
using ::android::hardware::radio::V1_0::CardStatus;
+using ::android::hardware::radio::V1_0::CardState;
using ::android::hardware::radio::V1_0::Call;
using ::android::hardware::radio::V1_0::CallForwardInfo;
using ::android::hardware::radio::V1_0::CarrierRestrictions;
@@ -38,6 +39,7 @@
using ::android::hardware::radio::V1_0::CellInfo;
using ::android::hardware::radio::V1_0::ClipStatus;
using ::android::hardware::radio::V1_0::DataRegStateResult;
+using ::android::hardware::radio::V1_0::Dial;
using ::android::hardware::radio::V1_0::GsmBroadcastSmsConfigInfo;
using ::android::hardware::radio::V1_0::HardwareConfig;
using ::android::hardware::radio::V1_0::IccIo;
@@ -87,6 +89,12 @@
IccIoResult iccIoResult;
int channelId;
+ // Sms
+ SendSmsResult sendSmsResult;
+ hidl_string smscAddress;
+ uint32_t writeSmsToSimIndex;
+ uint32_t writeSmsToRuimIndex;
+
RadioResponse(RadioHidlTest& parent);
virtual ~RadioResponse() = default;
@@ -234,8 +242,6 @@
Return<void> sendOemRilRequestStringsResponse(const RadioResponseInfo& info,
const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
- Return<void> sendScreenStateResponse(const RadioResponseInfo& info);
-
Return<void> setSuppServiceNotificationsResponse(
const RadioResponseInfo& info);
@@ -429,7 +435,7 @@
};
// The main test class for Radio HIDL.
-class RadioHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class RadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
private:
std::mutex mtx;
std::condition_variable cv;
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp
new file mode 100644
index 0000000..3638ccb
--- /dev/null
+++ b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp
@@ -0,0 +1,476 @@
+/*
+ * Copyright (C) 2017 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<radio_hidl_hal_utils.h>
+
+/*
+ * Test IRadio.getCurrentCalls() for the response returned.
+ */
+TEST_F(RadioHidlTest, getCurrentCalls) {
+ int serial = 1;
+
+ radio->getCurrentCalls(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE
+ || radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
+ }
+}
+
+/*
+ * Test IRadio.dial() for the response returned.
+ */
+TEST_F(RadioHidlTest, dial) {
+ int serial = 1;
+
+ Dial dialInfo;
+ memset(&dialInfo, 0, sizeof(dialInfo));
+ dialInfo.address = hidl_string("123456789");
+
+ radio->dial(serial, dialInfo);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.hangup() for the response returned.
+ */
+TEST_F(RadioHidlTest, hangup) {
+ int serial = 1;
+
+ radio->hangup(serial, 1);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.hangupWaitingOrBackground() for the response returned.
+ */
+TEST_F(RadioHidlTest, hangupWaitingOrBackground) {
+ int serial = 1;
+
+ radio->hangupWaitingOrBackground(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.hangupForegroundResumeBackground() for the response returned.
+ */
+TEST_F(RadioHidlTest, hangupForegroundResumeBackground) {
+ int serial = 1;
+
+ radio->hangupForegroundResumeBackground(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.switchWaitingOrHoldingAndActive() for the response returned.
+ */
+TEST_F(RadioHidlTest, switchWaitingOrHoldingAndActive) {
+ int serial = 1;
+
+ radio->switchWaitingOrHoldingAndActive(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.conference() for the response returned.
+ */
+TEST_F(RadioHidlTest, conference) {
+ int serial = 1;
+
+ radio->conference(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.rejectCall() for the response returned.
+ */
+TEST_F(RadioHidlTest, rejectCall) {
+ int serial = 1;
+
+ radio->rejectCall(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.getLastCallFailCause() for the response returned.
+ */
+TEST_F(RadioHidlTest, getLastCallFailCause) {
+ int serial = 1;
+
+ radio->getLastCallFailCause(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::NONE);
+ }
+}
+
+/*
+ * Test IRadio.sendUssd() for the response returned.
+ */
+TEST_F(RadioHidlTest, sendUssd) {
+ int serial = 1;
+ radio->sendUssd(serial, hidl_string("test"));
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::SYSTEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.cancelPendingUssd() for the response returned.
+ */
+TEST_F(RadioHidlTest, cancelPendingUssd) {
+ int serial = 1;
+
+ radio->cancelPendingUssd(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.getCallForwardStatus() for the response returned.
+ */
+TEST_F(RadioHidlTest, getCallForwardStatus) {
+ int serial = 1;
+ CallForwardInfo callInfo;
+ memset(&callInfo, 0, sizeof(callInfo));
+ callInfo.number = hidl_string();
+
+ radio->getCallForwardStatus(serial, callInfo);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.setCallForward() for the response returned.
+ */
+TEST_F(RadioHidlTest, setCallForward) {
+ int serial = 1;
+ CallForwardInfo callInfo;
+ memset(&callInfo, 0, sizeof(callInfo));
+ callInfo.number = hidl_string();
+
+ radio->setCallForward(serial, callInfo);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.getCallWaiting() for the response returned.
+ */
+TEST_F(RadioHidlTest, getCallWaiting) {
+ int serial = 1;
+
+ radio->getCallWaiting(serial, 1);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::NONE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.setCallWaiting() for the response returned.
+ */
+TEST_F(RadioHidlTest, setCallWaiting) {
+ int serial = 1;
+
+ radio->setCallWaiting(serial, true, 1);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.acceptCall() for the response returned.
+ */
+TEST_F(RadioHidlTest, acceptCall) {
+ int serial = 1;
+
+ radio->acceptCall(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.separateConnection() for the response returned.
+ */
+TEST_F(RadioHidlTest, separateConnection) {
+ int serial = 1;
+
+ radio->separateConnection(serial, 1);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::SYSTEM_ERR
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.explicitCallTransfer() for the response returned.
+ */
+TEST_F(RadioHidlTest, explicitCallTransfer) {
+ int serial = 1;
+
+ radio->explicitCallTransfer(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.sendDtmf() for the response returned.
+ */
+TEST_F(RadioHidlTest, sendDtmf) {
+ int serial = 1;
+
+ radio->sendDtmf(serial, "1");
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::NO_RESOURCES
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR);
+ }
+}
+
+/*
+ * Test IRadio.startDtmf() for the response returned.
+ */
+TEST_F(RadioHidlTest, startDtmf) {
+ int serial = 1;
+
+ radio->startDtmf(serial, "1");
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::SYSTEM_ERR
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.stopDtmf() for the response returned.
+ */
+TEST_F(RadioHidlTest, stopDtmf) {
+ int serial = 1;
+
+ radio->stopDtmf(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::SYSTEM_ERR
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
+ }
+}
+
+/*
+ * Test IRadio.setMute() for the response returned.
+ */
+TEST_F(RadioHidlTest, setMute) {
+ int serial = 1;
+
+ radio->setMute(serial, true);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::NONE);
+ }
+}
+
+/*
+ * Test IRadio.getMute() for the response returned.
+ */
+TEST_F(RadioHidlTest, getMute) {
+ int serial = 1;
+
+ radio->getMute(serial);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::NONE);
+ }
+}
+
+/*
+ * Test IRadio.sendBurstDtmf() for the response returned.
+ */
+TEST_F(RadioHidlTest, sendBurstDtmf) {
+ int serial = 1;
+
+ radio->sendBurstDtmf(serial, "1", 0, 0);
+ EXPECT_EQ(std::cv_status::no_timeout, wait());
+ EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+ EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+
+ if (cardStatus.cardState == CardState::ABSENT) {
+ ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS
+ || radioRsp->rspInfo.error == RadioError::SYSTEM_ERR
+ || radioRsp->rspInfo.error == RadioError::MODEM_ERR
+ || radioRsp->rspInfo.error == RadioError::INTERNAL_ERR
+ || radioRsp->rspInfo.error == RadioError::INVALID_STATE);
+ }
+}
\ No newline at end of file
diff --git a/radio/1.0/vts/functional/radio_response.cpp b/radio/1.0/vts/functional/radio_response.cpp
index 2b4f10f..3db2dd1 100644
--- a/radio/1.0/vts/functional/radio_response.cpp
+++ b/radio/1.0/vts/functional/radio_response.cpp
@@ -77,11 +77,15 @@
}
Return<void> RadioResponse::getCurrentCallsResponse(
- const RadioResponseInfo& /*info*/, const ::android::hardware::hidl_vec<Call>& /*calls*/) {
+ const RadioResponseInfo& info, const ::android::hardware::hidl_vec<Call>& /*calls*/) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::dialResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::dialResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -94,37 +98,51 @@
}
Return<void> RadioResponse::hangupConnectionResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::hangupWaitingOrBackgroundResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::hangupForegroundResumeBackgroundResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::switchWaitingOrHoldingAndActiveResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::conferenceResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::rejectCallResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::getLastCallFailCauseResponse(
- const RadioResponseInfo& /*info*/, const LastCallFailCauseInfo& /*failCauseInfo*/) {
+ const RadioResponseInfo& info, const LastCallFailCauseInfo& /*failCauseInfo*/) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -154,17 +172,25 @@
return Void();
}
-Return<void> RadioResponse::sendDtmfResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::sendDtmfResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::sendSmsResponse(const RadioResponseInfo& /*info*/,
- const SendSmsResult& /*sms*/) {
+Return<void> RadioResponse::sendSmsResponse(const RadioResponseInfo& info,
+ const SendSmsResult& sms) {
+ rspInfo = info;
+ sendSmsResult = sms;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::sendSMSExpectMoreResponse(
- const RadioResponseInfo& /*info*/, const SendSmsResult& /*sms*/) {
+ const RadioResponseInfo& info, const SendSmsResult& sms) {
+ rspInfo = info;
+ sendSmsResult = sms;
+ parent.notify();
return Void();
}
@@ -181,11 +207,15 @@
return Void();
}
-Return<void> RadioResponse::sendUssdResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::sendUssdResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::cancelPendingUssdResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::cancelPendingUssdResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -199,29 +229,41 @@
}
Return<void> RadioResponse::getCallForwardStatusResponse(
- const RadioResponseInfo& /*info*/, const ::android::hardware::hidl_vec<CallForwardInfo>&
+ const RadioResponseInfo& info, const ::android::hardware::hidl_vec<CallForwardInfo>&
/*callForwardInfos*/) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::setCallForwardResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::setCallForwardResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::getCallWaitingResponse(
- const RadioResponseInfo& /*info*/, bool /*enable*/, int32_t /*serviceClass*/) {
+ const RadioResponseInfo& info, bool /*enable*/, int32_t /*serviceClass*/) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::setCallWaitingResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::setCallWaitingResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::acknowledgeLastIncomingGsmSmsResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::acknowledgeLastIncomingGsmSmsResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::acceptCallResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::acceptCallResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -265,12 +307,16 @@
}
Return<void> RadioResponse::startDtmfResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::stopDtmfResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -279,15 +325,21 @@
return Void();
}
-Return<void> RadioResponse::separateConnectionResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::separateConnectionResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::setMuteResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::setMuteResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::getMuteResponse(const RadioResponseInfo& /*info*/, bool /*enable*/) {
+Return<void> RadioResponse::getMuteResponse(const RadioResponseInfo& info, bool /*enable*/) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -314,23 +366,23 @@
return Void();
}
-Return<void> RadioResponse::sendScreenStateResponse(
- const RadioResponseInfo& /*info*/) {
- return Void();
-}
-
Return<void> RadioResponse::setSuppServiceNotificationsResponse(
const RadioResponseInfo& /*info*/) {
return Void();
}
Return<void> RadioResponse::writeSmsToSimResponse(
- const RadioResponseInfo& /*info*/, int32_t /*index*/) {
+ const RadioResponseInfo& info, int32_t index) {
+ rspInfo = info;
+ writeSmsToSimIndex = index;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::deleteSmsOnSimResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -358,7 +410,9 @@
return Void();
}
-Return<void> RadioResponse::explicitCallTransferResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::explicitCallTransferResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -417,17 +471,24 @@
return Void();
}
-Return<void> RadioResponse::sendBurstDtmfResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::sendBurstDtmfResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::sendCdmaSmsResponse(
- const RadioResponseInfo& /*info*/, const SendSmsResult& /*sms*/) {
+ const RadioResponseInfo& info, const SendSmsResult& sms) {
+ rspInfo = info;
+ sendSmsResult = sms;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::acknowledgeLastIncomingCdmaSmsResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -469,12 +530,17 @@
}
Return<void> RadioResponse::writeSmsToRuimResponse(
- const RadioResponseInfo& /*info*/, uint32_t /*index*/) {
+ const RadioResponseInfo& info, uint32_t index) {
+ rspInfo = info;
+ writeSmsToRuimIndex = index;
+ parent.notify();
return Void();
}
Return<void> RadioResponse::deleteSmsOnRuimResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -491,15 +557,22 @@
}
Return<void> RadioResponse::getSmscAddressResponse(
- const RadioResponseInfo& /*info*/, const ::android::hardware::hidl_string& /*smsc*/) {
+ const RadioResponseInfo& info, const ::android::hardware::hidl_string& smsc) {
+ rspInfo = info;
+ smscAddress = smsc;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::setSmscAddressResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::setSmscAddressResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
-Return<void> RadioResponse::reportSmsMemoryStatusResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::reportSmsMemoryStatusResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -518,7 +591,9 @@
}
Return<void> RadioResponse::acknowledgeIncomingGsmSmsWithPduResponse(
- const RadioResponseInfo& /*info*/) {
+ const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -553,7 +628,10 @@
}
Return<void> RadioResponse::sendImsSmsResponse(
- const RadioResponseInfo& /*info*/, const SendSmsResult& /*sms*/) {
+ const RadioResponseInfo& info, const SendSmsResult& sms) {
+ rspInfo = info;
+ sendSmsResult = sms;
+ parent.notify();
return Void();
}
diff --git a/renderscript/1.0/default/Android.bp b/renderscript/1.0/default/Android.bp
index 564d6db..29b781e 100644
--- a/renderscript/1.0/default/Android.bp
+++ b/renderscript/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.renderscript@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
diff --git a/renderscript/1.0/default/Context.cpp b/renderscript/1.0/default/Context.cpp
index 4e0964e..ef17b463 100644
--- a/renderscript/1.0/default/Context.cpp
+++ b/renderscript/1.0/default/Context.cpp
@@ -711,7 +711,7 @@
RsScript _vs = hidl_to_rs<RsScript>(vs);
uint32_t _slot = slot;
size_t _len = static_cast<size_t>(len);
- std::vector<uint8_t> _data(static_cast<size_t>(len));
+ std::vector<uint8_t> _data(_len);
Device::getHal().ScriptGetVarV(mContext, _vs, _slot, _data.data(), _data.size());
hidl_vec<uint8_t> data = _data;
_hidl_cb(data);
diff --git a/sensors/1.0/default/Android.bp b/sensors/1.0/default/Android.bp
index 1d8d6a4..2ab1b90 100644
--- a/sensors/1.0/default/Android.bp
+++ b/sensors/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.sensors@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Sensors.cpp"],
@@ -22,6 +23,7 @@
cc_library_static {
name: "android.hardware.sensors@1.0-convert",
+ defaults: ["hidl_defaults"],
srcs: ["convert.cpp"],
export_include_dirs: ["include"],
shared_libs: [
diff --git a/sensors/1.0/default/Sensors.cpp b/sensors/1.0/default/Sensors.cpp
index 37e2b81..2457310 100644
--- a/sensors/1.0/default/Sensors.cpp
+++ b/sensors/1.0/default/Sensors.cpp
@@ -165,8 +165,9 @@
if(!lock.owns_lock()){
// cannot get the lock, hidl service will go into deadlock if it is not restarted.
// This is guaranteed to not trigger in passthrough mode.
- LOG(FATAL) <<
+ LOG(ERROR) <<
"ISensors::poll() re-entry. I do not know what to do except killing myself.";
+ ::exit(-1);
}
if (maxCount <= 0) {
diff --git a/sensors/1.0/vts/functional/Android.bp b/sensors/1.0/vts/functional/Android.bp
index 4be4f64..af149ba 100644
--- a/sensors/1.0/vts/functional/Android.bp
+++ b/sensors/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalSensorsV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalSensorsV1_0TargetTest.cpp"],
shared_libs: [
"android.hardware.sensors@1.0",
@@ -24,7 +25,7 @@
"liblog",
"libutils",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
index b1483e3..1298e16 100644
--- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
+++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
@@ -20,7 +20,7 @@
#include <android/hardware/sensors/1.0/types.h>
#include <android/log.h>
#include <cutils/ashmem.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <hardware/sensors.h> // for sensor type strings
#include <algorithm>
@@ -80,7 +80,7 @@
};
void SensorsHidlEnvironment::SetUp() {
- sensors = ::testing::VtsHalHidlTargetBaseTest::getService<ISensors>();
+ sensors = ::testing::VtsHalHidlTargetTestBase::getService<ISensors>();
ALOGI_IF(sensors, "sensors is not nullptr, %p", sensors.get());
ASSERT_NE(sensors, nullptr);
@@ -213,7 +213,7 @@
int32_t type = *reinterpret_cast<int32_t *>(mBuffer + offset + kOffsetType);
int64_t timestamp = *reinterpret_cast<int64_t *>(mBuffer + offset + kOffsetTimestamp);
- ALOGV("offset = %zu, cnt %" PRId32 ", token %" PRId32 ", type %" PRId32 ", timestamp %" PRId64,
+ ALOGV("offset = %zu, cnt %" PRId64 ", token %" PRId32 ", type %" PRId32 ", timestamp %" PRId64,
offset, atomicCounter, token, type, timestamp);
Event event = {
@@ -309,7 +309,7 @@
}
// The main test class for SENSORS HIDL HAL.
-class SensorsHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class SensorsHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
}
@@ -688,7 +688,7 @@
ALOGI("Collected %zu samples", events.size());
- ASSERT_GT(events.size(), 0);
+ ASSERT_GT(events.size(), 0u);
size_t nRealEvent = 0;
for (auto & e : events) {
@@ -773,7 +773,6 @@
std::vector<Event> events1, events2;
constexpr int64_t batchingPeriodInNs = 0; // no batching
- constexpr useconds_t minTimeUs = 5*1000*1000; // 5 s
constexpr size_t minNEvent = 50;
constexpr SensorType type = SensorType::ACCELEROMETER;
@@ -826,7 +825,7 @@
++ nEvent;
}
}
- ASSERT_GT(nEvent, 2);
+ ASSERT_GT(nEvent, 2u);
minDelayAverageInterval = timestampInterval / (nEvent - 1);
nEvent = 0;
@@ -842,7 +841,7 @@
++ nEvent;
}
}
- ASSERT_GT(nEvent, 2);
+ ASSERT_GT(nEvent, 2u);
maxDelayAverageInterval = timestampInterval / (nEvent - 1);
// change of rate is significant.
@@ -859,8 +858,6 @@
std::vector<Event> events;
constexpr int64_t oneSecondInNs = 1ull * 1000 * 1000 * 1000;
- constexpr useconds_t minTimeUs = 5*1000*1000; // 5 s
- constexpr size_t minNEvent = 50;
constexpr SensorType type = SensorType::ACCELEROMETER;
constexpr int64_t maxBatchingTestTimeNs = 30ull * 1000 * 1000 * 1000;
@@ -974,7 +971,7 @@
auto events = mem->parseEvents();
// allowed to be 55% of nominal freq (50Hz)
- ASSERT_GT(events.size(), 50 / 2);
+ ASSERT_GT(events.size(), 50u / 2u);
ASSERT_LT(events.size(), static_cast<size_t>(110*1.5));
int64_t lastTimestamp = 0;
diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
index afda739..b0aef4b 100644
--- a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
+++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
@@ -138,7 +138,7 @@
} while (mClients.valueFor(*modelId) != 0 && *modelId != 0);
}
LOG_ALWAYS_FATAL_IF(*modelId == 0,
- "wrap around in sound model IDs, num loaded models %d", mClients.size());
+ "wrap around in sound model IDs, num loaded models %zu", mClients.size());
client = new SoundModelClient(*modelId, callback, cookie);
diff --git a/soundtrigger/2.0/vts/functional/Android.bp b/soundtrigger/2.0/vts/functional/Android.bp
index 269e4b6..8f0cc4e 100644
--- a/soundtrigger/2.0/vts/functional/Android.bp
+++ b/soundtrigger/2.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalSoundtriggerV2_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalSoundtriggerV2_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.soundtrigger@2.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp b/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
index 41e7e69..0ef4063 100644
--- a/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
+++ b/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
@@ -15,6 +15,12 @@
*/
#define LOG_TAG "SoundTriggerHidlHalTest"
+#include <stdlib.h>
+#include <time.h>
+
+#include <condition_variable>
+#include <mutex>
+
#include <android/log.h>
#include <cutils/native_handle.h>
@@ -22,7 +28,9 @@
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
#include <android/hardware/soundtrigger/2.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
+
+#define SHORT_TIMEOUT_PERIOD (1)
using ::android::hardware::audio::common::V2_0::AudioDevice;
using ::android::hardware::soundtrigger::V2_0::SoundModelHandle;
@@ -36,43 +44,101 @@
using ::android::hardware::Void;
using ::android::sp;
+/**
+ * Test code uses this class to wait for notification from callback.
+ */
+class Monitor {
+ public:
+ Monitor() : mCount(0) {}
+
+ /**
+ * Adds 1 to the internal counter and unblocks one of the waiting threads.
+ */
+ void notify() {
+ std::unique_lock<std::mutex> lock(mMtx);
+ mCount++;
+ mCv.notify_one();
+ }
+
+ /**
+ * Blocks until the internal counter becomes greater than 0.
+ *
+ * If notified, this method decreases the counter by 1 and returns true.
+ * If timeout, returns false.
+ */
+ bool wait(int timeoutSeconds) {
+ std::unique_lock<std::mutex> lock(mMtx);
+ auto deadline = std::chrono::system_clock::now() +
+ std::chrono::seconds(timeoutSeconds);
+ while (mCount == 0) {
+ if (mCv.wait_until(lock, deadline) == std::cv_status::timeout) {
+ return false;
+ }
+ }
+ mCount--;
+ return true;
+ }
+
+ private:
+ std::mutex mMtx;
+ std::condition_variable mCv;
+ int mCount;
+};
+
// The main test class for Sound Trigger HIDL HAL.
-class SoundTriggerHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class SoundTriggerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- mSoundTriggerHal = ::testing::VtsHalHidlTargetBaseTest::getService<ISoundTriggerHw>("sound_trigger.primary");
+ mSoundTriggerHal = ::testing::VtsHalHidlTargetTestBase::getService<ISoundTriggerHw>("sound_trigger.primary");
ASSERT_NE(nullptr, mSoundTriggerHal.get());
- mCallback = new MyCallback();
+ mCallback = new SoundTriggerHwCallback(*this);
ASSERT_NE(nullptr, mCallback.get());
}
- class MyCallback : public ISoundTriggerHwCallback {
- virtual Return<void> recognitionCallback(
- const ISoundTriggerHwCallback::RecognitionEvent& event __unused,
- int32_t cookie __unused) {
- ALOGI("%s", __FUNCTION__);
- return Void();
- }
+ static void SetUpTestCase() {
+ srand(time(nullptr));
+ }
- virtual Return<void> phraseRecognitionCallback(
- const ISoundTriggerHwCallback::PhraseRecognitionEvent& event __unused,
- int32_t cookie __unused) {
- ALOGI("%s", __FUNCTION__);
- return Void();
- }
+ class SoundTriggerHwCallback : public ISoundTriggerHwCallback {
+ private:
+ SoundTriggerHidlTest& mParent;
- virtual Return<void> soundModelCallback(
- const ISoundTriggerHwCallback::ModelEvent& event __unused,
- int32_t cookie __unused) {
- ALOGI("%s", __FUNCTION__);
- return Void();
- }
+ public:
+ SoundTriggerHwCallback(SoundTriggerHidlTest& parent) : mParent(parent) {}
+
+ virtual Return<void> recognitionCallback(
+ const ISoundTriggerHwCallback::RecognitionEvent& event __unused,
+ int32_t cookie __unused) {
+ ALOGI("%s", __FUNCTION__);
+ return Void();
+ }
+
+ virtual Return<void> phraseRecognitionCallback(
+ const ISoundTriggerHwCallback::PhraseRecognitionEvent& event __unused,
+ int32_t cookie __unused) {
+ ALOGI("%s", __FUNCTION__);
+ return Void();
+ }
+
+ virtual Return<void> soundModelCallback(
+ const ISoundTriggerHwCallback::ModelEvent& event,
+ int32_t cookie __unused) {
+ ALOGI("%s", __FUNCTION__);
+ mParent.lastModelEvent = event;
+ mParent.monitor.notify();
+ return Void();
+ }
};
virtual void TearDown() override {}
+ Monitor monitor;
+ // updated by soundModelCallback()
+ ISoundTriggerHwCallback::ModelEvent lastModelEvent;
+
+ protected:
sp<ISoundTriggerHw> mSoundTriggerHal;
- sp<MyCallback> mCallback;
+ sp<SoundTriggerHwCallback> mCallback;
};
// A class for test environment setup (kept since this file is a template).
@@ -137,6 +203,36 @@
EXPECT_TRUE(hidlReturn.isOk());
EXPECT_NE(0, ret);
+ EXPECT_FALSE(monitor.wait(SHORT_TIMEOUT_PERIOD));
+}
+
+/**
+ * Test ISoundTriggerHw::loadSoundModel() method
+ *
+ * Verifies that:
+ * - the implementation returns error when passed a sound model with random data.
+ */
+TEST_F(SoundTriggerHidlTest, LoadGenericSoundModelFail) {
+ int ret = -ENODEV;
+ ISoundTriggerHw::SoundModel model;
+ SoundModelHandle handle = 0;
+
+ model.type = SoundModelType::GENERIC;
+ model.data.resize(100);
+ for (auto& d : model.data) {
+ d = rand();
+ }
+
+ Return<void> loadReturn = mSoundTriggerHal->loadSoundModel(
+ model,
+ mCallback, 0, [&](int32_t retval, auto res) {
+ ret = retval;
+ handle = res;
+ });
+
+ EXPECT_TRUE(loadReturn.isOk());
+ EXPECT_NE(0, ret);
+ EXPECT_FALSE(monitor.wait(SHORT_TIMEOUT_PERIOD));
}
/**
@@ -214,7 +310,6 @@
*/
TEST_F(SoundTriggerHidlTest, stopAllRecognitions) {
Return<int32_t> hidlReturn(0);
- SoundModelHandle handle = 0;
hidlReturn = mSoundTriggerHal->stopAllRecognitions();
diff --git a/tests/Android.bp b/tests/Android.bp
index 997ba79..6606d94 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -16,6 +16,7 @@
"memory/1.0",
"memory/1.0/default",
"msgq/1.0",
+ "msgq/1.0/default",
"pointer/1.0",
"pointer/1.0/default",
"pointer/1.0/default/lib",
diff --git a/tests/bar/1.0/default/Android.bp b/tests/bar/1.0/default/Android.bp
index 14506c5..2a9607b 100644
--- a/tests/bar/1.0/default/Android.bp
+++ b/tests/bar/1.0/default/Android.bp
@@ -2,6 +2,7 @@
cc_library_shared {
name: "android.hardware.tests.bar@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
diff --git a/tests/baz/1.0/default/Android.bp b/tests/baz/1.0/default/Android.bp
index e160d8a..794cdf5 100644
--- a/tests/baz/1.0/default/Android.bp
+++ b/tests/baz/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.tests.baz@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
diff --git a/tests/baz/1.0/default/Baz.cpp b/tests/baz/1.0/default/Baz.cpp
index 8e57fa0..6252fbe 100644
--- a/tests/baz/1.0/default/Baz.cpp
+++ b/tests/baz/1.0/default/Baz.cpp
@@ -33,7 +33,6 @@
static std::string to_string(const hidl_string &s);
static std::string to_string(bool x);
static std::string to_string(const IBaz::StringMatrix5x3 &M);
-static std::string to_string(const IBaz::StringMatrix3x5 &M);
template<typename T, size_t SIZE>
static std::string to_string(const hidl_array<T, SIZE> &array);
@@ -145,10 +144,6 @@
return to_string(M.s);
}
-static std::string to_string(const IBaz::StringMatrix3x5 &M) {
- return to_string(M.s);
-}
-
static std::string VectorOfArray_to_string(const IBaz::VectorOfArray &in) {
std::string out;
out += "VectorOfArray(";
diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp
index 77e617c..f8acf9d 100644
--- a/tests/foo/1.0/default/Android.bp
+++ b/tests/foo/1.0/default/Android.bp
@@ -2,6 +2,7 @@
cc_library_shared {
name: "android.hardware.tests.foo@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
diff --git a/tests/foo/1.0/default/lib/Android.bp b/tests/foo/1.0/default/lib/Android.bp
index 708cf43..895582c 100644
--- a/tests/foo/1.0/default/lib/Android.bp
+++ b/tests/foo/1.0/default/lib/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "libfootest",
+ defaults: ["hidl_defaults"],
srcs: [
"FooHelper.cpp"
],
diff --git a/tests/inheritance/1.0/default/Android.bp b/tests/inheritance/1.0/default/Android.bp
index a67dc09..f6ca88a 100644
--- a/tests/inheritance/1.0/default/Android.bp
+++ b/tests/inheritance/1.0/default/Android.bp
@@ -2,6 +2,7 @@
cc_library_shared {
name: "android.hardware.tests.inheritance@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
diff --git a/tests/libhwbinder/1.0/default/Android.bp b/tests/libhwbinder/1.0/default/Android.bp
index 6e8fbb1..e690ca5 100644
--- a/tests/libhwbinder/1.0/default/Android.bp
+++ b/tests/libhwbinder/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.tests.libhwbinder@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
diff --git a/tests/memory/1.0/default/Android.bp b/tests/memory/1.0/default/Android.bp
index 40716da..e889bd8 100644
--- a/tests/memory/1.0/default/Android.bp
+++ b/tests/memory/1.0/default/Android.bp
@@ -14,6 +14,7 @@
cc_library_shared {
name: "android.hardware.tests.memory@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: [
diff --git a/tests/msgq/1.0/Android.bp b/tests/msgq/1.0/Android.bp
index d17efe4..2d42699 100644
--- a/tests/msgq/1.0/Android.bp
+++ b/tests/msgq/1.0/Android.bp
@@ -3,6 +3,7 @@
filegroup {
name: "android.hardware.tests.msgq@1.0_hal",
srcs: [
+ "IBenchmarkMsgQ.hal",
"ITestMsgQ.hal",
],
}
@@ -15,6 +16,7 @@
":android.hardware.tests.msgq@1.0_hal",
],
out: [
+ "android/hardware/tests/msgq/1.0/BenchmarkMsgQAll.cpp",
"android/hardware/tests/msgq/1.0/TestMsgQAll.cpp",
],
}
@@ -27,6 +29,11 @@
":android.hardware.tests.msgq@1.0_hal",
],
out: [
+ "android/hardware/tests/msgq/1.0/IBenchmarkMsgQ.h",
+ "android/hardware/tests/msgq/1.0/IHwBenchmarkMsgQ.h",
+ "android/hardware/tests/msgq/1.0/BnHwBenchmarkMsgQ.h",
+ "android/hardware/tests/msgq/1.0/BpHwBenchmarkMsgQ.h",
+ "android/hardware/tests/msgq/1.0/BsBenchmarkMsgQ.h",
"android/hardware/tests/msgq/1.0/ITestMsgQ.h",
"android/hardware/tests/msgq/1.0/IHwTestMsgQ.h",
"android/hardware/tests/msgq/1.0/BnHwTestMsgQ.h",
diff --git a/benchmarks/msgq/1.0/IBenchmarkMsgQ.hal b/tests/msgq/1.0/IBenchmarkMsgQ.hal
similarity index 98%
rename from benchmarks/msgq/1.0/IBenchmarkMsgQ.hal
rename to tests/msgq/1.0/IBenchmarkMsgQ.hal
index c4b9d95..81754a4 100644
--- a/benchmarks/msgq/1.0/IBenchmarkMsgQ.hal
+++ b/tests/msgq/1.0/IBenchmarkMsgQ.hal
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.hardware.benchmarks.msgq@1.0;
+package android.hardware.tests.msgq@1.0;
interface IBenchmarkMsgQ {
/*
diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp
new file mode 100644
index 0000000..16018ac
--- /dev/null
+++ b/tests/msgq/1.0/default/Android.bp
@@ -0,0 +1,68 @@
+//
+// Copyright (C) 2017 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.
+
+cc_library_shared {
+ name: "android.hardware.tests.msgq@1.0-impl",
+ defaults: ["hidl_defaults"],
+ relative_install_path: "hw",
+ proprietary: true,
+ srcs: [
+ "TestMsgQ.cpp",
+ "BenchmarkMsgQ.cpp"
+ ],
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libfmq",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libutils",
+ "android.hardware.tests.msgq@1.0",
+ "android.hidl.base@1.0",
+ ],
+}
+
+cc_test {
+ name: "android.hardware.tests.msgq@1.0-service-benchmark",
+ srcs: ["mq_benchmark_service.cpp"],
+ gtest: false,
+
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libutils",
+ "android.hardware.tests.msgq@1.0"
+ ],
+}
+
+cc_test {
+ name: "android.hardware.tests.msgq@1.0-service-test",
+ srcs: ["mq_test_service.cpp"],
+ gtest: false,
+
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libutils",
+ "android.hardware.tests.msgq@1.0"
+ ],
+}
diff --git a/tests/msgq/1.0/default/BenchmarkMsgQ.cpp b/tests/msgq/1.0/default/BenchmarkMsgQ.cpp
new file mode 100644
index 0000000..43e6fcc
--- /dev/null
+++ b/tests/msgq/1.0/default/BenchmarkMsgQ.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2017 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 "BenchmarkMsgQ.h"
+#include <iostream>
+#include <thread>
+#include <fmq/MessageQueue.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace msgq {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::msgq::V1_0::IBenchmarkMsgQ follow.
+Return<void> BenchmarkMsgQ::configureClientInboxSyncReadWrite(
+ configureClientInboxSyncReadWrite_cb _hidl_cb) {
+ static constexpr size_t kNumElementsInQueue = 16 * 1024;
+ mFmqOutbox = new (std::nothrow) android::hardware::MessageQueue<uint8_t,
+ kSynchronizedReadWrite>(kNumElementsInQueue);
+ if (mFmqOutbox == nullptr) {
+ _hidl_cb(false /* ret */, android::hardware::MQDescriptorSync<uint8_t>(
+ std::vector<android::hardware::GrantorDescriptor>(),
+ nullptr /* nhandle */, 0 /* size */));
+ } else {
+ _hidl_cb(true /* ret */, *mFmqOutbox->getDesc());
+ }
+
+ return Void();
+}
+
+Return<void> BenchmarkMsgQ::configureClientOutboxSyncReadWrite(
+ configureClientOutboxSyncReadWrite_cb _hidl_cb) {
+ static constexpr size_t kNumElementsInQueue = 16 * 1024;
+ mFmqInbox = new (std::nothrow) android::hardware::MessageQueue<uint8_t,
+ kSynchronizedReadWrite>(kNumElementsInQueue);
+ if ((mFmqInbox == nullptr) || (mFmqInbox->isValid() == false)) {
+ _hidl_cb(false /* ret */, android::hardware::MQDescriptorSync<uint8_t>(
+ std::vector<android::hardware::GrantorDescriptor>(),
+ nullptr /* nhandle */, 0 /* size */));
+ } else {
+ _hidl_cb(true /* ret */, *mFmqInbox->getDesc());
+ }
+
+ return Void();
+}
+
+Return<bool> BenchmarkMsgQ::requestWrite(int32_t count) {
+ uint8_t* data = new (std::nothrow) uint8_t[count];
+ for (int i = 0; i < count; i++) {
+ data[i] = i;
+ }
+ bool result = mFmqOutbox->write(data, count);
+ delete[] data;
+ return result;
+}
+
+Return<bool> BenchmarkMsgQ::requestRead(int32_t count) {
+ uint8_t* data = new (std::nothrow) uint8_t[count];
+ bool result = mFmqInbox->read(data, count);
+ delete[] data;
+ return result;
+}
+
+Return<void> BenchmarkMsgQ::benchmarkPingPong(uint32_t numIter) {
+ std::thread(QueuePairReadWrite<kSynchronizedReadWrite>, mFmqInbox,
+ mFmqOutbox, numIter)
+ .detach();
+ return Void();
+}
+
+Return<void> BenchmarkMsgQ::benchmarkServiceWriteClientRead(uint32_t numIter) {
+ if (mTimeData) delete[] mTimeData;
+ mTimeData = new (std::nothrow) int64_t[numIter];
+ std::thread(QueueWriter<kSynchronizedReadWrite>, mFmqOutbox,
+ mTimeData, numIter).detach();
+ return Void();
+}
+
+Return<void> BenchmarkMsgQ::sendTimeData(const hidl_vec<int64_t>& clientRcvTimeArray) {
+ int64_t accumulatedTime = 0;
+
+ for (uint32_t i = 0; i < clientRcvTimeArray.size(); i++) {
+ std::chrono::time_point<std::chrono::high_resolution_clock>
+ clientRcvTime((std::chrono::high_resolution_clock::duration(
+ clientRcvTimeArray[i])));
+ std::chrono::time_point<std::chrono::high_resolution_clock>serverSendTime(
+ (std::chrono::high_resolution_clock::duration(mTimeData[i])));
+ accumulatedTime += static_cast<int64_t>(
+ std::chrono::duration_cast<std::chrono::nanoseconds>(clientRcvTime -
+ serverSendTime).count());
+ }
+
+ accumulatedTime /= clientRcvTimeArray.size();
+ std::cout << "Average service to client write to read delay::"
+ << accumulatedTime << "ns" << std::endl;
+ return Void();
+}
+
+template <MQFlavor flavor>
+void BenchmarkMsgQ::QueueWriter(android::hardware::MessageQueue<uint8_t, flavor>* mFmqOutbox,
+ int64_t* mTimeData,
+ uint32_t numIter) {
+ uint8_t data[kPacketSize64];
+ uint32_t numWrites = 0;
+
+ while (numWrites < numIter) {
+ do {
+ mTimeData[numWrites] =
+ std::chrono::high_resolution_clock::now().time_since_epoch().count();
+ } while (mFmqOutbox->write(data, kPacketSize64) == false);
+ numWrites++;
+ }
+}
+
+template <MQFlavor flavor>
+void BenchmarkMsgQ::QueuePairReadWrite(
+ android::hardware::MessageQueue<uint8_t, flavor>* mFmqInbox,
+ android::hardware::MessageQueue<uint8_t, flavor>* mFmqOutbox,
+ uint32_t numIter) {
+ uint8_t data[kPacketSize64];
+ uint32_t numRoundTrips = 0;
+
+ while (numRoundTrips < numIter) {
+ while (mFmqInbox->read(data, kPacketSize64) == false)
+ ;
+ while (mFmqOutbox->write(data, kPacketSize64) == false)
+ ;
+ numRoundTrips++;
+ }
+}
+
+IBenchmarkMsgQ* HIDL_FETCH_IBenchmarkMsgQ(const char* /* name */) {
+ return new BenchmarkMsgQ();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace msgq
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/msgq/1.0/default/BenchmarkMsgQ.h b/tests/msgq/1.0/default/BenchmarkMsgQ.h
new file mode 100644
index 0000000..2cbe93c
--- /dev/null
+++ b/tests/msgq/1.0/default/BenchmarkMsgQ.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef ANDROID_HARDWARE_TESTS_MSGQ_V1_0_BENCHMARKMSGQ_H
+#define ANDROID_HARDWARE_TESTS_MSGQ_V1_0_BENCHMARKMSGQ_H
+
+#include <android/hardware/tests/msgq/1.0/IBenchmarkMsgQ.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <fmq/MessageQueue.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace msgq {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::msgq::V1_0::IBenchmarkMsgQ;
+using ::android::hidl::base::V1_0::DebugInfo;
+using ::android::hidl::base::V1_0::IBase;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+using android::hardware::kSynchronizedReadWrite;
+using android::hardware::MQFlavor;
+
+struct BenchmarkMsgQ : public IBenchmarkMsgQ {
+ /*
+ * The various packet sizes used are as follows.
+ */
+ enum PacketSizes {
+ kPacketSize64 = 64,
+ kPacketSize128 = 128,
+ kPacketSize256 = 256,
+ kPacketSize512 = 512,
+ kPacketSize1024 = 1024
+ };
+ // Methods from ::android::hardware::tests::msgq::V1_0::IBenchmarkMsgQ follow.
+ Return<void> configureClientInboxSyncReadWrite(configureClientInboxSyncReadWrite_cb _hidl_cb) override;
+ Return<void> configureClientOutboxSyncReadWrite(configureClientOutboxSyncReadWrite_cb _hidl_cb) override;
+ Return<bool> requestWrite(int32_t count) override;
+ Return<bool> requestRead(int32_t count) override;
+ Return<void> benchmarkPingPong(uint32_t numIter) override;
+ Return<void> benchmarkServiceWriteClientRead(uint32_t numIter) override;
+ Return<void> sendTimeData(const hidl_vec<int64_t>& timeData) override;
+
+ /*
+ * This method writes numIter packets into the mFmqOutbox queue
+ * and notes the time before each write in the mTimeData array. It will
+ * be used to calculate the average server to client write to read delay.
+ */
+ template <MQFlavor flavor>
+ static void QueueWriter(android::hardware::MessageQueue<uint8_t, flavor>*
+ mFmqOutbox, int64_t* mTimeData, uint32_t numIter);
+ /*
+ * The method reads a packet from the inbox queue and writes the same
+ * into the outbox queue. The client will calculate the average time taken
+ * for each iteration which consists of two write and two read operations.
+ */
+ template <MQFlavor flavor>
+ static void QueuePairReadWrite(
+ android::hardware::MessageQueue<uint8_t, flavor>* mFmqInbox,
+ android::hardware::MessageQueue<uint8_t, flavor>* mFmqOutbox,
+ uint32_t numIter);
+
+private:
+ android::hardware::MessageQueue<uint8_t, kSynchronizedReadWrite>* mFmqInbox;
+ android::hardware::MessageQueue<uint8_t, kSynchronizedReadWrite>* mFmqOutbox;
+ int64_t* mTimeData;
+};
+
+extern "C" IBenchmarkMsgQ* HIDL_FETCH_IBenchmarkMsgQ(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace msgq
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TESTS_MSGQ_V1_0_BENCHMARKMSGQ_H
diff --git a/tests/msgq/1.0/default/TestMsgQ.cpp b/tests/msgq/1.0/default/TestMsgQ.cpp
new file mode 100644
index 0000000..6fd4fc6
--- /dev/null
+++ b/tests/msgq/1.0/default/TestMsgQ.cpp
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2017 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 "TestMsgQ.h"
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace msgq {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::msgq::V1_0::ITestMsgQ follow.
+Return<void> TestMsgQ::configureFmqSyncReadWrite(configureFmqSyncReadWrite_cb _hidl_cb) {
+ static constexpr size_t kNumElementsInQueue = 1024;
+ mFmqSynchronized.reset(new (std::nothrow) MessageQueueSync(
+ kNumElementsInQueue, true /* configureEventFlagWord */));
+ if ((mFmqSynchronized == nullptr) || (mFmqSynchronized->isValid() == false)) {
+ _hidl_cb(false /* ret */, MessageQueueSync::Descriptor());
+ } else {
+ /*
+ * Initialize the EventFlag word with bit FMQ_NOT_FULL.
+ */
+ auto evFlagWordPtr = mFmqSynchronized->getEventFlagWord();
+ if (evFlagWordPtr != nullptr) {
+ std::atomic_init(evFlagWordPtr,
+ static_cast<uint32_t>(ITestMsgQ::EventFlagBits::FMQ_NOT_FULL));
+ }
+ _hidl_cb(true /* ret */, *mFmqSynchronized->getDesc());
+ }
+ return Void();
+}
+
+Return<void> TestMsgQ::getFmqUnsyncWrite(bool configureFmq, getFmqUnsyncWrite_cb _hidl_cb) {
+ if (configureFmq) {
+ static constexpr size_t kNumElementsInQueue = 1024;
+ mFmqUnsynchronized.reset(new (std::nothrow) MessageQueueUnsync(kNumElementsInQueue));
+ }
+ if ((mFmqUnsynchronized == nullptr) ||
+ (mFmqUnsynchronized->isValid() == false)) {
+ _hidl_cb(false /* ret */, MessageQueueUnsync::Descriptor());
+ } else {
+ _hidl_cb(true /* ret */, *mFmqUnsynchronized->getDesc());
+ }
+ return Void();
+}
+
+Return<bool> TestMsgQ::requestWriteFmqSync(int32_t count) {
+ std::vector<uint16_t> data(count);
+ for (int i = 0; i < count; i++) {
+ data[i] = i;
+ }
+ bool result = mFmqSynchronized->write(&data[0], count);
+ return result;
+}
+
+Return<bool> TestMsgQ::requestReadFmqSync(int32_t count) {
+ std::vector<uint16_t> data(count);
+ bool result = mFmqSynchronized->read(&data[0], count)
+ && verifyData(&data[0], count);
+ return result;
+}
+
+Return<bool> TestMsgQ::requestWriteFmqUnsync(int32_t count) {
+ std::vector<uint16_t> data(count);
+ for (int i = 0; i < count; i++) {
+ data[i] = i;
+ }
+ bool result = mFmqUnsynchronized->write(&data[0], count);
+ return result;
+}
+
+Return<bool> TestMsgQ::requestReadFmqUnsync(int32_t count) {
+ std::vector<uint16_t> data(count);
+ bool result =
+ mFmqUnsynchronized->read(&data[0], count) && verifyData(&data[0], count);
+ return result;
+}
+
+Return<void> TestMsgQ::requestBlockingRead(int32_t count) {
+ std::vector<uint16_t> data(count);
+ bool result = mFmqSynchronized->readBlocking(
+ &data[0],
+ count,
+ static_cast<uint32_t>(ITestMsgQ::EventFlagBits::FMQ_NOT_FULL),
+ static_cast<uint32_t>(ITestMsgQ::EventFlagBits::FMQ_NOT_EMPTY),
+ 5000000000 /* timeOutNanos */);
+
+ if (result == false) {
+ ALOGE("Blocking read fails");
+ }
+ return Void();
+}
+
+Return<void> TestMsgQ::requestBlockingReadDefaultEventFlagBits(int32_t count) {
+ std::vector<uint16_t> data(count);
+ bool result = mFmqSynchronized->readBlocking(
+ &data[0],
+ count);
+
+ if (result == false) {
+ ALOGE("Blocking read fails");
+ }
+
+ return Void();
+}
+
+Return<void> TestMsgQ::requestBlockingReadRepeat(int32_t count, int32_t numIter) {
+ std::vector<uint16_t> data(count);
+ for (int i = 0; i < numIter; i++) {
+ bool result = mFmqSynchronized->readBlocking(
+ &data[0],
+ count,
+ static_cast<uint32_t>(ITestMsgQ::EventFlagBits::FMQ_NOT_FULL),
+ static_cast<uint32_t>(ITestMsgQ::EventFlagBits::FMQ_NOT_EMPTY),
+ 5000000000 /* timeOutNanos */);
+
+ if (result == false) {
+ ALOGE("Blocking read fails");
+ break;
+ }
+ }
+ return Void();
+}
+
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
+ITestMsgQ* HIDL_FETCH_ITestMsgQ(const char* /* name */) {
+ return new TestMsgQ();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace msgq
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/msgq/1.0/default/TestMsgQ.h b/tests/msgq/1.0/default/TestMsgQ.h
new file mode 100644
index 0000000..86e4ac4
--- /dev/null
+++ b/tests/msgq/1.0/default/TestMsgQ.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#ifndef ANDROID_HARDWARE_TESTS_MSGQ_V1_0_TESTMSGQ_H
+#define ANDROID_HARDWARE_TESTS_MSGQ_V1_0_TESTMSGQ_H
+
+#include <android/hardware/tests/msgq/1.0/ITestMsgQ.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <fmq/MessageQueue.h>
+#include <fmq/EventFlag.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace msgq {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::msgq::V1_0::ITestMsgQ;
+using ::android::hidl::base::V1_0::DebugInfo;
+using ::android::hidl::base::V1_0::IBase;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+using android::hardware::kSynchronizedReadWrite;
+using android::hardware::kUnsynchronizedWrite;
+using android::hardware::MQDescriptorSync;
+using android::hardware::MQDescriptorUnsync;
+
+using android::hardware::MessageQueue;
+
+struct TestMsgQ : public ITestMsgQ {
+ typedef MessageQueue<uint16_t, kSynchronizedReadWrite> MessageQueueSync;
+ typedef MessageQueue<uint16_t, kUnsynchronizedWrite> MessageQueueUnsync;
+
+ TestMsgQ() : mFmqSynchronized(nullptr), mFmqUnsynchronized(nullptr) {}
+
+ // Methods from ::android::hardware::tests::msgq::V1_0::ITestMsgQ follow.
+ Return<void> configureFmqSyncReadWrite(configureFmqSyncReadWrite_cb _hidl_cb) override;
+ Return<void> getFmqUnsyncWrite(bool configureFmq, getFmqUnsyncWrite_cb _hidl_cb) override;
+ Return<bool> requestWriteFmqSync(int32_t count) override;
+ Return<bool> requestReadFmqSync(int32_t count) override;
+ Return<bool> requestWriteFmqUnsync(int32_t count) override;
+ Return<bool> requestReadFmqUnsync(int32_t count) override;
+ Return<void> requestBlockingRead(int32_t count) override;
+ Return<void> requestBlockingReadDefaultEventFlagBits(int32_t count) override;
+ Return<void> requestBlockingReadRepeat(int32_t count, int32_t numIter) override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+private:
+ std::unique_ptr<MessageQueueSync> mFmqSynchronized;
+ std::unique_ptr<MessageQueueUnsync> mFmqUnsynchronized;
+
+ /*
+ * Utility function to verify data read from the fast message queue.
+ */
+ bool verifyData(uint16_t* data, int count) {
+ for (int i = 0; i < count; i++) {
+ if (data[i] != i) return false;
+ }
+ return true;
+ }
+};
+
+extern "C" ITestMsgQ* HIDL_FETCH_ITestMsgQ(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace msgq
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TESTS_MSGQ_V1_0_TESTMSGQ_H
diff --git a/tests/msgq/1.0/default/mq_benchmark_service.cpp b/tests/msgq/1.0/default/mq_benchmark_service.cpp
new file mode 100644
index 0000000..b9be81b
--- /dev/null
+++ b/tests/msgq/1.0/default/mq_benchmark_service.cpp
@@ -0,0 +1,28 @@
+/*
+* Copyright (C) 2017 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#define LOG_TAG "FMQ_Benchmarks"
+
+#include <android/hardware/tests/msgq/1.0/IBenchmarkMsgQ.h>
+
+#include <hidl/LegacySupport.h>
+
+using android::hardware::tests::msgq::V1_0::IBenchmarkMsgQ;
+using android::hardware::defaultPassthroughServiceImplementation;
+
+int main() {
+ return defaultPassthroughServiceImplementation<IBenchmarkMsgQ>();
+}
diff --git a/tests/msgq/1.0/default/mq_test_service.cpp b/tests/msgq/1.0/default/mq_test_service.cpp
new file mode 100644
index 0000000..b5cb662
--- /dev/null
+++ b/tests/msgq/1.0/default/mq_test_service.cpp
@@ -0,0 +1,28 @@
+/*
+* Copyright (C) 2017 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#define LOG_TAG "FMQ_UnitTests"
+
+#include <android/hardware/tests/msgq/1.0/ITestMsgQ.h>
+
+#include <hidl/LegacySupport.h>
+
+using android::hardware::tests::msgq::V1_0::ITestMsgQ;
+using android::hardware::defaultPassthroughServiceImplementation;
+
+int main() {
+ return defaultPassthroughServiceImplementation<ITestMsgQ>();
+}
diff --git a/tests/pointer/1.0/default/Android.bp b/tests/pointer/1.0/default/Android.bp
index c4dc013..4615463 100644
--- a/tests/pointer/1.0/default/Android.bp
+++ b/tests/pointer/1.0/default/Android.bp
@@ -2,6 +2,7 @@
cc_library_shared {
name: "android.hardware.tests.pointer@1.0-impl",
+ defaults: ["hidl_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
diff --git a/tests/pointer/1.0/default/lib/Android.bp b/tests/pointer/1.0/default/lib/Android.bp
index 7737932..ae07b04 100644
--- a/tests/pointer/1.0/default/lib/Android.bp
+++ b/tests/pointer/1.0/default/lib/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "libpointertest",
+ defaults: ["hidl_defaults"],
srcs: [
"PointerHelper.cpp"
],
diff --git a/thermal/1.0/default/Android.bp b/thermal/1.0/default/Android.bp
index 0b068e7..1510509 100644
--- a/thermal/1.0/default/Android.bp
+++ b/thermal/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.thermal@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Thermal.cpp"],
diff --git a/thermal/1.0/vts/functional/Android.bp b/thermal/1.0/vts/functional/Android.bp
index 456b75b..9046882 100644
--- a/thermal/1.0/vts/functional/Android.bp
+++ b/thermal/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalThermalV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalThermalV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.thermal@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp b/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
index 6feec73..3989c94 100644
--- a/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
+++ b/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
@@ -24,7 +24,7 @@
#include <android-base/logging.h>
#include <android/hardware/thermal/1.0/IThermal.h>
#include <android/hardware/thermal/1.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <unistd.h>
using ::android::hardware::hidl_string;
@@ -46,10 +46,10 @@
#define MAX_FAN_SPEED 20000
// The main test class for THERMAL HIDL HAL.
-class ThermalHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class ThermalHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- thermal_ = ::testing::VtsHalHidlTargetBaseTest::getService<IThermal>();
+ thermal_ = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>();
ASSERT_NE(thermal_, nullptr);
baseSize_ = 0;
names_.clear();
diff --git a/tv/input/1.0/vts/functional/Android.bp b/tv/input/1.0/vts/functional/Android.bp
index bcff457..c862429 100644
--- a/tv/input/1.0/vts/functional/Android.bp
+++ b/tv/input/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalTvInputV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalTvInputV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.tv.input@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp b/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp
index 6757df1..0d5110e 100644
--- a/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp
+++ b/tv/input/1.0/vts/functional/VtsHalTvInputV1_0TargetTest.cpp
@@ -21,7 +21,7 @@
#include <android/hardware/tv/input/1.0/ITvInput.h>
#include <android/hardware/tv/input/1.0/ITvInputCallback.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <utils/KeyedVector.h>
#include <mutex>
#include <vector>
@@ -43,10 +43,10 @@
#define DEFAULT_ID INT32_MIN
/* The main test class for TV Input HIDL HAL. */
-class TvInputHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class TvInputHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- tv_input_ = ::testing::VtsHalHidlTargetBaseTest::getService<ITvInput>();
+ tv_input_ = ::testing::VtsHalHidlTargetTestBase::getService<ITvInput>();
ASSERT_NE(tv_input_, nullptr);
tv_input_callback_ = new TvInputCallback(*this);
ASSERT_NE(tv_input_callback_, nullptr);
diff --git a/usb/1.0/vts/functional/Android.bp b/usb/1.0/vts/functional/Android.bp
index ef47f25..7438bc7 100644
--- a/usb/1.0/vts/functional/Android.bp
+++ b/usb/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalUsbV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalUsbV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -27,7 +28,7 @@
"libutils",
"android.hardware.usb@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp b/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp
index 9d59fe2..54db8c2 100644
--- a/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp
+++ b/usb/1.0/vts/functional/VtsHalUsbV1_0TargetTest.cpp
@@ -21,7 +21,7 @@
#include <android/hardware/usb/1.0/IUsbCallback.h>
#include <android/hardware/usb/1.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <stdlib.h>
#include <chrono>
#include <condition_variable>
@@ -50,7 +50,7 @@
#define USB_SERVICE_NAME "usb_hal"
// The main test class for the USB hidl HAL
-class UsbHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class UsbHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
// Callback class for the USB HIDL hal.
// Usb Hal will call this object upon role switch or port query.
@@ -97,7 +97,7 @@
virtual void SetUp() override {
ALOGI("Setup");
- usb = ::testing::VtsHalHidlTargetBaseTest::getService<IUsb>(USB_SERVICE_NAME);
+ usb = ::testing::VtsHalHidlTargetTestBase::getService<IUsb>(USB_SERVICE_NAME);
ASSERT_NE(usb, nullptr);
usb_cb_2 = new UsbCallback(*this, 2);
diff --git a/vibrator/1.0/default/Android.bp b/vibrator/1.0/default/Android.bp
index 3bd317f..d4200da 100644
--- a/vibrator/1.0/default/Android.bp
+++ b/vibrator/1.0/default/Android.bp
@@ -15,6 +15,7 @@
cc_library_shared {
name: "android.hardware.vibrator@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Vibrator.cpp"],
diff --git a/vibrator/1.0/vts/functional/Android.bp b/vibrator/1.0/vts/functional/Android.bp
index ff9dca8..9e25def 100644
--- a/vibrator/1.0/vts/functional/Android.bp
+++ b/vibrator/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalVibratorV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalVibratorV1_0TargetTest.cpp"],
shared_libs: [
"libbase",
@@ -24,7 +25,7 @@
"libutils",
"android.hardware.vibrator@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp b/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
index c9541fe..a978f2c 100644
--- a/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
+++ b/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
@@ -19,7 +19,7 @@
#include <android-base/logging.h>
#include <android/hardware/vibrator/1.0/IVibrator.h>
#include <android/hardware/vibrator/1.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <unistd.h>
using ::android::hardware::vibrator::V1_0::IVibrator;
@@ -29,10 +29,10 @@
using ::android::sp;
// The main test class for VIBRATOR HIDL HAL.
-class VibratorHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class VibratorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- vibrator = ::testing::VtsHalHidlTargetBaseTest::getService<IVibrator>();
+ vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>();
ASSERT_NE(vibrator, nullptr);
}
diff --git a/vr/1.0/default/Android.bp b/vr/1.0/default/Android.bp
index e7afa9a..ddc1bfb 100644
--- a/vr/1.0/default/Android.bp
+++ b/vr/1.0/default/Android.bp
@@ -1,5 +1,6 @@
cc_library_shared {
name: "android.hardware.vr@1.0-impl",
+ defaults: ["hidl_defaults"],
proprietary: true,
relative_install_path: "hw",
srcs: ["Vr.cpp"],
@@ -18,6 +19,7 @@
cc_binary {
relative_install_path: "hw",
+ defaults: ["hidl_defaults"],
proprietary: true,
name: "android.hardware.vr@1.0-service",
init_rc: ["android.hardware.vr@1.0-service.rc"],
diff --git a/vr/1.0/default/Vr.cpp b/vr/1.0/default/Vr.cpp
index 345db99..4bba9eb 100644
--- a/vr/1.0/default/Vr.cpp
+++ b/vr/1.0/default/Vr.cpp
@@ -43,7 +43,6 @@
}
IVr* HIDL_FETCH_IVr(const char * /*name*/) {
- vr_module_t *vr_module;
const hw_module_t *hw_module = NULL;
int ret = hw_get_module(VR_HARDWARE_MODULE_ID, &hw_module);
diff --git a/vr/1.0/vts/functional/Android.bp b/vr/1.0/vts/functional/Android.bp
index b2e50ad..5d5a99a 100644
--- a/vr/1.0/vts/functional/Android.bp
+++ b/vr/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalVrV1_0TargetTest",
+ defaults: ["hidl_defaults"],
srcs: ["VtsHalVrV1_0TargetTest.cpp"],
shared_libs: [
"liblog",
@@ -23,7 +24,7 @@
"libutils",
"android.hardware.vr@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp
index 6a7b078..a983731 100644
--- a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp
+++ b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp
@@ -18,7 +18,7 @@
#include <android-base/logging.h>
#include <android/hardware/vr/1.0/IVr.h>
#include <android/log.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <hardware/vr.h>
using ::android::hardware::vr::V1_0::IVr;
@@ -27,10 +27,10 @@
using ::android::sp;
// The main test class for VR HIDL HAL.
-class VrHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
void SetUp() override {
- vr = ::testing::VtsHalHidlTargetBaseTest::getService<IVr>();
+ vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>();
ASSERT_NE(vr, nullptr);
}
diff --git a/wifi/1.0/Android.mk b/wifi/1.0/Android.mk
index fa6ef6c..eabc63d 100644
--- a/wifi/1.0/Android.mk
+++ b/wifi/1.0/Android.mk
@@ -1043,6 +1043,25 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (StaScanLimits)
+#
+GEN := $(intermediates)/android/hardware/wifi/V1_0/StaScanLimits.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.wifi@1.0::types.StaScanLimits
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (StaScanResult)
#
GEN := $(intermediates)/android/hardware/wifi/V1_0/StaScanResult.java
@@ -2846,6 +2865,25 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (StaScanLimits)
+#
+GEN := $(intermediates)/android/hardware/wifi/V1_0/StaScanLimits.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.wifi@1.0::types.StaScanLimits
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build types.hal (StaScanResult)
#
GEN := $(intermediates)/android/hardware/wifi/V1_0/StaScanResult.java
diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk
index 00e5f98..cc5e1c6 100644
--- a/wifi/1.0/default/Android.mk
+++ b/wifi/1.0/default/Android.mk
@@ -18,6 +18,9 @@
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CPPFLAGS := -Wall -Werror -Wextra
+ifdef WIFI_HIDL_FEATURE_AWARE
+LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_AWARE
+endif
LOCAL_SRC_FILES := \
hidl_struct_util.cpp \
hidl_sync_util.cpp \
@@ -43,7 +46,8 @@
libnl \
libutils \
libwifi-hal \
- libwifi-system
+ libwifi-system \
+ libcld80211
LOCAL_WHOLE_STATIC_LIBRARIES := $(LIB_WIFI_HAL)
LOCAL_INIT_RC := android.hardware.wifi@1.0-service.rc
include $(BUILD_EXECUTABLE)
diff --git a/wifi/1.0/default/android.hardware.wifi@1.0-service.rc b/wifi/1.0/default/android.hardware.wifi@1.0-service.rc
index c0ae4d4..696b1f9 100644
--- a/wifi/1.0/default/android.hardware.wifi@1.0-service.rc
+++ b/wifi/1.0/default/android.hardware.wifi@1.0-service.rc
@@ -1,4 +1,4 @@
service wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service
class hal
user wifi
- group wifi
+ group wifi gps
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index 485ae7e..fb93c5a 100644
--- a/wifi/1.0/default/hidl_struct_util.cpp
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -354,7 +354,10 @@
hidl_scan_params.buckets[bucket_idx];
legacy_hal::wifi_scan_bucket_spec& legacy_bucket_spec =
legacy_scan_params->buckets[bucket_idx];
- legacy_bucket_spec.bucket = bucket_idx;
+ if (hidl_bucket_spec.bucketIdx >= MAX_BUCKETS) {
+ return false;
+ }
+ legacy_bucket_spec.bucket = hidl_bucket_spec.bucketIdx;
legacy_bucket_spec.band =
convertHidlWifiBandToLegacy(hidl_bucket_spec.band);
legacy_bucket_spec.period = hidl_bucket_spec.periodInMs;
@@ -703,11 +706,17 @@
hidl_stats->iface.wmeVoPktStats.retries =
legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries;
// radio legacy_stats conversion.
- hidl_stats->radio.onTimeInMs = legacy_stats.radio.on_time;
- hidl_stats->radio.txTimeInMs = legacy_stats.radio.tx_time;
- hidl_stats->radio.rxTimeInMs = legacy_stats.radio.rx_time;
- hidl_stats->radio.onTimeInMsForScan = legacy_stats.radio.on_time_scan;
- hidl_stats->radio.txTimeInMsPerLevel = legacy_stats.radio_tx_time_per_levels;
+ std::vector<StaLinkLayerRadioStats> hidl_radios_stats;
+ for (const auto& legacy_radio_stats : legacy_stats.radios) {
+ StaLinkLayerRadioStats hidl_radio_stats;
+ hidl_radio_stats.onTimeInMs = legacy_radio_stats.stats.on_time;
+ hidl_radio_stats.txTimeInMs = legacy_radio_stats.stats.tx_time;
+ hidl_radio_stats.rxTimeInMs = legacy_radio_stats.stats.rx_time;
+ hidl_radio_stats.onTimeInMsForScan = legacy_radio_stats.stats.on_time_scan;
+ hidl_radio_stats.txTimeInMsPerLevel = legacy_radio_stats.tx_time_per_levels;
+ hidl_radios_stats.push_back(hidl_radio_stats);
+ }
+ hidl_stats->radios = hidl_radios_stats;
// Timestamp in the HAL wrapper here since it's not provided in the legacy
// HAL API.
hidl_stats->timeStampInMs = uptimeMillis();
@@ -984,7 +993,7 @@
legacy_request->ranging_cfg.distance_egress_cm = hidl_request.baseConfigs.distanceEgressCm;
legacy_request->ranging_auto_response = hidl_request.baseConfigs.rangingRequired ?
legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
- legacy_request->range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
+ legacy_request->sdea_params.range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
legacy_request->publish_type = (legacy_hal::NanPublishType) hidl_request.publishType;
legacy_request->tx_type = (legacy_hal::NanTxType) hidl_request.txType;
legacy_request->service_responder_policy = hidl_request.autoAcceptDataPathRequests ?
@@ -1077,7 +1086,7 @@
legacy_request->ranging_cfg.distance_egress_cm = hidl_request.baseConfigs.distanceEgressCm;
legacy_request->ranging_auto_response = hidl_request.baseConfigs.rangingRequired ?
legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
- legacy_request->range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
+ legacy_request->sdea_params.range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
legacy_request->subscribe_type = (legacy_hal::NanSubscribeType) hidl_request.subscribeType;
legacy_request->serviceResponseFilter = (legacy_hal::NanSRFType) hidl_request.srfType;
legacy_request->serviceResponseInclude = hidl_request.srfRespondIfInAddressSet ?
@@ -1895,10 +1904,12 @@
hidl_result->timeStampInUs = legacy_result.ts;
hidl_result->burstDurationInMs = legacy_result.burst_duration;
hidl_result->negotiatedBurstNum = legacy_result.negotiated_burst_num;
- if (!convertLegacyIeToHidl(*legacy_result.LCI, &hidl_result->lci)) {
+ if (legacy_result.LCI && !convertLegacyIeToHidl(*legacy_result.LCI,
+ &hidl_result->lci)) {
return false;
}
- if (!convertLegacyIeToHidl(*legacy_result.LCR, &hidl_result->lcr)) {
+ if (legacy_result.LCR && !convertLegacyIeToHidl(*legacy_result.LCR,
+ &hidl_result->lcr)) {
return false;
}
return true;
diff --git a/wifi/1.0/default/wifi.cpp b/wifi/1.0/default/wifi.cpp
index 3d482b4..b48844e 100644
--- a/wifi/1.0/default/wifi.cpp
+++ b/wifi/1.0/default/wifi.cpp
@@ -115,6 +115,7 @@
}
}
}
+ LOG(INFO) << "Wifi HAL started";
return wifi_status;
}
@@ -139,6 +140,13 @@
}
}
}
+ // Clear the chip object and its child objects since the HAL is now
+ // stopped.
+ if (chip_.get()) {
+ chip_->invalidate();
+ chip_.clear();
+ }
+ LOG(INFO) << "Wifi HAL stopped";
return wifi_status;
}
@@ -172,13 +180,7 @@
WifiStatus Wifi::stopLegacyHalAndDeinitializeModeController() {
run_state_ = RunState::STOPPING;
- const auto on_complete_callback_ = [&]() {
- if (chip_.get()) {
- chip_->invalidate();
- }
- chip_.clear();
- run_state_ = RunState::STOPPED;
- };
+ const auto on_complete_callback_ = [&]() { run_state_ = RunState::STOPPED; };
legacy_hal::wifi_error legacy_status =
legacy_hal_->stop(on_complete_callback_);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
index 6f980c0..9c41a40 100644
--- a/wifi/1.0/default/wifi_chip.cpp
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -19,6 +19,7 @@
#include "hidl_return_util.h"
#include "hidl_struct_util.h"
#include "wifi_chip.h"
+#include "wifi_feature_flags.h"
#include "wifi_status_util.h"
namespace {
@@ -388,16 +389,21 @@
// The chip combination supported for current devices is fixed for now with
// 2 separate modes of operation:
// Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN iface operations
- // concurrently.
+ // concurrently [NAN conditional on wifiHidlFeatureAware]
// Mode 2 (AP mode): Will support 1 AP iface operations.
// TODO (b/32997844): Read this from some device specific flags in the
// makefile.
// STA mode iface combinations.
const IWifiChip::ChipIfaceCombinationLimit
sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1};
- const IWifiChip::ChipIfaceCombinationLimit
- sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN},
- 1};
+ IWifiChip::ChipIfaceCombinationLimit sta_chip_iface_combination_limit_2;
+ if (WifiFeatureFlags::wifiHidlFeatureAware) {
+ sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN},
+ 1};
+ } else {
+ sta_chip_iface_combination_limit_2 = {{IfaceType::P2P},
+ 1};
+ }
const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = {
{sta_chip_iface_combination_limit_1, sta_chip_iface_combination_limit_2}};
const IWifiChip::ChipMode sta_chip_mode = {kStaChipModeId,
@@ -552,18 +558,22 @@
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() {
// Only 1 of NAN or P2P iface can be active at a time.
- if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
- p2p_iface_.get()) {
+ if (WifiFeatureFlags::wifiHidlFeatureAware) {
+ if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
+ p2p_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
+ }
+ std::string ifname = legacy_hal_.lock()->getNanIfaceName();
+ nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ }
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
+ } else {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
- std::string ifname = legacy_hal_.lock()->getNanIfaceName();
- nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
- }
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
}
std::pair<WifiStatus, std::vector<hidl_string>>
diff --git a/wifi/1.0/default/wifi_feature_flags.h b/wifi/1.0/default/wifi_feature_flags.h
new file mode 100644
index 0000000..3502fbd
--- /dev/null
+++ b/wifi/1.0/default/wifi_feature_flags.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef WIFI_FEATURE_FLAGS_H_
+#define WIFI_FEATURE_FLAGS_H_
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+class WifiFeatureFlags {
+ public:
+#ifdef WIFI_HIDL_FEATURE_AWARE
+ static const bool wifiHidlFeatureAware = true;
+#else
+ static const bool wifiHidlFeatureAware = false;
+#endif // WIFI_HIDL_FEATURE_AWARE
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // WIFI_FEATURE_FLAGS_H_
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
index 7390b65..5fc0228 100644
--- a/wifi/1.0/default/wifi_legacy_hal.cpp
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -59,6 +59,8 @@
const auto lock = hidl_sync_util::acquireGlobalLock();
if (on_stop_complete_internal_callback) {
on_stop_complete_internal_callback(handle);
+ // Invalidate this callback since we don't want this firing again.
+ on_stop_complete_internal_callback = nullptr;
}
}
@@ -599,33 +601,37 @@
LinkLayerStats link_stats{};
LinkLayerStats* link_stats_ptr = &link_stats;
- on_link_layer_stats_result_internal_callback = [&link_stats_ptr](
- wifi_request_id /* id */,
- wifi_iface_stat* iface_stats_ptr,
- int num_radios,
- wifi_radio_stat* radio_stats_ptr) {
- if (iface_stats_ptr != nullptr) {
- link_stats_ptr->iface = *iface_stats_ptr;
- link_stats_ptr->iface.num_peers = 0;
- } else {
- LOG(ERROR) << "Invalid iface stats in link layer stats";
- }
- if (num_radios == 1 && radio_stats_ptr != nullptr) {
- link_stats_ptr->radio = *radio_stats_ptr;
- // Copy over the tx level array to the separate vector.
- if (radio_stats_ptr->num_tx_levels > 0 &&
- radio_stats_ptr->tx_time_per_levels != nullptr) {
- link_stats_ptr->radio_tx_time_per_levels.assign(
- radio_stats_ptr->tx_time_per_levels,
- radio_stats_ptr->tx_time_per_levels +
- radio_stats_ptr->num_tx_levels);
- }
- link_stats_ptr->radio.num_tx_levels = 0;
- link_stats_ptr->radio.tx_time_per_levels = nullptr;
- } else {
- LOG(ERROR) << "Invalid radio stats in link layer stats";
- }
- };
+ on_link_layer_stats_result_internal_callback =
+ [&link_stats_ptr](wifi_request_id /* id */,
+ wifi_iface_stat* iface_stats_ptr,
+ int num_radios,
+ wifi_radio_stat* radio_stats_ptr) {
+ if (iface_stats_ptr != nullptr) {
+ link_stats_ptr->iface = *iface_stats_ptr;
+ link_stats_ptr->iface.num_peers = 0;
+ } else {
+ LOG(ERROR) << "Invalid iface stats in link layer stats";
+ }
+ if (num_radios <= 0 || radio_stats_ptr == nullptr) {
+ LOG(ERROR) << "Invalid radio stats in link layer stats";
+ return;
+ }
+ for (int i = 0; i < num_radios; i++) {
+ LinkLayerRadioStats radio;
+ radio.stats = radio_stats_ptr[i];
+ // Copy over the tx level array to the separate vector.
+ if (radio_stats_ptr[i].num_tx_levels > 0 &&
+ radio_stats_ptr[i].tx_time_per_levels != nullptr) {
+ radio.tx_time_per_levels.assign(
+ radio_stats_ptr[i].tx_time_per_levels,
+ radio_stats_ptr[i].tx_time_per_levels +
+ radio_stats_ptr[i].num_tx_levels);
+ }
+ radio.stats.num_tx_levels = 0;
+ radio.stats.tx_time_per_levels = nullptr;
+ link_stats_ptr->radios.push_back(radio);
+ }
+ };
wifi_error status = global_func_table_.wifi_get_link_stats(
0, wlan_interface_handle_, {onSyncLinkLayerStatsResult});
@@ -1261,7 +1267,6 @@
void WifiLegacyHal::invalidate() {
global_handle_ = nullptr;
wlan_interface_handle_ = nullptr;
- on_stop_complete_internal_callback = nullptr;
on_driver_memory_dump_internal_callback = nullptr;
on_firmware_memory_dump_internal_callback = nullptr;
on_gscan_event_internal_callback = nullptr;
diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h
index c8fd5bd..576dfe6 100644
--- a/wifi/1.0/default/wifi_legacy_hal.h
+++ b/wifi/1.0/default/wifi_legacy_hal.h
@@ -49,10 +49,14 @@
// The |wifi_radio_stat.tx_time_per_levels| stats is provided as a pointer in
// |wifi_radio_stat| structure in the legacy HAL API. Separate that out
// into a separate return element to avoid passing pointers around.
+struct LinkLayerRadioStats {
+ wifi_radio_stat stats;
+ std::vector<uint32_t> tx_time_per_levels;
+};
+
struct LinkLayerStats {
wifi_iface_stat iface;
- wifi_radio_stat radio;
- std::vector<uint32_t> radio_tx_time_per_levels;
+ std::vector<LinkLayerRadioStats> radios;
};
#pragma GCC diagnostic pop
@@ -285,7 +289,7 @@
// Opaque handle to be used for all wlan0 interface specific operations.
wifi_interface_handle wlan_interface_handle_;
// Flag to indicate if we have initiated the cleanup of legacy HAL.
- bool awaiting_event_loop_termination_;
+ std::atomic<bool> awaiting_event_loop_termination_;
// Flag to indicate if the legacy HAL has been started.
bool is_started_;
wifi_system::InterfaceTool iface_tool_;
diff --git a/wifi/1.0/types.hal b/wifi/1.0/types.hal
index 83e6660..d3845c9 100644
--- a/wifi/1.0/types.hal
+++ b/wifi/1.0/types.hal
@@ -143,7 +143,7 @@
/**
* TimeStamp in milliseconds (ms).
*/
-typedef uint32_t TimeStampInMs;
+typedef uint64_t TimeStampInMs;
/**
* TimeStamp in microseconds (us).
@@ -320,6 +320,11 @@
*/
struct StaBackgroundScanBucketParameters {
/**
+ * Bucket index. This index is used to report results in
+ * |StaScanData.bucketsScanned|.
+ */
+ uint32_t bucketIdx;
+ /**
* Bands to scan or |BAND_UNSPECIFIED| if frequencies list must be used
* instead.
*/
@@ -473,7 +478,7 @@
*/
struct StaLinkLayerStats {
StaLinkLayerIfaceStats iface;
- StaLinkLayerRadioStats radio;
+ vec<StaLinkLayerRadioStats> radios;
/**
* TimeStamp for each stats sample.
* This is the absolute milliseconds from boot when these stats were
diff --git a/wifi/1.0/vts/functional/Android.bp b/wifi/1.0/vts/functional/Android.bp
index de917c0..9403e98 100644
--- a/wifi/1.0/vts/functional/Android.bp
+++ b/wifi/1.0/vts/functional/Android.bp
@@ -14,16 +14,32 @@
// limitations under the License.
//
-cc_test {
- name: "VtsHalWifiV1_0TargetTest",
+cc_library_static {
+ name: "VtsHalWifiV1_0TargetTestUtil",
srcs: [
"VtsHalWifiV1_0TargetTest.cpp",
- "wifi_ap_iface_hidl_test.cpp",
- "wifi_chip_hidl_test.cpp",
"wifi_hidl_call_util_selftest.cpp",
"wifi_hidl_test.cpp",
- "wifi_hidl_test_utils.cpp",
- "wifi_nan_iface_hidl_test.cpp",
+ "wifi_hidl_test_utils.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.wifi@1.0",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+}
+
+cc_test {
+ name: "VtsHalWifiV1_0TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: [
+ "wifi_ap_iface_hidl_test.cpp",
+ "wifi_chip_hidl_test.cpp",
"wifi_p2p_iface_hidl_test.cpp",
"wifi_rtt_controller_hidl_test.cpp",
"wifi_sta_iface_hidl_test.cpp"],
@@ -37,7 +53,28 @@
"libutils",
"android.hardware.wifi@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalWifiV1_0TargetTestUtil", "VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
+
+cc_test {
+ name: "VtsHalWifiNanV1_0TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["wifi_nan_iface_hidl_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidlbase",
+ "libhidltransport",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.wifi@1.0",
+ ],
+ static_libs: ["VtsHalWifiV1_0TargetTestUtil", "VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
index 51512a1..b56ed2b 100644
--- a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
+++ b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
@@ -16,7 +16,7 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "wifi_hidl_test_utils.h"
diff --git a/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
index dd3df56..42d9a96 100644
--- a/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_ap_iface_hidl_test.cpp
@@ -18,7 +18,7 @@
#include <android/hardware/wifi/1.0/IWifiApIface.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "wifi_hidl_test_utils.h"
@@ -28,7 +28,7 @@
/**
* Fixture to use for all AP Iface HIDL interface tests.
*/
-class WifiApIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class WifiApIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {}
diff --git a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
index 3c2ba9a..084067c 100644
--- a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
@@ -18,23 +18,125 @@
#include <android/hardware/wifi/1.0/IWifiChip.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
+#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
-using ::android::hardware::wifi::V1_0::IWifiChip;
using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::wifi::V1_0::IfaceType;
+using ::android::hardware::wifi::V1_0::ChipId;
+using ::android::hardware::wifi::V1_0::ChipModeId;
+using ::android::hardware::wifi::V1_0::WifiDebugRingBufferStatus;
+using ::android::hardware::wifi::V1_0::WifiDebugRingBufferVerboseLevel;
+using ::android::hardware::wifi::V1_0::WifiDebugHostWakeReasonStats;
+using ::android::hardware::wifi::V1_0::WifiStatus;
+using ::android::hardware::wifi::V1_0::WifiStatusCode;
+using ::android::hardware::wifi::V1_0::IWifiChip;
+using ::android::hardware::wifi::V1_0::IWifiApIface;
+using ::android::hardware::wifi::V1_0::IWifiIface;
+using ::android::hardware::wifi::V1_0::IWifiNanIface;
+using ::android::hardware::wifi::V1_0::IWifiP2pIface;
+using ::android::hardware::wifi::V1_0::IWifiRttController;
+using ::android::hardware::wifi::V1_0::IWifiStaIface;
+
+namespace {
+constexpr WifiDebugRingBufferVerboseLevel kDebugRingBufferVerboseLvl =
+ WifiDebugRingBufferVerboseLevel::VERBOSE;
+constexpr uint32_t kDebugRingBufferMaxInterval = 5;
+constexpr uint32_t kDebugRingBufferMaxDataSize = 1024;
+
+/**
+ * Check if any of the ring buffer capabilities are set.
+ */
+bool hasAnyRingBufferCapabilities(uint32_t caps) {
+ return (caps &
+ (IWifiChip::ChipCapabilityMask::DEBUG_RING_BUFFER_CONNECT_EVENT |
+ IWifiChip::ChipCapabilityMask::DEBUG_RING_BUFFER_POWER_EVENT |
+ IWifiChip::ChipCapabilityMask::DEBUG_RING_BUFFER_WAKELOCK_EVENT |
+ IWifiChip::ChipCapabilityMask::DEBUG_RING_BUFFER_VENDOR_DATA));
+}
+} // namespace
/**
* Fixture to use for all Wifi chip HIDL interface tests.
*/
-class WifiChipHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class WifiChipHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
- virtual void SetUp() override {}
+ virtual void SetUp() override {
+ wifi_chip_ = getWifiChip();
+ ASSERT_NE(nullptr, wifi_chip_.get());
+ }
virtual void TearDown() override { stopWifi(); }
protected:
+ // Helper function to configure the Chip in one of the supported modes.
+ // Most of the non-mode-configuration-related methods require chip
+ // to be first configured.
+ ChipModeId configureChipForIfaceType(IfaceType type) {
+ ChipModeId mode_id;
+ EXPECT_TRUE(
+ configureChipToSupportIfaceType(wifi_chip_, type, &mode_id));
+ return mode_id;
+ }
+
+ uint32_t configureChipForStaIfaceAndGetCapabilities() {
+ configureChipForIfaceType(IfaceType::STA);
+ const auto& status_and_caps = HIDL_INVOKE(wifi_chip_, getCapabilities);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+ return status_and_caps.second;
+ }
+
+ std::string getIfaceName(const sp<IWifiIface>& iface) {
+ const auto& status_and_name = HIDL_INVOKE(iface, getName);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_name.first.code);
+ return status_and_name.second;
+ }
+
+ WifiStatusCode createApIface(sp<IWifiApIface>* ap_iface) {
+ const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createApIface);
+ *ap_iface = status_and_iface.second;
+ return status_and_iface.first.code;
+ }
+
+ WifiStatusCode removeApIface(const std::string& name) {
+ return HIDL_INVOKE(wifi_chip_, removeApIface, name).code;
+ }
+
+ WifiStatusCode createNanIface(sp<IWifiNanIface>* nan_iface) {
+ const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createNanIface);
+ *nan_iface = status_and_iface.second;
+ return status_and_iface.first.code;
+ }
+
+ WifiStatusCode removeNanIface(const std::string& name) {
+ return HIDL_INVOKE(wifi_chip_, removeNanIface, name).code;
+ }
+
+ WifiStatusCode createP2pIface(sp<IWifiP2pIface>* p2p_iface) {
+ const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createP2pIface);
+ *p2p_iface = status_and_iface.second;
+ return status_and_iface.first.code;
+ }
+
+ WifiStatusCode removeP2pIface(const std::string& name) {
+ return HIDL_INVOKE(wifi_chip_, removeP2pIface, name).code;
+ }
+
+ WifiStatusCode createStaIface(sp<IWifiStaIface>* sta_iface) {
+ const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createStaIface);
+ *sta_iface = status_and_iface.second;
+ return status_and_iface.first.code;
+ }
+
+ WifiStatusCode removeStaIface(const std::string& name) {
+ return HIDL_INVOKE(wifi_chip_, removeStaIface, name).code;
+ }
+
+ sp<IWifiChip> wifi_chip_;
};
/*
@@ -46,3 +148,581 @@
EXPECT_NE(nullptr, getWifiChip().get());
stopWifi();
}
+
+/*
+ * GetId:
+ */
+TEST_F(WifiChipHidlTest, GetId) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_chip_, getId).first.code);
+}
+
+/*
+ * GetAvailableMode:
+ */
+TEST_F(WifiChipHidlTest, GetAvailableModes) {
+ const auto& status_and_modes = HIDL_INVOKE(wifi_chip_, getAvailableModes);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_modes.first.code);
+ EXPECT_LT(0u, status_and_modes.second.size());
+}
+
+/*
+ * ConfigureChip:
+ */
+TEST_F(WifiChipHidlTest, ConfigureChip) {
+ const auto& status_and_modes = HIDL_INVOKE(wifi_chip_, getAvailableModes);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_modes.first.code);
+ EXPECT_LT(0u, status_and_modes.second.size());
+ for (const auto& mode : status_and_modes.second) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ HIDL_INVOKE(wifi_chip_, configureChip, mode.id).code);
+ }
+}
+
+/*
+ * GetCapabilities:
+ */
+TEST_F(WifiChipHidlTest, GetCapabilities) {
+ configureChipForIfaceType(IfaceType::STA);
+ const auto& status_and_caps = HIDL_INVOKE(wifi_chip_, getCapabilities);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+ EXPECT_NE(0u, status_and_caps.second);
+}
+
+/*
+ * GetMode:
+ */
+TEST_F(WifiChipHidlTest, GetMode) {
+ ChipModeId chip_mode_id = configureChipForIfaceType(IfaceType::STA);
+ const auto& status_and_mode = HIDL_INVOKE(wifi_chip_, getMode);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_mode.first.code);
+ EXPECT_EQ(chip_mode_id, status_and_mode.second);
+}
+
+/*
+ * RequestChipDebugInfo:
+ */
+TEST_F(WifiChipHidlTest, RequestChipDebugInfo) {
+ configureChipForIfaceType(IfaceType::STA);
+ const auto& status_and_chip_info =
+ HIDL_INVOKE(wifi_chip_, requestChipDebugInfo);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_chip_info.first.code);
+ EXPECT_LT(0u, status_and_chip_info.second.driverDescription.size());
+ EXPECT_LT(0u, status_and_chip_info.second.firmwareDescription.size());
+}
+
+/*
+ * RequestFirmwareDebugDump
+ */
+TEST_F(WifiChipHidlTest, RequestFirmwareDebugDump) {
+ uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+ const auto& status_and_firmware_dump =
+ HIDL_INVOKE(wifi_chip_, requestFirmwareDebugDump);
+ if (caps & IWifiChip::ChipCapabilityMask::DEBUG_MEMORY_FIRMWARE_DUMP) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_firmware_dump.first.code);
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
+ status_and_firmware_dump.first.code);
+ }
+}
+
+/*
+ * RequestDriverDebugDump
+ */
+TEST_F(WifiChipHidlTest, RequestDriverDebugDump) {
+ uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+ const auto& status_and_driver_dump =
+ HIDL_INVOKE(wifi_chip_, requestDriverDebugDump);
+ if (caps & IWifiChip::ChipCapabilityMask::DEBUG_MEMORY_DRIVER_DUMP) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_driver_dump.first.code);
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
+ status_and_driver_dump.first.code);
+ }
+}
+
+/*
+ * GetDebugRingBuffersStatus
+ */
+TEST_F(WifiChipHidlTest, GetDebugRingBuffersStatus) {
+ uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+ const auto& status_and_ring_buffer_status =
+ HIDL_INVOKE(wifi_chip_, getDebugRingBuffersStatus);
+ if (hasAnyRingBufferCapabilities(caps)) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ status_and_ring_buffer_status.first.code);
+ for (const auto& ring_buffer : status_and_ring_buffer_status.second) {
+ EXPECT_LT(0u, ring_buffer.ringName.size());
+ }
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
+ status_and_ring_buffer_status.first.code);
+ }
+}
+
+/*
+ * StartLoggingToDebugRingBuffer
+ */
+TEST_F(WifiChipHidlTest, StartLoggingToDebugRingBuffer) {
+ uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+ std::string ring_name;
+ const auto& status_and_ring_buffer_status =
+ HIDL_INVOKE(wifi_chip_, getDebugRingBuffersStatus);
+ if (hasAnyRingBufferCapabilities(caps)) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ status_and_ring_buffer_status.first.code);
+ ASSERT_LT(0u, status_and_ring_buffer_status.second.size());
+ ring_name = status_and_ring_buffer_status.second[0].ringName.c_str();
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
+ status_and_ring_buffer_status.first.code);
+ }
+ const auto& status =
+ HIDL_INVOKE(wifi_chip_, startLoggingToDebugRingBuffer, ring_name,
+ kDebugRingBufferVerboseLvl, kDebugRingBufferMaxInterval,
+ kDebugRingBufferMaxDataSize);
+ if (hasAnyRingBufferCapabilities(caps)) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, status.code);
+ }
+}
+
+/*
+ * ForceDumpToDebugRingBuffer
+ */
+TEST_F(WifiChipHidlTest, ForceDumpToDebugRingBuffer) {
+ uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+ std::string ring_name;
+ const auto& status_and_ring_buffer_status =
+ HIDL_INVOKE(wifi_chip_, getDebugRingBuffersStatus);
+ if (hasAnyRingBufferCapabilities(caps)) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ status_and_ring_buffer_status.first.code);
+ ASSERT_LT(0u, status_and_ring_buffer_status.second.size());
+ ring_name = status_and_ring_buffer_status.second[0].ringName.c_str();
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
+ status_and_ring_buffer_status.first.code);
+ }
+ const auto& status =
+ HIDL_INVOKE(wifi_chip_, forceDumpToDebugRingBuffer, ring_name);
+ if (hasAnyRingBufferCapabilities(caps)) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, status.code);
+ }
+}
+
+/*
+ * GetDebugHostWakeReasonStats
+ */
+TEST_F(WifiChipHidlTest, GetDebugHostWakeReasonStats) {
+ uint32_t caps = configureChipForStaIfaceAndGetCapabilities();
+ const auto& status_and_debug_wake_reason =
+ HIDL_INVOKE(wifi_chip_, getDebugHostWakeReasonStats);
+ if (caps & IWifiChip::ChipCapabilityMask::DEBUG_HOST_WAKE_REASON_STATS) {
+ EXPECT_EQ(WifiStatusCode::SUCCESS,
+ status_and_debug_wake_reason.first.code);
+ } else {
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED,
+ status_and_debug_wake_reason.first.code);
+ }
+}
+
+/*
+ * CreateApIface
+ * Configures the chip in AP mode and ensures that only 1 iface creation
+ * succeeds. The 2nd iface creation should be rejected.
+ */
+TEST_F(WifiChipHidlTest, CreateApIface) {
+ configureChipForIfaceType(IfaceType::AP);
+
+ sp<IWifiApIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createApIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createApIface(&iface));
+}
+
+/*
+ * GetApIfaceNames
+ * Configures the chip in AP mode and ensures that the iface list is empty
+ * before creating the iface. Then, create the iface and ensure that
+ * iface name is returned via the list.
+ */
+TEST_F(WifiChipHidlTest, GetApIfaceNames) {
+ configureChipForIfaceType(IfaceType::AP);
+
+ const auto& status_and_iface_names1 =
+ HIDL_INVOKE(wifi_chip_, getApIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names1.first.code);
+ EXPECT_EQ(0u, status_and_iface_names1.second.size());
+
+ sp<IWifiApIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createApIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ std::string iface_name = getIfaceName(iface);
+ const auto& status_and_iface_names2 =
+ HIDL_INVOKE(wifi_chip_, getApIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names2.first.code);
+ EXPECT_EQ(1u, status_and_iface_names2.second.size());
+ EXPECT_EQ(iface_name, status_and_iface_names2.second[0]);
+
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeApIface(iface_name));
+ const auto& status_and_iface_names3 =
+ HIDL_INVOKE(wifi_chip_, getApIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names3.first.code);
+ EXPECT_EQ(0u, status_and_iface_names3.second.size());
+}
+
+/*
+ * GetApIface
+ * Configures the chip in AP mode and create an iface. Then, retrieve
+ * the iface object using the correct name and ensure any other name
+ * doesn't retrieve an iface object.
+ */
+TEST_F(WifiChipHidlTest, GetApIface) {
+ configureChipForIfaceType(IfaceType::AP);
+
+ sp<IWifiApIface> ap_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createApIface(&ap_iface));
+ EXPECT_NE(nullptr, ap_iface.get());
+
+ std::string iface_name = getIfaceName(ap_iface);
+ const auto& status_and_iface1 =
+ HIDL_INVOKE(wifi_chip_, getApIface, iface_name);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface1.first.code);
+ EXPECT_NE(nullptr, status_and_iface1.second.get());
+
+ std::string invalid_name = iface_name + "0";
+ const auto& status_and_iface2 =
+ HIDL_INVOKE(wifi_chip_, getApIface, invalid_name);
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, status_and_iface2.first.code);
+ EXPECT_EQ(nullptr, status_and_iface2.second.get());
+}
+
+/*
+ * RemoveApIface
+ * Configures the chip in AP mode and create an iface. Then, remove
+ * the iface object using the correct name and ensure any other name
+ * doesn't remove the iface.
+ */
+TEST_F(WifiChipHidlTest, RemoveApIface) {
+ configureChipForIfaceType(IfaceType::AP);
+
+ sp<IWifiApIface> ap_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createApIface(&ap_iface));
+ EXPECT_NE(nullptr, ap_iface.get());
+
+ std::string iface_name = getIfaceName(ap_iface);
+ std::string invalid_name = iface_name + "0";
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeApIface(invalid_name));
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeApIface(iface_name));
+
+ // No such iface exists now. So, this should return failure.
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeApIface(iface_name));
+}
+
+/*
+ * CreateNanIface
+ * Configures the chip in NAN mode and ensures that only 1 iface creation
+ * succeeds. The 2nd iface creation should be rejected.
+ */
+TEST_F(WifiChipHidlTest, CreateNanIface) {
+ configureChipForIfaceType(IfaceType::NAN);
+
+ sp<IWifiNanIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createNanIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createNanIface(&iface));
+}
+
+/*
+ * GetNanIfaceNames
+ * Configures the chip in NAN mode and ensures that the iface list is empty
+ * before creating the iface. Then, create the iface and ensure that
+ * iface name is returned via the list.
+ */
+TEST_F(WifiChipHidlTest, GetNanIfaceNames) {
+ configureChipForIfaceType(IfaceType::NAN);
+
+ const auto& status_and_iface_names1 =
+ HIDL_INVOKE(wifi_chip_, getNanIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names1.first.code);
+ EXPECT_EQ(0u, status_and_iface_names1.second.size());
+
+ sp<IWifiNanIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createNanIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ std::string iface_name = getIfaceName(iface);
+ const auto& status_and_iface_names2 =
+ HIDL_INVOKE(wifi_chip_, getNanIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names2.first.code);
+ EXPECT_EQ(1u, status_and_iface_names2.second.size());
+ EXPECT_EQ(iface_name, status_and_iface_names2.second[0]);
+
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeNanIface(iface_name));
+ const auto& status_and_iface_names3 =
+ HIDL_INVOKE(wifi_chip_, getNanIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names3.first.code);
+ EXPECT_EQ(0u, status_and_iface_names3.second.size());
+}
+
+/*
+ * GetNanIface
+ * Configures the chip in NAN mode and create an iface. Then, retrieve
+ * the iface object using the correct name and ensure any other name
+ * doesn't retrieve an iface object.
+ */
+TEST_F(WifiChipHidlTest, GetNanIface) {
+ configureChipForIfaceType(IfaceType::NAN);
+
+ sp<IWifiNanIface> nan_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createNanIface(&nan_iface));
+ EXPECT_NE(nullptr, nan_iface.get());
+
+ std::string iface_name = getIfaceName(nan_iface);
+ const auto& status_and_iface1 =
+ HIDL_INVOKE(wifi_chip_, getNanIface, iface_name);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface1.first.code);
+ EXPECT_NE(nullptr, status_and_iface1.second.get());
+
+ std::string invalid_name = iface_name + "0";
+ const auto& status_and_iface2 =
+ HIDL_INVOKE(wifi_chip_, getNanIface, invalid_name);
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, status_and_iface2.first.code);
+ EXPECT_EQ(nullptr, status_and_iface2.second.get());
+}
+
+/*
+ * RemoveNanIface
+ * Configures the chip in NAN mode and create an iface. Then, remove
+ * the iface object using the correct name and ensure any other name
+ * doesn't remove the iface.
+ */
+TEST_F(WifiChipHidlTest, RemoveNanIface) {
+ configureChipForIfaceType(IfaceType::NAN);
+
+ sp<IWifiNanIface> nan_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createNanIface(&nan_iface));
+ EXPECT_NE(nullptr, nan_iface.get());
+
+ std::string iface_name = getIfaceName(nan_iface);
+ std::string invalid_name = iface_name + "0";
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeNanIface(invalid_name));
+
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeNanIface(iface_name));
+
+ // No such iface exists now. So, this should return failure.
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeNanIface(iface_name));
+}
+
+/*
+ * CreateP2pIface
+ * Configures the chip in P2P mode and ensures that only 1 iface creation
+ * succeeds. The 2nd iface creation should be rejected.
+ */
+TEST_F(WifiChipHidlTest, CreateP2pIface) {
+ configureChipForIfaceType(IfaceType::P2P);
+
+ sp<IWifiP2pIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createP2pIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createP2pIface(&iface));
+}
+
+/*
+ * GetP2pIfaceNames
+ * Configures the chip in P2P mode and ensures that the iface list is empty
+ * before creating the iface. Then, create the iface and ensure that
+ * iface name is returned via the list.
+ */
+TEST_F(WifiChipHidlTest, GetP2pIfaceNames) {
+ configureChipForIfaceType(IfaceType::P2P);
+
+ const auto& status_and_iface_names1 =
+ HIDL_INVOKE(wifi_chip_, getP2pIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names1.first.code);
+ EXPECT_EQ(0u, status_and_iface_names1.second.size());
+
+ sp<IWifiP2pIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createP2pIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ std::string iface_name = getIfaceName(iface);
+ const auto& status_and_iface_names2 =
+ HIDL_INVOKE(wifi_chip_, getP2pIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names2.first.code);
+ EXPECT_EQ(1u, status_and_iface_names2.second.size());
+ EXPECT_EQ(iface_name, status_and_iface_names2.second[0]);
+
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeP2pIface(iface_name));
+ const auto& status_and_iface_names3 =
+ HIDL_INVOKE(wifi_chip_, getP2pIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names3.first.code);
+ EXPECT_EQ(0u, status_and_iface_names3.second.size());
+}
+
+/*
+ * GetP2pIface
+ * Configures the chip in P2P mode and create an iface. Then, retrieve
+ * the iface object using the correct name and ensure any other name
+ * doesn't retrieve an iface object.
+ */
+TEST_F(WifiChipHidlTest, GetP2pIface) {
+ configureChipForIfaceType(IfaceType::P2P);
+
+ sp<IWifiP2pIface> p2p_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createP2pIface(&p2p_iface));
+ EXPECT_NE(nullptr, p2p_iface.get());
+
+ std::string iface_name = getIfaceName(p2p_iface);
+ const auto& status_and_iface1 =
+ HIDL_INVOKE(wifi_chip_, getP2pIface, iface_name);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface1.first.code);
+ EXPECT_NE(nullptr, status_and_iface1.second.get());
+
+ std::string invalid_name = iface_name + "0";
+ const auto& status_and_iface2 =
+ HIDL_INVOKE(wifi_chip_, getP2pIface, invalid_name);
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, status_and_iface2.first.code);
+ EXPECT_EQ(nullptr, status_and_iface2.second.get());
+}
+
+/*
+ * RemoveP2pIface
+ * Configures the chip in P2P mode and create an iface. Then, remove
+ * the iface object using the correct name and ensure any other name
+ * doesn't remove the iface.
+ */
+TEST_F(WifiChipHidlTest, RemoveP2pIface) {
+ configureChipForIfaceType(IfaceType::P2P);
+
+ sp<IWifiP2pIface> p2p_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createP2pIface(&p2p_iface));
+ EXPECT_NE(nullptr, p2p_iface.get());
+
+ std::string iface_name = getIfaceName(p2p_iface);
+ std::string invalid_name = iface_name + "0";
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeP2pIface(invalid_name));
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeP2pIface(iface_name));
+
+ // No such iface exists now. So, this should return failure.
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeP2pIface(iface_name));
+}
+
+/*
+ * CreateStaIface
+ * Configures the chip in STA mode and ensures that only 1 iface creation
+ * succeeds. The 2nd iface creation should be rejected.
+ */
+TEST_F(WifiChipHidlTest, CreateStaIface) {
+ configureChipForIfaceType(IfaceType::STA);
+
+ sp<IWifiStaIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createStaIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createStaIface(&iface));
+}
+
+/*
+ * GetStaIfaceNames
+ * Configures the chip in STA mode and ensures that the iface list is empty
+ * before creating the iface. Then, create the iface and ensure that
+ * iface name is returned via the list.
+ */
+TEST_F(WifiChipHidlTest, GetStaIfaceNames) {
+ configureChipForIfaceType(IfaceType::STA);
+
+ const auto& status_and_iface_names1 =
+ HIDL_INVOKE(wifi_chip_, getStaIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names1.first.code);
+ EXPECT_EQ(0u, status_and_iface_names1.second.size());
+
+ sp<IWifiStaIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createStaIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ std::string iface_name = getIfaceName(iface);
+ const auto& status_and_iface_names2 =
+ HIDL_INVOKE(wifi_chip_, getStaIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names2.first.code);
+ EXPECT_EQ(1u, status_and_iface_names2.second.size());
+ EXPECT_EQ(iface_name, status_and_iface_names2.second[0]);
+
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeStaIface(iface_name));
+ const auto& status_and_iface_names3 =
+ HIDL_INVOKE(wifi_chip_, getStaIfaceNames);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface_names3.first.code);
+ EXPECT_EQ(0u, status_and_iface_names3.second.size());
+}
+
+/*
+ * GetStaIface
+ * Configures the chip in STA mode and create an iface. Then, retrieve
+ * the iface object using the correct name and ensure any other name
+ * doesn't retrieve an iface object.
+ */
+TEST_F(WifiChipHidlTest, GetStaIface) {
+ configureChipForIfaceType(IfaceType::STA);
+
+ sp<IWifiStaIface> sta_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createStaIface(&sta_iface));
+ EXPECT_NE(nullptr, sta_iface.get());
+
+ std::string iface_name = getIfaceName(sta_iface);
+ const auto& status_and_iface1 =
+ HIDL_INVOKE(wifi_chip_, getStaIface, iface_name);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface1.first.code);
+ EXPECT_NE(nullptr, status_and_iface1.second.get());
+
+ std::string invalid_name = iface_name + "0";
+ const auto& status_and_iface2 =
+ HIDL_INVOKE(wifi_chip_, getStaIface, invalid_name);
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, status_and_iface2.first.code);
+ EXPECT_EQ(nullptr, status_and_iface2.second.get());
+}
+
+/*
+ * RemoveStaIface
+ * Configures the chip in STA mode and create an iface. Then, remove
+ * the iface object using the correct name and ensure any other name
+ * doesn't remove the iface.
+ */
+TEST_F(WifiChipHidlTest, RemoveStaIface) {
+ configureChipForIfaceType(IfaceType::STA);
+
+ sp<IWifiStaIface> sta_iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createStaIface(&sta_iface));
+ EXPECT_NE(nullptr, sta_iface.get());
+
+ std::string iface_name = getIfaceName(sta_iface);
+ std::string invalid_name = iface_name + "0";
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeStaIface(invalid_name));
+ EXPECT_EQ(WifiStatusCode::SUCCESS, removeStaIface(iface_name));
+
+ // No such iface exists now. So, this should return failure.
+ EXPECT_EQ(WifiStatusCode::ERROR_INVALID_ARGS, removeStaIface(iface_name));
+}
+
+/*
+ * CreateRttController
+ */
+TEST_F(WifiChipHidlTest, CreateRttController) {
+ configureChipForIfaceType(IfaceType::AP);
+
+ sp<IWifiApIface> iface;
+ EXPECT_EQ(WifiStatusCode::SUCCESS, createApIface(&iface));
+ EXPECT_NE(nullptr, iface.get());
+
+ const auto& status_and_rtt_controller =
+ HIDL_INVOKE(wifi_chip_, createRttController, iface);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_rtt_controller.first.code);
+ EXPECT_NE(nullptr, status_and_rtt_controller.second.get());
+}
diff --git a/wifi/1.0/vts/functional/wifi_hidl_call_util.h b/wifi/1.0/vts/functional/wifi_hidl_call_util.h
index 4797423..f3ca517 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_call_util.h
+++ b/wifi/1.0/vts/functional/wifi_hidl_call_util.h
@@ -21,7 +21,7 @@
#include <type_traits>
#include <utility>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
namespace {
namespace detail {
diff --git a/wifi/1.0/vts/functional/wifi_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_hidl_test.cpp
index 2f4e01e..b8e501c 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_hidl_test.cpp
@@ -18,7 +18,7 @@
#include <android/hardware/wifi/1.0/IWifi.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "wifi_hidl_test_utils.h"
@@ -28,7 +28,7 @@
/**
* Fixture to use for all root Wifi HIDL interface tests.
*/
-class WifiHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class WifiHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {}
diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
index e0c92fe..2d0b081 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
+++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
@@ -35,6 +35,53 @@
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
+namespace {
+bool findAnyModeSupportingIfaceType(
+ IfaceType desired_type, const std::vector<IWifiChip::ChipMode>& modes,
+ ChipModeId* mode_id) {
+ for (const auto& mode : modes) {
+ for (const auto& combination : mode.availableCombinations) {
+ for (const auto& iface_limit : combination.limits) {
+ const auto& iface_types = iface_limit.types;
+ if (std::find(iface_types.begin(), iface_types.end(),
+ desired_type) != iface_types.end()) {
+ *mode_id = mode.id;
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+bool configureChipToSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
+ IfaceType type,
+ ChipModeId* configured_mode_id) {
+ if (!configured_mode_id) {
+ return false;
+ }
+ const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes);
+ if (status_and_modes.first.code != WifiStatusCode::SUCCESS) {
+ return false;
+ }
+ if (!findAnyModeSupportingIfaceType(type, status_and_modes.second,
+ configured_mode_id)) {
+ return false;
+ }
+ if (HIDL_INVOKE(wifi_chip, configureChip, *configured_mode_id).code !=
+ WifiStatusCode::SUCCESS) {
+ return false;
+ }
+ return true;
+}
+
+bool configureChipToSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
+ IfaceType type) {
+ ChipModeId mode_id;
+ return configureChipToSupportIfaceTypeInternal(wifi_chip, type, &mode_id);
+}
+} // namespace
+
void stopFramework() {
ASSERT_EQ(std::system("stop"), 0);
stopWifi();
@@ -44,7 +91,7 @@
void startFramework() { ASSERT_EQ(std::system("start"), 0); }
sp<IWifi> getWifi() {
- sp<IWifi> wifi = ::testing::VtsHalHidlTargetBaseTest::getService<IWifi>();
+ sp<IWifi> wifi = ::testing::VtsHalHidlTargetTestBase::getService<IWifi>();
return wifi;
}
@@ -53,79 +100,30 @@
if (!wifi.get()) {
return nullptr;
}
-
if (HIDL_INVOKE(wifi, start).code != WifiStatusCode::SUCCESS) {
return nullptr;
}
-
const auto& status_and_chip_ids = HIDL_INVOKE(wifi, getChipIds);
const auto& chip_ids = status_and_chip_ids.second;
if (status_and_chip_ids.first.code != WifiStatusCode::SUCCESS ||
chip_ids.size() != 1) {
return nullptr;
}
-
const auto& status_and_chip = HIDL_INVOKE(wifi, getChip, chip_ids[0]);
if (status_and_chip.first.code != WifiStatusCode::SUCCESS) {
return nullptr;
}
-
return status_and_chip.second;
}
-// Since we currently only support one iface of each type. Just iterate thru the
-// modes of operation and find the mode ID to use for that iface type.
-bool findModeToSupportIfaceType(IfaceType type,
- const std::vector<IWifiChip::ChipMode>& modes,
- ChipModeId* mode_id) {
- for (const auto& mode : modes) {
- std::vector<IWifiChip::ChipIfaceCombination> combinations =
- mode.availableCombinations;
- for (const auto& combination : combinations) {
- std::vector<IWifiChip::ChipIfaceCombinationLimit> iface_limits =
- combination.limits;
- for (const auto& iface_limit : iface_limits) {
- std::vector<IfaceType> iface_types = iface_limit.types;
- for (const auto& iface_type : iface_types) {
- if (iface_type == type) {
- *mode_id = mode.id;
- return true;
- }
- }
- }
- }
- }
- return false;
-}
-
-bool configureChipToSupportIfaceType(const sp<IWifiChip>& wifi_chip,
- IfaceType type) {
- const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes);
- if (status_and_modes.first.code != WifiStatusCode::SUCCESS) {
- return false;
- }
-
- ChipModeId mode_id;
- if (!findModeToSupportIfaceType(type, status_and_modes.second, &mode_id)) {
- return false;
- }
-
- if (HIDL_INVOKE(wifi_chip, configureChip, mode_id).code !=
- WifiStatusCode::SUCCESS) {
- return false;
- }
- return true;
-}
-
sp<IWifiApIface> getWifiApIface() {
sp<IWifiChip> wifi_chip = getWifiChip();
if (!wifi_chip.get()) {
return nullptr;
}
- if (!configureChipToSupportIfaceType(wifi_chip, IfaceType::AP)) {
+ if (!configureChipToSupportIfaceTypeInternal(wifi_chip, IfaceType::AP)) {
return nullptr;
}
-
const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createApIface);
if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
return nullptr;
@@ -138,10 +136,9 @@
if (!wifi_chip.get()) {
return nullptr;
}
- if (!configureChipToSupportIfaceType(wifi_chip, IfaceType::NAN)) {
+ if (!configureChipToSupportIfaceTypeInternal(wifi_chip, IfaceType::NAN)) {
return nullptr;
}
-
const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createNanIface);
if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
return nullptr;
@@ -154,10 +151,9 @@
if (!wifi_chip.get()) {
return nullptr;
}
- if (!configureChipToSupportIfaceType(wifi_chip, IfaceType::P2P)) {
+ if (!configureChipToSupportIfaceTypeInternal(wifi_chip, IfaceType::P2P)) {
return nullptr;
}
-
const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createP2pIface);
if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
return nullptr;
@@ -170,10 +166,9 @@
if (!wifi_chip.get()) {
return nullptr;
}
- if (!configureChipToSupportIfaceType(wifi_chip, IfaceType::STA)) {
+ if (!configureChipToSupportIfaceTypeInternal(wifi_chip, IfaceType::STA)) {
return nullptr;
}
-
const auto& status_and_iface = HIDL_INVOKE(wifi_chip, createStaIface);
if (status_and_iface.first.code != WifiStatusCode::SUCCESS) {
return nullptr;
@@ -190,7 +185,6 @@
if (!wifi_sta_iface.get()) {
return nullptr;
}
-
const auto& status_and_controller =
HIDL_INVOKE(wifi_chip, createRttController, wifi_sta_iface);
if (status_and_controller.first.code != WifiStatusCode::SUCCESS) {
@@ -199,6 +193,13 @@
return status_and_controller.second;
}
+bool configureChipToSupportIfaceType(const sp<IWifiChip>& wifi_chip,
+ IfaceType type,
+ ChipModeId* configured_mode_id) {
+ return configureChipToSupportIfaceTypeInternal(wifi_chip, type,
+ configured_mode_id);
+}
+
void stopWifi() {
sp<IWifi> wifi = getWifi();
ASSERT_NE(wifi, nullptr);
diff --git a/wifi/1.0/vts/functional/wifi_hidl_test_utils.h b/wifi/1.0/vts/functional/wifi_hidl_test_utils.h
index 08933d9..a723b2a 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.h
+++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.h
@@ -41,5 +41,11 @@
android::sp<android::hardware::wifi::V1_0::IWifiStaIface> getWifiStaIface();
android::sp<android::hardware::wifi::V1_0::IWifiRttController>
getWifiRttController();
+// Configure the chip in a mode to support the creation of the provided
+// iface type.
+bool configureChipToSupportIfaceType(
+ const android::sp<android::hardware::wifi::V1_0::IWifiChip>& wifi_chip,
+ android::hardware::wifi::V1_0::IfaceType type,
+ android::hardware::wifi::V1_0::ChipModeId* configured_mode_id);
// Used to trigger IWifi.stop() at the end of every test.
void stopWifi();
diff --git a/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp
index 95c0e5d..85bcccd 100644
--- a/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_nan_iface_hidl_test.cpp
@@ -19,7 +19,7 @@
#include <android/hardware/wifi/1.0/IWifiNanIface.h>
#include <android/hardware/wifi/1.0/IWifiNanIfaceEventCallback.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -38,7 +38,7 @@
/**
* Fixture to use for all NAN Iface HIDL interface tests.
*/
-class WifiNanIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class WifiNanIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
iwifiNanIface = getWifiNanIface();
diff --git a/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp
index d53096c..269eb6c 100644
--- a/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_p2p_iface_hidl_test.cpp
@@ -18,7 +18,7 @@
#include <android/hardware/wifi/1.0/IWifiP2pIface.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "wifi_hidl_test_utils.h"
@@ -28,7 +28,7 @@
/**
* Fixture to use for all P2P Iface HIDL interface tests.
*/
-class WifiP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class WifiP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {}
diff --git a/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp
index 4d08919..e13086d 100644
--- a/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_rtt_controller_hidl_test.cpp
@@ -18,7 +18,7 @@
#include <android/hardware/wifi/1.0/IWifiRttController.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "wifi_hidl_test_utils.h"
@@ -28,7 +28,7 @@
/**
* Fixture to use for all RTT controller HIDL interface tests.
*/
-class WifiRttControllerHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class WifiRttControllerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {}
diff --git a/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
index 4457487..95add61 100644
--- a/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_sta_iface_hidl_test.cpp
@@ -18,23 +18,30 @@
#include <android/hardware/wifi/1.0/IWifiStaIface.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
+#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
-using ::android::hardware::wifi::V1_0::IWifiStaIface;
using ::android::sp;
+using ::android::hardware::wifi::V1_0::IWifiStaIface;
+using ::android::hardware::wifi::V1_0::WifiStatus;
+using ::android::hardware::wifi::V1_0::WifiStatusCode;
/**
* Fixture to use for all STA Iface HIDL interface tests.
*/
-class WifiStaIfaceHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class WifiStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
- virtual void SetUp() override {}
+ virtual void SetUp() override {
+ wifi_sta_iface_ = getWifiStaIface();
+ ASSERT_NE(nullptr, wifi_sta_iface_.get());
+ }
virtual void TearDown() override { stopWifi(); }
protected:
+ sp<IWifiStaIface> wifi_sta_iface_;
};
/*
@@ -46,3 +53,12 @@
EXPECT_NE(nullptr, getWifiStaIface().get());
stopWifi();
}
+
+/*
+ * GetCapabilities:
+ */
+TEST_F(WifiStaIfaceHidlTest, GetCapabilities) {
+ const auto& status_and_caps = HIDL_INVOKE(wifi_sta_iface_, getCapabilities);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_caps.first.code);
+ EXPECT_NE(0u, status_and_caps.second);
+}
diff --git a/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.hal b/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.hal
index dd1d1c4..2223022 100644
--- a/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.hal
+++ b/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.hal
@@ -278,8 +278,10 @@
* reject.
* @param statusCode 802.11 code to indicate the reject reason.
* Refer to section 8.4.1.9 of IEEE 802.11 spec.
+ * @param timedOut Whether failure is due to timeout rather
+ * than explicit rejection response from the AP.
*/
- oneway onAssociationRejected(Bssid bssid, uint32_t statusCode);
+ oneway onAssociationRejected(Bssid bssid, uint32_t statusCode, bool timedOut);
/**
* Used to indicate the timeout of authentication to an AP.
diff --git a/wifi/supplicant/1.0/ISupplicantStaNetwork.hal b/wifi/supplicant/1.0/ISupplicantStaNetwork.hal
index 37e8d3f..7d5159a 100644
--- a/wifi/supplicant/1.0/ISupplicantStaNetwork.hal
+++ b/wifi/supplicant/1.0/ISupplicantStaNetwork.hal
@@ -277,6 +277,20 @@
setPskPassphrase(string psk) generates (SupplicantStatus status);
/**
+ * Set raw psk for WPA_PSK network.
+ *
+ * @param psk value to set as specified in IEEE 802.11i-2004 standard.
+ * This is the calculated using 'wpa_passphrase <ssid> [passphrase]'
+ * @return status Status of the operation.
+ * Possible status codes:
+ * |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
+ * |SupplicantStatusCode.SUCCESS|,
+ * |SupplicantStatusCode.FAILURE_UNKNOWN|,
+ * |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
+ */
+ setPsk(uint8_t[32] psk) generates (SupplicantStatus status);
+
+ /**
* Set WEP key for WEP network.
*
* @param keyIdx Index of wep key to set.
@@ -662,6 +676,8 @@
/**
* Get passphrase for WPA_PSK network.
+ * Must return a failure if network has no passphrase set (use |getPsk| if
+ * network was configured with raw psk instead).
*
* @return status Status of the operation.
* Possible status codes:
@@ -672,6 +688,19 @@
getPskPassphrase() generates (SupplicantStatus status, string psk);
/**
+ * Get raw psk for WPA_PSK network.
+ *
+ * @return status Status of the operation.
+ * Possible status codes:
+ * |SupplicantStatusCode.FAILURE_ARGS_INVALID|,
+ * |SupplicantStatusCode.SUCCESS|,
+ * |SupplicantStatusCode.FAILURE_UNKNOWN|,
+ * |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
+ * @param psk value set.
+ */
+ getPsk() generates (SupplicantStatus status, uint8_t[32] psk);
+
+ /**
* Get WEP key for WEP network.
*
* @param keyIdx Index of wep key to be fetched.
diff --git a/wifi/supplicant/1.0/vts/functional/Android.mk b/wifi/supplicant/1.0/vts/functional/Android.mk
index 93e5250..cfcd4f8 100644
--- a/wifi/supplicant/1.0/vts/functional/Android.mk
+++ b/wifi/supplicant/1.0/vts/functional/Android.mk
@@ -37,6 +37,6 @@
libwifi-system
LOCAL_STATIC_LIBRARIES := \
libgmock \
- VtsHalHidlTargetBaseTest
+ VtsHalHidlTargetTestBase
include $(BUILD_NATIVE_TEST)
diff --git a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
index 802d11c..a69d14d 100644
--- a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
+++ b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
@@ -16,7 +16,7 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "supplicant_hidl_test_utils.h"
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
index eb02445..ab1b6a3 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp
@@ -16,7 +16,7 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "supplicant_hidl_test_utils.h"
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
index 3f7ee1a..fdee0c6 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp
@@ -15,7 +15,7 @@
*/
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <hidl/HidlTransportSupport.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index 200845b..332b57b 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -16,7 +16,7 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "supplicant_hidl_test_utils.h"
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
index a1f5513..c50539b 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
@@ -16,7 +16,7 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "supplicant_hidl_test_utils.h"
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
index e2572c2..cde75fa 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
@@ -16,7 +16,7 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "supplicant_hidl_test_utils.h"