基础基础热敏打印功能
This commit is contained in:
parent
52faa09a62
commit
3804ec39a6
|
|
@ -11,13 +11,13 @@ android {
|
||||||
applicationId = "com.stand.standapp"
|
applicationId = "com.stand.standapp"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 11
|
versionCode = 12
|
||||||
versionName = "1.0.10"
|
versionName = "1.0.11"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64"))
|
abiFilters.addAll(listOf("armeabi-v7a","x86"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,9 @@
|
||||||
var html = '<strong>应用名称:</strong> ' + info.appName + '<br>' +
|
var html = '<strong>应用名称:</strong> ' + info.appName + '<br>' +
|
||||||
'<strong>版本号:</strong> <span style="color: #3b82f6;">' + info.versionName + '</span><br>' +
|
'<strong>版本号:</strong> <span style="color: #3b82f6;">' + info.versionName + '</span><br>' +
|
||||||
'<strong>设备型号:</strong> ' + info.model + '<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('aboutBody').innerHTML = html;
|
||||||
document.getElementById('aboutModal').style.display = 'flex';
|
document.getElementById('aboutModal').style.display = 'flex';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,22 @@ class AndroidInterface(private val activity: MainActivity) {
|
||||||
json.put("versionName", packageInfo.versionName)
|
json.put("versionName", packageInfo.versionName)
|
||||||
json.put("model", android.os.Build.MODEL)
|
json.put("model", android.os.Build.MODEL)
|
||||||
json.put("osVersion", android.os.Build.VERSION.RELEASE)
|
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()
|
json.toString()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
"{ \"appName\": \"StandApp\", \"versionName\": \"1.0.0\" }"
|
"{ \"appName\": \"消防值守台\", \"versionName\": \"1.0.0\" }"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,14 +138,21 @@ public class PrintTestActivity extends AppCompatActivity implements View.OnClick
|
||||||
}
|
}
|
||||||
|
|
||||||
String baudrate = spBaudrate.getSelectedItem().toString();
|
String baudrate = spBaudrate.getSelectedItem().toString();
|
||||||
if (sf.OpenPort(path, baudrate)) {
|
try {
|
||||||
tvStatus.setText("状态: 已连接 (" + path + ")");
|
if (sf.OpenPort(path, baudrate)) {
|
||||||
tvStatus.setTextColor(0xFF4CAF50);
|
tvStatus.setText("状态: 已连接 (" + path + ")");
|
||||||
Toast.makeText(this, "串口已开启", Toast.LENGTH_SHORT).show();
|
tvStatus.setTextColor(0xFF4CAF50);
|
||||||
} else {
|
Toast.makeText(this, "串口已开启", Toast.LENGTH_SHORT).show();
|
||||||
tvStatus.setText("状态: 连接失败");
|
} else {
|
||||||
|
tvStatus.setText("状态: 连接失败");
|
||||||
|
tvStatus.setTextColor(0xFFFF0000);
|
||||||
|
Toast.makeText(this, "串口开启失败", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
tvStatus.setText("状态: 驱动加载失败");
|
||||||
tvStatus.setTextColor(0xFFFF0000);
|
tvStatus.setTextColor(0xFFFF0000);
|
||||||
Toast.makeText(this, "串口开启失败", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "串口驱动异常(可能缺少64位库): " + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue