基础基础热敏打印功能

This commit is contained in:
fengge 2026-04-21 10:17:13 +08:00
parent 52faa09a62
commit 3804ec39a6
6 changed files with 34 additions and 12 deletions

View File

@ -11,13 +11,13 @@ android {
applicationId = "com.stand.standapp"
minSdk = 24
targetSdk = 34
versionCode = 11
versionName = "1.0.10"
versionCode = 12
versionName = "1.0.11"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64"))
abiFilters.addAll(listOf("armeabi-v7a","x86"))
}
}

View File

@ -281,7 +281,9 @@
var html = '<strong>应用名称:</strong> ' + info.appName + '<br>' +
'<strong>版本号:</strong> <span style="color: #3b82f6;">' + info.versionName + '</span><br>' +
'<strong>设备型号:</strong> ' + info.model + '<br>' +
'<strong>系统版本:</strong> Android ' + info.osVersion;
'<strong>系统版本:</strong> Android ' + info.osVersion + '<br>' +
'<strong>CPU 架构:</strong> ' + info.cpuAbi + '<br>' +
'<strong>运行模式:</strong> ' + (info.is64Bit ? "64位" : "32位兼容模式");
document.getElementById('aboutBody').innerHTML = html;
document.getElementById('aboutModal').style.display = 'flex';
} catch (e) {

View File

@ -149,9 +149,22 @@ class AndroidInterface(private val activity: MainActivity) {
json.put("versionName", packageInfo.versionName)
json.put("model", android.os.Build.MODEL)
json.put("osVersion", android.os.Build.VERSION.RELEASE)
// 增加 CPU 架构信息
val abis = android.os.Build.SUPPORTED_ABIS
json.put("cpuAbi", abis.joinToString(","))
// 增加当前进程是否为 64 位的判断
val is64Bit = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
android.os.Process.is64Bit()
} else {
abis.any { it.contains("64") }
}
json.put("is64Bit", is64Bit)
json.toString()
} catch (e: Exception) {
"{ \"appName\": \"StandApp\", \"versionName\": \"1.0.0\" }"
"{ \"appName\": \"消防值守台\", \"versionName\": \"1.0.0\" }"
}
}

View File

@ -138,14 +138,21 @@ public class PrintTestActivity extends AppCompatActivity implements View.OnClick
}
String baudrate = spBaudrate.getSelectedItem().toString();
if (sf.OpenPort(path, baudrate)) {
tvStatus.setText("状态: 已连接 (" + path + ")");
tvStatus.setTextColor(0xFF4CAF50);
Toast.makeText(this, "串口已开启", Toast.LENGTH_SHORT).show();
} else {
tvStatus.setText("状态: 连接失败");
try {
if (sf.OpenPort(path, baudrate)) {
tvStatus.setText("状态: 已连接 (" + path + ")");
tvStatus.setTextColor(0xFF4CAF50);
Toast.makeText(this, "串口已开启", Toast.LENGTH_SHORT).show();
} else {
tvStatus.setText("状态: 连接失败");
tvStatus.setTextColor(0xFFFF0000);
Toast.makeText(this, "串口开启失败", Toast.LENGTH_SHORT).show();
}
} catch (Throwable e) {
tvStatus.setText("状态: 驱动加载失败");
tvStatus.setTextColor(0xFFFF0000);
Toast.makeText(this, "串口开启失败", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "串口驱动异常(可能缺少64位库): " + e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}