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
699debda
Commit
699debda
authored
Feb 02, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cast AsyncTask.THREAD_POOL_EXECUTOR to ThreadPoolExecutor
parent
70eba568
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
38 additions
and
47 deletions
+38
-47
App.java
app-core/src/main/java/com/topjohnwu/magisk/App.java
+5
-0
FlashZip.java
...re/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.java
+1
-2
MagiskInstaller.java
...main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
+1
-2
UpdateRepos.java
...src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
+1
-2
Utils.java
app-core/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+1
-2
SplashActivity.java
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
+0
-1
ApplicationAdapter.java
...ava/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
+1
-1
GeneralReceiver.java
...java/com/topjohnwu/magisk/components/GeneralReceiver.java
+9
-11
MarkDownWindow.java
...ava/com/topjohnwu/magisk/uicomponents/MarkDownWindow.java
+15
-19
DownloadApp.java
...src/full/java/com/topjohnwu/magisk/utils/DownloadApp.java
+1
-3
PatchAPK.java
app/src/full/java/com/topjohnwu/magisk/utils/PatchAPK.java
+3
-4
No files found.
app-core/src/main/java/com/topjohnwu/magisk/App.java
View file @
699debda
...
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.res.Configuration
;
import
android.os.AsyncTask
;
import
android.preference.PreferenceManager
;
import
com.topjohnwu.magisk.core.BuildConfig
;
...
...
@@ -14,10 +15,13 @@ import com.topjohnwu.net.Networking;
import
com.topjohnwu.superuser.ContainerApp
;
import
com.topjohnwu.superuser.Shell
;
import
java.util.concurrent.ThreadPoolExecutor
;
public
class
App
extends
ContainerApp
{
public
static
App
self
;
public
boolean
init
=
false
;
public
static
ThreadPoolExecutor
THREAD_POOL
;
// Global resources
public
SharedPreferences
prefs
;
...
...
@@ -29,6 +33,7 @@ public class App extends ContainerApp {
Shell
.
Config
.
verboseLogging
(
BuildConfig
.
DEBUG
);
Shell
.
Config
.
addInitializers
(
RootUtils
.
class
);
Shell
.
Config
.
setTimeout
(
2
);
THREAD_POOL
=
(
ThreadPoolExecutor
)
AsyncTask
.
THREAD_POOL_EXECUTOR
;
}
@Override
...
...
app-core/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.java
View file @
699debda
package
com
.
topjohnwu
.
magisk
.
tasks
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.Const
;
...
...
@@ -70,7 +69,7 @@ public abstract class FlashZip {
}
public
void
exec
()
{
A
syncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
A
pp
.
THREAD_POOL
.
execute
(()
->
{
boolean
success
=
false
;
try
{
success
=
flash
();
...
...
app-core/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
View file @
699debda
package
com
.
topjohnwu
.
magisk
.
tasks
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.text.TextUtils
;
...
...
@@ -308,7 +307,7 @@ public abstract class MagiskInstaller {
protected
abstract
void
onResult
(
boolean
success
);
public
void
exec
()
{
A
syncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
A
pp
.
THREAD_POOL
.
execute
(()
->
{
boolean
b
=
operations
();
UiThreadHandler
.
run
(()
->
onResult
(
b
));
});
...
...
app-core/src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
View file @
699debda
package
com
.
topjohnwu
.
magisk
.
tasks
;
import
android.database.Cursor
;
import
android.os.AsyncTask
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.Config
;
...
...
@@ -142,7 +141,7 @@ public class UpdateRepos {
public
void
exec
(
boolean
force
)
{
Topic
.
reset
(
Topic
.
REPO_LOAD_DONE
);
A
syncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
A
pp
.
THREAD_POOL
.
execute
(()
->
{
cached
=
Collections
.
synchronizedSet
(
app
.
repoDB
.
getRepoIDSet
());
threadPool
=
Executors
.
newFixedThreadPool
(
CORE_POOL_SIZE
);
...
...
app-core/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
699debda
...
...
@@ -8,7 +8,6 @@ import android.content.res.Configuration;
import
android.content.res.Resources
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.provider.OpenableColumns
;
import
android.widget.Toast
;
...
...
@@ -97,7 +96,7 @@ public class Utils {
public
static
void
loadModules
()
{
Topic
.
reset
(
Topic
.
MODULE_LOAD_DONE
);
A
syncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
A
pp
.
THREAD_POOL
.
execute
(()
->
{
Map
<
String
,
Module
>
moduleMap
=
new
ValueSortedMap
<>();
SuFile
path
=
new
SuFile
(
Const
.
MAGISK_PATH
);
SuFile
[]
modules
=
path
.
listFiles
(
...
...
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
View file @
699debda
...
...
@@ -6,7 +6,6 @@ import android.os.Bundle;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.tasks.CheckUpdates
;
import
com.topjohnwu.magisk.tasks.UpdateRepos
;
import
com.topjohnwu.magisk.uicomponents.Notifications
;
import
com.topjohnwu.magisk.uicomponents.Shortcuts
;
...
...
app/src/full/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java
View file @
699debda
...
...
@@ -151,7 +151,7 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
}
public
void
refresh
()
{
AsyncTask
.
THREAD_POO
L_EXECUTOR
.
execute
(
this
::
loadApps
);
AsyncTask
.
SERIA
L_EXECUTOR
.
execute
(
this
::
loadApps
);
}
static
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
...
...
app/src/full/java/com/topjohnwu/magisk/components/GeneralReceiver.java
View file @
699debda
...
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk.components;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.AsyncTask
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.ClassMap
;
...
...
@@ -17,7 +16,6 @@ import com.topjohnwu.magisk.uicomponents.Shortcuts;
import
com.topjohnwu.magisk.utils.DownloadApp
;
import
com.topjohnwu.magisk.utils.SuLogger
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
public
class
GeneralReceiver
extends
BroadcastReceiver
{
...
...
@@ -61,7 +59,6 @@ public class GeneralReceiver extends BroadcastReceiver {
break
;
case
"boot"
:
default
:
AsyncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
/* Devices with DTBO might want to patch dtbo.img.
* However, that is not possible if Magisk is installed by
* patching boot image with Magisk Manager and flashed via
...
...
@@ -69,7 +66,8 @@ public class GeneralReceiver extends BroadcastReceiver {
* Check for dtbo status every boot time, and prompt user
* to reboot if dtbo wasn't patched and patched by Magisk Manager.
* */
if
(
Shell
.
rootAccess
()
&&
ShellUtils
.
fastCmdResult
(
"mm_patch_dtbo"
))
Shell
.
su
(
"mm_patch_dtbo"
).
submit
(
result
->
{
if
(
result
.
isSuccess
())
Notifications
.
dtboPatched
();
});
break
;
...
...
app/src/full/java/com/topjohnwu/magisk/uicomponents/MarkDownWindow.java
View file @
699debda
...
...
@@ -5,12 +5,10 @@ import android.graphics.Bitmap;
import
android.graphics.Canvas
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.os.AsyncTask
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
com.caverock.androidsvg.SVG
;
import
com.caverock.androidsvg.SVGParseException
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Utils
;
...
...
@@ -22,6 +20,7 @@ import com.topjohnwu.superuser.ShellUtils;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.concurrent.Callable
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AlertDialog
;
...
...
@@ -72,17 +71,16 @@ public class MarkDownWindow {
@Override
public
void
load
(
@NonNull
String
url
,
@NonNull
AsyncDrawable
asyncDrawable
)
{
A
syncTask
.
THREAD_POOL_EXECUTOR
.
execute
(
()
->
{
A
pp
.
THREAD_POOL
.
submit
((
Callable
<?>)
()
->
{
InputStream
is
=
Networking
.
get
(
url
).
execForInputStream
().
getResult
();
if
(
is
==
null
)
return
;
return
null
;
ByteArrayStream
buf
=
new
ByteArrayStream
();
buf
.
readFrom
(
is
);
// First try default drawables
Drawable
drawable
=
Drawable
.
createFromStream
(
buf
.
getInputStream
(),
""
);
if
(
drawable
==
null
)
{
// SVG
try
{
SVG
svg
=
SVG
.
getFromInputStream
(
buf
.
getInputStream
());
int
width
=
Utils
.
dpInPx
((
int
)
svg
.
getDocumentWidth
());
int
height
=
Utils
.
dpInPx
((
int
)
svg
.
getDocumentHeight
());
...
...
@@ -92,12 +90,10 @@ public class MarkDownWindow {
canvas
.
scale
(
density
,
density
);
svg
.
renderToCanvas
(
canvas
);
drawable
=
new
BitmapDrawable
(
App
.
self
.
getResources
(),
bitmap
);
}
catch
(
SVGParseException
ignored
)
{}
}
if
(
drawable
!=
null
)
{
drawable
.
setBounds
(
0
,
0
,
drawable
.
getIntrinsicWidth
(),
drawable
.
getIntrinsicHeight
());
asyncDrawable
.
setResult
(
drawable
);
}
return
null
;
});
}
...
...
app/src/full/java/com/topjohnwu/magisk/utils/DownloadApp.java
View file @
699debda
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.os.AsyncTask
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.Config
;
...
...
@@ -32,7 +30,7 @@ public class DownloadApp {
ProgressNotification
progress
=
new
ProgressNotification
(
name
);
listener
.
progress
=
progress
;
Networking
.
get
(
Config
.
managerLink
)
.
setExecutor
(
A
syncTask
.
THREAD_POOL_EXECUTOR
)
.
setExecutor
(
A
pp
.
THREAD_POOL
)
.
setDownloadProgressListener
(
progress
)
.
setErrorHandler
((
conn
,
e
)
->
progress
.
dlFail
())
.
getAsFile
(
apk
,
listener
);
...
...
app/src/full/java/com/topjohnwu/magisk/utils/PatchAPK.java
View file @
699debda
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.os.AsyncTask
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.App
;
...
...
@@ -136,14 +135,14 @@ public class PatchAPK {
}
public
static
void
hideManager
()
{
A
syncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
A
pp
.
THREAD_POOL
.
execute
(()
->
{
App
app
=
App
.
self
;
NotificationCompat
.
Builder
progress
=
Notifications
.
progress
(
app
.
getString
(
R
.
string
.
hide_manager_title
));
Notifications
.
mgr
.
notify
(
Const
.
ID
.
HIDE_MANAGER_NOTIFICATION_ID
,
progress
.
build
());
boolean
b
=
patchAndHide
();
if
(!
patchAndHide
())
Utils
.
toast
(
R
.
string
.
hide_manager_fail_toast
,
Toast
.
LENGTH_LONG
);
Notifications
.
mgr
.
cancel
(
Const
.
ID
.
HIDE_MANAGER_NOTIFICATION_ID
);
if
(!
b
)
Utils
.
toast
(
R
.
string
.
hide_manager_fail_toast
,
Toast
.
LENGTH_LONG
);
});
}
}
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