Revert "Introduce safer type castings for cb_handle_t"

This reverts commit afea830df6bc04e66e9757cb1ee0842d871af76b.

Reason for revert: https://android-build.googleplex.com/builds/branch-dashboard/aosp-emu-master-dev?build_id=5900549

Change-Id: Id5aafbb46d7510ea40c681c9e394a6c1dcb31ba7
diff --git a/shared/OpenglCodecCommon/gralloc_cb.h b/shared/OpenglCodecCommon/gralloc_cb.h
index 30acf89..bff33f3 100644
--- a/shared/OpenglCodecCommon/gralloc_cb.h
+++ b/shared/OpenglCodecCommon/gralloc_cb.h
@@ -73,26 +73,6 @@
         magic = 0;
     }
 
-    static cb_handle_t* from_native_handle(native_handle* n) {
-        cb_handle_t* cb = static_cast<cb_handle_t*>(n);
-        LOG_ALWAYS_FATAL_IF(cb->magic != BUFFER_HANDLE_MAGIC, "Unexpected magic");
-        return cb;
-    }
-
-    static const cb_handle_t* from_native_handle(const native_handle* n) {
-        const cb_handle_t* cb = static_cast<const cb_handle_t*>(n);
-        LOG_ALWAYS_FATAL_IF(cb->magic != BUFFER_HANDLE_MAGIC, "Unexpected magic");
-        return cb;
-    }
-
-    static cb_handle_t* from_raw_pointer(void* ptr) {
-        return from_native_handle(static_cast<native_handle*>(ptr));
-    }
-
-    static const cb_handle_t* from_raw_pointer(const void* ptr) {
-        return from_native_handle(static_cast<const native_handle*>(ptr));
-    }
-
     void setFd(int p_fd) {
         if (p_fd >= 0) {
             numFds++;
diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp
index 9708829..f0a3c23 100644
--- a/system/OpenglSystemCommon/HostConnection.cpp
+++ b/system/OpenglSystemCommon/HostConnection.cpp
@@ -84,12 +84,12 @@
 public:
     uint32_t getHostHandle(native_handle_t const* handle)
     {
-        return cb_handle_t::from_native_handle(handle)->hostHandle;
+        return ((cb_handle_t *)handle)->hostHandle;
     }
 
     int getFormat(native_handle_t const* handle)
     {
-        return cb_handle_t::from_native_handle(handle)->format;
+        return ((cb_handle_t *)handle)->format;
     }
 };
 
diff --git a/system/hwc2/EmuHWC2.cpp b/system/hwc2/EmuHWC2.cpp
index ae6be6b..3bda1a1 100644
--- a/system/hwc2/EmuHWC2.cpp
+++ b/system/hwc2/EmuHWC2.cpp
@@ -379,8 +379,7 @@
     if (mHandle != nullptr) {
         mGralloc->unregisterBuffer(mGralloc, mHandle);
         mAllocDev->free(mAllocDev, mHandle);
-        ALOGI("free targetCb %u",
-            cb_handle_t::from_raw_pointer(mHandle)->hostHandle);
+        ALOGI("free targetCb %d", ((cb_handle_t*)(mHandle))->hostHandle);
     }
 }
 
@@ -395,9 +394,10 @@
                                &mHandle, &stride);
         assert(ret == 0 && "Fail to allocate target ColorBuffer");
         mGralloc->registerBuffer(mGralloc, mHandle);
-        ALOGI("targetCb %u", cb_handle_t::from_raw_pointer(mHandle)->hostHandle);
+        ALOGI("targetCb %d", reinterpret_cast<const cb_handle_t*>(mHandle)
+              ->hostHandle);
     }
-    return cb_handle_t::from_raw_pointer(mHandle)->hostHandle;
+    return reinterpret_cast<const cb_handle_t*>(mHandle)->hostHandle;
 }
 
 // Display functions
@@ -781,8 +781,8 @@
                     ALOGV("%s: acquire fence not set for layer %u",
                           __FUNCTION__, (uint32_t)layer->getId());
                 }
-                const cb_handle_t *cb =
-                    cb_handle_t::from_raw_pointer(layer->getLayerBuffer().getBuffer());
+                cb_handle_t *cb =
+                    (cb_handle_t *)layer->getLayerBuffer().getBuffer();
                 if (cb != nullptr) {
                     l->cbHandle = cb->hostHandle;
                 }
@@ -892,7 +892,8 @@
         int32_t acquireFence, int32_t /*dataspace*/, hwc_region_t /*damage*/) {
     ALOGVV("%s", __FUNCTION__);
 
-    const cb_handle_t *cb = cb_handle_t::from_raw_pointer(target);
+    cb_handle_t *cb =
+            (cb_handle_t *)target;
     ALOGV("%s: display(%u) buffer handle %p cb %d, acquireFence %d", __FUNCTION__,
           (uint32_t)mId, target, cb->hostHandle, acquireFence);
     std::unique_lock<std::mutex> lock(mStateMutex);
diff --git a/system/vulkan_enc/AndroidHardwareBuffer.cpp b/system/vulkan_enc/AndroidHardwareBuffer.cpp
index a3ebdf2..62b122a 100644
--- a/system/vulkan_enc/AndroidHardwareBuffer.cpp
+++ b/system/vulkan_enc/AndroidHardwareBuffer.cpp
@@ -109,9 +109,10 @@
         ahbFormatProps->suggestedYChromaOffset = VK_CHROMA_LOCATION_MIDPOINT;
     }
 
-    const native_handle_t *nandle =
+    const native_handle_t *handle =
        AHardwareBuffer_getNativeHandle(buffer);
-    const cb_handle_t* cb_handle = cb_handle_t::from_native_handle(nandle);
+    const cb_handle_t* cb_handle =
+        reinterpret_cast<const cb_handle_t*>(handle);
     uint32_t colorBufferHandle = cb_handle->hostHandle;
 
     if (!colorBufferHandle) {
@@ -163,9 +164,10 @@
         return VK_ERROR_INVALID_EXTERNAL_HANDLE;
     }
 
-    const native_handle_t *nandle =
+    const native_handle_t *handle =
        AHardwareBuffer_getNativeHandle(info->buffer);
-    const cb_handle_t* cb_handle = cb_handle_t::from_native_handle(nandle);
+    const cb_handle_t* cb_handle =
+        reinterpret_cast<const cb_handle_t*>(handle);
     uint32_t colorBufferHandle = cb_handle->hostHandle;
 
     if (!colorBufferHandle) {
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index 1db44cc..35a5a38 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -1835,7 +1835,8 @@
             ALOGD("%s: Import AHardwareBulffer", __func__);
             const native_handle_t *handle =
                 AHardwareBuffer_getNativeHandle(ahw);
-            const cb_handle_t* cb_handle = cb_handle_t::from_native_handle(handle);
+            const cb_handle_t* cb_handle =
+                reinterpret_cast<const cb_handle_t*>(handle);
             importCbInfo.colorBuffer = cb_handle->hostHandle;
             vk_append_struct(&structChainIter, &importCbInfo);
         }
@@ -3463,7 +3464,7 @@
         }
 
         const cb_handle_t* cb_handle =
-            cb_handle_t::from_raw_pointer(nativeInfo->handle);
+            reinterpret_cast<const cb_handle_t*>(nativeInfo->handle);
 
         if (!cb_handle) return;