Update to libsu 1.2.0
This commit is contained in:
parent
1df41003ec
commit
4ff39f8817
@ -27,7 +27,7 @@ android {
|
|||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
full {
|
full {
|
||||||
versionCode 118
|
versionCode 120
|
||||||
versionName "5.7.0"
|
versionName "5.7.0"
|
||||||
}
|
}
|
||||||
stub {
|
stub {
|
||||||
@ -57,7 +57,7 @@ dependencies {
|
|||||||
fullImplementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
|
fullImplementation "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
|
||||||
fullImplementation "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
|
fullImplementation "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
|
||||||
fullImplementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
|
fullImplementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
|
||||||
fullImplementation 'com.github.topjohnwu:libsu:1.1.1'
|
fullImplementation 'com.github.topjohnwu:libsu:1.2.0'
|
||||||
fullImplementation 'com.atlassian.commonmark:commonmark:0.11.0'
|
fullImplementation 'com.atlassian.commonmark:commonmark:0.11.0'
|
||||||
fullImplementation 'org.kamranzafar:jtar:2.3'
|
fullImplementation 'org.kamranzafar:jtar:2.3'
|
||||||
fullImplementation 'com.jakewharton:butterknife:8.8.1'
|
fullImplementation 'com.jakewharton:butterknife:8.8.1'
|
||||||
|
@ -25,11 +25,11 @@ import com.topjohnwu.magisk.components.ExpandableView;
|
|||||||
import com.topjohnwu.magisk.components.Fragment;
|
import com.topjohnwu.magisk.components.Fragment;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
import com.topjohnwu.magisk.utils.ISafetyNetHelper;
|
import com.topjohnwu.magisk.utils.ISafetyNetHelper;
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
|
||||||
import com.topjohnwu.magisk.utils.ShowUI;
|
import com.topjohnwu.magisk.utils.ShowUI;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
|
||||||
import butterknife.BindColor;
|
import butterknife.BindColor;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -265,7 +265,7 @@ public class MagiskFragment extends Fragment
|
|||||||
|| mm.remoteManagerVersionCode > BuildConfig.VERSION_CODE) {
|
|| mm.remoteManagerVersionCode > BuildConfig.VERSION_CODE) {
|
||||||
install();
|
install();
|
||||||
} else if (mm.remoteMagiskVersionCode >= Const.MAGISK_VER.FIX_ENV &&
|
} else if (mm.remoteMagiskVersionCode >= Const.MAGISK_VER.FIX_ENV &&
|
||||||
!RootUtils.cmdResult("env_check")) {
|
!ShellUtils.fastCmdResult("env_check")) {
|
||||||
ShowUI.envFixDialog(getActivity());
|
ShowUI.envFixDialog(getActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
@ -20,10 +19,11 @@ import com.topjohnwu.magisk.database.RepoDatabaseHelper;
|
|||||||
import com.topjohnwu.magisk.services.UpdateCheckService;
|
import com.topjohnwu.magisk.services.UpdateCheckService;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
import com.topjohnwu.magisk.utils.RootUtils;
|
||||||
|
import com.topjohnwu.magisk.utils.ShellInitializer;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.superuser.BusyBox;
|
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
import com.topjohnwu.superuser.io.SuFile;
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
import com.topjohnwu.superuser.io.SuFileInputStream;
|
import com.topjohnwu.superuser.io.SuFileInputStream;
|
||||||
|
|
||||||
@ -32,7 +32,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -111,26 +110,7 @@ public class MagiskManager extends Application implements Shell.Container {
|
|||||||
|
|
||||||
Shell.setFlags(Shell.FLAG_MOUNT_MASTER);
|
Shell.setFlags(Shell.FLAG_MOUNT_MASTER);
|
||||||
Shell.verboseLogging(BuildConfig.DEBUG);
|
Shell.verboseLogging(BuildConfig.DEBUG);
|
||||||
BusyBox.BB_PATH = new File(Const.BUSYBOX_PATH);
|
Shell.setInitializer(ShellInitializer.class);
|
||||||
Shell.setInitializer(new Shell.Initializer() {
|
|
||||||
@Override
|
|
||||||
public void onRootShellInit(@NonNull Shell shell) {
|
|
||||||
try (InputStream magiskUtils = getAssets().open(Const.UTIL_FUNCTIONS);
|
|
||||||
InputStream managerUtils = getResources().openRawResource(R.raw.utils)
|
|
||||||
) {
|
|
||||||
shell.loadInputStream(null, null, magiskUtils);
|
|
||||||
shell.loadInputStream(null, null, managerUtils);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
shell.run(null, null,
|
|
||||||
"mount_partitions",
|
|
||||||
"find_boot_image",
|
|
||||||
"find_dtbo_image",
|
|
||||||
"get_flags",
|
|
||||||
"run_migrations");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
mDB = MagiskDatabaseHelper.getInstance(this);
|
mDB = MagiskDatabaseHelper.getInstance(this);
|
||||||
@ -207,19 +187,19 @@ public class MagiskManager extends Application implements Shell.Container {
|
|||||||
|
|
||||||
public void loadMagiskInfo() {
|
public void loadMagiskInfo() {
|
||||||
try {
|
try {
|
||||||
magiskVersionString = RootUtils.cmd("magisk -v").split(":")[0];
|
magiskVersionString = ShellUtils.fastCmd("magisk -v").split(":")[0];
|
||||||
magiskVersionCode = Integer.parseInt(RootUtils.cmd("magisk -V"));
|
magiskVersionCode = Integer.parseInt(ShellUtils.fastCmd("magisk -V"));
|
||||||
String s = RootUtils.cmd((magiskVersionCode >= Const.MAGISK_VER.RESETPROP_PERSIST ? "resetprop -p " : "getprop ")
|
String s = ShellUtils.fastCmd((magiskVersionCode >= Const.MAGISK_VER.RESETPROP_PERSIST ?
|
||||||
+ Const.MAGISKHIDE_PROP);
|
"resetprop -p " : "getprop ") + Const.MAGISKHIDE_PROP);
|
||||||
magiskHide = s == null || Integer.parseInt(s) != 0;
|
magiskHide = s == null || Integer.parseInt(s) != 0;
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
bootBlock = RootUtils.cmd("echo \"$BOOTIMAGE\"");
|
bootBlock = ShellUtils.fastCmd("echo \"$BOOTIMAGE\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getDefaultInstallFlags() {
|
public void getDefaultInstallFlags() {
|
||||||
keepVerity = Boolean.parseBoolean(RootUtils.cmd("echo $KEEPVERITY"));
|
keepVerity = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPVERITY"));
|
||||||
keepEnc = Boolean.parseBoolean(RootUtils.cmd("echo $KEEPFORCEENCRYPT"));
|
keepEnc = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPFORCEENCRYPT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupUpdateCheck() {
|
public void setupUpdateCheck() {
|
||||||
@ -250,7 +230,7 @@ public class MagiskManager extends Application implements Shell.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadPrefs() {
|
public void loadPrefs() {
|
||||||
SuFile config = new SuFile(Utils.fmt("/data/user/%d/%s", Const.USER_ID, Const.MANAGER_CONFIGS), true);
|
SuFile config = new SuFile(Utils.fmt("/data/user/%d/%s", Const.USER_ID, Const.MANAGER_CONFIGS));
|
||||||
if (config.exists()) {
|
if (config.exists()) {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
try {
|
try {
|
||||||
|
@ -30,6 +30,7 @@ import com.topjohnwu.magisk.utils.RootUtils;
|
|||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -172,7 +173,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
@Override
|
@Override
|
||||||
public void onDownloadDone(Context context, Uri uri) {
|
public void onDownloadDone(Context context, Uri uri) {
|
||||||
mm.dumpPrefs();
|
mm.dumpPrefs();
|
||||||
if (RootUtils.cmdResult("pm install " + uri.getPath()))
|
if (ShellUtils.fastCmdResult("pm install " + uri.getPath()))
|
||||||
RootUtils.uninstallPkg(context.getPackageName());
|
RootUtils.uninstallPkg(context.getPackageName());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,6 @@ import com.topjohnwu.magisk.FlashActivity;
|
|||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.components.SnackbarMaker;
|
import com.topjohnwu.magisk.components.SnackbarMaker;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
@ -41,7 +40,7 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
|
|||||||
|
|
||||||
private boolean unzipAndCheck() throws Exception {
|
private boolean unzipAndCheck() throws Exception {
|
||||||
ZipUtils.unzip(mCachedFile, mCachedFile.getParentFile(), "META-INF/com/google/android", true);
|
ZipUtils.unzip(mCachedFile, mCachedFile.getParentFile(), "META-INF/com/google/android", true);
|
||||||
String s = RootUtils.cmd("head -n 1 " + new File(mCachedFile.getParentFile(), "updater-script"));
|
String s = ShellUtils.fastCmd("head -n 1 " + new File(mCachedFile.getParentFile(), "updater-script"));
|
||||||
return s != null && s.contains("#MAGISK");
|
return s != null && s.contains("#MAGISK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
|
|||||||
MagiskManager mm = MagiskManager.get();
|
MagiskManager mm = MagiskManager.get();
|
||||||
|
|
||||||
// Generate a new app with random package name
|
// Generate a new app with random package name
|
||||||
SuFile repack = new SuFile("/data/local/tmp/repack.apk", true);
|
SuFile repack = new SuFile("/data/local/tmp/repack.apk");
|
||||||
String pkg = genPackageName("com.", Const.ORIG_PKG_NAME.length());
|
String pkg = genPackageName("com.", Const.ORIG_PKG_NAME.length());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -13,7 +13,6 @@ import com.topjohnwu.magisk.MagiskManager;
|
|||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.container.TarEntry;
|
import com.topjohnwu.magisk.container.TarEntry;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
@ -148,9 +147,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
case DIRECT_MODE:
|
case DIRECT_MODE:
|
||||||
console.add("- Patch boot/ramdisk image: " + mBootLocation);
|
console.add("- Patch boot/ramdisk image: " + mBootLocation);
|
||||||
if (mm.remoteMagiskVersionCode >= 1463) {
|
if (mm.remoteMagiskVersionCode >= 1463) {
|
||||||
highCompression = Integer.parseInt(RootUtils.cmd(Utils.fmt(
|
highCompression = Integer.parseInt(ShellUtils.fastCmd(Utils.fmt(
|
||||||
"%s/magiskboot --parse %s; echo $?",
|
"%s/magiskboot --parse %s; echo $?", install, mBootLocation))) == 2;
|
||||||
install, mBootLocation))) == 2;
|
|
||||||
if (highCompression)
|
if (highCompression)
|
||||||
console.add("! Insufficient boot partition size detected");
|
console.add("! Insufficient boot partition size detected");
|
||||||
}
|
}
|
||||||
@ -263,6 +261,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
.getFilesDir().getParent()
|
.getFilesDir().getParent()
|
||||||
, "install");
|
, "install");
|
||||||
Shell.Sync.sh("rm -rf " + install);
|
Shell.Sync.sh("rm -rf " + install);
|
||||||
|
install.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> abis = Arrays.asList(Build.SUPPORTED_ABIS);
|
List<String> abis = Arrays.asList(Build.SUPPORTED_ABIS);
|
||||||
@ -294,7 +293,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
File boot = new File(install, "boot.img");
|
File boot = new File(install, "boot.img");
|
||||||
SuFile patched_boot = new SuFile(install.getParent() + "/new-boot.img", true);
|
SuFile patched_boot = new SuFile(install.getParent(), "new-boot.img");
|
||||||
|
|
||||||
if (!dumpBoot(boot) || !patchBoot(boot, patched_boot))
|
if (!dumpBoot(boot) || !patchBoot(boot, patched_boot))
|
||||||
return false;
|
return false;
|
||||||
|
@ -4,8 +4,6 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
|
||||||
import com.topjohnwu.superuser.Shell;
|
|
||||||
import com.topjohnwu.superuser.ShellUtils;
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
|
||||||
public class RestoreImages extends ParallelTask<Void, Void, Boolean> {
|
public class RestoreImages extends ParallelTask<Void, Void, Boolean> {
|
||||||
@ -13,15 +11,15 @@ public class RestoreImages extends ParallelTask<Void, Void, Boolean> {
|
|||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
String sha1;
|
String sha1;
|
||||||
sha1 = RootUtils.cmd("cat /.backup/.sha1");
|
sha1 = ShellUtils.fastCmd("cat /.backup/.sha1");
|
||||||
if (sha1 == null) {
|
if (sha1 == null) {
|
||||||
sha1 = RootUtils.cmd("cat /init.magisk.rc | grep STOCKSHA1");
|
sha1 = ShellUtils.fastCmd("cat /init.magisk.rc | grep STOCKSHA1");
|
||||||
if (sha1 == null)
|
if (sha1 == null)
|
||||||
return false;
|
return false;
|
||||||
sha1 = sha1.substring(sha1.indexOf('=') + 1);
|
sha1 = sha1.substring(sha1.indexOf('=') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShellUtils.fastCmdResult(Shell.getShell(), "restore_imgs " + sha1);
|
return ShellUtils.fastCmdResult("restore_imgs " + sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,8 +3,6 @@ package com.topjohnwu.magisk.container;
|
|||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
import com.topjohnwu.superuser.io.SuFile;
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class Module extends BaseModule {
|
public class Module extends BaseModule {
|
||||||
|
|
||||||
private SuFile mRemoveFile, mDisableFile, mUpdateFile;
|
private SuFile mRemoveFile, mDisableFile, mUpdateFile;
|
||||||
@ -16,9 +14,9 @@ public class Module extends BaseModule {
|
|||||||
parseProps(Shell.Sync.su("dos2unix < " + path + "/module.prop"));
|
parseProps(Shell.Sync.su("dos2unix < " + path + "/module.prop"));
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {}
|
||||||
|
|
||||||
mRemoveFile = new SuFile(path + "/remove", true);
|
mRemoveFile = new SuFile(path + "/remove");
|
||||||
mDisableFile = new SuFile(path + "/disable", true);
|
mDisableFile = new SuFile(path + "/disable");
|
||||||
mUpdateFile = new SuFile(path + "/update", true);
|
mUpdateFile = new SuFile(path + "/update");
|
||||||
|
|
||||||
if (getId() == null) {
|
if (getId() == null) {
|
||||||
int sep = path.lastIndexOf('/');
|
int sep = path.lastIndexOf('/');
|
||||||
@ -36,9 +34,7 @@ public class Module extends BaseModule {
|
|||||||
|
|
||||||
public void createDisableFile() {
|
public void createDisableFile() {
|
||||||
mEnable = false;
|
mEnable = false;
|
||||||
try {
|
|
||||||
mDisableFile.createNewFile();
|
mDisableFile.createNewFile();
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDisableFile() {
|
public void removeDisableFile() {
|
||||||
@ -52,9 +48,7 @@ public class Module extends BaseModule {
|
|||||||
|
|
||||||
public void createRemoveFile() {
|
public void createRemoveFile() {
|
||||||
mRemove = true;
|
mRemove = true;
|
||||||
try {
|
|
||||||
mRemoveFile.createNewFile();
|
mRemoveFile.createNewFile();
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteRemoveFile() {
|
public void deleteRemoveFile() {
|
||||||
|
@ -86,7 +86,7 @@ public class MagiskDatabaseHelper {
|
|||||||
return de.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
|
return de.openOrCreateDatabase("su.db", Context.MODE_PRIVATE, null);
|
||||||
} else {
|
} else {
|
||||||
// Global database
|
// Global database
|
||||||
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db", true);
|
final SuFile GLOBAL_DB = new SuFile("/data/adb/magisk.db");
|
||||||
mm.deleteDatabase("su.db");
|
mm.deleteDatabase("su.db");
|
||||||
de.deleteDatabase("su.db");
|
de.deleteDatabase("su.db");
|
||||||
if (mm.magiskVersionCode < Const.MAGISK_VER.SEPOL_REFACTOR) {
|
if (mm.magiskVersionCode < Const.MAGISK_VER.SEPOL_REFACTOR) {
|
||||||
|
@ -8,26 +8,18 @@ import com.topjohnwu.superuser.io.SuFile;
|
|||||||
public class RootUtils {
|
public class RootUtils {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
Const.MAGISK_DISABLE_FILE = new SuFile("/cache/.disable_magisk", true);
|
Const.MAGISK_DISABLE_FILE = new SuFile("/cache/.disable_magisk");
|
||||||
SuFile file = new SuFile("/sbin/.core/img", true);
|
SuFile file = new SuFile("/sbin/.core/img");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
Const.MAGISK_PATH = file;
|
Const.MAGISK_PATH = file;
|
||||||
} else if ((file = new SuFile("/dev/magisk/img", true)).exists()) {
|
} else if ((file = new SuFile("/dev/magisk/img")).exists()) {
|
||||||
Const.MAGISK_PATH = file;
|
Const.MAGISK_PATH = file;
|
||||||
} else {
|
} else {
|
||||||
Const.MAGISK_PATH = new SuFile("/magisk", true);
|
Const.MAGISK_PATH = new SuFile("/magisk");
|
||||||
}
|
}
|
||||||
Const.MAGISK_HOST_FILE = new SuFile(Const.MAGISK_PATH + "/.core/hosts");
|
Const.MAGISK_HOST_FILE = new SuFile(Const.MAGISK_PATH + "/.core/hosts");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String cmd(String cmd) {
|
|
||||||
return ShellUtils.fastCmd(Shell.getShell(), cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean cmdResult(String cmd) {
|
|
||||||
return ShellUtils.fastCmdResult(Shell.getShell(), cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void uninstallPkg(String pkg) {
|
public static void uninstallPkg(String pkg) {
|
||||||
Shell.Sync.su("db_clean " + Const.USER_ID, "pm uninstall " + pkg);
|
Shell.Sync.su("db_clean " + Const.USER_ID, "pm uninstall " + pkg);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.R;
|
||||||
|
import com.topjohnwu.superuser.BusyBox;
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class ShellInitializer extends Shell.Initializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onRootShellInit(Context context, @NonNull Shell shell) throws Exception {
|
||||||
|
BusyBox.BB_PATH = new File(Const.BUSYBOX_PATH);
|
||||||
|
try (InputStream magiskUtils = context.getAssets().open(Const.UTIL_FUNCTIONS);
|
||||||
|
InputStream managerUtils = context.getResources().openRawResource(R.raw.utils)
|
||||||
|
) {
|
||||||
|
shell.loadInputStream(null, null, magiskUtils);
|
||||||
|
shell.loadInputStream(null, null, managerUtils);
|
||||||
|
}
|
||||||
|
shell.run(null, null,
|
||||||
|
"mount_partitions",
|
||||||
|
"find_boot_image",
|
||||||
|
"find_dtbo_image",
|
||||||
|
"get_flags",
|
||||||
|
"run_migrations");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -137,7 +137,7 @@ public class ShowUI {
|
|||||||
if (Shell.rootAccess()) {
|
if (Shell.rootAccess()) {
|
||||||
options.add(mm.getString(R.string.direct_install));
|
options.add(mm.getString(R.string.direct_install));
|
||||||
}
|
}
|
||||||
String s = RootUtils.cmd("echo $SLOT");
|
String s = ShellUtils.fastCmd("echo $SLOT");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
options.add(mm.getString(R.string.install_second_slot));
|
options.add(mm.getString(R.string.install_second_slot));
|
||||||
}
|
}
|
||||||
@ -211,9 +211,9 @@ public class ShowUI {
|
|||||||
if (slot[1] == 'a') slot[1] = 'b';
|
if (slot[1] == 'a') slot[1] = 'b';
|
||||||
else slot[1] = 'a';
|
else slot[1] = 'a';
|
||||||
// Then find the boot image again
|
// Then find the boot image again
|
||||||
boot = RootUtils.cmd(
|
boot = ShellUtils.fastCmd(
|
||||||
"SLOT=" + String.valueOf(slot) +
|
"SLOT=" + String.valueOf(slot),
|
||||||
"; find_boot_image;" +
|
"find_boot_image",
|
||||||
"echo \"$BOOTIMAGE\""
|
"echo \"$BOOTIMAGE\""
|
||||||
);
|
);
|
||||||
Shell.Async.su("mount_partitions");
|
Shell.Async.su("mount_partitions");
|
||||||
|
Loading…
Reference in New Issue
Block a user