6.7.0 - Alpha11 - 新增 crash 全局方法, 用于测试崩溃报告页面
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
"runtime.(set/is)JavaPrimitiveWrap 方法, 用于设置或获取 Java 原始类型包装策略 _[`issue #435`](http://issues.autojs6.com/435)_",
|
||||
"autojs.(restart/exit) 方法, 用于重启或退出 AutoJs6 应用, 并支持应用重启时自动运行其参数指定的脚本 _[`issue #460`](http://issues.autojs6.com/460)_",
|
||||
"UiObject#isShifted 方法, 用于检测控件位置变化",
|
||||
"crash 全局方法, 用于测试崩溃报告页面",
|
||||
"structuredClone 全局方法, 用于深拷贝 JavaScript 对象 (参阅 [MDN](https://developer.mozilla.org/zh-CN/docs/Web/API/Window/structuredClone))",
|
||||
"设置页面增加 \"Java 原始类型包装\" 设置选项 _[`issue #435`](http://issues.autojs6.com/435)_",
|
||||
"设置页面增加 \"定时任务调度引擎\" 设置选项, 支持 AlarmManager/WorkManager/JobScheduler _[`issue #457`](http://issues.autojs6.com/457)_ _[`issue #388`](http://issues.autojs6.com/388)_ _[`issue #163`](http://issues.autojs6.com/163)_ _[`issue #53`](http://issues.autojs6.com/53)_ _[`issue #21`](http://issues.autojs6.com/21)_",
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.autojs.autojs.runtime.ScriptRuntime;
|
||||
import org.autojs.autojs.runtime.api.augment.jsox.Jsox;
|
||||
import org.autojs.autojs.script.JavaScriptSource;
|
||||
import org.autojs.autojs.script.ScriptSource;
|
||||
import org.autojs.autojs.tool.CrashHandlerTestFunction;
|
||||
import org.autojs.autojs6.R;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -45,6 +46,7 @@ public abstract class JavaScriptEngine extends ScriptEngine.AbstractScriptEngine
|
||||
mRuntime = runtime;
|
||||
mRuntime.engines.setCurrentEngine(this);
|
||||
put("runtime", runtime);
|
||||
put("crash", new CrashHandlerTestFunction());
|
||||
}
|
||||
|
||||
public void emit(String eventName, Object... args) {
|
||||
|
||||
@@ -94,6 +94,7 @@ open class RhinoJavaScriptEngine(private val androidContext: android.content.Con
|
||||
override fun forceStop() {
|
||||
Log.d(TAG, "forceStop: interrupt Thread: $thread")
|
||||
thread.interrupt()
|
||||
runtime.cancelScriptJobs()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.autojs.autojs.tool
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import org.autojs.autojs.util.RhinoUtils.UNDEFINED
|
||||
import org.mozilla.javascript.BaseFunction
|
||||
import org.mozilla.javascript.Context
|
||||
import org.mozilla.javascript.Scriptable
|
||||
import org.mozilla.javascript.Undefined
|
||||
|
||||
class CrashHandlerTestFunction : BaseFunction() {
|
||||
|
||||
override fun call(
|
||||
cx: Context?,
|
||||
scope: Scriptable?,
|
||||
thisObj: Scriptable?,
|
||||
args: Array<out Any>?,
|
||||
): Undefined {
|
||||
val msg = if (!args.isNullOrEmpty()) Context.toString(args[0]) else "CrashHandler test"
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
throw RuntimeException(msg)
|
||||
}
|
||||
return UNDEFINED
|
||||
}
|
||||
|
||||
override fun getArity(): Int = 1
|
||||
|
||||
override fun getFunctionName(): String = "crash"
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user