stagefright: use uniqueId to detect same surface for setSurface

Bug: 29422927
Change-Id: I8b0105f87ca7e8ee745c60ab726b1dffbbd4aa87
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 1cbcaa9..ff5c4d4 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -2682,9 +2682,12 @@
 status_t MediaCodec::connectToSurface(const sp<Surface> &surface) {
     status_t err = OK;
     if (surface != NULL) {
+        uint64_t oldId, newId;
         if (mSurface != NULL
-                && surface->getConsumerName() == mSurface->getConsumerName()) {
-            ALOGI("connecting to native window with same name. Assuming no change of surface");
+                && surface->getUniqueId(&newId) == NO_ERROR
+                && mSurface->getUniqueId(&oldId) == NO_ERROR
+                && newId == oldId) {
+            ALOGI("[%s] connecting to the same surface. Nothing to do.", mComponentName.c_str());
             return ALREADY_EXISTS;
         }