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
21b00ac6
Commit
21b00ac6
authored
Jan 12, 2017
by
tonymanou
Committed by
topjohnwu
Jan 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use try-with-resources in some places
parent
57e6f308
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
33 deletions
+27
-33
AboutActivity.java
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
+1
-3
LogFragment.java
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
+1
-5
RepoDlReceiver.java
...n/java/com/topjohnwu/magisk/receivers/RepoDlReceiver.java
+3
-3
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+9
-9
ZipUtils.java
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
+13
-13
No files found.
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
View file @
21b00ac6
...
...
@@ -63,13 +63,11 @@ public class AboutActivity extends AppCompatActivity {
appVersionInfo
.
setSummary
(
BuildConfig
.
VERSION_NAME
);
String
changes
=
null
;
try
{
InputStream
is
=
getAssets
().
open
(
"changelog.html"
);
try
(
InputStream
is
=
getAssets
().
open
(
"changelog.html"
))
{
int
size
=
is
.
available
();
byte
[]
buffer
=
new
byte
[
size
];
is
.
read
(
buffer
);
is
.
close
();
changes
=
new
String
(
buffer
);
}
catch
(
IOException
ignored
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
View file @
21b00ac6
...
...
@@ -182,14 +182,10 @@ public class LogFragment extends Fragment {
List
<
String
>
in
=
Utils
.
readFile
(
MAGISK_LOG
);
try
{
FileWriter
out
=
new
FileWriter
(
targetFile
);
try
(
FileWriter
out
=
new
FileWriter
(
targetFile
))
{
for
(
String
line
:
in
)
{
out
.
write
(
line
+
"\n"
);
}
out
.
close
();
return
true
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/RepoDlReceiver.java
View file @
21b00ac6
...
...
@@ -33,9 +33,9 @@ public class RepoDlReceiver extends DownloadReceiver {
ZipUtils
.
signZip
(
mContext
,
buffer
.
getInputStream
(),
buffer
,
true
);
// Write it back to the downloaded zip
OutputStream
out
=
mContext
.
getContentResolver
().
openOutputStream
(
mUri
);
buffer
.
writeTo
(
out
);
out
.
close
();
try
(
OutputStream
out
=
mContext
.
getContentResolver
().
openOutputStream
(
mUri
))
{
buffer
.
writeTo
(
out
);
}
}
}.
exec
();
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
21b00ac6
...
...
@@ -194,21 +194,21 @@ public class Async {
protected
void
copyToCache
()
throws
Throwable
{
publishProgress
(
mContext
.
getString
(
R
.
string
.
copying_msg
));
try
{
InputStream
in
=
mContext
.
getContentResolver
().
openInputStream
(
mUri
);
mCachedFile
=
new
File
(
mContext
.
getCacheDir
().
getAbsolutePath
()
+
"/install.zip"
);
if
(
mCachedFile
.
exists
()
&&
!
mCachedFile
.
delete
())
{
throw
new
IOException
();
}
OutputStream
outputStream
=
new
FileOutputStream
(
mCachedFile
);
mCachedFile
=
new
File
(
mContext
.
getCacheDir
().
getAbsolutePath
()
+
"/install.zip"
);
if
(
mCachedFile
.
exists
()
&&
!
mCachedFile
.
delete
())
{
Log
.
e
(
Logger
.
TAG
,
"FlashZip: Error while deleting already existing file"
);
throw
new
IOException
();
}
try
(
InputStream
in
=
mContext
.
getContentResolver
().
openInputStream
(
mUri
);
OutputStream
outputStream
=
new
FileOutputStream
(
mCachedFile
)
)
{
byte
buffer
[]
=
new
byte
[
1024
];
int
length
;
while
((
length
=
in
.
read
(
buffer
))
>
0
)
{
outputStream
.
write
(
buffer
,
0
,
length
);
}
outputStream
.
close
();
Logger
.
dev
(
"FlashZip: File created successfully - "
+
mCachedFile
.
getPath
());
in
.
close
();
}
catch
(
FileNotFoundException
e
)
{
Log
.
e
(
Logger
.
TAG
,
"FlashZip: Invalid Uri"
);
throw
e
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
View file @
21b00ac6
...
...
@@ -125,17 +125,16 @@ public class ZipUtils {
}
public
static
void
unzip
(
File
file
,
File
folder
,
String
path
)
{
try
{
int
count
;
FileOutputStream
out
;
File
dest
;
InputStream
is
;
JarEntry
entry
;
byte
data
[]
=
new
byte
[
4096
];
JarFile
zipfile
=
new
JarFile
(
file
);
Enumeration
e
=
zipfile
.
entries
();
int
count
;
FileOutputStream
out
;
File
dest
;
InputStream
is
;
JarEntry
entry
;
byte
data
[]
=
new
byte
[
4096
];
try
(
JarFile
zipfile
=
new
JarFile
(
file
))
{
Enumeration
<
JarEntry
>
e
=
zipfile
.
entries
();
while
(
e
.
hasMoreElements
())
{
entry
=
(
JarEntry
)
e
.
nextElement
();
entry
=
e
.
nextElement
();
if
(!
entry
.
getName
().
contains
(
path
)
||
entry
.
getName
().
charAt
(
entry
.
getName
().
length
()
-
1
)
==
'/'
)
{
// Ignore directories, only create files
...
...
@@ -518,9 +517,10 @@ public class ZipUtils {
.
build
(
signer
,
publicKey
));
gen
.
addCertificates
(
certs
);
CMSSignedData
sigData
=
gen
.
generate
(
data
,
false
);
ASN1InputStream
asn1
=
new
ASN1InputStream
(
sigData
.
getEncoded
());
DEROutputStream
dos
=
new
DEROutputStream
(
out
);
dos
.
writeObject
(
asn1
.
readObject
());
try
(
ASN1InputStream
asn1
=
new
ASN1InputStream
(
sigData
.
getEncoded
()))
{
DEROutputStream
dos
=
new
DEROutputStream
(
out
);
dos
.
writeObject
(
asn1
.
readObject
());
}
}
/**
* Copy all the files in a manifest from input to output. We set
...
...
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