6.7.0 - Alpha - 修复调用 images.requestScreenCapture 时用户取消授权可能导致应用崩溃的问题
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
],
|
||||
"fix": [
|
||||
"使用 XML 语法将 JavaScript 表达式作为属性值时, this 对象可能出现指向错误的问题",
|
||||
"调用 images.requestScreenCapture 时用户取消授权可能导致应用崩溃的问题",
|
||||
"版本历史页面部分系统因字体差别导致统计数据显示不完整的问题"
|
||||
],
|
||||
"improvement": [],
|
||||
|
||||
@@ -75,6 +75,7 @@ public class ScreenCaptureRequester extends SimpleActivityLifecycleCallbacks imp
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
|
||||
// @Hint by kvii (https://github.com/kvii) on Oct 23, 2024.
|
||||
// ! 按照官方文档 (https://developer.android.com/reference/android/media/projection/MediaProjectionManager), 启动媒体投影的示例流程如下:
|
||||
// ! 1. AndroidManifest.xml 声明 mediaProjection 类型前台服务
|
||||
@@ -101,27 +102,33 @@ public class ScreenCaptureRequester extends SimpleActivityLifecycleCallbacks imp
|
||||
// ! The original code in ScreenCaptureRequesterImpl#request's startService may have timing issues,
|
||||
// ! if the user has not yet completed authorization, starting the foreground service on Android 14 will crash.
|
||||
// ! Change it to bindService and wait for the onServiceConnected callback.
|
||||
if (requestCode == REQUEST_CODE_MEDIA_PROJECTION) {
|
||||
Context applicationContext = getApplication().getApplicationContext();
|
||||
applicationContext.startService(new Intent(applicationContext, ScreenCapturerForegroundService.class));
|
||||
var clazz = ScreenCapturerForegroundService.class;
|
||||
if (ForegroundServiceUtils.isRunning(applicationContext, clazz)) {
|
||||
onRequest(resultCode, data);
|
||||
} else {
|
||||
mServiceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
onRequest(resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
/* Empty body. */
|
||||
}
|
||||
};
|
||||
applicationContext.bindService(new Intent(applicationContext, clazz), mServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
if (requestCode != REQUEST_CODE_MEDIA_PROJECTION) {
|
||||
return;
|
||||
}
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
onRequest(resultCode, data);
|
||||
return;
|
||||
}
|
||||
var clazz = ScreenCapturerForegroundService.class;
|
||||
Context applicationContext = getApplication().getApplicationContext();
|
||||
applicationContext.startService(new Intent(applicationContext, clazz));
|
||||
if (ForegroundServiceUtils.isRunning(applicationContext, clazz)) {
|
||||
onRequest(resultCode, data);
|
||||
return;
|
||||
}
|
||||
mServiceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
onRequest(resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
/* Empty body. */
|
||||
}
|
||||
};
|
||||
applicationContext.bindService(new Intent(applicationContext, clazz), mServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,14 +156,13 @@ public class ScreenCaptureRequester extends SimpleActivityLifecycleCallbacks imp
|
||||
try {
|
||||
StartForResultActivity.start(context, this);
|
||||
scheduleActivityCreateTimeout();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onRequestError(e);
|
||||
recycle();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException(ScreenCaptureRequester.class.getSimpleName() + "#request can be only call once");
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ public class ForegroundServiceCreator {
|
||||
notificationContent);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && foregroundServiceType != FOREGROUND_SERVICE_TYPE_UNKNOWN) {
|
||||
service.startForeground(notificationId, notification, foregroundServiceType);
|
||||
service.startForeground(notificationId, notification, foregroundServiceType);
|
||||
} else {
|
||||
service.startForeground(notificationId, notification);
|
||||
service.startForeground(notificationId, notification);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Mon Jun 09 15:52:27 CST 2025
|
||||
BUILD_TIME=1749455547476
|
||||
#Mon Jun 09 19:43:01 CST 2025
|
||||
BUILD_TIME=1749469381134
|
||||
COMPILE_SDK_VERSION=35
|
||||
IMAGE_QUANT_CMAKE_VERSION=3.22.1
|
||||
IMAGE_QUANT_NDK_VERSION=26.1.10909125
|
||||
@@ -19,6 +19,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
|
||||
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
||||
TARGET_SDK_VERSION=35
|
||||
TARGET_SDK_VERSION_INRT=29
|
||||
VERSION_BUILD=3285
|
||||
VERSION_BUILD=3286
|
||||
VERSION_NAME=6.7.0 Alpha
|
||||
VSCODE_EXT_REQUIRED_VERSION=1.0.8
|
||||
|
||||
Reference in New Issue
Block a user