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
71e37345
Commit
71e37345
authored
Mar 01, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update libsu
parent
e7c82f20
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
39 additions
and
40 deletions
+39
-40
build.gradle.kts
app/build.gradle.kts
+1
-1
BaseMainActivity.kt
...c/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt
+2
-2
App.kt
app/src/main/java/com/topjohnwu/magisk/core/App.kt
+1
-3
Receiver.kt
app/src/main/java/com/topjohnwu/magisk/core/Receiver.kt
+1
-1
Query.kt
...src/main/java/com/topjohnwu/magisk/core/magiskdb/Query.kt
+2
-2
LocalModule.kt
...ava/com/topjohnwu/magisk/core/model/module/LocalModule.kt
+9
-9
SuRequestHandler.kt
...ain/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt
+1
-1
FlashZip.kt
...src/main/java/com/topjohnwu/magisk/core/tasks/FlashZip.kt
+2
-2
HideAPK.kt
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
+1
-1
MagiskInstaller.kt
...n/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
+2
-2
RootRegistry.kt
...main/java/com/topjohnwu/magisk/core/utils/RootRegistry.kt
+2
-1
ShellInit.kt
...rc/main/java/com/topjohnwu/magisk/core/utils/ShellInit.kt
+1
-1
LogRepository.kt
...ava/com/topjohnwu/magisk/data/repository/LogRepository.kt
+3
-3
RebootEvent.kt
app/src/main/java/com/topjohnwu/magisk/events/RebootEvent.kt
+1
-1
UninstallDialog.kt
...ava/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt
+1
-1
XAndroid.kt
app/src/main/java/com/topjohnwu/magisk/ktx/XAndroid.kt
+1
-1
XSU.kt
app/src/main/java/com/topjohnwu/magisk/ktx/XSU.kt
+2
-2
DenyListRvItem.kt
.../main/java/com/topjohnwu/magisk/ui/deny/DenyListRvItem.kt
+1
-1
DenyListViewModel.kt
...in/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
+1
-1
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+1
-1
SettingsItems.kt
...in/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
+1
-1
SettingsViewModel.kt
...ava/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
+1
-1
build.gradle.kts
buildSrc/build.gradle.kts
+1
-1
No files found.
app/build.gradle.kts
View file @
71e37345
...
@@ -86,7 +86,7 @@ dependencies {
...
@@ -86,7 +86,7 @@ dependencies {
implementation
(
"${bindingAdapter}:${vBAdapt}"
)
implementation
(
"${bindingAdapter}:${vBAdapt}"
)
implementation
(
"${bindingAdapter}-recyclerview:${vBAdapt}"
)
implementation
(
"${bindingAdapter}-recyclerview:${vBAdapt}"
)
val
vLibsu
=
"
3.2.1
"
val
vLibsu
=
"
4.0.0
"
implementation
(
"com.github.topjohnwu.libsu:core:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:core:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:io:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:io:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:service:${vLibsu}"
)
implementation
(
"com.github.topjohnwu.libsu:service:${vLibsu}"
)
...
...
app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt
View file @
71e37345
...
@@ -111,13 +111,13 @@ abstract class BaseMainActivity<Binding : ViewDataBinding> : NavigationActivity<
...
@@ -111,13 +111,13 @@ abstract class BaseMainActivity<Binding : ViewDataBinding> : NavigationActivity<
runCatching
{
runCatching
{
// Hidden, remove com.topjohnwu.magisk if exist as it could be malware
// Hidden, remove com.topjohnwu.magisk if exist as it could be malware
packageManager
.
getApplicationInfo
(
APPLICATION_ID
,
0
)
packageManager
.
getApplicationInfo
(
APPLICATION_ID
,
0
)
Shell
.
su
(
"(pm uninstall $APPLICATION_ID)& >/dev/null 2>&1"
).
exec
()
Shell
.
cmd
(
"(pm uninstall $APPLICATION_ID)& >/dev/null 2>&1"
).
exec
()
}
}
}
else
{
}
else
{
if
(
Config
.
suManager
.
isNotEmpty
())
if
(
Config
.
suManager
.
isNotEmpty
())
Config
.
suManager
=
""
Config
.
suManager
=
""
pkg
?:
return
pkg
?:
return
if
(!
Shell
.
su
(
"(pm uninstall $pkg)& >/dev/null 2>&1"
).
exec
().
isSuccess
)
{
if
(!
Shell
.
cmd
(
"(pm uninstall $pkg)& >/dev/null 2>&1"
).
exec
().
isSuccess
)
{
// Uninstall through Android API
// Uninstall through Android API
uninstallAndWait
(
pkg
)
uninstallAndWait
(
pkg
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/App.kt
View file @
71e37345
...
@@ -70,7 +70,7 @@ open class App() : Application() {
...
@@ -70,7 +70,7 @@ open class App() : Application() {
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
RootRegistry
.
bindTask
=
RootService
.
createBind
Task
(
RootRegistry
.
bindTask
=
RootService
.
bindOr
Task
(
intent
<
RootRegistry
>(),
intent
<
RootRegistry
>(),
UiThreadHandler
.
executor
,
UiThreadHandler
.
executor
,
RootRegistry
.
Connection
RootRegistry
.
Connection
...
@@ -92,8 +92,6 @@ object ActivityTracker : Application.ActivityLifecycleCallbacks {
...
@@ -92,8 +92,6 @@ object ActivityTracker : Application.ActivityLifecycleCallbacks {
@Volatile
@Volatile
var
foreground
:
Activity
?
=
null
var
foreground
:
Activity
?
=
null
val
hasForeground
get
()
=
foreground
!=
null
override
fun
onActivityResumed
(
activity
:
Activity
)
{
override
fun
onActivityResumed
(
activity
:
Activity
)
{
if
(
activity
is
SuRequestActivity
)
return
if
(
activity
is
SuRequestActivity
)
return
foreground
=
activity
foreground
=
activity
...
...
app/src/main/java/com/topjohnwu/magisk/core/Receiver.kt
View file @
71e37345
...
@@ -43,7 +43,7 @@ open class Receiver : BaseReceiver() {
...
@@ -43,7 +43,7 @@ open class Receiver : BaseReceiver() {
getUid
(
intent
)
?.
let
{
rmPolicy
(
it
)
}
getUid
(
intent
)
?.
let
{
rmPolicy
(
it
)
}
}
}
Intent
.
ACTION_PACKAGE_FULLY_REMOVED
->
{
Intent
.
ACTION_PACKAGE_FULLY_REMOVED
->
{
getPkg
(
intent
)
?.
let
{
Shell
.
su
(
"magisk --denylist rm $it"
).
submit
()
}
getPkg
(
intent
)
?.
let
{
Shell
.
cmd
(
"magisk --denylist rm $it"
).
submit
()
}
}
}
Intent
.
ACTION_LOCALE_CHANGED
->
Shortcuts
.
setupDynamic
(
context
)
Intent
.
ACTION_LOCALE_CHANGED
->
Shortcuts
.
setupDynamic
(
context
)
Intent
.
ACTION_MY_PACKAGE_REPLACED
->
{
Intent
.
ACTION_MY_PACKAGE_REPLACED
->
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/magiskdb/Query.kt
View file @
71e37345
...
@@ -18,7 +18,7 @@ class Query(private val _query: String) {
...
@@ -18,7 +18,7 @@ class Query(private val _query: String) {
suspend
inline
fun
<
R
:
Any
>
query
(
crossinline
mapper
:
(
Map
<
String
,
String
>)
->
R
?):
List
<
R
>
=
suspend
inline
fun
<
R
:
Any
>
query
(
crossinline
mapper
:
(
Map
<
String
,
String
>)
->
R
?):
List
<
R
>
=
withContext
(
Dispatchers
.
Default
)
{
withContext
(
Dispatchers
.
Default
)
{
Shell
.
su
(
query
).
await
().
out
.
map
{
line
->
Shell
.
cmd
(
query
).
await
().
out
.
map
{
line
->
async
{
async
{
line
.
split
(
"\\|"
.
toRegex
())
line
.
split
(
"\\|"
.
toRegex
())
.
map
{
it
.
split
(
"="
,
limit
=
2
)
}
.
map
{
it
.
split
(
"="
,
limit
=
2
)
}
...
@@ -32,7 +32,7 @@ class Query(private val _query: String) {
...
@@ -32,7 +32,7 @@ class Query(private val _query: String) {
suspend
inline
fun
query
()
=
query
{
it
}
suspend
inline
fun
query
()
=
query
{
it
}
suspend
inline
fun
commit
()
=
Shell
.
su
(
query
).
to
(
null
).
await
()
suspend
inline
fun
commit
()
=
Shell
.
cmd
(
query
).
to
(
null
).
await
()
}
}
class
Delete
:
Query
.
Builder
{
class
Delete
:
Query
.
Builder
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt
View file @
71e37345
...
@@ -46,15 +46,15 @@ data class LocalModule(
...
@@ -46,15 +46,15 @@ data class LocalModule(
if
(
enable
)
{
if
(
enable
)
{
disableFile
.
delete
()
disableFile
.
delete
()
if
(
Const
.
Version
.
atLeast_21_2
())
if
(
Const
.
Version
.
atLeast_21_2
())
Shell
.
su
(
"copy_sepolicy_rules"
).
submit
()
Shell
.
cmd
(
"copy_sepolicy_rules"
).
submit
()
else
else
Shell
.
su
(
"mkdir -p $dir"
,
"cp -af $ruleFile $dir"
).
submit
()
Shell
.
cmd
(
"mkdir -p $dir"
,
"cp -af $ruleFile $dir"
).
submit
()
}
else
{
}
else
{
!
disableFile
.
createNewFile
()
!
disableFile
.
createNewFile
()
if
(
Const
.
Version
.
atLeast_21_2
())
if
(
Const
.
Version
.
atLeast_21_2
())
Shell
.
su
(
"copy_sepolicy_rules"
).
submit
()
Shell
.
cmd
(
"copy_sepolicy_rules"
).
submit
()
else
else
Shell
.
su
(
"rm -rf $dir"
).
submit
()
Shell
.
cmd
(
"rm -rf $dir"
).
submit
()
}
}
}
}
...
@@ -65,15 +65,15 @@ data class LocalModule(
...
@@ -65,15 +65,15 @@ data class LocalModule(
if
(
updateFile
.
exists
())
return
if
(
updateFile
.
exists
())
return
removeFile
.
createNewFile
()
removeFile
.
createNewFile
()
if
(
Const
.
Version
.
atLeast_21_2
())
if
(
Const
.
Version
.
atLeast_21_2
())
Shell
.
su
(
"copy_sepolicy_rules"
).
submit
()
Shell
.
cmd
(
"copy_sepolicy_rules"
).
submit
()
else
else
Shell
.
su
(
"rm -rf $PERSIST/$id"
).
submit
()
Shell
.
cmd
(
"rm -rf $PERSIST/$id"
).
submit
()
}
else
{
}
else
{
removeFile
.
delete
()
removeFile
.
delete
()
if
(
Const
.
Version
.
atLeast_21_2
())
if
(
Const
.
Version
.
atLeast_21_2
())
Shell
.
su
(
"copy_sepolicy_rules"
).
submit
()
Shell
.
cmd
(
"copy_sepolicy_rules"
).
submit
()
else
else
Shell
.
su
(
"cp -af $ruleFile $PERSIST/$id"
).
submit
()
Shell
.
cmd
(
"cp -af $ruleFile $PERSIST/$id"
).
submit
()
}
}
}
}
...
@@ -103,7 +103,7 @@ data class LocalModule(
...
@@ -103,7 +103,7 @@ data class LocalModule(
init
{
init
{
runCatching
{
runCatching
{
parseProps
(
Shell
.
su
(
"dos2unix < $path/module.prop"
).
exec
().
out
)
parseProps
(
Shell
.
cmd
(
"dos2unix < $path/module.prop"
).
exec
().
out
)
}
}
if
(
id
.
isEmpty
())
{
if
(
id
.
isEmpty
())
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/su/SuRequestHandler.kt
View file @
71e37345
...
@@ -36,7 +36,7 @@ class SuRequestHandler(
...
@@ -36,7 +36,7 @@ class SuRequestHandler(
// Never allow com.topjohnwu.magisk (could be malware)
// Never allow com.topjohnwu.magisk (could be malware)
if
(
policy
.
packageName
==
BuildConfig
.
APPLICATION_ID
)
{
if
(
policy
.
packageName
==
BuildConfig
.
APPLICATION_ID
)
{
Shell
.
su
(
"(pm uninstall ${BuildConfig.APPLICATION_ID})& >/dev/null 2>&1"
).
exec
()
Shell
.
cmd
(
"(pm uninstall ${BuildConfig.APPLICATION_ID})& >/dev/null 2>&1"
).
exec
()
return
false
return
false
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/tasks/FlashZip.kt
View file @
71e37345
...
@@ -63,7 +63,7 @@ open class FlashZip(
...
@@ -63,7 +63,7 @@ open class FlashZip(
console
.
add
(
"- Installing ${mUri.displayName}"
)
console
.
add
(
"- Installing ${mUri.displayName}"
)
return
Shell
.
su
(
"sh $installDir/update-binary dummy 1 \'$zipFile\'"
)
return
Shell
.
cmd
(
"sh $installDir/update-binary dummy 1 \'$zipFile\'"
)
.
to
(
console
,
logs
).
exec
().
isSuccess
.
to
(
console
,
logs
).
exec
().
isSuccess
}
}
...
@@ -79,7 +79,7 @@ open class FlashZip(
...
@@ -79,7 +79,7 @@ open class FlashZip(
Timber
.
e
(
e
)
Timber
.
e
(
e
)
false
false
}
finally
{
}
finally
{
Shell
.
su
(
"cd /"
,
"rm -rf $installDir ${Const.TMPDIR}"
).
submit
()
Shell
.
cmd
(
"cd /"
,
"rm -rf $installDir ${Const.TMPDIR}"
).
submit
()
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
View file @
71e37345
...
@@ -110,7 +110,7 @@ object HideAPK {
...
@@ -110,7 +110,7 @@ object HideAPK {
Timber
.
e
(
e
)
Timber
.
e
(
e
)
stub
.
createNewFile
()
stub
.
createNewFile
()
val
cmd
=
"\$MAGISKBIN/magiskinit -x manager ${stub.path}"
val
cmd
=
"\$MAGISKBIN/magiskinit -x manager ${stub.path}"
if
(!
Shell
.
su
(
cmd
).
exec
().
isSuccess
)
if
(!
Shell
.
cmd
(
cmd
).
exec
().
isSuccess
)
return
false
return
false
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt
View file @
71e37345
...
@@ -452,7 +452,7 @@ abstract class MagiskInstaller(
...
@@ -452,7 +452,7 @@ abstract class MagiskInstaller(
if
(
success
)
{
if
(
success
)
{
console
.
add
(
"- All done!"
)
console
.
add
(
"- All done!"
)
}
else
{
}
else
{
Shell
.
sh
(
"rm -rf $installDir"
).
submit
()
Shell
.
cmd
(
"rm -rf $installDir"
).
submit
()
console
.
add
(
"! Installation failed"
)
console
.
add
(
"! Installation failed"
)
}
}
return
success
return
success
...
@@ -497,7 +497,7 @@ abstract class MagiskInstaller(
...
@@ -497,7 +497,7 @@ abstract class MagiskInstaller(
val
success
=
super
.
exec
()
val
success
=
super
.
exec
()
if
(
success
)
{
if
(
success
)
{
UiThreadHandler
.
handler
.
postDelayed
(
3000
)
{
UiThreadHandler
.
handler
.
postDelayed
(
3000
)
{
Shell
.
su
(
"pm uninstall ${context.packageName}"
).
exec
()
Shell
.
cmd
(
"pm uninstall ${context.packageName}"
).
exec
()
}
}
}
}
return
success
return
success
...
...
app/src/main/java/com/topjohnwu/magisk/core/utils/RootRegistry.kt
View file @
71e37345
...
@@ -5,6 +5,7 @@ import android.content.Intent
...
@@ -5,6 +5,7 @@ import android.content.Intent
import
android.content.ServiceConnection
import
android.content.ServiceConnection
import
android.os.Binder
import
android.os.Binder
import
android.os.IBinder
import
android.os.IBinder
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.ipc.RootService
import
com.topjohnwu.superuser.ipc.RootService
import
timber.log.Timber
import
timber.log.Timber
import
java.util.concurrent.CountDownLatch
import
java.util.concurrent.CountDownLatch
...
@@ -48,6 +49,6 @@ class RootRegistry(stub: Any?) : RootService() {
...
@@ -48,6 +49,6 @@ class RootRegistry(stub: Any?) : RootService() {
}
}
companion
object
{
companion
object
{
var
bindTask
:
Runnable
?
=
null
var
bindTask
:
Shell
.
Task
?
=
null
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/core/utils/ShellInit.kt
View file @
71e37345
...
@@ -19,7 +19,7 @@ import java.util.jar.JarFile
...
@@ -19,7 +19,7 @@ import java.util.jar.JarFile
class
ShellInit
:
Shell
.
Initializer
()
{
class
ShellInit
:
Shell
.
Initializer
()
{
override
fun
onInit
(
context
:
Context
,
shell
:
Shell
):
Boolean
{
override
fun
onInit
(
context
:
Context
,
shell
:
Shell
):
Boolean
{
if
(
shell
.
isRoot
)
{
if
(
shell
.
isRoot
)
{
RootRegistry
.
bindTask
?.
run
()
RootRegistry
.
bindTask
?.
let
{
shell
.
execTask
(
it
)
}
RootRegistry
.
bindTask
=
null
RootRegistry
.
bindTask
=
null
}
}
shell
.
newJob
().
apply
{
shell
.
newJob
().
apply
{
...
...
app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt
View file @
71e37345
...
@@ -29,9 +29,9 @@ class LogRepository(
...
@@ -29,9 +29,9 @@ class LogRepository(
}
}
}
}
if
(
Info
.
env
.
isActive
)
{
if
(
Info
.
env
.
isActive
)
{
Shell
.
su
(
"cat ${Const.MAGISK_LOG} || logcat -d -s Magisk"
).
to
(
list
).
await
()
Shell
.
cmd
(
"cat ${Const.MAGISK_LOG} || logcat -d -s Magisk"
).
to
(
list
).
await
()
}
else
{
}
else
{
Shell
.
sh
(
"logcat -d"
).
to
(
list
).
await
()
Shell
.
cmd
(
"logcat -d"
).
to
(
list
).
await
()
}
}
return
list
.
buf
.
toString
()
return
list
.
buf
.
toString
()
}
}
...
@@ -39,7 +39,7 @@ class LogRepository(
...
@@ -39,7 +39,7 @@ class LogRepository(
suspend
fun
clearLogs
()
=
logDao
.
deleteAll
()
suspend
fun
clearLogs
()
=
logDao
.
deleteAll
()
fun
clearMagiskLogs
(
cb
:
(
Shell
.
Result
)
->
Unit
)
=
fun
clearMagiskLogs
(
cb
:
(
Shell
.
Result
)
->
Unit
)
=
Shell
.
su
(
"echo -n > ${Const.MAGISK_LOG}"
).
submit
(
cb
)
Shell
.
cmd
(
"echo -n > ${Const.MAGISK_LOG}"
).
submit
(
cb
)
suspend
fun
insert
(
log
:
SuLog
)
=
logDao
.
insert
(
log
)
suspend
fun
insert
(
log
:
SuLog
)
=
logDao
.
insert
(
log
)
...
...
app/src/main/java/com/topjohnwu/magisk/events/RebootEvent.kt
View file @
71e37345
...
@@ -20,7 +20,7 @@ object RebootEvent {
...
@@ -20,7 +20,7 @@ object RebootEvent {
R
.
id
.
action_reboot_bootloader
->
systemReboot
(
"bootloader"
)
R
.
id
.
action_reboot_bootloader
->
systemReboot
(
"bootloader"
)
R
.
id
.
action_reboot_download
->
systemReboot
(
"download"
)
R
.
id
.
action_reboot_download
->
systemReboot
(
"download"
)
R
.
id
.
action_reboot_edl
->
systemReboot
(
"edl"
)
R
.
id
.
action_reboot_edl
->
systemReboot
(
"edl"
)
R
.
id
.
action_reboot_recovery
->
Shell
.
su
(
"/system/bin/reboot recovery"
).
submit
()
R
.
id
.
action_reboot_recovery
->
Shell
.
cmd
(
"/system/bin/reboot recovery"
).
submit
()
else
->
Unit
else
->
Unit
}
}
return
true
return
true
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt
View file @
71e37345
...
@@ -34,7 +34,7 @@ class UninstallDialog : DialogEvent() {
...
@@ -34,7 +34,7 @@ class UninstallDialog : DialogEvent() {
show
()
show
()
}
}
Shell
.
su
(
"restore_imgs"
).
submit
{
result
->
Shell
.
cmd
(
"restore_imgs"
).
submit
{
result
->
dialog
.
dismiss
()
dialog
.
dismiss
()
if
(
result
.
isSuccess
)
{
if
(
result
.
isSuccess
)
{
Utils
.
toast
(
R
.
string
.
restore_done
,
Toast
.
LENGTH_SHORT
)
Utils
.
toast
(
R
.
string
.
restore_done
,
Toast
.
LENGTH_SHORT
)
...
...
app/src/main/java/com/topjohnwu/magisk/ktx/XAndroid.kt
View file @
71e37345
...
@@ -84,7 +84,7 @@ fun Intent.startActivity(context: Context) = context.startActivity(this)
...
@@ -84,7 +84,7 @@ fun Intent.startActivity(context: Context) = context.startActivity(this)
fun
Intent
.
startActivityWithRoot
()
{
fun
Intent
.
startActivityWithRoot
()
{
val
args
=
mutableListOf
(
"am"
,
"start"
,
"--user"
,
Const
.
USER_ID
.
toString
())
val
args
=
mutableListOf
(
"am"
,
"start"
,
"--user"
,
Const
.
USER_ID
.
toString
())
val
cmd
=
toCommand
(
args
).
joinToString
(
" "
)
val
cmd
=
toCommand
(
args
).
joinToString
(
" "
)
Shell
.
su
(
cmd
).
submit
()
Shell
.
cmd
(
cmd
).
submit
()
}
}
fun
Intent
.
toCommand
(
args
:
MutableList
<
String
>
=
mutableListOf
()):
MutableList
<
String
>
{
fun
Intent
.
toCommand
(
args
:
MutableList
<
String
>
=
mutableListOf
()):
MutableList
<
String
>
{
...
...
app/src/main/java/com/topjohnwu/magisk/ktx/XSU.kt
View file @
71e37345
...
@@ -8,14 +8,14 @@ import kotlinx.coroutines.Dispatchers
...
@@ -8,14 +8,14 @@ import kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
fun
reboot
(
reason
:
String
=
if
(
Config
.
recovery
)
"recovery"
else
""
)
{
fun
reboot
(
reason
:
String
=
if
(
Config
.
recovery
)
"recovery"
else
""
)
{
Shell
.
su
(
"/system/bin/svc power reboot $reason || /system/bin/reboot $reason"
).
submit
()
Shell
.
cmd
(
"/system/bin/svc power reboot $reason || /system/bin/reboot $reason"
).
submit
()
}
}
fun
relaunchApp
(
context
:
Context
)
{
fun
relaunchApp
(
context
:
Context
)
{
val
intent
=
context
.
packageManager
.
getLaunchIntentForPackage
(
context
.
packageName
)
?:
return
val
intent
=
context
.
packageManager
.
getLaunchIntentForPackage
(
context
.
packageName
)
?:
return
val
args
=
mutableListOf
(
"am"
,
"start"
,
"--user"
,
Const
.
USER_ID
.
toString
())
val
args
=
mutableListOf
(
"am"
,
"start"
,
"--user"
,
Const
.
USER_ID
.
toString
())
val
cmd
=
intent
.
toCommand
(
args
).
joinToString
(
separator
=
" "
)
val
cmd
=
intent
.
toCommand
(
args
).
joinToString
(
separator
=
" "
)
Shell
.
su
(
"run_delay 1 \"$cmd\""
).
exec
()
Shell
.
cmd
(
"run_delay 1 \"$cmd\""
).
exec
()
Runtime
.
getRuntime
().
exit
(
0
)
Runtime
.
getRuntime
().
exit
(
0
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListRvItem.kt
View file @
71e37345
...
@@ -103,7 +103,7 @@ class ProcessRvItem(
...
@@ -103,7 +103,7 @@ class ProcessRvItem(
set
(
value
)
=
set
(
value
,
process
.
isEnabled
,
{
process
.
isEnabled
=
it
},
BR
.
enabled
)
{
set
(
value
)
=
set
(
value
,
process
.
isEnabled
,
{
process
.
isEnabled
=
it
},
BR
.
enabled
)
{
val
arg
=
if
(
it
)
"add"
else
"rm"
val
arg
=
if
(
it
)
"add"
else
"rm"
val
(
name
,
pkg
)
=
process
val
(
name
,
pkg
)
=
process
Shell
.
su
(
"magisk --denylist $arg $pkg \'$name\'"
).
submit
()
Shell
.
cmd
(
"magisk --denylist $arg $pkg \'$name\'"
).
submit
()
}
}
fun
toggle
()
{
fun
toggle
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListViewModel.kt
View file @
71e37345
...
@@ -52,7 +52,7 @@ class DenyListViewModel : BaseViewModel() {
...
@@ -52,7 +52,7 @@ class DenyListViewModel : BaseViewModel() {
state
=
State
.
LOADING
state
=
State
.
LOADING
val
(
apps
,
diff
)
=
withContext
(
Dispatchers
.
Default
)
{
val
(
apps
,
diff
)
=
withContext
(
Dispatchers
.
Default
)
{
val
pm
=
AppContext
.
packageManager
val
pm
=
AppContext
.
packageManager
val
denyList
=
Shell
.
su
(
"magisk --denylist ls"
).
exec
().
out
val
denyList
=
Shell
.
cmd
(
"magisk --denylist ls"
).
exec
().
out
.
map
{
CmdlineListItem
(
it
)
}
.
map
{
CmdlineListItem
(
it
)
}
val
apps
=
pm
.
getInstalledApplications
(
MATCH_UNINSTALLED_PACKAGES
).
run
{
val
apps
=
pm
.
getInstalledApplications
(
MATCH_UNINSTALLED_PACKAGES
).
run
{
asFlow
()
asFlow
()
...
...
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
71e37345
...
@@ -144,7 +144,7 @@ class HomeViewModel(
...
@@ -144,7 +144,7 @@ class HomeViewModel(
private
suspend
fun
ensureEnv
()
{
private
suspend
fun
ensureEnv
()
{
if
(
MagiskState
.
NOT_INSTALLED
==
stateMagisk
||
checkedEnv
)
return
if
(
MagiskState
.
NOT_INSTALLED
==
stateMagisk
||
checkedEnv
)
return
val
cmd
=
"env_check ${Info.env.versionString} ${Info.env.versionCode}"
val
cmd
=
"env_check ${Info.env.versionString} ${Info.env.versionCode}"
if
(!
Shell
.
su
(
cmd
).
await
().
isSuccess
)
{
if
(!
Shell
.
cmd
(
cmd
).
await
().
isSuccess
)
{
EnvFixDialog
(
this
).
publish
()
EnvFixDialog
(
this
).
publish
()
}
}
checkedEnv
=
true
checkedEnv
=
true
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
View file @
71e37345
...
@@ -257,7 +257,7 @@ object DenyList : BaseSettingsItem.Toggle() {
...
@@ -257,7 +257,7 @@ object DenyList : BaseSettingsItem.Toggle() {
set
(
value
)
{
set
(
value
)
{
field
=
value
field
=
value
val
cmd
=
if
(
value
)
"enable"
else
"disable"
val
cmd
=
if
(
value
)
"enable"
else
"disable"
Shell
.
su
(
"magisk --denylist $cmd"
).
submit
{
result
->
Shell
.
cmd
(
"magisk --denylist $cmd"
).
submit
{
result
->
if
(
result
.
isSuccess
)
{
if
(
result
.
isSuccess
)
{
Config
.
denyList
=
value
Config
.
denyList
=
value
}
else
{
}
else
{
...
...
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt
View file @
71e37345
...
@@ -134,7 +134,7 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
...
@@ -134,7 +134,7 @@ class SettingsViewModel : BaseViewModel(), BaseSettingsItem.Handler {
}
}
private
fun
createHosts
()
{
private
fun
createHosts
()
{
Shell
.
su
(
"add_hosts_module"
).
submit
{
Shell
.
cmd
(
"add_hosts_module"
).
submit
{
Utils
.
toast
(
R
.
string
.
settings_hosts_toast
,
Toast
.
LENGTH_SHORT
)
Utils
.
toast
(
R
.
string
.
settings_hosts_toast
,
Toast
.
LENGTH_SHORT
)
}
}
}
}
...
...
buildSrc/build.gradle.kts
View file @
71e37345
...
@@ -25,7 +25,7 @@ tasks.withType<KotlinCompile> {
...
@@ -25,7 +25,7 @@ tasks.withType<KotlinCompile> {
dependencies
{
dependencies
{
implementation
(
kotlin
(
"gradle-plugin"
,
"1.6.10"
))
implementation
(
kotlin
(
"gradle-plugin"
,
"1.6.10"
))
implementation
(
"com.android.tools.build:gradle:7.1.
1
"
)
implementation
(
"com.android.tools.build:gradle:7.1.
2
"
)
implementation
(
"androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-alpha01"
)
implementation
(
"androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-alpha01"
)
implementation
(
"io.michaelrocks:paranoid-gradle-plugin:0.3.7"
)
implementation
(
"io.michaelrocks:paranoid-gradle-plugin:0.3.7"
)
implementation
(
"org.eclipse.jgit:org.eclipse.jgit:5.12.0.202106070339-r"
)
implementation
(
"org.eclipse.jgit:org.eclipse.jgit:5.12.0.202106070339-r"
)
...
...
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