Search in sources :

Example 1 with FileData

use of com.spazedog.lib.rootfw3.extenders.FileExtender.FileData in project mounts2sd by SpazeDog.

the class FragmentTabConfigure method getEnabledSelectorValues.

private String[] getEnabledSelectorValues(Integer id) {
    if (!oEnabledSelectorValues.containsKey(id)) {
        RootFW rootfw;
        switch(id) {
            case R.id.option_immc_item_readahead:
                oEnabledSelectorValues.put(id, new String[] { "4", "8", "16", "32", "64", "128" });
                break;
            case R.id.option_immc_item_scheduler:
            case R.id.option_emmc_item_scheduler:
                rootfw = Root.initiate();
                String file = id == R.id.option_immc_item_scheduler ? mPreferences.deviceSetup.path_device_scheduler_immc() : mPreferences.deviceSetup.path_device_scheduler_emmc();
                String content = rootfw.file(file).readOneLine();
                String[] parts = null;
                if (content != null) {
                    parts = content.split(" ");
                    for (int i = 0; i < parts.length; i++) {
                        if (parts[i].contains("[")) {
                            parts[i] = parts[i].substring(1, parts[i].length() - 1);
                        }
                    }
                }
                Root.release();
                oEnabledSelectorValues.put(id, parts);
                break;
            case R.id.option_filesystem_item_fstype:
                rootfw = Root.initiate();
                FileData data = rootfw.file("/proc/filesystems").read();
                ArrayList<String> filesystems = new ArrayList<String>();
                if (data != null) {
                    String[] lines = data.getArray();
                    filesystems.add("auto");
                    for (int i = 0; i < lines.length; i++) {
                        if (!lines[i].contains("nodev ")) {
                            filesystems.add(lines[i].trim());
                        }
                    }
                }
                Root.release();
                oEnabledSelectorValues.put(id, filesystems.size() > 0 ? filesystems.toArray(new String[filesystems.size()]) : null);
                break;
            default:
                oEnabledSelectorValues.put(id, null);
        }
    }
    return oEnabledSelectorValues.get(id);
}
Also used : ArrayList(java.util.ArrayList) FileData(com.spazedog.lib.rootfw3.extenders.FileExtender.FileData) RootFW(com.spazedog.lib.rootfw3.RootFW)

Example 2 with FileData

use of com.spazedog.lib.rootfw3.extenders.FileExtender.FileData in project mounts2sd by SpazeDog.

the class FragmentTabLog method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.fragment_tab_log, container, false);
    TableLayout table = (TableLayout) view.findViewById(R.id.log_table);
    if (oLogEntry == null) {
        RootFW rootfw = Root.initiate();
        FileData data = rootfw.file(getResources().getString(R.string.config_dir_tmp) + "/log.txt").read();
        if (data == null) {
            data = rootfw.file("/data/m2sd.fallback.log").read();
            if (data != null) {
                oLogEntry = data.getArray();
            }
        } else {
            oLogEntry = data.getArray();
        }
        if (oLogEntry == null || oLogEntry.length == 0) {
            oLogEntry = new String[] { "I/" + getResources().getString(R.string.log_empty) };
        }
        Root.release();
    }
    Boolean bool = false;
    Integer color1 = getResources().getColor(resolveAttr(R.attr.colorRef_logItemBackgroundFirst));
    Integer color2 = getResources().getColor(resolveAttr(R.attr.colorRef_logItemBackgroundSecond));
    for (int i = 0; i < oLogEntry.length; i++) {
        TableRow row = (TableRow) inflater.inflate(R.layout.inflate_log_item, table, false);
        String[] parts = oLogEntry[i].split("/", 2);
        ((TextView) row.getChildAt(0)).setText(parts.length > 1 ? parts[0] : "?");
        ((TextView) row.getChildAt(1)).setText(parts.length > 1 ? parts[1] : parts[0]);
        if ((bool = !bool)) {
            row.setBackgroundColor(color1);
        } else {
            row.setBackgroundColor(color2);
        }
        table.addView(row);
    }
    return (View) view;
}
Also used : ViewGroup(android.view.ViewGroup) TableRow(android.widget.TableRow) TextView(android.widget.TextView) TableLayout(android.widget.TableLayout) FileData(com.spazedog.lib.rootfw3.extenders.FileExtender.FileData) View(android.view.View) TextView(android.widget.TextView) RootFW(com.spazedog.lib.rootfw3.RootFW)

Aggregations

RootFW (com.spazedog.lib.rootfw3.RootFW)2 FileData (com.spazedog.lib.rootfw3.extenders.FileExtender.FileData)2 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TableLayout (android.widget.TableLayout)1 TableRow (android.widget.TableRow)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1