Merge "Move CameraParameters class to android.hardware.camera.common@1.0-helper" into oc-dr1-dev
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index bb66460..a291e14 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -282,6 +282,8 @@
 
     int power_state = BT_VND_PWR_OFF;
     lib_interface_->op(BT_VND_OP_POWER_CTRL, &power_state);
+
+    lib_interface_->cleanup();
   }
 
   if (lib_handle_ != nullptr) {
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index 94b79db..49281f5 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -1679,7 +1679,8 @@
                     ASSERT_EQ(Status::OK, status);
                     const camera_metadata_t* metadata = (camera_metadata_t*) chars.data();
                     size_t expectedSize = chars.size();
-                    ASSERT_EQ(0, validate_camera_metadata_structure(metadata, &expectedSize));
+                    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);
                     // TODO: we can do better than 0 here. Need to check how many required
                     // characteristics keys we've defined.
@@ -1996,8 +1997,9 @@
                             const camera_metadata_t* metadata =
                                 (camera_metadata_t*) req.data();
                             size_t expectedSize = req.size();
-                            ASSERT_EQ(0, validate_camera_metadata_structure(
-                                    metadata, &expectedSize));
+                            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);
                             // TODO: we can do better than 0 here. Need to check how many required
                             // request keys we've defined for each template
diff --git a/drm/1.0/Android.bp b/drm/1.0/Android.bp
index 7829de7..731f58f 100644
--- a/drm/1.0/Android.bp
+++ b/drm/1.0/Android.bp
@@ -89,3 +89,5 @@
         "libutils",
     ],
 }
+
+subdirs = ["default"]
diff --git a/drm/1.0/default/Android.bp b/drm/1.0/default/Android.bp
new file mode 100644
index 0000000..6b1db56
--- /dev/null
+++ b/drm/1.0/default/Android.bp
@@ -0,0 +1,23 @@
+cc_library_static {
+    name: "android.hardware.drm@1.0-helper",
+    vendor: true,
+    defaults: ["hidl_defaults"],
+    srcs: [
+        "SharedLibrary.cpp",
+    ],
+    cflags: [
+        "-Werror",
+        "-Wextra",
+        "-Wall",
+    ],
+    shared_libs: [
+        "liblog",
+    ],
+    header_libs: [
+        "libutils_headers",
+    ],
+    export_header_lib_headers: [
+        "libutils_headers",
+    ],
+    export_include_dirs : ["include"]
+}
diff --git a/drm/1.0/default/Android.mk b/drm/1.0/default/Android.mk
index 4c05da8..7916fba 100644
--- a/drm/1.0/default/Android.mk
+++ b/drm/1.0/default/Android.mk
@@ -36,6 +36,9 @@
   libutils \
   libbinder \
 
+LOCAL_STATIC_LIBRARIES := \
+  android.hardware.drm@1.0-helper \
+
 LOCAL_C_INCLUDES := \
   hardware/interfaces/drm
 
@@ -71,10 +74,12 @@
     libhidlmemory \
     libhidltransport \
     liblog \
-    libmediadrm \
-    libstagefright_foundation \
+    libstagefright_foundation_vendor \
     libutils \
 
+LOCAL_STATIC_LIBRARIES := \
+    android.hardware.drm@1.0-helper \
+
 LOCAL_C_INCLUDES := \
     frameworks/native/include \
     frameworks/av/include
diff --git a/drm/1.0/default/CryptoFactory.h b/drm/1.0/default/CryptoFactory.h
index 412b557..6b1d1ff 100644
--- a/drm/1.0/default/CryptoFactory.h
+++ b/drm/1.0/default/CryptoFactory.h
@@ -19,7 +19,7 @@
 #include <android/hardware/drm/1.0/ICryptoFactory.h>
 #include <hidl/Status.h>
 #include <media/hardware/CryptoAPI.h>
-#include <media/PluginLoader.h>
+#include <PluginLoader.h>
 #include <media/SharedLibrary.h>
 
 namespace android {
@@ -28,6 +28,7 @@
 namespace V1_0 {
 namespace implementation {
 
+using ::android::hardware::drm::V1_0::helper::PluginLoader;
 using ::android::hardware::drm::V1_0::ICryptoFactory;
 using ::android::hardware::drm::V1_0::ICryptoPlugin;
 using ::android::hardware::hidl_array;
@@ -51,7 +52,7 @@
             override;
 
 private:
-    android::PluginLoader<android::CryptoFactory> loader;
+    PluginLoader<android::CryptoFactory> loader;
 
     CryptoFactory(const CryptoFactory &) = delete;
     void operator=(const CryptoFactory &) = delete;
diff --git a/drm/1.0/default/DrmFactory.h b/drm/1.0/default/DrmFactory.h
index a008844..726bf97 100644
--- a/drm/1.0/default/DrmFactory.h
+++ b/drm/1.0/default/DrmFactory.h
@@ -19,7 +19,7 @@
 #include <android/hardware/drm/1.0/IDrmFactory.h>
 #include <hidl/Status.h>
 #include <media/drm/DrmAPI.h>
-#include <media/PluginLoader.h>
+#include <PluginLoader.h>
 #include <media/SharedLibrary.h>
 
 namespace android {
@@ -28,6 +28,7 @@
 namespace V1_0 {
 namespace implementation {
 
+using ::android::hardware::drm::V1_0::helper::PluginLoader;
 using ::android::hardware::drm::V1_0::IDrmFactory;
 using ::android::hardware::drm::V1_0::IDrmPlugin;
 using ::android::hardware::hidl_array;
@@ -53,7 +54,7 @@
             const hidl_string& appPackageName, createPlugin_cb _hidl_cb) override;
 
 private:
-    android::PluginLoader<android::DrmFactory> loader;
+    PluginLoader<android::DrmFactory> loader;
 
     DrmFactory(const DrmFactory &) = delete;
     void operator=(const DrmFactory &) = delete;
diff --git a/drm/1.0/vts/functional/shared_library.cpp b/drm/1.0/default/SharedLibrary.cpp
similarity index 82%
rename from drm/1.0/vts/functional/shared_library.cpp
rename to drm/1.0/default/SharedLibrary.cpp
index 6658150..0a942cd 100644
--- a/drm/1.0/vts/functional/shared_library.cpp
+++ b/drm/1.0/default/SharedLibrary.cpp
@@ -14,17 +14,19 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "drm-vts-shared-library"
+
+#include "SharedLibrary.h"
 
 #include <dlfcn.h>
-#include <shared_library.h>
 
-using std::string;
+namespace android {
+namespace hardware {
+namespace drm {
+namespace V1_0 {
+namespace helper {
 
-namespace drm_vts {
-
-SharedLibrary::SharedLibrary(const string& path) {
-    mLibHandle = dlopen(path.c_str(), RTLD_NOW);
+SharedLibrary::SharedLibrary(const String8& path) {
+    mLibHandle = dlopen(path.string(), RTLD_NOW);
 }
 
 SharedLibrary::~SharedLibrary() {
@@ -53,4 +55,9 @@
     const char* error = dlerror();
     return error ? error : "No errors or unknown error";
 }
-};
+
+}
+}
+}
+}
+} // namespace android
diff --git a/drm/1.0/default/include/PluginLoader.h b/drm/1.0/default/include/PluginLoader.h
new file mode 100644
index 0000000..f387b3c
--- /dev/null
+++ b/drm/1.0/default/include/PluginLoader.h
@@ -0,0 +1,107 @@
+/**
+ * Copyright (C) 2016 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 PLUGIN_LOADER_H_
+#define PLUGIN_LOADER_H_
+
+#include "SharedLibrary.h"
+#include <utils/Log.h>
+#include <utils/String8.h>
+#include <utils/Vector.h>
+
+namespace android {
+namespace hardware {
+namespace drm {
+namespace V1_0 {
+namespace helper {
+
+template <class T>
+class PluginLoader {
+
+  public:
+    PluginLoader(const char *dir, const char *entry) {
+        /**
+         * scan all plugins in the plugin directory and add them to the
+         * factories list.
+         */
+        String8 pluginDir(dir);
+
+        DIR* pDir = opendir(pluginDir.string());
+        if (pDir == NULL) {
+            ALOGE("Failed to find plugin directory %s", pluginDir.string());
+        } else {
+            struct dirent* pEntry;
+            while ((pEntry = readdir(pDir))) {
+                String8 file(pEntry->d_name);
+                if (file.getPathExtension() == ".so") {
+                    String8 path = pluginDir + "/" + pEntry->d_name;
+                    T *plugin = loadOne(path, entry);
+                    if (plugin) {
+                        factories.push(plugin);
+                    }
+                }
+            }
+            closedir(pDir);
+        }
+    }
+
+    ~PluginLoader() {
+        for (size_t i = 0; i < factories.size(); i++) {
+            delete factories[i];
+        }
+    }
+
+    T *getFactory(size_t i) const {
+        return factories[i];
+    }
+
+    size_t factoryCount() const {return factories.size();}
+
+  private:
+    T* loadOne(const char *path, const char *entry) {
+        sp<SharedLibrary> library = new SharedLibrary(String8(path));
+        if (!library.get()) {
+            ALOGE("Failed to open plugin library %s: %s", path,
+                    library->lastError());
+        } else {
+            typedef T *(*CreateFactoryFunc)();
+            CreateFactoryFunc createFactoryFunc =
+                    (CreateFactoryFunc)library->lookup(entry);
+            if (createFactoryFunc) {
+                ALOGV("Found plugin factory entry %s in %s", entry, path);
+                libraries.push(library);
+                T* result = createFactoryFunc();
+                return  result;
+           }
+        }
+        return NULL;
+    }
+
+    Vector<T *> factories;
+    Vector<sp<SharedLibrary> > libraries;
+
+    PluginLoader(const PluginLoader &) = delete;
+    void operator=(const PluginLoader &) = delete;
+};
+
+}
+}
+}
+}
+} // namespace android
+
+#endif // PLUGIN_LOADER_H_
+
diff --git a/drm/1.0/vts/functional/shared_library.h b/drm/1.0/default/include/SharedLibrary.h
similarity index 79%
rename from drm/1.0/vts/functional/shared_library.h
rename to drm/1.0/default/include/SharedLibrary.h
index 1f32243..8e174d0 100644
--- a/drm/1.0/vts/functional/shared_library.h
+++ b/drm/1.0/default/include/SharedLibrary.h
@@ -17,13 +17,18 @@
 #ifndef SHARED_LIBRARY_H_
 #define SHARED_LIBRARY_H_
 
-#include <string>
-#include <vector>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
 
-namespace drm_vts {
-class SharedLibrary {
+namespace android {
+namespace hardware {
+namespace drm {
+namespace V1_0 {
+namespace helper {
+
+class SharedLibrary : public RefBase {
    public:
-    explicit SharedLibrary(const std::string& path);
+    explicit SharedLibrary(const String8& path);
     ~SharedLibrary();
 
     bool operator!() const;
@@ -36,6 +41,11 @@
     SharedLibrary(const SharedLibrary&) = delete;
     void operator=(const SharedLibrary&) = delete;
 };
-};
+
+}
+}
+}
+}
+}
 
 #endif  // SHARED_LIBRARY_H_
diff --git a/drm/1.0/vts/functional/Android.bp b/drm/1.0/vts/functional/Android.bp
index 43ea372..b45ce84 100644
--- a/drm/1.0/vts/functional/Android.bp
+++ b/drm/1.0/vts/functional/Android.bp
@@ -19,7 +19,6 @@
     srcs: [
         "drm_hal_clearkey_test.cpp",
         "drm_hal_vendor_test.cpp",
-        "shared_library.cpp",
         "vendor_modules.cpp"
         ],
     shared_libs: [
@@ -39,7 +38,8 @@
         "libutils",
     ],
     static_libs: [
-        "VtsHalHidlTargetTestBase"
+        "VtsHalHidlTargetTestBase",
+        "android.hardware.drm@1.0-helper",
     ],
     cflags: [
         "-O0",
diff --git a/drm/1.0/vts/functional/vendor_modules.cpp b/drm/1.0/vts/functional/vendor_modules.cpp
index 2bf0b28..98430f5 100644
--- a/drm/1.0/vts/functional/vendor_modules.cpp
+++ b/drm/1.0/vts/functional/vendor_modules.cpp
@@ -20,13 +20,16 @@
 #include <dlfcn.h>
 #include <log/log.h>
 #include <memory>
+#include <utils/String8.h>
+#include <SharedLibrary.h>
 
-#include "shared_library.h"
 #include "vendor_modules.h"
 
 using std::string;
 using std::vector;
 using std::unique_ptr;
+using ::android::String8;
+using ::android::hardware::drm::V1_0::helper::SharedLibrary;
 
 namespace drm_vts {
 void VendorModules::scanModules(const std::string &directory) {
@@ -48,7 +51,7 @@
 
 DrmHalVTSVendorModule* VendorModules::getModule(const string& path) {
     if (mOpenLibraries.find(path) == mOpenLibraries.end()) {
-        auto library = std::make_unique<SharedLibrary>(path);
+        auto library = std::make_unique<SharedLibrary>(String8(path.c_str()));
         if (!library) {
             ALOGE("failed to map shared library %s", path.c_str());
             return NULL;
diff --git a/drm/1.0/vts/functional/vendor_modules.h b/drm/1.0/vts/functional/vendor_modules.h
index ca538f6..8330b0a 100644
--- a/drm/1.0/vts/functional/vendor_modules.h
+++ b/drm/1.0/vts/functional/vendor_modules.h
@@ -18,8 +18,12 @@
 #define VENDOR_MODULES_H
 
 #include <map>
+#include <vector>
+#include <string>
 
-#include "shared_library.h"
+#include <SharedLibrary.h>
+
+using ::android::hardware::drm::V1_0::helper::SharedLibrary;
 
 class DrmHalVTSVendorModule;
 
diff --git a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
index fde3171..91e75fe 100644
--- a/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
+++ b/gnss/1.0/vts/functional/VtsHalGnssV1_0TargetTest.cpp
@@ -39,7 +39,7 @@
 
 // for command line argument on how strictly to run the test
 bool sAgpsIsPresent = false;  // if SUPL or XTRA assistance available
-bool sSignalIsWeak = false;  // if GNSS signals are weak (e.g. light indoor)
+bool sSignalIsWeak = false;   // if GNSS signals are weak (e.g. light indoor)
 
 // The main test class for GNSS HAL.
 class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
@@ -49,6 +49,7 @@
     capabilities_called_count_ = 0;
     location_called_count_ = 0;
     info_called_count_ = 0;
+    notify_count_ = 0;
 
     gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>();
     ASSERT_NE(gnss_hal_, nullptr);
@@ -93,12 +94,15 @@
     if (gnss_hal_ != nullptr) {
       gnss_hal_->cleanup();
     }
+    if (notify_count_ > 0) {
+        ALOGW("%d unprocessed callbacks discarded", notify_count_);
+    }
   }
 
   /* Used as a mechanism to inform the test that a callback has occurred */
   inline void notify() {
     std::unique_lock<std::mutex> lock(mtx_);
-    count++;
+    notify_count_++;
     cv_.notify_one();
   }
 
@@ -108,14 +112,132 @@
 
     std::cv_status status = std::cv_status::no_timeout;
     auto now = std::chrono::system_clock::now();
-    while (count == 0) {
-      status = cv_.wait_until(lock, now + std::chrono::seconds(timeoutSeconds));
-      if (status == std::cv_status::timeout) return status;
+    while (notify_count_ == 0) {
+        status = cv_.wait_until(lock, now + std::chrono::seconds(timeoutSeconds));
+        if (status == std::cv_status::timeout) return status;
     }
-    count--;
+    notify_count_--;
     return status;
   }
 
+  /*
+   * StartAndGetSingleLocation:
+   * Helper function to get one Location and check fields
+   *
+   * returns  true if a location was successfully generated
+   */
+  bool StartAndGetSingleLocation(bool checkAccuracies) {
+      auto result = gnss_hal_->start();
+
+      EXPECT_TRUE(result.isOk());
+      EXPECT_TRUE(result);
+
+      /*
+       * GPS signals initially optional for this test, so don't expect fast fix,
+       * or no timeout, unless signal is present
+       */
+      int firstGnssLocationTimeoutSeconds = sAgpsIsPresent ? 15 : 45;
+      if (sSignalIsWeak) {
+          // allow more time for weak signals
+          firstGnssLocationTimeoutSeconds += 30;
+      }
+
+      wait(firstGnssLocationTimeoutSeconds);
+      if (sAgpsIsPresent) {
+          EXPECT_EQ(location_called_count_, 1);
+      }
+      if (location_called_count_ > 0) {
+          CheckLocation(last_location_, checkAccuracies);
+          return true;
+      }
+      return false;
+  }
+
+  /*
+   * StopAndClearLocations:
+   * Helper function to stop locations
+   *
+   * returns  true if a location was successfully generated
+   */
+  void StopAndClearLocations() {
+      auto result = gnss_hal_->stop();
+
+      EXPECT_TRUE(result.isOk());
+      EXPECT_TRUE(result);
+
+      /*
+       * Clear notify/waiting counter, allowing up till the timeout after
+       * the last reply for final startup messages to arrive (esp. system
+       * info.)
+       */
+      while (wait(TIMEOUT_SEC) == std::cv_status::no_timeout) {
+      }
+  }
+
+  /*
+   * CheckLocation:
+   * Helper function to vet Location fields
+   */
+  void CheckLocation(GnssLocation& location, bool checkAccuracies) {
+      EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG);
+      EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE);
+      EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED);
+      EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY);
+      // New uncertainties available in O must be provided,
+      // at least when paired with modern hardware (2017+)
+      if (checkAccuracies) {
+          EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY);
+          EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY);
+          if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
+              EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY);
+          }
+      }
+      EXPECT_GE(location.latitudeDegrees, -90.0);
+      EXPECT_LE(location.latitudeDegrees, 90.0);
+      EXPECT_GE(location.longitudeDegrees, -180.0);
+      EXPECT_LE(location.longitudeDegrees, 180.0);
+      EXPECT_GE(location.altitudeMeters, -1000.0);
+      EXPECT_LE(location.altitudeMeters, 30000.0);
+      EXPECT_GE(location.speedMetersPerSec, 0.0);
+      EXPECT_LE(location.speedMetersPerSec, 5.0);  // VTS tests are stationary.
+
+      // Non-zero speeds must be reported with an associated bearing
+      if (location.speedMetersPerSec > 0.0) {
+          EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING);
+      }
+
+      /*
+       * Tolerating some especially high values for accuracy estimate, in case of
+       * first fix with especially poor geometry (happens occasionally)
+       */
+      EXPECT_GT(location.horizontalAccuracyMeters, 0.0);
+      EXPECT_LE(location.horizontalAccuracyMeters, 250.0);
+
+      /*
+       * Some devices may define bearing as -180 to +180, others as 0 to 360.
+       * Both are okay & understandable.
+       */
+      if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
+          EXPECT_GE(location.bearingDegrees, -180.0);
+          EXPECT_LE(location.bearingDegrees, 360.0);
+      }
+      if (location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
+          EXPECT_GT(location.verticalAccuracyMeters, 0.0);
+          EXPECT_LE(location.verticalAccuracyMeters, 500.0);
+      }
+      if (location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
+          EXPECT_GT(location.speedAccuracyMetersPerSecond, 0.0);
+          EXPECT_LE(location.speedAccuracyMetersPerSecond, 50.0);
+      }
+      if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
+          EXPECT_GT(location.bearingAccuracyDegrees, 0.0);
+          EXPECT_LE(location.bearingAccuracyDegrees, 360.0);
+      }
+
+      // Check timestamp > 1.48e12 (47 years in msec - 1970->2017+)
+      EXPECT_GT(location.timestamp, 1.48e12);
+  }
+
   /* Callback class for data & Event. */
   class GnssCallback : public IGnssCallback {
    public:
@@ -188,7 +310,7 @@
  private:
   std::mutex mtx_;
   std::condition_variable cv_;
-  int count;
+  int notify_count_;
 };
 
 /*
@@ -201,107 +323,6 @@
 TEST_F(GnssHalTest, SetCallbackCapabilitiesCleanup) {}
 
 /*
- * CheckLocation:
- * Helper function to vet Location fields
- */
-void CheckLocation(GnssLocation& location, bool checkAccuracies) {
-  EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG);
-  EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE);
-  EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED);
-  EXPECT_TRUE(location.gnssLocationFlags &
-              GnssLocationFlags::HAS_HORIZONTAL_ACCURACY);
-  // New uncertainties available in O must be provided,
-  // at least when paired with modern hardware (2017+)
-  if (checkAccuracies) {
-    EXPECT_TRUE(location.gnssLocationFlags &
-                GnssLocationFlags::HAS_VERTICAL_ACCURACY);
-    EXPECT_TRUE(location.gnssLocationFlags &
-                GnssLocationFlags::HAS_SPEED_ACCURACY);
-    if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
-      EXPECT_TRUE(location.gnssLocationFlags &
-                  GnssLocationFlags::HAS_BEARING_ACCURACY);
-    }
-  }
-  EXPECT_GE(location.latitudeDegrees, -90.0);
-  EXPECT_LE(location.latitudeDegrees, 90.0);
-  EXPECT_GE(location.longitudeDegrees, -180.0);
-  EXPECT_LE(location.longitudeDegrees, 180.0);
-  EXPECT_GE(location.altitudeMeters, -1000.0);
-  EXPECT_LE(location.altitudeMeters, 30000.0);
-  EXPECT_GE(location.speedMetersPerSec, 0.0);
-  EXPECT_LE(location.speedMetersPerSec, 5.0);  // VTS tests are stationary.
-
-  // Non-zero speeds must be reported with an associated bearing
-  if (location.speedMetersPerSec > 0.0) {
-    EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING);
-  }
-
-  /*
-   * Tolerating some especially high values for accuracy estimate, in case of
-   * first fix with especially poor geometry (happens occasionally)
-   */
-  EXPECT_GT(location.horizontalAccuracyMeters, 0.0);
-  EXPECT_LE(location.horizontalAccuracyMeters, 250.0);
-
-  /*
-   * Some devices may define bearing as -180 to +180, others as 0 to 360.
-   * Both are okay & understandable.
-   */
-  if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
-    EXPECT_GE(location.bearingDegrees, -180.0);
-    EXPECT_LE(location.bearingDegrees, 360.0);
-  }
-  if (location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
-    EXPECT_GT(location.verticalAccuracyMeters, 0.0);
-    EXPECT_LE(location.verticalAccuracyMeters, 500.0);
-  }
-  if (location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
-    EXPECT_GT(location.speedAccuracyMetersPerSecond, 0.0);
-    EXPECT_LE(location.speedAccuracyMetersPerSecond, 50.0);
-  }
-  if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
-    EXPECT_GT(location.bearingAccuracyDegrees, 0.0);
-    EXPECT_LE(location.bearingAccuracyDegrees, 360.0);
-  }
-
-  // Check timestamp > 1.48e12 (47 years in msec - 1970->2017+)
-  EXPECT_GT(location.timestamp, 1.48e12);
-}
-
-/*
- * StartAndGetSingleLocation:
- * Helper function to get one Location and check fields
- *
- * returns  true if a location was successfully generated
- */
-bool StartAndGetSingleLocation(GnssHalTest* test, bool checkAccuracies) {
-  auto result = test->gnss_hal_->start();
-
-  EXPECT_TRUE(result.isOk());
-  EXPECT_TRUE(result);
-
-  /*
-   * GPS signals initially optional for this test, so don't expect fast fix,
-   * or no timeout, unless signal is present
-   */
-  int firstGnssLocationTimeoutSeconds = sAgpsIsPresent ? 15 : 45;
-  if (sSignalIsWeak) {
-    // allow more time for weak signals
-    firstGnssLocationTimeoutSeconds += 30;
-  }
-
-  test->wait(firstGnssLocationTimeoutSeconds);
-  if (sAgpsIsPresent) {
-    EXPECT_EQ(test->location_called_count_, 1);
-  }
-  if (test->location_called_count_ > 0) {
-    CheckLocation(test->last_location_, checkAccuracies);
-    return true;
-  }
-  return false;
-}
-
-/*
  * GetLocation:
  * Turns on location, waits 45 second for at least 5 locations,
  * and checks them for reasonable validity.
@@ -329,21 +350,17 @@
    * GPS signals initially optional for this test, so don't expect no timeout
    * yet
    */
-  bool gotLocation = StartAndGetSingleLocation(this, checkMoreAccuracies);
+  bool gotLocation = StartAndGetSingleLocation(checkMoreAccuracies);
 
   if (gotLocation) {
     for (int i = 1; i < LOCATIONS_TO_CHECK; i++) {
-      EXPECT_EQ(std::cv_status::no_timeout,
-          wait(LOCATION_TIMEOUT_SUBSEQUENT_SEC));
-      EXPECT_EQ(location_called_count_, i + 1);
-      CheckLocation(last_location_, checkMoreAccuracies);
+        EXPECT_EQ(std::cv_status::no_timeout, wait(LOCATION_TIMEOUT_SUBSEQUENT_SEC));
+        EXPECT_EQ(location_called_count_, i + 1);
+        CheckLocation(last_location_, checkMoreAccuracies);
     }
   }
 
-  result = gnss_hal_->stop();
-
-  ASSERT_TRUE(result.isOk());
-  ASSERT_TRUE(result);
+  StopAndClearLocations();
 }
 
 /*
@@ -368,7 +385,9 @@
   ASSERT_TRUE(resultVoid.isOk());
 
   // Ensure we can get a good location after a bad injection has been deleted
-  StartAndGetSingleLocation(this, false);
+  StartAndGetSingleLocation(false);
+
+  StopAndClearLocations();
 }
 
 /*
@@ -437,13 +456,13 @@
    * 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();
   ALOGI("Test result = %d", status);
   return status;
-}
\ No newline at end of file
+}
diff --git a/graphics/allocator/2.0/default/Gralloc1Allocator.cpp b/graphics/allocator/2.0/default/Gralloc1Allocator.cpp
index c0a5e1e..6cbb791 100644
--- a/graphics/allocator/2.0/default/Gralloc1Allocator.cpp
+++ b/graphics/allocator/2.0/default/Gralloc1Allocator.cpp
@@ -200,8 +200,8 @@
     // should be filtered out
     uint64_t producerUsage =
         usage &
-        ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK |
-                               BufferUsage::CPU_WRITE_MASK);
+        ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK | BufferUsage::CPU_WRITE_MASK |
+                               BufferUsage::GPU_DATA_BUFFER);
 
     switch (usage & BufferUsage::CPU_WRITE_MASK) {
         case static_cast<uint64_t>(BufferUsage::CPU_WRITE_RARELY):
@@ -225,6 +225,8 @@
             break;
     }
 
+    // BufferUsage::GPU_DATA_BUFFER is always filtered out
+
     return producerUsage;
 }
 
@@ -233,8 +235,8 @@
     // should be filtered out
     uint64_t consumerUsage =
         usage &
-        ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK |
-                               BufferUsage::CPU_WRITE_MASK);
+        ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK | BufferUsage::CPU_WRITE_MASK |
+                               BufferUsage::SENSOR_DIRECT_DATA | BufferUsage::GPU_DATA_BUFFER);
 
     switch (usage & BufferUsage::CPU_READ_MASK) {
         case static_cast<uint64_t>(BufferUsage::CPU_READ_RARELY):
@@ -247,6 +249,12 @@
             break;
     }
 
+    // BufferUsage::SENSOR_DIRECT_DATA is always filtered out
+
+    if (usage & BufferUsage::GPU_DATA_BUFFER) {
+        consumerUsage |= GRALLOC1_CONSUMER_USAGE_GPU_DATA_BUFFER;
+    }
+
     return consumerUsage;
 }
 
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 b86d957..570e33f 100644
--- a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
+++ b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
@@ -1373,7 +1373,7 @@
  */
 TEST_F(GetKeyCharacteristicsTest, SimpleRsa) {
     ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
-                                             .RsaSigningKey(256, 3)
+                                             .RsaSigningKey(1024, 3)
                                              .Digest(Digest::NONE)
                                              .Padding(PaddingMode::NONE)));
 
@@ -2245,7 +2245,7 @@
  */
 TEST_F(ExportKeyTest, RsaUnsupportedKeyFormat) {
     ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
-                                             .RsaSigningKey(256, 3)
+                                             .RsaSigningKey(1024, 3)
                                              .Digest(Digest::NONE)
                                              .Padding(PaddingMode::NONE)));
     HidlBuf export_data;
@@ -2262,7 +2262,7 @@
 TEST_F(ExportKeyTest, DISABLED_RsaCorruptedKeyBlob) {
     ASSERT_EQ(ErrorCode::OK, GenerateKey(AuthorizationSetBuilder()
                                              .Authorization(TAG_NO_AUTH_REQUIRED)
-                                             .RsaSigningKey(256, 3)
+                                             .RsaSigningKey(1024, 3)
                                              .Digest(Digest::NONE)
                                              .Padding(PaddingMode::NONE)));
     for (size_t i = 0; i < key_blob_.size(); ++i) {
diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
index e77cc14..e67f94f 100644
--- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
+++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp
@@ -46,13 +46,12 @@
     { 0x20, 0x01, 0x00 }
 #define INVALID_COMMAND \
   { 0x20, 0x00, 0x00 }
-#define FAULTY_DATA_PACKET \
-  { 0x00, 0x00, 0xFF }
 
 #define LOOP_BACK_HEADER_SIZE 3
 #define SYNTAX_ERROR 5
 #define NUMBER_LOOPS 3922
-#define VERSION 0x11
+#define NCI_VERSION_1_1 0x11
+#define NCI_VERSION_2 0x20
 #define TIMEOUT_PERIOD 5
 
 constexpr char kCallbackNameSendEvent[] = "sendEvent";
@@ -108,6 +107,42 @@
     EXPECT_TRUE(res.no_timeout);
     EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
     EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
+
+    /* Get the NCI version that the device supports */
+    std::vector<uint8_t> cmd = CORE_RESET_CMD;
+    NfcData data = cmd;
+    EXPECT_EQ(data.size(), nfc_->write(data));
+    // Wait for CORE_RESET_RSP
+    res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+    EXPECT_TRUE(res.no_timeout);
+    EXPECT_GE(6ul, res.args->last_data_.size());
+    EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+    if (res.args->last_data_.size() == 6) {
+        nci_version = res.args->last_data_[4];
+    } else {
+        EXPECT_EQ(4ul, res.args->last_data_.size());
+        nci_version = NCI_VERSION_2;
+        res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+        EXPECT_TRUE(res.no_timeout);
+    }
+
+    /*
+     * Close the hal and then re-open to make sure we are in a predictable
+     * state for all the tests.
+     */
+    EXPECT_EQ(NfcStatus::OK, nfc_->close());
+    // Wait for CLOSE_CPLT event
+    res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+    EXPECT_TRUE(res.no_timeout);
+    EXPECT_EQ(NfcEvent::CLOSE_CPLT, res.args->last_event_);
+    EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
+
+    EXPECT_EQ(NfcStatus::OK, nfc_->open(nfc_cb_));
+    // Wait for OPEN_CPLT event
+    res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
+    EXPECT_TRUE(res.no_timeout);
+    EXPECT_EQ(NfcEvent::OPEN_CPLT, res.args->last_event_);
+    EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
   }
 
   virtual void TearDown() override {
@@ -119,6 +154,9 @@
     EXPECT_EQ(NfcStatus::OK, res.args->last_status_);
   }
 
+  /* NCI version the device supports
+   * 0x11 for NCI 1.1, 0x20 for NCI 2.0 and so forth */
+  uint8_t nci_version;
   sp<INfc> nfc_;
   sp<NfcClientCallback> nfc_cb_;
 };
@@ -154,10 +192,26 @@
   // Wait for CORE_RESET_RSP
   auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
   EXPECT_TRUE(res.no_timeout);
-  EXPECT_EQ(6ul, res.args->last_data_.size());
-  EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
-  EXPECT_GE(VERSION, res.args->last_data_[4]);
-  EXPECT_GE(1ul, res.args->last_data_[5]);
+
+  /* The response/notification format for CORE_RESET_CMD differs
+   * with NCI 1.0 and 2.0. */
+  if (nci_version <= NCI_VERSION_1_1) {
+      EXPECT_EQ(6ul, res.args->last_data_.size());
+      EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+      EXPECT_GE(NCI_VERSION_1_1, res.args->last_data_[4]);
+      EXPECT_GE(1ul, res.args->last_data_[5]);
+  } else {
+      EXPECT_EQ(4ul, res.args->last_data_.size());
+      EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+      // Wait for CORE_RESET_NTF
+      res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+      EXPECT_TRUE(res.no_timeout);
+      // Check if reset trigger was due to CORE_RESET_CMD
+      EXPECT_LE(8ul, res.args->last_data_.size());
+      EXPECT_EQ(2ul, res.args->last_data_[3]);
+      EXPECT_GE(1ul, res.args->last_data_[4]);
+      EXPECT_EQ(NCI_VERSION_2, res.args->last_data_[5]);
+  }
 }
 
 /*
@@ -173,10 +227,26 @@
   // Wait for CORE_RESET_RSP
   auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
   EXPECT_TRUE(res.no_timeout);
-  EXPECT_EQ(6ul, res.args->last_data_.size());
-  EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
-  EXPECT_GE(VERSION, res.args->last_data_[4]);
-  EXPECT_EQ(1ul, res.args->last_data_[5]);
+
+  /* The response/notification format for CORE_RESET_CMD differs
+   * with NCI 1.0 and 2.0. */
+  if (nci_version <= NCI_VERSION_1_1) {
+      EXPECT_EQ(6ul, res.args->last_data_.size());
+      EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+      EXPECT_GE(NCI_VERSION_1_1, res.args->last_data_[4]);
+      EXPECT_EQ(1ul, res.args->last_data_[5]);
+  } else {
+      EXPECT_EQ(4ul, res.args->last_data_.size());
+      EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+      // Wait for CORE_RESET_NTF
+      res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+      EXPECT_TRUE(res.no_timeout);
+      // Check if reset trigger was due to CORE_RESET_CMD
+      EXPECT_LE(8ul, res.args->last_data_.size());
+      EXPECT_EQ(2ul, res.args->last_data_[3]);
+      EXPECT_EQ(1ul, res.args->last_data_[4]);
+      EXPECT_EQ(NCI_VERSION_2, res.args->last_data_[5]);
+  }
 }
 
 /*
@@ -199,8 +269,8 @@
 
 /*
  * WriteInvalidAndThenValidCommand:
- * Sends an Faulty Data Packet
- * Waits for CORE_INTERFACE_ERROR_NTF
+ * Sends an Invalid command
+ * Waits for response
  * Checks SYNTAX_ERROR status
  * Repeat for 100 times appending 0xFF each time to the packet
  * Send CORE_CONN_CREATE_CMD for loop-back mode
@@ -214,7 +284,13 @@
     auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
     EXPECT_TRUE(res.no_timeout);
     EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
-    EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+
+    /* NCI 2.0 sends CORE_RESET_NTF everytime. */
+    if (nci_version == NCI_VERSION_2) {
+        // Wait for CORE_RESET_NTF
+        res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+        EXPECT_TRUE(res.no_timeout);
+    }
 
     cmd = CORE_INIT_CMD;
     data = cmd;
@@ -225,7 +301,7 @@
     EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
 
     // Send an Error Data Packet
-    cmd = FAULTY_DATA_PACKET;
+    cmd = INVALID_COMMAND;
     data = cmd;
     size_t size = data.size();
 
@@ -233,13 +309,10 @@
         data.resize(++size);
         data[size - 1] = 0xFF;
         EXPECT_EQ(data.size(), nfc_->write(data));
-        // Wait for CORE_INTERFACE_ERROR_NTF
+        // Wait for response with SYNTAX_ERROR
         res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
         EXPECT_TRUE(res.no_timeout);
-        EXPECT_EQ(5ul, res.args->last_data_.size());
-        EXPECT_EQ(0x60, res.args->last_data_[0]);
-        EXPECT_EQ(0x08, res.args->last_data_[1]);
-        EXPECT_EQ(0x02, res.args->last_data_[2]);
+        EXPECT_EQ(4ul, res.args->last_data_.size());
         EXPECT_EQ(SYNTAX_ERROR, res.args->last_data_[3]);
   }
 
@@ -268,7 +341,13 @@
     auto res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
     EXPECT_TRUE(res.no_timeout);
     EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
-    EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]);
+
+    /* NCI 2.0 sends CORE_RESET_NTF everytime. */
+    if (nci_version == NCI_VERSION_2) {
+        // Wait for CORE_RESET_NTF
+        res = nfc_cb_->WaitForCallback(kCallbackNameSendData);
+        EXPECT_TRUE(res.no_timeout);
+    }
 
     cmd = CORE_INIT_CMD;
     data = cmd;
@@ -379,7 +458,13 @@
   // most devices.
   for (int i = 10; i <= 16; i++) {
       data[0] = i;
-      EXPECT_EQ(NfcStatus::OK, nfc_->coreInitialized(data));
+      NfcStatus status = nfc_->coreInitialized(data);
+
+      /* In case coreInitialized returned FAILED, do not wait for
+       * POST_INIT_CLPT event. */
+      if (status == NfcStatus::FAILED) continue;
+
+      EXPECT_EQ(NfcStatus::OK, status);
       // Wait for NfcEvent.POST_INIT_CPLT
       auto res = nfc_cb_->WaitForCallback(kCallbackNameSendEvent);
       EXPECT_TRUE(res.no_timeout);
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 3486db5..69da6b2 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp
@@ -441,8 +441,10 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
-        ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::SIM_ABSENT ||
-                    radioRsp->rspInfo.error == RadioError::SUBSCRIPTION_NOT_AVAILABLE);
+        std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
+        ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::SIM_ABSENT ||
+                    radioRsp->rspInfo.error == RadioError::SUBSCRIPTION_NOT_AVAILABLE ||
+                    radioRsp->rspInfo.error == RadioError::NONE);
     }
 }
 
@@ -508,7 +510,7 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
-        ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
+        ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
     }
 }
 
@@ -527,7 +529,7 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
-        ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
+        ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
     }
 }
 
@@ -544,7 +546,7 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
-        ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
+        ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
     }
 }
 
@@ -598,7 +600,7 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
-        ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
+        ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
     }
 }
 
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp b/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp
index 345747b..6ff0330 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp
@@ -34,8 +34,10 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
+        std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
         ASSERT_TRUE(CheckGeneralError() ||
-                    radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
+                    radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
+                    radioRsp->rspInfo.error == RadioError::NONE);
     }
 
     // Test with sending random string
@@ -49,8 +51,10 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
+        std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
         ASSERT_TRUE(CheckGeneralError() ||
-                    radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
+                    radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
+                    radioRsp->rspInfo.error == RadioError::NONE);
     }
 }
 
@@ -70,7 +74,10 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
-        EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
+        std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
+        ASSERT_TRUE(CheckGeneralError() ||
+                    radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
+                    radioRsp->rspInfo.error == RadioError::NONE);
     }
 
     serial = GetRandomSerialNumber();
@@ -85,6 +92,7 @@
     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
 
     if (cardStatus.cardState == CardState::ABSENT) {
+        std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
         ASSERT_TRUE(CheckGeneralError() ||
                     radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
     }
diff --git a/sensors/1.0/default/convert.cpp b/sensors/1.0/default/convert.cpp
index 2908737..a5747d4 100644
--- a/sensors/1.0/default/convert.cpp
+++ b/sensors/1.0/default/convert.cpp
@@ -67,9 +67,11 @@
     typedef ::android::hardware::sensors::V1_0::SensorType SensorType;
     typedef ::android::hardware::sensors::V1_0::MetaDataEventType MetaDataEventType;
 
-    dst->sensorHandle = src.sensor;
-    dst->sensorType = (SensorType)src.type;
-    dst->timestamp = src.timestamp;
+    *dst = {
+        .sensorHandle = src.sensor,
+        .sensorType = (SensorType)src.type,
+        .timestamp = src.timestamp
+    };
 
     switch (dst->sensorType) {
         case SensorType::META_DATA:
@@ -206,13 +208,13 @@
 }
 
 void convertToSensorEvent(const Event &src, sensors_event_t *dst) {
-  dst->version = sizeof(sensors_event_t);
-  dst->sensor = src.sensorHandle;
-  dst->type = (int32_t)src.sensorType;
-  dst->reserved0 = 0;
-  dst->timestamp = src.timestamp;
-  dst->flags = 0;
-  dst->reserved1[0] = dst->reserved1[1] = dst->reserved1[2] = 0;
+  *dst = {
+      .version = sizeof(sensors_event_t),
+      .sensor = src.sensorHandle,
+      .type = (int32_t)src.sensorType,
+      .reserved0 = 0,
+      .timestamp = src.timestamp
+  };
 
   switch (src.sensorType) {
       case SensorType::META_DATA:
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
index c92603b..4842946 100644
--- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
+++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
@@ -697,6 +697,7 @@
 SensorFlagBits SensorsHidlTest::expectedReportModeForType(SensorType type) {
   switch (type) {
     case SensorType::ACCELEROMETER:
+    case SensorType::ACCELEROMETER_UNCALIBRATED:
     case SensorType::GYROSCOPE:
     case SensorType::MAGNETIC_FIELD:
     case SensorType::ORIENTATION:
@@ -719,7 +720,6 @@
     case SensorType::AMBIENT_TEMPERATURE:
     case SensorType::HEART_RATE:
     case SensorType::DEVICE_ORIENTATION:
-    case SensorType::MOTION_DETECT:
     case SensorType::STEP_COUNTER:
     case SensorType::LOW_LATENCY_OFFBODY_DETECT:
       return SensorFlagBits::ON_CHANGE_MODE;
@@ -728,6 +728,8 @@
     case SensorType::WAKE_GESTURE:
     case SensorType::GLANCE_GESTURE:
     case SensorType::PICK_UP_GESTURE:
+    case SensorType::MOTION_DETECT:
+    case SensorType::STATIONARY_DETECT:
       return SensorFlagBits::ONE_SHOT_MODE;
 
     case SensorType::STEP_DETECTOR:
diff --git a/vibrator/1.1/Android.bp b/vibrator/1.1/Android.bp
index 86562a0..ee81d83 100644
--- a/vibrator/1.1/Android.bp
+++ b/vibrator/1.1/Android.bp
@@ -41,6 +41,7 @@
 
 cc_library_shared {
     name: "android.hardware.vibrator@1.1",
+    defaults: ["hidl-module-defaults"],
     generated_sources: ["android.hardware.vibrator@1.1_genc++"],
     generated_headers: ["android.hardware.vibrator@1.1_genc++_headers"],
     export_generated_headers: ["android.hardware.vibrator@1.1_genc++_headers"],
diff --git a/wifi/1.0/default/wifi_nan_iface.cpp b/wifi/1.0/default/wifi_nan_iface.cpp
index 1072015..88fb5b2 100644
--- a/wifi/1.0/default/wifi_nan_iface.cpp
+++ b/wifi/1.0/default/wifi_nan_iface.cpp
@@ -420,6 +420,11 @@
 }
 
 void WifiNanIface::invalidate() {
+  // send commands to HAL to actually disable and destroy interfaces
+  legacy_hal_.lock()->nanDisableRequest(0xFFFF);
+  legacy_hal_.lock()->nanDataInterfaceDelete(0xFFFE, "aware_data0");
+  legacy_hal_.lock()->nanDataInterfaceDelete(0xFFFD, "aware_data1");
+
   legacy_hal_.reset();
   event_cb_handler_.invalidate();
   is_valid_ = false;