From 1adfc222885f98cf07fae869732e833d504bad0e Mon Sep 17 00:00:00 2001 From: snicker Date: Mon, 23 Mar 2020 11:28:16 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9log=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../com/enqualcomm/support/CoreService.java | 16 +++++++------- .../com/enqualcomm/support/NMEAListener.java | 16 +++++++------- .../enqualcomm/support/adapter/LBSHelper.java | 22 ++++++++++--------- .../enqualcomm/support/service/Deliver.java | 6 ++--- .../enqualcomm/support/utils/AlarmWakeUp.java | 2 +- .../enqualcomm/support/utils/BatteryUtil.java | 10 ++++----- .../support/utils/CellInfoUtil.java | 2 +- .../support/utils/NettyConnection.java | 12 +++++----- 8 files changed, 44 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 2f48190a..3d356fb8 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -143,7 +143,7 @@ public class CoreService extends Service { stringBuilder1.append(Integer.valueOf(str, 16)); stringBuilder1.append(",CELLID="); stringBuilder1.append(Integer.valueOf(str1, 16)); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "LBS", stringBuilder1.toString()); + if (Config.LOG_TOFILE) ICLogger.logToFile( "LBS", stringBuilder1.toString()); } } } @@ -155,7 +155,7 @@ public class CoreService extends Service { StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.append("broadcastReceiver alarmCycle action=="); stringBuilder2.append(param1Intent.getAction()); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder2.toString()); + if (Config.LOG_TOFILE) ICLogger.logToFile( "alarmCycle", stringBuilder2.toString()); StringBuilder stringBuilder1 = new StringBuilder(); stringBuilder1.append("时间变化"); stringBuilder1.append(param1Intent.getAction()+stringBuilder2.toString()); @@ -658,7 +658,7 @@ public class CoreService extends Service { StringBuilder stringBuilder1 = new StringBuilder(); stringBuilder1.append("LOCATION_ALARM work mod="); stringBuilder1.append(runtime.getLocationInstance().getWorkingMod()); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder1.toString()); + if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", stringBuilder1.toString()); // this.locationClient.triggerLocationProcess(); } else { @@ -666,7 +666,7 @@ public class CoreService extends Service { if (Constants.SLEEP_ALARM.equals(paramIntent.getAction())) { ICLogger.i("SLEEP_ALARM"); is_allowed_in_sleep_mode = 1; - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "SLEEP_ALARM alarmCycle"); + if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", "SLEEP_ALARM alarmCycle"); setSleepAlarm(); boolean bool = ((PowerManager)getSystemService(POWER_SERVICE)).isScreenOn(); stringBuilder1 = new StringBuilder(); @@ -684,7 +684,7 @@ public class CoreService extends Service { if (Constants.WAKE_ALARM.equals(paramIntent.getAction())) { if (is_in_sleep_mode) { is_in_sleep_mode = false; - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "WAKE_ALARM alarmCycle"); + if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", "WAKE_ALARM alarmCycle"); if (this.mKeepAlive != null) this.mKeepAlive.setSleepMode(false); wakeUpFromSleep(); @@ -703,7 +703,7 @@ public class CoreService extends Service { this.startConnectionRetryTimer(); } setHeartAlarm(); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "HEART_ALARM alarmCycle " ); + if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", "HEART_ALARM alarmCycle " ); return Service.START_STICKY; } } else { @@ -766,8 +766,8 @@ public class CoreService extends Service { StringBuilder sb=new StringBuilder(); AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,delayTimeInMinutes, ACTION_SEND_EMEGENCY_LOCATION_STOP); sb.append(" tEmegencyLocationSTOPAlarm "+ACTION_SEND_EMEGENCY_LOCATION_STOP); - ICLogger.i(sb.toString()); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(),"alarmCycle",sb.toString()); +// ICLogger.i(sb.toString()); + if (Config.LOG_TOFILE)ICLogger.logToFile("alarmCycle",sb.toString()); } public void setLocationAlarm(int mod) { // int mod=runtime.getLocationInstance().getWorkingMod(); diff --git a/app/src/main/java/com/enqualcomm/support/NMEAListener.java b/app/src/main/java/com/enqualcomm/support/NMEAListener.java index 835a4002..1ea9e8d8 100644 --- a/app/src/main/java/com/enqualcomm/support/NMEAListener.java +++ b/app/src/main/java/com/enqualcomm/support/NMEAListener.java @@ -111,7 +111,7 @@ public class NMEAListener implements NmeaListener, LocationListener { // ICLogger.i("Nmea :"+nmeastr+" "+paramLong); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutputRaw(this.runtime.getCacheDir(), "Nmea", nmeastr); + ICLogger.logToFile("Nmea", nmeastr); if (nmeastr.startsWith("$RD_RSSI")) { //每组NMEA数据的头,只适用于 SL8521E,9820E @@ -131,9 +131,9 @@ public class NMEAListener implements NmeaListener, LocationListener { } sb.append("]"); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString()); - ICLogger.i(sb.toString()); + ICLogger.logToFile( "GPS", sb.toString()); + ICLogger.i(sb.toString()); // 卫星总数小于2 ,或者 snr小于20 if (runtime.getLocationInstance().numSatelliteList.size() < 3 && (runtime.getLocationInstance().max3Satellite.size() > 0 ? (runtime.getLocationInstance().max3Satellite.get(0).getSnr() < 20 ? true : false) : true)) { noSignalCount++; @@ -159,7 +159,7 @@ public class NMEAListener implements NmeaListener, LocationListener { } ICLogger.i(sb2.toString()); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb2.toString()); + ICLogger.logToFile("GPS", sb2.toString()); if (mCallback != null) @@ -327,7 +327,7 @@ public class NMEAListener implements NmeaListener, LocationListener { latitude = last; // 经纬度 保留4位小数点 - DecimalFormat df = new DecimalFormat("#.000000"); + DecimalFormat df = new DecimalFormat("#.0000000"); String strLatitude = df.format(latitude); String strLongitude = df.format(longitude); @@ -336,14 +336,14 @@ public class NMEAListener implements NmeaListener, LocationListener { sb.append("GPGGA, location time= " + TimeUtil.getLocalTime() + ", FixedCount=" + locationFixedCount + ", GPSTime=" + utctime + ", Lat=" + Lat + " (" + strLatitude + "), Lon=" + lon + " (" + strLongitude + "), fixed=" + fixed + ", hdop=" + hdop + ", usedStarts=" + usedStarts); ICLogger.i(sb.toString()); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString()); + ICLogger.logToFile( "GPS", sb.toString()); //定位了, if (hdop != null && hdop.trim().length() > 0 && Float.valueOf(hdop) < ICLocation.MAX_HDOP) { locationFixedCount++; } else { ICLogger.i("HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!"); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!"); + ICLogger.logToFile( "GPS", "HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!"); } if (locationFixedCount > MaxFixedTimes) { /* @@ -356,7 +356,7 @@ public class NMEAListener implements NmeaListener, LocationListener { runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED); ICLogger.i("定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED "); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED "); + ICLogger.logToFile("GPS", "定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED "); if (!noStop) { stopListen(); } diff --git a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java index 4b54faff..e09917fd 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java @@ -134,27 +134,29 @@ public class LBSHelper { } else { this.sortByLevel(aplist); StringBuilder sb = new StringBuilder(""); + StringBuilder sblog = new StringBuilder(""); Iterator it = aplist.iterator(); int count = 0; while (it.hasNext()) { ScanResult var5 = (ScanResult) it.next(); if (var5.level != 0) { - sb.append("&"); - sb.append("AP"); - sb.append(count); - sb.append("|"); - sb.append(var5.BSSID); - sb.append("|"); - sb.append(var5.level); count ++; - if (count == 6) { - break; + if (count < 6) { + sb.append("&"); + sb.append("AP"); + sb.append(count); + sb.append("|"); + sb.append(var5.BSSID); + sb.append("|"); + sb.append(var5.level); } + sblog.append("[").append(count).append(",SSID:").append(var5.SSID).append(",BSSID:").append(var5.BSSID).append(",Level:").append(var5.level).append("];"); } } if (sb.toString().startsWith("&")) sb.deleteCharAt(0); - return sb; + if(Config.LOG_TOFILE) ICLogger.logToFile("LBS",sblog.toString()); + return sb; } } diff --git a/app/src/main/java/com/enqualcomm/support/service/Deliver.java b/app/src/main/java/com/enqualcomm/support/service/Deliver.java index 2f1b2f67..b60730df 100644 --- a/app/src/main/java/com/enqualcomm/support/service/Deliver.java +++ b/app/src/main/java/com/enqualcomm/support/service/Deliver.java @@ -212,7 +212,7 @@ public class Deliver extends AbstractConnectionService { ICLogger.i("网络不通,不能发送!"); if (!ServiceUtil.offerQueue(stringMessage,true)){ ICLogger.i("MessageQueue 已满,数据将被丢弃!"+ stringMessage); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " queueFullskip! " + stringMessage); + if (Config.LOG_TOFILE) ICLogger.logToFile( "APILog", " queueFullskip! " + stringMessage); } ret=false; } @@ -286,7 +286,7 @@ public static void sendLocationMSG( String Msg){ if(mRuntime.getUseQueue()){ if(!ServiceUtil.offerQueue(protocolAPIHelper.genStringMessage("queue",Msg))) { ICLogger.i(" MessageQueue 已满,数据将被丢弃," + Msg); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " queueFullskip " + Msg); + if (Config.LOG_TOFILE)ICLogger.logToFile( "APILog", " queueFullskip " + Msg); } @@ -299,7 +299,7 @@ public static void sendLocationMSG( String Msg){ connection.send(protocolAPIHelper.genStringMessage("queue",Msg)); } else { ICLogger.i("offline skip " + Msg); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " offlineskip " + Msg); + if (Config.LOG_TOFILE) ICLogger.logToFile( "APILog", " offlineskip " + Msg); } } } diff --git a/app/src/main/java/com/enqualcomm/support/utils/AlarmWakeUp.java b/app/src/main/java/com/enqualcomm/support/utils/AlarmWakeUp.java index 0fa74545..0a5f6ab0 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/AlarmWakeUp.java +++ b/app/src/main/java/com/enqualcomm/support/utils/AlarmWakeUp.java @@ -31,7 +31,7 @@ public class AlarmWakeUp { stringBuilder.append("---lastAlarmTime="); stringBuilder.append(lastAlarmTime); ICLogger.i("AlarmWakeUp "+ stringBuilder.toString()); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder.toString()); + if (Config.LOG_TOFILE) ICLogger.logToFile( "alarmCycle", stringBuilder.toString()); } } diff --git a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java index b8a52be9..b50756a1 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java @@ -35,7 +35,7 @@ public class BatteryUtil { int batteryVolt = param1Intent.getIntExtra(EXTRA_VOLTAGE, -1); BatteryUtil.this.mRuntime.setBatteryVoltage(batteryVolt); ICLogger.i("BatteryLevel "+i + " BatteryVotage "+batteryVolt); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","BatteryLevel "+i + " BatteryVotage "+batteryVolt); + if (Config.LOG_TOFILE)ICLogger.logToFile("Battery","BatteryLevel "+i + " BatteryVotage "+batteryVolt); if (i >= 100) { Runtime runtime = BatteryUtil.this.mRuntime; StringBuffer stringBuffer = BatteryUtil.this.mBuffer; @@ -92,7 +92,7 @@ public class BatteryUtil { }else if (Intent.ACTION_BATTERY_LOW.equals(param1Intent.getAction())) { BatteryUtil.this.mRuntime.setBatteryLow(true); ICLogger.i("lowbattery finish video_end_call"); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","BatteryLow !"); + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow !"); mRuntime.setAlarmType(false,mRuntime.getBatteryLow(),false,false); //trigger AP10 报警定位 @@ -101,17 +101,17 @@ public class BatteryUtil { }else if (Intent.ACTION_BATTERY_OKAY.equals(param1Intent.getAction())){ ICLogger.i("Battery OKAY !"); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","Battery OKAY !"); + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","Battery OKAY !"); }else if (Intent.ACTION_POWER_CONNECTED.equals(param1Intent.getAction())){ ICLogger.i("ACTION_POWER_CONNECTED !"); mRuntime.setPowerConnected(true); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","ACTION_POWER_CONNECTED!"); + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","ACTION_POWER_CONNECTED!"); }else if (Intent.ACTION_POWER_DISCONNECTED.equals(param1Intent.getAction())){ ICLogger.i("ACTION_POWER_DISCONNECTED!"); mRuntime.setPowerConnected(false); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","ACTION_POWER_DISCONNECTED !"); + if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","ACTION_POWER_DISCONNECTED !"); } } diff --git a/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java b/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java index 47885d11..35f95718 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java @@ -109,7 +109,7 @@ public class CellInfoUtil { // EqcAlgorithmNative.native_EqcAlgorithmMethod4(0, 0, CellInfoUtil.BSSS, CellInfoUtil.MCC, CellInfoUtil.MNC, CellInfoUtil.LAC, CellInfoUtil.CELL_ID); mRuntime.cellinfo = mCellInfo; } - if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"LBS", mCellInfo); + if (Config.LOG_TOFILE)ICLogger.logToFile("LBS", mCellInfo); CellInfoUtil.releaseWakeLock(mWakeLock); ICLogger.i(" setCurrentAttachCellInfo " + mCellInfo); diff --git a/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java b/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java index 9787abdd..a52bd8ff 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java +++ b/app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java @@ -52,7 +52,7 @@ public class NettyConnection implements Connection { Runtime runtime=CoreService.getInstance().getRuntime(); boolean ret=true; ICLogger.i("handleCmd "+type.name() + " strLen="+cmd.length()); - if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " + cmd); + if (Config.LOG_TOFILE)ICLogger.logToFile("APILog", " recv " + cmd); switch (type){ case BP00: API.handleBP00(cmd); @@ -179,7 +179,7 @@ public class NettyConnection implements Connection { Runtime runtime=CoreService.getInstance().getRuntime(); boolean ret=true; ICLogger.i("handleCmd "+type.name() + " "+cmd+" bytelen="+bytes.length ); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " +new String(bytes)); + if (Config.LOG_TOFILE) ICLogger.logToFile("APILog", " recv " +new String(bytes)); switch (type) { case BP28: API.handleBP28(NettyConnection.this,cmd, runtime,bytes); @@ -299,7 +299,7 @@ public class NettyConnection implements Connection { if (!isServerConnected()){ log("skiped"+cmd); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + cmd); + if (Config.LOG_TOFILE) ICLogger.logToFile("APILog"," skiped " + cmd); return false; }else{ log("send "+cmd); @@ -320,7 +320,7 @@ public class NettyConnection implements Connection { } ); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sent " + cmd); + if (Config.LOG_TOFILE) ICLogger.logToFile("APILog"," sent " + cmd); } @@ -337,7 +337,7 @@ public class NettyConnection implements Connection { if (!isServerConnected()){ log("skipedBytes "+new String(cmdArray)); - if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + new String(cmdArray)); + if (Config.LOG_TOFILE)ICLogger.logToFile("APILog"," skiped " + new String(cmdArray)); return false; }else{ log("sendBytes "+new String(cmdArray)); @@ -357,7 +357,7 @@ public class NettyConnection implements Connection { } ); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sentBytes " + new String(cmdArray)); + if (Config.LOG_TOFILE) ICLogger.logToFile("APILog"," sentBytes " + new String(cmdArray)); } -- 2.17.1