Revert "Stop checking the global thread list in several trivial cases."

This reverts commit f5a4992b7186c01b98cb9400b2b5b490805a87bb.

Breaks OMX_ImgEnc in cameraserver (http://b/35088254).

Change-Id: I6dcf12706a184b0b8b72451584567a42dfa1bb4f
diff --git a/libc/bionic/pthread_setschedparam.cpp b/libc/bionic/pthread_setschedparam.cpp
index a0520fb..0ad68bb 100644
--- a/libc/bionic/pthread_setschedparam.cpp
+++ b/libc/bionic/pthread_setschedparam.cpp
@@ -34,8 +34,14 @@
 int pthread_setschedparam(pthread_t t, int policy, const sched_param* param) {
   ErrnoRestorer errno_restorer;
 
-  pid_t tid = reinterpret_cast<pthread_internal_t*>(t)->tid;
-  if (tid == 0) return ESRCH;
+  pthread_internal_t* thread = __pthread_internal_find(t);
+  if (thread == NULL) {
+    return ESRCH;
+  }
 
-  return (sched_setscheduler(tid, policy, param) == -1) ? errno : 0;
+  int rc = sched_setscheduler(thread->tid, policy, param);
+  if (rc == -1) {
+    return errno;
+  }
+  return 0;
 }