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
f8fcaadb
Commit
f8fcaadb
authored
Oct 23, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide manager with stub if feasible
parent
0b5fd3ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
UpdateInfo.kt
...main/java/com/topjohnwu/magisk/model/entity/UpdateInfo.kt
+8
-1
PatchAPK.kt
app/src/main/java/com/topjohnwu/magisk/utils/PatchAPK.kt
+23
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/model/entity/UpdateInfo.kt
View file @
f8fcaadb
...
@@ -8,7 +8,8 @@ import se.ansman.kotshi.JsonSerializable
...
@@ -8,7 +8,8 @@ import se.ansman.kotshi.JsonSerializable
data class
UpdateInfo
(
data class
UpdateInfo
(
val
app
:
ManagerJson
=
ManagerJson
(),
val
app
:
ManagerJson
=
ManagerJson
(),
val
uninstaller
:
UninstallerJson
=
UninstallerJson
(),
val
uninstaller
:
UninstallerJson
=
UninstallerJson
(),
val
magisk
:
MagiskJson
=
MagiskJson
()
val
magisk
:
MagiskJson
=
MagiskJson
(),
val
stub
:
StubJson
=
StubJson
()
)
)
@JsonSerializable
@JsonSerializable
...
@@ -33,3 +34,9 @@ data class ManagerJson(
...
@@ -33,3 +34,9 @@ data class ManagerJson(
val
link
:
String
=
""
,
val
link
:
String
=
""
,
val
note
:
String
=
""
val
note
:
String
=
""
)
:
Parcelable
)
:
Parcelable
@JsonSerializable
data class
StubJson
(
val
versionCode
:
Int
=
-
1
,
val
link
:
String
=
""
)
app/src/main/java/com/topjohnwu/magisk/utils/PatchAPK.kt
View file @
f8fcaadb
package
com.topjohnwu.magisk.utils
package
com.topjohnwu.magisk.utils
import
android.content.Context
import
android.content.Context
import
android.os.Build.VERSION.SDK_INT
import
android.widget.Toast
import
android.widget.Toast
import
com.topjohnwu.magisk.*
import
com.topjohnwu.magisk.*
import
com.topjohnwu.magisk.data.network.GithubRawServices
import
com.topjohnwu.magisk.extensions.DynamicClassLoader
import
com.topjohnwu.magisk.extensions.DynamicClassLoader
import
com.topjohnwu.magisk.extensions.get
import
com.topjohnwu.magisk.extensions.subscribeK
import
com.topjohnwu.magisk.extensions.subscribeK
import
com.topjohnwu.magisk.extensions.writeTo
import
com.topjohnwu.magisk.ui.SplashActivity
import
com.topjohnwu.magisk.ui.SplashActivity
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.signing.JarMap
import
com.topjohnwu.signing.JarMap
...
@@ -74,11 +78,28 @@ object PatchAPK {
...
@@ -74,11 +78,28 @@ object PatchAPK {
}
}
private
fun
patchAndHide
(
context
:
Context
,
label
:
String
):
Boolean
{
private
fun
patchAndHide
(
context
:
Context
,
label
:
String
):
Boolean
{
// If not running as stub, and we are compatible with stub, use stub
val
src
=
if
(!
isRunningAsStub
&&
SDK_INT
>=
28
&&
Info
.
env
.
connectionMode
==
3
)
{
val
stub
=
File
(
context
.
cacheDir
,
"stub.apk"
)
val
svc
=
get
<
GithubRawServices
>()
runCatching
{
svc
.
fetchFile
(
Info
.
remote
.
stub
.
link
).
blockingGet
().
byteStream
().
use
{
it
.
writeTo
(
stub
)
}
}.
onFailure
{
Timber
.
e
(
it
)
return
false
}
stub
.
path
}
else
{
context
.
packageCodePath
}
// Generate a new app with random package name
// Generate a new app with random package name
val
repack
=
File
(
context
.
files
Dir
,
"patched.apk"
)
val
repack
=
File
(
context
.
cache
Dir
,
"patched.apk"
)
val
pkg
=
genPackageName
(
"com."
,
BuildConfig
.
APPLICATION_ID
.
length
)
val
pkg
=
genPackageName
(
"com."
,
BuildConfig
.
APPLICATION_ID
.
length
)
if
(!
patch
(
context
.
packageCodePath
,
repack
.
path
,
pkg
,
label
))
if
(!
patch
(
src
,
repack
.
path
,
pkg
,
label
))
return
false
return
false
// Install the application
// Install the application
...
...
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