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
40b63bfe
Commit
40b63bfe
authored
Jul 29, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use DownloadManager for Magisk
parent
89861ece
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
109 additions
and
99 deletions
+109
-99
FlashActivity.java
app/src/full/java/com/topjohnwu/magisk/FlashActivity.java
+3
-3
CheckSafetyNet.java
...full/java/com/topjohnwu/magisk/asyncs/CheckSafetyNet.java
+1
-1
InstallMagisk.java
.../full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+71
-22
ProcessRepoZip.java
...full/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
+4
-10
EnvFixDialog.java
...ll/java/com/topjohnwu/magisk/components/EnvFixDialog.java
+1
-15
InstallMethodDialog.java
.../com/topjohnwu/magisk/components/InstallMethodDialog.java
+16
-48
WebService.java
app/src/main/java/com/topjohnwu/magisk/utils/WebService.java
+13
-0
No files found.
app/src/full/java/com/topjohnwu/magisk/FlashActivity.java
View file @
40b63bfe
...
@@ -119,13 +119,13 @@ public class FlashActivity extends Activity {
...
@@ -119,13 +119,13 @@ public class FlashActivity extends Activity {
new
UninstallMagisk
(
this
,
uri
,
console
,
logs
).
exec
();
new
UninstallMagisk
(
this
,
uri
,
console
,
logs
).
exec
();
break
;
break
;
case
Const
.
Value
.
FLASH_MAGISK
:
case
Const
.
Value
.
FLASH_MAGISK
:
new
InstallMagisk
(
this
,
console
,
logs
,
uri
,
InstallMagisk
.
DIRECT_MODE
).
exec
();
new
InstallMagisk
(
this
,
console
,
logs
,
InstallMagisk
.
DIRECT_MODE
).
exec
();
break
;
break
;
case
Const
.
Value
.
FLASH_INACTIVE_SLOT
:
case
Const
.
Value
.
FLASH_INACTIVE_SLOT
:
new
InstallMagisk
(
this
,
console
,
logs
,
uri
,
InstallMagisk
.
SECOND_SLOT_MODE
).
exec
();
new
InstallMagisk
(
this
,
console
,
logs
,
InstallMagisk
.
SECOND_SLOT_MODE
).
exec
();
break
;
break
;
case
Const
.
Value
.
PATCH_BOOT
:
case
Const
.
Value
.
PATCH_BOOT
:
new
InstallMagisk
(
this
,
console
,
logs
,
uri
,
new
InstallMagisk
(
this
,
console
,
logs
,
intent
.
getParcelableExtra
(
Const
.
Key
.
FLASH_SET_BOOT
)).
exec
();
intent
.
getParcelableExtra
(
Const
.
Key
.
FLASH_SET_BOOT
)).
exec
();
break
;
break
;
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/CheckSafetyNet.java
View file @
40b63bfe
...
@@ -32,7 +32,7 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
...
@@ -32,7 +32,7 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
private
void
dlSnet
()
throws
Exception
{
private
void
dlSnet
()
throws
Exception
{
Shell
.
sh
(
"rm -rf "
+
dexPath
.
getParent
()).
exec
();
Shell
.
sh
(
"rm -rf "
+
dexPath
.
getParent
()).
exec
();
dexPath
.
getParentFile
().
mkdir
();
dexPath
.
getParentFile
().
mkdir
();
HttpURLConnection
conn
=
WebService
.
r
equest
(
Const
.
Url
.
SNET_URL
,
null
);
HttpURLConnection
conn
=
WebService
.
mustR
equest
(
Const
.
Url
.
SNET_URL
,
null
);
try
(
try
(
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
dexPath
));
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
dexPath
));
InputStream
in
=
new
BufferedInputStream
(
conn
.
getInputStream
()))
{
InputStream
in
=
new
BufferedInputStream
(
conn
.
getInputStream
()))
{
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
40b63bfe
...
@@ -4,6 +4,7 @@ import android.app.Activity;
...
@@ -4,6 +4,7 @@ import android.app.Activity;
import
android.app.ProgressDialog
;
import
android.app.ProgressDialog
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.support.annotation.NonNull
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -14,6 +15,7 @@ import com.topjohnwu.magisk.R;
...
@@ -14,6 +15,7 @@ import com.topjohnwu.magisk.R;
import
com.topjohnwu.magisk.container.TarEntry
;
import
com.topjohnwu.magisk.container.TarEntry
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebService
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.ShellUtils
;
...
@@ -31,9 +33,11 @@ import java.io.BufferedOutputStream;
...
@@ -31,9 +33,11 @@ import java.io.BufferedOutputStream;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.FilterInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -44,7 +48,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -44,7 +48,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
private
static
final
int
FIX_ENV_MODE
=
2
;
private
static
final
int
FIX_ENV_MODE
=
2
;
public
static
final
int
SECOND_SLOT_MODE
=
3
;
public
static
final
int
SECOND_SLOT_MODE
=
3
;
private
Uri
bootUri
,
mZip
;
private
Uri
bootUri
;
private
List
<
String
>
console
,
logs
;
private
List
<
String
>
console
,
logs
;
private
String
mBoot
;
private
String
mBoot
;
private
int
mode
;
private
int
mode
;
...
@@ -52,22 +56,21 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -52,22 +56,21 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
private
ProgressDialog
dialog
;
private
ProgressDialog
dialog
;
private
MagiskManager
mm
;
private
MagiskManager
mm
;
public
InstallMagisk
(
Activity
context
,
Uri
zip
)
{
public
InstallMagisk
(
Activity
context
)
{
super
(
context
);
super
(
context
);
mZip
=
zip
;
mm
=
MagiskManager
.
get
();
mm
=
MagiskManager
.
get
();
mode
=
FIX_ENV_MODE
;
mode
=
FIX_ENV_MODE
;
}
}
public
InstallMagisk
(
Activity
context
,
List
<
String
>
console
,
List
<
String
>
logs
,
Uri
zip
,
int
mode
)
{
public
InstallMagisk
(
Activity
context
,
List
<
String
>
console
,
List
<
String
>
logs
,
int
mode
)
{
this
(
context
,
zip
);
this
(
context
);
this
.
console
=
console
;
this
.
console
=
console
;
this
.
logs
=
logs
;
this
.
logs
=
logs
;
this
.
mode
=
mode
;
this
.
mode
=
mode
;
}
}
public
InstallMagisk
(
FlashActivity
context
,
List
<
String
>
console
,
List
<
String
>
logs
,
Uri
zip
,
Uri
boot
)
{
public
InstallMagisk
(
FlashActivity
context
,
List
<
String
>
console
,
List
<
String
>
logs
,
Uri
boot
)
{
this
(
context
,
console
,
logs
,
zip
,
PATCH_MODE
);
this
(
context
,
console
,
logs
,
PATCH_MODE
);
bootUri
=
boot
;
bootUri
=
boot
;
}
}
...
@@ -80,23 +83,69 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -80,23 +83,69 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
}
}
}
}
private
class
ProgressStream
extends
FilterInputStream
{
private
int
prev
=
-
1
;
private
int
progress
=
0
;
private
int
total
;
private
ProgressStream
(
HttpURLConnection
conn
)
throws
IOException
{
super
(
conn
.
getInputStream
());
total
=
conn
.
getContentLength
();
}
private
void
update
(
int
step
)
{
progress
+=
step
;
int
curr
=
(
int
)
(
10
*
(
double
)
progress
/
total
);
if
(
prev
!=
curr
)
{
prev
=
curr
;
console
.
add
(
"... "
+
prev
*
10
+
"%"
);
}
}
@Override
public
int
read
()
throws
IOException
{
int
b
=
super
.
read
();
if
(
b
>
0
)
update
(
1
);
return
b
;
}
@Override
public
int
read
(
@NonNull
byte
[]
b
)
throws
IOException
{
return
read
(
b
,
0
,
b
.
length
);
}
@Override
public
int
read
(
@NonNull
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
int
step
=
super
.
read
(
b
,
off
,
len
);
if
(
step
>
0
)
update
(
step
);
return
step
;
}
}
private
void
extractFiles
(
String
arch
)
throws
IOException
{
private
void
extractFiles
(
String
arch
)
throws
IOException
{
console
.
add
(
"- Extracting files"
);
console
.
add
(
"- Downloading zip"
);
try
(
InputStream
in
=
mm
.
getContentResolver
().
openInputStream
(
mZip
))
{
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
if
(
in
==
null
)
throw
new
FileNotFoundException
();
mm
.
remoteMagiskVersionString
,
mm
.
remoteMagiskVersionCode
);
BufferedInputStream
buf
=
new
BufferedInputStream
(
in
);
HttpURLConnection
conn
=
WebService
.
mustRequest
(
mm
.
magiskLink
,
null
);
BufferedInputStream
buf
=
new
BufferedInputStream
(
new
ProgressStream
(
conn
));
buf
.
mark
(
Integer
.
MAX_VALUE
);
buf
.
mark
(
Integer
.
MAX_VALUE
);
ZipUtils
.
unzip
(
buf
,
installDir
,
arch
+
"/"
,
true
);
try
(
OutputStream
out
=
new
FileOutputStream
(
new
File
(
Const
.
EXTERNAL_PATH
,
filename
)))
{
buf
.
reset
();
ShellUtils
.
pump
(
buf
,
out
);
ZipUtils
.
unzip
(
buf
,
installDir
,
"common/"
,
true
);
buf
.
reset
();
buf
.
reset
();
ZipUtils
.
unzip
(
buf
,
installDir
,
"chromeos/"
,
false
);
}
buf
.
reset
();
conn
.
disconnect
();
ZipUtils
.
unzip
(
buf
,
installDir
,
"META-INF/com/google/android/update-binary"
,
true
);
console
.
add
(
"- Extracting files"
);
buf
.
close
();
try
(
InputStream
in
=
buf
)
{
}
catch
(
FileNotFoundException
e
)
{
ZipUtils
.
unzip
(
in
,
installDir
,
arch
+
"/"
,
true
);
console
.
add
(
"! Invalid Uri"
);
in
.
reset
();
throw
e
;
ZipUtils
.
unzip
(
in
,
installDir
,
"common/"
,
true
);
in
.
reset
();
ZipUtils
.
unzip
(
in
,
installDir
,
"chromeos/"
,
false
);
in
.
reset
();
ZipUtils
.
unzip
(
in
,
installDir
,
"META-INF/com/google/android/update-binary"
,
true
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
console
.
add
(
"! Cannot unzip zip"
);
console
.
add
(
"! Cannot unzip zip"
);
throw
e
;
throw
e
;
...
...
app/src/full/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java
View file @
40b63bfe
...
@@ -87,15 +87,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
...
@@ -87,15 +87,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
if
(
activity
==
null
)
return
null
;
if
(
activity
==
null
)
return
null
;
try
{
try
{
// Request zip from Internet
// Request zip from Internet
HttpURLConnection
conn
;
HttpURLConnection
conn
=
WebService
.
mustRequest
(
mLink
,
null
);
do
{
conn
=
WebService
.
request
(
mLink
,
null
);
total
=
conn
.
getContentLength
();
total
=
conn
.
getContentLength
();
if
(
total
<
0
)
conn
.
disconnect
();
else
break
;
}
while
(
true
);
// Temp files
// Temp files
File
temp1
=
new
File
(
activity
.
getCacheDir
(),
"1.zip"
);
File
temp1
=
new
File
(
activity
.
getCacheDir
(),
"1.zip"
);
...
@@ -170,7 +163,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
...
@@ -170,7 +163,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
private
void
updateDlProgress
(
int
step
)
{
private
void
updateDlProgress
(
int
step
)
{
progress
+=
step
;
progress
+=
step
;
progressDialog
.
setMessage
(
getActivity
().
getString
(
R
.
string
.
zip_download_msg
,
(
int
)
(
100
*
(
double
)
progress
/
total
+
0.5
)));
progressDialog
.
setMessage
(
getActivity
().
getString
(
R
.
string
.
zip_download_msg
,
(
int
)
(
100
*
(
double
)
progress
/
total
+
0.5
)));
}
}
@Override
@Override
...
...
app/src/full/java/com/topjohnwu/magisk/components/EnvFixDialog.java
View file @
40b63bfe
package
com
.
topjohnwu
.
magisk
.
components
;
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.asyncs.InstallMagisk
;
import
com.topjohnwu.magisk.asyncs.InstallMagisk
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
EnvFixDialog
extends
CustomAlertDialog
{
public
class
EnvFixDialog
extends
CustomAlertDialog
{
public
EnvFixDialog
(
@NonNull
Activity
activity
)
{
public
EnvFixDialog
(
@NonNull
Activity
activity
)
{
super
(
activity
);
super
(
activity
);
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
String
filename
=
Utils
.
fmt
(
"Magisk-v%s(%d).zip"
,
mm
.
remoteMagiskVersionString
,
mm
.
remoteMagiskVersionCode
);
setTitle
(
R
.
string
.
env_fix_title
);
setTitle
(
R
.
string
.
env_fix_title
);
setMessage
(
R
.
string
.
env_fix_msg
);
setMessage
(
R
.
string
.
env_fix_msg
);
setCancelable
(
true
);
setCancelable
(
true
);
setPositiveButton
(
R
.
string
.
yes
,
(
d
,
i
)
->
Utils
.
dlAndReceive
(
activity
,
setPositiveButton
(
R
.
string
.
yes
,
(
d
,
i
)
->
new
InstallMagisk
(
activity
).
exec
());
new
DownloadReceiver
()
{
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
new
InstallMagisk
(
activity
,
uri
).
exec
();
}
},
mm
.
magiskLink
,
filename
));
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
setNegativeButton
(
R
.
string
.
no_thanks
,
null
);
}
}
}
}
app/src/full/java/com/topjohnwu/magisk/components/InstallMethodDialog.java
View file @
40b63bfe
...
@@ -23,7 +23,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
...
@@ -23,7 +23,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
MagiskManager
mm
=
Utils
.
getMagiskManager
(
activity
);
setTitle
(
R
.
string
.
select_method
);
setTitle
(
R
.
string
.
select_method
);
setItems
(
options
.
toArray
(
new
String
[
0
]),
(
dialog
,
idx
)
->
{
setItems
(
options
.
toArray
(
new
String
[
0
]),
(
dialog
,
idx
)
->
{
DownloadReceiver
receiver
=
null
;
Intent
intent
;
switch
(
idx
)
{
switch
(
idx
)
{
case
1
:
case
1
:
if
(
mm
.
remoteMagiskVersionCode
<
1400
)
{
if
(
mm
.
remoteMagiskVersionCode
<
1400
)
{
...
@@ -32,70 +32,38 @@ class InstallMethodDialog extends AlertDialog.Builder {
...
@@ -32,70 +32,38 @@ class InstallMethodDialog extends AlertDialog.Builder {
return
;
return
;
}
}
MagiskManager
.
toast
(
R
.
string
.
boot_file_patch_msg
,
Toast
.
LENGTH_LONG
);
MagiskManager
.
toast
(
R
.
string
.
boot_file_patch_msg
,
Toast
.
LENGTH_LONG
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
).
setType
(
"*/*"
);
intent
.
setType
(
"*/*"
);
activity
.
startActivityForResult
(
intent
,
Const
.
ID
.
SELECT_BOOT
,
activity
.
startActivityForResult
(
intent
,
Const
.
ID
.
SELECT_BOOT
,
(
requestCode
,
resultCode
,
data
)
->
{
(
requestCode
,
resultCode
,
data
)
->
{
if
(
requestCode
==
Const
.
ID
.
SELECT_BOOT
&&
if
(
requestCode
==
Const
.
ID
.
SELECT_BOOT
&&
resultCode
==
Activity
.
RESULT_OK
&&
data
!=
null
)
{
resultCode
==
Activity
.
RESULT_OK
&&
data
!=
null
)
{
Utils
.
dlAndReceive
(
activity
,
new
SelectBoot
(
data
),
Intent
i
=
new
Intent
(
activity
,
FlashActivity
.
class
)
mm
.
magiskLink
,
filename
);
.
putExtra
(
Const
.
Key
.
FLASH_SET_BOOT
,
data
.
getData
())
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
PATCH_BOOT
);
activity
.
startActivity
(
i
);
}
}
});
});
return
;
break
;
case
0
:
case
0
:
receiver
=
new
DownloadReceiver
()
{
Utils
.
dlAndReceive
(
activity
,
new
DownloadReceiver
()
{
@Override
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
SnackbarMaker
.
showUri
(
activity
,
uri
);
SnackbarMaker
.
showUri
(
activity
,
uri
);
}
}
};
}
,
mm
.
magiskLink
,
filename
)
;
break
;
break
;
case
2
:
case
2
:
receiver
=
new
DownloadReceiver
()
{
intent
=
new
Intent
(
activity
,
FlashActivity
.
class
)
@Override
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_MAGISK
);
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
activity
.
startActivity
(
intent
);
Intent
intent
=
new
Intent
(
context
,
FlashActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
setData
(
uri
).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_MAGISK
);
context
.
startActivity
(
intent
);
}
};
break
;
break
;
case
3
:
case
3
:
receiver
=
new
DownloadReceiver
()
{
intent
=
new
Intent
(
activity
,
FlashActivity
.
class
)
@Override
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_INACTIVE_SLOT
);
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
activity
.
startActivity
(
intent
);
Intent
intent
=
new
Intent
(
context
,
FlashActivity
.
class
);
break
;
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
setData
(
uri
).
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
FLASH_INACTIVE_SLOT
);
context
.
startActivity
(
intent
);
}
};
default
:
default
:
}
}
Utils
.
dlAndReceive
(
activity
,
receiver
,
mm
.
magiskLink
,
filename
);
});
});
}
}
private
static
class
SelectBoot
extends
DownloadReceiver
{
private
Intent
data
;
public
SelectBoot
(
Intent
data
)
{
this
.
data
=
data
;
}
@Override
public
void
onDownloadDone
(
Context
context
,
Uri
uri
)
{
Intent
intent
=
new
Intent
(
context
,
FlashActivity
.
class
);
intent
.
setData
(
uri
)
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
.
putExtra
(
Const
.
Key
.
FLASH_SET_BOOT
,
data
.
getData
())
.
putExtra
(
Const
.
Key
.
FLASH_ACTION
,
Const
.
Value
.
PATCH_BOOT
);
context
.
startActivity
(
intent
);
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/utils/WebService.java
View file @
40b63bfe
...
@@ -69,4 +69,17 @@ public class WebService {
...
@@ -69,4 +69,17 @@ public class WebService {
return
conn
;
return
conn
;
}
}
public
static
HttpURLConnection
mustRequest
(
String
address
,
Map
<
String
,
String
>
header
)
throws
IOException
{
HttpURLConnection
conn
;
do
{
conn
=
WebService
.
request
(
address
,
header
);
int
total
=
conn
.
getContentLength
();
if
(
total
<
0
)
conn
.
disconnect
();
else
break
;
}
while
(
true
);
return
conn
;
}
}
}
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