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
403e30fe
Commit
403e30fe
authored
Nov 23, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add zipadjust JNI code
parent
f58c73b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
335 additions
and
9 deletions
+335
-9
.gitignore
.gitignore
+1
-0
CMakeLists.txt
app/CMakeLists.txt
+5
-0
build.gradle
app/build.gradle
+10
-0
ReposAdapter.java
...main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
+4
-6
ZipUtils.java
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
+8
-3
zipadjust.c
app/src/main/jni/zipadjust.c
+307
-0
No files found.
.gitignore
View file @
403e30fe
...
...
@@ -5,3 +5,4 @@
/build
app/app-release.apk
*.hprof
app/.externalNativeBuild/
app/CMakeLists.txt
0 → 100644
View file @
403e30fe
cmake_minimum_required
(
VERSION 3.6
)
add_library
(
zipadjust SHARED src/main/jni/zipadjust.c
)
find_library
(
libz z
)
find_library
(
liblog log
)
target_link_libraries
(
zipadjust
${
libz
}
${
liblog
}
)
\ No newline at end of file
app/build.gradle
View file @
403e30fe
...
...
@@ -13,6 +13,11 @@ android {
jackOptions
{
enabled
true
}
ndk
{
moduleName
'zipadjust'
// abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
abiFilters
'x86'
,
'x86_64'
,
'armeabi'
}
}
buildTypes
{
...
...
@@ -27,6 +32,11 @@ android {
dexOptions
{
preDexLibraries
=
false
}
externalNativeBuild
{
cmake
{
path
'CMakeLists.txt'
}
}
}
repositories
{
jcenter
()
...
...
app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
View file @
403e30fe
...
...
@@ -30,7 +30,6 @@ import com.topjohnwu.magisk.utils.ZipUtils;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.List
;
...
...
@@ -113,16 +112,15 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
// First remove top folder (the folder with the repo name) in Github source zip
ZipUtils
.
removeTopFolder
(
mContext
.
getContentResolver
().
openInputStream
(
uri
),
outBuffer
);
inBuffer
=
new
ByteArrayInputStream
(
outBuffer
.
toByteArray
()
.
clone
()
);
inBuffer
=
new
ByteArrayInputStream
(
outBuffer
.
toByteArray
());
outBuffer
.
reset
();
// Then sign the zip for the first time
ZipUtils
.
signZip
(
mContext
,
inBuffer
,
outBuffer
,
false
);
inBuffer
=
new
ByteArrayInputStream
(
outBuffer
.
toByteArray
().
clone
());
outBuffer
.
reset
();
// ZipAdjust to be placed here
// Call JNI for zipadjust...
// Call zipadjust through JNI
inBuffer
=
new
ByteArrayInputStream
(
ZipUtils
.
zipAdjust
(
outBuffer
.
toByteArray
(),
outBuffer
.
size
()));
outBuffer
.
reset
();
// Finally, sign the whole zip file again
ZipUtils
.
signZip
(
mContext
,
inBuffer
,
outBuffer
,
true
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
View file @
403e30fe
...
...
@@ -23,7 +23,6 @@ import org.spongycastle.util.encoders.Base64;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FilterOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -74,6 +73,14 @@ public class ZipUtils {
private
static
final
int
USE_SHA1
=
1
;
private
static
final
int
USE_SHA256
=
2
;
static
{
System
.
loadLibrary
(
"zipadjust"
);
sBouncyCastleProvider
=
new
BouncyCastleProvider
();
Security
.
insertProviderAt
(
sBouncyCastleProvider
,
1
);
}
public
native
static
byte
[]
zipAdjust
(
byte
[]
bytes
,
int
size
);
public
static
void
removeTopFolder
(
InputStream
in
,
OutputStream
out
)
{
try
{
JarInputStream
source
=
new
JarInputStream
(
in
);
...
...
@@ -106,8 +113,6 @@ public class ZipUtils {
public
static
void
signZip
(
Context
context
,
InputStream
inputStream
,
OutputStream
outputStream
,
boolean
signWholeFile
)
{
sBouncyCastleProvider
=
new
BouncyCastleProvider
();
Security
.
insertProviderAt
(
sBouncyCastleProvider
,
1
);
JarMap
inputJar
;
int
hashes
=
0
;
try
{
...
...
app/src/main/jni/zipadjust.c
0 → 100644
View file @
403e30fe
This diff is collapsed.
Click to expand it.
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