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
35dc3d9d
Commit
35dc3d9d
authored
Sep 30, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update WebService
parent
566714a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
44 deletions
+38
-44
DownloadBusybox.java
...ain/java/com/topjohnwu/magisk/asyncs/DownloadBusybox.java
+5
-6
ProcessRepoZip.java
...main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
+5
-3
WebService.java
app/src/main/java/com/topjohnwu/magisk/utils/WebService.java
+28
-35
No files found.
app/src/main/java/com/topjohnwu/magisk/asyncs/DownloadBusybox.java
View file @
35dc3d9d
...
@@ -11,7 +11,7 @@ import java.io.BufferedInputStream;
...
@@ -11,7 +11,7 @@ import java.io.BufferedInputStream;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.
io.InputStream
;
import
java.
net.HttpURLConnection
;
public
class
DownloadBusybox
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
public
class
DownloadBusybox
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
...
@@ -31,22 +31,21 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
...
@@ -31,22 +31,21 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
Utils
.
removeItem
(
getShell
(),
context
.
getApplicationInfo
().
dataDir
+
"/busybox"
);
Utils
.
removeItem
(
getShell
(),
context
.
getApplicationInfo
().
dataDir
+
"/busybox"
);
try
{
try
{
FileOutputStream
out
=
new
FileOutputStream
(
busybox
);
FileOutputStream
out
=
new
FileOutputStream
(
busybox
);
InputStream
in
=
WebService
.
request
(
WebService
.
GET
,
HttpURLConnection
conn
=
WebService
.
request
(
Build
.
SUPPORTED_32_BIT_ABIS
[
0
].
contains
(
"x86"
)
?
Build
.
SUPPORTED_32_BIT_ABIS
[
0
].
contains
(
"x86"
)
?
BUSYBOX_X86
:
BUSYBOX_X86
:
BUSYBOX_ARM
,
BUSYBOX_ARM
,
null
null
);
);
if
(
i
n
==
null
)
throw
new
IOException
();
if
(
con
n
==
null
)
throw
new
IOException
();
BufferedInputStream
bis
=
new
BufferedInputStream
(
in
);
BufferedInputStream
bis
=
new
BufferedInputStream
(
conn
.
getInputStream
()
);
byte
[]
buffer
=
new
byte
[
4096
];
byte
[]
buffer
=
new
byte
[
4096
];
int
len
;
int
len
;
while
((
len
=
bis
.
read
(
buffer
))
!=
-
1
)
{
while
((
len
=
bis
.
read
(
buffer
))
!=
-
1
)
{
out
.
write
(
buffer
,
0
,
len
);
out
.
write
(
buffer
,
0
,
len
);
}
}
out
.
close
();
out
.
close
();
bis
.
close
();
conn
.
disconnect
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
View file @
35dc3d9d
...
@@ -23,6 +23,7 @@ import java.io.FileInputStream;
...
@@ -23,6 +23,7 @@ import java.io.FileInputStream;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
public
class
ProcessRepoZip
extends
ParallelTask
<
Void
,
Void
,
Boolean
>
{
public
class
ProcessRepoZip
extends
ParallelTask
<
Void
,
Void
,
Boolean
>
{
...
@@ -60,9 +61,9 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -60,9 +61,9 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
try
{
try
{
// Request zip from Internet
// Request zip from Internet
InputStream
in
=
WebService
.
request
(
WebService
.
GET
,
mLink
,
null
);
HttpURLConnection
conn
=
WebService
.
request
(
mLink
,
null
);
if
(
i
n
==
null
)
return
false
;
if
(
con
n
==
null
)
return
false
;
in
=
new
BufferedInputStream
(
in
);
InputStream
in
=
new
BufferedInputStream
(
conn
.
getInputStream
()
);
// Temp files
// Temp files
File
temp1
=
new
File
(
activity
.
getCacheDir
(),
"1.zip"
);
File
temp1
=
new
File
(
activity
.
getCacheDir
(),
"1.zip"
);
...
@@ -72,6 +73,7 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -72,6 +73,7 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
// First remove top folder in Github source zip, Web -> temp1
// First remove top folder in Github source zip, Web -> temp1
ZipUtils
.
removeTopFolder
(
in
,
temp1
);
ZipUtils
.
removeTopFolder
(
in
,
temp1
);
conn
.
disconnect
();
publishProgress
();
publishProgress
();
// Then sign the zip for the first time, temp1 -> temp2
// Then sign the zip for the first time, temp1 -> temp2
...
...
app/src/main/java/com/topjohnwu/magisk/utils/WebService.java
View file @
35dc3d9d
...
@@ -2,57 +2,50 @@ package com.topjohnwu.magisk.utils;
...
@@ -2,57 +2,50 @@ package com.topjohnwu.magisk.utils;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.net.ssl.HttpsURLConnection
;
public
class
WebService
{
public
class
WebService
{
public
final
static
int
GET
=
1
;
public
final
static
int
POST
=
2
;
public
static
String
getString
(
String
url
)
{
public
static
String
getString
(
String
url
)
{
return
getString
(
url
,
null
);
return
getString
(
url
,
null
);
}
}
public
static
String
getString
(
String
url
,
Map
<
String
,
String
>
header
)
{
public
static
String
getString
(
String
url
,
Map
<
String
,
String
>
header
)
{
InputStream
in
=
request
(
GET
,
url
,
header
);
HttpURLConnection
conn
=
request
(
url
,
header
);
if
(
i
n
==
null
)
return
""
;
if
(
con
n
==
null
)
return
""
;
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
in
)
);
return
getString
(
conn
);
int
len
;
}
StringBuilder
builder
=
new
StringBuilder
();
char
buf
[]
=
new
char
[
4096
];
public
static
String
getString
(
HttpURLConnection
conn
)
{
try
{
try
{
while
((
len
=
br
.
read
(
buf
))
!=
-
1
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
buf
,
0
,
len
);
if
(
conn
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_OK
)
{
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
()));
int
len
;
char
buf
[]
=
new
char
[
4096
];
while
((
len
=
br
.
read
(
buf
))
!=
-
1
)
{
builder
.
append
(
buf
,
0
,
len
);
}
}
}
in
.
close
();
conn
.
disconnect
();
return
builder
.
toString
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
""
;
}
}
return
builder
.
toString
();
}
}
public
static
InputStream
request
(
int
method
,
String
address
,
Map
<
String
,
String
>
header
)
{
public
static
HttpURLConnection
request
(
String
address
,
Map
<
String
,
String
>
header
)
{
Logger
.
dev
(
"WebService: Service call "
+
address
);
try
{
try
{
URL
url
=
new
URL
(
address
);
URL
url
=
new
URL
(
address
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setReadTimeout
(
15000
);
conn
.
setReadTimeout
(
15000
);
conn
.
setConnectTimeout
(
15000
);
conn
.
setConnectTimeout
(
15000
);
conn
.
setDoInput
(
true
);
if
(
method
==
POST
)
{
conn
.
setRequestMethod
(
"POST"
);
}
else
if
(
method
==
GET
)
{
conn
.
setRequestMethod
(
"GET"
);
}
if
(
header
!=
null
)
{
if
(
header
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
header
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
header
.
entrySet
())
{
...
@@ -60,20 +53,20 @@ public class WebService {
...
@@ -60,20 +53,20 @@ public class WebService {
}
}
}
}
if
(
conn
.
getResponseCode
()
==
HttpsURLConnection
.
HTTP_OK
)
{
conn
.
connect
();
if
(
header
!=
null
)
{
header
.
clear
();
if
(
header
!=
null
)
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
conn
.
getHeaderFields
().
entrySet
())
{
header
.
clear
();
List
<
String
>
l
=
entry
.
getValue
();
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
conn
.
getHeaderFields
().
entrySet
())
{
header
.
put
(
entry
.
getKey
(),
l
.
get
(
l
.
size
()
-
1
)
);
List
<
String
>
l
=
entry
.
getValue
(
);
}
header
.
put
(
entry
.
getKey
(),
l
.
get
(
l
.
size
()
-
1
));
}
}
return
conn
.
getInputStream
();
}
}
return
conn
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
null
;
}
}
return
null
;
}
}
}
}
\ No newline at end of file
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