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
00bff491
Commit
00bff491
authored
Jun 12, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use svc for reboot if feasible
Close #1488
parent
0ce17205
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
91 deletions
+56
-91
Config.kt
app/src/main/java/com/topjohnwu/magisk/Config.kt
+1
-1
RepositoryModule.kt
...src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt
+3
-1
GeneralReceiver.kt
...va/com/topjohnwu/magisk/model/receiver/GeneralReceiver.kt
+2
-2
FlashViewModel.kt
...main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt
+1
-1
ModulesFragment.kt
...in/java/com/topjohnwu/magisk/ui/module/ModulesFragment.kt
+5
-26
RootUtils.kt
app/src/main/java/com/topjohnwu/magisk/utils/RootUtils.kt
+0
-5
XSU.kt
app/src/main/java/com/topjohnwu/magisk/utils/XSU.kt
+3
-8
EnvFixDialog.java
.../java/com/topjohnwu/magisk/view/dialogs/EnvFixDialog.java
+0
-47
EnvFixDialog.kt
...in/java/com/topjohnwu/magisk/view/dialogs/EnvFixDialog.kt
+41
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/Config.kt
View file @
00bff491
...
@@ -3,9 +3,9 @@ package com.topjohnwu.magisk
...
@@ -3,9 +3,9 @@ package com.topjohnwu.magisk
import
android.content.Context
import
android.content.Context
import
android.util.Xml
import
android.util.Xml
import
androidx.core.content.edit
import
androidx.core.content.edit
import
com.topjohnwu.magisk.data.repository.DBConfig
import
com.topjohnwu.magisk.data.database.SettingsDao
import
com.topjohnwu.magisk.data.database.SettingsDao
import
com.topjohnwu.magisk.data.database.StringDao
import
com.topjohnwu.magisk.data.database.StringDao
import
com.topjohnwu.magisk.data.repository.DBConfig
import
com.topjohnwu.magisk.di.Protected
import
com.topjohnwu.magisk.di.Protected
import
com.topjohnwu.magisk.model.preference.PreferenceModel
import
com.topjohnwu.magisk.model.preference.PreferenceModel
import
com.topjohnwu.magisk.utils.*
import
com.topjohnwu.magisk.utils.*
...
...
app/src/main/java/com/topjohnwu/magisk/di/RepositoryModule.kt
View file @
00bff491
package
com.topjohnwu.magisk.di
package
com.topjohnwu.magisk.di
import
com.topjohnwu.magisk.data.repository.*
import
com.topjohnwu.magisk.data.repository.AppRepository
import
com.topjohnwu.magisk.data.repository.LogRepository
import
com.topjohnwu.magisk.data.repository.MagiskRepository
import
org.koin.dsl.module
import
org.koin.dsl.module
...
...
app/src/main/java/com/topjohnwu/magisk/model/receiver/GeneralReceiver.kt
View file @
00bff491
...
@@ -11,9 +11,9 @@ import com.topjohnwu.magisk.data.database.base.su
...
@@ -11,9 +11,9 @@ import com.topjohnwu.magisk.data.database.base.su
import
com.topjohnwu.magisk.data.repository.AppRepository
import
com.topjohnwu.magisk.data.repository.AppRepository
import
com.topjohnwu.magisk.ui.surequest.SuRequestActivity
import
com.topjohnwu.magisk.ui.surequest.SuRequestActivity
import
com.topjohnwu.magisk.utils.DownloadApp
import
com.topjohnwu.magisk.utils.DownloadApp
import
com.topjohnwu.magisk.utils.RootUtils
import
com.topjohnwu.magisk.utils.SuLogger
import
com.topjohnwu.magisk.utils.SuLogger
import
com.topjohnwu.magisk.utils.inject
import
com.topjohnwu.magisk.utils.inject
import
com.topjohnwu.magisk.utils.reboot
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Shortcuts
import
com.topjohnwu.magisk.view.Shortcuts
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
...
@@ -76,7 +76,7 @@ open class GeneralReceiver : BroadcastReceiver() {
...
@@ -76,7 +76,7 @@ open class GeneralReceiver : BroadcastReceiver() {
Info
.
managerLink
=
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_LINK
)
Info
.
managerLink
=
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_LINK
)
DownloadApp
.
upgrade
(
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_NAME
))
DownloadApp
.
upgrade
(
intent
.
getStringExtra
(
Const
.
Key
.
INTENT_SET_NAME
))
}
}
Const
.
Key
.
BROADCAST_REBOOT
->
RootUtils
.
reboot
()
Const
.
Key
.
BROADCAST_REBOOT
->
reboot
()
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt
View file @
00bff491
...
@@ -103,7 +103,7 @@ class FlashViewModel(
...
@@ -103,7 +103,7 @@ class FlashViewModel(
.
subscribeK
{
SnackbarEvent
(
it
).
publish
()
}
.
subscribeK
{
SnackbarEvent
(
it
).
publish
()
}
.
add
()
.
add
()
fun
restartPressed
()
=
RootUtils
.
reboot
()
fun
restartPressed
()
=
reboot
()
fun
backPressed
()
=
back
()
fun
backPressed
()
=
back
()
...
...
app/src/main/java/com/topjohnwu/magisk/ui/module/ModulesFragment.kt
View file @
00bff491
...
@@ -16,7 +16,7 @@ import com.topjohnwu.magisk.databinding.FragmentModulesBinding
...
@@ -16,7 +16,7 @@ import com.topjohnwu.magisk.databinding.FragmentModulesBinding
import
com.topjohnwu.magisk.model.events.OpenFilePickerEvent
import
com.topjohnwu.magisk.model.events.OpenFilePickerEvent
import
com.topjohnwu.magisk.ui.base.MagiskFragment
import
com.topjohnwu.magisk.ui.base.MagiskFragment
import
com.topjohnwu.magisk.ui.flash.FlashActivity
import
com.topjohnwu.magisk.ui.flash.FlashActivity
import
com.topjohnwu.magisk.utils.
RootUtils
import
com.topjohnwu.magisk.utils.
reboot
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
org.koin.androidx.viewmodel.ext.android.sharedViewModel
import
org.koin.androidx.viewmodel.ext.android.sharedViewModel
...
@@ -64,19 +64,20 @@ class ModulesFragment : MagiskFragment<ModuleViewModel, FragmentModulesBinding>(
...
@@ -64,19 +64,20 @@ class ModulesFragment : MagiskFragment<ModuleViewModel, FragmentModulesBinding>(
override
fun
onOptionsItemSelected
(
item
:
MenuItem
):
Boolean
{
override
fun
onOptionsItemSelected
(
item
:
MenuItem
):
Boolean
{
when
(
item
.
itemId
)
{
when
(
item
.
itemId
)
{
R
.
id
.
reboot
->
{
R
.
id
.
reboot
->
{
RootUtils
.
reboot
()
reboot
()
return
true
return
true
}
}
R
.
id
.
reboot_recovery
->
{
R
.
id
.
reboot_recovery
->
{
Shell
.
su
(
"/system/bin/reboot recovery"
).
submit
(
)
reboot
(
"recovery"
)
return
true
return
true
}
}
R
.
id
.
reboot_bootloader
->
{
R
.
id
.
reboot_bootloader
->
{
reboot
(
"booloader"
)
Shell
.
su
(
"/system/bin/reboot bootloader"
).
submit
()
Shell
.
su
(
"/system/bin/reboot bootloader"
).
submit
()
return
true
return
true
}
}
R
.
id
.
reboot_download
->
{
R
.
id
.
reboot_download
->
{
Shell
.
su
(
"/system/bin/reboot download"
).
submit
(
)
reboot
(
"download"
)
return
true
return
true
}
}
else
->
return
false
else
->
return
false
...
@@ -90,26 +91,4 @@ class ModulesFragment : MagiskFragment<ModuleViewModel, FragmentModulesBinding>(
...
@@ -90,26 +91,4 @@ class ModulesFragment : MagiskFragment<ModuleViewModel, FragmentModulesBinding>(
startActivityForResult
(
intent
,
Const
.
ID
.
FETCH_ZIP
)
startActivityForResult
(
intent
,
Const
.
ID
.
FETCH_ZIP
)
}
}
}
}
/*override fun getListeningEvents(): IntArray {
return intArrayOf(Event.MODULE_LOAD_DONE)
}
override fun onEvent(event: Int) {
updateUI(Event.getResult(event))
}*/
/*private fun updateUI(moduleMap: Map<String, Module>) {
listModules.clear()
listModules.addAll(moduleMap.values)
if (listModules.size == 0) {
emptyRv!!.visibility = View.VISIBLE
recyclerView!!.visibility = View.GONE
} else {
emptyRv!!.visibility = View.GONE
recyclerView!!.visibility = View.VISIBLE
recyclerView!!.adapter = ModulesAdapter(listModules)
}
mSwipeRefreshLayout!!.isRefreshing = false
}*/
}
}
app/src/main/java/com/topjohnwu/magisk/utils/RootUtils.kt
View file @
00bff491
...
@@ -155,10 +155,5 @@ class RootUtils : Shell.Initializer() {
...
@@ -155,10 +155,5 @@ class RootUtils : Shell.Initializer() {
fun
rmAndLaunch
(
rm
:
String
,
component
:
ComponentName
)
{
fun
rmAndLaunch
(
rm
:
String
,
component
:
ComponentName
)
{
Shell
.
su
(
"(rm_launch $rm ${component.flattenToString()})"
).
exec
()
Shell
.
su
(
"(rm_launch $rm ${component.flattenToString()})"
).
exec
()
}
}
@JvmStatic
fun
reboot
()
{
Shell
.
su
(
"/system/bin/reboot ${if (Info.recovery) "
recovery
" else ""}"
).
submit
()
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/utils/XSU.kt
View file @
00bff491
package
com.topjohnwu.magisk.utils
package
com.topjohnwu.magisk.utils
import
com.topjohnwu.magisk.Info
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.io.SuFileInputStream
import
com.topjohnwu.superuser.io.SuFileInputStream
import
com.topjohnwu.superuser.io.SuFileOutputStream
import
com.topjohnwu.superuser.io.SuFileOutputStream
import
java.io.File
import
java.io.File
fun
reboot
(
recovery
:
Boolean
=
false
):
Shell
.
Result
{
fun
reboot
(
reason
:
String
=
if
(
Info
.
recovery
)
"recovery"
else
""
)
{
val
command
=
StringBuilder
(
"/system/bin/reboot"
)
Shell
.
su
(
"/system/bin/svc power reboot $reason || /system/bin/reboot $reason"
).
submit
()
.
appendIf
(
recovery
)
{
append
(
" recovery"
)
}
.
toString
()
return
Shell
.
su
(
command
).
exec
()
}
}
fun
File
.
suOutputStream
()
=
SuFileOutputStream
(
this
)
fun
File
.
suOutputStream
()
=
SuFileOutputStream
(
this
)
...
...
app/src/main/java/com/topjohnwu/magisk/view/dialogs/EnvFixDialog.java
deleted
100644 → 0
View file @
0ce17205
package
com
.
topjohnwu
.
magisk
.
view
.
dialogs
;
import
android.app.Activity
;
import
android.app.ProgressDialog
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.tasks.MagiskInstaller
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.internal.UiThreadHandler
;
import
com.topjohnwu.superuser.io.SuFile
;
public
class
EnvFixDialog
extends
CustomAlertDialog
{
public
EnvFixDialog
(
@NonNull
Activity
activity
)
{
super
(
activity
);
setTitle
(
R
.
string
.
env_fix_title
);
setMessage
(
R
.
string
.
env_fix_msg
);
setCancelable
(
true
);
setPositiveButton
(
R
.
string
.
yes
,
(
d
,
i
)
->
{
ProgressDialog
pd
=
ProgressDialog
.
show
(
activity
,
activity
.
getString
(
R
.
string
.
setup_title
),
activity
.
getString
(
R
.
string
.
setup_msg
));
new
MagiskInstaller
()
{
@Override
protected
boolean
operations
()
{
installDir
=
new
SuFile
(
"/data/adb/magisk"
);
Shell
.
su
(
"rm -rf /data/adb/magisk/*"
).
exec
();
return
extractZip
()
&&
Shell
.
su
(
"fix_env"
).
exec
().
isSuccess
();
}
@Override
protected
void
onResult
(
boolean
success
)
{
pd
.
dismiss
();
Utils
.
INSTANCE
.
toast
(
success
?
R
.
string
.
reboot_delay_toast
:
R
.
string
.
setup_fail
,
Toast
.
LENGTH_LONG
);
if
(
success
)
UiThreadHandler
.
handler
.
postDelayed
(
RootUtils:
:
reboot
,
5000
);
}
}.
exec
();
});
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
}
}
app/src/main/java/com/topjohnwu/magisk/view/dialogs/EnvFixDialog.kt
0 → 100644
View file @
00bff491
package
com.topjohnwu.magisk.view.dialogs
import
android.app.Activity
import
android.app.ProgressDialog
import
android.widget.Toast
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.tasks.MagiskInstaller
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.reboot
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.internal.UiThreadHandler
import
com.topjohnwu.superuser.io.SuFile
class
EnvFixDialog
(
activity
:
Activity
)
:
CustomAlertDialog
(
activity
)
{
init
{
setTitle
(
R
.
string
.
env_fix_title
)
setMessage
(
R
.
string
.
env_fix_msg
)
setCancelable
(
true
)
setPositiveButton
(
R
.
string
.
yes
)
{
_
,
_
->
val
pd
=
ProgressDialog
.
show
(
activity
,
activity
.
getString
(
R
.
string
.
setup_title
),
activity
.
getString
(
R
.
string
.
setup_msg
))
object
:
MagiskInstaller
()
{
override
fun
operations
():
Boolean
{
installDir
=
SuFile
(
"/data/adb/magisk"
)
Shell
.
su
(
"rm -rf /data/adb/magisk/*"
).
exec
()
return
extractZip
()
&&
Shell
.
su
(
"fix_env"
).
exec
().
isSuccess
}
override
fun
onResult
(
success
:
Boolean
)
{
pd
.
dismiss
()
Utils
.
toast
(
if
(
success
)
R
.
string
.
reboot_delay_toast
else
R
.
string
.
setup_fail
,
Toast
.
LENGTH_LONG
)
if
(
success
)
UiThreadHandler
.
handler
.
postDelayed
({
reboot
()
},
5000
)
}
}.
exec
()
}
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
}
}
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