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
bb7560e4
Commit
bb7560e4
authored
Feb 02, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add artificial delay to CheckUpdate
parent
43c0cac5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
29 deletions
+35
-29
CheckUpdates.java
...rc/main/java/com/topjohnwu/magisk/tasks/CheckUpdates.java
+35
-29
No files found.
app-core/src/main/java/com/topjohnwu/magisk/tasks/CheckUpdates.java
View file @
bb7560e4
package
com
.
topjohnwu
.
magisk
.
tasks
;
import
android.os.SystemClock
;
import
com.topjohnwu.magisk.Config
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.net.Networking
;
import
com.topjohnwu.net.Request
;
import
com.topjohnwu.net.ResponseListener
;
import
com.topjohnwu.superuser.internal.UiThreadHandler
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
public
class
CheckUpdates
{
private
static
int
getInt
(
JSONObject
json
,
String
name
,
int
defValue
)
{
if
(
json
==
null
)
return
defValue
;
try
{
return
json
.
getInt
(
name
);
}
catch
(
JSONException
e
)
{
return
defValue
;
}
}
private
static
String
getString
(
JSONObject
json
,
String
name
,
String
defValue
)
{
if
(
json
==
null
)
return
defValue
;
try
{
return
json
.
getString
(
name
);
}
catch
(
JSONException
e
)
{
return
defValue
;
}
}
private
static
JSONObject
getJson
(
JSONObject
json
,
String
name
)
{
try
{
return
json
.
getJSONObject
(
name
);
}
catch
(
JSONException
e
)
{
return
null
;
}
}
private
static
Request
getRequest
()
{
String
url
;
switch
((
int
)
Config
.
get
(
Config
.
Key
.
UPDATE_CHANNEL
))
{
...
...
@@ -70,9 +45,39 @@ public class CheckUpdates {
private
static
class
UpdateListener
implements
ResponseListener
<
JSONObject
>
{
private
Runnable
cb
;
private
long
start
;
UpdateListener
(
Runnable
callback
)
{
cb
=
callback
;
start
=
SystemClock
.
uptimeMillis
();
}
private
int
getInt
(
JSONObject
json
,
String
name
,
int
defValue
)
{
if
(
json
==
null
)
return
defValue
;
try
{
return
json
.
getInt
(
name
);
}
catch
(
JSONException
e
)
{
return
defValue
;
}
}
private
String
getString
(
JSONObject
json
,
String
name
,
String
defValue
)
{
if
(
json
==
null
)
return
defValue
;
try
{
return
json
.
getString
(
name
);
}
catch
(
JSONException
e
)
{
return
defValue
;
}
}
private
JSONObject
getJson
(
JSONObject
json
,
String
name
)
{
try
{
return
json
.
getJSONObject
(
name
);
}
catch
(
JSONException
e
)
{
return
null
;
}
}
@Override
...
...
@@ -93,7 +98,8 @@ public class CheckUpdates {
JSONObject
uninstaller
=
getJson
(
json
,
"uninstaller"
);
Config
.
uninstallerLink
=
getString
(
uninstaller
,
"link"
,
null
);
Topic
.
publish
(
Topic
.
UPDATE_CHECK_DONE
);
UiThreadHandler
.
handler
.
postAtTime
(()
->
Topic
.
publish
(
Topic
.
UPDATE_CHECK_DONE
),
start
+
1000
/* Add artificial delay to let UI behave correctly */
);
if
(
cb
!=
null
)
cb
.
run
();
...
...
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