Commit c1acf87f by hoangtc Committed by Oliver Woodman

Support handling frame queries for MetadataRetriever.

- Support handling frame queries (i.e get frames at times, output to certain
sizes) from MetadataRetriever.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203489788
parent 2c00be1a
...@@ -93,8 +93,9 @@ public final class RobolectricUtil { ...@@ -93,8 +93,9 @@ public final class RobolectricUtil {
} }
private void doLoop() { private void doLoop() {
try { boolean wasInterrupted = false;
while (true) { while (true) {
try {
PendingMessage pendingMessage = pendingMessages.take(); PendingMessage pendingMessage = pendingMessages.take();
if (pendingMessage.message == null) { if (pendingMessage.message == null) {
// Null message is signal to end message loop. // Null message is signal to end message loop.
...@@ -118,6 +119,11 @@ public final class RobolectricUtil { ...@@ -118,6 +119,11 @@ public final class RobolectricUtil {
} }
if (!isRemoved) { if (!isRemoved) {
try { try {
if (wasInterrupted) {
wasInterrupted = false;
// Restore the interrupt status flag, so long-running messages will exit early.
Thread.currentThread().interrupt();
}
target.dispatchMessage(pendingMessage.message); target.dispatchMessage(pendingMessage.message);
} catch (Throwable t) { } catch (Throwable t) {
// Interrupt the main thread to terminate the test. Robolectric's HandlerThread will // Interrupt the main thread to terminate the test. Robolectric's HandlerThread will
...@@ -132,9 +138,9 @@ public final class RobolectricUtil { ...@@ -132,9 +138,9 @@ public final class RobolectricUtil {
} else { } else {
callInstanceMethod(pendingMessage.message, "recycle"); callInstanceMethod(pendingMessage.message, "recycle");
} }
}
} catch (InterruptedException e) { } catch (InterruptedException e) {
// Ignore. wasInterrupted = true;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment