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