diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/App.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/App.java index 5921c8d..02872a2 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/base/App.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/App.java @@ -15,6 +15,7 @@ import java.util.List; import cc.niushuai.project.devcontrol.BuildConfig; import cc.niushuai.project.devcontrol.base.util.Global; import cc.niushuai.project.devcontrol.base.util.Keys; +import cc.niushuai.project.devcontrol.base.util.XLog; import cc.niushuai.project.devcontrol.db.DB; import cn.hutool.core.io.FileUtil; import cn.hutool.core.text.StrPool; @@ -25,12 +26,13 @@ public class App { public static void init(Activity activity) { + // 申请权限 + requestPermissions(activity); + // 初始化日志相关内容 initLog(activity); // 检查root权限 checkRoot(activity); - // 申请权限 - requestPermissions(activity); // 初始化数据库 initDb(activity); // 重建设备信息缓存 @@ -47,10 +49,13 @@ public class App { private static void checkRoot(Activity activity) { String which_su = RuntimeUtil.execForStr("which su"); + XLog.i(Keys.Tag.APP_INIT, "检查root权限... {}", which_su); if (StrUtil.isNotEmpty(which_su)) { Global.HAS_ROOT = true; + XLog.i(Keys.Tag.APP_INIT, "当前设备具有root权限, su路径: {}", which_su); + } else { + XLog.i(Keys.Tag.APP_INIT, "当前设备不具有root权限"); } - System.out.println("当前设备具有root权限"); } /** diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/Keys.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/Keys.java index d7dd4a9..98e3abc 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/Keys.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/Keys.java @@ -14,5 +14,7 @@ public interface Keys { interface Tag { String MY_OPEN_HELPER = "MyOpenHelper"; + + String APP_INIT = "AppInit"; } } diff --git a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java index c14163e..a46e5a7 100644 --- a/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java +++ b/app/src/main/java/cc/niushuai/project/devcontrol/base/util/XLog.java @@ -9,6 +9,7 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.text.StrPool; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; /** @@ -124,7 +125,7 @@ public class XLog { private static String filterThr(String message, Object[] params) { String format = StrUtil.format(message, params); - if (null != params) { + if (ArrayUtil.isNotEmpty(params)) { Object lastParam = params[params.length - 1]; if (lastParam instanceof Throwable) { // 最后一个元素如果为异常对象 @@ -179,7 +180,7 @@ public class XLog { public static void write(String tag, String message, int level) { String logContent = concatFinalLog(tag, level, message); - FileUtil.appendUtf8String(logContent, currentAbsoluteLogPath()); + FileUtil.appendUtf8String(logContent + System.lineSeparator(), currentAbsoluteLogPath()); } /**