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 {
}
private void doLoop() {
try {
while (true) {
boolean wasInterrupted = false;
while (true) {
try {
PendingMessage pendingMessage = pendingMessages.take();
if (pendingMessage.message == null) {
// Null message is signal to end message loop.
......@@ -118,6 +119,11 @@ public final class RobolectricUtil {
}
if (!isRemoved) {
try {
if (wasInterrupted) {
wasInterrupted = false;
// Restore the interrupt status flag, so long-running messages will exit early.
Thread.currentThread().interrupt();
}
target.dispatchMessage(pendingMessage.message);
} catch (Throwable t) {
// Interrupt the main thread to terminate the test. Robolectric's HandlerThread will
......@@ -132,9 +138,9 @@ public final class RobolectricUtil {
} else {
callInstanceMethod(pendingMessage.message, "recycle");
}
} catch (InterruptedException e) {
wasInterrupted = true;
}
} catch (InterruptedException e) {
// Ignore.
}
}
}
......
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