Commit ce425b44 by pye52

优化设备上传日志的设计,增加日志输出

parent 14ea85d2
...@@ -14,8 +14,6 @@ import com.blankj.utilcode.util.LogUtils; ...@@ -14,8 +14,6 @@ import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PathUtils; import com.blankj.utilcode.util.PathUtils;
import com.blankj.utilcode.util.ZipUtils; import com.blankj.utilcode.util.ZipUtils;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.IOException; import java.io.IOException;
...@@ -149,15 +147,14 @@ public class LogCommandWorker extends CommandWorker { ...@@ -149,15 +147,14 @@ public class LogCommandWorker extends CommandWorker {
return zip; return zip;
} }
@NotNull
private File getLogDirByType(String logType) { private File getLogDirByType(String logType) {
File logDir; File logDir;
if (logType.equals(BOOT_LOG)) { if (logType.equals(BOOT_LOG)) {
logDir = new File(DeviceProxy.systemLogPath()); logDir = DeviceProxy.systemLogDir();
} else { } else {
logDir = new File(LogUtils.getConfig().getDir()); logDir = new File(LogUtils.getConfig().getDir());
} }
LogUtils.d(TAG, "待上传日志文件类型: " + logType); LogUtils.d(TAG, "待上传日志文件类型: " + logType + ", 日志文件夹路径: " + (logDir != null ? logDir : "null"));
return logDir; return logDir;
} }
...@@ -177,6 +174,9 @@ public class LogCommandWorker extends CommandWorker { ...@@ -177,6 +174,9 @@ public class LogCommandWorker extends CommandWorker {
} }
private boolean copyTargetFiles(File src, File descDir) { private boolean copyTargetFiles(File src, File descDir) {
if (src == null || descDir == null) {
return true;
}
FileFilter filter = file -> { FileFilter filter = file -> {
Date date = new Date(file.lastModified()); Date date = new Date(file.lastModified());
return date.after(startTime) && date.before(endTime); return date.after(startTime) && date.before(endTime);
......
...@@ -9,7 +9,7 @@ import java.io.File; ...@@ -9,7 +9,7 @@ import java.io.File;
public interface DeviceFeatures { public interface DeviceFeatures {
IQRCodeScan createQRCodeScan() throws Exception; IQRCodeScan createQRCodeScan() throws Exception;
String systemLogPath(); File systemLogDir();
boolean updateApp(Context context, File updateApk); boolean updateApp(Context context, File updateApk);
} }
...@@ -12,7 +12,7 @@ import java.io.File; ...@@ -12,7 +12,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
public class QUADDevice implements DeviceFeatures { public class QUADDevice implements DeviceFeatures {
private static final String SYSTEM_LOG_PATH = "boot_log"; private static final String SYSTEM_LOG_DIR_NAME = "boot_log";
private static final String PORT = "/dev/ttyS6"; private static final String PORT = "/dev/ttyS6";
@Override @Override
...@@ -21,8 +21,8 @@ public class QUADDevice implements DeviceFeatures { ...@@ -21,8 +21,8 @@ public class QUADDevice implements DeviceFeatures {
} }
@Override @Override
public String systemLogPath() { public File systemLogDir() {
return PathUtils.getExternalStoragePath() + File.separator + SYSTEM_LOG_PATH; return new File(PathUtils.getExternalStoragePath() + File.separator + SYSTEM_LOG_DIR_NAME);
} }
@Override @Override
......
...@@ -5,14 +5,12 @@ import android.content.Context; ...@@ -5,14 +5,12 @@ import android.content.Context;
import com.bgycc.smartcanteen.installer.TPSInstaller; import com.bgycc.smartcanteen.installer.TPSInstaller;
import com.bgycc.smartcanteen.qrcode.DefaultQRCodeScan; import com.bgycc.smartcanteen.qrcode.DefaultQRCodeScan;
import com.bgycc.smartcanteen.qrcode.IQRCodeScan; import com.bgycc.smartcanteen.qrcode.IQRCodeScan;
import com.blankj.utilcode.util.PathUtils;
import com.telpo.tps550.api.DeviceAlreadyOpenException; import com.telpo.tps550.api.DeviceAlreadyOpenException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class TPSDevice implements DeviceFeatures { public class TPSDevice implements DeviceFeatures {
private static final String SYSTEM_LOG_PATH = "boot_log";
private static final String PORT = "/dev/ttyS0"; private static final String PORT = "/dev/ttyS0";
@Override @Override
...@@ -21,8 +19,8 @@ public class TPSDevice implements DeviceFeatures { ...@@ -21,8 +19,8 @@ public class TPSDevice implements DeviceFeatures {
} }
@Override @Override
public String systemLogPath() { public File systemLogDir() {
return PathUtils.getExternalStoragePath() + File.separator + SYSTEM_LOG_PATH; return null;
} }
@Override @Override
......
...@@ -38,7 +38,7 @@ public class DeviceProxy { ...@@ -38,7 +38,7 @@ public class DeviceProxy {
return deviceImpl.updateApp(context, updateApk); return deviceImpl.updateApp(context, updateApk);
} }
public static String systemLogPath() { public static File systemLogDir() {
return deviceImpl.systemLogPath(); return deviceImpl.systemLogDir();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment