mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-21 21:01:43 +08:00
fix: captureScreen() return null
This commit is contained in:
parent
3e592370dc
commit
7145faa533
@ -13,6 +13,7 @@ import android.media.projection.MediaProjectionManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.util.Log;
|
||||
@ -85,22 +86,20 @@ public class ScreenCapturer {
|
||||
|
||||
private void setImageListener(Handler handler) {
|
||||
mImageReader.setOnImageAvailableListener(reader -> {
|
||||
if (mCachedImage != null) {
|
||||
synchronized (mCachedImageLock) {
|
||||
if (mCachedImage != null) {
|
||||
mCachedImage.close();
|
||||
}
|
||||
mCachedImage = reader.acquireLatestImage();
|
||||
synchronized (mCachedImageLock) {
|
||||
if (mCachedImage != null) {
|
||||
mCachedImage.close();
|
||||
}
|
||||
mCachedImage = reader.acquireLatestImage();
|
||||
if (mCachedImage != null) {
|
||||
mImageAvailable = true;
|
||||
mCachedImageLock.notify();
|
||||
return;
|
||||
}
|
||||
}
|
||||
mCachedImage = reader.acquireLatestImage();
|
||||
}, handler);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NonNull
|
||||
public Image capture() {
|
||||
if (!mImageAvailable) {
|
||||
waitForImageAvailable();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user