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
9d5efea6
Commit
9d5efea6
authored
Jan 24, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove ManagerJson
Everything is now Magisk
parent
658d74e0
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
84 additions
and
117 deletions
+84
-117
UpdateCheckService.kt
...main/java/com/topjohnwu/magisk/core/UpdateCheckService.kt
+4
-11
Subject.kt
...c/main/java/com/topjohnwu/magisk/core/download/Subject.kt
+4
-4
UpdateInfo.kt
...c/main/java/com/topjohnwu/magisk/core/model/UpdateInfo.kt
+1
-10
HideAPK.kt
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
+1
-1
NetworkService.kt
...va/com/topjohnwu/magisk/data/repository/NetworkService.kt
+4
-4
ViewEvents.kt
app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt
+9
-7
ManagerInstallDialog.kt
...om/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt
+10
-21
MarkDownDialog.kt
...java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt
+48
-0
ModuleViewModel.kt
...in/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
+2
-4
SettingsItems.kt
...in/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
+1
-1
MarkDownWindow.kt
...src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt
+0
-54
No files found.
app/src/main/java/com/topjohnwu/magisk/core/UpdateCheckService.kt
View file @
9d5efea6
package
com.topjohnwu.magisk.core
package
com.topjohnwu.magisk.core
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Context
import
androidx.work.*
import
androidx.work.*
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.data.repository.NetworkService
import
com.topjohnwu.magisk.data.repository.NetworkService
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.superuser.Shell
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
org.koin.core.KoinComponent
import
org.koin.core.KoinComponent
import
org.koin.core.inject
import
org.koin.core.inject
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
...
@@ -18,20 +16,15 @@ class UpdateCheckService(context: Context, workerParams: WorkerParameters)
...
@@ -18,20 +16,15 @@ class UpdateCheckService(context: Context, workerParams: WorkerParameters)
private
val
svc
:
NetworkService
by
inject
()
private
val
svc
:
NetworkService
by
inject
()
override
suspend
fun
doWork
():
Result
{
override
suspend
fun
doWork
():
Result
{
// Make sure shell initializer was ran
return
svc
.
fetchUpdate
()
?.
run
{
withContext
(
Dispatchers
.
IO
)
{
if
(
Info
.
env
.
isActive
&&
BuildConfig
.
VERSION_CODE
<
magisk
.
versionCode
)
Shell
.
getShell
()
}
return
svc
.
fetchUpdate
()
?.
let
{
if
(
BuildConfig
.
VERSION_CODE
<
it
.
app
.
versionCode
)
Notifications
.
managerUpdate
(
applicationContext
)
Notifications
.
managerUpdate
(
applicationContext
)
else
if
(
Info
.
env
.
isActive
&&
Info
.
env
.
magiskVersionCode
<
it
.
magisk
.
versionCode
)
Notifications
.
magiskUpdate
(
applicationContext
)
Result
.
success
()
Result
.
success
()
}
?:
Result
.
failure
()
}
?:
Result
.
failure
()
}
}
companion
object
{
companion
object
{
@SuppressLint
(
"NewApi"
)
fun
schedule
(
context
:
Context
)
{
fun
schedule
(
context
:
Context
)
{
if
(
Config
.
checkUpdate
)
{
if
(
Config
.
checkUpdate
)
{
val
constraints
=
Constraints
.
Builder
()
val
constraints
=
Constraints
.
Builder
()
...
...
app/src/main/java/com/topjohnwu/magisk/core/download/Subject.kt
View file @
9d5efea6
...
@@ -5,7 +5,7 @@ import android.net.Uri
...
@@ -5,7 +5,7 @@ import android.net.Uri
import
android.os.Parcelable
import
android.os.Parcelable
import
androidx.core.net.toUri
import
androidx.core.net.toUri
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.model.Ma
nager
Json
import
com.topjohnwu.magisk.core.model.Ma
gisk
Json
import
com.topjohnwu.magisk.core.model.StubJson
import
com.topjohnwu.magisk.core.model.StubJson
import
com.topjohnwu.magisk.core.model.module.OnlineModule
import
com.topjohnwu.magisk.core.model.module.OnlineModule
import
com.topjohnwu.magisk.core.utils.MediaStoreUtils
import
com.topjohnwu.magisk.core.utils.MediaStoreUtils
...
@@ -39,12 +39,12 @@ sealed class Subject : Parcelable {
...
@@ -39,12 +39,12 @@ sealed class Subject : Parcelable {
@Parcelize
@Parcelize
class
Manager
(
class
Manager
(
private
val
app
:
ManagerJson
=
Info
.
remote
.
app
,
private
val
json
:
MagiskJson
=
Info
.
remote
.
magisk
,
val
stub
:
StubJson
=
Info
.
remote
.
stub
val
stub
:
StubJson
=
Info
.
remote
.
stub
)
:
Subject
()
{
)
:
Subject
()
{
override
val
action
get
()
=
Action
.
Download
override
val
action
get
()
=
Action
.
Download
override
val
title
:
String
get
()
=
"Magisk
Manager-${app.version}(${app
.versionCode})"
override
val
title
:
String
get
()
=
"Magisk
-${json.version}(${json
.versionCode})"
override
val
url
:
String
get
()
=
app
.
link
override
val
url
:
String
get
()
=
json
.
link
@IgnoredOnParcel
@IgnoredOnParcel
override
val
file
by
lazy
{
override
val
file
by
lazy
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/model/UpdateInfo.kt
View file @
9d5efea6
...
@@ -6,11 +6,11 @@ import kotlinx.parcelize.Parcelize
...
@@ -6,11 +6,11 @@ import kotlinx.parcelize.Parcelize
@JsonClass
(
generateAdapter
=
true
)
@JsonClass
(
generateAdapter
=
true
)
data class
UpdateInfo
(
data class
UpdateInfo
(
val
app
:
ManagerJson
=
ManagerJson
(),
val
magisk
:
MagiskJson
=
MagiskJson
(),
val
magisk
:
MagiskJson
=
MagiskJson
(),
val
stub
:
StubJson
=
StubJson
()
val
stub
:
StubJson
=
StubJson
()
)
)
@Parcelize
@JsonClass
(
generateAdapter
=
true
)
@JsonClass
(
generateAdapter
=
true
)
data class
MagiskJson
(
data class
MagiskJson
(
val
version
:
String
=
""
,
val
version
:
String
=
""
,
...
@@ -18,15 +18,6 @@ data class MagiskJson(
...
@@ -18,15 +18,6 @@ data class MagiskJson(
val
link
:
String
=
""
,
val
link
:
String
=
""
,
val
note
:
String
=
""
,
val
note
:
String
=
""
,
val
md5
:
String
=
""
val
md5
:
String
=
""
)
@Parcelize
@JsonClass
(
generateAdapter
=
true
)
data class
ManagerJson
(
val
version
:
String
=
""
,
val
versionCode
:
Int
=
-
1
,
val
link
:
String
=
""
,
val
note
:
String
=
""
)
:
Parcelable
)
:
Parcelable
@Parcelize
@Parcelize
...
...
app/src/main/java/com/topjohnwu/magisk/core/tasks/HideAPK.kt
View file @
9d5efea6
...
@@ -148,7 +148,7 @@ object HideAPK {
...
@@ -148,7 +148,7 @@ object HideAPK {
}
else
{
}
else
{
File
(
context
.
cacheDir
,
"manager.apk"
).
also
{
apk
->
File
(
context
.
cacheDir
,
"manager.apk"
).
also
{
apk
->
try
{
try
{
svc
.
fetchFile
(
Info
.
remote
.
app
.
link
).
byteStream
().
writeTo
(
apk
)
svc
.
fetchFile
(
Info
.
remote
.
magisk
.
link
).
byteStream
().
writeTo
(
apk
)
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
Timber
.
e
(
e
)
Timber
.
e
(
e
)
return
false
return
false
...
...
app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt
View file @
9d5efea6
...
@@ -8,7 +8,9 @@ import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL
...
@@ -8,7 +8,9 @@ import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL
import
com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL
import
com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.model.*
import
com.topjohnwu.magisk.core.model.MagiskJson
import
com.topjohnwu.magisk.core.model.StubJson
import
com.topjohnwu.magisk.core.model.UpdateInfo
import
com.topjohnwu.magisk.data.network.*
import
com.topjohnwu.magisk.data.network.*
import
retrofit2.HttpException
import
retrofit2.HttpException
import
timber.log.Timber
import
timber.log.Timber
...
@@ -47,14 +49,12 @@ class NetworkService(
...
@@ -47,14 +49,12 @@ class NetworkService(
val
info
=
jsd
.
fetchCanaryUpdate
(
sha
)
val
info
=
jsd
.
fetchCanaryUpdate
(
sha
)
fun
genCDNUrl
(
name
:
String
)
=
"${Const.Url.JS_DELIVR_URL}${MAGISK_FILES}@${sha}/${name}"
fun
genCDNUrl
(
name
:
String
)
=
"${Const.Url.JS_DELIVR_URL}${MAGISK_FILES}@${sha}/${name}"
fun
ManagerJson
.
updateCopy
()
=
copy
(
link
=
genCDNUrl
(
link
),
note
=
genCDNUrl
(
note
))
fun
MagiskJson
.
updateCopy
()
=
copy
(
link
=
genCDNUrl
(
link
),
note
=
genCDNUrl
(
note
))
fun
MagiskJson
.
updateCopy
()
=
copy
(
link
=
genCDNUrl
(
link
),
note
=
genCDNUrl
(
note
))
fun
StubJson
.
updateCopy
()
=
copy
(
link
=
genCDNUrl
(
link
))
fun
StubJson
.
updateCopy
()
=
copy
(
link
=
genCDNUrl
(
link
))
return
info
.
copy
(
return
info
.
copy
(
app
=
info
.
app
.
updateCopy
(),
magisk
=
info
.
magisk
.
updateCopy
(),
magisk
=
info
.
magisk
.
updateCopy
(),
stub
=
info
.
stub
.
updateCopy
()
,
stub
=
info
.
stub
.
updateCopy
()
)
)
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/ViewEvents.kt
View file @
9d5efea6
...
@@ -14,20 +14,22 @@ import com.topjohnwu.magisk.core.Const
...
@@ -14,20 +14,22 @@ import com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.base.ActivityResultCallback
import
com.topjohnwu.magisk.core.base.ActivityResultCallback
import
com.topjohnwu.magisk.core.base.BaseActivity
import
com.topjohnwu.magisk.core.base.BaseActivity
import
com.topjohnwu.magisk.core.model.module.OnlineModule
import
com.topjohnwu.magisk.core.model.module.OnlineModule
import
com.topjohnwu.magisk.events.dialog.MarkDownDialog
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.view.Ma
rkDownWindow
import
com.topjohnwu.magisk.view.Ma
giskDialog
import
com.topjohnwu.magisk.view.Shortcuts
import
com.topjohnwu.magisk.view.Shortcuts
import
kotlinx.coroutines.launch
class
ViewActionEvent
(
val
action
:
BaseActivity
.()
->
Unit
)
:
ViewEvent
(),
ActivityExecutor
{
class
ViewActionEvent
(
val
action
:
BaseActivity
.()
->
Unit
)
:
ViewEvent
(),
ActivityExecutor
{
override
fun
invoke
(
activity
:
BaseUIActivity
<
*
,
*
>)
=
action
(
activity
)
override
fun
invoke
(
activity
:
BaseUIActivity
<
*
,
*
>)
=
action
(
activity
)
}
}
class
OpenReadmeEvent
(
val
item
:
OnlineModule
)
:
ViewEventWithScope
(),
ContextExecutor
{
class
OpenReadmeEvent
(
private
val
item
:
OnlineModule
)
:
MarkDownDialog
()
{
override
fun
invoke
(
context
:
Context
)
{
override
suspend
fun
getMarkdownText
()
=
item
.
notes
()
scope
.
launch
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
MarkDownWindow
.
show
(
context
,
null
,
item
::
notes
)
super
.
build
(
dialog
)
}
dialog
.
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
android
.
R
.
string
.
cancel
}.
cancellable
(
true
)
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt
View file @
9d5efea6
...
@@ -4,37 +4,26 @@ import com.topjohnwu.magisk.R
...
@@ -4,37 +4,26 @@ import com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.Subject
import
com.topjohnwu.magisk.core.download.Subject
import
com.topjohnwu.magisk.
ktx.res
import
com.topjohnwu.magisk.
data.repository.NetworkService
import
com.topjohnwu.magisk.view.MagiskDialog
import
com.topjohnwu.magisk.view.MagiskDialog
import
com.topjohnwu.magisk.view.MarkDownWindow
import
org.koin.core.inject
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.launch
class
ManagerInstallDialog
:
DialogEvent
()
{
class
ManagerInstallDialog
:
MarkDownDialog
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
private
val
svc
:
NetworkService
by
inject
()
with
(
dialog
)
{
val
subject
=
Subject
.
Manager
()
applyTitle
(
R
.
string
.
repo_install_title
.
res
(
R
.
string
.
app_name
.
res
()))
override
suspend
fun
getMarkdownText
()
=
svc
.
fetchString
(
Info
.
remote
.
magisk
.
note
)
applyMessage
(
R
.
string
.
repo_install_msg
.
res
(
subject
.
title
))
override
fun
build
(
dialog
:
MagiskDialog
)
{
super
.
build
(
dialog
)
with
(
dialog
)
{
setCancelable
(
true
)
setCancelable
(
true
)
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
R
.
string
.
install
titleRes
=
R
.
string
.
install
onClick
{
DownloadService
.
start
(
context
,
subject
)
}
onClick
{
DownloadService
.
start
(
context
,
Subject
.
Manager
()
)
}
}
}
if
(
Info
.
remote
.
app
.
note
.
isEmpty
())
return
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
R
.
string
.
app_changelog
titleRes
=
android
.
R
.
string
.
cancel
onClick
{
GlobalScope
.
launch
(
Dispatchers
.
Main
.
immediate
)
{
MarkDownWindow
.
show
(
context
,
null
,
Info
.
remote
.
app
.
note
)
}
}
}
}
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt
0 → 100644
View file @
9d5efea6
package
com.topjohnwu.magisk.events.dialog
import
android.view.LayoutInflater
import
android.widget.TextView
import
androidx.annotation.CallSuper
import
androidx.lifecycle.lifecycleScope
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.base.BaseActivity
import
com.topjohnwu.magisk.ktx.coroutineScope
import
com.topjohnwu.magisk.view.MagiskDialog
import
io.noties.markwon.Markwon
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
org.koin.core.KoinComponent
import
org.koin.core.inject
import
timber.log.Timber
import
kotlin.coroutines.cancellation.CancellationException
abstract
class
MarkDownDialog
:
DialogEvent
(),
KoinComponent
{
private
val
markwon
:
Markwon
by
inject
()
abstract
suspend
fun
getMarkdownText
():
String
@CallSuper
override
fun
build
(
dialog
:
MagiskDialog
)
{
with
(
dialog
)
{
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
markdown_window_md2
,
null
)
applyView
(
view
)
(
ownerActivity
as
BaseActivity
).
lifecycleScope
.
launch
{
val
tv
=
view
.
findViewById
<
TextView
>(
R
.
id
.
md_txt
)
tv
.
coroutineScope
=
CoroutineScope
(
coroutineContext
)
withContext
(
Dispatchers
.
IO
)
{
try
{
markwon
.
setMarkdown
(
tv
,
getMarkdownText
())
}
catch
(
e
:
Exception
)
{
if
(
e
is
CancellationException
)
throw
e
Timber
.
e
(
e
)
tv
.
post
{
tv
.
setText
(
R
.
string
.
download_file_error
)
}
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt
View file @
9d5efea6
...
@@ -313,10 +313,8 @@ class ModuleViewModel(
...
@@ -313,10 +313,8 @@ class ModuleViewModel(
fun
infoPressed
(
item
:
ModuleItem
)
{
fun
infoPressed
(
item
:
ModuleItem
)
{
item
.
repo
?.
also
{
item
.
repo
?.
also
{
if
(
isConnected
.
get
())
if
(
isConnected
.
get
())
OpenReadmeEvent
(
it
).
publish
()
OpenReadmeEvent
(
it
).
publish
()
else
SnackbarEvent
(
R
.
string
.
no_connection
).
publish
()
else
SnackbarEvent
(
R
.
string
.
no_connection
).
publish
()
}
?:
return
}
?:
return
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt
View file @
9d5efea6
...
@@ -109,7 +109,7 @@ object Restore : BaseSettingsItem.Blank() {
...
@@ -109,7 +109,7 @@ object Restore : BaseSettingsItem.Blank() {
override
val
title
=
R
.
string
.
settings_restore_manager_title
.
asTransitive
()
override
val
title
=
R
.
string
.
settings_restore_manager_title
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_restore_manager_summary
.
asTransitive
()
override
val
description
=
R
.
string
.
settings_restore_manager_summary
.
asTransitive
()
override
fun
refresh
()
{
override
fun
refresh
()
{
isEnabled
=
Info
.
remote
.
app
.
versionCode
>
0
isEnabled
=
Info
.
remote
.
magisk
.
versionCode
>
0
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt
deleted
100644 → 0
View file @
658d74e0
package
com.topjohnwu.magisk.view
import
android.content.Context
import
android.view.LayoutInflater
import
android.widget.TextView
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.repository.NetworkService
import
com.topjohnwu.magisk.ktx.coroutineScope
import
io.noties.markwon.Markwon
import
kotlinx.coroutines.CancellationException
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
org.koin.core.KoinComponent
import
org.koin.core.inject
import
timber.log.Timber
import
kotlin.coroutines.coroutineContext
object
MarkDownWindow
:
KoinComponent
{
private
val
svc
:
NetworkService
by
inject
()
private
val
markwon
:
Markwon
by
inject
()
suspend
fun
show
(
activity
:
Context
,
title
:
String
?,
url
:
String
)
{
show
(
activity
,
title
)
{
svc
.
fetchString
(
url
)
}
}
suspend
fun
show
(
activity
:
Context
,
title
:
String
?,
input
:
suspend
()
->
String
)
{
val
view
=
LayoutInflater
.
from
(
activity
).
inflate
(
R
.
layout
.
markdown_window_md2
,
null
)
MagiskDialog
(
activity
)
.
applyTitle
(
title
?:
""
)
.
applyView
(
view
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
android
.
R
.
string
.
cancel
}
.
reveal
()
val
tv
=
view
.
findViewById
<
TextView
>(
R
.
id
.
md_txt
)
tv
.
coroutineScope
=
CoroutineScope
(
coroutineContext
)
withContext
(
Dispatchers
.
IO
)
{
try
{
markwon
.
setMarkdown
(
tv
,
input
())
}
catch
(
e
:
Exception
)
{
if
(
e
is
CancellationException
)
throw
e
Timber
.
e
(
e
)
tv
.
post
{
tv
.
setText
(
R
.
string
.
download_file_error
)
}
}
}
}
}
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