Add initializer list to hidl_vec.

Test: libhidl_test
Change-Id: I7f25fee84feed31c3f84ca640156c0befea1d2c7
diff --git a/include/hidl/HidlSupport.h b/include/hidl/HidlSupport.h
index 1c468ed..d2a0a8a 100644
--- a/include/hidl/HidlSupport.h
+++ b/include/hidl/HidlSupport.h
@@ -125,10 +125,21 @@
     }
 
     hidl_vec(hidl_vec<T> &&other)
-	: mOwnsBuffer(false) {
+    : mOwnsBuffer(false) {
         *this = std::move(other);
     }
 
+    hidl_vec(const std::initializer_list<int> list)
+            : mSize(list.size()),
+              mOwnsBuffer(true) {
+        mBuffer = new T[mSize];
+
+        int idx = 0;
+        for (auto it = list.begin(); it != list.end(); ++it) {
+            mBuffer[idx++] = *it;
+        }
+    }
+
     hidl_vec(const std::vector<T> &other) : hidl_vec() {
         *this = other;
     }
diff --git a/test/main.cpp b/test/main.cpp
index f5b5f20..a7dc243 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -89,6 +89,10 @@
 
     vector<int32_t> v2 = hv1; // cast
     EXPECT_ARRAYEQ(v2, v, 3);
+
+    hidl_vec<int32_t> v3 = {5, 6, 7}; // initializer_list
+    EXPECT_EQ(v3.size(), 3);
+    EXPECT_ARRAYEQ(v3, array, v3.size());
 }
 
 TEST_F(LibHidlTest, TaskRunnerTest) {