Skip to content

Commit

Permalink
Merge pull request #667 from aiselp/dev-test
Browse files Browse the repository at this point in the history
bug修复
  • Loading branch information
kkevsekk1 authored Sep 16, 2023
2 parents 7540458 + f888975 commit b5f2e1a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions autojs/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- termux -->
<uses-permission android:name="com.termux.permission.RUN_COMMAND"/>
<uses-permission
android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ open class RhinoJavaScriptEngine(private val mAndroidContext: android.content.Co
}
}

internal fun initRequireBuilder(context: Context, scope: Scriptable) {
private fun initRequireBuilder(context: Context, scope: Scriptable) {
val provider = AssetAndUrlModuleSourceProvider(
mAndroidContext,
listOf(
Expand All @@ -126,7 +126,7 @@ open class RhinoJavaScriptEngine(private val mAndroidContext: android.content.Co
require.install(scope)
}

protected fun createScope(context: Context): TopLevelScope {
private fun createScope(context: Context): TopLevelScope {
val topLevelScope = TopLevelScope()
topLevelScope.initStandardObjects(context, false)
return topLevelScope
Expand All @@ -139,7 +139,7 @@ open class RhinoJavaScriptEngine(private val mAndroidContext: android.content.Co
return context
}

private fun setupContext(context: Context) {
fun setupContext(context: Context) {
context.wrapFactory = WrapFactory()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class ScriptBridges {

private fun <T> useJsContext(f: (context: Context) -> T): T {
val context = Context.getCurrentContext()
val cx: Context = context ?: with(Context.enter()) {
engine?.setupContext(this)
this
}
try {
return f(context ?: engine?.enterContext() ?: Context.enter())
return f(cx)
} finally {
context ?: Context.exit()
}
Expand Down

0 comments on commit b5f2e1a

Please sign in to comment.