Merge "Move camera hal imp to vendor partition"
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/vts/functional/Android.bp b/audio/2.0/vts/functional/Android.bp
index cee69ef..02f9330 100644
--- a/audio/2.0/vts/functional/Android.bp
+++ b/audio/2.0/vts/functional/Android.bp
@@ -17,7 +17,6 @@
cc_test {
name: "VtsHalAudioV2_0TargetTest",
defaults: ["hidl_defaults"],
- gtest: true,
srcs: ["AudioPrimaryHidlHalTest.cpp"],
shared_libs: [
"libbase",
@@ -28,7 +27,7 @@
"android.hardware.audio@2.0",
"android.hardware.audio.common@2.0",
],
- static_libs: ["libgtest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index cc20456..e50b912 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -26,12 +26,13 @@
#include <type_traits>
#include <vector>
-#include <gtest/gtest.h>
+#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>
@@ -48,12 +49,19 @@
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;
@@ -63,9 +71,11 @@
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;
@@ -109,7 +119,7 @@
// Instance to register global tearDown
static Environment* environment;
-class HidlTest : public ::testing::Test {
+class HidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
// Convenient member to store results
Result res;
@@ -127,7 +137,7 @@
if (devicesFactory == nullptr) {
environment->registerTearDown([]{ devicesFactory.clear(); });
- devicesFactory = IDevicesFactory::getService();
+ devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>();
}
ASSERT_TRUE(devicesFactory != nullptr);
}
@@ -154,19 +164,23 @@
ASSERT_NO_FATAL_FAILURE(AudioHidlTest::SetUp()); // setup base
if (device == nullptr) {
- environment->registerTearDown([]{ device.clear(); });
IDevicesFactory::Result result;
+ sp<IDevice> baseDevice;
ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY,
- returnIn(result, device)));
+ returnIn(result, baseDevice)));
+ ASSERT_TRUE(baseDevice != nullptr);
+
+ environment->registerTearDown([]{ device.clear(); });
+ device = IPrimaryDevice::castFrom(baseDevice);
+ ASSERT_TRUE(device != nullptr);
}
- ASSERT_TRUE(device != nullptr);
}
protected:
// Cache the device opening to speed up each test by ~0.5s
- static sp<IDevice> device;
+ static sp<IPrimaryDevice> device;
};
-sp<IDevice> AudioPrimaryHidlTest::device;
+sp<IPrimaryDevice> AudioPrimaryHidlTest::device;
TEST_F(AudioPrimaryHidlTest, OpenPrimaryDevice) {
doc::test("Test the openDevice (called in SetUp)");
@@ -178,101 +192,112 @@
}
//////////////////////////////////////////////////////////////////////////////
-//////////////////////////// {set,get}MasterVolume ///////////////////////////
+///////////////////// {set,get}{Master,Mic}{Mute,Volume} /////////////////////
//////////////////////////////////////////////////////////////////////////////
-class MasterVolumeTest : public AudioPrimaryHidlTest {
+template <class Property>
+class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
protected:
- void testSetGetConsistency(float volume, Result expectedSetResult, float expectedGetVolume) {
- SCOPED_TRACE("Test set/get consistency for " + to_string(volume));
- auto ret = device->setMasterVolume(volume);
- ASSERT_TRUE(ret.isOk());
- ASSERT_EQ(expectedSetResult, ret);
- float observedVolume;
- ASSERT_OK(device->getMasterVolume(returnIn(res, observedVolume)));
+ /** 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);
- // Check that `get` returned the expected value
- EXPECT_EQ(expectedGetVolume, observedVolume);
- }
-};
-
-TEST_F(MasterVolumeTest, MasterVolumeTest) {
- doc::test("Test the master volume if supported");
- {
- SCOPED_TRACE("Check for master volume support");
- auto ret = device->setMasterVolume(1);
- ASSERT_TRUE(ret.isOk());
- if (ret == Result::NOT_SUPPORTED) {
- doc::partialTest("Master volume is not supported");
- return;
- }
- }
- // NOTE: this code has never been tested on a platform supporting MasterVolume
- float lastValidVolumeSet;
- using Volumes = float[];
- SCOPED_TRACE("As set/get master volume are supported...");
- {
- SCOPED_TRACE("...test them with valid values");
- for (float validVolume : Volumes{0, 0.5, 1}) {
- ASSERT_NO_FATAL_FAILURE(testSetGetConsistency(validVolume, Result::OK, validVolume));
- lastValidVolumeSet = validVolume;
- }
- }{
- SCOPED_TRACE("...test them with tricky values");
- for (float outOfBoundVolume :Volumes{-0.1, 1.1, NAN, INFINITY, -INFINITY,
- 1 + std::numeric_limits<float>::epsilon()}) {
- ASSERT_NO_FATAL_FAILURE(testSetGetConsistency(outOfBoundVolume,
- Result::INVALID_ARGUMENTS,
- lastValidVolumeSet));
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-////////////////////////// {set,get}{Master,Mic}Mute /////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-class BoolAccessorPrimaryHidlTest : public AudioPrimaryHidlTest {
-protected:
- template <class Getter, class Setter>
- void testBoolAccessors(const string& propertyName, const vector<bool>& valuesToTest,
- Setter setter, Getter getter) {
- for (bool setState : valuesToTest) {
- SCOPED_TRACE("Test " + propertyName + " state: " + to_string(setState));
- ASSERT_OK((device.get()->*setter)(setState));
- bool getState;
- ASSERT_OK((device.get()->*getter)(returnIn(res, getState)));
+ 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);
- ASSERT_EQ(setState, getState);
+ 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");
- testBoolAccessors("mic mute", {true, false, true}, &IDevice::setMicMute, &IDevice::getMicMute);
+ 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");
- {
- SCOPED_TRACE("Check for master mute support");
- auto ret = device->setMasterMute(false);
- ASSERT_TRUE(ret.isOk());
- if (ret == Result::NOT_SUPPORTED) {
- doc::partialTest("Master mute is not supported");
- return;
- }
- }
- // NOTE: this code has never been tested on a platform supporting MasterMute
- testBoolAccessors("master mute", {true, false, true},
- &IDevice::setMasterMute, &IDevice::getMasterMute);
+ 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
@@ -280,7 +305,7 @@
/////////// TODO: move to the beginning of the file for easier update ////////
//////////////////////////////////////////////////////////////////////////////
-class AudioConfigPrimaryTest : public AudioPrimaryHidlTest {
+class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest {
public:
// Cache result ?
static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() {
@@ -339,6 +364,20 @@
}
};
+/** 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 /////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -376,10 +415,12 @@
}
INSTANTIATE_TEST_CASE_P(
RequiredInputBufferSize, RequiredInputBufferSizeTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
+ &generateTestName);
INSTANTIATE_TEST_CASE_P(
SupportedInputBufferSize, RequiredInputBufferSizeTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
+ &generateTestName);
// Test that the recommended capture config are supported or lead to a INVALID_ARGUMENTS return
class OptionalInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {};
@@ -389,7 +430,8 @@
}
INSTANTIATE_TEST_CASE_P(
RecommendedCaptureAudioConfigSupport, OptionalInputBufferSizeTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
+ &generateTestName);
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////// setScreenState ///////////////////////////////
@@ -423,8 +465,8 @@
//////////////////////////////// debugDebug //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
-TEST_F(AudioPrimaryHidlTest, debugDump) {
- doc::test("Check that the hal can dump its state without error");
+template <class DebugDump>
+static void testDebugDump(DebugDump debugDump) {
FILE* file = tmpfile();
ASSERT_NE(nullptr, file) << errno;
@@ -435,28 +477,23 @@
hidl_handle handle;
handle.setTo(nativeHandle, true /*take ownership*/);
- auto ret = device->debugDump(handle);
- ASSERT_TRUE(ret.isOk());
-
- // FIXME: debugDump does not return a Result.
+ // TODO: debugDump does not return a Result.
// This mean that the hal can not report that it not implementing the function.
- // As the default hal does not implement debugDump, the function can not be tested.
- /*
- res = ret;
- if (res == Result::NOT_SUPPORTED) {
- doc::partialTest("debugDump is not implemented");
- return;
- }
- ASSERT_OK(res);
- rewind(file);
+ ASSERT_OK(debugDump(handle));
+
+ rewind(file); // can not fail
// Check that at least one bit was written by the hal
char buff;
- ASSERT_EQ(1, fread(&buff, sizeof(buff), 1, file));
- */
+ 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 //////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -496,6 +533,10 @@
open = true;
}
+ Return<Result> closeStream() {
+ open = false;
+ return stream->close();
+ }
private:
void TearDown() override {
if (open) {
@@ -506,6 +547,7 @@
protected:
AudioConfig audioConfig;
+ DeviceAddress address = {};
sp<Stream> stream;
bool open = false;
};
@@ -515,12 +557,11 @@
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();
- DeviceAddress deviceAddr{}; // Ignored by primary hal
AudioOutputFlag flags = AudioOutputFlag::NONE; // TODO: test all flag combination
testOpen([&](AudioIoHandle handle, AudioConfig config, auto cb)
- { return device->openOutputStream(handle, deviceAddr, config, flags, cb); },
+ { return device->openOutputStream(handle, address, config, flags, cb); },
config);
}
};
@@ -530,14 +571,17 @@
}
INSTANTIATE_TEST_CASE_P(
RequiredOutputStreamConfigSupport, OutputStreamTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()),
+ &generateTestName);
INSTANTIATE_TEST_CASE_P(
SupportedOutputStreamConfig, OutputStreamTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()),
+ &generateTestName);
INSTANTIATE_TEST_CASE_P(
RecommendedOutputStreamConfigSupport, OutputStreamTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()),
+ &generateTestName);
////////////////////////////// openInputStream //////////////////////////////
@@ -545,13 +589,12 @@
virtual void SetUp() override {
ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base
-
+ address.device = AudioDevice::IN_DEFAULT;
const AudioConfig& config = GetParam();
- DeviceAddress deviceAddr{}; // TODO: test all devices
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, deviceAddr, config, flags, source, cb); },
+ { return device->openInputStream(handle, address, config, flags, source, cb); },
config);
}
};
@@ -562,14 +605,17 @@
}
INSTANTIATE_TEST_CASE_P(
RequiredInputStreamConfigSupport, InputStreamTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()),
+ &generateTestName);
INSTANTIATE_TEST_CASE_P(
SupportedInputStreamConfig, InputStreamTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()),
+ &generateTestName);
INSTANTIATE_TEST_CASE_P(
RecommendedInputStreamConfigSupport, InputStreamTest,
- ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()));
+ ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()),
+ &generateTestName);
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// IStream getters ///////////////////////////////
@@ -586,8 +632,40 @@
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,
+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)));
@@ -610,6 +688,48 @@
}
}
+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;
@@ -618,80 +738,238 @@
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.sampleRateHz, sampleRateHz);
+ EXPECT_EQ(expectedConfig.channelMask, mask);
EXPECT_EQ(expectedConfig.format, format);
}
-static void testAccessors(IStream* stream, AudioConfig audioConfig) {
- doc::test("Test IStream getters and setters that can be called in the stop state");
+TEST_IO_STREAM(GetAudioProperties,
+ "Check that the stream audio properties == the ones it was opened with",
+ testGetAudioProperties(stream.get(), audioConfig))
- auto frameCount = extract(stream->getFrameCount());
- ASSERT_EQ(audioConfig.frameCount, frameCount);
+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;
- auto sampleRate = extract(stream->getSampleRate());
- // FIXME: the qcom hal it does not currently negotiate the sampleRate
- // ASSERT_EQ(audioConfig.sampleRateHz, sampleRate);
-
- auto channelMask = extract(stream->getChannelMask());
- // FIXME: the qcom hal it does not currently negotiate the channelMask
- // ASSERT_EQ(audioConfig.channelMask, channelMask);
-
- auto frameSize = extract(stream->getFrameSize());
- ASSERT_GE(frameSize, 0U);
-
- auto bufferSize = extract(stream->getBufferSize());
- ASSERT_GE(bufferSize, frameSize);
-
- testCapabilityGetter("getSupportedsampleRate", stream, sampleRate,
- &IStream::getSupportedSampleRates,
- &IStream::getSampleRate, &IStream::setSampleRate);
-
- testCapabilityGetter("getSupportedChannelMask", stream, channelMask,
- &IStream::getSupportedChannelMasks,
- &IStream::getChannelMask, &IStream::setChannelMask);
-
- AudioFormat format = extract(stream->getFormat());
- ASSERT_EQ(audioConfig.format, format);
-
- testCapabilityGetter("getSupportedFormats", stream, format,
- &IStream::getSupportedFormats, &IStream::getFormat, &IStream::setFormat);
-
- testGetAudioProperties(stream, audioConfig);
-
- // FIXME: Stream wrapper does not implement getDevice properly.
- // It needs to call getProperty({"routing"}).
- // The current implementation segfault with the default hal
- /*
- * auto ret = stream->getDevice();
- * ASSERT_TRUE(ret.isOk());
- * AudioDevice device = ret;
- * ASSERT_EQ(AudioDevice::OUT_ALL, device);
- */
-}
-
-TEST_P(InputStreamTest, GettersTest) {
- testAccessors(stream.get(), audioConfig);
-}
-TEST_P(OutputStreamTest, GettersTest) {
- testAccessors(stream.get(), audioConfig);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////// AudioPatches ////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-
-
-TEST_F(AudioPrimaryHidlTest, AudioPatches) {
- doc::test("Test if audio patches are supported");
- auto result = device->supportsAudioPatches();
- ASSERT_TRUE(result.isOk());
- bool supportsAudioPatch = result;
- if (!supportsAudioPatch) {
- doc::partialTest("Audio patches are not supported");
- return;
+ ASSERT_OK(stream->setConnectedState(address, true));
+ ASSERT_OK(stream->setConnectedState(address, false));
}
- // TODO: test audio patches
+}
+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);
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/audio/2.0/vts/functional/utility/AssertOk.h b/audio/2.0/vts/functional/utility/AssertOk.h
index 5397436..39c9a1d 100644
--- a/audio/2.0/vts/functional/utility/AssertOk.h
+++ b/audio/2.0/vts/functional/utility/AssertOk.h
@@ -13,22 +13,52 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include <vector>
+#include <algorithm>
+
#include <hidl/Status.h>
namespace detail {
-inline void assertOk(::android::hardware::Return<void> ret) {
+// 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(::android::hardware::audio::V2_0::Result result) {
- ASSERT_EQ(decltype(result)::OK, result);
+inline void assertOk(Result result) {
+ assertResult(Result::OK, result);
}
-inline void assertOk(::android::hardware::Return<::android::hardware::audio::V2_0::Result> ret) {
- ASSERT_TRUE(ret.isOk());
- ::android::hardware::audio::V2_0::Result result = ret;
- assertOk(result);
+inline void assertOk(Return<Result> ret) {
+ assertResult(Result::OK, std::move(ret));
}
}
@@ -36,3 +66,6 @@
// 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
index 8dfcb29..025cd1c 100644
--- a/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h
+++ b/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h
@@ -13,23 +13,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <type_traits>
-// Use HIDL generated toString methods to pretty print gtest errors
+/** @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/effect/2.0/vts/functional/Android.bp b/audio/effect/2.0/vts/functional/Android.bp
index 4d50201..1bc3f39 100644
--- a/audio/effect/2.0/vts/functional/Android.bp
+++ b/audio/effect/2.0/vts/functional/Android.bp
@@ -28,7 +28,7 @@
"libutils",
"android.hardware.audio.effect@2.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..063243b 100644
--- a/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp
+++ b/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp
@@ -21,7 +21,7 @@
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
#include <android/hardware/audio/effect/2.0/types.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
using ::android::hardware::audio::common::V2_0::Uuid;
using ::android::hardware::audio::effect::V2_0::EffectDescriptor;
@@ -35,10 +35,10 @@
using ::android::sp;
// The main test class for Audio Effect HIDL HAL.
-class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- effectsFactory = ::testing::VtsHalHidlTargetBaseTest::getService<IEffectsFactory>();
+ effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
ASSERT_NE(effectsFactory, nullptr);
}
diff --git a/automotive/evs/1.0/default/EvsCamera.cpp b/automotive/evs/1.0/default/EvsCamera.cpp
index 542cd1f..c4436ee 100644
--- a/automotive/evs/1.0/default/EvsCamera.cpp
+++ b/automotive/evs/1.0/default/EvsCamera.cpp
@@ -162,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 %zd)",
+ 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",
diff --git a/automotive/vehicle/2.0/default/Android.mk b/automotive/vehicle/2.0/default/Android.mk
index 9b3323d..4a010e9 100644
--- a/automotive/vehicle/2.0/default/Android.mk
+++ b/automotive/vehicle/2.0/default/Android.mk
@@ -133,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/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h
index 596ad85..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,
},
{
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 2214100..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
@@ -410,7 +410,7 @@
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;
diff --git a/biometrics/fingerprint/2.1/vts/functional/Android.bp b/biometrics/fingerprint/2.1/vts/functional/Android.bp
index 729282d..27b7157 100644
--- a/biometrics/fingerprint/2.1/vts/functional/Android.bp
+++ b/biometrics/fingerprint/2.1/vts/functional/Android.bp
@@ -27,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/async_fd_watcher.cc b/bluetooth/1.0/default/async_fd_watcher.cc
index 2f23a69..05ac537 100644
--- a/bluetooth/1.0/default/async_fd_watcher.cc
+++ b/bluetooth/1.0/default/async_fd_watcher.cc
@@ -159,19 +159,13 @@
}
// Invoke the data ready callbacks if appropriate.
- std::vector<decltype(watched_fds_)::value_type> saved_callbacks;
{
+ // Hold the mutex to make sure that the callbacks are still valid.
std::unique_lock<std::mutex> guard(internal_mutex_);
for (auto& it : watched_fds_) {
if (FD_ISSET(it.first, &read_fds)) {
- saved_callbacks.push_back(it);
- }
- }
- }
-
- for (auto& it : saved_callbacks) {
- if (it.second) {
it.second(it.first);
+ }
}
}
}
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index 6d3b56f..57ea1a3 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -215,11 +215,9 @@
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(s)
@@ -268,6 +266,13 @@
}
void VendorInterface::Close() {
+ // 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) {
@@ -276,10 +281,8 @@
}
if (lib_interface_ != nullptr) {
- bt_vendor_lpm_mode_t mode = BT_VND_LPM_DISABLE;
- lib_interface_->op(BT_VND_OP_LPM_SET_MODE, &mode);
-
lib_interface_->op(BT_VND_OP_USERIAL_CLOSE, nullptr);
+
int power_state = BT_VND_PWR_OFF;
lib_interface_->op(BT_VND_OP_POWER_CTRL, &power_state);
}
diff --git a/bluetooth/1.0/vts/functional/Android.bp b/bluetooth/1.0/vts/functional/Android.bp
index cb1abe8..d2e6553 100644
--- a/bluetooth/1.0/vts/functional/Android.bp
+++ b/bluetooth/1.0/vts/functional/Android.bp
@@ -28,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 e77eb5c..5b14f54 100644
--- a/boot/1.0/vts/functional/Android.bp
+++ b/boot/1.0/vts/functional/Android.bp
@@ -27,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 190dfa1..cf52f49 100644
--- a/broadcastradio/1.0/vts/functional/Android.bp
+++ b/broadcastradio/1.0/vts/functional/Android.bp
@@ -28,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 9d56164..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>
@@ -51,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) {
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 3b212eb..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");
@@ -26,18 +26,38 @@
TEMPORARILY_UNAVAILABLE,
};
-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
+/**
+ * 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.
+/**
+ * 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 172e684..a4c0849 100644
--- a/broadcastradio/1.1/vts/functional/Android.bp
+++ b/broadcastradio/1.1/vts/functional/Android.bp
@@ -29,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/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/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp
index 3e5d996..f1215b8 100644
--- a/camera/provider/2.4/vts/functional/Android.bp
+++ b/camera/provider/2.4/vts/functional/Android.bp
@@ -29,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 846d9a4..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 {}
diff --git a/configstore/1.0/ISurfaceFlingerConfigs.hal b/configstore/1.0/ISurfaceFlingerConfigs.hal
index 4403a90..318590d 100644
--- a/configstore/1.0/ISurfaceFlingerConfigs.hal
+++ b/configstore/1.0/ISurfaceFlingerConfigs.hal
@@ -16,6 +16,29 @@
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);
};
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.cpp b/configstore/1.0/default/SurfaceFlingerConfigs.cpp
index 5d62b15..f73ecb4 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
diff --git a/configstore/1.0/default/SurfaceFlingerConfigs.h b/configstore/1.0/default/SurfaceFlingerConfigs.h
index c9652fc..bbb61d6 100644
--- a/configstore/1.0/default/SurfaceFlingerConfigs.h
+++ b/configstore/1.0/default/SurfaceFlingerConfigs.h
@@ -25,6 +25,7 @@
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;
// 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..49314d7 100644
--- a/configstore/1.0/default/surfaceflinger.mk
+++ b/configstore/1.0/default/surfaceflinger.mk
@@ -5,6 +5,10 @@
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
diff --git a/contexthub/1.0/vts/functional/Android.bp b/contexthub/1.0/vts/functional/Android.bp
index 69aad30..c35386d 100644
--- a/contexthub/1.0/vts/functional/Android.bp
+++ b/contexthub/1.0/vts/functional/Android.bp
@@ -25,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 40a05e6..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>
@@ -78,7 +78,7 @@
static std::vector<uint32_t> hubIds;
if (hubIds.size() == 0) {
- sp<IContexthub> hubApi = ::testing::VtsHalHidlTargetBaseTest::getService<IContexthub>();
+ sp<IContexthub> hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>();
if (hubApi != nullptr) {
for (ContextHub hub : getHubsSync(hubApi)) {
@@ -93,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>();
+ hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>();
ASSERT_NE(hubApi, nullptr);
// getHubs() must be called at least once for proper initialization of the
diff --git a/gatekeeper/1.0/vts/functional/Android.bp b/gatekeeper/1.0/vts/functional/Android.bp
index 5ece336..70cb615 100644
--- a/gatekeeper/1.0/vts/functional/Android.bp
+++ b/gatekeeper/1.0/vts/functional/Android.bp
@@ -28,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/vts/functional/Android.bp b/gnss/1.0/vts/functional/Android.bp
index b273b20..6d96059 100644
--- a/gnss/1.0/vts/functional/Android.bp
+++ b/gnss/1.0/vts/functional/Android.bp
@@ -28,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 b813813..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);
diff --git a/graphics/allocator/2.0/vts/functional/Android.bp b/graphics/allocator/2.0/vts/functional/Android.bp
index 392103b..fb77ab3 100644
--- a/graphics/allocator/2.0/vts/functional/Android.bp
+++ b/graphics/allocator/2.0/vts/functional/Android.bp
@@ -22,7 +22,7 @@
"android.hardware.graphics.allocator@2.0",
],
static_libs: [
- "VtsHalHidlTargetBaseTest",
+ "VtsHalHidlTargetTestBase",
],
cflags: [
"-Wall",
@@ -50,7 +50,7 @@
],
static_libs: [
"libVtsHalGraphicsAllocatorTestUtils",
- "VtsHalHidlTargetBaseTest",
+ "VtsHalHidlTargetTestBase",
],
cflags: [
"-Wall",
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
index 141743b..0dc43be 100644
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
+++ b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "VtsHalGraphicsAllocatorTestUtils.h"
@@ -28,7 +28,7 @@
Allocator::Allocator() { init(); }
void Allocator::init() {
- mAllocator = ::testing::VtsHalHidlTargetBaseTest::getService<IAllocator>();
+ mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>();
ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service";
std::vector<IAllocator::Capability> capabilities = getCapabilities();
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
index 2e3ed73..b1c764f 100644
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
+++ b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
@@ -17,7 +17,7 @@
#define LOG_TAG "graphics_allocator_hidl_hal_test"
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "VtsHalGraphicsAllocatorTestUtils.h"
@@ -40,7 +40,7 @@
} \
} while (0)
-class GraphicsAllocatorHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GraphicsAllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
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 890cc05..8e1f925 100644
--- a/graphics/composer/2.1/vts/functional/Android.bp
+++ b/graphics/composer/2.1/vts/functional/Android.bp
@@ -20,7 +20,7 @@
srcs: ["VtsHalGraphicsComposerTestUtils.cpp"],
shared_libs: ["android.hardware.graphics.composer@2.1"],
static_libs: [
- "VtsHalHidlTargetBaseTest",
+ "VtsHalHidlTargetTestBase",
],
cflags: [
"-Wall",
@@ -55,7 +55,7 @@
"libVtsHalGraphicsAllocatorTestUtils",
"libVtsHalGraphicsComposerTestUtils",
"libVtsHalGraphicsMapperTestUtils",
- "VtsHalHidlTargetBaseTest",
+ "VtsHalHidlTargetTestBase",
],
cflags: [
"-Wall",
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
index 5b6a108..33cf84c 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "VtsHalGraphicsComposerTestUtils.h"
@@ -28,7 +28,7 @@
Composer::Composer() { init(); }
void Composer::init() {
- mComposer = ::testing::VtsHalHidlTargetBaseTest::getService<IComposer>();
+ mComposer = ::testing::VtsHalHidlTargetTestBase::getService<IComposer>();
ASSERT_NE(nullptr, mComposer.get()) << "failed to get composer service";
std::vector<IComposer::Capability> capabilities = getCapabilities();
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
index 0390c88..0da3a33 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
@@ -22,7 +22,7 @@
#include "VtsHalGraphicsComposerTestUtils.h"
#include "VtsHalGraphicsMapperTestUtils.h"
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <unistd.h>
#include <algorithm>
@@ -134,7 +134,7 @@
int mInvalidVsyncCount = 0;
};
-class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
ASSERT_NO_FATAL_FAILURE(mComposer = std::make_unique<Composer>());
diff --git a/graphics/mapper/2.0/vts/functional/Android.bp b/graphics/mapper/2.0/vts/functional/Android.bp
index 5b31fe5..e26f087 100644
--- a/graphics/mapper/2.0/vts/functional/Android.bp
+++ b/graphics/mapper/2.0/vts/functional/Android.bp
@@ -23,7 +23,7 @@
"android.hardware.graphics.mapper@2.0",
],
static_libs: [
- "VtsHalHidlTargetBaseTest",
+ "VtsHalHidlTargetTestBase",
"libVtsHalGraphicsAllocatorTestUtils",
],
cflags: [
@@ -56,7 +56,7 @@
static_libs: [
"libVtsHalGraphicsAllocatorTestUtils",
"libVtsHalGraphicsMapperTestUtils",
- "VtsHalHidlTargetBaseTest",
+ "VtsHalHidlTargetTestBase",
],
cflags: [
"-Wall",
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
index fc26587..f6a26ac 100644
--- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include "VtsHalGraphicsMapperTestUtils.h"
@@ -32,7 +32,7 @@
Mapper::Mapper() { init(); }
void Mapper::init() {
- mMapper = ::testing::VtsHalHidlTargetBaseTest::getService<IMapper>();
+ 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";
}
diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
index bd8315e..92d74d5 100644
--- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
+++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp
@@ -17,7 +17,7 @@
#define LOG_TAG "graphics_mapper_hidl_hal_test"
#include <android-base/logging.h>
-#include <VtsHalHidlTargetBaseTest.h>
+#include <VtsHalHidlTargetTestBase.h>
#include <sync/sync.h>
#include "VtsHalGraphicsMapperTestUtils.h"
@@ -32,7 +32,7 @@
using namespace android::hardware::graphics::allocator::V2_0;
using namespace android::hardware::graphics::allocator::V2_0::tests;
-class GraphicsMapperHidlTest : public ::testing::VtsHalHidlTargetBaseTest {
+class GraphicsMapperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
diff --git a/ir/1.0/vts/functional/Android.bp b/ir/1.0/vts/functional/Android.bp
index 8076126..4aac297 100644
--- a/ir/1.0/vts/functional/Android.bp
+++ b/ir/1.0/vts/functional/Android.bp
@@ -27,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 ead41c8..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);
}
diff --git a/light/2.0/vts/functional/Android.bp b/light/2.0/vts/functional/Android.bp
index 90f80df..0558ff2 100644
--- a/light/2.0/vts/functional/Android.bp
+++ b/light/2.0/vts/functional/Android.bp
@@ -25,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/memtrack/1.0/vts/functional/Android.bp b/memtrack/1.0/vts/functional/Android.bp
index 0eba82e..71e6111 100644
--- a/memtrack/1.0/vts/functional/Android.bp
+++ b/memtrack/1.0/vts/functional/Android.bp
@@ -27,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/vts/functional/Android.bp b/nfc/1.0/vts/functional/Android.bp
index f0359dc..d9ba702 100644
--- a/nfc/1.0/vts/functional/Android.bp
+++ b/nfc/1.0/vts/functional/Android.bp
@@ -28,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 4aa6d7e..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);
diff --git a/power/1.0/vts/functional/Android.bp b/power/1.0/vts/functional/Android.bp
index 161dacd..5ab1eb4 100644
--- a/power/1.0/vts/functional/Android.bp
+++ b/power/1.0/vts/functional/Android.bp
@@ -28,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 9309a5f..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);
}
diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp
index 7b80fa2..7f16163 100644
--- a/radio/1.0/vts/functional/Android.bp
+++ b/radio/1.0/vts/functional/Android.bp
@@ -19,6 +19,7 @@
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"],
@@ -32,7 +33,7 @@
"libutils",
"android.hardware.radio@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["VtsHalHidlTargetTestBase"],
cflags: [
"-O0",
"-g",
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 329f0b4..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;
@@ -433,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 19199ea..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,7 +172,9 @@
return Void();
}
-Return<void> RadioResponse::sendDtmfResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::sendDtmfResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -187,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();
}
@@ -205,21 +229,29 @@
}
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();
}
@@ -229,7 +261,9 @@
return Void();
}
-Return<void> RadioResponse::acceptCallResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::acceptCallResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
@@ -273,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();
}
@@ -287,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();
}
@@ -366,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();
}
@@ -425,7 +471,9 @@
return Void();
}
-Return<void> RadioResponse::sendBurstDtmfResponse(const RadioResponseInfo& /*info*/) {
+Return<void> RadioResponse::sendBurstDtmfResponse(const RadioResponseInfo& info) {
+ rspInfo = info;
+ parent.notify();
return Void();
}
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 f43557a..af149ba 100644
--- a/sensors/1.0/vts/functional/Android.bp
+++ b/sensors/1.0/vts/functional/Android.bp
@@ -25,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 2937a43..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);
@@ -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 {
}
diff --git a/soundtrigger/2.0/vts/functional/Android.bp b/soundtrigger/2.0/vts/functional/Android.bp
index b8ca2f9..8f0cc4e 100644
--- a/soundtrigger/2.0/vts/functional/Android.bp
+++ b/soundtrigger/2.0/vts/functional/Android.bp
@@ -28,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 fcc989f..0ef4063 100644
--- a/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
+++ b/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
@@ -28,7 +28,7 @@
#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)
@@ -86,10 +86,10 @@
};
// 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 SoundTriggerHwCallback(*this);
ASSERT_NE(nullptr, mCallback.get());
diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp
index 692edda..16018ac 100644
--- a/tests/msgq/1.0/default/Android.bp
+++ b/tests/msgq/1.0/default/Android.bp
@@ -1,3 +1,18 @@
+//
+// 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"],
@@ -5,6 +20,7 @@
proprietary: true,
srcs: [
"TestMsgQ.cpp",
+ "BenchmarkMsgQ.cpp"
],
shared_libs: [
"libbase",
@@ -18,3 +34,35 @@
"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
index 7cc4f5b..6fd4fc6 100644
--- a/tests/msgq/1.0/default/TestMsgQ.cpp
+++ b/tests/msgq/1.0/default/TestMsgQ.cpp
@@ -1,3 +1,19 @@
+/*
+ * 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 {
diff --git a/tests/msgq/1.0/default/TestMsgQ.h b/tests/msgq/1.0/default/TestMsgQ.h
index 760d931..86e4ac4 100644
--- a/tests/msgq/1.0/default/TestMsgQ.h
+++ b/tests/msgq/1.0/default/TestMsgQ.h
@@ -1,3 +1,19 @@
+/*
+ * 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
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/thermal/1.0/vts/functional/Android.bp b/thermal/1.0/vts/functional/Android.bp
index 95fbea8..9046882 100644
--- a/thermal/1.0/vts/functional/Android.bp
+++ b/thermal/1.0/vts/functional/Android.bp
@@ -28,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 57fb35e..c862429 100644
--- a/tv/input/1.0/vts/functional/Android.bp
+++ b/tv/input/1.0/vts/functional/Android.bp
@@ -28,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 1bca694..7438bc7 100644
--- a/usb/1.0/vts/functional/Android.bp
+++ b/usb/1.0/vts/functional/Android.bp
@@ -28,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/vts/functional/Android.bp b/vibrator/1.0/vts/functional/Android.bp
index 07fdeea..9e25def 100644
--- a/vibrator/1.0/vts/functional/Android.bp
+++ b/vibrator/1.0/vts/functional/Android.bp
@@ -25,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/vts/functional/Android.bp b/vr/1.0/vts/functional/Android.bp
index 5c077ea..5d5a99a 100644
--- a/vr/1.0/vts/functional/Android.bp
+++ b/vr/1.0/vts/functional/Android.bp
@@ -24,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/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/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index 5917efc..fb93c5a 100644
--- a/wifi/1.0/default/hidl_struct_util.cpp
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -706,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();
@@ -987,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 ?
@@ -1080,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 ?
@@ -1898,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_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..f79e62a 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
diff --git a/wifi/1.0/types.hal b/wifi/1.0/types.hal
index d90d5be..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).
@@ -478,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 11d0619..eab338b 100644
--- a/wifi/1.0/vts/functional/Android.bp
+++ b/wifi/1.0/vts/functional/Android.bp
@@ -38,7 +38,7 @@
"libutils",
"android.hardware.wifi@1.0",
],
- static_libs: ["VtsHalHidlTargetBaseTest"],
+ static_libs: ["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/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"