修改log输出
authorsnicker <snickersun@163.com>
Mon, 23 Mar 2020 03:28:16 +0000 (11:28 +0800)
committersnicker <snickersun@163.com>
Mon, 23 Mar 2020 03:28:16 +0000 (11:28 +0800)
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/NMEAListener.java
app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/utils/AlarmWakeUp.java
app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java
app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java
app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java

index 2f48190..3d356fb 100644 (file)
@@ -143,7 +143,7 @@ public class CoreService extends Service {
                         stringBuilder1.append(Integer.valueOf(str, 16));\r
                         stringBuilder1.append(",CELLID=");\r
                         stringBuilder1.append(Integer.valueOf(str1, 16));\r
-                        if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "LBS", stringBuilder1.toString());\r
+                        if (Config.LOG_TOFILE) ICLogger.logToFile( "LBS", stringBuilder1.toString());\r
                     }\r
                 }\r
             }\r
@@ -155,7 +155,7 @@ public class CoreService extends Service {
             StringBuilder stringBuilder2 = new StringBuilder();\r
             stringBuilder2.append("broadcastReceiver  alarmCycle action==");\r
             stringBuilder2.append(param1Intent.getAction());\r
-            if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder2.toString());\r
+            if (Config.LOG_TOFILE) ICLogger.logToFile( "alarmCycle", stringBuilder2.toString());\r
             StringBuilder stringBuilder1 = new StringBuilder();\r
             stringBuilder1.append("时间变化");\r
             stringBuilder1.append(param1Intent.getAction()+stringBuilder2.toString());\r
@@ -658,7 +658,7 @@ public class CoreService extends Service {
                 StringBuilder stringBuilder1 = new StringBuilder();\r
                 stringBuilder1.append("LOCATION_ALARM  work mod=");\r
                 stringBuilder1.append(runtime.getLocationInstance().getWorkingMod());\r
-                if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder1.toString());\r
+                if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", stringBuilder1.toString());\r
 //                this.locationClient.triggerLocationProcess();\r
 \r
             } else {\r
@@ -666,7 +666,7 @@ public class CoreService extends Service {
                 if (Constants.SLEEP_ALARM.equals(paramIntent.getAction())) {\r
                     ICLogger.i("SLEEP_ALARM");\r
                     is_allowed_in_sleep_mode = 1;\r
-                    if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "SLEEP_ALARM  alarmCycle");\r
+                    if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", "SLEEP_ALARM  alarmCycle");\r
                     setSleepAlarm();\r
                     boolean bool = ((PowerManager)getSystemService(POWER_SERVICE)).isScreenOn();\r
                     stringBuilder1 = new StringBuilder();\r
@@ -684,7 +684,7 @@ public class CoreService extends Service {
                     if (Constants.WAKE_ALARM.equals(paramIntent.getAction())) {\r
                         if (is_in_sleep_mode) {\r
                             is_in_sleep_mode = false;\r
-                            if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "WAKE_ALARM  alarmCycle");\r
+                            if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", "WAKE_ALARM  alarmCycle");\r
                             if (this.mKeepAlive != null)\r
                                 this.mKeepAlive.setSleepMode(false);\r
                             wakeUpFromSleep();\r
@@ -703,7 +703,7 @@ public class CoreService extends Service {
                                 this.startConnectionRetryTimer();\r
                             }\r
                             setHeartAlarm();\r
-                            if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "HEART_ALARM alarmCycle  " );\r
+                            if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", "HEART_ALARM alarmCycle  " );\r
                             return Service.START_STICKY;\r
                         }\r
                     } else {\r
@@ -766,8 +766,8 @@ public class CoreService extends Service {
         StringBuilder sb=new StringBuilder();\r
         AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,delayTimeInMinutes, ACTION_SEND_EMEGENCY_LOCATION_STOP);\r
         sb.append(" tEmegencyLocationSTOPAlarm  "+ACTION_SEND_EMEGENCY_LOCATION_STOP);\r
-        ICLogger.i(sb.toString());\r
-        if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(),"alarmCycle",sb.toString());\r
+//        ICLogger.i(sb.toString());\r
+        if (Config.LOG_TOFILE)ICLogger.logToFile("alarmCycle",sb.toString());\r
     }\r
     public void setLocationAlarm(int mod) {\r
 //        int mod=runtime.getLocationInstance().getWorkingMod();\r
index 835a400..1ea9e8d 100644 (file)
@@ -111,7 +111,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
 //    ICLogger.i("Nmea :"+nmeastr+" "+paramLong);\r
 \r
     if (Config.LOG_TOFILE)\r
-      FileOutputUtil.fileOutputRaw(this.runtime.getCacheDir(), "Nmea", nmeastr);\r
+      ICLogger.logToFile("Nmea", nmeastr);\r
 \r
     if (nmeastr.startsWith("$RD_RSSI")) {\r
         //每组NMEA数据的头,只适用于 SL8521E,9820E\r
@@ -131,9 +131,9 @@ public class NMEAListener implements NmeaListener, LocationListener {
       }\r
       sb.append("]");\r
       if (Config.LOG_TOFILE)\r
-        FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
-      ICLogger.i(sb.toString());\r
+        ICLogger.logToFile( "GPS", sb.toString());\r
 \r
+      ICLogger.i(sb.toString());\r
       // 卫星总数小于2 ,或者 snr小于20\r
       if (runtime.getLocationInstance().numSatelliteList.size() < 3 && (runtime.getLocationInstance().max3Satellite.size() > 0 ? (runtime.getLocationInstance().max3Satellite.get(0).getSnr() < 20 ? true : false) : true)) {\r
         noSignalCount++;\r
@@ -159,7 +159,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
       }\r
       ICLogger.i(sb2.toString());\r
       if (Config.LOG_TOFILE)\r
-        FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb2.toString());\r
+        ICLogger.logToFile("GPS", sb2.toString());\r
 \r
 \r
       if (mCallback != null)\r
@@ -327,7 +327,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
         latitude = last;\r
 \r
         // 经纬度 保留4位小数点\r
-        DecimalFormat df = new DecimalFormat("#.000000");\r
+        DecimalFormat df = new DecimalFormat("#.0000000");\r
         String strLatitude = df.format(latitude);\r
         String strLongitude = df.format(longitude);\r
 \r
@@ -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);\r
         ICLogger.i(sb.toString());\r
         if (Config.LOG_TOFILE)\r
-          FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
+          ICLogger.logToFile( "GPS", sb.toString());\r
         //定位了,\r
         if (hdop != null && hdop.trim().length() > 0 && Float.valueOf(hdop) < ICLocation.MAX_HDOP) {\r
           locationFixedCount++;\r
         } else {\r
           ICLogger.i("HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!");\r
           if (Config.LOG_TOFILE)\r
-            FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!");\r
+            ICLogger.logToFile( "GPS", "HDOP is larger than " + ICLocation.MAX_HDOP + " , skip this location!");\r
         }\r
         if (locationFixedCount > MaxFixedTimes) {\r
                /*\r
@@ -356,7 +356,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
           runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
           ICLogger.i("定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED ");\r
           if (Config.LOG_TOFILE)\r
-            FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED ");\r
+            ICLogger.logToFile("GPS", "定位" + locationFixedCount + "次 > " + MaxFixedTimes + ", set LOCATION_FIXED ");\r
           if (!noStop) {\r
             stopListen();\r
           }\r
index 4b54faf..e09917f 100644 (file)
@@ -134,27 +134,29 @@ public class LBSHelper {
         } else {\r
             this.sortByLevel(aplist);\r
             StringBuilder sb = new StringBuilder("");\r
+            StringBuilder sblog = new StringBuilder("");\r
             Iterator it = aplist.iterator();\r
             int count = 0;\r
 \r
             while (it.hasNext()) {\r
                 ScanResult var5 = (ScanResult) it.next();\r
                 if (var5.level != 0) {\r
-                    sb.append("&");\r
-                    sb.append("AP");\r
-                    sb.append(count);\r
-                    sb.append("|");\r
-                    sb.append(var5.BSSID);\r
-                    sb.append("|");\r
-                    sb.append(var5.level);\r
                     count ++;\r
-                    if (count == 6) {\r
-                        break;\r
+                    if (count < 6) {\r
+                        sb.append("&");\r
+                        sb.append("AP");\r
+                        sb.append(count);\r
+                        sb.append("|");\r
+                        sb.append(var5.BSSID);\r
+                        sb.append("|");\r
+                        sb.append(var5.level);\r
                     }\r
+                    sblog.append("[").append(count).append(",SSID:").append(var5.SSID).append(",BSSID:").append(var5.BSSID).append(",Level:").append(var5.level).append("];");\r
                 }\r
             }\r
             if (sb.toString().startsWith("&"))  sb.deleteCharAt(0);\r
-             return sb;\r
+            if(Config.LOG_TOFILE) ICLogger.logToFile("LBS",sblog.toString());\r
+            return sb;\r
         }\r
     }\r
 \r
index 2f1b2f6..b60730d 100644 (file)
@@ -212,7 +212,7 @@ public class Deliver extends AbstractConnectionService {
                 ICLogger.i("网络不通,不能发送!");\r
                 if (!ServiceUtil.offerQueue(stringMessage,true)){\r
                   ICLogger.i("MessageQueue 已满,数据将被丢弃!"+ stringMessage);\r
-                  if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " queueFullskip!  " + stringMessage);\r
+                  if (Config.LOG_TOFILE) ICLogger.logToFile( "APILog", " queueFullskip!  " + stringMessage);\r
                 }\r
                 ret=false;\r
               }\r
@@ -286,7 +286,7 @@ public static void sendLocationMSG( String Msg){
     if(mRuntime.getUseQueue()){\r
       if(!ServiceUtil.offerQueue(protocolAPIHelper.genStringMessage("queue",Msg))) {\r
         ICLogger.i(" MessageQueue 已满,数据将被丢弃," + Msg);\r
-        if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " queueFullskip  " + Msg);\r
+        if (Config.LOG_TOFILE)ICLogger.logToFile( "APILog", " queueFullskip  " + Msg);\r
 \r
       }\r
 \r
@@ -299,7 +299,7 @@ public static void sendLocationMSG( String Msg){
         connection.send(protocolAPIHelper.genStringMessage("queue",Msg));\r
       } else {\r
         ICLogger.i("offline skip  " + Msg);\r
-        if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " offlineskip  " + Msg);\r
+        if (Config.LOG_TOFILE) ICLogger.logToFile( "APILog", " offlineskip  " + Msg);\r
       }\r
     }\r
 }\r
index 0fa7454..0a5f6ab 100644 (file)
@@ -31,7 +31,7 @@ public class AlarmWakeUp {
       stringBuilder.append("---lastAlarmTime=");\r
       stringBuilder.append(lastAlarmTime);\r
       ICLogger.i("AlarmWakeUp "+ stringBuilder.toString());\r
-      if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder.toString());\r
+      if (Config.LOG_TOFILE) ICLogger.logToFile( "alarmCycle", stringBuilder.toString());\r
     } \r
   }\r
   \r
index b8a52be..b50756a 100644 (file)
@@ -35,7 +35,7 @@ public class BatteryUtil {
           int batteryVolt = param1Intent.getIntExtra(EXTRA_VOLTAGE, -1);\r
           BatteryUtil.this.mRuntime.setBatteryVoltage(batteryVolt);\r
           ICLogger.i("BatteryLevel "+i + " BatteryVotage "+batteryVolt);\r
-          if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","BatteryLevel "+i + " BatteryVotage "+batteryVolt);\r
+          if (Config.LOG_TOFILE)ICLogger.logToFile("Battery","BatteryLevel "+i + " BatteryVotage "+batteryVolt);\r
           if (i >= 100) {\r
             Runtime runtime = BatteryUtil.this.mRuntime;\r
             StringBuffer stringBuffer = BatteryUtil.this.mBuffer;\r
@@ -92,7 +92,7 @@ public class BatteryUtil {
         }else if (Intent.ACTION_BATTERY_LOW.equals(param1Intent.getAction())) {\r
           BatteryUtil.this.mRuntime.setBatteryLow(true);\r
           ICLogger.i("lowbattery finish video_end_call");\r
-          if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","BatteryLow !");\r
+          if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","BatteryLow !");\r
 \r
           mRuntime.setAlarmType(false,mRuntime.getBatteryLow(),false,false);\r
           //trigger AP10 报警定位\r
@@ -101,17 +101,17 @@ public class BatteryUtil {
         }else if (Intent.ACTION_BATTERY_OKAY.equals(param1Intent.getAction())){\r
 \r
           ICLogger.i("Battery OKAY !");\r
-          if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","Battery OKAY !");\r
+          if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","Battery OKAY !");\r
 \r
         }else if (Intent.ACTION_POWER_CONNECTED.equals(param1Intent.getAction())){\r
           ICLogger.i("ACTION_POWER_CONNECTED !");\r
           mRuntime.setPowerConnected(true);\r
-          if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","ACTION_POWER_CONNECTED!");\r
+          if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","ACTION_POWER_CONNECTED!");\r
 \r
         }else if (Intent.ACTION_POWER_DISCONNECTED.equals(param1Intent.getAction())){\r
           ICLogger.i("ACTION_POWER_DISCONNECTED!");\r
           mRuntime.setPowerConnected(false);\r
-          if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","ACTION_POWER_DISCONNECTED !");\r
+          if (Config.LOG_TOFILE) ICLogger.logToFile("Battery","ACTION_POWER_DISCONNECTED !");\r
 \r
         }\r
       }\r
index 47885d1..35f9571 100644 (file)
@@ -109,7 +109,7 @@ public class CellInfoUtil {
 //                EqcAlgorithmNative.native_EqcAlgorithmMethod4(0, 0, CellInfoUtil.BSSS, CellInfoUtil.MCC, CellInfoUtil.MNC, CellInfoUtil.LAC, CellInfoUtil.CELL_ID);\r
                   mRuntime.cellinfo = mCellInfo;\r
                 }\r
-                if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"LBS", mCellInfo);\r
+                if (Config.LOG_TOFILE)ICLogger.logToFile("LBS", mCellInfo);\r
                 CellInfoUtil.releaseWakeLock(mWakeLock);\r
                 ICLogger.i(" setCurrentAttachCellInfo " + mCellInfo);\r
 \r
index 9787abd..a52bd8f 100644 (file)
@@ -52,7 +52,7 @@ public class NettyConnection implements Connection {
                         Runtime runtime=CoreService.getInstance().getRuntime();\r
                         boolean ret=true;\r
                         ICLogger.i("handleCmd "+type.name() + " strLen="+cmd.length());\r
-                    if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " + cmd);\r
+                    if (Config.LOG_TOFILE)ICLogger.logToFile("APILog", " recv " + cmd);\r
                         switch (type){\r
                             case BP00:\r
                                 API.handleBP00(cmd);\r
@@ -179,7 +179,7 @@ public class NettyConnection implements Connection {
                     Runtime runtime=CoreService.getInstance().getRuntime();\r
                     boolean ret=true;\r
                     ICLogger.i("handleCmd "+type.name() + " "+cmd+" bytelen="+bytes.length );\r
-                    if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " +new String(bytes));\r
+                    if (Config.LOG_TOFILE) ICLogger.logToFile("APILog", " recv " +new String(bytes));\r
                     switch (type) {\r
                         case BP28:\r
                             API.handleBP28(NettyConnection.this,cmd, runtime,bytes);\r
@@ -299,7 +299,7 @@ public class NettyConnection implements Connection {
     if (!isServerConnected()){\r
 \r
         log("skiped"+cmd);\r
-        if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + cmd);\r
+        if (Config.LOG_TOFILE) ICLogger.logToFile("APILog"," skiped " + cmd);\r
         return false;\r
     }else{\r
         log("send  "+cmd);\r
@@ -320,7 +320,7 @@ public class NettyConnection implements Connection {
                         }\r
                 );\r
 \r
-        if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sent " + cmd);\r
+        if (Config.LOG_TOFILE) ICLogger.logToFile("APILog"," sent " + cmd);\r
 \r
     }\r
 \r
@@ -337,7 +337,7 @@ public class NettyConnection implements Connection {
         if (!isServerConnected()){\r
 \r
             log("skipedBytes "+new String(cmdArray));\r
-            if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + new String(cmdArray));\r
+            if (Config.LOG_TOFILE)ICLogger.logToFile("APILog"," skiped " + new String(cmdArray));\r
             return false;\r
         }else{\r
             log("sendBytes  "+new String(cmdArray));\r
@@ -357,7 +357,7 @@ public class NettyConnection implements Connection {
                             }\r
                     );\r
 \r
-            if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sentBytes  " + new String(cmdArray));\r
+            if (Config.LOG_TOFILE) ICLogger.logToFile("APILog"," sentBytes  " + new String(cmdArray));\r
 \r
         }\r
 \r