Commit 63fe3fc0 by pye52

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

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