From: snickersun Date: Tue, 1 Dec 2020 11:31:45 +0000 (+0800) Subject: release L02protocolV2 V720 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=99199675927e569ee734cd7ab05fc2f000126f8d;p=protocol_srv.git release L02protocolV2 V720 优化扫描数据整理逻辑,更正APBR格式。 --- diff --git a/app/release/ICSer_V719_2011301058_release.apk b/app/release/ICSer_V720_2012011924_release.apk similarity index 78% rename from app/release/ICSer_V719_2011301058_release.apk rename to app/release/ICSer_V720_2012011924_release.apk index 61e2dc15..a8a8f39b 100644 Binary files a/app/release/ICSer_V719_2011301058_release.apk and b/app/release/ICSer_V720_2012011924_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 518fc2dc..3814e48e 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":719,"versionName":"2011301058","enabled":true,"outputFile":"ICSer_V719_2011301058_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V719_2011301058_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":720,"versionName":"2012011924","enabled":true,"outputFile":"ICSer_V720_2012011924_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V720_2012011924_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java index 9faafc47..3d74b978 100644 --- a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java +++ b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java @@ -1275,7 +1275,10 @@ public class ICSmsManager extends BroadcastReceiver { */ } + }else if(cmd.startsWith("testBT1")) { + if(CoreService.getInstance()!=null) + CoreService.getInstance().setBleScanAlarm(20); } } } \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index 64ea9564..bdbdcaaa 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -1,1178 +1,1182 @@ -package com.enqualcomm.support; - -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.Message; -import android.os.PowerManager; -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.StringMessage; -import com.enqualcomm.support.service.Deliver; -import com.enqualcomm.support.utils.CellInfoUtil; -import com.enqualcomm.support.utils.DeviceInfoUtil; -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 java.util.ArrayList; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import rx.Single; -import rx.android.schedulers.AndroidSchedulers; -import rx.functions.Action1; - -import static com.enqualcomm.support.Config.GPSLocationTimeoutInSeconds; -import static com.enqualcomm.support.Config.WiFiLocationTimeoutInSeconds; -import static com.enqualcomm.support.Constants.ACTION_CHECK_LOCATION_RESULT; - -/*** - * 周期定位:按周期进行,如果正在定位,则skip此次定位。 - * 强制定位:随机根据指令执行,如果正在定位,强制停止当前定位,立即执行新的定位。 - * 1、模式1 WiFi+LBS定位、15分钟一次,WiFi扫描3次如果都没有结果,20秒内返回LBS定位 - * 2、模式2 WiFi+LBS模式,1小时1一次,WiFi扫描3次如果都没有结果,20秒内返回LBS定位 - * 3、模式3 GPS定位模式,1分钟一次定位,GPS常开,超时返回WiFi定位。GPS 15秒内信号很差的话会提前关闭,返回wifi+LBS定位。 - * 4、模式4 GPS定位模式,1分钟定位一次,GPS常开,超时返回WiFi定位,GPS 15秒内信号很差的话会提前关闭,返回wifi+LBS定位。5分钟后自动工作在模式1上。 - * 5、模式5、8 GPS定位模式,客户自定义定位时间, 1分钟以内含1分钟,GPS常开,超时返回WiFi+LBS定位,1分钟以上的,GPS超2分钟时会关闭,GPS 15秒内信号很差的话也会提前关闭,返回wifi+LBS定位。 - * 6、模式9 WiFi模式,客户自定义定位时间,WiFi扫描3次如果都没有结果,20秒内返回LBS定位 - * 7、即时定位返回当前模式的定位方式,会强制进行定位。 - * 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 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() { -// 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 btBeaconScanResult, ArrayList 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.contains(beacon.major)) { - runtime.bleInfo.btScanResult.add(beacon.toString()); - sb.append("in list!"); - }else{ - sb.append("not in!"); - } - } - ICLogger.i(sb.toString()); - Deliver.sendLocationMSG(protocolAPIHelper.getBLEScanResult(runtime)); - } else { - ICLogger.i("未搜到蓝牙设备!"); - } - } - } - }); - - 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; - } - 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(); - -// this.H12StepCount = DeviceInfoUtil.getStepCount((runtime.getContextProxy()).context); -// if (i != 0 && Math.abs(this.H12StepCount - this.mPedometer2) > 1000) { -//// connection.send(API.H12(runtime, this.H12StepCount)); -// ICLogger.i("StepCount 运动开始后 变化超过1000 ,则发送给服务器!"); -// } - - } - - private void performAlarm(PowerManager.WakeLock paramWakeLock) { -// if (!runtime.isAirMode) { - 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 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定位成功状态 -// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { -// public void call(Object param1Object) { -// 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("工厂模式,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 " ); - - 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(){ - - public void handleMessage(Message msg) { - super.handleMessage(msg); - if (msg.what == msgWhat_WaitAndSendLocation){ - Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { - 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(); - } - } else { - ICLogger.i("BT Scanning skip ScanBLE only!"); - } - } - }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 { - Util.mSleep(1000); - StringMessage waningmsg = protocolAPIHelper.getWarningMSG(runtime); - DeliverMessage(waningmsg); - } - } - - -// -// startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。 -// forceLocation=1; -// if (runtime.bleInfo.btMacList.size() > 0) { -// //有蓝牙搜索要求则 先进行蓝牙扫描 -// if (needLocationForBT()) -// btHelper.scanBLE(); -// } else { -// startLocationProcess(ICLocation.NORMAL_MOD); -// } - } - } - }; - - - boolean wifi_ok=false,gps_ok=false,lbs_ok=false,gps_nosignal=false; - - private static boolean needCheckAgain=false; - public void waitAndSendLocation(){ - - this.mLbsHelper.getWifiResult(); - - 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定位 - } - 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); - } - - } - - - 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秒时间 - - 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; - } - ICLogger.i("needCheckAgain "+needCheckAgain); - if(needCheckAgain) { - AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, 1, ACTION_CHECK_LOCATION_RESULT); - } - } - - private void DeliverMessage(StringMessage msg){ - -// if(Runtime.practising==true){ -// if(msg==null){ -// ICLogger.i("msg is null skip!"); -// } -// ICLogger.i("自由锻炼中,定位缓存再发送!"); -// Runtime.healthInfo.setLocationData(msg.isFromCache()); -// -// //因为心率和定位用时都比温度多,但是定位和心率不一定谁用时多,所以两个都需要检测是否结束 -// if(Runtime.healthInfo.check_info_item_finished()){ -// Runtime.healthInfo.appendBuffer(Runtime.healthInfo.getHealthInfoString()); -// Runtime.healthInfo.reset(); -// } -// if(Runtime.healthInfo.getInfoCount()>=(30-1)){ -// //超过30次发送数据给服务器 -// ICLogger.i("发送数据给服务器 "+Runtime.healthInfo.getBufferData().length); -// //发送过后重置 -// Runtime.healthInfo.resetBuffer(); -// } -// }else { - Deliver.sendLocationMSG(msg); -// } - } - public void stopCheckLocationResult(){ - ICLogger.i("stopCheckLocationResult!"); -// if (mTimer!=null){ -// mTimer.shutdownNow(); -// Runnable tmp= mTimer.getQueue().poll(); -// while (tmp!=null){ -// mTimer.remove(tmp); -// } -// mTimer.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); -// mTimer.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); -// mTimer.setRemoveOnCancelPolicy(true); -// ICLogger.i("Wait for thread pool getContinueExistingPeriodicTasksAfterShutdownPolicy " +mTimer.getContinueExistingPeriodicTasksAfterShutdownPolicy()+ -// "\ngetExecuteExistingDelayedTasksAfterShutdownPolicy "+mTimer.getExecuteExistingDelayedTasksAfterShutdownPolicy()+ -// "\ngetRemoveOnCancelPolicy "+mTimer.getRemoveOnCancelPolicy()); -// while(!mTimer.isTerminated()) -// { -// StringBuilder sb=new StringBuilder(); -// if (mTimer.isTerminated()) sb.append("+"); -// if (mTimer.isShutdown()) sb.append("*"); -// if (mTimer.isTerminating()) sb.append("-"); -// ICLogger.i(sb.toString()); -// -// try { -// Thread.sleep(500); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } -// } -// mTimer.purge(); -// mTimer=null; -// } - - needCheckAgain=false; - isLocating = false; - startCheckTime=0L; - isWifiScanning=false; -// ICLogger.i(" stopCheckLocationResult Done "); - } - -// 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(); -// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { -// 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"); - } - } - - -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; - } - 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); - - // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过 - if ( ( forceLocation != 1 ) && - (Config.forceMoveCheck==true) && - (NoMoveTimeout) && (skipMoveCheck ==false )){ - ICLogger.i("No Move ,skip BT location!"); - - return false; - } - //以目前逻辑,每次检测必然跟随蓝牙扫描,因此可以在此直接更新上一次的计步次数,配合下次的运动检测 - 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; - } - //只做正常定位前是否运动的判断,给定位前蓝牙扫描专用的。和 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){ -// 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。 - if (gpsTimeoutCountOnNoMove>= MaxGpsTimeoutCountOnNoMove){ - NoMoveAndNoGPSsignalSkipGpsFlag=true; - }else{ - NoMoveAndNoGPSsignalSkipGpsFlag=false; - } - - }else{ - NoMoveAndNoGPSsignalSkipGpsFlag=false; - gpsTimeoutCountOnNoMove=0; //只要有一次 移动,则清零。 - } - - 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); -// nmeaListener.setNoStop(false);//保证从Custom切换回来的时候不至于不关闭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(); - } - - public static void setForceLocation(int _forcelocation){ - forceLocation=_forcelocation; - } - private static int forceLocation=0; - 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分钟自动停止 -// 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() { - - this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context); - - //获取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()); - - - /*注册 亮屏监控*/ -// IntentFilter intentFilter = new IntentFilter(); -// intentFilter.addAction("android.intent.action.SCREEN_ON"); -// (runtime.getContextProxy()).context.registerReceiver(this.screenOnReceiver, intentFilter); - - registerBroadReceiver(); - - - //暂时没有处理4G、2G切换问题 -// this.haveChanegTo4GTime = SystemClock.elapsedRealtime(); - } - - public void deinit() { - - ICLogger.i("GPS deinit!"); -// (runtime.getContextProxy()).context.unregisterReceiver(this.screenOnReceiver); -// mLbsHelper.unRegisterWiFiBroadReceiver(); -// this.executor.execute(new Runnable() { -// public void run() { -// Deliver.saveQueue(); -// } -// }); - 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()); - - } - })).start(); } - - - // 飞行模式 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(); - - } - - break; - case 0: - - if (isAirModeOn) { - //this.mSignalUtil.setAirMode("CloseAirplane"); - runtime.isAirMode = false; - notifiSetAirModeMethod(); - return; - } - break; - - default: - break; - } - - } - -} - +package com.enqualcomm.support; + +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.Message; +import android.os.PowerManager; +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.StringMessage; +import com.enqualcomm.support.service.Deliver; +import com.enqualcomm.support.utils.CellInfoUtil; +import com.enqualcomm.support.utils.DeviceInfoUtil; +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 java.util.ArrayList; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import rx.Single; +import rx.android.schedulers.AndroidSchedulers; +import rx.functions.Action1; + +import static com.enqualcomm.support.Config.GPSLocationTimeoutInSeconds; +import static com.enqualcomm.support.Config.WiFiLocationTimeoutInSeconds; +import static com.enqualcomm.support.Constants.ACTION_CHECK_LOCATION_RESULT; + +/*** + * 周期定位:按周期进行,如果正在定位,则skip此次定位。 + * 强制定位:随机根据指令执行,如果正在定位,强制停止当前定位,立即执行新的定位。 + * 1、模式1 WiFi+LBS定位、15分钟一次,WiFi扫描3次如果都没有结果,20秒内返回LBS定位 + * 2、模式2 WiFi+LBS模式,1小时1一次,WiFi扫描3次如果都没有结果,20秒内返回LBS定位 + * 3、模式3 GPS定位模式,1分钟一次定位,GPS常开,超时返回WiFi定位。GPS 15秒内信号很差的话会提前关闭,返回wifi+LBS定位。 + * 4、模式4 GPS定位模式,1分钟定位一次,GPS常开,超时返回WiFi定位,GPS 15秒内信号很差的话会提前关闭,返回wifi+LBS定位。5分钟后自动工作在模式1上。 + * 5、模式5、8 GPS定位模式,客户自定义定位时间, 1分钟以内含1分钟,GPS常开,超时返回WiFi+LBS定位,1分钟以上的,GPS超2分钟时会关闭,GPS 15秒内信号很差的话也会提前关闭,返回wifi+LBS定位。 + * 6、模式9 WiFi模式,客户自定义定位时间,WiFi扫描3次如果都没有结果,20秒内返回LBS定位 + * 7、即时定位返回当前模式的定位方式,会强制进行定位。 + * 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 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() { +// 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 btBeaconScanResult, ArrayList 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("未搜到蓝牙设备!"); + } + } + } + }); + + 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; + } + 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(); + +// this.H12StepCount = DeviceInfoUtil.getStepCount((runtime.getContextProxy()).context); +// if (i != 0 && Math.abs(this.H12StepCount - this.mPedometer2) > 1000) { +//// connection.send(API.H12(runtime, this.H12StepCount)); +// ICLogger.i("StepCount 运动开始后 变化超过1000 ,则发送给服务器!"); +// } + + } + + private void performAlarm(PowerManager.WakeLock paramWakeLock) { +// if (!runtime.isAirMode) { + 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 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定位成功状态 +// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { +// public void call(Object param1Object) { +// 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("工厂模式,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 " ); + + 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(){ + + public void handleMessage(Message msg) { + super.handleMessage(msg); + if (msg.what == msgWhat_WaitAndSendLocation){ + Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { + 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(); + } + } else { + ICLogger.i("BT Scanning skip ScanBLE only!"); + } + } + }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 { + Util.mSleep(1000); + StringMessage waningmsg = protocolAPIHelper.getWarningMSG(runtime); + DeliverMessage(waningmsg); + } + } + + +// +// startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。 +// forceLocation=1; +// if (runtime.bleInfo.btMacList.size() > 0) { +// //有蓝牙搜索要求则 先进行蓝牙扫描 +// if (needLocationForBT()) +// btHelper.scanBLE(); +// } else { +// startLocationProcess(ICLocation.NORMAL_MOD); +// } + } + } + }; + + + boolean wifi_ok=false,gps_ok=false,lbs_ok=false,gps_nosignal=false; + + private static boolean needCheckAgain=false; + public void waitAndSendLocation(){ + + this.mLbsHelper.getWifiResult(); + + 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定位 + } + 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); + } + + } + + + 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秒时间 + + 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; + } + ICLogger.i("needCheckAgain "+needCheckAgain); + if(needCheckAgain) { + AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, 1, ACTION_CHECK_LOCATION_RESULT); + } + } + + private void DeliverMessage(StringMessage msg){ + +// if(Runtime.practising==true){ +// if(msg==null){ +// ICLogger.i("msg is null skip!"); +// } +// ICLogger.i("自由锻炼中,定位缓存再发送!"); +// Runtime.healthInfo.setLocationData(msg.isFromCache()); +// +// //因为心率和定位用时都比温度多,但是定位和心率不一定谁用时多,所以两个都需要检测是否结束 +// if(Runtime.healthInfo.check_info_item_finished()){ +// Runtime.healthInfo.appendBuffer(Runtime.healthInfo.getHealthInfoString()); +// Runtime.healthInfo.reset(); +// } +// if(Runtime.healthInfo.getInfoCount()>=(30-1)){ +// //超过30次发送数据给服务器 +// ICLogger.i("发送数据给服务器 "+Runtime.healthInfo.getBufferData().length); +// //发送过后重置 +// Runtime.healthInfo.resetBuffer(); +// } +// }else { + Deliver.sendLocationMSG(msg); +// } + } + public void stopCheckLocationResult(){ + ICLogger.i("stopCheckLocationResult!"); +// if (mTimer!=null){ +// mTimer.shutdownNow(); +// Runnable tmp= mTimer.getQueue().poll(); +// while (tmp!=null){ +// mTimer.remove(tmp); +// } +// mTimer.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); +// mTimer.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); +// mTimer.setRemoveOnCancelPolicy(true); +// ICLogger.i("Wait for thread pool getContinueExistingPeriodicTasksAfterShutdownPolicy " +mTimer.getContinueExistingPeriodicTasksAfterShutdownPolicy()+ +// "\ngetExecuteExistingDelayedTasksAfterShutdownPolicy "+mTimer.getExecuteExistingDelayedTasksAfterShutdownPolicy()+ +// "\ngetRemoveOnCancelPolicy "+mTimer.getRemoveOnCancelPolicy()); +// while(!mTimer.isTerminated()) +// { +// StringBuilder sb=new StringBuilder(); +// if (mTimer.isTerminated()) sb.append("+"); +// if (mTimer.isShutdown()) sb.append("*"); +// if (mTimer.isTerminating()) sb.append("-"); +// ICLogger.i(sb.toString()); +// +// try { +// Thread.sleep(500); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// mTimer.purge(); +// mTimer=null; +// } + + needCheckAgain=false; + isLocating = false; + startCheckTime=0L; + isWifiScanning=false; +// ICLogger.i(" stopCheckLocationResult Done "); + } + +// 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(); +// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { +// 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"); + } + } + + +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; + } + 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); + + // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过 + if ( ( forceLocation != 1 ) && + (Config.forceMoveCheck==true) && + (NoMoveTimeout) && (skipMoveCheck ==false )){ + ICLogger.i("No Move ,skip BT location!"); + + return false; + } + //以目前逻辑,每次检测必然跟随蓝牙扫描,因此可以在此直接更新上一次的计步次数,配合下次的运动检测 + 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; + } + //只做正常定位前是否运动的判断,给定位前蓝牙扫描专用的。和 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){ +// 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。 + if (gpsTimeoutCountOnNoMove>= MaxGpsTimeoutCountOnNoMove){ + NoMoveAndNoGPSsignalSkipGpsFlag=true; + }else{ + NoMoveAndNoGPSsignalSkipGpsFlag=false; + } + + }else{ + NoMoveAndNoGPSsignalSkipGpsFlag=false; + gpsTimeoutCountOnNoMove=0; //只要有一次 移动,则清零。 + } + + 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); +// nmeaListener.setNoStop(false);//保证从Custom切换回来的时候不至于不关闭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(); + } + + public static void setForceLocation(int _forcelocation){ + forceLocation=_forcelocation; + } + private static int forceLocation=0; + 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分钟自动停止 +// 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() { + + this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context); + + //获取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()); + + + /*注册 亮屏监控*/ +// IntentFilter intentFilter = new IntentFilter(); +// intentFilter.addAction("android.intent.action.SCREEN_ON"); +// (runtime.getContextProxy()).context.registerReceiver(this.screenOnReceiver, intentFilter); + + registerBroadReceiver(); + + + //暂时没有处理4G、2G切换问题 +// this.haveChanegTo4GTime = SystemClock.elapsedRealtime(); + } + + public void deinit() { + + ICLogger.i("GPS deinit!"); +// (runtime.getContextProxy()).context.unregisterReceiver(this.screenOnReceiver); +// mLbsHelper.unRegisterWiFiBroadReceiver(); +// this.executor.execute(new Runnable() { +// public void run() { +// Deliver.saveQueue(); +// } +// }); + 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()); + + } + })).start(); } + + + // 飞行模式 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(); + + } + + break; + case 0: + + if (isAirModeOn) { + //this.mSignalUtil.setAirMode("CloseAirplane"); + runtime.isAirMode = false; + notifiSetAirModeMethod(); + return; + } + break; + + default: + break; + } + + } + +} + diff --git a/app/version_code.properties b/app/version_code.properties index 950e6f53..da93444b 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Mon Nov 30 10:58:29 CST 2020 -VERSION_CODE=719 +#Tue Dec 01 19:24:13 CST 2020 +VERSION_CODE=720 diff --git a/local.properties b/local.properties index 922ccafd..38825a3a 100644 --- a/local.properties +++ b/local.properties @@ -1,8 +1,8 @@ -## This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Sat Nov 28 22:50:15 CST 2020 -sdk.dir=D\:\\Android\\Sdk +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Tue Dec 01 09:24:14 CST 2020 +sdk.dir=C\:\\Users\\incar\\AppData\\Local\\Android\\Sdk