Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ac01383f
authored
Jun 02, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加设备重启时的日志输出
parent
2df9c9ad
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
app/src/main/java/com/bgycc/smartcanteen/monitor/ReBootMonitor.java
+4
-0
app/src/main/java/com/bgycc/smartcanteen/utils/MonitorUtils.java
+4
-0
No files found.
app/src/main/java/com/bgycc/smartcanteen/monitor/ReBootMonitor.java
View file @
ac01383f
...
@@ -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
();
}
}
...
...
app/src/main/java/com/bgycc/smartcanteen/utils/MonitorUtils.java
View file @
ac01383f
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment