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> {
...
@@ -49,12 +49,14 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
mHandler
=
new
Handler
();
mHandler
=
new
Handler
();
}
}
private
void
removeTopFolder
(
InputStream
in
,
File
output
)
throws
IOException
{
private
void
removeTopFolder
(
File
input
,
File
output
)
throws
IOException
{
JarInputStream
source
=
new
JarInputStream
(
in
);
JarOutputStream
dest
=
new
JarOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
output
)));
JarEntry
entry
;
JarEntry
entry
;
try
(
JarInputStream
in
=
new
JarInputStream
(
new
BufferedInputStream
(
new
FileInputStream
(
input
)));
JarOutputStream
out
=
new
JarOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
output
)))
)
{
String
path
;
String
path
;
while
((
entry
=
source
.
getNextJarEntry
())
!=
null
)
{
while
((
entry
=
in
.
getNextJarEntry
())
!=
null
)
{
// Remove the top directory from the path
// Remove the top directory from the path
path
=
entry
.
getName
().
substring
(
entry
.
getName
().
indexOf
(
"/"
)
+
1
);
path
=
entry
.
getName
().
substring
(
entry
.
getName
().
indexOf
(
"/"
)
+
1
);
// If it's the top folder, ignore it
// If it's the top folder, ignore it
...
@@ -65,12 +67,10 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
...
@@ -65,12 +67,10 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
if
(
path
.
equals
(
"system/placeholder"
))
{
if
(
path
.
equals
(
"system/placeholder"
))
{
continue
;
continue
;
}
}
dest
.
putNextEntry
(
new
JarEntry
(
path
));
out
.
putNextEntry
(
new
JarEntry
(
path
));
Utils
.
inToOut
(
source
,
dest
);
Utils
.
inToOut
(
in
,
out
);
}
}
}
source
.
close
();
dest
.
close
();
in
.
close
();
}
}
@Override
@Override
...
@@ -97,41 +97,37 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
...
@@ -97,41 +97,37 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
break
;
break
;
}
while
(
true
);
}
while
(
true
);
InputStream
in
=
new
BufferedInputStream
(
new
ProgressInputStream
(
conn
.
getInputStream
()));
// Temp files
// Temp files
File
temp1
=
new
File
(
activity
.
getCacheDir
(),
"1.zip"
);
File
temp1
=
new
File
(
activity
.
getCacheDir
(),
"1.zip"
);
File
temp2
=
new
File
(
temp1
.
getParentFile
(),
"2.zip"
);
File
temp2
=
new
File
(
temp1
.
getParentFile
(),
"2.zip"
);
temp1
.
getParentFile
().
mkdir
();
temp1
.
getParentFile
().
mkdir
();
// First remove top folder in Github source zip, Web -> temp1
// First download the zip, Web -> temp1
removeTopFolder
(
in
,
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
();
conn
.
disconnect
();
mHandler
.
post
(()
->
{
mHandler
.
post
(()
->
{
progressDialog
.
setTitle
(
R
.
string
.
zip_process_title
);
progressDialog
.
setTitle
(
R
.
string
.
zip_process_title
);
progressDialog
.
setMessage
(
getActivity
().
getString
(
R
.
string
.
zip_process_msg
));
progressDialog
.
setMessage
(
getActivity
().
getString
(
R
.
string
.
zip_process_msg
));
});
});
//
Then sign the zip for the first time
, temp1 -> temp2
//
First remove top folder in Github source zip
, temp1 -> temp2
ZipUtils
.
signZip
(
temp1
,
temp2
,
false
);
removeTopFolder
(
temp1
,
temp2
);
//
Adjust the zip to prevent unzip issues
, temp2 -> temp1
//
Then sign the zip for the first time
, temp2 -> temp1
ZipUtils
.
zipAdjust
(
temp2
.
getPath
(),
temp1
.
getPath
()
);
ZipUtils
.
signZip
(
temp2
,
temp1
,
false
);
//
Finally, sign the whole zip file again
, temp1 -> temp2
//
Adjust the zip to prevent unzip issues
, temp1 -> temp2
ZipUtils
.
signZip
(
temp1
,
temp2
,
true
);
ZipUtils
.
zipAdjust
(
temp1
.
getPath
(),
temp2
.
getPath
()
);
// Write it to the target zip, temp2 -> file
// Finally, sign the whole zip file again, temp2 -> target
try
(
ZipUtils
.
signZip
(
temp2
,
mFile
,
true
);
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
);
}
// Delete temp files
// Delete temp files
temp1
.
delete
();
temp1
.
delete
();
...
@@ -149,8 +145,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
...
@@ -149,8 +145,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
Activity
activity
=
getActivity
();
Activity
activity
=
getActivity
();
if
(
activity
==
null
)
return
;
if
(
activity
==
null
)
return
;
progressDialog
.
dismiss
();
progressDialog
.
dismiss
();
Uri
uri
=
Uri
.
fromFile
(
mFile
);
if
(
result
)
{
if
(
result
)
{
Uri
uri
=
Uri
.
fromFile
(
mFile
);
if
(
Shell
.
rootAccess
()
&&
mInstall
)
{
if
(
Shell
.
rootAccess
()
&&
mInstall
)
{
Intent
intent
=
new
Intent
(
activity
,
FlashActivity
.
class
);
Intent
intent
=
new
Intent
(
activity
,
FlashActivity
.
class
);
intent
.
setData
(
uri
).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_ZIP
);
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 {
...
@@ -225,13 +225,15 @@ public class Utils {
}
}
}
}
public
static
void
inToOut
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
public
static
int
inToOut
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
int
read
;
int
read
,
total
=
0
;
byte
buffer
[]
=
new
byte
[
4096
];
byte
buffer
[]
=
new
byte
[
4096
];
while
((
read
=
in
.
read
(
buffer
))
>
0
)
{
while
((
read
=
in
.
read
(
buffer
))
>
0
)
{
out
.
write
(
buffer
,
0
,
read
);
out
.
write
(
buffer
,
0
,
read
);
total
+=
read
;
}
}
out
.
flush
();
out
.
flush
();
return
total
;
}
}
public
static
void
patchDTBO
()
{
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