Merge "Convert drm hal test to use VtsHalHidlTargetTestEnvBase"
diff --git a/audio/4.0/IDevice.hal b/audio/4.0/IDevice.hal
index bb58568..7eb03c8 100644
--- a/audio/4.0/IDevice.hal
+++ b/audio/4.0/IDevice.hal
@@ -268,4 +268,16 @@
*/
getMicrophones()
generates(Result retval, vec<MicrophoneInfo> microphones);
+
+ /**
+ * Notifies the device module about the connection state of an input/output
+ * device attached to it. Calling this method is equivalent to setting
+ * AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL.
+ *
+ * @param address audio device specification.
+ * @param connected whether the device is connected.
+ * @return retval operation completion status.
+ */
+ setConnectedState(DeviceAddress address, bool connected)
+ generates (Result retval);
};
diff --git a/audio/4.0/IPrimaryDevice.hal b/audio/4.0/IPrimaryDevice.hal
index f3d904c..258c28b 100644
--- a/audio/4.0/IPrimaryDevice.hal
+++ b/audio/4.0/IPrimaryDevice.hal
@@ -37,6 +37,17 @@
setMode(AudioMode mode) generates (Result retval);
/**
+ * Sets the name of the current BT SCO headset. Calling this method
+ * is equivalent to setting legacy "bt_headset_name" parameter.
+ * The BT SCO headset name must only be used for debugging purposes.
+ * Optional method
+ *
+ * @param name the name of the current BT SCO headset (can be empty).
+ * @return retval operation completion status.
+ */
+ setBtScoHeadsetDebugName(string name) generates (Result retval);
+
+ /**
* Gets whether BT SCO Noise Reduction and Echo Cancellation are enabled.
* Calling this method is equivalent to getting AUDIO_PARAMETER_KEY_BT_NREC
* on the legacy HAL.
@@ -76,6 +87,48 @@
*/
setBtScoWidebandEnabled(bool enabled) generates (Result retval);
+ /**
+ * Gets whether BT HFP (Hands-Free Profile) is enabled. Calling this method
+ * is equivalent to getting "hfp_enable" parameter value on the legacy HAL.
+ *
+ * @return retval operation completion status.
+ * @return enabled whether BT HFP is enabled.
+ */
+ getBtHfpEnabled() generates (Result retval, bool enabled);
+
+ /**
+ * Sets whether BT HFP (Hands-Free Profile) is enabled. Calling this method
+ * is equivalent to setting "hfp_enable" parameter on the legacy HAL.
+ * Optional method
+ *
+ * @param enabled whether BT HFP is enabled.
+ * @return retval operation completion status.
+ */
+ setBtHfpEnabled(bool enabled) generates (Result retval);
+
+ /**
+ * Sets the sampling rate of BT HFP (Hands-Free Profile). Calling this
+ * method is equivalent to setting "hfp_set_sampling_rate" parameter
+ * on the legacy HAL.
+ * Optional method
+ *
+ * @param sampleRateHz sample rate in Hz.
+ * @return retval operation completion status.
+ */
+ setBtHfpSampleRate(uint32_t sampleRateHz) generates (Result retval);
+
+ /**
+ * Sets the current output volume Hz for BT HFP (Hands-Free Profile).
+ * Calling this method is equivalent to setting "hfp_volume" parameter value
+ * on the legacy HAL (except that legacy HAL implementations expect
+ * an integer value in the range from 0 to 15.)
+ * Optional method
+ *
+ * @param volume 1.0f means unity, 0.0f is zero.
+ * @return retval operation completion status.
+ */
+ setBtHfpVolume(float volume) generates (Result retval);
+
enum TtyMode : int32_t {
OFF,
VCO,
@@ -121,4 +174,22 @@
* @return retval operation completion status.
*/
setHacEnabled(bool enabled) generates (Result retval);
+
+ enum Rotation : int32_t {
+ DEG_0,
+ DEG_90,
+ DEG_180,
+ DEG_270
+ };
+
+ /**
+ * Updates HAL on the current rotation of the device relative to natural
+ * orientation. Calling this method is equivalent to setting legacy
+ * parameter "rotation".
+ *
+ * @param rotation rotation in degrees relative to natural device
+ * orientation.
+ * @return retval operation completion status.
+ */
+ updateRotation(Rotation rotation) generates (Result retval);
};
diff --git a/audio/4.0/IStream.hal b/audio/4.0/IStream.hal
index f05d7b0..e7a4b7d 100644
--- a/audio/4.0/IStream.hal
+++ b/audio/4.0/IStream.hal
@@ -175,38 +175,26 @@
standby() generates (Result retval);
/**
- * Return the set of device(s) which this stream is connected to.
+ * Return the set of devices which this stream is connected to.
* Optional method
*
* @return retval operation completion status: OK or NOT_SUPPORTED.
- * @return device set of device(s) which this stream is connected to.
+ * @return device set of devices which this stream is connected to.
*/
- getDevice() generates (Result retval, bitfield<AudioDevice> device);
+ getDevices() generates (Result retval, vec<DeviceAddress> devices);
/**
- * Connects the stream to the device.
+ * Connects the stream to one or multiple devices.
*
* This method must only be used for HALs that do not support
* 'IDevice.createAudioPatch' method. Calling this method is
- * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING in the legacy HAL
- * interface.
+ * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceeded
+ * with a device address in the legacy HAL interface.
*
* @param address device to connect the stream to.
* @return retval operation completion status.
*/
- setDevice(DeviceAddress address) generates (Result retval);
-
- /**
- * Notifies the stream about device connection state. Calling this method is
- * equivalent to setting AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy
- * HAL.
- *
- * @param address audio device specification.
- * @param connected whether the device is connected.
- * @return retval operation completion status.
- */
- setConnectedState(DeviceAddress address, bool connected)
- generates (Result retval);
+ setDevices(vec<DeviceAddress> devices) generates (Result retval);
/**
* Sets the HW synchronization source. Calling this method is equivalent to
diff --git a/audio/4.0/IStreamOut.hal b/audio/4.0/IStreamOut.hal
index 3aa93fc..65eba60 100644
--- a/audio/4.0/IStreamOut.hal
+++ b/audio/4.0/IStreamOut.hal
@@ -264,4 +264,16 @@
*/
getPresentationPosition()
generates (Result retval, uint64_t frames, TimeSpec timeStamp);
+
+ /**
+ * Selects a presentation for decoding from a next generation media stream
+ * (as defined per ETSI TS 103 190-2) and a program within the presentation.
+ * Optional method
+ *
+ * @param presentationId selected audio presentation.
+ * @param programId refinement for the presentation.
+ * @return retval operation completion status.
+ */
+ selectPresentation(int32_t presentationId, int32_t programId)
+ generates (Result retval);
};
diff --git a/audio/4.0/types.hal b/audio/4.0/types.hal
index 7853f3c..7b2035b 100644
--- a/audio/4.0/types.hal
+++ b/audio/4.0/types.hal
@@ -23,6 +23,10 @@
NOT_INITIALIZED,
INVALID_ARGUMENTS,
INVALID_STATE,
+ /**
+ * Methods marked as "Optional method" must return this result value
+ * if the operation is not supported by HAL.
+ */
NOT_SUPPORTED
};
diff --git a/audio/common/4.0/types.hal b/audio/common/4.0/types.hal
index d4c6efe..4efdea3 100644
--- a/audio/common/4.0/types.hal
+++ b/audio/common/4.0/types.hal
@@ -485,7 +485,7 @@
};
@export(name="", value_prefix="AUDIO_DEVICE_")
-enum AudioDevice : uint64_t {
+enum AudioDevice : uint32_t {
NONE = 0x0,
/** reserved bits */
BIT_IN = 0x80000000,
@@ -530,6 +530,7 @@
OUT_BUS = 0x1000000,
OUT_PROXY = 0x2000000,
OUT_USB_HEADSET = 0x4000000,
+ OUT_HEARING_AID = 0x8000000,
OUT_ECHO_CANCELLER = 0x10000000,
OUT_DEFAULT = BIT_DEFAULT,
// Note that the 2.0 OUT_ALL* have been moved to helper functions
diff --git a/automotive/vehicle/2.0/default/common/src/VmsUtils.cpp b/automotive/vehicle/2.0/default/common/src/VmsUtils.cpp
index abf425f..f001a32 100644
--- a/automotive/vehicle/2.0/default/common/src/VmsUtils.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VmsUtils.cpp
@@ -126,19 +126,18 @@
return result;
}
-bool verifyPropertyAndArea(const VehiclePropValue& value) {
- return (value.prop == toInt(VehicleProperty::VEHICLE_MAP_SERVICE) &&
- value.areaId == toInt(VehicleArea::GLOBAL));
+bool isValidVmsProperty(const VehiclePropValue& value) {
+ return (value.prop == toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
}
-bool verifyMessageType(const VehiclePropValue& value) {
+bool isValidVmsMessageType(const VehiclePropValue& value) {
return (value.value.int32Values.size() > 0 &&
value.value.int32Values[kMessageIndex] >= kFirstMessageType &&
value.value.int32Values[kMessageIndex] <= kLastMessageType);
}
bool isValidVmsMessage(const VehiclePropValue& value) {
- return (verifyPropertyAndArea(value) && verifyMessageType(value));
+ return (isValidVmsProperty(value) && isValidVmsMessageType(value));
}
VmsMessageType parseMessageType(const VehiclePropValue& value) {
diff --git a/automotive/vehicle/2.0/default/tests/VmsUtils_test.cpp b/automotive/vehicle/2.0/default/tests/VmsUtils_test.cpp
index c102ce8..414c5c2 100644
--- a/automotive/vehicle/2.0/default/tests/VmsUtils_test.cpp
+++ b/automotive/vehicle/2.0/default/tests/VmsUtils_test.cpp
@@ -35,7 +35,6 @@
ASSERT_NE(message, nullptr);
EXPECT_TRUE(isValidVmsMessage(*message));
EXPECT_EQ(message->prop, toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
- EXPECT_EQ(message->areaId, toInt(VehicleArea::GLOBAL));
EXPECT_EQ(message->value.int32Values.size(), 0x4ul);
EXPECT_EQ(parseMessageType(*message), VmsMessageType::SUBSCRIBE);
@@ -51,7 +50,6 @@
ASSERT_NE(message, nullptr);
EXPECT_TRUE(isValidVmsMessage(*message));
EXPECT_EQ(message->prop, toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
- EXPECT_EQ(message->areaId, toInt(VehicleArea::GLOBAL));
EXPECT_EQ(message->value.int32Values.size(), 0x4ul);
EXPECT_EQ(parseMessageType(*message), VmsMessageType::UNSUBSCRIBE);
@@ -67,7 +65,6 @@
ASSERT_NE(message, nullptr);
EXPECT_TRUE(isValidVmsMessage(*message));
EXPECT_EQ(message->prop, toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
- EXPECT_EQ(message->areaId, toInt(VehicleArea::GLOBAL));
EXPECT_EQ(message->value.int32Values.size(), 0x6ul);
EXPECT_EQ(parseMessageType(*message), VmsMessageType::OFFERING);
@@ -91,7 +88,6 @@
ASSERT_NE(message, nullptr);
EXPECT_TRUE(isValidVmsMessage(*message));
EXPECT_EQ(message->prop, toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
- EXPECT_EQ(message->areaId, toInt(VehicleArea::GLOBAL));
EXPECT_EQ(message->value.int32Values.size(), 0x9ul);
EXPECT_EQ(parseMessageType(*message), VmsMessageType::OFFERING);
@@ -117,7 +113,6 @@
ASSERT_NE(message, nullptr);
EXPECT_TRUE(isValidVmsMessage(*message));
EXPECT_EQ(message->prop, toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
- EXPECT_EQ(message->areaId, toInt(VehicleArea::GLOBAL));
EXPECT_EQ(message->value.int32Values.size(), 0x1ul);
EXPECT_EQ(parseMessageType(*message), VmsMessageType::AVAILABILITY_REQUEST);
}
@@ -127,7 +122,6 @@
ASSERT_NE(message, nullptr);
EXPECT_TRUE(isValidVmsMessage(*message));
EXPECT_EQ(message->prop, toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
- EXPECT_EQ(message->areaId, toInt(VehicleArea::GLOBAL));
EXPECT_EQ(message->value.int32Values.size(), 0x1ul);
EXPECT_EQ(parseMessageType(*message), VmsMessageType::SUBSCRIPTIONS_REQUEST);
}
@@ -138,7 +132,6 @@
ASSERT_NE(message, nullptr);
EXPECT_TRUE(isValidVmsMessage(*message));
EXPECT_EQ(message->prop, toInt(VehicleProperty::VEHICLE_MAP_SERVICE));
- EXPECT_EQ(message->areaId, toInt(VehicleArea::GLOBAL));
EXPECT_EQ(message->value.int32Values.size(), 0x1ul);
EXPECT_EQ(parseMessageType(*message), VmsMessageType::DATA);
EXPECT_EQ(message->value.bytes.size(), bytes.size());
diff --git a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
index 6c9aa18..b9f505d 100644
--- a/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
+++ b/bluetooth/1.0/vts/functional/VtsHalBluetoothV1_0TargetTest.cpp
@@ -25,6 +25,7 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <queue>
using ::android::hardware::bluetooth::V1_0::IBluetoothHci;
@@ -126,6 +127,23 @@
std::chrono::steady_clock::time_point start_time_;
};
+// Test environment for Bluetooth HIDL HAL.
+class BluetoothHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static BluetoothHidlEnvironment* Instance() {
+ static BluetoothHidlEnvironment* instance = new BluetoothHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override {
+ registerTestService<IBluetoothHci>();
+ }
+
+ private:
+ BluetoothHidlEnvironment() {}
+};
+
// The main test class for Bluetooth HIDL HAL.
class BluetoothHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
@@ -251,15 +269,6 @@
int max_sco_data_packets;
};
-// A class for test environment setup (kept since this file is a template).
-class BluetoothHidlEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- private:
-};
-
// Receive and check status events until a COMMAND_COMPLETE is received.
void BluetoothHidlTest::wait_for_command_complete_event(hidl_vec<uint8_t> cmd) {
// Allow intermediate COMMAND_STATUS events
@@ -662,8 +671,9 @@
}
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new BluetoothHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(BluetoothHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ BluetoothHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
diff --git a/broadcastradio/1.0/vts/functional/Android.bp b/broadcastradio/1.0/vts/functional/Android.bp
index f31a2dc..7040a01 100644
--- a/broadcastradio/1.0/vts/functional/Android.bp
+++ b/broadcastradio/1.0/vts/functional/Android.bp
@@ -18,5 +18,8 @@
name: "VtsHalBroadcastradioV1_0TargetTest",
defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalBroadcastradioV1_0TargetTest.cpp"],
- static_libs: ["android.hardware.broadcastradio@1.0"],
+ static_libs: [
+ "android.hardware.broadcastradio@1.0",
+ "android.hardware.broadcastradio@vts-utils-lib",
+ ],
}
diff --git a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
index fd048db..90c8463 100644
--- a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
+++ b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp
@@ -22,12 +22,12 @@
#include <hidl/HidlTransportSupport.h>
#include <utils/threads.h>
-#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>
#include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h>
+#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>
#include <android/hardware/broadcastradio/1.0/ITuner.h>
#include <android/hardware/broadcastradio/1.0/ITunerCallback.h>
#include <android/hardware/broadcastradio/1.0/types.h>
-
+#include <broadcastradio-vts-utils/environment-utils.h>
using ::android::sp;
using ::android::Mutex;
@@ -48,6 +48,7 @@
using ::android::hardware::broadcastradio::V1_0::MetaData;
using ::android::hardware::broadcastradio::V1_0::MetadataKey;
using ::android::hardware::broadcastradio::V1_0::MetadataType;
+using ::android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
#define RETURN_IF_SKIPPED \
if (skipped) { \
@@ -55,8 +56,8 @@
return; \
}
+static BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>* gEnv = nullptr;
// The main test class for Broadcast Radio HIDL HAL.
-
class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetTestBase,
public ::testing::WithParamInterface<Class> {
protected:
@@ -67,7 +68,7 @@
skipped = false;
sp<IBroadcastRadioFactory> factory =
- ::testing::VtsHalHidlTargetTestBase::getService<IBroadcastRadioFactory>();
+ getService<IBroadcastRadioFactory>(gEnv->getServiceName<IBroadcastRadioFactory>());
ASSERT_NE(nullptr, factory.get());
Result connectResult;
@@ -731,8 +732,11 @@
::testing::Values(Class::AM_FM, Class::SAT, Class::DT));
int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
- return status;
+ gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>;
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
}
diff --git a/broadcastradio/1.1/vts/functional/Android.bp b/broadcastradio/1.1/vts/functional/Android.bp
index 27ae4e9..9240cf0 100644
--- a/broadcastradio/1.1/vts/functional/Android.bp
+++ b/broadcastradio/1.1/vts/functional/Android.bp
@@ -21,7 +21,6 @@
static_libs: [
"android.hardware.broadcastradio@1.0",
"android.hardware.broadcastradio@1.1",
- "android.hardware.broadcastradio@1.2", // common-utils-lib dependency
"android.hardware.broadcastradio@common-utils-1x-lib",
"android.hardware.broadcastradio@vts-utils-lib",
"libgmock",
diff --git a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
index 823d14c..6687731 100644
--- a/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
+++ b/broadcastradio/1.1/vts/functional/VtsHalBroadcastradioV1_1TargetTest.cpp
@@ -25,6 +25,7 @@
#include <android/hardware/broadcastradio/1.1/types.h>
#include <broadcastradio-utils-1x/Utils.h>
#include <broadcastradio-vts-utils/call-barrier.h>
+#include <broadcastradio-vts-utils/environment-utils.h>
#include <broadcastradio-vts-utils/mock-timeout.h>
#include <broadcastradio-vts-utils/pointer-utils.h>
#include <cutils/native_handle.h>
@@ -58,6 +59,7 @@
using V1_0::MetadataType;
using broadcastradio::vts::clearAndWait;
+using broadcastradio::vts::BroadcastRadioHidlEnvironment;
static constexpr auto kConfigTimeout = 10s;
static constexpr auto kConnectModuleTimeout = 1s;
@@ -91,6 +93,8 @@
MOCK_TIMEOUT_METHOD1(currentProgramInfoChanged, Return<void>(const ProgramInfo&));
};
+static BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>* gEnv = nullptr;
+
class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase,
public ::testing::WithParamInterface<Class> {
protected:
@@ -119,7 +123,8 @@
radioClass = GetParam();
// lookup HIDL service
- auto factory = getService<IBroadcastRadioFactory>();
+ auto factory =
+ getService<IBroadcastRadioFactory>(gEnv->getServiceName<IBroadcastRadioFactory>());
ASSERT_NE(nullptr, factory.get());
// connect radio module
@@ -606,8 +611,14 @@
} // namespace android
int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
- return status;
+ using android::hardware::broadcastradio::V1_1::vts::gEnv;
+ using android::hardware::broadcastradio::V1_1::IBroadcastRadioFactory;
+ using android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
+ gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>;
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
}
diff --git a/broadcastradio/1.2/Android.bp b/broadcastradio/1.2/Android.bp
deleted file mode 100644
index 40eb4e0..0000000
--- a/broadcastradio/1.2/Android.bp
+++ /dev/null
@@ -1,25 +0,0 @@
-// This file is autogenerated by hidl-gen -Landroidbp.
-
-hidl_interface {
- name: "android.hardware.broadcastradio@1.2",
- root: "android.hardware",
- vndk: {
- enabled: true,
- },
- srcs: [
- "types.hal",
- "IBroadcastRadioFactory.hal",
- "ITuner.hal",
- "ITunerCallback.hal",
- ],
- interfaces: [
- "android.hardware.broadcastradio@1.0",
- "android.hardware.broadcastradio@1.1",
- "android.hidl.base@1.0",
- ],
- types: [
- "IdentifierType",
- ],
- gen_java: false,
-}
-
diff --git a/broadcastradio/1.2/IBroadcastRadioFactory.hal b/broadcastradio/1.2/IBroadcastRadioFactory.hal
deleted file mode 100644
index 29f6ab3..0000000
--- a/broadcastradio/1.2/IBroadcastRadioFactory.hal
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-
-package android.hardware.broadcastradio@1.2;
-
-import @1.1::IBroadcastRadioFactory;
-
-/**
- * To use 1.2 features you must cast specific interfaces returned from the
- * 1.0 HAL. For example V1_0::IBroadcastRadio::openTuner() returns V1_0::ITuner,
- * which can be cast with V1_2::ITuner::castFrom() call.
- *
- * The 1.2 server must always return the 1.2 version of specific interface.
- */
-interface IBroadcastRadioFactory extends @1.1::IBroadcastRadioFactory {
-};
diff --git a/broadcastradio/1.2/ITuner.hal b/broadcastradio/1.2/ITuner.hal
deleted file mode 100644
index ba97ea0..0000000
--- a/broadcastradio/1.2/ITuner.hal
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.
- */
-
-package android.hardware.broadcastradio@1.2;
-
-import @1.1::ITuner;
-
-interface ITuner extends @1.1::ITuner {
- /**
- * Generic method for setting vendor-specific parameter values.
- * The framework does not interpret the parameters, they are passed
- * in an opaque manner between a vendor application and HAL.
- *
- * Framework does not make any assumptions on the keys or values, other than
- * ones stated in VendorKeyValue documentation (a requirement of key
- * prefixes).
- *
- * For each pair in the result vector, the key must be one of the keys
- * contained in the input (possibly with wildcards expanded), and the value
- * must be a vendor-specific result status (i.e. the string "OK" or an error
- * code). The implementation may choose to return an empty vector, or only
- * return a status for a subset of the provided inputs, at its discretion.
- *
- * Application and HAL must not use keys with unknown prefix. In particular,
- * it must not place a key-value pair in results vector for unknown key from
- * parameters vector - instead, an unknown key should simply be ignored.
- * In other words, results vector may contain a subset of parameter keys
- * (however, the framework doesn't enforce a strict subset - the only
- * formal requirement is vendor domain prefix for keys).
- *
- * @param parameters Vendor-specific key-value pairs.
- * @return results Operation completion status for parameters being set.
- */
- setParameters(vec<VendorKeyValue> parameters)
- generates (vec<VendorKeyValue> results);
-
- /**
- * Generic method for retrieving vendor-specific parameter values.
- * The framework does not interpret the parameters, they are passed
- * in an opaque manner between a vendor application and HAL.
- *
- * Framework does not cache set/get requests, so it's allowed for
- * getParameter to return a different value than previous setParameter call.
- *
- * The syntax and semantics of keys are up to the vendor (as long as prefix
- * rules are obeyed). For instance, vendors may include some form of
- * wildcard support. In such case, result vector may be of different size
- * than requested keys vector. However, wildcards are not recognized by
- * framework and they are passed as-is to the HAL implementation.
- *
- * Unknown keys must be ignored and not placed into results vector.
- *
- * @param keys Parameter keys to fetch.
- * @return parameters Vendor-specific key-value pairs.
- */
- getParameters(vec<string> keys) generates (vec<VendorKeyValue> parameters);
-};
diff --git a/broadcastradio/1.2/ITunerCallback.hal b/broadcastradio/1.2/ITunerCallback.hal
deleted file mode 100644
index 4e3d0a5..0000000
--- a/broadcastradio/1.2/ITunerCallback.hal
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-package android.hardware.broadcastradio@1.2;
-
-import @1.1::ITunerCallback;
-
-interface ITunerCallback extends @1.1::ITunerCallback {
- /**
- * Generic callback for passing updates to vendor-specific parameter values.
- * The framework does not interpret the parameters, they are passed
- * in an opaque manner between a vendor application and HAL.
- *
- * It's up to the HAL implementation if and how to implement this callback,
- * as long as it obeys the prefix rule. In particular, only selected keys
- * may be notified this way. However, setParameters must not trigger
- * this callback, while an internal event can change parameters
- * asynchronously.
- *
- * @param parameters Vendor-specific key-value pairs.
- */
- oneway parametersUpdated(vec<VendorKeyValue> parameters);
-};
diff --git a/broadcastradio/1.2/types.hal b/broadcastradio/1.2/types.hal
deleted file mode 100644
index 7301e13..0000000
--- a/broadcastradio/1.2/types.hal
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.hardware.broadcastradio@1.2;
-
-import @1.1::IdentifierType;
-import @1.1::Result;
-import @1.1::VendorKeyValue;
-
-typedef @1.1::Result Result;
-typedef @1.1::VendorKeyValue VendorKeyValue;
-
-enum IdentifierType : @1.1::IdentifierType {
- /**
- * 28bit compound primary identifier for DAB.
- *
- * Consists of (from the LSB):
- * - 16bit: SId;
- * - 8bit: ECC code;
- * - 4bit: SCIdS (optional).
- *
- * SCIdS (Service Component Identifier within the Service) value
- * of 0 represents the main service, while 1 and above represents
- * secondary services.
- *
- * The remaining bits should be set to zeros when writing on the chip side
- * and ignored when read.
- *
- * This identifier deprecates DAB_SIDECC and makes new primary identifier
- * for DAB. If the hal implementation detects 1.2 client (by casting
- * V1_0::ITunerCallback to V1_2::ITunerCallback), it must use DAB_SID_EXT
- * as a primary identifier for DAB program type. If the hal client detects
- * either 1.1 or 1.2 HAL, it must convert those identifiers to the
- * correct version.
- */
- DAB_SID_EXT = SXM_CHANNEL + 1,
-};
diff --git a/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp b/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp
index 37095d4..6877f07 100644
--- a/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp
+++ b/broadcastradio/2.0/vts/functional/VtsHalBroadcastradioV2_0TargetTest.cpp
@@ -26,6 +26,7 @@
#include <android/hardware/broadcastradio/2.0/types.h>
#include <broadcastradio-utils-2x/Utils.h>
#include <broadcastradio-vts-utils/call-barrier.h>
+#include <broadcastradio-vts-utils/environment-utils.h>
#include <broadcastradio-vts-utils/mock-timeout.h>
#include <broadcastradio-vts-utils/pointer-utils.h>
#include <cutils/bitops.h>
@@ -52,6 +53,7 @@
using testing::Invoke;
using testing::SaveArg;
+using broadcastradio::vts::BroadcastRadioHidlEnvironment;
using broadcastradio::vts::CallBarrier;
using broadcastradio::vts::clearAndWait;
using utils::make_identifier;
@@ -81,7 +83,8 @@
TunerCallbackMock();
MOCK_METHOD2(onTuneFailed, Return<void>(Result, const ProgramSelector&));
- MOCK_TIMEOUT_METHOD1(onCurrentProgramInfoChanged, Return<void>(const ProgramInfo&));
+ MOCK_TIMEOUT_METHOD1(onCurrentProgramInfoChanged_, Return<void>(const ProgramInfo&));
+ virtual Return<void> onCurrentProgramInfoChanged(const ProgramInfo& info);
Return<void> onProgramListUpdated(const ProgramListChunk& chunk);
MOCK_METHOD1(onAntennaStateChange, Return<void>(bool connected));
MOCK_METHOD1(onParametersUpdated, Return<void>(const hidl_vec<VendorKeyValue>& parameters));
@@ -96,6 +99,8 @@
MOCK_METHOD1(onListUpdated, Return<void>(const hidl_vec<Announcement>&));
};
+static BroadcastRadioHidlEnvironment<IBroadcastRadio>* gEnv = nullptr;
+
class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
virtual void SetUp() override;
@@ -122,12 +127,40 @@
}
TunerCallbackMock::TunerCallbackMock() {
- EXPECT_TIMEOUT_CALL(*this, onCurrentProgramInfoChanged, _).Times(AnyNumber());
+ EXPECT_TIMEOUT_CALL(*this, onCurrentProgramInfoChanged_, _).Times(AnyNumber());
// we expect the antenna is connected through the whole test
EXPECT_CALL(*this, onAntennaStateChange(false)).Times(0);
}
+Return<void> TunerCallbackMock::onCurrentProgramInfoChanged(const ProgramInfo& info) {
+ auto logically = utils::getType(info.logicallyTunedTo);
+ if (logically != IdentifierType::INVALID) {
+ EXPECT_TRUE(logically == IdentifierType::AMFM_FREQUENCY ||
+ logically == IdentifierType::RDS_PI ||
+ logically == IdentifierType::HD_STATION_ID_EXT ||
+ logically == IdentifierType::DAB_SID_EXT ||
+ logically == IdentifierType::DRMO_SERVICE_ID ||
+ logically == IdentifierType::SXM_SERVICE_ID ||
+ (logically >= IdentifierType::VENDOR_START &&
+ logically <= IdentifierType::VENDOR_END) ||
+ logically > IdentifierType::SXM_CHANNEL);
+ }
+
+ auto physically = utils::getType(info.physicallyTunedTo);
+ if (physically != IdentifierType::INVALID) {
+ EXPECT_TRUE(physically == IdentifierType::AMFM_FREQUENCY ||
+ physically == IdentifierType::DAB_ENSEMBLE ||
+ physically == IdentifierType::DRMO_FREQUENCY ||
+ physically == IdentifierType::SXM_CHANNEL ||
+ (physically >= IdentifierType::VENDOR_START &&
+ physically <= IdentifierType::VENDOR_END) ||
+ physically > IdentifierType::SXM_CHANNEL);
+ }
+
+ return onCurrentProgramInfoChanged_(info);
+}
+
Return<void> TunerCallbackMock::onProgramListUpdated(const ProgramListChunk& chunk) {
std::lock_guard<std::mutex> lk(mLock);
@@ -142,7 +175,7 @@
EXPECT_EQ(nullptr, mModule.get()) << "Module is already open";
// lookup HIDL service (radio module)
- mModule = getService<IBroadcastRadio>();
+ mModule = getService<IBroadcastRadio>(gEnv->getServiceName<IBroadcastRadio>());
ASSERT_NE(nullptr, mModule.get()) << "Couldn't find broadcast radio HAL implementation";
// get module properties
@@ -385,7 +418,7 @@
// try tuning
ProgramInfo infoCb = {};
- EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged,
+ EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_,
InfoHasId(utils::make_identifier(IdentifierType::AMFM_FREQUENCY, freq)))
.Times(AnyNumber())
.WillOnce(DoAll(SaveArg<0>(&infoCb), testing::Return(ByMove(Void()))));
@@ -399,7 +432,7 @@
// expect a callback if it succeeds
EXPECT_EQ(Result::OK, result);
- EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged, timeout::tune);
+ EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
ALOGD("current program info: %s", toString(infoCb).c_str());
@@ -469,15 +502,15 @@
// TODO(b/69958777): see FmTune workaround
std::this_thread::sleep_for(100ms);
- EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged, _);
+ EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _);
auto result = mSession->scan(true /* up */, true /* skip subchannel */);
EXPECT_EQ(Result::OK, result);
- EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged, timeout::tune);
+ EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
- EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged, _);
+ EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _);
result = mSession->scan(false /* down */, false /* don't skip subchannel */);
EXPECT_EQ(Result::OK, result);
- EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged, timeout::tune);
+ EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
}
/**
@@ -494,19 +527,19 @@
// TODO(b/69958777): see FmTune workaround
std::this_thread::sleep_for(100ms);
- EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged, _).Times(AnyNumber());
+ EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _).Times(AnyNumber());
auto result = mSession->step(true /* up */);
if (result == Result::NOT_SUPPORTED) {
printSkipped("step not supported");
return;
}
EXPECT_EQ(Result::OK, result);
- EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged, timeout::tune);
+ EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
- EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged, _);
+ EXPECT_TIMEOUT_CALL(*mCallback, onCurrentProgramInfoChanged_, _);
result = mSession->step(false /* down */);
EXPECT_EQ(Result::OK, result);
- EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged, timeout::tune);
+ EXPECT_TIMEOUT_CALL_WAIT(*mCallback, onCurrentProgramInfoChanged_, timeout::tune);
}
/**
@@ -768,9 +801,6 @@
closeHandle->close();
}
-// TODO(b/70939328): test ProgramInfo's currentlyTunedId and
-// currentlyTunedChannel once the program list is implemented.
-
} // namespace vts
} // namespace V2_0
} // namespace broadcastradio
@@ -778,7 +808,13 @@
} // namespace android
int main(int argc, char** argv) {
+ using android::hardware::broadcastradio::V2_0::vts::gEnv;
+ using android::hardware::broadcastradio::V2_0::IBroadcastRadio;
+ using android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
+ gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadio>;
+ ::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
diff --git a/broadcastradio/common/utils1x/include/broadcastradio-utils-1x/Utils.h b/broadcastradio/common/utils1x/include/broadcastradio-utils-1x/Utils.h
index 8ad7109..d47746d 100644
--- a/broadcastradio/common/utils1x/include/broadcastradio-utils-1x/Utils.h
+++ b/broadcastradio/common/utils1x/include/broadcastradio-utils-1x/Utils.h
@@ -29,7 +29,6 @@
enum class HalRevision : uint32_t {
V1_0 = 1,
V1_1,
- V1_2, // TODO(b/62945293): remove
};
/**
diff --git a/broadcastradio/common/vts/utils/Android.bp b/broadcastradio/common/vts/utils/Android.bp
index 4ba8a17..d3edc76 100644
--- a/broadcastradio/common/vts/utils/Android.bp
+++ b/broadcastradio/common/vts/utils/Android.bp
@@ -25,4 +25,8 @@
"-Wextra",
"-Werror",
],
+ static_libs: [
+ "VtsHalHidlTargetTestBase",
+ ],
+ group_static_libs: true,
}
diff --git a/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/environment-utils.h b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/environment-utils.h
new file mode 100644
index 0000000..274e632
--- /dev/null
+++ b/broadcastradio/common/vts/utils/include/broadcastradio-vts-utils/environment-utils.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 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_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
+#define ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
+
+#include <VtsHalHidlTargetTestEnvBase.h>
+
+namespace android {
+namespace hardware {
+namespace broadcastradio {
+namespace vts {
+
+// Test environment for BroadcastRadio HIDL HAL.
+template <typename... T>
+class BroadcastRadioHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ virtual void registerTestServices() override {
+ using expander = int[];
+ (void)expander{0, (registerTestService<T>(), 0)...};
+ }
+};
+
+} // namespace vts
+} // namespace broadcastradio
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
diff --git a/camera/device/3.4/ICameraDeviceSession.hal b/camera/device/3.4/ICameraDeviceSession.hal
index 7afcf94..c41d90e 100644
--- a/camera/device/3.4/ICameraDeviceSession.hal
+++ b/camera/device/3.4/ICameraDeviceSession.hal
@@ -31,43 +31,6 @@
interface ICameraDeviceSession extends @3.3::ICameraDeviceSession {
/**
- * constructDefaultRequestSettings_3_4:
- *
- * Create capture settings for standard camera use cases. Supports the
- * new template enums added in @3.4.
- *
- * The device must return a settings buffer that is configured to meet the
- * requested use case, which must be one of the CAMERA3_TEMPLATE_*
- * enums. All request control fields must be included.
- *
- * Performance requirements:
- *
- * This must be a non-blocking call. The HAL should return from this call
- * in 1ms, and must return from this call in 5ms.
- *
- * Return values:
- * @return status Status code for the operation, one of:
- * OK:
- * On a successful construction of default settings.
- * INTERNAL_ERROR:
- * An unexpected internal error occurred, and the default settings
- * are not available.
- * ILLEGAL_ARGUMENT:
- * The camera HAL does not support the input template type
- * CAMERA_DISCONNECTED:
- * An external camera device has been disconnected, and is no longer
- * available. This camera device interface is now stale, and a new
- * instance must be acquired if the device is reconnected. All
- * subsequent calls on this interface must return
- * CAMERA_DISCONNECTED.
- * @return requestTemplate The default capture request settings for the requested
- * use case, or an empty metadata structure if status is not OK.
- *
- */
- constructDefaultRequestSettings_3_4(RequestTemplate type) generates
- (Status status, @3.2::CameraMetadata requestTemplate);
-
- /**
* configureStreams_3_4:
*
* Identical to @3.3::ICameraDeviceSession.configureStreams, except that:
diff --git a/camera/device/3.4/default/CameraDeviceSession.cpp b/camera/device/3.4/default/CameraDeviceSession.cpp
index f6c6b2b..bb4886d 100644
--- a/camera/device/3.4/default/CameraDeviceSession.cpp
+++ b/camera/device/3.4/default/CameraDeviceSession.cpp
@@ -56,14 +56,6 @@
CameraDeviceSession::~CameraDeviceSession() {
}
-Return<void> CameraDeviceSession::constructDefaultRequestSettings_3_4(
- RequestTemplate type, ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) {
- V3_2::CameraMetadata outMetadata;
- Status status = constructDefaultRequestSettingsRaw( (int) type, &outMetadata);
- _hidl_cb(status, outMetadata);
- return Void();
-}
-
Return<void> CameraDeviceSession::configureStreams_3_4(
const StreamConfiguration& requestedConfiguration,
ICameraDeviceSession::configureStreams_3_4_cb _hidl_cb) {
@@ -378,7 +370,7 @@
for (size_t i = 0; i < settingsCount; i++) {
uint64_t settingsSize = request.physicalCameraSettings[i].fmqSettingsSize;
- const camera_metadata_t *settings;
+ const camera_metadata_t *settings = nullptr;
if (settingsSize > 0) {
physicalFmq.push_back(V3_2::CameraMetadata(settingsSize));
bool read = mRequestMetadataQueue->read(physicalFmq[i].data(), settingsSize);
@@ -400,6 +392,13 @@
ALOGE("%s: physical camera settings metadata is corrupt!", __FUNCTION__);
return Status::ILLEGAL_ARGUMENT;
}
+
+ if (mFirstRequest && settings == nullptr) {
+ ALOGE("%s: Individual request settings must not be null for first request!",
+ __FUNCTION__);
+ return Status::ILLEGAL_ARGUMENT;
+ }
+
physicalCameraIds.push_back(request.physicalCameraSettings[i].physicalCameraId.c_str());
}
}
diff --git a/camera/device/3.4/default/ExternalCameraDevice.cpp b/camera/device/3.4/default/ExternalCameraDevice.cpp
index 569acfd..b6470f5 100644
--- a/camera/device/3.4/default/ExternalCameraDevice.cpp
+++ b/camera/device/3.4/default/ExternalCameraDevice.cpp
@@ -44,9 +44,10 @@
} // anonymous namespace
-ExternalCameraDevice::ExternalCameraDevice(const std::string& cameraId) :
+ExternalCameraDevice::ExternalCameraDevice(
+ const std::string& cameraId, const ExternalCameraConfig& cfg) :
mCameraId(cameraId),
- mCfg(ExternalCameraDeviceConfig::loadFromCfg()) {
+ mCfg(cfg) {
status_t ret = initCameraCharacteristics();
if (ret != OK) {
@@ -594,16 +595,19 @@
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT);
}
- int64_t min_frame_duration = std::numeric_limits<int64_t>::max();
- for (const auto& frameRate : supportedFormat.frameRates) {
- int64_t frame_duration = 1000000000LL / frameRate;
- if (frame_duration < min_frame_duration) {
- min_frame_duration = frame_duration;
+ int64_t minFrameDuration = std::numeric_limits<int64_t>::max();
+ for (const auto& fr : supportedFormat.frameRates) {
+ // 1000000000LL < (2^32 - 1) and
+ // fr.durationNumerator is uint32_t, so no overflow here
+ int64_t frameDuration = 1000000000LL * fr.durationNumerator /
+ fr.durationDenominator;
+ if (frameDuration < minFrameDuration) {
+ minFrameDuration = frameDuration;
}
- if (frame_duration > maxFrameDuration) {
- maxFrameDuration = frame_duration;
+ if (frameDuration > maxFrameDuration) {
+ maxFrameDuration = frameDuration;
}
- int32_t frameRateInt = static_cast<int32_t>(frameRate);
+ int32_t frameRateInt = static_cast<int32_t>(fr.getDouble());
if (minFps > frameRateInt) {
minFps = frameRateInt;
}
@@ -617,7 +621,7 @@
minFrameDurations.push_back(format);
minFrameDurations.push_back(supportedFormat.width);
minFrameDurations.push_back(supportedFormat.height);
- minFrameDurations.push_back(min_frame_duration);
+ minFrameDurations.push_back(minFrameDuration);
}
// The stall duration is 0 for non-jpeg formats. For JPEG format, stall
@@ -704,8 +708,10 @@
++frameInterval.index) {
if (frameInterval.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
if (frameInterval.discrete.numerator != 0) {
- float framerate = frameInterval.discrete.denominator /
- static_cast<float>(frameInterval.discrete.numerator);
+ SupportedV4L2Format::FrameRate fr = {
+ frameInterval.discrete.numerator,
+ frameInterval.discrete.denominator};
+ double framerate = fr.getDouble();
if (framerate > fpsUpperBound) {
continue;
}
@@ -716,7 +722,7 @@
(frameInterval.pixel_format >> 16) & 0xFF,
(frameInterval.pixel_format >> 24) & 0xFF,
frameInterval.width, frameInterval.height, framerate);
- format->frameRates.push_back(framerate);
+ format->frameRates.push_back(fr);
}
}
}
diff --git a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
index 51bfe36..d6d9ff8 100644
--- a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
+++ b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
@@ -55,7 +55,7 @@
ExternalCameraDeviceSession::ExternalCameraDeviceSession(
const sp<ICameraDeviceCallback>& callback,
- const ExternalCameraDeviceConfig& cfg,
+ const ExternalCameraConfig& cfg,
const std::vector<SupportedV4L2Format>& sortedFormats,
const CroppingType& croppingType,
const common::V1_0::helper::CameraMetadata& chars,
@@ -133,15 +133,6 @@
return Void();
}
-Return<void> ExternalCameraDeviceSession::constructDefaultRequestSettings_3_4(
- RequestTemplate type,
- ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) {
- V3_2::CameraMetadata outMetadata;
- Status status = constructDefaultRequestSettingsRaw(type, &outMetadata);
- _hidl_cb(status, outMetadata);
- return Void();
-}
-
Status ExternalCameraDeviceSession::constructDefaultRequestSettingsRaw(RequestTemplate type,
V3_2::CameraMetadata *outMetadata) {
CameraMetadata emptyMd;
@@ -160,9 +151,7 @@
}
case RequestTemplate::MANUAL:
case RequestTemplate::ZERO_SHUTTER_LAG:
- case RequestTemplate::MOTION_TRACKING_PREVIEW:
- case RequestTemplate::MOTION_TRACKING_BEST:
- // Don't support MANUAL, ZSL, MOTION_TRACKING_* templates
+ // Don't support MANUAL, ZSL templates
status = Status::ILLEGAL_ARGUMENT;
break;
default:
@@ -281,6 +270,12 @@
}
Return<Status> ExternalCameraDeviceSession::flush() {
+ Mutex::Autolock _il(mInterfaceLock);
+ Status status = initStatus();
+ if (status != Status::OK) {
+ return status;
+ }
+ mOutputThread->flush();
return Status::OK;
}
@@ -492,7 +487,7 @@
}
//TODO: refactor with processCaptureResult
-Status ExternalCameraDeviceSession::processCaptureRequestError(HalRequest& req) {
+Status ExternalCameraDeviceSession::processCaptureRequestError(const HalRequest& req) {
// Return V4L2 buffer to V4L2 buffer queue
enqueueV4l2Frame(req.frameIn);
@@ -1494,19 +1489,23 @@
return true;
}
+ auto onDeviceError = [&](auto... args) {
+ ALOGE(args...);
+ parent->notifyError(
+ req.frameNumber, /*stream*/-1, ErrorCode::ERROR_DEVICE);
+ signalRequestDone();
+ return false;
+ };
+
if (req.frameIn->mFourcc != V4L2_PIX_FMT_MJPEG) {
- ALOGE("%s: do not support V4L2 format %c%c%c%c", __FUNCTION__,
+ return onDeviceError("%s: do not support V4L2 format %c%c%c%c", __FUNCTION__,
req.frameIn->mFourcc & 0xFF,
(req.frameIn->mFourcc >> 8) & 0xFF,
(req.frameIn->mFourcc >> 16) & 0xFF,
(req.frameIn->mFourcc >> 24) & 0xFF);
- parent->notifyError(
- /*frameNum*/req.frameNumber, /*stream*/-1, ErrorCode::ERROR_DEVICE);
- return false;
}
- std::unique_lock<std::mutex> lk(mLock);
-
+ std::unique_lock<std::mutex> lk(mBufferLock);
// Convert input V4L2 frame to YU12 of the same size
// TODO: see if we can save some computation by converting to YV12 here
uint8_t* inData;
@@ -1531,11 +1530,9 @@
lk.unlock();
Status st = parent->processCaptureRequestError(req);
if (st != Status::OK) {
- ALOGE("%s: failed to process capture request error!", __FUNCTION__);
- parent->notifyError(
- /*frameNum*/req.frameNumber, /*stream*/-1, ErrorCode::ERROR_DEVICE);
- return false;
+ return onDeviceError("%s: failed to process capture request error!", __FUNCTION__);
}
+ signalRequestDone();
return true;
}
@@ -1562,15 +1559,9 @@
int ret = createJpegLocked(halBuf, req);
if(ret != 0) {
- ALOGE("%s: createJpegLocked failed with %d",
- __FUNCTION__, ret);
lk.unlock();
- parent->notifyError(
- /*frameNum*/req.frameNumber,
- /*stream*/-1,
- ErrorCode::ERROR_DEVICE);
-
- return false;
+ return onDeviceError("%s: createJpegLocked failed with %d",
+ __FUNCTION__, ret);
}
} break;
case PixelFormat::YCBCR_420_888:
@@ -1598,21 +1589,15 @@
Size { halBuf.width, halBuf.height },
&cropAndScaled);
if (ret != 0) {
- ALOGE("%s: crop and scale failed!", __FUNCTION__);
lk.unlock();
- parent->notifyError(
- /*frameNum*/req.frameNumber, /*stream*/-1, ErrorCode::ERROR_DEVICE);
- return false;
+ return onDeviceError("%s: crop and scale failed!", __FUNCTION__);
}
Size sz {halBuf.width, halBuf.height};
ret = formatConvertLocked(cropAndScaled, outLayout, sz, outputFourcc);
if (ret != 0) {
- ALOGE("%s: format coversion failed!", __FUNCTION__);
lk.unlock();
- parent->notifyError(
- /*frameNum*/req.frameNumber, /*stream*/-1, ErrorCode::ERROR_DEVICE);
- return false;
+ return onDeviceError("%s: format coversion failed!", __FUNCTION__);
}
int relFence = sHandleImporter.unlock(*(halBuf.bufPtr));
if (relFence > 0) {
@@ -1620,11 +1605,8 @@
}
} break;
default:
- ALOGE("%s: unknown output format %x", __FUNCTION__, halBuf.format);
lk.unlock();
- parent->notifyError(
- /*frameNum*/req.frameNumber, /*stream*/-1, ErrorCode::ERROR_DEVICE);
- return false;
+ return onDeviceError("%s: unknown output format %x", __FUNCTION__, halBuf.format);
}
} // for each buffer
mScaledYu12Frames.clear();
@@ -1633,18 +1615,16 @@
lk.unlock();
Status st = parent->processCaptureResult(req);
if (st != Status::OK) {
- ALOGE("%s: failed to process capture result!", __FUNCTION__);
- parent->notifyError(
- /*frameNum*/req.frameNumber, /*stream*/-1, ErrorCode::ERROR_DEVICE);
- return false;
+ return onDeviceError("%s: failed to process capture result!", __FUNCTION__);
}
+ signalRequestDone();
return true;
}
Status ExternalCameraDeviceSession::OutputThread::allocateIntermediateBuffers(
const Size& v4lSize, const Size& thumbSize,
const hidl_vec<Stream>& streams) {
- std::lock_guard<std::mutex> lk(mLock);
+ std::lock_guard<std::mutex> lk(mBufferLock);
if (mScaledYu12Frames.size() != 0) {
ALOGE("%s: intermediate buffer pool has %zu inflight buffers! (expect 0)",
__FUNCTION__, mScaledYu12Frames.size());
@@ -1716,17 +1696,36 @@
}
Status ExternalCameraDeviceSession::OutputThread::submitRequest(const HalRequest& req) {
- std::lock_guard<std::mutex> lk(mLock);
+ std::unique_lock<std::mutex> lk(mRequestListLock);
// TODO: reduce object copy in this path
mRequestList.push_back(req);
+ lk.unlock();
mRequestCond.notify_one();
return Status::OK;
}
void ExternalCameraDeviceSession::OutputThread::flush() {
- std::lock_guard<std::mutex> lk(mLock);
- // TODO: send buffer/request errors back to framework
+ auto parent = mParent.promote();
+ if (parent == nullptr) {
+ ALOGE("%s: session has been disconnected!", __FUNCTION__);
+ return;
+ }
+
+ std::unique_lock<std::mutex> lk(mRequestListLock);
+ std::list<HalRequest> reqs = mRequestList;
mRequestList.clear();
+ if (mProcessingRequest) {
+ std::chrono::seconds timeout = std::chrono::seconds(kReqWaitTimeoutSec);
+ auto st = mRequestDoneCond.wait_for(lk, timeout);
+ if (st == std::cv_status::timeout) {
+ ALOGE("%s: wait for inflight request finish timeout!", __FUNCTION__);
+ }
+ }
+
+ lk.unlock();
+ for (const auto& req : reqs) {
+ parent->processCaptureRequestError(req);
+ }
}
void ExternalCameraDeviceSession::OutputThread::waitForNextRequest(HalRequest* out) {
@@ -1735,7 +1734,7 @@
return;
}
- std::unique_lock<std::mutex> lk(mLock);
+ std::unique_lock<std::mutex> lk(mRequestListLock);
while (mRequestList.empty()) {
std::chrono::seconds timeout = std::chrono::seconds(kReqWaitTimeoutSec);
auto st = mRequestCond.wait_for(lk, timeout);
@@ -1746,6 +1745,14 @@
}
*out = mRequestList.front();
mRequestList.pop_front();
+ mProcessingRequest = true;
+}
+
+void ExternalCameraDeviceSession::OutputThread::signalRequestDone() {
+ std::unique_lock<std::mutex> lk(mRequestListLock);
+ mProcessingRequest = false;
+ lk.unlock();
+ mRequestDoneCond.notify_one();
}
void ExternalCameraDeviceSession::cleanupBuffersLocked(int id) {
@@ -1904,7 +1911,8 @@
float fps = 1000.f;
const float kDefaultFps = 30.f;
// Try to pick the slowest fps that is at least 30
- for (const auto& f : v4l2Fmt.frameRates) {
+ for (const auto& fr : v4l2Fmt.frameRates) {
+ double f = fr.getDouble();
if (maxFps < f) {
maxFps = f;
}
@@ -2067,8 +2075,8 @@
{
std::lock_guard<std::mutex> lk(mV4l2BufferLock);
mNumDequeuedV4l2Buffers--;
- mV4L2BufferReturned.notify_one();
}
+ mV4L2BufferReturned.notify_one();
}
Status ExternalCameraDeviceSession::configureStreams(
@@ -2346,8 +2354,8 @@
bool support30Fps = false;
int32_t maxFps = std::numeric_limits<int32_t>::min();
for (const auto& supportedFormat : mSupportedFormats) {
- for (const auto& frameRate : supportedFormat.frameRates) {
- int32_t framerateInt = static_cast<int32_t>(frameRate);
+ for (const auto& fr : supportedFormat.frameRates) {
+ int32_t framerateInt = static_cast<int32_t>(fr.getDouble());
if (maxFps < framerateInt) {
maxFps = framerateInt;
}
diff --git a/camera/device/3.4/default/ExternalCameraUtils.cpp b/camera/device/3.4/default/ExternalCameraUtils.cpp
index 212573a..d28a4dd 100644
--- a/camera/device/3.4/default/ExternalCameraUtils.cpp
+++ b/camera/device/3.4/default/ExternalCameraUtils.cpp
@@ -30,14 +30,6 @@
namespace V3_4 {
namespace implementation {
-namespace {
- const int kDefaultJpegBufSize = 5 << 20; // 5MB
- const int kDefaultNumVideoBuffer = 4;
- const int kDefaultNumStillBuffer = 2;
-} // anonymous namespace
-
-const char* ExternalCameraDeviceConfig::kDefaultCfgPath = "/vendor/etc/external_camera_config.xml";
-
V4L2Frame::V4L2Frame(
uint32_t w, uint32_t h, uint32_t fourcc,
int bufIdx, int fd, uint32_t dataSize, uint64_t offset) :
@@ -148,10 +140,36 @@
return 0;
}
+bool isAspectRatioClose(float ar1, float ar2) {
+ const float kAspectRatioMatchThres = 0.025f; // This threshold is good enough to distinguish
+ // 4:3/16:9/20:9
+ // 1.33 / 1.78 / 2
+ return (std::abs(ar1 - ar2) < kAspectRatioMatchThres);
+}
-ExternalCameraDeviceConfig ExternalCameraDeviceConfig::loadFromCfg(const char* cfgPath) {
+double SupportedV4L2Format::FrameRate::getDouble() const {
+ return durationDenominator / static_cast<double>(durationNumerator);
+}
+
+} // namespace implementation
+} // namespace V3_4
+} // namespace device
+
+
+namespace external {
+namespace common {
+
+namespace {
+ const int kDefaultJpegBufSize = 5 << 20; // 5MB
+ const int kDefaultNumVideoBuffer = 4;
+ const int kDefaultNumStillBuffer = 2;
+} // anonymous namespace
+
+const char* ExternalCameraConfig::kDefaultCfgPath = "/vendor/etc/external_camera_config.xml";
+
+ExternalCameraConfig ExternalCameraConfig::loadFromCfg(const char* cfgPath) {
using namespace tinyxml2;
- ExternalCameraDeviceConfig ret;
+ ExternalCameraConfig ret;
XMLDocument configXml;
XMLError err = configXml.LoadFile(cfgPath);
@@ -169,6 +187,29 @@
return ret;
}
+ XMLElement *providerCfg = extCam->FirstChildElement("Provider");
+ if (providerCfg == nullptr) {
+ ALOGI("%s: no external camera provider config specified", __FUNCTION__);
+ return ret;
+ }
+
+ XMLElement *ignore = providerCfg->FirstChildElement("ignore");
+ if (ignore == nullptr) {
+ ALOGI("%s: no internal ignored device specified", __FUNCTION__);
+ return ret;
+ }
+
+ XMLElement *id = ignore->FirstChildElement("id");
+ while (id != nullptr) {
+ const char* text = id->GetText();
+ if (text != nullptr) {
+ ret.mInternalDevices.insert(text);
+ ALOGI("%s: device %s will be ignored by external camera provider",
+ __FUNCTION__, text);
+ }
+ id = id->NextSiblingElement("id");
+ }
+
XMLElement *deviceCfg = extCam->FirstChildElement("Device");
if (deviceCfg == nullptr) {
ALOGI("%s: no external camera device config specified", __FUNCTION__);
@@ -210,7 +251,7 @@
limit.size = {
row->UnsignedAttribute("width", /*Default*/0),
row->UnsignedAttribute("height", /*Default*/0)};
- limit.fpsUpperBound = row->FloatAttribute("fpsBound", /*Default*/1000.0);
+ limit.fpsUpperBound = row->DoubleAttribute("fpsBound", /*Default*/1000.0);
if (limit.size.width <= prevLimit.size.width ||
limit.size.height <= prevLimit.size.height ||
limit.fpsUpperBound >= prevLimit.fpsUpperBound) {
@@ -226,7 +267,7 @@
ret.fpsLimits = limits;
}
- ALOGI("%s: external camera cfd loaded: maxJpgBufSize %d,"
+ ALOGI("%s: external camera cfg loaded: maxJpgBufSize %d,"
" num video buffers %d, num still buffers %d",
__FUNCTION__, ret.maxJpegBufSize,
ret.numVideoBuffers, ret.numStillBuffers);
@@ -237,7 +278,7 @@
return ret;
}
-ExternalCameraDeviceConfig::ExternalCameraDeviceConfig() :
+ExternalCameraConfig::ExternalCameraConfig() :
maxJpegBufSize(kDefaultJpegBufSize),
numVideoBuffers(kDefaultNumVideoBuffer),
numStillBuffers(kDefaultNumStillBuffer) {
@@ -247,16 +288,9 @@
fpsLimits.push_back({/*Size*/{4096, 3072}, /*FPS upper bound*/5.0});
}
-bool isAspectRatioClose(float ar1, float ar2) {
- const float kAspectRatioMatchThres = 0.025f; // This threshold is good enough to distinguish
- // 4:3/16:9/20:9
- // 1.33 / 1.78 / 2
- return (std::abs(ar1 - ar2) < kAspectRatioMatchThres);
-}
-} // namespace implementation
-} // namespace V3_4
-} // namespace device
+} // namespace common
+} // namespace external
} // namespace camera
} // namespace hardware
} // namespace android
diff --git a/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h b/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h
index 9cd7da7..6e90ed4 100644
--- a/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h
+++ b/camera/device/3.4/default/include/device_v3_4_impl/CameraDeviceSession.h
@@ -74,11 +74,6 @@
protected:
// Methods from v3.3 and earlier will trampoline to inherited implementation
- // New methods for v3.4
- Return<void> constructDefaultRequestSettings_3_4(
- RequestTemplate type,
- ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb);
-
Return<void> configureStreams_3_4(
const StreamConfiguration& requestedConfiguration,
ICameraDeviceSession::configureStreams_3_4_cb _hidl_cb);
@@ -163,12 +158,6 @@
return mParent->close();
}
- virtual Return<void> constructDefaultRequestSettings_3_4(
- RequestTemplate type,
- ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) override {
- return mParent->constructDefaultRequestSettings_3_4(type, _hidl_cb);
- }
-
virtual Return<void> configureStreams_3_3(
const V3_2::StreamConfiguration& requestedConfiguration,
configureStreams_3_3_cb _hidl_cb) override {
diff --git a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h
index fabf26a..43656c8 100644
--- a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h
+++ b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDeviceSession.h
@@ -53,7 +53,7 @@
using ::android::hardware::camera::device::V3_2::ICameraDeviceCallback;
using ::android::hardware::camera::device::V3_2::MsgType;
using ::android::hardware::camera::device::V3_2::NotifyMsg;
-using ::android::hardware::camera::device::V3_4::RequestTemplate;
+using ::android::hardware::camera::device::V3_2::RequestTemplate;
using ::android::hardware::camera::device::V3_2::Stream;
using ::android::hardware::camera::device::V3_4::StreamConfiguration;
using ::android::hardware::camera::device::V3_2::StreamConfigurationMode;
@@ -67,6 +67,9 @@
using ::android::hardware::camera::common::V1_0::Status;
using ::android::hardware::camera::common::V1_0::helper::HandleImporter;
using ::android::hardware::camera::common::V1_0::helper::ExifUtils;
+using ::android::hardware::camera::external::common::ExternalCameraConfig;
+using ::android::hardware::camera::external::common::Size;
+using ::android::hardware::camera::external::common::SizeHasher;
using ::android::hardware::graphics::common::V1_0::BufferUsage;
using ::android::hardware::graphics::common::V1_0::Dataspace;
using ::android::hardware::graphics::common::V1_0::PixelFormat;
@@ -84,7 +87,7 @@
struct ExternalCameraDeviceSession : public virtual RefBase {
ExternalCameraDeviceSession(const sp<ICameraDeviceCallback>&,
- const ExternalCameraDeviceConfig& cfg,
+ const ExternalCameraConfig& cfg,
const std::vector<SupportedV4L2Format>& sortedFormats,
const CroppingType& croppingType,
const common::V1_0::helper::CameraMetadata& chars,
@@ -110,11 +113,7 @@
// Methods from ::android::hardware::camera::device::V3_2::ICameraDeviceSession follow
Return<void> constructDefaultRequestSettings(
- V3_2::RequestTemplate,
- ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb);
-
- Return<void> constructDefaultRequestSettings_3_4(
- RequestTemplate type,
+ RequestTemplate,
ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb);
Return<void> configureStreams(
@@ -200,7 +199,7 @@
Status processOneCaptureRequest(const CaptureRequest& request);
Status processCaptureResult(HalRequest&);
- Status processCaptureRequestError(HalRequest&);
+ Status processCaptureRequestError(const HalRequest&);
void notifyShutter(uint32_t frameNumber, nsecs_t shutterTs);
void notifyError(uint32_t frameNumber, int32_t streamId, ErrorCode ec);
void invokeProcessCaptureResultCallback(
@@ -236,6 +235,8 @@
static const int kReqWaitTimeoutSec = 3;
void waitForNextRequest(HalRequest* out);
+ void signalRequestDone();
+
int cropAndScaleLocked(
sp<AllocatedFrame>& in, const Size& outSize,
YCbCrLayout* out);
@@ -255,15 +256,20 @@
int createJpegLocked(HalStreamBuffer &halBuf, HalRequest &req);
- mutable std::mutex mLock;
- std::condition_variable mRequestCond;
- wp<ExternalCameraDeviceSession> mParent;
- CroppingType mCroppingType;
+ const wp<ExternalCameraDeviceSession> mParent;
+ const CroppingType mCroppingType;
+
+ mutable std::mutex mRequestListLock; // Protect acccess to mRequestList
+ std::condition_variable mRequestCond; // signaled when a new request is submitted
+ std::condition_variable mRequestDoneCond; // signaled when a request is done processing
std::list<HalRequest> mRequestList;
+ bool mProcessingRequest = false;
+
// V4L2 frameIn
// (MJPG decode)-> mYu12Frame
// (Scale)-> mScaledYu12Frames
// (Format convert) -> output gralloc frames
+ mutable std::mutex mBufferLock; // Protect access to intermediate buffers
sp<AllocatedFrame> mYu12Frame;
sp<AllocatedFrame> mYu12ThumbFrame;
std::unordered_map<Size, sp<AllocatedFrame>, SizeHasher> mIntermediateBuffers;
@@ -277,7 +283,7 @@
mutable Mutex mLock; // Protect all private members except otherwise noted
const sp<ICameraDeviceCallback> mCallback;
- const ExternalCameraDeviceConfig mCfg;
+ const ExternalCameraConfig& mCfg;
const common::V1_0::helper::CameraMetadata mCameraCharacteristics;
const std::vector<SupportedV4L2Format> mSupportedFormats;
const CroppingType mCroppingType;
@@ -293,13 +299,14 @@
bool mV4l2Streaming = false;
SupportedV4L2Format mV4l2StreamingFmt;
- size_t mV4L2BufferCount;
+ size_t mV4L2BufferCount = 0;
static const int kBufferWaitTimeoutSec = 3; // TODO: handle long exposure (or not allowing)
std::mutex mV4l2BufferLock; // protect the buffer count and condition below
std::condition_variable mV4L2BufferReturned;
size_t mNumDequeuedV4l2Buffers = 0;
+ // Not protected by mLock (but might be used when mLock is locked)
sp<OutputThread> mOutputThread;
// Stream ID -> Camera3Stream cache
@@ -341,7 +348,7 @@
mParent(parent) {}
virtual Return<void> constructDefaultRequestSettings(
- V3_2::RequestTemplate type,
+ RequestTemplate type,
V3_3::ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) override {
return mParent->constructDefaultRequestSettings(type, _hidl_cb);
}
@@ -376,12 +383,6 @@
return mParent->close();
}
- virtual Return<void> constructDefaultRequestSettings_3_4(
- RequestTemplate type,
- ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) override {
- return mParent->constructDefaultRequestSettings_3_4(type, _hidl_cb);
- }
-
virtual Return<void> configureStreams_3_3(
const V3_2::StreamConfiguration& requestedConfiguration,
configureStreams_3_3_cb _hidl_cb) override {
diff --git a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h
index ef4b41c..5880469 100644
--- a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h
+++ b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraDevice_3_4.h
@@ -38,6 +38,8 @@
using ::android::hardware::camera::common::V1_0::CameraResourceCost;
using ::android::hardware::camera::common::V1_0::TorchMode;
using ::android::hardware::camera::common::V1_0::Status;
+using ::android::hardware::camera::external::common::ExternalCameraConfig;
+using ::android::hardware::camera::external::common::Size;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
@@ -54,7 +56,7 @@
// be multiple CameraDevice trying to access the same physical camera. Also, provider will have
// to keep track of all CameraDevice objects in order to notify CameraDevice when the underlying
// camera is detached.
- ExternalCameraDevice(const std::string& cameraId);
+ ExternalCameraDevice(const std::string& cameraId, const ExternalCameraConfig& cfg);
~ExternalCameraDevice();
// Caller must use this method to check if CameraDevice ctor failed
@@ -95,7 +97,7 @@
Mutex mLock;
bool mInitFailed = false;
std::string mCameraId;
- const ExternalCameraDeviceConfig mCfg;
+ const ExternalCameraConfig& mCfg;
std::vector<SupportedV4L2Format> mSupportedFormats;
CroppingType mCroppingType;
diff --git a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraUtils.h b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraUtils.h
index 849f947..37e7cfb 100644
--- a/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraUtils.h
+++ b/camera/device/3.4/default/include/ext_device_v3_4_impl/ExternalCameraUtils.h
@@ -21,6 +21,7 @@
#include "utils/LightRefBase.h"
#include <mutex>
#include <vector>
+#include <unordered_set>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
using android::hardware::graphics::mapper::V2_0::IMapper;
@@ -29,6 +30,60 @@
namespace android {
namespace hardware {
namespace camera {
+
+namespace external {
+namespace common {
+
+struct Size {
+ uint32_t width;
+ uint32_t height;
+
+ bool operator==(const Size& other) const {
+ return (width == other.width && height == other.height);
+ }
+};
+
+struct SizeHasher {
+ size_t operator()(const Size& sz) const {
+ size_t result = 1;
+ result = 31 * result + sz.width;
+ result = 31 * result + sz.height;
+ return result;
+ }
+};
+
+struct ExternalCameraConfig {
+ static const char* kDefaultCfgPath;
+ static ExternalCameraConfig loadFromCfg(const char* cfgPath = kDefaultCfgPath);
+
+ // List of internal V4L2 video nodes external camera HAL must ignore.
+ std::unordered_set<std::string> mInternalDevices;
+
+ // Maximal size of a JPEG buffer, in bytes
+ uint32_t maxJpegBufSize;
+
+ // Maximum Size that can sustain 30fps streaming
+ Size maxVideoSize;
+
+ // Size of v4l2 buffer queue when streaming <= kMaxVideoSize
+ uint32_t numVideoBuffers;
+
+ // Size of v4l2 buffer queue when streaming > kMaxVideoSize
+ uint32_t numStillBuffers;
+
+ struct FpsLimitation {
+ Size size;
+ double fpsUpperBound;
+ };
+ std::vector<FpsLimitation> fpsLimits;
+
+private:
+ ExternalCameraConfig();
+};
+
+} // common
+} // external
+
namespace device {
namespace V3_4 {
namespace implementation {
@@ -38,7 +93,12 @@
uint32_t height;
uint32_t fourcc;
// All supported frame rate for this w/h/fourcc combination
- std::vector<float> frameRates;
+ struct FrameRate {
+ uint32_t durationNumerator; // frame duration numerator. Ex: 1
+ uint32_t durationDenominator; // frame duration denominator. Ex: 30
+ double getDouble() const; // FrameRate in double. Ex: 30.0
+ };
+ std::vector<FrameRate> frameRates;
};
// A class provide access to a dequeued V4L2 frame buffer (mostly in MJPG format)
@@ -85,50 +145,6 @@
VERTICAL = 1
};
-struct Size {
- uint32_t width;
- uint32_t height;
-
- bool operator==(const Size& other) const {
- return (width == other.width && height == other.height);
- }
-};
-
-struct SizeHasher {
- size_t operator()(const Size& sz) const {
- size_t result = 1;
- result = 31 * result + sz.width;
- result = 31 * result + sz.height;
- return result;
- }
-};
-
-struct ExternalCameraDeviceConfig {
- static const char* kDefaultCfgPath;
- static ExternalCameraDeviceConfig loadFromCfg(const char* cfgPath = kDefaultCfgPath);
-
- // Maximal size of a JPEG buffer, in bytes
- uint32_t maxJpegBufSize;
-
- // Maximum Size that can sustain 30fps streaming
- Size maxVideoSize;
-
- // Size of v4l2 buffer queue when streaming <= kMaxVideoSize
- uint32_t numVideoBuffers;
-
- // Size of v4l2 buffer queue when streaming > kMaxVideoSize
- uint32_t numStillBuffers;
-
- struct FpsLimitation {
- Size size;
- float fpsUpperBound;
- };
- std::vector<FpsLimitation> fpsLimits;
-
-private:
- ExternalCameraDeviceConfig();
-};
-
// Aspect ratio is defined as width/height here and ExternalCameraDevice
// will guarantee all supported sizes has width >= height (so aspect ratio >= 1.0)
#define ASPECT_RATIO(sz) (static_cast<float>((sz).width) / (sz).height)
diff --git a/camera/device/3.4/types.hal b/camera/device/3.4/types.hal
index c8ebb17..bf2b3fc 100644
--- a/camera/device/3.4/types.hal
+++ b/camera/device/3.4/types.hal
@@ -78,36 +78,6 @@
};
/**
- * New request templates, extending the @3.2 RequestTemplate
- */
-enum RequestTemplate : @3.2::RequestTemplate {
- /**
- * A template for selecting camera parameters that match TEMPLATE_PREVIEW as closely as
- * possible while improving the camera output for motion tracking use cases.
- *
- * This template is best used by applications that are frequently switching between motion
- * tracking use cases and regular still capture use cases, to minimize the IQ changes
- * when swapping use cases.
- *
- * This template is guaranteed to be supported on camera devices that support the
- * REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING capability.
- */
- MOTION_TRACKING_PREVIEW = 7,
-
- /**
- * A template for selecting camera parameters that maximize the quality of camera output for
- * motion tracking use cases.
- *
- * This template is best used by applications dedicated to motion tracking applications,
- * which aren't concerned about fast switches between motion tracking and other use cases.
- *
- * This template is guaranteed to be supported on camera devices that support the
- * REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING capability.
- */
- MOTION_TRACKING_BEST = 8,
-};
-
-/**
* StreamConfiguration:
*
* Identical to @3.2::StreamConfiguration, except that it contains session
@@ -207,9 +177,14 @@
/**
* If fmqSettingsSize is zero, the settings buffer contains the capture and
- * processing parameters for the physical device with id 'phyCamId'.
- * In case the individual settings are empty or missing, Hal should fail the
- * request and return Status::ILLEGAL_ARGUMENT.
+ * processing parameters for the physical device with id 'physicalCameraId'.
+ * As a special case, an empty settings buffer indicates that the
+ * settings are identical to the most-recently submitted capture request.
+ * An empty buffer cannot be used as the first submitted request after
+ * a configureStreams() call.
+ *
+ * This field must be used if fmqSettingsSize is zero. It must not be used
+ * if fmqSettingsSize is non-zero.
*/
CameraMetadata settings;
};
diff --git a/camera/metadata/3.3/types.hal b/camera/metadata/3.3/types.hal
index d2a5886..b70802a 100644
--- a/camera/metadata/3.3/types.hal
+++ b/camera/metadata/3.3/types.hal
@@ -94,7 +94,7 @@
/** android.statistics.oisDataMode [dynamic, enum, public]
*
- * <p>Whether the camera device outputs the OIS data in output
+ * <p>A control for selecting whether OIS position information is included in output
* result metadata.</p>
*/
ANDROID_STATISTICS_OIS_DATA_MODE = android.hardware.camera.metadata@3.2::CameraMetadataTag:ANDROID_STATISTICS_END,
@@ -200,12 +200,12 @@
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA,
};
-/** android.logicalMultiCamera.sensorSyncType enumeration values
- * @see ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE
+/** android.statistics.oisDataMode enumeration values
+ * @see ANDROID_STATISTICS_OIS_DATA_MODE
*/
-enum CameraMetadataEnumAndroidLogicalMultiCameraSensorSyncType : uint32_t {
- ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_APPROXIMATE,
- ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_CALIBRATED,
+enum CameraMetadataEnumAndroidStatisticsOisDataMode : uint32_t {
+ ANDROID_STATISTICS_OIS_DATA_MODE_OFF,
+ ANDROID_STATISTICS_OIS_DATA_MODE_ON,
};
/** android.info.supportedHardwareLevel enumeration values added since v3.2
@@ -216,10 +216,10 @@
ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL,
};
-/** android.statistics.oisDataMode enumeration values
- * @see ANDROID_STATISTICS_OIS_DATA_MODE
+/** android.logicalMultiCamera.sensorSyncType enumeration values
+ * @see ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE
*/
-enum CameraMetadataEnumAndroidStatisticsOisDataMode : uint32_t {
- ANDROID_STATISTICS_OIS_DATA_MODE_OFF,
- ANDROID_STATISTICS_OIS_DATA_MODE_ON,
+enum CameraMetadataEnumAndroidLogicalMultiCameraSensorSyncType : uint32_t {
+ ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_APPROXIMATE,
+ ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_CALIBRATED,
};
diff --git a/camera/provider/2.4/default/ExternalCameraProvider.cpp b/camera/provider/2.4/default/ExternalCameraProvider.cpp
index 7657fa3..faa4e3a 100644
--- a/camera/provider/2.4/default/ExternalCameraProvider.cpp
+++ b/camera/provider/2.4/default/ExternalCameraProvider.cpp
@@ -24,7 +24,6 @@
#include <linux/videodev2.h>
#include "ExternalCameraProvider.h"
#include "ExternalCameraDevice_3_4.h"
-#include "tinyxml2.h" // XML parsing
namespace android {
namespace hardware {
@@ -38,6 +37,8 @@
const std::regex kDeviceNameRE("device@([0-9]+\\.[0-9]+)/external/(.+)");
const int kMaxDevicePathLen = 256;
const char* kDevicePath = "/dev/";
+constexpr char kPrefix[] = "video";
+constexpr int kPrefixLen = sizeof(kPrefix) - 1;
bool matchDeviceName(const hidl_string& deviceName, std::string* deviceVersion,
std::string* cameraId) {
@@ -58,6 +59,7 @@
} // anonymous namespace
ExternalCameraProvider::ExternalCameraProvider() :
+ mCfg(ExternalCameraConfig::loadFromCfg()),
mHotPlugThread(this) {
mHotPlugThread.run("ExtCamHotPlug", PRIORITY_BACKGROUND);
}
@@ -69,8 +71,17 @@
Return<Status> ExternalCameraProvider::setCallback(
const sp<ICameraProviderCallback>& callback) {
- Mutex::Autolock _l(mLock);
- mCallbacks = callback;
+ {
+ Mutex::Autolock _l(mLock);
+ mCallbacks = callback;
+ }
+ // Send a callback for all devices to initialize
+ {
+ for (const auto& pair : mCameraStatusMap) {
+ mCallbacks->cameraDeviceStatusChange(pair.first, pair.second);
+ }
+ }
+
return Status::OK;
}
@@ -82,14 +93,9 @@
}
Return<void> ExternalCameraProvider::getCameraIdList(getCameraIdList_cb _hidl_cb) {
- std::vector<hidl_string> deviceNameList;
- for (auto const& kvPair : mCameraStatusMap) {
- if (kvPair.second == CameraDeviceStatus::PRESENT) {
- deviceNameList.push_back(kvPair.first);
- }
- }
- hidl_vec<hidl_string> hidlDeviceNameList(deviceNameList);
- ALOGV("ExtCam: number of cameras is %zu", deviceNameList.size());
+ // External camera HAL always report 0 camera, and extra cameras
+ // are just reported via cameraDeviceStatusChange callbacks
+ hidl_vec<hidl_string> hidlDeviceNameList;
_hidl_cb(Status::OK, hidlDeviceNameList);
return Void();
}
@@ -130,7 +136,7 @@
sp<device::V3_2::ICameraDevice> device;
sp<device::V3_4::implementation::ExternalCameraDevice> deviceImpl =
new device::V3_4::implementation::ExternalCameraDevice(
- cameraId);
+ cameraId, mCfg);
if (deviceImpl == nullptr || deviceImpl->isInitFailed()) {
ALOGE("%s: camera device %s init failed!", __FUNCTION__, cameraId.c_str());
device = nullptr;
@@ -194,59 +200,10 @@
}
}
-std::unordered_set<std::string>
-ExternalCameraProvider::HotplugThread::initInternalDevices() {
- std::unordered_set<std::string> ret;
- using device::V3_4::implementation::ExternalCameraDeviceConfig;
- const char* configPath = ExternalCameraDeviceConfig::kDefaultCfgPath;
-
- using namespace tinyxml2;
-
- XMLDocument configXml;
- XMLError err = configXml.LoadFile(configPath);
- if (err != XML_SUCCESS) {
- ALOGE("%s: Unable to load external camera config file '%s'. Error: %s",
- __FUNCTION__, configPath, XMLDocument::ErrorIDToName(err));
- } else {
- ALOGI("%s: load external camera config succeed!", __FUNCTION__);
- }
-
- XMLElement *extCam = configXml.FirstChildElement("ExternalCamera");
- if (extCam == nullptr) {
- ALOGI("%s: no external camera config specified", __FUNCTION__);
- return ret;
- }
-
- XMLElement *providerCfg = extCam->FirstChildElement("Provider");
- if (providerCfg == nullptr) {
- ALOGI("%s: no external camera provider config specified", __FUNCTION__);
- return ret;
- }
-
- XMLElement *ignore = providerCfg->FirstChildElement("ignore");
- if (ignore == nullptr) {
- ALOGI("%s: no internal ignored device specified", __FUNCTION__);
- return ret;
- }
-
- XMLElement *id = ignore->FirstChildElement("id");
- while (id != nullptr) {
- const char* text = id->GetText();
- if (text != nullptr) {
- ret.insert(text);
- ALOGI("%s: device %s will be ignored by external camera provider",
- __FUNCTION__, text);
- }
- id = id->NextSiblingElement("id");
- }
-
- return ret;
-}
-
ExternalCameraProvider::HotplugThread::HotplugThread(ExternalCameraProvider* parent) :
Thread(/*canCallJava*/false),
mParent(parent),
- mInternalDevices(initInternalDevices()) {}
+ mInternalDevices(parent->mCfg.mInternalDevices) {}
ExternalCameraProvider::HotplugThread::~HotplugThread() {}
@@ -261,10 +218,10 @@
struct dirent* de;
while ((de = readdir(devdir)) != 0) {
// Find external v4l devices that's existing before we start watching and add them
- if (!strncmp("video", de->d_name, 5)) {
+ if (!strncmp(kPrefix, de->d_name, kPrefixLen)) {
// TODO: This might reject some valid devices. Ex: internal is 33 and a device named 3
// is added.
- std::string deviceId(de->d_name + 5);
+ std::string deviceId(de->d_name + kPrefixLen);
if (mInternalDevices.count(deviceId) == 0) {
ALOGV("Non-internal v4l device %s found", de->d_name);
char v4l2DevicePath[kMaxDevicePathLen];
@@ -300,8 +257,8 @@
while (offset < ret) {
struct inotify_event* event = (struct inotify_event*)&eventBuf[offset];
if (event->wd == mWd) {
- if (!strncmp("video", event->name, 5)) {
- std::string deviceId(event->name + 5);
+ if (!strncmp(kPrefix, event->name, kPrefixLen)) {
+ std::string deviceId(event->name + kPrefixLen);
if (mInternalDevices.count(deviceId) == 0) {
char v4l2DevicePath[kMaxDevicePathLen];
snprintf(v4l2DevicePath, kMaxDevicePathLen,
diff --git a/camera/provider/2.4/default/ExternalCameraProvider.h b/camera/provider/2.4/default/ExternalCameraProvider.h
index 64a8878..c83cc70 100644
--- a/camera/provider/2.4/default/ExternalCameraProvider.h
+++ b/camera/provider/2.4/default/ExternalCameraProvider.h
@@ -25,6 +25,7 @@
#include <android/hardware/camera/provider/2.4/ICameraProvider.h>
#include <hidl/Status.h>
#include <hidl/MQDescriptor.h>
+#include "ExternalCameraUtils.h"
namespace android {
namespace hardware {
@@ -36,6 +37,7 @@
using ::android::hardware::camera::common::V1_0::CameraDeviceStatus;
using ::android::hardware::camera::common::V1_0::Status;
using ::android::hardware::camera::common::V1_0::VendorTagSection;
+using ::android::hardware::camera::external::common::ExternalCameraConfig;
using ::android::hardware::camera::provider::V2_4::ICameraProvider;
using ::android::hardware::camera::provider::V2_4::ICameraProviderCallback;
using ::android::hardware::Return;
@@ -81,8 +83,6 @@
virtual bool threadLoop() override;
private:
- static std::unordered_set<std::string> initInternalDevices();
-
ExternalCameraProvider* mParent = nullptr;
const std::unordered_set<std::string> mInternalDevices;
@@ -93,6 +93,7 @@
Mutex mLock;
sp<ICameraProviderCallback> mCallbacks = nullptr;
std::unordered_map<std::string, CameraDeviceStatus> mCameraStatusMap; // camera id -> status
+ const ExternalCameraConfig mCfg;
HotplugThread mHotPlugThread;
};
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 1405ea9..e78dbe8 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -116,6 +116,7 @@
const int64_t kTorchTimeoutSec = 1;
const int64_t kEmptyFlushTimeoutMSec = 200;
const char kDumpOutput[] = "/dev/null";
+const uint32_t kBurstFrameCount = 10;
struct AvailableStream {
int32_t width;
@@ -655,6 +656,13 @@
static Status isLogicalMultiCamera(camera_metadata_t *staticMeta);
static Status getPhysicalCameraIds(camera_metadata_t *staticMeta,
std::unordered_set<std::string> *physicalIds/*out*/);
+ static Status getSupportedKeys(camera_metadata_t *staticMeta,
+ uint32_t tagId, std::unordered_set<int32_t> *requestIDs/*out*/);
+ static void constructFilteredSettings(const sp<ICameraDeviceSession>& session,
+ const std::unordered_set<int32_t>& availableKeys, RequestTemplate reqTemplate,
+ android::hardware::camera::common::V1_0::helper::CameraMetadata* defaultSettings/*out*/,
+ android::hardware::camera::common::V1_0::helper::CameraMetadata* filteredSettings
+ /*out*/);
static Status pickConstrainedModeSize(camera_metadata_t *staticMeta,
AvailableStream &hfrStream);
static Status isZSLModeAvailable(camera_metadata_t *staticMeta);
@@ -712,6 +720,20 @@
// return from HAL but framework.
::android::Vector<StreamBuffer> resultOutputBuffers;
+ InFlightRequest() :
+ shutterTimestamp(0),
+ errorCodeValid(false),
+ errorCode(ErrorCode::ERROR_BUFFER),
+ usePartialResult(false),
+ numPartialResults(0),
+ resultQueue(nullptr),
+ haveResultMetadata(false),
+ numBuffersLeft(0),
+ frameNumber(0),
+ partialResultCount(0),
+ errorStreamId(-1),
+ hasInputBuffer(false) {}
+
InFlightRequest(ssize_t numBuffers, bool hasInput,
bool partialResults, uint32_t partialCount,
std::shared_ptr<ResultMetadataQueue> queue = nullptr) :
@@ -2748,42 +2770,23 @@
castSession(session, deviceVersion, &session3_3, &session3_4);
ASSERT_NE(session3_4, nullptr);
- const android::hardware::camera::common::V1_0::helper::CameraMetadata staticMeta(
- staticMetaBuffer);
- camera_metadata_ro_entry availableSessionKeys = staticMeta.find(
- ANDROID_REQUEST_AVAILABLE_SESSION_KEYS);
- if (availableSessionKeys.count == 0) {
+ std::unordered_set<int32_t> availableSessionKeys;
+ auto rc = getSupportedKeys(staticMetaBuffer, ANDROID_REQUEST_AVAILABLE_SESSION_KEYS,
+ &availableSessionKeys);
+ ASSERT_TRUE(Status::OK == rc);
+ if (availableSessionKeys.empty()) {
+ free_camera_metadata(staticMetaBuffer);
ret = session->close();
ASSERT_TRUE(ret.isOk());
continue;
}
android::hardware::camera::common::V1_0::helper::CameraMetadata previewRequestSettings;
- ret = session->constructDefaultRequestSettings(RequestTemplate::PREVIEW,
- [&previewRequestSettings] (auto status, const auto& req) mutable {
- ASSERT_EQ(Status::OK, status);
-
- const camera_metadata_t *metadata = reinterpret_cast<const camera_metadata_t*> (
- req.data());
- size_t expectedSize = req.size();
- int result = validate_camera_metadata_structure(metadata, &expectedSize);
- ASSERT_TRUE((result == 0) || (result == CAMERA_METADATA_VALIDATION_SHIFTED));
-
- size_t entryCount = get_camera_metadata_entry_count(metadata);
- ASSERT_GT(entryCount, 0u);
- previewRequestSettings = metadata;
- });
- ASSERT_TRUE(ret.isOk());
- const android::hardware::camera::common::V1_0::helper::CameraMetadata &constSettings =
- previewRequestSettings;
android::hardware::camera::common::V1_0::helper::CameraMetadata sessionParams;
- for (size_t i = 0; i < availableSessionKeys.count; i++) {
- camera_metadata_ro_entry entry = constSettings.find(availableSessionKeys.data.i32[i]);
- if (entry.count > 0) {
- sessionParams.update(entry);
- }
- }
+ constructFilteredSettings(session, availableSessionKeys, RequestTemplate::PREVIEW,
+ &previewRequestSettings, &sessionParams);
if (sessionParams.isEmpty()) {
+ free_camera_metadata(staticMetaBuffer);
ret = session->close();
ASSERT_TRUE(ret.isOk());
continue;
@@ -2817,7 +2820,7 @@
});
ASSERT_TRUE(ret.isOk());
- sessionParams.unlock(sessionParamsBuffer);
+ free_camera_metadata(staticMetaBuffer);
ret = session->close();
ASSERT_TRUE(ret.isOk());
}
@@ -3350,6 +3353,8 @@
if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_4) {
continue;
}
+ std::string version, deviceId;
+ ASSERT_TRUE(::matchDeviceName(name, mProviderType, &version, &deviceId));
camera_metadata_t* staticMeta;
Return<void> ret;
sp<ICameraDeviceSession> session;
@@ -3357,6 +3362,7 @@
Status rc = isLogicalMultiCamera(staticMeta);
if (Status::METHOD_NOT_SUPPORTED == rc) {
+ free_camera_metadata(staticMeta);
ret = session->close();
ASSERT_TRUE(ret.isOk());
continue;
@@ -3366,13 +3372,45 @@
ASSERT_TRUE(Status::OK == rc);
ASSERT_TRUE(physicalIds.size() > 1);
+ std::unordered_set<int32_t> physicalRequestKeyIDs;
+ rc = getSupportedKeys(staticMeta,
+ ANDROID_REQUEST_AVAILABLE_PHYSICAL_CAMERA_REQUEST_KEYS, &physicalRequestKeyIDs);
+ ASSERT_TRUE(Status::OK == rc);
+ if (physicalRequestKeyIDs.empty()) {
+ free_camera_metadata(staticMeta);
+ ret = session->close();
+ ASSERT_TRUE(ret.isOk());
+ // The logical camera doesn't support any individual physical requests.
+ continue;
+ }
+
+ android::hardware::camera::common::V1_0::helper::CameraMetadata defaultPreviewSettings;
+ android::hardware::camera::common::V1_0::helper::CameraMetadata filteredSettings;
+ constructFilteredSettings(session, physicalRequestKeyIDs, RequestTemplate::PREVIEW,
+ &defaultPreviewSettings, &filteredSettings);
+ if (filteredSettings.isEmpty()) {
+ // No physical device settings in default request.
+ free_camera_metadata(staticMeta);
+ ret = session->close();
+ ASSERT_TRUE(ret.isOk());
+ continue;
+ }
+
+ const camera_metadata_t *settingsBuffer = defaultPreviewSettings.getAndLock();
+ settings.setToExternal(
+ reinterpret_cast<uint8_t *> (const_cast<camera_metadata_t *> (settingsBuffer)),
+ get_camera_metadata_size(settingsBuffer));
+
free_camera_metadata(staticMeta);
ret = session->close();
ASSERT_TRUE(ret.isOk());
- // Leave only 2 physical devices in the id set.
- auto it = physicalIds.begin(); it++; it++;
- physicalIds.erase(it, physicalIds.end());
+ auto it = physicalIds.begin();
+ string physicalDeviceId = *it;
+ // Leave only the first physical device in the id set and insert the logical device.
+ physicalIds.erase(++it, physicalIds.end());
+ physicalIds.emplace(deviceId);
+ ASSERT_EQ(physicalIds.size(), 2u);
V3_4::HalStreamConfiguration halStreamConfig;
bool supportsPartialResults = false;
@@ -3400,38 +3438,34 @@
});
ASSERT_TRUE(resultQueueRet.isOk());
- InFlightRequest inflightReq = {static_cast<ssize_t> (physicalIds.size()), false,
+ InFlightRequest inflightReq = {static_cast<ssize_t> (halStreamConfig.streams.size()), false,
supportsPartialResults, partialResultCount, resultQueue};
- RequestTemplate reqTemplate = RequestTemplate::PREVIEW;
- ret = session3_4->constructDefaultRequestSettings(reqTemplate,
- [&](auto status, const auto& req) {
- ASSERT_EQ(Status::OK, status);
- settings = req;
- });
- ASSERT_TRUE(ret.isOk());
- ASSERT_TRUE(settings.size() > 0);
-
std::vector<sp<GraphicBuffer>> graphicBuffers;
- graphicBuffers.reserve(physicalIds.size());
+ graphicBuffers.reserve(halStreamConfig.streams.size());
::android::hardware::hidl_vec<StreamBuffer> outputBuffers;
- outputBuffers.resize(physicalIds.size());
- hidl_vec<V3_4::PhysicalCameraSetting> camSettings;
- camSettings.resize(physicalIds.size());
+ outputBuffers.resize(halStreamConfig.streams.size());
size_t k = 0;
- for (const auto physicalIdIt : physicalIds) {
+ for (const auto& halStream : halStreamConfig.streams) {
sp<GraphicBuffer> gb = new GraphicBuffer(previewStream.width, previewStream.height,
- static_cast<int32_t>(halStreamConfig.streams[k].v3_3.v3_2.overrideFormat), 1,
+ static_cast<int32_t>(halStream.v3_3.v3_2.overrideFormat), 1,
android_convertGralloc1To0Usage(
- halStreamConfig.streams[k].v3_3.v3_2.producerUsage,
- halStreamConfig.streams[k].v3_3.v3_2.consumerUsage));
+ halStream.v3_3.v3_2.producerUsage, halStream.v3_3.v3_2.consumerUsage));
ASSERT_NE(nullptr, gb.get());
- outputBuffers[k] = {halStreamConfig.streams[k].v3_3.v3_2.id, bufferId,
- hidl_handle(gb->getNativeBuffer()->handle), BufferStatus::OK, nullptr, nullptr};
graphicBuffers.push_back(gb);
- camSettings[k] = {0, hidl_string(physicalIdIt), settings};
+ outputBuffers[k] = {halStream.v3_3.v3_2.id, bufferId,
+ hidl_handle(gb->getNativeBuffer()->handle), BufferStatus::OK, nullptr, nullptr};
+ bufferId++;
k++;
}
+ hidl_vec<V3_4::PhysicalCameraSetting> camSettings(1);
+ const camera_metadata_t *filteredSettingsBuffer = filteredSettings.getAndLock();
+ camSettings[0].settings.setToExternal(
+ reinterpret_cast<uint8_t *> (const_cast<camera_metadata_t *> (
+ filteredSettingsBuffer)),
+ get_camera_metadata_size(filteredSettingsBuffer));
+ camSettings[0].fmqSettingsSize = 0;
+ camSettings[0].physicalCameraId = physicalDeviceId;
StreamBuffer emptyInputBuffer = {-1, 0, nullptr, BufferStatus::ERROR, nullptr, nullptr};
V3_4::CaptureRequest request = {{frameNumber, 0 /* fmqSettingsSize */, settings,
@@ -3468,24 +3502,49 @@
ASSERT_FALSE(inflightReq.errorCodeValid);
ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u);
+
+ request.v3_2.frameNumber++;
+ // Empty settings should be supported after the first call
+ // for repeating requests.
+ request.v3_2.settings.setToExternal(nullptr, 0, true);
+ request.physicalCameraSettings[0].settings.setToExternal(nullptr, 0, true);
+ // The buffer has been registered to HAL by bufferId, so per
+ // API contract we should send a null handle for this buffer
+ request.v3_2.outputBuffers[0].buffer = nullptr;
+ mInflightMap.clear();
+ inflightReq = {static_cast<ssize_t> (physicalIds.size()), false,
+ supportsPartialResults, partialResultCount, resultQueue};
+ mInflightMap.add(request.v3_2.frameNumber, &inflightReq);
}
- // Empty physical camera settings should fail process requests
- camSettings[1].settings = emptySettings;
- frameNumber++;
- request = {{frameNumber, 0 /* fmqSettingsSize */, settings,
- emptyInputBuffer, outputBuffers}, camSettings};
returnStatus = session3_4->processCaptureRequest_3_4(
{request}, cachesToRemove, [&stat, &numRequestProcessed](auto s, uint32_t n) {
stat = s;
numRequestProcessed = n;
});
ASSERT_TRUE(returnStatus.isOk());
- ASSERT_EQ(Status::ILLEGAL_ARGUMENT, stat);
+ ASSERT_EQ(Status::OK, stat);
+ ASSERT_EQ(numRequestProcessed, 1u);
+
+ {
+ std::unique_lock<std::mutex> l(mLock);
+ while (!inflightReq.errorCodeValid &&
+ ((0 < inflightReq.numBuffersLeft) ||
+ (!inflightReq.haveResultMetadata))) {
+ auto timeout = std::chrono::system_clock::now() +
+ std::chrono::seconds(kStreamBufferTimeoutSec);
+ ASSERT_NE(std::cv_status::timeout,
+ mResultCondition.wait_until(l, timeout));
+ }
+
+ ASSERT_FALSE(inflightReq.errorCodeValid);
+ ASSERT_NE(inflightReq.resultOutputBuffers.size(), 0u);
+ }
// Invalid physical camera id should fail process requests
- camSettings[1].physicalCameraId = invalidPhysicalId;
- camSettings[1].settings = settings;
+ frameNumber++;
+ camSettings[0].physicalCameraId = invalidPhysicalId;
+ camSettings[0].settings = settings;
request = {{frameNumber, 0 /* fmqSettingsSize */, settings,
emptyInputBuffer, outputBuffers}, camSettings};
returnStatus = session3_4->processCaptureRequest_3_4(
@@ -3496,11 +3555,158 @@
ASSERT_TRUE(returnStatus.isOk());
ASSERT_EQ(Status::ILLEGAL_ARGUMENT, stat);
+ defaultPreviewSettings.unlock(settingsBuffer);
+ filteredSettings.unlock(filteredSettingsBuffer);
ret = session3_4->close();
ASSERT_TRUE(ret.isOk());
}
}
+// Generate and verify a burst containing alternating sensor sensitivity values
+TEST_F(CameraHidlTest, processCaptureRequestBurstISO) {
+ hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider);
+ AvailableStream previewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
+ static_cast<int32_t>(PixelFormat::IMPLEMENTATION_DEFINED)};
+ uint64_t bufferId = 1;
+ uint32_t frameNumber = 1;
+ ::android::hardware::hidl_vec<uint8_t> settings;
+
+ for (const auto& name : cameraDeviceNames) {
+ int deviceVersion = getCameraDeviceVersion(name, mProviderType);
+ if (deviceVersion == CAMERA_DEVICE_API_VERSION_1_0) {
+ continue;
+ } else if (deviceVersion <= 0) {
+ ALOGE("%s: Unsupported device version %d", __func__, deviceVersion);
+ ADD_FAILURE();
+ return;
+ }
+ camera_metadata_t* staticMetaBuffer;
+ Return<void> ret;
+ sp<ICameraDeviceSession> session;
+ openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMetaBuffer /*out*/);
+ ::android::hardware::camera::common::V1_0::helper::CameraMetadata staticMeta(
+ staticMetaBuffer);
+
+ camera_metadata_entry_t hwLevel = staticMeta.find(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL);
+ ASSERT_TRUE(0 < hwLevel.count);
+ if (ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED == hwLevel.data.u8[0]) {
+ //Limited devices can skip this test
+ ret = session->close();
+ ASSERT_TRUE(ret.isOk());
+ continue;
+ }
+
+ camera_metadata_entry_t isoRange = staticMeta.find(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE);
+ ASSERT_EQ(isoRange.count, 2u);
+
+ ret = session->close();
+ ASSERT_TRUE(ret.isOk());
+
+ bool supportsPartialResults = false;
+ uint32_t partialResultCount = 0;
+ V3_2::Stream previewStream;
+ HalStreamConfiguration halStreamConfig;
+ configurePreviewStream(name, deviceVersion, mProvider, &previewThreshold,
+ &session /*out*/, &previewStream /*out*/, &halStreamConfig /*out*/,
+ &supportsPartialResults /*out*/, &partialResultCount /*out*/);
+ std::shared_ptr<ResultMetadataQueue> resultQueue;
+
+ auto resultQueueRet = session->getCaptureResultMetadataQueue(
+ [&resultQueue](const auto& descriptor) {
+ resultQueue = std::make_shared<ResultMetadataQueue>(descriptor);
+ if (!resultQueue->isValid() || resultQueue->availableToWrite() <= 0) {
+ ALOGE("%s: HAL returns empty result metadata fmq,"
+ " not use it", __func__);
+ resultQueue = nullptr;
+ // Don't use the queue onwards.
+ }
+ });
+ ASSERT_TRUE(resultQueueRet.isOk());
+ ASSERT_NE(nullptr, resultQueue);
+
+ ret = session->constructDefaultRequestSettings(RequestTemplate::PREVIEW,
+ [&](auto status, const auto& req) {
+ ASSERT_EQ(Status::OK, status);
+ settings = req; });
+ ASSERT_TRUE(ret.isOk());
+
+ ::android::hardware::camera::common::V1_0::helper::CameraMetadata requestMeta;
+ StreamBuffer emptyInputBuffer = {-1, 0, nullptr, BufferStatus::ERROR, nullptr, nullptr};
+ sp<GraphicBuffer> buffers[kBurstFrameCount];
+ StreamBuffer outputBuffers[kBurstFrameCount];
+ CaptureRequest requests[kBurstFrameCount];
+ InFlightRequest inflightReqs[kBurstFrameCount];
+ int32_t isoValues[kBurstFrameCount];
+ hidl_vec<uint8_t> requestSettings[kBurstFrameCount];
+ for (uint32_t i = 0; i < kBurstFrameCount; i++) {
+ std::unique_lock<std::mutex> l(mLock);
+
+ isoValues[i] = ((i % 2) == 0) ? isoRange.data.i32[0] : isoRange.data.i32[1];
+ buffers[i] = new GraphicBuffer( previewStream.width, previewStream.height,
+ static_cast<int32_t>(halStreamConfig.streams[0].overrideFormat), 1,
+ android_convertGralloc1To0Usage( halStreamConfig.streams[0].producerUsage,
+ halStreamConfig.streams[0].consumerUsage));
+ ASSERT_NE(nullptr, buffers[i].get());
+
+ outputBuffers[i] = {halStreamConfig.streams[0].id, bufferId + i,
+ hidl_handle( buffers[i]->getNativeBuffer()->handle), BufferStatus::OK, nullptr,
+ nullptr};
+ requestMeta.append(reinterpret_cast<camera_metadata_t *> (settings.data()));
+
+ // Disable all 3A routines
+ uint8_t mode = static_cast<uint8_t>(ANDROID_CONTROL_MODE_OFF);
+ ASSERT_EQ(::android::OK, requestMeta.update(ANDROID_CONTROL_MODE, &mode, 1));
+ ASSERT_EQ(::android::OK, requestMeta.update(ANDROID_SENSOR_SENSITIVITY, &isoValues[i],
+ 1));
+ camera_metadata_t *metaBuffer = requestMeta.release();
+ requestSettings[i].setToExternal(reinterpret_cast<uint8_t *> (metaBuffer),
+ get_camera_metadata_size(metaBuffer), true);
+
+ requests[i] = {frameNumber + i, 0 /* fmqSettingsSize */, requestSettings[i],
+ emptyInputBuffer, {outputBuffers[i]}};
+
+ inflightReqs[i] = {1, false, supportsPartialResults, partialResultCount, resultQueue};
+ mInflightMap.add(frameNumber + i, &inflightReqs[i]);
+ }
+
+ Status status = Status::INTERNAL_ERROR;
+ uint32_t numRequestProcessed = 0;
+ hidl_vec<BufferCache> cachesToRemove;
+ hidl_vec<CaptureRequest> burstRequest;
+ burstRequest.setToExternal(requests, kBurstFrameCount);
+ Return<void> returnStatus = session->processCaptureRequest(burstRequest, cachesToRemove,
+ [&status, &numRequestProcessed] (auto s, uint32_t n) {
+ status = s;
+ numRequestProcessed = n;
+ });
+ ASSERT_TRUE(returnStatus.isOk());
+ ASSERT_EQ(Status::OK, status);
+ ASSERT_EQ(numRequestProcessed, kBurstFrameCount);
+
+ for (size_t i = 0; i < kBurstFrameCount; i++) {
+ std::unique_lock<std::mutex> l(mLock);
+ while (!inflightReqs[i].errorCodeValid && ((0 < inflightReqs[i].numBuffersLeft) ||
+ (!inflightReqs[i].haveResultMetadata))) {
+ auto timeout = std::chrono::system_clock::now() +
+ std::chrono::seconds(kStreamBufferTimeoutSec);
+ ASSERT_NE(std::cv_status::timeout, mResultCondition.wait_until(l, timeout));
+ }
+
+ ASSERT_FALSE(inflightReqs[i].errorCodeValid);
+ ASSERT_NE(inflightReqs[i].resultOutputBuffers.size(), 0u);
+ ASSERT_EQ(previewStream.id, inflightReqs[i].resultOutputBuffers[0].streamId);
+ ASSERT_FALSE(inflightReqs[i].collectedResult.isEmpty());
+ ASSERT_TRUE(inflightReqs[i].collectedResult.exists(ANDROID_SENSOR_SENSITIVITY));
+ camera_metadata_entry_t isoResult = inflightReqs[i].collectedResult.find(
+ ANDROID_SENSOR_SENSITIVITY);
+ ASSERT_TRUE(isoResult.data.i32[0] == isoValues[i]);
+ }
+
+ ret = session->close();
+ ASSERT_TRUE(ret.isOk());
+ }
+}
+
// Test whether an incorrect capture request with missing settings will
// be reported correctly.
TEST_F(CameraHidlTest, processCaptureRequestInvalidSinglePreview) {
@@ -3901,6 +4107,56 @@
return Status::OK;
}
+// Generate a set of suported camera key ids.
+Status CameraHidlTest::getSupportedKeys(camera_metadata_t *staticMeta,
+ uint32_t tagId, std::unordered_set<int32_t> *requestIDs) {
+ if ((nullptr == staticMeta) || (nullptr == requestIDs)) {
+ return Status::ILLEGAL_ARGUMENT;
+ }
+
+ camera_metadata_ro_entry entry;
+ int rc = find_camera_metadata_ro_entry(staticMeta, tagId, &entry);
+ if ((0 != rc) || (entry.count == 0)) {
+ return Status::OK;
+ }
+
+ requestIDs->insert(entry.data.i32, entry.data.i32 + entry.count);
+
+ return Status::OK;
+}
+
+void CameraHidlTest::constructFilteredSettings(const sp<ICameraDeviceSession>& session,
+ const std::unordered_set<int32_t>& availableKeys, RequestTemplate reqTemplate,
+ android::hardware::camera::common::V1_0::helper::CameraMetadata* defaultSettings,
+ android::hardware::camera::common::V1_0::helper::CameraMetadata* filteredSettings) {
+ ASSERT_NE(defaultSettings, nullptr);
+ ASSERT_NE(filteredSettings, nullptr);
+
+ auto ret = session->constructDefaultRequestSettings(reqTemplate,
+ [&defaultSettings] (auto status, const auto& req) mutable {
+ ASSERT_EQ(Status::OK, status);
+
+ const camera_metadata_t *metadata = reinterpret_cast<const camera_metadata_t*> (
+ req.data());
+ size_t expectedSize = req.size();
+ int result = validate_camera_metadata_structure(metadata, &expectedSize);
+ ASSERT_TRUE((result == 0) || (result == CAMERA_METADATA_VALIDATION_SHIFTED));
+
+ size_t entryCount = get_camera_metadata_entry_count(metadata);
+ ASSERT_GT(entryCount, 0u);
+ *defaultSettings = metadata;
+ });
+ ASSERT_TRUE(ret.isOk());
+ const android::hardware::camera::common::V1_0::helper::CameraMetadata &constSettings =
+ *defaultSettings;
+ for (const auto& keyIt : availableKeys) {
+ camera_metadata_ro_entry entry = constSettings.find(keyIt);
+ if (entry.count > 0) {
+ filteredSettings->update(entry);
+ }
+ }
+}
+
// Check if constrained mode is supported by using the static
// camera characteristics.
Status CameraHidlTest::isConstrainedModeAvailable(camera_metadata_t *staticMeta) {
diff --git a/cas/1.0/vts/functional/Android.bp b/cas/1.0/vts/functional/Android.bp
index e1e09e9..0db9bb0 100644
--- a/cas/1.0/vts/functional/Android.bp
+++ b/cas/1.0/vts/functional/Android.bp
@@ -23,6 +23,7 @@
"android.hardware.cas.native@1.0",
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",
+ "libhidlallocatorutils",
"libhidlmemory",
],
shared_libs: [
diff --git a/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp b/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
index 053d37a..14b8bbd 100644
--- a/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
+++ b/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
@@ -30,6 +30,7 @@
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/Status.h>
+#include <hidlmemory/FrameworkUtils.h>
#include <utils/Condition.h>
#include <utils/Mutex.h>
@@ -53,6 +54,7 @@
using android::hardware::cas::V1_0::ICas;
using android::hardware::cas::V1_0::ICasListener;
using android::hardware::cas::V1_0::IDescramblerBase;
+using android::hardware::cas::V1_0::Status;
using android::hardware::cas::native::V1_0::IDescrambler;
using android::hardware::cas::native::V1_0::SubSample;
using android::hardware::cas::native::V1_0::SharedBuffer;
@@ -61,13 +63,12 @@
using android::hardware::cas::native::V1_0::ScramblingControl;
using android::hardware::cas::V1_0::IMediaCasService;
using android::hardware::cas::V1_0::HidlCasPluginDescriptor;
-using android::hardware::Void;
+using android::hardware::fromHeap;
using android::hardware::hidl_vec;
using android::hardware::hidl_string;
-using android::hardware::hidl_handle;
-using android::hardware::hidl_memory;
+using android::hardware::HidlMemory;
using android::hardware::Return;
-using android::hardware::cas::V1_0::Status;
+using android::hardware::Void;
using android::IMemory;
using android::IMemoryHeap;
using android::MemoryDealer;
@@ -315,7 +316,7 @@
}
*inMemory = mem;
- // build hidl_memory from memory heap
+ // build HidlMemory from memory heap
ssize_t offset;
size_t size;
sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
@@ -324,18 +325,14 @@
return ::testing::AssertionFailure();
}
- native_handle_t* nativeHandle = native_handle_create(1, 0);
- if (!nativeHandle) {
- ALOGE("failed to create native handle!");
- return ::testing::AssertionFailure();
- }
- nativeHandle->data[0] = heap->getHeapID();
-
uint8_t* ipBuffer = static_cast<uint8_t*>(static_cast<void*>(mem->pointer()));
memcpy(ipBuffer, kInBinaryBuffer, sizeof(kInBinaryBuffer));
+ // hidlMemory is not to be passed out of scope!
+ sp<HidlMemory> hidlMemory = fromHeap(heap);
+
SharedBuffer srcBuffer = {
- .heapBase = hidl_memory("ashmem", hidl_handle(nativeHandle), heap->getSize()),
+ .heapBase = *hidlMemory,
.offset = (uint64_t) offset,
.size = (uint64_t) size
};
@@ -380,7 +377,7 @@
return ::testing::AssertionFailure();
}
- // build hidl_memory from memory heap
+ // build HidlMemory from memory heap
ssize_t offset;
size_t size;
sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
@@ -389,15 +386,11 @@
return ::testing::AssertionFailure();
}
- native_handle_t* nativeHandle = native_handle_create(1, 0);
- if (!nativeHandle) {
- ALOGE("failed to create native handle!");
- return ::testing::AssertionFailure();
- }
- nativeHandle->data[0] = heap->getHeapID();
+ // hidlMemory is not to be passed out of scope!
+ sp<HidlMemory> hidlMemory = fromHeap(heap);
SharedBuffer srcBuffer = {
- .heapBase = hidl_memory("ashmem", hidl_handle(nativeHandle), heap->getSize()),
+ .heapBase = *hidlMemory,
.offset = (uint64_t) offset + params.imemOffset,
.size = (uint64_t) params.imemSize,
};
diff --git a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
index e501580..a1676be 100644
--- a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
+++ b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "ConfigstoreHidlHalTest"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
#include <android/hardware/configstore/1.0/types.h>
@@ -34,13 +35,25 @@
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
+// Test environment for Configstore HIDL HAL.
+class ConfigstoreHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ConfigstoreHidlEnvironment* Instance() {
+ static ConfigstoreHidlEnvironment* instance = new ConfigstoreHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<ISurfaceFlingerConfigs>(); }
+};
+
class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
sp<ISurfaceFlingerConfigs> sfConfigs;
virtual void SetUp() override {
- sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService<
- ISurfaceFlingerConfigs>();
+ sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService<ISurfaceFlingerConfigs>(
+ ConfigstoreHidlEnvironment::Instance()->getServiceName<ISurfaceFlingerConfigs>());
ASSERT_NE(sfConfigs, nullptr);
}
@@ -119,7 +132,9 @@
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(ConfigstoreHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ ConfigstoreHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp
index 5672824..7492152 100644
--- a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp
+++ b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "contexthub_hidl_hal_test"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/contexthub/1.0/IContexthub.h>
#include <android/hardware/contexthub/1.0/IContexthubCallback.h>
@@ -92,12 +93,27 @@
return hubIds;
}
+// Test environment for Contexthub HIDL HAL.
+class ContexthubHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ContexthubHidlEnvironment* Instance() {
+ static ContexthubHidlEnvironment* instance = new ContexthubHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IContexthub>(); }
+ private:
+ ContexthubHidlEnvironment() {}
+};
+
// Base test fixture that initializes the HAL and makes the context hub API
// handle available
class ContexthubHidlTestBase : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>();
+ hubApi = ::testing::VtsHalHidlTargetTestBase::getService<IContexthub>(
+ ContexthubHidlEnvironment::Instance()->getServiceName<IContexthub>());
ASSERT_NE(hubApi, nullptr);
// getHubs() must be called at least once for proper initialization of the
@@ -381,7 +397,11 @@
} // anonymous namespace
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(ContexthubHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ContexthubHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI ("Test result = %d", status);
+ return status;
}
diff --git a/current.txt b/current.txt
index a5ab307..de2511e 100644
--- a/current.txt
+++ b/current.txt
@@ -255,4 +255,5 @@
fb92e2b40f8e9d494e8fd3b4ac18499a3216342e7cff160714c3bbf3660b6e79 android.hardware.gnss@1.0::IGnssConfiguration
251594ea9b27447bfa005ebd806e58fb0ae4aad84a69938129c9800ec0c64eda android.hardware.gnss@1.0::IGnssMeasurementCallback
4e7169919d24fbe5573e5bcd683d0bd7abf553a4e6c34c41f9dfc1e12050db07 android.hardware.gnss@1.0::IGnssNavigationMessageCallback
+0e6e80ddd5c312726e20b003af438325a2d7c305a60a8c8d8e229df2306d50df android.hardware.radio@1.0::types
b280c4704dfcc548a9bf127b59b7c3578f460c50cce70a06b66fe0df8b27cff0 android.hardware.wifi@1.0::types
diff --git a/drm/1.1/IDrmPlugin.hal b/drm/1.1/IDrmPlugin.hal
index 7dd397a..2980dc2 100644
--- a/drm/1.1/IDrmPlugin.hal
+++ b/drm/1.1/IDrmPlugin.hal
@@ -26,6 +26,7 @@
import @1.0::SecureStopId;
import @1.1::SecureStopRelease;
import @1.1::SecurityLevel;
+import @1.0::SessionId;
/**
* IDrmPlugin is used to interact with a specific drm plugin that was created by
@@ -34,6 +35,34 @@
*/
interface IDrmPlugin extends @1.0::IDrmPlugin {
/**
+ * Open a new session at a requested security level. The security level
+ * represents the robustness of the device's DRM implementation. By default,
+ * sessions are opened at the native security level of the device which is
+ * the maximum level that can be supported. Overriding the security level is
+ * necessary when the decrypted frames need to be manipulated, such as for
+ * image compositing. The security level parameter must be equal to or lower
+ * than the native level. If the requested level is not supported, the next
+ * lower supported security level must be set. The level can be queried
+ * using {@link #getSecurityLevel}. A session ID is returned. When the
+ * drm@1.0 openSession is called, which has no securityLevel parameter, the
+ * security level is defaulted to the native security level of the device.
+ *
+ * @return status the status of the call. The status must be OK or one of
+ * the following errors: ERROR_DRM_NOT_PROVISIONED if the device
+ * requires provisioning before it can open a session,
+ * ERROR_DRM_RESOURCE_BUSY if there are insufficent resources available
+ * to open a session, ERROR_DRM_CANNOT_HANDLE if the requested security
+ * level is higher than the native level or lower than the lowest
+ * supported level or if openSession is not supported at the time of
+ * the call, or ERROR_DRM_INVALID_STATE if the HAL is in a state where
+ * a session cannot be opened.
+ * @param level the requested security level
+ * @return sessionId the session ID for the newly opened session
+ */
+ openSession_1_1(SecurityLevel securityLevel) generates (Status status,
+ SessionId sessionId);
+
+ /**
* A key request/response exchange occurs between the app and a License
* Server to obtain the keys required to decrypt the content.
* getKeyRequest_1_1() is used to obtain an opaque key request blob that is
@@ -149,24 +178,6 @@
SecurityLevel level);
/**
- * Set the security level of a session. This can be useful if specific
- * attributes of a lower security level are needed by an application, such
- * as image manipulation or compositing which requires non-secure decoded
- * frames. Reducing the security level may limit decryption to lower content
- * resolutions, depending on the license policy.
- *
- * @param sessionId the session id the call applies to
- * @param level the requested security level
- * @return status the status of the call. The status must be OK or one of
- * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session
- * is not opened, BAD_VALUE if the sessionId or security level is
- * invalid or ERROR_DRM_INVALID_STATE if the HAL is in a state where
- * the security level cannot be set.
- */
- setSecurityLevel(vec<uint8_t> sessionId, SecurityLevel level)
- generates(Status status);
-
- /**
* Returns the plugin-specific metrics. Multiple metric groups may be
* returned in one call to getMetrics(). The scope and definition of the
* metrics is defined by the plugin.
diff --git a/drm/1.1/vts/functional/drm_hal_clearkey_test.cpp b/drm/1.1/vts/functional/drm_hal_clearkey_test.cpp
index 5133f47..061f2cd 100644
--- a/drm/1.1/vts/functional/drm_hal_clearkey_test.cpp
+++ b/drm/1.1/vts/functional/drm_hal_clearkey_test.cpp
@@ -164,6 +164,7 @@
virtual void TearDown() override {}
SessionId openSession();
+ SessionId openSession(SecurityLevel level);
void closeSession(const SessionId& sessionId);
hidl_vec<uint8_t> loadKeys(const SessionId& sessionId, const KeyType& type);
sp<IMemory> getDecryptMemory(size_t size, size_t index);
@@ -283,6 +284,23 @@
}
/**
+ * Helper method to open as session using V1.1 API
+ */
+SessionId DrmHalClearkeyTest::openSession(SecurityLevel level) {
+ SessionId sessionId;
+
+ auto res = drmPlugin->openSession_1_1(level,
+ [&sessionId](Status status, const SessionId& id) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_NE(0u, id.size());
+ sessionId = id;
+ });
+ EXPECT_OK(res);
+ return sessionId;
+}
+
+
+/**
* Helper method to close a session
*/
void DrmHalClearkeyTest::closeSession(const SessionId& sessionId) {
@@ -304,14 +322,14 @@
}
/**
- * Test that the plugin returns valid open and max session counts
+ * Test that the plugin returns default open and max session counts
*/
-TEST_F(DrmHalClearkeyTest, GetSessionCounts) {
+TEST_F(DrmHalClearkeyTest, GetDefaultSessionCounts) {
auto res = drmPlugin->getNumberOfSessions(
[&](Status status, uint32_t currentSessions,
uint32_t maxSessions) {
EXPECT_EQ(Status::OK, status);
- EXPECT_GT(maxSessions, (uint32_t)0);
+ EXPECT_GE(maxSessions, (uint32_t)8);
EXPECT_GE(currentSessions, (uint32_t)0);
EXPECT_LE(currentSessions, maxSessions);
});
@@ -319,16 +337,76 @@
}
/**
- * Test that the plugin returns a valid security level for
- * a valid session
+ * Test that the plugin returns valid open and max session counts
+ * after a session is opened.
*/
-TEST_F(DrmHalClearkeyTest, GetSecurityLevel) {
+TEST_F(DrmHalClearkeyTest, GetOpenSessionCounts) {
+ uint32_t initialSessions = 0;
+ auto res = drmPlugin->getNumberOfSessions(
+ [&](Status status, uint32_t currentSessions,
+ uint32_t maxSessions) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_GE(maxSessions, (uint32_t)8);
+ EXPECT_GE(currentSessions, (uint32_t)0);
+ EXPECT_LE(currentSessions, maxSessions);
+ initialSessions = currentSessions;
+ });
+ EXPECT_OK(res);
+
SessionId session = openSession();
+ res = drmPlugin->getNumberOfSessions(
+ [&](Status status, uint32_t currentSessions,
+ uint32_t /*maxSessions*/) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_EQ(currentSessions, initialSessions + 1);
+ });
+ EXPECT_OK(res);
+
+ closeSession(session);
+ res = drmPlugin->getNumberOfSessions(
+ [&](Status status, uint32_t currentSessions,
+ uint32_t /*maxSessions*/) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_EQ(currentSessions, initialSessions);
+ });
+ EXPECT_OK(res);
+}
+
+/**
+ * Test that the plugin returns the same security level
+ * by default as when it is requested explicitly
+ */
+TEST_F(DrmHalClearkeyTest, GetDefaultSecurityLevel) {
+ SessionId session = openSession();
+ SecurityLevel defaultLevel;
auto res = drmPlugin->getSecurityLevel(session,
[&](Status status, SecurityLevel level) {
EXPECT_EQ(Status::OK, status);
- EXPECT_GE(level, SecurityLevel::SW_SECURE_CRYPTO);
- EXPECT_LE(level, SecurityLevel::HW_SECURE_ALL);
+ defaultLevel = level;
+ });
+ EXPECT_OK(res);
+ closeSession(session);
+
+ session = openSession(defaultLevel);
+ res = drmPlugin->getSecurityLevel(session,
+ [&](Status status, SecurityLevel level) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_EQ(level, defaultLevel);
+ });
+ EXPECT_OK(res);
+ closeSession(session);
+}
+
+/**
+ * Test that the plugin returns the lowest security level
+ * when it is requested
+ */
+TEST_F(DrmHalClearkeyTest, GetSecurityLevel) {
+ SessionId session = openSession(SecurityLevel::SW_SECURE_CRYPTO);
+ auto res = drmPlugin->getSecurityLevel(session,
+ [&](Status status, SecurityLevel level) {
+ EXPECT_EQ(Status::OK, status);
+ EXPECT_EQ(level, SecurityLevel::SW_SECURE_CRYPTO);
});
EXPECT_OK(res);
closeSession(session);
@@ -348,51 +426,6 @@
}
/**
- * Test that setting all valid security levels on a valid sessionId
- * is supported
- */
-TEST_F(DrmHalClearkeyTest, SetSecurityLevel) {
- SessionId session = openSession();
- for (uint32_t level = static_cast<uint32_t>(SecurityLevel::SW_SECURE_CRYPTO);
- level <= static_cast<uint32_t>(SecurityLevel::HW_SECURE_ALL); level++) {
- EXPECT_EQ(Status::OK, drmPlugin->setSecurityLevel(session, static_cast<SecurityLevel>(level)));
-
- // check that the level got set
- auto res = drmPlugin->getSecurityLevel(session,
- [&](Status status, SecurityLevel readLevel) {
- EXPECT_EQ(Status::OK, status);
- EXPECT_EQ(level, static_cast<uint32_t>(readLevel));
- });
- EXPECT_OK(res);
- }
- closeSession(session);
-}
-
-/**
- * Test that setting an invalid security level on a valid
- * sessionId is prohibited with the documented error code.
- */
-TEST_F(DrmHalClearkeyTest, SetInvalidSecurityLevel) {
- SessionId session = openSession();
- SecurityLevel level = static_cast<SecurityLevel>(
- static_cast<uint32_t>(SecurityLevel::HW_SECURE_ALL) + 1);
- Status status = drmPlugin->setSecurityLevel(session, level);
- EXPECT_EQ(Status::BAD_VALUE, status);
- closeSession(session);
-}
-
-/**
- * Test that attempting to set security level on an invalid
- * (empty) sessionId is prohibited with the documented error
- * code.
- */
-TEST_F(DrmHalClearkeyTest, SetSecurityLevelInvalidSessionId) {
- SessionId session;
- SecurityLevel level = SecurityLevel::SW_SECURE_CRYPTO;
- EXPECT_EQ(Status::BAD_VALUE, drmPlugin->setSecurityLevel(session, level));
-}
-
-/**
* Test metrics are set appropriately for open and close operations.
*/
TEST_F(DrmHalClearkeyTest, GetMetricsSuccess) {
diff --git a/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp b/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
index e9a44eb..715e9fc 100644
--- a/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
+++ b/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
@@ -33,6 +33,7 @@
#include <log/log.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
@@ -77,6 +78,20 @@
return auth_token;
}
+// Test environment for Gatekeeper HIDL HAL.
+class GatekeeperHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static GatekeeperHidlEnvironment* Instance() {
+ static GatekeeperHidlEnvironment* instance = new GatekeeperHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IGatekeeper>(); }
+ private:
+ GatekeeperHidlEnvironment() {}
+};
+
// The main test class for Gatekeeper HIDL HAL.
class GatekeeperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
@@ -189,7 +204,8 @@
GatekeeperHidlTest() : uid_(0) {}
virtual void SetUp() override {
GatekeeperResponse rsp;
- gatekeeper_ = ::testing::VtsHalHidlTargetTestBase::getService<IGatekeeper>();
+ gatekeeper_ = ::testing::VtsHalHidlTargetTestBase::getService<IGatekeeper>(
+ GatekeeperHidlEnvironment::Instance()->getServiceName<IGatekeeper>());
ASSERT_NE(nullptr, gatekeeper_.get());
doDeleteAllUsers(rsp);
}
@@ -433,7 +449,9 @@
}
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(GatekeeperHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ GatekeeperHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
diff --git a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
index b3ab594..010a46d 100644
--- a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
+++ b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
@@ -19,6 +19,7 @@
#include <log/log.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <chrono>
#include <condition_variable>
@@ -41,6 +42,21 @@
bool sAgpsIsPresent = false; // if SUPL or XTRA assistance available
bool sSignalIsWeak = false; // if GNSS signals are weak (e.g. light indoor)
+// Test environment for GNSS HIDL HAL.
+class GnssHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static GnssHidlEnvironment* Instance() {
+ static GnssHidlEnvironment* instance = new GnssHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IGnss>(); }
+
+ private:
+ GnssHidlEnvironment() {}
+};
+
// The main test class for GNSS HAL.
class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
public:
@@ -51,7 +67,8 @@
info_called_count_ = 0;
notify_count_ = 0;
- gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>();
+ gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
+ GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
ASSERT_NE(gnss_hal_, nullptr);
gnss_cb_ = new GnssCallback(*this);
@@ -456,17 +473,19 @@
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(GnssHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ GnssHidlEnvironment::Instance()->init(&argc, argv);
/*
* These arguments not used by automated VTS testing.
* Only for use in manual testing, when wanting to run
* stronger tests that require the presence of GPS signal.
*/
for (int i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-agps") == 0) {
- sAgpsIsPresent = true;
- } else if (strcmp(argv[i], "-weak") == 0) {
- sSignalIsWeak = true;
+ if (strcmp(argv[i], "-agps") == 0) {
+ sAgpsIsPresent = true;
+ } else if (strcmp(argv[i], "-weak") == 0) {
+ sSignalIsWeak = true;
}
}
int status = RUN_ALL_TESTS();
diff --git a/gnss/1.1/vts/functional/VtsHalGnssV1_1TargetTest.cpp b/gnss/1.1/vts/functional/VtsHalGnssV1_1TargetTest.cpp
index 9b805e4..ca9eef4 100644
--- a/gnss/1.1/vts/functional/VtsHalGnssV1_1TargetTest.cpp
+++ b/gnss/1.1/vts/functional/VtsHalGnssV1_1TargetTest.cpp
@@ -13,12 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#define LOG_TAG "VtsHalGnssV1_1TargetTest"
#include <VtsHalHidlTargetTestBase.h>
+#include "gnss_hal_test.h"
+
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(GnssHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ GnssHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
-}
\ No newline at end of file
+}
diff --git a/gnss/1.1/vts/functional/gnss_hal_test.cpp b/gnss/1.1/vts/functional/gnss_hal_test.cpp
index 7e43b92..23b7317 100644
--- a/gnss/1.1/vts/functional/gnss_hal_test.cpp
+++ b/gnss/1.1/vts/functional/gnss_hal_test.cpp
@@ -27,7 +27,8 @@
notify_count_(0) {}
void GnssHalTest::SetUp() {
- gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>();
+ gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>(
+ GnssHidlEnvironment::Instance()->getServiceName<IGnss>());
list_gnss_sv_status_.clear();
ASSERT_NE(gnss_hal_, nullptr);
}
diff --git a/gnss/1.1/vts/functional/gnss_hal_test.h b/gnss/1.1/vts/functional/gnss_hal_test.h
index 6aab3cb..6d5bb4c 100644
--- a/gnss/1.1/vts/functional/gnss_hal_test.h
+++ b/gnss/1.1/vts/functional/gnss_hal_test.h
@@ -17,11 +17,10 @@
#ifndef GNSS_HAL_TEST_H_
#define GNSS_HAL_TEST_H_
-#define LOG_TAG "VtsHalGnssV1_1TargetTest"
-
#include <android/hardware/gnss/1.1/IGnss.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <condition_variable>
#include <list>
@@ -40,6 +39,21 @@
#define TIMEOUT_SEC 2 // for basic commands/responses
+// Test environment for GNSS HIDL HAL.
+class GnssHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static GnssHidlEnvironment* Instance() {
+ static GnssHidlEnvironment* instance = new GnssHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IGnss>(); }
+
+ private:
+ GnssHidlEnvironment() {}
+};
+
// The main test class for GNSS HAL.
class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
public:
diff --git a/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp b/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp
index 324eb9f..335d15d 100644
--- a/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp
+++ b/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp
@@ -19,7 +19,9 @@
#include <android/hardware/health/1.0/IHealth.h>
#include <android/hardware/health/1.0/types.h>
#include <log/log.h>
+
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using HealthConfig = ::android::hardware::health::V1_0::HealthConfig;
using HealthInfo = ::android::hardware::health::V1_0::HealthInfo;
@@ -28,10 +30,25 @@
using ::android::sp;
+// Test environment for Health HIDL HAL.
+class HealthHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static HealthHidlEnvironment* Instance() {
+ static HealthHidlEnvironment* instance = new HealthHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IHealth>(); }
+ private:
+ HealthHidlEnvironment() {}
+};
+
class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- health = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>();
+ health = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>(
+ HealthHidlEnvironment::Instance()->getServiceName<IHealth>());
ASSERT_NE(health, nullptr);
health->init(config,
[&](const auto& halConfigOut) { config = halConfigOut; });
@@ -57,7 +74,9 @@
}
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(HealthHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ HealthHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
diff --git a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
index a017404..5fd2dd4 100644
--- a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
+++ b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
@@ -22,6 +22,7 @@
#include <android/hardware/ir/1.0/types.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <algorithm>
using ::android::hardware::ir::V1_0::IConsumerIr;
@@ -30,11 +31,26 @@
using ::android::hardware::Return;
using ::android::sp;
+// Test environment for Ir
+class ConsumerIrHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ConsumerIrHidlEnvironment* Instance() {
+ static ConsumerIrHidlEnvironment* instance = new ConsumerIrHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IConsumerIr>(); }
+ private:
+ ConsumerIrHidlEnvironment() {}
+};
+
// The main test class for IR HIDL HAL.
class ConsumerIrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- ir = ::testing::VtsHalHidlTargetTestBase::getService<IConsumerIr>();
+ ir = ::testing::VtsHalHidlTargetTestBase::getService<IConsumerIr>(
+ ConsumerIrHidlEnvironment::Instance()->getServiceName<IConsumerIr>());
ASSERT_NE(ir, nullptr);
}
@@ -77,7 +93,9 @@
}
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(ConsumerIrHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ ConsumerIrHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
index 6abd9bf..fbe5237 100644
--- a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
+++ b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
@@ -33,19 +33,14 @@
#include "key_param_output.h"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include "attestation_record.h"
#include "openssl_utils.h"
using ::android::sp;
-
using ::std::string;
-// This service_name will be passed to getService when retrieving the keymaster service to test. To
-// change it from "default" specify the selected service name on the command line. The first
-// non-gtest argument will be used as the service name.
-string service_name = "default";
-
static bool arm_deleteAllKeys = false;
static bool dump_Attestations = false;
@@ -417,6 +412,20 @@
} // namespace
+// Test environment for Keymaster HIDL HAL.
+class KeymasterHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static KeymasterHidlEnvironment* Instance() {
+ static KeymasterHidlEnvironment* instance = new KeymasterHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IKeymasterDevice>(); }
+ private:
+ KeymasterHidlEnvironment() {}
+};
+
class KeymasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
void TearDown() override {
@@ -428,7 +437,8 @@
// SetUpTestCase runs only once per test case, not once per test.
static void SetUpTestCase() {
- keymaster_ = IKeymasterDevice::getService(service_name);
+ keymaster_ = ::testing::VtsHalHidlTargetTestBase::getService<IKeymasterDevice>(
+ KeymasterHidlEnvironment::Instance()->getServiceName<IKeymasterDevice>());
ASSERT_NE(keymaster_, nullptr);
ASSERT_TRUE(
@@ -2908,6 +2918,28 @@
}
/*
+ * EncryptionOperationsTest.AesEcbWithUserId
+ *
+ * Verifies that AES ECB mode works when Tag::USER_ID is specified.
+ */
+TEST_F(EncryptionOperationsTest, AesEcbWithUserId) {
+ string key = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ ASSERT_EQ(ErrorCode::OK, ImportKey(AuthorizationSetBuilder()
+ .Authorization(TAG_NO_AUTH_REQUIRED)
+ .Authorization(TAG_USER_ID, 0)
+ .AesEncryptionKey(key.size() * 8)
+ .EcbMode()
+ .Padding(PaddingMode::PKCS7),
+ KeyFormat::RAW, key));
+
+ string message = "Hello World!";
+ auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7);
+ string ciphertext = EncryptMessage(message, params);
+ string plaintext = DecryptMessage(ciphertext, params);
+ EXPECT_EQ(message, plaintext);
+}
+
+/*
* EncryptionOperationsTest.AesEcbRoundTripSuccess
*
* Verifies that AES encryption fails in the correct way when an unauthorized mode is specified.
@@ -4203,8 +4235,10 @@
} // namespace android
int main(int argc, char** argv) {
+ using android::hardware::keymaster::V3_0::test::KeymasterHidlEnvironment;
+ ::testing::AddGlobalTestEnvironment(KeymasterHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
- std::vector<std::string> positional_args;
+ KeymasterHidlEnvironment::Instance()->init(&argc, argv);
for (int i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
if (std::string(argv[i]) == "--arm_deleteAllKeys") {
@@ -4213,14 +4247,8 @@
if (std::string(argv[i]) == "--dump_attestations") {
dump_Attestations = true;
}
- } else {
- positional_args.push_back(argv[i]);
}
}
- if (positional_args.size()) {
- ALOGI("Running keymaster VTS against service \"%s\"", positional_args[0].c_str());
- service_name = positional_args[0];
- }
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
diff --git a/keymaster/4.0/support/Keymaster3.cpp b/keymaster/4.0/support/Keymaster3.cpp
index b2cdbd9..84b3ee1 100644
--- a/keymaster/4.0/support/Keymaster3.cpp
+++ b/keymaster/4.0/support/Keymaster3.cpp
@@ -61,9 +61,12 @@
}
hidl_vec<V3_0::KeyParameter> convert(const hidl_vec<KeyParameter>& params) {
- hidl_vec<V3_0::KeyParameter> converted(params.size());
- for (size_t i = 0; i < params.size(); ++i) {
- converted[i] = convert(params[i]);
+ std::vector<V3_0::KeyParameter> converted;
+ converted.reserve(params.size());
+ for (const auto& param : params) {
+ // Qualcomm's Keymaster3 implementation behaves oddly if Tag::USER_ID is provided. Filter it
+ // out. Revert this change when b/73286437 is fixed.
+ if (param.tag != Tag::USER_ID) converted.push_back(convert(param));
}
return converted;
}
diff --git a/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h b/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h
index 9d6501b..ce213bc 100644
--- a/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h
+++ b/keymaster/4.0/support/include/keymasterV4_0/keymaster_tags.h
@@ -142,24 +142,28 @@
DECLARE_TYPED_TAG(RSA_PUBLIC_EXPONENT);
DECLARE_TYPED_TAG(TRUSTED_CONFIRMATION_REQUIRED);
DECLARE_TYPED_TAG(UNIQUE_ID);
+DECLARE_TYPED_TAG(UNLOCKED_DEVICE_REQUIRED);
DECLARE_TYPED_TAG(USAGE_EXPIRE_DATETIME);
DECLARE_TYPED_TAG(USER_AUTH_TYPE);
+DECLARE_TYPED_TAG(USER_ID);
DECLARE_TYPED_TAG(USER_SECURE_ID);
template <typename... Elems>
struct MetaList {};
-using all_tags_t = MetaList<
- TAG_INVALID_t, TAG_KEY_SIZE_t, TAG_MAC_LENGTH_t, TAG_CALLER_NONCE_t, TAG_MIN_MAC_LENGTH_t,
- TAG_RSA_PUBLIC_EXPONENT_t, TAG_INCLUDE_UNIQUE_ID_t, TAG_ACTIVE_DATETIME_t,
- TAG_ORIGINATION_EXPIRE_DATETIME_t, TAG_USAGE_EXPIRE_DATETIME_t, TAG_MIN_SECONDS_BETWEEN_OPS_t,
- TAG_MAX_USES_PER_BOOT_t, TAG_USER_SECURE_ID_t, TAG_NO_AUTH_REQUIRED_t, TAG_AUTH_TIMEOUT_t,
- TAG_ALLOW_WHILE_ON_BODY_t, TAG_APPLICATION_ID_t, TAG_APPLICATION_DATA_t,
- TAG_CREATION_DATETIME_t, TAG_ROLLBACK_RESISTANCE_t, TAG_ROOT_OF_TRUST_t, TAG_ASSOCIATED_DATA_t,
- TAG_NONCE_t, TAG_BOOTLOADER_ONLY_t, TAG_OS_VERSION_t, TAG_OS_PATCHLEVEL_t, TAG_UNIQUE_ID_t,
- TAG_ATTESTATION_CHALLENGE_t, TAG_ATTESTATION_APPLICATION_ID_t, TAG_RESET_SINCE_ID_ROTATION_t,
- TAG_PURPOSE_t, TAG_ALGORITHM_t, TAG_BLOCK_MODE_t, TAG_DIGEST_t, TAG_PADDING_t,
- TAG_BLOB_USAGE_REQUIREMENTS_t, TAG_ORIGIN_t, TAG_USER_AUTH_TYPE_t, TAG_EC_CURVE_t>;
+using all_tags_t =
+ MetaList<TAG_INVALID_t, TAG_KEY_SIZE_t, TAG_MAC_LENGTH_t, TAG_CALLER_NONCE_t,
+ TAG_MIN_MAC_LENGTH_t, TAG_RSA_PUBLIC_EXPONENT_t, TAG_INCLUDE_UNIQUE_ID_t,
+ TAG_ACTIVE_DATETIME_t, TAG_ORIGINATION_EXPIRE_DATETIME_t, TAG_USAGE_EXPIRE_DATETIME_t,
+ TAG_MIN_SECONDS_BETWEEN_OPS_t, TAG_MAX_USES_PER_BOOT_t, TAG_USER_ID_t,
+ TAG_USER_SECURE_ID_t, TAG_NO_AUTH_REQUIRED_t, TAG_AUTH_TIMEOUT_t,
+ TAG_ALLOW_WHILE_ON_BODY_t, TAG_UNLOCKED_DEVICE_REQUIRED_t, TAG_APPLICATION_ID_t,
+ TAG_APPLICATION_DATA_t, TAG_CREATION_DATETIME_t, TAG_ROLLBACK_RESISTANCE_t,
+ TAG_ROOT_OF_TRUST_t, TAG_ASSOCIATED_DATA_t, TAG_NONCE_t, TAG_BOOTLOADER_ONLY_t,
+ TAG_OS_VERSION_t, TAG_OS_PATCHLEVEL_t, TAG_UNIQUE_ID_t, TAG_ATTESTATION_CHALLENGE_t,
+ TAG_ATTESTATION_APPLICATION_ID_t, TAG_RESET_SINCE_ID_ROTATION_t, TAG_PURPOSE_t,
+ TAG_ALGORITHM_t, TAG_BLOCK_MODE_t, TAG_DIGEST_t, TAG_PADDING_t,
+ TAG_BLOB_USAGE_REQUIREMENTS_t, TAG_ORIGIN_t, TAG_USER_AUTH_TYPE_t, TAG_EC_CURVE_t>;
template <typename TypedTagType>
struct TypedTag2ValueType;
@@ -343,6 +347,7 @@
case Tag::BOOTLOADER_ONLY:
case Tag::NO_AUTH_REQUIRED:
case Tag::ALLOW_WHILE_ON_BODY:
+ case Tag::UNLOCKED_DEVICE_REQUIRED:
case Tag::ROLLBACK_RESISTANCE:
case Tag::RESET_SINCE_ID_ROTATION:
case Tag::TRUSTED_CONFIRMATION_REQUIRED:
@@ -357,6 +362,7 @@
case Tag::OS_VERSION:
case Tag::OS_PATCHLEVEL:
case Tag::MAC_LENGTH:
+ case Tag::USER_ID:
case Tag::AUTH_TIMEOUT:
case Tag::VENDOR_PATCHLEVEL:
case Tag::BOOT_PATCHLEVEL:
diff --git a/keymaster/4.0/types.hal b/keymaster/4.0/types.hal
index 91ec9bf..47fd1ed 100644
--- a/keymaster/4.0/types.hal
+++ b/keymaster/4.0/types.hal
@@ -118,7 +118,8 @@
* boot. */
/* User authentication */
- // 500-501 reserved
+ // 500 reserved
+ USER_ID = TagType:UINT | 501, /* Android ID of authorized user or authenticator(s), */
USER_SECURE_ID = TagType:ULONG_REP | 502, /* Secure ID of authorized user or authenticator(s).
* Disallowed if NO_AUTH_REQUIRED is present. */
NO_AUTH_REQUIRED = TagType:BOOL | 503, /* If key is usable without authentication. */
@@ -191,6 +192,9 @@
* match the data described in the token, keymaster must return NO_USER_CONFIRMATION. */
TRUSTED_CONFIRMATION_REQUIRED = TagType:BOOL | 508,
+ UNLOCKED_DEVICE_REQUIRED = TagType:BOOL | 509, /* Require the device screen to be unlocked if
+ * the key is used. */
+
/* Application access control */
APPLICATION_ID = TagType:BYTES | 601, /* Byte string identifying the authorized application. */
@@ -471,6 +475,7 @@
PROOF_OF_PRESENCE_REQUIRED = -69,
CONCURRENT_PROOF_OF_PRESENCE_REQUESTED = -70,
NO_USER_CONFIRMATION = -71,
+ DEVICE_LOCKED = -72,
UNIMPLEMENTED = -100,
VERSION_MISMATCH = -101,
diff --git a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
index 3405422..13290d9 100644
--- a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
+++ b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp
@@ -16,12 +16,13 @@
#define LOG_TAG "light_hidl_hal_test"
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/light/2.0/ILight.h>
#include <android/hardware/light/2.0/types.h>
-#include <VtsHalHidlTargetTestBase.h>
-#include <set>
#include <unistd.h>
+#include <set>
using ::android::hardware::light::V2_0::Brightness;
using ::android::hardware::light::V2_0::Flash;
@@ -72,10 +73,25 @@
Type::WIFI
};
+// Test environment for Light HIDL HAL.
+class LightHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static LightHidlEnvironment* Instance() {
+ static LightHidlEnvironment* instance = new LightHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<ILight>(); }
+ private:
+ LightHidlEnvironment() {}
+};
+
class LightHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- light = ::testing::VtsHalHidlTargetTestBase::getService<ILight>();
+ light = ::testing::VtsHalHidlTargetTestBase::getService<ILight>(
+ LightHidlEnvironment::Instance()->getServiceName<ILight>());
ASSERT_NE(light, nullptr);
LOG(INFO) << "Test is remote " << light->isRemote();
@@ -149,7 +165,9 @@
}
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(LightHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ LightHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
index 38cdcd6..42f9947 100644
--- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
+++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp
@@ -50,85 +50,6 @@
#include <media_hidl_test_common.h>
#include <fstream>
-// A class for test environment setup
-class ComponentTestEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
-
- void setInstance(const char* _instance) { instance = _instance; }
-
- void setComponent(const char* _component) { component = _component; }
-
- void setRole(const char* _role) { role = _role; }
-
- void setRes(const char* _res) { res = _res; }
-
- const hidl_string getInstance() const { return instance; }
-
- const hidl_string getComponent() const { return component; }
-
- const hidl_string getRole() const { return role; }
-
- const hidl_string getRes() const { return res; }
-
- int initFromOptions(int argc, char** argv) {
- static struct option options[] = {
- {"instance", required_argument, 0, 'I'},
- {"component", required_argument, 0, 'C'},
- {"role", required_argument, 0, 'R'},
- {"res", required_argument, 0, 'P'},
- {0, 0, 0, 0}};
-
- while (true) {
- int index = 0;
- int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
- if (c == -1) {
- break;
- }
-
- switch (c) {
- case 'I':
- setInstance(optarg);
- break;
- case 'C':
- setComponent(optarg);
- break;
- case 'R':
- setRole(optarg);
- break;
- case 'P':
- setRes(optarg);
- break;
- case '?':
- break;
- }
- }
-
- if (optind < argc) {
- fprintf(stderr,
- "unrecognized option: %s\n\n"
- "usage: %s <gtest options> <test options>\n\n"
- "test options are:\n\n"
- "-I, --instance: HAL instance to test\n"
- "-C, --component: OMX component to test\n"
- "-R, --role: OMX component Role\n"
- "-P, --res: Resource files directory location\n",
- argv[optind ?: 1], argv[0]);
- return 2;
- }
- return 0;
- }
-
- private:
- hidl_string instance;
- hidl_string component;
- hidl_string role;
- hidl_string res;
-};
-
static ComponentTestEnvironment* gEnv = nullptr;
// audio decoder test fixture class
@@ -1220,6 +1141,7 @@
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
index 953dc75..d5f1f2d 100644
--- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
+++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp
@@ -50,85 +50,6 @@
#include <media_hidl_test_common.h>
#include <fstream>
-// A class for test environment setup
-class ComponentTestEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
-
- void setInstance(const char* _instance) { instance = _instance; }
-
- void setComponent(const char* _component) { component = _component; }
-
- void setRole(const char* _role) { role = _role; }
-
- void setRes(const char* _res) { res = _res; }
-
- const hidl_string getInstance() const { return instance; }
-
- const hidl_string getComponent() const { return component; }
-
- const hidl_string getRole() const { return role; }
-
- const hidl_string getRes() const { return res; }
-
- int initFromOptions(int argc, char** argv) {
- static struct option options[] = {
- {"instance", required_argument, 0, 'I'},
- {"component", required_argument, 0, 'C'},
- {"role", required_argument, 0, 'R'},
- {"res", required_argument, 0, 'P'},
- {0, 0, 0, 0}};
-
- while (true) {
- int index = 0;
- int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
- if (c == -1) {
- break;
- }
-
- switch (c) {
- case 'I':
- setInstance(optarg);
- break;
- case 'C':
- setComponent(optarg);
- break;
- case 'R':
- setRole(optarg);
- break;
- case 'P':
- setRes(optarg);
- break;
- case '?':
- break;
- }
- }
-
- if (optind < argc) {
- fprintf(stderr,
- "unrecognized option: %s\n\n"
- "usage: %s <gtest options> <test options>\n\n"
- "test options are:\n\n"
- "-I, --instance: HAL instance to test\n"
- "-C, --component: OMX component to test\n"
- "-R, --role: OMX component Role\n"
- "-P, --res: Resource files directory location\n",
- argv[optind ?: 1], argv[0]);
- return 2;
- }
- return 0;
- }
-
- private:
- hidl_string instance;
- hidl_string component;
- hidl_string role;
- hidl_string res;
-};
-
static ComponentTestEnvironment* gEnv = nullptr;
// audio encoder test fixture class
@@ -562,6 +483,7 @@
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();
diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
index bec733d..c1863d5 100644
--- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
+++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h
@@ -21,6 +21,7 @@
#define OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
#endif
+#include <getopt.h>
#include <media/stagefright/foundation/ALooper.h>
#include <utils/Condition.h>
#include <utils/List.h>
@@ -33,6 +34,8 @@
#include <media/openmax/OMX_AudioExt.h>
#include <media/openmax/OMX_VideoExt.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
/* TIME OUTS (Wait time in dequeueMessage()) */
/* As component is switching states (loaded<->idle<->execute), dequeueMessage()
@@ -355,4 +358,77 @@
portreconfig fptr = nullptr, OMX_U32 kPortIndexInput = 0,
OMX_U32 kPortIndexOutput = 1, void* args = nullptr);
+// A class for test environment setup
+class ComponentTestEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ private:
+ typedef ::testing::VtsHalHidlTargetTestEnvBase Super;
+
+ public:
+ virtual void registerTestServices() override { registerTestService<IOmx>(); }
+
+ ComponentTestEnvironment() : res("/sdcard/media/") {}
+
+ void setComponent(const char* _component) { component = _component; }
+
+ void setRole(const char* _role) { role = _role; }
+
+ void setRes(const char* _res) { res = _res; }
+
+ const hidl_string getInstance() { return Super::getServiceName<IOmx>(); }
+
+ const hidl_string getComponent() const { return component; }
+
+ const hidl_string getRole() const { return role; }
+
+ const hidl_string getRes() const { return res; }
+
+ int initFromOptions(int argc, char** argv) {
+ static struct option options[] = {{"component", required_argument, 0, 'C'},
+ {"role", required_argument, 0, 'R'},
+ {"res", required_argument, 0, 'P'},
+ {0, 0, 0, 0}};
+
+ while (true) {
+ int index = 0;
+ int c = getopt_long(argc, argv, "C:R:P:", options, &index);
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'C':
+ setComponent(optarg);
+ break;
+ case 'R':
+ setRole(optarg);
+ break;
+ case 'P':
+ setRes(optarg);
+ break;
+ case '?':
+ break;
+ }
+ }
+
+ if (optind < argc) {
+ fprintf(stderr,
+ "unrecognized option: %s\n\n"
+ "usage: %s <gtest options> <test options>\n\n"
+ "test options are:\n\n"
+ "-C, --component: OMX component to test\n"
+ "-R, --role: OMX component Role\n"
+ "-P, --res: Resource files directory location\n",
+ argv[optind ?: 1], argv[0]);
+ return 2;
+ }
+ return 0;
+ }
+
+ private:
+ hidl_string instance;
+ hidl_string component;
+ hidl_string role;
+ hidl_string res;
+};
+
#endif // MEDIA_HIDL_TEST_COMMON_H
diff --git a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
index d66136d..f7c8433 100644
--- a/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
+++ b/media/omx/1.0/vts/functional/component/VtsHalMediaOmxV1_0TargetComponentTest.cpp
@@ -48,75 +48,6 @@
#include <getopt.h>
#include <media_hidl_test_common.h>
-// A class for test environment setup
-class ComponentTestEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- ComponentTestEnvironment() : instance("default") {}
-
- void setInstance(const char* _instance) { instance = _instance; }
-
- void setComponent(const char* _component) { component = _component; }
-
- void setRole(const char* _role) { role = _role; }
-
- const hidl_string getInstance() const { return instance; }
-
- const hidl_string getComponent() const { return component; }
-
- const hidl_string getRole() const { return role; }
-
- int initFromOptions(int argc, char** argv) {
- static struct option options[] = {
- {"instance", required_argument, 0, 'I'},
- {"component", required_argument, 0, 'C'},
- {"role", required_argument, 0, 'R'},
- {0, 0, 0, 0}};
-
- while (true) {
- int index = 0;
- int c = getopt_long(argc, argv, "I:C:R:", options, &index);
- if (c == -1) {
- break;
- }
-
- switch (c) {
- case 'I':
- setInstance(optarg);
- break;
- case 'C':
- setComponent(optarg);
- break;
- case 'R':
- setRole(optarg);
- break;
- case '?':
- break;
- }
- }
-
- if (optind < argc) {
- fprintf(stderr,
- "unrecognized option: %s\n\n"
- "usage: %s <gtest options> <test options>\n\n"
- "test options are:\n\n"
- "-I, --instance: HAL instance to test\n"
- "-C, --component: OMX component to test\n"
- "-R, --Role: OMX component Role\n",
- argv[optind ?: 1], argv[0]);
- return 2;
- }
- return 0;
- }
-
- private:
- hidl_string instance;
- hidl_string component;
- hidl_string role;
-};
-
static ComponentTestEnvironment* gEnv = nullptr;
// generic component test fixture class
@@ -1321,6 +1252,7 @@
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();
diff --git a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp
index 5a31d69..64abe1c 100644
--- a/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp
+++ b/media/omx/1.0/vts/functional/master/VtsHalMediaOmxV1_0TargetMasterTest.cpp
@@ -50,54 +50,6 @@
#include <getopt.h>
#include <media_hidl_test_common.h>
-// A class for test environment setup
-class ComponentTestEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- ComponentTestEnvironment() : instance("default") {}
-
- void setInstance(const char* _instance) { instance = _instance; }
-
- const hidl_string getInstance() const { return instance; }
-
- int initFromOptions(int argc, char** argv) {
- static struct option options[] = {
- {"instance", required_argument, 0, 'I'}, {0, 0, 0, 0}};
-
- while (true) {
- int index = 0;
- int c = getopt_long(argc, argv, "I:", options, &index);
- if (c == -1) {
- break;
- }
-
- switch (c) {
- case 'I':
- setInstance(optarg);
- break;
- case '?':
- break;
- }
- }
-
- if (optind < argc) {
- fprintf(stderr,
- "unrecognized option: %s\n\n"
- "usage: %s <gtest options> <test options>\n\n"
- "test options are:\n\n"
- "-I, --instance: HAL instance to test\n",
- argv[optind ?: 1], argv[0]);
- return 2;
- }
- return 0;
- }
-
- private:
- hidl_string instance;
-};
-
static ComponentTestEnvironment* gEnv = nullptr;
class MasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
@@ -226,6 +178,7 @@
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
index 034992e..40e76c9 100644
--- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
+++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp
@@ -51,85 +51,6 @@
#include <media_video_hidl_test_common.h>
#include <fstream>
-// A class for test environment setup
-class ComponentTestEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
-
- void setInstance(const char* _instance) { instance = _instance; }
-
- void setComponent(const char* _component) { component = _component; }
-
- void setRole(const char* _role) { role = _role; }
-
- void setRes(const char* _res) { res = _res; }
-
- const hidl_string getInstance() const { return instance; }
-
- const hidl_string getComponent() const { return component; }
-
- const hidl_string getRole() const { return role; }
-
- const hidl_string getRes() const { return res; }
-
- int initFromOptions(int argc, char** argv) {
- static struct option options[] = {
- {"instance", required_argument, 0, 'I'},
- {"component", required_argument, 0, 'C'},
- {"role", required_argument, 0, 'R'},
- {"res", required_argument, 0, 'P'},
- {0, 0, 0, 0}};
-
- while (true) {
- int index = 0;
- int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
- if (c == -1) {
- break;
- }
-
- switch (c) {
- case 'I':
- setInstance(optarg);
- break;
- case 'C':
- setComponent(optarg);
- break;
- case 'R':
- setRole(optarg);
- break;
- case 'P':
- setRes(optarg);
- break;
- case '?':
- break;
- }
- }
-
- if (optind < argc) {
- fprintf(stderr,
- "unrecognized option: %s\n\n"
- "usage: %s <gtest options> <test options>\n\n"
- "test options are:\n\n"
- "-I, --instance: HAL instance to test\n"
- "-C, --component: OMX component to test\n"
- "-R, --role: OMX component Role\n"
- "-P, --res: Resource files directory location\n",
- argv[optind ?: 1], argv[0]);
- return 2;
- }
- return 0;
- }
-
- private:
- hidl_string instance;
- hidl_string component;
- hidl_string role;
- hidl_string res;
-};
-
static ComponentTestEnvironment* gEnv = nullptr;
// video decoder test fixture class
@@ -1488,6 +1409,7 @@
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp
index 099658f..2056d9e 100644
--- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp
+++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp
@@ -64,85 +64,6 @@
#include <system/window.h>
#include <fstream>
-// A class for test environment setup
-class ComponentTestEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- ComponentTestEnvironment() : instance("default"), res("/sdcard/media/") {}
-
- void setInstance(const char* _instance) { instance = _instance; }
-
- void setComponent(const char* _component) { component = _component; }
-
- void setRole(const char* _role) { role = _role; }
-
- void setRes(const char* _res) { res = _res; }
-
- const hidl_string getInstance() const { return instance; }
-
- const hidl_string getComponent() const { return component; }
-
- const hidl_string getRole() const { return role; }
-
- const hidl_string getRes() const { return res; }
-
- int initFromOptions(int argc, char** argv) {
- static struct option options[] = {
- {"instance", required_argument, 0, 'I'},
- {"component", required_argument, 0, 'C'},
- {"role", required_argument, 0, 'R'},
- {"res", required_argument, 0, 'P'},
- {0, 0, 0, 0}};
-
- while (true) {
- int index = 0;
- int c = getopt_long(argc, argv, "I:C:R:P:", options, &index);
- if (c == -1) {
- break;
- }
-
- switch (c) {
- case 'I':
- setInstance(optarg);
- break;
- case 'C':
- setComponent(optarg);
- break;
- case 'R':
- setRole(optarg);
- break;
- case 'P':
- setRes(optarg);
- break;
- case '?':
- break;
- }
- }
-
- if (optind < argc) {
- fprintf(stderr,
- "unrecognized option: %s\n\n"
- "usage: %s <gtest options> <test options>\n\n"
- "test options are:\n\n"
- "-I, --instance: HAL instance to test\n"
- "-C, --component: OMX component to test\n"
- "-R, --role: OMX component Role\n"
- "-P, --res: Resource files directory location\n",
- argv[optind ?: 1], argv[0]);
- return 2;
- }
- return 0;
- }
-
- private:
- hidl_string instance;
- hidl_string component;
- hidl_string role;
- hidl_string res;
-};
-
static ComponentTestEnvironment* gEnv = nullptr;
// video encoder test fixture class
@@ -1580,6 +1501,7 @@
gEnv = new ComponentTestEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();
diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp
index e33ee77..54dd14a 100644
--- a/neuralnetworks/1.0/vts/functional/Android.bp
+++ b/neuralnetworks/1.0/vts/functional/Android.bp
@@ -14,22 +14,49 @@
// limitations under the License.
//
+cc_library_static {
+ name: "VtsHalNeuralnetworksTest_utils",
+ srcs: [
+ "Callbacks.cpp",
+ "Models.cpp",
+ "GeneratedTestHarness.cpp",
+ ],
+ defaults: ["VtsHalTargetTestDefaults"],
+ export_include_dirs: ["."],
+ static_libs: [
+ "android.hardware.neuralnetworks@1.0",
+ "android.hardware.neuralnetworks@1.1",
+ "android.hidl.allocator@1.0",
+ "android.hidl.memory@1.0",
+ "libhidlmemory",
+ "libneuralnetworks_utils",
+ ],
+ header_libs: [
+ "libneuralnetworks_headers",
+ "libneuralnetworks_generated_test_harness_headers",
+ "libneuralnetworks_generated_tests",
+ ],
+}
+
cc_test {
name: "VtsHalNeuralnetworksV1_0TargetTest",
srcs: [
- "Callbacks.cpp",
- "GeneratedTestHarness.cpp",
- "Models.cpp",
- "VtsHalNeuralnetworksV1_0TargetTest.cpp",
+ "VtsHalNeuralnetworksV1_0.cpp",
+ "VtsHalNeuralnetworksV1_0BasicTest.cpp",
+ "VtsHalNeuralnetworksV1_0GeneratedTest.cpp",
],
defaults: ["VtsHalTargetTestDefaults"],
static_libs: [
"android.hardware.neuralnetworks@1.0",
+ "android.hardware.neuralnetworks@1.1",
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",
"libhidlmemory",
+ "libneuralnetworks_utils",
+ "VtsHalNeuralnetworksTest_utils",
],
header_libs: [
+ "libneuralnetworks_headers",
"libneuralnetworks_generated_test_harness_headers",
"libneuralnetworks_generated_tests",
],
diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
index d740b5f..5fe8415 100644
--- a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
@@ -16,9 +16,15 @@
#include "Callbacks.h"
#include "TestHarness.h"
-#include "VtsHalNeuralnetworksV1_0TargetTest.h"
+#include "Utils.h"
#include <android-base/logging.h>
+#include <android/hardware/neuralnetworks/1.0/IDevice.h>
+#include <android/hardware/neuralnetworks/1.0/IExecutionCallback.h>
+#include <android/hardware/neuralnetworks/1.0/IPreparedModel.h>
+#include <android/hardware/neuralnetworks/1.0/IPreparedModelCallback.h>
+#include <android/hardware/neuralnetworks/1.0/types.h>
+#include <android/hidl/allocator/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMemory.h>
#include <hidlmemory/mapping.h>
#include <iostream>
@@ -26,11 +32,6 @@
namespace android {
namespace hardware {
namespace neuralnetworks {
-namespace V1_0 {
-namespace vts {
-namespace functional {
-// allocator helper
-hidl_memory allocateSharedMemory(int64_t size, const std::string& type = "ashmem");
namespace generated_tests {
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
@@ -64,54 +65,10 @@
// Top level driver for models and examples generated by test_generator.py
// Test driver for those generated from ml/nn/runtime/test/spec
-void Execute(const sp<IDevice>& device, std::function<Model(void)> create_model,
- std::function<bool(int)> is_ignored,
- const std::vector<MixedTypedExampleType>& examples) {
+void EvaluatePreparedModel(sp<IPreparedModel>& preparedModel, std::function<bool(int)> is_ignored,
+ const std::vector<MixedTypedExampleType>& examples) {
const uint32_t INPUT = 0;
const uint32_t OUTPUT = 1;
- Model model = create_model();
-
- // see if service can handle model
- ErrorStatus supportedStatus;
- bool fullySupportsModel = false;
- Return<void> supportedCall = device->getSupportedOperations(
- model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
- supportedStatus = status;
- ASSERT_NE(0ul, supported.size());
- fullySupportsModel =
- std::all_of(supported.begin(), supported.end(), [](bool valid) { return valid; });
- });
- ASSERT_TRUE(supportedCall.isOk());
- ASSERT_EQ(ErrorStatus::NONE, supportedStatus);
-
- // launch prepare model
- sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
- ASSERT_NE(nullptr, preparedModelCallback.get());
- Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
- ASSERT_TRUE(prepareLaunchStatus.isOk());
-
- // retrieve prepared model
- preparedModelCallback->wait();
- ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
- sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
- if (fullySupportsModel) {
- EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus);
- } else {
- EXPECT_TRUE(prepareReturnStatus == ErrorStatus::NONE ||
- prepareReturnStatus == ErrorStatus::GENERAL_FAILURE);
- }
-
- // early termination if vendor service cannot fully prepare model
- if (!fullySupportsModel && prepareReturnStatus == ErrorStatus::GENERAL_FAILURE) {
- ASSERT_EQ(nullptr, preparedModel.get());
- LOG(INFO) << "NN VTS: Early termination of test because vendor service cannot "
- "prepare model that it does not support.";
- std::cout << "[ ] Early termination of test because vendor service cannot "
- "prepare model that it does not support."
- << std::endl;
- return;
- }
- ASSERT_NE(nullptr, preparedModel.get());
int example_no = 1;
for (auto& example : examples) {
@@ -167,8 +124,8 @@
offset += i.location.length;
}
}
- std::vector<hidl_memory> pools = {allocateSharedMemory(inputSize),
- allocateSharedMemory(outputSize)};
+ std::vector<hidl_memory> pools = {nn::allocateSharedMemory(inputSize),
+ nn::allocateSharedMemory(outputSize)};
ASSERT_NE(0ull, pools[INPUT].size());
ASSERT_NE(0ull, pools[OUTPUT].size());
@@ -221,11 +178,107 @@
}
}
+void Execute(sp<V1_0::IDevice>& device, std::function<V1_0::Model(void)> create_model,
+ std::function<bool(int)> is_ignored,
+ const std::vector<MixedTypedExampleType>& examples) {
+ V1_0::Model model = create_model();
+
+ // see if service can handle model
+ bool fullySupportsModel = false;
+ ErrorStatus supportedStatus;
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+
+ Return<void> supportedCall = device->getSupportedOperations(
+ model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
+ supportedStatus = status;
+ ASSERT_NE(0ul, supported.size());
+ fullySupportsModel =
+ std::all_of(supported.begin(), supported.end(), [](bool valid) { return valid; });
+ });
+ ASSERT_TRUE(supportedCall.isOk());
+ ASSERT_EQ(ErrorStatus::NONE, supportedStatus);
+ Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+
+ // retrieve prepared model
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
+ if (fullySupportsModel) {
+ EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus);
+ } else {
+ EXPECT_TRUE(prepareReturnStatus == ErrorStatus::NONE ||
+ prepareReturnStatus == ErrorStatus::GENERAL_FAILURE);
+ }
+
+ // early termination if vendor service cannot fully prepare model
+ if (!fullySupportsModel && prepareReturnStatus == ErrorStatus::GENERAL_FAILURE) {
+ ASSERT_EQ(nullptr, preparedModel.get());
+ LOG(INFO) << "NN VTS: Early termination of test because vendor service cannot "
+ "prepare model that it does not support.";
+ std::cout << "[ ] Early termination of test because vendor service cannot "
+ "prepare model that it does not support."
+ << std::endl;
+ return;
+ }
+ ASSERT_NE(nullptr, preparedModel.get());
+
+ EvaluatePreparedModel(preparedModel, is_ignored, examples);
+}
+
+void Execute(sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> create_model,
+ std::function<bool(int)> is_ignored,
+ const std::vector<MixedTypedExampleType>& examples) {
+ V1_1::Model model = create_model();
+
+ // see if service can handle model
+ bool fullySupportsModel = false;
+ ErrorStatus supportedStatus;
+ sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
+ ASSERT_NE(nullptr, preparedModelCallback.get());
+
+ Return<void> supportedCall = device->getSupportedOperations_1_1(
+ model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
+ supportedStatus = status;
+ ASSERT_NE(0ul, supported.size());
+ fullySupportsModel =
+ std::all_of(supported.begin(), supported.end(), [](bool valid) { return valid; });
+ });
+ ASSERT_TRUE(supportedCall.isOk());
+ ASSERT_EQ(ErrorStatus::NONE, supportedStatus);
+ Return<ErrorStatus> prepareLaunchStatus =
+ device->prepareModel_1_1(model, preparedModelCallback);
+ ASSERT_TRUE(prepareLaunchStatus.isOk());
+
+ // retrieve prepared model
+ preparedModelCallback->wait();
+ ErrorStatus prepareReturnStatus = preparedModelCallback->getStatus();
+ sp<IPreparedModel> preparedModel = preparedModelCallback->getPreparedModel();
+ if (fullySupportsModel) {
+ EXPECT_EQ(ErrorStatus::NONE, prepareReturnStatus);
+ } else {
+ EXPECT_TRUE(prepareReturnStatus == ErrorStatus::NONE ||
+ prepareReturnStatus == ErrorStatus::GENERAL_FAILURE);
+ }
+
+ // early termination if vendor service cannot fully prepare model
+ if (!fullySupportsModel && prepareReturnStatus == ErrorStatus::GENERAL_FAILURE) {
+ ASSERT_EQ(nullptr, preparedModel.get());
+ LOG(INFO) << "NN VTS: Early termination of test because vendor service cannot "
+ "prepare model that it does not support.";
+ std::cout << "[ ] Early termination of test because vendor service cannot "
+ "prepare model that it does not support."
+ << std::endl;
+ return;
+ }
+ ASSERT_NE(nullptr, preparedModel.get());
+
+ EvaluatePreparedModel(preparedModel, is_ignored, examples);
+}
+
} // namespace generated_tests
-} // namespace functional
-} // namespace vts
-} // namespace V1_0
} // namespace neuralnetworks
} // namespace hardware
} // namespace android
diff --git a/neuralnetworks/1.0/vts/functional/Models.cpp b/neuralnetworks/1.0/vts/functional/Models.cpp
index 8ce4f25..180286a 100644
--- a/neuralnetworks/1.0/vts/functional/Models.cpp
+++ b/neuralnetworks/1.0/vts/functional/Models.cpp
@@ -17,19 +17,22 @@
#define LOG_TAG "neuralnetworks_hidl_hal_test"
#include "Models.h"
+#include "Utils.h"
+
+#include <android-base/logging.h>
+#include <android/hidl/allocator/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMemory.h>
#include <hidlmemory/mapping.h>
#include <vector>
+using ::android::sp;
+
namespace android {
namespace hardware {
namespace neuralnetworks {
-namespace V1_0 {
-namespace vts {
-namespace functional {
// create a valid model
-Model createValidTestModel() {
+V1_1::Model createValidTestModel_1_1() {
const std::vector<float> operand2Data = {5.0f, 6.0f, 7.0f, 8.0f};
const uint32_t size = operand2Data.size() * sizeof(float);
@@ -103,39 +106,34 @@
}
// create first invalid model
-Model createInvalidTestModel1() {
- Model model = createValidTestModel();
+V1_1::Model createInvalidTestModel1_1_1() {
+ Model model = createValidTestModel_1_1();
model.operations[0].type = static_cast<OperationType>(0xDEADBEEF); /* INVALID */
return model;
}
// create second invalid model
-Model createInvalidTestModel2() {
- Model model = createValidTestModel();
+V1_1::Model createInvalidTestModel2_1_1() {
+ Model model = createValidTestModel_1_1();
const uint32_t operand1 = 0;
const uint32_t operand5 = 4; // INVALID OPERAND
model.inputIndexes = std::vector<uint32_t>({operand1, operand5 /* INVALID OPERAND */});
return model;
}
-// allocator helper
-hidl_memory allocateSharedMemory(int64_t size, const std::string& type = "ashmem") {
- hidl_memory memory;
+V1_0::Model createValidTestModel_1_0() {
+ V1_1::Model model = createValidTestModel_1_1();
+ return nn::convertToV1_0(model);
+}
- sp<IAllocator> allocator = IAllocator::getService(type);
- if (!allocator.get()) {
- return {};
- }
+V1_0::Model createInvalidTestModel1_1_0() {
+ V1_1::Model model = createInvalidTestModel1_1_1();
+ return nn::convertToV1_0(model);
+}
- Return<void> ret = allocator->allocate(size, [&](bool success, const hidl_memory& mem) {
- ASSERT_TRUE(success);
- memory = mem;
- });
- if (!ret.isOk()) {
- return {};
- }
-
- return memory;
+V1_0::Model createInvalidTestModel2_1_0() {
+ V1_1::Model model = createInvalidTestModel2_1_1();
+ return nn::convertToV1_0(model);
}
// create a valid request
@@ -154,8 +152,8 @@
std::vector<RequestArgument> outputs = {{
.location = {.poolIndex = OUTPUT, .offset = 0, .length = outputSize}, .dimensions = {},
}};
- std::vector<hidl_memory> pools = {allocateSharedMemory(inputSize),
- allocateSharedMemory(outputSize)};
+ std::vector<hidl_memory> pools = {nn::allocateSharedMemory(inputSize),
+ nn::allocateSharedMemory(outputSize)};
if (pools[INPUT].size() == 0 || pools[OUTPUT].size() == 0) {
return {};
}
@@ -199,9 +197,6 @@
return request;
}
-} // namespace functional
-} // namespace vts
-} // namespace V1_0
} // namespace neuralnetworks
} // namespace hardware
} // namespace android
diff --git a/neuralnetworks/1.0/vts/functional/Models.h b/neuralnetworks/1.0/vts/functional/Models.h
index e0d57d5..9398235 100644
--- a/neuralnetworks/1.0/vts/functional/Models.h
+++ b/neuralnetworks/1.0/vts/functional/Models.h
@@ -16,28 +16,27 @@
#define LOG_TAG "neuralnetworks_hidl_hal_test"
-#include "VtsHalNeuralnetworksV1_0TargetTest.h"
+#include <android/hardware/neuralnetworks/1.1/types.h>
namespace android {
namespace hardware {
namespace neuralnetworks {
-namespace V1_0 {
-namespace vts {
-namespace functional {
-// create the model
-Model createValidTestModel();
-Model createInvalidTestModel1();
-Model createInvalidTestModel2();
+// create V1_1 model
+V1_1::Model createValidTestModel_1_1();
+V1_1::Model createInvalidTestModel1_1_1();
+V1_1::Model createInvalidTestModel2_1_1();
+
+// create V1_0 model
+V1_0::Model createValidTestModel_1_0();
+V1_0::Model createInvalidTestModel1_1_0();
+V1_0::Model createInvalidTestModel2_1_0();
// create the request
-Request createValidTestRequest();
-Request createInvalidTestRequest1();
-Request createInvalidTestRequest2();
+V1_0::Request createValidTestRequest();
+V1_0::Request createInvalidTestRequest1();
+V1_0::Request createInvalidTestRequest2();
-} // namespace functional
-} // namespace vts
-} // namespace V1_0
} // namespace neuralnetworks
} // namespace hardware
} // namespace android
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0.cpp
new file mode 100644
index 0000000..b14fb2c
--- /dev/null
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
+
+#include "VtsHalNeuralnetworksV1_0.h"
+#include "Utils.h"
+
+#include <android-base/logging.h>
+
+using ::android::hardware::hidl_memory;
+using ::android::hidl::allocator::V1_0::IAllocator;
+using ::android::hidl::memory::V1_0::IMemory;
+using ::android::sp;
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+namespace V1_0 {
+namespace vts {
+namespace functional {
+
+// allocator helper
+hidl_memory allocateSharedMemory(int64_t size) {
+ return nn::allocateSharedMemory(size);
+}
+
+// A class for test environment setup
+NeuralnetworksHidlEnvironment::NeuralnetworksHidlEnvironment() {}
+
+NeuralnetworksHidlEnvironment::~NeuralnetworksHidlEnvironment() {}
+
+NeuralnetworksHidlEnvironment* NeuralnetworksHidlEnvironment::getInstance() {
+ // This has to return a "new" object because it is freed inside
+ // ::testing::AddGlobalTestEnvironment when the gtest is being torn down
+ static NeuralnetworksHidlEnvironment* instance = new NeuralnetworksHidlEnvironment();
+ return instance;
+}
+
+void NeuralnetworksHidlEnvironment::registerTestServices() {
+ registerTestService<V1_0::IDevice>();
+}
+
+// The main test class for NEURALNETWORK HIDL HAL.
+NeuralnetworksHidlTest::~NeuralnetworksHidlTest() {}
+
+void NeuralnetworksHidlTest::SetUp() {
+ device = ::testing::VtsHalHidlTargetTestBase::getService<V1_0::IDevice>(
+ NeuralnetworksHidlEnvironment::getInstance());
+ ASSERT_NE(nullptr, device.get());
+}
+
+void NeuralnetworksHidlTest::TearDown() {}
+
+} // namespace functional
+} // namespace vts
+} // namespace V1_0
+} // namespace neuralnetworks
+} // namespace hardware
+} // namespace android
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0.h
similarity index 69%
rename from neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h
rename to neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0.h
index 5cd209a..fbb1607 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -29,23 +29,6 @@
#include <gtest/gtest.h>
#include <string>
-using ::android::hardware::neuralnetworks::V1_0::IDevice;
-using ::android::hardware::neuralnetworks::V1_0::IPreparedModel;
-using ::android::hardware::neuralnetworks::V1_0::Capabilities;
-using ::android::hardware::neuralnetworks::V1_0::DeviceStatus;
-using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc;
-using ::android::hardware::neuralnetworks::V1_0::Model;
-using ::android::hardware::neuralnetworks::V1_0::OperationType;
-using ::android::hardware::neuralnetworks::V1_0::PerformanceInfo;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hidl::allocator::V1_0::IAllocator;
-using ::android::hidl::memory::V1_0::IMemory;
-using ::android::sp;
-
namespace android {
namespace hardware {
namespace neuralnetworks {
@@ -53,6 +36,8 @@
namespace vts {
namespace functional {
+hidl_memory allocateSharedMemory(int64_t size);
+
// A class for test environment setup
class NeuralnetworksHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
NeuralnetworksHidlEnvironment();
@@ -74,25 +59,22 @@
void SetUp() override;
void TearDown() override;
- sp<IPreparedModel> doPrepareModelShortcut();
-
- sp<IDevice> device;
+ sp<V1_0::IDevice> device;
};
-
} // namespace functional
} // namespace vts
// pretty-print values for error messages
-template<typename CharT, typename Traits>
+template <typename CharT, typename Traits>
::std::basic_ostream<CharT, Traits>& operator<<(::std::basic_ostream<CharT, Traits>& os,
- ErrorStatus errorStatus) {
+ V1_0::ErrorStatus errorStatus) {
return os << toString(errorStatus);
}
-template<typename CharT, typename Traits>
+template <typename CharT, typename Traits>
::std::basic_ostream<CharT, Traits>& operator<<(::std::basic_ostream<CharT, Traits>& os,
- DeviceStatus deviceStatus) {
+ V1_0::DeviceStatus deviceStatus) {
return os << toString(deviceStatus);
}
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0BasicTest.cpp
similarity index 80%
rename from neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
rename to neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0BasicTest.cpp
index b99e20e..e838997 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0BasicTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
#define LOG_TAG "neuralnetworks_hidl_hal_test"
-#include "VtsHalNeuralnetworksV1_0TargetTest.h"
+#include "VtsHalNeuralnetworksV1_0.h"
#include "Callbacks.h"
#include "Models.h"
@@ -26,51 +26,34 @@
#include <android/hidl/memory/1.0/IMemory.h>
#include <hidlmemory/mapping.h>
+using ::android::hardware::neuralnetworks::V1_0::IDevice;
+using ::android::hardware::neuralnetworks::V1_0::IPreparedModel;
+using ::android::hardware::neuralnetworks::V1_0::Capabilities;
+using ::android::hardware::neuralnetworks::V1_0::DeviceStatus;
+using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc;
+using ::android::hardware::neuralnetworks::V1_0::Model;
+using ::android::hardware::neuralnetworks::V1_0::OperationType;
+using ::android::hardware::neuralnetworks::V1_0::PerformanceInfo;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hidl::allocator::V1_0::IAllocator;
+using ::android::hidl::memory::V1_0::IMemory;
+using ::android::sp;
+
namespace android {
namespace hardware {
namespace neuralnetworks {
namespace V1_0 {
namespace vts {
namespace functional {
-
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
-using ::generated_tests::MixedTypedExampleType;
-namespace generated_tests {
-extern void Execute(const sp<IDevice>&, std::function<Model(void)>, std::function<bool(int)>,
- const std::vector<MixedTypedExampleType>&);
-}
-
-// A class for test environment setup
-NeuralnetworksHidlEnvironment::NeuralnetworksHidlEnvironment() {}
-
-NeuralnetworksHidlEnvironment::~NeuralnetworksHidlEnvironment() {}
-
-NeuralnetworksHidlEnvironment* NeuralnetworksHidlEnvironment::getInstance() {
- // This has to return a "new" object because it is freed inside
- // ::testing::AddGlobalTestEnvironment when the gtest is being torn down
- static NeuralnetworksHidlEnvironment* instance = new NeuralnetworksHidlEnvironment();
- return instance;
-}
-
-void NeuralnetworksHidlEnvironment::registerTestServices() {
- registerTestService<IDevice>();
-}
-
-// The main test class for NEURALNETWORK HIDL HAL.
-NeuralnetworksHidlTest::~NeuralnetworksHidlTest() {}
-
-void NeuralnetworksHidlTest::SetUp() {
- device = ::testing::VtsHalHidlTargetTestBase::getService<IDevice>(
- NeuralnetworksHidlEnvironment::getInstance());
- ASSERT_NE(nullptr, device.get());
-}
-
-void NeuralnetworksHidlTest::TearDown() {}
-
-sp<IPreparedModel> NeuralnetworksHidlTest::doPrepareModelShortcut() {
- Model model = createValidTestModel();
+inline sp<IPreparedModel> doPrepareModelShortcut(sp<IDevice>& device) {
+ Model model = createValidTestModel_1_0();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
if (preparedModelCallback == nullptr) {
@@ -116,7 +99,7 @@
// supported operations positive test
TEST_F(NeuralnetworksHidlTest, SupportedOperationsPositiveTest) {
- Model model = createValidTestModel();
+ Model model = createValidTestModel_1_0();
Return<void> ret = device->getSupportedOperations(
model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
EXPECT_EQ(ErrorStatus::NONE, status);
@@ -127,7 +110,7 @@
// supported operations negative test 1
TEST_F(NeuralnetworksHidlTest, SupportedOperationsNegativeTest1) {
- Model model = createInvalidTestModel1();
+ Model model = createInvalidTestModel1_1_0();
Return<void> ret = device->getSupportedOperations(
model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, status);
@@ -138,7 +121,7 @@
// supported operations negative test 2
TEST_F(NeuralnetworksHidlTest, SupportedOperationsNegativeTest2) {
- Model model = createInvalidTestModel2();
+ Model model = createInvalidTestModel2_1_0();
Return<void> ret = device->getSupportedOperations(
model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, status);
@@ -149,7 +132,7 @@
// prepare simple model positive test
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelPositiveTest) {
- Model model = createValidTestModel();
+ Model model = createValidTestModel_1_0();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
ASSERT_NE(nullptr, preparedModelCallback.get());
Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
@@ -165,7 +148,7 @@
// prepare simple model negative test 1
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelNegativeTest1) {
- Model model = createInvalidTestModel1();
+ Model model = createInvalidTestModel1_1_0();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
ASSERT_NE(nullptr, preparedModelCallback.get());
Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
@@ -181,7 +164,7 @@
// prepare simple model negative test 2
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelNegativeTest2) {
- Model model = createInvalidTestModel2();
+ Model model = createInvalidTestModel2_1_0();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
ASSERT_NE(nullptr, preparedModelCallback.get());
Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
@@ -201,7 +184,7 @@
std::vector<float> expectedData = {6.0f, 8.0f, 10.0f, 12.0f};
const uint32_t OUTPUT = 1;
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut(device);
ASSERT_NE(nullptr, preparedModel.get());
Request request = createValidTestRequest();
@@ -235,7 +218,7 @@
// execute simple graph negative test 1
TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphNegativeTest1) {
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut(device);
ASSERT_NE(nullptr, preparedModel.get());
Request request = createInvalidTestRequest1();
@@ -252,7 +235,7 @@
// execute simple graph negative test 2
TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphNegativeTest2) {
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut(device);
ASSERT_NE(nullptr, preparedModel.get());
Request request = createInvalidTestRequest2();
@@ -267,16 +250,6 @@
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, executionReturnStatus);
}
-// Mixed-typed examples
-typedef MixedTypedExampleType MixedTypedExample;
-
-// in frameworks/ml/nn/runtime/tests/generated/
-#include "all_generated_vts_tests.cpp"
-
-// TODO: Add tests for execution failure, or wait_for/wait_until timeout.
-// Discussion:
-// https://googleplex-android-review.git.corp.google.com/#/c/platform/hardware/interfaces/+/2654636/5/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp@222
-
} // namespace functional
} // namespace vts
} // namespace V1_0
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0GeneratedTest.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0GeneratedTest.cpp
new file mode 100644
index 0000000..b99aef7
--- /dev/null
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0GeneratedTest.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
+
+#include "VtsHalNeuralnetworksV1_0.h"
+
+#include "Callbacks.h"
+#include "TestHarness.h"
+
+#include <android-base/logging.h>
+#include <android/hidl/memory/1.0/IMemory.h>
+#include <hidlmemory/mapping.h>
+
+using ::android::hardware::neuralnetworks::V1_0::IDevice;
+using ::android::hardware::neuralnetworks::V1_0::IPreparedModel;
+using ::android::hardware::neuralnetworks::V1_0::Capabilities;
+using ::android::hardware::neuralnetworks::V1_0::DeviceStatus;
+using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc;
+using ::android::hardware::neuralnetworks::V1_0::Model;
+using ::android::hardware::neuralnetworks::V1_0::OperationType;
+using ::android::hardware::neuralnetworks::V1_0::PerformanceInfo;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hidl::allocator::V1_0::IAllocator;
+using ::android::hidl::memory::V1_0::IMemory;
+using ::android::sp;
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+
+namespace generated_tests {
+using ::generated_tests::MixedTypedExampleType;
+extern void Execute(sp<IDevice>&, std::function<Model(void)>, std::function<bool(int)>,
+ const std::vector<MixedTypedExampleType>&);
+} // namespace generated_tests
+
+namespace V1_0 {
+namespace vts {
+namespace functional {
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
+using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
+
+// Mixed-typed examples
+typedef generated_tests::MixedTypedExampleType MixedTypedExample;
+
+// in frameworks/ml/nn/runtime/tests/generated/
+#include "all_generated_V1_0_vts_tests.cpp"
+
+} // namespace functional
+} // namespace vts
+} // namespace V1_0
+} // namespace neuralnetworks
+} // namespace hardware
+} // namespace android
diff --git a/neuralnetworks/1.1/vts/OWNERS b/neuralnetworks/1.1/vts/OWNERS
new file mode 100644
index 0000000..7f75ab3
--- /dev/null
+++ b/neuralnetworks/1.1/vts/OWNERS
@@ -0,0 +1,10 @@
+# Neuralnetworks team
+butlermichael@google.com
+dgross@google.com
+jeanluc@google.com
+miaowang@google.com
+yangni@google.com
+
+# VTS team
+yim@google.com
+yuexima@google.com
diff --git a/neuralnetworks/1.1/vts/functional/Android.bp b/neuralnetworks/1.1/vts/functional/Android.bp
new file mode 100644
index 0000000..623b441
--- /dev/null
+++ b/neuralnetworks/1.1/vts/functional/Android.bp
@@ -0,0 +1,39 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_test {
+ name: "VtsHalNeuralnetworksV1_1TargetTest",
+ srcs: [
+ "VtsHalNeuralnetworksV1_1.cpp",
+ "VtsHalNeuralnetworksV1_1BasicTest.cpp",
+ "VtsHalNeuralnetworksV1_1GeneratedTest.cpp",
+ ],
+ defaults: ["VtsHalTargetTestDefaults"],
+ static_libs: [
+ "android.hardware.neuralnetworks@1.0",
+ "android.hardware.neuralnetworks@1.1",
+ "android.hidl.allocator@1.0",
+ "android.hidl.memory@1.0",
+ "libhidlmemory",
+ "libneuralnetworks_utils",
+ "VtsHalNeuralnetworksTest_utils",
+ ],
+ header_libs: [
+ "libneuralnetworks_headers",
+ "libneuralnetworks_generated_test_harness_headers",
+ "libneuralnetworks_generated_tests",
+ ],
+}
diff --git a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1.cpp b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1.cpp
new file mode 100644
index 0000000..b1d3be7
--- /dev/null
+++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
+
+#include "VtsHalNeuralnetworksV1_1.h"
+#include "Utils.h"
+
+#include <android-base/logging.h>
+#include <hidlmemory/mapping.h>
+
+using ::android::hardware::hidl_memory;
+using ::android::hidl::allocator::V1_0::IAllocator;
+using ::android::hidl::memory::V1_0::IMemory;
+using ::android::sp;
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+namespace V1_1 {
+namespace vts {
+namespace functional {
+
+// allocator helper
+hidl_memory allocateSharedMemory(int64_t size) {
+ return nn::allocateSharedMemory(size);
+}
+
+// A class for test environment setup
+NeuralnetworksHidlEnvironment::NeuralnetworksHidlEnvironment() {}
+
+NeuralnetworksHidlEnvironment::~NeuralnetworksHidlEnvironment() {}
+
+NeuralnetworksHidlEnvironment* NeuralnetworksHidlEnvironment::getInstance() {
+ // This has to return a "new" object because it is freed inside
+ // ::testing::AddGlobalTestEnvironment when the gtest is being torn down
+ static NeuralnetworksHidlEnvironment* instance = new NeuralnetworksHidlEnvironment();
+ return instance;
+}
+
+void NeuralnetworksHidlEnvironment::registerTestServices() {
+ registerTestService<V1_1::IDevice>();
+}
+
+// The main test class for NEURALNETWORK HIDL HAL.
+NeuralnetworksHidlTest::~NeuralnetworksHidlTest() {}
+
+void NeuralnetworksHidlTest::SetUp() {
+ device = ::testing::VtsHalHidlTargetTestBase::getService<V1_1::IDevice>(
+ NeuralnetworksHidlEnvironment::getInstance());
+ ASSERT_NE(nullptr, device.get());
+}
+
+void NeuralnetworksHidlTest::TearDown() {}
+
+} // namespace functional
+} // namespace vts
+} // namespace V1_1
+} // namespace neuralnetworks
+} // namespace hardware
+} // namespace android
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1.h
similarity index 61%
copy from neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h
copy to neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1.h
index 5cd209a..426246c 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.h
+++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-#ifndef VTS_HAL_NEURALNETWORKS_V1_0_TARGET_TESTS_H
-#define VTS_HAL_NEURALNETWORKS_V1_0_TARGET_TESTS_H
+#ifndef VTS_HAL_NEURALNETWORKS_V1_1_H
+#define VTS_HAL_NEURALNETWORKS_V1_1_H
-#include <android/hardware/neuralnetworks/1.0/IDevice.h>
#include <android/hardware/neuralnetworks/1.0/IExecutionCallback.h>
#include <android/hardware/neuralnetworks/1.0/IPreparedModel.h>
#include <android/hardware/neuralnetworks/1.0/IPreparedModelCallback.h>
-#include <android/hardware/neuralnetworks/1.0/types.h>
+#include <android/hardware/neuralnetworks/1.1/IDevice.h>
+#include <android/hardware/neuralnetworks/1.1/types.h>
#include <android/hidl/allocator/1.0/IAllocator.h>
#include <VtsHalHidlTargetTestBase.h>
@@ -29,29 +29,13 @@
#include <gtest/gtest.h>
#include <string>
-using ::android::hardware::neuralnetworks::V1_0::IDevice;
-using ::android::hardware::neuralnetworks::V1_0::IPreparedModel;
-using ::android::hardware::neuralnetworks::V1_0::Capabilities;
-using ::android::hardware::neuralnetworks::V1_0::DeviceStatus;
-using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc;
-using ::android::hardware::neuralnetworks::V1_0::Model;
-using ::android::hardware::neuralnetworks::V1_0::OperationType;
-using ::android::hardware::neuralnetworks::V1_0::PerformanceInfo;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hidl::allocator::V1_0::IAllocator;
-using ::android::hidl::memory::V1_0::IMemory;
-using ::android::sp;
-
namespace android {
namespace hardware {
namespace neuralnetworks {
-namespace V1_0 {
+namespace V1_1 {
namespace vts {
namespace functional {
+hidl_memory allocateSharedMemory(int64_t size);
// A class for test environment setup
class NeuralnetworksHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
@@ -74,31 +58,28 @@
void SetUp() override;
void TearDown() override;
- sp<IPreparedModel> doPrepareModelShortcut();
-
- sp<IDevice> device;
+ sp<V1_1::IDevice> device;
};
-
} // namespace functional
} // namespace vts
// pretty-print values for error messages
-template<typename CharT, typename Traits>
+template <typename CharT, typename Traits>
::std::basic_ostream<CharT, Traits>& operator<<(::std::basic_ostream<CharT, Traits>& os,
- ErrorStatus errorStatus) {
+ V1_0::ErrorStatus errorStatus) {
return os << toString(errorStatus);
}
-template<typename CharT, typename Traits>
+template <typename CharT, typename Traits>
::std::basic_ostream<CharT, Traits>& operator<<(::std::basic_ostream<CharT, Traits>& os,
- DeviceStatus deviceStatus) {
+ V1_0::DeviceStatus deviceStatus) {
return os << toString(deviceStatus);
}
-} // namespace V1_0
+} // namespace V1_1
} // namespace neuralnetworks
} // namespace hardware
} // namespace android
-#endif // VTS_HAL_NEURALNETWORKS_V1_0_TARGET_TESTS_H
+#endif // VTS_HAL_NEURALNETWORKS_V1_1_H
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1BasicTest.cpp
similarity index 74%
copy from neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
copy to neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1BasicTest.cpp
index b99e20e..51eff2a 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
+++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1BasicTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,67 +16,58 @@
#define LOG_TAG "neuralnetworks_hidl_hal_test"
-#include "VtsHalNeuralnetworksV1_0TargetTest.h"
+#include "VtsHalNeuralnetworksV1_1.h"
#include "Callbacks.h"
#include "Models.h"
#include "TestHarness.h"
#include <android-base/logging.h>
+#include <android/hardware/neuralnetworks/1.1/IDevice.h>
+#include <android/hardware/neuralnetworks/1.1/types.h>
#include <android/hidl/memory/1.0/IMemory.h>
#include <hidlmemory/mapping.h>
+using ::android::hardware::neuralnetworks::V1_0::IPreparedModel;
+using ::android::hardware::neuralnetworks::V1_0::Capabilities;
+using ::android::hardware::neuralnetworks::V1_0::DeviceStatus;
+using ::android::hardware::neuralnetworks::V1_0::ErrorStatus;
+using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc;
+using ::android::hardware::neuralnetworks::V1_0::Operand;
+using ::android::hardware::neuralnetworks::V1_0::OperandLifeTime;
+using ::android::hardware::neuralnetworks::V1_0::OperandType;
+using ::android::hardware::neuralnetworks::V1_0::Request;
+using ::android::hardware::neuralnetworks::V1_1::IDevice;
+using ::android::hardware::neuralnetworks::V1_1::Model;
+using ::android::hardware::neuralnetworks::V1_1::Operation;
+using ::android::hardware::neuralnetworks::V1_1::OperationType;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hidl::allocator::V1_0::IAllocator;
+using ::android::hidl::memory::V1_0::IMemory;
+using ::android::sp;
+
namespace android {
namespace hardware {
namespace neuralnetworks {
-namespace V1_0 {
+namespace V1_1 {
namespace vts {
namespace functional {
-
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
-using ::generated_tests::MixedTypedExampleType;
-namespace generated_tests {
-extern void Execute(const sp<IDevice>&, std::function<Model(void)>, std::function<bool(int)>,
- const std::vector<MixedTypedExampleType>&);
-}
-
-// A class for test environment setup
-NeuralnetworksHidlEnvironment::NeuralnetworksHidlEnvironment() {}
-
-NeuralnetworksHidlEnvironment::~NeuralnetworksHidlEnvironment() {}
-
-NeuralnetworksHidlEnvironment* NeuralnetworksHidlEnvironment::getInstance() {
- // This has to return a "new" object because it is freed inside
- // ::testing::AddGlobalTestEnvironment when the gtest is being torn down
- static NeuralnetworksHidlEnvironment* instance = new NeuralnetworksHidlEnvironment();
- return instance;
-}
-
-void NeuralnetworksHidlEnvironment::registerTestServices() {
- registerTestService<IDevice>();
-}
-
-// The main test class for NEURALNETWORK HIDL HAL.
-NeuralnetworksHidlTest::~NeuralnetworksHidlTest() {}
-
-void NeuralnetworksHidlTest::SetUp() {
- device = ::testing::VtsHalHidlTargetTestBase::getService<IDevice>(
- NeuralnetworksHidlEnvironment::getInstance());
- ASSERT_NE(nullptr, device.get());
-}
-
-void NeuralnetworksHidlTest::TearDown() {}
-
-sp<IPreparedModel> NeuralnetworksHidlTest::doPrepareModelShortcut() {
- Model model = createValidTestModel();
+inline sp<IPreparedModel> doPrepareModelShortcut(sp<IDevice>& device) {
+ Model model = createValidTestModel_1_1();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
if (preparedModelCallback == nullptr) {
return nullptr;
}
- Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ Return<ErrorStatus> prepareLaunchStatus =
+ device->prepareModel_1_1(model, preparedModelCallback);
if (!prepareLaunchStatus.isOk() || prepareLaunchStatus != ErrorStatus::NONE) {
return nullptr;
}
@@ -116,8 +107,8 @@
// supported operations positive test
TEST_F(NeuralnetworksHidlTest, SupportedOperationsPositiveTest) {
- Model model = createValidTestModel();
- Return<void> ret = device->getSupportedOperations(
+ Model model = createValidTestModel_1_1();
+ Return<void> ret = device->getSupportedOperations_1_1(
model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
EXPECT_EQ(ErrorStatus::NONE, status);
EXPECT_EQ(model.operations.size(), supported.size());
@@ -127,8 +118,8 @@
// supported operations negative test 1
TEST_F(NeuralnetworksHidlTest, SupportedOperationsNegativeTest1) {
- Model model = createInvalidTestModel1();
- Return<void> ret = device->getSupportedOperations(
+ Model model = createInvalidTestModel1_1_1();
+ Return<void> ret = device->getSupportedOperations_1_1(
model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, status);
(void)supported;
@@ -138,8 +129,8 @@
// supported operations negative test 2
TEST_F(NeuralnetworksHidlTest, SupportedOperationsNegativeTest2) {
- Model model = createInvalidTestModel2();
- Return<void> ret = device->getSupportedOperations(
+ Model model = createInvalidTestModel2_1_1();
+ Return<void> ret = device->getSupportedOperations_1_1(
model, [&](ErrorStatus status, const hidl_vec<bool>& supported) {
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, status);
(void)supported;
@@ -149,10 +140,11 @@
// prepare simple model positive test
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelPositiveTest) {
- Model model = createValidTestModel();
+ Model model = createValidTestModel_1_1();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
ASSERT_NE(nullptr, preparedModelCallback.get());
- Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ Return<ErrorStatus> prepareLaunchStatus =
+ device->prepareModel_1_1(model, preparedModelCallback);
ASSERT_TRUE(prepareLaunchStatus.isOk());
EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(prepareLaunchStatus));
@@ -165,10 +157,11 @@
// prepare simple model negative test 1
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelNegativeTest1) {
- Model model = createInvalidTestModel1();
+ Model model = createInvalidTestModel1_1_1();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
ASSERT_NE(nullptr, preparedModelCallback.get());
- Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ Return<ErrorStatus> prepareLaunchStatus =
+ device->prepareModel_1_1(model, preparedModelCallback);
ASSERT_TRUE(prepareLaunchStatus.isOk());
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(prepareLaunchStatus));
@@ -181,10 +174,11 @@
// prepare simple model negative test 2
TEST_F(NeuralnetworksHidlTest, SimplePrepareModelNegativeTest2) {
- Model model = createInvalidTestModel2();
+ Model model = createInvalidTestModel2_1_1();
sp<PreparedModelCallback> preparedModelCallback = new PreparedModelCallback();
ASSERT_NE(nullptr, preparedModelCallback.get());
- Return<ErrorStatus> prepareLaunchStatus = device->prepareModel(model, preparedModelCallback);
+ Return<ErrorStatus> prepareLaunchStatus =
+ device->prepareModel_1_1(model, preparedModelCallback);
ASSERT_TRUE(prepareLaunchStatus.isOk());
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(prepareLaunchStatus));
@@ -201,7 +195,7 @@
std::vector<float> expectedData = {6.0f, 8.0f, 10.0f, 12.0f};
const uint32_t OUTPUT = 1;
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut(device);
ASSERT_NE(nullptr, preparedModel.get());
Request request = createValidTestRequest();
@@ -235,7 +229,7 @@
// execute simple graph negative test 1
TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphNegativeTest1) {
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut(device);
ASSERT_NE(nullptr, preparedModel.get());
Request request = createInvalidTestRequest1();
@@ -252,7 +246,7 @@
// execute simple graph negative test 2
TEST_F(NeuralnetworksHidlTest, SimpleExecuteGraphNegativeTest2) {
- sp<IPreparedModel> preparedModel = doPrepareModelShortcut();
+ sp<IPreparedModel> preparedModel = doPrepareModelShortcut(device);
ASSERT_NE(nullptr, preparedModel.get());
Request request = createInvalidTestRequest2();
@@ -267,24 +261,14 @@
EXPECT_EQ(ErrorStatus::INVALID_ARGUMENT, executionReturnStatus);
}
-// Mixed-typed examples
-typedef MixedTypedExampleType MixedTypedExample;
-
-// in frameworks/ml/nn/runtime/tests/generated/
-#include "all_generated_vts_tests.cpp"
-
-// TODO: Add tests for execution failure, or wait_for/wait_until timeout.
-// Discussion:
-// https://googleplex-android-review.git.corp.google.com/#/c/platform/hardware/interfaces/+/2654636/5/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp@222
-
} // namespace functional
} // namespace vts
-} // namespace V1_0
+} // namespace V1_1
} // namespace neuralnetworks
} // namespace hardware
} // namespace android
-using android::hardware::neuralnetworks::V1_0::vts::functional::NeuralnetworksHidlEnvironment;
+using android::hardware::neuralnetworks::V1_1::vts::functional::NeuralnetworksHidlEnvironment;
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(NeuralnetworksHidlEnvironment::getInstance());
diff --git a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1GeneratedTest.cpp b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1GeneratedTest.cpp
new file mode 100644
index 0000000..025d9fe
--- /dev/null
+++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworksV1_1GeneratedTest.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2018 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 "neuralnetworks_hidl_hal_test"
+
+#include "VtsHalNeuralnetworksV1_1.h"
+
+#include "Callbacks.h"
+#include "TestHarness.h"
+
+#include <android-base/logging.h>
+#include <android/hardware/neuralnetworks/1.1/IDevice.h>
+#include <android/hardware/neuralnetworks/1.1/types.h>
+#include <android/hidl/memory/1.0/IMemory.h>
+#include <hidlmemory/mapping.h>
+
+using ::android::hardware::neuralnetworks::V1_0::IPreparedModel;
+using ::android::hardware::neuralnetworks::V1_0::Capabilities;
+using ::android::hardware::neuralnetworks::V1_0::DeviceStatus;
+using ::android::hardware::neuralnetworks::V1_0::ErrorStatus;
+using ::android::hardware::neuralnetworks::V1_0::FusedActivationFunc;
+using ::android::hardware::neuralnetworks::V1_0::Operand;
+using ::android::hardware::neuralnetworks::V1_0::OperandLifeTime;
+using ::android::hardware::neuralnetworks::V1_0::OperandType;
+using ::android::hardware::neuralnetworks::V1_0::Request;
+using ::android::hardware::neuralnetworks::V1_1::IDevice;
+using ::android::hardware::neuralnetworks::V1_1::Model;
+using ::android::hardware::neuralnetworks::V1_1::Operation;
+using ::android::hardware::neuralnetworks::V1_1::OperationType;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hidl::allocator::V1_0::IAllocator;
+using ::android::hidl::memory::V1_0::IMemory;
+using ::android::sp;
+
+namespace android {
+namespace hardware {
+namespace neuralnetworks {
+
+namespace generated_tests {
+using ::generated_tests::MixedTypedExampleType;
+extern void Execute(sp<V1_1::IDevice>&, std::function<Model(void)>, std::function<bool(int)>,
+ const std::vector<MixedTypedExampleType>&);
+} // namespace generated_tests
+
+namespace V1_1 {
+namespace vts {
+namespace functional {
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
+using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
+
+// Mixed-typed examples
+typedef generated_tests::MixedTypedExampleType MixedTypedExample;
+
+// in frameworks/ml/nn/runtime/tests/generated/
+#include "all_generated_V1_0_vts_tests.cpp"
+#include "all_generated_V1_1_vts_tests.cpp"
+
+} // namespace functional
+} // namespace vts
+} // namespace V1_1
+} // namespace neuralnetworks
+} // namespace hardware
+} // namespace android
diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
index 2f00fbb..e17c961 100644
--- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
+++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
@@ -24,6 +24,7 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::hardware::nfc::V1_0::INfc;
using ::android::hardware::nfc::V1_0::INfcClientCallback;
@@ -93,11 +94,26 @@
};
};
+// Test environment for Nfc HIDL HAL.
+class NfcHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static NfcHidlEnvironment* Instance() {
+ static NfcHidlEnvironment* instance = new NfcHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<INfc>(); }
+ private:
+ NfcHidlEnvironment() {}
+};
+
// The main test class for NFC HIDL HAL.
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>();
+ nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>(
+ NfcHidlEnvironment::Instance()->getServiceName<INfc>());
ASSERT_NE(nfc_, nullptr);
nfc_cb_ = new NfcClientCallback();
@@ -163,15 +179,6 @@
sp<NfcClientCallback> nfc_cb_;
};
-// A class for test environment setup (kept since this file is a template).
-class NfcHidlEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- private:
-};
-
/*
* OpenAndClose:
* Makes an open call, waits for NfcEvent.OPEN_CPLT
@@ -586,8 +593,9 @@
}
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ NfcHidlEnvironment::Instance()->init(&argc, argv);
std::system("svc nfc disable"); /* Turn off NFC */
sleep(5);
diff --git a/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp b/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp
index a5b40d4..bef412b 100644
--- a/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp
+++ b/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp
@@ -25,6 +25,7 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::hardware::nfc::V1_1::INfc;
using ::android::hardware::nfc::V1_1::INfcClientCallback;
@@ -78,6 +79,20 @@
};
};
+// Test environment for Nfc HIDL HAL.
+class NfcHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static NfcHidlEnvironment* Instance() {
+ static NfcHidlEnvironment* instance = new NfcHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<INfc>(); }
+ private:
+ NfcHidlEnvironment() {}
+};
+
// The main test class for NFC HIDL HAL.
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
@@ -127,15 +142,6 @@
sp<NfcClientCallback> nfc_cb_;
};
-// A class for test environment setup (kept since this file is a template).
-class NfcHidlEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- private:
-};
-
/*
* factoryReset
* calls factoryReset()
@@ -204,8 +210,9 @@
}
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ NfcHidlEnvironment::Instance()->init(&argc, argv);
std::system("svc nfc disable"); /* Turn off NFC */
sleep(5);
diff --git a/radio/1.0/types.hal b/radio/1.0/types.hal
index 4d22bc0..6787a82 100644
--- a/radio/1.0/types.hal
+++ b/radio/1.0/types.hal
@@ -1292,10 +1292,9 @@
// from cell to device.
// Approximate distance is calculated using
// 300m/us * timingAdvance.
- // Range: 0 to 0x7FFFFFFE
- // INT_MAX : 0x7FFFFFFF denotes invalid value.
- // Reference: 3GPP 36.321 section 6.1.3.5
- // also: http://www.cellular-planningoptimization.com/2010/02/timing-advance-with-calculation.html
+ // Range: 0 to 1282 inclusive.
+ // INT_MAX : 0x7FFFFFFF denotes unknown value.
+ // Reference: 3GPP 36.213 section 4.2.3
};
struct TdScdmaSignalStrength {
diff --git a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
index a3eb54c..d53c062 100644
--- a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
+++ b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp
@@ -17,7 +17,9 @@
#include <radio_hidl_hal_utils_v1_0.h>
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(RadioHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ RadioHidlEnvironment::Instance()->init(&argc, argv);
// setup seed for rand function
int seedSrand = time(NULL);
@@ -28,4 +30,4 @@
LOG(INFO) << "Test result = " << status;
return status;
-}
\ No newline at end of file
+}
diff --git a/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp b/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp
index 84b67c9..859e6fb 100644
--- a/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp
+++ b/radio/1.0/vts/functional/VtsHalSapV1_0TargetTest.cpp
@@ -17,7 +17,9 @@
#include <sap_hidl_hal_utils.h>
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(SapHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ SapHidlEnvironment::Instance()->init(&argc, argv);
// setup seed for rand function
int seedSrand = time(NULL);
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 1c7653b..d9c00ce 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
@@ -17,12 +17,13 @@
#include <radio_hidl_hal_utils_v1_0.h>
void RadioHidlTest::SetUp() {
- radio =
- ::testing::VtsHalHidlTargetTestBase::getService<IRadio>(hidl_string(RADIO_SERVICE_NAME));
+ radio = ::testing::VtsHalHidlTargetTestBase::getService<IRadio>(
+ RadioHidlEnvironment::Instance()->getServiceName<IRadio>(hidl_string(RADIO_SERVICE_NAME)));
if (radio == NULL) {
sleep(60);
radio = ::testing::VtsHalHidlTargetTestBase::getService<IRadio>(
- hidl_string(RADIO_SERVICE_NAME));
+ RadioHidlEnvironment::Instance()->getServiceName<IRadio>(
+ hidl_string(RADIO_SERVICE_NAME)));
}
ASSERT_NE(nullptr, radio.get());
@@ -67,4 +68,4 @@
}
count--;
return status;
-}
\ No newline at end of file
+}
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
index 6b95ab0..15ac0b8 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
+++ b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h
@@ -17,6 +17,7 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -511,6 +512,20 @@
const ::android::hardware::hidl_string& reason);
};
+// Test environment for Radio HIDL HAL.
+class RadioHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static RadioHidlEnvironment* Instance() {
+ static RadioHidlEnvironment* instance = new RadioHidlEnvironment;
+ return instance;
+ }
+ virtual void registerTestServices() override { registerTestService<IRadio>(); }
+
+ private:
+ RadioHidlEnvironment() {}
+};
+
// The main test class for Radio HIDL.
class RadioHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_test.cpp b/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
index fc8cb2a..79668bb 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
@@ -17,7 +17,8 @@
#include <sap_hidl_hal_utils.h>
void SapHidlTest::SetUp() {
- sap = ::testing::VtsHalHidlTargetTestBase::getService<ISap>(hidl_string(SAP_SERVICE_NAME));
+ sap = ::testing::VtsHalHidlTargetTestBase::getService<ISap>(
+ SapHidlEnvironment::Instance()->getServiceName<ISap>(hidl_string(SAP_SERVICE_NAME)));
ASSERT_NE(sap, nullptr);
sapCb = new SapCallback(*this);
@@ -49,4 +50,4 @@
}
count--;
return status;
-}
\ No newline at end of file
+}
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_utils.h b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
index fb142b7..ec237dc 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
@@ -17,6 +17,7 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -79,6 +80,20 @@
Return<void> transferProtocolResponse(int32_t token, SapResultCode resultCode);
};
+// Test environment for Sap HIDL HAL.
+class SapHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static SapHidlEnvironment* Instance() {
+ static SapHidlEnvironment* instance = new SapHidlEnvironment;
+ return instance;
+ }
+ virtual void registerTestServices() override { registerTestService<ISap>(); }
+
+ private:
+ SapHidlEnvironment() {}
+};
+
// The main test class for Sap HIDL.
class SapHidlTest : public ::testing::VtsHalHidlTargetTestBase {
private:
@@ -102,4 +117,4 @@
/* Sap Callback object */
sp<SapCallback> sapCb;
-};
\ No newline at end of file
+};
diff --git a/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
index 107a9e0..83564ee 100644
--- a/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
+++ b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp
@@ -17,10 +17,10 @@
#include <radio_hidl_hal_utils_v1_1.h>
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(RadioHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
-
+ RadioHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
-
return status;
-}
\ No newline at end of file
+}
diff --git a/radio/1.1/vts/functional/radio_hidl_hal_test.cpp b/radio/1.1/vts/functional/radio_hidl_hal_test.cpp
index 773d165..6d16cd8 100644
--- a/radio/1.1/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.1/vts/functional/radio_hidl_hal_test.cpp
@@ -19,11 +19,16 @@
void RadioHidlTest_v1_1::SetUp() {
radio_v1_1 =
::testing::VtsHalHidlTargetTestBase::getService<::android::hardware::radio::V1_1::IRadio>(
- hidl_string(RADIO_SERVICE_NAME));
+ RadioHidlEnvironment::Instance()
+ ->getServiceName<::android::hardware::radio::V1_1::IRadio>(
+ hidl_string(RADIO_SERVICE_NAME)));
if (radio_v1_1 == NULL) {
sleep(60);
radio_v1_1 = ::testing::VtsHalHidlTargetTestBase::getService<
- ::android::hardware::radio::V1_1::IRadio>(hidl_string(RADIO_SERVICE_NAME));
+ ::android::hardware::radio::V1_1::IRadio>(
+ RadioHidlEnvironment::Instance()
+ ->getServiceName<::android::hardware::radio::V1_1::IRadio>(
+ hidl_string(RADIO_SERVICE_NAME)));
}
ASSERT_NE(nullptr, radio_v1_1.get());
diff --git a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
index a081ab9..36d15c7 100644
--- a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
+++ b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h
@@ -17,6 +17,7 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -534,6 +535,22 @@
const ::android::hardware::hidl_string& reason);
};
+// Test environment for Radio HIDL HAL.
+class RadioHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static RadioHidlEnvironment* Instance() {
+ static RadioHidlEnvironment* instance = new RadioHidlEnvironment;
+ return instance;
+ }
+ virtual void registerTestServices() override {
+ registerTestService<::android::hardware::radio::V1_1::IRadio>();
+ }
+
+ private:
+ RadioHidlEnvironment() {}
+};
+
// The main test class for Radio HIDL.
class RadioHidlTest_v1_1 : public ::testing::VtsHalHidlTargetTestBase {
protected:
diff --git a/radio/1.2/Android.bp b/radio/1.2/Android.bp
index 552e33d..a9c80b7 100644
--- a/radio/1.2/Android.bp
+++ b/radio/1.2/Android.bp
@@ -19,6 +19,7 @@
"android.hidl.base@1.0",
],
types: [
+ "AccessNetwork",
"AudioQuality",
"Call",
"CardStatus",
@@ -27,12 +28,15 @@
"CellIdentityGsm",
"CellIdentityLte",
"CellIdentityOperatorNames",
+ "CellIdentityTdscdma",
"CellIdentityWcdma",
"CellInfo",
"CellInfoCdma",
"CellInfoGsm",
"CellInfoLte",
+ "CellInfoTdscdma",
"CellInfoWcdma",
+ "DataRequestReason",
"IncrementalResultsPeriodicityRange",
"IndicationFilter",
"LinkCapacityEstimate",
@@ -42,6 +46,9 @@
"PhysicalChannelConfig",
"RadioConst",
"ScanIntervalRange",
+ "SignalStrength",
+ "TdscdmaSignalStrength",
+ "WcdmaSignalStrength",
],
gen_java: true,
}
diff --git a/radio/1.2/IRadio.hal b/radio/1.2/IRadio.hal
index 67ce56c..6463b0f 100644
--- a/radio/1.2/IRadio.hal
+++ b/radio/1.2/IRadio.hal
@@ -50,7 +50,7 @@
*
* @param serial Serial number of request.
* @param indicationFilter 32-bit bitmap of IndicationFilter. Bits set to 1 indicate the
- * indications are enabled. See @1.2::IndicationFilter for the definition of each bit.
+ * indications are enabled. See @1.2::IndicationFilter for the definition of each bit.
*
* Response callback is IRadioResponse.setIndicationFilterResponse()
*/
@@ -68,16 +68,16 @@
*
* @param serial Serial number of request.
* @param hysteresisMs A hysteresis time in milliseconds to prevent flapping. A value of 0
- * disables hysteresis.
+ * disables hysteresis.
* @param hysteresisDb An interval in dB defining the required magnitude change between reports.
- * hysteresisDb must be smaller than the smallest threshold delta. An
- * interval value of 0 disables hysteresis.
+ * hysteresisDb must be smaller than the smallest threshold delta. An
+ * interval value of 0 disables hysteresis.
* @param thresholdsDbm A vector of trigger thresholds in dBm. A vector size of 0 disables the
- * use of thresholds for reporting.
- * @param ran The type of network for which to apply these thresholds.
+ * use of thresholds for reporting.
+ * @param accessNetwork The type of network for which to apply these thresholds.
*/
oneway setSignalStrengthReportingCriteria(int32_t serial, int32_t hysteresisMs,
- int32_t hysteresisDb, vec<int32_t> thresholdsDbm, RadioAccessNetworks ran);
+ int32_t hysteresisDb, vec<int32_t> thresholdsDbm, AccessNetwork accessNetwork);
/**
* Sets the link capacity reporting criteria.
@@ -91,23 +91,22 @@
*
* @param serial Serial number of request.
* @param hysteresisMs A hysteresis time in milliseconds to prevent flapping. A value of 0
- * disables hysteresis.
+ * disables hysteresis.
* @param hysteresisDlKbps An interval in kbps defining the required magnitude change between DL
- * reports. hysteresisDlKbps must be smaller than the smallest threshold
- * delta. A value of 0 disables hysteresis.
+ * reports. hysteresisDlKbps must be smaller than the smallest threshold delta. A value of 0
+ * disables hysteresis.
* @param hysteresisUlKbps An interval in kbps defining the required magnitude change between UL
- * reports. hysteresisUlKbps must be smaller than the smallest threshold
- * delta. A value of 0 disables hysteresis.
+ * reports. hysteresisUlKbps must be smaller than the smallest threshold delta. A value of 0
+ * disables hysteresis.
* @param thresholdsDownlinkKbps A vector of trigger thresholds in kbps for downlink reports. A
- * vector size of 0 disables the use of DL thresholds for
- * reporting.
+ * vector size of 0 disables the use of DL thresholds for reporting.
* @param thresholdsUplinkKbps A vector of trigger thresholds in kbps for uplink reports. A
- * vector size of 0 disables the use of UL thresholds for reporting.
- * @param ran The type of network for which to apply these thresholds.
+ * vector size of 0 disables the use of UL thresholds for reporting.
+ * @param accessNetwork The type of network for which to apply these thresholds.
*/
oneway setLinkCapacityReportingCriteria(int32_t serial, int32_t hysteresisMs,
int32_t hysteresisDlKbps, int32_t hysteresisUlKbps, vec<int32_t> thresholdsDownlinkKbps,
- vec<int32_t> thresholdsUplinkKbps, RadioAccessNetworks ran);
+ vec<int32_t> thresholdsUplinkKbps, AccessNetwork accessNetwork);
/**
* Setup a packet data connection. If DataCallResponse.status returns DataCallFailCause:NONE,
diff --git a/radio/1.2/IRadioIndication.hal b/radio/1.2/IRadioIndication.hal
index a124557..3d93b98 100644
--- a/radio/1.2/IRadioIndication.hal
+++ b/radio/1.2/IRadioIndication.hal
@@ -34,7 +34,7 @@
* Same information as returned by getCellInfoList() in 1.0::IRadio.
*
* @param type Type of radio indication
- * @param records Current cell information known to radio
+ * @param records Current cell information
*/
oneway cellInfoList_1_2(RadioIndicationType type, vec<CellInfo> records);
@@ -50,7 +50,7 @@
* suppressed by @1.2::IRadio.setIndicationFilter_1_2().
*
* @param type Type of radio indication
- * @param lce LinkCapacityEstimate information as defined in types.hal
+ * @param lce LinkCapacityEstimate
*/
oneway currentLinkCapacityEstimate(RadioIndicationType type, LinkCapacityEstimate lce);
@@ -58,8 +58,16 @@
* Indicates physical channel configurations.
*
* @param type Type of radio indication
- * @param configs List of PhysicalChannelConfigs as defined in types.hal
+ * @param configs Vector of PhysicalChannelConfigs
*/
oneway currentPhysicalChannelConfigs(RadioIndicationType type,
vec<PhysicalChannelConfig> configs);
+
+ /**
+ * Indicates current signal strength of the radio.
+ *
+ * @param type Type of radio indication
+ * @param signalStrength SignalStrength information
+ */
+ oneway currentSignalStrength_1_2(RadioIndicationType type, SignalStrength signalStrength);
};
diff --git a/radio/1.2/IRadioResponse.hal b/radio/1.2/IRadioResponse.hal
index 93ec4d7..f26c9ec 100644
--- a/radio/1.2/IRadioResponse.hal
+++ b/radio/1.2/IRadioResponse.hal
@@ -88,4 +88,14 @@
* RadioError:CANCELLED
*/
oneway getCurrentCallsResponse_1_2(RadioResponseInfo info, vec<Call> calls);
+
+ /**
+ * @param signalStrength Current signal strength
+ *
+ * Valid errors returned:
+ * RadioError:NONE
+ * RadioError:RADIO_NOT_AVAILABLE
+ * RadioError:INTERNAL_ERR
+ */
+ oneway getSignalStrengthResponse_1_2(RadioResponseInfo info, SignalStrength signalStrength);
};
diff --git a/radio/1.2/types.hal b/radio/1.2/types.hal
index c353645..b68895e 100644
--- a/radio/1.2/types.hal
+++ b/radio/1.2/types.hal
@@ -17,12 +17,13 @@
package android.hardware.radio@1.2;
import @1.0::Call;
-import @1.0::CdmaSignalStrength;
import @1.0::CardState;
import @1.0::CardStatus;
+import @1.0::CdmaSignalStrength;
import @1.0::CellIdentityCdma;
import @1.0::CellIdentityGsm;
import @1.0::CellIdentityLte;
+import @1.0::CellIdentityTdscdma;
import @1.0::CellIdentityWcdma;
import @1.0::CellInfoTdscdma;
import @1.0::CellInfoType;
@@ -30,10 +31,12 @@
import @1.0::GsmSignalStrength;
import @1.0::LteSignalStrength;
import @1.0::RadioConst;
+import @1.0::RadioError;
+import @1.0::SignalStrength;
+import @1.0::TdScdmaSignalStrength;
import @1.0::TimeStampType;
import @1.0::WcdmaSignalStrength;
import @1.1::RadioAccessSpecifier;
-import @1.0::RadioError;
import @1.1::ScanStatus;
import @1.1::ScanType;
@@ -251,6 +254,15 @@
int32_t bandwidth;
};
+struct CellIdentityTdscdma {
+ @1.0::CellIdentityTdscdma base;
+ /**
+ * 16-bit UMTS Absolute RF Channel Number defined in TS 25.102 5.4.4; this value must be valid.
+ */
+ int32_t uarfcn;
+ CellIdentityOperatorNames operatorNames;
+};
+
struct CellIdentityWcdma {
@1.0::CellIdentityWcdma base;
CellIdentityOperatorNames operatorNames;
@@ -277,6 +289,11 @@
LteSignalStrength signalStrengthLte;
};
+struct CellInfoTdscdma {
+ CellIdentityTdscdma cellIdentityTdscdma;
+ TdscdmaSignalStrength signalStrengthTdscdma;
+};
+
struct CellInfo {
/**
* Cell type for selecting from union CellInfo.
@@ -344,11 +361,17 @@
struct LinkCapacityEstimate {
/**
- * Estimated downlink capacity in kbps.
+ * Estimated downlink capacity in kbps. This bandwidth estimate shall be the estimated
+ * maximum sustainable link bandwidth (as would be measured at the Upper PDCP or SNDCP SAP).
+ * If the DL Aggregate Maximum Bit Rate is known, this value shall not exceed the DL-AMBR
+ * for the Internet PDN connection.
*/
uint32_t downlinkCapacityKbps;
/**
- * Estimated uplink capacity in kbps.
+ * Estimated uplink capacity in kbps. This bandwidth estimate shall be the estimated
+ * maximum sustainable link bandwidth (as would be measured at the Upper PDCP or SNDCP SAP).
+ * If the UL Aggregate Maximum Bit Rate is known, this value shall not exceed the UL-AMBR
+ * for the Internet PDN connection.
*/
uint32_t uplinkCapacityKbps;
};
@@ -397,3 +420,45 @@
@1.0::Call base;
AudioQuality audioQuality;
};
+
+struct WcdmaSignalStrength {
+ @1.0::WcdmaSignalStrength base;
+ /**
+ * CPICH RSCP as defined in TS 25.215 5.1.1
+ * Valid values are (0-96, 255) as defined in TS 27.007 8.69
+ */
+ uint32_t rscp;
+ /**
+ * Ec/No value as defined in TS 25.215 5.1.5
+ * Valid values are (0-49, 255) as defined in TS 27.007 8.69
+ */
+ uint32_t ecno;
+
+};
+
+struct TdscdmaSignalStrength {
+ /**
+ * UTRA carrier RSSI as defined in TS 25.225 5.1.4
+ * Valid values are (0-96, 99) as defined in TS 27.007 8.69
+ */
+ uint32_t signalStrength;
+ /**
+ * Transport Channel BER as defined in TS 25.225 5.2.5
+ * Valid values are (0-49, 99) as defined in TS 27.007 8.69
+ */
+ uint32_t bitErrorRate;
+ /**
+ * P-CCPCH RSCP as defined in TS 25.225 5.1.1
+ * Valid values are (0-96, 255) as defined in TS 27.007 8.69
+ */
+ uint32_t rscp;
+};
+
+struct SignalStrength {
+ GsmSignalStrength gsm;
+ CdmaSignalStrength cdma;
+ EvdoSignalStrength evdo;
+ LteSignalStrength lte;
+ TdScdmaSignalStrength tdScdma;
+ WcdmaSignalStrength wcdma;
+};
diff --git a/radio/1.2/vts/functional/Android.bp b/radio/1.2/vts/functional/Android.bp
index 6f8781a..a4e8c02 100644
--- a/radio/1.2/vts/functional/Android.bp
+++ b/radio/1.2/vts/functional/Android.bp
@@ -22,6 +22,7 @@
"radio_hidl_hal_test.cpp",
"radio_response.cpp",
"radio_indication.cpp",
+ "VtsHalRadioV1_2TargetTest.cpp",
],
static_libs: [
"RadioVtsTestUtilBase",
diff --git a/radio/1.2/vts/functional/VtsHalRadioV1_2TargetTest.cpp b/radio/1.2/vts/functional/VtsHalRadioV1_2TargetTest.cpp
new file mode 100644
index 0000000..c1a2f3d
--- /dev/null
+++ b/radio/1.2/vts/functional/VtsHalRadioV1_2TargetTest.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2018 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_v1_2.h>
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(RadioHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ RadioHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/radio/1.2/vts/functional/radio_hidl_hal_test.cpp b/radio/1.2/vts/functional/radio_hidl_hal_test.cpp
index c1ab88b..d74d077 100644
--- a/radio/1.2/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.2/vts/functional/radio_hidl_hal_test.cpp
@@ -18,11 +18,13 @@
void RadioHidlTest_v1_2::SetUp() {
radio_v1_2 = ::testing::VtsHalHidlTargetTestBase::getService<V1_2::IRadio>(
- hidl_string(RADIO_SERVICE_NAME));
+ RadioHidlEnvironment::Instance()->getServiceName<V1_2::IRadio>(
+ hidl_string(RADIO_SERVICE_NAME)));
if (radio_v1_2 == NULL) {
sleep(60);
radio_v1_2 = ::testing::VtsHalHidlTargetTestBase::getService<V1_2::IRadio>(
- hidl_string(RADIO_SERVICE_NAME));
+ RadioHidlEnvironment::Instance()->getServiceName<V1_2::IRadio>(
+ hidl_string(RADIO_SERVICE_NAME)));
}
ASSERT_NE(nullptr, radio_v1_2.get());
diff --git a/radio/1.2/vts/functional/radio_hidl_hal_utils_v1_2.h b/radio/1.2/vts/functional/radio_hidl_hal_utils_v1_2.h
index b3b53b1..781c12a 100644
--- a/radio/1.2/vts/functional/radio_hidl_hal_utils_v1_2.h
+++ b/radio/1.2/vts/functional/radio_hidl_hal_utils_v1_2.h
@@ -17,6 +17,7 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -525,6 +526,20 @@
const ::android::hardware::hidl_string& reason);
};
+// Test environment for Radio HIDL HAL.
+class RadioHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static RadioHidlEnvironment* Instance() {
+ static RadioHidlEnvironment* instance = new RadioHidlEnvironment;
+ return instance;
+ }
+ virtual void registerTestServices() override { registerTestService<V1_2::IRadio>(); }
+
+ private:
+ RadioHidlEnvironment() {}
+};
+
// The main test class for Radio HIDL.
class RadioHidlTest_v1_2 : public ::testing::VtsHalHidlTargetTestBase {
protected:
diff --git a/radio/config/1.0/vts/functional/Android.bp b/radio/config/1.0/vts/functional/Android.bp
index 66bfd92..aa8266e 100644
--- a/radio/config/1.0/vts/functional/Android.bp
+++ b/radio/config/1.0/vts/functional/Android.bp
@@ -22,6 +22,7 @@
"radio_config_hidl_hal_test.cpp",
"radio_config_response.cpp",
"radio_config_indication.cpp",
+ "VtsHalRadioConfigV1_0TargetTest.cpp",
],
static_libs: [
"RadioVtsTestUtilBase",
diff --git a/radio/config/1.0/vts/functional/VtsHalRadioConfigV1_0TargetTest.cpp b/radio/config/1.0/vts/functional/VtsHalRadioConfigV1_0TargetTest.cpp
new file mode 100644
index 0000000..2fc6b62
--- /dev/null
+++ b/radio/config/1.0/vts/functional/VtsHalRadioConfigV1_0TargetTest.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2018 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_config_hidl_hal_utils.h>
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(RadioConfigHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ RadioConfigHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/radio/config/1.0/vts/functional/radio_config_hidl_hal_test.cpp b/radio/config/1.0/vts/functional/radio_config_hidl_hal_test.cpp
index 8df6842..c01dc4c 100644
--- a/radio/config/1.0/vts/functional/radio_config_hidl_hal_test.cpp
+++ b/radio/config/1.0/vts/functional/radio_config_hidl_hal_test.cpp
@@ -18,11 +18,13 @@
void RadioConfigHidlTest::SetUp() {
radioConfig = ::testing::VtsHalHidlTargetTestBase::getService<IRadioConfig>(
- hidl_string(RADIO_SERVICE_NAME));
+ RadioConfigHidlEnvironment::Instance()->getServiceName<IRadioConfig>(
+ hidl_string(RADIO_SERVICE_NAME)));
if (radioConfig == NULL) {
sleep(60);
radioConfig = ::testing::VtsHalHidlTargetTestBase::getService<IRadioConfig>(
- hidl_string(RADIO_SERVICE_NAME));
+ RadioConfigHidlEnvironment::Instance()->getServiceName<IRadioConfig>(
+ hidl_string(RADIO_SERVICE_NAME)));
}
ASSERT_NE(nullptr, radioConfig.get());
diff --git a/radio/config/1.0/vts/functional/radio_config_hidl_hal_utils.h b/radio/config/1.0/vts/functional/radio_config_hidl_hal_utils.h
index 762cc98..e7d697a 100644
--- a/radio/config/1.0/vts/functional/radio_config_hidl_hal_utils.h
+++ b/radio/config/1.0/vts/functional/radio_config_hidl_hal_utils.h
@@ -17,6 +17,7 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <chrono>
#include <condition_variable>
#include <mutex>
@@ -75,6 +76,20 @@
RadioIndicationType type, const ::android::hardware::hidl_vec<SimSlotStatus>& slotStatus);
};
+// Test environment for Radio HIDL HAL.
+class RadioConfigHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static RadioConfigHidlEnvironment* Instance() {
+ static RadioConfigHidlEnvironment* instance = new RadioConfigHidlEnvironment;
+ return instance;
+ }
+ virtual void registerTestServices() override { registerTestService<IRadioConfig>(); }
+
+ private:
+ RadioConfigHidlEnvironment() {}
+};
+
// The main test class for Radio config HIDL.
class RadioConfigHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
diff --git a/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp b/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
index 97956c5..59ac13e 100644
--- a/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
+++ b/soundtrigger/2.0/vts/functional/VtsHalSoundtriggerV2_0TargetTest.cpp
@@ -30,6 +30,7 @@
#include <android/hardware/soundtrigger/2.0/types.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#define SHORT_TIMEOUT_PERIOD (1)
@@ -85,12 +86,27 @@
int mCount;
};
+// Test environment for SoundTrigger HIDL HAL.
+class SoundTriggerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static SoundTriggerHidlEnvironment* Instance() {
+ static SoundTriggerHidlEnvironment* instance = new SoundTriggerHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<ISoundTriggerHw>(); }
+
+ private:
+ SoundTriggerHidlEnvironment() {}
+};
+
// The main test class for Sound Trigger HIDL HAL.
class SoundTriggerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- mSoundTriggerHal =
- ::testing::VtsHalHidlTargetTestBase::getService<ISoundTriggerHw>();
+ mSoundTriggerHal = ::testing::VtsHalHidlTargetTestBase::getService<ISoundTriggerHw>(
+ SoundTriggerHidlEnvironment::Instance()->getServiceName<ISoundTriggerHw>());
ASSERT_NE(nullptr, mSoundTriggerHal.get());
mCallback = new SoundTriggerHwCallback(*this);
ASSERT_NE(nullptr, mCallback.get());
@@ -142,15 +158,6 @@
sp<SoundTriggerHwCallback> mCallback;
};
-// A class for test environment setup (kept since this file is a template).
-class SoundTriggerHidlEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- private:
-};
-
/**
* Test ISoundTriggerHw::getProperties() method
*
@@ -318,11 +325,11 @@
EXPECT_TRUE(hidlReturn == 0 || hidlReturn == -ENOSYS);
}
-
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new SoundTriggerHidlEnvironment);
- ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
- return status;
+ ::testing::AddGlobalTestEnvironment(SoundTriggerHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ SoundTriggerHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
}
diff --git a/soundtrigger/2.1/vts/functional/VtsHalSoundtriggerV2_1TargetTest.cpp b/soundtrigger/2.1/vts/functional/VtsHalSoundtriggerV2_1TargetTest.cpp
index fdd5f0d..0a2eeac 100644
--- a/soundtrigger/2.1/vts/functional/VtsHalSoundtriggerV2_1TargetTest.cpp
+++ b/soundtrigger/2.1/vts/functional/VtsHalSoundtriggerV2_1TargetTest.cpp
@@ -33,6 +33,7 @@
#include <hidlmemory/mapping.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#define SHORT_TIMEOUT_PERIOD (1)
@@ -93,11 +94,27 @@
int mCount;
};
+// Test environment for SoundTrigger HIDL HAL.
+class SoundTriggerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static SoundTriggerHidlEnvironment* Instance() {
+ static SoundTriggerHidlEnvironment* instance = new SoundTriggerHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<ISoundTriggerHw>(); }
+
+ private:
+ SoundTriggerHidlEnvironment() {}
+};
+
// The main test class for Sound Trigger HIDL HAL.
class SoundTriggerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- mSoundTriggerHal = ::testing::VtsHalHidlTargetTestBase::getService<ISoundTriggerHw>();
+ mSoundTriggerHal = ::testing::VtsHalHidlTargetTestBase::getService<ISoundTriggerHw>(
+ SoundTriggerHidlEnvironment::Instance()->getServiceName<ISoundTriggerHw>());
ASSERT_NE(nullptr, mSoundTriggerHal.get());
mCallback = new SoundTriggerHwCallback(*this);
ASSERT_NE(nullptr, mCallback.get());
@@ -480,3 +497,12 @@
EXPECT_TRUE(hidlReturn.isOk());
EXPECT_TRUE(hidlReturn == 0 || hidlReturn == -ENOSYS);
}
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(SoundTriggerHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ SoundTriggerHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}
diff --git a/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp b/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp
index bf211f0..34a95f2 100644
--- a/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp
+++ b/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "VtsOffloadConfigV1_0TargetTest"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <android/hardware/tetheroffload/config/1.0/IOffloadConfig.h>
@@ -77,10 +78,25 @@
return netlinkSocket(NETLINK_NETFILTER, groups);
}
+// Test environment for OffloadConfig HIDL HAL.
+class OffloadConfigHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static OffloadConfigHidlEnvironment* Instance() {
+ static OffloadConfigHidlEnvironment* instance = new OffloadConfigHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IOffloadConfig>(); }
+ private:
+ OffloadConfigHidlEnvironment() {}
+};
+
class OffloadConfigHidlTest : public testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>();
+ config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>(
+ OffloadConfigHidlEnvironment::Instance()->getServiceName<IOffloadConfig>());
ASSERT_NE(nullptr, config.get()) << "Could not get HIDL instance";
}
@@ -175,7 +191,9 @@
}
int main(int argc, char** argv) {
- testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(OffloadConfigHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ OffloadConfigHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGE("Test result with status=%d", status);
return status;
diff --git a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
index d2fa92d..4eef4ec 100644
--- a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
+++ b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
@@ -18,6 +18,7 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <android/hardware/tetheroffload/config/1.0/IOffloadConfig.h>
@@ -114,6 +115,23 @@
NatTimeoutUpdate last_params;
};
+// Test environment for OffloadControl HIDL HAL.
+class OffloadControlHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static OffloadControlHidlEnvironment* Instance() {
+ static OffloadControlHidlEnvironment* instance = new OffloadControlHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override {
+ registerTestService<IOffloadConfig>();
+ registerTestService<IOffloadControl>();
+ }
+ private:
+ OffloadControlHidlEnvironment() {}
+};
+
class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
@@ -131,7 +149,8 @@
// The IOffloadConfig HAL is tested more thoroughly elsewhere. He we just
// setup everything correctly and verify basic readiness.
void setupConfigHal() {
- config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>();
+ config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>(
+ OffloadControlHidlEnvironment::Instance()->getServiceName<IOffloadConfig>());
ASSERT_NE(nullptr, config.get()) << "Could not get HIDL instance";
unique_fd fd1(conntrackSocket(NF_NETLINK_CONNTRACK_NEW | NF_NETLINK_CONNTRACK_DESTROY));
@@ -159,7 +178,8 @@
}
void prepareControlHal() {
- control = testing::VtsHalHidlTargetTestBase::getService<IOffloadControl>();
+ control = testing::VtsHalHidlTargetTestBase::getService<IOffloadControl>(
+ OffloadControlHidlEnvironment::Instance()->getServiceName<IOffloadControl>());
ASSERT_NE(nullptr, control.get()) << "Could not get HIDL instance";
control_cb = new TetheringOffloadCallback();
@@ -678,7 +698,9 @@
}
int main(int argc, char** argv) {
- testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(OffloadControlHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ OffloadControlHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGE("Test result with status=%d", status);
return status;
diff --git a/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp b/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
index dfa11a1..6f059ef 100644
--- a/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
+++ b/thermal/1.0/vts/functional/VtsHalThermalV1_0TargetTest.cpp
@@ -21,10 +21,11 @@
#define LOG_TAG "thermal_hidl_hal_test"
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/thermal/1.0/IThermal.h>
#include <android/hardware/thermal/1.0/types.h>
-#include <VtsHalHidlTargetTestBase.h>
#include <unistd.h>
using ::android::hardware::hidl_string;
@@ -45,11 +46,26 @@
#define MAX_DEVICE_TEMPERATURE 200
#define MAX_FAN_SPEED 20000
+// Test environment for Thermal HIDL HAL.
+class ThermalHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ThermalHidlEnvironment* Instance() {
+ static ThermalHidlEnvironment* instance = new ThermalHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IThermal>(); }
+ private:
+ ThermalHidlEnvironment() {}
+};
+
// The main test class for THERMAL HIDL HAL.
class ThermalHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- thermal_ = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>();
+ thermal_ = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>(
+ ThermalHidlEnvironment::Instance()->getServiceName<IThermal>());
ASSERT_NE(thermal_, nullptr);
baseSize_ = 0;
names_.clear();
@@ -207,7 +223,9 @@
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(ThermalHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ ThermalHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp b/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp
index 6c1599b..91c8b6e 100644
--- a/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp
+++ b/thermal/1.1/vts/functional/VtsHalThermalV1_1TargetTest.cpp
@@ -20,6 +20,7 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::hardware::thermal::V1_0::Temperature;
using ::android::hardware::thermal::V1_0::TemperatureType;
@@ -62,11 +63,26 @@
}
};
+// Test environment for Thermal HIDL HAL.
+class ThermalHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ThermalHidlEnvironment* Instance() {
+ static ThermalHidlEnvironment* instance = new ThermalHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IThermal>(); }
+ private:
+ ThermalHidlEnvironment() {}
+};
+
// The main test class for THERMAL HIDL HAL 1.1.
class ThermalHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- mThermal = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>();
+ mThermal = ::testing::VtsHalHidlTargetTestBase::getService<IThermal>(
+ ThermalHidlEnvironment::Instance()->getServiceName<IThermal>());
ASSERT_NE(mThermal, nullptr);
mThermalCallback = new(std::nothrow) ThermalCallback();
ASSERT_NE(mThermalCallback, nullptr);
@@ -99,7 +115,9 @@
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(ThermalHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ ThermalHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
cout << "Test result = " << status << std::endl;
return status;
diff --git a/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp b/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
index f415ad5..a0e927b 100644
--- a/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
+++ b/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
@@ -19,9 +19,11 @@
#include <android-base/logging.h>
#include <android/hardware/vibrator/1.0/IVibrator.h>
#include <android/hardware/vibrator/1.0/types.h>
-#include <VtsHalHidlTargetTestBase.h>
#include <unistd.h>
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
using ::android::hardware::vibrator::V1_0::Effect;
using ::android::hardware::vibrator::V1_0::EffectStrength;
using ::android::hardware::vibrator::V1_0::IVibrator;
@@ -30,11 +32,27 @@
using ::android::hardware::Void;
using ::android::sp;
+// Test environment for Vibrator HIDL HAL.
+class VibratorHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static VibratorHidlEnvironment* Instance() {
+ static VibratorHidlEnvironment* instance = new VibratorHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IVibrator>(); }
+
+ private:
+ VibratorHidlEnvironment() {}
+};
+
// The main test class for VIBRATOR HIDL HAL.
class VibratorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>();
+ vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>(
+ VibratorHidlEnvironment::Instance()->getServiceName<IVibrator>());
ASSERT_NE(vibrator, nullptr);
}
@@ -43,15 +61,6 @@
sp<IVibrator> vibrator;
};
-// A class for test environment setup (kept since this file is a template).
-class VibratorHidlEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-
- private:
-};
-
static void validatePerformEffect(Status status, uint32_t lengthMs) {
ASSERT_TRUE(status == Status::OK || status == Status::UNSUPPORTED_OPERATION);
if (status == Status::OK) {
@@ -96,8 +105,9 @@
}
int main(int argc, char **argv) {
- ::testing::AddGlobalTestEnvironment(new VibratorHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(VibratorHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ VibratorHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp b/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp
index 35000f8..1a47fe9 100644
--- a/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp
+++ b/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "vibrator_hidl_hal_test"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/vibrator/1.1/IVibrator.h>
#include <android/hardware/vibrator/1.1/types.h>
@@ -31,11 +32,27 @@
using ::android::hardware::Void;
using ::android::sp;
+// Test environment for Vibrator HIDL HAL.
+class VibratorHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static VibratorHidlEnvironment* Instance() {
+ static VibratorHidlEnvironment* instance = new VibratorHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IVibrator>(); }
+
+ private:
+ VibratorHidlEnvironment() {}
+};
+
// The main test class for VIBRATOR HIDL HAL 1.1.
class VibratorHidlTest_1_1 : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>();
+ vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>(
+ VibratorHidlEnvironment::Instance()->getServiceName<IVibrator>());
ASSERT_NE(vibrator, nullptr);
}
@@ -61,7 +78,9 @@
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(VibratorHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ VibratorHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp b/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp
index d07d1b7..d8df18b 100644
--- a/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp
+++ b/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "vibrator_hidl_hal_test"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/vibrator/1.0/types.h>
#include <android/hardware/vibrator/1.2/IVibrator.h>
@@ -32,11 +33,27 @@
using ::android::hardware::Void;
using ::android::sp;
+// Test environment for Vibrator HIDL HAL.
+class VibratorHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static VibratorHidlEnvironment* Instance() {
+ static VibratorHidlEnvironment* instance = new VibratorHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IVibrator>(); }
+
+ private:
+ VibratorHidlEnvironment() {}
+};
+
// The main test class for VIBRATOR HIDL HAL 1.2.
class VibratorHidlTest_1_2 : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>();
+ vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>(
+ VibratorHidlEnvironment::Instance()->getServiceName<IVibrator>());
ASSERT_NE(vibrator, nullptr);
}
@@ -65,7 +82,9 @@
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(VibratorHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ VibratorHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/wifi/1.0/vts/functional/Android.bp b/wifi/1.0/vts/functional/Android.bp
index ea27f02..b2f76a3 100644
--- a/wifi/1.0/vts/functional/Android.bp
+++ b/wifi/1.0/vts/functional/Android.bp
@@ -20,7 +20,8 @@
srcs: [
"wifi_hidl_call_util_selftest.cpp",
"wifi_hidl_test.cpp",
- "wifi_hidl_test_utils.cpp"],
+ "wifi_hidl_test_utils.cpp",
+ ],
export_include_dirs: [
"."
],
diff --git a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
index beac039..e7b8593 100644
--- a/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
+++ b/wifi/1.0/vts/functional/VtsHalWifiV1_0TargetTest.cpp
@@ -16,16 +16,31 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetTestBase.h>
-
#include "wifi_hidl_test_utils.h"
-WifiHidlEnvironment* gEnv;
+class WifiVtsHidlEnvironment_1_0 : public WifiHidlEnvironment {
+ public:
+ // get the test environment singleton
+ static WifiVtsHidlEnvironment_1_0* Instance() {
+ static WifiVtsHidlEnvironment_1_0* instance =
+ new WifiVtsHidlEnvironment_1_0;
+ return instance;
+ }
+
+ virtual void registerTestServices() override {
+ registerTestService<android::hardware::wifi::V1_0::IWifi>();
+ }
+
+ private:
+ WifiVtsHidlEnvironment_1_0() {}
+};
+
+WifiHidlEnvironment* gEnv = WifiVtsHidlEnvironment_1_0::Instance();
int main(int argc, char** argv) {
- gEnv = new WifiHidlEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
status = RUN_ALL_TESTS();
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 313bdd8..97a371b 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
+++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.cpp
@@ -35,6 +35,8 @@
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
+extern WifiHidlEnvironment* gEnv;
+
namespace {
constexpr uint32_t kHalStartRetryMaxCount = 5;
constexpr uint32_t kHalStartRetryIntervalInMs = 2;
@@ -86,7 +88,8 @@
} // namespace
sp<IWifi> getWifi() {
- sp<IWifi> wifi = ::testing::VtsHalHidlTargetTestBase::getService<IWifi>();
+ sp<IWifi> wifi = ::testing::VtsHalHidlTargetTestBase::getService<IWifi>(
+ gEnv->getServiceName<IWifi>());
return wifi;
}
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 c4a19dd..2b1c8ec 100644
--- a/wifi/1.0/vts/functional/wifi_hidl_test_utils.h
+++ b/wifi/1.0/vts/functional/wifi_hidl_test_utils.h
@@ -26,6 +26,7 @@
#include <getopt.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
// Helper functions to obtain references to the various HIDL interface objects.
// Note: We only have a single instance of each of these objects currently.
// These helper functions should be modified to return vectors if we support
@@ -47,9 +48,9 @@
// Used to trigger IWifi.stop() at the end of every test.
void stopWifi();
-class WifiHidlEnvironment : public ::testing::Environment {
+class WifiHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
protected:
- virtual void SetUp() override {
+ virtual void HidlSetUp() override {
stopWifi();
sleep(5);
}
diff --git a/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp b/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp
index 9b92b57..a0f97f8 100644
--- a/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp
+++ b/wifi/1.1/vts/functional/VtsHalWifiV1_1TargetTest.cpp
@@ -15,17 +15,32 @@
*/
#include <android-base/logging.h>
-
-#include <VtsHalHidlTargetTestBase.h>
+#include <android/hardware/wifi/1.1/IWifi.h>
#include "wifi_hidl_test_utils.h"
-WifiHidlEnvironment* gEnv;
+class WifiHidlEnvironment_1_1 : public WifiHidlEnvironment {
+ public:
+ // get the test environment singleton
+ static WifiHidlEnvironment_1_1* Instance() {
+ static WifiHidlEnvironment_1_1* instance = new WifiHidlEnvironment_1_1;
+ return instance;
+ }
+
+ virtual void registerTestServices() override {
+ registerTestService<android::hardware::wifi::V1_1::IWifi>();
+ }
+
+ private:
+ WifiHidlEnvironment_1_1() {}
+};
+
+WifiHidlEnvironment* gEnv = WifiHidlEnvironment_1_1::Instance();
int main(int argc, char** argv) {
- gEnv = new WifiHidlEnvironment();
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
int status = RUN_ALL_TESTS();
diff --git a/wifi/hostapd/1.0/vts/functional/VtsHalWifiHostapdV1_0TargetTest.cpp b/wifi/hostapd/1.0/vts/functional/VtsHalWifiHostapdV1_0TargetTest.cpp
index 64e6fbe..0303b20 100644
--- a/wifi/hostapd/1.0/vts/functional/VtsHalWifiHostapdV1_0TargetTest.cpp
+++ b/wifi/hostapd/1.0/vts/functional/VtsHalWifiHostapdV1_0TargetTest.cpp
@@ -15,20 +15,34 @@
*/
#include <android-base/logging.h>
-
-#include <VtsHalHidlTargetTestBase.h>
+#include <android/hardware/wifi/1.0/IWifi.h>
#include "hostapd_hidl_test_utils.h"
-class HostapdHidlEnvironment : public ::testing::Environment {
+class WifiHostapdHidlEnvironment_1_0 : public WifiHostapdHidlEnvironment {
public:
- virtual void SetUp() override { stopHostapd(); }
- virtual void TearDown() override { startHostapdAndWaitForHidlService(); }
+ // get the test environment singleton
+ static WifiHostapdHidlEnvironment_1_0* Instance() {
+ static WifiHostapdHidlEnvironment_1_0* instance =
+ new WifiHostapdHidlEnvironment_1_0;
+ return instance;
+ }
+
+ virtual void registerTestServices() override {
+ registerTestService<::android::hardware::wifi::V1_0::IWifi>();
+ registerTestService<android::hardware::wifi::hostapd::V1_0::IHostapd>();
+ }
+
+ private:
+ WifiHostapdHidlEnvironment_1_0() {}
};
+WifiHostapdHidlEnvironment* gEnv = WifiHostapdHidlEnvironment_1_0::Instance();
+
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new HostapdHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
index 0915150..e5ba8ef 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
@@ -42,9 +42,9 @@
using ::android::hidl::manager::V1_0::IServiceNotification;
using ::android::wifi_system::HostapdManager;
-namespace {
-const char kHostapdServiceName[] = "default";
+extern WifiHostapdHidlEnvironment* gEnv;
+namespace {
// Helper function to initialize the driver and firmware to AP mode
// using the vendor HAL HIDL interface.
void initilializeDriverAndFirmware() {
@@ -120,16 +120,17 @@
android::sp<ServiceNotificationListener> notification_listener =
new ServiceNotificationListener();
+ string service_name = gEnv->getServiceName<IHostapd>();
ASSERT_TRUE(notification_listener->registerForHidlServiceNotifications(
- kHostapdServiceName));
+ service_name));
HostapdManager hostapd_manager;
ASSERT_TRUE(hostapd_manager.StartHostapd());
- ASSERT_TRUE(
- notification_listener->waitForHidlService(200, kHostapdServiceName));
+ ASSERT_TRUE(notification_listener->waitForHidlService(200, service_name));
}
sp<IHostapd> getHostapd() {
- return ::testing::VtsHalHidlTargetTestBase::getService<IHostapd>();
+ return ::testing::VtsHalHidlTargetTestBase::getService<IHostapd>(
+ gEnv->getServiceName<IHostapd>());
}
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
index 74ed284..1b92477 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
@@ -19,6 +19,8 @@
#include <android/hardware/wifi/hostapd/1.0/IHostapd.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
// Used to stop the android wifi framework before every test.
void stopWifiFramework();
void startWifiFramework();
@@ -33,4 +35,13 @@
// multiple instances.
android::sp<android::hardware::wifi::hostapd::V1_0::IHostapd> getHostapd();
+class WifiHostapdHidlEnvironment
+ : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ virtual void HidlSetUp() override { stopHostapd(); }
+ virtual void HidlTearDown() override {
+ startHostapdAndWaitForHidlService();
+ }
+};
+
#endif /* HOSTAPD_HIDL_TEST_UTILS_H */
diff --git a/wifi/offload/1.0/vts/functional/VtsHalWifiOffloadV1_0TargetTest.cpp b/wifi/offload/1.0/vts/functional/VtsHalWifiOffloadV1_0TargetTest.cpp
index 90c36dd..dbe4e74 100644
--- a/wifi/offload/1.0/vts/functional/VtsHalWifiOffloadV1_0TargetTest.cpp
+++ b/wifi/offload/1.0/vts/functional/VtsHalWifiOffloadV1_0TargetTest.cpp
@@ -23,6 +23,7 @@
#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <vector>
@@ -68,12 +69,33 @@
OffloadStatus error_code_;
};
+// Test environment for Weaver HIDL HAL.
+class WifiOffloadHidlEnvironment
+ : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static WifiOffloadHidlEnvironment* Instance() {
+ static WifiOffloadHidlEnvironment* instance =
+ new WifiOffloadHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override {
+ registerTestService<IOffload>();
+ }
+
+ private:
+ WifiOffloadHidlEnvironment() {}
+};
+
// The main test class for WifiOffload HIDL HAL.
class WifiOffloadHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
wifi_offload_ =
- ::testing::VtsHalHidlTargetTestBase::getService<IOffload>();
+ ::testing::VtsHalHidlTargetTestBase::getService<IOffload>(
+ WifiOffloadHidlEnvironment::Instance()
+ ->getServiceName<IOffload>());
ASSERT_NE(wifi_offload_, nullptr);
wifi_offload_cb_ = new OffloadCallback();
@@ -209,17 +231,10 @@
ASSERT_EQ(true, res.no_timeout);
}
-// A class for test environment setup
-class WifiOffloadHalHidlEnvironment : public ::testing::Environment {
- public:
- virtual void SetUp() {}
- virtual void TearDown() {}
-};
-
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new WifiOffloadHalHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(WifiOffloadHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
-
+ WifiOffloadHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
diff --git a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
index 7fa20c9..adf2a85 100644
--- a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
+++ b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
@@ -16,21 +16,34 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetTestBase.h>
-
#include "supplicant_hidl_test_utils.h"
+#include "wifi_hidl_test_utils.h"
-class SupplicantHidlEnvironment : public ::testing::Environment {
+class WifiSupplicantHidlEnvironment_1_0 : public WifiSupplicantHidlEnvironment {
public:
- virtual void SetUp() override {
- stopSupplicant();
+ // get the test environment singleton
+ static WifiSupplicantHidlEnvironment_1_0* Instance() {
+ static WifiSupplicantHidlEnvironment_1_0* instance =
+ new WifiSupplicantHidlEnvironment_1_0;
+ return instance;
}
- virtual void TearDown() override { startSupplicantAndWaitForHidlService(); }
+ virtual void registerTestServices() override {
+ registerTestService<::android::hardware::wifi::V1_0::IWifi>();
+ registerTestService<
+ ::android::hardware::wifi::supplicant::V1_0::ISupplicant>();
+ }
+
+ private:
+ WifiSupplicantHidlEnvironment_1_0() {}
};
+WifiSupplicantHidlEnvironment* gEnv =
+ WifiSupplicantHidlEnvironment_1_0::Instance();
+
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new SupplicantHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
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 3b75508..6dd64ec 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
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <android-base/logging.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hidl/manager/1.0/IServiceNotification.h>
@@ -49,8 +49,9 @@
using ::android::wifi_system::InterfaceTool;
using ::android::wifi_system::SupplicantManager;
+extern WifiSupplicantHidlEnvironment* gEnv;
+
namespace {
-const char kSupplicantServiceName[] = "default";
// Helper function to initialize the driver and firmware to STA mode
// using the vendor HAL HIDL interface.
@@ -153,19 +154,20 @@
android::sp<ServiceNotificationListener> notification_listener =
new ServiceNotificationListener();
+ string service_name = gEnv->getServiceName<ISupplicant>();
ASSERT_TRUE(notification_listener->registerForHidlServiceNotifications(
- kSupplicantServiceName));
+ service_name));
SupplicantManager supplicant_manager;
ASSERT_TRUE(supplicant_manager.StartSupplicant());
ASSERT_TRUE(supplicant_manager.IsSupplicantRunning());
- ASSERT_TRUE(
- notification_listener->waitForHidlService(200, kSupplicantServiceName));
+ ASSERT_TRUE(notification_listener->waitForHidlService(200, service_name));
}
sp<ISupplicant> getSupplicant() {
- return ::testing::VtsHalHidlTargetTestBase::getService<ISupplicant>();
+ return ::testing::VtsHalHidlTargetTestBase::getService<ISupplicant>(
+ gEnv->getServiceName<ISupplicant>());
}
sp<ISupplicantStaIface> getSupplicantStaIface() {
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h
index 38143e4..4426ab6 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h
@@ -22,6 +22,8 @@
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
// Used to stop the android wifi framework before every test.
void stopWifiFramework();
void startWifiFramework();
@@ -45,4 +47,13 @@
bool turnOnExcessiveLogging();
+class WifiSupplicantHidlEnvironment
+ : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ virtual void HidlSetUp() override { stopSupplicant(); }
+ virtual void HidlTearDown() override {
+ startSupplicantAndWaitForHidlService();
+ }
+};
+
#endif /* SUPPLICANT_HIDL_TEST_UTILS_H */
diff --git a/wifi/supplicant/1.1/vts/functional/Android.bp b/wifi/supplicant/1.1/vts/functional/Android.bp
index 9375cf5..188dba3 100644
--- a/wifi/supplicant/1.1/vts/functional/Android.bp
+++ b/wifi/supplicant/1.1/vts/functional/Android.bp
@@ -48,6 +48,7 @@
"android.hardware.wifi.supplicant@1.0",
"android.hardware.wifi.supplicant@1.1",
"android.hardware.wifi@1.0",
+ "android.hardware.wifi@1.1",
"libcrypto",
"libgmock",
"libwifi-system",
diff --git a/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp b/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp
index b5e369a..3d24fc3 100644
--- a/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp
+++ b/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp
@@ -15,20 +15,37 @@
*/
#include <android-base/logging.h>
-
-#include <VtsHalHidlTargetTestBase.h>
+#include <android/hardware/wifi/1.1/IWifi.h>
+#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
#include "supplicant_hidl_test_utils.h"
+#include "wifi_hidl_test_utils.h"
-class SupplicantHidlEnvironment : public ::testing::Environment {
+class WifiSupplicantHidlEnvironment_1_1 : public WifiSupplicantHidlEnvironment {
public:
- virtual void SetUp() override { stopSupplicant(); }
- virtual void TearDown() override { startSupplicantAndWaitForHidlService(); }
+ // get the test environment singleton
+ static WifiSupplicantHidlEnvironment_1_1* Instance() {
+ static WifiSupplicantHidlEnvironment_1_1* instance =
+ new WifiSupplicantHidlEnvironment_1_1;
+ return instance;
+ }
+ virtual void registerTestServices() override {
+ registerTestService<::android::hardware::wifi::V1_1::IWifi>();
+ registerTestService<
+ ::android::hardware::wifi::supplicant::V1_1::ISupplicant>();
+ }
+
+ private:
+ WifiSupplicantHidlEnvironment_1_1() {}
};
+WifiSupplicantHidlEnvironment* gEnv =
+ WifiSupplicantHidlEnvironment_1_1::Instance();
+
int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(new SupplicantHidlEnvironment);
+ ::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;