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
0245e135
Commit
0245e135
authored
May 12, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed usage of old database object
parent
d5467332
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
+19
-17
SuRequestViewModel.kt
...a/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt
+19
-17
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt
View file @
0245e135
...
...
@@ -15,9 +15,11 @@ import com.skoumal.teanity.util.KObservableField
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.database.MagiskDB
import
com.topjohnwu.magisk.data.repository.AppRepository
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.Policy
import
com.topjohnwu.magisk.model.entity.recycler.SpinnerRvItem
import
com.topjohnwu.magisk.model.entity.toPolicy
import
com.topjohnwu.magisk.model.events.DieEvent
import
com.topjohnwu.magisk.ui.base.MagiskViewModel
import
com.topjohnwu.magisk.utils.FingerprintHelper
...
...
@@ -29,7 +31,7 @@ import java.util.concurrent.TimeUnit.*
class
SuRequestViewModel
(
private
val
packageManager
:
PackageManager
,
private
val
database
:
MagiskDB
,
private
val
appRepo
:
AppRepository
,
private
val
timeoutPrefs
:
SharedPreferences
,
private
val
resources
:
Resources
)
:
MagiskViewModel
()
{
...
...
@@ -52,7 +54,7 @@ class SuRequestViewModel(
var
handler
:
ActionHandler
?
=
null
private
var
timer
:
CountDownTimer
?
=
null
private
var
policy
:
Policy
?
=
null
private
var
policy
:
Magisk
Policy
?
=
null
set
(
value
)
{
field
=
value
updatePolicy
(
value
)
...
...
@@ -64,10 +66,10 @@ class SuRequestViewModel(
.
let
{
items
.
update
(
it
)
}
}
private
fun
updatePolicy
(
policy
:
Policy
?)
{
private
fun
updatePolicy
(
policy
:
Magisk
Policy
?)
{
policy
?:
return
icon
.
value
=
policy
.
i
nfo
.
loadIcon
(
packageManager
)
icon
.
value
=
policy
.
applicationI
nfo
.
loadIcon
(
packageManager
)
title
.
value
=
policy
.
appName
packageName
.
value
=
policy
.
packageName
...
...
@@ -107,8 +109,8 @@ class SuRequestViewModel(
}
val
bundle
=
connector
.
readSocketInput
()
val
uid
=
bundle
.
getString
(
"uid"
)
?.
toIntOrNull
()
?:
return
false
database
.
clearOutdated
()
policy
=
database
.
getPolicy
(
uid
)
?:
Policy
(
uid
,
packageManager
)
appRepo
.
deleteOutdated
().
blockingGet
()
// wrong!
policy
=
appRepo
.
fetch
(
uid
).
blockingGet
()
?:
uid
.
toPolicy
(
packageManager
)
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
return
false
...
...
@@ -130,18 +132,18 @@ class SuRequestViewModel(
}
override
fun
handleAction
(
action
:
Int
,
time
:
Int
)
{
policy
?.
apply
{
policy
=
action
if
(
time
>=
0
)
{
until
=
if
(
time
==
0
)
{
0
}
else
{
MILLISECONDS
.
toSeconds
(
now
)
+
MINUTES
.
toSeconds
(
time
.
toLong
())
}
database
.
updatePolicy
(
this
)
val
until
=
if
(
time
>=
0
)
{
if
(
time
==
0
)
{
0
}
else
{
MILLISECONDS
.
toSeconds
(
now
)
+
MINUTES
.
toSeconds
(
time
.
toLong
())
}
}
else
{
policy
?.
until
?:
0
}
policy
=
policy
?.
copy
(
policy
=
action
,
until
=
until
)
?.
apply
{
appRepo
.
update
(
this
).
blockingGet
()
}
policy
?.
policy
=
action
handleAction
()
}
...
...
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