-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":727,"versionName":"2012151815","enabled":true,"outputFile":"ICSer_V727_2012151815_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V727_2012151815_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":731,"versionName":"2012161523","enabled":true,"outputFile":"ICSer_V731_2012161523_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V731_2012161523_release.apk","properties":{}}]
\ No newline at end of file
import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.IClipboard;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.SystemClock;
import com.enqualcomm.support.adapter.BTHelper;
-import com.enqualcomm.support.utils.AlarmHelper;
import com.enqualcomm.support.adapter.LBSHelper;
-import com.enqualcomm.support.utils.Connection;
-import com.enqualcomm.support.utils.IBeaconUtil;
-import com.enqualcomm.support.utils.Util;
-import com.ic.protocols.protocolAPIHelper;
import com.enqualcomm.support.bean.ICLocation;
+import com.enqualcomm.support.bean.Runtime;
import com.enqualcomm.support.bean.StringMessage;
import com.enqualcomm.support.service.Deliver;
+import com.enqualcomm.support.utils.AlarmHelper;
import com.enqualcomm.support.utils.CellInfoUtil;
+import com.enqualcomm.support.utils.Connection;
import com.enqualcomm.support.utils.DeviceInfoUtil;
+import com.enqualcomm.support.utils.IBeaconUtil;
import com.enqualcomm.support.utils.ICLogger;
-import com.enqualcomm.support.utils.NettyConnection;
import com.enqualcomm.support.utils.SimSignalUtil;
-import com.enqualcomm.support.bean.Runtime;
import com.enqualcomm.support.utils.TimeUtil;
+import com.enqualcomm.support.utils.Util;
+import com.ic.protocols.protocolAPIHelper;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
* 8、每次切换定位模式,会执行一次强制定位。
*/
public class LocationClient {
- private static final String TAG = LocationClient.class.getSimpleName();
- private static final long CHANGENETMODETIME = 43200000L;
- private static long startCheckTime=0L;
- private static final int CLOSE_AIRMODE = 0;
-
- private static final int IS_GPS = 0;
-
- private static final int IS_LBS = 2;
-
- private static final int IS_WIFI = 1;
-
- public static final String LOCATION_CYCLE = "location_cycle";
-
- public static final String LOCATION_MODE = "location_mode";
-
- private static final int MAX_SIZE = 50;
-
- private static final int OPEN_AIRMODE = 1;
-
- private static final int TIME_OUT = 30000;
-
- private static Connection connection;
-
- private static boolean isLocationCallBack = false;
-
- private static boolean linkOK = false;
-
-
-
- private static boolean mHasWifiResult = true;
-
-
- private static Runtime runtime;
-
+ private static final String TAG = LocationClient.class.getSimpleName();
+ private static final long CHANGENETMODETIME = 43200000L;
+ private static long startCheckTime = 0L;
+ private static final int CLOSE_AIRMODE = 0;
+
+ private static final int IS_GPS = 0;
+
+ private static final int IS_LBS = 2;
+
+ private static final int IS_WIFI = 1;
+
+ public static final String LOCATION_CYCLE = "location_cycle";
+
+ public static final String LOCATION_MODE = "location_mode";
+
+ private static final int MAX_SIZE = 50;
+
+ private static final int OPEN_AIRMODE = 1;
+
+ private static final int TIME_OUT = 30000;
+
+ private static Connection connection;
+
+ private static boolean isLocationCallBack = false;
+
+ private static boolean linkOK = false;
+
+
+ private static boolean mHasWifiResult = true;
+
+
+ private static Runtime runtime;
+
// private int H12StepCount;
-
- private boolean batteryLowNotification;
-
- private boolean batteryNotification;
-
- private String cdmaInfo;
-
- private ExecutorService executor = Executors.newCachedThreadPool();
-
- private GSensorListener gSensorListener;
-
- private boolean haveChanegTo4G;
-
- private long haveChanegTo4GTime;
-
- private String mCellInfo;
-
-
- private LBSHelper mLbsHelper;
- private static BTHelper btHelper=null;
-
- private int mPedometer2;
-
- private SimSignalUtil mSignalUtil;
-
- private NMEAListener nmeaListener;
-
- private boolean startSOSLocation=false;
- private boolean startNomalLocation=false;
-
- private int preLbsCid;
-
- int preNetworkTypeNomber;
- private boolean scanBLEOnly=false;
-
- //如果未扫到,重试扫描的次数。
- private int maxBLEScanTime=0;
- private int ScanBLERetryCount=maxBLEScanTime;
- private int OneBLEScanTimeOUT=15;
-
- private static LocationClient gLocationCline=null;
-// private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() {
+
+ private boolean batteryLowNotification;
+
+ private boolean batteryNotification;
+
+ private String cdmaInfo;
+
+ private ExecutorService executor = Executors.newCachedThreadPool();
+
+ private GSensorListener gSensorListener;
+
+ private boolean haveChanegTo4G;
+
+ private long haveChanegTo4GTime;
+
+ private String mCellInfo;
+
+
+ private LBSHelper mLbsHelper;
+ private static BTHelper btHelper = null;
+
+ private int mPedometer2;
+
+ private SimSignalUtil mSignalUtil;
+
+ private NMEAListener nmeaListener;
+
+ private boolean startSOSLocation = false;
+ private boolean startNomalLocation = false;
+
+ private int preLbsCid;
+
+ int preNetworkTypeNomber;
+ private boolean scanBLEOnly = false;
+
+ //如果未扫到,重试扫描的次数。
+ private int maxBLEScanTime = 0;
+ private int ScanBLERetryCount = maxBLEScanTime;
+ private int OneBLEScanTimeOUT = 15;
+
+ private static LocationClient gLocationCline = null;
+
+ // private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() {
// public void onReceive(Context param1Context, Intent param1Intent) {
// if ("android.intent.action.SCREEN_ON".equals(param1Intent.getAction())) {
// mSignalUtil.setAirMode("CloseAirplane");
// }
// }
// };
- public static LocationClient getInstance(){
- return gLocationCline;
- }
- public LocationClient(Connection paramNettyConnection, Runtime paramRuntime) {
- connection = paramNettyConnection;
- runtime = paramRuntime;
- btHelper = BTHelper.CreateInstance(paramRuntime, new BTHelper.BTScanCallback() {
- @Override
- public void OnScanFinished(ArrayList<IBeaconUtil.iBeacon> btBeaconScanResult, ArrayList<String> btNewScanResult) {
- if (Config.BLEScanProtocol == 0) { //扫描并判定是否在区域内。
- if (btNewScanResult != null && btNewScanResult.size() > 0) {
- StringBuilder sb = new StringBuilder();
- sb.append("found bt mac ").append(btNewScanResult.size());
- sb.append(" bounding BeaconMacList ").append(runtime.bleInfo.btMacList.size());
- runtime.bleInfo.btScanResult.clear();
- for (String mac : runtime.bleInfo.btMacList) {
- sb.append(" ").append(mac);
- }
- ICLogger.i(sb.toString());
-
-
- boolean in_area = false;
- try {
- for (String mac : btNewScanResult) {
- ICLogger.i("bt mac " + mac.replace(":", "").toLowerCase() + " " + mac.toLowerCase());
- String tmp = mac.replace(":", "").toLowerCase();
- tmp = tmp.substring(0, tmp.indexOf(","));
- if (runtime.bleInfo.btMacList.contains(tmp)) {
- in_area = true;
- break;
+ public static LocationClient getInstance() {
+ return gLocationCline;
+ }
+
+ public LocationClient(Connection paramNettyConnection, Runtime paramRuntime) {
+ connection = paramNettyConnection;
+ runtime = paramRuntime;
+ btHelper = BTHelper.CreateInstance(paramRuntime, new BTHelper.BTScanCallback() {
+ @Override
+ public void OnScanFinished(ArrayList<IBeaconUtil.iBeacon> btBeaconScanResult, ArrayList<String> btNewScanResult) {
+ if (Config.BLEScanProtocol == 0) { //扫描并判定是否在区域内。
+ if (btNewScanResult != null && btNewScanResult.size() > 0) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("found bt mac ").append(btNewScanResult.size());
+ sb.append(" bounding BeaconMacList ").append(runtime.bleInfo.btMacList.size());
+ runtime.bleInfo.btScanResult.clear();
+ for (String mac : runtime.bleInfo.btMacList) {
+ sb.append(" ").append(mac);
+ }
+ ICLogger.i(sb.toString());
+
+
+ boolean in_area = false;
+ try {
+ for (String mac : btNewScanResult) {
+ ICLogger.i("bt mac " + mac.replace(":", "").toLowerCase() + " " + mac.toLowerCase());
+ String tmp = mac.replace(":", "").toLowerCase();
+ tmp = tmp.substring(0, tmp.indexOf(","));
+ if (runtime.bleInfo.btMacList.contains(tmp)) {
+ in_area = true;
+ break;
+ }
+ }
+ if (in_area == false && ScanBLERetryCount-- > 0) {
+ //如果没有扫描到,且扫描次数没有超限,则重新扫描一次。注意要delay 5秒
+ Util.mSleep(5000);
+ //Do retry Scan
+ ICLogger.i("BT BLE not found retry Scan " + ScanBLERetryCount);
+ btHelper.scanBLE();
+ return;
+ } else {
+ runtime.bleInfo.is_in_area = in_area;
+ ScanBLERetryCount = maxBLEScanTime;
+ }
+
+ } catch (Exception e) {//如果出错,原来的状态不要变。防止误报,最多延迟一个周期报。
+ e.printStackTrace();
+ ICLogger.i(e.getMessage());
+ }
+
+
+ } else {
+ runtime.bleInfo.is_in_area = false;
+ ScanBLERetryCount = maxBLEScanTime;
+ }
+ ICLogger.i("Bt Dev Is in Area " + runtime.bleInfo.is_in_area);
+
+ if (scanBLEOnly == true) {
+ //只扫描蓝牙,不做定位
+ if (runtime.bleInfo.is_in_area == false) {
+ runtime.updateFZDDevStatusEscape(true);
+ ICLogger.i("BT 不在区域内");
+ if (runtime.bleInfo.last_is_in_area == true) {
+ //只有上一次在区域内,这次出区域才需要报警
+ ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
+ //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
+ StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AL_CMD);
+ }
+ } else {
+ ICLogger.i("BT 在区域内!");
+ runtime.updateFZDDevStatusEscape(false);
+ if (runtime.bleInfo.last_is_in_area == false) {
+ //上一次不在区域内,这次进区域要报警
+ ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
+ if (!Config.noBLE_RelaseEscapeAlarm) {
+ //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
+ StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AL_CMD);
+ }
+ }
+ }
+ } else {
+ //定位前的蓝牙扫描
+ if (runtime.bleInfo.is_in_area == false) {
+ ICLogger.i("BT 不在区域内,开启定位流程");
+ runtime.updateFZDDevStatusEscape(true);
+ if (runtime.bleInfo.last_is_in_area == true) {
+ //只有上一次在区域内,这次出区域才需要报警
+ ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
+
+ StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AL_CMD);
+ runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+ startSOSLocation = false; //如果已经报警,后面就不用再报了
+ }
+
+ if (startSOSLocation) {
+ StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AL_CMD);
+ runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+ startSOSLocation = false;
+ }
+ if (startNomalLocation) {
+ startLocationProcess(runtime.getLocationInstance().getWorkingMod());
+ }
+
+ } else {
+ ICLogger.i("BT 在区域内,直接发送区域坐标即可!");
+ runtime.updateFZDDevStatusEscape(false);
+ if (runtime.bleInfo.last_is_in_area == false) {
+ //上一次不在区域内,这次进区域要报警
+ ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
+
+ if (!Config.noBLE_RelaseEscapeAlarm) {
+ //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
+ StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AL_CMD);
+ runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+ startSOSLocation = false;//如果已经报警,后面就不用再报了
+ }
+ }
+
+ if (startSOSLocation) {
+ StringMessage AP01_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AP01_CMD);
+ runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+ startSOSLocation = false;
+ }
+ if (startNomalLocation) {
+ //已经通过蓝牙定位,则清除 forceLocation=0
+ forceLocation = 0;
+ startNomalLocation = false; //蓝牙定位,直接发GPS坐标
+ StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);
+ DeliverMessage(AP01_CMD);
+ }
+ }
+ }
+
+ //处理过此次数据后,把当前状态赋值给上次检测状态
+ runtime.bleInfo.last_is_in_area = runtime.bleInfo.is_in_area;
+ //扫描结束就清掉scanBLEOnly,保证下次不会被误操作。
+ scanBLEOnly = false;
+ } else {
+ //Config.BLEScanProtocol == 1
+ if (btBeaconScanResult != null && btBeaconScanResult.size() > 0) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("found bt mac ").append(btBeaconScanResult.size());
+ runtime.bleInfo.btScanResult.clear();
+ for (IBeaconUtil.iBeacon beacon : btBeaconScanResult) {
+ sb.append("\n").append(beacon.toString());
+ if (runtime.bleInfo.btMajorList.size() > 0) {
+ if (runtime.bleInfo.btMajorList.contains(String.valueOf(beacon.major))) {
+ runtime.bleInfo.btScanResult.add(beacon.toString());
+ sb.append(" in list!");
+ } else {
+ sb.append(" not in!");
+ }
+ } else {
+ runtime.bleInfo.btScanResult.add(beacon.toString());
+ }
+ }
+ ICLogger.i(sb.toString());
+ Deliver.sendLocationMSG(protocolAPIHelper.getBLEScanResult(runtime));
+ } else {
+ ICLogger.i("未搜到蓝牙设备!");
+ }
}
- }
- if (in_area == false && ScanBLERetryCount-- > 0) {
- //如果没有扫描到,且扫描次数没有超限,则重新扫描一次。注意要delay 5秒
- Util.mSleep(5000);
- //Do retry Scan
- ICLogger.i("BT BLE not found retry Scan " + ScanBLERetryCount);
- btHelper.scanBLE();
- return;
- } else {
- runtime.bleInfo.is_in_area = in_area;
- ScanBLERetryCount = maxBLEScanTime;
- }
-
- } catch (Exception e) {//如果出错,原来的状态不要变。防止误报,最多延迟一个周期报。
- e.printStackTrace();
- ICLogger.i(e.getMessage());
}
+ });
+
+ btHelper.setBLEScanTimeout(OneBLEScanTimeOUT);
+ gLocationCline = this;
+ //GPS 监听管理初始化
+ this.nmeaListener = new NMEAListener(paramRuntime.getContextProxy().getLocationManager(), paramRuntime);
+ // 初始化同时开启计步(硬件计步器,比较省电,全程开启计步功能)
+ this.gSensorListener = new GSensorListener(paramRuntime);
+ }
+ private LocationResponseUrl responseUrl = null;
- } else {
- runtime.bleInfo.is_in_area = false;
- ScanBLERetryCount = maxBLEScanTime;
- }
- ICLogger.i("Bt Dev Is in Area " + runtime.bleInfo.is_in_area);
-
- if (scanBLEOnly == true) {
- //只扫描蓝牙,不做定位
- if (runtime.bleInfo.is_in_area == false) {
- runtime.updateFZDDevStatusEscape(true);
- ICLogger.i("BT 不在区域内");
- if (runtime.bleInfo.last_is_in_area == true) {
- //只有上一次在区域内,这次出区域才需要报警
- ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
- //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
- StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AL_CMD);
- }
- } else {
- ICLogger.i("BT 在区域内!");
- runtime.updateFZDDevStatusEscape(false);
- if (runtime.bleInfo.last_is_in_area == false) {
- //上一次不在区域内,这次进区域要报警
- ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
- if(!Config.noBLE_RelaseEscapeAlarm) {
- //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
- StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AL_CMD);
- }
- }
- }
- } else {
- //定位前的蓝牙扫描
- if (runtime.bleInfo.is_in_area == false) {
- ICLogger.i("BT 不在区域内,开启定位流程");
- runtime.updateFZDDevStatusEscape(true);
- if (runtime.bleInfo.last_is_in_area == true) {
- //只有上一次在区域内,这次出区域才需要报警
- ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
-
- StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AL_CMD);
- runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
- startSOSLocation = false; //如果已经报警,后面就不用再报了
- }
-
- if (startSOSLocation) {
- StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AL_CMD);
- runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
- startSOSLocation = false;
- }
- if (startNomalLocation) {
- startLocationProcess(runtime.getLocationInstance().getWorkingMod());
- }
+ public void setLocationResponse(LocationResponseUrl lru) {
+ responseUrl = lru;
+ }
- } else {
- ICLogger.i("BT 在区域内,直接发送区域坐标即可!");
- runtime.updateFZDDevStatusEscape(false);
- if (runtime.bleInfo.last_is_in_area == false) {
- //上一次不在区域内,这次进区域要报警
- ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
-
- if(!Config.noBLE_RelaseEscapeAlarm) {
- //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
- StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AL_CMD);
- runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
- startSOSLocation = false;//如果已经报警,后面就不用再报了
- }
- }
-
- if (startSOSLocation) {
- StringMessage AP01_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AP01_CMD);
- runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
- startSOSLocation = false;
- }
- if (startNomalLocation) {
- //已经通过蓝牙定位,则清除 forceLocation=0
- forceLocation = 0;
- startNomalLocation = false; //蓝牙定位,直接发GPS坐标
- StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);
- DeliverMessage(AP01_CMD);
- }
- }
- }
+ public interface LocationResponseUrl {
+ abstract public void replyCallBack(String locationResponseUrl);
+ }
- //处理过此次数据后,把当前状态赋值给上次检测状态
- runtime.bleInfo.last_is_in_area = runtime.bleInfo.is_in_area;
- //扫描结束就清掉scanBLEOnly,保证下次不会被误操作。
- scanBLEOnly = false;
- } else {
- //Config.BLEScanProtocol == 1
- if (btBeaconScanResult != null && btBeaconScanResult.size() > 0) {
- StringBuilder sb = new StringBuilder();
- sb.append("found bt mac ").append(btBeaconScanResult.size());
- runtime.bleInfo.btScanResult.clear();
- for (IBeaconUtil.iBeacon beacon : btBeaconScanResult) {
- sb.append("\n").append(beacon.toString());
- if (runtime.bleInfo.btMajorList.size()>0) {
- if (runtime.bleInfo.btMajorList.contains(String.valueOf(beacon.major))) {
- runtime.bleInfo.btScanResult.add(beacon.toString());
- sb.append(" in list!");
- } else {
- sb.append(" not in!");
+ ;
+
+ private void handler2GTo4G() {
+ int networktype = this.mSignalUtil.getNetworkType();
+ int singal = runtime.getSignalStrength();
+ long currenttime = SystemClock.elapsedRealtime();
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("networkType=");
+ stringBuilder.append(networktype);
+ stringBuilder.append("signalStrength=");
+ stringBuilder.append(singal);
+ stringBuilder.append("haveChanegTo4G=");
+ stringBuilder.append(this.haveChanegTo4G);
+ ICLogger.i(stringBuilder.toString());
+ switch (networktype) {
+ default:
+ return;
+ case SimSignalUtil.IS_4G:
+ if (singal < -93) {
+ this.mSignalUtil.changeNetWorkType("2G");
+ this.haveChanegTo4GTime = currenttime;
+ return;
}
- }else{
- runtime.bleInfo.btScanResult.add(beacon.toString());
- }
- }
- ICLogger.i(sb.toString());
- Deliver.sendLocationMSG(protocolAPIHelper.getBLEScanResult(runtime));
- } else {
- ICLogger.i("未搜到蓝牙设备!");
- }
+ return;
+ case SimSignalUtil.IS_2G:
+ case SimSignalUtil.IS_3G:
+ break;
}
- }
- });
-
- btHelper.setBLEScanTimeout(OneBLEScanTimeOUT);
- gLocationCline = this;
- //GPS 监听管理初始化
- this.nmeaListener = new NMEAListener(paramRuntime.getContextProxy().getLocationManager(), paramRuntime);
- // 初始化同时开启计步(硬件计步器,比较省电,全程开启计步功能)
- this.gSensorListener = new GSensorListener(paramRuntime);
- }
-
- private LocationResponseUrl responseUrl=null;
- public void setLocationResponse(LocationResponseUrl lru){
- responseUrl=lru;
- }
- public interface LocationResponseUrl{
- abstract public void replyCallBack(String locationResponseUrl);
- };
-
- private void handler2GTo4G() {
- int networktype = this.mSignalUtil.getNetworkType();
- int singal = runtime.getSignalStrength();
- long currenttime = SystemClock.elapsedRealtime();
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("networkType=");
- stringBuilder.append(networktype);
- stringBuilder.append("signalStrength=");
- stringBuilder.append(singal);
- stringBuilder.append("haveChanegTo4G=");
- stringBuilder.append(this.haveChanegTo4G);
- ICLogger.i(stringBuilder.toString());
- switch (networktype) {
- default:
- return;
- case SimSignalUtil.IS_4G:
- if (singal < -93) {
- this.mSignalUtil.changeNetWorkType("2G");
- this.haveChanegTo4GTime = currenttime;
- return;
+ if (this.haveChanegTo4G || currenttime - this.haveChanegTo4GTime > 43200000L) {
+ this.mSignalUtil.changeNetWorkType("4G");
+ this.haveChanegTo4G = false;
+ this.haveChanegTo4GTime = currenttime;
}
- return;
- case SimSignalUtil.IS_2G:
- case SimSignalUtil.IS_3G:
- break;
}
- if (this.haveChanegTo4G || currenttime - this.haveChanegTo4GTime > 43200000L) {
- this.mSignalUtil.changeNetWorkType("4G");
- this.haveChanegTo4G = false;
- this.haveChanegTo4GTime = currenttime;
- }
- }
- //计算运动并发送数据
- public void updateStepCount() {
- this.gSensorListener.updateStepCount();
+
+ //计算运动并发送数据
+ public void updateStepCount() {
+ this.gSensorListener.updateStepCount();
// this.H12StepCount = DeviceInfoUtil.getStepCount((runtime.getContextProxy()).context);
// if (i != 0 && Math.abs(this.H12StepCount - this.mPedometer2) > 1000) {
// ICLogger.i("StepCount 运动开始后 变化超过1000 ,则发送给服务器!");
// }
- }
+ }
- private void performAlarm(PowerManager.WakeLock paramWakeLock) {
+ private void performAlarm(PowerManager.WakeLock paramWakeLock) {
// if (!runtime.isAirMode) {
- updateStepCount();//update StepCount
- // CellInfoUtil.triggerUpdateCellinfo(); //这个在locationClinet中也会执行更新
+ updateStepCount();//update StepCount
+ // CellInfoUtil.triggerUpdateCellinfo(); //这个在locationClinet中也会执行更新
// sendBatteryNotification();
// }
- }
- public void triggerLocationProcess(){
- mhandler.sendEmptyMessage(msgWhat_StartLocationProcess);
- }
-
- public void triggerBLEProcess(){
- mhandler.sendEmptyMessage(msgWhat_StartBLEProcess);
- }
-
- public void triggerSOSLocationProcess(){
-
- mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess);
-
- }
-
- private static int checktimes=0;
- private static boolean timeout=false;
- private static boolean isLocating=false;
- private static boolean isWifiScanning=false;
- LBSHelper.OnWiFiInfoListener wifiinfoListener=new LBSHelper.OnWiFiInfoListener() {
- public void getWifiInfoCallBack(String param1String) {
- ICLogger.i("get wifi scan Callback " + param1String);
- LocationClient.mHasWifiResult=true;
- runtime.setWifiinfo(param1String==null?"":param1String);
- isWifiScanning=false;
}
- };
- public void startWifiScan(){
-
- if (isWifiScanning==false) {
- ICLogger.i("开启wifi扫描");
- isWifiScanning=true;
- runtime.setWifiinfo("");
- mHasWifiResult = false;
- this.mLbsHelper.setOnWiFiInfoListener(wifiinfoListener);
- this.mLbsHelper.getWifiInfo();
- }else{
- ICLogger.i("wifi扫描进行中,skip开启");
+
+ public void triggerLocationProcess() {
+ mhandler.sendEmptyMessage(msgWhat_StartLocationProcess);
+ }
+
+ public void triggerBLEProcess() {
+ mhandler.sendEmptyMessage(msgWhat_StartBLEProcess);
+ }
+
+ public void triggerSOSLocationProcess() {
+
+ mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess);
+
+ }
+
+ private static int checktimes = 0;
+ private static boolean timeout = false;
+ private static boolean isLocating = false;
+ private static boolean isWifiScanning = false;
+ LBSHelper.OnWiFiInfoListener wifiinfoListener = new LBSHelper.OnWiFiInfoListener() {
+ public void getWifiInfoCallBack(String param1String) {
+ ICLogger.i("get wifi scan Callback " + param1String);
+ LocationClient.mHasWifiResult = true;
+ runtime.setWifiinfo(param1String == null ? "" : param1String);
+ isWifiScanning = false;
+ }
+ };
+
+ public void startWifiScan() {
+
+ if (isWifiScanning == false) {
+ ICLogger.i("开启wifi扫描");
+ isWifiScanning = true;
+ runtime.setWifiinfo("");
+ mHasWifiResult = false;
+ this.mLbsHelper.setOnWiFiInfoListener(wifiinfoListener);
+ this.mLbsHelper.getWifiInfo();
+ } else {
+ ICLogger.i("wifi扫描进行中,skip开启");
+ }
}
- }
+
public void startGpsLocate() {
- boolean FactryModeOpening=DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context);
- boolean needReOpenGPS=runtime.getFactoryTestingStat();
-
- //防止与工厂测试冲突
- if (FactryModeOpening==false || needReOpenGPS==true) {
-
- if (needReOpenGPS==true) {
- ICLogger.i("工厂模式关闭了GPS,需要重新关闭GPS以同步状态!");
- //处理过后,要把状态设置为初始状态,防止每次都重启。
- runtime.setFactoryTestingStat(false);
- //如果发现需要重启GPS,为了状态正确,需要先停止GPS
- nmeaListener.stopListen();
- }
- ICLogger.i("开启GPS扫描!");
- if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","开启GPS扫描!");
- if (!nmeaListener.isListening()) {
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
+ boolean FactryModeOpening = DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context);
+ boolean needReOpenGPS = runtime.getFactoryTestingStat();
+
+ //防止与工厂测试冲突
+ if (FactryModeOpening == false || needReOpenGPS == true) {
+
+ if (needReOpenGPS == true) {
+ ICLogger.i("工厂模式关闭了GPS,需要重新关闭GPS以同步状态!");
+ //处理过后,要把状态设置为初始状态,防止每次都重启。
+ runtime.setFactoryTestingStat(false);
+ //如果发现需要重启GPS,为了状态正确,需要先停止GPS
+ nmeaListener.stopListen();
+ }
+ ICLogger.i("开启GPS扫描!");
+ if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "开启GPS扫描!");
+ if (!nmeaListener.isListening()) {
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
// public void call(Object param1Object) {
// nmeaListener.startListen();
// }
// });
- nmeaListener.startListen();
+ nmeaListener.startListen();
+ } else {
+ ICLogger.i("GPS is still listening, skip open it!");
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
+ if (Config.LOG_TOFILE)
+ ICLogger.logToFile("GPS", "GPS is still listening, skip open it!");
+ }
} else {
- ICLogger.i("GPS is still listening, skip open it!");
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
- if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "GPS is still listening, skip open it!");
+ ICLogger.i("工厂模式,skip 开启GPS扫描!");
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
+ if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "工厂模式,skip 开启GPS扫描!");
}
- }else{
- ICLogger.i("工厂模式,skip 开启GPS扫描!");
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
- if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","工厂模式,skip 开启GPS扫描!");
- }
- }
-
- public void clearGPSlocateStat(){
- ICLogger.i("clearGPSlocateStat");
- stopGpsLocate();
- runtime.getLocationInstance().setLocationStat( ICLocation.LOCATION_STAT.LOCATION_CLOSED);//此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
- }
+ }
- public void startCheckResult(){
- checktimes=0;
- timeout=false;
- startCheckTime= System.currentTimeMillis();
- needCheckAgain=true;
- ICLogger.i("startCheckResult " );
+ public void clearGPSlocateStat() {
+ ICLogger.i("clearGPSlocateStat");
+ stopGpsLocate();
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_CLOSED);//此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
+ }
- AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context,1,ACTION_CHECK_LOCATION_RESULT);
+ public void startCheckResult() {
+ checktimes = 0;
+ timeout = false;
+ startCheckTime = System.currentTimeMillis();
+ needCheckAgain = true;
+ ICLogger.i("startCheckResult ");
- }
+ AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, 1, ACTION_CHECK_LOCATION_RESULT);
+ }
- private final static int msgWhat_WaitAndSendLocation=100;
- private final static int msgWhat_StartLocationProcess=0;
- private final static int msgWhat_StartBLEProcess=1;
- private final static int msgWhat_StartSOSLocationProcess=2;
- Handler mhandler=new Handler(){
+ private final static int msgWhat_WaitAndSendLocation = 100;
+ private final static int msgWhat_StartLocationProcess = 0;
+ private final static int msgWhat_StartBLEProcess = 1;
+ private final static int msgWhat_StartSOSLocationProcess = 2;
+ Handler mhandler = new Handler() {
public void handleMessage(Message msg) {
- super.handleMessage(msg);
- if (msg.what == msgWhat_WaitAndSendLocation){
- Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
- public void call(Object param1Object) { waitAndSendLocation(); }
- });
- }else if (msg.what == msgWhat_StartLocationProcess) {
- startNomalLocation=true;
- if (Config.BLEScanProtocol == 0 && runtime.bleInfo.btMacList.size() > 0) {
- if(scanBLEOnly && btHelper.isBtscanning()){
- //如果正在进行独立蓝牙扫描,则强制切换为正常扫描。
- scanBLEOnly=false;
- }else {
- //有蓝牙搜索要求则 先进行蓝牙扫描
- if (needLocation()) {
- btHelper.scanBLE();
- }
- }
- } else {
- //没有蓝牙搜索要求,就正常定位
- startLocationProcess(runtime.getLocationInstance().getWorkingMod());
- }
- }else if (msg.what == msgWhat_StartBLEProcess){
- if(Config.BLEScanProtocol==0) {
- if (runtime.bleInfo.btMacList.size() > 0) {
- //有蓝牙搜索要求则 先进行蓝牙扫描
- if (!btHelper.isBtscanning()) {
- scanBLEOnly = true;
- if (needLocationForBT()) {
- ICLogger.i("msgWhat_StartBLEProcess");
- btHelper.scanBLE();
- }
+ super.handleMessage(msg);
+ if (msg.what == msgWhat_WaitAndSendLocation) {
+ Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
+ public void call(Object param1Object) {
+ waitAndSendLocation();
+ }
+ });
+ } else if (msg.what == msgWhat_StartLocationProcess) {
+ startNomalLocation = true;
+ if (Config.BLEScanProtocol == 0 && runtime.bleInfo.btMacList.size() > 0) {
+ if (scanBLEOnly && btHelper.isBtscanning()) {
+ //如果正在进行独立蓝牙扫描,则强制切换为正常扫描。
+ scanBLEOnly = false;
+ } else {
+ //有蓝牙搜索要求则 先进行蓝牙扫描
+ if (needLocation()) {
+ btHelper.scanBLE();
+ }
+ }
} else {
- ICLogger.i("BT Scanning skip ScanBLE only!");
+ //没有蓝牙搜索要求,就正常定位
+ startLocationProcess(runtime.getLocationInstance().getWorkingMod());
}
- }
- }else{
- //有蓝牙搜索要求则 先进行蓝牙扫描
- if (!btHelper.isBtscanning()) {
- if (needLocationForBT()) {
- ICLogger.i("msgWhat_StartBLEProcess2");
- btHelper.scanBLE();
- }
- } else {
- ICLogger.i("BT Scanning skip ScanBLE only2!");
- }
- }
- }else if (msg.what == msgWhat_StartSOSLocationProcess){
-
- if (runtime !=null) {
- //更新lbs信息
- CellInfoUtil.getCellInfo(runtime.getContextProxy().getTelephonyManager(),runtime);
-
- if (Config.BLEScanProtocol==0 && runtime.bleInfo.btMacList.size() > 0) {
- startSOSLocation = true;//启动SOS定位,为了快速响应,只要wifi定位即可。
- if (scanBLEOnly && btHelper.isBtscanning()) {
- //如果正在进行独立蓝牙扫描,则强制切换为正常扫描。
- scanBLEOnly = false;
- } else {
- //SOS location 有蓝牙搜索要求则 先进行蓝牙扫描
- forceLocation = 1;
- if(!btHelper.isBtscanning())
- btHelper.scanBLE();
- }
+ } else if (msg.what == msgWhat_StartBLEProcess) {
+ if (Config.BLEScanProtocol == 0) {
+ if (runtime.bleInfo.btMacList.size() > 0) {
+ //有蓝牙搜索要求则 先进行蓝牙扫描
+ if (!btHelper.isBtscanning()) {
+ scanBLEOnly = true;
+ if (needLocationForBT()) {
+ ICLogger.i("msgWhat_StartBLEProcess");
+ btHelper.scanBLE();
+ }
+ } else {
+ ICLogger.i("BT Scanning skip ScanBLE only!");
+ }
+ }
} else {
- Util.mSleep(1000);
- StringMessage waningmsg = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(waningmsg);
+ //有蓝牙搜索要求则 先进行蓝牙扫描
+ if (!btHelper.isBtscanning()) {
+ if (needLocationForBT()) {
+ ICLogger.i("msgWhat_StartBLEProcess2");
+ btHelper.scanBLE();
+ }
+ } else {
+ ICLogger.i("BT Scanning skip ScanBLE only2!");
+ }
+ }
+ } else if (msg.what == msgWhat_StartSOSLocationProcess) {
+
+ if (runtime != null) {
+ //更新lbs信息
+ CellInfoUtil.getCellInfo(runtime.getContextProxy().getTelephonyManager(), runtime);
+
+ if (Config.BLEScanProtocol == 0 && runtime.bleInfo.btMacList.size() > 0) {
+ startSOSLocation = true;//启动SOS定位,为了快速响应,只要wifi定位即可。
+ if (scanBLEOnly && btHelper.isBtscanning()) {
+ //如果正在进行独立蓝牙扫描,则强制切换为正常扫描。
+ scanBLEOnly = false;
+ } else {
+ //SOS location 有蓝牙搜索要求则 先进行蓝牙扫描
+ forceLocation = 1;
+ if (!btHelper.isBtscanning())
+ btHelper.scanBLE();
+ }
+ } else {
+ Util.mSleep(1000);
+ StringMessage waningmsg = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(waningmsg);
+ }
}
- }
//
// } else {
// startLocationProcess(ICLocation.NORMAL_MOD);
// }
- }
+ }
}
- };
+ };
+
+ boolean wifi_ok = false, gps_ok = false, lbs_ok = false, gps_nosignal = false;
- boolean wifi_ok=false,gps_ok=false,lbs_ok=false,gps_nosignal=false;
+ private static boolean needCheckAgain = false;
- private static boolean needCheckAgain=false;
- public void waitAndSendLocation(){
+ public void waitAndSendLocation() {
this.mLbsHelper.getWifiResult();
- long timeCost=0L;
- wifi_ok=false;
- gps_ok=false;
- lbs_ok=false;
- gps_nosignal=false;
+ long timeCost = 0L;
+ wifi_ok = false;
+ gps_ok = false;
+ lbs_ok = false;
+ gps_nosignal = false;
checktimes++;
- int mode=runtime.getLocationInstance().getWorkingMod();
- if (runtime.getWifiInfo().length()>0 ) wifi_ok =true;
- if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_FIXED) gps_ok=true;
- if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT) gps_nosignal=true;
- lbs_ok=( runtime.getLocationInstance().isDataChanged()==false
- ||(runtime.getLocationInstance().getMNC().equals("0")
- && runtime.getLocationInstance().getMCC().equals("0")
- && runtime.getLocationInstance().getGSMStationCID() ==0
- && runtime.getLocationInstance().getLAC()==0)) ?false:true;
-
- // ICLogger.i("getMNC "+runtime.getLocationInstance().getMNC()+" getMCC "+runtime.getLocationInstance().getMCC()+" getGSMStationCID " + runtime.getLocationInstance().getGSMStationCID()+ " getLAC "+runtime.getLocationInstance().getLAC()+" changed "+runtime.getLocationInstance().isDataChanged());
- ICLogger.i("waitAndSendLocation "+checktimes+", lbs="+lbs_ok+", wifi="+ wifi_ok+ ", gps="+gps_ok + ", mode="+mode);
- if(NoMoveAndNoGPSsignalSkipGpsFlag==true){
- ICLogger.i("NoMove And NoGPSsignal SkipGpsLocation!");
- mode=ICLocation.NORMAL_MOD;//如果没有移动且没有Gps信号,则采用Normal 模式进行wifi定位
+ int mode = runtime.getLocationInstance().getWorkingMod();
+ if (runtime.getWifiInfo().length() > 0) wifi_ok = true;
+ if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_FIXED)
+ gps_ok = true;
+ if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT)
+ gps_nosignal = true;
+ lbs_ok = (runtime.getLocationInstance().isDataChanged() == false
+ || (runtime.getLocationInstance().getMNC().equals("0")
+ && runtime.getLocationInstance().getMCC().equals("0")
+ && runtime.getLocationInstance().getGSMStationCID() == 0
+ && runtime.getLocationInstance().getLAC() == 0)) ? false : true;
+
+ // ICLogger.i("getMNC "+runtime.getLocationInstance().getMNC()+" getMCC "+runtime.getLocationInstance().getMCC()+" getGSMStationCID " + runtime.getLocationInstance().getGSMStationCID()+ " getLAC "+runtime.getLocationInstance().getLAC()+" changed "+runtime.getLocationInstance().isDataChanged());
+ ICLogger.i("waitAndSendLocation " + checktimes + ", lbs=" + lbs_ok + ", wifi=" + wifi_ok + ", gps=" + gps_ok + ", mode=" + mode);
+ if (NoMoveAndNoGPSsignalSkipGpsFlag == true) {
+ ICLogger.i("NoMove And NoGPSsignal SkipGpsLocation!");
+ mode = ICLocation.NORMAL_MOD;//如果没有移动且没有Gps信号,则采用Normal 模式进行wifi定位
}
- switch(mode){
- case ICLocation.CUSTOM_MOD:
- case ICLocation.CUSTOM_MOD8_GPS:
- case ICLocation.EMERGNECY_MOD:
- case ICLocation.REALTIME_MOD:
-
-
- //GPS 优先的话多给些时间(10秒)
- if (checktimes> GPSLocationTimeoutInSeconds )
- {
- ICLogger.i("waitAndSendLocation "+checktimes+" timeout");
- timeout=true;
-
- }
- if (NoMoveTimeout==true && (timeout==true || gps_nosignal==true)){
- //没有移动,GPS超时或者没信号都会给 计数 加 1
- gpsTimeoutCountOnNoMove++;
- }
- timeCost=System.currentTimeMillis()-startCheckTime;
- if ((startCheckTime!=0L)&& (timeCost> 50*1000L)){
- //有时timer计数不准,则根据实际时间计算
- ICLogger.i("waitAndSendLocation "+timeCost+"> 50000ms timeout");
- //timeout=true;
- }
-
- // lbs only +timeout, lbs+wifi+gpsNosignal, libs+ , lbs+gps+wifi, Timeout can override wifi and gps
- if ((lbs_ok && timeout==true)
- ||( gps_ok )
- ||(lbs_ok && ( gps_ok || startSOSLocation==true ) )
- ||(lbs_ok && ( gps_ok || startSOSLocation==true ) && wifi_ok )
- ||(lbs_ok&&gps_nosignal&&wifi_ok)
- ){
- if (startSOSLocation==true){
- StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AP10_CMD);
- runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
- startSOSLocation=false;
- }
-
- if(startNomalLocation=true){
- startNomalLocation=false;
- if (gps_ok) {
- StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);
- DeliverMessage(AP01_CMD);
- }else{
- StringMessage AP02_CMD = protocolAPIHelper.getLBSLocationMSG(runtime);
- DeliverMessage(AP02_CMD);
- }
-
- }
+ switch (mode) {
+ case ICLocation.CUSTOM_MOD:
+ case ICLocation.CUSTOM_MOD8_GPS:
+ case ICLocation.EMERGNECY_MOD:
+ case ICLocation.REALTIME_MOD:
- stopCheckLocationResult();
+ //GPS 优先的话多给些时间(10秒)
+ if (checktimes > GPSLocationTimeoutInSeconds) {
+ ICLogger.i("waitAndSendLocation " + checktimes + " timeout");
+ timeout = true;
- String locationtype="LBS";
- if (gps_ok ){
- locationtype="GPS";
- }else if (wifi_ok){
- locationtype="WiFi";
- }
-
- runtime.getLocationInstance().setLocationType(locationtype);
- runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
-
- String msg="Location Fixed Type "+runtime.getLocationInstance().getLocationType()+" at "+runtime.getLocationInstance().getLocationTime()+" timeout "+timeout;
- ICLogger.i(msg);
-
- if (responseUrl!=null){
- if(locationtype.equals("GPS")){
- responseUrl.replyCallBack(runtime.getLocationInstance().getLocation().latGPSStr+","+runtime.getLocationInstance().getLocation().lonGPSStr);
- }else{
- responseUrl.replyCallBack("Location Fixed Type "+locationtype);
+ }
+ if (NoMoveTimeout == true && (timeout == true || gps_nosignal == true)) {
+ //没有移动,GPS超时或者没信号都会给 计数 加 1
+ gpsTimeoutCountOnNoMove++;
+ }
+ timeCost = System.currentTimeMillis() - startCheckTime;
+ if ((startCheckTime != 0L) && (timeCost > 50 * 1000L)) {
+ //有时timer计数不准,则根据实际时间计算
+ ICLogger.i("waitAndSendLocation " + timeCost + "> 50000ms timeout");
+ //timeout=true;
}
- }
- if (Config.LOG_TOFILE)
- ICLogger.logToFile("GPS",msg);
+ // lbs only +timeout, lbs+wifi+gpsNosignal, libs+ , lbs+gps+wifi, Timeout can override wifi and gps
+ if ((lbs_ok && timeout == true)
+ || (gps_ok)
+ || (lbs_ok && (gps_ok || startSOSLocation == true))
+ || (lbs_ok && (gps_ok || startSOSLocation == true) && wifi_ok)
+ || (lbs_ok && gps_nosignal && wifi_ok)
+ ) {
+ if (startSOSLocation == true) {
+ StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AP10_CMD);
+ runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+ startSOSLocation = false;
+ }
+
+ if (startNomalLocation = true) {
+ startNomalLocation = false;
+ if (gps_ok) {
+ StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);
+ DeliverMessage(AP01_CMD);
+ } else {
+ StringMessage AP02_CMD = protocolAPIHelper.getLBSLocationMSG(runtime);
+ DeliverMessage(AP02_CMD);
+ }
+
+ }
+
+
+ stopCheckLocationResult();
+
+ String locationtype = "LBS";
+ if (gps_ok) {
+ locationtype = "GPS";
+ } else if (wifi_ok) {
+ locationtype = "WiFi";
+ }
+
+ runtime.getLocationInstance().setLocationType(locationtype);
+ runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
+
+ String msg = "Location Fixed Type " + runtime.getLocationInstance().getLocationType() + " at " + runtime.getLocationInstance().getLocationTime() + " timeout " + timeout;
+ ICLogger.i(msg);
+
+ if (responseUrl != null) {
+ if (locationtype.equals("GPS")) {
+ responseUrl.replyCallBack(runtime.getLocationInstance().getLocation().latGPSStr + "," + runtime.getLocationInstance().getLocation().lonGPSStr);
+ } else {
+ responseUrl.replyCallBack("Location Fixed Type " + locationtype);
+ }
+
+ }
+ if (Config.LOG_TOFILE)
+ ICLogger.logToFile("GPS", msg);
+
+
+ } else if (timeout == true) {
+ //timeout + noLBS +noGPS
+ ICLogger.i("timeout no location ");
+ stopCheckLocationResult();
+ if (Config.LOG_TOFILE)
+ ICLogger.logToFile("GPS", "timeout no location ");
+ }
+ break;
+ case ICLocation.NORMAL_MOD:
+ case ICLocation.LOWPOWER_MOD:
+ case ICLocation.CUSTOM_MOD8_WIFI:
+ default:
+ //wifi优先的话给20秒时间
- }else if (timeout==true){
- //timeout + noLBS +noGPS
- ICLogger.i("timeout no location ");
- stopCheckLocationResult();
- if (Config.LOG_TOFILE)
- ICLogger.logToFile("GPS","timeout no location ");
- }
- break;
-
- case ICLocation.NORMAL_MOD:
- case ICLocation.LOWPOWER_MOD:
- case ICLocation.CUSTOM_MOD8_WIFI:
- default:
- //wifi优先的话给20秒时间
-
- if (checktimes> WiFiLocationTimeoutInSeconds )
- {
- ICLogger.i("waitAndSendLocation "+checktimes+" timeout");
- timeout=true;
- }
- timeCost=System.currentTimeMillis()-startCheckTime;
- if ((startCheckTime!=0L)&& (timeCost> 20*1000L)){
- //有时timer计数不准,则根据实际时间计算
- ICLogger.i("waitAndSendLocation "+timeCost+"> 20000ms timeout");
- // timeout=true;
- }
+ if (checktimes > WiFiLocationTimeoutInSeconds) {
+ ICLogger.i("waitAndSendLocation " + checktimes + " timeout");
+ timeout = true;
+ }
+ timeCost = System.currentTimeMillis() - startCheckTime;
+ if ((startCheckTime != 0L) && (timeCost > 20 * 1000L)) {
+ //有时timer计数不准,则根据实际时间计算
+ ICLogger.i("waitAndSendLocation " + timeCost + "> 20000ms timeout");
+ // timeout=true;
+ }
- if ((lbs_ok && timeout==true) ||(lbs_ok && wifi_ok )){
-
-
- if (startSOSLocation==true){
- StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);
- DeliverMessage(AP10_CMD);
- runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
- startSOSLocation=false;
- }
- if(startNomalLocation=true){
- startNomalLocation=false;
- StringMessage AP02_CMD = protocolAPIHelper.getLBSLocationMSG(runtime);
- DeliverMessage(AP02_CMD);
- }
-
- stopCheckLocationResult();
-
- String locationtype="LBS";
- if (wifi_ok){
- locationtype="WiFi";
- }
- runtime.getLocationInstance().setLocationType(locationtype);
- runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
-
- String msg="Location Fixed Type "+runtime.getLocationInstance().getLocationType()+" at "+runtime.getLocationInstance().getLocationTime()+" timeout "+timeout;
- ICLogger.i(msg);
-
- if (responseUrl!=null){
- responseUrl.replyCallBack("Location Fixed Type "+locationtype);
- }
- if (Config.LOG_TOFILE)
- ICLogger.logToFile("GPS",msg);
-
-
- }else if (timeout==true){
- ICLogger.i("timeout no location ");
- stopCheckLocationResult();
- if (Config.LOG_TOFILE)
- ICLogger.logToFile("GPS","timeout no location ");
- }
- break;
+ if ((lbs_ok && timeout == true) || (lbs_ok && wifi_ok)) {
+
+
+ if (startSOSLocation == true) {
+ StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);
+ DeliverMessage(AP10_CMD);
+ runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+ startSOSLocation = false;
+ }
+ if (startNomalLocation = true) {
+ startNomalLocation = false;
+ StringMessage AP02_CMD = protocolAPIHelper.getLBSLocationMSG(runtime);
+ DeliverMessage(AP02_CMD);
+ }
+
+ stopCheckLocationResult();
+
+ String locationtype = "LBS";
+ if (wifi_ok) {
+ locationtype = "WiFi";
+ }
+ runtime.getLocationInstance().setLocationType(locationtype);
+ runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
+
+ String msg = "Location Fixed Type " + runtime.getLocationInstance().getLocationType() + " at " + runtime.getLocationInstance().getLocationTime() + " timeout " + timeout;
+ ICLogger.i(msg);
+
+ if (responseUrl != null) {
+ responseUrl.replyCallBack("Location Fixed Type " + locationtype);
+ }
+ if (Config.LOG_TOFILE)
+ ICLogger.logToFile("GPS", msg);
+
+
+ } else if (timeout == true) {
+ ICLogger.i("timeout no location ");
+ stopCheckLocationResult();
+ if (Config.LOG_TOFILE)
+ ICLogger.logToFile("GPS", "timeout no location ");
+ }
+ break;
}
- ICLogger.i("needCheckAgain "+needCheckAgain);
- if(needCheckAgain) {
- AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, 1, ACTION_CHECK_LOCATION_RESULT);
+ ICLogger.i("needCheckAgain " + needCheckAgain);
+ if (needCheckAgain) {
+ AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, 1, ACTION_CHECK_LOCATION_RESULT);
}
- }
+ }
- private void DeliverMessage(StringMessage msg){
+ private void DeliverMessage(StringMessage msg) {
// if(Runtime.practising==true){
// if(msg==null){
// Runtime.healthInfo.resetBuffer();
// }
// }else {
- Deliver.sendLocationMSG(msg);
+ Deliver.sendLocationMSG(msg);
// }
- }
- public void stopCheckLocationResult(){
- ICLogger.i("stopCheckLocationResult!");
+ }
+
+ public void stopCheckLocationResult() {
+ ICLogger.i("stopCheckLocationResult!");
// if (mTimer!=null){
// mTimer.shutdownNow();
// Runnable tmp= mTimer.getQueue().poll();
// mTimer=null;
// }
- needCheckAgain=false;
- isLocating = false;
- startCheckTime=0L;
- isWifiScanning=false;
+ needCheckAgain = false;
+ isLocating = false;
+ startCheckTime = 0L;
+ isWifiScanning = false;
// ICLogger.i(" stopCheckLocationResult Done ");
- }
+ }
-// public void EqcAlgorithmInterfaceMethod3() {
- public void stopGpsLocate() {
+ // public void EqcAlgorithmInterfaceMethod3() {
+ public void stopGpsLocate() {
- boolean FactryModeOpening=DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context);
- //防止与工厂测试冲突
- if (FactryModeOpening==false ) {
- ICLogger.i("stopGpsLocate");
- if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","stopGpsLocate");
- nmeaListener.stopListen();
+ boolean FactryModeOpening = DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context);
+ //防止与工厂测试冲突
+ if (FactryModeOpening == false) {
+ ICLogger.i("stopGpsLocate");
+ if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "stopGpsLocate");
+ nmeaListener.stopListen();
// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
// public void call(Object param1Object) {
// nmeaListener.stopListen();
// }
// });
- }else{
- ICLogger.i("工厂模式 skip stopGpsLocate");
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
- if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","工厂模式 skip stopGpsLocate");
+ } else {
+ ICLogger.i("工厂模式 skip stopGpsLocate");
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态
+ if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "工厂模式 skip stopGpsLocate");
+ }
+ }
+
+
+ public void updateCellInfo() {
+ CellInfoUtil.setCurrentAttachCellInfo(runtime);
+ }
+
+
+ public PowerManager.WakeLock getLocationWakeLock() {
+ PowerManager.WakeLock wakeLock = ((PowerManager) (runtime.getContextProxy()).context.getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getSimpleName());
+ wakeLock.acquire(1000L);
+ return wakeLock;
}
- }
-
-
-public void updateCellInfo() {
- CellInfoUtil.setCurrentAttachCellInfo(runtime);
- }
-
-
- public PowerManager.WakeLock getLocationWakeLock() {
- PowerManager.WakeLock wakeLock = ((PowerManager)(runtime.getContextProxy()).context.getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getSimpleName());
- wakeLock.acquire(1000L);
- return wakeLock;
- }
-
- public void onAlarm(PowerManager.WakeLock paramWakeLock) {
- //每分钟更新一次数据
- runtime.preCellInfo = runtime.getCurrentCellInfo();
- runtime.preCdmaInfo = runtime.getCdmaInfo();
- runtime.preTime = TimeUtil.getSystemTime(System.currentTimeMillis() - (CoreService.alarmCycle * 60 * 1000));
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("runtime.preCellInfo=");
- stringBuilder.append(runtime.preCellInfo);
- ICLogger.i(stringBuilder.toString());
- performAlarm(paramWakeLock);
- }
-
-
- private static int gpsTimeoutCountOnNoMove=0;// 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。
- private static final int MaxGpsTimeoutCountOnNoMove=5;//不动的情况最大的gps搜不到星的次数。
- private static boolean skipMoveCheck=false;
-
-
- public static void setSkipMoveCheck(boolean _skipMoveCheck){
- skipMoveCheck=_skipMoveCheck;
- }
- public static boolean getSkipMoveCheck(){
- return skipMoveCheck;
- }
-
- private static boolean NoMoveAndNoGPSsignalSkipGpsFlag=false;
- private static boolean noMove=false;
- private static boolean NoMoveTimeout=false;
- private static boolean last_noMove=false;
- private static final int MaxNoMoveTimeout=3*60*1000; //3分钟
- private static long first_NoMove_timestamp=0;
- private static long first_NoMove_timestampForBT=0;
- private static boolean last_noMoveForBT=false;
-
- /***
- *noMove and timeout return true
- * else return false
- */
- private boolean checkNoMoveTimeoutForBT(){
- noMove= (( runtime.getTotalStepCount() - runtime.getLastStepCountForBT())<=0) ;
- runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态
- ICLogger.i("BT checkNoMoveTimeout last_noMoveForBT "+last_noMoveForBT+" noMove "+noMove+ " lastStepCountForBT "+runtime.getLastStepCountForBT()+" StepCount "+runtime.getTotalStepCount());
- if (last_noMoveForBT==false&& noMove==true){
- first_NoMove_timestampForBT=System.currentTimeMillis();
- }else if (noMove==false){
- first_NoMove_timestampForBT=0;
+
+ public void onAlarm(PowerManager.WakeLock paramWakeLock) {
+ //每分钟更新一次数据
+ runtime.preCellInfo = runtime.getCurrentCellInfo();
+ runtime.preCdmaInfo = runtime.getCdmaInfo();
+ runtime.preTime = TimeUtil.getSystemTime(System.currentTimeMillis() - (CoreService.alarmCycle * 60 * 1000));
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("runtime.preCellInfo=");
+ stringBuilder.append(runtime.preCellInfo);
+ ICLogger.i(stringBuilder.toString());
+ performAlarm(paramWakeLock);
}
- last_noMoveForBT=noMove;
- //属于 判断是否 不动的状态超时
- if (noMove==true&& first_NoMove_timestampForBT>0.01 && System.currentTimeMillis()-first_NoMove_timestampForBT > MaxNoMoveTimeout){
- ICLogger.i("BT checkNoMoveTimeout true ");
- return true;
- }else{
- ICLogger.i("BT checkNoMoveTimeout false");
- return false;
+
+
+ private static int gpsTimeoutCountOnNoMove = 0;// 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。
+ private static final int MaxGpsTimeoutCountOnNoMove = 5;//不动的情况最大的gps搜不到星的次数。
+ private static boolean skipMoveCheck = false;
+
+
+ public static void setSkipMoveCheck(boolean _skipMoveCheck) {
+ skipMoveCheck = _skipMoveCheck;
}
- }
-
- /***
- *noMove and timeout return true
- * else return false
- */
- private boolean checkNoMoveTimeout(){
- noMove=(runtime.getTotalStepCount() - runtime.getLastStepCount() <=0);
- runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态
- ICLogger.i("checkNoMoveTimeout last_noMove "+last_noMove+" noMove "+noMove+ " lastStepCount "+runtime.getLastStepCount()+" StepCount "+runtime.getTotalStepCount());
- if (last_noMove==false&& noMove==true){
- first_NoMove_timestamp=System.currentTimeMillis();
- }else if (noMove==false){
- first_NoMove_timestamp=0;
+ public static boolean getSkipMoveCheck() {
+ return skipMoveCheck;
}
- last_noMove=noMove;
- //属于 判断是否 不动的状态超时
- if (noMove==true&& first_NoMove_timestamp>0.01 && System.currentTimeMillis()-first_NoMove_timestamp > MaxNoMoveTimeout){
- ICLogger.i(" checkNoMoveTimeout true ");
- return true;
- }else{
- ICLogger.i("checkNoMoveTimeout false");
- return false;
+
+ private static boolean NoMoveAndNoGPSsignalSkipGpsFlag = false;
+ private static boolean noMove = false;
+ private static boolean NoMoveTimeout = false;
+ private static boolean last_noMove = false;
+ private static final int MaxNoMoveTimeout = 3 * 60 * 1000; //3分钟
+ private static long first_NoMove_timestamp = 0;
+ private static long first_NoMove_timestampForBT = 0;
+ private static boolean last_noMoveForBT = false;
+
+ /***
+ *noMove and timeout return true
+ * else return false
+ */
+ private boolean checkNoMoveTimeoutForBT() {
+ noMove = ((runtime.getTotalStepCount() - runtime.getLastStepCountForBT()) <= 0);
+ runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态
+ ICLogger.i("BT checkNoMoveTimeout last_noMoveForBT " + last_noMoveForBT + " noMove " + noMove + " lastStepCountForBT " + runtime.getLastStepCountForBT() + " StepCount " + runtime.getTotalStepCount());
+ if (last_noMoveForBT == false && noMove == true) {
+ first_NoMove_timestampForBT = System.currentTimeMillis();
+ } else if (noMove == false) {
+ first_NoMove_timestampForBT = 0;
+ }
+ last_noMoveForBT = noMove;
+ //属于 判断是否 不动的状态超时
+ if (noMove == true && first_NoMove_timestampForBT > 0.01 && System.currentTimeMillis() - first_NoMove_timestampForBT > MaxNoMoveTimeout) {
+ ICLogger.i("BT checkNoMoveTimeout true ");
+ return true;
+ } else {
+ ICLogger.i("BT checkNoMoveTimeout false");
+ return false;
+ }
+
}
- }
+ /***
+ *noMove and timeout return true
+ * else return false
+ */
+ private boolean checkNoMoveTimeout() {
+ noMove = (runtime.getTotalStepCount() - runtime.getLastStepCount() <= 0);
+ runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态
+ ICLogger.i("checkNoMoveTimeout last_noMove " + last_noMove + " noMove " + noMove + " lastStepCount " + runtime.getLastStepCount() + " StepCount " + runtime.getTotalStepCount());
+ if (last_noMove == false && noMove == true) {
+ first_NoMove_timestamp = System.currentTimeMillis();
+ } else if (noMove == false) {
+ first_NoMove_timestamp = 0;
+ }
+ last_noMove = noMove;
+ //属于 判断是否 不动的状态超时
+ if (noMove == true && first_NoMove_timestamp > 0.01 && System.currentTimeMillis() - first_NoMove_timestamp > MaxNoMoveTimeout) {
+ ICLogger.i(" checkNoMoveTimeout true ");
+ return true;
+ } else {
+ ICLogger.i("checkNoMoveTimeout false");
+ return false;
+ }
+
+ }
- private boolean needLocationForBT(){
- updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。
- //如果没有动,且超时。则跳过定位
- NoMoveTimeout=checkNoMoveTimeoutForBT();
- ICLogger.i("BT NoMoveTimeout "+NoMoveTimeout+", forceLocation="+forceLocation+", Config.forceMoveCheck="+Config.forceMoveCheck+", skipMoveCheck="+skipMoveCheck);
+ private boolean needLocationForBT() {
+ updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。
+ //如果没有动,且超时。则跳过定位
+ NoMoveTimeout = checkNoMoveTimeoutForBT();
+ ICLogger.i("BT NoMoveTimeout " + NoMoveTimeout + ", forceLocation=" + forceLocation + ", Config.forceMoveCheck=" + Config.forceMoveCheck + ", skipMoveCheck=" + skipMoveCheck);
- // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过
- if ( ( forceLocation != 1 ) &&
- (Config.forceMoveCheck==true) &&
- (NoMoveTimeout) && (skipMoveCheck ==false )){
- ICLogger.i("No Move ,skip BT location!");
+ // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过
+ if ((forceLocation != 1) &&
+ (Config.forceMoveCheck == true) &&
+ (NoMoveTimeout) && (skipMoveCheck == false)) {
+ ICLogger.i("No Move ,skip BT location!");
- return false;
+ return false;
+ }
+ //以目前逻辑,每次检测必然跟随蓝牙扫描,因此可以在此直接更新上一次的计步次数,配合下次的运动检测
+ runtime.setLastStepCountForBT(runtime.getTotalStepCount());
+ return true;
}
- //以目前逻辑,每次检测必然跟随蓝牙扫描,因此可以在此直接更新上一次的计步次数,配合下次的运动检测
- runtime.setLastStepCountForBT(runtime.getTotalStepCount());
- return true;
- }
-
- private boolean needLocation(){
- updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。
- //如果没有动,且超时。则跳过定位
- NoMoveTimeout=checkNoMoveTimeout();
- ICLogger.i(" NoMoveTimeout "+NoMoveTimeout+", forceLocation="+forceLocation+", Config.forceMoveCheck="+Config.forceMoveCheck+", skipMoveCheck="+skipMoveCheck);
-
- // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过
- if ( ( forceLocation != 1 ) &&
- (Config.forceMoveCheck==true) &&
- (NoMoveTimeout) && (skipMoveCheck ==false )){
- ICLogger.i("No Move ,skip BT location2!");
-
- return false;
+
+ private boolean needLocation() {
+ updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。
+ //如果没有动,且超时。则跳过定位
+ NoMoveTimeout = checkNoMoveTimeout();
+ ICLogger.i(" NoMoveTimeout " + NoMoveTimeout + ", forceLocation=" + forceLocation + ", Config.forceMoveCheck=" + Config.forceMoveCheck + ", skipMoveCheck=" + skipMoveCheck);
+
+ // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过
+ if ((forceLocation != 1) &&
+ (Config.forceMoveCheck == true) &&
+ (NoMoveTimeout) && (skipMoveCheck == false)) {
+ ICLogger.i("No Move ,skip BT location2!");
+
+ return false;
+ }
+ //只做正常定位前是否运动的判断,给定位前蓝牙扫描专用的。和 NeedlocationFotBT 还不同。
+ return true;
}
- //只做正常定位前是否运动的判断,给定位前蓝牙扫描专用的。和 NeedlocationFotBT 还不同。
- return true;
- }
- public void startLocationProcess(int mod){
- updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。
- ICLogger.i("forceLocation="+forceLocation+", WorkingMod="+mod+", isLocating="+isLocating+", lastStep="+runtime.getLastStepCount()+", currentStep="+ runtime.getTotalStepCount());
- if (isLocating && 1!=forceLocation) { //如果是强制定位,则即使是正在定位,也要执行,因为有时模式变换的时候,需要取消上一次定位信息,马上新的模式定位。
- ICLogger.i("locating ,skip location!");
- return;
- }
- //如果没有动,且超时。则跳过定位
- NoMoveTimeout=checkNoMoveTimeout();
- // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过
- if ( ( forceLocation != 1 ) &&
- ((( mod == ICLocation.NORMAL_MOD ) || ( mod == ICLocation.LOWPOWER_MOD ) || (mod == ICLocation.CUSTOM_MOD8_WIFI ) ) || Config.forceMoveCheck==true) &&
- (NoMoveTimeout) && (skipMoveCheck ==false )){
- ICLogger.i("No Move ,skip location!");
- return ;
- }
-
- if (NoMoveTimeout){
+
+ public void startLocationProcess(int mod) {
+ updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。
+ ICLogger.i("forceLocation=" + forceLocation + ", WorkingMod=" + mod + ", isLocating=" + isLocating + ", lastStep=" + runtime.getLastStepCount() + ", currentStep=" + runtime.getTotalStepCount());
+ if (isLocating && 1 != forceLocation) { //如果是强制定位,则即使是正在定位,也要执行,因为有时模式变换的时候,需要取消上一次定位信息,马上新的模式定位。
+ ICLogger.i("locating ,skip location!");
+ return;
+ }
+ //如果没有动,且超时。则跳过定位
+ NoMoveTimeout = checkNoMoveTimeout();
+ // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过
+ if ((forceLocation != 1) &&
+ (((mod == ICLocation.NORMAL_MOD) || (mod == ICLocation.LOWPOWER_MOD) || (mod == ICLocation.CUSTOM_MOD8_WIFI)) || Config.forceMoveCheck == true) &&
+ (NoMoveTimeout) && (skipMoveCheck == false)) {
+ ICLogger.i("No Move ,skip location!");
+ return;
+ }
+
+ if (NoMoveTimeout) {
// 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。
- if (gpsTimeoutCountOnNoMove>= MaxGpsTimeoutCountOnNoMove){
- NoMoveAndNoGPSsignalSkipGpsFlag=true;
- }else{
- NoMoveAndNoGPSsignalSkipGpsFlag=false;
- }
-
- }else{
- NoMoveAndNoGPSsignalSkipGpsFlag=false;
- gpsTimeoutCountOnNoMove=0; //只要有一次 移动,则清零。
- }
+ if (gpsTimeoutCountOnNoMove >= MaxGpsTimeoutCountOnNoMove) {
+ NoMoveAndNoGPSsignalSkipGpsFlag = true;
+ } else {
+ NoMoveAndNoGPSsignalSkipGpsFlag = false;
+ }
- forceLocation=0;
- isLocating=true;
-
- //如果不动且超时,则意味着要进行定位,更新计步,配合下一次运动检查。
- runtime.setLastStepCount(runtime.getTotalStepCount());
- updateCellInfo();
- if(!Config.disableWiFiScan) startWifiScan();
- switch(mod){
- case ICLocation.CUSTOM_MOD:
- case ICLocation.CUSTOM_MOD8_GPS:
- if (NoMoveAndNoGPSsignalSkipGpsFlag==false) {
- if (runtime.getLocationInstance().getLocation_cycle() <= 60) {
- nmeaListener.setNoStop(true);
- } else {
- nmeaListener.setNoStop(false);
- }
- startGpsLocate();
- }else{
- clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。
+ } else {
+ NoMoveAndNoGPSsignalSkipGpsFlag = false;
+ gpsTimeoutCountOnNoMove = 0; //只要有一次 移动,则清零。
}
- break;
- case ICLocation.EMERGNECY_MOD:
- case ICLocation.REALTIME_MOD:
+
+ forceLocation = 0;
+ isLocating = true;
+
+ //如果不动且超时,则意味着要进行定位,更新计步,配合下一次运动检查。
+ runtime.setLastStepCount(runtime.getTotalStepCount());
+ updateCellInfo();
+ if (!Config.disableWiFiScan) startWifiScan();
+ switch (mod) {
+ case ICLocation.CUSTOM_MOD:
+ case ICLocation.CUSTOM_MOD8_GPS:
+ if (NoMoveAndNoGPSsignalSkipGpsFlag == false) {
+ if (runtime.getLocationInstance().getLocation_cycle() <= 60) {
+ nmeaListener.setNoStop(true);
+ } else {
+ nmeaListener.setNoStop(false);
+ }
+ startGpsLocate();
+ } else {
+ clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。
+ }
+ break;
+ case ICLocation.EMERGNECY_MOD:
+ case ICLocation.REALTIME_MOD:
- if(NoMoveAndNoGPSsignalSkipGpsFlag==false) {
- nmeaListener.setNoStop(true);
+ if (NoMoveAndNoGPSsignalSkipGpsFlag == false) {
+ nmeaListener.setNoStop(true);
// nmeaListener.setNoStop(false);//保证从Custom切换回来的时候不至于不关闭gps
- startGpsLocate();
- }else{
- clearGPSlocateStat(); //确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。
+ startGpsLocate();
+ } else {
+ clearGPSlocateStat(); //确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。
+ }
+
+ break;
+ case ICLocation.LOWPOWER_MOD:
+ case ICLocation.NORMAL_MOD:
+ case ICLocation.CUSTOM_MOD8_WIFI:
+ default:
+ gpsTimeoutCountOnNoMove = 0; //只要有一次不是GPS定位,则清零。
+ clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。
+ break;
}
+ startCheckResult();
+ }
- break;
- case ICLocation.LOWPOWER_MOD:
- case ICLocation.NORMAL_MOD:
- case ICLocation.CUSTOM_MOD8_WIFI:
- default:
- gpsTimeoutCountOnNoMove=0; //只要有一次不是GPS定位,则清零。
- clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。
- break;
+ public static void setForceLocation(int _forcelocation) {
+ forceLocation = _forcelocation;
}
- startCheckResult();
- }
- public static void setForceLocation(int _forcelocation){
- forceLocation=_forcelocation;
- }
- private static int forceLocation=0;
- public void onReceive(StringMessage paramStringMessage) {
+ private static int forceLocation = 0;
- ICLogger.i("LocationClient onReceive " +paramStringMessage.cmd() );
+ public void onReceive(StringMessage paramStringMessage) {
+
+ ICLogger.i("LocationClient onReceive " + paramStringMessage.cmd());
// Deliver.triggerSendThread();
- //响应定位指令
- if ("StartLocate".equals(paramStringMessage.cmd()) ){
- forceLocation=1;
- this.startLocationProcess(runtime.getLocationInstance().getWorkingMod());
- }else if ("setWorkMod".equals(paramStringMessage.cmd())) {
- //此处不负责给工作模式赋值,在API接收的位置能够直接拿到变量,可以直接赋值较方便。
- int mod = runtime.getLocationInstance().getWorkingMod();
- ICLogger.i("Set WorkMODE "+mod +" and reset Location AlarmCycle");
- CoreService.getInstance().setLocationAlarm(mod); //默认设置好Alarm后会触发一次定位,无需后面再触发定位了。
- forceLocation=1; //不管是什么模式,都强制定位一次,然后再说其他情况
-
- if(mod==ICLocation.EMERGNECY_MOD)
- CoreService.getInstance().setEmegencyLocationSTOPAlarm(5);//Emergency模式5分钟自动停止
+ //响应定位指令
+ if ("StartLocate".equals(paramStringMessage.cmd())) {
+ forceLocation = 1;
+ this.startLocationProcess(runtime.getLocationInstance().getWorkingMod());
+ } else if ("setWorkMod".equals(paramStringMessage.cmd())) {
+ //此处不负责给工作模式赋值,在API接收的位置能够直接拿到变量,可以直接赋值较方便。
+ int mod = runtime.getLocationInstance().getWorkingMod();
+ ICLogger.i("Set WorkMODE " + mod + " and reset Location AlarmCycle");
+ CoreService.getInstance().setLocationAlarm(mod); //默认设置好Alarm后会触发一次定位,无需后面再触发定位了。
+ forceLocation = 1; //不管是什么模式,都强制定位一次,然后再说其他情况
+
+ if (mod == ICLocation.EMERGNECY_MOD)
+ CoreService.getInstance().setEmegencyLocationSTOPAlarm(5);//Emergency模式5分钟自动停止
// this.startLocationProcess(mod);
- }
- }
- private static String ACTION_GPSCMD="com.enqualcomm.support.gps";
- public void registerBroadReceiver() {
-
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(ACTION_GPSCMD);
- (this.runtime.getContextProxy()).context.registerReceiver(this.mLocationBroadcastReceiver, intentFilter);
- }
-
- public void unregisterBroadReceiver() {
- (this.runtime.getContextProxy()).context.unregisterReceiver(this.mLocationBroadcastReceiver);
- }
-
- private final BroadcastReceiver mLocationBroadcastReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (ACTION_GPSCMD.equals(action)) { //此消息来自工厂测试工具,测试GPS时会发送。
- String status = intent.getStringExtra("status");
- if( status.equals("needReopen")){
- runtime.setFactoryTestingStat(true);
}
- }
}
- };
- public void init() {
+ private static String ACTION_GPSCMD = "com.enqualcomm.support.gps";
+
+ public void registerBroadReceiver() {
+
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(ACTION_GPSCMD);
+ (this.runtime.getContextProxy()).context.registerReceiver(this.mLocationBroadcastReceiver, intentFilter);
+ }
+
+ public void unregisterBroadReceiver() {
+ (this.runtime.getContextProxy()).context.unregisterReceiver(this.mLocationBroadcastReceiver);
+ }
+
+ private final BroadcastReceiver mLocationBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (ACTION_GPSCMD.equals(action)) { //此消息来自工厂测试工具,测试GPS时会发送。
+ String status = intent.getStringExtra("status");
+ if (status.equals("needReopen")) {
+ runtime.setFactoryTestingStat(true);
+ }
+ }
+ }
+ };
+
+ public void init() {
- this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context);
+ this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context);
- //获取LBS定位服务
- this.mLbsHelper = runtime.getLbsHelper();
+ //获取LBS定位服务
+ this.mLbsHelper = runtime.getLbsHelper();
//
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("LOCATION_MODE=");
- stringBuilder.append(runtime.getLocationInstance().getWorkingMod());
- stringBuilder.append("LOCATION_CYCLE=");
- stringBuilder.append(runtime.getLocationInstance().getLocation_cycle());
- ICLogger.i(stringBuilder.toString());
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("LOCATION_MODE=");
+ stringBuilder.append(runtime.getLocationInstance().getWorkingMod());
+ stringBuilder.append("LOCATION_CYCLE=");
+ stringBuilder.append(runtime.getLocationInstance().getLocation_cycle());
+ ICLogger.i(stringBuilder.toString());
- /*注册 亮屏监控*/
+ /*注册 亮屏监控*/
// IntentFilter intentFilter = new IntentFilter();
// intentFilter.addAction("android.intent.action.SCREEN_ON");
// (runtime.getContextProxy()).context.registerReceiver(this.screenOnReceiver, intentFilter);
- registerBroadReceiver();
+ registerBroadReceiver();
- //暂时没有处理4G、2G切换问题
+ //暂时没有处理4G、2G切换问题
// this.haveChanegTo4GTime = SystemClock.elapsedRealtime();
- }
-
- public void deinit() {
+ }
+
+ public void deinit() {
- ICLogger.i("GPS deinit!");
+ ICLogger.i("GPS deinit!");
// (runtime.getContextProxy()).context.unregisterReceiver(this.screenOnReceiver);
// mLbsHelper.unRegisterWiFiBroadReceiver();
// this.executor.execute(new Runnable() {
// Deliver.saveQueue();
// }
// });
- stopGpsLocate();
- unregisterBroadReceiver();
- }
-
-
-
+ stopGpsLocate();
+ unregisterBroadReceiver();
+ }
- private void notifiSetAirModeMethod() { (new Thread(new Runnable() {
- public void run() {
- SystemClock.sleep(3000L);
- boolean bool = mSignalUtil.IsAirModeOn();
- byte b = 1;
- if (bool != true)
- b = 0;
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("AirMode==");
- stringBuilder.append(b);
- ICLogger.i(stringBuilder.toString());
+ private void notifiSetAirModeMethod() {
+ (new Thread(new Runnable() {
+ public void run() {
+ SystemClock.sleep(3000L);
+ boolean bool = mSignalUtil.IsAirModeOn();
+ byte b = 1;
+ if (bool != true)
+ b = 0;
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("AirMode==");
+ stringBuilder.append(b);
+ ICLogger.i(stringBuilder.toString());
+ }
+ })).start();
}
- })).start(); }
- // 飞行模式 1 开启 0 关闭
- public void setAirMode(int paramInt) {
- boolean isAirModeOn = this.mSignalUtil.IsAirModeOn();
- boolean isScreenOn = this.mSignalUtil.isScreenON(runtime.getContextProxy().context);
- switch (paramInt) {
+ // 飞行模式 1 开启 0 关闭
+ public void setAirMode(int paramInt) {
+ boolean isAirModeOn = this.mSignalUtil.IsAirModeOn();
+ boolean isScreenOn = this.mSignalUtil.isScreenON(runtime.getContextProxy().context);
+ switch (paramInt) {
- case 1:
- if (!isAirModeOn && !isScreenOn) {
- // this.mSignalUtil.setAirMode("OpenAirplane");
- runtime.isAirMode = true;
- notifiSetAirModeMethod();
+ case 1:
+ if (!isAirModeOn && !isScreenOn) {
+ // this.mSignalUtil.setAirMode("OpenAirplane");
+ runtime.isAirMode = true;
+ notifiSetAirModeMethod();
- }
+ }
- break;
- case 0:
+ break;
+ case 0:
- if (isAirModeOn) {
- //this.mSignalUtil.setAirMode("CloseAirplane");
- runtime.isAirMode = false;
- notifiSetAirModeMethod();
- return;
+ if (isAirModeOn) {
+ //this.mSignalUtil.setAirMode("CloseAirplane");
+ runtime.isAirMode = false;
+ notifiSetAirModeMethod();
+ return;
+ }
+ break;
+
+ default:
+ break;
}
- break;
- default:
- break;
}
- }
-
}
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.os.Handler;
+
import com.enqualcomm.support.bean.Runtime;
import com.enqualcomm.support.Config;
import com.enqualcomm.support.utils.IBeaconUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Set;
+
public class BTHelper {
+ private static final String TAG = "BTHelper";
private BluetoothAdapter mBtAdapter;
- private static ArrayList<IBeaconUtil.iBeacon> mBeaconDevicesArray=new ArrayList<>();
- private static ArrayList<String> mNewDevicesArray=new ArrayList<>();
- private Context mContext=null;
- private BTScanCallback mCallback=null;
- private static BTHelper mBThelper=null;
- private int BLETimeoutForOneScan=10;
- private static boolean btscanning=false;
+ private static ArrayList<IBeaconUtil.iBeacon> mBeaconDevicesArray = new ArrayList<>();
+ private static ArrayList<String> mNewDevicesArray = new ArrayList<>();
+ private Context mContext = null;
+ private BTScanCallback mCallback = null;
+ private static BTHelper mBThelper = null;
+ private int BLETimeoutForOneScan = 10;
+ private static boolean btscanning = false;
private static Runtime mRuntime;
- private boolean enabledBeforScan=false;
- private static Handler mHandler=null;
- BTHelper(){
+ private boolean enabledBeforScan = false;
+ private static Handler mHandler = null;
+
+ BTHelper() {
}
- public void setBLEScanTimeout(int timeout){
- BLETimeoutForOneScan=timeout;
+ public void setBLEScanTimeout(int timeout) {
+ BLETimeoutForOneScan = timeout;
}
- private boolean isBeaconFounded(String beaconAddr){
+
+ private boolean isBeaconFounded(String beaconAddr) {
String tmp = beaconAddr.replace(":", "").toLowerCase();
- if(tmp.contains(","))
+ if (tmp.contains(","))
tmp = tmp.substring(0, tmp.indexOf(","));
- for (String beacon:mRuntime.bleInfo.btMacList){
- if (tmp.equals(beacon)) {
- ICLogger.i("bt mac " + tmp + " " + beaconAddr.toLowerCase());
- return true;
- }
+ for (String beacon : mRuntime.bleInfo.btMacList) {
+ if (tmp.equals(beacon)) {
+ ICLogger.i("bt mac " + tmp + " " + beaconAddr.toLowerCase());
+ return true;
+ }
}
return false;
}
+
//enableBT
public void enableBT() {
ICLogger.i("BT enableBT()");
}
//disableBT
- public void disableBT(){
- ICLogger.i( "BT disableBT()");
- if (mBtAdapter.isEnabled()) {
- mBtAdapter.disable();
+ public void disableBT() {
+ //根据环境变量来判断是否关闭
+ String isUserEnable = Util.getSystemProperties("persist.sys.ic.bt_enable", "false");
+ ICLogger.log(TAG, "isUserEnable === > " + isUserEnable);
+ //如果是用户手动打开的(true),那么不就不走这里关闭了
+ if ("false".equals(isUserEnable)) {
+ ICLogger.i("BT disableBT()");
+ if (mBtAdapter.isEnabled()) {
+ mBtAdapter.disable();
+ }
}
}
//初始化 BTHlper
- public void Init(Context context , BTScanCallback callback){
- ICLogger.i( "BT Init()");
- mCallback=callback;
- mContext=context;
+ public void Init(Context context, BTScanCallback callback) {
+ ICLogger.i("BT Init()");
+ mCallback = callback;
+ mContext = context;
// Get the local Bluetooth adapter
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
- if (lecallback==null)
- lecallback= new BLeScanCallback();
- if(mHandler==null)
- mHandler=new Handler();
+ if (lecallback == null)
+ lecallback = new BLeScanCallback();
+ if (mHandler == null)
+ mHandler = new Handler();
}
//获取实例
- public static BTHelper CreateInstance(Runtime runtime , BTScanCallback callback){
- mRuntime=runtime;
- if (mBThelper==null) {
- ICLogger.i( "BT getInstance ");
+ public static BTHelper CreateInstance(Runtime runtime, BTScanCallback callback) {
+ mRuntime = runtime;
+ if (mBThelper == null) {
+ ICLogger.i("BT getInstance ");
mBThelper = new BTHelper();
- mBThelper.Init(runtime.getContextProxy().context,callback);
+ mBThelper.Init(runtime.getContextProxy().context, callback);
}
return mBThelper;
}
- private BLeScanCallback lecallback =null;
+ private BLeScanCallback lecallback = null;
- private RunableStopBleScan mRunable_stopBleScan=new RunableStopBleScan();
+ private RunableStopBleScan mRunable_stopBleScan = new RunableStopBleScan();
- private static boolean hasStopedByFoundBT=false;
- public boolean isBtscanning(){
+ private static boolean hasStopedByFoundBT = false;
+
+ public boolean isBtscanning() {
return btscanning;
}
+
//开始扫描BLE
public void scanBLE() {
- ICLogger.i( "BT scanBLE()");
+ ICLogger.i("BT scanBLE()");
- if(btscanning==false) {
- btscanning=true;
+ if (btscanning == false) {
+ btscanning = true;
enabledBeforScan = mBtAdapter.isEnabled();
enableBT();
// mBtAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE, BLETimeoutForOneScan);
ICLogger.i("BT startLeScan");
- if (lecallback==null)
- lecallback= new BLeScanCallback();
- if(mHandler==null)
- mHandler=new Handler();
+ if (lecallback == null)
+ lecallback = new BLeScanCallback();
+ if (mHandler == null)
+ mHandler = new Handler();
mBtAdapter.startLeScan(lecallback);
- mHandler.postDelayed(mRunable_stopBleScan, BLETimeoutForOneScan*1000);
+ mHandler.postDelayed(mRunable_stopBleScan, BLETimeoutForOneScan * 1000);
- }else{
+ } else {
ICLogger.i("BT Scanning skip Scan!");
}
}
-
//开启蓝牙可被搜索300秒
private void ensureDiscoverable() {
- ICLogger.i("ensure discoverable");
+ ICLogger.i("ensure discoverable");
if (mBtAdapter.getScanMode() !=
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
}
}
- private advcallback advcb=new advcallback();
+ private advcallback advcb = new advcallback();
//停止自定义广播
- public void stopGattAdvertising(){
+ public void stopGattAdvertising() {
if (mBtAdapter.isEnabled())
mBtAdapter.stopAdvertising(advcb);
}
//开启自定义广播数据,前两字会被丢弃
- public void enableGattAdvertising(String serverData){
+ public void enableGattAdvertising(String serverData) {
byte[] serviceData = serverData.getBytes();
if (mBtAdapter.isEnabled())
mBtAdapter.startAdvertising(advcb, serviceData);
}
+
public class advcallback implements BluetoothAdapter.AdvertiseCallback {
- public void onAdvertiseStart(int status){
- ICLogger.i( "--onAdvertiseStart --");
+ public void onAdvertiseStart(int status) {
+ ICLogger.i("--onAdvertiseStart --");
}
- public void onAdvertiseStop(int status){
+ public void onAdvertiseStop(int status) {
- ICLogger.i( "-- onAdvertiseStop --");
+ ICLogger.i("-- onAdvertiseStop --");
}
}
- private class BLeScanCallback implements LeScanCallback{
+
+ private class BLeScanCallback implements LeScanCallback {
@Override
public void onLeScan(BluetoothDevice bluetoothDevice, int rssi, byte[] scanRecode) {
}
}
- private void resortScanResult1( ArrayList<String> btlist){
+ private void resortScanResult1(ArrayList<String> btlist) {
Collections.sort(btlist, new Comparator<String>() {
public int compare(String var1, String var2) {
tmp = var2.indexOf(",");
int rssi2 = Integer.parseInt(var2.substring(tmp + 1));
return Math.abs(rssi1) - Math.abs(rssi2);
- }catch (Exception e){
+ } catch (Exception e) {
return 0;
}
}
}
- private void resortScanResult( ArrayList<IBeaconUtil.iBeacon> btlist){
+ private void resortScanResult(ArrayList<IBeaconUtil.iBeacon> btlist) {
Collections.sort(btlist, new Comparator<IBeaconUtil.iBeacon>() {
public int compare(IBeaconUtil.iBeacon var1, IBeaconUtil.iBeacon var2) {
int rssi1 = var1.rssi;
int rssi2 = var2.rssi;
return Math.abs(rssi1) - Math.abs(rssi2);
- }catch (Exception e){
+ } catch (Exception e) {
return 0;
}
}
});
}
- private class RunableStopBleScan implements Runnable{
+
+ private class RunableStopBleScan implements Runnable {
@Override
public void run() {
ICLogger.i("BT stopLeScan");
mBtAdapter.stopLeScan(lecallback);
- //开始扫描前是关闭的,就关闭它
+ //开始扫描前是关闭的,就关闭它
// if(!enabledBeforScan)
disableBT();
- if (mCallback != null){
+ if (mCallback != null) {
resortScanResult1(mNewDevicesArray);
resortScanResult(mBeaconDevicesArray);
mCallback.OnScanFinished(mBeaconDevicesArray, mNewDevicesArray);
}
- btscanning=false;
+ btscanning = false;
}
}
- public interface BTScanCallback{
- void OnScanFinished(ArrayList<IBeaconUtil.iBeacon> btBeaconScanResult,ArrayList<String> btNewScanResult);
+ public interface BTScanCallback {
+ void OnScanFinished(ArrayList<IBeaconUtil.iBeacon> btBeaconScanResult, ArrayList<String> btNewScanResult);
}
}
package com.enqualcomm.support.adapter;\r
\r
-import android.Manifest;\r
-import android.annotation.SuppressLint;\r
import android.content.BroadcastReceiver;\r
import android.content.Context;\r
-import android.content.Intent;\r
-import android.content.IntentFilter;\r
-import android.content.pm.PackageManager;\r
import android.net.wifi.ScanResult;\r
import android.net.wifi.WifiManager;\r
-import android.os.Build;\r
import android.os.Handler;\r
-import android.os.Message;\r
-import android.os.SystemClock;\r
-import android.support.annotation.RequiresApi;\r
-import android.telephony.CellInfo;\r
-import android.telephony.CellLocation;\r
-import android.telephony.NeighboringCellInfo;\r
import android.telephony.PhoneStateListener;\r
import android.telephony.SignalStrength;\r
import android.telephony.TelephonyManager;\r
-import android.telephony.cdma.CdmaCellLocation;\r
-import android.telephony.gsm.GsmCellLocation;\r
\r
import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.bean.Runtime;\r
-import com.enqualcomm.support.service.Deliver;\r
import com.enqualcomm.support.utils.CellInfoUtil;\r
import com.enqualcomm.support.utils.DeviceInfoUtil;\r
-import com.enqualcomm.support.utils.FileOutputUtil;\r
import com.enqualcomm.support.utils.ICLogger;\r
-import com.enqualcomm.support.utils.SimSignalUtil;\r
import com.enqualcomm.support.utils.Util;\r
\r
import java.util.Collections;\r
import java.util.Comparator;\r
import java.util.Iterator;\r
import java.util.List;\r
-import java.util.concurrent.TimeUnit;\r
\r
-import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED;\r
-import static android.net.wifi.WifiManager.WIFI_STATE_DISABLING;\r
-import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED;\r
-import static android.net.wifi.WifiManager.WIFI_STATE_ENABLING;\r
-import static android.net.wifi.WifiManager.WIFI_STATE_UNKNOWN;\r
import static android.telephony.PhoneStateListener.LISTEN_SIGNAL_STRENGTHS;\r
-import static android.telephony.TelephonyManager.NETWORK_TYPE_LTE;\r
\r
public class LBSHelper {\r
private boolean IS_HASOPEN = false;\r
private String wifiInfoResult;\r
private WifiManager wifiManager;\r
\r
- private final int MsgWhat_GetWifiResult=104;\r
- private int MaxWiFiScanRetryTimes=3;\r
- private static int CurrentWiFiScanTimes=0;\r
+ private final int MsgWhat_GetWifiResult = 104;\r
+ private int MaxWiFiScanRetryTimes = 3;\r
+ private static int CurrentWiFiScanTimes = 0;\r
\r
public LBSHelper(Context _context, WifiManager _wifiManager, Runtime dev) {\r
this.wifiManager = _wifiManager;\r
}\r
\r
\r
-\r
-\r
- public void getWifiResult(){\r
+ public void getWifiResult() {\r
\r
\r
//检查是否已经得到结果。\r
- if(runtime.getWifiInfo().length()==0){\r
+ if (runtime.getWifiInfo().length() == 0) {\r
//还没有结果\r
- if (wifiManager.isWifiEnabled()){\r
+ if (wifiManager.isWifiEnabled()) {\r
//wifi开着,可以开始检测扫描结果\r
wait_count++;\r
- if ( wait_count == 3){\r
+ if (wait_count == 3) {\r
//3秒检查一次!\r
- wait_count=0;\r
+ wait_count = 0;\r
ICLogger.i("get WiFi Scan result !");\r
- }else{\r
- ICLogger.i("WiFi Wait "+wait_count+"!");\r
- return ;\r
+ } else {\r
+ ICLogger.i("WiFi Wait " + wait_count + "!");\r
+ return;\r
}\r
\r
- }else{\r
- // ICLogger.i("WiFi is Not Open, skip check scan result!");\r
- return ;\r
+ } else {\r
+ // ICLogger.i("WiFi is Not Open, skip check scan result!");\r
+ return;\r
}\r
- }else{\r
+ } else {\r
\r
- // ICLogger.i("WiFiScan is done, skip check scan result!");\r
+ // ICLogger.i("WiFiScan is done, skip check scan result!");\r
return;\r
}\r
//停止扫描\r
StringBuilder sb = handleScanResults();\r
- if (sb != null){\r
- ICLogger.i("GetWifiScanResults "+sb.toString());\r
- if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", "GetWifiScanResults "+sb.toString());\r
- }else{\r
+ if (sb != null) {\r
+ ICLogger.i("GetWifiScanResults " + sb.toString());\r
+ if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", "GetWifiScanResults " + sb.toString());\r
+ } else {\r
ICLogger.i("GetWifiScanResults null");\r
if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", "GetWifiScanResults null");\r
}\r
if (sb == null) {\r
CurrentWiFiScanTimes++;\r
- if (CurrentWiFiScanTimes< MaxWiFiScanRetryTimes) {\r
- ICLogger.i("WiFi Scan get Result failed , retry scan "+CurrentWiFiScanTimes+ " times");\r
+ if (CurrentWiFiScanTimes < MaxWiFiScanRetryTimes) {\r
+ ICLogger.i("WiFi Scan get Result failed , retry scan " + CurrentWiFiScanTimes + " times");\r
wifiManager.startScan();\r
delayedStopScan();\r
return;\r
- }else {\r
+ } else {\r
wifiInfoResult = null;\r
}\r
} else {\r
// public void call(Object param1Object) {\r
Util.mSleep(500);\r
\r
- //由于wifi状态不好确认客户是如何设置的,干脆只有屏幕灭的时候才考虑关闭wifi ,防止在开启屏幕用来视频的时候被后台关掉\r
- ICLogger.i("setWifiEnabled false");\r
+ //由于wifi状态不好确认客户是如何设置的,干脆只有屏幕灭的时候才考虑关闭wifi ,防止在开启屏幕用来视频的时候被后台关掉\r
+ ICLogger.i("setWifiEnabled false");\r
// if(SimSignalUtil.isScreenON(runtime.getContextProxy().context)==false) {\r
- if (runtime.isNoTurnOffWifiOnScreenOff() || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
- //如果 NoTurnOffWifiOnScreenOff 开关 开启,且是屏灭,或者是在工厂测试模式,则原来什么状态就什么状态。\r
- ICLogger.i("isNoTurnOffWifiOnScreenOff or In Factory Mode");\r
- if (!IS_HASOPEN && IS_OPEN) {\r
+ if (runtime.isNoTurnOffWifiOnScreenOff() || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
+ //如果 NoTurnOffWifiOnScreenOff 开关 开启,且是屏灭,或者是在工厂测试模式,则原来什么状态就什么状态。\r
+ ICLogger.i("isNoTurnOffWifiOnScreenOff or In Factory Mode");\r
+ if (!IS_HASOPEN && IS_OPEN) {\r
// wifiManager.setWifiEnabled(false);\r
- IS_OPEN = false;\r
- }\r
- } else {\r
- //如果 NoTurnOffWifiOnScreenOff 开关 关闭,且是屏灭,则关闭wifi省电\r
- ICLogger.i("isTurnOffWifiOnScreenOff");\r
- wifiManager.setWifiEnabled(false);\r
IS_OPEN = false;\r
- IS_HASOPEN = false;\r
-\r
}\r
+ } else {\r
+ //根据环境变量来判断是否要关闭\r
+ String isUserOpen = Util.getSystemProperties("persist.sys.ic.wifi_enable", "false");\r
+ ICLogger.d("is open by user == > " + isUserOpen);\r
+ if ("true".equals(isUserOpen)) {\r
+ //用户手动打开的,那么就不走后面的逻辑了\r
+ return;\r
+ }\r
+ //如果 NoTurnOffWifiOnScreenOff 开关 关闭,且是屏灭,则关闭wifi省电\r
+ ICLogger.i("isTurnOffWifiOnScreenOff");\r
+ wifiManager.setWifiEnabled(false);\r
+ IS_OPEN = false;\r
+ IS_HASOPEN = false;\r
+ }\r
// }else{\r
// ICLogger.i("isTurnOffWifiOnScreenOff");\r
// wifiManager.setWifiEnabled(false);\r
// IS_OPEN = false;\r
// IS_HASOPEN = false;\r
// }\r
- ICLogger.i("setWifiEnabled done");\r
+ ICLogger.i("setWifiEnabled done");\r
\r
\r
- }else{\r
+ } else {\r
ICLogger.i("mMyWifiListener is null skip callback");\r
}\r
\r
}\r
+\r
private StringBuilder handleScanResults() {\r
List aplist = this.wifiManager.getScanResults();\r
- ICLogger.i("get Wifi Result "+aplist.size());\r
+ ICLogger.i("get Wifi Result " + aplist.size());\r
if (aplist.size() < 1) {\r
return null;\r
} else {\r
while (it.hasNext()) {\r
ScanResult result = (ScanResult) it.next();\r
if (result.level != 0) {\r
- count ++;\r
+ count++;\r
if (count < 6) {\r
sb.append("&");\r
sb.append("AP");\r
sblog.append("[").append(count).append(",SSID:").append(result.SSID).append(",BSSID:").append(result.BSSID).append(",Level:").append(result.level).append("];");\r
}\r
}\r
- if (sb.toString().startsWith("&")) sb.deleteCharAt(0);\r
- if(Config.LOG_TOFILE) ICLogger.logToFile("LBS",sblog.toString());\r
+ if (sb.toString().startsWith("&")) sb.deleteCharAt(0);\r
+ if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", sblog.toString());\r
return sb;\r
}\r
}\r
\r
}\r
\r
- private static int wait_count=0;\r
+ private static int wait_count = 0;\r
\r
public void getWifiInfo() {\r
if (this.wifiManager.isWifiEnabled()) {\r
Util.mSleep(500);\r
}\r
//wait_count=0;\r
- CurrentWiFiScanTimes=0;\r
+ CurrentWiFiScanTimes = 0;\r
wifiManager.startScan();\r
// delayedStopScan();\r
\r
private MyPhoneStateListener() {\r
}\r
\r
-// @RequiresApi(api = Build.VERSION_CODES.M)\r
+ // @RequiresApi(api = Build.VERSION_CODES.M)\r
public void onSignalStrengthsChanged(SignalStrength ss) {\r
super.onSignalStrengthsChanged(ss);\r
- TelephonyManager tm=(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);\r
- int tmpsignal=CellInfoUtil.getSignal(tm,runtime);\r
- int gsmSignal= 150-Math.abs(tmpsignal);\r
+ TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);\r
+ int tmpsignal = CellInfoUtil.getSignal(tm, runtime);\r
+ int gsmSignal = 150 - Math.abs(tmpsignal);\r
runtime.setSignalStrength(gsmSignal);\r
\r
}\r
}\r
\r
\r
-\r
public interface OnWiFiInfoListener {\r
void getWifiInfoCallBack(String var1);\r
}\r
--- /dev/null
+package com.enqualcomm.support.bean;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class TemperatureItem implements Parcelable {
+
+ private String bodyTemp/*体温*/;
+ private String cpuTemp/*cpu温度*/;
+ private String evnTemp/*环境温度*/;
+ private String gpuTemp/*gpu温度*/;
+ private String chargeTemp/*充电版温度*/;
+ private String boardTemp/*主板温度*/;
+ private String paTemp/*射频的温度*/;
+
+ public TemperatureItem(String bodyTemp, String cpuTemp, String evnTemp, String gpuTemp, String chargeTemp, String boardTemp, String paTemp) {
+ this.bodyTemp = bodyTemp;
+ this.cpuTemp = cpuTemp;
+ this.evnTemp = evnTemp;
+ this.gpuTemp = gpuTemp;
+ this.chargeTemp = chargeTemp;
+ this.boardTemp = boardTemp;
+ this.paTemp = paTemp;
+ }
+
+ protected TemperatureItem(Parcel in) {
+ bodyTemp = in.readString();
+ cpuTemp = in.readString();
+ evnTemp = in.readString();
+ gpuTemp = in.readString();
+ chargeTemp = in.readString();
+ boardTemp = in.readString();
+ paTemp = in.readString();
+ }
+
+ public static final Creator<TemperatureItem> CREATOR = new Creator<TemperatureItem>() {
+ @Override
+ public TemperatureItem createFromParcel(Parcel in) {
+ return new TemperatureItem(in);
+ }
+
+ @Override
+ public TemperatureItem[] newArray(int size) {
+ return new TemperatureItem[size];
+ }
+ };
+
+ public String getBodyTemp() {
+ return bodyTemp;
+ }
+
+ public void setBodyTemp(String bodyTemp) {
+ this.bodyTemp = bodyTemp;
+ }
+
+ public String getCpuTemp() {
+ return cpuTemp;
+ }
+
+ public void setCpuTemp(String cpuTemp) {
+ this.cpuTemp = cpuTemp;
+ }
+
+ public String getEvnTemp() {
+ return evnTemp;
+ }
+
+ public void setEvnTemp(String evnTemp) {
+ this.evnTemp = evnTemp;
+ }
+
+ public String getGpuTemp() {
+ return gpuTemp;
+ }
+
+ public void setGpuTemp(String gpuTemp) {
+ this.gpuTemp = gpuTemp;
+ }
+
+ public String getChargeTemp() {
+ return chargeTemp;
+ }
+
+ public void setChargeTemp(String chargeTemp) {
+ this.chargeTemp = chargeTemp;
+ }
+
+ public String getBoardTemp() {
+ return boardTemp;
+ }
+
+ public void setBoardTemp(String boardTemp) {
+ this.boardTemp = boardTemp;
+ }
+
+ public String getPaTemp() {
+ return paTemp;
+ }
+
+ public void setPaTemp(String paTemp) {
+ this.paTemp = paTemp;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(bodyTemp);
+ dest.writeString(cpuTemp);
+ dest.writeString(evnTemp);
+ dest.writeString(gpuTemp);
+ dest.writeString(chargeTemp);
+ dest.writeString(boardTemp);
+ dest.writeString(paTemp);
+ }
+}
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
+import android.text.TextUtils;
import com.enqualcomm.support.Config;
import com.enqualcomm.support.CoreService;
public class AntiMonitorService extends AbstractInvokeHandlerService {
+ private static final String TAG = "AntiMonitorService";
Context mContext;
Runtime mRuntime;
* @param antioff
*/
private void broadcast_antioff_event_to_other_application(boolean antioff) {
+ ICLogger.log(TAG, "antioff == > " + antioff);
+ //第一次佩戴的时候,走到这里说明支持佩戴检测了
+ //那么默认修改值为false
+ String isEnough = Util.getSystemProperties("persist.sys.ic_antiWearEnough", "");
+ if (TextUtils.isEmpty(isEnough)) {
+ ICLogger.log(TAG, "set up default value..." + isEnough);
+ Util.setSystemProperties("persist.sys.ic_antiWearEnough", "false");
+ }
Intent intent = new Intent(ACTION_ANTI_OFF0);
if (antioff) {
//脱落
private int getWearEnoughTime() {
//佩戴多久为佩戴够长时间了
- return Util.getSystemPropertiesInt("persist.sys.ic_anti_wear_enough_time",
+ return Util.getSystemPropertiesInt("persist.sys.ic_antiWearEnoughT",
DEFAULT_WEAR_ENOUGH_TIME);
}
private int getAntiOffDelayTime() {
- return Util.getSystemPropertiesInt("persist.sys.ic_anti_off_delay_time",
+ return Util.getSystemPropertiesInt("persist.sys.ic_antiOffDelayT",
DEFAULT_RESET_WEAR_TIME);
}
* 这个任务用于更新是否佩戴够久的标记量
*/
private final Runnable mUpdateTimeFlagTask = () -> {
+ ICLogger.log(TAG, "mUpdateTimeFlagTask...");
//如果叠加够5分钟了,就去修改标记量,如果脱落了超过30秒,这个任务就会被干掉。并且会修改成false
- Util.setSystemProperties("persist.sys.ic_anti_wear_enough", "true");
+ Util.setSystemProperties("persist.sys.ic_antiWearEnough", "true");
};
/**
* 这个任务是延时30秒执行,就会干掉mUpdateTimeFlagTask。如果佩戴上了这个任务就会被干掉。
*/
private final Runnable mDeleteTimeFlagTask = () -> {
+ ICLogger.log(TAG, "mDeleteTimeFlagTask...");
//如果脱落了超过30秒,就会干掉mUpdateTimeFlagTask。并且会修改成false
- Util.setSystemProperties("persist.sys.ic_anti_wear_enough", "false");
+ Util.setSystemProperties("persist.sys.ic_antiWearEnough", "false");
mHandler.removeCallbacks(mUpdateTimeFlagTask);
};
private void send_antiof_cutoff_event() {
-
if (last_send_antoff_event == current_anti_status) {
ICLogger.i("佩戴状态未变,skip!");
return;
--- /dev/null
+package com.enqualcomm.support.utils;
+
+import android.util.Log;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+public class ShellUtil {
+ /**
+ * 执行命令并且输出结果
+ */
+ public static String execRootCmd(String cmd) {
+ String result = "";
+ DataOutputStream dos = null;
+ DataInputStream dis = null;
+
+ try {
+ Process p = Runtime.getRuntime().exec(cmd);// 经过Root处理的androi:qd系统即有su命令
+ dos = new DataOutputStream(p.getOutputStream());
+ dis = new DataInputStream(p.getInputStream());
+ String line;
+ while ((line = dis.readLine()) != null) {
+ Log.d("result", line);
+ result += line;
+ }
+ p.waitFor();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (dos != null) {
+ try {
+ dos.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (dis != null) {
+ try {
+ dis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+}
--- /dev/null
+package com.enqualcomm.support.utils;
+
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.enqualcomm.support.bean.TemperatureItem;
+import com.ic.jni.ICJniUtils;
+
+public class TempAlgUtil {
+ private static String TAG = "TemperatureUtil";
+
+ private static double temp_value_orig = 0.0f;
+ private static double tempOut_value = 0.0f;
+
+ public static double get_tempOut_value_origin() {
+ tempOut_value = ICJniUtils.getTemperatureOrigin();
+ Log.i(TAG, "测量环境温度 原始值 " + tempOut_value);
+ return tempOut_value;
+ }
+
+ public static double get_temp_value_adjusted() {
+ temp_value_orig = ICJniUtils.getTemperature();
+ Log.i(TAG, "测量体温 原始值 " + temp_value_orig);
+ return temp_value_orig;
+ }
+
+
+ public static void enableTemp() {
+ if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
+ ICJniUtils.disablePedometer();
+ ICJniUtils.enableTemperature();
+ mSleep(1000);
+ }
+ }
+
+ public static void disableTemp() {
+ if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
+ ICJniUtils.disableTemperature();
+ ICJniUtils.enablePedometer();
+ }
+ }
+
+ public static void mSleep(int ms) {
+ try {
+ Thread.yield();
+ Thread.sleep(ms);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ //thermal_zone0
+ public static final String CMD_CPU_TEM = "cat /sys/class/thermal/thermal_zone0/temp";
+ public static final String CMD_CPU_TYPE = "cat /sys/class/thermal/thermal_zone0/type";
+ //thermal_zone1
+ public static final String CMD_GPU_TEM = "cat /sys/class/thermal/thermal_zone1/temp";
+ public static final String CMD_GPU_TYPE = "cat /sys/class/thermal/thermal_zone1/type";
+ //thermal_zone2
+ public static final String CMD_CHARGE_TEM = "cat /sys/class/thermal/thermal_zone2/temp";
+ public static final String CMD_CHARGE_TYPE = "cat /sys/class/thermal/thermal_zone2/type";
+ //thermal_zone3
+ public static final String CMD_PA_TEM = "cat /sys/class/thermal/thermal_zone3/temp";
+ public static final String CMD_PA_TYPE = "cat /sys/class/thermal/thermal_zone3/type";
+ //thermal_zone4
+ public static final String CMD_BOARD_TEM = "cat /sys/class/thermal/thermal_zone4/temp";
+ public static final String CMD_BOARD_TYPE = "cat /sys/class/thermal/thermal_zone4/type";
+
+
+ /**
+ * 这里获取到CPU温度,主板温度,体温,外温的数据,然后写到log里,后面转成数据表,再转成函数表达式。
+ */
+ public static TemperatureItem doTempTest() {
+ if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
+
+ double bodyTemp/*体温*/ = 0.0f;
+ double cpuTemp/*cpu温度*/ = 0.0f;
+ double evnTemp/*环境温度*/ = 0.0f;
+ double gpuTemp/*gpu温度*/ = 0.0f;
+ double chargeTemp/*充电板的温度*/ = 0.0f;
+ double paTemp/*射频的温度*/ = 0.0f;
+ double boardTemp/*主板的温度*/ = 0.0f;
+ try {
+ String cpuTempType = ShellUtil.execRootCmd(CMD_CPU_TYPE);
+ String cpuTempStr = ShellUtil.execRootCmd(CMD_CPU_TEM);
+ String gpuTempType = ShellUtil.execRootCmd(CMD_GPU_TYPE);
+ String gpuTempStr = ShellUtil.execRootCmd(CMD_GPU_TEM);
+ String chargeTempType = ShellUtil.execRootCmd(CMD_CHARGE_TYPE);
+ String chargeTempStr = ShellUtil.execRootCmd(CMD_CHARGE_TEM);
+ String paTempType = ShellUtil.execRootCmd(CMD_PA_TYPE);
+ String paTempStr = ShellUtil.execRootCmd(CMD_PA_TEM);
+ String boardTempType = ShellUtil.execRootCmd(CMD_BOARD_TYPE);
+ String boardTempStr = ShellUtil.execRootCmd(CMD_BOARD_TEM);
+ //cpuTempType == > cpu-thmzone cpuTempStr == > 45295 gpuTempType == > gpu-thmzone gpuTempStr == > 43910
+ Log.d(TAG, " cpuTempType == > " + cpuTempType +
+ " cpuTempStr == > " + cpuTempStr +
+ "\n | " +
+ " gpuTempType == > " + gpuTempType +
+ " gpuTempStr == > " + gpuTempStr
+ + "\n | "
+ + "chargeTempType == > " + chargeTempType +
+ " chargeTempStr == > " + chargeTempStr
+ + "\n | "
+ + "paTempType == > " + paTempType +
+ " paTempStr == > " + paTempStr
+ + "\n | "
+ + "boardTempType == > " + boardTempType +
+ " boardTempStr == > " + boardTempStr
+ );
+ //数据处理一下
+ cpuTemp = Integer.parseInt(cpuTempStr) / 1000.0f;
+ gpuTemp = Integer.parseInt(gpuTempStr) / 1000.0f;
+ chargeTemp = Integer.parseInt(chargeTempStr) / 1000.0f;
+ paTemp = Integer.parseInt(paTempStr) / 1000.0f;
+ boardTemp = Integer.parseInt(boardTempStr) / 1000.0f;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ evnTemp = get_tempOut_value_origin();
+ bodyTemp = get_temp_value_adjusted();
+ //对数据进行处理=======================================================start
+ // 环境温度计算公式:
+ // Ut=St-(0.6205x-22.049),St为传感器温度,其中x主板温度,x∈[38,56]
+ // 体温计算公式:
+ // Ut = St-(Bt*0.4533-15.294) St为传感器温度,Bt为板子温度 Bt∈[38,56]
+ // 系数不要抽成常量,以后如果有更好的公式可以替换。
+ // 以上公式通过数据分析出来的,此公式仅适用于S123的产品,公式跟产品结构有关系
+ //TODO:以上重要,所以同时对外可支持配置,如果没有配置不进行数据处理,直接返回原数值
+ //TODO:配置格式:
+ // PRODUCT_PROPERTY_OVERRIDES += persist.sys.envTempAlgSlope=系数(斜率)
+ // PRODUCT_PROPERTY_OVERRIDES += persist.sys.envTempAlgDy=Y轴偏移值
+ //========================================================================//
+ //环境温度的斜率和Y轴偏移值
+ String envSlope = Util.getSystemProperties("persist.sys.envAlgSlope", "");
+ String envDy = Util.getSystemProperties("persist.sys.envAlgDy", "");
+ ICLogger.d("envSlope == > " + envSlope + " envDy == > " + envDy);
+ double resultEnvTemp = evnTemp;
+ if (!TextUtils.isEmpty(envDy) && !TextUtils.isEmpty(envSlope)) {
+ //进行换算
+ ICLogger.d("env temp with board temp...");
+ resultEnvTemp = evnTemp - (Float.parseFloat(envSlope) * boardTemp + Float.parseFloat(envDy));
+ }
+
+ String bodySlope = Util.getSystemProperties("persist.sys.bodyAlgSlope", "");
+ String bodyDy = Util.getSystemProperties("persist.sys.bodyAlgDy", "");
+ ICLogger.d("bodySlope == > " + bodySlope + " bodyDy == > " + bodyDy);
+ double resultBodyTemp = bodyTemp;
+ if (!TextUtils.isEmpty(bodyDy) && !TextUtils.isEmpty(bodySlope)) {
+ ICLogger.d("body temp with board temp...");
+ resultBodyTemp = bodyTemp - (Float.parseFloat(bodySlope) * boardTemp + Float.parseFloat(bodyDy));
+ }
+
+ //=======================================================================end
+ ICLogger.d("evnTemp == > " + evnTemp + " resultEnvTemp = > " + resultEnvTemp);
+ ICLogger.d("bodyTemp == > " + bodyTemp + " resultBodyTemp = > " + resultBodyTemp);
+ if (resultBodyTemp < 0) {
+ return null;
+ }
+ try {
+ //发送消息给launcher显示
+ TemperatureItem temperatureItem = new TemperatureItem(
+ String.format("%.01f", resultBodyTemp),
+ String.format("%.01f", cpuTemp),
+ String.format("%.01f", resultEnvTemp),
+ String.format("%.01f", gpuTemp),
+ String.format("%.01f", chargeTemp),
+ String.format("%.01f", boardTemp),
+ String.format("%.01f", paTemp));
+ return temperatureItem;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+}
package com.enqualcomm.support.utils;
-import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.enqualcomm.support.Config;
-import com.enqualcomm.support.Constants;
import com.enqualcomm.support.CoreService;
import com.enqualcomm.support.LocationClient;
import com.enqualcomm.support.bean.Runtime;
import com.enqualcomm.support.bean.StringMessage;
-import com.enqualcomm.support.bean.heartRateStatus;
+import com.enqualcomm.support.bean.TemperatureItem;
import com.enqualcomm.support.service.Deliver;
-import com.enqualcomm.support.service.HeartRateManager;
import com.ic.jni.ICJniUtils;
import com.ic.protocols.protocolAPIHelper;
public class TemperatureUtil {
- private static double temp_value_orig =0.0f;
- private static double temp_adjust_value=0.0f;
- private static double body_temp_value=0.0f;
- private static double tempOut_value=0.0f;
- public static double get_tempOut_value_origin()
- {
- tempOut_value= ICJniUtils.getTemperatureOrigin();
- ICLogger.i("测量环境温度 原始值 "+tempOut_value);
+ private static final String TAG = "TemperatureUtil";
+ private static double temp_value_orig = 0.0f;
+ private static double temp_adjust_value = 0.0f;
+ private static double body_temp_value = 0.0f;
+ private static double tempOut_value = 0.0f;
+
+ public static double get_tempOut_value_origin() {
+ tempOut_value = ICJniUtils.getTemperatureOrigin();
+ ICLogger.i("测量环境温度 原始值 " + tempOut_value);
return tempOut_value;
}
- public static double get_temp_value_adjusted()
- {
- temp_value_orig= ICJniUtils.getTemperature();
- ICLogger.i("测量体温 原始值 "+temp_value_orig);
+
+ public static double get_temp_value_adjusted() {
+ temp_value_orig = ICJniUtils.getTemperature();
+ ICLogger.i("测量体温 原始值 " + temp_value_orig);
return temp_value_orig;
}
- public static double getTempAdjustValue(){
+ public static double getTempAdjustValue() {
- // temp_adjust_value=ICJniUtils.getTemperatureAdjustValue();
- ICLogger.i("get Temperature Adjust value="+temp_adjust_value);
+ // temp_adjust_value=ICJniUtils.getTemperatureAdjustValue();
+ ICLogger.i("get Temperature Adjust value=" + temp_adjust_value);
return temp_adjust_value;
}
- public static double getBodyTemp(double wristtemp,double envtemp){
- body_temp_value=ICJniUtils.getBodyTempFromWristTemp(wristtemp,envtemp);
- ICLogger.i("get body Temperature value="+body_temp_value);
+
+ public static double getBodyTemp(double wristtemp, double envtemp) {
+ body_temp_value = ICJniUtils.getBodyTempFromWristTemp(wristtemp, envtemp);
+ ICLogger.i("get body Temperature value=" + body_temp_value);
return body_temp_value;
}
- public static void doTempTestInThread(){
+ public static void doTempTestInThread() {
new Handler().postDelayed(new Runnable() {
@Override
DoTempTest();
}
- },500);
+ }, 500);
}
public static final String ACTION_TEMP_RESULT = "com.ic.action.temp_result";
public static final String KEY_TEMP_WRIST = "wrist"; // double 腕温
public static final String KEY_TEMP_OUT = "out"; //temp out
public static final String KEY_TEMP_BYPROTOCOL = "protocol"; //temp out
- private static void sendTempBroadcast(double value, double animal,double tempOut) {
+
+ private static void sendTempBroadcast(double value, double animal, double tempOut) {
Intent pedIntent = new Intent();
pedIntent.setAction(ACTION_TEMP_RESULT);
pedIntent.putExtra(KEY_TEMP_WRIST, value);
pedIntent.putExtra(KEY_TEMP_BODY, animal);
pedIntent.putExtra(KEY_TEMP_OUT, tempOut);
- pedIntent.putExtra(KEY_TEMP_BYPROTOCOL,true);
- if(CoreService.getInstance()!=null)
+ pedIntent.putExtra(KEY_TEMP_BYPROTOCOL, true);
+ if (CoreService.getInstance() != null)
CoreService.getInstance().sendBroadcast(pedIntent);
}
- public static void DoTempTest(){
- if(CoreService.getInstance()!=null)
- {
- if (CoreService.getInstance().getRuntime().Anti_off_flag==1) {
+ public static void DoTempTest() {
+ if (CoreService.getInstance() != null) {
+ if (CoreService.getInstance().getRuntime().Anti_off_flag == 1) {
ICLogger.i("未佩戴,取消TempTest!");
return;
}
- }else
+ } else
return;
- if (ICJniUtils.isTemperatureDevAvailable() >ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
+ if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {
- if(!DeviceInfoUtil.isFactoryTestTopActivity(CoreService.getInstance())){
+ if (!DeviceInfoUtil.isFactoryTestTopActivity(CoreService.getInstance())) {
ICJniUtils.disablePedometer();
}
ICJniUtils.enableTemperature();
Util.mSleep(1000);
- double wrist_temp, body_temp,temout;
- temout=0.0f;
+ double wrist_temp, body_temp, temout;
+ temout = 0.0f;
wrist_temp = TemperatureUtil.get_temp_value_adjusted();
- if(wrist_temp< 10){
+ if (wrist_temp < 10) {
Util.mSleep(1000);
ICLogger.i("retry read temp for <10");
wrist_temp = TemperatureUtil.get_temp_value_adjusted();
}
- if(ICJniUtils.isTemperatureDevAvailable()==ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal()){
- //如果是IC68,只有体温,没有腕温
- if (Config.disableWristTemp) {
- body_temp=wrist_temp;
- }else {
- temout = TemperatureUtil.get_tempOut_value_origin();
- if (temout < 10) {
- Util.mSleep(1000);
- ICLogger.i("retry read tempOut for <10");
- temout = TemperatureUtil.get_tempOut_value_origin();
- }
- if (temout > 60 || temout < 10) {
- temout = 0.0f;
- }
- if (temout > 10) {
- body_temp = TemperatureUtil.getBodyTemp(wrist_temp, temout);
+ if (ICJniUtils.isTemperatureDevAvailable() == ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal()) {
+ //此处温度会走一个算法,跟主板挂钩,不同的主板有不同的公式,需要做实验,配置。
+ //具体可以点击进去看里面的代码。
+ TemperatureItem temperatureItem = TempAlgUtil.doTempTest();
+ if (temperatureItem != null) {
+ body_temp = Float.parseFloat(temperatureItem.getBodyTemp());
+ temout = Float.parseFloat(temperatureItem.getEvnTemp());
+ } else {
+ ICLogger.log(TAG, "temperatureItem is null...");
+ if (Config.disableWristTemp) {
+ body_temp = wrist_temp;
} else {
- body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);
+ temout = TemperatureUtil.get_tempOut_value_origin();
+ if (temout < 10) {
+ Util.mSleep(1000);
+ ICLogger.i("retry read tempOut for <10");
+ temout = TemperatureUtil.get_tempOut_value_origin();
+ }
+ if (temout > 60 || temout < 10) {
+ temout = 0.0f;
+ }
+ if (temout > 10) {
+ body_temp = TemperatureUtil.getBodyTemp(wrist_temp, temout);
+ } else {
+ body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);
+ }
}
}
- }else {
+ } else {
body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);
}
- if(Runtime.practising==true){
- ICLogger.i("自由锻炼中,设置测量体温!" +String.format("%.1f",body_temp));
+
+ if (Runtime.practising == true) {
+ ICLogger.i("自由锻炼中,设置测量体温!" + String.format("%.1f", body_temp));
Runtime.healthInfo.setTemperatureData(body_temp);
- }else {
- StringMessage temperatureMsg = protocolAPIHelper.getTemperatureMSG(wrist_temp, body_temp,temout, null);
+ } else {
+ StringMessage temperatureMsg = protocolAPIHelper.getTemperatureMSG(wrist_temp, body_temp, temout, null);
Deliver.sendLocationMSG(temperatureMsg);
- if (temperatureMsg!=null) ICLogger.i("发送体温测量值 " + temperatureMsg.isFromCache());
+ if (temperatureMsg != null) ICLogger.i("发送体温测量值 " + temperatureMsg.isFromCache());
}
Runtime runtime = CoreService.getInstance().getRuntime();
- runtime.tempInfo.setTemp(body_temp, wrist_temp,temout);
+ runtime.tempInfo.setTemp(body_temp, wrist_temp, temout);
//发送消息给launcher显示
- sendTempBroadcast(wrist_temp,body_temp,temout);
+ sendTempBroadcast(wrist_temp, body_temp, temout);
ICJniUtils.disableTemperature();
ICJniUtils.enablePedometer();
case 0:
break;
case 1:
- if(runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_HIGH)) {
+ if (runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_HIGH)) {
//trigger AP10 报警定位
ICLogger.i("triggerSOSLocationProcess ");
LocationClient.getInstance().triggerSOSLocationProcess();
}
break;
case 2:
- if(runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_LOW)) {
+ if (runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_LOW)) {
//trigger AP10 报警定位
ICLogger.i("triggerSOSLocationProcess ");
LocationClient.getInstance().triggerSOSLocationProcess();
import com.enqualcomm.support.Config;
import com.enqualcomm.support.CoreService;
-import com.enqualcomm.support.adapter.BTHelper;
import com.enqualcomm.support.bean.Contact;
import com.enqualcomm.support.bean.Runtime;
import com.enqualcomm.support.bean.StringMessage;
import com.enqualcomm.support.service.HeartRateManager;
import com.enqualcomm.support.utils.Connection;
import com.enqualcomm.support.utils.ICLogger;
-import com.enqualcomm.support.utils.MD5;
import com.enqualcomm.support.utils.TemperatureUtil;
import com.enqualcomm.support.utils.TimeUtil;
-import com.enqualcomm.support.utils.Util;
import com.enqualcomm.support.utils.regexUtil;
import java.util.ArrayList;
public static final String projName = "WBG100";
public static final String protocolVersion = "v1";
public static final String mqttKey = "QWER15WTF156OQRT1230";
- public static final String username="yq_watch";
- public static final String passwd="yq_watch@yg2020";
+ public static final String username = "yq_watch";
+ public static final String passwd = "yq_watch@yg2020";
public static String MQTT_CLIENT_TOPIC_HEADER = "";
public enum CMD_TYPE {
public static StringMessage genStringMessage(String cmdName, String msg) {
StringMessage sm = new StringMessage(new String[]{cmdName, msg});
sm.refresh(msg);
- sm.setDate(TimeUtil.getSystemDateYYMMDD(),TimeUtil.getSystemTimeHHmmss());
+ sm.setDate(TimeUtil.getSystemDateYYMMDD(), TimeUtil.getSystemTimeHHmmss());
return sm;
}
*/
public boolean parserCmd(String cmdtype, byte[] bytes) {
String cmd_msgbuf = new String(bytes);
- log(cmdtype+" bytes.size " + bytes.length+" "+cmd_msgbuf);
+ log(cmdtype + " bytes.size " + bytes.length + " " + cmd_msgbuf);
// cmdbuf.append(cmd_msgbuf);
// log("cmdbuf.size " + cmdbuf.length() + " " + cmdbuf.toString());
// String[] cmdlist=cmdbuf.toString().split(CMDEND+CMDHEADER);
// for ( String cmditem : cmdlist ) {
- cmd_msgbuf = cmd_msgbuf.replace(CMDHEADER, "").replace(CMDEND, "").replace("'","");
- for (CMD_TYPE key : cmdMap.keySet()) {
- if (cmdMap.get(key).toString().equals(cmdtype)) {
- handleCmd(key, cmdtype, cmd_msgbuf);
- return true;
- }
+ cmd_msgbuf = cmd_msgbuf.replace(CMDHEADER, "").replace(CMDEND, "").replace("'", "");
+ for (CMD_TYPE key : cmdMap.keySet()) {
+ if (cmdMap.get(key).toString().equals(cmdtype)) {
+ handleCmd(key, cmdtype, cmd_msgbuf);
+ return true;
}
+ }
// }
return false;
.append("/").append(protocolVersion)
.append("/").append(cmdtype)
.append("/").append(imei)
- ;
+ ;
return genStringMessage(sbtopic.toString(), sb.toString());
}
* 平台发布的子主题为:KA
* 回应的消息为:[LEN,KA]
*/
- if(runtime.bleInfo.ble_area_id.isEmpty()){
+ if (runtime.bleInfo.ble_area_id.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder();
* 123456789,为区域id
*/
- if(runtime.bleInfo.ble_area_id.isEmpty()){
+ if (runtime.bleInfo.ble_area_id.isEmpty()) {
ICLogger.i("not Bind, skip send Location!");
return null;
}
log("BP02定位接收成功");
}
- public static StringMessage LGZONE(Runtime runtime){
+ public static StringMessage LGZONE(Runtime runtime) {
/***
* 获取服务器端时间(LGZONE)
* 终端发布(平台订阅):
* 实例表示:东八区,上午8 点整
*/
- if(runtime.bleInfo.ble_area_id.isEmpty()){
+ if (runtime.bleInfo.ble_area_id.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder();
return genMqttCMDMsg(cmd, sb.toString(), runtime.IMEI());
}
- public void handleLGZONE(Connection connection,Runtime runtime, String data){
- /***
- * 获取服务器端时间(LGZONE)
- * 终端发布(平台订阅):
- * 终端向“WBG100/v1/LGZONE/ID_手表IMEI”的主题发布 [LEN,区域id]
- *
- * 实例:若手表IMEI号为334588000000156,请求绑定时下发的区域id为123456789,
- * 则向WBG100/v1/LGZONE/ID_334588000000156的主题发布 [0009,123456789]
- *
- * 终端订阅(平台发布):
- * 终端订阅“WBG100/v1/ID_手表IMEI/+”的主题列表,会收到平台的回应
- * 平台发布的子主题为:LGZONE
- * 回应的消息为:[LEN, 时区,时间,日期]
- *
- * 实例: 若手表IMEI号为334588000000156,绑定的区域为123456789,
- * 则终端订阅“WBG100/v1/ID_334588000000156/+”的主题列表,会收到平台的回应
- * 先判断子主题是否为:LGZONE
- * 是,则消息为:[001D,+8,08:00:00,2016-01-12]
- * 实例表示:东八区,上午8 点整
+ public void handleLGZONE(Connection connection, Runtime runtime, String data) {
- */
- String[] list=data.split(CMDSPLIT);
- if (list.length==4){
- String timeZone=list[1].trim();
- String date=list[3].trim();
- String time=list[2].trim();
- Date datetime= TimeUtil.parseDatetiime(date,time);
+ /***
+ * 获取服务器端时间(LGZONE)
+ * 终端发布(平台订阅):
+ * 终端向“WBG100/v1/LGZONE/ID_手表IMEI”的主题发布 [LEN,区域id]
+ *
+ * 实例:若手表IMEI号为334588000000156,请求绑定时下发的区域id为123456789,
+ * 则向WBG100/v1/LGZONE/ID_334588000000156的主题发布 [0009,123456789]
+ *
+ * 终端订阅(平台发布):
+ * 终端订阅“WBG100/v1/ID_手表IMEI/+”的主题列表,会收到平台的回应
+ * 平台发布的子主题为:LGZONE
+ * 回应的消息为:[LEN, 时区,时间,日期]
+ *
+ * 实例: 若手表IMEI号为334588000000156,绑定的区域为123456789,
+ * 则终端订阅“WBG100/v1/ID_334588000000156/+”的主题列表,会收到平台的回应
+ * 先判断子主题是否为:LGZONE
+ * 是,则消息为:[001D,+8,08:00:00,2016-01-12]
+ * 实例表示:东八区,上午8 点整
+
+ */
+ String[] list = data.split(CMDSPLIT);
+ if (list.length == 4) {
+ String timeZone = list[1].trim();
+ String date = list[3].trim();
+ String time = list[2].trim();
+ Date datetime = TimeUtil.parseDatetiime(date, time);
int timezone;
- try
- {
- timezone=Integer.parseInt(timeZone.replace("+","").trim());
- }catch (Exception e){
- ICLogger.e("timezone",e);
- timezone=8;
+ try {
+ timezone = Integer.parseInt(timeZone.replace("+", "").trim());
+ } catch (Exception e) {
+ ICLogger.e("timezone", e);
+ timezone = 8;
}
- if (datetime!=null){
- ICLogger.i("==="+timezone+" "+TimeUtil.getDefaultTimeZone());
+ if (datetime != null) {
+ ICLogger.i("===" + timezone + " " + TimeUtil.getDefaultTimeZone());
TimeUtil.setTimeZone(timezone);
- ICLogger.i("==="+TimeUtil.getDefaultTimeZone());
- TimeUtil.setSysDateTime(runtime.getContextProxy().context,datetime,timezone);
- ICLogger.i("==="+TimeUtil.getDefaultTimeZone());
+ ICLogger.i("===" + TimeUtil.getDefaultTimeZone());
+ TimeUtil.setSysDateTime(runtime.getContextProxy().context, datetime, timezone);
+ ICLogger.i("===" + TimeUtil.getDefaultTimeZone());
}
// Set Datetime 20200505112734
// Set TimeZone 8
- }else{
+ } else {
ICLogger.i("LGZONE Format Error!");
}
}
- public static StringMessage AL(Runtime runtime){
+ public static StringMessage AL(Runtime runtime) {
/***
* 报警数据上报(AL)
* 终端发布(平台订阅):
*
* 说明:终端产生警情后发送报警信息到平台,若终端没有收到回复,则定时上报直到收到报警确认为止.
*/
- if(runtime.bleInfo.ble_area_id.isEmpty()){
+ if (runtime.bleInfo.ble_area_id.isEmpty()) {
return null;
}
StringBuilder sb = new StringBuilder();
}
- public static StringMessage UPLOAD(Runtime runtime){
+ public static StringMessage UPLOAD(Runtime runtime) {
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.UPLOAD),runtime.bleInfo.ble_area_id,runtime.IMEI());
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.UPLOAD), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleUPLOAD(Connection connection,Runtime runtime,String cmd,String data){
+ public void handleUPLOAD(Connection connection, Runtime runtime, String cmd, String data) {
/**
* 数据上传间隔设置(UPLOAD)
* 平台发布(终端订阅):
* 终端收到数据,向“WBG100/v1/ID_手表IMEI/UPLOAD”的主题发布回应
* [LEN,区域id]
*/
- connection.send(UPLOAD(runtime));
- String[] list=data.split(CMDSPLIT);
- if (TextUtils.isDigitsOnly(list[1].trim())) {
- try {
- int timesecond = Integer.parseInt(list[1].trim());
- int mod = runtime.getLocationInstance().getWorkingMod();
- log("LOCATION_MODE " + LOCATION_MODE + " mod " + mod + " cycle " + timesecond);
- Config.setLocationMode(runtime.getContextProxy().context, mod);
- Config.setLocationCycle(runtime.getContextProxy().context, timesecond);
- runtime.getLocationInstance().setLocation_cycle(timesecond);
- runtime.getLocationInstance().setWorkingMod(mod);
- CoreService.getInstance().setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
- }catch (Exception e){
- ICLogger.e(e.getMessage(),e);
- }
- //此处设置好配置后,会在LocationClient通过消息开始执行及时定位操作。
- }else{
- ICLogger.i("UPLOAD format error!");
+ connection.send(UPLOAD(runtime));
+ String[] list = data.split(CMDSPLIT);
+ if (TextUtils.isDigitsOnly(list[1].trim())) {
+ try {
+ int timesecond = Integer.parseInt(list[1].trim());
+ int mod = runtime.getLocationInstance().getWorkingMod();
+ log("LOCATION_MODE " + LOCATION_MODE + " mod " + mod + " cycle " + timesecond);
+ Config.setLocationMode(runtime.getContextProxy().context, mod);
+ Config.setLocationCycle(runtime.getContextProxy().context, timesecond);
+ runtime.getLocationInstance().setLocation_cycle(timesecond);
+ runtime.getLocationInstance().setWorkingMod(mod);
+ CoreService.getInstance().setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
}
+ //此处设置好配置后,会在LocationClient通过消息开始执行及时定位操作。
+ } else {
+ ICLogger.i("UPLOAD format error!");
+ }
}
- public static StringMessage heart(int hrt,Runtime runtime){
+ public static StringMessage heart(int hrt, Runtime runtime) {
/***
* 终端心率上传(heart)
* 终端发布(平台订阅):
* 平台不需要回复
* 说明:终端按照设定间隔上报,不需要平台回复.
*/
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.heart),String.valueOf(hrt),runtime.IMEI());
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.heart), String.valueOf(hrt), runtime.IMEI());
}
- public static StringMessage oxygen(int ox ,Runtime runtime){
+
+ public static StringMessage oxygen(int ox, Runtime runtime) {
/***
*
* 上传血氧数据(oxygen)
* 平台不需要回复
* 说明:终端按照设定间隔上报,不需要平台回复.
*/
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.oxygen),String.valueOf(ox),runtime.IMEI());
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.oxygen), String.valueOf(ox), runtime.IMEI());
}
- public static StringMessage blood(int pbl,int pbh, Runtime runtime){
+ public static StringMessage blood(int pbl, int pbh, Runtime runtime) {
/***
* 上传血压数据(blood)
* 终端发布(平台订阅):
* 说明:终端按照设定间隔上报,不需要平台回复.
*
*/
- String data=pbh+CMDSPLIT+pbl;
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.blood),data,runtime.IMEI());
+ String data = pbh + CMDSPLIT + pbl;
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.blood), data, runtime.IMEI());
}
- public static StringMessage temp(double temp,Runtime runtime){
+ public static StringMessage temp(double temp, Runtime runtime) {
/***
* 上传体温数据(temp)
* 终端发布(平台订阅):
* 说明:终端按照设定间隔上报,不需要平台回复.
*/
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.temp),String.format("%.1f",temp ),runtime.IMEI());
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.temp), String.format("%.1f", temp), runtime.IMEI());
}
- public static StringMessage wdstart(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.wdstart),runtime.bleInfo.ble_area_id,runtime.IMEI());
+ public static StringMessage wdstart(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.wdstart), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleWdstart(Connection connection,Runtime runtime ,String data) {
+
+ public void handleWdstart(Connection connection, Runtime runtime, String data) {
/***
* 设置体温上传频率(wdstart)
* [LEN,区域id]
*/
connection.send(wdstart(runtime));
- String[] list=data.split(CMDSPLIT);
- if (list.length==2){
- String cycle=list[1];
- if (TextUtils.isDigitsOnly(cycle.trim())){
+ String[] list = data.split(CMDSPLIT);
+ if (list.length == 2) {
+ String cycle = list[1];
+ if (TextUtils.isDigitsOnly(cycle.trim())) {
try {
int cycle_int = Integer.parseInt(cycle.trim());
ICLogger.i("收到服务器指令:设置体温上传频率 " + cycle + "秒");
Config.setTemperatureTestCycle(runtime, cycle_int);
CoreService.getInstance().setTempAlarm();
- if(runtime.check_stat_do_temp_test()) TemperatureUtil.doTempTestInThread();
- }catch (Exception e){
- ICLogger.e(e.getMessage(),e);
+ if (runtime.check_stat_do_temp_test()) TemperatureUtil.doTempTestInThread();
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
}
- }else
- {
+ } else {
ICLogger.i("wdstart Format Error!");
}
- }else
- {
+ } else {
ICLogger.i("wdstart Format Error!");
}
}
- public static StringMessage hrtstart(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.hrtstart),runtime.bleInfo.ble_area_id,runtime.IMEI());
+
+ public static StringMessage hrtstart(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.hrtstart), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleHrtstart(Connection connection,Runtime runtime, String data) {
+
+ public void handleHrtstart(Connection connection, Runtime runtime, String data) {
/***
* 设置心率、血氧、血压上传频率(hrtstart)
* 平台发布(终端订阅):
* [LEN,区域id]
*/
connection.send(hrtstart(runtime));
- String[] list=data.split(CMDSPLIT);
- if (list.length==2){
- String cycle=list[1];
- if (TextUtils.isDigitsOnly(cycle.trim())){
+ String[] list = data.split(CMDSPLIT);
+ if (list.length == 2) {
+ String cycle = list[1];
+ if (TextUtils.isDigitsOnly(cycle.trim())) {
try {
int cycle_int = Integer.parseInt(cycle.trim());
ICLogger.i("收到服务器指令:设置心率血压周期 " + cycle + "秒" + cycle_int / 60 + "分钟");
Intent intent = new Intent();
intent.putExtra("PPGTestCycle", cycle_int / 60);
runtime.getContextProxy().sendBrodcast(ACTION_HEATR_RATE_START, intent);
- }catch (Exception e){
- ICLogger.e(e.getMessage(),e);
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
}
- }else
- {
+ } else {
ICLogger.i("Hrtstart Format Error!");
}
- }else{
+ } else {
ICLogger.i("Hrtstart Format Error!");
}
}
- public static StringMessage SOS(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.SOS),runtime.bleInfo.ble_area_id,runtime.IMEI());
+ public static StringMessage SOS(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.SOS), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleSOS(Connection connection,Runtime runtime,String cmd,String data) {
+ public void handleSOS(Connection connection, Runtime runtime, String cmd, String data) {
/***
* 设置SOS 号码(SOS)
* 平台发布(终端订阅):
* 说明:设置SOS 号码后,触发sos 警情时,终端向设置的几个号码拨打电话,一直没有接听,则循环拨打两轮,接听后则不再继续拨打电话,同时发送报警短信给2 个sos 号码.
*/
connection.send(SOS(runtime));
- if (data!=null && data.length()>0) {
+ if (data != null && data.length() > 0) {
String list[] = data.split(CMDSPLIT);
- if (list.length==2){
- ArrayList<Contact> contactArray=new ArrayList<Contact>();
- if (regexUtil.isMobileNumber( list[1]) || regexUtil.isPhoneNumber(list[1]))
- {
- contactArray.add(new Contact(Contact.CATEGORY_SOS,"sos1",list[1]));
- ICLogger.i("find SOS1 number "+list[1]);
- runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true);
- }
- }else if (list.length==3){
-
- ArrayList<Contact> contactArray=new ArrayList<Contact>();
- if (regexUtil.isMobileNumber( list[1]) || regexUtil.isPhoneNumber(list[1]))
- {
- contactArray.add(new Contact(Contact.CATEGORY_SOS,"sos1",list[1]));
- ICLogger.i("find SOS1 number "+list[1]);
+ if (list.length == 2) {
+ ArrayList<Contact> contactArray = new ArrayList<Contact>();
+ if (regexUtil.isMobileNumber(list[1]) || regexUtil.isPhoneNumber(list[1])) {
+ contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos1", list[1]));
+ ICLogger.i("find SOS1 number " + list[1]);
+ runtime.getDbHelper().saveContacts(contactArray, false, false, false, false, false, true);
+ }
+ } else if (list.length == 3) {
+
+ ArrayList<Contact> contactArray = new ArrayList<Contact>();
+ if (regexUtil.isMobileNumber(list[1]) || regexUtil.isPhoneNumber(list[1])) {
+ contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos1", list[1]));
+ ICLogger.i("find SOS1 number " + list[1]);
}
- if (regexUtil.isMobileNumber( list[2]) || regexUtil.isPhoneNumber(list[2]))
- {
- contactArray.add(new Contact(Contact.CATEGORY_SOS,"sos2",list[2]));
- ICLogger.i("find SOS2 number "+list[2]);
+ if (regexUtil.isMobileNumber(list[2]) || regexUtil.isPhoneNumber(list[2])) {
+ contactArray.add(new Contact(Contact.CATEGORY_SOS, "sos2", list[2]));
+ ICLogger.i("find SOS2 number " + list[2]);
}
- runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true);
+ runtime.getDbHelper().saveContacts(contactArray, false, false, false, false, false, true);
- }else{
+ } else {
ICLogger.i("SOS Format Error!");
}
- }else
+ } else
ICLogger.i("SOS Format Error!");
}
- public static StringMessage FACTORY(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.FACTORY),runtime.bleInfo.ble_area_id,runtime.IMEI());
+ public static StringMessage FACTORY(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.FACTORY), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleFactory(Connection connection,Runtime runtime,String cmd,String data) {
+ public void handleFactory(Connection connection, Runtime runtime, String cmd, String data) {
/***
* 恢复出厂设置(FACTORY)
* 平台发布(终端订阅):
}
- public static StringMessage MSGDOWN(Runtime runtime,String index){
- String data=new StringBuffer(index).append(CMDSPLIT).append(runtime.bleInfo.ble_area_id).toString();
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.MSGDOWN),data,runtime.IMEI());
+ public static StringMessage MSGDOWN(Runtime runtime, String index) {
+ String data = new StringBuffer(index).append(CMDSPLIT).append(runtime.bleInfo.ble_area_id).toString();
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.MSGDOWN), data, runtime.IMEI());
}
- public void handleMSGDOWN(Connection connection,Runtime runtime,String cmd,String data) {
+ public void handleMSGDOWN(Connection connection, Runtime runtime, String cmd, String data) {
/**
* 消息下发到指定手表(MSGDOWN)
* 具体消息为英文,ASCII格式,长度不超过512个字节
*/
- String[] cmdlist=data.split(CMDSPLIT);
- if (cmdlist.length == 3){
- String cmdindex=cmdlist[1];
- String txtmsg=cmdlist[2];
- StringMessage msg=MSGDOWN(runtime,cmdindex);
+ String[] cmdlist = data.split(CMDSPLIT);
+ if (cmdlist.length == 3) {
+ String cmdindex = cmdlist[1];
+ String txtmsg = cmdlist[2];
+ StringMessage msg = MSGDOWN(runtime, cmdindex);
connection.send(msg);
- ICLogger.i("received Txt Msg "+txtmsg);
- runtime.getContextProxy().sendMsgBroadcast(txtmsg,0);
+ ICLogger.i("received Txt Msg " + txtmsg);
+ runtime.getContextProxy().sendMsgBroadcast(txtmsg, 0);
runtime.getContextProxy().saveMstToSMSDB(txtmsg);
- }else{
+ } else {
ICLogger.i("MSGDOWN format error!");
}
}
- public static StringMessage REMOVE(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.REMOVE),runtime.bleInfo.ble_area_id,runtime.IMEI());
+
+ public static StringMessage REMOVE(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.REMOVE), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleREMOVE(Connection connection,Runtime runtime,String cmd,String data) {
+ public void handleREMOVE(Connection connection, Runtime runtime, String cmd, String data) {
/**
* 取下手环报警开关(REMOVE)
* 说明:手表拆除报警的开关,1 打开,0 关闭.
*/
connection.send(REMOVE(runtime));
- String[] cmdlist=data.split(CMDSPLIT);
- if (cmdlist.length == 2){
- String cmdindex=cmdlist[1];
- ICLogger.i("设置REMOVE "+cmdindex);
- }else{
+ String[] cmdlist = data.split(CMDSPLIT);
+ if (cmdlist.length == 2) {
+ String cmdindex = cmdlist[1];
+ ICLogger.i("设置REMOVE " + cmdindex);
+ } else {
ICLogger.i("REMOVE format error!");
}
}
- public static StringMessage PEDO(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.PEDO),runtime.bleInfo.ble_area_id,runtime.IMEI());
+ public static StringMessage PEDO(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.PEDO), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handlePEDO(Connection connection,Runtime runtime,String cmd,String data) {
+ public void handlePEDO(Connection connection, Runtime runtime, String cmd, String data) {
/***
* 计步功能开关(PEDO)
* 说明: 终端计步功能的开关.1 打开,0 关闭
*/
connection.send(PEDO(runtime));
- String[] cmdlist=data.split(CMDSPLIT);
- if (cmdlist.length == 2){
- String cmdindex=cmdlist[1];
- ICLogger.i("设置PEDO "+cmdindex);
- }else{
+ String[] cmdlist = data.split(CMDSPLIT);
+ if (cmdlist.length == 2) {
+ String cmdindex = cmdlist[1];
+ ICLogger.i("设置PEDO " + cmdindex);
+ } else {
ICLogger.i("PEDO format error!");
}
}
- public static StringMessage MONITOR(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.MONITOR),runtime.bleInfo.ble_area_id,runtime.IMEI());
+ public static StringMessage MONITOR(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.MONITOR), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleMONITOR(Connection connection,Runtime runtime,String cmd,String data) {
+ public void handleMONITOR(Connection connection, Runtime runtime, String cmd, String data) {
/***
监听(MONITOR)
说明:终端收到该指令后会自动回拨给设置的电话号码,电话号码为CENTER时,回拨给中心号码.
*/
connection.send(MONITOR(runtime));
- String[] cmdlist=data.split(CMDSPLIT);
- if (cmdlist.length == 2){
- String cmdindex=cmdlist[1];
- ICLogger.i("设置MONITOR 号码 "+cmdindex);
- }else{
+ String[] cmdlist = data.split(CMDSPLIT);
+ if (cmdlist.length == 2) {
+ String cmdindex = cmdlist[1];
+ ICLogger.i("设置MONITOR 号码 " + cmdindex);
+ } else {
ICLogger.i("MONITOR format error!");
}
}
- public static StringMessage CENTER(Runtime runtime){
- return genMqttCMDMsg(cmdMap.get(CMD_TYPE.CENTER),runtime.bleInfo.ble_area_id,runtime.IMEI());
+ public static StringMessage CENTER(Runtime runtime) {
+ return genMqttCMDMsg(cmdMap.get(CMD_TYPE.CENTER), runtime.bleInfo.ble_area_id, runtime.IMEI());
}
- public void handleCENTER(Connection connection,Runtime runtime,String cmd,String data) {
+ public void handleCENTER(Connection connection, Runtime runtime, String cmd, String data) {
/***
中心号码设置(CENTER)
说明:设置中心号码,通过该手机号码可发送短信指令。同时终端的各种报警短信会发送到该号码的手机上面
*/
connection.send(CENTER(runtime));
- String[] cmdlist=data.split(CMDSPLIT);
- if (cmdlist.length == 2){
- String cmdindex=cmdlist[1];
- ICLogger.i("设置CENTER 号码 "+cmdindex);
- }else{
+ String[] cmdlist = data.split(CMDSPLIT);
+ if (cmdlist.length == 2) {
+ String cmdindex = cmdlist[1];
+ ICLogger.i("设置CENTER 号码 " + cmdindex);
+ } else {
ICLogger.i("CENTER format error!");
}
}
+
public void sendBroadcast(String cmd, Runtime dev) {
ComponentName componentName = new ComponentName("com.eqc.watch", "com.eqc.watch.launcher.ChatActivity");
dev.getContextProxy().context.startActivity(intent);
}
- public boolean handleCmd(CMD_TYPE type, String cmd , String data) {
+ public boolean handleCmd(CMD_TYPE type, String cmd, String data) {
//普通非二进制命令用此函数处理
- boolean ret=true;
- ICLogger.i("mqtt handleCmd "+type.name() + " strLen="+data.length());
+ boolean ret = true;
+ ICLogger.i("mqtt handleCmd " + type.name() + " strLen=" + data.length());
- switch (type){
+ switch (type) {
case KA:
ICLogger.i("服务器收到心跳包KA");
- mConnection.DeliverCMDMessageToSystem("heartbeat",cmd);//通知下面线程状态变化
+ mConnection.DeliverCMDMessageToSystem("heartbeat", cmd);//通知下面线程状态变化
break;
case BREQ:
- handleBREQ(mRuntime,data);
+ handleBREQ(mRuntime, data);
//ICLogger.i("服务器返回Ping绑定信息");
ICLogger.i("服务器收到登录包BREQ");
- mConnection.DeliverCMDMessageToSystem("login",cmd);//通知下面线程状态变化
+ mConnection.DeliverCMDMessageToSystem("login", cmd);//通知下面线程状态变化
break;
case LGZONE:
- handleLGZONE(mConnection,mRuntime,data);
+ handleLGZONE(mConnection, mRuntime, data);
break;
case UD:
- mConnection.DeliverCMDMessageToSystem("UD",cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
+ mConnection.DeliverCMDMessageToSystem("UD", cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
break;
case AL:
- mConnection.DeliverCMDMessageToSystem("AL",cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
+ mConnection.DeliverCMDMessageToSystem("AL", cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
break;
case PEDO:
- handlePEDO(mConnection,mRuntime,cmd,data);
- mConnection.DeliverCMDMessageToSystem("PEDO",cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
+ handlePEDO(mConnection, mRuntime, cmd, data);
+ mConnection.DeliverCMDMessageToSystem("PEDO", cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
break;
case REMOVE:
- handleREMOVE(mConnection,mRuntime,cmd,data);
- mConnection.DeliverCMDMessageToSystem("REMOVE",cmd);//通知下面线程状态变化
+ handleREMOVE(mConnection, mRuntime, cmd, data);
+ mConnection.DeliverCMDMessageToSystem("REMOVE", cmd);//通知下面线程状态变化
break;
case CENTER:
- handleCENTER(mConnection,mRuntime,cmd,data);
- mConnection.DeliverCMDMessageToSystem("CENTER",cmd);//通知下面线程状态变化
+ handleCENTER(mConnection, mRuntime, cmd, data);
+ mConnection.DeliverCMDMessageToSystem("CENTER", cmd);//通知下面线程状态变化
break;
case MONITOR:
- handleMONITOR(mConnection,mRuntime,cmd,data);
- mConnection.DeliverCMDMessageToSystem("MONITOR",cmd);//通知下面线程状态变化
+ handleMONITOR(mConnection, mRuntime, cmd, data);
+ mConnection.DeliverCMDMessageToSystem("MONITOR", cmd);//通知下面线程状态变化
break;
// case CR:
// break;
case UPLOAD:
//设置工作模式
- handleUPLOAD(mConnection,mRuntime,cmd,data);
- mConnection.DeliverCMDMessageToSystem("setWorkMod",cmd);//通知下面线程状态变化
+ handleUPLOAD(mConnection, mRuntime, cmd, data);
+ mConnection.DeliverCMDMessageToSystem("setWorkMod", cmd);//通知下面线程状态变化
break;
// case BP34:
//
case SOS:
//收到设置SOS号码
- handleSOS(mConnection,mRuntime,cmd,data);
+ handleSOS(mConnection, mRuntime, cmd, data);
ICLogger.i("收到服务器设置SOS号码命令BP12");
break;
// case PHL:
// break;
case FACTORY:
//收到恢复出厂设置
- handleFactory(mConnection,mRuntime,cmd,data);
+ handleFactory(mConnection, mRuntime, cmd, data);
ICLogger.i("收到服务器恢复出厂设置命令");
- mConnection.DeliverCMDMessageToSystem("FactoryReset",cmd);//通知下面线程状态变化
+ mConnection.DeliverCMDMessageToSystem("FactoryReset", cmd);//通知下面线程状态变化
break;
//
// case BP18:
case MSGDOWN:
//服务器推送文本
- handleMSGDOWN(mConnection,mRuntime,cmd,data);
+ handleMSGDOWN(mConnection, mRuntime, cmd, data);
ICLogger.i("收到服务器推送文本消息");
// mConnection.DeliverCMDMessageToSystem("showTxt",cmd);//通知下面线程状态变化
break;
case hrtstart:
- handleHrtstart(mConnection,mRuntime,data);
+ handleHrtstart(mConnection, mRuntime, data);
ICLogger.i("收到服务器心率检测命令");
- if(mRuntime.check_stat_do_ppg_test()) HeartRateManager.triggerPPGtest();
+ if (mRuntime.check_stat_do_ppg_test()) HeartRateManager.triggerPPGtest();
break;
case wdstart:
- handleWdstart(mConnection,mRuntime,data);
+ handleWdstart(mConnection, mRuntime, data);
ICLogger.i("收到服务器体温测试及设置命令");
break;
case blood:
ICLogger.i("服务器收到上传的血压");
- mConnection.DeliverCMDMessageToSystem("blood",cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
+ mConnection.DeliverCMDMessageToSystem("blood", cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
break;
case oxygen:
ICLogger.i("服务器收到上传的血氧");
- mConnection.DeliverCMDMessageToSystem("oxygen",cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
+ mConnection.DeliverCMDMessageToSystem("oxygen", cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
break;
case temp:
ICLogger.i("服务器收到上传的体温");
- mConnection.DeliverCMDMessageToSystem("temp",cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
+ mConnection.DeliverCMDMessageToSystem("temp", cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
break;
case heart:
ICLogger.i("服务器收到上传的心率heart");
- mConnection.DeliverCMDMessageToSystem("heart",cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
+ mConnection.DeliverCMDMessageToSystem("heart", cmd);//通知下面线程状态变化,用Deliver发送的话必须发,表示服务器响应了
break;
// case BP84:
// handleBP84(cmd,mConnection);
//只有需要传递二级制数据的才需要这个函数,目前只有BP28需要
- boolean ret=true;
- ICLogger.i("handleCmd "+type.name() + " "+cmd+" bytelen="+bytes.length );
- if (Config.LOG_TOFILE) ICLogger.logToFile("APILog", " recv " +new String(bytes));
+ boolean ret = true;
+ ICLogger.i("handleCmd " + type.name() + " " + cmd + " bytelen=" + bytes.length);
+ if (Config.LOG_TOFILE) ICLogger.logToFile("APILog", " recv " + new String(bytes));
// switch (type) {
// case LK:
// // handleBP28(mConnection,cmd, mRuntime,bytes);
-#Tue Dec 15 18:15:09 CST 2020
-VERSION_CODE=727
+#Wed Dec 16 15:23:32 CST 2020
+VERSION_CODE=731