Merge "Add EMPTY_RECORD for getDeviceIdentity" into oc-dev
diff --git a/audio/2.0/config/audio_policy_configuration.xsd b/audio/2.0/config/audio_policy_configuration.xsd
index 48b9a9b..c94da80 100644
--- a/audio/2.0/config/audio_policy_configuration.xsd
+++ b/audio/2.0/config/audio_policy_configuration.xsd
@@ -188,6 +188,7 @@
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/>
+                        <xs:element name="gains" type="gains" minOccurs="0"/>
                     </xs:sequence>
                     <xs:attribute name="name" type="xs:token" use="required"/>
                     <xs:attribute name="role" type="role" use="required"/>
@@ -199,6 +200,10 @@
                     <xs:field xpath="samplingRate"/>
                     <xs:field xpath="channelMasks"/>
                 </xs:unique>
+                <xs:unique name="mixPortGainUniqueness">
+                    <xs:selector xpath="gains/gain"/>
+                    <xs:field xpath="@name"/>
+                </xs:unique>
             </xs:element>
         </xs:sequence>
     </xs:complexType>
@@ -365,16 +370,42 @@
         <xs:attribute name="samplingRates" type="samplingRates" use="required"/>
         <xs:attribute name="channelMasks" type="channelMask" use="required"/>
     </xs:complexType>
+    <xs:simpleType name="gainMode">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="AUDIO_GAIN_MODE_JOINT"/>
+            <xs:enumeration value="AUDIO_GAIN_MODE_CHANNELS"/>
+            <xs:enumeration value="AUDIO_GAIN_MODE_RAMP"/>
+        </xs:restriction>
+    </xs:simpleType>
+    <xs:complexType name="gains">
+        <xs:sequence>
+            <xs:element name="gain" minOccurs="0" maxOccurs="unbounded">
+                <xs:complexType>
+                    <xs:attribute name="name" type="xs:token" use="required"/>
+                    <xs:attribute name="mode" type="gainMode" use="required"/>
+                    <xs:attribute name="channel_mask" type="channelMask" use="optional"/>
+                    <xs:attribute name="minValueMB" type="xs:int" use="optional"/>
+                    <xs:attribute name="maxValueMB" type="xs:int" use="optional"/>
+                    <xs:attribute name="defaultValueMB" type="xs:int" use="optional"/>
+                    <xs:attribute name="stepValueMB" type="xs:int" use="optional"/>
+                    <xs:attribute name="minRampMs" type="xs:int" use="optional"/>
+                    <xs:attribute name="maxRampMs" type="xs:int" use="optional"/>
+                </xs:complexType>
+            </xs:element>
+        </xs:sequence>
+    </xs:complexType>
     <xs:complexType name="devicePorts">
         <xs:sequence>
             <xs:element name="devicePort" minOccurs="0" maxOccurs="unbounded">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/>
+                        <xs:element name="gains" type="gains" minOccurs="0"/>
                     </xs:sequence>
                     <xs:attribute name="tagName" type="xs:token" use="required"/>
                     <xs:attribute name="type" type="audioDevice" use="required"/>
                     <xs:attribute name="role" type="role" use="required"/>
+                    <xs:attribute name="address" type="xs:string" use="optional"/>
                 </xs:complexType>
                 <xs:unique name="devicePortProfileUniqueness">
                     <xs:selector xpath="profile"/>
@@ -382,6 +413,10 @@
                     <xs:field xpath="samplingRate"/>
                     <xs:field xpath="channelMasks"/>
                 </xs:unique>
+                <xs:unique name="devicePortGainUniqueness">
+                    <xs:selector xpath="gains/gain"/>
+                    <xs:field xpath="@name"/>
+                </xs:unique>
             </xs:element>
         </xs:sequence>
     </xs:complexType>
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 55f55f6..0d47f00 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -131,22 +131,34 @@
     const char *kHAL1_0 = "1.0";
 
     bool matchDeviceName(const hidl_string& deviceName,
-            const hidl_string &providerType, std::smatch& sm) {
+            const hidl_string &providerType,
+            std::string* deviceVersion,
+            std::string* cameraId) {
         ::android::String8 pattern;
         pattern.appendFormat(kDeviceNameRE, providerType.c_str());
         std::regex e(pattern.string());
         std::string deviceNameStd(deviceName.c_str());
-        return std::regex_match(deviceNameStd, sm, e);
+        std::smatch sm;
+        if (std::regex_match(deviceNameStd, sm, e)) {
+            if (deviceVersion != nullptr) {
+                *deviceVersion = sm[1];
+            }
+            if (cameraId != nullptr) {
+                *cameraId = sm[2];
+            }
+            return true;
+        }
+        return false;
     }
 
     int getCameraDeviceVersion(const hidl_string& deviceName,
             const hidl_string &providerType) {
-        std::smatch sm;
-        bool match = matchDeviceName(deviceName, providerType, sm);
+        std::string version;
+        bool match = matchDeviceName(deviceName, providerType, &version, nullptr);
         if (!match) {
             return -1;
         }
-        std::string version = sm[1].str();
+
         if (version.compare(kHAL3_2) == 0) {
             // maybe switched to 3.4 or define the hidl version enumlater
             return CAMERA_DEVICE_API_VERSION_3_2;
@@ -2441,7 +2453,8 @@
                     Stream stream = {streamId, StreamType::OUTPUT,
                             static_cast<uint32_t> (it.width),
                             static_cast<uint32_t> (it.height),
-                            static_cast<PixelFormat> (it.format), 0, 0,
+                            static_cast<PixelFormat> (it.format),
+                            GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0,
                             StreamRotation::ROTATION_0};
                     ::android::hardware::hidl_vec<Stream> streams = {stream};
                     StreamConfiguration config = {streams,
@@ -2490,7 +2503,8 @@
                         static_cast<uint32_t> (0),
                         static_cast<uint32_t> (0),
                         static_cast<PixelFormat> (outputStreams[0].format),
-                        0, 0, StreamRotation::ROTATION_0};
+                        GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0,
+                        StreamRotation::ROTATION_0};
                 ::android::hardware::hidl_vec<Stream> streams = {stream};
                 StreamConfiguration config = {streams,
                         StreamConfigurationMode::NORMAL_MODE};
@@ -2505,7 +2519,8 @@
                         static_cast<uint32_t> (UINT32_MAX),
                         static_cast<uint32_t> (UINT32_MAX),
                         static_cast<PixelFormat> (outputStreams[0].format),
-                        0, 0, StreamRotation::ROTATION_0};
+                        GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0,
+                        StreamRotation::ROTATION_0};
                 streams[0] = stream;
                 config = {streams,
                         StreamConfigurationMode::NORMAL_MODE};
@@ -2520,7 +2535,8 @@
                             static_cast<uint32_t> (it.width),
                             static_cast<uint32_t> (it.height),
                             static_cast<PixelFormat> (UINT32_MAX),
-                            0, 0, StreamRotation::ROTATION_0};
+                            GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0,
+                            StreamRotation::ROTATION_0};
                     streams[0] = stream;
                     config = {streams,
                             StreamConfigurationMode::NORMAL_MODE};
@@ -2534,7 +2550,8 @@
                             static_cast<uint32_t> (it.width),
                             static_cast<uint32_t> (it.height),
                             static_cast<PixelFormat> (it.format),
-                            0, 0, static_cast<StreamRotation> (UINT32_MAX)};
+                            GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0,
+                            static_cast<StreamRotation> (UINT32_MAX)};
                     streams[0] = stream;
                     config = {streams,
                             StreamConfigurationMode::NORMAL_MODE};
@@ -2611,12 +2628,14 @@
                         Stream inputStream = {streamId++, StreamType::INPUT,
                                 static_cast<uint32_t> (input.width),
                                 static_cast<uint32_t> (input.height),
-                                static_cast<PixelFormat> (input.format), 0, 0,
+                                static_cast<PixelFormat> (input.format),
+                                0, 0,
                                 StreamRotation::ROTATION_0};
                         Stream outputStream = {streamId++, StreamType::OUTPUT,
                                 static_cast<uint32_t> (outputIter.width),
                                 static_cast<uint32_t> (outputIter.height),
-                                static_cast<PixelFormat> (outputIter.format), 0, 0,
+                                static_cast<PixelFormat> (outputIter.format),
+                                GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0,
                                 StreamRotation::ROTATION_0};
 
                         ::android::hardware::hidl_vec<Stream> streams = {
@@ -2678,12 +2697,14 @@
                         Stream previewStream = {streamId++, StreamType::OUTPUT,
                                 static_cast<uint32_t> (previewIter.width),
                                 static_cast<uint32_t> (previewIter.height),
-                                static_cast<PixelFormat> (previewIter.format), 0, 0,
+                                static_cast<PixelFormat> (previewIter.format),
+                                GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0,
                                 StreamRotation::ROTATION_0};
                         Stream blobStream = {streamId++, StreamType::OUTPUT,
                                 static_cast<uint32_t> (blobIter.width),
                                 static_cast<uint32_t> (blobIter.height),
-                                static_cast<PixelFormat> (blobIter.format), 0, 0,
+                                static_cast<PixelFormat> (blobIter.format),
+                                GRALLOC1_CONSUMER_USAGE_CPU_READ, 0,
                                 StreamRotation::ROTATION_0};
                         ::android::hardware::hidl_vec<Stream> streams = {
                                 previewStream, blobStream};
@@ -2739,7 +2760,8 @@
                 Stream stream = {streamId, StreamType::OUTPUT,
                         static_cast<uint32_t> (hfrStream.width),
                         static_cast<uint32_t> (hfrStream.height),
-                        static_cast<PixelFormat> (hfrStream.format), 0, 0,
+                        static_cast<PixelFormat> (hfrStream.format),
+                        GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, 0,
                         StreamRotation::ROTATION_0};
                 ::android::hardware::hidl_vec<Stream> streams = {stream};
                 StreamConfiguration config = {streams,
@@ -2755,7 +2777,8 @@
                 stream = {streamId++, StreamType::OUTPUT,
                         static_cast<uint32_t> (0),
                         static_cast<uint32_t> (0),
-                        static_cast<PixelFormat> (hfrStream.format), 0, 0,
+                        static_cast<PixelFormat> (hfrStream.format),
+                        GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, 0,
                         StreamRotation::ROTATION_0};
                 streams[0] = stream;
                 config = {streams,
@@ -2770,7 +2793,8 @@
                 stream = {streamId++, StreamType::OUTPUT,
                         static_cast<uint32_t> (UINT32_MAX),
                         static_cast<uint32_t> (UINT32_MAX),
-                        static_cast<PixelFormat> (hfrStream.format), 0, 0,
+                        static_cast<PixelFormat> (hfrStream.format),
+                        GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, 0,
                         StreamRotation::ROTATION_0};
                 streams[0] = stream;
                 config = {streams,
@@ -2784,7 +2808,8 @@
                 stream = {streamId++, StreamType::OUTPUT,
                         static_cast<uint32_t> (hfrStream.width),
                         static_cast<uint32_t> (hfrStream.height),
-                        static_cast<PixelFormat> (UINT32_MAX), 0, 0,
+                        static_cast<PixelFormat> (UINT32_MAX),
+                        GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, 0,
                         StreamRotation::ROTATION_0};
                 streams[0] = stream;
                 config = {streams,
@@ -2842,12 +2867,13 @@
                                 static_cast<uint32_t> (videoIter.width),
                                 static_cast<uint32_t> (videoIter.height),
                                 static_cast<PixelFormat> (videoIter.format),
-                                0, 0, StreamRotation::ROTATION_0};
+                                GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, 0,
+                                StreamRotation::ROTATION_0};
                         Stream blobStream = {streamId++, StreamType::OUTPUT,
                                 static_cast<uint32_t> (blobIter.width),
                                 static_cast<uint32_t> (blobIter.height),
                                 static_cast<PixelFormat> (blobIter.format),
-                                GRALLOC_USAGE_HW_VIDEO_ENCODER, 0,
+                                GRALLOC1_CONSUMER_USAGE_CPU_READ, 0,
                                 StreamRotation::ROTATION_0};
                         ::android::hardware::hidl_vec<Stream> streams = {
                                 videoStream, blobStream};
@@ -2908,7 +2934,6 @@
                         }
                     });
                 ASSERT_TRUE(resultQueueRet.isOk());
-                ASSERT_NE(nullptr, resultQueue);
 
                 InFlightRequest inflightReq = {1, false, supportsPartialResults,
                         partialResultCount, resultQueue};
@@ -2978,6 +3003,9 @@
                     //Empty settings should be supported after the first call
                     //for repeating requests.
                     request.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.outputBuffers[0].buffer = nullptr;
                     mInflightMap.clear();
                     inflightReq = {1, false, supportsPartialResults,
                                         partialResultCount, resultQueue};
@@ -3074,7 +3102,10 @@
                             numRequestProcessed = n;
                         });
                 ASSERT_TRUE(ret.isOk());
-                ASSERT_EQ(Status::INTERNAL_ERROR, status);
+                // b/64041692: Temporariy accept ILLEGAL_ARGUMENT or INTERNAL_ERROR
+                // It will be changed to only accept ILLEGAL_ARGUMENT in next release
+                ASSERT_TRUE(status == Status::ILLEGAL_ARGUMENT ||
+                        status == Status::INTERNAL_ERROR);
                 ASSERT_EQ(numRequestProcessed, 0u);
 
                 ret = session->close();
@@ -3135,7 +3166,10 @@
                             numRequestProcessed = n;
                         });
                 ASSERT_TRUE(ret.isOk());
-                ASSERT_EQ(Status::INTERNAL_ERROR, status);
+                // b/64041692: Temporariy accept ILLEGAL_ARGUMENT or INTERNAL_ERROR
+                // It will be changed to only accept ILLEGAL_ARGUMENT in next release
+                ASSERT_TRUE(status == Status::ILLEGAL_ARGUMENT ||
+                        status == Status::INTERNAL_ERROR);
                 ASSERT_EQ(numRequestProcessed, 0u);
 
                 ret = session->close();
@@ -3184,7 +3218,6 @@
                         }
                     });
                 ASSERT_TRUE(resultQueueRet.isOk());
-                ASSERT_NE(nullptr, resultQueue);
 
                 InFlightRequest inflightReq = {1, false, supportsPartialResults,
                         partialResultCount, resultQueue};
@@ -3569,7 +3602,7 @@
             static_cast<uint32_t> (outputPreviewStreams[0].width),
             static_cast<uint32_t> (outputPreviewStreams[0].height),
             static_cast<PixelFormat> (outputPreviewStreams[0].format),
-            0, 0, StreamRotation::ROTATION_0};
+            GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0, StreamRotation::ROTATION_0};
     ::android::hardware::hidl_vec<Stream> streams = {*previewStream};
     StreamConfiguration config = {streams,
             StreamConfigurationMode::NORMAL_MODE};
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_data.cpp b/radio/1.0/vts/functional/radio_hidl_hal_data.cpp
index 87ca606..1e0cff4 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_data.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_data.cpp
@@ -104,8 +104,8 @@
     if (cardStatus.cardState == CardState::ABSENT) {
         ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
                     radioRsp->rspInfo.error == RadioError::INVALID_CALL_ID ||
-                    radioRsp->rspInfo.error == RadioError::SIM_ABSENT ||
-                    CheckOEMError());
+                    radioRsp->rspInfo.error == RadioError::SIM_ABSENT || CheckOEMError() ||
+                    radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE);
     }
 }
 
@@ -230,8 +230,8 @@
 
     if (cardStatus.cardState == CardState::ABSENT) {
         ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
-                    radioRsp->rspInfo.error ==
-                        RadioError::RADIO_NOT_AVAILABLE ||
-                    radioRsp->rspInfo.error == RadioError::SIM_ABSENT);
+                    radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE ||
+                    radioRsp->rspInfo.error == RadioError::SIM_ABSENT ||
+                    radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
     }
 }
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
index ad892ac..87e7a40 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
@@ -764,8 +764,7 @@
 
     if (cardStatus.cardState == CardState::ABSENT) {
         ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
-                    radioRsp->rspInfo.error ==
-                        RadioError::REQUEST_NOT_SUPPORTED);
+                    radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
     }
 
     /* Reset back to no carrier restriction */
@@ -780,8 +779,7 @@
 
     if (cardStatus.cardState == CardState::ABSENT) {
         ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
-                    radioRsp->rspInfo.error ==
-                        RadioError::REQUEST_NOT_SUPPORTED);
+                    radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
     }
 }
 
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 b957c6e..158cd6e 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
@@ -35,6 +35,10 @@
     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
     EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
+
+    /* Vts Testing with Sim Absent only. This needs to be removed later in P when sim present
+     * scenarios will be tested. */
+    EXPECT_EQ(CardState::ABSENT, cardStatus.cardState);
 }
 
 void RadioHidlTest::TearDown() {}
diff --git a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
index a69d14d..33f3049 100644
--- a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
+++ b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp
@@ -23,12 +23,9 @@
 class SupplicantHidlEnvironment : public ::testing::Environment {
    public:
     virtual void SetUp() override {
-        stopWifiFramework();
         stopSupplicant();
     }
     virtual void TearDown() override {
-        startWifiFramework();
-        // Framework will start wpa_supplicant.
     }
 };
 
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 df4bfa9..79be2b0 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
@@ -135,19 +135,6 @@
     std::condition_variable condition_;
 };
 
-void stopWifiFramework() {
-    ASSERT_EQ(std::system("stop"), 0);
-    // TODO: Use some other mechanism to wait for the framework to
-    // finish disabling.
-    sleep(5);
-}
-
-void startWifiFramework() {
-    ASSERT_EQ(std::system("start"), 0);
-    // These tests don't care whether the framework
-    // finished enabling or not.
-}
-
 void stopSupplicant() {
     DriverTool driver_tool;
     SupplicantManager supplicant_manager;