Commit 5cf16966 by pye52

修改日志、下载APP路径到SD卡

parent 480ad683
...@@ -4,22 +4,25 @@ import android.app.Application; ...@@ -4,22 +4,25 @@ import android.app.Application;
import com.blankj.utilcode.util.CrashUtils; import com.blankj.utilcode.util.CrashUtils;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PathUtils;
import com.blankj.utilcode.util.Utils; import com.blankj.utilcode.util.Utils;
import java.io.File; import java.io.File;
public class RootApp extends Application { public class RootApp extends Application {
private static final String LOG_PREFIX = "app";
private static final String LOG_DIR = "log"; private static final String LOG_DIR = "log";
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Utils.init(getApplicationContext()); Utils.init(getApplicationContext());
String logDir = getApplicationContext().getFilesDir().getAbsolutePath() + File.separator + LOG_DIR; String logDir = PathUtils.getExternalStoragePath() + File.separator + LOG_DIR;
CrashUtils.init(logDir); CrashUtils.init(logDir);
LogUtils.getConfig() LogUtils.getConfig()
.setDir(logDir) .setDir(logDir)
.setLog2FileSwitch(true) .setLog2FileSwitch(true)
.setBorderSwitch(false); .setBorderSwitch(false)
.setFilePrefix(LOG_PREFIX);
} }
} }
...@@ -11,6 +11,7 @@ import com.blankj.utilcode.util.AppUtils; ...@@ -11,6 +11,7 @@ import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.FileIOUtils; import com.blankj.utilcode.util.FileIOUtils;
import com.blankj.utilcode.util.FileUtils; import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PathUtils;
import com.blankj.utilcode.util.Utils; import com.blankj.utilcode.util.Utils;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -78,7 +79,7 @@ public class UpdateCommandHandler extends CommandHandler { ...@@ -78,7 +79,7 @@ public class UpdateCommandHandler extends CommandHandler {
}) })
.build(); .build();
this.commandUpdate = gson.fromJson(command.getData(), CommandUpdate.class); this.commandUpdate = gson.fromJson(command.getData(), CommandUpdate.class);
this.updateApk = new File(Utils.getApp().getCacheDir(), UPDATE_APK); this.updateApk = new File(PathUtils.getExternalStoragePath(), UPDATE_APK);
} }
private void init(Command command, Gson gson, CommandProgressCallback callback) { private void init(Command command, Gson gson, CommandProgressCallback callback) {
......
...@@ -3,13 +3,27 @@ package com.bgycc.smartcanteen.daemon; ...@@ -3,13 +3,27 @@ package com.bgycc.smartcanteen.daemon;
import android.app.Application; import android.app.Application;
import com.blankj.utilcode.util.CrashUtils; import com.blankj.utilcode.util.CrashUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PathUtils;
import com.blankj.utilcode.util.Utils; import com.blankj.utilcode.util.Utils;
import java.io.File;
public class ServiceApplication extends Application { public class ServiceApplication extends Application {
private static final String LOG_PREFIX = "daemon";
private static final String LOG_DIR = "log";
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Utils.init(getApplicationContext()); Utils.init(getApplicationContext());
CrashUtils.init(); CrashUtils.init();
String logDir = PathUtils.getExternalStoragePath() + File.separator + LOG_DIR;
CrashUtils.init(logDir);
LogUtils.getConfig()
.setDir(logDir)
.setLog2FileSwitch(true)
.setBorderSwitch(false)
.setFilePrefix(LOG_PREFIX);
} }
} }
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