Merge "Test importing EC P-256 keys with multiple encodings"
diff --git a/current.txt b/current.txt
index 1108beb..96c1bbf 100644
--- a/current.txt
+++ b/current.txt
@@ -505,7 +505,7 @@
 21aa259585caaa27b6470ebcd8509aabde0ef5d039160aa6425d589cb787488b android.hardware.media.c2@1.0::IInputSink
 b9422a9aca84df1ff9623dc12c0562abce97716e28d63a965f2bfb88f9ad9607 android.hardware.media.c2@1.0::IInputSurface
 0a786a19e6753f9774a7ca7781c2a2edfe5c0b5fa112355dfa0e50ebedeb08b9 android.hardware.media.c2@1.0::IInputSurfaceConnection
-4cb139f729c29d8d6f4ecdab149c4feb571dad8a06e56cd57fcb52e70208bab4 android.hardware.media.c2@1.0::types
+7d3c292ca75ec3e22a8fd4ae72d2edb0659d280257e763786e766f3429954dd1 android.hardware.media.c2@1.0::types
 4880af120fc1640225abdc2c60bda6d79617d73484d5124913c7278af3b11e2d android.hardware.neuralnetworks@1.2::IBurstCallback
 19877e466ad8c6ed42b38050b77bd010cf7800ff365fdc8574f45bbfda03a758 android.hardware.neuralnetworks@1.2::IBurstContext
 b83317b66721241887d2770b5ae95fd5af1e77c5daa7530ecb08fae8892f2b43 android.hardware.neuralnetworks@1.2::IDevice
diff --git a/keymaster/4.0/support/keymaster_utils.cpp b/keymaster/4.0/support/keymaster_utils.cpp
index 729e1c1..e35fdd3 100644
--- a/keymaster/4.0/support/keymaster_utils.cpp
+++ b/keymaster/4.0/support/keymaster_utils.cpp
@@ -21,7 +21,9 @@
 namespace hardware {
 
 inline static bool operator<(const hidl_vec<uint8_t>& a, const hidl_vec<uint8_t>& b) {
-    return memcmp(a.data(), b.data(), std::min(a.size(), b.size())) == -1;
+    auto result = memcmp(a.data(), b.data(), std::min(a.size(), b.size()));
+    if (!result) return a.size() < b.size();
+    return result < 0;
 }
 
 template <size_t SIZE>
diff --git a/media/c2/1.0/Android.bp b/media/c2/1.0/Android.bp
index 7307a81..895e9db 100644
--- a/media/c2/1.0/Android.bp
+++ b/media/c2/1.0/Android.bp
@@ -27,6 +27,7 @@
         "android.hardware.media.omx@1.0",
         "android.hardware.media@1.0",
         "android.hidl.base@1.0",
+        "android.hidl.safe_union@1.0",
     ],
     gen_java: false,
 }
diff --git a/media/c2/1.0/types.hal b/media/c2/1.0/types.hal
index ec422b1..f4f6f2f 100644
--- a/media/c2/1.0/types.hal
+++ b/media/c2/1.0/types.hal
@@ -17,6 +17,7 @@
 package android.hardware.media.c2@1.0;
 
 import android.hardware.media.bufferpool@2.0::BufferStatusMessage;
+import android.hidl.safe_union@1.0::Monostate;
 
 /**
  * Common return values for Codec2 operations.
@@ -190,89 +191,68 @@
  */
 typedef uint64_t PrimitiveValue;
 
+/**
+ * Description of a set of values.
+ *
+ * If the `step` member is 0, and `num` and `denom` are both 1, the `Range`
+ * structure represents a closed interval bounded by `min` and `max`.
+ *
+ * Otherwise, the #ValueRange structure represents a finite sequence of numbers
+ * produced from the following recurrence relation:
+ *
+ * @code
+ * v[0] = min
+ * v[i] = v[i - 1] * num / denom + step ; i >= 1
+ * @endcode
+ *
+ * Both the ratio `num / denom` and the value `step` must be positive. The
+ * last number in the sequence described by this #Range structure is the
+ * largest number in the sequence that is smaller than or equal to `max`.
+ *
+ * @note
+ * The division in the formula may truncate the result if the data type of
+ * these values is an integral type.
+ */
+struct ValueRange {
+    /**
+     * Lower end of the range (inclusive).
+     */
+    PrimitiveValue min;
+    /**
+     * Upper end of the range (inclusive).
+     */
+    PrimitiveValue max;
+    /**
+     * The non-homogeneous term in the recurrence relation.
+     */
+    PrimitiveValue step;
+    /**
+     * The numerator of the scale coefficient in the recurrence relation.
+     */
+    PrimitiveValue num;
+    /**
+     * The denominator of the scale coefficient in the recurrence relation.
+     */
+    PrimitiveValue denom;
+};
+
 /*
  * Description of supported values for a field.
  *
  * This can be a continuous range or a discrete set of values.
+ *
+ * The intended type of values must be made clear in the context where
+ * `FieldSupportedValues` is used.
  */
-struct FieldSupportedValues {
-    /**
-     * Used if #type is `RANGE`.
-     *
-     * If the `step` member is 0, and `num` and `denom` are both 1, the `Range`
-     * structure represents a closed interval bounded by `min` and `max`.
-     *
-     * Otherwise, the #Range structure represents a finite sequence of numbers
-     * produced from the following recurrence relation:
-     *
-     * @code
-     * v[0] = min
-     * v[i] = v[i - 1] * num / denom + step ; i >= 1
-     * @endcode
-     *
-     * Both the ratio `num / denom` and the value `step` must be positive. The
-     * last number in the sequence described by this #Range structure is the
-     * largest number in the sequence that is smaller than or equal to `max`.
-     *
-     * @note
-     * The division in the formula may truncate the result if the data type of
-     * these values is an integral type.
-     */
-    struct Range {
-        /**
-         * Lower end of the range (inclusive).
-         */
-        PrimitiveValue min;
-        /**
-         * Upper end of the range (inclusive).
-         */
-        PrimitiveValue max;
-        /**
-         * The non-homogeneous term in the recurrence relation.
-         */
-        PrimitiveValue step;
-        /**
-         * The numerator of the scale coefficient in the recurrence relation.
-         */
-        PrimitiveValue num;
-        /**
-         * The denominator of the scale coefficient in the recurrence relation.
-         */
-        PrimitiveValue denom;
-    };
-
-    enum Type : int32_t {
-        /** No supported values */
-        EMPTY = 0,
-        /** Numeric range, described in a #Range structure */
-        RANGE,
-        /** List of values */
-        VALUES,
-        /** List of flags that can be OR-ed */
-        FLAGS,
-    };
-    /**
-     * Type of the supported values.
-     */
-    Type type;
-
-    /**
-     * When #type is #Type.RANGE, #range shall specify the range of possible
-     * values.
-     *
-     * The intended type of members of #range shall be clear in the context
-     * where `FieldSupportedValues` is used.
-     */
-    Range range;
-
-    /**
-     * When #type is #Type.VALUES or #Type.FLAGS, #value shall list supported
-     * values/flags.
-     *
-     * The intended type of components of #value shall be clear in the context
-     * where `FieldSupportedValues` is used.
-     */
+safe_union FieldSupportedValues {
+    /** No supported values */
+    Monostate empty;
+    /** Numeric range, described in a #ValueRange structure */
+    ValueRange range;
+    /** List of values */
     vec<PrimitiveValue> values;
+    /** List of flags that can be OR-ed */
+    vec<PrimitiveValue> flags;
 };
 
 /**
diff --git a/vibrator/1.3/example/OWNERS b/vibrator/1.3/example/OWNERS
new file mode 100644
index 0000000..4b34968
--- /dev/null
+++ b/vibrator/1.3/example/OWNERS
@@ -0,0 +1,2 @@
+eliptus@google.com
+michaelwr@google.com
diff --git a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
index 72cafd1..1b7e821 100644
--- a/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
+++ b/wifi/1.0/vts/functional/wifi_chip_hidl_test.cpp
@@ -361,8 +361,8 @@
 
 /*
  * CreateApIface
- * Configures the chip in AP mode and ensures that only 1 iface creation
- * succeeds. The 2nd iface creation should be rejected.
+ * Configures the chip in AP mode and ensures that at least 1 iface creation
+ * succeeds.
  */
 TEST_F(WifiChipHidlTest, CreateApIface) {
     if (!gEnv->isSoftApOn) return;
@@ -371,8 +371,6 @@
     sp<IWifiApIface> iface;
     EXPECT_EQ(WifiStatusCode::SUCCESS, createApIface(&iface));
     EXPECT_NE(nullptr, iface.get());
-
-    EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createApIface(&iface));
 }
 
 /*
@@ -460,8 +458,8 @@
 
 /*
  * CreateNanIface
- * Configures the chip in NAN mode and ensures that only 1 iface creation
- * succeeds. The 2nd iface creation should be rejected.
+ * Configures the chip in NAN mode and ensures that at least 1 iface creation
+ * succeeds.
  */
 TEST_F(WifiChipHidlTest, CreateNanIface) {
     if (!gEnv->isNanOn) return;
@@ -470,8 +468,6 @@
     sp<IWifiNanIface> iface;
     ASSERT_EQ(WifiStatusCode::SUCCESS, createNanIface(&iface));
     EXPECT_NE(nullptr, iface.get());
-
-    EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createNanIface(&iface));
 }
 
 /*
@@ -560,8 +556,8 @@
 
 /*
  * CreateP2pIface
- * Configures the chip in P2P mode and ensures that only 1 iface creation
- * succeeds. The 2nd iface creation should be rejected.
+ * Configures the chip in P2P mode and ensures that at least 1 iface creation
+ * succeeds.
  */
 TEST_F(WifiChipHidlTest, CreateP2pIface) {
     configureChipForIfaceType(IfaceType::P2P, true);
@@ -569,8 +565,6 @@
     sp<IWifiP2pIface> iface;
     EXPECT_EQ(WifiStatusCode::SUCCESS, createP2pIface(&iface));
     EXPECT_NE(nullptr, iface.get());
-
-    EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createP2pIface(&iface));
 }
 
 /*
@@ -655,8 +649,8 @@
 
 /*
  * CreateStaIface
- * Configures the chip in STA mode and ensures that only 1 iface creation
- * succeeds. The 2nd iface creation should be rejected.
+ * Configures the chip in STA mode and ensures that at least 1 iface creation
+ * succeeds.
  */
 TEST_F(WifiChipHidlTest, CreateStaIface) {
     configureChipForIfaceType(IfaceType::STA, true);
@@ -664,8 +658,6 @@
     sp<IWifiStaIface> iface;
     EXPECT_EQ(WifiStatusCode::SUCCESS, createStaIface(&iface));
     EXPECT_NE(nullptr, iface.get());
-
-    EXPECT_EQ(WifiStatusCode::ERROR_NOT_AVAILABLE, createStaIface(&iface));
 }
 
 /*
diff --git a/wifi/1.3/default/tests/mock_wifi_legacy_hal.h b/wifi/1.3/default/tests/mock_wifi_legacy_hal.h
index deb3a5a..65fd115 100644
--- a/wifi/1.3/default/tests/mock_wifi_legacy_hal.h
+++ b/wifi/1.3/default/tests/mock_wifi_legacy_hal.h
@@ -39,6 +39,10 @@
     MOCK_METHOD2(registerRadioModeChangeCallbackHandler,
                  wifi_error(const std::string&,
                             const on_radio_mode_change_callback&));
+    MOCK_METHOD1(getFirmwareVersion, std::pair<wifi_error, std::string>(
+                 const std::string& iface_name));
+    MOCK_METHOD1(getDriverVersion, std::pair<wifi_error, std::string>(
+                 const std::string& iface_name));
     MOCK_METHOD2(nanRegisterCallbackHandlers,
                  wifi_error(const std::string&, const NanCallbackHandlers&));
     MOCK_METHOD2(nanDisableRequest,
diff --git a/wifi/1.3/default/wifi_legacy_hal.h b/wifi/1.3/default/wifi_legacy_hal.h
index 70a919f..4d6beb3 100644
--- a/wifi/1.3/default/wifi_legacy_hal.h
+++ b/wifi/1.3/default/wifi_legacy_hal.h
@@ -184,9 +184,9 @@
     // Checks if legacy HAL has successfully started
     bool isStarted();
     // Wrappers for all the functions in the legacy HAL function table.
-    std::pair<wifi_error, std::string> getDriverVersion(
+    virtual std::pair<wifi_error, std::string> getDriverVersion(
         const std::string& iface_name);
-    std::pair<wifi_error, std::string> getFirmwareVersion(
+    virtual std::pair<wifi_error, std::string> getFirmwareVersion(
         const std::string& iface_name);
     std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump(
         const std::string& iface_name);