From 2af6427ca8e9ff257b9a888be8652d268a8d852b Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Tue, 17 Mar 2026 04:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80nfc=20action=20=E6=95=B0?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- winboll/build.properties | 4 +- winboll/src/main/AndroidManifest.xml | 5 - .../termux/NfcTermuxBridgeActivity.java | 142 +++++++++--------- .../unittest/TermuxEnvTestActivity.java | 8 +- .../res/layout/activity_termux_env_test.xml | 7 - 5 files changed, 75 insertions(+), 91 deletions(-) diff --git a/winboll/build.properties b/winboll/build.properties index f82b4aa..0bd5fb1 100644 --- a/winboll/build.properties +++ b/winboll/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Mon Mar 16 08:40:20 GMT 2026 +#Mon Mar 16 19:52:21 GMT 2026 stageCount=26 libraryProject= baseVersion=15.11 publishVersion=15.11.25 -buildCount=26 +buildCount=29 baseBetaVersion=15.11.26 diff --git a/winboll/src/main/AndroidManifest.xml b/winboll/src/main/AndroidManifest.xml index dae7eea..1477fdc 100644 --- a/winboll/src/main/AndroidManifest.xml +++ b/winboll/src/main/AndroidManifest.xml @@ -301,11 +301,6 @@ - - - - - diff --git a/winboll/src/main/java/cc/winboll/studio/winboll/termux/NfcTermuxBridgeActivity.java b/winboll/src/main/java/cc/winboll/studio/winboll/termux/NfcTermuxBridgeActivity.java index 49cc346..38544f6 100644 --- a/winboll/src/main/java/cc/winboll/studio/winboll/termux/NfcTermuxBridgeActivity.java +++ b/winboll/src/main/java/cc/winboll/studio/winboll/termux/NfcTermuxBridgeActivity.java @@ -26,7 +26,6 @@ public class NfcTermuxBridgeActivity extends Activity { // 外部应用调用时使用的 Action 常量 public static final String ACTION_BUILD = "cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD"; - public static final String ACTION_BUILD_VIEW = "cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD_VIEW"; private static final Gson GSON = new Gson(); @@ -67,12 +66,9 @@ public class NfcTermuxBridgeActivity extends Activity { } String action = intent.getAction(); - if (ACTION_BUILD_VIEW.equals(action)) { - ToastUtils.show("ACTION_BUILD_VIEW 命中"); - onOpenTermuxProjectBuildView(intent); - } else if (ACTION_BUILD.equals(action)) { - LogUtils.d(TAG, "ACTION_BUILD 命中"); - handleNfcIntent(intent); + if (ACTION_BUILD.equals(action)) { + ToastUtils.show("ACTION_BUILD 命中"); + onOpenTermuxProjectBuild(intent); } else { LogUtils.w(TAG, "dispatchIntent() 未知 Action: " + action); finish(); @@ -83,63 +79,63 @@ public class NfcTermuxBridgeActivity extends Activity { /** * 处理 ACTION_BUILD 动作:后台执行 NFC 指令 */ - private void handleNfcIntent(Intent intent) { - LogUtils.d(TAG, "handleNfcIntent() 调用"); - if (intent == null) { - LogUtils.w(TAG, "handleNfcIntent() intent 为空"); - return; - } - - try { - String json = intent.getStringExtra(Intent.EXTRA_TEXT); - LogUtils.d(TAG, "handleNfcIntent() json: " + json); - - if (json == null || json.isEmpty()) { - LogUtils.e(TAG, "handleNfcIntent() 指令为空"); - showToast("指令为空"); - finish(); - return; - } - - NfcTermuxCmd cmd = GSON.fromJson(json, NfcTermuxCmd.class); - LogUtils.d(TAG, "handleNfcIntent() cmd: " + cmd); - - if (cmd.script == null || cmd.script.isEmpty()) { - LogUtils.e(TAG, "handleNfcIntent() script 为空"); - showToast("script 不能为空"); - finish(); - return; - } - - //String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + cmd.script; - String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + "BuildWinBoLLProject.sh"; - LogUtils.d(TAG, "handleNfcIntent() 脚本路径: " + scriptPath); - - boolean success = TermuxCommandExecutor.executeCommand( - this, scriptPath, cmd.args, cmd.workDir, cmd.background, cmd.resultDir - ); - LogUtils.d(TAG, "handleNfcIntent() 执行结果: " + success); - - if (success) { - showToast("指令已发送: " + cmd.script); - LogUtils.i(TAG, "执行成功: " + scriptPath); - } else { - showToast("指令发送失败"); - LogUtils.e(TAG, "执行失败"); - } - - } catch (Exception e) { - LogUtils.e(TAG, "handleNfcIntent() 异常: " + e.getMessage(), e); - showToast("解析失败"); - } finally { - finish(); - } - } +// private void handleNfcIntent(Intent intent) { +// LogUtils.d(TAG, "handleNfcIntent() 调用"); +// if (intent == null) { +// LogUtils.w(TAG, "handleNfcIntent() intent 为空"); +// return; +// } +// +// try { +// String json = intent.getStringExtra(Intent.EXTRA_TEXT); +// LogUtils.d(TAG, "handleNfcIntent() json: " + json); +// +// if (json == null || json.isEmpty()) { +// LogUtils.e(TAG, "handleNfcIntent() 指令为空"); +// showToast("指令为空"); +// finish(); +// return; +// } +// +// NfcTermuxCmd cmd = GSON.fromJson(json, NfcTermuxCmd.class); +// LogUtils.d(TAG, "handleNfcIntent() cmd: " + cmd); +// +// if (cmd.script == null || cmd.script.isEmpty()) { +// LogUtils.e(TAG, "handleNfcIntent() script 为空"); +// showToast("script 不能为空"); +// finish(); +// return; +// } +// +// //String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + cmd.script; +// String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + "BuildWinBoLLProject.sh"; +// LogUtils.d(TAG, "handleNfcIntent() 脚本路径: " + scriptPath); +// +// boolean success = TermuxCommandExecutor.executeCommand( +// this, scriptPath, cmd.args, cmd.workDir, cmd.background, cmd.resultDir +// ); +// LogUtils.d(TAG, "handleNfcIntent() 执行结果: " + success); +// +// if (success) { +// showToast("指令已发送: " + cmd.script); +// LogUtils.i(TAG, "执行成功: " + scriptPath); +// } else { +// showToast("指令发送失败"); +// LogUtils.e(TAG, "执行失败"); +// } +// +// } catch (Exception e) { +// LogUtils.e(TAG, "handleNfcIntent() 异常: " + e.getMessage(), e); +// showToast("解析失败"); +// } finally { +// finish(); +// } +// } /** * 处理 ACTION_BUILD_VIEW 动作:唤起 Termux 窗口执行命令 */ - public void onOpenTermuxProjectBuildView(Intent intent) { + public void onOpenTermuxProjectBuild(Intent intent) { LogUtils.d(TAG, "onOpenTermuxProjectBuildView() 调用"); if (intent == null) { LogUtils.w(TAG, "onOpenTermuxProjectBuildView() intent 为空"); @@ -171,7 +167,7 @@ public class NfcTermuxBridgeActivity extends Activity { String nfcScriptFolder = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/"; targetCmd.append("cd " + nfcScriptFolder + " && "); //targetCmd.append("stdbuf -o0 -e0 -i0 bash ").append(cmd.script).append(" "); - targetCmd.append("stdbuf -o0 -e0 -i0 bash ").append("BuildWinBoLLProjectView.sh").append(" "); + targetCmd.append("stdbuf -o0 -e0 -i0 bash ").append("BuildWinBoLLProject.sh").append(" "); if (cmd.args != null) { for (String arg : cmd.args) { targetCmd.append(arg).append(" "); @@ -216,18 +212,18 @@ public class NfcTermuxBridgeActivity extends Activity { /** * 内部测试方法:发送 ACTION_BUILD_VIEW 指令 */ - public static void testViewCommand(Context context) { - LogUtils.d(TAG, "testViewCommand()"); - try { - String testJson = "{\"script\":\"BuildWinBoLLProjectView.sh\",\"args\":[\"DebugTemp\"],\"workDir\":null,\"background\":true,\"resultDir\":null}"; - Intent intent = new Intent(context, NfcTermuxBridgeActivity.class); - intent.setAction(ACTION_BUILD_VIEW); // 指定 Action - intent.putExtra(Intent.EXTRA_TEXT, testJson); - context.startActivity(intent); - } catch (Exception e) { - LogUtils.e(TAG, "testViewCommand() 失败: " + e.getMessage()); - } - } +// public static void testViewCommand(Context context) { +// LogUtils.d(TAG, "testViewCommand()"); +// try { +// String testJson = "{\"script\":\"BuildWinBoLLProjectView.sh\",\"args\":[\"DebugTemp\"],\"workDir\":null,\"background\":true,\"resultDir\":null}"; +// Intent intent = new Intent(context, NfcTermuxBridgeActivity.class); +// intent.setAction(ACTION_BUILD_VIEW); // 指定 Action +// intent.putExtra(Intent.EXTRA_TEXT, testJson); +// context.startActivity(intent); +// } catch (Exception e) { +// LogUtils.e(TAG, "testViewCommand() 失败: " + e.getMessage()); +// } +// } // ========================= 工具方法 ========================= /** diff --git a/winboll/src/main/java/cc/winboll/studio/winboll/unittest/TermuxEnvTestActivity.java b/winboll/src/main/java/cc/winboll/studio/winboll/unittest/TermuxEnvTestActivity.java index 841f9b7..4b07046 100644 --- a/winboll/src/main/java/cc/winboll/studio/winboll/unittest/TermuxEnvTestActivity.java +++ b/winboll/src/main/java/cc/winboll/studio/winboll/unittest/TermuxEnvTestActivity.java @@ -222,10 +222,10 @@ public class TermuxEnvTestActivity extends BaseWinBoLLActivity { NfcTermuxBridgeActivity.testCommand(this); } - public void onTestWinBoLLProjectBuildView(View view) { - ToastUtils.show("onTestWinBoLLProjectBuildView"); - NfcTermuxBridgeActivity.testViewCommand(this); - } +// public void onTestWinBoLLProjectBuildView(View view) { +// ToastUtils.show("onTestWinBoLLProjectBuildView"); +// NfcTermuxBridgeActivity.testViewCommand(this); +// } public void onOpenTermuxBash(View view) { LogUtils.d(TAG, "onTestTermuxCMD() 按钮点击,执行Gradle命令(实时输出)"); diff --git a/winboll/src/main/res/layout/activity_termux_env_test.xml b/winboll/src/main/res/layout/activity_termux_env_test.xml index fee9667..0ca36f3 100644 --- a/winboll/src/main/res/layout/activity_termux_env_test.xml +++ b/winboll/src/main/res/layout/activity_termux_env_test.xml @@ -45,13 +45,6 @@ android:text="Test WinBoLL Project Build" android:onClick="onTestWinBoLLProjectBuild"/> -