Merge "Modify StateTransitions test" into oc-mr1-dev
diff --git a/audio/2.0/vts/functional/Android.bp b/audio/2.0/vts/functional/Android.bp
index b289709..f3b2ca7 100644
--- a/audio/2.0/vts/functional/Android.bp
+++ b/audio/2.0/vts/functional/Android.bp
@@ -16,29 +16,18 @@
 
 cc_test {
     name: "VtsHalAudioV2_0TargetTest",
-    defaults: ["hidl_defaults"],
-    srcs: ["AudioPrimaryHidlHalTest.cpp",
-           "ValidateAudioConfiguration.cpp"],
-    shared_libs: [
-        "libbase",
-        "liblog",
-        "libhidlbase",
-        "libhidltransport",
-        "libutils",
-        "libcutils",
-        "libxml2",
-        "android.hardware.audio@2.0",
-        "android.hardware.audio.common@2.0",
+    defaults: ["VtsHalTargetTestDefaults"],
+    srcs: [
+        "AudioPrimaryHidlHalTest.cpp",
+        "ValidateAudioConfiguration.cpp"
     ],
     static_libs: [
-        "VtsHalHidlTargetTestBase",
         "android.hardware.audio.common.test.utility",
+        "android.hardware.audio@2.0",
+        "android.hardware.audio.common@2.0",
+        "libxml2",
     ],
-    cflags: [
-        "-O0",
-        "-g",
-        "-Wall",
-        "-Wextra",
-        "-Werror",
+    shared_libs: [
+        "libicuuc",
     ],
 }
diff --git a/audio/effect/2.0/vts/functional/Android.bp b/audio/effect/2.0/vts/functional/Android.bp
index 15f1e64..7b421cb 100644
--- a/audio/effect/2.0/vts/functional/Android.bp
+++ b/audio/effect/2.0/vts/functional/Android.bp
@@ -16,30 +16,20 @@
 
 cc_test {
     name: "VtsHalAudioEffectV2_0TargetTest",
-    defaults: ["hidl_defaults"],
-    srcs: ["VtsHalAudioEffectV2_0TargetTest.cpp",
-           "ValidateAudioEffectsConfiguration.cpp"],
-    shared_libs: [
-        "libbase",
-        "liblog",
-        "libcutils",
-        "libhidlbase",
-        "libhidltransport",
-        "libnativehelper",
-        "libutils",
-        "libxml2",
+    defaults: ["VtsHalTargetTestDefaults"],
+    srcs: [
+        "VtsHalAudioEffectV2_0TargetTest.cpp",
+        "ValidateAudioEffectsConfiguration.cpp"
+    ],
+    static_libs: [
+        "android.hardware.audio.common.test.utility",
         "android.hardware.audio.common@2.0",
         "android.hardware.audio.effect@2.0",
         "android.hidl.allocator@1.0",
         "android.hidl.memory@1.0",
+        "libxml2",
     ],
-    static_libs: [
-        "VtsHalHidlTargetTestBase",
-        "android.hardware.audio.common.test.utility",
-    ],
-    cflags: [
-        "-O0",
-        "-g",
-        "-Wextra",
+    shared_libs: [
+        "libicuuc",
     ],
 }
diff --git a/automotive/vehicle/2.1/default/service.cpp b/automotive/vehicle/2.1/default/service.cpp
index bae64fd..03a0a5d 100644
--- a/automotive/vehicle/2.1/default/service.cpp
+++ b/automotive/vehicle/2.1/default/service.cpp
@@ -88,7 +88,7 @@
 
     Vehicle_V2_1 vehicle21(vehicleManager.get());
 
-    configureRpcThreadpool(1, true /* callerWillJoin */);
+    configureRpcThreadpool(4, true /* callerWillJoin */);
 
     ALOGI("Registering as service...");
     status_t status = vehicle21.registerAsService();
diff --git a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp
index c6774ca..f687959 100644
--- a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp
+++ b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.cpp
@@ -145,6 +145,7 @@
 
 Return<uint64_t> BiometricsFingerprint::setNotify(
         const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
+    std::lock_guard<std::mutex> lock(mClientCallbackMutex);
     mClientCallback = clientCallback;
     // This is here because HAL 2.1 doesn't have a way to propagate a
     // unique token for its driver. Subsequent versions should send a unique
@@ -259,6 +260,7 @@
 void BiometricsFingerprint::notify(const fingerprint_msg_t *msg) {
     BiometricsFingerprint* thisPtr = static_cast<BiometricsFingerprint*>(
             BiometricsFingerprint::getInstance());
+    std::lock_guard<std::mutex> lock(thisPtr->mClientCallbackMutex);
     if (thisPtr == nullptr || thisPtr->mClientCallback == nullptr) {
         ALOGE("Receiving callbacks before the client callback is registered.");
         return;
diff --git a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h
index 5923c84..6d64e3d 100644
--- a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h
+++ b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h
@@ -69,6 +69,7 @@
     static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
     static BiometricsFingerprint* sInstance;
 
+    std::mutex mClientCallbackMutex;
     sp<IBiometricsFingerprintClientCallback> mClientCallback;
     fingerprint_device_t *mDevice;
 };
diff --git a/camera/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp
index 439fe3d..84d76f1 100644
--- a/camera/provider/2.4/vts/functional/Android.bp
+++ b/camera/provider/2.4/vts/functional/Android.bp
@@ -16,30 +16,27 @@
 
 cc_test {
     name: "VtsHalCameraProviderV2_4TargetTest",
-    defaults: ["hidl_defaults"],
+    defaults: ["VtsHalTargetTestDefaults"],
     srcs: ["VtsHalCameraProviderV2_4TargetTest.cpp"],
+
+    // TODO(b/64437680): Assume these are always available on the device.
     shared_libs: [
-        "liblog",
-        "libhidlbase",
-        "libhidltransport",
-        "libcutils",
-        "libutils",
-        "android.hardware.camera.provider@2.4",
-        "android.hardware.camera.device@3.2",
-        "android.hardware.camera.device@1.0",
-        "libcamera_metadata",
         "libbinder",
+        "libcamera_metadata",
+        "libfmq",
         "libgui",
         "libui",
-        "libfmq",
     ],
+
+    // Statically link to libs not guaranteed to be present on the device.
     static_libs: [
-        "VtsHalHidlTargetTestBase",
-        "libgrallocusage",
+        "android.hardware.camera.common@1.0",
         "android.hardware.camera.common@1.0-helper",
-    ],
-    cflags: [
-        "-O0",
-        "-g",
+        "android.hardware.camera.device@1.0",
+        "android.hardware.camera.device@3.2",
+        "android.hardware.camera.provider@2.4",
+        "android.hardware.graphics.common@1.0",
+        "android.hardware.graphics.mapper@2.0",
+        "libgrallocusage",
     ],
 }
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 8ff9847..e6cd3b4 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -1417,8 +1417,8 @@
     }
 }
 
-// Image capture cancel should fail when image capture is not running.
-TEST_F(CameraHidlTest, cancelPictureFail) {
+// Image capture cancel is a no-op when image capture is not running.
+TEST_F(CameraHidlTest, cancelPictureNOP) {
     hidl_vec<hidl_string> cameraDeviceNames = getCameraDeviceNames(mProvider);
 
     for (const auto& name : cameraDeviceNames) {
@@ -1433,7 +1433,7 @@
 
             Return<Status> returnStatus = device1->cancelPicture();
             ASSERT_TRUE(returnStatus.isOk());
-            ASSERT_NE(Status::OK, returnStatus);
+            ASSERT_EQ(Status::OK, returnStatus);
 
             stopPreviewAndClose(device1);
         }
diff --git a/current.txt b/current.txt
index bb5f2ac..f8cdc93 100644
--- a/current.txt
+++ b/current.txt
@@ -195,6 +195,7 @@
 e822cb7f4a1bdd45689c5e92ccd19a2201c20b771bd4b2ec1ae627e324591f9d android.hardware.radio@1.0::IRadioResponse
 6e69adb24d7c0b0ca3a54a38c49a5625b161b3f5d5f7d6fda0befdbbfc8e9e06 android.hardware.radio@1.0::IRadioResponse
 28e929b453df3d9f5060af2764e6cdb123ddb893e3e86923c877f6ff7e5f02c9 android.hardware.wifi@1.0::types
+df1d7b27e644bfed0a4f606a8c44d35d45cafce82c7c648494c8a25c7cd4a949 android.hardware.wifi@1.0::types
 
 # HALs released in Android O MR1
 
diff --git a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
index 5564513..3966eac 100644
--- a/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_clearkey_test.cpp
@@ -76,9 +76,12 @@
 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
 #define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
 
-static const uint8_t kClearKeyUUID[16] = {
-    0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02,
-    0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B};
+static const uint8_t kCommonPsshBoxUUID[16] = {0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02,
+                                               0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B};
+
+// To be used in mpd to specify drm scheme for players
+static const uint8_t kClearKeyUUID[16] = {0xE2, 0x71, 0x9D, 0x58, 0xA9, 0x85, 0xB3, 0xC9,
+                                          0x78, 0x1A, 0xB0, 0x30, 0xAF, 0x78, 0xD3, 0x0E};
 
 static const uint8_t kInvalidUUID[16] = {
     0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
@@ -111,6 +114,9 @@
  * Ensure the factory supports the clearkey scheme UUID
  */
 TEST_F(DrmHalClearkeyFactoryTest, ClearKeyPluginSupported) {
+    EXPECT_TRUE(drmFactory->isCryptoSchemeSupported(kCommonPsshBoxUUID));
+    EXPECT_TRUE(cryptoFactory->isCryptoSchemeSupported(kCommonPsshBoxUUID));
+
     EXPECT_TRUE(drmFactory->isCryptoSchemeSupported(kClearKeyUUID));
     EXPECT_TRUE(cryptoFactory->isCryptoSchemeSupported(kClearKeyUUID));
 }
diff --git a/drm/1.0/vts/functional/drm_hal_vendor_test.cpp b/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
index 61f3014..47c6950 100644
--- a/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
+++ b/drm/1.0/vts/functional/drm_hal_vendor_test.cpp
@@ -1595,9 +1595,8 @@
 #endif
     gVendorModules = new drm_vts::VendorModules(kModulePath);
     if (gVendorModules->getPathList().size() == 0) {
-        std::cerr << "No vendor modules found in " << kModulePath <<
-                ", exiting" << std::endl;
-        exit(-1);
+        std::cerr << "WARNING: No vendor modules found in " << kModulePath <<
+                ", all vendor tests will be skipped" << std::endl;
     }
     ::testing::InitGoogleTest(&argc, argv);
     return RUN_ALL_TESTS();
diff --git a/neuralnetworks/1.0/types.hal b/neuralnetworks/1.0/types.hal
index ccc17f1..0adebb8 100644
--- a/neuralnetworks/1.0/types.hal
+++ b/neuralnetworks/1.0/types.hal
@@ -32,7 +32,7 @@
     UINT32                    = 7,
     TENSOR_FLOAT16            = 8,
     TENSOR_FLOAT32            = 9,
-    TENSOR_SYMMETRICAL_QUANT8 = 10,
+    TENSOR_QUANT8_ASYMM       = 10,
 };
 
 // The type of operations.  Unlike the operation types found in
@@ -41,39 +41,39 @@
 // TODO: Currently they are the same.  Add a conversion when finalizing the model.
 // When modifying, be sure to update HAL_NUM_OPERATION_TYPES in HalIntefaces.h.
 enum OperationType : uint32_t {
-    AVERAGE_POOL_FLOAT32                 = 0,
-    CONCATENATION_FLOAT32                = 1,
-    CONV_FLOAT32                         = 2,
-    DEPTHWISE_CONV_FLOAT32               = 3,
-    MAX_POOL_FLOAT32                     = 4,
-    L2_POOL_FLOAT32                      = 5,
-    DEPTH_TO_SPACE_FLOAT32               = 6,
-    SPACE_TO_DEPTH_FLOAT32               = 7,
-    LOCAL_RESPONSE_NORMALIZATION_FLOAT32 = 8,
-    SOFTMAX_FLOAT32                      = 9,
-    RESHAPE_FLOAT32                      = 10,
-    SPLIT_FLOAT32                        = 11,
-    FAKE_QUANT_FLOAT32                   = 12,
-    ADD_FLOAT32                          = 13,
-    FULLY_CONNECTED_FLOAT32              = 14,
-    CAST_FLOAT32                         = 15,
-    MUL_FLOAT32                          = 16,
-    L2_NORMALIZATION_FLOAT32             = 17,
-    LOGISTIC_FLOAT32                     = 18,
-    RELU_FLOAT32                         = 19,
-    RELU6_FLOAT32                        = 20,
-    RELU1_FLOAT32                        = 21,
-    TANH_FLOAT32                         = 22,
-    DEQUANTIZE_FLOAT32                   = 23,
-    FLOOR_FLOAT32                        = 24,
-    GATHER_FLOAT32                       = 25,
-    RESIZE_BILINEAR_FLOAT32              = 26,
-    LSH_PROJECTION_FLOAT32               = 27,
-    LSTM_FLOAT32                         = 28,
-    SVDF_FLOAT32                         = 29,
-    RNN_FLOAT32                          = 30,
-    N_GRAM_FLOAT32                       = 31,
-    LOOKUP_FLOAT32                       = 32,
+    AVERAGE_POOL                 = 0,
+    CONCATENATION                = 1,
+    CONV                         = 2,
+    DEPTHWISE_CONV               = 3,
+    MAX_POOL                     = 4,
+    L2_POOL                      = 5,
+    DEPTH_TO_SPACE               = 6,
+    SPACE_TO_DEPTH               = 7,
+    LOCAL_RESPONSE_NORMALIZATION = 8,
+    SOFTMAX                      = 9,
+    RESHAPE                      = 10,
+    SPLIT                        = 11,
+    FAKE_QUANT                   = 12,
+    ADD                          = 13,
+    FULLY_CONNECTED              = 14,
+    CAST                         = 15,
+    MUL                          = 16,
+    L2_NORMALIZATION             = 17,
+    LOGISTIC                     = 18,
+    RELU                         = 19,
+    RELU6                        = 20,
+    RELU1                        = 21,
+    TANH                         = 22,
+    DEQUANTIZE                   = 23,
+    FLOOR                        = 24,
+    GATHER                       = 25,
+    RESIZE_BILINEAR              = 26,
+    LSH_PROJECTION               = 27,
+    LSTM                         = 28,
+    SVDF                         = 29,
+    RNN                          = 30,
+    N_GRAM                       = 31,
+    LOOKUP                       = 32,
 };
 
 // Two special values that can be used instead of a regular poolIndex.
@@ -102,9 +102,16 @@
     float powerUsage;  // in picoJoules
 };
 
+struct OperationTuple {
+    // The type of operation.
+    OperationType operationType;
+    // The input data type of operation.
+    OperandType operandType;
+};
+
 // The capabilities of a driver.
 struct Capabilities {
-    vec<OperationType> supportedOperationTypes;
+    vec<OperationTuple> supportedOperationTuples;
     // TODO Do the same for baseline model IDs
     bool cachesCompilation;
     // TODO revisit the data types and scales.
@@ -142,8 +149,8 @@
 
 // Describes one operation of the graph.
 struct Operation {
-    // The type of operation.
-    OperationType type;
+    // The tuple describing the operation type and input type.
+    OperationTuple opTuple;
     // Describes the table that contains the indexes of the inputs of the
     // operation. The offset is the index in the operandIndexes table.
     vec<uint32_t> inputs;
diff --git a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
index 9fa694d..5e6b1bd 100644
--- a/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
+++ b/neuralnetworks/1.0/vts/functional/VtsHalNeuralnetworksV1_0TargetTest.cpp
@@ -66,8 +66,8 @@
 // initialization
 TEST_F(NeuralnetworksHidlTest, InitializeTest) {
     Return<void> ret = device->initialize([](const Capabilities& capabilities) {
-        EXPECT_NE(nullptr, capabilities.supportedOperationTypes.data());
-        EXPECT_NE(0ull, capabilities.supportedOperationTypes.size());
+        EXPECT_NE(nullptr, capabilities.supportedOperationTuples.data());
+        EXPECT_NE(0ull, capabilities.supportedOperationTuples.size());
         EXPECT_EQ(0u, static_cast<uint32_t>(capabilities.cachesCompilation) & ~0x1);
         EXPECT_LT(0.0f, capabilities.bootupTime);
         EXPECT_LT(0.0f, capabilities.float16Performance.execTime);
@@ -92,7 +92,7 @@
 
     const std::vector<Operand> operands = {
         {
-            .type = OperandType::FLOAT32,
+            .type = OperandType::TENSOR_FLOAT32,
             .dimensions = {1, 2, 2, 1},
             .numberOfConsumers = 1,
             .scale = 0.0f,
@@ -102,7 +102,7 @@
                          .length = 0},
         },
         {
-            .type = OperandType::FLOAT32,
+            .type = OperandType::TENSOR_FLOAT32,
             .dimensions = {1, 2, 2, 1},
             .numberOfConsumers = 1,
             .scale = 0.0f,
@@ -112,7 +112,7 @@
                          .length = size},
         },
         {
-            .type = OperandType::FLOAT32,
+            .type = OperandType::TENSOR_FLOAT32,
             .dimensions = {1, 2, 2, 1},
             .numberOfConsumers = 0,
             .scale = 0.0f,
@@ -124,7 +124,9 @@
     };
 
     const std::vector<Operation> operations = {{
-        .type = OperationType::ADD_FLOAT32, .inputs = {operand1, operand2}, .outputs = {operand3},
+        .opTuple = {OperationType::ADD, OperandType::TENSOR_FLOAT32},
+        .inputs = {operand1, operand2},
+        .outputs = {operand3},
     }};
 
     const std::vector<uint32_t> inputIndexes = {operand1};
diff --git a/renderscript/1.0/default/Device.cpp b/renderscript/1.0/default/Device.cpp
index 3aae060..4831a8b 100644
--- a/renderscript/1.0/default/Device.cpp
+++ b/renderscript/1.0/default/Device.cpp
@@ -1,6 +1,9 @@
 #include "Context.h"
 #include "Device.h"
 
+#include <android/dlext.h>
+#include <dlfcn.h>
+
 namespace android {
 namespace hardware {
 namespace renderscript {
@@ -39,7 +42,25 @@
     static_assert(sizeof(size_t) <= sizeof(uint64_t), "RenderScript HIDL Error: sizeof(size_t) > sizeof(uint64_t)");
 
     const char* filename = "libRS_internal.so";
-    void* handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+    // Try to load libRS_internal.so from the "rs" namespace directly.
+    typedef struct android_namespace_t* (*GetExportedNamespaceFnPtr)(const char*);
+    GetExportedNamespaceFnPtr getExportedNamespace =
+        (GetExportedNamespaceFnPtr)dlsym(RTLD_DEFAULT, "android_get_exported_namespace");
+    void* handle = nullptr;
+    if (getExportedNamespace != nullptr) {
+        android_namespace_t* rs_namespace = getExportedNamespace("rs");
+        if (rs_namespace != nullptr) {
+            const android_dlextinfo dlextinfo = {
+                .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = rs_namespace,
+            };
+            handle = android_dlopen_ext(filename, RTLD_LAZY | RTLD_LOCAL, &dlextinfo);
+        }
+    }
+    if (handle == nullptr) {
+        // if there is no "rs" namespace (in case when this HAL impl is loaded
+        // into a vendor process), then use the plain dlopen.
+        handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+    }
 
     dispatchTable dispatchHal = {
         .SetNativeLibDir = (SetNativeLibDirFnPtr) nullptr,
diff --git a/wifi/1.0/types.hal b/wifi/1.0/types.hal
index 1b5f8f7..b9fb0bd 100644
--- a/wifi/1.0/types.hal
+++ b/wifi/1.0/types.hal
@@ -1355,8 +1355,8 @@
    */
   uint32_t maxNdiInterfaces;
   /**
-   * Maximum number of data paths (NDP) which can be created concurrently on each individual
-   * data interface (NDI).
+   * Maximum number of data paths (NDP) which can be created concurrently on the device, across all
+   * data interfaces (NDI).
    */
   uint32_t maxNdpSessions;
   /**
diff --git a/wifi/1.1/default/wifi_legacy_hal.cpp b/wifi/1.1/default/wifi_legacy_hal.cpp
index 7d683d3..151a600 100644
--- a/wifi/1.1/default/wifi_legacy_hal.cpp
+++ b/wifi/1.1/default/wifi_legacy_hal.cpp
@@ -1284,7 +1284,7 @@
     for (int i = 0; i < num_scan_results; i++) {
       auto& scan_result = cached_scan_result.results[i];
       if (scan_result.ie_length > 0) {
-        LOG(ERROR) << "Cached scan result has non-zero IE length "
+        LOG(DEBUG) << "Cached scan result has non-zero IE length "
                    << scan_result.ie_length;
         scan_result.ie_length = 0;
       }