Merge "Add p2 option in OpenLogicalChannel"
diff --git a/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc b/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
index 8545d2f..0f76c39 100644
--- a/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
+++ b/bluetooth/1.0/default/android.hardware.bluetooth@1.0-service.rc
@@ -2,3 +2,4 @@
     class hal
     user bluetooth
     group bluetooth
+    writepid /dev/stune/foreground/tasks
diff --git a/configstore/utils/Android.bp b/configstore/utils/Android.bp
index aa420d1..2c8aad6 100644
--- a/configstore/utils/Android.bp
+++ b/configstore/utils/Android.bp
@@ -14,14 +14,22 @@
 // limitations under the License.
 //
 
-cc_library_headers {
+cc_library_shared {
     name: "android.hardware.configstore-utils",
     defaults: ["hidl_defaults"],
+
+    srcs: [ "ConfigStoreUtils.cpp" ],
+
     export_include_dirs: ["include"],
+
     shared_libs: [
+        "android.hardware.configstore@1.0",
+        "libbase",
         "libhidlbase"
     ],
     export_shared_lib_headers: [
+        "android.hardware.configstore@1.0",
+        "libbase",
         "libhidlbase"
     ],
 }
diff --git a/configstore/utils/ConfigStoreUtils.cpp b/configstore/utils/ConfigStoreUtils.cpp
new file mode 100644
index 0000000..5a1fb42
--- /dev/null
+++ b/configstore/utils/ConfigStoreUtils.cpp
@@ -0,0 +1,40 @@
+//
+// Copyright (C) 2017 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.
+//
+
+#define LOG_TAG "ConfigStore"
+
+#include <android-base/logging.h>
+#include <configstore/Utils.h>
+
+namespace android {
+namespace hardware {
+namespace details {
+
+bool wouldLogInfo() {
+    return WOULD_LOG(INFO);
+}
+
+void logAlwaysInfo(const std::string& message) {
+    LOG(INFO) << message;
+}
+
+void logAlwaysError(const std::string& message) {
+    LOG(ERROR) << message;
+}
+
+}  // namespace details
+}  // namespace hardware
+}  // namespace android
diff --git a/configstore/utils/include/configstore/Utils.h b/configstore/utils/include/configstore/Utils.h
index 98ccae9..b054534 100644
--- a/configstore/utils/include/configstore/Utils.h
+++ b/configstore/utils/include/configstore/Utils.h
@@ -17,20 +17,31 @@
 #ifndef ANDROID_HARDWARE_CONFIGSTORE_UTILS_H
 #define ANDROID_HARDWARE_CONFIGSTORE_UTILS_H
 
+#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
 #include <hidl/Status.h>
-#include <stdatomic.h>
+
+#include <sstream>
 
 namespace android {
 namespace hardware {
+
+namespace details {
+// Templated classes can use the below method
+// to avoid creating dependencies on liblog.
+bool wouldLogInfo();
+void logAlwaysInfo(const std::string& message);
+void logAlwaysError(const std::string& message);
+}  // namespace details
+
 namespace configstore {
+using namespace android::hardware::configstore::V1_0;
 // arguments V: type for the value (i.e., OptionalXXX)
 //           I: interface class name
 //           func: member function pointer
-using namespace V1_0;
-
 template<typename V, typename I, android::hardware::Return<void> (I::* func)
         (std::function<void(const V&)>)>
 decltype(V::value) get(const decltype(V::value) &defValue) {
+    using namespace android::hardware::details;
     auto getHelper = []()->V {
         V ret;
         sp<I> configs = I::getService();
@@ -39,15 +50,39 @@
             // fallback to the default value
             ret.specified = false;
         } else {
-            (*configs.*func)([&ret](V v) {
-                ret = v;
-            });
+            auto status = (*configs.*func)([&ret](V v) { ret = v; });
+            if (!status.isOk()) {
+                std::ostringstream oss;
+                oss << "HIDL call failed for retrieving a config item from "
+                       "configstore : "
+                    << status.description().c_str();
+                logAlwaysError(oss.str());
+                ret.specified = false;
+            }
         }
 
         return ret;
     };
     static V cachedValue = getHelper();
 
+    if (wouldLogInfo()) {
+        std::string iname = __PRETTY_FUNCTION__;
+        // func name starts with "func = " in __PRETTY_FUNCTION__
+        auto pos = iname.find("func = ");
+        if (pos != std::string::npos) {
+            iname = iname.substr(pos + sizeof("func = "));
+            iname.pop_back();  // remove trailing ']'
+        } else {
+            iname += " (unknown)";
+        }
+
+        std::ostringstream oss;
+        oss << iname << " retrieved: "
+            << (cachedValue.specified ? cachedValue.value : defValue)
+            << (cachedValue.specified ? "" : " (default)");
+        logAlwaysInfo(oss.str());
+    }
+
     return cachedValue.specified ? cachedValue.value : defValue;
 }
 
diff --git a/renderscript/1.0/vts/functional/VtsCopyTests.cpp b/renderscript/1.0/vts/functional/VtsCopyTests.cpp
index 168e681..f47253f 100644
--- a/renderscript/1.0/vts/functional/VtsCopyTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsCopyTests.cpp
@@ -30,12 +30,18 @@
 TEST_F(RenderscriptHidlTest, Simple1DCopyTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 128 x float1
     Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     // 128 x float1
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     std::vector<float> dataIn(128), dataOut(128);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -60,12 +66,18 @@
 TEST_F(RenderscriptHidlTest, Simple2DCopyTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 128 x 128 x float1
     Type type = context->typeCreate(element, 128, 128, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     // 128 x 128 x float1
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     std::vector<float> dataIn(128*128), dataOut(128*128);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -91,12 +103,18 @@
 TEST_F(RenderscriptHidlTest, Simple3DCopyTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 32 x 32 x 32 x float1
     Type type = context->typeCreate(element, 32, 32, 32, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     // 32 x 32 x 32 x float1
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     std::vector<float> dataIn(32*32*32), dataOut(32*32*32);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -122,8 +140,12 @@
 TEST_F(RenderscriptHidlTest, SimpleBitmapTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 512 x 512 x float1
     Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     std::vector<float> dataIn(512*512), dataOut1(512*512), dataOut2(512*512);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -133,7 +155,7 @@
                                                                 AllocationMipmapControl::NONE,
                                                                 _data,
                                                                 (int)AllocationUsageType::SCRIPT);
-    EXPECT_NE(Allocation(0), allocation);
+    ASSERT_NE(Allocation(0), allocation);
 
     context->allocationCopyToBitmap(allocation, (Ptr)dataOut1.data(),
                                     (Size)dataOut1.size()*sizeof(float));
@@ -158,10 +180,16 @@
 TEST_F(RenderscriptHidlTest, AllocationCopy2DRangeTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 512 x 512 x float1
     Type typeSrc = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), typeSrc);
+
     // 256 x 256 x float1
     Type typeDst = context->typeCreate(element, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), typeDst);
+
     std::vector<float> dataIn(512*512), dataOut(256*256), expected(256*256);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -170,10 +198,14 @@
     Allocation allocSrc = context->allocationCreateFromBitmap(typeSrc,
                                                               AllocationMipmapControl::NONE, _data,
                                                               (int)AllocationUsageType::SCRIPT);
+    ASSERT_NE(Allocation(0), allocSrc);
+
     // 256 x 256 x float1
     Allocation allocDst = context->allocationCreateTyped(typeDst, AllocationMipmapControl::NONE,
                                                          (int)AllocationUsageType::SCRIPT,
                                                          (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocDst);
+
     context->allocationCopy2DRange(allocDst, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
                                    allocSrc, 128, 128, 0, AllocationCubemapFace::POSITIVE_X);
     context->allocationRead(allocDst, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float));
@@ -200,10 +232,16 @@
 TEST_F(RenderscriptHidlTest, AllocationCopy3DRangeTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 128 x 128 x 128 x float1
     Type typeSrc = context->typeCreate(element, 128, 128, 128, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), typeSrc);
+
     // 64 x 64 x 64 x float1
     Type typeDst = context->typeCreate(element, 64, 64, 64, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), typeDst);
+
     std::vector<float> dataIn(128*128*128), dataOut(64*64*64), expected(64*64*64);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -212,10 +250,14 @@
     Allocation allocSrc = context->allocationCreateTyped(typeSrc, AllocationMipmapControl::NONE,
                                                          (int)AllocationUsageType::SCRIPT,
                                                          (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocSrc);
+
     // 256 x 256 x float1
     Allocation allocDst = context->allocationCreateTyped(typeDst, AllocationMipmapControl::NONE,
                                                          (int)AllocationUsageType::SCRIPT,
                                                          (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocDst);
+
     context->allocation3DWrite(allocSrc, 0, 0, 0, 0, 128, 128, 128, _data, 128*sizeof(float));
     context->allocationCopy3DRange(allocDst, 0, 0, 0, 0, 64, 64, 64, allocSrc, 32, 32, 32, 0);
     context->allocationRead(allocDst, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float));
@@ -243,8 +285,12 @@
 TEST_F(RenderscriptHidlTest, SimpleAdapterTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 512 x 512 x float1
     Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     std::vector<float> dataIn(512*512), dataOut(256*256), expected;
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -254,11 +300,15 @@
                                                                 AllocationMipmapControl::NONE,
                                                                 _data,
                                                                 (int)AllocationUsageType::SCRIPT);
+    ASSERT_NE(Allocation(0), allocation);
+
     // 256 x 256 x float1
     Type subType = context->typeCreate(element, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), subType);
+
     // 256 x 256 x float1
     AllocationAdapter allocationAdapter = context->allocationAdapterCreate(subType, allocation);
-    EXPECT_NE(AllocationAdapter(0), allocationAdapter);
+    ASSERT_NE(AllocationAdapter(0), allocationAdapter);
 
     std::vector<uint32_t> offsets(9, 0);
     offsets[0] = 128;
@@ -292,8 +342,12 @@
 TEST_F(RenderscriptHidlTest, SimpleMipmapTest) {
     // uint8_t
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 64 x 64 x uint8_t
     Type type = context->typeCreate(element, 64, 64, 0, true, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     std::vector<uint8_t> dataIn(64*64), dataOut(32*32), expected(32*32);
     std::generate(dataIn.begin(), dataIn.end(),
                   [](){ static int val = 0; return (uint8_t)(0xFF & val++); });
@@ -303,6 +357,8 @@
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::FULL,
                                                          (int)AllocationUsageType::SCRIPT,
                                                          (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     context->allocation2DWrite(allocation, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 64, 64,
                                _data, 64*sizeof(uint8_t));
     context->allocationGenerateMipmaps(allocation);
@@ -333,8 +389,12 @@
 TEST_F(RenderscriptHidlTest, SimpleCubemapTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 128 x 128 x float1
     Type type = context->typeCreate(element, 128, 128, 0, false, true, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     std::vector<float> dataIn(128*128*6), dataOut(128*128), expected(128*128);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
     hidl_vec<uint8_t> _data;
@@ -342,7 +402,7 @@
     // 128 x 128 x float1 x 6
     Allocation allocation = context->allocationCubeCreateFromBitmap(
         type, AllocationMipmapControl::NONE, _data, (int)AllocationUsageType::SCRIPT);
-    EXPECT_NE(Allocation(0), allocation);
+    ASSERT_NE(Allocation(0), allocation);
 
     context->allocation2DRead(allocation, 0, 0, 0, AllocationCubemapFace::NEGATIVE_Z, 128,
                               128, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float),
@@ -367,13 +427,16 @@
  */
 TEST_F(RenderscriptHidlTest, ComplexElementTest) {
     Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element1);
+
     Element element2 = context->elementCreate(DataType::UNSIGNED_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element2);
 
     hidl_vec<Element> eins = {element1, element2};
     hidl_vec<hidl_string> names = {hidl_string("first"), hidl_string("second")};
     hidl_vec<Size> arraySizesPtr = {1, 1};
     Element element3 = context->elementComplexCreate(eins, names, arraySizesPtr);
-    EXPECT_NE(Element(0), element3);
+    ASSERT_NE(Element(0), element3);
 
     std::vector<Element> ids;
     std::vector<std::string> namesOut;
@@ -395,10 +458,14 @@
 
     // 1 x (uint8_t, uint32_t)
     Type type = context->typeCreate(element3, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     // 1 x (uint8_t, uint32_t)
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     std::vector<uint32_t> dataIn(1), dataOut(1);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
     hidl_vec<uint8_t> _data;
diff --git a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
index 39d63ca..23b09ac 100644
--- a/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsMiscellaneousTests.cpp
@@ -46,18 +46,18 @@
 TEST_F(RenderscriptHidlTest, ElementTypeAllocationCreate) {
     // Element create test
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
-    EXPECT_NE(Element(0), element);
+    ASSERT_NE(Element(0), element);
 
     // Type create test
     Type type = context->typeCreate(element, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
-    EXPECT_NE(Type(0), type);
+    ASSERT_NE(Type(0), type);
 
     // Allocation create test
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)((uint32_t)AllocationUsageType::ALL
                                                            & ~(uint32_t)AllocationUsageType::OEM),
                                                            (Ptr)nullptr);
-    EXPECT_NE(Allocation(0), allocation);
+    ASSERT_NE(Allocation(0), allocation);
 
     // Allocation type test
     Type type2 = context->allocationGetType(allocation);
@@ -74,8 +74,11 @@
 TEST_F(RenderscriptHidlTest, MetadataTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 128 x float1
     Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
 
     std::vector<uint32_t> elementMetadata(5);
     context->elementGetNativeMetadata(element, [&](const hidl_vec<uint32_t>& _metadata){
@@ -107,24 +110,30 @@
 TEST_F(RenderscriptHidlTest, ResizeTest) {
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 128 x float1
     Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     // 128 x float1
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     Ptr dataPtr1, dataPtr2;
     Size stride;
     context->allocationGetPointer(allocation, 0, AllocationCubemapFace::POSITIVE_X, 0,
                                   [&](Ptr _dataPtr, Size _stride){
                                       dataPtr1 = _dataPtr; stride = _stride; });
-    EXPECT_EQ(0ul, stride);
+    EXPECT_EQ(Size(0), stride);
 
     context->allocationResize1D(allocation, 1024*1024);
     context->allocationGetPointer(allocation, 0, AllocationCubemapFace::POSITIVE_X, 0,
                                   [&](Ptr _dataPtr, Size _stride){
                                       dataPtr2 = _dataPtr; stride = _stride; });
-    EXPECT_EQ(0ul, stride);
+    EXPECT_EQ(Size(0), stride);
     EXPECT_NE(dataPtr1, dataPtr2);
 }
 
@@ -139,8 +148,12 @@
 TEST_F(RenderscriptHidlTest, NativeWindowIoTest) {
     // uint8x4
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4);
+    ASSERT_NE(Element(0), element);
+
     // 512 x 512 x uint8x4
     Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     std::vector<uint32_t> dataIn(512*512), dataOut(512*512);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
     hidl_vec<uint8_t> _data;
@@ -150,12 +163,16 @@
                                                                (int)(AllocationUsageType::SCRIPT
                                                                | AllocationUsageType::IO_INPUT),
                                                                (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocationRecv);
+
     Allocation allocationSend = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                                (int)(AllocationUsageType::SCRIPT
                                                                | AllocationUsageType::IO_OUTPUT),
                                                                (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocationSend);
+
     NativeWindow nativeWindow = context->allocationGetNativeWindow(allocationRecv);
-    EXPECT_NE(NativeWindow(0), nativeWindow);
+    ASSERT_NE(NativeWindow(0), nativeWindow);
 
     ((ANativeWindow *)nativeWindow)->incStrong(nullptr);
 
@@ -174,14 +191,20 @@
  * two allocations with IO_INPUT are made to share the same BufferQueue.
  *
  * Calls: elementCreate, typeCreate, allocationCreateTyped,
- * allocationCreateFromBitmap, allocationSetupBufferQueue,
- * allocationShareBufferQueue
+ * allocationSetupBufferQueue, allocationShareBufferQueue,
+ * allocationGetNativeWindow, allocationSetNativeWindow,
+ * allocation2DWrite, allocation2DRead, allocationIoSend,
+ * allocationIoReceive
  */
 TEST_F(RenderscriptHidlTest, BufferQueueTest) {
     // uint8x4
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 4);
+    ASSERT_NE(Element(0), element);
+
     // 512 x 512 x uint8x4
     Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     std::vector<uint32_t> dataIn(512*512), dataOut1(512*512), dataOut2(512*512);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
     hidl_vec<uint8_t> _data;
@@ -191,20 +214,28 @@
                                                                 (int)(AllocationUsageType::SCRIPT
                                                                 | AllocationUsageType::IO_INPUT),
                                                                 (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocationRecv1);
+
     Allocation allocationRecv2 = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                                 (int)(AllocationUsageType::SCRIPT
                                                                 | AllocationUsageType::IO_INPUT),
                                                                 (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocationRecv2);
+
     Allocation allocationSend  = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                                 (int)(AllocationUsageType::SCRIPT
                                                                 | AllocationUsageType::IO_INPUT),
                                                                 (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocationSend);
+
     context->allocationSetupBufferQueue(allocationRecv1, 2);
     context->allocationShareBufferQueue(allocationRecv2, allocationRecv1);
 
     NativeWindow nativeWindow1 = context->allocationGetNativeWindow(allocationRecv1);
-    EXPECT_NE(NativeWindow(0), nativeWindow1);
+    ASSERT_NE(NativeWindow(0), nativeWindow1);
+
     NativeWindow nativeWindow2 = context->allocationGetNativeWindow(allocationRecv2);
+    ASSERT_NE(NativeWindow(0), nativeWindow2);
     EXPECT_EQ(nativeWindow2, nativeWindow1);
 
     ((ANativeWindow *)nativeWindow1)->incStrong(nullptr);
@@ -269,6 +300,8 @@
     context->contextSetCacheDir("/data/local/tmp/temp/");
 
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     std::string nameIn = "element_test_name";
     std::string nameOut = "not_name";
     hidl_string _nameIn;
diff --git a/renderscript/1.0/vts/functional/VtsScriptTests.cpp b/renderscript/1.0/vts/functional/VtsScriptTests.cpp
index 6bb375a..fed7c6e 100644
--- a/renderscript/1.0/vts/functional/VtsScriptTests.cpp
+++ b/renderscript/1.0/vts/functional/VtsScriptTests.cpp
@@ -25,6 +25,8 @@
 TEST_F(RenderscriptHidlTest, IntrinsicTest) {
     // uint8
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    EXPECT_NE(Element(0), element);
+
     Script script = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_BLUR, element);
     EXPECT_NE(Script(0), script);
 
@@ -43,7 +45,7 @@
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
-    EXPECT_NE(Script(0), script);
+    ASSERT_NE(Script(0), script);
 
     // arg tests
     context->scriptSetVarI(script, mExportVarIdx_var_int, 100);
@@ -75,12 +77,18 @@
 
     // float1
     Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 128 x float1
     Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     // 128 x float1
     Allocation allocationIn = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                              (int)AllocationUsageType::SCRIPT,
                                                              (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocationIn);
+
     Allocation allocationOut = Allocation(0);
     context->scriptSetVarObj(script, mExportVarIdx_var_allocation, (ObjectBase)allocationIn);
     context->scriptGetVarV(script, mExportVarIdx_var_allocation, sizeof(ObjectBase),
@@ -107,6 +115,8 @@
     _dimsVE.setToExternal((uint32_t*)dimsVE.data(), dimsVE.size());
     // intx2 to represent point2 which is {int, int}
     Element elementVE = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 2);
+    ASSERT_NE(Element(0), elementVE);
+
     context->scriptSetVarVE(script, mExportVarIdx_var_point2, _dataVE, elementVE, _dimsVE);
     context->scriptGetVarV(script, mExportVarIdx_var_point2, 2*sizeof(int),
                            [&](const hidl_vec<uint8_t>& _data){
@@ -126,7 +136,7 @@
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
-    EXPECT_NE(Script(0), script);
+    ASSERT_NE(Script(0), script);
 
     // invoke test
     int resultI = 0;
@@ -185,12 +195,16 @@
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
-    EXPECT_NE(Script(0), script);
+    ASSERT_NE(Script(0), script);
 
     // uint8_t
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 64 x uint8_t
     Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     std::vector<uint8_t> dataIn(64), dataOut(64), expected(64);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static uint8_t val = 0; return val++; });
     std::generate(expected.begin(), expected.end(), [](){ static uint8_t val = 1; return val++; });
@@ -200,9 +214,13 @@
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     Allocation vout = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                      (int)AllocationUsageType::SCRIPT,
                                                      (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), vout);
+
     context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
     hidl_vec<Allocation> vains;
     vains.setToExternal(&allocation, 1);
@@ -223,13 +241,19 @@
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
-    EXPECT_NE(Script(0), script);
+    ASSERT_NE(Script(0), script);
 
     // uint8_t
     Element element = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 64 x uint8_t
     Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     Type type2 = context->typeCreate(element, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type2);
+
     std::vector<int> dataIn(64), dataOut(1);
     std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return val++; });
     hidl_vec<uint8_t> _data;
@@ -238,9 +262,13 @@
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     Allocation vaout = context->allocationCreateTyped(type2, AllocationMipmapControl::NONE,
                                                       (int)AllocationUsageType::SCRIPT,
                                                       (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), vaout);
+
     context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
     hidl_vec<Allocation> vains;
     vains.setToExternal(&allocation, 1);
@@ -257,22 +285,29 @@
  * RenderScript script, represented in the bitcode.
  *
  * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped,
- * scriptSetVarV, scriptBindAllocation, allocationRead
+ * allocation1DWrite, scriptBindAllocation, scriptSetVarV, scriptBindAllocation,
+ * allocationRead, scriptInvokeV, allocationRead
  */
 TEST_F(RenderscriptHidlTest, ScriptBindTest) {
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
-    EXPECT_NE(Script(0), script);
+    ASSERT_NE(Script(0), script);
 
     // in32
     Element element = context->elementCreate(DataType::SIGNED_32, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     // 64 x int32
     Type type = context->typeCreate(element, 64, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     // 64 x int32
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     std::vector<int> dataIn(64), dataOut(64), expected(64, 5);
     hidl_vec<uint8_t> _data;
     _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(int));
@@ -295,7 +330,8 @@
  *
  * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation2DWrite,
  * scriptIntrinsicCreate, scriptKernelIDCreate, scriptFieldIDCreate,
- * scriptGroupCreate, scriptGroupSetOutput, scriptGroupExecute, allocation2DRead
+ * scriptGroupCreate, scriptSetVarObj, scriptGroupSetOutput, scriptGroupExecute,
+ * contextFinish, allocation2DRead
  */
 TEST_F(RenderscriptHidlTest, ScriptGroupTest) {
     std::vector<uint8_t> dataIn(256*256*1, 128), dataOut(256*256*4, 0), zeros(256*256*4, 0);
@@ -305,36 +341,49 @@
 
     // 256 x 256 YUV pixels
     Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::PIXEL_YUV, true, 1);
+    ASSERT_NE(Element(0), element1);
+
     Type type1 = context->typeCreate(element1, 256, 256, 0, false, false, YuvFormat::YUV_420_888);
+    ASSERT_NE(Type(0), type1);
+
     Allocation allocation1 = context->allocationCreateTyped(type1, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation1);
+
     context->allocation2DWrite(allocation1, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
                                _dataIn, 0);
 
     // 256 x 256 RGBA pixels
     Element element2 = context->elementCreate(DataType::UNSIGNED_8, DataKind::PIXEL_RGBA, true, 4);
+    ASSERT_NE(Element(0), element2);
+
     Type type2 = context->typeCreate(element2, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type2);
+
     Allocation allocation2 = context->allocationCreateTyped(type2, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation2);
+
     context->allocation2DWrite(allocation2, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
                                _dataOut, 0);
 
     // create scripts
     Script yuv2rgb = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_YUV_TO_RGB, element1);
-    EXPECT_NE(Script(0), yuv2rgb);
+    ASSERT_NE(Script(0), yuv2rgb);
 
     ScriptKernelID yuv2rgbKID = context->scriptKernelIDCreate(yuv2rgb, 0, 2);
-    EXPECT_NE(ScriptKernelID(0), yuv2rgbKID);
+    ASSERT_NE(ScriptKernelID(0), yuv2rgbKID);
 
     Script blur = context->scriptIntrinsicCreate(ScriptIntrinsicID::ID_BLUR, element2);
-    EXPECT_NE(Script(0), blur);
+    ASSERT_NE(Script(0), blur);
 
     ScriptKernelID blurKID = context->scriptKernelIDCreate(blur, 0, 2);
-    EXPECT_NE(ScriptKernelID(0), blurKID);
+    ASSERT_NE(ScriptKernelID(0), blurKID);
+
     ScriptFieldID blurFID = context->scriptFieldIDCreate(blur, 1);
-    EXPECT_NE(ScriptFieldID(0), blurFID);
+    ASSERT_NE(ScriptFieldID(0), blurFID);
 
     // ScriptGroup
     hidl_vec<ScriptKernelID> kernels = {yuv2rgbKID, blurKID};
@@ -343,7 +392,7 @@
     hidl_vec<ScriptFieldID> dstF = {blurFID};
     hidl_vec<Type> types = {type2};
     ScriptGroup scriptGroup = context->scriptGroupCreate(kernels, srcK, dstK, dstF, types);
-    EXPECT_NE(ScriptGroup(0), scriptGroup);
+    ASSERT_NE(ScriptGroup(0), scriptGroup);
 
     context->scriptSetVarObj(yuv2rgb, 0, (ObjectBase)allocation1);
     context->scriptGroupSetOutput(scriptGroup, blurKID, allocation2);
@@ -360,14 +409,16 @@
  * Similar to the ScriptGroup test, this test verifies the execution flow of
  * RenderScript kernels and invokables.
  *
- * Calls: scriptFieldIDCreate, closureCreate, scriptInvokeIDCreate,
- * invokeClosureCreate, closureSetGlobal, scriptGroup2Create, scriptGroupExecute
+ * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped,
+ * allocation1DWrite, scriptFieldIDCreate, scriptInvokeIDCreate,
+ * invokeClosureCreate, closureCreate, closureSetGlobal, scriptGroup2Create,
+ * scriptGroupExecute, allocationRead
  */
 TEST_F(RenderscriptHidlTest, ScriptGroup2Test) {
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
-    EXPECT_NE(Script(0), script);
+    ASSERT_NE(Script(0), script);
 
     std::vector<uint8_t> dataIn(128, 128), dataOut(128, 0), expected(128, 7+1);
     hidl_vec<uint8_t> _dataIn, _dataOut;
@@ -375,19 +426,23 @@
 
     // 256 x 256 YUV pixels
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     context->allocation1DWrite(allocation, 0, 0, (Size)_dataIn.size(), _dataIn);
 
     ScriptFieldID fieldID = context->scriptFieldIDCreate(script, mExportVarIdx_var_allocation);
-    EXPECT_NE(ScriptFieldID(0), fieldID);
     ASSERT_NE(ScriptFieldID(0), fieldID);
 
     // invoke
     ScriptInvokeID invokeID = context->scriptInvokeIDCreate(script, mExportFuncIdx_setAllocation);
-    EXPECT_NE(ScriptInvokeID(0), invokeID);
     ASSERT_NE(ScriptInvokeID(0), invokeID);
 
     int dim = 128;
@@ -397,12 +452,10 @@
     hidl_vec<int64_t> values1 = {int64_t(0)};
     hidl_vec<int32_t> sizes1 = {int32_t(0)};
     Closure closure1 = context->invokeClosureCreate(invokeID, params, fieldIDS1, values1, sizes1);
-    EXPECT_NE(Closure(0), closure1);
     ASSERT_NE(Closure(0), closure1);
 
     // kernel
     ScriptKernelID kernelID = context->scriptKernelIDCreate(script, mExportForEachIdx_increment, 3);
-    EXPECT_NE(ScriptKernelID(0), kernelID);
     ASSERT_NE(ScriptKernelID(0), kernelID);
 
     hidl_vec<ScriptFieldID> fieldIDS2 = {ScriptFieldID(0)};
@@ -412,7 +465,6 @@
     hidl_vec<ScriptFieldID> depFieldIDS2 = {fieldID};
     Closure closure2 = context->closureCreate(kernelID, allocation /* returnValue */, fieldIDS2,
                                               values2, sizes2, depClosures2, depFieldIDS2);
-    EXPECT_NE(Closure(0), closure2);
     ASSERT_NE(Closure(0), closure2);
 
     // set argument
@@ -424,7 +476,6 @@
     hidl_string cacheDir = "/data/local/tmp";
     hidl_vec<Closure> closures = {closure1, closure2};
     ScriptGroup2 scriptGroup2 = context->scriptGroup2Create(name, cacheDir, closures);
-    EXPECT_NE(ScriptGroup2(0), scriptGroup2);
     ASSERT_NE(ScriptGroup2(0), scriptGroup2);
 
     context->scriptGroupExecute(scriptGroup2);
@@ -436,14 +487,15 @@
  * Similar to the ScriptGroup test, this test verifies a single kernel can be
  * called by ScriptGroup with an unbound allocation specified before launch
  *
- * Calls: scriptFieldIDCreate, closureCreate, scriptInvokeIDCreate,
- * invokeClosureCreate, closureSetArg, scriptGroup2Create, scriptGroupExecute
+ * Calls: scriptCCreate, elementCreate, typeCreate, allocationCreateTyped,
+ * allocation1DWrite, scriptKernelIDCreate, closureCreate, closureSetArg,
+ * scriptGroup2Create, scriptGroupExecute, allocationRead
  */
 TEST_F(RenderscriptHidlTest, ScriptGroup2KernelTest) {
     hidl_vec<uint8_t> bitcode;
     bitcode.setToExternal((uint8_t*)bitCode, bitCodeLength);
     Script script = context->scriptCCreate("struct_test", "/data/local/tmp/", bitcode);
-    EXPECT_NE(Script(0), script);
+    ASSERT_NE(Script(0), script);
 
     std::vector<uint8_t> dataIn(128, 128), dataOut(128, 0), expected(128, 128 + 1);
     hidl_vec<uint8_t> _dataIn, _dataOut;
@@ -451,15 +503,20 @@
 
     // 256 x 256 YUV pixels
     Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
+    ASSERT_NE(Element(0), element);
+
     Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
+    ASSERT_NE(Type(0), type);
+
     Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
                                                            (int)AllocationUsageType::SCRIPT,
                                                            (Ptr)nullptr);
+    ASSERT_NE(Allocation(0), allocation);
+
     context->allocation1DWrite(allocation, 0, 0, (Size)_dataIn.size(), _dataIn);
 
     // kernel
     ScriptKernelID kernelID = context->scriptKernelIDCreate(script, mExportForEachIdx_increment, 3);
-    EXPECT_NE(ScriptKernelID(0), kernelID);
     ASSERT_NE(ScriptKernelID(0), kernelID);
 
     hidl_vec<ScriptFieldID> fieldIDS = {ScriptFieldID(0)};
@@ -469,7 +526,6 @@
     hidl_vec<ScriptFieldID> depFieldIDS = {ScriptFieldID(0)};
     Closure closure = context->closureCreate(kernelID, allocation /* returnValue */, fieldIDS,
                                               values, sizes, depClosures, depFieldIDS);
-    EXPECT_NE(Closure(0), closure);
     ASSERT_NE(Closure(0), closure);
 
     // set argument
@@ -480,7 +536,6 @@
     hidl_string cacheDir = "/data/local/tmp";
     hidl_vec<Closure> closures = {closure};
     ScriptGroup2 scriptGroup2 = context->scriptGroup2Create(name, cacheDir, closures);
-    EXPECT_NE(ScriptGroup2(0), scriptGroup2);
     ASSERT_NE(ScriptGroup2(0), scriptGroup2);
 
     context->scriptGroupExecute(scriptGroup2);
diff --git a/tests/baz/1.0/Android.bp b/tests/baz/1.0/Android.bp
index 8f327e3..1d5013b 100644
--- a/tests/baz/1.0/Android.bp
+++ b/tests/baz/1.0/Android.bp
@@ -7,6 +7,7 @@
         "IBase.hal",
         "IBaz.hal",
         "IBazCallback.hal",
+        "IQuux.hal",
     ],
 }
 
@@ -22,6 +23,7 @@
         "android/hardware/tests/baz/1.0/BaseAll.cpp",
         "android/hardware/tests/baz/1.0/BazAll.cpp",
         "android/hardware/tests/baz/1.0/BazCallbackAll.cpp",
+        "android/hardware/tests/baz/1.0/QuuxAll.cpp",
     ],
 }
 
@@ -50,6 +52,11 @@
         "android/hardware/tests/baz/1.0/BnHwBazCallback.h",
         "android/hardware/tests/baz/1.0/BpHwBazCallback.h",
         "android/hardware/tests/baz/1.0/BsBazCallback.h",
+        "android/hardware/tests/baz/1.0/IQuux.h",
+        "android/hardware/tests/baz/1.0/IHwQuux.h",
+        "android/hardware/tests/baz/1.0/BnHwQuux.h",
+        "android/hardware/tests/baz/1.0/BpHwQuux.h",
+        "android/hardware/tests/baz/1.0/BsQuux.h",
     ],
 }
 
diff --git a/tests/baz/1.0/Android.mk b/tests/baz/1.0/Android.mk
index 40026ec..9d4d6b6 100644
--- a/tests/baz/1.0/Android.mk
+++ b/tests/baz/1.0/Android.mk
@@ -76,6 +76,25 @@
 $(GEN): $(LOCAL_PATH)/IBazCallback.hal
 	$(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IQuux.hal
+#
+GEN := $(intermediates)/android/hardware/tests/baz/V1_0/IQuux.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IQuux.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava \
+        -randroid.hardware:hardware/interfaces \
+        -randroid.hidl:system/libhidl/transport \
+        android.hardware.tests.baz@1.0::IQuux
+
+$(GEN): $(LOCAL_PATH)/IQuux.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
 include $(BUILD_JAVA_LIBRARY)
 
 
@@ -153,6 +172,25 @@
 $(GEN): $(LOCAL_PATH)/IBazCallback.hal
 	$(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IQuux.hal
+#
+GEN := $(intermediates)/android/hardware/tests/baz/V1_0/IQuux.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IQuux.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava \
+        -randroid.hardware:hardware/interfaces \
+        -randroid.hidl:system/libhidl/transport \
+        android.hardware.tests.baz@1.0::IQuux
+
+$(GEN): $(LOCAL_PATH)/IQuux.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 
diff --git a/tests/baz/1.0/IQuux.hal b/tests/baz/1.0/IQuux.hal
new file mode 100644
index 0000000..ccf3212
--- /dev/null
+++ b/tests/baz/1.0/IQuux.hal
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+package android.hardware.tests.baz@1.0;
+
+interface IQuux {
+};
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index df9c9df..ae4f95d 100644
--- a/wifi/1.0/default/hidl_struct_util.cpp
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -1067,6 +1067,7 @@
         hidl_request.baseConfigs.disableMatchExpirationIndication ? 0x2 : 0x0;
   legacy_request->recv_indication_cfg |=
         hidl_request.baseConfigs.disableFollowupReceivedIndication ? 0x4 : 0x0;
+  legacy_request->recv_indication_cfg |= 0x8;
   legacy_request->cipher_type = (unsigned int) hidl_request.baseConfigs.securityConfig.cipherType;
   if (hidl_request.baseConfigs.securityConfig.securityType == NanDataPathSecurityType::PMK) {
     legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
index ba57ba7..44acc04 100644
--- a/wifi/1.0/default/wifi_legacy_hal.cpp
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -180,6 +180,12 @@
   }
 }
 
+std::function<void(const NanPublishRepliedInd&)>
+    on_nan_event_publish_replied_user_callback;
+void onAysncNanEventPublishReplied(NanPublishRepliedInd* /* event */) {
+  LOG(ERROR) << "onAysncNanEventPublishReplied triggered";
+}
+
 std::function<void(const NanPublishTerminatedInd&)>
     on_nan_event_publish_terminated_user_callback;
 void onAysncNanEventPublishTerminated(NanPublishTerminatedInd* event) {
@@ -1054,6 +1060,7 @@
   return global_func_table_.wifi_nan_register_handler(
       wlan_interface_handle_,
       {onAysncNanNotifyResponse,
+       onAysncNanEventPublishReplied,
        onAysncNanEventPublishTerminated,
        onAysncNanEventMatch,
        onAysncNanEventMatchExpired,