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
2eb00187
Commit
2eb00187
authored
Sep 11, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
b510dc51
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
15 deletions
+13
-15
SuPolicy.kt
.../main/java/com/topjohnwu/magisk/core/model/su/SuPolicy.kt
+9
-9
ViewModelsModule.kt
...src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt
+1
-1
SuperuserViewModel.kt
...a/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt
+1
-3
SuRequestViewModel.kt
...a/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt
+2
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/core/model/su/SuPolicy.kt
View file @
2eb00187
package
com.topjohnwu.magisk.core.model.su
package
com.topjohnwu.magisk.core.model.su
import
android.content.pm.ApplicationInfo
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.graphics.drawable.Drawable
import
com.topjohnwu.magisk.core.model.su.SuPolicy.Companion.INTERACTIVE
import
com.topjohnwu.magisk.core.model.su.SuPolicy.Companion.INTERACTIVE
import
com.topjohnwu.magisk.ktx.getLabel
import
com.topjohnwu.magisk.ktx.getLabel
...
@@ -10,11 +10,11 @@ data class SuPolicy(
...
@@ -10,11 +10,11 @@ data class SuPolicy(
var
uid
:
Int
,
var
uid
:
Int
,
val
packageName
:
String
,
val
packageName
:
String
,
val
appName
:
String
,
val
appName
:
String
,
val
icon
:
Drawable
,
var
policy
:
Int
=
INTERACTIVE
,
var
policy
:
Int
=
INTERACTIVE
,
var
until
:
Long
=
-
1L
,
var
until
:
Long
=
-
1L
,
val
logging
:
Boolean
=
true
,
val
logging
:
Boolean
=
true
,
val
notification
:
Boolean
=
true
,
val
notification
:
Boolean
=
true
val
applicationInfo
:
ApplicationInfo
)
{
)
{
companion
object
{
companion
object
{
...
@@ -46,12 +46,12 @@ fun Map<String, String>.toPolicy(pm: PackageManager): SuPolicy {
...
@@ -46,12 +46,12 @@ fun Map<String, String>.toPolicy(pm: PackageManager): SuPolicy {
return
SuPolicy
(
return
SuPolicy
(
uid
=
uid
,
uid
=
uid
,
packageName
=
packageName
,
packageName
=
packageName
,
appName
=
info
.
getLabel
(
pm
),
icon
=
info
.
loadIcon
(
pm
),
policy
=
get
(
"policy"
)
?.
toIntOrNull
()
?:
INTERACTIVE
,
policy
=
get
(
"policy"
)
?.
toIntOrNull
()
?:
INTERACTIVE
,
until
=
get
(
"until"
)
?.
toLongOrNull
()
?:
-
1L
,
until
=
get
(
"until"
)
?.
toLongOrNull
()
?:
-
1L
,
logging
=
get
(
"logging"
)
?.
toIntOrNull
()
!=
0
,
logging
=
get
(
"logging"
)
?.
toIntOrNull
()
!=
0
,
notification
=
get
(
"notification"
)
?.
toIntOrNull
()
!=
0
,
notification
=
get
(
"notification"
)
?.
toIntOrNull
()
!=
0
applicationInfo
=
info
,
appName
=
info
.
getLabel
(
pm
)
)
)
}
}
...
@@ -63,8 +63,8 @@ fun Int.toPolicy(pm: PackageManager, policy: Int = INTERACTIVE): SuPolicy {
...
@@ -63,8 +63,8 @@ fun Int.toPolicy(pm: PackageManager, policy: Int = INTERACTIVE): SuPolicy {
return
SuPolicy
(
return
SuPolicy
(
uid
=
info
.
uid
,
uid
=
info
.
uid
,
packageName
=
pkg
,
packageName
=
pkg
,
policy
=
policy
,
appName
=
info
.
getLabel
(
pm
)
,
applicationInfo
=
info
,
icon
=
info
.
loadIcon
(
pm
)
,
appName
=
info
.
getLabel
(
pm
)
policy
=
policy
)
)
}
}
app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt
View file @
2eb00187
...
@@ -23,7 +23,7 @@ val viewModelModules = module {
...
@@ -23,7 +23,7 @@ val viewModelModules = module {
viewModel
{
ModuleViewModel
(
get
(),
get
(),
get
())
}
viewModel
{
ModuleViewModel
(
get
(),
get
(),
get
())
}
viewModel
{
SafetynetViewModel
()
}
viewModel
{
SafetynetViewModel
()
}
viewModel
{
SettingsViewModel
(
get
())
}
viewModel
{
SettingsViewModel
(
get
())
}
viewModel
{
SuperuserViewModel
(
get
(),
get
()
,
get
()
)
}
viewModel
{
SuperuserViewModel
(
get
(),
get
())
}
viewModel
{
ThemeViewModel
()
}
viewModel
{
ThemeViewModel
()
}
viewModel
{
InstallViewModel
(
get
())
}
viewModel
{
InstallViewModel
(
get
())
}
viewModel
{
MainViewModel
()
}
viewModel
{
MainViewModel
()
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt
View file @
2eb00187
package
com.topjohnwu.magisk.ui.superuser
package
com.topjohnwu.magisk.ui.superuser
import
android.content.pm.PackageManager
import
android.content.res.Resources
import
android.content.res.Resources
import
androidx.databinding.ObservableArrayList
import
androidx.databinding.ObservableArrayList
import
androidx.lifecycle.viewModelScope
import
androidx.lifecycle.viewModelScope
...
@@ -27,7 +26,6 @@ import me.tatarka.bindingcollectionadapter2.collections.MergeObservableList
...
@@ -27,7 +26,6 @@ import me.tatarka.bindingcollectionadapter2.collections.MergeObservableList
class
SuperuserViewModel
(
class
SuperuserViewModel
(
private
val
db
:
PolicyDao
,
private
val
db
:
PolicyDao
,
private
val
packageManager
:
PackageManager
,
private
val
resources
:
Resources
private
val
resources
:
Resources
)
:
BaseViewModel
(),
TappableHeadlineItem
.
Listener
{
)
:
BaseViewModel
(),
TappableHeadlineItem
.
Listener
{
...
@@ -51,7 +49,7 @@ class SuperuserViewModel(
...
@@ -51,7 +49,7 @@ class SuperuserViewModel(
state
=
State
.
LOADING
state
=
State
.
LOADING
val
(
policies
,
diff
)
=
withContext
(
Dispatchers
.
Default
)
{
val
(
policies
,
diff
)
=
withContext
(
Dispatchers
.
Default
)
{
val
policies
=
db
.
fetchAll
{
val
policies
=
db
.
fetchAll
{
PolicyRvItem
(
it
,
it
.
applicationInfo
.
loadIcon
(
packageManager
)
,
this
@SuperuserViewModel
)
PolicyRvItem
(
it
,
it
.
icon
,
this
@SuperuserViewModel
)
}.
sortedWith
(
compareBy
(
}.
sortedWith
(
compareBy
(
{
it
.
item
.
appName
.
toLowerCase
(
currentLocale
)
},
{
it
.
item
.
appName
.
toLowerCase
(
currentLocale
)
},
{
it
.
item
.
packageName
}
{
it
.
item
.
packageName
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt
View file @
2eb00187
...
@@ -29,7 +29,7 @@ import me.tatarka.bindingcollectionadapter2.ItemBinding
...
@@ -29,7 +29,7 @@ import me.tatarka.bindingcollectionadapter2.ItemBinding
import
java.util.concurrent.TimeUnit.SECONDS
import
java.util.concurrent.TimeUnit.SECONDS
class
SuRequestViewModel
(
class
SuRequestViewModel
(
p
rivate
val
p
m
:
PackageManager
,
pm
:
PackageManager
,
policyDB
:
PolicyDao
,
policyDB
:
PolicyDao
,
private
val
timeoutPrefs
:
SharedPreferences
,
private
val
timeoutPrefs
:
SharedPreferences
,
private
val
res
:
Resources
private
val
res
:
Resources
...
@@ -94,7 +94,7 @@ class SuRequestViewModel(
...
@@ -94,7 +94,7 @@ class SuRequestViewModel(
}
}
private
fun
showDialog
(
policy
:
SuPolicy
)
{
private
fun
showDialog
(
policy
:
SuPolicy
)
{
icon
=
policy
.
applicationInfo
.
loadIcon
(
pm
)
icon
=
policy
.
icon
title
=
policy
.
appName
title
=
policy
.
appName
packageName
=
policy
.
packageName
packageName
=
policy
.
packageName
selectedItemPosition
=
timeoutPrefs
.
getInt
(
policy
.
packageName
,
0
)
selectedItemPosition
=
timeoutPrefs
.
getInt
(
policy
.
packageName
,
0
)
...
...
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