Commit ac01383f by pye52

增加设备重启时的日志输出

parent 2df9c9ad
...@@ -7,6 +7,9 @@ import androidx.work.Worker; ...@@ -7,6 +7,9 @@ import androidx.work.Worker;
import androidx.work.WorkerParameters; import androidx.work.WorkerParameters;
import com.bgycc.smartcanteen.utils.DangerousUtils; import com.bgycc.smartcanteen.utils.DangerousUtils;
import com.blankj.utilcode.util.LogUtils;
import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
public class ReBootMonitor extends Worker { public class ReBootMonitor extends Worker {
...@@ -17,6 +20,7 @@ public class ReBootMonitor extends Worker { ...@@ -17,6 +20,7 @@ public class ReBootMonitor extends Worker {
@NonNull @NonNull
@Override @Override
public Result doWork() { public Result doWork() {
LogUtils.d(TAG, "尝试重启设备");
DangerousUtils.reboot(); DangerousUtils.reboot();
return Result.success(); return Result.success();
} }
......
...@@ -10,11 +10,14 @@ import androidx.work.WorkManager; ...@@ -10,11 +10,14 @@ import androidx.work.WorkManager;
import com.bgycc.smartcanteen.monitor.DatabaseMonitor; import com.bgycc.smartcanteen.monitor.DatabaseMonitor;
import com.bgycc.smartcanteen.monitor.LogFileMonitor; import com.bgycc.smartcanteen.monitor.LogFileMonitor;
import com.bgycc.smartcanteen.monitor.ReBootMonitor; import com.bgycc.smartcanteen.monitor.ReBootMonitor;
import com.blankj.utilcode.util.LogUtils;
import java.util.Calendar; import java.util.Calendar;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
public class MonitorUtils { public class MonitorUtils {
private static final String LOG_MONITOR_WORKER = "worker_log_monitor"; private static final String LOG_MONITOR_WORKER = "worker_log_monitor";
private static final String DATABASE_MONITOR_WORKER = "database_log_monitor"; private static final String DATABASE_MONITOR_WORKER = "database_log_monitor";
...@@ -48,6 +51,7 @@ public class MonitorUtils { ...@@ -48,6 +51,7 @@ public class MonitorUtils {
future.set(Calendar.MINUTE, REBOOT_MIN); future.set(Calendar.MINUTE, REBOOT_MIN);
future.set(Calendar.SECOND, 0); future.set(Calendar.SECOND, 0);
long delay = future.getTimeInMillis() - now.getTimeInMillis(); long delay = future.getTimeInMillis() - now.getTimeInMillis();
LogUtils.d(TAG, delay + "毫秒后将重启设备");
OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(ReBootMonitor.class) OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(ReBootMonitor.class)
.setInitialDelay(delay, TimeUnit.MILLISECONDS) .setInitialDelay(delay, TimeUnit.MILLISECONDS)
.build(); .build();
......
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