fix: requestScreenCapture() dead lock if request activity destroyed
This commit is contained in:
@@ -42,6 +42,29 @@ public class VolatileDispose<T> {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public T blockedGetOrThrow(Class<? extends RuntimeException> exception, long timeout, T defaultValue) {
|
||||
synchronized (this) {
|
||||
if (mValue != null) {
|
||||
return mValue;
|
||||
}
|
||||
try {
|
||||
this.wait(timeout);
|
||||
} catch (InterruptedException e) {
|
||||
try {
|
||||
throw exception.newInstance();
|
||||
} catch (InstantiationException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
} catch (IllegalAccessException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
if (mValue == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void setAndNotify(T value) {
|
||||
synchronized (this) {
|
||||
mValue = value;
|
||||
|
||||
Reference in New Issue
Block a user