use of com.moro.mtweaks.utils.root.RootFile in project MTweaks-KernelAdiutorMOD by morogoku.
the class PathReaderFragment method load.
private void load(List<RecyclerViewItem> items) {
if (mPath == null)
return;
String path = mPath;
if (path.contains("%d")) {
path = Utils.strFormat(mPath, mMin);
}
RootFile files = new RootFile(path);
for (final RootFile file : files.listFiles()) {
final String name = file.getName();
final String value = file.readFile();
if (value != null && !value.isEmpty() && !value.contains("\n")) {
DescriptionView descriptionView = new DescriptionView();
descriptionView.setTitle(name);
descriptionView.setSummary(value);
descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
List<Integer> freqs = CPUFreq.getFreqs(mMin);
int freq = Utils.strToInt(value);
if (freqs != null && freq != 0 && freqs.contains(freq)) {
String[] values = new String[freqs.size()];
for (int i = 0; i < values.length; i++) {
values[i] = String.valueOf(freqs.get(i));
}
showArrayDialog(value, values, mPath + "/" + name, name);
} else {
showEditTextDialog(value, name);
}
}
});
items.add(descriptionView);
}
}
}
use of com.moro.mtweaks.utils.root.RootFile in project MTweaks-KernelAdiutorMOD by morogoku.
the class FilePickerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragments);
initToolBar();
mPath = getIntent().getStringExtra(PATH_INTENT);
mExtension = getIntent().getStringExtra(EXTENSION_INTENT);
RootFile path = new RootFile(mPath);
if (!path.exists() || !path.isDirectory()) {
mPath = "/";
}
getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mFragment = (FilePickerFragment) getFragment(), "fragment").commit();
}
use of com.moro.mtweaks.utils.root.RootFile in project MTweaks-KernelAdiutorMOD by morogoku.
the class RecoveryFragment method flashNow.
private void flashNow(final int recoveryOption) {
mFlashDialog = ViewUtils.dialogBuilder(getString(R.string.flash_now_confirm), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
String file = "/cache/recovery/" + mCommands.get(0).getFile(recoveryOption == 1 ? Recovery.RECOVERY.TWRP : Recovery.RECOVERY.CWM);
RootFile recoveryFile = new RootFile(file);
recoveryFile.delete();
for (Recovery commands : mCommands) {
for (String command : commands.getCommands(recoveryOption == 1 ? Recovery.RECOVERY.TWRP : Recovery.RECOVERY.CWM)) recoveryFile.write(command, true);
}
RootUtils.runCommand("reboot recovery");
}
}, new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
mFlashDialog = null;
}
}, getActivity());
mFlashDialog.show();
}
use of com.moro.mtweaks.utils.root.RootFile in project MTweaks-KernelAdiutorMOD by morogoku.
the class Utils method readFile.
public static String readFile(String file, RootUtils.SU su) {
if (su != null)
return new RootFile(file, su).readFile();
StringBuilder s = null;
FileReader fileReader = null;
BufferedReader buf = null;
try {
fileReader = new FileReader(file);
buf = new BufferedReader(fileReader);
String line;
s = new StringBuilder();
while ((line = buf.readLine()) != null) s.append(line).append("\n");
} catch (FileNotFoundException ignored) {
Log.e(TAG, "File does not exist " + file);
} catch (IOException e) {
Log.e(TAG, "Failed to read " + file);
} finally {
try {
if (fileReader != null)
fileReader.close();
if (buf != null)
buf.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return s == null ? null : s.toString().trim();
}
use of com.moro.mtweaks.utils.root.RootFile in project MTweaks-KernelAdiutorMOD by morogoku.
the class Utils method isPatched.
// Sorry pirates!
public static boolean isPatched(ApplicationInfo applicationInfo) {
try {
boolean withBase = new File(applicationInfo.publicSourceDir).getName().equals("base.apk");
if (withBase) {
RootFile parent = new RootFile(applicationInfo.publicSourceDir).getParentFile();
RootFile odex = new RootFile(parent.toString() + "/oat/*/base.odex");
if (odex.exists()) {
String text = RootUtils.runCommand("strings " + odex.toString());
if (text.contains("--dex-file") || text.contains("--oat-file")) {
return true;
}
}
String dex = "/data/dalvik-cache/*/data@app@" + applicationInfo.packageName + "*@classes.dex";
if (Utils.existFile(dex)) {
String path = RootUtils.runCommand("realpath " + dex);
if (path != null) {
String text = RootUtils.runCommand("strings " + path);
if (text.contains("--dex-file") || text.contains("--oat-file")) {
return true;
}
}
}
} else if (Utils.existFile(applicationInfo.publicSourceDir.replace(".apk", ".odex"))) {
new RootFile(applicationInfo.publicSourceDir.replace(".apk", ".odex")).delete();
RootUtils.runCommand("pkill " + applicationInfo.packageName);
return false;
}
} catch (Exception ignored) {
}
return false;
}
Aggregations