Include busybox binary and remove busybox toggle
This commit is contained in:
parent
962f8354ac
commit
e272dbe9af
@ -1,4 +1,6 @@
|
|||||||
# 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)
|
||||||
|
@ -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-v8a'
|
abiFilters 'x86', 'armeabi-v7a'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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;
|
||||||
|
@ -68,7 +68,7 @@ public class FlashZip extends SerialTask<Void, String, Integer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean unzipAndCheck() throws Exception {
|
private 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());
|
||||||
|
@ -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> {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
|
BIN
app/src/main/jniLibs/armeabi-v7a/libbusybox.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libbusybox.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/x86/libbusybox.so
Normal file
BIN
app/src/main/jniLibs/x86/libbusybox.so
Normal file
Binary file not shown.
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user