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
2a8477cb
Commit
2a8477cb
authored
Nov 20, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process zip with Java
parent
f5bee7b6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
35 deletions
+55
-35
README.md
README.md
+0
-6
ReposAdapter.java
...main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
+13
-26
DownloadReceiver.java
...java/com/topjohnwu/magisk/receivers/DownloadReceiver.java
+1
-0
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+1
-3
ZipUtils.java
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
+40
-0
libzip.so
app/src/main/jniLibs/armeabi/libzip.so
+0
-0
libzip.so
app/src/main/jniLibs/x86/libzip.so
+0
-0
No files found.
README.md
View file @
2a8477cb
...
@@ -6,9 +6,3 @@ I use Java 8 features, which requires Jack compiler and that's only available 2.
...
@@ -6,9 +6,3 @@ I use Java 8 features, which requires Jack compiler and that's only available 2.
### libbusybox.so
### libbusybox.so
Static BusyBox binary by @yashdsaraf
Static BusyBox binary by @yashdsaraf
Link and source: http://forum.xda-developers.com/showthread.php?t=3348543
Link and source: http://forum.xda-developers.com/showthread.php?t=3348543
### libzip.so
Static ndk-built info-zip
NDK makefiles: https://github.com/cloudchou/ndkzip
Info-Zip source: https://sourceforge.net/projects/infozip/
bzip2 source: http://www.bzip.org/
app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
View file @
2a8477cb
...
@@ -23,11 +23,13 @@ import com.topjohnwu.magisk.R;
...
@@ -23,11 +23,13 @@ import com.topjohnwu.magisk.R;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebWindow
;
import
com.topjohnwu.magisk.utils.WebWindow
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
java.io.File
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -102,30 +104,15 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
...
@@ -102,30 +104,15 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
new
DownloadReceiver
()
{
new
DownloadReceiver
()
{
@Override
@Override
public
void
task
(
Uri
uri
)
{
public
void
task
(
Uri
uri
)
{
new
Async
.
FlashZIP
(
context
,
uri
,
mFilename
)
{
try
{
/*
ByteArrayOutputStream
buffer
=
new
ByteArrayOutputStream
();
* !!! This method is now depreciated, will be replaced with new method !!!
InputStream
in
=
mContext
.
getContentResolver
().
openInputStream
(
uri
);
*/
ZipUtils
.
removeTopFolder
(
in
,
buffer
);
@Override
buffer
.
writeTo
(
mContext
.
getContentResolver
().
openOutputStream
(
uri
));
protected
void
preProcessing
()
throws
Throwable
{
}
catch
(
IOException
e
)
{
File
file
=
new
File
(
mUri
.
getPath
());
return
;
Shell
.
sh
(
}
"PATH="
+
context
.
getApplicationInfo
().
dataDir
+
"/tools:$PATH"
,
new
Async
.
FlashZIP
(
mContext
,
uri
,
mFilename
).
exec
();
"cd "
+
file
.
getParent
(),
"mkdir git"
,
"unzip -o "
+
file
+
" -d git"
,
"mv git/* install"
,
"cd install"
,
"rm -rf system/placeholder"
,
"chmod 644 $(find . -type f)"
,
"chmod 755 $(find . -type d)"
,
"rm -rf ../install.zip ../git"
,
"zip -r ../install.zip *"
,
"rm -rf ../install"
);
mUri
=
Uri
.
fromFile
(
new
File
(
file
.
getParent
()
+
"/install.zip"
));
}
}.
exec
();
}
}
},
},
repo
.
getZipUrl
(),
repo
.
getZipUrl
(),
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/DownloadReceiver.java
View file @
2a8477cb
...
@@ -40,6 +40,7 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
...
@@ -40,6 +40,7 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
}
}
context
.
unregisterReceiver
(
this
);
context
.
unregisterReceiver
(
this
);
}
}
c
.
close
();
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
2a8477cb
...
@@ -60,7 +60,6 @@ public class Async {
...
@@ -60,7 +60,6 @@ public class Async {
protected
Void
doInBackground
(
Void
...
voids
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
String
toolPath
=
mInfo
.
dataDir
+
"/tools"
;
String
toolPath
=
mInfo
.
dataDir
+
"/tools"
;
String
busybox
=
mInfo
.
dataDir
+
"/lib/libbusybox.so"
;
String
busybox
=
mInfo
.
dataDir
+
"/lib/libbusybox.so"
;
String
zip
=
mInfo
.
dataDir
+
"/lib/libzip.so"
;
if
(!
Utils
.
itemExist
(
false
,
toolPath
))
{
if
(!
Utils
.
itemExist
(
false
,
toolPath
))
{
Shell
.
sh
(
Shell
.
sh
(
"mkdir "
+
toolPath
,
"mkdir "
+
toolPath
,
...
@@ -70,8 +69,7 @@ public class Async {
...
@@ -70,8 +69,7 @@ public class Async {
"for tool in $(./busybox --list); do"
,
"for tool in $(./busybox --list); do"
,
"ln -s "
+
busybox
+
" $tool"
,
"ln -s "
+
busybox
+
" $tool"
,
"done"
,
"done"
,
"rm -f su sh"
,
"rm -f su sh"
"ln -s "
+
zip
+
" zip"
);
);
}
}
return
null
;
return
null
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
0 → 100644
View file @
2a8477cb
package
com
.
topjohnwu
.
magisk
.
utils
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
import
java.util.zip.ZipOutputStream
;
public
class
ZipUtils
{
public
static
void
removeTopFolder
(
InputStream
in
,
OutputStream
out
)
{
try
{
ZipInputStream
source
=
new
ZipInputStream
(
in
);
ZipOutputStream
dest
=
new
ZipOutputStream
(
out
);
ZipEntry
entry
;
String
path
;
int
size
;
byte
buffer
[]
=
new
byte
[
2048
];
while
((
entry
=
source
.
getNextEntry
())
!=
null
)
{
// Remove the top directory from the path
path
=
entry
.
toString
().
substring
(
entry
.
toString
().
indexOf
(
"/"
)
+
1
);
// If it's the top folder, ignore it
if
(
path
.
isEmpty
())
continue
;
// Don't include placeholder
if
(
path
.
contains
(
"system/placeholder"
))
continue
;
dest
.
putNextEntry
(
new
ZipEntry
(
path
));
while
((
size
=
source
.
read
(
buffer
,
0
,
2048
))
!=
-
1
)
dest
.
write
(
buffer
,
0
,
size
);
}
source
.
close
();
dest
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
Logger
.
dev
(
"ZipUtils: removeTopFolder IO error!"
);
}
}
}
app/src/main/jniLibs/armeabi/libzip.so
deleted
100644 → 0
View file @
f5bee7b6
File deleted
app/src/main/jniLibs/x86/libzip.so
deleted
100644 → 0
View file @
f5bee7b6
File deleted
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