Merge "wifi: Fix single AP iface isn't deleted" into udc-dev
diff --git a/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp b/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
index f8d301f..aee5366 100644
--- a/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
+++ b/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
@@ -2063,18 +2063,17 @@
 TEST_P(CameraAidlTest, processZoomSettingsOverrideRequests) {
     const int32_t kFrameCount = 5;
     const int32_t kTestCases = 2;
-    const bool kOverrideSequence[kTestCases][kFrameCount] = {
-        // ZOOM, ZOOM, ZOOM, ZOOM, ZOOM;
-        { true, true, true, true, true },
-        // OFF, OFF, ZOOM, ZOOM, OFF;
-        { false, false, true, true, false } };
+    const bool kOverrideSequence[kTestCases][kFrameCount] = {// ZOOM, ZOOM, ZOOM, ZOOM, ZOOM;
+                                                             {true, true, true, true, true},
+                                                             // OFF, ZOOM, ZOOM, ZOOM, OFF;
+                                                             {false, true, true, true, false}};
     const bool kExpectedOverrideResults[kTestCases][kFrameCount] = {
-        // All resuls should be overridden except the last one. The last result's
-        // zoom doesn't have speed-up.
-        { true, true, true, true, false },
-        // Because we require at least 2 frames speed-up, request #1, #2 and #3
-        // will be overridden.
-        { true, true, true, false, false } };
+            // All resuls should be overridden except the last one. The last result's
+            // zoom doesn't have speed-up.
+            {true, true, true, true, false},
+            // Because we require at least 1 frame speed-up, request #1, #2 and #3
+            // will be overridden.
+            {true, true, true, false, false}};
 
     for (int i = 0; i < kTestCases; i++) {
         processZoomSettingsOverrideRequests(kFrameCount, kOverrideSequence[i],
diff --git a/compatibility_matrices/compatibility_matrix.8.xml b/compatibility_matrices/compatibility_matrix.8.xml
index 4ac95f5..c04a499 100644
--- a/compatibility_matrices/compatibility_matrix.8.xml
+++ b/compatibility_matrices/compatibility_matrix.8.xml
@@ -345,6 +345,7 @@
             <name>IRemotelyProvisionedComponent</name>
             <instance>default</instance>
             <instance>strongbox</instance>
+            <instance>widevine</instance>
         </interface>
     </hal>
     <hal format="aidl" optional="true">
diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerCommandEngine.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerCommandEngine.h
index f1d61f8..42996dd 100644
--- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerCommandEngine.h
+++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerCommandEngine.h
@@ -82,7 +82,7 @@
 
         std::vector<IComposerClient::PerFrameMetadataBlob> metadata;
 
-        for (size_t i = 0; i < numBlobs; i++) {
+        for (size_t i = 0; i < numBlobs && length >= 2; i++) {
             IComposerClient::PerFrameMetadataKey key =
                 static_cast<IComposerClient::PerFrameMetadataKey>(readSigned());
             uint32_t blobSize = read();
diff --git a/identity/aidl/vts/Util.cpp b/identity/aidl/vts/Util.cpp
index 4f5c121..ad9281c 100644
--- a/identity/aidl/vts/Util.cpp
+++ b/identity/aidl/vts/Util.cpp
@@ -73,7 +73,7 @@
     ndkMacedPublicKey.macedKey = macedPublicKey.macedKey;
 
     vector<uint8_t> publicKeyBits;
-    check_maced_pubkey(ndkMacedPublicKey, /*testMode=*/true, &publicKeyBits);
+    check_maced_pubkey(ndkMacedPublicKey, /*testMode=*/false, &publicKeyBits);
 
     ::aidl::android::hardware::security::keymint::EVP_PKEY_Ptr publicKey;
     p256_pub_key(publicKeyBits, &publicKey);
diff --git a/keymaster/4.0/vts/functional/BootloaderStateTest.cpp b/keymaster/4.0/vts/functional/BootloaderStateTest.cpp
index 6b5e8bf..912b59b 100644
--- a/keymaster/4.0/vts/functional/BootloaderStateTest.cpp
+++ b/keymaster/4.0/vts/functional/BootloaderStateTest.cpp
@@ -60,13 +60,9 @@
         ASSERT_TRUE(attest_rec) << "Failed to get attestation record.";
 
         // Parse root of trust.
-        HidlBuf verified_boot_key;
-        keymaster_verified_boot_t verified_boot_state;
-        bool device_locked;
-        HidlBuf verified_boot_hash;
-        auto result =
-                parse_root_of_trust(attest_rec->data, attest_rec->length, &verified_boot_key,
-                                    &verified_boot_state, &device_locked, &verified_boot_hash);
+        auto result = parse_root_of_trust(attest_rec->data, attest_rec->length, &attestedVbKey_,
+                                          &attestedVbState_, &attestedBootloaderState_,
+                                          &attestedVbmetaDigest_);
         ASSERT_EQ(result, ErrorCode::OK) << "Failed to parse root of trust.";
     }
 
diff --git a/security/keymint/aidl/vts/functional/AttestKeyTest.cpp b/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
index c035f19..a868c96 100644
--- a/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
+++ b/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
@@ -80,7 +80,13 @@
         return "";
     }
 
-    return ::android::base::Trim(out[0]);
+    string imei = ::android::base::Trim(out[0]);
+    if (imei.compare("null") == 0) {
+        LOG(ERROR) << "Error in getting IMEI from Telephony service: value is null. Cmd: " << cmd;
+        return "";
+    }
+
+    return imei;
 }
 
 }  // namespace
@@ -972,7 +978,7 @@
 
     // Skip the test if there is no second IMEI exists.
     string second_imei = get_imei(1);
-    if (second_imei.empty() || second_imei.compare("null") == 0) {
+    if (second_imei.empty()) {
         GTEST_SKIP() << "Test not applicable as there is no second IMEI";
     }
 
@@ -1050,13 +1056,13 @@
 
     // Skip the test if there is no first IMEI exists.
     string imei = get_imei(0);
-    if (imei.empty() || imei.compare("null") == 0) {
+    if (imei.empty()) {
         GTEST_SKIP() << "Test not applicable as there is no first IMEI";
     }
 
     // Skip the test if there is no second IMEI exists.
     string second_imei = get_imei(1);
-    if (second_imei.empty() || second_imei.compare("null") == 0) {
+    if (second_imei.empty()) {
         GTEST_SKIP() << "Test not applicable as there is no second IMEI";
     }
 
diff --git a/tv/cec/1.0/default/HdmiCec.cpp b/tv/cec/1.0/default/HdmiCec.cpp
index 74de785..f05f610 100644
--- a/tv/cec/1.0/default/HdmiCec.cpp
+++ b/tv/cec/1.0/default/HdmiCec.cpp
@@ -307,6 +307,9 @@
 }
 
 Return<SendMessageResult> HdmiCec::sendMessage(const CecMessage& message) {
+    if (message.body.size() > CEC_MESSAGE_BODY_MAX_LENGTH) {
+        return SendMessageResult::FAIL;
+    }
     cec_message_t legacyMessage {
         .initiator = static_cast<cec_logical_address_t>(message.initiator),
         .destination = static_cast<cec_logical_address_t>(message.destination),
diff --git a/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl b/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl
index cbaf066..c63e0ac 100644
--- a/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl
+++ b/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl
@@ -98,6 +98,11 @@
      * detected from the stream based on whether or not they are enabled by
      * {@link #setTvMessageEnabled(int, int, TvMessageEventType, boolean)}.
      *
+     * This queue is expected to already contain the message data before calling
+     * {@link android.hardware.tv.input.ITvInputCallback#notifyTvMessageEvent}.
+     * The HAL implementation is expected to have already created the queue
+     * before the notification callback is called for the first time.
+     *
      * @param deviceId The ID of the device that contains the stream to get the queue for.
      * @param streamId THe ID of the stream to get the queue for.
      * @return The descriptor of the TV message queue.
diff --git a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
index 2c7e32f..a3afd41 100644
--- a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
+++ b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
@@ -39,6 +39,11 @@
      * the device that sent the message should be contained in
      * {@link android.hardware.tv.input.TvMessage#groupId}
      *
+     * Invoking this callback for the first time immediately triggers
+     * {@link android.hardware.tv.input.ITvInput#getTvMessageQueueDesc}. It is
+     * expected for the queue to be ready with
+     * the relevant messages for the event before this callback is called.
+     *
      * @param event Event passed to the client.
      */
     void notifyTvMessageEvent(in TvMessageEvent event);
diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
index 6433305..8d3395b 100644
--- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
+++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
@@ -134,6 +134,19 @@
     return result;
 }
 
+bool TvInputAidlTest::isValidHandle(NativeHandle& handle) {
+    if (handle.fds.empty()) {
+        return false;
+    }
+    for (size_t i = 0; i < handle.fds.size(); i++) {
+        int fd = handle.fds[i].get();
+        if (fcntl(fd, F_GETFL) < 0) {
+            return false;
+        }
+    }
+    return true;
+}
+
 /*
  * GetStreamConfigTest:
  * Calls updateStreamConfigurations() for each existing device
@@ -168,6 +181,8 @@
             ALOGD("OpenAndCloseStreamTest: open stream, device_id=%d, stream_id=%d", device_id,
                   stream_id);
             ASSERT_TRUE(tv_input_->openStream(device_id, stream_id, &handle).isOk());
+            ASSERT_TRUE(isValidHandle(handle));
+
             ALOGD("OpenAndCloseStreamTest: close stream, device_id=%d, stream_id=%d", device_id,
                   stream_id);
             ASSERT_TRUE(tv_input_->closeStream(device_id, stream_id).isOk());
@@ -268,6 +283,7 @@
 
     ALOGD("OpenAnOpenedStreamsTest: open stream, device_id=%d, stream_id=%d", device_id, stream_id);
     ASSERT_TRUE(tv_input_->openStream(device_id, stream_id, &handle).isOk());
+    ASSERT_TRUE(isValidHandle(handle));
 
     ALOGD("OpenAnOpenedStreamsTest: open stream, device_id=%d, stream_id=%d", device_id, stream_id);
     ASSERT_TRUE(tv_input_->openStream(device_id, stream_id, &handle).getServiceSpecificError() ==
diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
index 832b27c..7e66a88 100644
--- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
+++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
@@ -17,6 +17,7 @@
 #pragma once
 
 #include <android/binder_manager.h>
+#include <fcntl.h>
 
 #include <aidl/Gtest.h>
 #include <aidl/Vintf.h>
@@ -84,6 +85,9 @@
      */
     int32_t getNumNotIn(vector<int32_t>& nums);
 
+    /* Checks if a native handle contains valid file descriptor(s). */
+    bool isValidHandle(NativeHandle& handle);
+
   protected:
     shared_ptr<ITvInput> tv_input_;
     shared_ptr<TvInputCallback> tv_input_callback_;
diff --git a/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp b/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp
index 288f20a..f12d873 100644
--- a/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp
+++ b/wifi/aidl/vts/functional/wifi_sta_iface_aidl_test.cpp
@@ -24,6 +24,7 @@
 #include <android/binder_status.h>
 #include <binder/IServiceManager.h>
 #include <binder/ProcessState.h>
+#include <cutils/properties.h>
 
 #include "wifi_aidl_test_utils.h"
 
@@ -98,16 +99,23 @@
  */
 // @VsrTest = 5.3.12
 TEST_P(WifiStaIfaceAidlTest, CheckApfIsSupported) {
-    // It is not required to check the vendor API level is at least U here
-    // because the Wi-Fi AIDL interface is launched with Android U(VSR-14).
-    // TODO: Add wavier list to the chipsets that doesn't support APF.
-    EXPECT_TRUE(isFeatureSupported(IWifiStaIface::FeatureSetMask::APF));
-    StaApfPacketFilterCapabilities apf_caps = {};
-    EXPECT_TRUE(wifi_sta_iface_->getApfPacketFilterCapabilities(&apf_caps).isOk());
-    // The APF version must be 4 and the usable memory must be at least
-    // 1024 bytes.
-    EXPECT_EQ(apf_caps.version, 4);
-    EXPECT_GE(apf_caps.maxLength, 1024);
+    int vendor_api_level = property_get_int32("ro.vendor.api_level", 0);
+    // Before VSR 14, APF support is optional.
+    if (vendor_api_level < __ANDROID_API_U__) {
+        if (!isFeatureSupported(IWifiStaIface::FeatureSetMask::APF)) {
+            GTEST_SKIP() << "APF packet filter capabilities are not supported.";
+        }
+        StaApfPacketFilterCapabilities apf_caps = {};
+        EXPECT_TRUE(wifi_sta_iface_->getApfPacketFilterCapabilities(&apf_caps).isOk());
+    } else {
+        EXPECT_TRUE(isFeatureSupported(IWifiStaIface::FeatureSetMask::APF));
+        StaApfPacketFilterCapabilities apf_caps = {};
+        EXPECT_TRUE(wifi_sta_iface_->getApfPacketFilterCapabilities(&apf_caps).isOk());
+        // The APF version must be 4 and the usable memory must be at least
+        // 1024 bytes.
+        EXPECT_EQ(apf_caps.version, 4);
+        EXPECT_GE(apf_caps.maxLength, 1024);
+    }
 }
 
 /*