From: snickersun Date: Wed, 14 Oct 2020 11:32:37 +0000 (+0800) Subject: release V650 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=d3fec36f4a06278a48f1121a1f42794e1352cdca;p=protocol_srv.git release V650 解决蓝牙扫描互斥问题。防止重复扫描造成状态错误。 --- diff --git a/app/release/ICSer_V647_2010132120_release.apk b/app/release/ICSer_V650_2010141931_release.apk similarity index 78% rename from app/release/ICSer_V647_2010132120_release.apk rename to app/release/ICSer_V650_2010141931_release.apk index 6f043346..140eb821 100644 Binary files a/app/release/ICSer_V647_2010132120_release.apk and b/app/release/ICSer_V650_2010141931_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index f1c222d1..aad11516 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":647,"versionName":"2010132120","enabled":true,"outputFile":"ICSer_V647_2010132120_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V647_2010132120_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":650,"versionName":"2010141931","enabled":true,"outputFile":"ICSer_V650_2010141931_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V650_2010141931_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java index 931ee116..61e9078b 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java @@ -24,6 +24,7 @@ public class BTHelper { private BTScanCallback mCallback=null; private static BTHelper mBThelper=null; + private static boolean btscanning=false; private boolean enabledBeforScan=false; BTHelper(){ @@ -31,7 +32,9 @@ public class BTHelper { //enableBT public void enableBT() { - ICLogger.i( "BT enableBT()"); + ICLogger.i("BT enableBT()"); + + if (!mBtAdapter.isEnabled()) { // Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); // mContext.startActivity(enableIntent); @@ -45,11 +48,13 @@ public class BTHelper { //此处无法执行说没权限 // mBtAdapter.enableNoAutoConnect(); } + } //disableBT public void disableBT(){ ICLogger.i( "BT disableBT()"); + btscanning=false; if (mBtAdapter.isEnabled()) { mBtAdapter.disable(); // Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); @@ -158,70 +163,65 @@ public class BTHelper { public void scanBLE() { ICLogger.i( "BT doDiscovery()"); - - enabledBeforScan=mBtAdapter.isEnabled(); - - enableBT(); - - - // If we're already discovering, stop it - + if(btscanning==false) { + btscanning=true; + enabledBeforScan = mBtAdapter.isEnabled(); + enableBT(); + // If we're already discovering, stop it // ICLogger.i(" mBtAdapter.isDiscovering() "+mBtAdapter.isDiscovering()); // if (mBtAdapter.isDiscovering()) { // mBtAdapter.cancelDiscovery(); // } // mBtAdapter.setDiscoverableTimeout(3); - mPairedDevicesArray.clear(); - mNewDevicesArray.clear(); - // Request discover from BluetoothAdapter - + mPairedDevicesArray.clear(); + mNewDevicesArray.clear(); + // Request discover from BluetoothAdapter // mBtAdapter.startDiscovery(); + mBtAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE, Config.bleScanTimeout); + LeScanCallback lecallback = new LeScanCallback() { - - - mBtAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE, Config.bleScanTimeout); - LeScanCallback lecallback=new LeScanCallback(){ - - @Override - public void onLeScan(BluetoothDevice bluetoothDevice, int rssi, byte[] scanRecode) { + @Override + public void onLeScan(BluetoothDevice bluetoothDevice, int rssi, byte[] scanRecode) { // ICLogger.i( "BT onLeScan "+bluetoothDevice.getName()+" "+bluetoothDevice.getAddress()+" rssi "+rssi); // ICLogger.logToFile("LBS","BT onLeScan "+bluetoothDevice.getName()+" "+bluetoothDevice.getAddress()+" rssi "+rssi ); - boolean found=false; - for (String dev: mNewDevicesArray){ - if (dev.contains(bluetoothDevice.getAddress())) { - found = true; - break; - } + boolean found = false; + for (String dev : mNewDevicesArray) { + if (dev.contains(bluetoothDevice.getAddress())) { + found = true; + break; + } + } + if (!found) + mNewDevicesArray.add(bluetoothDevice.getAddress() + "," + rssi); } - if(!found) - mNewDevicesArray.add(bluetoothDevice.getAddress()+","+rssi); - } - }; + }; - ICLogger.i("BT startLeScan"); - mBtAdapter.startLeScan(lecallback); + ICLogger.i("BT startLeScan"); + mBtAdapter.startLeScan(lecallback); - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - ICLogger.i("BT stopLeScan"); - mBtAdapter.stopLeScan(lecallback); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ICLogger.i("BT stopLeScan"); + mBtAdapter.stopLeScan(lecallback); - //开始扫描前是关闭的,就关闭它 + //开始扫描前是关闭的,就关闭它 // if(!enabledBeforScan) disableBT(); - if (mCallback!=null) - mCallback.OnScanFinished(mPairedDevicesArray,mNewDevicesArray); - } - },5000); - + if (mCallback != null) + mCallback.OnScanFinished(mPairedDevicesArray, mNewDevicesArray); + } + }, 5000); + }else{ + ICLogger.i("BT Scanning skip Scan!"); + } } diff --git a/app/version_code.properties b/app/version_code.properties index a9c96afb..8d1cbe1a 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Tue Oct 13 21:20:34 CST 2020 -VERSION_CODE=647 +#Wed Oct 14 19:31:29 CST 2020 +VERSION_CODE=650