精简nfc action 数量

This commit is contained in:
2026-03-17 04:03:20 +08:00
parent b8c70bef98
commit 2af6427ca8
5 changed files with 75 additions and 91 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #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 stageCount=26
libraryProject= libraryProject=
baseVersion=15.11 baseVersion=15.11
publishVersion=15.11.25 publishVersion=15.11.25
buildCount=26 buildCount=29
baseBetaVersion=15.11.26 baseBetaVersion=15.11.26

View File

@@ -301,11 +301,6 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<!-- 接收 ACTION_BUILD_VIEW 意图 -->
<intent-filter>
<action android:name="cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD_VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> </activity>
</application> </application>

View File

@@ -26,7 +26,6 @@ public class NfcTermuxBridgeActivity extends Activity {
// 外部应用调用时使用的 Action 常量 // 外部应用调用时使用的 Action 常量
public static final String ACTION_BUILD = "cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD"; 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(); private static final Gson GSON = new Gson();
@@ -67,12 +66,9 @@ public class NfcTermuxBridgeActivity extends Activity {
} }
String action = intent.getAction(); String action = intent.getAction();
if (ACTION_BUILD_VIEW.equals(action)) { if (ACTION_BUILD.equals(action)) {
ToastUtils.show("ACTION_BUILD_VIEW 命中"); ToastUtils.show("ACTION_BUILD 命中");
onOpenTermuxProjectBuildView(intent); onOpenTermuxProjectBuild(intent);
} else if (ACTION_BUILD.equals(action)) {
LogUtils.d(TAG, "ACTION_BUILD 命中");
handleNfcIntent(intent);
} else { } else {
LogUtils.w(TAG, "dispatchIntent() 未知 Action: " + action); LogUtils.w(TAG, "dispatchIntent() 未知 Action: " + action);
finish(); finish();
@@ -83,63 +79,63 @@ public class NfcTermuxBridgeActivity extends Activity {
/** /**
* 处理 ACTION_BUILD 动作:后台执行 NFC 指令 * 处理 ACTION_BUILD 动作:后台执行 NFC 指令
*/ */
private void handleNfcIntent(Intent intent) { // private void handleNfcIntent(Intent intent) {
LogUtils.d(TAG, "handleNfcIntent() 调用"); // LogUtils.d(TAG, "handleNfcIntent() 调用");
if (intent == null) { // if (intent == null) {
LogUtils.w(TAG, "handleNfcIntent() intent 为空"); // LogUtils.w(TAG, "handleNfcIntent() intent 为空");
return; // return;
} // }
//
try { // try {
String json = intent.getStringExtra(Intent.EXTRA_TEXT); // String json = intent.getStringExtra(Intent.EXTRA_TEXT);
LogUtils.d(TAG, "handleNfcIntent() json: " + json); // LogUtils.d(TAG, "handleNfcIntent() json: " + json);
//
if (json == null || json.isEmpty()) { // if (json == null || json.isEmpty()) {
LogUtils.e(TAG, "handleNfcIntent() 指令为空"); // LogUtils.e(TAG, "handleNfcIntent() 指令为空");
showToast("指令为空"); // showToast("指令为空");
finish(); // finish();
return; // return;
} // }
//
NfcTermuxCmd cmd = GSON.fromJson(json, NfcTermuxCmd.class); // NfcTermuxCmd cmd = GSON.fromJson(json, NfcTermuxCmd.class);
LogUtils.d(TAG, "handleNfcIntent() cmd: " + cmd); // LogUtils.d(TAG, "handleNfcIntent() cmd: " + cmd);
//
if (cmd.script == null || cmd.script.isEmpty()) { // if (cmd.script == null || cmd.script.isEmpty()) {
LogUtils.e(TAG, "handleNfcIntent() script 为空"); // LogUtils.e(TAG, "handleNfcIntent() script 为空");
showToast("script 不能为空"); // showToast("script 不能为空");
finish(); // finish();
return; // 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/" + cmd.script;
String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + "BuildWinBoLLProject.sh"; // String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + "BuildWinBoLLProject.sh";
LogUtils.d(TAG, "handleNfcIntent() 脚本路径: " + scriptPath); // LogUtils.d(TAG, "handleNfcIntent() 脚本路径: " + scriptPath);
//
boolean success = TermuxCommandExecutor.executeCommand( // boolean success = TermuxCommandExecutor.executeCommand(
this, scriptPath, cmd.args, cmd.workDir, cmd.background, cmd.resultDir // this, scriptPath, cmd.args, cmd.workDir, cmd.background, cmd.resultDir
); // );
LogUtils.d(TAG, "handleNfcIntent() 执行结果: " + success); // LogUtils.d(TAG, "handleNfcIntent() 执行结果: " + success);
//
if (success) { // if (success) {
showToast("指令已发送: " + cmd.script); // showToast("指令已发送: " + cmd.script);
LogUtils.i(TAG, "执行成功: " + scriptPath); // LogUtils.i(TAG, "执行成功: " + scriptPath);
} else { // } else {
showToast("指令发送失败"); // showToast("指令发送失败");
LogUtils.e(TAG, "执行失败"); // LogUtils.e(TAG, "执行失败");
} // }
//
} catch (Exception e) { // } catch (Exception e) {
LogUtils.e(TAG, "handleNfcIntent() 异常: " + e.getMessage(), e); // LogUtils.e(TAG, "handleNfcIntent() 异常: " + e.getMessage(), e);
showToast("解析失败"); // showToast("解析失败");
} finally { // } finally {
finish(); // finish();
} // }
} // }
/** /**
* 处理 ACTION_BUILD_VIEW 动作:唤起 Termux 窗口执行命令 * 处理 ACTION_BUILD_VIEW 动作:唤起 Termux 窗口执行命令
*/ */
public void onOpenTermuxProjectBuildView(Intent intent) { public void onOpenTermuxProjectBuild(Intent intent) {
LogUtils.d(TAG, "onOpenTermuxProjectBuildView() 调用"); LogUtils.d(TAG, "onOpenTermuxProjectBuildView() 调用");
if (intent == null) { if (intent == null) {
LogUtils.w(TAG, "onOpenTermuxProjectBuildView() intent 为空"); 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/"; String nfcScriptFolder = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/";
targetCmd.append("cd " + nfcScriptFolder + " && "); targetCmd.append("cd " + nfcScriptFolder + " && ");
//targetCmd.append("stdbuf -o0 -e0 -i0 bash ").append(cmd.script).append(" "); //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) { if (cmd.args != null) {
for (String arg : cmd.args) { for (String arg : cmd.args) {
targetCmd.append(arg).append(" "); targetCmd.append(arg).append(" ");
@@ -216,18 +212,18 @@ public class NfcTermuxBridgeActivity extends Activity {
/** /**
* 内部测试方法:发送 ACTION_BUILD_VIEW 指令 * 内部测试方法:发送 ACTION_BUILD_VIEW 指令
*/ */
public static void testViewCommand(Context context) { // public static void testViewCommand(Context context) {
LogUtils.d(TAG, "testViewCommand()"); // LogUtils.d(TAG, "testViewCommand()");
try { // try {
String testJson = "{\"script\":\"BuildWinBoLLProjectView.sh\",\"args\":[\"DebugTemp\"],\"workDir\":null,\"background\":true,\"resultDir\":null}"; // String testJson = "{\"script\":\"BuildWinBoLLProjectView.sh\",\"args\":[\"DebugTemp\"],\"workDir\":null,\"background\":true,\"resultDir\":null}";
Intent intent = new Intent(context, NfcTermuxBridgeActivity.class); // Intent intent = new Intent(context, NfcTermuxBridgeActivity.class);
intent.setAction(ACTION_BUILD_VIEW); // 指定 Action // intent.setAction(ACTION_BUILD_VIEW); // 指定 Action
intent.putExtra(Intent.EXTRA_TEXT, testJson); // intent.putExtra(Intent.EXTRA_TEXT, testJson);
context.startActivity(intent); // context.startActivity(intent);
} catch (Exception e) { // } catch (Exception e) {
LogUtils.e(TAG, "testViewCommand() 失败: " + e.getMessage()); // LogUtils.e(TAG, "testViewCommand() 失败: " + e.getMessage());
} // }
} // }
// ========================= 工具方法 ========================= // ========================= 工具方法 =========================
/** /**

View File

@@ -222,10 +222,10 @@ public class TermuxEnvTestActivity extends BaseWinBoLLActivity {
NfcTermuxBridgeActivity.testCommand(this); NfcTermuxBridgeActivity.testCommand(this);
} }
public void onTestWinBoLLProjectBuildView(View view) { // public void onTestWinBoLLProjectBuildView(View view) {
ToastUtils.show("onTestWinBoLLProjectBuildView"); // ToastUtils.show("onTestWinBoLLProjectBuildView");
NfcTermuxBridgeActivity.testViewCommand(this); // NfcTermuxBridgeActivity.testViewCommand(this);
} // }
public void onOpenTermuxBash(View view) { public void onOpenTermuxBash(View view) {
LogUtils.d(TAG, "onTestTermuxCMD() 按钮点击执行Gradle命令实时输出"); LogUtils.d(TAG, "onTestTermuxCMD() 按钮点击执行Gradle命令实时输出");

View File

@@ -45,13 +45,6 @@
android:text="Test WinBoLL Project Build" android:text="Test WinBoLL Project Build"
android:onClick="onTestWinBoLLProjectBuild"/> android:onClick="onTestWinBoLLProjectBuild"/>
<Button
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test WinBoLL Project Build View"
android:onClick="onTestWinBoLLProjectBuildView"/>
</LinearLayout> </LinearLayout>
<ScrollView <ScrollView