Commit ce425b44 by pye52

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

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