Merge "Deprecate Mapper 2.0 from Q launching devices" into qt-dev
diff --git a/compatibility_matrices/Android.bp b/compatibility_matrices/Android.bp
index 96b05c9..7a779b9 100644
--- a/compatibility_matrices/Android.bp
+++ b/compatibility_matrices/Android.bp
@@ -70,8 +70,8 @@
         "compatibility_matrix.4.xml",
     ],
     kernel_configs: [
-        "kernel_config_current_4.9",
-        "kernel_config_current_4.14",
-        "kernel_config_current_4.19",
+        "kernel_config_q_4.9",
+        "kernel_config_q_4.14",
+        "kernel_config_q_4.19",
     ]
 }
diff --git a/current.txt b/current.txt
index 2ecd50a..1d1b80a 100644
--- a/current.txt
+++ b/current.txt
@@ -487,7 +487,7 @@
 01c6398c90fc6be0640810e2c5d8a4863b457280132bb3f97dd5682e19632b62 android.hardware.graphics.bufferqueue@2.0::types
 7a2d64095252f85781b2d521f4f11d04ce774544feececcec2088c568656e93c android.hardware.graphics.common@1.2::types
 3dff04a36b86660b5807414587e530bb0c294ed56fdff06f8915ba0a9b73f974 android.hardware.graphics.composer@2.3::IComposer
-54bc1dc874f8bc0781767786075dafd33a0796c1eea7d2317231b8929280e946 android.hardware.graphics.composer@2.3::IComposerClient
+b2b0ef3e6f5e9bb4aa6e978bc62e017b3fd64dba95a2152e8b07e3b7c4581d4f android.hardware.graphics.composer@2.3::IComposerClient
 033e096cb65e5093ee1d0e473892b9a487911d4611dbb65ebecb5cef18338923 android.hardware.graphics.mapper@3.0::IMapper
 7183d9d9acfa41a61a64bdfed548e98299265a7bb1821a3ed204173b5c2cfd4a android.hardware.graphics.mapper@3.0::types
 c3f831a66d5815baf74f5b82fe79cf099542ddae4dfab3f388e1d41828e794fc android.hardware.health.storage@1.0::IGarbageCollectCallback
diff --git a/graphics/composer/2.3/IComposerClient.hal b/graphics/composer/2.3/IComposerClient.hal
index 1eea306..4d6f78f 100644
--- a/graphics/composer/2.3/IComposerClient.hal
+++ b/graphics/composer/2.3/IComposerClient.hal
@@ -502,6 +502,10 @@
                        float minLuminance);
 
     /**
+     * Use getDisplayCapabilities instead. If brightness is supported, must return
+     * DisplayCapability::BRIGHTNESS as one of the display capabilities via getDisplayCapabilities.
+     * Only use getDisplayCapabilities as the source of truth to query brightness support.
+     *
      * Gets whether brightness operations are supported on a display.
      *
      * @param display
diff --git a/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp b/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp
index 56b2e33..d51c30a 100644
--- a/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp
+++ b/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp
@@ -572,6 +572,10 @@
             std::find(capabilities.begin(), capabilities.end(),
                       IComposerClient::DisplayCapability::DOZE) != capabilities.end();
     EXPECT_EQ(mComposerClient->getDozeSupport(mPrimaryDisplay), hasDozeSupport);
+    bool hasBrightnessSupport =
+            std::find(capabilities.begin(), capabilities.end(),
+                      IComposerClient::DisplayCapability::BRIGHTNESS) != capabilities.end();
+    EXPECT_EQ(mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay), hasBrightnessSupport);
 }
 
 TEST_F(GraphicsComposerHidlTest, getDisplayCapabilitiesBadDisplay) {
@@ -604,24 +608,18 @@
 }
 
 /*
- * Test that getDisplayBrightnessSupport works as expected.
+ * Test that if brightness operations are supported, setDisplayBrightness works as expected.
  */
-TEST_F(GraphicsComposerHidlTest, getDisplayBrightnessSupport) {
+TEST_F(GraphicsComposerHidlTest, setDisplayBrightness) {
     std::vector<IComposerClient::DisplayCapability> capabilities;
     const auto error = mComposerClient->getDisplayCapabilities(mPrimaryDisplay, &capabilities);
     ASSERT_EQ(Error::NONE, error);
     bool brightnessSupport =
             std::find(capabilities.begin(), capabilities.end(),
                       IComposerClient::DisplayCapability::BRIGHTNESS) != capabilities.end();
-    EXPECT_EQ(mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay), brightnessSupport);
-}
-
-/*
- * Test that if brightness operations are supported, setDisplayBrightness works as expected.
- */
-TEST_F(GraphicsComposerHidlTest, setDisplayBrightness) {
-    if (!mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay)) {
-        EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.5f), Error::UNSUPPORTED);
+    if (!brightnessSupport) {
+        EXPECT_EQ(mComposerClient->getRaw()->setDisplayBrightness(mPrimaryDisplay, 0.5f),
+                  Error::UNSUPPORTED);
         GTEST_SUCCEED() << "Brightness operations are not supported";
         return;
     }
diff --git a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
index 2988211..a0b6d9a 100644
--- a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
+++ b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
@@ -508,9 +508,10 @@
                 }
             }
         }
-        // BIDIRECTIONAL_SEQUENCE_RNN can have either on or two outputs
-        // depending on a mergeOutputs parameter
-        if (operation.type == OperationType::BIDIRECTIONAL_SEQUENCE_RNN) {
+        // BIDIRECTIONAL_SEQUENCE_LSTM and BIDIRECTIONAL_SEQUENCE_RNN can have either one or two
+        // outputs depending on their mergeOutputs parameter.
+        if (operation.type == OperationType::BIDIRECTIONAL_SEQUENCE_LSTM ||
+            operation.type == OperationType::BIDIRECTIONAL_SEQUENCE_RNN) {
             for (const size_t outOprand : operation.outputs) {
                 if (operand == outOprand) {
                     return true;
diff --git a/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp b/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
index a0e927b..6f8aa02 100644
--- a/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
+++ b/vibrator/1.0/vts/functional/VtsHalVibratorV1_0TargetTest.cpp
@@ -24,13 +24,16 @@
 #include <VtsHalHidlTargetTestBase.h>
 #include <VtsHalHidlTargetTestEnvBase.h>
 
+using ::android::sp;
+using ::android::hardware::hidl_enum_range;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
 using ::android::hardware::vibrator::V1_0::Effect;
 using ::android::hardware::vibrator::V1_0::EffectStrength;
 using ::android::hardware::vibrator::V1_0::IVibrator;
 using ::android::hardware::vibrator::V1_0::Status;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
+
+#define EXPECT_OK(ret) EXPECT_TRUE((ret).isOk())
 
 // Test environment for Vibrator HIDL HAL.
 class VibratorHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
@@ -70,6 +73,12 @@
   }
 }
 
+static void validatePerformEffectBadInput(Status status, uint32_t lengthMs) {
+    ASSERT_EQ(Status::UNSUPPORTED_OPERATION, status);
+    ASSERT_EQ(static_cast<uint32_t>(0), lengthMs)
+            << "Effects that return UNSUPPORTED_OPERATION must have a duration of zero";
+}
+
 TEST_F(VibratorHidlTest, OnThenOffBeforeTimeout) {
   EXPECT_EQ(Status::OK, vibrator->on(2000));
   sleep(1);
@@ -81,6 +90,42 @@
   vibrator->perform(Effect::DOUBLE_CLICK, EffectStrength::LIGHT, validatePerformEffect);
 }
 
+/*
+ * Test to make sure effect values above the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest, PerformEffect_BadEffects_AboveValidRange) {
+    Effect effect = *std::prev(hidl_enum_range<Effect>().end());
+    Effect badEffect = static_cast<Effect>(static_cast<int32_t>(effect) + 1);
+    EXPECT_OK(vibrator->perform(badEffect, EffectStrength::LIGHT, validatePerformEffectBadInput));
+}
+
+/*
+ * Test to make sure effect values below the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest, PerformEffect_BadEffects_BelowValidRange) {
+    Effect effect = *hidl_enum_range<Effect>().begin();
+    Effect badEffect = static_cast<Effect>(static_cast<int32_t>(effect) - 1);
+    EXPECT_OK(vibrator->perform(badEffect, EffectStrength::LIGHT, validatePerformEffectBadInput));
+}
+
+/*
+ * Test to make sure strength values above the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest, PerformEffect_BadStrength_AboveValidRange) {
+    EffectStrength strength = *std::prev(hidl_enum_range<EffectStrength>().end());
+    EffectStrength badStrength = static_cast<EffectStrength>(static_cast<int32_t>(strength) + 1);
+    EXPECT_OK(vibrator->perform(Effect::CLICK, badStrength, validatePerformEffectBadInput));
+}
+
+/*
+ * Test to make sure strength values below the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest, PerformEffect_BadStrength_BelowValidRange) {
+    EffectStrength strength = *hidl_enum_range<EffectStrength>().begin();
+    EffectStrength badStrength = static_cast<EffectStrength>(static_cast<int32_t>(strength) - 1);
+    EXPECT_OK(vibrator->perform(Effect::CLICK, badStrength, validatePerformEffectBadInput));
+}
+
 TEST_F(VibratorHidlTest, ChangeVibrationalAmplitude) {
   if (vibrator->supportsAmplitudeControl()) {
     EXPECT_EQ(Status::OK, vibrator->setAmplitude(1));
diff --git a/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp b/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp
index 1a47fe9..3c3ebf2 100644
--- a/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp
+++ b/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp
@@ -23,14 +23,16 @@
 #include <android/hardware/vibrator/1.1/types.h>
 #include <unistd.h>
 
-using ::android::hardware::vibrator::V1_0::Effect;
+using ::android::sp;
+using ::android::hardware::hidl_enum_range;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
 using ::android::hardware::vibrator::V1_0::EffectStrength;
 using ::android::hardware::vibrator::V1_0::Status;
 using ::android::hardware::vibrator::V1_1::Effect_1_1;
 using ::android::hardware::vibrator::V1_1::IVibrator;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
+
+#define EXPECT_OK(ret) EXPECT_TRUE((ret).isOk())
 
 // Test environment for Vibrator HIDL HAL.
 class VibratorHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
@@ -72,11 +74,55 @@
     }
 }
 
+static void validatePerformEffectBadInput(Status status, uint32_t lengthMs) {
+    ASSERT_EQ(Status::UNSUPPORTED_OPERATION, status);
+    ASSERT_EQ(static_cast<uint32_t>(0), lengthMs)
+            << "Effects that return UNSUPPORTED_OPERATION must have a duration of zero";
+}
+
 TEST_F(VibratorHidlTest_1_1, PerformEffect_1_1) {
     vibrator->perform_1_1(Effect_1_1::CLICK, EffectStrength::MEDIUM, validatePerformEffect);
     vibrator->perform_1_1(Effect_1_1::TICK, EffectStrength::STRONG, validatePerformEffect);
 }
 
+/*
+ * Test to make sure effect values above the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest_1_1, PerformEffect_1_1_BadEffects_AboveValidRange) {
+    Effect_1_1 effect = *std::prev(hidl_enum_range<Effect_1_1>().end());
+    Effect_1_1 badEffect = static_cast<Effect_1_1>(static_cast<int32_t>(effect) + 1);
+    EXPECT_OK(
+            vibrator->perform_1_1(badEffect, EffectStrength::LIGHT, validatePerformEffectBadInput));
+}
+
+/*
+ * Test to make sure effect values below the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest_1_1, PerformEffect_1_1_BadEffects_BelowValidRange) {
+    Effect_1_1 effect = *hidl_enum_range<Effect_1_1>().begin();
+    Effect_1_1 badEffect = static_cast<Effect_1_1>(static_cast<int32_t>(effect) - 1);
+    EXPECT_OK(
+            vibrator->perform_1_1(badEffect, EffectStrength::LIGHT, validatePerformEffectBadInput));
+}
+
+/*
+ * Test to make sure strength values above the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest_1_1, PerformEffect_1_1_BadStrength_AboveValidRange) {
+    EffectStrength strength = *std::prev(hidl_enum_range<EffectStrength>().end());
+    EffectStrength badStrength = static_cast<EffectStrength>(static_cast<int32_t>(strength) + 1);
+    EXPECT_OK(vibrator->perform_1_1(Effect_1_1::CLICK, badStrength, validatePerformEffectBadInput));
+}
+
+/*
+ * Test to make sure strength values below the valid range are rejected.
+ */
+TEST_F(VibratorHidlTest_1_1, PerformEffect_1_1_BadStrength_BelowValidRange) {
+    EffectStrength strength = *hidl_enum_range<EffectStrength>().begin();
+    EffectStrength badStrength = static_cast<EffectStrength>(static_cast<int32_t>(strength) - 1);
+    EXPECT_OK(vibrator->perform_1_1(Effect_1_1::CLICK, badStrength, validatePerformEffectBadInput));
+}
+
 int main(int argc, char** argv) {
     ::testing::AddGlobalTestEnvironment(VibratorHidlEnvironment::Instance());
     ::testing::InitGoogleTest(&argc, argv);
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
index fa780f9..6dc9eb4 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
@@ -41,6 +41,7 @@
 class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    public:
     virtual void SetUp() override {
+        stopSupplicantIfNeeded();
         startHostapdAndWaitForHidlService();
         hostapd_ = getHostapd();
         ASSERT_NE(hostapd_.get(), nullptr);
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 22dbb52..1c499e7 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
@@ -23,24 +23,26 @@
 
 #include <wifi_system/hostapd_manager.h>
 #include <wifi_system/interface_tool.h>
+#include <wifi_system/supplicant_manager.h>
 
 #include "hostapd_hidl_test_utils.h"
 #include "wifi_hidl_test_utils.h"
 
 using ::android::sp;
 using ::android::hardware::configureRpcThreadpool;
-using ::android::hardware::joinRpcThreadpool;
 using ::android::hardware::hidl_string;
 using ::android::hardware::hidl_vec;
+using ::android::hardware::joinRpcThreadpool;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
-using ::android::hardware::wifi::V1_0::ChipModeId;
-using ::android::hardware::wifi::V1_0::IWifiChip;
-using ::android::hardware::wifi::hostapd::V1_0::IHostapd;
 using ::android::hardware::wifi::hostapd::V1_0::HostapdStatus;
 using ::android::hardware::wifi::hostapd::V1_0::HostapdStatusCode;
+using ::android::hardware::wifi::hostapd::V1_0::IHostapd;
+using ::android::hardware::wifi::V1_0::ChipModeId;
+using ::android::hardware::wifi::V1_0::IWifiChip;
 using ::android::hidl::manager::V1_0::IServiceNotification;
 using ::android::wifi_system::HostapdManager;
+using ::android::wifi_system::SupplicantManager;
 
 extern WifiHostapdHidlEnvironment* gEnv;
 
@@ -108,6 +110,16 @@
     std::condition_variable condition_;
 };
 
+void stopSupplicantIfNeeded() {
+    SupplicantManager supplicant_manager;
+    if (supplicant_manager.IsSupplicantRunning()) {
+        LOG(INFO) << "Supplicant is running, stop supplicant first.";
+        ASSERT_TRUE(supplicant_manager.StopSupplicant());
+        deInitilializeDriverAndFirmware();
+        ASSERT_FALSE(supplicant_manager.IsSupplicantRunning());
+    }
+}
+
 void stopHostapd() {
     HostapdManager hostapd_manager;
 
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 8e2f1a3..9b3df42 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
@@ -25,6 +25,7 @@
 // Used to stop the android wifi framework before every test.
 void stopWifiFramework();
 void startWifiFramework();
+void stopSupplicantIfNeeded();
 void stopHostapd();
 // Used to configure the chip, driver and start wpa_hostapd before every
 // test.
diff --git a/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp
index 439a624..26a58b2 100644
--- a/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp
+++ b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp
@@ -45,6 +45,7 @@
 class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    public:
     virtual void SetUp() override {
+        stopSupplicantIfNeeded();
         startHostapdAndWaitForHidlService();
         hostapd_ = getHostapd_1_1();
         ASSERT_NE(hostapd_.get(), nullptr);
diff --git a/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index 9249045..36bde16 100644
--- a/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.2/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -57,7 +57,7 @@
 TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_Success) {
     std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
     std::string passphrase = kTestPassphrase;
-    int freq = 5;
+    int freq = 0;
     std::array<uint8_t, 6> zero_mac_addr;
     memcpy(zero_mac_addr.data(), kTestZeroMacAddr, zero_mac_addr.size());
     bool persistent = false;
@@ -76,7 +76,7 @@
 TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidSsid) {
     std::vector<uint8_t> ssid;
     std::string passphrase = kTestPassphrase;
-    int freq = 5;
+    int freq = 0;
     std::array<uint8_t, 6> zero_mac_addr;
     memcpy(zero_mac_addr.data(), kTestZeroMacAddr, zero_mac_addr.size());
     bool persistent = false;
@@ -95,7 +95,7 @@
 TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidPassphrase) {
     std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
     std::string passphrase = "1234";
-    int freq = 5;
+    int freq = 0;
     std::array<uint8_t, 6> zero_mac_addr;
     memcpy(zero_mac_addr.data(), kTestZeroMacAddr, zero_mac_addr.size());
     bool persistent = false;