Merge changes from topic 'hidl-vendor-available' into oc-dev

* changes:
  Update makefiles (2/2).
  Update makefiles.
diff --git a/graphics/allocator/2.0/default/Android.bp b/graphics/allocator/2.0/default/Android.bp
index 6adfa71..4a7cfe0 100644
--- a/graphics/allocator/2.0/default/Android.bp
+++ b/graphics/allocator/2.0/default/Android.bp
@@ -15,7 +15,9 @@
         "liblog",
         "libutils",
     ],
-    static_libs: ["libgrallocmapperincludes"],
+    header_libs: [
+        "libgrallocmapperincludes",
+    ],
 }
 
 cc_binary {
diff --git a/graphics/composer/2.1/IComposer.hal b/graphics/composer/2.1/IComposer.hal
index b3ac761..e2aa5cd 100644
--- a/graphics/composer/2.1/IComposer.hal
+++ b/graphics/composer/2.1/IComposer.hal
@@ -44,6 +44,12 @@
          * applying the color transform during its composition step.
          */
         SKIP_CLIENT_COLOR_TRANSFORM = 2,
+
+        /**
+         * Specifies that the present fence must not be used as an accurate
+         * representation of the actual present time of a frame.
+         */
+        PRESENT_FENCE_IS_NOT_RELIABLE = 3,
     };
 
     /**
diff --git a/graphics/composer/2.1/default/Hwc.cpp b/graphics/composer/2.1/default/Hwc.cpp
index 1497065..8ca0eb3 100644
--- a/graphics/composer/2.1/default/Hwc.cpp
+++ b/graphics/composer/2.1/default/Hwc.cpp
@@ -65,6 +65,12 @@
     }
 
     initCapabilities();
+    if (majorVersion >= 2 &&
+        hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) {
+        ALOGE("Present fence must be reliable from HWC2 on.");
+        abort();
+    }
+
     initDispatch();
 }
 
diff --git a/graphics/mapper/2.0/default/Android.bp b/graphics/mapper/2.0/default/Android.bp
index 090c61f..677d966 100644
--- a/graphics/mapper/2.0/default/Android.bp
+++ b/graphics/mapper/2.0/default/Android.bp
@@ -16,7 +16,7 @@
 cc_library_shared {
     name: "android.hardware.graphics.mapper@2.0-impl",
     defaults: ["hidl_defaults"],
-    proprietary: true,
+    vendor: true,
     relative_install_path: "hw",
     srcs: ["GrallocMapper.cpp", "Gralloc0Mapper.cpp", "Gralloc1Mapper.cpp"],
     cppflags: ["-Wall", "-Wextra"],
@@ -33,7 +33,8 @@
     ],
 }
 
-cc_library_static {
+cc_library_headers {
     name: "libgrallocmapperincludes",
+    vendor: true,
     export_include_dirs: ["."],
 }
diff --git a/media/1.0/types.hal b/media/1.0/types.hal
index 1f9c4dc..bb1a73b 100644
--- a/media/1.0/types.hal
+++ b/media/1.0/types.hal
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * 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.
diff --git a/media/omx/1.0/Android.bp b/media/omx/1.0/Android.bp
index b09f50c..0ecf085 100644
--- a/media/omx/1.0/Android.bp
+++ b/media/omx/1.0/Android.bp
@@ -9,6 +9,7 @@
         "IOmxBufferSource.hal",
         "IOmxNode.hal",
         "IOmxObserver.hal",
+        "IOmxStore.hal",
     ],
 }
 
@@ -26,6 +27,7 @@
         "android/hardware/media/omx/1.0/OmxBufferSourceAll.cpp",
         "android/hardware/media/omx/1.0/OmxNodeAll.cpp",
         "android/hardware/media/omx/1.0/OmxObserverAll.cpp",
+        "android/hardware/media/omx/1.0/OmxStoreAll.cpp",
     ],
 }
 
@@ -64,6 +66,11 @@
         "android/hardware/media/omx/1.0/BnHwOmxObserver.h",
         "android/hardware/media/omx/1.0/BpHwOmxObserver.h",
         "android/hardware/media/omx/1.0/BsOmxObserver.h",
+        "android/hardware/media/omx/1.0/IOmxStore.h",
+        "android/hardware/media/omx/1.0/IHwOmxStore.h",
+        "android/hardware/media/omx/1.0/BnHwOmxStore.h",
+        "android/hardware/media/omx/1.0/BpHwOmxStore.h",
+        "android/hardware/media/omx/1.0/BsOmxStore.h",
     ],
 }
 
diff --git a/media/omx/1.0/IOmx.hal b/media/omx/1.0/IOmx.hal
index 78d4b32..f5fc449 100644
--- a/media/omx/1.0/IOmx.hal
+++ b/media/omx/1.0/IOmx.hal
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * 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.
@@ -26,7 +26,7 @@
 /**
  * Ref: frameworks/av/include/media/IOMX.h: IOMX
  *
- * IOmx is the main entry point for communicating with OMX components.
+ * IOmx has the ability to create OMX nodes.
  */
 interface IOmx {
 
@@ -41,8 +41,8 @@
     /**
      * List available components.
      *
-     * @param[out] status The status of the call.
-     * @param[out] nodeList The list of ComponentInfo.
+     * @return status The status of the call.
+     * @return nodeList The list of ComponentInfo.
      */
     listNodes(
         ) generates (
@@ -50,14 +50,15 @@
             vec<ComponentInfo> nodeList
         );
 
+
     /**
-     * Allocate an IOmxNode instance with the specified component name.
+     * Allocate an IOmxNode instance with the specified node name.
      *
-     * @param[in] name The name of the component to create.
-     * @param[in] observer An observer object that will receive messages from
+     * @param name The name of the node to create.
+     * @param observer An observer object that will receive messages from
      * the created instance.
-     * @param[out] status The status of the call.
-     * @param[out] omxNode The allocated instance of IOmxNode.
+     * @return status The status of the call.
+     * @return omxNode The allocated instance of `IOmxNode`.
      */
     allocateNode(
             string name,
@@ -70,8 +71,9 @@
     /**
      * Create an input surface for recording.
      *
-     * @param[out] producer The associated producer end of the buffer queue.
-     * @param[out] source The associated `IGraphicBufferSource`.
+     * @return status The status of the call.
+     * @return producer The associated producer end of the buffer queue.
+     * @return source The associated `IGraphicBufferSource`.
      */
     createInputSurface(
         ) generates (
diff --git a/media/omx/1.0/IOmxNode.hal b/media/omx/1.0/IOmxNode.hal
index 8729637..71c0da3 100644
--- a/media/omx/1.0/IOmxNode.hal
+++ b/media/omx/1.0/IOmxNode.hal
@@ -35,7 +35,7 @@
     /**
      * Free the node.
      *
-     * @param[out] status Status of the call.
+     * @return status Status of the call.
      */
     freeNode(
         ) generates (
@@ -45,9 +45,9 @@
     /**
      * Invoke a command on the node.
      *
-     * @param[in] cmd Type of the command.
-     * @param[in] param Parameter for the command.
-     * @param[out] status Status of the call.
+     * @param cmd Type of the command.
+     * @param param Parameter for the command.
+     * @return status Status of the call.
      *
      * @see OMX_SendCommand() in the OpenMax IL standard.
      */
@@ -61,10 +61,10 @@
     /**
      * Retrieve a parameter setting from the node.
      *
-     * @param[in] index Type of the parameter to retrieve.
-     * @param[in] inParams Information about the retrieval.
-     * @param[out] status Status of the call.
-     * @param[out] outParams Current parameter setting.
+     * @param index Type of the parameter to retrieve.
+     * @param inParams Information about the retrieval.
+     * @return status Status of the call.
+     * @return outParams Current parameter setting.
      *
      * @see OMX_GetParameter() in the OpenMax IL standard.
      */
@@ -79,9 +79,9 @@
     /**
      * Change a parameter setting of the node.
      *
-     * @param[in] index Type of the parameter to change.
-     * @param[in] params New parameter setting.
-     * @param[out] status Status of the call.
+     * @param index Type of the parameter to change.
+     * @param params New parameter setting.
+     * @return status Status of the call.
      *
      * @see OMX_SetParameter() in the OpenMax IL standard.
      */
@@ -95,10 +95,10 @@
     /**
      * Retrieve a configuration from the node.
      *
-     * @param[in] index Type of the configuration to retrieve.
-     * @param[in] inConfig Information about the retrieval.
-     * @param[out] status Status of the call.
-     * @param[out] outConfig Current configuration.
+     * @param index Type of the configuration to retrieve.
+     * @param inConfig Information about the retrieval.
+     * @return status Status of the call.
+     * @return outConfig Current configuration.
      *
      * @see OMX_GetConfig() in the OpenMax IL standard.
      */
@@ -113,9 +113,9 @@
     /**
      * Change a configuration of the node.
      *
-     * @param[in] index Type of the configuration to change.
-     * @param[in] config New configuration.
-     * @param[out] status Status of the call.
+     * @param index Type of the configuration to change.
+     * @param config New configuration.
+     * @return status Status of the call.
      *
      * @see OMX_SetConfig() in the OpenMax IL standard.
      */
@@ -129,9 +129,9 @@
     /**
      * Set the mode of a port on the node.
      *
-     * @param[in] portIndex Index of the port.
-     * @param[in] mode Target mode on the specified port.
-     * @param[out] status Status of the call.
+     * @param portIndex Index of the port.
+     * @param mode Target mode on the specified port.
+     * @return status Status of the call.
      */
     setPortMode(
             uint32_t portIndex,
@@ -144,11 +144,11 @@
      * Prepare a port for adaptive playback. This is based on the extension
      * "OMX.google.android.index.prepareForAdaptivePlayback".
      *
-     * @param[in] portIndex Index of the port.
-     * @param[in] enable Whether the adaptive playback is enabled or not.
-     * @param[in] maxFrameWidth Maximum frame width.
-     * @param[in] maxFrameHeight Maximum frame height.
-     * @param[out] status Status of the call.
+     * @param portIndex Index of the port.
+     * @param enable Whether the adaptive playback is enabled or not.
+     * @param maxFrameWidth Maximum frame width.
+     * @param maxFrameHeight Maximum frame height.
+     * @return status Status of the call.
      */
     prepareForAdaptivePlayback(
             uint32_t portIndex,
@@ -163,12 +163,12 @@
      * Configure a port for a tunneled playback mode. This is based on the
      * extension "OMX.google.android.index.configureVideoTunnelMode".
      *
-     * @param[in] portIndex Index of the port.
-     * @param[in] tunneled Whether the tunneled mode is used or not.
-     * @param[in] audioHwSync HW SYNC ID of the audio HAL output stream to sync
+     * @param portIndex Index of the port.
+     * @param tunneled Whether the tunneled mode is used or not.
+     * @param audioHwSync HW SYNC ID of the audio HAL output stream to sync
      * the video with.
-     * @param[out] status Status of the call.
-     * @param[out] sidebandHandle Codec-allocated sideband window handle.
+     * @return status Status of the call.
+     * @return sidebandHandle Codec-allocated sideband window handle.
      */
     configureVideoTunnelMode(
             uint32_t portIndex,
@@ -183,9 +183,9 @@
      * Retrieve the buffer usage on a port. This is based on the extension
      * "OMX.google.android.index.getAndroidNativeBufferUsage".
      *
-     * @param[in] portIndex Index of the port.
-     * @param[out] status Status of the call.
-     * @param[out] usage Current graphic buffer usage.
+     * @param portIndex Index of the port.
+     * @return status Status of the call.
+     * @return usage Current graphic buffer usage.
      */
     getGraphicBufferUsage(
             uint32_t portIndex
@@ -197,9 +197,9 @@
     /**
      * Set up a listener to events related to the input surface.
      *
-     * @param[in] bufferSource Listener object that implements
+     * @param bufferSource Listener object that implements
      * IOmxBufferSource.
-     * @param[out] status Status of the call.
+     * @return status Status of the call.
      *
      * @see IOmxBufferSource.
      */
@@ -212,12 +212,12 @@
     /**
      * Allocate an opaque buffer on a port as a native handle.
      *
-     * @param[in] portIndex Index of the port.
-     * @param[in] size Desired size of the buffer.
-     * @param[out] status Status of the call.
-     * @param[out] buffer Id of the allocated buffer, which will be needed in
+     * @param portIndex Index of the port.
+     * @param size Desired size of the buffer.
+     * @return status Status of the call.
+     * @return buffer Id of the allocated buffer, which will be needed in
      * other buffer-related functions.
-     * @param[out] nativeHandle Native handle of the allocated buffer.
+     * @return nativeHandle Native handle of the allocated buffer.
      *
      * @see OMX_AllocateBuffer() in the OpenMax IL standard.
      */
@@ -233,10 +233,10 @@
     /**
      * Assign a buffer to a port.
      *
-     * @param[in] portIndex Index of the port.
-     * @param[in] omxBuffer Buffer to be assigned to the port.
-     * @param[out] status Status of the call.
-     * @param[out] buffer Id of the assigned buffer, which will be needed in
+     * @param portIndex Index of the port.
+     * @param omxBuffer Buffer to be assigned to the port.
+     * @return status Status of the call.
+     * @return buffer Id of the assigned buffer, which will be needed in
      * other buffer-related functions.
      *
      * @see OMX_UseBuffer() in the OpenMax IL standard.
@@ -253,9 +253,9 @@
      * Free a buffer previously assigned to a port by allocateSecureBuffer() or
      * useBuffer().
      *
-     * @param[in] portIndex Index of the port.
-     * @param[in] buffer Id of the buffer to be freed.
-     * @param[out] status Status of the call.
+     * @param portIndex Index of the port.
+     * @param buffer Id of the buffer to be freed.
+     * @return status Status of the call.
      *
      * @see OMX_FreeBuffer() in the OpenMax IL standard.
      */
@@ -275,10 +275,10 @@
      * the new buffer passed in via \p omxBuffer before OMX_FillThisBuffer() is
      * called. Otherwise, \p omxBuffer is not used.
      *
-     * @param[in] buffer Id of the buffer to fill.
-     * @param[in] omxBuffer New buffer information (in metadata mode).
-     * @param[in] fence Fence to wait for (if not null).
-     * @param[out] status Status of the call.
+     * @param buffer Id of the buffer to fill.
+     * @param omxBuffer New buffer information (in metadata mode).
+     * @param fence Fence to wait for (if not null).
+     * @return status Status of the call.
      *
      * @see OMX_FillThisBuffer() in the OpenMax IL standard.
      */
@@ -299,12 +299,12 @@
      * the new buffer passed in via \p omxBuffer before OMX_EmptyThisBuffer() is
      * called. Otherwise, \p omxBuffer is not used.
      *
-     * @param[in] buffer Id of the buffer to fill.
-     * @param[in] omxBuffer New buffer information (in metadata mode).
-     * @param[in] flags Flags to be passed to OMX_EmptyBuffer().
-     * @param[in] timestampUs Timestamp OMX_EmptyBuffer().
-     * @param[in] fence Fence to wait for (if not null).
-     * @param[out] status Status of the call.
+     * @param buffer Id of the buffer to fill.
+     * @param omxBuffer New buffer information (in metadata mode).
+     * @param flags Flags to be passed to OMX_EmptyBuffer().
+     * @param timestampUs Timestamp OMX_EmptyBuffer().
+     * @param fence Fence to wait for (if not null).
+     * @return status Status of the call.
      *
      * @see OMX_EmptyThisBuffer() in the OpenMax IL standard.
      */
@@ -321,9 +321,9 @@
     /**
      * Request the node to translate an extension string to an index.
      *
-     * @param[in] parameterName Requested extension string.
-     * @param[out] status Status of the call.
-     * @param[out] index Translated index.
+     * @param parameterName Requested extension string.
+     * @return status Status of the call.
+     * @return index Translated index.
      *
      * @see OMX_GetExtensionIndex() in the OpenMax IL standard.
      */
@@ -340,8 +340,8 @@
      * receive the message in batches by the callback
      * IOmxObserver::onMessages().
      *
-     * @param[in] msg Message to send.
-     * @param[out] status Status of the call.
+     * @param msg Message to send.
+     * @return status Status of the call.
      *
      * @see IOmxObserver::onMessages().
      */
@@ -350,16 +350,5 @@
         ) generates (
             Status status
         );
-
-    /**
-     * Set quirks.
-     *
-     * @param[in] quirks Quirks for the component, generally obtained from
-     * MediaCodecList::getQuirksFor().
-     */
-    oneway setQuirks(
-            uint32_t quirks
-        );
-
 };
 
diff --git a/media/omx/1.0/IOmxStore.hal b/media/omx/1.0/IOmxStore.hal
new file mode 100644
index 0000000..a224b0e
--- /dev/null
+++ b/media/omx/1.0/IOmxStore.hal
@@ -0,0 +1,215 @@
+/*
+ * 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.media.omx@1.0;
+
+import IOmx;
+
+/**
+ * Ref: frameworks/av/include/media/IOMX.h: IOMX
+ *
+ * There will be two instances of IOmxStore: "platform" and "vendor".
+ *
+ * The IOmxStore service provided by the platform must present "platform" as the
+ * interface name.
+ *
+ * The IOmxStore service provided by the vendor must present "vendor" as the
+ * instance name.
+ */
+interface IOmxStore {
+
+    /**
+     * Attribute is a key-value pair of strings. The `value` member is generally
+     * a stringified value of the following:
+     *   enum<v1,v2,...,vn>:    v1 | v2 | ... | vn
+     *   num:                   0 | [1-9][0-9]*
+     *   string:                arbitrary string
+     *   size:                  <num>x<num>
+     *   ratio:                 <num>:<num>
+     *   range<type>:           <type>-<type>
+     *   list<type>:            <type> | <type>,<list<type>>
+     */
+    struct Attribute {
+        string key;
+        string value;
+    };
+
+    /**
+     * Service attribute
+     *
+     * Optional service attributes:
+     *   key: 'max-video-encoder-input-buffers', value-type: num
+     *   key: 'supports-multiple-secure-codecs', value-type: enum<0,1>
+     *   key: 'supports-secure-with-non-secure-codec', value-type: enum<0,1>
+     *
+     * For keys with prefix 'supports-', the value of 0 means "no" (not
+     * supported) while the value of 1 means "yes" (supported).
+     */
+    typedef Attribute ServiceAttribute;
+
+    /**
+     * List attributes that are service-specific (not node-specific).
+     *
+     * @return attributes The list of `Attribute`s that are specific to this
+     *                    service.
+     */
+    listServiceAttributes(
+        ) generates (
+            Status status,
+            vec<ServiceAttribute> attributes
+        );
+
+    /**
+     * Node attribute
+     *
+     * Optional node attributes to describe supported values:
+     *   key: 'bitrate-range', value-type: range<num>
+     *   key: 'max-concurrent-instances', value-type: num
+     *   key: 'max-supported-instances', value-type: num
+     *
+     * Optional node attributes for audio nodes to describe supported values:
+     *   key: 'max-channel-count', value-type: num
+     *   key: 'sample-rate-ranges', value-type: list<range<num>>
+     *
+     * Optional node attributes for video nodes to describe supported values:
+     *   key: 'alignment', value-type: size
+     *   key: 'block-aspect-ratio-range', value-type: range<ratio>
+     *   key: 'block-count-range', value-type: range<num>
+     *   key: 'block-size', value-type: size
+     *   key: 'blocks-per-second-range', value-type: range<num>
+     *   key: 'feature-can-swap-width-height', value-type: enum<0,1>
+     *   key: 'frame-rate-range', value-type: range<num>
+     *   key: 'pixel-aspect-ratio-range', value-type: range<ratio>
+     *   key: 'size-range', value-type: range<size>
+     *
+     * Required node attributes for video nodes that are required by Android to
+     * describe measured values for this device:
+     *   key: 'measured-frame-rate-<width>-<height>-range',
+     *     value-type: range<num>; where width: num, height: num
+     *
+     * Optional node attributes for decoders to describe supported values:
+     *   key: 'feature-adaptive-playback', value: enum<0,1>
+     *   key: 'feature-secure-playback', value: enum<0,1>
+     *   key: 'feature-tunneled-playback', value: enum<0,1>
+     *
+     * Optional node attributes for video decoders to describe supported values:
+     *   key: 'feature-partial-frame', value: enum<0,1>
+     *
+     * Optional node attributes for encoders to describe supported values:
+     *   key: 'complexity-default', value-type: num
+     *   key: 'complexity-range', value-type: range<num>
+     *   key: 'feature-bitrate-control', value-type: list<enum<VBR,CBR,CQ>>
+     *   key: 'feature-intra-refresh', value-type: enum<0,1>
+     *   key: 'quality-default', value-type: num
+     *   key: 'quality-range', value-type: range<num>
+     *   key: 'quality-scale', value-type: string
+     *
+     * For keys with prefix 'feature-' and value type enum<0,1>, the value of 0
+     * means "optional", while the value of 1 means "required".
+     */
+    typedef Attribute NodeAttribute;
+
+    /**
+     * Information for an IOmxNode node.
+     */
+    struct NodeInfo {
+        /**
+         * Name of this node.
+         *
+         * `name` can be supplied to `IOmx::allocateNode` of a
+         * corresponding `IOmx` instance to create the node.
+         */
+        string name;
+        /**
+         * Name of the `IOmx` instance that can create this node.
+         *
+         * To obtain the `IOmx` instance, call `getOmx(owner)`.
+         */
+        string owner;
+        /**
+         * List of node attributes.
+         */
+        vec<NodeAttribute> attributes;
+    };
+
+    /**
+     * Information about nodes provided for a supported node role
+     */
+    struct RoleInfo {
+        /**
+         * Standard OMX node role.
+         */
+        string role;
+        /**
+         * Corresponding media type (as defined in MediaFormat.MIMETYPE_*
+         * constants for types required by Android).
+         */
+        string type;
+        /**
+         * Whether this role is for an encoder or a decoder.
+         */
+        bool isEncoder;
+        /**
+         * Whether to prefer platform nodes for this role.
+         */
+        bool preferPlatformNodes;
+        /**
+         * List of nodes that support this role, ordered by preference.
+         */
+        vec<NodeInfo> nodes;
+    };
+
+    /**
+     * Return the prefix of names of supported nodes.
+     *
+     * @return prefix The prefix of the names of all nodes supported by this
+     *                service.
+     */
+    getNodePrefix(
+        ) generates (
+            string prefix
+        );
+
+    /**
+     * List roles of supported nodes.
+     *
+     * The name of each node inside `NodeInfo` must start with the prefix
+     * returned by `getNodePrefix()`.
+     *
+     * @return roleList The list of `RoleInfo`s.
+     *
+     * @see RoleInfo
+     */
+    listRoles(
+        ) generates (
+            vec<RoleInfo> roleList
+        );
+
+    /**
+     * Obtain an `IOmx` instance with a specified name.
+     *
+     * @param name The name of the instance.
+     * @return omx The `IOmx` interface associated with `name`. This must be
+     * null if the name is not found.
+     */
+    getOmx(
+            string name
+        ) generates (
+            IOmx omx
+        );
+
+};
+
diff --git a/media/omx/1.0/types.hal b/media/omx/1.0/types.hal
index 5413344..76a6007 100644
--- a/media/omx/1.0/types.hal
+++ b/media/omx/1.0/types.hal
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * 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.
@@ -35,6 +35,7 @@
     NAME_NOT_FOUND          = -2,
     WOULD_BLOCK             = -11,
     NO_MEMORY               = -12,
+    ALREADY_EXISTS          = -17,
     NO_INIT                 = -19,
     BAD_VALUE               = -22,
     DEAD_OBJECT             = -32,
diff --git a/power/1.0/default/Power.cpp b/power/1.0/default/Power.cpp
index 6ea9167..51f87f5 100644
--- a/power/1.0/default/Power.cpp
+++ b/power/1.0/default/Power.cpp
@@ -145,25 +145,27 @@
 }
 
 IPower* HIDL_FETCH_IPower(const char* /* name */) {
-    int ret = 0;
-    const hw_module_t* hw_module = NULL;
-    power_module_t *power_module;
-    ret = hw_get_module(POWER_HARDWARE_MODULE_ID, &hw_module);
-    if (ret == 0 && hw_module->methods->open) {
-        ret = hw_module->methods->open(hw_module, POWER_HARDWARE_MODULE_ID,
-                reinterpret_cast<hw_device_t**>(&power_module));
-        if (ret == 0) {
-            return new Power(power_module);
-        }
-        else {
-            ALOGE("Passthrough failed to load legacy power HAL.");
+    const hw_module_t* hw_module = nullptr;
+    power_module_t* power_module = nullptr;
+    int err = hw_get_module(POWER_HARDWARE_MODULE_ID, &hw_module);
+    if (err) {
+        ALOGE("hw_get_module %s failed: %d", POWER_HARDWARE_MODULE_ID, err);
+        return nullptr;
+    }
+
+    if (!hw_module->methods || !hw_module->methods->open) {
+        power_module = reinterpret_cast<power_module_t*>(
+            const_cast<hw_module_t*>(hw_module));
+    } else {
+        err = hw_module->methods->open(
+            hw_module, POWER_HARDWARE_MODULE_ID,
+            reinterpret_cast<hw_device_t**>(&power_module));
+        if (err) {
+            ALOGE("Passthrough failed to load legacy HAL.");
             return nullptr;
         }
     }
-    else {
-        ALOGE ("hw_get_module %s failed: %d", POWER_HARDWARE_MODULE_ID, ret);
-        return nullptr;
-    }
+    return new Power(power_module);
 }
 
 } // namespace implementation
diff --git a/radio/1.0/IRadio.hal b/radio/1.0/IRadio.hal
index 2976290..236dbf5 100644
--- a/radio/1.0/IRadio.hal
+++ b/radio/1.0/IRadio.hal
@@ -1285,10 +1285,11 @@
      *
      * @param serial Serial number of request.
      * @param aid AID value, See ETSI 102.221 and 101.220.
+     * @param p2 P2 value, described in ISO 7816-4. Ignore if equal to P2Constant:NO_P2
      *
      * Response callback is IRadioResponse.iccOpenLogicalChannelResponse()
      */
-    oneway iccOpenLogicalChannel(int32_t serial, string aid);
+    oneway iccOpenLogicalChannel(int32_t serial, string aid, int32_t p2);
 
     /**
      * Close a previously opened logical channel. This command reflects TS 27.007
diff --git a/radio/1.0/types.hal b/radio/1.0/types.hal
index 2224c8b..c5d7f8a 100644
--- a/radio/1.0/types.hal
+++ b/radio/1.0/types.hal
@@ -1161,6 +1161,10 @@
                                           // this doesn't mean no data is expected.
 };
 
+enum P2Constant : int32_t {
+    NO_P2 = -1,                           // No P2 value is provided
+};
+
 struct RadioResponseInfo {
     RadioResponseType type;               // Response type
     int32_t serial;                       // Serial number of the request
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
index 19738d5..b759c48 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
@@ -246,12 +246,15 @@
  */
 TEST_F(RadioHidlTest, iccOpenLogicalChannel) {
   int serial = 1;
-
+  int p2 = 0x04;
+  // Specified in ISO 7816-4 clause 7.1.1 0x04 means that FCP template is
+  // requested.
   for (int i = 0; i < (int)cardStatus.applications.size(); i++) {
-    radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr);
-    EXPECT_EQ(std::cv_status::no_timeout, wait());
-    EXPECT_EQ(serial, radioRsp->rspInfo.serial);
-    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+      radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr,
+                                   p2);
+      EXPECT_EQ(std::cv_status::no_timeout, wait());
+      EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+      EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
   }
 }
 
@@ -317,4 +320,4 @@
   if (cardStatus.cardState == CardState::ABSENT) {
     ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::PASSWORD_INCORRECT);
   }
-}
\ No newline at end of file
+}
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
index 9094f39..d40f15a 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp
@@ -18,7 +18,7 @@
 
 void RadioHidlTest::SetUp() {
   radio = ::testing::VtsHalHidlTargetTestBase::getService<IRadio>(
-      hidl_string("rild"));
+      hidl_string(RADIO_SERVICE_NAME));
   ASSERT_NE(radio, nullptr);
 
   radioRsp = new RadioResponse(*this);
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils.h b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
index 6826238..51db87b 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/radio_hidl_hal_utils.h
@@ -81,6 +81,7 @@
 using ::android::sp;
 
 #define TIMEOUT_PERIOD 40
+#define RADIO_SERVICE_NAME "slot1"
 
 class RadioHidlTest;
 extern CardStatus cardStatus;
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_test.cpp b/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
index 88274cd..02accef 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
+++ b/radio/1.0/vts/functional/sap_hidl_hal_test.cpp
@@ -18,7 +18,7 @@
 
 void SapHidlTest::SetUp() {
   sap = ::testing::VtsHalHidlTargetTestBase::getService<ISap>(
-      hidl_string("sap_uim_socket1"));
+      hidl_string(SAP_SERVICE_NAME));
   ASSERT_NE(sap, nullptr);
 
   sapCb = new SapCallback(*this);
diff --git a/radio/1.0/vts/functional/sap_hidl_hal_utils.h b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
index 2ee3c96..38fb003 100644
--- a/radio/1.0/vts/functional/sap_hidl_hal_utils.h
+++ b/radio/1.0/vts/functional/sap_hidl_hal_utils.h
@@ -34,6 +34,7 @@
 using ::android::sp;
 
 #define TIMEOUT_PERIOD 40
+#define SAP_SERVICE_NAME "slot1"
 
 class SapHidlTest;
 
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/soundtrigger/2.0/types.hal b/soundtrigger/2.0/types.hal
index fc7d019..99bbd56 100644
--- a/soundtrigger/2.0/types.hal
+++ b/soundtrigger/2.0/types.hal
@@ -75,8 +75,3 @@
     vec<ConfidenceLevel> levels;
 };
 
-/** TODO(elaurent) remove when Java build problem is fixed */
-union Dummy {
-  uint32_t dummy1;
-  int32_t dummy2;
-};
diff --git a/tests/foo/1.0/default/lib/Android.bp b/tests/foo/1.0/default/lib/Android.bp
index 895582c..b512311 100644
--- a/tests/foo/1.0/default/lib/Android.bp
+++ b/tests/foo/1.0/default/lib/Android.bp
@@ -1,5 +1,6 @@
 cc_library_shared {
     name: "libfootest",
+    vendor: true,
     defaults: ["hidl_defaults"],
     srcs: [
         "FooHelper.cpp"
diff --git a/tests/pointer/1.0/default/lib/Android.bp b/tests/pointer/1.0/default/lib/Android.bp
index ae07b04..1fe0896 100644
--- a/tests/pointer/1.0/default/lib/Android.bp
+++ b/tests/pointer/1.0/default/lib/Android.bp
@@ -1,5 +1,6 @@
 cc_library_shared {
     name: "libpointertest",
+    vendor: true,
     defaults: ["hidl_defaults"],
     srcs: [
         "PointerHelper.cpp"
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_call_util.h b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_call_util.h
new file mode 100644
index 0000000..1c0fcec
--- /dev/null
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_call_util.h
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+
+// This file is copied from
+// hardware/interfaces/wifi/1.0/vts/functional/wifi_hidl_call_util.h
+// Please make sure these two file are consistent.
+
+#pragma once
+
+#include <functional>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+namespace {
+namespace detail {
+template <typename>
+struct functionArgSaver;
+
+// Provides a std::function that takes one argument, and a buffer
+// wherein the function will store its argument. The buffer has
+// the same type as the argument, but with const and reference
+// modifiers removed.
+template <typename ArgT>
+struct functionArgSaver<std::function<void(ArgT)>> final {
+    using StorageT = typename std::remove_const<
+        typename std::remove_reference<ArgT>::type>::type;
+
+    std::function<void(ArgT)> saveArgs = [this](ArgT arg) {
+        this->saved_values = arg;
+    };
+
+    StorageT saved_values;
+};
+
+// Provides a std::function that takes two arguments, and a buffer
+// wherein the function will store its arguments. The buffer is a
+// std::pair, whose elements have the same types as the arguments
+// (but with const and reference modifiers removed).
+template <typename Arg1T, typename Arg2T>
+struct functionArgSaver<std::function<void(Arg1T, Arg2T)>> final {
+    using StorageT =
+        std::pair<typename std::remove_const<
+                      typename std::remove_reference<Arg1T>::type>::type,
+                  typename std::remove_const<
+                      typename std::remove_reference<Arg2T>::type>::type>;
+
+    std::function<void(Arg1T, Arg2T)> saveArgs = [this](Arg1T arg1,
+                                                        Arg2T arg2) {
+        this->saved_values = {arg1, arg2};
+    };
+
+    StorageT saved_values;
+};
+
+// Provides a std::function that takes three or more arguments, and a
+// buffer wherein the function will store its arguments. The buffer is a
+// std::tuple whose elements have the same types as the arguments (but
+// with const and reference modifiers removed).
+template <typename... ArgT>
+struct functionArgSaver<std::function<void(ArgT...)>> final {
+    using StorageT = std::tuple<typename std::remove_const<
+        typename std::remove_reference<ArgT>::type>::type...>;
+
+    std::function<void(ArgT...)> saveArgs = [this](ArgT... arg) {
+        this->saved_values = {arg...};
+    };
+
+    StorageT saved_values;
+};
+
+// Invokes |method| on |object|, providing |method| a CallbackT as the
+// final argument. Returns a copy of the parameters that |method| provided
+// to CallbackT. (The parameters are returned by value.)
+template <typename CallbackT, typename MethodT, typename ObjectT,
+          typename... ArgT>
+typename functionArgSaver<CallbackT>::StorageT invokeMethod(
+    MethodT method, ObjectT object, ArgT&&... methodArg) {
+    functionArgSaver<CallbackT> result_buffer;
+    const auto& res = ((*object).*method)(std::forward<ArgT>(methodArg)...,
+                                          result_buffer.saveArgs);
+    EXPECT_TRUE(res.isOk());
+    return result_buffer.saved_values;
+}
+}  // namespace detail
+}  // namespace
+
+// Invokes |method| on |strong_pointer|, passing provided arguments through to
+// |method|.
+//
+// Returns either:
+// - A copy of the result callback parameter (for callbacks with a single
+//   parameter), OR
+// - A pair containing a copy of the result callback parameters (for callbacks
+//   with two parameters), OR
+// - A tuple containing a copy of the result callback paramters (for callbacks
+//   with three or more parameters).
+//
+// Example usage:
+//   EXPECT_EQ(WifiStatusCode::SUCCESS,
+//       HIDL_INVOKE(strong_pointer, methodReturningWifiStatus).code);
+//   EXPECT_EQ(WifiStatusCode::SUCCESS,
+//       HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndOneMore)
+//         .first.code);
+//   EXPECT_EQ(WifiStatusCode::SUCCESS, std::get<0>(
+//       HIDL_INVOKE(strong_pointer, methodReturningWifiStatusAndTwoMore))
+//         .code);
+#define HIDL_INVOKE(strong_pointer, method, ...)                              \
+    (detail::invokeMethod<                                                    \
+        std::remove_reference<decltype(*strong_pointer)>::type::method##_cb>( \
+        &std::remove_reference<decltype(*strong_pointer)>::type::method,      \
+        strong_pointer, ##__VA_ARGS__))
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
index 72a3c42..5a210d6 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp
@@ -20,6 +20,7 @@
 
 #include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h>
 
+#include "supplicant_hidl_call_util.h"
 #include "supplicant_hidl_test_utils.h"
 
 using ::android::sp;
@@ -28,6 +29,7 @@
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface;
 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIfaceCallback;
 using ::android::hardware::wifi::supplicant::V1_0::SupplicantNetworkId;
@@ -42,6 +44,7 @@
 constexpr char kTestGroupIfName[] = "TestGroup";
 constexpr uint32_t kTestConnectGoIntent = 6;
 constexpr uint32_t kTestFindTimeout = 5;
+constexpr uint32_t kTestSetGroupIdleTimeout = 6;
 constexpr SupplicantNetworkId kTestNetworkId = 5;
 constexpr uint32_t kTestChannel = 1;
 constexpr uint32_t kTestOperatingClass = 81;
@@ -178,6 +181,26 @@
 }
 
 /*
+ * GetName
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, GetName) {
+    const auto& status_and_interface_name = HIDL_INVOKE(p2p_iface_, getName);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              status_and_interface_name.first.code);
+    EXPECT_FALSE(std::string(status_and_interface_name.second).empty());
+}
+
+/*
+ * GetType
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, GetType) {
+    const auto& status_and_interface_type = HIDL_INVOKE(p2p_iface_, getType);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              status_and_interface_type.first.code);
+    EXPECT_EQ(status_and_interface_type.second, IfaceType::P2P);
+}
+
+/*
  * GetDeviceAddress
  */
 TEST_F(SupplicantP2pIfaceHidlTest, GetDeviceAddress) {
@@ -219,10 +242,6 @@
     p2p_iface_->stopFind([](const SupplicantStatus& status) {
         EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
     });
-
-    p2p_iface_->stopFind([](const SupplicantStatus& status) {
-        EXPECT_NE(SupplicantStatusCode::SUCCESS, status.code);
-    });
 }
 
 /*
@@ -411,3 +430,28 @@
                                               status.code);
                                 });
 }
+
+/*
+ * SetGroupIdle
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetGroupIdle) {
+    // This is not going to work with fake values.
+    EXPECT_NE(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(p2p_iface_, setGroupIdle, kTestGroupIfName,
+                          kTestSetGroupIdleTimeout)
+                  .code);
+}
+
+/*
+ * SetPowerSave
+ */
+TEST_F(SupplicantP2pIfaceHidlTest, SetPowerSave) {
+    // This is not going to work with fake values.
+    EXPECT_NE(
+        SupplicantStatusCode::SUCCESS,
+        HIDL_INVOKE(p2p_iface_, setPowerSave, kTestGroupIfName, true).code);
+    // This is not going to work with fake values.
+    EXPECT_NE(
+        SupplicantStatusCode::SUCCESS,
+        HIDL_INVOKE(p2p_iface_, setPowerSave, kTestGroupIfName, false).code);
+}
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
index 5abf4e0..3670321 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_iface_hidl_test.cpp
@@ -20,6 +20,7 @@
 
 #include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
 
+#include "supplicant_hidl_call_util.h"
 #include "supplicant_hidl_test_utils.h"
 
 using ::android::sp;
@@ -28,6 +29,7 @@
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIfaceCallback;
 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
@@ -163,6 +165,26 @@
 }
 
 /*
+ * GetName
+ */
+TEST_F(SupplicantStaIfaceHidlTest, GetName) {
+    const auto& status_and_interface_name = HIDL_INVOKE(sta_iface_, getName);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              status_and_interface_name.first.code);
+    EXPECT_FALSE(std::string(status_and_interface_name.second).empty());
+}
+
+/*
+ * GetType
+ */
+TEST_F(SupplicantStaIfaceHidlTest, GetType) {
+    const auto& status_and_interface_type = HIDL_INVOKE(sta_iface_, getType);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              status_and_interface_type.first.code);
+    EXPECT_EQ(status_and_interface_type.second, IfaceType::STA);
+}
+
+/*
  * listNetworks.
  */
 TEST_F(SupplicantStaIfaceHidlTest, listNetworks) {
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
index aa84e9a..832dd41 100644
--- a/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
+++ b/wifi/supplicant/1.0/vts/functional/supplicant_sta_network_hidl_test.cpp
@@ -22,6 +22,7 @@
 
 #include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
 
+#include "supplicant_hidl_call_util.h"
 #include "supplicant_hidl_test_utils.h"
 
 using ::android::sp;
@@ -30,6 +31,7 @@
 using ::android::hardware::hidl_vec;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
+using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface;
 using ::android::hardware::wifi::supplicant::V1_0::ISupplicantStaNetwork;
 using ::android::hardware::wifi::supplicant::V1_0::
@@ -39,7 +41,7 @@
 
 namespace {
 constexpr char kTestSsidStr[] = "TestSsid1234";
-constexpr char kTestPsk[] = "TestPsk123";
+constexpr char kTestPskPassphrase[] = "TestPsk123";
 constexpr char kTestIdStr[] = "TestIdstr";
 constexpr char kTestEapPasswdStr[] = "TestEapPasswd1234";
 constexpr char kTestEapCert[] = "keystore://CERT";
@@ -54,7 +56,10 @@
 constexpr uint8_t kTestIk[] = {[0 ... 15] = 0x65};
 constexpr uint8_t kTestCk[] = {[0 ... 15] = 0x45};
 constexpr uint8_t kTestIdentity[] = {0x45, 0x67, 0x98, 0x67, 0x56};
+constexpr uint8_t kTestPsk[] = {[0 ... 31] = 0x12};
+constexpr uint8_t kTestAutParam[] = {[0 ... 13] = 0xe1};
 constexpr uint32_t kTestWepTxKeyIdx = 2;
+constexpr uint32_t kTestUpdateIdentifier = 21;
 constexpr uint32_t kTestKeyMgmt = (ISupplicantStaNetwork::KeyMgmtMask::WPA_PSK |
                                    ISupplicantStaNetwork::KeyMgmtMask::WPA_EAP);
 constexpr uint32_t kTestProto = (ISupplicantStaNetwork::ProtoMask::OSEN |
@@ -137,6 +142,27 @@
         });
 }
 
+/*
+ * GetInterfaceName
+ */
+TEST_F(SupplicantStaNetworkHidlTest, GetInterfaceName) {
+    const auto& status_and_interface_name =
+        HIDL_INVOKE(sta_network_, getInterfaceName);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              status_and_interface_name.first.code);
+    EXPECT_FALSE(std::string(status_and_interface_name.second).empty());
+}
+
+/*
+ * GetType
+ */
+TEST_F(SupplicantStaNetworkHidlTest, GetType) {
+    const auto& status_and_interface_type = HIDL_INVOKE(sta_network_, getType);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              status_and_interface_type.first.code);
+    EXPECT_EQ(status_and_interface_type.second, IfaceType::STA);
+}
+
 /* Tests out the various setter/getter methods. */
 /*
  * SetGetSsid
@@ -246,17 +272,29 @@
  */
 TEST_F(SupplicantStaNetworkHidlTest, SetGetPskPassphrase) {
     sta_network_->setPskPassphrase(
-        kTestPsk, [](const SupplicantStatus& status) {
+        kTestPskPassphrase, [](const SupplicantStatus& status) {
             EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
         });
     sta_network_->getPskPassphrase(
         [&](const SupplicantStatus& status, const hidl_string& psk) {
             EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
-            EXPECT_EQ(kTestPsk, std::string(psk.c_str()));
+            EXPECT_EQ(kTestPskPassphrase, std::string(psk.c_str()));
         });
 }
 
 /*
+ * SetGetPsk
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetPsk) {
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, setPsk, kTestPsk).code);
+    const auto& status_and_psk = HIDL_INVOKE(sta_network_, getPsk);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS, status_and_psk.first.code);
+    hidl_array<uint8_t, 32> expected_psk(kTestPsk);
+    EXPECT_EQ(expected_psk, status_and_psk.second);
+}
+
+/*
  * SetGetWepKeys
  */
 TEST_F(SupplicantStaNetworkHidlTest, SetGetWepTxKeyIdx) {
@@ -361,6 +399,12 @@
  * SetGetEapPhase2Method
  */
 TEST_F(SupplicantStaNetworkHidlTest, SetGetEapPhase2Method) {
+    ISupplicantStaNetwork::EapMethod set_eap_method =
+        ISupplicantStaNetwork::EapMethod::PEAP;
+    sta_network_->setEapMethod(
+        set_eap_method, [](const SupplicantStatus& status) {
+            EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
+        });
     ISupplicantStaNetwork::EapPhase2Method set_eap_phase2_method =
         ISupplicantStaNetwork::EapPhase2Method::NONE;
     sta_network_->setEapPhase2Method(
@@ -500,6 +544,21 @@
 }
 
 /*
+ * SetGetEapSubjectMatch
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetGetEapSubjectMatch) {
+    EXPECT_EQ(
+        SupplicantStatusCode::SUCCESS,
+        HIDL_INVOKE(sta_network_, setEapSubjectMatch, kTestEapMatch).code);
+    const auto& status_and_subject_match =
+        HIDL_INVOKE(sta_network_, getEapSubjectMatch);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              status_and_subject_match.first.code);
+    EXPECT_EQ(kTestEapMatch,
+              std::string(status_and_subject_match.second.c_str()));
+}
+
+/*
  * SetGetEapDomainSuffixMatch
  */
 TEST_F(SupplicantStaNetworkHidlTest, SetGetEapDomainSuffixMatch) {
@@ -634,6 +693,14 @@
 }
 
 /*
+ * SendNetworkEapSimGsmAuthFailure
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimGsmAuthFailure) {
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, sendNetworkEapSimGsmAuthFailure).code);
+}
+
+/*
  * SendNetworkEapSimUmtsAuthResponse
  */
 TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimUmtsAuthResponse) {
@@ -648,6 +715,24 @@
 }
 
 /*
+ * SendNetworkEapSimUmtsAuthFailure
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimUmtsAuthFailure) {
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, sendNetworkEapSimUmtsAuthFailure).code);
+}
+
+/*
+ * SendNetworkEapSimUmtsAutsResponse
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapSimUmtsAutsResponse) {
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, sendNetworkEapSimUmtsAutsResponse,
+                          kTestAutParam)
+                  .code);
+}
+
+/*
  * SendNetworkEapIdentityResponse
  */
 TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapIdentityResponse) {
@@ -658,3 +743,40 @@
             EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
         });
 }
+
+/*
+ * SetUpdateIdentifier
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetUpdateIdentifier) {
+    EXPECT_EQ(
+        SupplicantStatusCode::SUCCESS,
+        HIDL_INVOKE(sta_network_, setUpdateIdentifier, kTestUpdateIdentifier)
+            .code);
+}
+
+/*
+ * SetProactiveKeyCaching
+ */
+TEST_F(SupplicantStaNetworkHidlTest, SetProactiveKeyCaching) {
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, setProactiveKeyCaching, true).code);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, setProactiveKeyCaching, false).code);
+}
+
+/*
+ * GetWpsNfcConfigurationToken
+ */
+TEST_F(SupplicantStaNetworkHidlTest, GetWpsNfcConfigurationToken) {
+    ASSERT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, setSsid, ssid_).code);
+    ASSERT_EQ(SupplicantStatusCode::SUCCESS,
+              HIDL_INVOKE(sta_network_, setKeyMgmt, kTestKeyMgmt).code);
+    ASSERT_EQ(
+        SupplicantStatusCode::SUCCESS,
+        HIDL_INVOKE(sta_network_, setPskPassphrase, kTestPskPassphrase).code);
+    const auto& status_and_token =
+        HIDL_INVOKE(sta_network_, getWpsNfcConfigurationToken);
+    EXPECT_EQ(SupplicantStatusCode::SUCCESS, status_and_token.first.code);
+    EXPECT_FALSE(0 == status_and_token.second.size());
+}