Closed Platanus04 closed 1 year ago
应该是因为安卓版本比较新的原因,我手上的设备版本比较老所以没遇到过,我研究一下怎么改正。
应急的话可以这么处理:编辑utils.js,把第110行里的isLandscape改成false,把100-109行删掉
function requestScreenCaptureAuto() {
//安卓版本高于Android 9
if (device.sdkInt > 28) {
//等待截屏权限申请并同意
threads.start(function () {
packageName('com.android.systemui').text('允许').waitFor();
text('允许').click();
});
}
- // 检查屏幕方向
- let rotation = context.getDisplay().getRotation();
- // 旋转0度/180度,为竖屏
- // 对平板/宽屏来说,竖屏时横边长,竖边短
- if (rotation == android.view.Surface.ROTATION_0 ||
- rotation == android.view.Surface.ROTATION_180)
- isLandscape = false;
- else
- isLandscape = true
- toastLog(`申请截屏权限:${isLandscape ? '横' : '竖'}屏`);
- if (!requestScreenCapture(isLandscape)) {
+ if (!requestScreenCapture(false)) {
log("请求截图失败");
exit();
}
}
因为我手头上没有合适的设备,所以如果方便的话,需要麻烦你帮忙调试一下
新建一个空白脚本,内容填上:
toastLog(context.getResources().getConfiguration().orientation);
运行一下,看看有没有报错。没有的话,正常情况下,手机竖屏的时候会显示1,横屏的时候会显示2
utils.js编辑后已解决,横屏检测运行正常
好的,谢谢,之后我就照着新方式改了