From 46040962fd2069e68c9301658eeaa8b8aabafdbe Mon Sep 17 00:00:00 2001 From: snickersun Date: Tue, 3 Mar 2020 18:42:08 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9SMS=E5=91=BD=E4=BB=A4=EF=BC=9A?= =?utf8?q?=201=E3=80=81TP=E5=8D=87=E7=BA=A7=E6=B7=BB=E5=8A=A0=E7=89=88?= =?utf8?q?=E6=9C=AC=E5=88=A4=E6=96=AD=EF=BC=8C=E9=98=B2=E6=AD=A2=E8=AF=AF?= =?utf8?q?=E5=8D=87=E7=BA=A7=E5=8F=8A=E9=87=8D=E5=A4=8D=E5=8D=87=E7=BA=A7?= =?utf8?q?=E3=80=82=202=E3=80=81=E6=B7=BB=E5=8A=A0=E5=AF=B9SD=E5=8D=A1?= =?utf8?q?=E4=B8=AD=E7=9A=84=E7=9B=AE=E5=BD=95=E6=88=96=E8=80=85=E6=96=87?= =?utf8?q?=E4=BB=B6=E7=9A=84=E4=B8=8A=E4=BC=A0=E3=80=82=E6=96=B9=E4=BE=BF?= =?utf8?q?=E8=8E=B7=E5=8F=96=E5=85=B6=E4=BB=96=E5=BA=94=E7=94=A8=E7=9A=84?= =?utf8?q?=E6=97=A5=E5=BF=97=E3=80=82=20=E5=91=BD=E4=BB=A4=E6=A0=BC?= =?utf8?q?=E5=BC=8F=EF=BC=9A#logctl#=3Dupload,SDLog:[dirname|filename]?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- app/app.iml | 11 ++- .../com/enqualcomm/support/ICSmsManager.java | 94 ++++++++++++++----- .../enqualcomm/support/utils/ICHttpUtil.java | 21 +++-- dNSCache/dNSCache.iml | 1 + 4 files changed, 91 insertions(+), 36 deletions(-) diff --git a/app/app.iml b/app/app.iml index 51cd3ff0..438d0136 100644 --- a/app/app.iml +++ b/app/app.iml @@ -103,11 +103,11 @@ - - - - - + + + + + @@ -124,5 +124,6 @@ + \ 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 37b15795..4bf42a9d 100644 --- a/app/src/main/java/com/enqualcomm/support/ICSmsManager.java +++ b/app/src/main/java/com/enqualcomm/support/ICSmsManager.java @@ -9,6 +9,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; import android.net.Uri; +import android.os.Environment; import android.os.SystemClock; import android.telephony.SmsManager; import android.telephony.SmsMessage; @@ -364,15 +365,15 @@ public class ICSmsManager { if (cmdl.length == 2) { String logfile=cmdl[1]; - if (logfile.isEmpty()|| logfile.equals("all")){ - String filelist[]={"crashlog","APILog","GPS","LocationAlarm","Battery","log"}; + if (logfile.isEmpty()|| logfile.equals("all")) { + String filelist[] = {"crashlog", "APILog", "GPS", "LocationAlarm", "Battery", "log"}; // String filelist[]={"APILog","LocationAlarm","Battery"}; - String time=TimeUtil.getSystemTime3(); - StringBuilder sb=new StringBuilder(); + String time = TimeUtil.getSystemTime3(); + StringBuilder sb = new StringBuilder(); Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { sendSMS(phonenumber, "start Upload allLogfile [crashlog APILog log GPS LocationAlarm Battery] to " + Config.getFtpServer(mContext)); - String logtime=TimeUtil.getSystemTime3(); + String logtime = TimeUtil.getSystemTime3(); for (String file : filelist) { if (Util.LogfileExist(runtime, file)) { @@ -380,40 +381,78 @@ public class ICSmsManager { String filepath = Util.getLogfilePath(runtime, file); URL serverurl = null; try { - serverurl = new URL(Util.getServerLogfilePath(Config.getFtpServer(mContext), time, file,runtime)); + serverurl = new URL(Util.getServerLogfilePath(Config.getFtpServer(mContext), time, file, runtime)); } catch (MalformedURLException e) { e.printStackTrace(); } - if (upload_logs_via_ftp){ + if (upload_logs_via_ftp) { if (ftpUtils.upload(serverurl, Config.getFtpUser(mContext), Config.getFtpPWD(mContext), new File(filepath))) { sb.append(" ").append(file); - ICLogger.i("Upload file "+file+" success! "); - }else{ - ICLogger.i("Upload file "+file+" failed! "); + ICLogger.i("Upload file " + file + " success! "); + } else { + ICLogger.i("Upload file " + file + " failed! "); } - }else{ - if (ICHttpUtil.uploadFile(filepath,runtime,logtime)) { + } else { + if (ICHttpUtil.uploadFile(filepath, runtime, logtime)) { sb.append(" ").append(file); - ICLogger.i("Upload file "+file+" success! "); - }else{ - ICLogger.i("Upload file "+file+" failed! "); + ICLogger.i("Upload file " + file + " success! "); + } else { + ICLogger.i("Upload file " + file + " failed! "); } } - } } - if (sb.length()>0) { + if (sb.length() > 0) { sendSMS(phonenumber, "Upload [" + sb.toString() + "] success to " + Config.getFtpServer(mContext)); - }else - { + } else { sendSMS(phonenumber, "Upload all files failed to " + Config.getFtpServer(mContext)); } } }); + }else if (!logfile.isEmpty()&& logfile.startsWith("SDLog:")){ + + String sdfilelist[] = logfile.split(":"); + if (sdfilelist.length==2) { + String fileOrDir=sdfilelist[1]; + Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1() { + public void call(Long param1Long) { + String filepath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + fileOrDir; + URL serverurl = null; + try { + serverurl = new URL(Util.getServerLogfilePath(Config.getFtpServer(mContext), TimeUtil.getSystemTime3(), logfile, runtime)); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + if ( new File(filepath).exists()) { + + sendSMS(phonenumber, "start Upload " + filepath + " to " + Config.getFtpServer(mContext) + " ..."); + String logtime = TimeUtil.getSystemTime3(); + + if (upload_logs_via_ftp) { + if (ftpUtils.upload(serverurl, Config.getFtpUser(mContext), Config.getFtpPWD(mContext), new File(filepath))) { + sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!"); + } else { + sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!"); + } + } else { + if (ICHttpUtil.uploadFile(filepath, runtime, logtime)) { + sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!"); + } else { + sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!"); + } + } + } else { + sendSMS(phonenumber, filepath + " not exist !"); + } + } + }); + }else{ + sendSMS(phonenumber, " SDLog format error !"); + } }else{ Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { @@ -484,13 +523,18 @@ public class ICSmsManager { } } else if (tmp[1].equals("upgrade")) { if (Util.is_FT6236U_upgrade_firmware_support()){ - - if (Util.FT6236U_upgrade_firmware()){ - Util.FT6236U_getVer(); - String ver=Util.FT6236U_getVer(); - sendSMS(phonenumber, " Current FT6236U Firmware Version is "+ver+"!"); + Util.FT6236U_getVer(); + String ver=Util.FT6236U_getVer(); + if (ver.startsWith("A1")) { + if (Util.FT6236U_upgrade_firmware()) { + Util.FT6236U_getVer(); + ver = Util.FT6236U_getVer(); + sendSMS(phonenumber, " Current FT6236U Firmware Version is " + ver + "!"); + } else { + sendSMS(phonenumber, " FT6236U Firmware upgrade failed !"); + } }else{ - sendSMS(phonenumber, " FT6236U Firmware upgrade failed !"); + sendSMS(phonenumber, " FT6236U current Firmware version is "+ver+" , upgrade only support A1 to A3 !"); } }else { sendSMS(phonenumber, " system Not Support FT6236U upgrade Firmware!"); diff --git a/app/src/main/java/com/enqualcomm/support/utils/ICHttpUtil.java b/app/src/main/java/com/enqualcomm/support/utils/ICHttpUtil.java index 303d361e..d7515b75 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/ICHttpUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/ICHttpUtil.java @@ -1,6 +1,7 @@ package com.enqualcomm.support.utils; import android.content.Context; +import android.os.Environment; import android.util.Log; import com.enqualcomm.support.Config; @@ -22,24 +23,32 @@ import java.util.zip.ZipOutputStream; import static android.content.ContentValues.TAG; public class ICHttpUtil { - public static boolean uploadFile(String filenames, Runtime runtime,String logtime) { + public static boolean uploadFile(String filename, Runtime runtime,String logtime) { + + String zipfile=filename; + boolean compressSuccess=false; try { - if (Util.zipFile(new File(filenames), runtime.getCacheDir().getAbsolutePath(), - new ZipOutputStream(new CheckedOutputStream(new FileOutputStream(filenames+".zip"),new CRC32())) - , filenames)) { - filenames += ".zip"; + String sdcard= Environment.getExternalStorageDirectory().getAbsolutePath(); + File srcfile=new File(filename); + zipfile=sdcard+File.separator+srcfile.getName()+".zip"; + if (Util.zipFile(srcfile, "", + new ZipOutputStream(new CheckedOutputStream(new FileOutputStream(zipfile),new CRC32())) + , filename)) { + compressSuccess=true; } }catch (Exception e){ e.printStackTrace(); + compressSuccess=false; } + if (compressSuccess==false) return false; String server= Config.getFotaServerIP(runtime.getContextProxy().context); int port= Config.getFotaServerPort(runtime.getContextProxy().context); String product=DeviceInfoUtil.getModule(); String pkgver=DeviceInfoUtil.getSWVersionDisplayName(); String imei=runtime.IMEI(); String actionUrl = "http://"+server+":"+port + "/UploadFile.jsp?product=" + product + "&pkgver="+ pkgver + "&imei="+ imei+"&logtime="+logtime; - return upLoadFile(actionUrl, new File(filenames)); + return upLoadFile(actionUrl, new File(zipfile)); } public static boolean upLoadFile(String url, File file) { diff --git a/dNSCache/dNSCache.iml b/dNSCache/dNSCache.iml index 9e1eb977..31c0c0c7 100644 --- a/dNSCache/dNSCache.iml +++ b/dNSCache/dNSCache.iml @@ -91,5 +91,6 @@ + \ No newline at end of file -- 2.17.1