sendSMS(phonenumber, "WiFi Control format error!");\r
}\r
}else if(sms.startsWith(ENCRYPED_HEADER+"#logctl#=")){\r
+\r
+ Handler mhandler=new Handler(){\r
+ @Override\r
+ public void handleMessage(Message msg) {\r
+\r
+ switch(msg.what){\r
+ case 0:\r
+ sendSMS(phonenumber, "Upload Failed!");\r
+ Util.ShowToast(runtime,"Upload cmd Failed!");\r
+\r
+ break;\r
+\r
+ case 1:\r
+ sendSMS(phonenumber, "Upload success!");\r
+ Util.ShowToast(runtime,"Upload cmd success!");\r
+ break;\r
+ }\r
+\r
+ super.handleMessage(msg);\r
+ }\r
+ };\r
String tmp[] = sms.split("=");\r
if (tmp.length == 2) {\r
if (tmp[1].equals("current")) {\r
\r
}\r
} else {\r
- if (ICHttpUtil.uploadFile(filepath, runtime, logtime)) {\r
+ if (ICHttpUtil.uploadFile(filepath, runtime, logtime,mhandler)) {\r
sb.append(" ").append(file);\r
ICLogger.i("Upload file " + file + " success! ");\r
} else {\r
\r
}\r
}\r
- if (sb.length() > 0) {\r
- sendSMS(phonenumber, "Upload [" + sb.toString() + "] success to " + Config.getFtpServer(mContext));\r
- } else {\r
- sendSMS(phonenumber, "Upload all files failed to " + Config.getFtpServer(mContext));\r
- }\r
+// if (sb.length() > 0) {\r
+// sendSMS(phonenumber, "Upload [" + sb.toString() + "] success to " + Config.getFtpServer(mContext));\r
+// } else {\r
+// sendSMS(phonenumber, "Upload all files failed to " + Config.getFtpServer(mContext));\r
+// }\r
}\r
}, 500);\r
\r
}\r
}\r
} else {\r
- if (ICHttpUtil.uploadFile(filepath, runtime, logtime)) {\r
- sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!");\r
- if (logfile.startsWith("SDLogInfo:")){\r
- Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!");\r
- }\r
+ if (ICHttpUtil.uploadFile(filepath, runtime, logtime,mhandler)) {\r
+// sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!");\r
+// if (logfile.startsWith("SDLogInfo:")){\r
+// Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " success!");\r
+// }\r
} else {\r
- sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!");\r
- if (logfile.startsWith("SDLogInfo:")){\r
- Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!");\r
- }\r
+// sendSMS(phonenumber, "Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!");\r
+// if (logfile.startsWith("SDLogInfo:")){\r
+// Util.ShowToast(runtime,"Upload " + filepath + " to " + Config.getFtpServer(mContext) + " failed!");\r
+// }\r
}\r
}\r
} else {\r
sendSMS(phonenumber, "Upload " + logfile + " to " + Config.getFtpServer(mContext) + " failed!");\r
}\r
}else{\r
- if (ICHttpUtil.uploadFile(filepath,runtime,logtime)) {\r
- sendSMS(phonenumber, "Upload " + logfile + " to " + Config.getFtpServer(mContext) + " success!");\r
+ if (ICHttpUtil.uploadFile(filepath,runtime,logtime,mhandler)) {\r
+// sendSMS(phonenumber, "Upload " + logfile + " to " + Config.getFtpServer(mContext) + " success!");\r
} else {\r
- sendSMS(phonenumber, "Upload " + logfile + " to " + Config.getFtpServer(mContext) + " failed!");\r
+// sendSMS(phonenumber, "Upload " + logfile + " to " + Config.getFtpServer(mContext) + " failed!");\r
}\r
}\r
} else {\r
new Handler().postDelayed(new Runnable() {\r
@Override\r
public void run() {\r
- String logfile = "/sdcard/Android/ic";\r
+ String logfile = "";\r
+ String fileOrDir = "Android/ic";\r
\r
Util.getDBFile();\r
- sendSMS(phonenumber, "mail " + logfile + " to " + mailaddr + " ...");\r
- Util.ShowToast(runtime,"mail " + logfile + " to " + mailaddr + " ...");\r
\r
- String logtime = TimeUtil.getSystemTime3();\r
- if (SendEmail.getInstance().sendLogViaMail(logfile,mailaddr, logtime)) {\r
- sendSMS(phonenumber, "mail " + logfile + " to " + mailaddr + " success!");\r
- Util.ShowToast(runtime,"mail " + logfile + " to " + mailaddr + " success!");\r
+ logfile = Util.zipfiles(fileOrDir);\r
+ if (new File(logfile).exists()) {\r
+\r
+ sendSMS(phonenumber, "mail " + fileOrDir + " to " + mailaddr + " ...");\r
+ Util.ShowToast(runtime,"mail " + fileOrDir + " to " + mailaddr + " ...");\r
+\r
+ String logtime = TimeUtil.getSystemTime3();\r
+ if (SendEmail.getInstance().sendLogViaMail(logfile,mailaddr, logtime)) {\r
+ sendSMS(phonenumber, "mail " + fileOrDir + " to " + mailaddr + " success!");\r
+// Util.ShowToast(runtime,"mail " + fileOrDir + " to " + mailaddr + " success!");\r
+ } else {\r
+ sendSMS(phonenumber, "mail " + fileOrDir + " to " + mailaddr + " failed!");\r
+// Util.ShowToast(runtime,"mail " + fileOrDir + " to " + mailaddr + " failed!");\r
+ }\r
+\r
} else {\r
- sendSMS(phonenumber, "mail " + logfile + " to " + mailaddr + " failed!");\r
- Util.ShowToast(runtime,"mail " + logfile + " to " + mailaddr + " failed!");\r
+ sendSMS(phonenumber, fileOrDir + " not exist !");\r
+// if (logfile.startsWith("SDLogInfo:")) {\r
+// Util.ShowToast(runtime, fileOrDir + " not exist !");\r
+// }\r
}\r
}\r
+\r
+\r
+\r
}, 500);\r
\r
}\r
\r
import android.content.Context;\r
import android.os.Environment;\r
+import android.os.Handler;\r
import android.util.Log;\r
\r
import com.enqualcomm.support.Config;\r
\r
public class ICHttpUtil {\r
\r
- public static boolean uploadFile(String filename, Runtime runtime,String logtime) {\r
+ public static boolean uploadFile(String filename, Runtime runtime, String logtime, Handler mhandler) {\r
\r
String zipfile=filename;\r
boolean compressSuccess=false;\r
e.printStackTrace();\r
compressSuccess=false;\r
}\r
- if (compressSuccess==false) return false;\r
+ if (compressSuccess==false) {\r
+\r
+ if(mhandler!=null)\r
+ mhandler.sendEmptyMessage(0);\r
+ return false;\r
+ }\r
String server= Config.getLogServerIP(runtime.getContextProxy().context);\r
int port= Config.getLogServerPort(runtime.getContextProxy().context);\r
String product=DeviceInfoUtil.getModule();\r
}\r
\r
ICLogger.i("url="+actionUrl+"\nfile="+zipfile);\r
- return upLoadFile(actionUrl, new File(zipfile));\r
+ return upLoadFile(actionUrl, new File(zipfile),mhandler);\r
\r
}\r
- public static boolean upLoadFile(String url, File file) {\r
+ public static boolean upLoadFile(String url, File file, Handler mhandler) {\r
boolean result = false;\r
- try {\r
+\r
if (null == url || null == file || !file.exists() || file.length() < 1) {\r
+ if(mhandler!=null)\r
+ mhandler.sendEmptyMessage(0);\r
return false;\r
}\r
- /**\r
- * 第一部分\r
- */\r
- URL urlObj = new URL(url);\r
- HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();\r
-\r
- /**\r
- * 设置关键值\r
- */\r
- con.setRequestMethod("POST"); // 以Post方式提交表单,默认get方式\r
- con.setDoInput(true);\r
- con.setDoOutput(true);\r
- con.setUseCaches(false); // post方式不能使用缓存\r
-\r
- // 设置请求头信息\r
- con.setRequestProperty("Connection", "Keep-Alive");\r
- con.setRequestProperty("Charset", "UTF-8");\r
-\r
- // 设置边界\r
- String BOUNDARY = "----------" + System.currentTimeMillis();\r
- con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);\r
-\r
- // 请求正文信息\r
-\r
- // 第一部分:\r
- StringBuilder sb = new StringBuilder();\r
- sb.append("--"); // ////////必须多两道线\r
- sb.append(BOUNDARY);\r
- sb.append("\r\n");\r
- sb.append("Content-Disposition: form-data;name=\"file\";filename=\"" + file.getName() + "\"\r\n");\r
- sb.append("Content-Type:application/octet-stream\r\n\r\n");\r
-\r
- byte[] head = sb.toString().getBytes("utf-8");\r
-\r
- // 获得输出流\r
- OutputStream out = new DataOutputStream(con.getOutputStream());\r
- out.write(head);\r
-\r
- // 文件正文部分\r
- DataInputStream in = new DataInputStream(new FileInputStream(file));\r
- int bytes = 0;\r
- byte[] bufferOut = new byte[1024];\r
- while ((bytes = in.read(bufferOut)) != -1) {\r
- out.write(bufferOut, 0, bytes);\r
- }\r
- in.close();\r
-\r
- // 结尾部分\r
- byte[] foot = ("\r\n--" + BOUNDARY + "--\r\n").getBytes("utf-8");// 定义最后数据分隔线\r
- out.write(foot);\r
- out.flush();\r
- out.close();\r
-\r
- int statusCode = con.getResponseCode();\r
- String msg=con.getResponseMessage();\r
- ICLogger.i(msg);\r
- if (statusCode == 200) {\r
- result = true;\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- return result;\r
+\r
+\r
+ new Thread(new Runnable() {\r
+ @Override\r
+ public void run() {\r
+ try {\r
+ /**\r
+ * 第一部分\r
+ */\r
+ URL urlObj = new URL(url);\r
+ HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();\r
+\r
+ /**\r
+ * 设置关键值\r
+ */\r
+ con.setRequestMethod("POST"); // 以Post方式提交表单,默认get方式\r
+ con.setDoInput(true);\r
+ con.setDoOutput(true);\r
+ con.setUseCaches(false); // post方式不能使用缓存\r
+\r
+ // 设置请求头信息\r
+ con.setRequestProperty("Connection", "Keep-Alive");\r
+ con.setRequestProperty("Charset", "UTF-8");\r
+\r
+ // 设置边界\r
+ String BOUNDARY = "----------" + System.currentTimeMillis();\r
+ con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);\r
+\r
+ // 请求正文信息\r
+\r
+ // 第一部分:\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("--"); // ////////必须多两道线\r
+ sb.append(BOUNDARY);\r
+ sb.append("\r\n");\r
+ sb.append("Content-Disposition: form-data;name=\"file\";filename=\"" + file.getName() + "\"\r\n");\r
+ sb.append("Content-Type:application/octet-stream\r\n\r\n");\r
+\r
+ byte[] head = sb.toString().getBytes("utf-8");\r
+\r
+ // 获得输出流\r
+ OutputStream out = new DataOutputStream(con.getOutputStream());\r
+ out.write(head);\r
+\r
+ // 文件正文部分\r
+ DataInputStream in = new DataInputStream(new FileInputStream(file));\r
+ int bytes = 0;\r
+ byte[] bufferOut = new byte[1024];\r
+ while ((bytes = in.read(bufferOut)) != -1) {\r
+ out.write(bufferOut, 0, bytes);\r
+ }\r
+ in.close();\r
+\r
+ // 结尾部分\r
+ byte[] foot = ("\r\n--" + BOUNDARY + "--\r\n").getBytes("utf-8");// 定义最后数据分隔线\r
+ out.write(foot);\r
+ out.flush();\r
+ out.close();\r
+\r
+ int statusCode = con.getResponseCode();\r
+ String msg = con.getResponseMessage();\r
+ ICLogger.i(msg);\r
+ if (statusCode == 200) {\r
+ if(mhandler!=null)\r
+ mhandler.sendEmptyMessage(1);\r
+ }else\r
+ {\r
+ if(mhandler!=null)\r
+ mhandler.sendEmptyMessage(0);\r
+ }\r
+\r
+\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ if(mhandler!=null)\r
+ mhandler.sendEmptyMessage(0);\r
+ }\r
+ }\r
+ }).start();\r
+\r
+ return true;\r
}\r
}\r
return files;\r
}\r
\r
+ /***\r
+ *\r
+ * @param filename 输入SD卡中的文件或者目录的 相对路径\r
+ * @return 压缩有的文件\r
+ */\r
+ public static String zipfiles(String filename){\r
+ String zipfile=filename;\r
+\r
+ try {\r
+ String sdcard= Environment.getExternalStorageDirectory().getAbsolutePath();\r
+ File srcfile=new File(sdcard+"/"+filename);\r
+ zipfile=sdcard+File.separator+srcfile.getName()+".zip";\r
+ if (Util.zipFile(srcfile, "",\r
+ new ZipOutputStream(new CheckedOutputStream(new FileOutputStream(zipfile),new CRC32()))\r
+ , filename)) {\r
+ }\r
+ }catch (Exception e){\r
+ e.printStackTrace();\r
+ zipfile="";\r
+ }\r
+\r
+ return zipfile;\r
+ }\r
+\r
private static boolean unzipChildFile(final File destDir, final List<File> files, final ZipFile zip, final ZipEntry entry)\r
throws IOException {\r
File file = new File(destDir, entry.getName());\r
-#Tue Sep 08 19:41:57 CST 2020\r
-VERSION_CODE=608\r
+#Thu Sep 10 11:10:16 CST 2020\r
+VERSION_CODE=609\r