From: snickersun Date: Tue, 3 Mar 2020 10:42:08 +0000 (+0800) Subject: 修改SMS命令: X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=46040962fd2069e68c9301658eeaa8b8aabafdbe;p=icsupport.git 修改SMS命令: 1、TP升级添加版本判断,防止误升级及重复升级。 2、添加对SD卡中的目录或者文件的上传。方便获取其他应用的日志。 命令格式:#logctl#=upload,SDLog:[dirname|filename] --- 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