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
5f22d3e0
Commit
5f22d3e0
authored
Oct 31, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support new xml binary format
parent
fdd700f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
HideManager.java
...rc/main/java/com/topjohnwu/magisk/asyncs/HideManager.java
+27
-5
No files found.
app/src/main/java/com/topjohnwu/magisk/asyncs/HideManager.java
View file @
5f22d3e0
...
...
@@ -43,13 +43,12 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
return
builder
.
toString
();
}
private
boolean
findAndPatch
(
byte
xml
[],
String
from
,
String
to
)
{
private
int
findOffset
(
byte
buf
[],
byte
pattern
[]
)
{
int
offset
=
-
1
;
byte
target
[]
=
(
from
+
'\0'
).
getBytes
();
for
(
int
i
=
0
;
i
<
xml
.
length
-
target
.
length
;
++
i
)
{
for
(
int
i
=
0
;
i
<
buf
.
length
-
pattern
.
length
;
++
i
)
{
boolean
match
=
true
;
for
(
int
j
=
0
;
j
<
target
.
length
;
++
j
)
{
if
(
xml
[
i
+
j
]
!=
target
[
j
])
{
for
(
int
j
=
0
;
j
<
pattern
.
length
;
++
j
)
{
if
(
buf
[
i
+
j
]
!=
pattern
[
j
])
{
match
=
false
;
break
;
}
...
...
@@ -59,9 +58,32 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
break
;
}
}
return
offset
;
}
/* It seems that AAPT sometimes generate another type of string format */
private
boolean
fallbackPatch
(
byte
xml
[],
String
from
,
String
to
)
{
byte
[]
target
=
new
byte
[
from
.
length
()
*
2
+
2
];
for
(
int
i
=
0
;
i
<
from
.
length
();
++
i
)
{
target
[
i
*
2
]
=
(
byte
)
from
.
charAt
(
i
);
}
int
offset
=
findOffset
(
xml
,
target
);
if
(
offset
<
0
)
return
false
;
byte
[]
dest
=
new
byte
[
target
.
length
-
2
];
for
(
int
i
=
0
;
i
<
to
.
length
();
++
i
)
{
dest
[
i
*
2
]
=
(
byte
)
to
.
charAt
(
i
);
}
System
.
arraycopy
(
dest
,
0
,
xml
,
offset
,
dest
.
length
);
return
true
;
}
private
boolean
findAndPatch
(
byte
xml
[],
String
from
,
String
to
)
{
byte
target
[]
=
(
from
+
'\0'
).
getBytes
();
int
offset
=
findOffset
(
xml
,
target
);
if
(
offset
<
0
)
return
fallbackPatch
(
xml
,
from
,
to
);
System
.
arraycopy
(
to
.
getBytes
(),
0
,
xml
,
offset
,
to
.
length
());
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