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
a07ca5ff
Commit
a07ca5ff
authored
Sep 02, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly change busybox handling
parent
f07e7571
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
51 deletions
+54
-51
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+22
-12
DownloadBusybox.java
...ain/java/com/topjohnwu/magisk/asyncs/DownloadBusybox.java
+30
-38
ParallelTask.java
...c/main/java/com/topjohnwu/magisk/asyncs/ParallelTask.java
+2
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
a07ca5ff
...
...
@@ -35,6 +35,7 @@ import java.io.File;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.concurrent.ExecutionException
;
public
class
MagiskManager
extends
Application
{
...
...
@@ -47,7 +48,7 @@ public class MagiskManager extends Application {
public
static
final
String
MAGISKHIDE_PROP
=
"persist.magisk.hide"
;
public
static
final
String
DISABLE_INDICATION_PROP
=
"ro.magisk.disable"
;
public
static
final
String
NOTIFICATION_CHANNEL
=
"magisk_update_notice"
;
public
static
final
String
BUSYBOX
_VERSION
=
"1.27.1
"
;
public
static
final
String
BUSYBOX
PATH
=
"/dev/magisk/bin
"
;
public
static
final
int
UPDATE_SERVICE_ID
=
1
;
// Topics
...
...
@@ -107,7 +108,7 @@ public class MagiskManager extends Application {
public
Shell
shell
;
private
static
Handler
mHandler
=
new
Handler
();
private
boolean
start
up
=
false
;
private
boolean
start
ed
=
false
;
private
static
class
LoadLocale
extends
ParallelTask
<
Void
,
Void
,
Void
>
{
...
...
@@ -186,14 +187,26 @@ public class MagiskManager extends Application {
}
public
void
startup
()
{
if
(
start
up
)
if
(
start
ed
)
return
;
startup
=
true
;
started
=
true
;
boolean
hasNetwork
=
Utils
.
checkNetworkStatus
(
this
);
shell
=
Shell
.
getShell
();
new
LoadLocale
(
this
).
exec
();
new
DownloadBusybox
(
this
).
exec
();
getMagiskInfo
();
new
LoadLocale
(
this
).
exec
();
// Force synchronous, make sure we have busybox to use
if
(
hasNetwork
&&
Shell
.
rootAccess
()
&&
!
Utils
.
itemExist
(
shell
,
BUSYBOXPATH
+
"/busybox"
))
{
try
{
new
DownloadBusybox
(
this
).
exec
().
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
e
.
printStackTrace
();
}
}
shell
.
su_raw
(
"export PATH="
+
BUSYBOXPATH
+
":$PATH"
);
updateBlockInfo
();
// Write back default values
...
...
@@ -211,13 +224,9 @@ public class MagiskManager extends Application {
.
putString
(
"multiuser_mode"
,
String
.
valueOf
(
multiuserMode
))
.
putString
(
"mnt_ns"
,
String
.
valueOf
(
suNamespaceMode
))
.
putString
(
"update_channel"
,
String
.
valueOf
(
updateChannel
))
.
putString
(
"busybox_version"
,
BUSYBOX_VERSION
)
.
putString
(
"locale"
,
localeConfig
)
.
apply
();
// Add busybox to PATH
shell
.
su_raw
(
"PATH="
+
getApplicationInfo
().
dataDir
+
"/busybox:$PATH"
);
// Create notification channel on Android O
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
NotificationChannel
channel
=
new
NotificationChannel
(
NOTIFICATION_CHANNEL
,
...
...
@@ -227,7 +236,7 @@ public class MagiskManager extends Application {
LoadModules
loadModuleTask
=
new
LoadModules
(
this
);
// Start update check job
if
(
Utils
.
checkNetworkStatus
(
this
)
)
{
if
(
hasNetwork
)
{
ComponentName
service
=
new
ComponentName
(
this
,
UpdateCheckService
.
class
);
JobInfo
jobInfo
=
new
JobInfo
.
Builder
(
UPDATE_SERVICE_ID
,
service
)
.
setRequiredNetworkType
(
JobInfo
.
NETWORK_TYPE_ANY
)
...
...
@@ -244,6 +253,7 @@ public class MagiskManager extends Application {
public
void
getMagiskInfo
()
{
List
<
String
>
ret
;
Shell
.
getShell
(
this
);
ret
=
shell
.
sh
(
"su -v"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
{
suVersion
=
ret
.
get
(
0
);
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/DownloadBusybox.java
View file @
a07ca5ff
...
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.asyncs;
import
android.content.Context
;
import
android.os.Build
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebService
;
...
...
@@ -15,7 +16,6 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
private
static
final
String
BUSYBOX_ARM
=
"https://github.com/topjohnwu/ndk-busybox/releases/download/1.27.1/busybox-arm"
;
private
static
final
String
BUSYBOX_X86
=
"https://github.com/topjohnwu/ndk-busybox/releases/download/1.27.1/busybox-x86"
;
private
static
final
String
BUSYBOXPATH
=
"/dev/magisk/bin"
;
private
File
busybox
;
...
...
@@ -24,47 +24,39 @@ public class DownloadBusybox extends ParallelTask<Void, Void, Void> {
busybox
=
new
File
(
context
.
getCacheDir
(),
"busybox"
);
}
@Override
protected
void
onPreExecute
()
{
getShell
().
su_raw
(
"export PATH="
+
BUSYBOXPATH
+
":$PATH"
);
}
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
Context
context
=
getMagiskManager
();
if
(!
Utils
.
itemExist
(
getShell
(),
BUSYBOXPATH
+
"/busybox"
))
{
if
(!
busybox
.
exists
()
&&
Utils
.
checkNetworkStatus
(
context
))
{
Utils
.
removeItem
(
getShell
(),
context
.
getApplicationInfo
().
dataDir
+
"/busybox"
);
try
{
FileOutputStream
out
=
new
FileOutputStream
(
busybox
);
InputStream
in
=
WebService
.
request
(
WebService
.
GET
,
Build
.
SUPPORTED_32_BIT_ABIS
[
0
].
contains
(
"x86"
)
?
BUSYBOX_X86
:
BUSYBOX_ARM
,
null
);
if
(
in
==
null
)
throw
new
IOException
();
byte
[]
buffer
=
new
byte
[
4096
];
int
read
;
while
((
read
=
in
.
read
(
buffer
))
!=
-
1
)
{
out
.
write
(
buffer
,
0
,
read
);
}
out
.
close
();
in
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
busybox
.
exists
())
{
getShell
().
su_raw
(
"rm -rf "
+
BUSYBOXPATH
,
"mkdir -p "
+
BUSYBOXPATH
,
"cp "
+
busybox
+
" "
+
BUSYBOXPATH
,
"chmod -R 755 "
+
BUSYBOXPATH
,
BUSYBOXPATH
+
"/busybox --install -s "
+
BUSYBOXPATH
);
Utils
.
removeItem
(
getShell
(),
context
.
getApplicationInfo
().
dataDir
+
"/busybox"
);
try
{
FileOutputStream
out
=
new
FileOutputStream
(
busybox
);
InputStream
in
=
WebService
.
request
(
WebService
.
GET
,
Build
.
SUPPORTED_32_BIT_ABIS
[
0
].
contains
(
"x86"
)
?
BUSYBOX_X86
:
BUSYBOX_ARM
,
null
);
if
(
in
==
null
)
throw
new
IOException
();
byte
[]
buffer
=
new
byte
[
4096
];
int
read
;
while
((
read
=
in
.
read
(
buffer
))
!=
-
1
)
{
out
.
write
(
buffer
,
0
,
read
);
}
out
.
close
();
in
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
busybox
.
exists
())
{
getShell
().
su_raw
(
"rm -rf "
+
MagiskManager
.
BUSYBOXPATH
,
"mkdir -p "
+
MagiskManager
.
BUSYBOXPATH
,
"cp "
+
busybox
+
" "
+
MagiskManager
.
BUSYBOXPATH
,
"chmod -R 755 "
+
MagiskManager
.
BUSYBOXPATH
,
MagiskManager
.
BUSYBOXPATH
+
"/busybox --install -s "
+
MagiskManager
.
BUSYBOXPATH
);
busybox
.
delete
();
}
return
null
;
}
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/ParallelTask.java
View file @
a07ca5ff
...
...
@@ -42,8 +42,9 @@ public abstract class ParallelTask<Params, Progress, Result> extends AsyncTask<P
}
@SuppressWarnings
(
"unchecked"
)
public
void
exec
(
Params
...
params
)
{
public
ParallelTask
<
Params
,
Progress
,
Result
>
exec
(
Params
...
params
)
{
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
,
params
);
return
this
;
}
@Override
...
...
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