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
b16f696b
Commit
b16f696b
authored
Jul 28, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups
parent
9adfb382
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
34 deletions
+17
-34
AppRepository.kt
...ava/com/topjohnwu/magisk/data/repository/AppRepository.kt
+0
-15
RepositoryModule.kt
...src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt
+0
-2
GeneralReceiver.kt
...va/com/topjohnwu/magisk/model/receiver/GeneralReceiver.kt
+4
-4
SuperuserViewModel.kt
...a/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt
+5
-5
SuRequestViewModel.kt
...a/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt
+5
-5
SuLogger.kt
app/src/main/java/com/topjohnwu/magisk/utils/SuLogger.kt
+3
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/data/repository/AppRepository.kt
deleted
100644 → 0
View file @
9adfb382
package
com.topjohnwu.magisk.data.repository
import
com.topjohnwu.magisk.data.database.PolicyDao
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
class
AppRepository
(
private
val
policyDao
:
PolicyDao
)
{
fun
deleteOutdated
()
=
policyDao
.
deleteOutdated
()
fun
delete
(
packageName
:
String
)
=
policyDao
.
delete
(
packageName
)
fun
delete
(
uid
:
Int
)
=
policyDao
.
delete
(
uid
)
fun
fetch
(
uid
:
Int
)
=
policyDao
.
fetch
(
uid
)
fun
fetchAll
()
=
policyDao
.
fetchAll
()
fun
update
(
policy
:
MagiskPolicy
)
=
policyDao
.
update
(
policy
)
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt
View file @
b16f696b
package
com.topjohnwu.magisk.di
package
com.topjohnwu.magisk.di
import
com.topjohnwu.magisk.data.repository.AppRepository
import
com.topjohnwu.magisk.data.repository.LogRepository
import
com.topjohnwu.magisk.data.repository.LogRepository
import
com.topjohnwu.magisk.data.repository.MagiskRepository
import
com.topjohnwu.magisk.data.repository.MagiskRepository
import
com.topjohnwu.magisk.data.repository.StringRepository
import
com.topjohnwu.magisk.data.repository.StringRepository
...
@@ -10,6 +9,5 @@ import org.koin.dsl.module
...
@@ -10,6 +9,5 @@ import org.koin.dsl.module
val
repositoryModule
=
module
{
val
repositoryModule
=
module
{
single
{
MagiskRepository
(
get
(),
get
())
}
single
{
MagiskRepository
(
get
(),
get
())
}
single
{
LogRepository
(
get
())
}
single
{
LogRepository
(
get
())
}
single
{
AppRepository
(
get
())
}
single
{
StringRepository
(
get
())
}
single
{
StringRepository
(
get
())
}
}
}
app/src/main/java/com/topjohnwu/magisk/model/receiver/GeneralReceiver.kt
View file @
b16f696b
...
@@ -7,8 +7,8 @@ import com.topjohnwu.magisk.ClassMap
...
@@ -7,8 +7,8 @@ import com.topjohnwu.magisk.ClassMap
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.Info
import
com.topjohnwu.magisk.Info
import
com.topjohnwu.magisk.data.database.PolicyDao
import
com.topjohnwu.magisk.data.database.base.su
import
com.topjohnwu.magisk.data.database.base.su
import
com.topjohnwu.magisk.data.repository.AppRepository
import
com.topjohnwu.magisk.extensions.inject
import
com.topjohnwu.magisk.extensions.inject
import
com.topjohnwu.magisk.extensions.reboot
import
com.topjohnwu.magisk.extensions.reboot
import
com.topjohnwu.magisk.ui.surequest.SuRequestActivity
import
com.topjohnwu.magisk.ui.surequest.SuRequestActivity
...
@@ -20,7 +20,7 @@ import com.topjohnwu.superuser.Shell
...
@@ -20,7 +20,7 @@ import com.topjohnwu.superuser.Shell
open
class
GeneralReceiver
:
BroadcastReceiver
()
{
open
class
GeneralReceiver
:
BroadcastReceiver
()
{
private
val
appRepo
:
AppRepository
by
inject
()
private
val
policyDB
:
PolicyDao
by
inject
()
companion
object
{
companion
object
{
const
val
REQUEST
=
"request"
const
val
REQUEST
=
"request"
...
@@ -65,10 +65,10 @@ open class GeneralReceiver : BroadcastReceiver() {
...
@@ -65,10 +65,10 @@ open class GeneralReceiver : BroadcastReceiver() {
Intent
.
ACTION_PACKAGE_REPLACED
->
Intent
.
ACTION_PACKAGE_REPLACED
->
// This will only work pre-O
// This will only work pre-O
if
(
Config
.
suReAuth
)
if
(
Config
.
suReAuth
)
appRepo
.
delete
(
getPkg
(
intent
)).
blockingGet
()
policyDB
.
delete
(
getPkg
(
intent
)).
blockingGet
()
Intent
.
ACTION_PACKAGE_FULLY_REMOVED
->
{
Intent
.
ACTION_PACKAGE_FULLY_REMOVED
->
{
val
pkg
=
getPkg
(
intent
)
val
pkg
=
getPkg
(
intent
)
appRepo
.
delete
(
pkg
).
blockingGet
()
policyDB
.
delete
(
pkg
).
blockingGet
()
"magiskhide --rm $pkg"
.
su
().
blockingGet
()
"magiskhide --rm $pkg"
.
su
().
blockingGet
()
}
}
Intent
.
ACTION_LOCALE_CHANGED
->
Shortcuts
.
setup
(
context
)
Intent
.
ACTION_LOCALE_CHANGED
->
Shortcuts
.
setup
(
context
)
...
...
app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt
View file @
b16f696b
...
@@ -10,7 +10,7 @@ import com.skoumal.teanity.util.DiffObservableList
...
@@ -10,7 +10,7 @@ import com.skoumal.teanity.util.DiffObservableList
import
com.skoumal.teanity.viewevents.SnackbarEvent
import
com.skoumal.teanity.viewevents.SnackbarEvent
import
com.topjohnwu.magisk.BR
import
com.topjohnwu.magisk.BR
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.
repository.AppRepository
import
com.topjohnwu.magisk.data.
database.PolicyDao
import
com.topjohnwu.magisk.extensions.toggle
import
com.topjohnwu.magisk.extensions.toggle
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.Policy
import
com.topjohnwu.magisk.model.entity.Policy
...
@@ -26,7 +26,7 @@ import io.reactivex.disposables.Disposable
...
@@ -26,7 +26,7 @@ import io.reactivex.disposables.Disposable
import
me.tatarka.bindingcollectionadapter2.ItemBinding
import
me.tatarka.bindingcollectionadapter2.ItemBinding
class
SuperuserViewModel
(
class
SuperuserViewModel
(
private
val
appRepo
:
AppRepository
,
private
val
policyDB
:
PolicyDao
,
private
val
packageManager
:
PackageManager
,
private
val
packageManager
:
PackageManager
,
private
val
resources
:
Resources
,
private
val
resources
:
Resources
,
rxBus
:
RxBus
rxBus
:
RxBus
...
@@ -54,7 +54,7 @@ class SuperuserViewModel(
...
@@ -54,7 +54,7 @@ class SuperuserViewModel(
fun
updatePolicies
()
{
fun
updatePolicies
()
{
if
(
fetchTask
?.
isDisposed
?.
not
()
==
true
)
return
if
(
fetchTask
?.
isDisposed
?.
not
()
==
true
)
return
fetchTask
=
appRepo
.
fetchAll
()
fetchTask
=
policyDB
.
fetchAll
()
.
flattenAsFlowable
{
it
}
.
flattenAsFlowable
{
it
}
.
map
{
PolicyRvItem
(
it
,
it
.
applicationInfo
.
loadIcon
(
packageManager
))
}
.
map
{
PolicyRvItem
(
it
,
it
.
applicationInfo
.
loadIcon
(
packageManager
))
}
.
toList
()
.
toList
()
...
@@ -140,9 +140,9 @@ class SuperuserViewModel(
...
@@ -140,9 +140,9 @@ class SuperuserViewModel(
}
}
private
fun
updatePolicy
(
policy
:
MagiskPolicy
)
=
private
fun
updatePolicy
(
policy
:
MagiskPolicy
)
=
appRepo
.
update
(
policy
).
andThen
(
Single
.
just
(
policy
))
policyDB
.
update
(
policy
).
andThen
(
Single
.
just
(
policy
))
private
fun
deletePolicy
(
policy
:
MagiskPolicy
)
=
private
fun
deletePolicy
(
policy
:
MagiskPolicy
)
=
appRepo
.
delete
(
policy
.
uid
).
andThen
(
Single
.
just
(
policy
))
policyDB
.
delete
(
policy
.
uid
).
andThen
(
Single
.
just
(
policy
))
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt
View file @
b16f696b
...
@@ -16,7 +16,7 @@ import com.skoumal.teanity.util.KObservableField
...
@@ -16,7 +16,7 @@ import com.skoumal.teanity.util.KObservableField
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.
repository.AppRepository
import
com.topjohnwu.magisk.data.
database.PolicyDao
import
com.topjohnwu.magisk.extensions.now
import
com.topjohnwu.magisk.extensions.now
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.Policy
import
com.topjohnwu.magisk.model.entity.Policy
...
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit.*
...
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit.*
class
SuRequestViewModel
(
class
SuRequestViewModel
(
private
val
packageManager
:
PackageManager
,
private
val
packageManager
:
PackageManager
,
private
val
appRepo
:
AppRepository
,
private
val
policyDB
:
PolicyDao
,
private
val
timeoutPrefs
:
SharedPreferences
,
private
val
timeoutPrefs
:
SharedPreferences
,
private
val
resources
:
Resources
private
val
resources
:
Resources
)
:
MagiskViewModel
()
{
)
:
MagiskViewModel
()
{
...
@@ -121,8 +121,8 @@ class SuRequestViewModel(
...
@@ -121,8 +121,8 @@ class SuRequestViewModel(
}
}
val
bundle
=
connector
.
readSocketInput
()
val
bundle
=
connector
.
readSocketInput
()
val
uid
=
bundle
.
getString
(
"uid"
)
?.
toIntOrNull
()
?:
return
false
val
uid
=
bundle
.
getString
(
"uid"
)
?.
toIntOrNull
()
?:
return
false
appRepo
.
deleteOutdated
().
blockingGet
()
// wrong!
policyDB
.
deleteOutdated
().
blockingGet
()
// wrong!
policy
=
runCatching
{
appRepo
.
fetch
(
uid
).
blockingGet
()
}
policy
=
runCatching
{
policyDB
.
fetch
(
uid
).
blockingGet
()
}
.
getOrDefault
(
uid
.
toPolicy
(
packageManager
))
.
getOrDefault
(
uid
.
toPolicy
(
packageManager
))
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
...
@@ -156,7 +156,7 @@ class SuRequestViewModel(
...
@@ -156,7 +156,7 @@ class SuRequestViewModel(
policy
?.
until
?:
0
policy
?.
until
?:
0
}
}
policy
=
policy
?.
copy
(
policy
=
action
,
until
=
until
)
?.
apply
{
policy
=
policy
?.
copy
(
policy
=
action
,
until
=
until
)
?.
apply
{
appRepo
.
update
(
this
).
blockingGet
()
policyDB
.
update
(
this
).
blockingGet
()
}
}
handleAction
()
handleAction
()
...
...
app/src/main/java/com/topjohnwu/magisk/utils/SuLogger.kt
View file @
b16f696b
...
@@ -7,7 +7,7 @@ import android.os.Process
...
@@ -7,7 +7,7 @@ import android.os.Process
import
android.widget.Toast
import
android.widget.Toast
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.
repository.AppRepository
import
com.topjohnwu.magisk.data.
database.PolicyDao
import
com.topjohnwu.magisk.data.repository.LogRepository
import
com.topjohnwu.magisk.data.repository.LogRepository
import
com.topjohnwu.magisk.extensions.inject
import
com.topjohnwu.magisk.extensions.inject
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
import
com.topjohnwu.magisk.model.entity.MagiskPolicy
...
@@ -38,8 +38,8 @@ object SuLogger {
...
@@ -38,8 +38,8 @@ object SuLogger {
}.
getOrElse
{
return
}
}.
getOrElse
{
return
}
}
else
{
}
else
{
// Doesn't report whether notify or not, check database ourselves
// Doesn't report whether notify or not, check database ourselves
val
appRepo
:
AppRepository
by
inject
()
val
policyDB
:
PolicyDao
by
inject
()
val
policy
=
appRepo
.
fetch
(
fromUid
).
blockingGet
()
?:
return
val
policy
=
policyDB
.
fetch
(
fromUid
).
blockingGet
()
?:
return
notify
=
policy
.
notification
notify
=
policy
.
notification
policy
policy
}.
copy
(
policy
=
data
.
getInt
(
"policy"
,
-
1
))
}.
copy
(
policy
=
data
.
getInt
(
"policy"
,
-
1
))
...
...
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