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
2fe917ff
Commit
2fe917ff
authored
May 12, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed updating values with sql
parent
0e6c2057
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
11 deletions
+19
-11
MagiskQuery.kt
...va/com/topjohnwu/magisk/data/database/base/MagiskQuery.kt
+2
-2
MagiskQueryBuilder.kt
...topjohnwu/magisk/data/database/base/MagiskQueryBuilder.kt
+1
-1
MagiskPolicy.kt
...in/java/com/topjohnwu/magisk/model/entity/MagiskPolicy.kt
+1
-1
PolicyRvItem.kt
...om/topjohnwu/magisk/model/entity/recycler/PolicyRvItem.kt
+9
-2
RxEvents.kt
...c/main/java/com/topjohnwu/magisk/model/events/RxEvents.kt
+4
-3
SuperuserViewModel.kt
...a/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt
+2
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/data/database/base/MagiskQuery.kt
View file @
2fe917ff
package
com.topjohnwu.magisk.data.database.base
package
com.topjohnwu.magisk.data.database.base
data
class
MagiskQuery
(
private
val
_query
:
String
)
{
inline
class
MagiskQuery
(
private
val
_query
:
String
)
{
val
query
=
"magisk --sqlite '$_query'"
val
query
get
()
=
"magisk --sqlite '$_query'"
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/data/database/base/MagiskQueryBuilder.kt
View file @
2fe917ff
...
@@ -82,7 +82,7 @@ open class Insert : MagiskQueryBuilder {
...
@@ -82,7 +82,7 @@ open class Insert : MagiskQueryBuilder {
override
lateinit
var
table
:
String
override
lateinit
var
table
:
String
private
val
keys
get
()
=
_values
.
keys
.
joinToString
(
","
)
private
val
keys
get
()
=
_values
.
keys
.
joinToString
(
","
)
private
val
values
get
()
=
_values
.
values
.
joinToString
(
","
)
private
val
values
get
()
=
_values
.
values
.
joinToString
(
","
)
{
"\"$it\""
}
private
var
_values
:
Map
<
String
,
String
>
=
mapOf
()
private
var
_values
:
Map
<
String
,
String
>
=
mapOf
()
fun
values
(
vararg
pairs
:
Pair
<
String
,
String
>)
{
fun
values
(
vararg
pairs
:
Pair
<
String
,
String
>)
{
...
...
app/src/main/java/com/topjohnwu/magisk/model/entity/MagiskPolicy.kt
View file @
2fe917ff
...
@@ -59,7 +59,7 @@ fun MagiskPolicy.toMap() = mapOf(
...
@@ -59,7 +59,7 @@ fun MagiskPolicy.toMap() = mapOf(
"until"
to
until
,
"until"
to
until
,
"logging"
to
if
(
logging
)
1
else
0
,
"logging"
to
if
(
logging
)
1
else
0
,
"notification"
to
if
(
notification
)
1
else
0
"notification"
to
if
(
notification
)
1
else
0
).
mapValues
{
it
.
toString
()
}
).
mapValues
{
it
.
value
.
toString
()
}
@Throws
(
PackageManager
.
NameNotFoundException
::
class
)
@Throws
(
PackageManager
.
NameNotFoundException
::
class
)
fun
Map
<
String
,
String
>.
toPolicy
(
pm
:
PackageManager
):
MagiskPolicy
{
fun
Map
<
String
,
String
>.
toPolicy
(
pm
:
PackageManager
):
MagiskPolicy
{
...
...
app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/PolicyRvItem.kt
View file @
2fe917ff
...
@@ -26,6 +26,13 @@ class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvIte
...
@@ -26,6 +26,13 @@ class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvIte
private
val
rxBus
:
RxBus
by
inject
()
private
val
rxBus
:
RxBus
by
inject
()
private
val
currentStateItem
get
()
=
item
.
copy
(
policy
=
if
(
isEnabled
.
value
)
Policy
.
ALLOW
else
Policy
.
DENY
,
notification
=
shouldNotify
.
value
,
logging
=
shouldLog
.
value
)
init
{
init
{
isEnabled
.
addOnPropertyChangedCallback
{
isEnabled
.
addOnPropertyChangedCallback
{
it
?:
return
@addOnPropertyChangedCallback
it
?:
return
@addOnPropertyChangedCallback
...
@@ -33,11 +40,11 @@ class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvIte
...
@@ -33,11 +40,11 @@ class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvIte
}
}
shouldNotify
.
addOnPropertyChangedCallback
{
shouldNotify
.
addOnPropertyChangedCallback
{
it
?:
return
@addOnPropertyChangedCallback
it
?:
return
@addOnPropertyChangedCallback
rxBus
.
post
(
PolicyUpdateEvent
.
Notification
(
this
@PolicyRvItem
,
shouldNotify
.
value
))
rxBus
.
post
(
PolicyUpdateEvent
.
Notification
(
currentStateItem
))
}
}
shouldLog
.
addOnPropertyChangedCallback
{
shouldLog
.
addOnPropertyChangedCallback
{
it
?:
return
@addOnPropertyChangedCallback
it
?:
return
@addOnPropertyChangedCallback
rxBus
.
post
(
PolicyUpdateEvent
.
Log
(
this
@PolicyRvItem
,
shouldLog
.
value
))
rxBus
.
post
(
PolicyUpdateEvent
.
Log
(
currentStateItem
))
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/model/events/RxEvents.kt
View file @
2fe917ff
package
com.topjohnwu.magisk.model.events
package
com.topjohnwu.magisk.model.events
import
com.skoumal.teanity.rxbus.RxBus
import
com.skoumal.teanity.rxbus.RxBus
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.recycler.HideProcessRvItem
import
com.topjohnwu.magisk.model.entity.recycler.HideProcessRvItem
import
com.topjohnwu.magisk.model.entity.recycler.ModuleRvItem
import
com.topjohnwu.magisk.model.entity.recycler.ModuleRvItem
import
com.topjohnwu.magisk.model.entity.recycler.PolicyRvItem
import
com.topjohnwu.magisk.model.entity.recycler.PolicyRvItem
...
@@ -8,9 +9,9 @@ import com.topjohnwu.magisk.model.entity.recycler.PolicyRvItem
...
@@ -8,9 +9,9 @@ import com.topjohnwu.magisk.model.entity.recycler.PolicyRvItem
class
HideProcessEvent
(
val
item
:
HideProcessRvItem
)
:
RxBus
.
Event
class
HideProcessEvent
(
val
item
:
HideProcessRvItem
)
:
RxBus
.
Event
class
PolicyEnableEvent
(
val
item
:
PolicyRvItem
,
val
enable
:
Boolean
)
:
RxBus
.
Event
class
PolicyEnableEvent
(
val
item
:
PolicyRvItem
,
val
enable
:
Boolean
)
:
RxBus
.
Event
sealed
class
PolicyUpdateEvent
(
val
item
:
PolicyRvItem
)
:
RxBus
.
Event
{
sealed
class
PolicyUpdateEvent
(
val
item
:
MagiskPolicy
)
:
RxBus
.
Event
{
class
Notification
(
item
:
PolicyRvItem
,
val
shouldNotify
:
Boolean
)
:
PolicyUpdateEvent
(
item
)
class
Notification
(
item
:
MagiskPolicy
)
:
PolicyUpdateEvent
(
item
)
class
Log
(
item
:
PolicyRvItem
,
val
shouldLog
:
Boolean
)
:
PolicyUpdateEvent
(
item
)
class
Log
(
item
:
MagiskPolicy
)
:
PolicyUpdateEvent
(
item
)
}
}
class
ModuleUpdatedEvent
(
val
item
:
ModuleRvItem
)
:
RxBus
.
Event
class
ModuleUpdatedEvent
(
val
item
:
ModuleRvItem
)
:
RxBus
.
Event
app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt
View file @
2fe917ff
...
@@ -85,13 +85,13 @@ class SuperuserViewModel(
...
@@ -85,13 +85,13 @@ class SuperuserViewModel(
}
}
private
fun
updatePolicy
(
it
:
PolicyUpdateEvent
)
=
when
(
it
)
{
private
fun
updatePolicy
(
it
:
PolicyUpdateEvent
)
=
when
(
it
)
{
is
PolicyUpdateEvent
.
Notification
->
updatePolicy
(
it
.
item
.
item
.
copy
(
notification
=
it
.
shouldNotify
)
)
{
is
PolicyUpdateEvent
.
Notification
->
updatePolicy
(
it
.
item
)
{
val
textId
=
val
textId
=
if
(
it
.
notification
)
R
.
string
.
su_snack_notif_on
else
R
.
string
.
su_snack_notif_off
if
(
it
.
notification
)
R
.
string
.
su_snack_notif_on
else
R
.
string
.
su_snack_notif_off
val
text
=
resources
.
getString
(
textId
).
format
(
it
.
appName
)
val
text
=
resources
.
getString
(
textId
).
format
(
it
.
appName
)
SnackbarEvent
(
text
).
publish
()
SnackbarEvent
(
text
).
publish
()
}
}
is
PolicyUpdateEvent
.
Log
->
updatePolicy
(
it
.
item
.
item
.
copy
(
logging
=
it
.
shouldLog
)
)
{
is
PolicyUpdateEvent
.
Log
->
updatePolicy
(
it
.
item
)
{
val
textId
=
val
textId
=
if
(
it
.
logging
)
R
.
string
.
su_snack_log_on
else
R
.
string
.
su_snack_log_off
if
(
it
.
logging
)
R
.
string
.
su_snack_log_on
else
R
.
string
.
su_snack_log_off
val
text
=
resources
.
getString
(
textId
).
format
(
it
.
appName
)
val
text
=
resources
.
getString
(
textId
).
format
(
it
.
appName
)
...
...
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