release V609
authorsnickersun <scy@incartech.cn>
Thu, 10 Sep 2020 03:16:57 +0000 (11:16 +0800)
committersnickersun <scy@incartech.cn>
Thu, 10 Sep 2020 03:16:57 +0000 (11:16 +0800)
修复 用Thread替代observer.timer后造成的日志上传问题。
修复 Email上传日志的问题。

app/release/ICSer_V609_2009101110_release.apk [moved from app/release/ICSer_V608_2009081941_release.apk with 78% similarity]
app/src/main/java/com/enqualcomm/support/ICSmsManager.java
app/src/main/java/com/enqualcomm/support/utils/ICHttpUtil.java
app/src/main/java/com/enqualcomm/support/utils/Util.java
app/version_code.properties

similarity index 78%
rename from app/release/ICSer_V608_2009081941_release.apk
rename to app/release/ICSer_V609_2009101110_release.apk
index 3caf198..e6d1944 100644 (file)
Binary files a/app/release/ICSer_V608_2009081941_release.apk and b/app/release/ICSer_V609_2009101110_release.apk differ
index 554eb92..da61b47 100644 (file)
@@ -558,6 +558,27 @@ public class ICSmsManager  extends BroadcastReceiver {
                     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
@@ -605,7 +626,7 @@ public class ICSmsManager  extends BroadcastReceiver {
 \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
@@ -617,11 +638,11 @@ public class ICSmsManager  extends BroadcastReceiver {
 \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
@@ -663,16 +684,16 @@ public class ICSmsManager  extends BroadcastReceiver {
                                                         }\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
@@ -711,10 +732,10 @@ public class ICSmsManager  extends BroadcastReceiver {
                                                     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
@@ -1070,21 +1091,36 @@ public class ICSmsManager  extends BroadcastReceiver {
                         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
index 8d1114d..3dcb7c2 100644 (file)
@@ -2,6 +2,7 @@ package com.enqualcomm.support.utils;
 \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
@@ -24,7 +25,7 @@ import static android.content.ContentValues.TAG;
 \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
@@ -41,7 +42,12 @@ public class ICHttpUtil {
             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
@@ -57,77 +63,97 @@ public class ICHttpUtil {
         }\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
index a7c8e74..5e00ff8 100644 (file)
@@ -620,6 +620,30 @@ public class Util {
     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
index 8628d58..b668e72 100644 (file)
@@ -1,2 +1,2 @@
-#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