You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Ready for release
This commit is contained in:
@@ -46,16 +46,18 @@ public class Async {
|
||||
String busybox = mContext.getApplicationInfo().dataDir + "/lib/libbusybox.so";
|
||||
String zip = mContext.getApplicationInfo().dataDir + "/lib/libzip.so";
|
||||
if (Shell.rootAccess()) {
|
||||
if (!Utils.commandExists("unzip") || !Utils.commandExists("zip") || !Utils.itemExist(toolPath)) {
|
||||
if (!Utils.itemExist(toolPath)) {
|
||||
Shell.sh(
|
||||
"rm -rf " + toolPath,
|
||||
"mkdir " + toolPath,
|
||||
"chmod 755 " + toolPath,
|
||||
"ln -s " + busybox + " " + toolPath + "/busybox",
|
||||
"for tool in $(" + toolPath + "/busybox --list); do",
|
||||
"ln -s " + busybox + " " + toolPath + "/$tool",
|
||||
"cd " + toolPath,
|
||||
"ln -s " + busybox + " busybox",
|
||||
"for tool in $(./busybox --list); do",
|
||||
"ln -s " + busybox + " $tool",
|
||||
"done",
|
||||
"ln -s " + zip + " " + toolPath + "/zip"
|
||||
"rm -f su sh",
|
||||
"ln -s " + zip + " zip"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -165,15 +167,18 @@ public class Async {
|
||||
mContext = context;
|
||||
mUri = uri;
|
||||
Cursor c = mContext.getContentResolver().query(uri, null, null, null, null);
|
||||
int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||
c.moveToFirst();
|
||||
if (nameIndex != -1) {
|
||||
mName = c.getString(nameIndex);
|
||||
} else {
|
||||
if (c != null) {
|
||||
int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||
c.moveToFirst();
|
||||
if (nameIndex != -1) {
|
||||
mName = c.getString(nameIndex);
|
||||
}
|
||||
c.close();
|
||||
}
|
||||
if (mName == null) {
|
||||
int idx = uri.getPath().lastIndexOf('/');
|
||||
mName = uri.getPath().substring(idx + 1);
|
||||
}
|
||||
c.close();
|
||||
copyToSD = false;
|
||||
}
|
||||
|
||||
@@ -296,6 +301,10 @@ public class Async {
|
||||
}
|
||||
|
||||
protected void done() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
prefs.edit().putBoolean("module_done", false).apply();
|
||||
new LoadModules(mContext).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
|
||||
AlertDialog.Builder builder;
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(mContext).getString("theme", "");
|
||||
if (theme.equals("Dark")) {
|
||||
@@ -306,9 +315,31 @@ public class Async {
|
||||
builder
|
||||
.setTitle(R.string.reboot_title)
|
||||
.setMessage(R.string.reboot_msg)
|
||||
.setPositiveButton(R.string.reboot, (dialogInterface1, i) -> Shell.su("sh -c reboot"))
|
||||
.setPositiveButton(R.string.reboot, (dialogInterface1, i) -> Shell.sh("su -c reboot"))
|
||||
.setNegativeButton(R.string.no_thanks, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LinkBusyBox extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private boolean link;
|
||||
|
||||
public LinkBusyBox(boolean b) {
|
||||
link = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
if (link) {
|
||||
Shell.su(
|
||||
"rm -rf /magisk/.core/busybox",
|
||||
"ln -s /data/busybox /magisk/.core/busybox"
|
||||
);
|
||||
} else {
|
||||
Shell.su("rm -rf /magisk/.core/busybox");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.widget.Toast;
|
||||
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
||||
import com.topjohnwu.magisk.MagiskFragment;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.module.BaseModule;
|
||||
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
|
||||
import com.topjohnwu.magisk.services.MonitorService;
|
||||
@@ -36,7 +35,6 @@ import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -63,7 +61,7 @@ public class Utils {
|
||||
MagiskFragment.magiskVersion = Integer.parseInt(ret.get(0));
|
||||
}
|
||||
String toolPath = context.getApplicationInfo().dataDir + "/tools";
|
||||
Shell.su("PATH=$PATH:" + toolPath);
|
||||
Shell.su("PATH=" + toolPath + ":$PATH");
|
||||
}
|
||||
|
||||
public static boolean itemExist(String path) {
|
||||
@@ -113,7 +111,7 @@ public class Utils {
|
||||
Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0");
|
||||
}
|
||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
|
||||
SetupQuickSettingsTile(context);
|
||||
setupQuickSettingsTile(context);
|
||||
}
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root", b).apply();
|
||||
}
|
||||
@@ -140,7 +138,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) {
|
||||
SetupQuickSettingsTile(context);
|
||||
setupQuickSettingsTile(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +172,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
if ((!file.getParentFile().exists() && !file.getParentFile().mkdirs()) || (file.exists() && !file.delete())) {
|
||||
Toast.makeText(context, R.string.toast_error_makedir, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
@@ -208,7 +206,7 @@ public class Utils {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public static void SetupQuickSettingsTile(Context mContext) {
|
||||
public static void setupQuickSettingsTile(Context mContext) {
|
||||
Logger.dev("Utils: SetupQuickSettings called");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Logger.dev("Utils: Starting N quick settings service");
|
||||
@@ -266,7 +264,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void installTile(Context context) {
|
||||
public static boolean installTile(Context context) {
|
||||
String qsTileId;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
qsTileId = "custom(com.topjohnwu.magisk/.services.TileServiceNewApi)";
|
||||
@@ -281,8 +279,7 @@ public class Utils {
|
||||
if (tiles.size() > 1) {
|
||||
for (String tile : tiles) {
|
||||
if (tile.equals(qsTileId)) {
|
||||
Toast.makeText(context, "Tile already installed", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,17 +287,16 @@ public class Utils {
|
||||
String newTiles = TextUtils.join(",", tiles);
|
||||
Logger.dev("Utils: NewtilesString is " + newTiles);
|
||||
Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\"");
|
||||
Toast.makeText(context, "Tile installed", Toast.LENGTH_SHORT).show();
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
||||
Utils.refreshService(context);
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Toast.makeText(context, "Tile installation error", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void uninstallTile(Context context) {
|
||||
public static boolean uninstallTile(Context context) {
|
||||
|
||||
String qsTileId;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
@@ -323,17 +319,15 @@ public class Utils {
|
||||
if (isPresent) {
|
||||
String newTiles = TextUtils.join(",", tiles);
|
||||
Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\"");
|
||||
Toast.makeText(context, "Tile uninstalled", Toast.LENGTH_SHORT).show();
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
||||
Utils.refreshService(context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Toast.makeText(context, "Tile already uninstalled", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
Toast.makeText(context, "Tile uninstallation error", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void refreshService(Context context) {
|
||||
|
||||
Reference in New Issue
Block a user