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
e272dbe9
Commit
e272dbe9
authored
May 11, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include busybox binary and remove busybox toggle
parent
962f8354
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
38 additions
and
65 deletions
+38
-65
README.md
README.md
+5
-3
build.gradle
app/build.gradle
+1
-1
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+16
-8
FlashZip.java
app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java
+1
-1
ProcessMagiskZip.java
...in/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java
+8
-42
Logger.java
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
+1
-1
Shell.java
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
+0
-4
libbusybox.so
app/src/main/jniLibs/armeabi-v7a/libbusybox.so
+0
-0
libbusybox.so
app/src/main/jniLibs/x86/libbusybox.so
+0
-0
app_settings.xml
app/src/main/res/xml/app_settings.xml
+6
-5
No files found.
README.md
View file @
e272dbe9
# Magisk Manager
# Magisk Manager
I used Java 8 features in the app, and official supported is added in Android Studio 2.4
Aware that Android Studio 2.4 is currently in the Preview Channel
You need to install CMake and NDK to build the zipadjust library for zip preprocessing
You need to install CMake and NDK to build the zipadjust library for zip preprocessing
## Pre-built Binaries
Busybox (arm and x86) compiled by osm0sis (
`libbusybox.so`
under
`app\src\main\jniLibs`
)
Source and more info:
[
osm0sis' Odds and Ends
](
https://forum.xda-developers.com/showthread.php?t=2239421
)
app/build.gradle
View file @
e272dbe9
...
@@ -13,7 +13,7 @@ android {
...
@@ -13,7 +13,7 @@ android {
versionName
"4.3.3"
versionName
"4.3.3"
ndk
{
ndk
{
moduleName
'zipadjust'
moduleName
'zipadjust'
abiFilters
'x86'
,
'
x86_64'
,
'armeabi-v7a'
,
'arm64-v8
a'
abiFilters
'x86'
,
'
armeabi-v7
a'
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
e272dbe9
...
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
...
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.ApplicationInfo
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.text.TextUtils
;
import
android.util.SparseArray
;
import
android.util.SparseArray
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -12,6 +13,7 @@ import com.topjohnwu.magisk.module.Module;
...
@@ -12,6 +13,7 @@ import com.topjohnwu.magisk.module.Module;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.superuser.Policy
;
import
com.topjohnwu.magisk.superuser.Policy
;
import
com.topjohnwu.magisk.utils.CallbackEvent
;
import
com.topjohnwu.magisk.utils.CallbackEvent
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ValueSortedMap
;
import
com.topjohnwu.magisk.utils.ValueSortedMap
;
...
@@ -26,6 +28,7 @@ public class MagiskManager extends Application {
...
@@ -26,6 +28,7 @@ public class MagiskManager extends Application {
public
static
final
String
TMP_FOLDER_PATH
=
"/dev/tmp"
;
public
static
final
String
TMP_FOLDER_PATH
=
"/dev/tmp"
;
public
static
final
String
MAGISK_PATH
=
"/magisk"
;
public
static
final
String
MAGISK_PATH
=
"/magisk"
;
public
static
final
String
INTENT_SECTION
=
"section"
;
public
static
final
String
INTENT_SECTION
=
"section"
;
public
static
final
String
BUSYBOX_VERSION
=
"1.26.2"
;
// Events
// Events
public
final
CallbackEvent
<
Void
>
blockDetectionDone
=
new
CallbackEvent
<>();
public
final
CallbackEvent
<
Void
>
blockDetectionDone
=
new
CallbackEvent
<>();
...
@@ -65,7 +68,6 @@ public class MagiskManager extends Application {
...
@@ -65,7 +68,6 @@ public class MagiskManager extends Application {
public
boolean
magiskHide
;
public
boolean
magiskHide
;
public
boolean
isDarkTheme
;
public
boolean
isDarkTheme
;
public
boolean
updateNotification
;
public
boolean
updateNotification
;
public
boolean
busybox
;
public
int
suRequestTimeout
;
public
int
suRequestTimeout
;
public
int
suLogTimeout
=
14
;
public
int
suLogTimeout
=
14
;
public
int
suAccessState
;
public
int
suAccessState
;
...
@@ -106,19 +108,31 @@ public class MagiskManager extends Application {
...
@@ -106,19 +108,31 @@ public class MagiskManager extends Application {
updateMagiskInfo
();
updateMagiskInfo
();
initSuAccess
();
initSuAccess
();
initSuConfigs
();
initSuConfigs
();
// Initialize busybox
File
busybox
=
new
File
(
getApplicationInfo
().
dataDir
+
"/busybox/busybox"
);
if
(!
busybox
.
exists
()
||
!
TextUtils
.
equals
(
prefs
.
getString
(
"busybox_version"
,
""
),
BUSYBOX_VERSION
))
{
busybox
.
getParentFile
().
mkdirs
();
Shell
.
su
(
"cp -f "
+
new
File
(
getApplicationInfo
().
nativeLibraryDir
,
"libbusybox.so"
)
+
" "
+
busybox
,
"chmod -R 755 "
+
busybox
.
getParent
(),
busybox
+
" --install -s "
+
busybox
.
getParent
()
);
}
// Initialize prefs
// Initialize prefs
prefs
.
edit
()
prefs
.
edit
()
.
putBoolean
(
"dark_theme"
,
isDarkTheme
)
.
putBoolean
(
"dark_theme"
,
isDarkTheme
)
.
putBoolean
(
"magiskhide"
,
magiskHide
)
.
putBoolean
(
"magiskhide"
,
magiskHide
)
.
putBoolean
(
"notification"
,
updateNotification
)
.
putBoolean
(
"notification"
,
updateNotification
)
.
putBoolean
(
"busybox"
,
busybox
)
.
putBoolean
(
"hosts"
,
new
File
(
"/magisk/.core/hosts"
).
exists
())
.
putBoolean
(
"hosts"
,
new
File
(
"/magisk/.core/hosts"
).
exists
())
.
putBoolean
(
"disable"
,
Utils
.
itemExist
(
MAGISK_DISABLE_FILE
))
.
putBoolean
(
"disable"
,
Utils
.
itemExist
(
MAGISK_DISABLE_FILE
))
.
putString
(
"su_request_timeout"
,
String
.
valueOf
(
suRequestTimeout
))
.
putString
(
"su_request_timeout"
,
String
.
valueOf
(
suRequestTimeout
))
.
putString
(
"su_auto_response"
,
String
.
valueOf
(
suResponseType
))
.
putString
(
"su_auto_response"
,
String
.
valueOf
(
suResponseType
))
.
putString
(
"su_notification"
,
String
.
valueOf
(
suNotificationType
))
.
putString
(
"su_notification"
,
String
.
valueOf
(
suNotificationType
))
.
putString
(
"su_access"
,
String
.
valueOf
(
suAccessState
))
.
putString
(
"su_access"
,
String
.
valueOf
(
suAccessState
))
.
putString
(
"busybox_version"
,
BUSYBOX_VERSION
)
.
apply
();
.
apply
();
// Add busybox to PATH
Shell
.
su
(
"PATH=$PATH:"
+
busybox
.
getParent
());
}
}
public
void
initSuConfigs
()
{
public
void
initSuConfigs
()
{
...
@@ -162,12 +176,6 @@ public class MagiskManager extends Application {
...
@@ -162,12 +176,6 @@ public class MagiskManager extends Application {
magiskVersionCode
=
Integer
.
parseInt
(
ret
.
get
(
0
));
magiskVersionCode
=
Integer
.
parseInt
(
ret
.
get
(
0
));
}
catch
(
NumberFormatException
ignored
)
{}
}
catch
(
NumberFormatException
ignored
)
{}
}
}
ret
=
Shell
.
sh
(
"getprop persist.magisk.busybox"
);
try
{
busybox
=
Utils
.
isValidShellResponse
(
ret
)
&&
Integer
.
parseInt
(
ret
.
get
(
0
))
!=
0
;
}
catch
(
NumberFormatException
e
)
{
busybox
=
false
;
}
ret
=
Shell
.
sh
(
"getprop ro.magisk.disable"
);
ret
=
Shell
.
sh
(
"getprop ro.magisk.disable"
);
try
{
try
{
disabled
=
Utils
.
isValidShellResponse
(
ret
)
&&
Integer
.
parseInt
(
ret
.
get
(
0
))
!=
0
;
disabled
=
Utils
.
isValidShellResponse
(
ret
)
&&
Integer
.
parseInt
(
ret
.
get
(
0
))
!=
0
;
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java
View file @
e272dbe9
...
@@ -68,7 +68,7 @@ public class FlashZip extends SerialTask<Void, String, Integer> {
...
@@ -68,7 +68,7 @@ public class FlashZip extends SerialTask<Void, String, Integer> {
}
}
}
}
pr
otected
boolean
unzipAndCheck
()
throws
Exception
{
pr
ivate
boolean
unzipAndCheck
()
throws
Exception
{
ZipUtils
.
unzip
(
mCachedFile
,
mCachedFile
.
getParentFile
(),
"META-INF/com/google/android"
);
ZipUtils
.
unzip
(
mCachedFile
,
mCachedFile
.
getParentFile
(),
"META-INF/com/google/android"
);
List
<
String
>
ret
;
List
<
String
>
ret
;
ret
=
Utils
.
readFile
(
mCheckFile
.
getPath
());
ret
=
Utils
.
readFile
(
mCheckFile
.
getPath
());
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessMagiskZip.java
View file @
e272dbe9
...
@@ -38,27 +38,13 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -38,27 +38,13 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
@Override
@Override
protected
Boolean
doInBackground
(
Void
...
params
)
{
protected
Boolean
doInBackground
(
Void
...
params
)
{
if
(
Shell
.
rootAccess
())
{
if
(
Shell
.
rootAccess
())
{
try
{
// Running in parallel mode, open new shell
// We might not have busybox yet, unzip with Java
Shell
.
su
(
true
,
// We shall have complete busybox after Magisk installation
"rm -f /dev/.magisk"
,
File
tempdir
=
new
File
(
magiskManager
.
getCacheDir
(),
"magisk"
);
(
mBoot
!=
null
)
?
"echo \"BOOTIMAGE=/dev/block/"
+
mBoot
+
"\" >> /dev/.magisk"
:
""
,
ZipUtils
.
unzip
(
magiskManager
.
getContentResolver
().
openInputStream
(
mUri
),
tempdir
);
"echo \"KEEPFORCEENCRYPT="
+
String
.
valueOf
(
mEnc
)
+
"\" >> /dev/.magisk"
,
// Running in parallel mode, open new shell
"echo \"KEEPVERITY="
+
String
.
valueOf
(
mVerity
)
+
"\" >> /dev/.magisk"
Shell
.
su
(
true
,
);
"rm -f /dev/.magisk"
,
(
mBoot
!=
null
)
?
"echo \"BOOTIMAGE=/dev/block/"
+
mBoot
+
"\" >> /dev/.magisk"
:
""
,
"echo \"KEEPFORCEENCRYPT="
+
String
.
valueOf
(
mEnc
)
+
"\" >> /dev/.magisk"
,
"echo \"KEEPVERITY="
+
String
.
valueOf
(
mVerity
)
+
"\" >> /dev/.magisk"
,
"mkdir -p "
+
MagiskManager
.
TMP_FOLDER_PATH
,
"cp -af "
+
tempdir
+
"/. "
+
MagiskManager
.
TMP_FOLDER_PATH
+
"/magisk"
,
"mv -f "
+
tempdir
+
"/META-INF "
+
magiskManager
.
getCacheDir
()
+
"/META-INF"
,
"rm -rf "
+
tempdir
);
}
catch
(
Exception
e
)
{
Logger
.
error
(
"ProcessMagiskZip: Error!"
);
e
.
printStackTrace
();
return
false
;
}
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -68,27 +54,7 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
...
@@ -68,27 +54,7 @@ public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {
protected
void
onPostExecute
(
Boolean
result
)
{
protected
void
onPostExecute
(
Boolean
result
)
{
progressDialog
.
dismiss
();
progressDialog
.
dismiss
();
if
(
result
)
{
if
(
result
)
{
new
FlashZip
(
activity
,
mUri
)
{
new
FlashZip
(
activity
,
mUri
).
exec
();
@Override
protected
boolean
unzipAndCheck
()
throws
Exception
{
// Don't need to check, as it is downloaded in correct form
return
true
;
}
@Override
protected
void
onSuccess
()
{
new
SerialTask
<
Void
,
Void
,
Void
>(
activity
)
{
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
Shell
.
su
(
"setprop magisk.version "
+
String
.
valueOf
(
magiskManager
.
remoteMagiskVersionCode
));
magiskManager
.
updateCheckDone
.
trigger
();
return
null
;
}
}.
exec
();
super
.
onSuccess
();
}
}.
exec
();
}
else
{
}
else
{
Utils
.
showUriSnack
(
activity
,
mUri
);
Utils
.
showUriSnack
(
activity
,
mUri
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
View file @
e272dbe9
...
@@ -34,7 +34,7 @@ public class Logger {
...
@@ -34,7 +34,7 @@ public class Logger {
public
static
void
shell
(
boolean
root
,
String
msg
)
{
public
static
void
shell
(
boolean
root
,
String
msg
)
{
if
(
MagiskManager
.
shellLogging
)
{
if
(
MagiskManager
.
shellLogging
)
{
Log
.
d
(
TAG
,
root
?
"MANAGERSU"
:
"MANAGERSH"
+
msg
);
Log
.
d
(
TAG
,
(
root
?
"MANAGERSU "
:
"MANAGERSH "
)
+
msg
);
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Shell.java
View file @
e272dbe9
...
@@ -40,7 +40,6 @@ public class Shell {
...
@@ -40,7 +40,6 @@ public class Shell {
// Setup umask and PATH
// Setup umask and PATH
su
(
"umask 022"
);
su
(
"umask 022"
);
su
(
"PATH=`[ -e /dev/busybox ] && echo /dev/busybox || echo /data/busybox`:$PATH"
);
List
<
String
>
ret
=
su
(
"echo -BOC-"
,
"id"
);
List
<
String
>
ret
=
su
(
"echo -BOC-"
,
"id"
);
...
@@ -138,9 +137,6 @@ public class Shell {
...
@@ -138,9 +137,6 @@ public class Shell {
// Run the new shell with busybox and proper umask
// Run the new shell with busybox and proper umask
STDIN
.
write
((
"umask 022\n"
).
getBytes
(
"UTF-8"
));
STDIN
.
write
((
"umask 022\n"
).
getBytes
(
"UTF-8"
));
STDIN
.
flush
();
STDIN
.
flush
();
STDIN
.
write
((
"PATH=`[ -e /dev/busybox ] && echo /dev/busybox || "
+
"echo /data/busybox`:$PATH\n"
).
getBytes
(
"UTF-8"
));
STDIN
.
flush
();
}
catch
(
IOException
err
)
{
}
catch
(
IOException
err
)
{
return
null
;
return
null
;
}
}
...
...
app/src/main/jniLibs/armeabi-v7a/libbusybox.so
0 → 100644
View file @
e272dbe9
File added
app/src/main/jniLibs/x86/libbusybox.so
0 → 100644
View file @
e272dbe9
File added
app/src/main/res/xml/app_settings.xml
View file @
e272dbe9
...
@@ -31,11 +31,12 @@
...
@@ -31,11 +31,12 @@
android:title=
"@string/settings_core_only_title"
android:title=
"@string/settings_core_only_title"
android:summary=
"@string/settings_core_only_summary"
/>
android:summary=
"@string/settings_core_only_summary"
/>
<SwitchPreference
<!-- No more busybox -->
android:key=
"busybox"
<!--<SwitchPreference-->
android:defaultValue=
"false"
<!--android:key="busybox"-->
android:title=
"@string/settings_busybox_title"
<!--android:defaultValue="false"-->
android:summary=
"@string/settings_busybox_summary"
/>
<!--android:title="@string/settings_busybox_title"-->
<!--android:summary="@string/settings_busybox_summary" />-->
<SwitchPreference
<SwitchPreference
android:key=
"magiskhide"
android:key=
"magiskhide"
...
...
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