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
b3328a0e
Commit
b3328a0e
authored
Jan 01, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure shell command won't block
parent
3c204193
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
19 deletions
+37
-19
Config.kt
app/src/main/java/com/topjohnwu/magisk/Config.kt
+3
-0
Info.kt
app/src/main/java/com/topjohnwu/magisk/Info.kt
+18
-0
PolicyDao.kt
...main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt
+1
-1
SettingsDao.kt
...in/java/com/topjohnwu/magisk/data/database/SettingsDao.kt
+1
-1
StringDao.kt
...main/java/com/topjohnwu/magisk/data/database/StringDao.kt
+1
-1
SplashActivity.kt
app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.kt
+13
-7
RootInit.kt
app/src/main/java/com/topjohnwu/magisk/utils/RootInit.kt
+0
-9
No files found.
app/src/main/java/com/topjohnwu/magisk/Config.kt
View file @
b3328a0e
...
...
@@ -48,6 +48,7 @@ object Config : PreferenceModel, DBConfig {
const
val
REPO_ORDER
=
"repo_order"
const
val
SHOW_SYSTEM_APP
=
"show_system"
const
val
DOWNLOAD_PATH
=
"download_path"
const
val
BOOT_ID
=
"boot_id"
// system state
const
val
MAGISKHIDE
=
"magiskhide"
...
...
@@ -105,6 +106,8 @@ object Config : PreferenceModel, DBConfig {
}
else
Value
.
DEFAULT_CHANNEL
var
bootId
by
preference
(
Key
.
BOOT_ID
,
""
)
var
downloadPath
by
preference
(
Key
.
DOWNLOAD_PATH
,
Environment
.
DIRECTORY_DOWNLOADS
)
var
repoOrder
by
preference
(
Key
.
REPO_ORDER
,
Value
.
ORDER_DATE
)
...
...
app/src/main/java/com/topjohnwu/magisk/Info.kt
View file @
b3328a0e
...
...
@@ -8,6 +8,8 @@ import com.topjohnwu.magisk.utils.CachedValue
import
com.topjohnwu.magisk.utils.KObservableField
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.ShellUtils
import
java.io.FileInputStream
import
java.io.IOException
val
isRunningAsStub
get
()
=
Info
.
stub
!=
null
...
...
@@ -32,6 +34,22 @@ object Info {
}
}
val
isNewReboot
by
lazy
{
try
{
FileInputStream
(
"/proc/sys/kernel/random/boot_id"
).
bufferedReader
().
use
{
val
id
=
it
.
readLine
()
if
(
id
!=
Config
.
bootId
)
{
Config
.
bootId
=
id
true
}
else
{
false
}
}
}
catch
(
e
:
IOException
)
{
false
}
}
private
fun
loadState
()
=
runCatching
{
val
str
=
ShellUtils
.
fastCmd
(
"magisk -v"
).
split
(
":"
.
toRegex
())[
0
]
val
code
=
ShellUtils
.
fastCmd
(
"magisk -V"
).
toInt
()
...
...
app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt
View file @
b3328a0e
...
...
@@ -3,8 +3,8 @@ package com.topjohnwu.magisk.data.database
import
android.content.Context
import
android.content.pm.PackageManager
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.data.database.magiskdb.Delete
import
com.topjohnwu.magisk.data.database.magiskdb.BaseDao
import
com.topjohnwu.magisk.data.database.magiskdb.Delete
import
com.topjohnwu.magisk.data.database.magiskdb.Replace
import
com.topjohnwu.magisk.data.database.magiskdb.Select
import
com.topjohnwu.magisk.extensions.now
...
...
app/src/main/java/com/topjohnwu/magisk/data/database/SettingsDao.kt
View file @
b3328a0e
package
com.topjohnwu.magisk.data.database
import
com.topjohnwu.magisk.data.database.magiskdb.Delete
import
com.topjohnwu.magisk.data.database.magiskdb.BaseDao
import
com.topjohnwu.magisk.data.database.magiskdb.Delete
import
com.topjohnwu.magisk.data.database.magiskdb.Replace
import
com.topjohnwu.magisk.data.database.magiskdb.Select
...
...
app/src/main/java/com/topjohnwu/magisk/data/database/StringDao.kt
View file @
b3328a0e
package
com.topjohnwu.magisk.data.database
import
com.topjohnwu.magisk.data.database.magiskdb.Delete
import
com.topjohnwu.magisk.data.database.magiskdb.BaseDao
import
com.topjohnwu.magisk.data.database.magiskdb.Delete
import
com.topjohnwu.magisk.data.database.magiskdb.Replace
import
com.topjohnwu.magisk.data.database.magiskdb.Select
...
...
app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.kt
View file @
b3328a0e
...
...
@@ -3,14 +3,12 @@ package com.topjohnwu.magisk.ui
import
android.app.Activity
import
android.content.Context
import
android.os.Bundle
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.intent
import
com.topjohnwu.magisk.*
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Shortcuts
import
com.topjohnwu.magisk.wrap
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.ShellUtils
open
class
SplashActivity
:
Activity
()
{
...
...
@@ -37,6 +35,10 @@ open class SplashActivity : Activity() {
}
}
Info
.
keepVerity
=
ShellUtils
.
fastCmd
(
"echo \$KEEPVERITY"
).
toBoolean
()
Info
.
keepEnc
=
ShellUtils
.
fastCmd
(
"echo \$KEEPFORCEENCRYPT"
).
toBoolean
()
Info
.
recovery
=
ShellUtils
.
fastCmd
(
"echo \$RECOVERYMODE"
).
toBoolean
()
// Set default configs
Config
.
initialize
()
...
...
@@ -49,9 +51,13 @@ open class SplashActivity : Activity() {
// Setup shortcuts
Shortcuts
.
setup
(
this
)
Shell
.
su
(
"mm_patch_dtb"
).
submit
{
if
(
Info
.
isNewReboot
)
{
val
shell
=
Shell
.
newInstance
()
shell
.
newJob
().
add
(
"mm_patch_dtb"
).
submit
{
if
(
it
.
isSuccess
)
Notifications
.
dtboPatched
(
this
)
shell
.
close
()
}
}
DONE
=
true
...
...
app/src/main/java/com/topjohnwu/magisk/utils/RootInit.kt
View file @
b3328a0e
...
...
@@ -2,12 +2,10 @@ package com.topjohnwu.magisk.utils
import
android.content.Context
import
com.topjohnwu.magisk.Const
import
com.topjohnwu.magisk.Info
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.extensions.rawResource
import
com.topjohnwu.magisk.wrap
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.ShellUtils
import
com.topjohnwu.superuser.io.SuFile
class
RootInit
:
Shell
.
Initializer
()
{
...
...
@@ -17,9 +15,6 @@ class RootInit : Shell.Initializer() {
}
fun
init
(
context
:
Context
,
shell
:
Shell
):
Boolean
{
// Invalidate env state if shell is recreated
Info
.
envRef
.
invalidate
()
val
job
=
shell
.
newJob
()
if
(
shell
.
isRoot
)
{
job
.
add
(
context
.
rawResource
(
R
.
raw
.
util_functions
))
...
...
@@ -36,10 +31,6 @@ class RootInit : Shell.Initializer() {
"export BOOTMODE=true"
).
exec
()
Info
.
keepVerity
=
ShellUtils
.
fastCmd
(
"echo \$KEEPVERITY"
).
toBoolean
()
Info
.
keepEnc
=
ShellUtils
.
fastCmd
(
"echo \$KEEPFORCEENCRYPT"
).
toBoolean
()
Info
.
recovery
=
ShellUtils
.
fastCmd
(
"echo \$RECOVERYMODE"
).
toBoolean
()
return
true
}
}
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