mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-28 15:08:04 +00:00
Better support for low API levels
This commit is contained in:
parent
72270825c1
commit
c7301a5161
@ -15,7 +15,7 @@ dependencies {
|
||||
api project(':signing')
|
||||
api 'org.kamranzafar:jtar:2.3'
|
||||
|
||||
def libsuVersion = 'd99f481563'
|
||||
def libsuVersion = '2.3.0'
|
||||
api "com.github.topjohnwu.libsu:core:${libsuVersion}"
|
||||
api "com.github.topjohnwu.libsu:io:${libsuVersion}"
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
@ -12,12 +13,11 @@ import com.topjohnwu.magisk.database.RepoDatabaseHelper;
|
||||
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||
import com.topjohnwu.magisk.utils.RootUtils;
|
||||
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 class App extends Application {
|
||||
|
||||
public static App self;
|
||||
public static ThreadPoolExecutor THREAD_POOL;
|
||||
|
@ -7,11 +7,14 @@ env_check() {
|
||||
|
||||
fix_env() {
|
||||
cd /data/adb/magisk
|
||||
local OLDPATH="$PATH"
|
||||
PATH=/sbin:/system/bin:/vendor/bin
|
||||
sh update-binary extract
|
||||
PATH="$OLDPATH"
|
||||
./busybox rm -f /sbin/.magisk/busybox/*
|
||||
/sbin/.magisk/mirror/bin/busybox --install -s /sbin/.magisk/busybox
|
||||
rm -f update-binary magisk.apk
|
||||
cd /
|
||||
rm -rf /sbin/.magisk/busybox/*
|
||||
/sbin/.magisk/mirror/bin/busybox --install -s /sbin/.magisk/busybox
|
||||
}
|
||||
|
||||
direct_install() {
|
||||
|
@ -23,6 +23,22 @@ public class SplashActivity extends BaseActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Shell.getShell(shell -> {
|
||||
if (Config.magiskVersionCode > 0 &&
|
||||
Config.magiskVersionCode < Const.MAGISK_VER.MIN_SUPPORT) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.unsupport_magisk_title)
|
||||
.setMessage(R.string.unsupport_magisk_message)
|
||||
.setNegativeButton(R.string.ok, null)
|
||||
.setOnDismissListener(dialog -> finish())
|
||||
.show();
|
||||
} else {
|
||||
initAndStart();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initAndStart() {
|
||||
String pkg = Config.get(Config.Key.SU_MANAGER);
|
||||
if (pkg != null && getPackageName().equals(BuildConfig.APPLICATION_ID)) {
|
||||
Config.remove(Config.Key.SU_MANAGER);
|
||||
@ -36,19 +52,6 @@ public class SplashActivity extends BaseActivity {
|
||||
} catch (PackageManager.NameNotFoundException ignored) {}
|
||||
}
|
||||
|
||||
if (Config.magiskVersionCode > 0 && Config.magiskVersionCode < Const.MAGISK_VER.MIN_SUPPORT) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.unsupport_magisk_title)
|
||||
.setMessage(R.string.unsupport_magisk_message)
|
||||
.setNegativeButton(R.string.ok, null)
|
||||
.setOnDismissListener(dialog -> finish())
|
||||
.show();
|
||||
} else {
|
||||
initAndStart();
|
||||
}
|
||||
}
|
||||
|
||||
private void initAndStart() {
|
||||
// Dynamic detect all locales
|
||||
LocaleManager.loadAvailableLocales(R.string.app_changelog);
|
||||
|
||||
|
@ -2,14 +2,19 @@ package com.topjohnwu.magisk.dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.ClassMap;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.SplashActivity;
|
||||
import com.topjohnwu.magisk.tasks.MagiskInstaller;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
import com.topjohnwu.superuser.io.SuFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class EnvFixDialog extends CustomAlertDialog {
|
||||
@ -35,6 +40,17 @@ public class EnvFixDialog extends CustomAlertDialog {
|
||||
protected void onResult(boolean success) {
|
||||
pd.dismiss();
|
||||
Utils.toast(success ? R.string.setup_done : R.string.setup_fail, Toast.LENGTH_LONG);
|
||||
if (success) {
|
||||
// Relaunch the app
|
||||
try {
|
||||
Shell.getShell().close();
|
||||
} catch (IOException ignored) {}
|
||||
Intent intent = new Intent(activity, ClassMap.get(SplashActivity.class));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
activity.startActivity(intent);
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
}
|
||||
}.exec();
|
||||
});
|
||||
|
@ -1,11 +1,10 @@
|
||||
#!/sbin/sh
|
||||
X86_CNT=__X86_CNT__
|
||||
extract_bb() {
|
||||
case `uname -m` in
|
||||
x*) dd if="$0" of="$BBBIN" bs=1024 skip=1 count=$X86_CNT ;;
|
||||
*) dd if="$0" of="$BBBIN" bs=1024 skip=$(($X86_CNT + 1));;
|
||||
esac
|
||||
touch "$BBBIN"
|
||||
chmod 755 "$BBBIN"
|
||||
dd if="$0" of="$BBBIN" bs=1024 skip=$(($X86_CNT + 1))
|
||||
"./$BBBIN" >/dev/null || dd if="$0" of="$BBBIN" bs=1024 skip=1 count=$X86_CNT
|
||||
}
|
||||
setup_bb() {
|
||||
BBDIR=$TMPDIR/bin
|
||||
|
Loading…
x
Reference in New Issue
Block a user