精简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
#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

View File

@@ -301,11 +301,6 @@
<category android:name="android.intent.category.DEFAULT" />
</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>
</application>

View File

@@ -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());
// }
// }
// ========================= 工具方法 =========================
/**

View File

@@ -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命令实时输出");

View File

@@ -45,13 +45,6 @@
android:text="Test WinBoLL Project Build"
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>
<ScrollView