Remove ThreadUtils.waitUninterruptibly.

This method is an anti-pattern. Removes usage of the method from
CameraCapturer and deletes it.

Bug: webrtc:8456
Change-Id: I8a70ce968af412fa6e6b9308a9e05d6a8a1ba05d
Reviewed-on: https://webrtc-review.googlesource.com/46140
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21808}
diff --git a/rtc_base/java/src/org/webrtc/ThreadUtils.java b/rtc_base/java/src/org/webrtc/ThreadUtils.java
index f7c7b81..3cc80d3 100644
--- a/rtc_base/java/src/org/webrtc/ThreadUtils.java
+++ b/rtc_base/java/src/org/webrtc/ThreadUtils.java
@@ -143,17 +143,6 @@
     return result;
   }
 
-  // TODO(sakal): This method is broken. It should be removed: crbug.com/webrtc/8456
-  @SuppressWarnings("WaitNotInLoop")
-  public static void waitUninterruptibly(final Object object) {
-    executeUninterruptibly(new BlockingOperation() {
-      @Override
-      public void run() throws InterruptedException {
-        object.wait();
-      }
-    });
-  }
-
   /**
    * Post |callable| to |handler| and wait for the result.
    */
diff --git a/sdk/android/src/java/org/webrtc/CameraCapturer.java b/sdk/android/src/java/org/webrtc/CameraCapturer.java
index 3b442fb1..20596be 100644
--- a/sdk/android/src/java/org/webrtc/CameraCapturer.java
+++ b/sdk/android/src/java/org/webrtc/CameraCapturer.java
@@ -350,7 +350,13 @@
     synchronized (stateLock) {
       while (sessionOpening) {
         Logging.d(TAG, "Stop capture: Waiting for session to open");
-        ThreadUtils.waitUninterruptibly(stateLock);
+        try {
+          stateLock.wait();
+        } catch (InterruptedException e) {
+          Logging.w(TAG, "Stop capture interrupted while waiting for the session to open.");
+          Thread.currentThread().interrupt();
+          return;
+        }
       }
 
       if (currentSession != null) {