OSDN Git Service

BufferQueue: fix a test crash
authorJamie Gennis <jgennis@google.com>
Thu, 26 Sep 2013 00:21:56 +0000 (17:21 -0700)
committerJamie Gennis <jgennis@google.com>
Wed, 2 Oct 2013 18:02:28 +0000 (18:02 +0000)
Bug: 10935880
Change-Id: If76e9fb055103bad0db7e6c16487532671573149

libs/gui/BufferQueue.cpp

index 87d66e2..c165a68 100644 (file)
@@ -668,11 +668,15 @@ status_t BufferQueue::connect(const sp<IBinder>& token,
                 mConnectedApi = api;
                 output->inflate(mDefaultWidth, mDefaultHeight, mTransformHint, mQueue.size());
 
-                // set-up a death notification so that we can disconnect automatically
-                // when/if the remote producer dies.
-                // This will fail with INVALID_OPERATION if the "token" is local to our process.
-                if (token->linkToDeath(static_cast<IBinder::DeathRecipient*>(this)) == NO_ERROR) {
-                    mConnectedProducerToken = token;
+                // set-up a death notification so that we can disconnect
+                // automatically when/if the remote producer dies.
+                if (token != NULL && token->remoteBinder() != NULL) {
+                    status_t err = token->linkToDeath(static_cast<IBinder::DeathRecipient*>(this));
+                    if (err == NO_ERROR) {
+                        mConnectedProducerToken = token;
+                    } else {
+                        ALOGE("linkToDeath failed: %s (%d)", strerror(-err), err);
+                    }
                 }
             }
             break;