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
334beebf
Commit
334beebf
authored
Nov 18, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Not all devices work well with streaming
parent
13dad848
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
43 deletions
+41
-43
ProcessRepoZip.java
...main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
+37
-41
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+4
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
View file @
334beebf
...
...
@@ -49,12 +49,14 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
mHandler
=
new
Handler
();
}
private
void
removeTopFolder
(
InputStream
in
,
File
output
)
throws
IOException
{
JarInputStream
source
=
new
JarInputStream
(
in
);
JarOutputStream
dest
=
new
JarOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
output
)));
private
void
removeTopFolder
(
File
input
,
File
output
)
throws
IOException
{
JarEntry
entry
;
try
(
JarInputStream
in
=
new
JarInputStream
(
new
BufferedInputStream
(
new
FileInputStream
(
input
)));
JarOutputStream
out
=
new
JarOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
output
)))
)
{
String
path
;
while
((
entry
=
source
.
getNextJarEntry
())
!=
null
)
{
while
((
entry
=
in
.
getNextJarEntry
())
!=
null
)
{
// Remove the top directory from the path
path
=
entry
.
getName
().
substring
(
entry
.
getName
().
indexOf
(
"/"
)
+
1
);
// If it's the top folder, ignore it
...
...
@@ -65,12 +67,10 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
if
(
path
.
equals
(
"system/placeholder"
))
{
continue
;
}
dest
.
putNextEntry
(
new
JarEntry
(
path
));
Utils
.
inToOut
(
source
,
dest
);
out
.
putNextEntry
(
new
JarEntry
(
path
));
Utils
.
inToOut
(
in
,
out
);
}
}
source
.
close
();
dest
.
close
();
in
.
close
();
}
@Override
...
...
@@ -97,41 +97,37 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
break
;
}
while
(
true
);
InputStream
in
=
new
BufferedInputStream
(
new
ProgressInputStream
(
conn
.
getInputStream
()));
// Temp files
File
temp1
=
new
File
(
activity
.
getCacheDir
(),
"1.zip"
);
File
temp2
=
new
File
(
temp1
.
getParentFile
(),
"2.zip"
);
temp1
.
getParentFile
().
mkdir
();
// First remove top folder in Github source zip, Web -> temp1
removeTopFolder
(
in
,
temp1
);
// First download the zip, Web -> temp1
try
(
InputStream
in
=
new
BufferedInputStream
(
new
ProgressInputStream
(
conn
.
getInputStream
()));
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
temp1
))
)
{
Utils
.
inToOut
(
in
,
out
);
in
.
close
();
}
conn
.
disconnect
();
mHandler
.
post
(()
->
{
progressDialog
.
setTitle
(
R
.
string
.
zip_process_title
);
progressDialog
.
setMessage
(
getActivity
().
getString
(
R
.
string
.
zip_process_msg
));
});
//
Then sign the zip for the first time
, temp1 -> temp2
ZipUtils
.
signZip
(
temp1
,
temp2
,
false
);
//
First remove top folder in Github source zip
, temp1 -> temp2
removeTopFolder
(
temp1
,
temp2
);
//
Adjust the zip to prevent unzip issues
, temp2 -> temp1
ZipUtils
.
zipAdjust
(
temp2
.
getPath
(),
temp1
.
getPath
()
);
//
Then sign the zip for the first time
, temp2 -> temp1
ZipUtils
.
signZip
(
temp2
,
temp1
,
false
);
//
Finally, sign the whole zip file again
, temp1 -> temp2
ZipUtils
.
signZip
(
temp1
,
temp2
,
true
);
//
Adjust the zip to prevent unzip issues
, temp1 -> temp2
ZipUtils
.
zipAdjust
(
temp1
.
getPath
(),
temp2
.
getPath
()
);
// Write it to the target zip, temp2 -> file
try
(
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
mFile
));
InputStream
source
=
new
BufferedInputStream
(
new
FileInputStream
(
temp2
))
)
{
byte
[]
buffer
=
new
byte
[
4096
];
int
length
;
while
((
length
=
source
.
read
(
buffer
))
>
0
)
out
.
write
(
buffer
,
0
,
length
);
}
// Finally, sign the whole zip file again, temp2 -> target
ZipUtils
.
signZip
(
temp2
,
mFile
,
true
);
// Delete temp files
temp1
.
delete
();
...
...
@@ -149,8 +145,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
Activity
activity
=
getActivity
();
if
(
activity
==
null
)
return
;
progressDialog
.
dismiss
();
Uri
uri
=
Uri
.
fromFile
(
mFile
);
if
(
result
)
{
Uri
uri
=
Uri
.
fromFile
(
mFile
);
if
(
Shell
.
rootAccess
()
&&
mInstall
)
{
Intent
intent
=
new
Intent
(
activity
,
FlashActivity
.
class
);
intent
.
setData
(
uri
).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_ZIP
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
334beebf
...
...
@@ -225,13 +225,15 @@ public class Utils {
}
}
public
static
void
inToOut
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
int
read
;
public
static
int
inToOut
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
int
read
,
total
=
0
;
byte
buffer
[]
=
new
byte
[
4096
];
while
((
read
=
in
.
read
(
buffer
))
>
0
)
{
out
.
write
(
buffer
,
0
,
read
);
total
+=
read
;
}
out
.
flush
();
return
total
;
}
public
static
void
patchDTBO
()
{
...
...
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