Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
50edb8d0
Commit
50edb8d0
authored
Jun 10, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better network detection and invalidation
parent
515f8194
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
Info.kt
app/src/main/java/com/topjohnwu/magisk/core/Info.kt
+2
-2
NetworkService.kt
...va/com/topjohnwu/magisk/core/repository/NetworkService.kt
+4
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/core/Info.kt
View file @
50edb8d0
...
...
@@ -10,7 +10,6 @@ import com.topjohnwu.magisk.core.repository.NetworkService
import
com.topjohnwu.magisk.core.utils.net.NetworkObserver
import
com.topjohnwu.magisk.ktx.getProperty
import
com.topjohnwu.superuser.ShellUtils.fastCmd
import
com.topjohnwu.superuser.internal.UiThreadHandler
val
isRunningAsStub
get
()
=
Info
.
stub
!=
null
...
...
@@ -47,7 +46,8 @@ object Info {
val
isConnected
:
LiveData
<
Boolean
>
by
lazy
{
MutableLiveData
(
false
).
also
{
field
->
NetworkObserver
.
observe
(
AppContext
)
{
UiThreadHandler
.
run
{
field
.
value
=
it
}
remote
=
EMPTY_REMOTE
field
.
postValue
(
it
)
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt
View file @
50edb8d0
...
...
@@ -46,7 +46,10 @@ class NetworkService(
private
inline
fun
<
T
>
safe
(
factory
:
()
->
T
):
T
?
{
return
try
{
if
(
Info
.
isConnected
.
value
==
true
)
factory
()
else
null
}
catch
(
e
:
Exception
)
{
Timber
.
e
(
e
)
null
...
...
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