Search in sources :

Example 1 with RootFile

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);
        }
    }
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) ArrayList(java.util.ArrayList) List(java.util.List) RootFile(com.moro.mtweaks.utils.root.RootFile) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem)

Example 2 with RootFile

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();
}
Also used : RootFile(com.moro.mtweaks.utils.root.RootFile)

Example 3 with RootFile

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();
}
Also used : DialogInterface(android.content.DialogInterface) RootFile(com.moro.mtweaks.utils.root.RootFile) Recovery(com.moro.mtweaks.utils.tools.Recovery)

Example 4 with RootFile

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();
}
Also used : BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) RootFile(com.moro.mtweaks.utils.root.RootFile)

Example 5 with RootFile

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;
}
Also used : RootFile(com.moro.mtweaks.utils.root.RootFile) RootFile(com.moro.mtweaks.utils.root.RootFile) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

RootFile (com.moro.mtweaks.utils.root.RootFile)13 File (java.io.File)3 IOException (java.io.IOException)3 DialogInterface (android.content.DialogInterface)2 Recovery (com.moro.mtweaks.utils.tools.Recovery)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 View (android.view.View)1 TextView (android.widget.TextView)1 Settings (com.moro.mtweaks.database.Settings)1 Controls (com.moro.mtweaks.database.tools.customcontrols.Controls)1 Profiles (com.moro.mtweaks.database.tools.profiles.Profiles)1 CPUFreq (com.moro.mtweaks.utils.kernel.cpu.CPUFreq)1 RootUtils (com.moro.mtweaks.utils.root.RootUtils)1