Commit 63fe3fc0 by pye52

用于debug,测试黑色设备异常扫码阻塞的问题

parent 16bc5455
...@@ -7,8 +7,8 @@ android { ...@@ -7,8 +7,8 @@ android {
applicationId "com.bgycc.smartcanteen" applicationId "com.bgycc.smartcanteen"
minSdkVersion 22 minSdkVersion 22
targetSdkVersion 30 targetSdkVersion 30
versionCode 141 versionCode 143
versionName "1.4.1" versionName "1.4.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk { ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips" abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
......
...@@ -41,10 +41,14 @@ public class DefaultQRCodeScan implements IQRCodeScan { ...@@ -41,10 +41,14 @@ public class DefaultQRCodeScan implements IQRCodeScan {
while (buf == null || !end(buf)) { while (buf == null || !end(buf)) {
byte[] b = new byte[64]; byte[] b = new byte[64];
int l = serialPortIS.read(b); int l = serialPortIS.read(b);
if (l == 0) break; if (l == 0) {
LogUtils.w(TAG, "扫码枪异常");
break;
}
b = Arrays.copyOfRange(b, 0, l); b = Arrays.copyOfRange(b, 0, l);
buf = merge(buf, b); buf = merge(buf, b);
len += l; len += l;
LogUtils.d(TAG, "扫码枪结果: " + (buf != null ? Arrays.toString(buf) : "empty"));
} }
String str = null; String str = null;
......
...@@ -218,7 +218,6 @@ public class NetworkUtils { ...@@ -218,7 +218,6 @@ public class NetworkUtils {
private static void requestEthernet(ConnectivityManager.NetworkCallback callback) { private static void requestEthernet(ConnectivityManager.NetworkCallback callback) {
NetworkRequest request = new NetworkRequest.Builder() NetworkRequest request = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET) .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
.removeTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.build(); .build();
connectivityManager.requestNetwork(request, callback); connectivityManager.requestNetwork(request, callback);
} }
...@@ -230,7 +229,6 @@ public class NetworkUtils { ...@@ -230,7 +229,6 @@ public class NetworkUtils {
} }
NetworkRequest request = new NetworkRequest.Builder() NetworkRequest request = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.removeTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
.build(); .build();
connectivityManager.requestNetwork(request, callback); connectivityManager.requestNetwork(request, callback);
} }
......
...@@ -70,14 +70,14 @@ public class QRCodeViewModel extends ViewModel { ...@@ -70,14 +70,14 @@ public class QRCodeViewModel extends ViewModel {
if (scan == null) return; if (scan == null) return;
if (scanFuture == null || scanFuture.isDone()) { if (scanFuture == null || scanFuture.isDone()) {
scanFuture = SCTaskExecutor.getInstance().schedule(scanRunnable, DELAY, TimeUnit.MILLISECONDS); scanFuture = SCTaskExecutor.getInstance().schedule(scanRunnable, DELAY, TimeUnit.MILLISECONDS);
} else {
LogUtils.w(TAG, "当前已有扫码任务");
} }
} }
private Runnable scanRunnable = () -> { private Runnable scanRunnable = () -> {
qrCodeState.postValue(new QRCodeState(QRCodeState.IDLE)); qrCodeState.postValue(new QRCodeState(QRCodeState.IDLE));
LogUtils.i(TAG, "开始扫描二维码"); LogUtils.i(TAG, "开始扫描二维码");
while (!scan.available()) {}
qrCodeState.postValue(new QRCodeState(QRCodeState.SCANNING));
// 读取串口扫描的二维码数据 // 读取串口扫描的二维码数据
String scanData; String scanData;
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment