修复 captureScreen()可能造成死循环的问题

This commit is contained in:
hyb1996
2018-11-05 11:47:46 +08:00
parent 248d698708
commit 67614b8016
6 changed files with 55 additions and 44 deletions

View File

@@ -1,10 +1,5 @@
package com.stardust.autojs.core.http;
import android.widget.AdapterView;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.Collections;
import java.util.concurrent.TimeUnit;

View File

@@ -21,6 +21,7 @@ import android.view.OrientationEventListener;
import com.stardust.autojs.runtime.exception.ScriptException;
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
import com.stardust.lang.ThreadCompat;
import com.stardust.util.ScreenMetrics;
import java.util.concurrent.atomic.AtomicReference;
@@ -152,7 +153,8 @@ public class ScreenCapturer {
mException = null;
throw new ScriptException(e);
}
while (true) {
Thread thread = ThreadCompat.currentThread();
while (!thread.isInterrupted()) {
Image cachedImage = mCachedImage.getAndSet(null);
if (cachedImage != null) {
if (mUnderUsingImage != null) {
@@ -162,6 +164,7 @@ public class ScreenCapturer {
return cachedImage;
}
}
throw new ScriptInterruptedException();
}
public int getScreenDensity() {