Fix and tweaks for MagiskHide
This commit is contained in:
parent
b69a4fe8b5
commit
793269731d
@ -5,7 +5,6 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -56,22 +55,28 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
ApplicationInfo info = mList.get(position);
|
||||
|
||||
holder.appIcon.setImageDrawable(info.loadIcon(packageManager));
|
||||
holder.appName.setText(info.loadLabel(packageManager));
|
||||
holder.appPackage.setText(info.packageName);
|
||||
holder.checkBox.setChecked(false);
|
||||
|
||||
for (String hidePackage : mHideList) {
|
||||
if (info.packageName.contains(hidePackage)) {
|
||||
holder.checkBox.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
holder.checkBox.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||
Async.MagiskHide mh = new Async.MagiskHide();
|
||||
if (b) {
|
||||
mh.add(info.packageName);
|
||||
} else {
|
||||
mh.rm(info.packageName);
|
||||
|
||||
holder.checkBox.setOnClickListener(v -> {
|
||||
CheckBox chkbox = (CheckBox) v;
|
||||
if (chkbox.isChecked()) {
|
||||
new Async.MagiskHide().add(info.packageName);
|
||||
mHideList.add(info.packageName);
|
||||
}
|
||||
else {
|
||||
new Async.MagiskHide().rm(info.packageName);
|
||||
mHideList.remove(info.packageName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@ -26,6 +25,8 @@ import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
@ -81,49 +82,25 @@ public class LogFragment extends Fragment {
|
||||
reloadErrorLog();
|
||||
return true;
|
||||
case R.id.menu_send:
|
||||
send();
|
||||
new LogManager().send();
|
||||
return true;
|
||||
case R.id.menu_save:
|
||||
save();
|
||||
new LogManager().save();
|
||||
return true;
|
||||
case R.id.menu_clear:
|
||||
clear();
|
||||
new LogManager().clear();
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void reloadErrorLog() {
|
||||
new LogsManager(true).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
new LogManager().read();
|
||||
svLog.post(() -> svLog.scrollTo(0, txtLog.getHeight()));
|
||||
hsvLog.post(() -> hsvLog.scrollTo(0, 0));
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
new LogsManager(false).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
reloadErrorLog();
|
||||
}
|
||||
|
||||
private void send() {
|
||||
new SaveLog() {
|
||||
@Override
|
||||
protected void onPostExecute(Boolean bool) {
|
||||
super.onPostExecute(bool);
|
||||
if (bool) {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(targetFile));
|
||||
sendIntent.setType("application/html");
|
||||
startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.menuSend)));
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getString(R.string.logs_save_failed), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
@ -138,112 +115,125 @@ public class LogFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
new SaveLog(){
|
||||
@Override
|
||||
protected void onPostExecute(Boolean bool) {
|
||||
super.onPostExecute(bool);
|
||||
if (bool) {
|
||||
Toast.makeText(getActivity(), targetFile.toString(), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getString(R.string.logs_save_failed), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
}
|
||||
|
||||
private class SaveLog extends AsyncTask<Void, Void, Boolean> {
|
||||
public class LogManager extends Async.RootTask<Object, Void, Object> {
|
||||
|
||||
int mode;
|
||||
File targetFile;
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected Object doInBackground(Object... params) {
|
||||
mode = (int) params[0];
|
||||
switch (mode) {
|
||||
case 0:
|
||||
List<String> logList = Utils.readFile(MAGISK_LOG);
|
||||
|
||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
return false;
|
||||
}
|
||||
StringBuilder llog = new StringBuilder(15 * 10 * 1024);
|
||||
for (String s : logList) {
|
||||
llog.append(s).append("\n");
|
||||
}
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
String filename = String.format(
|
||||
"magisk_%s_%04d%02d%02d_%02d%02d%02d.log", "error",
|
||||
now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,
|
||||
now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY),
|
||||
now.get(Calendar.MINUTE), now.get(Calendar.SECOND));
|
||||
return llog.toString();
|
||||
|
||||
targetFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MagiskManager/" + filename);
|
||||
|
||||
if ((!targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs()) || (targetFile.exists() && !targetFile.delete())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<String> in = Utils.readFile(MAGISK_LOG);
|
||||
|
||||
try {
|
||||
FileWriter out = new FileWriter(targetFile);
|
||||
for (String line : in) {
|
||||
out.write(line + "\n");
|
||||
}
|
||||
out.close();
|
||||
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class LogsManager extends AsyncTask<Void, Integer, String> {
|
||||
|
||||
private boolean readLog;
|
||||
|
||||
public LogsManager(boolean read) {
|
||||
readLog = read;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
txtLog.setText("");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... voids) {
|
||||
if (readLog) {
|
||||
List<String> logList = Utils.readFile(MAGISK_LOG);
|
||||
|
||||
StringBuilder llog = new StringBuilder(15 * 10 * 1024);
|
||||
for (String s : logList) {
|
||||
llog.append(s).append("\n");
|
||||
}
|
||||
|
||||
return llog.toString();
|
||||
} else {
|
||||
if (Utils.removeItem(MAGISK_LOG)) {
|
||||
case 1:
|
||||
Shell.su("echo > " + MAGISK_LOG);
|
||||
Snackbar.make(txtLog, R.string.logs_cleared, Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Snackbar.make(txtLog, R.string.logs_clear_failed, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
return "";
|
||||
return "";
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
|
||||
return false;
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
String filename = String.format(
|
||||
"magisk_%s_%04d%02d%02d_%02d%02d%02d.log", "error",
|
||||
now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,
|
||||
now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY),
|
||||
now.get(Calendar.MINUTE), now.get(Calendar.SECOND));
|
||||
|
||||
targetFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MagiskManager/" + filename);
|
||||
|
||||
if ((!targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs())
|
||||
|| (targetFile.exists() && !targetFile.delete()))
|
||||
return false;
|
||||
|
||||
List<String> in = Utils.readFile(MAGISK_LOG);
|
||||
|
||||
try {
|
||||
FileWriter out = new FileWriter(targetFile);
|
||||
for (String line : in) {
|
||||
out.write(line + "\n");
|
||||
}
|
||||
out.close();
|
||||
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String llog) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
txtLog.setText(llog);
|
||||
|
||||
if (llog.length() == 0)
|
||||
txtLog.setText(R.string.log_is_empty);
|
||||
protected void onPostExecute(Object o) {
|
||||
boolean bool;
|
||||
String llog;
|
||||
switch (mode) {
|
||||
case 0:
|
||||
case 1:
|
||||
llog = (String) o;
|
||||
progressBar.setVisibility(View.GONE);
|
||||
if (llog.length() == 0)
|
||||
txtLog.setText(R.string.log_is_empty);
|
||||
else
|
||||
txtLog.setText(llog);
|
||||
break;
|
||||
case 2:
|
||||
bool = (boolean) o;
|
||||
if (bool)
|
||||
Toast.makeText(getActivity(), targetFile.toString(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toast.makeText(getActivity(), getString(R.string.logs_save_failed), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case 3:
|
||||
bool = (boolean) o;
|
||||
if (bool) {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(targetFile));
|
||||
sendIntent.setType("application/html");
|
||||
startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.menuSend)));
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getString(R.string.logs_save_failed), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void read() {
|
||||
exec(0);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
exec(1);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
exec(2);
|
||||
}
|
||||
|
||||
public void send() {
|
||||
exec(3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import android.view.View;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@ -131,7 +130,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
|
||||
private void checkHideSection() {
|
||||
Menu menu = navigationView.getMenu();
|
||||
if (PreferenceManager.getDefaultSharedPreferences(getApplication()).getBoolean("magiskhide",false) | (Utils.itemExist("/data/su/suhide"))) {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(getApplication()).getBoolean("magiskhide", false)) {
|
||||
|
||||
menu.findItem(R.id.magiskhide).setVisible(true);
|
||||
} else {
|
||||
|
@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
@ -81,8 +80,6 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
themePreference = (ListPreference) findPreference("theme");
|
||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
|
||||
magiskhidePreference.setChecked(Utils.itemExist(false, "/magisk/.core/magiskhide/enable"));
|
||||
busyboxPreference.setChecked(Utils.commandExists("unzip"));
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
@ -132,26 +129,26 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
case "magiskhide":
|
||||
boolean checked = sharedPreferences.getBoolean("magiskhide", false);
|
||||
if (checked) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
new Async.RootTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
Utils.createFile("/magisk/.core/magiskhide/enable");
|
||||
return null;
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
}.exec();
|
||||
} else {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
new Async.RootTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
Utils.removeItem("/magisk/.core/magiskhide/enable");
|
||||
return null;
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
}.exec();
|
||||
}
|
||||
break;
|
||||
case "busybox":
|
||||
checked = sharedPreferences.getBoolean("busybox", false);
|
||||
new Async.LinkBusyBox(checked).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
new Async.LinkBusyBox(checked).exec();
|
||||
break;
|
||||
case "developer_logging":
|
||||
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
|
||||
|
@ -8,13 +8,8 @@ import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
private SharedPreferences prefs;
|
||||
@ -31,18 +26,17 @@ public class SplashActivity extends AppCompatActivity {
|
||||
Logger.devLog = prefs.getBoolean("developer_logging", false);
|
||||
Logger.logShell = prefs.getBoolean("shell_logging", false);
|
||||
|
||||
// Check and set preferences/hides
|
||||
setupHideLists();
|
||||
|
||||
// Initialize
|
||||
// Initialize prefs
|
||||
prefs.edit()
|
||||
.putBoolean("module_done", false)
|
||||
.putBoolean("repo_done", false)
|
||||
.putBoolean("update_check_done", false)
|
||||
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
|
||||
.putBoolean("busybox", Utils.commandExists("unzip"))
|
||||
.apply();
|
||||
|
||||
new Async.CheckUpdates(prefs).exec();
|
||||
new Async.constructEnv(getApplicationInfo()).exec();
|
||||
new Async.ConstructEnv(getApplicationInfo()).exec();
|
||||
|
||||
new Async.LoadModules(prefs) {
|
||||
@Override
|
||||
@ -57,64 +51,4 @@ public class SplashActivity extends AppCompatActivity {
|
||||
}.exec();
|
||||
|
||||
}
|
||||
|
||||
private void setupHideLists() {
|
||||
|
||||
Set<String> set = new HashSet<>();
|
||||
Set<String> setOriginal = null;
|
||||
List<String> hideList = null;
|
||||
// List<String> addList = null;
|
||||
String listCmd, addCmd, addCmd2, rmCmd, rmCmd2;
|
||||
|
||||
// Build list of apps currently listed, add to preferences
|
||||
|
||||
int hideVersion = Utils.WhichHide(getApplication());
|
||||
|
||||
switch (hideVersion) {
|
||||
case 1:
|
||||
listCmd = "/magisk/.core/magiskhide/list";
|
||||
break;
|
||||
case 2:
|
||||
listCmd = "/su/suhide/list";
|
||||
break;
|
||||
case 3:
|
||||
listCmd = "/magisk/.core/magiskhide/list && /su/suhide/list";
|
||||
break;
|
||||
default:
|
||||
listCmd = "";
|
||||
|
||||
}
|
||||
if (Shell.rootAccess()) {
|
||||
hideList = Shell.su(listCmd);
|
||||
}
|
||||
// Set up default preferences,make sure we add "extra" blacklist entries.
|
||||
|
||||
if (!prefs.contains("auto_blacklist")) {
|
||||
Logger.dev("SplashActivity: Setting default preferences for application");
|
||||
set.add("com.google.android.apps.walletnfcrel");
|
||||
set.add("com.google.android.gms");
|
||||
set.add("com.google.commerce.tapandpay");
|
||||
|
||||
// Add current items to hide list
|
||||
if (hideList != null) set.addAll(hideList);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putStringSet("auto_blacklist", set);
|
||||
Logger.dev("SplashActivity: Adding entries " + set.toString());
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
setOriginal = prefs.getStringSet("auto_blacklist", set);
|
||||
// if (hideList != null) {
|
||||
// for (String item : hideList) {
|
||||
// if (!(setOriginal.contains(item))) {
|
||||
// addList.add(item);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putStringSet("auto_blacklist", set);
|
||||
editor.apply();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ public class Async {
|
||||
public static final String UPDATE_JSON = "https://raw.githubusercontent.com/topjohnwu/MagiskManager/updates/magisk_update.json";
|
||||
public static final String MAGISK_HIDE_PATH = "/magisk/.core/magiskhide/";
|
||||
|
||||
public static class constructEnv extends NormalTask<Void, Void, Void> {
|
||||
public static class ConstructEnv extends NormalTask<Void, Void, Void> {
|
||||
|
||||
ApplicationInfo mInfo;
|
||||
|
||||
public constructEnv(ApplicationInfo info) {
|
||||
public ConstructEnv(ApplicationInfo info) {
|
||||
mInfo = info;
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ public class Async {
|
||||
}
|
||||
}
|
||||
|
||||
public static class LinkBusyBox extends AsyncTask<Void, Void, Void> {
|
||||
public static class LinkBusyBox extends RootTask<Void, Void, Void> {
|
||||
|
||||
private boolean link;
|
||||
|
||||
|
@ -4,11 +4,9 @@ import android.Manifest;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.Context;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.util.Base64;
|
||||
import android.widget.Toast;
|
||||
@ -33,8 +31,6 @@ import javax.crypto.spec.DESKeySpec;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private static final String TAG = "Magisk";
|
||||
|
||||
private static final String cryptoPass = "MagiskRox666";
|
||||
private static final String secret = "GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus";
|
||||
|
||||
@ -51,29 +47,6 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAppUID(String packageName) {
|
||||
List<String> retString = Shell.su("ls -nld /data/data/" + packageName);
|
||||
String splitMe = retString.get(0);
|
||||
String[] splitString = retString.get(0).split(" ");
|
||||
return splitString[5];
|
||||
}
|
||||
|
||||
public static int WhichHide(Context context) {
|
||||
Boolean mh = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("magiskhide", false);
|
||||
Boolean sh = Utils.itemExist("/su/suhide/add");
|
||||
if (mh && !sh) {
|
||||
return 1;
|
||||
}
|
||||
if (sh && !mh) {
|
||||
return 2;
|
||||
}
|
||||
if (sh && mh) {
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static boolean commandExists(String s) {
|
||||
List<String> ret;
|
||||
String command = "if [ -z $(which " + s + ") ]; then echo false; else echo true; fi";
|
||||
@ -81,17 +54,6 @@ public class Utils {
|
||||
return Boolean.parseBoolean(ret.get(0));
|
||||
}
|
||||
|
||||
public static boolean rootEnabled() {
|
||||
return commandExists("su");
|
||||
}
|
||||
|
||||
public static boolean autoToggleEnabled(Context context) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
Logger.dev("Utils: AutoRootEnableCheck is " + preferences.getBoolean("autoRootEnable", false));
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("autoRootEnable", false);
|
||||
|
||||
}
|
||||
|
||||
public static boolean createFile(String path) {
|
||||
String command = "touch " + path + " 2>/dev/null; if [ -f " + path + " ]; then echo true; else echo false; fi";
|
||||
return Shell.rootAccess() && Boolean.parseBoolean(Shell.su(command).get(0));
|
||||
|
Loading…
Reference in New Issue
Block a user