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
1d89fe50
Commit
1d89fe50
authored
Jan 29, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix manager hiding
Workaround bizarre optimization bugs
parent
788db036
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
PatchAPK.kt
...src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt
+7
-7
No files found.
app/src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt
View file @
1d89fe50
...
...
@@ -35,7 +35,7 @@ object PatchAPK {
val
ALPHANUM
=
ALPHA
+
DIGITS
private
val
ALPHANUMDOTS
=
"$ALPHANUM............"
private
fun
genPackageName
(
prefix
:
String
,
length
:
Int
):
String
{
private
fun
genPackageName
(
prefix
:
String
,
length
:
Int
):
CharSequence
{
val
builder
=
StringBuilder
(
length
)
builder
.
append
(
prefix
)
val
len
=
length
-
prefix
.
length
...
...
@@ -51,10 +51,10 @@ object PatchAPK {
builder
.
append
(
next
)
prev
=
next
}
return
builder
.
toString
()
return
builder
}
private
fun
findAndPatch
(
xml
:
ByteArray
,
from
:
String
,
to
:
String
):
Boolean
{
private
fun
findAndPatch
(
xml
:
ByteArray
,
from
:
CharSequence
,
to
:
CharSequence
):
Boolean
{
if
(
to
.
length
>
from
.
length
)
return
false
val
buf
=
ByteBuffer
.
wrap
(
xml
).
order
(
ByteOrder
.
LITTLE_ENDIAN
).
asCharBuffer
()
...
...
@@ -73,7 +73,7 @@ object PatchAPK {
if
(
offList
.
isEmpty
())
return
false
val
toBuf
=
to
.
toCharArray
().
copyOf
(
from
.
length
)
val
toBuf
=
to
.
to
String
().
to
CharArray
().
copyOf
(
from
.
length
)
for
(
off
in
offList
)
{
buf
.
position
(
off
)
buf
.
put
(
toBuf
)
...
...
@@ -113,7 +113,7 @@ object PatchAPK {
if
(!
Shell
.
su
(
"force_pm_install $repack"
).
exec
().
isSuccess
)
return
false
Config
.
suManager
=
pkg
Config
.
suManager
=
pkg
.
toString
()
Config
.
export
()
Shell
.
su
(
"pm uninstall ${BuildConfig.APPLICATION_ID}"
).
submit
()
...
...
@@ -122,7 +122,7 @@ object PatchAPK {
@JvmStatic
@JvmOverloads
fun
patch
(
apk
:
String
,
out
:
String
,
pkg
:
String
,
label
:
String
=
"Manager"
):
Boolean
{
fun
patch
(
apk
:
String
,
out
:
String
,
pkg
:
CharSequence
,
label
:
String
=
"Manager"
):
Boolean
{
try
{
val
jar
=
JarMap
.
open
(
apk
)
val
je
=
jar
.
getJarEntry
(
Const
.
ANDROID_MANIFEST
)
...
...
@@ -144,7 +144,7 @@ object PatchAPK {
return
true
}
fun
patch
(
apk
:
File
,
out
:
File
,
pkg
:
String
,
label
:
String
):
Boolean
{
fun
patch
(
apk
:
File
,
out
:
File
,
pkg
:
CharSequence
,
label
:
String
):
Boolean
{
try
{
if
(
apk
.
length
()
<
1
shl
18
)
{
// APK is smaller than 256K, must be stub
...
...
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