Skip to content

Commit 129dbce

Browse files
committed
fix(android): add network security configuration to AndroidManifest.xml and clean up logging in qjs.cpp
1 parent 8861672 commit 129dbce

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<!-- Debug 环境: 全局允许 HTTP 明文通信 -->
4+
<base-config cleartextTrafficPermitted="true">
5+
<trust-anchors>
6+
<!-- 信任系统证书 -->
7+
<certificates src="system" />
8+
<!-- 信任用户安装的证书(用于抓包调试) -->
9+
<certificates src="user" />
10+
</trust-anchors>
11+
</base-config>
12+
</network-security-config>

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
android:roundIcon="@mipmap/ic_launcher_round"
1313
android:supportsRtl="true"
1414
android:theme="@style/Theme.DiminaAndroid"
15+
android:networkSecurityConfig="@xml/network_security_config"
1516
tools:targetApi="31">
1617
<activity
1718
android:name=".MainActivity"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<!-- Release 环境: 禁止 HTTP 明文通信,只允许 HTTPS -->
4+
<base-config cleartextTrafficPermitted="false">
5+
<trust-anchors>
6+
<!-- 仅信任系统证书 -->
7+
<certificates src="system" />
8+
</trust-anchors>
9+
</base-config>
10+
11+
<!-- 如果 Release 环境需要对特定域名允许 HTTP,可以添加: -->
12+
<!--
13+
<domain-config cleartextTrafficPermitted="true">
14+
<domain includeSubdomains="true">example.com</domain>
15+
</domain-config>
16+
-->
17+
</network-security-config>

android/engine_qjs/src/main/cpp/qjs.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,10 +1088,7 @@ Java_com_didi_dimina_engine_qjs_QuickJSEngine_nativeRunEventLoop(
10881088
"Failed to run event loop: Instance %d not found or loop is null", instanceId);
10891089
return;
10901090
}
1091-
1092-
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG,
1093-
"Starting libuv event loop for instance %d", instanceId);
1094-
1091+
10951092
// Run the event loop in non-blocking mode with a timeout
10961093
// This allows the loop to process events without blocking indefinitely
10971094
uv_run(instance->loop, UV_RUN_NOWAIT);

0 commit comments

Comments
 (0)