gralloc: Additional buffer validation in getTransportSize

getTransportSize should return BAD_BUFFER for non-imported raw buffers.

Bug: 152438363
Test: run vts -m VtsHalGraphicsMapperV2_1TargetTest
Change-Id: Ife686b996220df8094216a7e55e66176fe6c3521
diff --git a/gralloc/QtiMapper.cpp b/gralloc/QtiMapper.cpp
index 8065536..ee1d36f 100644
--- a/gralloc/QtiMapper.cpp
+++ b/gralloc/QtiMapper.cpp
@@ -245,13 +245,15 @@
   auto err = Error::BAD_BUFFER;
   auto hnd = static_cast<private_handle_t *>(buffer);
   uint32_t num_fds = 0, num_ints = 0;
-  if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+  if (buffer != nullptr && private_handle_t::validate(hnd) == 0 &&
+      buf_mgr_->IsBufferImported(hnd) == Error::NONE) {
     num_fds = 2;
     // TODO(user): reduce to transported values;
     num_ints = static_cast<uint32_t >(hnd->numInts);
     err = Error::NONE;
   }
-  ALOGD_IF(DEBUG, "GetTransportSize: num fds: %d num ints: %d err:%d", num_fds, num_ints, err);
+  ALOGD_IF(DEBUG, "GetTransportSize: num fds: %d num ints: %d IsBufferImported:%d err:%d",
+                   num_fds, num_ints, buf_mgr_->IsBufferImported(hnd), err);
   hidl_cb(err, num_fds, num_ints);
   return Void();
 }