From: snickersun Date: Wed, 21 Oct 2020 10:12:23 +0000 (+0800) Subject: release V667 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=38b7700b6b97347a15ba3c4a34ec25cca37b98a5;p=protocol_srv.git release V667 1、优化蓝牙扫描停止逻辑,解决特定逻辑可能造成蓝牙不关闭,而无法继续扫描问题。 2、电池包含15%,%5 都会上报电量低, 且取消只报一次的限制。 3、蓝牙扫描15秒,重试次数改为0 4、修改测试页面。增加 重启服务,usb mtp开关,mod8 5分钟模式,运动检测开关。 --- diff --git a/app/app.iml b/app/app.iml index d1100d69..497b2ac8 100644 --- a/app/app.iml +++ b/app/app.iml @@ -29,14 +29,14 @@ - - + + - + diff --git a/app/release/ICSer_V665_2010201758_release.apk b/app/release/ICSer_V667_2010211806_release.apk similarity index 77% rename from app/release/ICSer_V665_2010201758_release.apk rename to app/release/ICSer_V667_2010211806_release.apk index f00316ce..ad991a67 100644 Binary files a/app/release/ICSer_V665_2010201758_release.apk and b/app/release/ICSer_V667_2010211806_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index c57fa4c4..f7b50fe4 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":665,"versionName":"2010201758","enabled":true,"outputFile":"ICSer_V665_2010201758_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V665_2010201758_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":667,"versionName":"2010211806","enabled":true,"outputFile":"ICSer_V667_2010211806_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V667_2010211806_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java index 6c6c2c1d..712d8afb 100644 --- a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java +++ b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java @@ -761,12 +761,13 @@ public class ICSmsManager extends BroadcastReceiver { if (tmp.length == 2) { if(tmp[1].equals("current")) { - String conf= Util.getSystemProperties("persist.sys.usb.config"); + String conf= Util.getSystemProperties("sys.usb.config"); sendSMS(phonenumber, "Current USB config is "+conf+"!"); }else if(tmp[1].equals("mtp")||tmp[1].equals("adb")||tmp[1].equals("mtp,adb")||tmp[1].equals("adb,mtp")||tmp[1].equals("none")) { sendSMS(phonenumber, "Set USB config to "+tmp[1]+"!"); - Util.setSystemProperties("persist.sys.usb.config", "none"); - Util.setSystemProperties("persist.sys.usb.config", tmp[1]); + Util.setSystemProperties("sys.usb.config", "none"); + + Util.setSystemProperties("sys.usb.config", tmp[1]); }else{ sendSMS(phonenumber, "USB cmd format error only support current|adb|mtp|adb,mtp|mtp,adb|none !"); } diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index 14d0320f..8a38105b 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -119,7 +119,7 @@ public class LocationClient { private boolean scanBLEOnly=false; //如果未扫到,重试扫描的次数。 - private int maxBLEScanTime=1; + private int maxBLEScanTime=0; private int ScanBLERetryCount=maxBLEScanTime; private int OneBLEScanTimeOUT=15; @@ -829,6 +829,8 @@ public void updateCellInfo() { updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。 //如果没有动,且超时。则跳过定位 NoMoveTimeout=checkNoMoveTimeout(); + ICLogger.i("BT NoMoveTimeout "+NoMoveTimeout+", forceLocation="+forceLocation+", Config.forceMoveCheck="+Config.forceMoveCheck+", skipMoveCheck="+skipMoveCheck); + // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过 if ( ( forceLocation != 1 ) && (Config.forceMoveCheck==true) && @@ -837,7 +839,6 @@ public void updateCellInfo() { return false; } - ICLogger.i("BT NoMoveTimeout "+NoMoveTimeout+", forceLocation="+forceLocation+", Config.forceMoveCheck="+Config.forceMoveCheck+", skipMoveCheck="+skipMoveCheck); return true; } public void startLocationProcess(int mod){ 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 87efb599..689ad8b2 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java @@ -27,7 +27,7 @@ public class BTHelper { private static boolean btscanning=false; private static Runtime mRuntime; private boolean enabledBeforScan=false; - private Handler mHandler=null; + private static Handler mHandler=null; BTHelper(){ } @@ -40,15 +40,12 @@ public class BTHelper { String tmp = beaconAddr.replace(":", "").toLowerCase(); if(tmp.contains(",")) tmp = tmp.substring(0, tmp.indexOf(",")); - for (String beacon:mRuntime.bleInfo.btMacList){ -// ICLogger.i(beacon +" ==? "+tmp); if (tmp.equals(beacon)) { ICLogger.i("bt mac " + tmp + " " + beaconAddr.toLowerCase()); return true; } } -// ICLogger.i(" false "); return false; } //enableBT @@ -57,8 +54,6 @@ public class BTHelper { if (!mBtAdapter.isEnabled()) { -// Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); -// mContext.startActivity(enableIntent); mBtAdapter.enable(); try { @@ -77,10 +72,7 @@ public class BTHelper { ICLogger.i( "BT disableBT()"); if (mBtAdapter.isEnabled()) { mBtAdapter.disable(); -// Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); -// mContext.startActivity(enableIntent); } - btscanning=false; } //初始化 BTHlper @@ -88,19 +80,13 @@ public class BTHelper { ICLogger.i( "BT Init()"); mCallback=callback; mContext=context; -// // Register for broadcasts when a device is discovered -// IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); -// mContext.registerReceiver(mReceiver, filter); -// -// // Register for broadcasts when discovery has finished -// filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); -// mContext.registerReceiver(mReceiver, filter); -// - // Get the local Bluetooth adapter mBtAdapter = BluetoothAdapter.getDefaultAdapter(); - mHandler = new Handler(); - lecallback = new BLeScanCallback(); + + if (lecallback==null) + lecallback= new BLeScanCallback(); + if(mHandler==null) + mHandler=new Handler(); } @@ -116,76 +102,6 @@ public class BTHelper { return mBThelper; } - -// // The BroadcastReceiver that listens for discovered devices and -// // changes the title when discovery is finished -// private final BroadcastReceiver mReceiver = new BroadcastReceiver() { -// @Override -// public void onReceive(Context context, Intent intent) { -// String action = intent.getAction(); -// ICLogger.i( "BT onReceive "+action); -// // When discovery finds a device -// if (BluetoothDevice.ACTION_FOUND.equals(action)) { -// // Get the BluetoothDevice object from the Intent -// BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); -// // If it's already paired, skip it, because it's been listed already -// -// ICLogger.i("BT "+device.getName() + "\t" + device.getAddress()); -// -//// ICLogger.i( device.getName() + "\n" + device.getAddress()); -// if (device.getBondState() != BluetoothDevice.BOND_BONDED) { -// if(!mNewDevicesArray.contains(device.getAddress())) -// mNewDevicesArray.add(device.getAddress()); -// } -// // When discovery is finished, change the Activity title -// } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { -// -// if (mNewDevicesArray.size() == 0) { -// //没有设备 -// } -// // Get a set of currently paired devices -// Set pairedDevices = mBtAdapter.getBondedDevices(); -// -// // If there are paired devices, add each one to the ArrayAdapter -// if (pairedDevices.size() > 0) { -// for (BluetoothDevice device : pairedDevices) { -// ICLogger.i("BT "+device.getName() + "\t" + device.getAddress()); -// if(!mPairedDevicesArray.contains(device.getAddress())) -// mPairedDevicesArray.add(device.getAddress()); -// -// } -// } -// -// //开始扫描前是关闭的,就关闭它 -// if(!enabledBeforScan) -// disableBT(); -// -// if (mCallback!=null) -// mCallback.OnScanFinished(mPairedDevicesArray,mNewDevicesArray); -// } -// } -// }; - - //清除BThelper -// public void Deinit() { -// ICLogger.i( "BT Deinit()"); -// // Make sure we're not doing discovery anymore -//// if (mBtAdapter != null) { -//// mBtAdapter.cancelDiscovery(); -//// } -//// -//// // Unregister broadcast listeners -//// if(mContext!=null) -//// mContext.unregisterReceiver(mReceiver); -//// -// -// -//// mContext=null; -////// mCallback=null; -// -// } - - private BLeScanCallback lecallback =null; private RunableStopBleScan mRunable_stopBleScan=new RunableStopBleScan(); @@ -196,29 +112,23 @@ public class BTHelper { } //开始扫描BLE public void scanBLE() { - ICLogger.i( "BT doDiscovery()"); + ICLogger.i( "BT scanBLE()"); 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 - - -// mBtAdapter.startDiscovery(); // mBtAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE, BLETimeoutForOneScan); ICLogger.i("BT startLeScan"); + if (lecallback==null) + lecallback= new BLeScanCallback(); + if(mHandler==null) + mHandler=new Handler(); mBtAdapter.startLeScan(lecallback); mHandler.postDelayed(mRunable_stopBleScan, BLETimeoutForOneScan*1000); @@ -291,15 +201,16 @@ public class BTHelper { if(isBeaconFounded(bluetoothDevice.getAddress())){ - hasStopedByFoundBT=true; mHandler.removeCallbacks(mRunable_stopBleScan); - ICLogger.i("BT stopLeScan"); + ICLogger.i("BT onLeScan stopLeScan"); mBtAdapter.stopLeScan(this); + btscanning=false; //开始扫描前是关闭的,就关闭它 // if(!enabledBeforScan) disableBT(); + hasStopedByFoundBT=true; if (mCallback != null) mCallback.OnScanFinished(mPairedDevicesArray, mNewDevicesArray); @@ -312,19 +223,14 @@ public class BTHelper { @Override public void run() { ICLogger.i("BT stopLeScan"); + mBtAdapter.stopLeScan(lecallback); + btscanning=false; + //开始扫描前是关闭的,就关闭它 + // if(!enabledBeforScan) + disableBT(); + if (mCallback != null) + mCallback.OnScanFinished(mPairedDevicesArray, mNewDevicesArray); - if(hasStopedByFoundBT) { - hasStopedByFoundBT=false; - ICLogger.i(" BT has Stoped !"); - - }else{ - mBtAdapter.stopLeScan(lecallback); - //开始扫描前是关闭的,就关闭它 - // if(!enabledBeforScan) - disableBT(); - if (mCallback != null) - mCallback.OnScanFinished(mPairedDevicesArray, mNewDevicesArray); - } } } diff --git a/app/src/main/java/com/enqualcomm/support/toolActivity.java b/app/src/main/java/com/enqualcomm/support/toolActivity.java index 21ccb125..68d7ec79 100644 --- a/app/src/main/java/com/enqualcomm/support/toolActivity.java +++ b/app/src/main/java/com/enqualcomm/support/toolActivity.java @@ -16,7 +16,7 @@ import com.ic.protocols.protocol_mqtt; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; public class toolActivity extends Activity { - + private static boolean usbstat=true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -28,6 +28,11 @@ public class toolActivity extends Activity { Button btnmod1=(Button)findViewById(R.id.btn_location1); Button btnmod3=(Button)findViewById(R.id.btn_location3); Button btnmod530=(Button)findViewById(R.id.btn_location530); + + Button btnRestSrv=(Button)findViewById(R.id.btn_restartSrv); + Button btnUsbEnable=(Button)findViewById(R.id.btn_usb); + Button btnSlog=(Button)findViewById(R.id.btn_cpslog); + // protocol_mqtt_client mqttClient=new protocol_mqtt_client(toolActivity.this); // mqttClient.connectservice(); btnmod1.setOnClickListener(new View.OnClickListener() { @@ -57,9 +62,9 @@ public class toolActivity extends Activity { @Override public void onClick(View view) { Intent intent=new Intent(); - intent.putExtra("smsCmd","#setlocation#=5,30#"); + intent.putExtra("smsCmd","#setlocation#=8,300#"); CoreService.getInstance().runtime.getContextProxy().sendBrodcast("com.enqualcomm.support.SMSCMD",intent); - Util.ShowToast(CoreService.getInstance().runtime,"设置模式5 , 间隔30秒定位。"); + Util.ShowToast(CoreService.getInstance().runtime,"设置模式8, 间隔300秒定位。"); // mqttClient.sendMessage("WBG100/v1/BREQ/1","[0016,QWER15WTF156OQRT1230]"); @@ -97,5 +102,55 @@ public class toolActivity extends Activity { CoreService.getInstance().runtime.getContextProxy().sendBrodcast("com.enqualcomm.support.SMSCMD",intent); } }); + + + + btnUsbEnable.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(usbstat) { + Intent intent=new Intent(); + intent.putExtra("smsCmd", "#USB#=mtp"); + CoreService.getInstance().runtime.getContextProxy().sendBrodcast("com.enqualcomm.support.SMSCMD",intent); + Util.ShowToast(CoreService.getInstance().runtime,"Enable MTP"); + }else{ + Intent intent=new Intent(); + intent.putExtra("smsCmd", "#USB#=none"); + CoreService.getInstance().runtime.getContextProxy().sendBrodcast("com.enqualcomm.support.SMSCMD",intent); + Util.ShowToast(CoreService.getInstance().runtime,"Diable MTP"); + } + + } + }); + btnRestSrv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + if (CoreService.getInstance()!=null) + Util.ShowToast(CoreService.getInstance().runtime, "Stop ProtocolService!"); + stopService(new Intent(toolActivity.this, CoreService.class));// protocol service + + try{ + Thread.sleep(3000); + }catch (Exception e ){} + if (CoreService.getInstance()!=null) + Util.ShowToast(CoreService.getInstance().runtime, "Start ProtocolService!"); + startService(new Intent(toolActivity.this, CoreService.class));// protocol service + + } + }); + btnSlog.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(Config.forceMoveCheck) + { + Config.forceMoveCheck=false; + }else{ + Config.forceMoveCheck=true; + } + Util.ShowToast(CoreService.getInstance().runtime,"Set ForceMoveCheck "+ Config.forceMoveCheck); + } + }); + } } diff --git a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java index a73be70f..36767bf1 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java @@ -85,12 +85,12 @@ public class BatteryUtil { mRuntime.setBattery(batLevel); mRuntime.setHaveBatteryChange(false); mRuntime.setBatteryLow(false); - } else if (batLevel<25 && batLevel >= 15) { + } else if (batLevel<25 && batLevel > 15) { mRuntime.setBattery(String.format("%03d",batLevel)); mRuntime.setBattery(batLevel); mRuntime.setHaveBatteryChange(true); - } else if (batLevel<15 && batLevel >= 5) { + } else if (batLevel<=15 && batLevel > 5) { if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 15%!"); @@ -149,7 +149,7 @@ public class BatteryUtil { public static void checkAndSendBatteryEvent(Context context, Runtime runtime){ //没有充电,上次电池level > 15% , 上次电池并且不是 低电状态,则报警 - if (runtime.isPowerConnected()==false && runtime.getBatterylevel()<15 && runtime.getBatteryLow()==false) { + if (runtime.isPowerConnected()==false && runtime.getBatterylevel()<= 15 && runtime.getBatterylevel()> 5) { Intent intent=new Intent(); intent.setAction(ACTION_BATTERYLOW); intent.putExtra(KEY_BATTERY_EVENT,1); @@ -160,7 +160,7 @@ public class BatteryUtil { // Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime)); ICLogger.i("triggerSOSLocationProcess "); LocationClient.getInstance().triggerSOSLocationProcess(); - }else if (runtime.isPowerConnected()==false && runtime.getBatterylevel()< 5 ) { + }else if (runtime.isPowerConnected()==false && runtime.getBatterylevel()<= 5 ) { //没有充电,上次电池level > 15% , 上次电池并且不是 电池低电状态,则报警 Intent intent=new Intent(); intent.setAction(ACTION_BATTERYLOW); @@ -233,10 +233,10 @@ public class BatteryUtil { int batLevel = (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) / intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); - if( batLevel>=15) { + if( batLevel>15) { - }else if (batLevel<15 && batLevel >= 5) { + }else if (batLevel<=15 && batLevel > 5) { if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow less than 15%!"); checkAndSendBatteryEvent(context,mRuntime); mRuntime.setBattery(String.format("%03d",batLevel)); diff --git a/app/src/main/res/layout/activity_tool.xml b/app/src/main/res/layout/activity_tool.xml index 79dd4f33..a91af8c3 100644 --- a/app/src/main/res/layout/activity_tool.xml +++ b/app/src/main/res/layout/activity_tool.xml @@ -26,7 +26,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" - android:text="重置SIM" + android:text="重置sim" android:textSize="18sp" />